diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 626fab6347..bb49764229 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,7 @@ on: env: # All versions should be declared here - PHALCON_VERSION: 5.7.0 + PHALCON_VERSION: 5.8.0 ZEPHIR_PARSER_VERSION: 1.6.1 # For tests diff --git a/CHANGELOG-5.0.md b/CHANGELOG-5.0.md index 0e741aef88..c7a95c671a 100644 --- a/CHANGELOG-5.0.md +++ b/CHANGELOG-5.0.md @@ -1,6 +1,6 @@ # Changelog -## [5.8.0](https://github.com/phalcon/cphalcon/releases/tag/v5.8.0) (XXXX-XX-XX) +## [5.8.0](https://github.com/phalcon/cphalcon/releases/tag/v5.8.0) (2024-07-09) ### Changed diff --git a/build/phalcon/phalcon.zep.c b/build/phalcon/phalcon.zep.c index 9d33544f37..2f6a9e5faa 100644 --- a/build/phalcon/phalcon.zep.c +++ b/build/phalcon/phalcon.zep.c @@ -16698,1448 +16698,1588 @@ static PHP_METHOD(Phalcon_Tag, inputFieldChecked) -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt) +ZEPHIR_INIT_CLASS(Phalcon_Dispatcher_AbstractDispatcher) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption, Crypt, phalcon, encryption_crypt, phalcon_encryption_crypt_method_entry, 0); - - zend_declare_property_string(phalcon_encryption_crypt_ce, SL("authData"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_encryption_crypt_ce, SL("authTag"), "", ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_encryption_crypt_ce, SL("authTagLength"), 16, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_encryption_crypt_ce, SL("availableCiphers"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_encryption_crypt_ce, SL("cipher"), "aes-256-cfb", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_encryption_crypt_ce, SL("hashAlgorithm"), "sha256", ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_encryption_crypt_ce, SL("ivLength"), 16, ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_encryption_crypt_ce, SL("key"), "", ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_encryption_crypt_ce, SL("padding"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_encryption_crypt_ce, SL("padFactory"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_encryption_crypt_ce, SL("useSigning"), 1, ZEND_ACC_PROTECTED); - phalcon_encryption_crypt_ce->create_object = zephir_init_properties_Phalcon_Encryption_Crypt; - zephir_declare_class_constant_string(phalcon_encryption_crypt_ce, SL("DEFAULT_ALGORITHM"), "sha256"); - - zephir_declare_class_constant_string(phalcon_encryption_crypt_ce, SL("DEFAULT_CIPHER"), "aes-256-cfb"); - - zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_ANSI_X_923"), 1); - - zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_DEFAULT"), 0); - - zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_ISO_10126"), 3); - - zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_ISO_IEC_7816_4"), 4); - - zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_PKCS7"), 2); - - zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_SPACE"), 6); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Dispatcher, AbstractDispatcher, phalcon, dispatcher_abstractdispatcher, phalcon_di_abstractinjectionaware_ce, phalcon_dispatcher_abstractdispatcher_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_ZERO"), 5); + zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("activeHandler"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("activeMethodMap"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("actionName"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("actionSuffix"), "Action", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("camelCaseMap"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("defaultAction"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("defaultNamespace"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("defaultHandler"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("handlerHashes"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("handlerName"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("handlerSuffix"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_dispatcher_abstractdispatcher_ce, SL("finished"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_dispatcher_abstractdispatcher_ce, SL("forwarded"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_dispatcher_abstractdispatcher_ce, SL("isControllerInitialize"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("lastHandler"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("modelBinder"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_dispatcher_abstractdispatcher_ce, SL("modelBinding"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("moduleName"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("namespaceName"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("params"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("previousActionName"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("previousHandlerName"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("previousNamespaceName"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("returnedValue"), ZEND_ACC_PROTECTED); + phalcon_dispatcher_abstractdispatcher_ce->create_object = zephir_init_properties_Phalcon_Dispatcher_AbstractDispatcher; - zend_class_implements(phalcon_encryption_crypt_ce, 1, phalcon_encryption_crypt_cryptinterface_ce); + zend_class_implements(phalcon_dispatcher_abstractdispatcher_ce, 1, phalcon_dispatcher_dispatcherinterface_ce); + zend_class_implements(phalcon_dispatcher_abstractdispatcher_ce, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Encryption_Crypt, __construct) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, callActionMethod) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool useSigning; - zval *cipher_param = NULL, *useSigning_param = NULL, *padFactory = NULL, padFactory_sub, __$null, _0, _1, _2, _3; - zval cipher; - zval *this_ptr = getThis(); + zval params, _0; + zval actionMethod; + zval *handler, handler_sub, *actionMethod_param = NULL, *params_param = NULL; - ZVAL_UNDEF(&cipher); - ZVAL_UNDEF(&padFactory_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&actionMethod); + ZVAL_UNDEF(¶ms); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 3) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ZVAL(handler) + Z_PARAM_STR(actionMethod) Z_PARAM_OPTIONAL - Z_PARAM_STR(cipher) - Z_PARAM_BOOL(useSigning) - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(padFactory, phalcon_encryption_crypt_padfactory_ce) + Z_PARAM_ARRAY(params) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 3, &cipher_param, &useSigning_param, &padFactory); - if (!cipher_param) { - ZEPHIR_INIT_VAR(&cipher); - ZVAL_STRING(&cipher, "aes-256-cfb"); - } else { - zephir_get_strval(&cipher, cipher_param); - } - if (!useSigning_param) { - useSigning = 1; - } else { - } - if (!padFactory) { - padFactory = &padFactory_sub; - ZEPHIR_CPY_WRT(padFactory, &__$null); + zephir_fetch_params(1, 2, 1, &handler, &actionMethod_param, ¶ms_param); + zephir_get_strval(&actionMethod, actionMethod_param); + if (!params_param) { + ZEPHIR_INIT_VAR(¶ms); + array_init(¶ms); } else { - ZEPHIR_SEPARATE_PARAM(padFactory); - } - if (Z_TYPE_P(padFactory) == IS_NULL) { - ZEPHIR_INIT_NVAR(padFactory); - object_init_ex(padFactory, phalcon_encryption_crypt_padfactory_ce); - ZEPHIR_CALL_METHOD(NULL, padFactory, "__construct", NULL, 225); - zephir_check_call_status(); + ZEPHIR_OBS_COPY_OR_DUP(¶ms, params_param); } - zephir_update_property_zval(this_ptr, ZEND_STRL("padFactory"), padFactory); ZEPHIR_INIT_VAR(&_0); - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, "sha256"); - zephir_update_property_zval(this_ptr, ZEND_STRL("hashAlgorithm"), &_0); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "initializeavailableciphers", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_2, &_1, "setcipher", NULL, 0, &cipher); - zephir_check_call_status(); - if (useSigning) { - ZVAL_BOOL(&_3, 1); - } else { - ZVAL_BOOL(&_3, 0); - } - ZEPHIR_CALL_METHOD(NULL, &_2, "usesigning", NULL, 0, &_3); + zephir_create_array(&_0, 2, 0); + zephir_array_fast_append(&_0, handler); + zephir_array_fast_append(&_0, &actionMethod); + ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_0, ¶ms); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, decrypt) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, dispatch) { + zval _44$$10; + zend_bool hasService = 0, hasEventsManager = 0, isNewHandler = 0, _5$$5, _16$$13, _21$$15, _29$$18, _34$$20, _42$$23, _52$$25, _56$$31, _62$$33, _66$$36, _72$$38, _78$$43, _83$$46, _88$$48, _105$$59, _110$$62, _115$$64, _118$$67, _123$$69, _130$$73; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL, *key_param = NULL, __$true, __$null, blockSize, cipher, cipherText, decrypted, decryptKey, digest, hashAlgorithm, hashLength, iv, ivLength, mode, padded, _0, _1, _6, _7, _2$$5, _3$$5, _4$$5, _5$$6, _8$$7; - zval input, key; + zephir_fcall_cache_entry *_11 = NULL, *_12 = NULL, *_15 = NULL, *_20 = NULL, *_23 = NULL, *_25 = NULL, *_28 = NULL, *_30 = NULL, *_33 = NULL, *_35 = NULL, *_41 = NULL, *_43 = NULL, *_47 = NULL, *_51 = NULL, *_55 = NULL, *_58 = NULL, *_61 = NULL, *_64 = NULL, *_68 = NULL, *_71 = NULL, *_74 = NULL, *_77 = NULL, *_82 = NULL, *_87 = NULL, *_94 = NULL, *_100 = NULL, *_104 = NULL, *_109 = NULL, *_114 = NULL, *_122 = NULL, *_126 = NULL, *_129 = NULL; + zval __$true, __$false, value, handler, container, namespaceName, handlerName, actionName, eventsManager, handlerClass, status, actionMethod, modelBinder, bindCacheKey, handlerHash, e, _0, _1$$3, _2$$3, _3$$5, _4$$5, _6$$5, _7$$4, _8$$7, _9$$11, _10$$11, _13$$13, _14$$13, _17$$13, _18$$12, _19$$15, _22$$15, _24$$10, _36$$10, _37$$10, _38$$10, _102$$10, _26$$18, _27$$18, _31$$20, _32$$20, _39$$23, _40$$23, _45$$26, _46$$26, _48$$26, _49$$25, _50$$25, _53$$31, _54$$31, _57$$31, _59$$30, _60$$33, _63$$33, _65$$36, _67$$36, _69$$35, _70$$38, _73$$38, _75$$41, _76$$43, _79$$43, _80$$46, _81$$46, _84$$46, _85$$45, _86$$48, _89$$48, _90$$50, _91$$50, _92$$51, _93$$51, _95$$51, _96$$54, _97$$54, _98$$57, _99$$57, _101$$57, _103$$59, _106$$59, _107$$62, _108$$62, _111$$62, _112$$61, _113$$64, _116$$64, _117$$67, _119$$67, _120$$66, _121$$69, _124$$69, _125$$72, _127$$71, _128$$73, _131$$73, _132$$76, _133$$75, _134$$77; + zend_long ZEPHIR_LAST_CALL_STATUS, numberDispatches = 0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&key); ZVAL_BOOL(&__$true, 1); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&blockSize); - ZVAL_UNDEF(&cipher); - ZVAL_UNDEF(&cipherText); - ZVAL_UNDEF(&decrypted); - ZVAL_UNDEF(&decryptKey); - ZVAL_UNDEF(&digest); - ZVAL_UNDEF(&hashAlgorithm); - ZVAL_UNDEF(&hashLength); - ZVAL_UNDEF(&iv); - ZVAL_UNDEF(&ivLength); - ZVAL_UNDEF(&mode); - ZVAL_UNDEF(&padded); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&handler); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&namespaceName); + ZVAL_UNDEF(&handlerName); + ZVAL_UNDEF(&actionName); + ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&handlerClass); + ZVAL_UNDEF(&status); + ZVAL_UNDEF(&actionMethod); + ZVAL_UNDEF(&modelBinder); + ZVAL_UNDEF(&bindCacheKey); + ZVAL_UNDEF(&handlerHash); + ZVAL_UNDEF(&e); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$5); ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_7$$4); ZVAL_UNDEF(&_8$$7); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(input) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(key) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_9$$11); + ZVAL_UNDEF(&_10$$11); + ZVAL_UNDEF(&_13$$13); + ZVAL_UNDEF(&_14$$13); + ZVAL_UNDEF(&_17$$13); + ZVAL_UNDEF(&_18$$12); + ZVAL_UNDEF(&_19$$15); + ZVAL_UNDEF(&_22$$15); + ZVAL_UNDEF(&_24$$10); + ZVAL_UNDEF(&_36$$10); + ZVAL_UNDEF(&_37$$10); + ZVAL_UNDEF(&_38$$10); + ZVAL_UNDEF(&_102$$10); + ZVAL_UNDEF(&_26$$18); + ZVAL_UNDEF(&_27$$18); + ZVAL_UNDEF(&_31$$20); + ZVAL_UNDEF(&_32$$20); + ZVAL_UNDEF(&_39$$23); + ZVAL_UNDEF(&_40$$23); + ZVAL_UNDEF(&_45$$26); + ZVAL_UNDEF(&_46$$26); + ZVAL_UNDEF(&_48$$26); + ZVAL_UNDEF(&_49$$25); + ZVAL_UNDEF(&_50$$25); + ZVAL_UNDEF(&_53$$31); + ZVAL_UNDEF(&_54$$31); + ZVAL_UNDEF(&_57$$31); + ZVAL_UNDEF(&_59$$30); + ZVAL_UNDEF(&_60$$33); + ZVAL_UNDEF(&_63$$33); + ZVAL_UNDEF(&_65$$36); + ZVAL_UNDEF(&_67$$36); + ZVAL_UNDEF(&_69$$35); + ZVAL_UNDEF(&_70$$38); + ZVAL_UNDEF(&_73$$38); + ZVAL_UNDEF(&_75$$41); + ZVAL_UNDEF(&_76$$43); + ZVAL_UNDEF(&_79$$43); + ZVAL_UNDEF(&_80$$46); + ZVAL_UNDEF(&_81$$46); + ZVAL_UNDEF(&_84$$46); + ZVAL_UNDEF(&_85$$45); + ZVAL_UNDEF(&_86$$48); + ZVAL_UNDEF(&_89$$48); + ZVAL_UNDEF(&_90$$50); + ZVAL_UNDEF(&_91$$50); + ZVAL_UNDEF(&_92$$51); + ZVAL_UNDEF(&_93$$51); + ZVAL_UNDEF(&_95$$51); + ZVAL_UNDEF(&_96$$54); + ZVAL_UNDEF(&_97$$54); + ZVAL_UNDEF(&_98$$57); + ZVAL_UNDEF(&_99$$57); + ZVAL_UNDEF(&_101$$57); + ZVAL_UNDEF(&_103$$59); + ZVAL_UNDEF(&_106$$59); + ZVAL_UNDEF(&_107$$62); + ZVAL_UNDEF(&_108$$62); + ZVAL_UNDEF(&_111$$62); + ZVAL_UNDEF(&_112$$61); + ZVAL_UNDEF(&_113$$64); + ZVAL_UNDEF(&_116$$64); + ZVAL_UNDEF(&_117$$67); + ZVAL_UNDEF(&_119$$67); + ZVAL_UNDEF(&_120$$66); + ZVAL_UNDEF(&_121$$69); + ZVAL_UNDEF(&_124$$69); + ZVAL_UNDEF(&_125$$72); + ZVAL_UNDEF(&_127$$71); + ZVAL_UNDEF(&_128$$73); + ZVAL_UNDEF(&_131$$73); + ZVAL_UNDEF(&_132$$76); + ZVAL_UNDEF(&_133$$75); + ZVAL_UNDEF(&_134$$77); + ZVAL_UNDEF(&_44$$10); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &input_param, &key_param); - zephir_get_strval(&input, input_param); - if (!key_param) { - ZEPHIR_INIT_VAR(&key); - } else { - zephir_get_strval(&key, key_param); - } - zephir_memory_observe(&decryptKey); - zephir_read_property(&decryptKey, this_ptr, ZEND_STRL("key"), PH_NOISY_CC); - if (1 != ZEPHIR_IS_EMPTY(&key)) { - ZEPHIR_CPY_WRT(&decryptKey, &key); - } - if (1 == ZEPHIR_IS_EMPTY(&decryptKey)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Decryption key cannot be empty", "phalcon/Encryption/Crypt.zep", 175); - return; - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&cipher, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("ivLength"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&ivLength, &_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "cipher"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkcipherhashisavailable", NULL, 0, &cipher, &_1); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&mode, this_ptr, "getmode", NULL, 226); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&blockSize, this_ptr, "getblocksize", NULL, 227, &mode); - zephir_check_call_status(); - ZVAL_LONG(&_0, 0); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "8bit"); - ZEPHIR_CALL_FUNCTION(&iv, "mb_substr", NULL, 228, &input, &_0, &ivLength, &_1); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&digest); - ZVAL_STRING(&digest, ""); - ZEPHIR_CALL_METHOD(&hashAlgorithm, this_ptr, "gethashalgorithm", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("useSigning"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - ZEPHIR_INIT_VAR(&_2$$5); - ZVAL_STRING(&_2$$5, ""); - ZEPHIR_CALL_FUNCTION(&_3$$5, "hash", NULL, 71, &hashAlgorithm, &_2$$5, &__$true); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&hashLength); - ZVAL_LONG(&hashLength, zephir_fast_strlen_ev(&_3$$5)); - ZEPHIR_INIT_NVAR(&_2$$5); - ZVAL_STRING(&_2$$5, "8bit"); - ZEPHIR_CALL_FUNCTION(&digest, "mb_substr", NULL, 228, &input, &ivLength, &hashLength, &_2$$5); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_4$$5); - zephir_add_function(&_4$$5, &ivLength, &hashLength); - ZEPHIR_INIT_NVAR(&_2$$5); - ZVAL_STRING(&_2$$5, "8bit"); - ZEPHIR_CALL_FUNCTION(&cipherText, "mb_substr", NULL, 228, &input, &_4$$5, &__$null, &_2$$5); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_VAR(&_5$$6); - ZVAL_STRING(&_5$$6, "8bit"); - ZEPHIR_CALL_FUNCTION(&cipherText, "mb_substr", NULL, 228, &input, &ivLength, &__$null, &_5$$6); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_0); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "A dependency injection container is required to access related dispatching services"); + ZVAL_LONG(&_2$$3, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwdispatchexception", NULL, 0, &_1$$3, &_2$$3); zephir_check_call_status(); + RETURN_MM_BOOL(0); } - ZEPHIR_CALL_METHOD(&decrypted, this_ptr, "decryptgcmccmauth", NULL, 0, &mode, &cipherText, &decryptKey, &iv); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&padded, &decrypted); - ZEPHIR_CALL_METHOD(&_6, this_ptr, "decryptgetunpadded", NULL, 0, &mode, &blockSize, &decrypted); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&decrypted, &_6); - zephir_read_property(&_7, this_ptr, ZEND_STRL("useSigning"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_7)) { - ZEPHIR_CALL_FUNCTION(&_8$$7, "hash_hmac", NULL, 229, &hashAlgorithm, &padded, &decryptKey, &__$true); - zephir_check_call_status(); - if (!ZEPHIR_IS_IDENTICAL(&digest, &_8$$7)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_mismatch_ce, "Hash does not match.", "phalcon/Encryption/Crypt.zep", 224); - return; - } + zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_0); + hasEventsManager = Z_TYPE_P(&eventsManager) == IS_OBJECT; + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$false); } - RETURN_CCTOR(&decrypted); -} + if (hasEventsManager) { -static PHP_METHOD(Phalcon_Encryption_Crypt, decryptBase64) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool safe; - zval *input_param = NULL, *key_param = NULL, *safe_param = NULL, _0$$3, _1$$3, _2$$3, _3$$3, _4$$3, _5; - zval input, key; - zval *this_ptr = getThis(); + /* try_start_1: */ - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(input) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(key) - Z_PARAM_BOOL(safe) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &input_param, &key_param, &safe_param); - zephir_get_strval(&input, input_param); - if (!key_param) { - ZEPHIR_INIT_VAR(&key); - } else { - zephir_get_strval(&key, key_param); + ZEPHIR_INIT_VAR(&_4$$5); + ZVAL_STRING(&_4$$5, "dispatch:beforeDispatchLoop"); + ZEPHIR_CALL_METHOD(&_3$$5, &eventsManager, "fire", NULL, 0, &_4$$5, this_ptr); + zephir_check_call_status_or_jump(try_end_1); + _5$$5 = ZEPHIR_IS_FALSE_IDENTICAL(&_3$$5); + if (_5$$5) { + zephir_read_property(&_6$$5, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _5$$5 = !ZEPHIR_IS_FALSE_IDENTICAL(&_6$$5); + } + if (_5$$5) { + RETURN_MM_BOOL(0); + } + + try_end_1: + + if (EG(exception)) { + ZEPHIR_INIT_VAR(&_7$$4); + ZVAL_OBJ(&_7$$4, EG(exception)); + Z_ADDREF_P(&_7$$4); + if (zephir_is_instance_of(&_7$$4, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_7$$4); + ZEPHIR_CALL_METHOD(&status, this_ptr, "handleexception", NULL, 0, &e); + zephir_check_call_status(); + zephir_read_property(&_8$$7, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_8$$7)) { + if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) { + RETURN_MM_BOOL(0); + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 229); + ZEPHIR_MM_RESTORE(); + return; + } + } + } } - if (!safe_param) { - safe = 0; + ZEPHIR_INIT_VAR(&value); + ZVAL_NULL(&value); + ZEPHIR_INIT_VAR(&handler); + ZVAL_NULL(&handler); + numberDispatches = 0; + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$true); } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$false); + } + while (1) { + zephir_read_property(&_0, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + if (!(!(zephir_is_true(&_0)))) { + break; } - if (safe) { - ZEPHIR_INIT_VAR(&_0$$3); - ZVAL_STRING(&_0$$3, "-_"); - ZEPHIR_INIT_VAR(&_1$$3); - ZVAL_STRING(&_1$$3, "+/"); - ZEPHIR_CALL_FUNCTION(&_2$$3, "strtr", NULL, 5, &input, &_0$$3, &_1$$3); + numberDispatches++; + if (UNEXPECTED(numberDispatches == 256)) { + ZEPHIR_INIT_NVAR(&_9$$11); + ZVAL_STRING(&_9$$11, "Dispatcher has detected a cyclic routing causing stability problems"); + ZVAL_LONG(&_10$$11, 1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwdispatchexception", &_11, 0, &_9$$11, &_10$$11); + zephir_check_call_status(); + break; + } + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$false); + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "resolveemptyproperties", &_12, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_0$$3); - ZVAL_STRING(&_0$$3, "==="); - ZVAL_DOUBLE(&_3$$3, zephir_safe_mod_long_long(((zephir_fast_strlen_ev(&input) + 3)), 4)); - ZEPHIR_INIT_NVAR(&_1$$3); - zephir_substr(&_1$$3, &_0$$3, zephir_get_intval(&_3$$3), 0, ZEPHIR_SUBSTR_NO_LENGTH); - ZEPHIR_INIT_VAR(&_4$$3); - ZEPHIR_CONCAT_VV(&_4$$3, &_2$$3, &_1$$3); - zephir_get_strval(&input, &_4$$3); - } - ZEPHIR_CALL_FUNCTION(&_5, "base64_decode", NULL, 230, &input); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "decrypt", NULL, 0, &_5, &key); - zephir_check_call_status(); - RETURN_MM(); -} + if (hasEventsManager) { -static PHP_METHOD(Phalcon_Encryption_Crypt, encrypt) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL, *key_param = NULL, __$true, blockSize, cipher, digest, encryptKey, encrypted, iv, ivLength, mode, padded, _0, _1, _2$$6; - zval input, key; - zval *this_ptr = getThis(); + /* try_start_2: */ - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&key); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&blockSize); - ZVAL_UNDEF(&cipher); - ZVAL_UNDEF(&digest); - ZVAL_UNDEF(&encryptKey); - ZVAL_UNDEF(&encrypted); - ZVAL_UNDEF(&iv); - ZVAL_UNDEF(&ivLength); - ZVAL_UNDEF(&mode); - ZVAL_UNDEF(&padded); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$6); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(input) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(key) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &input_param, &key_param); - zephir_get_strval(&input, input_param); - if (!key_param) { - ZEPHIR_INIT_VAR(&key); - } else { - zephir_get_strval(&key, key_param); - } - zephir_memory_observe(&encryptKey); - zephir_read_property(&encryptKey, this_ptr, ZEND_STRL("key"), PH_NOISY_CC); - if (1 != ZEPHIR_IS_EMPTY(&key)) { - ZEPHIR_CPY_WRT(&encryptKey, &key); - } - if (1 == ZEPHIR_IS_EMPTY(&encryptKey)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Encryption key cannot be empty", "phalcon/Encryption/Crypt.zep", 282); - return; - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&cipher, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("ivLength"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&ivLength, &_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "cipher"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkcipherhashisavailable", NULL, 0, &cipher, &_1); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&mode, this_ptr, "getmode", NULL, 226); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&blockSize, this_ptr, "getblocksize", NULL, 227, &mode); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&iv, this_ptr, "phpopensslrandompseudobytes", NULL, 0, &ivLength); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&iv)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Cannot calculate Random Pseudo Bytes", "phalcon/Encryption/Crypt.zep", 295); - return; - } - ZEPHIR_CALL_METHOD(&padded, this_ptr, "encryptgetpadded", NULL, 0, &mode, &input, &blockSize); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&encrypted, this_ptr, "encryptgcmccm", NULL, 0, &mode, &padded, &encryptKey, &iv); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("useSigning"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - ZEPHIR_CALL_METHOD(&_2$$6, this_ptr, "gethashalgorithm", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&digest, "hash_hmac", NULL, 229, &_2$$6, &padded, &encryptKey, &__$true); - zephir_check_call_status(); - ZEPHIR_CONCAT_VVV(return_value, &iv, &digest, &encrypted); - RETURN_MM(); - } - ZEPHIR_CONCAT_VV(return_value, &iv, &encrypted); - RETURN_MM(); -} + ZEPHIR_INIT_NVAR(&_14$$13); + ZVAL_STRING(&_14$$13, "dispatch:beforeDispatch"); + ZEPHIR_CALL_METHOD(&_13$$13, &eventsManager, "fire", &_15, 0, &_14$$13, this_ptr); + zephir_check_call_status_or_jump(try_end_2); + _16$$13 = ZEPHIR_IS_FALSE_IDENTICAL(&_13$$13); + if (!(_16$$13)) { + zephir_read_property(&_17$$13, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _16$$13 = ZEPHIR_IS_FALSE_IDENTICAL(&_17$$13); + } + if (_16$$13) { + continue; + } -static PHP_METHOD(Phalcon_Encryption_Crypt, encryptBase64) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool safe; - zval *input_param = NULL, *key_param = NULL, *safe_param = NULL, _0$$3, _1$$3, _2$$3, _3$$3, _4$$3, _5; - zval input, key; - zval *this_ptr = getThis(); + try_end_2: - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(input) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(key) - Z_PARAM_BOOL(safe) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &input_param, &key_param, &safe_param); - zephir_get_strval(&input, input_param); - if (!key_param) { - ZEPHIR_INIT_VAR(&key); - } else { - zephir_get_strval(&key, key_param); - } - if (!safe_param) { - safe = 0; - } else { + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_18$$12); + ZVAL_OBJ(&_18$$12, EG(exception)); + Z_ADDREF_P(&_18$$12); + if (zephir_is_instance_of(&_18$$12, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_18$$12); + ZEPHIR_CALL_METHOD(&_19$$15, this_ptr, "handleexception", &_20, 0, &e); + zephir_check_call_status(); + _21$$15 = ZEPHIR_IS_FALSE_IDENTICAL(&_19$$15); + if (!(_21$$15)) { + zephir_read_property(&_22$$15, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _21$$15 = ZEPHIR_IS_FALSE_IDENTICAL(&_22$$15); + } + if (_21$$15) { + continue; + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 269); + ZEPHIR_MM_RESTORE(); + return; + } + } } - if (safe) { - ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "encrypt", NULL, 0, &input, &key); + ZEPHIR_CALL_METHOD(&handlerClass, this_ptr, "gethandlerclass", &_23, 0); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_1$$3, "base64_encode", NULL, 231, &_0$$3); + ZEPHIR_CALL_METHOD(&_24$$10, &container, "has", &_25, 0, &handlerClass); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "+/"); - ZEPHIR_INIT_VAR(&_3$$3); - ZVAL_STRING(&_3$$3, "-_"); - ZEPHIR_CALL_FUNCTION(&_4$$3, "strtr", NULL, 5, &_1$$3, &_2$$3, &_3$$3); + hasService = zephir_get_boolval(&_24$$10); + if (!(hasService)) { + hasService = zephir_class_exists(&handlerClass, 1); + } + if (!(hasService)) { + ZEPHIR_INIT_NVAR(&_26$$18); + ZEPHIR_CONCAT_VS(&_26$$18, &handlerClass, " handler class cannot be loaded"); + ZVAL_LONG(&_27$$18, 2); + ZEPHIR_CALL_METHOD(&status, this_ptr, "throwdispatchexception", &_28, 0, &_26$$18, &_27$$18); + zephir_check_call_status(); + _29$$18 = ZEPHIR_IS_FALSE_IDENTICAL(&status); + if (_29$$18) { + zephir_read_property(&_27$$18, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _29$$18 = ZEPHIR_IS_FALSE_IDENTICAL(&_27$$18); + } + if (_29$$18) { + continue; + } + break; + } + ZEPHIR_CALL_METHOD(&handler, &container, "getshared", &_30, 0, &handlerClass); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_2$$3); - ZVAL_STRING(&_2$$3, "="); - zephir_fast_trim(return_value, &_4$$3, &_2$$3, ZEPHIR_TRIM_RIGHT); - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(&_5, this_ptr, "encrypt", NULL, 0, &input, &key); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_FUNCTION("base64_encode", NULL, 231, &_5); - zephir_check_call_status(); - RETURN_MM(); -} + if (UNEXPECTED(Z_TYPE_P(&handler) != IS_OBJECT)) { + ZEPHIR_INIT_NVAR(&_31$$20); + ZVAL_STRING(&_31$$20, "Invalid handler returned from the services container"); + ZVAL_LONG(&_32$$20, 3); + ZEPHIR_CALL_METHOD(&status, this_ptr, "throwdispatchexception", &_33, 0, &_31$$20, &_32$$20); + zephir_check_call_status(); + _34$$20 = ZEPHIR_IS_FALSE_IDENTICAL(&status); + if (_34$$20) { + zephir_read_property(&_32$$20, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _34$$20 = ZEPHIR_IS_FALSE_IDENTICAL(&_32$$20); + } + if (_34$$20) { + continue; + } + break; + } + ZEPHIR_CALL_FUNCTION(&handlerHash, "spl_object_hash", &_35, 80, &handler); + zephir_check_call_status(); + zephir_read_property(&_36$$10, this_ptr, ZEND_STRL("handlerHashes"), PH_NOISY_CC | PH_READONLY); + isNewHandler = !((zephir_array_isset(&_36$$10, &handlerHash))); + if (isNewHandler) { + zephir_update_property_array(this_ptr, SL("handlerHashes"), &handlerHash, &__$true); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("activeHandler"), &handler); + zephir_read_property(&_37$$10, this_ptr, ZEND_STRL("namespaceName"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&namespaceName, &_37$$10); + zephir_read_property(&_37$$10, this_ptr, ZEND_STRL("handlerName"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&handlerName, &_37$$10); + zephir_read_property(&_37$$10, this_ptr, ZEND_STRL("actionName"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&actionName, &_37$$10); + ZEPHIR_OBS_NVAR(&_38$$10); + zephir_read_property(&_38$$10, this_ptr, ZEND_STRL("params"), PH_NOISY_CC); + if (UNEXPECTED(Z_TYPE_P(&_38$$10) != IS_ARRAY)) { + ZEPHIR_INIT_NVAR(&_39$$23); + ZVAL_STRING(&_39$$23, "Action parameters must be an Array"); + ZVAL_LONG(&_40$$23, 4); + ZEPHIR_CALL_METHOD(&status, this_ptr, "throwdispatchexception", &_41, 0, &_39$$23, &_40$$23); + zephir_check_call_status(); + _42$$23 = ZEPHIR_IS_FALSE_IDENTICAL(&status); + if (_42$$23) { + zephir_read_property(&_40$$23, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _42$$23 = ZEPHIR_IS_FALSE_IDENTICAL(&_40$$23); + } + if (_42$$23) { + continue; + } + break; + } + ZEPHIR_CALL_METHOD(&actionMethod, this_ptr, "getactivemethod", &_43, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_44$$10); + zephir_create_array(&_44$$10, 2, 0); + zephir_array_fast_append(&_44$$10, &handler); + zephir_array_fast_append(&_44$$10, &actionMethod); + if (UNEXPECTED(!(zephir_is_callable(&_44$$10)))) { + if (hasEventsManager) { + ZEPHIR_INIT_NVAR(&_46$$26); + ZVAL_STRING(&_46$$26, "dispatch:beforeNotFoundAction"); + ZEPHIR_CALL_METHOD(&_45$$26, &eventsManager, "fire", &_47, 0, &_46$$26, this_ptr); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_45$$26)) { + continue; + } + zephir_read_property(&_48$$26, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_48$$26)) { + continue; + } + } + ZEPHIR_INIT_NVAR(&_49$$25); + ZEPHIR_CONCAT_SVSVS(&_49$$25, "Action '", &actionName, "' was not found on handler '", &handlerName, "'"); + ZVAL_LONG(&_50$$25, 5); + ZEPHIR_CALL_METHOD(&status, this_ptr, "throwdispatchexception", &_51, 0, &_49$$25, &_50$$25); + zephir_check_call_status(); + _52$$25 = ZEPHIR_IS_FALSE_IDENTICAL(&status); + if (_52$$25) { + zephir_read_property(&_50$$25, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _52$$25 = ZEPHIR_IS_FALSE_IDENTICAL(&_50$$25); + } + if (_52$$25) { + continue; + } + break; + } + if (hasEventsManager) { -static PHP_METHOD(Phalcon_Encryption_Crypt, getAvailableCiphers) -{ + /* try_start_3: */ - RETURN_MEMBER(getThis(), "availableCiphers"); -} + ZEPHIR_INIT_NVAR(&_54$$31); + ZVAL_STRING(&_54$$31, "dispatch:beforeExecuteRoute"); + ZEPHIR_CALL_METHOD(&_53$$31, &eventsManager, "fire", &_55, 0, &_54$$31, this_ptr); + zephir_check_call_status_or_jump(try_end_3); + _56$$31 = ZEPHIR_IS_FALSE_IDENTICAL(&_53$$31); + if (!(_56$$31)) { + zephir_read_property(&_57$$31, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _56$$31 = ZEPHIR_IS_FALSE_IDENTICAL(&_57$$31); + } + if (_56$$31) { + ZEPHIR_CALL_METHOD(NULL, &container, "remove", &_58, 0, &handlerClass); + zephir_check_call_status_or_jump(try_end_3); + continue; + } -static PHP_METHOD(Phalcon_Encryption_Crypt, getAuthData) -{ + try_end_3: - RETURN_MEMBER(getThis(), "authData"); -} + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_59$$30); + ZVAL_OBJ(&_59$$30, EG(exception)); + Z_ADDREF_P(&_59$$30); + if (zephir_is_instance_of(&_59$$30, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_59$$30); + ZEPHIR_CALL_METHOD(&_60$$33, this_ptr, "handleexception", &_61, 0, &e); + zephir_check_call_status(); + _62$$33 = ZEPHIR_IS_FALSE_IDENTICAL(&_60$$33); + if (!(_62$$33)) { + zephir_read_property(&_63$$33, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _62$$33 = ZEPHIR_IS_FALSE_IDENTICAL(&_63$$33); + } + if (_62$$33) { + ZEPHIR_CALL_METHOD(NULL, &container, "remove", &_64, 0, &handlerClass); + zephir_check_call_status(); + continue; + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 408); + ZEPHIR_MM_RESTORE(); + return; + } + } + } + if ((zephir_method_exists_ex(&handler, ZEND_STRL("beforeexecuteroute")) == SUCCESS)) { -static PHP_METHOD(Phalcon_Encryption_Crypt, getAuthTag) -{ + /* try_start_4: */ - RETURN_MEMBER(getThis(), "authTag"); -} + ZEPHIR_CALL_METHOD(&_65$$36, &handler, "beforeexecuteroute", NULL, 0, this_ptr); + zephir_check_call_status_or_jump(try_end_4); + _66$$36 = ZEPHIR_IS_FALSE_IDENTICAL(&_65$$36); + if (!(_66$$36)) { + zephir_read_property(&_67$$36, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _66$$36 = ZEPHIR_IS_FALSE_IDENTICAL(&_67$$36); + } + if (_66$$36) { + ZEPHIR_CALL_METHOD(NULL, &container, "remove", &_68, 0, &handlerClass); + zephir_check_call_status_or_jump(try_end_4); + continue; + } -static PHP_METHOD(Phalcon_Encryption_Crypt, getAuthTagLength) -{ + try_end_4: - RETURN_MEMBER(getThis(), "authTagLength"); -} + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_69$$35); + ZVAL_OBJ(&_69$$35, EG(exception)); + Z_ADDREF_P(&_69$$35); + if (zephir_is_instance_of(&_69$$35, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_69$$35); + ZEPHIR_CALL_METHOD(&_70$$38, this_ptr, "handleexception", &_71, 0, &e); + zephir_check_call_status(); + _72$$38 = ZEPHIR_IS_FALSE_IDENTICAL(&_70$$38); + if (!(_72$$38)) { + zephir_read_property(&_73$$38, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _72$$38 = ZEPHIR_IS_FALSE_IDENTICAL(&_73$$38); + } + if (_72$$38) { + ZEPHIR_CALL_METHOD(NULL, &container, "remove", &_74, 0, &handlerClass); + zephir_check_call_status(); + continue; + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 427); + ZEPHIR_MM_RESTORE(); + return; + } + } + } + if (isNewHandler) { + if ((zephir_method_exists_ex(&handler, ZEND_STRL("initialize")) == SUCCESS)) { -static PHP_METHOD(Phalcon_Encryption_Crypt, getAvailableHashAlgorithms) -{ - zval _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + /* try_start_5: */ - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("isControllerInitialize"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("isControllerInitialize"), &__$false); + } + ZEPHIR_CALL_METHOD(NULL, &handler, "initialize", NULL, 0); + zephir_check_call_status_or_jump(try_end_5); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "hash_hmac_algos"); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "phpfunctionexists", NULL, 0, &_1); - zephir_check_call_status(); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - ZEPHIR_RETURN_CALL_FUNCTION("hash_hmac_algos", NULL, 232); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_RETURN_CALL_FUNCTION("hash_algos", NULL, 233); - zephir_check_call_status(); - RETURN_MM(); -} + try_end_5: -static PHP_METHOD(Phalcon_Encryption_Crypt, getHashAlgorithm) -{ + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_75$$41); + ZVAL_OBJ(&_75$$41, EG(exception)); + Z_ADDREF_P(&_75$$41); + if (zephir_is_instance_of(&_75$$41, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_75$$41); + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("isControllerInitialize"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("isControllerInitialize"), &__$false); + } + ZEPHIR_CALL_METHOD(&_76$$43, this_ptr, "handleexception", &_77, 0, &e); + zephir_check_call_status(); + _78$$43 = ZEPHIR_IS_FALSE_IDENTICAL(&_76$$43); + if (!(_78$$43)) { + zephir_read_property(&_79$$43, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _78$$43 = ZEPHIR_IS_FALSE_IDENTICAL(&_79$$43); + } + if (_78$$43) { + continue; + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 469); + ZEPHIR_MM_RESTORE(); + return; + } + } + } + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("isControllerInitialize"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("isControllerInitialize"), &__$false); + } + if (zephir_is_true(&eventsManager)) { - RETURN_MEMBER(getThis(), "hashAlgorithm"); -} + /* try_start_6: */ -static PHP_METHOD(Phalcon_Encryption_Crypt, getCipher) -{ + ZEPHIR_INIT_NVAR(&_81$$46); + ZVAL_STRING(&_81$$46, "dispatch:afterInitialize"); + ZEPHIR_CALL_METHOD(&_80$$46, &eventsManager, "fire", &_82, 0, &_81$$46, this_ptr); + zephir_check_call_status_or_jump(try_end_6); + _83$$46 = ZEPHIR_IS_FALSE_IDENTICAL(&_80$$46); + if (!(_83$$46)) { + zephir_read_property(&_84$$46, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _83$$46 = ZEPHIR_IS_FALSE_IDENTICAL(&_84$$46); + } + if (_83$$46) { + continue; + } - RETURN_MEMBER(getThis(), "cipher"); -} + try_end_6: -static PHP_METHOD(Phalcon_Encryption_Crypt, getKey) -{ + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_85$$45); + ZVAL_OBJ(&_85$$45, EG(exception)); + Z_ADDREF_P(&_85$$45); + if (zephir_is_instance_of(&_85$$45, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_85$$45); + ZEPHIR_CALL_METHOD(&_86$$48, this_ptr, "handleexception", &_87, 0, &e); + zephir_check_call_status(); + _88$$48 = ZEPHIR_IS_FALSE_IDENTICAL(&_86$$48); + if (!(_88$$48)) { + zephir_read_property(&_89$$48, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _88$$48 = ZEPHIR_IS_FALSE_IDENTICAL(&_89$$48); + } + if (_88$$48) { + continue; + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 488); + ZEPHIR_MM_RESTORE(); + return; + } + } + } + } + zephir_read_property(&_37$$10, this_ptr, ZEND_STRL("modelBinding"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_37$$10)) { + zephir_read_property(&_90$$50, this_ptr, ZEND_STRL("modelBinder"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&modelBinder, &_90$$50); + ZEPHIR_INIT_NVAR(&bindCacheKey); + ZEPHIR_CONCAT_SVSV(&bindCacheKey, "_PHMB_", &handlerClass, "_", &actionMethod); + zephir_read_property(&_90$$50, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_91$$50, &modelBinder, "bindtohandler", NULL, 0, &handler, &_90$$50, &bindCacheKey, &actionMethod); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("params"), &_91$$50); + } + if (hasEventsManager) { + ZEPHIR_INIT_NVAR(&_93$$51); + ZVAL_STRING(&_93$$51, "dispatch:afterBinding"); + ZEPHIR_CALL_METHOD(&_92$$51, &eventsManager, "fire", &_94, 0, &_93$$51, this_ptr); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_92$$51)) { + continue; + } + zephir_read_property(&_95$$51, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_95$$51)) { + continue; + } + } + if ((zephir_method_exists_ex(&handler, ZEND_STRL("afterbinding")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(&_96$$54, &handler, "afterbinding", NULL, 0, this_ptr); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_96$$54)) { + continue; + } + zephir_read_property(&_97$$54, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_97$$54)) { + continue; + } + } + zephir_update_property_zval(this_ptr, ZEND_STRL("lastHandler"), &handler); - RETURN_MEMBER(getThis(), "key"); -} + /* try_start_7: */ -static PHP_METHOD(Phalcon_Encryption_Crypt, isValidDecryptLength) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL, length, _0, _1; - zval input; - zval *this_ptr = getThis(); + zephir_read_property(&_99$$57, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_98$$57, this_ptr, "callactionmethod", &_100, 0, &handler, &actionMethod, &_99$$57); + zephir_check_call_status_or_jump(try_end_7); + zephir_update_property_zval(this_ptr, ZEND_STRL("returnedValue"), &_98$$57); + zephir_read_property(&_101$$57, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_101$$57)) { + continue; + } - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&length); - ZVAL_UNDEF(&_0); + try_end_7: + + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_102$$10); + ZVAL_OBJ(&_102$$10, EG(exception)); + Z_ADDREF_P(&_102$$10); + if (zephir_is_instance_of(&_102$$10, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_102$$10); + ZEPHIR_CALL_METHOD(&_103$$59, this_ptr, "handleexception", &_104, 0, &e); + zephir_check_call_status(); + _105$$59 = ZEPHIR_IS_FALSE_IDENTICAL(&_103$$59); + if (!(_105$$59)) { + zephir_read_property(&_106$$59, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _105$$59 = ZEPHIR_IS_FALSE_IDENTICAL(&_106$$59); + } + if (_105$$59) { + continue; + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 560); + ZEPHIR_MM_RESTORE(); + return; + } + } + if (hasEventsManager) { + + /* try_start_8: */ + + ZEPHIR_INIT_NVAR(&_108$$62); + ZVAL_STRING(&_108$$62, "dispatch:afterExecuteRoute"); + ZEPHIR_CALL_METHOD(&_107$$62, &eventsManager, "fire", &_109, 0, &_108$$62, this_ptr, &value); + zephir_check_call_status_or_jump(try_end_8); + _110$$62 = ZEPHIR_IS_FALSE_IDENTICAL(&_107$$62); + if (!(_110$$62)) { + zephir_read_property(&_111$$62, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _110$$62 = ZEPHIR_IS_FALSE_IDENTICAL(&_111$$62); + } + if (_110$$62) { + continue; + } + + try_end_8: + + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_112$$61); + ZVAL_OBJ(&_112$$61, EG(exception)); + Z_ADDREF_P(&_112$$61); + if (zephir_is_instance_of(&_112$$61, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_112$$61); + ZEPHIR_CALL_METHOD(&_113$$64, this_ptr, "handleexception", &_114, 0, &e); + zephir_check_call_status(); + _115$$64 = ZEPHIR_IS_FALSE_IDENTICAL(&_113$$64); + if (!(_115$$64)) { + zephir_read_property(&_116$$64, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _115$$64 = ZEPHIR_IS_FALSE_IDENTICAL(&_116$$64); + } + if (_115$$64) { + continue; + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 576); + ZEPHIR_MM_RESTORE(); + return; + } + } + } + if ((zephir_method_exists_ex(&handler, ZEND_STRL("afterexecuteroute")) == SUCCESS)) { + + /* try_start_9: */ + + ZEPHIR_CALL_METHOD(&_117$$67, &handler, "afterexecuteroute", NULL, 0, this_ptr, &value); + zephir_check_call_status_or_jump(try_end_9); + _118$$67 = ZEPHIR_IS_FALSE_IDENTICAL(&_117$$67); + if (!(_118$$67)) { + zephir_read_property(&_119$$67, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _118$$67 = ZEPHIR_IS_FALSE_IDENTICAL(&_119$$67); + } + if (_118$$67) { + continue; + } + + try_end_9: + + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_120$$66); + ZVAL_OBJ(&_120$$66, EG(exception)); + Z_ADDREF_P(&_120$$66); + if (zephir_is_instance_of(&_120$$66, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_120$$66); + ZEPHIR_CALL_METHOD(&_121$$69, this_ptr, "handleexception", &_122, 0, &e); + zephir_check_call_status(); + _123$$69 = ZEPHIR_IS_FALSE_IDENTICAL(&_121$$69); + if (!(_123$$69)) { + zephir_read_property(&_124$$69, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _123$$69 = ZEPHIR_IS_FALSE_IDENTICAL(&_124$$69); + } + if (_123$$69) { + continue; + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 593); + ZEPHIR_MM_RESTORE(); + return; + } + } + } + if (hasEventsManager) { + + /* try_start_10: */ + + ZEPHIR_INIT_NVAR(&_125$$72); + ZVAL_STRING(&_125$$72, "dispatch:afterDispatch"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_126, 0, &_125$$72, this_ptr, &value); + zephir_check_call_status_or_jump(try_end_10); + + try_end_10: + + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_127$$71); + ZVAL_OBJ(&_127$$71, EG(exception)); + Z_ADDREF_P(&_127$$71); + if (zephir_is_instance_of(&_127$$71, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_127$$71); + ZEPHIR_CALL_METHOD(&_128$$73, this_ptr, "handleexception", &_129, 0, &e); + zephir_check_call_status(); + _130$$73 = ZEPHIR_IS_FALSE_IDENTICAL(&_128$$73); + if (!(_130$$73)) { + zephir_read_property(&_131$$73, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); + _130$$73 = ZEPHIR_IS_FALSE_IDENTICAL(&_131$$73); + } + if (_130$$73) { + continue; + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 610); + ZEPHIR_MM_RESTORE(); + return; + } + } + } + } + if (hasEventsManager) { + + /* try_start_11: */ + + ZEPHIR_INIT_VAR(&_132$$76); + ZVAL_STRING(&_132$$76, "dispatch:afterDispatchLoop"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_132$$76, this_ptr); + zephir_check_call_status_or_jump(try_end_11); + + try_end_11: + + if (EG(exception)) { + ZEPHIR_INIT_VAR(&_133$$75); + ZVAL_OBJ(&_133$$75, EG(exception)); + Z_ADDREF_P(&_133$$75); + if (zephir_is_instance_of(&_133$$75, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_133$$75); + ZEPHIR_CALL_METHOD(&_134$$77, this_ptr, "handleexception", NULL, 0, &e); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_134$$77)) { + RETURN_MM_BOOL(0); + } + zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 627); + ZEPHIR_MM_RESTORE(); + return; + } + } + } + RETURN_CCTOR(&handler); +} + +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, forward) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *forward_param = NULL, __$true, __$false, namespaceName, controllerName, params, actionName, taskName, _0, _1, _2, _3; + zval forward; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&forward); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&namespaceName); + ZVAL_UNDEF(&controllerName); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&actionName); + ZVAL_UNDEF(&taskName); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(input) + Z_PARAM_ARRAY(forward) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &input_param); - zephir_get_strval(&input, input_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&length, this_ptr, "phpopensslcipherivlength", NULL, 0, &_0); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&length)) { - RETURN_MM_BOOL(0); + zephir_fetch_params(1, 1, 0, &forward_param); + zephir_get_arrval(&forward, forward_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("isControllerInitialize"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(ZEPHIR_IS_TRUE_IDENTICAL(&_0))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_dispatcher_exception_ce, "Forwarding inside a controller's initialize() method is forbidden", "phalcon/Dispatcher/AbstractDispatcher.zep", 661); + return; } - ZEPHIR_CALL_FUNCTION(&_1, "mb_strlen", NULL, 234, &input); - zephir_check_call_status(); - RETURN_MM_BOOL(ZEPHIR_LE(&length, &_1)); + zephir_read_property(&_1, this_ptr, ZEND_STRL("namespaceName"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("previousNamespaceName"), &_1); + zephir_read_property(&_2, this_ptr, ZEND_STRL("handlerName"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("previousHandlerName"), &_2); + zephir_read_property(&_3, this_ptr, ZEND_STRL("actionName"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("previousActionName"), &_3); + if (zephir_array_isset_string_fetch(&namespaceName, &forward, SL("namespace"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("namespaceName"), &namespaceName); + } + zephir_memory_observe(&taskName); + if (zephir_array_isset_string_fetch(&controllerName, &forward, SL("controller"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("handlerName"), &controllerName); + } else if (zephir_array_isset_string_fetch(&taskName, &forward, SL("task"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("handlerName"), &taskName); + } + if (zephir_array_isset_string_fetch(&actionName, &forward, SL("action"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("actionName"), &actionName); + } + if (zephir_array_isset_string_fetch(¶ms, &forward, SL("params"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("params"), ¶ms); + } + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$false); + } + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("forwarded"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("forwarded"), &__$false); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, setAuthData) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getActionName) +{ + + RETURN_MEMBER(getThis(), "actionName"); +} + +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getActionSuffix) +{ + + RETURN_MEMBER(getThis(), "actionSuffix"); +} + +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getActiveMethod) { + zval activeMethodName, _0, _1, _5, _2$$3, _3$$3, _4$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *data_param = NULL; - zval data; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(data) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&activeMethodName); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &data_param); - zephir_get_strval(&data, data_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("authData"), &data); - RETURN_THIS(); + + zephir_memory_observe(&activeMethodName); + zephir_read_property(&_0, this_ptr, ZEND_STRL("activeMethodMap"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_1, this_ptr, ZEND_STRL("actionName"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&activeMethodName, &_0, &_1, 0))) { + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("actionName"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "tocamelcase", NULL, 0, &_3$$3); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&activeMethodName, "lcfirst", NULL, 76, &_2$$3); + zephir_check_call_status(); + zephir_memory_observe(&_4$$3); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("actionName"), PH_NOISY_CC); + zephir_update_property_array(this_ptr, SL("activeMethodMap"), &_4$$3, &activeMethodName); + } + zephir_read_property(&_5, this_ptr, ZEND_STRL("actionSuffix"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CONCAT_VV(return_value, &activeMethodName, &_5); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, setAuthTag) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getBoundModels) { + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *tag_param = NULL; - zval tag; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&tag); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(tag) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &tag_param); - zephir_get_strval(&tag, tag_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("authTag"), &tag); - RETURN_THIS(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelBinder"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + array_init(return_value); + RETURN_MM(); + } + zephir_read_property(&_1, this_ptr, ZEND_STRL("modelBinder"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_1, "getboundmodels", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, setAuthTagLength) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getDefaultNamespace) { - zval *length_param = NULL, _0; - zend_long length; + + RETURN_MEMBER(getThis(), "defaultNamespace"); +} + +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getEventsManager) +{ + + RETURN_MEMBER(getThis(), "eventsManager"); +} + +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getHandlerSuffix) +{ + + RETURN_MEMBER(getThis(), "handlerSuffix"); +} + +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getModelBinder) +{ + + RETURN_MEMBER(getThis(), "modelBinder"); +} + +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getModuleName) +{ + + RETURN_MEMBER(getThis(), "moduleName"); +} + +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getNamespaceName) +{ + + RETURN_MEMBER(getThis(), "namespaceName"); +} + +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getParam) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *param, param_sub, *filters = NULL, filters_sub, *defaultValue = NULL, defaultValue_sub, __$null; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(length) + ZVAL_UNDEF(¶m_sub); + ZVAL_UNDEF(&filters_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ZVAL(param) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(filters) + Z_PARAM_ZVAL_OR_NULL(defaultValue) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &length_param); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, length); - zephir_update_property_zval(this_ptr, ZEND_STRL("authTagLength"), &_0); - RETURN_THISW(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, ¶m, &filters, &defaultValue); + if (!filters) { + filters = &filters_sub; + filters = &__$null; + } + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getparameter", NULL, 0, param, filters, defaultValue); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, setCipher) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getParameter) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *cipher_param = NULL, _0, _1; - zval cipher; + zval *param, param_sub, *filters = NULL, filters_sub, *defaultValue = NULL, defaultValue_sub, __$null, params, filter, paramValue, _0, _3, _4, _5, _1$$5, _2$$5; zval *this_ptr = getThis(); - ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(¶m_sub); + ZVAL_UNDEF(&filters_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&filter); + ZVAL_UNDEF(¶mValue); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(cipher) + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_1$$5); + ZVAL_UNDEF(&_2$$5); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ZVAL(param) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(filters) + Z_PARAM_ZVAL_OR_NULL(defaultValue) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &cipher_param); - zephir_get_strval(&cipher, cipher_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "cipher"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkcipherhashisavailable", NULL, 0, &cipher, &_0); + zephir_fetch_params(1, 1, 2, ¶m, &filters, &defaultValue); + if (!filters) { + filters = &filters_sub; + filters = &__$null; + } + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(¶ms, &_0); + zephir_memory_observe(¶mValue); + if (!(zephir_array_isset_fetch(¶mValue, ¶ms, param, 0))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + if (Z_TYPE_P(filters) == IS_NULL) { + RETURN_CCTOR(¶mValue); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$5); + ZVAL_STRING(&_1$$5, "A dependency injection container is required to access the 'filter' service"); + ZVAL_LONG(&_2$$5, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwdispatchexception", NULL, 0, &_1$$5, &_2$$5); + zephir_check_call_status(); + } + zephir_read_property(&_3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_5); + ZVAL_STRING(&_5, "filter"); + ZEPHIR_CALL_METHOD(&_4, &_3, "getshared", NULL, 0, &_5); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getivlength", NULL, 235, &cipher); + ZEPHIR_CPY_WRT(&filter, &_4); + ZEPHIR_RETURN_CALL_METHOD(&filter, "sanitize", NULL, 0, ¶mValue, filters); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("ivLength"), &_1); - zephir_update_property_zval(this_ptr, ZEND_STRL("cipher"), &cipher); - RETURN_THIS(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, setKey) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getParams) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *key_param = NULL; - zval key; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - - ZVAL_UNDEF(&key); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - zephir_get_strval(&key, key_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("key"), &key); - RETURN_THIS(); + + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getparameters", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, setHashAlgorithm) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getParameters) +{ + + RETURN_MEMBER(getThis(), "params"); +} + +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, hasParam) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *hashAlgorithm_param = NULL, _0; - zval hashAlgorithm; + zval *param, param_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&hashAlgorithm); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(¶m_sub); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(hashAlgorithm) + Z_PARAM_ZVAL(param) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &hashAlgorithm_param); - zephir_get_strval(&hashAlgorithm, hashAlgorithm_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "hash"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkcipherhashisavailable", NULL, 0, &hashAlgorithm, &_0); + zephir_fetch_params(1, 1, 0, ¶m); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hasparameter", NULL, 0, param); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("hashAlgorithm"), &hashAlgorithm); - RETURN_THIS(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, setPadding) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, hasParameter) { - zval *scheme_param = NULL, _0; - zend_long scheme; + zval *param, param_sub, _0; zval *this_ptr = getThis(); + ZVAL_UNDEF(¶m_sub); ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(scheme) + Z_PARAM_ZVAL(param) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &scheme_param); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, scheme); - zephir_update_property_zval(this_ptr, ZEND_STRL("padding"), &_0); - RETURN_THISW(); + zephir_fetch_params_without_memory_grow(1, 0, ¶m); + zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + RETURN_BOOL(zephir_array_isset(&_0, param)); } -static PHP_METHOD(Phalcon_Encryption_Crypt, useSigning) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, isFinished) { - zval *useSigning_param = NULL, __$true, __$false; - zend_bool useSigning; + + RETURN_MEMBER(getThis(), "finished"); +} + +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setActionName) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *actionName_param = NULL; + zval actionName; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&actionName); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(useSigning) + Z_PARAM_STR(actionName) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &useSigning_param); - if (useSigning) { - zephir_update_property_zval(this_ptr, ZEND_STRL("useSigning"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("useSigning"), &__$false); - } - RETURN_THISW(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &actionName_param); + zephir_get_strval(&actionName, actionName_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("actionName"), &actionName); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, checkCipherHashIsAvailable) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setDefaultAction) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *cipher_param = NULL, *type_param = NULL, available, lower, method, _0, _1$$5, _2$$5, _3$$5; - zval cipher, type; + zval *actionName_param = NULL; + zval actionName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&cipher); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&available); - ZVAL_UNDEF(&lower); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$5); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_3$$5); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(cipher) - Z_PARAM_STR(type) + ZVAL_UNDEF(&actionName); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(actionName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &cipher_param, &type_param); - zephir_get_strval(&cipher, cipher_param); - zephir_get_strval(&type, type_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "hash"); - ZEPHIR_INIT_VAR(&method); - if (ZEPHIR_IS_IDENTICAL(&_0, &cipher)) { - ZVAL_STRING(&method, "getAvailableHashAlgorithms"); - } else { - ZVAL_STRING(&method, "getAvailableCiphers"); - } - ZEPHIR_CALL_METHOD_ZVAL(&available, this_ptr, &method, NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&lower, "mb_strtolower", NULL, 10, &cipher); - zephir_check_call_status(); - if (1 != zephir_fast_in_array(&lower, &available)) { - ZEPHIR_INIT_VAR(&_1$$5); - object_init_ex(&_1$$5, phalcon_encryption_crypt_exception_exception_ce); - ZEPHIR_INIT_VAR(&_2$$5); - ZVAL_STRING(&_2$$5, "The %s algorithm '%s' is not supported on this system."); - ZEPHIR_CALL_FUNCTION(&_3$$5, "sprintf", NULL, 117, &_2$$5, &type, &cipher); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_1$$5, "__construct", NULL, 33, &_3$$5); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$5, "phalcon/Encryption/Crypt.zep", 608); - ZEPHIR_MM_RESTORE(); - return; - } + zephir_fetch_params(1, 1, 0, &actionName_param); + zephir_get_strval(&actionName, actionName_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultAction"), &actionName); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, cryptPadText) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setDefaultNamespace) { - zend_bool _4$$3; - zval _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long blockSize, paddingType, ZEPHIR_LAST_CALL_STATUS, paddingSize = 0; - zval *input_param = NULL, *mode_param = NULL, *blockSize_param = NULL, *paddingType_param = NULL, padding, service, _0, _2, _9, _10, _3$$3, _5$$3, _6$$3, _7$$3, _8$$3; - zval input, mode; + zval *defaultNamespace_param = NULL; + zval defaultNamespace; zval *this_ptr = getThis(); - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&mode); - ZVAL_UNDEF(&padding); - ZVAL_UNDEF(&service); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_STR(input) - Z_PARAM_STR(mode) - Z_PARAM_LONG(blockSize) - Z_PARAM_LONG(paddingType) + ZVAL_UNDEF(&defaultNamespace); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(defaultNamespace) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 0, &input_param, &mode_param, &blockSize_param, &paddingType_param); - zephir_get_strval(&input, input_param); - zephir_get_strval(&mode, mode_param); - ZEPHIR_INIT_VAR(&padding); - ZVAL_STRING(&padding, ""); - paddingSize = 0; - ZEPHIR_INIT_VAR(&_1); - zephir_create_array(&_1, 2, 0); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "cbc"); - zephir_array_fast_append(&_1, &_2); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "ecb"); - zephir_array_fast_append(&_1, &_2); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkismode", NULL, 236, &_1, &mode); - zephir_check_call_status(); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - ZEPHIR_CALL_FUNCTION(&_3$$3, "mb_strlen", NULL, 234, &input); - zephir_check_call_status(); - paddingSize = (blockSize - zephir_safe_mod_zval_long(&_3$$3, blockSize)); - _4$$3 = paddingSize >= 256; - if (!(_4$$3)) { - _4$$3 = paddingSize < 0; - } - if (_4$$3) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Padding size cannot be less than 0 or greater than 256", "phalcon/Encryption/Crypt.zep", 641); - return; - } - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("padFactory"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_6$$3, paddingType); - ZEPHIR_CALL_METHOD(&service, &_5$$3, "padnumbertoservice", NULL, 0, &_6$$3); - zephir_check_call_status(); - zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("padFactory"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_7$$3, &_6$$3, "newinstance", NULL, 0, &service); - zephir_check_call_status(); - ZVAL_LONG(&_8$$3, paddingSize); - ZEPHIR_CALL_METHOD(&padding, &_7$$3, "pad", NULL, 0, &_8$$3); - zephir_check_call_status(); - } - if (0 == paddingSize) { - RETURN_CTOR(&input); - } - ZVAL_LONG(&_9, 0); - ZVAL_LONG(&_10, paddingSize); - ZEPHIR_INIT_NVAR(&_2); - zephir_substr(&_2, &padding, 0 , zephir_get_intval(&_10), 0); - ZEPHIR_CONCAT_VV(return_value, &input, &_2); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &defaultNamespace_param); + zephir_get_strval(&defaultNamespace, defaultNamespace_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultNamespace"), &defaultNamespace); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, cryptUnpadText) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getHandlerClass) { - zval _3; - zend_bool _0, _1; + zval handlerSuffix, handlerName, namespaceName, camelizedClass, handlerClass, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long blockSize, paddingType, ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL, *mode_param = NULL, *blockSize_param = NULL, *paddingType_param = NULL, length, paddingSize, service, _2, _4, _5$$3, _6$$3, _7$$3, _8$$3, _9$$6, _10$$6; - zval input, mode; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&mode); - ZVAL_UNDEF(&length); - ZVAL_UNDEF(&paddingSize); - ZVAL_UNDEF(&service); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_9$$6); - ZVAL_UNDEF(&_10$$6); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_STR(input) - Z_PARAM_STR(mode) - Z_PARAM_LONG(blockSize) - Z_PARAM_LONG(paddingType) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&handlerSuffix); + ZVAL_UNDEF(&handlerName); + ZVAL_UNDEF(&namespaceName); + ZVAL_UNDEF(&camelizedClass); + ZVAL_UNDEF(&handlerClass); + ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 0, &input_param, &mode_param, &blockSize_param, &paddingType_param); - zephir_get_strval(&input, input_param); - zephir_get_strval(&mode, mode_param); - ZEPHIR_INIT_VAR(&length); - ZVAL_LONG(&length, zephir_fast_strlen_ev(&input)); - ZEPHIR_INIT_VAR(&paddingSize); - ZVAL_LONG(&paddingSize, 0); - _0 = ZEPHIR_GT_LONG(&length, 0); - if (_0) { - _0 = (zephir_safe_mod_zval_long(&length, blockSize) == 0); - } - _1 = _0; - if (_1) { - ZEPHIR_INIT_VAR(&_3); - zephir_create_array(&_3, 2, 0); - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, "cbc"); - zephir_array_fast_append(&_3, &_4); - ZEPHIR_INIT_NVAR(&_4); - ZVAL_STRING(&_4, "ecb"); - zephir_array_fast_append(&_3, &_4); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "checkismode", NULL, 236, &_3, &mode); + + ZEPHIR_CALL_METHOD(NULL, this_ptr, "resolveemptyproperties", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("handlerSuffix"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&handlerSuffix, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("handlerName"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&handlerName, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("namespaceName"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&namespaceName, &_0); + if (!(zephir_memnstr_str(&handlerName, SL("\\"), "phalcon/Dispatcher/AbstractDispatcher.zep", 938))) { + ZEPHIR_CALL_METHOD(&camelizedClass, this_ptr, "tocamelcase", NULL, 0, &handlerName); zephir_check_call_status(); - _1 = ZEPHIR_IS_TRUE_IDENTICAL(&_2); + } else { + ZEPHIR_CPY_WRT(&camelizedClass, &handlerName); } - if (_1) { - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("padFactory"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_6$$3, paddingType); - ZEPHIR_CALL_METHOD(&service, &_5$$3, "padnumbertoservice", NULL, 0, &_6$$3); - zephir_check_call_status(); - zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("padFactory"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_7$$3, &_6$$3, "newinstance", NULL, 0, &service); - zephir_check_call_status(); - ZVAL_LONG(&_8$$3, blockSize); - ZEPHIR_CALL_METHOD(&paddingSize, &_7$$3, "unpad", NULL, 0, &input, &_8$$3); - zephir_check_call_status(); - if (ZEPHIR_GT_LONG(&paddingSize, 0)) { - if (ZEPHIR_LE_LONG(&paddingSize, blockSize)) { - if (ZEPHIR_LT(&paddingSize, &length)) { - ZEPHIR_INIT_VAR(&_9$$6); - zephir_sub_function(&_9$$6, &length, &paddingSize); - ZVAL_LONG(&_10$$6, 0); - zephir_substr(return_value, &input, 0 , zephir_get_intval(&_9$$6), 0); - RETURN_MM(); - } - RETURN_MM_STRING(""); - } - ZEPHIR_INIT_NVAR(&paddingSize); - ZVAL_LONG(&paddingSize, 0); + ZEPHIR_INIT_VAR(&handlerClass); + if (zephir_is_true(&namespaceName)) { + if (!(zephir_end_with_str(&namespaceName, SL("\\")))) { + zephir_concat_self_str(&namespaceName, SL("\\")); } + ZEPHIR_CONCAT_VVV(&handlerClass, &namespaceName, &camelizedClass, &handlerSuffix); + } else { + ZEPHIR_CONCAT_VV(&handlerClass, &camelizedClass, &handlerSuffix); } - if (ZEPHIR_IS_LONG_IDENTICAL(&paddingSize, 0)) { - RETURN_CTOR(&input); - } - RETURN_MM_STRING(""); + RETURN_CCTOR(&handlerClass); } -static PHP_METHOD(Phalcon_Encryption_Crypt, decryptGetUnpadded) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setParam) { - zval _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long blockSize, ZEPHIR_LAST_CALL_STATUS; - zval *mode_param = NULL, *blockSize_param = NULL, decrypted, *decrypted_param = NULL, padding, _0, _2, _3$$3, _4$$3; - zval mode; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *param, param_sub, *value, value_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&mode); - ZVAL_UNDEF(&decrypted); - ZVAL_UNDEF(&padding); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_STR(mode) - Z_PARAM_LONG(blockSize) - Z_PARAM_STR(decrypted) + ZVAL_UNDEF(¶m_sub); + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(param) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &mode_param, &blockSize_param, &decrypted_param); - zephir_get_strval(&mode, mode_param); - zephir_get_strval(&decrypted, decrypted_param); - ZEPHIR_INIT_VAR(&_1); - zephir_create_array(&_1, 2, 0); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "cbc"); - zephir_array_fast_append(&_1, &_2); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "ecb"); - zephir_array_fast_append(&_1, &_2); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkismode", NULL, 236, &_1, &mode); + zephir_fetch_params(1, 2, 0, ¶m, &value); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setparameter", NULL, 0, param, value); zephir_check_call_status(); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("padding"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&padding, &_3$$3); - ZVAL_LONG(&_3$$3, blockSize); - ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "cryptunpadtext", NULL, 0, &decrypted, &mode, &_3$$3, &padding); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&decrypted, &_4$$3); - } - RETURN_CCTOR(&decrypted); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, decryptGcmCcmAuth) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setParameter) +{ + zval *param, param_sub, *value, value_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(¶m_sub); + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(param) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(2, 0, ¶m, &value); + zephir_update_property_array(this_ptr, SL("params"), param, value); +} + +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setParams) { - zval _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *mode_param = NULL, *cipherText_param = NULL, *decryptKey_param = NULL, *iv_param = NULL, authData, authTag, authTagLength, cipher, encrypted, decrypted, _0, _1, _3, _4$$3, _5$$3, _6$$4; - zval mode, cipherText, decryptKey, iv; + zval *params_param = NULL; + zval params; zval *this_ptr = getThis(); - ZVAL_UNDEF(&mode); - ZVAL_UNDEF(&cipherText); - ZVAL_UNDEF(&decryptKey); - ZVAL_UNDEF(&iv); - ZVAL_UNDEF(&authData); - ZVAL_UNDEF(&authTag); - ZVAL_UNDEF(&authTagLength); - ZVAL_UNDEF(&cipher); - ZVAL_UNDEF(&encrypted); - ZVAL_UNDEF(&decrypted); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_STR(mode) - Z_PARAM_STR(cipherText) - Z_PARAM_STR(decryptKey) - Z_PARAM_STR(iv) + ZVAL_UNDEF(¶ms); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(params) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 0, &mode_param, &cipherText_param, &decryptKey_param, &iv_param); - zephir_get_strval(&mode, mode_param); - zephir_get_strval(&cipherText, cipherText_param); - zephir_get_strval(&decryptKey, decryptKey_param); - zephir_get_strval(&iv, iv_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&cipher, &_0); - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 2, 0); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "ccm"); - zephir_array_fast_append(&_2, &_3); - ZEPHIR_INIT_NVAR(&_3); - ZVAL_STRING(&_3, "gcm"); - zephir_array_fast_append(&_2, &_3); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "checkismode", NULL, 236, &_2, &mode); + zephir_fetch_params(1, 1, 0, ¶ms_param); + zephir_get_arrval(¶ms, params_param); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setparameters", NULL, 0, ¶ms); zephir_check_call_status(); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_1)) { - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("authData"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&authData, &_4$$3); - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("authTagLength"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&authTagLength, &_4$$3); - zephir_negate(&authTagLength); - ZEPHIR_INIT_VAR(&authTag); - zephir_substr(&authTag, &cipherText, zephir_get_intval(&authTagLength), 0, ZEPHIR_SUBSTR_NO_LENGTH); - ZEPHIR_INIT_VAR(&_5$$3); - ZVAL_STRING(&_5$$3, ""); - ZEPHIR_INIT_VAR(&encrypted); - zephir_fast_str_replace(&encrypted, &authTag, &_5$$3, &cipherText); - ZVAL_LONG(&_4$$3, 1); - ZEPHIR_CALL_FUNCTION(&decrypted, "openssl_decrypt", NULL, 237, &encrypted, &cipher, &decryptKey, &_4$$3, &iv, &authTag, &authData); - zephir_check_call_status(); - } else { - ZVAL_LONG(&_6$$4, 1); - ZEPHIR_CALL_FUNCTION(&decrypted, "openssl_decrypt", NULL, 237, &cipherText, &cipher, &decryptKey, &_6$$4, &iv); - zephir_check_call_status(); - } - if (ZEPHIR_IS_FALSE_IDENTICAL(&decrypted)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Could not decrypt data", "phalcon/Encryption/Crypt.zep", 782); - return; - } - RETURN_CCTOR(&decrypted); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, encryptGetPadded) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setParameters) { - zval _3; - zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long blockSize, ZEPHIR_LAST_CALL_STATUS; - zval *mode_param = NULL, *input_param = NULL, *blockSize_param = NULL, _0, _2, _4, _5$$3, _6$$3; - zval mode, input; + zval *params_param = NULL; + zval params; zval *this_ptr = getThis(); - ZVAL_UNDEF(&mode); - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_STR(mode) - Z_PARAM_STR(input) - Z_PARAM_LONG(blockSize) + ZVAL_UNDEF(¶ms); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(params) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &mode_param, &input_param, &blockSize_param); - zephir_get_strval(&mode, mode_param); - zephir_get_strval(&input, input_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("padding"), PH_NOISY_CC | PH_READONLY); - _1 = !ZEPHIR_IS_LONG_IDENTICAL(&_0, 0); - if (_1) { - ZEPHIR_INIT_VAR(&_3); - zephir_create_array(&_3, 2, 0); - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, "cbc"); - zephir_array_fast_append(&_3, &_4); - ZEPHIR_INIT_NVAR(&_4); - ZVAL_STRING(&_4, "ecb"); - zephir_array_fast_append(&_3, &_4); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "checkismode", NULL, 236, &_3, &mode); - zephir_check_call_status(); - _1 = ZEPHIR_IS_TRUE_IDENTICAL(&_2); - } - if (_1) { - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("padding"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_6$$3, blockSize); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "cryptpadtext", NULL, 0, &input, &mode, &_6$$3, &_5$$3); - zephir_check_call_status(); - RETURN_MM(); - } - RETURN_CTOR(&input); + zephir_fetch_params(1, 1, 0, ¶ms_param); + zephir_get_arrval(¶ms, params_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("params"), ¶ms); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, encryptGcmCcm) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setReturnedValue) { - zval _2; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *mode_param = NULL, *padded_param = NULL, *encryptKey_param = NULL, *iv_param = NULL, authData, authTag, authTagLength, cipher, encrypted, _0, _1, _3, _4$$3, _5$$5; - zval mode, padded, encryptKey, iv; + zval *value, value_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&mode); - ZVAL_UNDEF(&padded); - ZVAL_UNDEF(&encryptKey); - ZVAL_UNDEF(&iv); - ZVAL_UNDEF(&authData); - ZVAL_UNDEF(&authTag); - ZVAL_UNDEF(&authTagLength); - ZVAL_UNDEF(&cipher); - ZVAL_UNDEF(&encrypted); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_STR(mode) - Z_PARAM_STR(padded) - Z_PARAM_STR(encryptKey) - Z_PARAM_STR(iv) + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 0, &mode_param, &padded_param, &encryptKey_param, &iv_param); - zephir_get_strval(&mode, mode_param); - zephir_get_strval(&padded, padded_param); - zephir_get_strval(&encryptKey, encryptKey_param); - zephir_get_strval(&iv, iv_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&cipher, &_0); - ZEPHIR_INIT_VAR(&authTag); - ZVAL_STRING(&authTag, ""); - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 2, 0); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "ccm"); - zephir_array_fast_append(&_2, &_3); - ZEPHIR_INIT_NVAR(&_3); - ZVAL_STRING(&_3, "gcm"); - zephir_array_fast_append(&_2, &_3); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "checkismode", NULL, 236, &_2, &mode); - zephir_check_call_status(); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_1)) { - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("authData"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&authData, &_4$$3); - if (1 == ZEPHIR_IS_EMPTY(&authData)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Auth data must be provided when using AEAD mode", "phalcon/Encryption/Crypt.zep", 841); - return; - } - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("authTag"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&authTag, &_4$$3); - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("authTagLength"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&authTagLength, &_4$$3); - ZVAL_LONG(&_4$$3, 1); - ZEPHIR_MAKE_REF(&authTag); - ZEPHIR_CALL_FUNCTION(&encrypted, "openssl_encrypt", NULL, 238, &padded, &cipher, &encryptKey, &_4$$3, &iv, &authTag, &authData, &authTagLength); - ZEPHIR_UNREF(&authTag); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("authTag"), &authTag); - } else { - ZVAL_LONG(&_5$$5, 1); - ZEPHIR_CALL_FUNCTION(&encrypted, "openssl_encrypt", NULL, 238, &padded, &cipher, &encryptKey, &_5$$5, &iv); - zephir_check_call_status(); - } - if (ZEPHIR_IS_FALSE_IDENTICAL(&encrypted)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Could not encrypt data", "phalcon/Encryption/Crypt.zep", 870); - return; - } - ZEPHIR_CONCAT_VV(return_value, &encrypted, &authTag); - RETURN_MM(); + zephir_fetch_params_without_memory_grow(1, 0, &value); + zephir_update_property_zval(this_ptr, ZEND_STRL("returnedValue"), value); } -static PHP_METHOD(Phalcon_Encryption_Crypt, initializeAvailableCiphers) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setActionSuffix) { - zend_bool _4$$4, _5$$4, _6$$4, _7$$6, _8$$6, _9$$6; - zval allowed; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$true, available, cipher, _0, _1, *_2, _3; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *actionSuffix_param = NULL; + zval actionSuffix; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&available); - ZVAL_UNDEF(&cipher); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&allowed); + ZVAL_UNDEF(&actionSuffix); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(actionSuffix) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "openssl_get_cipher_methods"); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "phpfunctionexists", NULL, 0, &_1); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "This class requires the openssl extension for PHP", "phalcon/Encryption/Crypt.zep", 892); - return; - } - ZEPHIR_CALL_FUNCTION(&available, "openssl_get_cipher_methods", NULL, 239, &__$true); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&allowed); - array_init(&allowed); - zephir_is_iterable(&available, 0, "phalcon/Encryption/Crypt.zep", 909); - if (Z_TYPE_P(&available) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&available), _2) - { - ZEPHIR_INIT_NVAR(&cipher); - ZVAL_COPY(&cipher, _2); - _4$$4 = 1 != zephir_start_with_str(&cipher, SL("des")); - if (_4$$4) { - _4$$4 = 1 != zephir_start_with_str(&cipher, SL("rc2")); - } - _5$$4 = _4$$4; - if (_5$$4) { - _5$$4 = 1 != zephir_start_with_str(&cipher, SL("rc4")); - } - _6$$4 = _5$$4; - if (_6$$4) { - _6$$4 = 1 != zephir_end_with_str(&cipher, SL("ecb")); - } - if (_6$$4) { - zephir_array_update_zval(&allowed, &cipher, &cipher, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &available, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &available, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3)) { - break; - } - ZEPHIR_CALL_METHOD(&cipher, &available, "current", NULL, 0); - zephir_check_call_status(); - _7$$6 = 1 != zephir_start_with_str(&cipher, SL("des")); - if (_7$$6) { - _7$$6 = 1 != zephir_start_with_str(&cipher, SL("rc2")); - } - _8$$6 = _7$$6; - if (_8$$6) { - _8$$6 = 1 != zephir_start_with_str(&cipher, SL("rc4")); - } - _9$$6 = _8$$6; - if (_9$$6) { - _9$$6 = 1 != zephir_end_with_str(&cipher, SL("ecb")); - } - if (_9$$6) { - zephir_array_update_zval(&allowed, &cipher, &cipher, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &available, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&cipher); - zephir_update_property_zval(this_ptr, ZEND_STRL("availableCiphers"), &allowed); - RETURN_THIS(); + zephir_fetch_params(1, 1, 0, &actionSuffix_param); + zephir_get_strval(&actionSuffix, actionSuffix_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("actionSuffix"), &actionSuffix); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, checkIsMode) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setEventsManager) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval mode; - zval *modes_param = NULL, *mode_param = NULL; - zval modes; + zval *eventsManager, eventsManager_sub; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&modes); - ZVAL_UNDEF(&mode); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ARRAY(modes) - Z_PARAM_STR(mode) + ZVAL_UNDEF(&eventsManager_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &modes_param, &mode_param); - zephir_get_arrval(&modes, modes_param); - zephir_get_strval(&mode, mode_param); - RETURN_MM_BOOL(zephir_fast_in_array(&mode, &modes)); + zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); + zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); } -static PHP_METHOD(Phalcon_Encryption_Crypt, getBlockSize) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setHandlerSuffix) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *mode_param = NULL, _0, _2, _3, _4; - zval mode, _1; + zval *handlerSuffix_param = NULL; + zval handlerSuffix; zval *this_ptr = getThis(); - ZVAL_UNDEF(&mode); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&handlerSuffix); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(mode) + Z_PARAM_STR(handlerSuffix) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &mode_param); - zephir_get_strval(&mode, mode_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("ivLength"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_GT_LONG(&_0, 0)) { - RETURN_MM_MEMBER(getThis(), "ivLength"); - } - ZEPHIR_INIT_VAR(&_1); - ZEPHIR_CONCAT_SV(&_1, "-", &mode); - zephir_read_property(&_2, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, ""); - ZEPHIR_CALL_FUNCTION(&_4, "str_ireplace", NULL, 240, &_1, &_3, &_2); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getivlength", NULL, 235, &_4); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &handlerSuffix_param); + zephir_get_strval(&handlerSuffix, handlerSuffix_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("handlerSuffix"), &handlerSuffix); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, getIvLength) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setModelBinder) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *cipher_param = NULL, length; - zval cipher; + zval *modelBinder, modelBinder_sub, *cache = NULL, cache_sub, __$true, __$false, __$null, container, _0$$3, _1$$3; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&cipher); - ZVAL_UNDEF(&length); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(cipher) + ZVAL_UNDEF(&modelBinder_sub); + ZVAL_UNDEF(&cache_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(modelBinder, phalcon_mvc_model_binderinterface_ce) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(cache) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &cipher_param); - zephir_get_strval(&cipher, cipher_param); - ZEPHIR_CALL_FUNCTION(&length, "openssl_cipher_iv_length", NULL, 241, &cipher); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&length)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Cannot calculate the initialization vector (IV) length of the cipher", "phalcon/Encryption/Crypt.zep", 962); - return; + zephir_fetch_params(1, 1, 1, &modelBinder, &cache); + if (!cache) { + cache = &cache_sub; + ZEPHIR_CPY_WRT(cache, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(cache); } - RETURN_CCTOR(&length); + if (Z_TYPE_P(cache) == IS_STRING) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_0$$3); + ZEPHIR_CALL_METHOD(&_1$$3, &container, "get", NULL, 0, cache); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(cache, &_1$$3); + } + if (Z_TYPE_P(cache) != IS_NULL) { + ZEPHIR_CALL_METHOD(NULL, modelBinder, "setcache", NULL, 0, cache); + zephir_check_call_status(); + } + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("modelBinding"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("modelBinding"), &__$false); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("modelBinder"), modelBinder); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, getMode) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setModuleName) { - zval position, _0, _1, _2, _3, _4, _5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *moduleName_param = NULL; + zval moduleName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&position); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&moduleName); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(moduleName) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "-"); - ZEPHIR_CALL_FUNCTION(&_2, "strrpos", NULL, 242, &_0, &_1); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&position); - ZVAL_LONG(&position, zephir_get_intval(&_2)); - zephir_read_property(&_3, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_4, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_5, ((zephir_get_numberval(&position) - zephir_fast_strlen_ev(&_4)) + 1)); - ZEPHIR_INIT_NVAR(&_1); - zephir_substr(&_1, &_3, zephir_get_intval(&_5), 0, ZEPHIR_SUBSTR_NO_LENGTH); - ZEPHIR_RETURN_CALL_FUNCTION("mb_strtolower", NULL, 10, &_1); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 0, 1, &moduleName_param); + if (!moduleName_param) { + ZEPHIR_INIT_VAR(&moduleName); + } else { + zephir_get_strval(&moduleName, moduleName_param); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("moduleName"), &moduleName); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, phpFunctionExists) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setNamespaceName) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL; - zval name; + zval *namespaceName_param = NULL; + zval namespaceName; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); + ZVAL_UNDEF(&namespaceName); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + Z_PARAM_STR(namespaceName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - zephir_get_strval(&name, name_param); - RETURN_MM_BOOL((zephir_function_exists(&name) == SUCCESS)); + zephir_fetch_params(1, 1, 0, &namespaceName_param); + zephir_get_strval(&namespaceName, namespaceName_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("namespaceName"), &namespaceName); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Crypt, phpOpensslCipherIvLength) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getReturnedValue) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *cipher_param = NULL; - zval cipher; - ZVAL_UNDEF(&cipher); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(cipher) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &cipher_param); - zephir_get_strval(&cipher, cipher_param); - ZEPHIR_RETURN_CALL_FUNCTION("openssl_cipher_iv_length", NULL, 241, &cipher); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MEMBER(getThis(), "returnedValue"); } -static PHP_METHOD(Phalcon_Encryption_Crypt, phpOpensslRandomPseudoBytes) +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, wasForwarded) +{ + + RETURN_MEMBER(getThis(), "forwarded"); +} + +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, resolveEmptyProperties) +{ + zval _0, _2, _4, _1$$3, _3$$4, _5$$5; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + zephir_read_property(&_0, this_ptr, ZEND_STRL("namespaceName"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_is_true(&_0))) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("defaultNamespace"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("namespaceName"), &_1$$3); + } + zephir_read_property(&_2, this_ptr, ZEND_STRL("handlerName"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_is_true(&_2))) { + zephir_read_property(&_3$$4, this_ptr, ZEND_STRL("defaultHandler"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("handlerName"), &_3$$4); + } + zephir_read_property(&_4, this_ptr, ZEND_STRL("actionName"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_is_true(&_4))) { + zephir_read_property(&_5$$5, this_ptr, ZEND_STRL("defaultAction"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("actionName"), &_5$$5); + } +} + +static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, toCamelCase) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *length_param = NULL, _0; - zend_long length, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL, camelCaseInput, _0, _1$$3, _2$$3, _3$$3; + zval input; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&camelCaseInput); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(length) + Z_PARAM_STR(input) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &length_param); - ZVAL_LONG(&_0, length); - ZEPHIR_RETURN_CALL_FUNCTION("openssl_random_pseudo_bytes", NULL, 243, &_0); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &input_param); + zephir_get_strval(&input, input_param); + zephir_memory_observe(&camelCaseInput); + zephir_read_property(&_0, this_ptr, ZEND_STRL("camelCaseMap"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&camelCaseInput, &_0, &input, 0))) { + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "/[_-]+/"); + ZEPHIR_CALL_FUNCTION(&_2$$3, "preg_split", NULL, 70, &_1$$3, &input); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_1$$3); + ZVAL_STRING(&_1$$3, "ucfirst"); + ZEPHIR_CALL_FUNCTION(&_3$$3, "array_map", NULL, 81, &_1$$3, &_2$$3); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&camelCaseInput); + zephir_fast_join_str(&camelCaseInput, SL(""), &_3$$3); + zephir_update_property_array(this_ptr, SL("camelCaseMap"), &input, &camelCaseInput); + } + RETURN_CCTOR(&camelCaseInput); } -zend_object *zephir_init_properties_Phalcon_Encryption_Crypt(zend_class_entry *class_type) +zend_object *zephir_init_properties_Phalcon_Dispatcher_AbstractDispatcher(zend_class_entry *class_type) { - zval _0, _1$$3; + zval _0, _2, _4, _6, _1$$3, _3$$4, _5$$5, _7$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); @@ -18148,11 +18288,29 @@ zend_object *zephir_init_properties_Phalcon_Encryption_Crypt(zend_class_entry *c { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("availableCiphers"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("availableCiphers"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("handlerHashes"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("handlerHashes"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("camelCaseMap"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("camelCaseMap"), &_5$$5); + } + zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("activeMethodMap"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_6) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$6); + array_init(&_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("activeMethodMap"), &_7$$6); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -18169,952 +18327,1107 @@ zend_object *zephir_init_properties_Phalcon_Encryption_Crypt(zend_class_entry *c -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security) +ZEPHIR_INIT_CLASS(Phalcon_Dispatcher_DispatcherInterface) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption, Security, phalcon, encryption_security, phalcon_di_abstractinjectionaware_ce, phalcon_encryption_security_method_entry, 0); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Dispatcher, DispatcherInterface, phalcon, dispatcher_dispatcherinterface, phalcon_dispatcher_dispatcherinterface_method_entry); - zend_declare_property_long(phalcon_encryption_security_ce, SL("defaultHash"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_encryption_security_ce, SL("numberBytes"), 16, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_encryption_security_ce, SL("random"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_encryption_security_ce, SL("requestToken"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_encryption_security_ce, SL("token"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_encryption_security_ce, SL("tokenKey"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_encryption_security_ce, SL("tokenKeySessionId"), "$PHALCON/CSRF/KEY$", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_encryption_security_ce, SL("tokenValueSessionId"), "$PHALCON/CSRF$", ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_encryption_security_ce, SL("workFactor"), 10, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_encryption_security_ce, SL("localSession"), ZEND_ACC_PRIVATE); - zend_declare_property_null(phalcon_encryption_security_ce, SL("localRequest"), ZEND_ACC_PRIVATE); - zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_ARGON2I"), 10); + return SUCCESS; +} - zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_ARGON2ID"), 11); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, dispatch); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, forward); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getActionName); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getActionSuffix); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getHandlerSuffix); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getParam); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getParameter); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getParams); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getParameters); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getReturnedValue); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, hasParam); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, isFinished); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setActionName); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setActionSuffix); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setDefaultAction); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setDefaultNamespace); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setHandlerSuffix); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setModuleName); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setNamespaceName); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setParam); +ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setParams); - zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_BCRYPT"), 0); - zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_DEFAULT"), 0); - zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_BLOWFISH"), 4); +#ifdef HAVE_CONFIG_H +#endif - zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_BLOWFISH_A"), 5); - zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_BLOWFISH_X"), 6); - zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_BLOWFISH_Y"), 7); - zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_EXT_DES"), 2); - zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_MD5"), 3); +ZEPHIR_INIT_CLASS(Phalcon_Dispatcher_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Dispatcher, Exception, phalcon, dispatcher_exception, zend_ce_exception, NULL, 0); - zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_SHA256"), 8); + zephir_declare_class_constant_long(phalcon_dispatcher_exception_ce, SL("EXCEPTION_ACTION_NOT_FOUND"), 5); - zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_SHA512"), 9); + zephir_declare_class_constant_long(phalcon_dispatcher_exception_ce, SL("EXCEPTION_CYCLIC_ROUTING"), 1); - zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_STD_DES"), 1); + zephir_declare_class_constant_long(phalcon_dispatcher_exception_ce, SL("EXCEPTION_HANDLER_NOT_FOUND"), 2); + + zephir_declare_class_constant_long(phalcon_dispatcher_exception_ce, SL("EXCEPTION_INVALID_HANDLER"), 3); + + zephir_declare_class_constant_long(phalcon_dispatcher_exception_ce, SL("EXCEPTION_INVALID_PARAMS"), 4); + + zephir_declare_class_constant_long(phalcon_dispatcher_exception_ce, SL("EXCEPTION_NO_DI"), 0); return SUCCESS; } -static PHP_METHOD(Phalcon_Encryption_Security, __construct) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Di_AbstractInjectionAware) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Di, AbstractInjectionAware, phalcon, di_abstractinjectionaware, zend_standard_class_def, phalcon_di_abstractinjectionaware_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + zend_declare_property_null(phalcon_di_abstractinjectionaware_ce, SL("container"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_di_abstractinjectionaware_ce, 1, phalcon_di_injectionawareinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Di_AbstractInjectionAware, getDI) +{ + + RETURN_MEMBER(getThis(), "container"); +} + +static PHP_METHOD(Phalcon_Di_AbstractInjectionAware, setDI) +{ + zval *container, container_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&container_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &container); + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Di_Di) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Di, Di, phalcon, di_di, phalcon_di_di_method_entry, 0); + + zend_declare_property_null(phalcon_di_di_ce, SL("services"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_di_di_ce, SL("sharedInstances"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_di_di_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_di_di_ce, SL("defaultDi"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC); + phalcon_di_di_ce->create_object = zephir_init_properties_Phalcon_Di_Di; + + zend_class_implements(phalcon_di_di_ce, 1, phalcon_di_diinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Di_Di, __construct) +{ + zval _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + zephir_read_static_property_ce(&_0, phalcon_di_di_ce, SL("defaultDi"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_is_true(&_0))) { + zephir_update_static_property_ce(phalcon_di_di_ce, ZEND_STRL("defaultDi"), this_ptr); + } +} + +static PHP_METHOD(Phalcon_Di_Di, __call) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *session = NULL, session_sub, *request = NULL, request_sub, __$null, _0; + zval arguments; + zval *method_param = NULL, *arguments_param = NULL, instance, possibleService, definition, _6, _0$$3, _1$$3, _2$$3, _3$$6, _4$$6, _5$$6; + zval method, _7; zval *this_ptr = getThis(); - ZVAL_UNDEF(&session_sub); - ZVAL_UNDEF(&request_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&instance); + ZVAL_UNDEF(&possibleService); + ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$6); + ZVAL_UNDEF(&_4$$6); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&arguments); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(method) Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(session, phalcon_session_managerinterface_ce) - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(request, phalcon_http_requestinterface_ce) + Z_PARAM_ARRAY(arguments) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &session, &request); - if (!session) { - session = &session_sub; - session = &__$null; + zephir_fetch_params(1, 1, 1, &method_param, &arguments_param); + if (UNEXPECTED(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 of the type string")); + RETURN_MM_NULL(); } - if (!request) { - request = &request_sub; - request = &__$null; + if (EXPECTED(Z_TYPE_P(method_param) == IS_STRING)) { + zephir_get_strval(&method, method_param); + } else { + ZEPHIR_INIT_VAR(&method); } - ZEPHIR_INIT_VAR(&_0); - object_init_ex(&_0, phalcon_encryption_security_random_ce); - if (zephir_has_constructor(&_0)) { - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); + if (!arguments_param) { + ZEPHIR_INIT_VAR(&arguments); + array_init(&arguments); + } else { + zephir_get_arrval(&arguments, arguments_param); + } + if (zephir_start_with_str(&method, SL("get"))) { + ZVAL_LONG(&_0$$3, 3); + ZEPHIR_INIT_VAR(&_1$$3); + zephir_substr(&_1$$3, &method, 3 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + ZEPHIR_CALL_FUNCTION(&possibleService, "lcfirst", NULL, 76, &_1$$3); zephir_check_call_status(); + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset(&_2$$3, &possibleService)) { + ZEPHIR_CALL_METHOD(&instance, this_ptr, "get", NULL, 0, &possibleService, &arguments); + zephir_check_call_status(); + RETURN_CCTOR(&instance); + } } - - zephir_update_property_zval(this_ptr, ZEND_STRL("random"), &_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("localRequest"), request); - zephir_update_property_zval(this_ptr, ZEND_STRL("localSession"), session); + if (zephir_start_with_str(&method, SL("set"))) { + zephir_memory_observe(&definition); + if (zephir_array_isset_long_fetch(&definition, &arguments, 0, 0)) { + ZVAL_LONG(&_3$$6, 3); + ZEPHIR_INIT_VAR(&_4$$6); + zephir_substr(&_4$$6, &method, 3 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + ZEPHIR_CALL_FUNCTION(&_5$$6, "lcfirst", NULL, 76, &_4$$6); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, 0, &_5$$6, &definition); + zephir_check_call_status(); + RETURN_MM_NULL(); + } + } + ZEPHIR_INIT_VAR(&_6); + object_init_ex(&_6, phalcon_di_exception_ce); + ZEPHIR_INIT_VAR(&_7); + ZEPHIR_CONCAT_SVS(&_7, "Call to undefined method or service '", &method, "'"); + ZEPHIR_CALL_METHOD(NULL, &_6, "__construct", NULL, 33, &_7); + zephir_check_call_status(); + zephir_throw_exception_debug(&_6, "phalcon/Di/Di.zep", 147); ZEPHIR_MM_RESTORE(); + return; } -static PHP_METHOD(Phalcon_Encryption_Security, checkHash) +static PHP_METHOD(Phalcon_Di_Di, attempt) { - zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long maxPassLength, ZEPHIR_LAST_CALL_STATUS; - zval *password_param = NULL, *passwordHash_param = NULL, *maxPassLength_param = NULL; - zval password, passwordHash; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool shared; + zval *name_param = NULL, *definition, definition_sub, *shared_param = NULL, _0, _1, _2, _3, _4; + zval name; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&password); - ZVAL_UNDEF(&passwordHash); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&definition_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(password) - Z_PARAM_STR(passwordHash) + Z_PARAM_STR(name) + Z_PARAM_ZVAL(definition) Z_PARAM_OPTIONAL - Z_PARAM_LONG(maxPassLength) + Z_PARAM_BOOL(shared) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &password_param, &passwordHash_param, &maxPassLength_param); - zephir_get_strval(&password, password_param); - zephir_get_strval(&passwordHash, passwordHash_param); - if (!maxPassLength_param) { - maxPassLength = 0; + zephir_fetch_params(1, 2, 1, &name_param, &definition, &shared_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - } - _0 = maxPassLength > 0; - if (_0) { - _0 = zephir_fast_strlen_ev(&password) > maxPassLength; + ZEPHIR_INIT_VAR(&name); } - if (_0) { + if (!shared_param) { + shared = 0; + } else { + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset(&_0, &name)) { RETURN_MM_BOOL(0); } - ZEPHIR_RETURN_CALL_FUNCTION("password_verify", NULL, 247, &password, &passwordHash); + ZEPHIR_INIT_VAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + if (shared) { + ZVAL_BOOL(&_2, 1); + } else { + ZVAL_BOOL(&_2, 0); + } + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, definition, &_2); zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_array(this_ptr, SL("services"), &name, &_1); + zephir_read_property(&_3, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_4, &_3, &name, PH_NOISY | PH_READONLY, "phalcon/Di/Di.zep", 163); + RETURN_CTOR(&_4); } -static PHP_METHOD(Phalcon_Encryption_Security, checkToken) +static PHP_METHOD(Phalcon_Di_Di, get) { + zval _7$$5, _18$$18; + zend_bool _1$$3, _15$$11; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool destroyIfValid, _1, _2; - zval *tokenKey_param = NULL, *tokenValue = NULL, tokenValue_sub, *destroyIfValid_param = NULL, __$null, equals, knownToken, userToken, _0; - zval tokenKey; + zval *name_param = NULL, *parameters = NULL, parameters_sub, __$null, service, isShared, instance, _0, _5, _16, _2$$3, _3$$4, _4$$4, _6$$5, _8$$5, _9$$7, _10$$7, _11$$9, _13$$12, _17$$18, _19$$18; + zval name, _12$$9, _14$$12; zval *this_ptr = getThis(); - ZVAL_UNDEF(&tokenKey); - ZVAL_UNDEF(&tokenValue_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_12$$9); + ZVAL_UNDEF(&_14$$12); + ZVAL_UNDEF(¶meters_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&equals); - ZVAL_UNDEF(&knownToken); - ZVAL_UNDEF(&userToken); + ZVAL_UNDEF(&service); + ZVAL_UNDEF(&isShared); + ZVAL_UNDEF(&instance); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_16); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_9$$7); + ZVAL_UNDEF(&_10$$7); + ZVAL_UNDEF(&_11$$9); + ZVAL_UNDEF(&_13$$12); + ZVAL_UNDEF(&_17$$18); + ZVAL_UNDEF(&_19$$18); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_18$$18); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 3) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(name) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(tokenKey) - Z_PARAM_ZVAL_OR_NULL(tokenValue) - Z_PARAM_BOOL(destroyIfValid) + Z_PARAM_ZVAL_OR_NULL(parameters) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 3, &tokenKey_param, &tokenValue, &destroyIfValid_param); - if (!tokenKey_param) { - ZEPHIR_INIT_VAR(&tokenKey); + zephir_fetch_params(1, 1, 1, &name_param, ¶meters); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - zephir_get_strval(&tokenKey, tokenKey_param); + ZEPHIR_INIT_VAR(&name); } - if (!tokenValue) { - tokenValue = &tokenValue_sub; - tokenValue = &__$null; + if (!parameters) { + parameters = ¶meters_sub; + parameters = &__$null; } - if (!destroyIfValid_param) { - destroyIfValid = 1; - } else { + ZEPHIR_INIT_VAR(&instance); + ZVAL_NULL(&instance); + zephir_memory_observe(&service); + zephir_read_property(&_0, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&service, &_0, &name, 0)) { + ZEPHIR_CALL_METHOD(&isShared, &service, "isshared", NULL, 0); + zephir_check_call_status(); + _1$$3 = zephir_is_true(&isShared); + if (_1$$3) { + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("sharedInstances"), PH_NOISY_CC | PH_READONLY); + _1$$3 = zephir_array_isset(&_2$$3, &name); + } + if (_1$$3) { + zephir_read_property(&_3$$4, this_ptr, ZEND_STRL("sharedInstances"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_4$$4, &_3$$4, &name, PH_NOISY | PH_READONLY, "phalcon/Di/Di.zep", 181); + RETURN_CTOR(&_4$$4); } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "processtokenkey", NULL, 248, &tokenKey); - zephir_check_call_status(); - zephir_get_strval(&tokenKey, &_0); - if (!(!(ZEPHIR_IS_EMPTY(&tokenKey)))) { - RETURN_MM_BOOL(0); } - ZEPHIR_CALL_METHOD(&userToken, this_ptr, "processusertoken", NULL, 249, &tokenKey, tokenValue); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&knownToken, this_ptr, "getrequesttoken", NULL, 0); - zephir_check_call_status(); - _1 = Z_TYPE_P(&knownToken) == IS_NULL; - if (!(_1)) { - _1 = Z_TYPE_P(&userToken) == IS_NULL; + zephir_read_property(&_5, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_5) != IS_NULL) { + zephir_read_property(&_6$$5, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_7$$5); + zephir_create_array(&_7$$5, 2, 0); + zephir_array_update_string(&_7$$5, SL("name"), &name, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_7$$5, SL("parameters"), parameters, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_8$$5); + ZVAL_STRING(&_8$$5, "di:beforeServiceResolve"); + ZEPHIR_CALL_METHOD(&instance, &_6$$5, "fire", NULL, 0, &_8$$5, this_ptr, &_7$$5); + zephir_check_call_status(); } - if (_1) { - RETURN_MM_BOOL(0); + if (Z_TYPE_P(&instance) == IS_NULL) { + if (Z_TYPE_P(&service) != IS_NULL) { + + /* try_start_1: */ + + ZEPHIR_CALL_METHOD(&instance, &service, "resolve", NULL, 0, parameters, this_ptr); + zephir_check_call_status_or_jump(try_end_1); + + try_end_1: + + if (EG(exception)) { + ZEPHIR_INIT_VAR(&_9$$7); + ZVAL_OBJ(&_9$$7, EG(exception)); + Z_ADDREF_P(&_9$$7); + ZEPHIR_INIT_VAR(&_10$$7); + if (zephir_instance_of_ev(&_9$$7, phalcon_di_exception_serviceresolutionexception_ce)) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&_10$$7, &_9$$7); + ZEPHIR_INIT_VAR(&_11$$9); + object_init_ex(&_11$$9, phalcon_di_exception_ce); + ZEPHIR_INIT_VAR(&_12$$9); + ZEPHIR_CONCAT_SVS(&_12$$9, "Service '", &name, "' cannot be resolved"); + ZEPHIR_CALL_METHOD(NULL, &_11$$9, "__construct", NULL, 33, &_12$$9); + zephir_check_call_status(); + zephir_throw_exception_debug(&_11$$9, "phalcon/Di/Di.zep", 208); + ZEPHIR_MM_RESTORE(); + return; + } + } + if (zephir_is_true(&isShared)) { + zephir_update_property_array(this_ptr, SL("sharedInstances"), &name, &instance); + } + } else { + if (UNEXPECTED(!(zephir_class_exists(&name, 1)))) { + ZEPHIR_INIT_VAR(&_13$$12); + object_init_ex(&_13$$12, phalcon_di_exception_ce); + ZEPHIR_INIT_VAR(&_14$$12); + ZEPHIR_CONCAT_SVS(&_14$$12, "Service '", &name, "' was not found in the dependency injection container"); + ZEPHIR_CALL_METHOD(NULL, &_13$$12, "__construct", NULL, 33, &_14$$12); + zephir_check_call_status(); + zephir_throw_exception_debug(&_13$$12, "phalcon/Di/Di.zep", 223); + ZEPHIR_MM_RESTORE(); + return; + } + _15$$11 = Z_TYPE_P(parameters) == IS_ARRAY; + if (_15$$11) { + _15$$11 = ((zephir_fast_count_int(parameters)) ? 1 : 0); + } + if (_15$$11) { + ZEPHIR_INIT_NVAR(&instance); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&instance, &name, parameters); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&instance); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&instance, &name); + zephir_check_call_status(); + } + } } - ZEPHIR_INIT_VAR(&equals); - ZEPHIR_INIT_NVAR(&equals); - ZVAL_BOOL(&equals, zephir_hash_equals(&knownToken, &userToken)); - _2 = zephir_is_true(&equals); - if (_2) { - _2 = destroyIfValid; + if (Z_TYPE_P(&instance) == IS_OBJECT) { + if (zephir_instance_of_ev(&instance, phalcon_di_injectionawareinterface_ce)) { + ZEPHIR_CALL_METHOD(NULL, &instance, "setdi", NULL, 0, this_ptr); + zephir_check_call_status(); + } + if (zephir_instance_of_ev(&instance, phalcon_di_initializationawareinterface_ce)) { + ZEPHIR_CALL_METHOD(NULL, &instance, "initialize", NULL, 0); + zephir_check_call_status(); + } } - if (_2) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "destroytoken", NULL, 0); + zephir_read_property(&_16, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_16) != IS_NULL) { + zephir_read_property(&_17$$18, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_18$$18); + zephir_create_array(&_18$$18, 3, 0); + zephir_array_update_string(&_18$$18, SL("name"), &name, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_18$$18, SL("parameters"), parameters, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_18$$18, SL("instance"), &instance, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_19$$18); + ZVAL_STRING(&_19$$18, "di:afterServiceResolve"); + ZEPHIR_CALL_METHOD(NULL, &_17$$18, "fire", NULL, 0, &_19$$18, this_ptr, &_18$$18); zephir_check_call_status(); } - RETURN_CCTOR(&equals); + RETURN_CCTOR(&instance); } -static PHP_METHOD(Phalcon_Encryption_Security, computeHmac) +static PHP_METHOD(Phalcon_Di_Di, getDefault) +{ + zval _0; + + ZVAL_UNDEF(&_0); + zephir_read_static_property_ce(&_0, phalcon_di_di_ce, SL("defaultDi"), PH_NOISY_CC | PH_READONLY); + RETURN_CTORW(&_0); +} + +static PHP_METHOD(Phalcon_Di_Di, getInternalEventsManager) +{ + + RETURN_MEMBER(getThis(), "eventsManager"); +} + +static PHP_METHOD(Phalcon_Di_Di, getRaw) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool raw; - zval *data_param = NULL, *key_param = NULL, *algo_param = NULL, *raw_param = NULL, hmac, _0, _1$$3, _2$$3, _3$$3; - zval data, key, algo; + zval *name_param = NULL, service, _0, _1$$3; + zval name, _2$$3; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&algo); - ZVAL_UNDEF(&hmac); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&service); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_STR(data) - Z_PARAM_STR(key) - Z_PARAM_STR(algo) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(raw) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 1, &data_param, &key_param, &algo_param, &raw_param); - zephir_get_strval(&data, data_param); - zephir_get_strval(&key, key_param); - zephir_get_strval(&algo, algo_param); - if (!raw_param) { - raw = 0; + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - } - ZVAL_BOOL(&_0, (raw ? 1 : 0)); - ZEPHIR_CALL_FUNCTION(&hmac, "hash_hmac", NULL, 229, &algo, &data, &key, &_0); - zephir_check_call_status(); - if (UNEXPECTED(!zephir_is_true(&hmac))) { + ZEPHIR_INIT_VAR(&name); + } + zephir_memory_observe(&service); + zephir_read_property(&_0, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(!(zephir_array_isset_fetch(&service, &_0, &name, 0)))) { ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_encryption_security_exception_ce); + object_init_ex(&_1$$3, phalcon_di_exception_ce); ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "Unknown hashing algorithm: %s"); - ZEPHIR_CALL_FUNCTION(&_3$$3, "sprintf", NULL, 117, &_2$$3, &algo); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_3$$3); + ZEPHIR_CONCAT_SVS(&_2$$3, "Service '", &name, "' was not found in the dependency injection container"); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3); zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Encryption/Security.zep", 219); + zephir_throw_exception_debug(&_1$$3, "phalcon/Di/Di.zep", 293); ZEPHIR_MM_RESTORE(); return; } - RETURN_CCTOR(&hmac); + ZEPHIR_RETURN_CALL_METHOD(&service, "getdefinition", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Security, destroyToken) +static PHP_METHOD(Phalcon_Di_Di, getService) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$null, session, _0, _1, _2$$3, _3$$3; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, service, _0, _1$$3; + zval name, _2$$3; zval *this_ptr = getThis(); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&session); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&name); ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&service); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "session"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "localSession"); - ZEPHIR_CALL_METHOD(&session, this_ptr, "getlocalservice", NULL, 0, &_0, &_1); - zephir_check_call_status(); - if (UNEXPECTED(zephir_is_true(&session))) { - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("tokenKeySessionId"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &session, "remove", NULL, 0, &_2$$3); - zephir_check_call_status(); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("tokenValueSessionId"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &session, "remove", NULL, 0, &_3$$3); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_memory_observe(&service); + zephir_read_property(&_0, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(!(zephir_array_isset_fetch(&service, &_0, &name, 0)))) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_di_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + ZEPHIR_CONCAT_SVS(&_2$$3, "Service '", &name, "' was not found in the dependency injection container"); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3); zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Di/Di.zep", 309); + ZEPHIR_MM_RESTORE(); + return; } - zephir_update_property_zval(this_ptr, ZEND_STRL("token"), &__$null); - zephir_update_property_zval(this_ptr, ZEND_STRL("tokenKey"), &__$null); - zephir_update_property_zval(this_ptr, ZEND_STRL("requestToken"), &__$null); - RETURN_THIS(); + RETURN_CCTOR(&service); } -static PHP_METHOD(Phalcon_Encryption_Security, getDefaultHash) +static PHP_METHOD(Phalcon_Di_Di, getServices) { - RETURN_MEMBER(getThis(), "defaultHash"); + RETURN_MEMBER(getThis(), "services"); } -static PHP_METHOD(Phalcon_Encryption_Security, getHashInformation) +static PHP_METHOD(Phalcon_Di_Di, getShared) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *hash_param = NULL; - zval hash; + zval *name_param = NULL, *parameters = NULL, parameters_sub, __$null, instance, _0; + zval name; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&hash); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(hash) + ZVAL_UNDEF(&name); + ZVAL_UNDEF(¶meters_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&instance); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(name) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(parameters) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &hash_param); - zephir_get_strval(&hash, hash_param); - ZEPHIR_RETURN_CALL_FUNCTION("password_get_info", NULL, 250, &hash); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Encryption_Security, getRandom) -{ - - RETURN_MEMBER(getThis(), "random"); -} - -static PHP_METHOD(Phalcon_Encryption_Security, getRandomBytes) -{ - - RETURN_MEMBER(getThis(), "numberBytes"); + zephir_fetch_params(1, 1, 1, &name_param, ¶meters); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + if (!parameters) { + parameters = ¶meters_sub; + parameters = &__$null; + } + zephir_memory_observe(&instance); + zephir_read_property(&_0, this_ptr, ZEND_STRL("sharedInstances"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&instance, &_0, &name, 0))) { + ZEPHIR_CALL_METHOD(&instance, this_ptr, "get", NULL, 0, &name, parameters); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("sharedInstances"), &name, &instance); + } + RETURN_CCTOR(&instance); } -static PHP_METHOD(Phalcon_Encryption_Security, getRequestToken) +static PHP_METHOD(Phalcon_Di_Di, loadFromConfig) { - zval _0; + zend_bool _4$$3, _8$$4; + zend_string *_3; + zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_7 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *config, config_sub, services, name, service, *_0, _1, _5$$3, _6$$3, _9$$4, _10$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&config_sub); + ZVAL_UNDEF(&services); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&service); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&_10$$4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(config, phalcon_config_configinterface_ce) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("requestToken"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_EMPTY(&_0)) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsessiontoken", NULL, 0); + zephir_fetch_params(1, 1, 0, &config); + ZEPHIR_CALL_METHOD(&services, config, "toarray", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&services, 0, "phalcon/Di/Di.zep", 359); + if (Z_TYPE_P(&services) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&services), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&name); + if (_3 != NULL) { + ZVAL_STR_COPY(&name, _3); + } else { + ZVAL_LONG(&name, _2); + } + ZEPHIR_INIT_NVAR(&service); + ZVAL_COPY(&service, _0); + _4$$3 = zephir_array_isset_string(&service, SL("shared")); + if (_4$$3) { + ZEPHIR_OBS_NVAR(&_5$$3); + zephir_array_fetch_string(&_5$$3, &service, SL("shared"), PH_NOISY, "phalcon/Di/Di.zep", 357); + _4$$3 = zephir_is_true(&_5$$3); + } + ZVAL_BOOL(&_6$$3, _4$$3); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", &_7, 0, &name, &service, &_6$$3); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &services, "rewind", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &services, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&name, &services, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&service, &services, "current", NULL, 0); + zephir_check_call_status(); + _8$$4 = zephir_array_isset_string(&service, SL("shared")); + if (_8$$4) { + ZEPHIR_OBS_NVAR(&_9$$4); + zephir_array_fetch_string(&_9$$4, &service, SL("shared"), PH_NOISY, "phalcon/Di/Di.zep", 357); + _8$$4 = zephir_is_true(&_9$$4); + } + ZVAL_BOOL(&_10$$4, _8$$4); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", &_7, 0, &name, &service, &_10$$4); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &services, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_MM_MEMBER(getThis(), "requestToken"); + ZEPHIR_INIT_NVAR(&service); + ZEPHIR_INIT_NVAR(&name); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Security, getSessionToken) +static PHP_METHOD(Phalcon_Di_Di, loadFromPhp) { - zval session, _0, _1, _2$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *filePath_param = NULL, services; + zval filePath; zval *this_ptr = getThis(); - ZVAL_UNDEF(&session); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&filePath); + ZVAL_UNDEF(&services); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(filePath) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "session"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "localSession"); - ZEPHIR_CALL_METHOD(&session, this_ptr, "getlocalservice", NULL, 0, &_0, &_1); - zephir_check_call_status(); - if (UNEXPECTED(zephir_is_true(&session))) { - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("tokenValueSessionId"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&session, "get", NULL, 0, &_2$$3); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &filePath_param); + if (UNEXPECTED(Z_TYPE_P(filePath_param) != IS_STRING && Z_TYPE_P(filePath_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'filePath' must be of the type string")); + RETURN_MM_NULL(); } - RETURN_MM_NULL(); + if (EXPECTED(Z_TYPE_P(filePath_param) == IS_STRING)) { + zephir_get_strval(&filePath, filePath_param); + } else { + ZEPHIR_INIT_VAR(&filePath); + } + ZEPHIR_INIT_VAR(&services); + object_init_ex(&services, phalcon_config_adapter_php_ce); + ZEPHIR_CALL_METHOD(NULL, &services, "__construct", NULL, 78, &filePath); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "loadfromconfig", NULL, 0, &services); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Security, getSaltBytes) +static PHP_METHOD(Phalcon_Di_Di, loadFromYaml) { - zend_bool _3$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *numberBytes_param = NULL, safeBytes, _0$$3, _1$$4, _2$$4; - zend_long numberBytes, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval callbacks; + zval *filePath_param = NULL, *callbacks_param = NULL, services; + zval filePath; zval *this_ptr = getThis(); - ZVAL_UNDEF(&safeBytes); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); - ZEND_PARSE_PARAMETERS_START(0, 1) + ZVAL_UNDEF(&filePath); + ZVAL_UNDEF(&services); + ZVAL_UNDEF(&callbacks); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(filePath) Z_PARAM_OPTIONAL - Z_PARAM_LONG(numberBytes) + Z_PARAM_ARRAY_OR_NULL(callbacks) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &numberBytes_param); - if (!numberBytes_param) { - numberBytes = 0; + zephir_fetch_params(1, 1, 1, &filePath_param, &callbacks_param); + if (UNEXPECTED(Z_TYPE_P(filePath_param) != IS_STRING && Z_TYPE_P(filePath_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'filePath' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(filePath_param) == IS_STRING)) { + zephir_get_strval(&filePath, filePath_param); } else { - } - if (!(numberBytes)) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("numberBytes"), PH_NOISY_CC | PH_READONLY); - numberBytes = zephir_get_numberval(&_0$$3); + ZEPHIR_INIT_VAR(&filePath); } - while (1) { - zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("random"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_2$$4, numberBytes); - ZEPHIR_CALL_METHOD(&safeBytes, &_1$$4, "base64safe", NULL, 0, &_2$$4); - zephir_check_call_status(); - _3$$4 = zephir_is_true(&safeBytes); - if (_3$$4) { - _3$$4 = zephir_fast_strlen_ev(&safeBytes) >= numberBytes; - } - if (_3$$4) { - break; - } + if (!callbacks_param) { + ZEPHIR_INIT_VAR(&callbacks); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&callbacks, callbacks_param); } - RETURN_CCTOR(&safeBytes); + ZEPHIR_INIT_VAR(&services); + object_init_ex(&services, phalcon_config_adapter_yaml_ce); + ZEPHIR_CALL_METHOD(NULL, &services, "__construct", NULL, 79, &filePath, &callbacks); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "loadfromconfig", NULL, 0, &services); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Security, getToken) +static PHP_METHOD(Phalcon_Di_Di, has) { - zval session, _0, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, _7$$4, _8$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, _0; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&session); + ZVAL_UNDEF(&name); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_8$$4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "getsessiontoken", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("requestToken"), &_1$$3); - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("random"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("numberBytes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_3$$3, &_2$$3, "base64safe", NULL, 0, &_4$$3); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("token"), &_3$$3); - ZEPHIR_INIT_VAR(&_5$$3); - ZVAL_STRING(&_5$$3, "session"); - ZEPHIR_INIT_VAR(&_6$$3); - ZVAL_STRING(&_6$$3, "localSession"); - ZEPHIR_CALL_METHOD(&session, this_ptr, "getlocalservice", NULL, 0, &_5$$3, &_6$$3); - zephir_check_call_status(); - if (Z_TYPE_P(&session) != IS_NULL) { - zephir_read_property(&_7$$4, this_ptr, ZEND_STRL("tokenValueSessionId"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_8$$4, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &session, "set", NULL, 0, &_7$$4, &_8$$4); - zephir_check_call_status(); - } + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); } - RETURN_MM_MEMBER(getThis(), "token"); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); + RETURN_MM_BOOL(zephir_array_isset(&_0, &name)); } -static PHP_METHOD(Phalcon_Encryption_Security, getTokenKey) +static PHP_METHOD(Phalcon_Di_Di, offsetGet) { - zval session, _0, _1$$3, _2$$3, _3$$4, _4$$4, _5$$4, _6$$4, _7$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval name_sub; + zval *name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&session); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&name_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(name) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("tokenKey"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - ZVAL_STRING(&_1$$3, "session"); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "localSession"); - ZEPHIR_CALL_METHOD(&session, this_ptr, "getlocalservice", NULL, 0, &_1$$3, &_2$$3); - zephir_check_call_status(); - if (Z_TYPE_P(&session) != IS_NULL) { - zephir_read_property(&_3$$4, this_ptr, ZEND_STRL("random"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_5$$4, this_ptr, ZEND_STRL("numberBytes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_4$$4, &_3$$4, "base64safe", NULL, 0, &_5$$4); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("tokenKey"), &_4$$4); - zephir_read_property(&_6$$4, this_ptr, ZEND_STRL("tokenKeySessionId"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_7$$4, this_ptr, ZEND_STRL("tokenKey"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &session, "set", NULL, 0, &_6$$4, &_7$$4); - zephir_check_call_status(); - } - } - RETURN_MM_MEMBER(getThis(), "tokenKey"); + zephir_fetch_params(1, 1, 0, &name); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getshared", NULL, 0, name); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Security, getWorkFactor) +static PHP_METHOD(Phalcon_Di_Di, offsetExists) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval name_sub; + zval *name; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "workFactor"); + ZVAL_UNDEF(&name_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, name); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Security, hash) +static PHP_METHOD(Phalcon_Di_Di, offsetSet) { - zend_bool legacy = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, bytes = 0; - zval options; - zval *password_param = NULL, *options_param = NULL, algorithm, arguments, cost, formatted, prefix, salt, _0, _1, _6, _2$$6, _3$$7, _4$$9, _5$$9; - zval password; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval offset_sub, value_sub; + zval *offset, *value; zval *this_ptr = getThis(); - ZVAL_UNDEF(&password); - ZVAL_UNDEF(&algorithm); - ZVAL_UNDEF(&arguments); - ZVAL_UNDEF(&cost); - ZVAL_UNDEF(&formatted); - ZVAL_UNDEF(&prefix); - ZVAL_UNDEF(&salt); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_2$$6); - ZVAL_UNDEF(&_3$$7); - ZVAL_UNDEF(&_4$$9); - ZVAL_UNDEF(&_5$$9); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(password) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZVAL_UNDEF(&offset_sub); + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(offset) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &password_param, &options_param); - zephir_get_strval(&password, password_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - ZEPHIR_CALL_METHOD(&cost, this_ptr, "processcost", NULL, 251, &options); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "%02s"); - ZEPHIR_CALL_FUNCTION(&formatted, "sprintf", NULL, 117, &_0, &cost); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&prefix); - ZVAL_STRING(&prefix, ""); - bytes = 22; - legacy = 1; - zephir_memory_observe(&_1); - zephir_read_property(&_1, this_ptr, ZEND_STRL("defaultHash"), PH_NOISY_CC); - do { - if (ZEPHIR_IS_LONG(&_1, 3)) { - ZEPHIR_INIT_NVAR(&prefix); - ZVAL_STRING(&prefix, "$1$"); - bytes = 12; - break; - } - if (ZEPHIR_IS_LONG(&_1, 8)) { - ZEPHIR_INIT_NVAR(&prefix); - ZVAL_STRING(&prefix, "$5$"); - bytes = 16; - break; - } - if (ZEPHIR_IS_LONG(&_1, 9)) { - ZEPHIR_INIT_NVAR(&prefix); - ZVAL_STRING(&prefix, "$6$"); - bytes = 16; - break; - } - if (ZEPHIR_IS_LONG(&_1, 5)) { - ZEPHIR_INIT_VAR(&_2$$6); - ZVAL_STRING(&_2$$6, "$2a$%s$"); - ZEPHIR_CALL_FUNCTION(&prefix, "sprintf", NULL, 117, &_2$$6, &formatted); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&_1, 6)) { - ZEPHIR_INIT_VAR(&_3$$7); - ZVAL_STRING(&_3$$7, "$2x$%s$"); - ZEPHIR_CALL_FUNCTION(&prefix, "sprintf", NULL, 117, &_3$$7, &formatted); - zephir_check_call_status(); - break; - } - legacy = 0; - break; - } while(0); - - if (UNEXPECTED(legacy)) { - ZVAL_LONG(&_5$$9, bytes); - ZEPHIR_CALL_METHOD(&_4$$9, this_ptr, "getsaltbytes", NULL, 0, &_5$$9); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&salt); - ZEPHIR_CONCAT_VVS(&salt, &prefix, &_4$$9, "$"); - ZEPHIR_RETURN_CALL_FUNCTION("crypt", NULL, 252, &password, &salt); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_INIT_VAR(&_6); - zephir_create_array(&_6, 1, 0); - zephir_array_update_string(&_6, SL("cost"), &cost, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&options, &_6); - ZEPHIR_CALL_METHOD(&algorithm, this_ptr, "processalgorithm", NULL, 253); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&arguments, this_ptr, "processargonoptions", NULL, 254, &options); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_FUNCTION("password_hash", NULL, 255, &password, &algorithm, &arguments); + zephir_fetch_params(1, 2, 0, &offset, &value); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setshared", NULL, 0, offset, value); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Security, isLegacyHash) +static PHP_METHOD(Phalcon_Di_Di, offsetUnset) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *passwordHash_param = NULL; - zval passwordHash; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval name_sub; + zval *name; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&passwordHash); + ZVAL_UNDEF(&name_sub); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(passwordHash) + Z_PARAM_ZVAL(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &passwordHash_param); - zephir_get_strval(&passwordHash, passwordHash_param); - RETURN_MM_BOOL(zephir_start_with_str(&passwordHash, SL("$2a$"))); + zephir_fetch_params(1, 1, 0, &name); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "remove", NULL, 0, name); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Security, setDefaultHash) +static PHP_METHOD(Phalcon_Di_Di, register) { - zval *defaultHash_param = NULL, _0; - zend_long defaultHash; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *provider, provider_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&provider_sub); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(defaultHash) + Z_PARAM_OBJECT_OF_CLASS(provider, phalcon_di_serviceproviderinterface_ce) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &defaultHash_param); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, defaultHash); - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultHash"), &_0); - RETURN_THISW(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &provider); + ZEPHIR_CALL_METHOD(NULL, provider, "register", NULL, 0, this_ptr); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Security, setRandomBytes) +static PHP_METHOD(Phalcon_Di_Di, remove) { - zval *randomBytes_param = NULL, _0; - zend_long randomBytes; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *name_param = NULL, services, _0, sharedInstances; + zval name; zval *this_ptr = getThis(); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&services); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&sharedInstances); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(randomBytes) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &randomBytes_param); - if (UNEXPECTED(Z_TYPE_P(randomBytes_param) != IS_LONG)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'randomBytes' must be of the type int")); - RETURN_NULL(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); } - randomBytes = Z_LVAL_P(randomBytes_param); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, randomBytes); - zephir_update_property_zval(this_ptr, ZEND_STRL("numberBytes"), &_0); - RETURN_THISW(); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&services, &_0); + zephir_array_unset(&services, &name, PH_SEPARATE); + zephir_update_property_zval(this_ptr, ZEND_STRL("services"), &services); + zephir_read_property(&_0, this_ptr, ZEND_STRL("sharedInstances"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&sharedInstances, &_0); + zephir_array_unset(&sharedInstances, &name, PH_SEPARATE); + zephir_update_property_zval(this_ptr, ZEND_STRL("sharedInstances"), &sharedInstances); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Security, setWorkFactor) +static PHP_METHOD(Phalcon_Di_Di, reset) { - zval *workFactor_param = NULL, _0; - zend_long workFactor; - zval *this_ptr = getThis(); + zval __$null; - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(workFactor) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &workFactor_param); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, workFactor); - zephir_update_property_zval(this_ptr, ZEND_STRL("workFactor"), &_0); - RETURN_THISW(); + ZVAL_NULL(&__$null); + zephir_update_static_property_ce(phalcon_di_di_ce, ZEND_STRL("defaultDi"), &__$null); } -static PHP_METHOD(Phalcon_Encryption_Security, getLocalService) +static PHP_METHOD(Phalcon_Di_Di, set) { - zend_bool _1, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, *property_param = NULL, _0, _2, _4, _5, _8, _6$$3, _7$$3; - zval name, property; + zend_bool shared; + zval *name_param = NULL, *definition, definition_sub, *shared_param = NULL, _0, _1, _2, _3; + zval name; zval *this_ptr = getThis(); ZVAL_UNDEF(&name); - ZVAL_UNDEF(&property); + ZVAL_UNDEF(&definition_sub); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$3); - ZEND_PARSE_PARAMETERS_START(2, 2) + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(2, 3) Z_PARAM_STR(name) - Z_PARAM_STR(property) + Z_PARAM_ZVAL(definition) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(shared) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &property_param); - zephir_get_strval(&name, name_param); - zephir_get_strval(&property, property_param); - zephir_memory_observe(&_0); - zephir_read_property_zval(&_0, this_ptr, &property, PH_NOISY_CC); - _1 = Z_TYPE_P(&_0) == IS_NULL; - if (_1) { - zephir_read_property(&_2, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - _1 = Z_TYPE_P(&_2) != IS_NULL; + zephir_fetch_params(1, 2, 1, &name_param, &definition, &shared_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); } - _3 = _1; - if (_3) { - zephir_read_property(&_4, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_5, &_4, "has", NULL, 0, &name); - zephir_check_call_status(); - _3 = ZEPHIR_IS_TRUE_IDENTICAL(&_5); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); } - if (_3) { - zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_7$$3, &_6$$3, "getshared", NULL, 0, &name); - zephir_check_call_status(); - zephir_update_property_zval_zval(this_ptr, &property, &_7$$3); + if (!shared_param) { + shared = 0; + } else { + } + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, phalcon_di_service_ce); + if (shared) { + ZVAL_BOOL(&_1, 1); + } else { + ZVAL_BOOL(&_1, 0); } - zephir_memory_observe(&_8); - zephir_read_property_zval(&_8, this_ptr, &property, PH_NOISY_CC); - RETURN_CCTOR(&_8); + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 77, definition, &_1); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("services"), &name, &_0); + zephir_read_property(&_2, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_3, &_2, &name, PH_NOISY | PH_READONLY, "phalcon/Di/Di.zep", 550); + RETURN_CTOR(&_3); } -static PHP_METHOD(Phalcon_Encryption_Security, processAlgorithm) +static PHP_METHOD(Phalcon_Di_Di, setDefault) { - zval algorithm, _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&algorithm); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zval *container, container_sub; - ZEPHIR_INIT_VAR(&algorithm); - ZVAL_STRING(&algorithm, "2y"); - zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultHash"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_1, this_ptr, ZEND_STRL("defaultHash"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_LONG_IDENTICAL(&_0, 10)) { - ZEPHIR_INIT_NVAR(&algorithm); - ZVAL_STRING(&algorithm, "argon2i"); - } else if (ZEPHIR_IS_LONG_IDENTICAL(&_1, 11)) { - ZEPHIR_INIT_NVAR(&algorithm); - ZVAL_STRING(&algorithm, "argon2id"); - } - RETURN_CCTOR(&algorithm); + ZVAL_UNDEF(&container_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &container); + zephir_update_static_property_ce(phalcon_di_di_ce, ZEND_STRL("defaultDi"), container); } -static PHP_METHOD(Phalcon_Encryption_Security, processArgonOptions) +static PHP_METHOD(Phalcon_Di_Di, setInternalEventsManager) { - zend_bool _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *options_param = NULL, value, _0, _2; - zval options; + zval *eventsManager, eventsManager_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&eventsManager_sub); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(options) + Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &options_param); - zephir_get_arrval(&options, options_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultHash"), PH_NOISY_CC | PH_READONLY); - _1 = ZEPHIR_IS_LONG_IDENTICAL(&_0, 10); - if (!(_1)) { - zephir_read_property(&_2, this_ptr, ZEND_STRL("defaultHash"), PH_NOISY_CC | PH_READONLY); - _1 = ZEPHIR_IS_LONG_IDENTICAL(&_2, 11); - } - if (_1) { - zephir_memory_observe(&value); - if (!(zephir_array_isset_string_fetch(&value, &options, SL("memory_cost"), 0))) { - ZEPHIR_INIT_NVAR(&value); - ZVAL_LONG(&value, 65536); - } - zephir_array_update_string(&options, SL("memory_cost"), &value, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&value); - if (!(zephir_array_isset_string_fetch(&value, &options, SL("time_cost"), 0))) { - ZEPHIR_INIT_NVAR(&value); - ZVAL_LONG(&value, 4); - } - zephir_array_update_string(&options, SL("time_cost"), &value, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&value); - if (!(zephir_array_isset_string_fetch(&value, &options, SL("threads"), 0))) { - ZEPHIR_INIT_NVAR(&value); - ZVAL_LONG(&value, 1); - } - zephir_array_update_string(&options, SL("threads"), &value, PH_COPY | PH_SEPARATE); - } - RETURN_CTOR(&options); + zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); + zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); } -static PHP_METHOD(Phalcon_Encryption_Security, processCost) +static PHP_METHOD(Phalcon_Di_Di, setService) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *options_param = NULL, cost; - zval options; + zval *name_param = NULL, *rawDefinition, rawDefinition_sub; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&cost); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&rawDefinition_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_OBJECT_OF_CLASS(rawDefinition, phalcon_di_serviceinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &options_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - zephir_memory_observe(&cost); - if (!(zephir_array_isset_string_fetch(&cost, &options, SL("cost"), 0))) { - ZEPHIR_OBS_NVAR(&cost); - zephir_read_property(&cost, this_ptr, ZEND_STRL("workFactor"), PH_NOISY_CC); - } - if (ZEPHIR_LT_LONG(&cost, 4)) { - ZEPHIR_INIT_NVAR(&cost); - ZVAL_LONG(&cost, 4); + zephir_fetch_params(1, 2, 0, &name_param, &rawDefinition); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); } - if (ZEPHIR_GT_LONG(&cost, 31)) { - ZEPHIR_INIT_NVAR(&cost); - ZVAL_LONG(&cost, 31); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); } - RETURN_CCTOR(&cost); + zephir_update_property_array(this_ptr, SL("services"), &name, rawDefinition); + RETVAL_ZVAL(rawDefinition, 1, 0); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Security, processTokenKey) +static PHP_METHOD(Phalcon_Di_Di, setShared) { - zend_bool _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *tokenKey_param = NULL, key, session, _0, _1, _3$$3; - zval tokenKey; + zval *name_param = NULL, *definition, definition_sub, _0; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&tokenKey); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&session); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&definition_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3$$3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(tokenKey) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_ZVAL(definition) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &tokenKey_param); - if (!tokenKey_param) { - ZEPHIR_INIT_VAR(&tokenKey); + zephir_fetch_params(1, 2, 0, &name_param, &definition); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - zephir_get_strval(&tokenKey, tokenKey_param); + ZEPHIR_INIT_VAR(&name); } - ZEPHIR_CPY_WRT(&key, &tokenKey); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "session"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "localSession"); - ZEPHIR_CALL_METHOD(&session, this_ptr, "getlocalservice", NULL, 0, &_0, &_1); + ZVAL_BOOL(&_0, 1); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "set", NULL, 0, &name, definition, &_0); zephir_check_call_status(); - _2 = Z_TYPE_P(&session) != IS_NULL; - if (_2) { - _2 = 1 == ZEPHIR_IS_EMPTY(&key); - } - if (_2) { - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("tokenKeySessionId"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&key, &session, "get", NULL, 0, &_3$$3); - zephir_check_call_status(); - } - RETURN_CCTOR(&key); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Security, processUserToken) +zend_object *zephir_init_properties_Phalcon_Di_Di(zend_class_entry *class_type) { + zval _0, _2, _1$$3, _3$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *tokenKey_param = NULL, *tokenValue_param = NULL, request, userToken, _0$$3, _1$$3, _2$$4; - zval tokenKey, tokenValue; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&tokenKey); - ZVAL_UNDEF(&tokenValue); - ZVAL_UNDEF(&request); - ZVAL_UNDEF(&userToken); - ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(tokenKey) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(tokenValue) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &tokenKey_param, &tokenValue_param); - zephir_get_strval(&tokenKey, tokenKey_param); - if (!tokenValue_param) { - ZEPHIR_INIT_VAR(&tokenValue); - } else { - zephir_get_strval(&tokenValue, tokenValue_param); - } - ZEPHIR_CPY_WRT(&userToken, &tokenValue); - if (!(!(ZEPHIR_IS_EMPTY(&tokenValue)))) { - ZEPHIR_INIT_VAR(&_0$$3); - ZVAL_STRING(&_0$$3, "request"); - ZEPHIR_INIT_VAR(&_1$$3); - ZVAL_STRING(&_1$$3, "localRequest"); - ZEPHIR_CALL_METHOD(&request, this_ptr, "getlocalservice", NULL, 0, &_0$$3, &_1$$3); - zephir_check_call_status(); - if (Z_TYPE_P(&request) != IS_NULL) { - ZEPHIR_INIT_VAR(&_2$$4); - ZVAL_STRING(&_2$$4, "string"); - ZEPHIR_CALL_METHOD(&userToken, &request, "getpost", NULL, 0, &tokenKey, &_2$$4); - zephir_check_call_status(); + ZVAL_UNDEF(&_3$$4); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("sharedInstances"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sharedInstances"), &_1$$3); } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("services"), &_3$$4); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } - RETURN_CCTOR(&userToken); } @@ -19127,13 +19440,28 @@ static PHP_METHOD(Phalcon_Encryption_Security, processUserToken) -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_Exception) +ZEPHIR_INIT_CLASS(Phalcon_Di_DiInterface) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Security, Exception, phalcon, encryption_security_exception, zend_ce_exception, NULL, 0); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Di, DiInterface, phalcon, di_diinterface, phalcon_di_diinterface_method_entry); + zend_class_implements(phalcon_di_diinterface_ce, 1, zend_ce_arrayaccess); return SUCCESS; } +ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, attempt); +ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, get); +ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, getDefault); +ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, getRaw); +ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, getService); +ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, getServices); +ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, getShared); +ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, has); +ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, remove); +ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, reset); +ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, set); +ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, setDefault); +ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, setService); +ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, setShared); @@ -19144,390 +19472,242 @@ ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_Exception) -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_Random) +ZEPHIR_INIT_CLASS(Phalcon_Di_Exception) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security, Random, phalcon, encryption_security_random, phalcon_encryption_security_random_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Di, Exception, phalcon, di_exception, zend_ce_exception, NULL, 0); return SUCCESS; } -static PHP_METHOD(Phalcon_Encryption_Security_Random, base58) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Di_FactoryDefault) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *len_param = NULL, _0, _1, _2; - zend_long len, ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Di, FactoryDefault, phalcon, di_factorydefault, phalcon_di_di_ce, phalcon_di_factorydefault_method_entry, 0); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_LONG_OR_NULL(len, is_null_true) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &len_param); - if (!len_param) { - len = 0; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"); - ZVAL_LONG(&_1, 58); - ZVAL_LONG(&_2, len); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "base", NULL, 0, &_0, &_1, &_2); - zephir_check_call_status(); - RETURN_MM(); + return SUCCESS; } -static PHP_METHOD(Phalcon_Encryption_Security_Random, base62) +static PHP_METHOD(Phalcon_Di_FactoryDefault, __construct) { + zval _0, _4, _5, _6, _8; + zval filter, _1, _2, _3, _7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *len_param = NULL, _0, _1, _2; - zend_long len, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&filter); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_LONG_OR_NULL(len, is_null_true) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_8); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &len_param); - if (!len_param) { - len = 0; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); - ZVAL_LONG(&_1, 62); - ZVAL_LONG(&_2, len); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "base", NULL, 0, &_0, &_1, &_2); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Encryption_Security_Random, base64) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *len_param = NULL, _0, _1; - zend_long len, ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + ZEPHIR_CALL_PARENT(NULL, phalcon_di_factorydefault_ce, getThis(), "__construct", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&filter); + object_init_ex(&filter, phalcon_filter_filterfactory_ce); + if (zephir_has_constructor(&filter)) { + ZEPHIR_CALL_METHOD(NULL, &filter, "__construct", NULL, 0); + zephir_check_call_status(); + } - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_LONG_OR_NULL(len, is_null_true) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &len_param); - if (!len_param) { - len = 0; - } else { - } - ZVAL_LONG(&_1, len); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "bytes", NULL, 0, &_1); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 20, 0); + ZEPHIR_INIT_VAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Annotations\\Adapter\\Memory"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); zephir_check_call_status(); - ZEPHIR_RETURN_CALL_FUNCTION("base64_encode", NULL, 231, &_0); + zephir_array_update_string(&_0, SL("annotations"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_VAR(&_4); + zephir_create_array(&_4, 2, 0); + add_assoc_stringl_ex(&_4, SL("className"), SL("Phalcon\\Assets\\Manager")); + ZEPHIR_INIT_VAR(&_5); + zephir_create_array(&_5, 1, 0); + ZEPHIR_INIT_VAR(&_6); + zephir_create_array(&_6, 2, 0); + add_assoc_stringl_ex(&_6, SL("type"), SL("service")); + add_assoc_stringl_ex(&_6, SL("name"), SL("tag")); + zephir_array_fast_append(&_5, &_6); + zephir_array_update_string(&_4, SL("arguments"), &_5, PH_COPY | PH_SEPARATE); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_4, &_3); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Encryption_Security_Random, base64Safe) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool padding; - zval *len_param = NULL, *padding_param = NULL, s, _0, _1, _2, _3, _4, _5, _6$$3; - zend_long len, ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&s); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6$$3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_LONG_OR_NULL(len, is_null_true) - Z_PARAM_BOOL(padding) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &len_param, &padding_param); - if (!len_param) { - len = 0; - } else { - } - if (!padding_param) { - padding = 0; - } else { - } - ZVAL_LONG(&_1, len); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "base64", NULL, 0, &_1); + zephir_array_update_string(&_0, SL("assets"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Encryption\\Crypt"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_2, "base64_encode", NULL, 231, &_0); + zephir_array_update_string(&_0, SL("crypt"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Http\\Response\\Cookies"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "+/"); - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, "-_"); - ZEPHIR_CALL_FUNCTION(&s, "strtr", NULL, 5, &_2, &_3, &_4); + zephir_array_update_string(&_0, SL("cookies"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Mvc\\Dispatcher"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_3); - ZVAL_STRING(&_3, "#[^a-z0-9_=-]+#i"); - ZEPHIR_INIT_NVAR(&_4); - ZVAL_STRING(&_4, ""); - ZEPHIR_CALL_FUNCTION(&_5, "preg_replace", NULL, 41, &_3, &_4, &s); + zephir_array_update_string(&_0, SL("dispatcher"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Html\\Escaper"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); zephir_check_call_status(); - ZEPHIR_CPY_WRT(&s, &_5); - if (!(padding)) { - ZEPHIR_INIT_VAR(&_6$$3); - ZVAL_STRING(&_6$$3, "="); - zephir_fast_trim(return_value, &s, &_6$$3, ZEPHIR_TRIM_RIGHT); - RETURN_MM(); - } - RETURN_CCTOR(&s); -} - -static PHP_METHOD(Phalcon_Encryption_Security_Random, bytes) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *len_param = NULL, _0; - zend_long len, ZEPHIR_LAST_CALL_STATUS; - - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(len) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &len_param); - if (!len_param) { - len = 16; - } else { - } - if (len <= 0) { - len = 16; - } - ZVAL_LONG(&_0, len); - ZEPHIR_RETURN_CALL_FUNCTION("random_bytes", NULL, 267, &_0); + zephir_array_update_string(&_0, SL("escaper"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Events\\Manager"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Encryption_Security_Random, hex) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *len_param = NULL, _0, _1, _2, _3; - zend_long len, ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_LONG_OR_NULL(len, is_null_true) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &len_param); - if (!len_param) { - len = 0; - } else { - } - ZVAL_LONG(&_1, len); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "bytes", NULL, 0, &_1); + zephir_array_update_string(&_0, SL("eventsManager"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Flash\\Direct"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "H*"); - ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 268, &_2, &_0); + zephir_array_update_string(&_0, SL("flash"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Flash\\Session"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); zephir_check_call_status(); - ZEPHIR_MAKE_REF(&_3); - ZEPHIR_RETURN_CALL_FUNCTION("array_shift", NULL, 22, &_3); - ZEPHIR_UNREF(&_3); + zephir_array_update_string(&_0, SL("flashSession"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_CALL_METHOD(&_7, &filter, "newinstance", NULL, 94); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Encryption_Security_Random, number) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *len_param = NULL, _0, _1; - zend_long len, ZEPHIR_LAST_CALL_STATUS; - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(len) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &len_param); - if (UNEXPECTED(len <= 0)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_exception_ce, "Input number must be a positive integer", "phalcon/Encryption/Security/Random.zep", 272); - return; - } - ZVAL_LONG(&_0, 0); - ZVAL_LONG(&_1, len); - ZEPHIR_RETURN_CALL_FUNCTION("random_int", NULL, 269, &_0, &_1); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_7, &_3); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Encryption_Security_Random, uuid) -{ - zval ary, _0, _1, _2, _3, _4, _5, _6, _7; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&ary); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZVAL_LONG(&_1, 16); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "bytes", NULL, 0, &_1); + zephir_array_update_string(&_0, SL("filter"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Support\\HelperFactory"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "N1a/n1b/n1c/n1d/n1e/N1f"); - ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 268, &_2, &_0); + zephir_array_update_string(&_0, SL("helper"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Mvc\\Model\\Manager"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&ary, "array_values", NULL, 14, &_3); + zephir_array_update_string(&_0, SL("modelsManager"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Mvc\\Model\\MetaData\\Memory"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); zephir_check_call_status(); - zephir_array_fetch_long(&_4, &ary, 2, PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/Random.zep", 311); + zephir_array_update_string(&_0, SL("modelsMetadata"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); ZEPHIR_INIT_NVAR(&_2); - ZVAL_LONG(&_2, ((((int) (zephir_get_numberval(&_4)) & 0x0fff)) | 0x4000)); - zephir_array_update_long(&ary, 2, &_2, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_fetch_long(&_5, &ary, 3, PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/Random.zep", 312); - ZEPHIR_INIT_VAR(&_6); - ZVAL_LONG(&_6, ((((int) (zephir_get_numberval(&_5)) & 0x3fff)) | 0x8000)); - zephir_array_update_long(&ary, 3, &_6, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); - ZEPHIR_INIT_VAR(&_7); - ZVAL_STRING(&_7, "%08x-%04x-%04x-%04x-%04x%08x"); - ZEPHIR_MAKE_REF(&ary); - ZEPHIR_CALL_FUNCTION(NULL, "array_unshift", NULL, 270, &ary, &_7); - ZEPHIR_UNREF(&ary); + ZVAL_STRING(&_2, "Phalcon\\Http\\Request"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_7); - ZVAL_STRING(&_7, "sprintf"); - ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_7, &ary); + zephir_array_update_string(&_0, SL("request"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Http\\Response"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Encryption_Security_Random, base) -{ - unsigned char _7$$3, _10$$5; - double _4$$3, _8$$5; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_6 = NULL; - zend_long base, ZEPHIR_LAST_CALL_STATUS; - zval *alphabet_param = NULL, *base_param = NULL, *n = NULL, n_sub, __$null, bytes, idx, _0, _1, *_2, _3, _5$$4, _9$$6; - zval alphabet, byteString; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&alphabet); - ZVAL_UNDEF(&byteString); - ZVAL_UNDEF(&n_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&bytes); - ZVAL_UNDEF(&idx); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_9$$6); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(alphabet) - Z_PARAM_LONG(base) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(n) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &alphabet_param, &base_param, &n); - zephir_get_strval(&alphabet, alphabet_param); - if (!n) { - n = &n_sub; - n = &__$null; - } - ZEPHIR_INIT_VAR(&byteString); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "bytes", NULL, 0, n); + zephir_array_update_string(&_0, SL("response"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Mvc\\Router"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "C*"); - ZEPHIR_CALL_FUNCTION(&bytes, "unpack", NULL, 268, &_1, &_0); + zephir_array_update_string(&_0, SL("router"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Encryption\\Security"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); zephir_check_call_status(); - zephir_is_iterable(&bytes, 0, "phalcon/Encryption/Security/Random.zep", 351); - if (Z_TYPE_P(&bytes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&bytes), _2) - { - ZEPHIR_INIT_NVAR(&idx); - ZVAL_COPY(&idx, _2); - _4$$3 = zephir_safe_mod_zval_long(&idx, 64); - ZEPHIR_INIT_NVAR(&idx); - ZVAL_DOUBLE(&idx, _4$$3); - if (ZEPHIR_GE_LONG(&idx, base)) { - ZVAL_LONG(&_5$$4, (base - 1)); - ZEPHIR_CALL_METHOD(&idx, this_ptr, "number", &_6, 0, &_5$$4); - zephir_check_call_status(); - } - _7$$3 = ZEPHIR_STRING_OFFSET(&alphabet, zephir_get_intval(&idx)); - zephir_concat_self_char(&byteString, _7$$3); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &bytes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &bytes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3)) { - break; - } - ZEPHIR_CALL_METHOD(&idx, &bytes, "current", NULL, 0); - zephir_check_call_status(); - _8$$5 = zephir_safe_mod_zval_long(&idx, 64); - ZEPHIR_INIT_NVAR(&idx); - ZVAL_DOUBLE(&idx, _8$$5); - if (ZEPHIR_GE_LONG(&idx, base)) { - ZVAL_LONG(&_9$$6, (base - 1)); - ZEPHIR_CALL_METHOD(&idx, this_ptr, "number", &_6, 0, &_9$$6); - zephir_check_call_status(); - } - _10$$5 = ZEPHIR_STRING_OFFSET(&alphabet, zephir_get_intval(&idx)); - zephir_concat_self_char(&byteString, _10$$5); - ZEPHIR_CALL_METHOD(NULL, &bytes, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&idx); - RETURN_CTOR(&byteString); + zephir_array_update_string(&_0, SL("security"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_5); + zephir_create_array(&_5, 2, 0); + add_assoc_stringl_ex(&_5, SL("className"), SL("Phalcon\\Html\\TagFactory")); + ZEPHIR_INIT_NVAR(&_6); + zephir_create_array(&_6, 1, 0); + ZEPHIR_INIT_VAR(&_8); + zephir_create_array(&_8, 2, 0); + add_assoc_stringl_ex(&_8, SL("type"), SL("service")); + add_assoc_stringl_ex(&_8, SL("name"), SL("escaper")); + zephir_array_fast_append(&_6, &_8); + zephir_array_update_string(&_5, SL("arguments"), &_6, PH_COPY | PH_SEPARATE); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_5, &_3); + zephir_check_call_status(); + zephir_array_update_string(&_0, SL("tag"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Mvc\\Model\\Transaction\\Manager"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); + zephir_check_call_status(); + zephir_array_update_string(&_0, SL("transactionManager"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Mvc\\Url"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); + zephir_check_call_status(); + zephir_array_update_string(&_0, SL("url"), &_1, PH_COPY | PH_SEPARATE); + zephir_update_property_zval(this_ptr, ZEND_STRL("services"), &_0); + ZEPHIR_MM_RESTORE(); } @@ -19540,145 +19720,120 @@ static PHP_METHOD(Phalcon_Encryption_Security_Random, base) -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Builder) +ZEPHIR_INIT_CLASS(Phalcon_Di_InitializationAwareInterface) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT, Builder, phalcon, encryption_security_jwt_builder, phalcon_encryption_security_jwt_builder_method_entry, 0); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Di, InitializationAwareInterface, phalcon, di_initializationawareinterface, phalcon_di_initializationawareinterface_method_entry); - zend_declare_property_null(phalcon_encryption_security_jwt_builder_ce, SL("claims"), ZEND_ACC_PRIVATE); - zend_declare_property_null(phalcon_encryption_security_jwt_builder_ce, SL("encode"), ZEND_ACC_PRIVATE); - zend_declare_property_null(phalcon_encryption_security_jwt_builder_ce, SL("jose"), ZEND_ACC_PRIVATE); - zend_declare_property_null(phalcon_encryption_security_jwt_builder_ce, SL("passphrase"), ZEND_ACC_PRIVATE); - zend_declare_property_null(phalcon_encryption_security_jwt_builder_ce, SL("signer"), ZEND_ACC_PRIVATE); return SUCCESS; } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *signer, signer_sub, _0, _1, _2, _3, _4; - zval *this_ptr = getThis(); +ZEPHIR_DOC_METHOD(Phalcon_Di_InitializationAwareInterface, initialize); - ZVAL_UNDEF(&signer_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(signer, phalcon_encryption_security_jwt_signer_signerinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &signer); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("signer"), signer); - ZEPHIR_INIT_VAR(&_0); - object_init_ex(&_0, phalcon_support_helper_json_encode_ce); - if (zephir_has_constructor(&_0)) { - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); - zephir_check_call_status(); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("encode"), &_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("jose"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_2, this_ptr, ZEND_STRL("signer"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_3, &_2, "getalgheader", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, "alg"); - ZEPHIR_CALL_METHOD(NULL, &_1, "set", NULL, 0, &_4, &_3); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, init) -{ - zval _2; - zval _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); +#ifdef HAVE_CONFIG_H +#endif - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, ""); - zephir_update_property_zval(this_ptr, ZEND_STRL("passphrase"), &_0); - ZEPHIR_INIT_NVAR(&_0); - object_init_ex(&_0, phalcon_support_collection_ce); - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 23); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("claims"), &_0); - ZEPHIR_INIT_VAR(&_1); - object_init_ex(&_1, phalcon_support_collection_ce); - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 2, 0); - add_assoc_stringl_ex(&_2, SL("typ"), SL("JWT")); - add_assoc_stringl_ex(&_2, SL("alg"), SL("none")); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 23, &_2); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("jose"), &_1); - RETURN_THIS(); + + + +ZEPHIR_INIT_CLASS(Phalcon_Di_Injectable) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Di, Injectable, phalcon, di_injectable, zend_standard_class_def, phalcon_di_injectable_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + zend_declare_property_null(phalcon_di_injectable_ce, SL("container"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_di_injectable_ce, 1, phalcon_di_injectionawareinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, addClaim) +static PHP_METHOD(Phalcon_Di_Injectable, __get) { + zval _2$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, *value, value_sub, _0; - zval name; + zval *propertyName_param = NULL, container, service, _0, _1$$4, _3$$4, _4$$4; + zval propertyName, _5; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&propertyName); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&service); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_ZVAL(value) + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_2$$4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(propertyName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &value); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + zephir_fetch_params(1, 1, 0, &propertyName_param); + if (UNEXPECTED(Z_TYPE_P(propertyName_param) != IS_STRING && Z_TYPE_P(propertyName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'propertyName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + if (EXPECTED(Z_TYPE_P(propertyName_param) == IS_STRING)) { + zephir_get_strval(&propertyName, propertyName_param); } else { - ZEPHIR_INIT_VAR(&name); + ZEPHIR_INIT_VAR(&propertyName); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &name, value); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getdi", NULL, 0); zephir_check_call_status(); - RETURN_THIS(); + ZEPHIR_CPY_WRT(&container, &_0); + if (ZEPHIR_IS_STRING_IDENTICAL(&propertyName, "di")) { + zephir_update_property_zval(this_ptr, ZEND_STRL("di"), &container); + RETURN_CCTOR(&container); + } + if (ZEPHIR_IS_STRING_IDENTICAL(&propertyName, "persistent")) { + ZEPHIR_INIT_VAR(&_2$$4); + zephir_create_array(&_2$$4, 2, 0); + ZEPHIR_INIT_VAR(&_3$$4); + zephir_get_class(&_3$$4, this_ptr, 0); + zephir_array_fast_append(&_2$$4, &_3$$4); + zephir_array_fast_append(&_2$$4, &container); + ZEPHIR_INIT_NVAR(&_3$$4); + ZVAL_STRING(&_3$$4, "sessionBag"); + ZEPHIR_CALL_METHOD(&_1$$4, &container, "get", NULL, 0, &_3$$4, &_2$$4); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("persistent"), &_1$$4); + zephir_memory_observe(&_4$$4); + zephir_read_property(&_4$$4, this_ptr, ZEND_STRL("persistent"), PH_NOISY_CC); + RETURN_CCTOR(&_4$$4); + } + ZEPHIR_CALL_METHOD(&_0, &container, "has", NULL, 0, &propertyName); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + ZEPHIR_CALL_METHOD(&service, &container, "getshared", NULL, 0, &propertyName); + zephir_check_call_status(); + zephir_update_property_zval_zval(this_ptr, &propertyName, &service); + RETURN_CCTOR(&service); + } + ZEPHIR_INIT_VAR(&_5); + ZEPHIR_CONCAT_SV(&_5, "Access to undefined property ", &propertyName); + ZEPHIR_CALL_FUNCTION(NULL, "trigger_error", NULL, 7, &_5); + zephir_check_call_status(); + RETURN_MM_NULL(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, addHeader) +static PHP_METHOD(Phalcon_Di_Injectable, __isset) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, *value, value_sub, _0; + zval *name_param = NULL, _0; zval name; zval *this_ptr = getThis(); ZVAL_UNDEF(&name); - ZVAL_UNDEF(&value_sub); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) + ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(name) - Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &value); + zephir_fetch_params(1, 1, 0, &name_param); if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); RETURN_MM_NULL(); @@ -19688,699 +19843,432 @@ static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, addHeader) } else { ZEPHIR_INIT_VAR(&name); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("jose"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &name, value); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getdi", NULL, 0); zephir_check_call_status(); - RETURN_THIS(); + ZEPHIR_RETURN_CALL_METHOD(&_0, "has", NULL, 0, &name); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getAudience) +static PHP_METHOD(Phalcon_Di_Injectable, getDI) { - zval _0, _1; + zval container, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); + ZVAL_UNDEF(&container); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "aud"); - ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1); - zephir_check_call_status(); - RETURN_MM(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_0); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "A dependency injection container is required to access internal services", "phalcon/Di/Injectable.zep", 126); + return; + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdi", NULL, 0, &container); + zephir_check_call_status(); + } + RETURN_CCTOR(&container); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getClaims) +static PHP_METHOD(Phalcon_Di_Injectable, setDI) { - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *container, container_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "toarray", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + ZVAL_UNDEF(&container_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &container); + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getContentType) -{ - zval _0, _1, _2, _3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("jose"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "cty"); - ZVAL_NULL(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "string"); - ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getExpirationTime) -{ - zval _0, _1, _2, _3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); +#ifdef HAVE_CONFIG_H +#endif - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "exp"); - ZVAL_NULL(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "int"); - ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getHeaders) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("jose"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "toarray", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); +ZEPHIR_INIT_CLASS(Phalcon_Di_InjectionAwareInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Di, InjectionAwareInterface, phalcon, di_injectionawareinterface, phalcon_di_injectionawareinterface_method_entry); + + return SUCCESS; } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getId) -{ - zval _0, _1, _2, _3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); +ZEPHIR_DOC_METHOD(Phalcon_Di_InjectionAwareInterface, setDI); +ZEPHIR_DOC_METHOD(Phalcon_Di_InjectionAwareInterface, getDI); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "jti"); - ZVAL_NULL(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "string"); - ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getIssuedAt) -{ - zval _0, _1, _2, _3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); +#ifdef HAVE_CONFIG_H +#endif - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "iat"); - ZVAL_NULL(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "int"); - ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getIssuer) -{ - zval _0, _1, _2, _3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "iss"); - ZVAL_NULL(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "string"); - ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); - zephir_check_call_status(); - RETURN_MM(); +ZEPHIR_INIT_CLASS(Phalcon_Di_Service) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Di, Service, phalcon, di_service, phalcon_di_service_method_entry, 0); + + zend_declare_property_null(phalcon_di_service_ce, SL("definition"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_di_service_ce, SL("resolved"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_di_service_ce, SL("shared"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_di_service_ce, SL("sharedInstance"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_di_service_ce, 1, phalcon_di_serviceinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getNotBefore) +static PHP_METHOD(Phalcon_Di_Service, __construct) { - zval _0, _1, _2, _3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool shared; + zval *definition, definition_sub, *shared_param = NULL, __$true, __$false; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "nbf"); - ZVAL_NULL(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "int"); - ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); - zephir_check_call_status(); - RETURN_MM(); + ZVAL_UNDEF(&definition_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(definition) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(shared) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 1, &definition, &shared_param); + if (!shared_param) { + shared = 0; + } else { + } + zephir_update_property_zval(this_ptr, ZEND_STRL("definition"), definition); + if (shared) { + zephir_update_property_zval(this_ptr, ZEND_STRL("shared"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("shared"), &__$false); + } } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getSubject) +static PHP_METHOD(Phalcon_Di_Service, getDefinition) { - zval _0, _1, _2, _3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "sub"); - ZVAL_NULL(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "string"); - ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MEMBER(getThis(), "definition"); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getToken) +static PHP_METHOD(Phalcon_Di_Service, getParameter) { - zval claims, encodedClaims, encodedHeaders, encodedSignature, headers, signature, signatureHash, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *position_param = NULL, arguments, parameter, _0, _1; + zend_long position; zval *this_ptr = getThis(); - ZVAL_UNDEF(&claims); - ZVAL_UNDEF(&encodedClaims); - ZVAL_UNDEF(&encodedHeaders); - ZVAL_UNDEF(&encodedSignature); - ZVAL_UNDEF(&headers); - ZVAL_UNDEF(&signature); - ZVAL_UNDEF(&signatureHash); + ZVAL_UNDEF(&arguments); + ZVAL_UNDEF(¶meter); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_11); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(position) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("passphrase"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_EMPTY(&_0)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_validatorexception_ce, "Invalid passphrase (empty)", "phalcon/Encryption/Security/JWT/Builder.zep", 220); + zephir_fetch_params(1, 1, 0, &position_param); + zephir_memory_observe(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("definition"), PH_NOISY_CC); + if (UNEXPECTED(Z_TYPE_P(&_0) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "Definition must be an array to obtain its parameters", "phalcon/Di/Service.zep", 80); return; } - zephir_read_property(&_1, this_ptr, ZEND_STRL("encode"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "getclaims", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_2, &_1, "__invoke", NULL, 0, &_3); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&encodedClaims, this_ptr, "encodeurl", NULL, 256, &_2); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&claims); - object_init_ex(&claims, phalcon_encryption_security_jwt_token_item_ce); - ZEPHIR_CALL_METHOD(&_4, this_ptr, "getclaims", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &claims, "__construct", NULL, 257, &_4, &encodedClaims); - zephir_check_call_status(); - zephir_read_property(&_5, this_ptr, ZEND_STRL("encode"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_7, this_ptr, "getheaders", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_6, &_5, "__invoke", NULL, 0, &_7); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&encodedHeaders, this_ptr, "encodeurl", NULL, 256, &_6); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&headers); - object_init_ex(&headers, phalcon_encryption_security_jwt_token_item_ce); - ZEPHIR_CALL_METHOD(&_8, this_ptr, "getheaders", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &headers, "__construct", NULL, 257, &_8, &encodedHeaders); - zephir_check_call_status(); - zephir_read_property(&_9, this_ptr, ZEND_STRL("signer"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_10); - ZEPHIR_CONCAT_VSV(&_10, &encodedHeaders, ".", &encodedClaims); - zephir_read_property(&_11, this_ptr, ZEND_STRL("passphrase"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&signatureHash, &_9, "sign", NULL, 0, &_10, &_11); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&encodedSignature, this_ptr, "encodeurl", NULL, 256, &signatureHash); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&signature); - object_init_ex(&signature, phalcon_encryption_security_jwt_token_signature_ce); - ZEPHIR_CALL_METHOD(NULL, &signature, "__construct", NULL, 258, &signatureHash, &encodedSignature); - zephir_check_call_status(); - object_init_ex(return_value, phalcon_encryption_security_jwt_token_token_ce); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 259, &headers, &claims, &signature); - zephir_check_call_status(); - RETURN_MM(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("definition"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_string_fetch(&arguments, &_1, SL("arguments"), 1)) { + if (zephir_array_isset_long_fetch(¶meter, &arguments, position, 1)) { + RETURN_CTOR(¶meter); + } + } + RETURN_MM_NULL(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getPassphrase) +static PHP_METHOD(Phalcon_Di_Service, isResolved) { - RETURN_MEMBER(getThis(), "passphrase"); + RETURN_MEMBER(getThis(), "resolved"); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setAudience) +static PHP_METHOD(Phalcon_Di_Service, isShared) { - zend_bool _0; + + RETURN_MEMBER(getThis(), "shared"); +} + +static PHP_METHOD(Phalcon_Di_Service, resolve) +{ + zend_class_entry *_6$$12; + zend_bool found = 0, _1, _4$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *audience, audience_sub, aud, _1; + zval *parameters = NULL, parameters_sub, *container = NULL, container_sub, __$true, __$false, __$null, definition, instance, builder, _0, _2, _3, _5$$12, _7$$19; zval *this_ptr = getThis(); - ZVAL_UNDEF(&audience_sub); - ZVAL_UNDEF(&aud); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(audience) + ZVAL_UNDEF(¶meters_sub); + ZVAL_UNDEF(&container_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&instance); + ZVAL_UNDEF(&builder); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5$$12); + ZVAL_UNDEF(&_7$$19); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(parameters) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(container, phalcon_di_diinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &audience); - _0 = Z_TYPE_P(audience) != IS_STRING; - if (_0) { - _0 = Z_TYPE_P(audience) != IS_ARRAY; - } - if (_0) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_validatorexception_ce, "Invalid Audience", "phalcon/Encryption/Security/JWT/Builder.zep", 270); + zephir_fetch_params(1, 0, 2, ¶meters, &container); + if (!parameters) { + parameters = ¶meters_sub; + parameters = &__$null; + } + if (!container) { + container = &container_sub; + container = &__$null; + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("shared"), PH_NOISY_CC | PH_READONLY); + _1 = zephir_is_true(&_0); + if (_1) { + zephir_read_property(&_2, this_ptr, ZEND_STRL("sharedInstance"), PH_NOISY_CC | PH_READONLY); + _1 = Z_TYPE_P(&_2) != IS_NULL; + } + if (_1) { + RETURN_MM_MEMBER(getThis(), "sharedInstance"); + } + found = 1; + ZEPHIR_INIT_VAR(&instance); + ZVAL_NULL(&instance); + zephir_read_property(&_3, this_ptr, ZEND_STRL("definition"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&definition, &_3); + if (Z_TYPE_P(&definition) == IS_STRING) { + if (zephir_class_exists(&definition, 1)) { + _4$$5 = Z_TYPE_P(parameters) == IS_ARRAY; + if (_4$$5) { + _4$$5 = ((zephir_fast_count_int(parameters)) ? 1 : 0); + } + if (_4$$5) { + ZEPHIR_INIT_NVAR(&instance); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&instance, &definition, parameters); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&instance); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&instance, &definition); + zephir_check_call_status(); + } + } else { + found = 0; + } + } else { + if (Z_TYPE_P(&definition) == IS_OBJECT) { + if (zephir_is_instance_of(&definition, SL("Closure"))) { + if (Z_TYPE_P(container) != IS_NULL) { + _6$$12 = zephir_fetch_class_str_ex(SL("Closure"), ZEND_FETCH_CLASS_AUTO); + ZEPHIR_CALL_CE_STATIC(&_5$$12, _6$$12, "bind", NULL, 0, &definition, container); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&definition, &_5$$12); + } + if (Z_TYPE_P(parameters) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&instance); + ZEPHIR_CALL_USER_FUNC_ARRAY(&instance, &definition, parameters); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&instance); + ZEPHIR_CALL_USER_FUNC(&instance, &definition); + zephir_check_call_status(); + } + } else { + ZEPHIR_CPY_WRT(&instance, &definition); + } + } else { + if (Z_TYPE_P(&definition) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&builder); + object_init_ex(&builder, phalcon_di_service_builder_ce); + if (zephir_has_constructor(&builder)) { + ZEPHIR_CALL_METHOD(NULL, &builder, "__construct", NULL, 0); + zephir_check_call_status(); + } + + ZEPHIR_CALL_METHOD(&instance, &builder, "build", NULL, 222, container, &definition, parameters); + zephir_check_call_status(); + } else { + found = 0; + } + } + } + if (UNEXPECTED(found == 0)) { + ZEPHIR_INIT_VAR(&_7$$19); + object_init_ex(&_7$$19, phalcon_di_exception_serviceresolutionexception_ce); + ZEPHIR_CALL_METHOD(NULL, &_7$$19, "__construct", NULL, 33); + zephir_check_call_status(); + zephir_throw_exception_debug(&_7$$19, "phalcon/Di/Service.zep", 195); + ZEPHIR_MM_RESTORE(); return; } - if (Z_TYPE_P(audience) == IS_STRING) { - ZEPHIR_INIT_VAR(&aud); - zephir_create_array(&aud, 1, 0); - zephir_array_fast_append(&aud, audience); + zephir_read_property(&_3, this_ptr, ZEND_STRL("shared"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_3)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("sharedInstance"), &instance); + } + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("resolved"), &__$true); } else { - ZEPHIR_CPY_WRT(&aud, audience); + zephir_update_property_zval(this_ptr, ZEND_STRL("resolved"), &__$false); } - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "aud"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_1, &aud); - zephir_check_call_status(); - RETURN_MM(); + RETURN_CCTOR(&instance); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setContentType) +static PHP_METHOD(Phalcon_Di_Service, setDefinition) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *contentType_param = NULL, _0, _1; - zval contentType; + zval *definition, definition_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&contentType); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&definition_sub); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(contentType) + Z_PARAM_ZVAL(definition) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &contentType_param); - zephir_get_strval(&contentType, contentType_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("jose"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "cty"); - ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &_1, &contentType); - zephir_check_call_status(); - RETURN_THIS(); + zephir_fetch_params_without_memory_grow(1, 0, &definition); + zephir_update_property_zval(this_ptr, ZEND_STRL("definition"), definition); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setExpirationTime) +static PHP_METHOD(Phalcon_Di_Service, setParameter) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *timestamp_param = NULL, _0, _1, _2; - zend_long timestamp, ZEPHIR_LAST_CALL_STATUS; + zval parameter; + zval *position_param = NULL, *parameter_param = NULL, arguments, _0, _1, _3, _2$$5; + zend_long position; zval *this_ptr = getThis(); + ZVAL_UNDEF(&arguments); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(timestamp) + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(¶meter); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_LONG(position) + Z_PARAM_ARRAY(parameter) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, ×tamp_param); - ZEPHIR_INIT_VAR(&_0); - zephir_time(&_0); - if (ZEPHIR_GT_LONG(&_0, timestamp)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_validatorexception_ce, "Invalid Expiration Time", "phalcon/Encryption/Security/JWT/Builder.zep", 315); + zephir_fetch_params(1, 2, 0, &position_param, ¶meter_param); + ZEPHIR_OBS_COPY_OR_DUP(¶meter, parameter_param); + zephir_memory_observe(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("definition"), PH_NOISY_CC); + if (UNEXPECTED(Z_TYPE_P(&_0) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "Definition must be an array to update its parameters", "phalcon/Di/Service.zep", 228); return; } - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "exp"); - ZVAL_LONG(&_2, timestamp); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_1, &_2); - zephir_check_call_status(); - RETURN_MM(); + zephir_memory_observe(&arguments); + zephir_read_property(&_1, this_ptr, ZEND_STRL("definition"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_string_fetch(&arguments, &_1, SL("arguments"), 0)) { + zephir_array_update_long(&arguments, position, ¶meter, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + } else { + ZEPHIR_INIT_VAR(&_2$$5); + zephir_create_array(&_2$$5, 1, 0); + zephir_array_update_long(&_2$$5, position, ¶meter, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); + ZEPHIR_CPY_WRT(&arguments, &_2$$5); + } + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "arguments"); + zephir_update_property_array(this_ptr, SL("definition"), &_3, &arguments); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setId) +static PHP_METHOD(Phalcon_Di_Service, setShared) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *id_param = NULL, _0; - zval id; + zval *shared_param = NULL, __$true, __$false; + zend_bool shared; zval *this_ptr = getThis(); - ZVAL_UNDEF(&id); - ZVAL_UNDEF(&_0); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(id) + Z_PARAM_BOOL(shared) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &id_param); - if (UNEXPECTED(Z_TYPE_P(id_param) != IS_STRING && Z_TYPE_P(id_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'id' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(id_param) == IS_STRING)) { - zephir_get_strval(&id, id_param); + zephir_fetch_params_without_memory_grow(1, 0, &shared_param); + if (shared) { + zephir_update_property_zval(this_ptr, ZEND_STRL("shared"), &__$true); } else { - ZEPHIR_INIT_VAR(&id); + zephir_update_property_zval(this_ptr, ZEND_STRL("shared"), &__$false); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "jti"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_0, &id); - zephir_check_call_status(); - RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setIssuedAt) +static PHP_METHOD(Phalcon_Di_Service, setSharedInstance) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *timestamp_param = NULL, _0, _1; - zend_long timestamp, ZEPHIR_LAST_CALL_STATUS; + zval *sharedInstance, sharedInstance_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&sharedInstance_sub); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(timestamp) + Z_PARAM_ZVAL(sharedInstance) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, ×tamp_param); - if (UNEXPECTED(Z_TYPE_P(timestamp_param) != IS_LONG)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'timestamp' must be of the type int")); - RETURN_MM_NULL(); - } - timestamp = Z_LVAL_P(timestamp_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "iat"); - ZVAL_LONG(&_1, timestamp); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params_without_memory_grow(1, 0, &sharedInstance); + zephir_update_property_zval(this_ptr, ZEND_STRL("sharedInstance"), sharedInstance); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setIssuer) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *issuer_param = NULL, _0; - zval issuer; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&issuer); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(issuer) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &issuer_param); - if (UNEXPECTED(Z_TYPE_P(issuer_param) != IS_STRING && Z_TYPE_P(issuer_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'issuer' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(issuer_param) == IS_STRING)) { - zephir_get_strval(&issuer, issuer_param); - } else { - ZEPHIR_INIT_VAR(&issuer); - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "iss"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_0, &issuer); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setNotBefore) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *timestamp_param = NULL, _0, _1, _2; - zend_long timestamp, ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(timestamp) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, ×tamp_param); - if (UNEXPECTED(Z_TYPE_P(timestamp_param) != IS_LONG)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'timestamp' must be of the type int")); - RETURN_MM_NULL(); - } - timestamp = Z_LVAL_P(timestamp_param); - ZEPHIR_INIT_VAR(&_0); - zephir_time(&_0); - if (ZEPHIR_LT_LONG(&_0, timestamp)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_validatorexception_ce, "Invalid Not Before", "phalcon/Encryption/Security/JWT/Builder.zep", 389); - return; - } - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "nbf"); - ZVAL_LONG(&_2, timestamp); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_1, &_2); - zephir_check_call_status(); - RETURN_MM(); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setSubject) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *subject_param = NULL, _0; - zval subject; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&subject); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(subject) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &subject_param); - if (UNEXPECTED(Z_TYPE_P(subject_param) != IS_STRING && Z_TYPE_P(subject_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'subject' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(subject_param) == IS_STRING)) { - zephir_get_strval(&subject, subject_param); - } else { - ZEPHIR_INIT_VAR(&subject); - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "sub"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_0, &subject); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setPassphrase) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *passphrase_param = NULL, _0, _1, _2, _3; - zval passphrase; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&passphrase); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(passphrase) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &passphrase_param); - if (UNEXPECTED(Z_TYPE_P(passphrase_param) != IS_STRING && Z_TYPE_P(passphrase_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'passphrase' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(passphrase_param) == IS_STRING)) { - zephir_get_strval(&passphrase, passphrase_param); - } else { - ZEPHIR_INIT_VAR(&passphrase); - } - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "/(?=^.{16,}$)((?=.*\\d)|(?=.*\\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/"); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "/(?=^.{16,}$)((?=.*\\d)|(?=.*\\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/"); - zephir_preg_match(&_2, &_3, &passphrase, &_0, 0, 0 , 0 ); - if (!(zephir_is_true(&_2))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_validatorexception_ce, "Invalid passphrase (too weak)", "phalcon/Encryption/Security/JWT/Builder.zep", 427); - return; - } - zephir_update_property_zval(this_ptr, ZEND_STRL("passphrase"), &passphrase); - RETURN_THIS(); -} -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setClaim) +ZEPHIR_INIT_CLASS(Phalcon_Di_ServiceInterface) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, *value, value_sub, _0; - zval name; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Di, ServiceInterface, phalcon, di_serviceinterface, phalcon_di_serviceinterface_method_entry); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &value); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &name, value); - zephir_check_call_status(); - RETURN_THIS(); + return SUCCESS; } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, encodeUrl) +ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, getDefinition); +ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, getParameter); +ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, isResolved); +ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, isShared); +ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, resolve); +ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, setDefinition); +ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, setParameter); +ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, setShared); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Di_ServiceProviderInterface) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL, _0, _1, _2, _3, _4; - zval input; + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Di, ServiceProviderInterface, phalcon, di_serviceproviderinterface, phalcon_di_serviceproviderinterface_method_entry); - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(input) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &input_param); - if (UNEXPECTED(Z_TYPE_P(input_param) != IS_STRING && Z_TYPE_P(input_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'input' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(input_param) == IS_STRING)) { - zephir_get_strval(&input, input_param); - } else { - ZEPHIR_INIT_VAR(&input); - } - ZEPHIR_CALL_FUNCTION(&_0, "base64_encode", NULL, 231, &input); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "+/"); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "-_"); - ZEPHIR_CALL_FUNCTION(&_3, "strtr", NULL, 5, &_0, &_1, &_2); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "="); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, ""); - ZEPHIR_INIT_VAR(&_4); - zephir_fast_str_replace(&_4, &_1, &_2, &_3); - RETURN_CCTOR(&_4); + return SUCCESS; } +ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceProviderInterface, register); @@ -20391,533 +20279,1215 @@ static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, encodeUrl) -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Validator) +ZEPHIR_INIT_CLASS(Phalcon_Di_Exception_ServiceResolutionException) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT, Validator, phalcon, encryption_security_jwt_validator, phalcon_encryption_security_jwt_validator_method_entry, 0); - - zend_declare_property_null(phalcon_encryption_security_jwt_validator_ce, SL("claims"), ZEND_ACC_PRIVATE); - zend_declare_property_null(phalcon_encryption_security_jwt_validator_ce, SL("errors"), ZEND_ACC_PRIVATE); - zend_declare_property_long(phalcon_encryption_security_jwt_validator_ce, SL("timeShift"), 0, ZEND_ACC_PRIVATE); - zend_declare_property_null(phalcon_encryption_security_jwt_validator_ce, SL("token"), ZEND_ACC_PRIVATE); - phalcon_encryption_security_jwt_validator_ce->create_object = zephir_init_properties_Phalcon_Encryption_Security_JWT_Validator; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Di\\Exception, ServiceResolutionException, phalcon, di_exception_serviceresolutionexception, phalcon_di_exception_ce, NULL, 0); return SUCCESS; } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, __construct) -{ - zval _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long timeShift; - zval *token, token_sub, *timeShift_param = NULL, __$null, now, _0; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&token_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&now); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(token, phalcon_encryption_security_jwt_token_token_ce) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(timeShift) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &token, &timeShift_param); - if (!timeShift_param) { - timeShift = 0; - } else { - } - ZEPHIR_INIT_VAR(&now); - zephir_time(&now); - zephir_update_property_zval(this_ptr, ZEND_STRL("token"), token); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, timeShift); - zephir_update_property_zval(this_ptr, ZEND_STRL("timeShift"), &_0); - ZEPHIR_INIT_VAR(&_1); - zephir_create_array(&_1, 7, 0); - zephir_array_update_string(&_1, SL("aud"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_1, SL("exp"), &now, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_1, SL("jti"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_1, SL("iat"), &now, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_1, SL("iss"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_1, SL("nbf"), &now, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_1, SL("sub"), &__$null, PH_COPY | PH_SEPARATE); - zephir_update_property_zval(this_ptr, ZEND_STRL("claims"), &_1); - ZEPHIR_MM_RESTORE(); -} -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, getErrors) -{ - RETURN_MEMBER(getThis(), "errors"); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, get) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *claim_param = NULL, _0, _1$$3, _2$$3; - zval claim; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&claim); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(claim) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &claim_param); - zephir_get_strval(&claim, claim_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset(&_0, &claim)) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_2$$3, &_1$$3, &claim, PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/JWT/Validator.zep", 87); - RETURN_CTOR(&_2$$3); - } - RETURN_MM_NULL(); -} -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, set) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *claim_param = NULL, *value, value_sub; - zval claim; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&claim); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(claim) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &claim_param, &value); - zephir_get_strval(&claim, claim_param); - zephir_update_property_array(this_ptr, SL("claims"), &claim, value); - RETURN_THIS(); -} -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, setToken) +ZEPHIR_INIT_CLASS(Phalcon_Di_Service_Builder) { - zval *token, token_sub; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS(Phalcon\\Di\\Service, Builder, phalcon, di_service_builder, phalcon_di_service_builder_method_entry, 0); - ZVAL_UNDEF(&token_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(token, phalcon_encryption_security_jwt_token_token_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &token); - zephir_update_property_zval(this_ptr, ZEND_STRL("token"), token); - RETURN_THISW(); + return SUCCESS; } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateAudience) +static PHP_METHOD(Phalcon_Di_Service_Builder, build) { - zend_bool _0; + zval _11$$17, _12$$17, _22$$23, _23$$23; + zend_string *_4$$10, *_30$$25; + zend_ulong _3$$10, _29$$25; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_7 = NULL, *_38 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *audience = NULL, audience_sub, item, tokenAudience, _2, _3, _4, _5, *_6, _7, _1$$4, _8$$6, _9$$8; + zval definition; + zval *container, container_sub, *definition_param = NULL, *parameters = NULL, parameters_sub, __$null, className, arguments, paramCalls, methodPosition, method, methodName, methodCall, instance, propertyPosition, property, propertyName, propertyValue, _0$$8, *_1$$10, _2$$10, _5$$14, _6$$14, _8$$15, _9$$15, _10$$17, _13$$18, _14$$18, _15$$13, _16$$20, _17$$20, _18$$21, _19$$21, _20$$19, _26$$19, _21$$23, _24$$24, _25$$24, *_27$$25, _28$$25, _31$$29, _32$$29, _33$$30, _34$$30, _35$$31, _36$$31, _37$$28, _39$$33, _40$$33, _41$$34, _42$$34, _43$$35, _44$$35, _45$$32; zval *this_ptr = getThis(); - ZVAL_UNDEF(&audience_sub); - ZVAL_UNDEF(&item); - ZVAL_UNDEF(&tokenAudience); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_8$$6); - ZVAL_UNDEF(&_9$$8); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(audience) + ZVAL_UNDEF(&container_sub); + ZVAL_UNDEF(¶meters_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&arguments); + ZVAL_UNDEF(¶mCalls); + ZVAL_UNDEF(&methodPosition); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&methodName); + ZVAL_UNDEF(&methodCall); + ZVAL_UNDEF(&instance); + ZVAL_UNDEF(&propertyPosition); + ZVAL_UNDEF(&property); + ZVAL_UNDEF(&propertyName); + ZVAL_UNDEF(&propertyValue); + ZVAL_UNDEF(&_0$$8); + ZVAL_UNDEF(&_2$$10); + ZVAL_UNDEF(&_5$$14); + ZVAL_UNDEF(&_6$$14); + ZVAL_UNDEF(&_8$$15); + ZVAL_UNDEF(&_9$$15); + ZVAL_UNDEF(&_10$$17); + ZVAL_UNDEF(&_13$$18); + ZVAL_UNDEF(&_14$$18); + ZVAL_UNDEF(&_15$$13); + ZVAL_UNDEF(&_16$$20); + ZVAL_UNDEF(&_17$$20); + ZVAL_UNDEF(&_18$$21); + ZVAL_UNDEF(&_19$$21); + ZVAL_UNDEF(&_20$$19); + ZVAL_UNDEF(&_26$$19); + ZVAL_UNDEF(&_21$$23); + ZVAL_UNDEF(&_24$$24); + ZVAL_UNDEF(&_25$$24); + ZVAL_UNDEF(&_28$$25); + ZVAL_UNDEF(&_31$$29); + ZVAL_UNDEF(&_32$$29); + ZVAL_UNDEF(&_33$$30); + ZVAL_UNDEF(&_34$$30); + ZVAL_UNDEF(&_35$$31); + ZVAL_UNDEF(&_36$$31); + ZVAL_UNDEF(&_37$$28); + ZVAL_UNDEF(&_39$$33); + ZVAL_UNDEF(&_40$$33); + ZVAL_UNDEF(&_41$$34); + ZVAL_UNDEF(&_42$$34); + ZVAL_UNDEF(&_43$$35); + ZVAL_UNDEF(&_44$$35); + ZVAL_UNDEF(&_45$$32); + ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&_11$$17); + ZVAL_UNDEF(&_12$$17); + ZVAL_UNDEF(&_22$$23); + ZVAL_UNDEF(&_23$$23); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + Z_PARAM_ARRAY(definition) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(parameters) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &audience); - ZEPHIR_SEPARATE_PARAM(audience); - _0 = Z_TYPE_P(audience) != IS_STRING; - if (_0) { - _0 = Z_TYPE_P(audience) != IS_ARRAY; + zephir_fetch_params(1, 2, 1, &container, &definition_param, ¶meters); + ZEPHIR_OBS_COPY_OR_DUP(&definition, definition_param); + if (!parameters) { + parameters = ¶meters_sub; + parameters = &__$null; } - if (_0) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_validatorexception_ce, "Audience must be a string or an array", "phalcon/Encryption/Security/JWT/Validator.zep", 137); + zephir_memory_observe(&className); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&className, &definition, SL("className"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "Invalid service definition. Missing 'className' parameter", "phalcon/Di/Service/Builder.zep", 41); return; } - if (Z_TYPE_P(audience) == IS_STRING) { - ZEPHIR_INIT_VAR(&_1$$4); - zephir_create_array(&_1$$4, 1, 0); - zephir_array_fast_append(&_1$$4, audience); - ZEPHIR_CPY_WRT(audience, &_1$$4); - } - zephir_read_property(&_2, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_3, &_2, "getclaims", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_4); - array_init(&_4); - ZEPHIR_INIT_VAR(&_5); - ZVAL_STRING(&_5, "aud"); - ZEPHIR_CALL_METHOD(&tokenAudience, &_3, "get", NULL, 0, &_5, &_4); - zephir_check_call_status(); - zephir_is_iterable(audience, 0, "phalcon/Encryption/Security/JWT/Validator.zep", 152); - if (Z_TYPE_P(audience) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(audience), _6) - { - ZEPHIR_INIT_NVAR(&item); - ZVAL_COPY(&item, _6); - if (1 != zephir_fast_in_array(&item, &tokenAudience)) { - ZVAL_UNDEF(&_8$$6); - ZEPHIR_INIT_NVAR(&_8$$6); - ZVAL_STRING(&_8$$6, "Validation: audience not allowed"); - zephir_update_property_array_append(this_ptr, SL("errors"), &_8$$6); - } - } ZEND_HASH_FOREACH_END(); + if (Z_TYPE_P(parameters) == IS_ARRAY) { + if (zephir_fast_count_int(parameters)) { + ZEPHIR_INIT_VAR(&instance); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&instance, &className, parameters); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&instance); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&instance, &className); + zephir_check_call_status(); + } } else { - ZEPHIR_CALL_METHOD(NULL, audience, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_7, audience, "valid", NULL, 0); + zephir_memory_observe(&arguments); + if (zephir_array_isset_string_fetch(&arguments, &definition, SL("arguments"), 0)) { + ZEPHIR_CALL_METHOD(&_0$$8, this_ptr, "buildparameters", NULL, 223, container, &arguments); zephir_check_call_status(); - if (!zend_is_true(&_7)) { - break; - } - ZEPHIR_CALL_METHOD(&item, audience, "current", NULL, 0); + ZEPHIR_INIT_NVAR(&instance); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&instance, &className, &_0$$8); zephir_check_call_status(); - if (1 != zephir_fast_in_array(&item, &tokenAudience)) { - ZVAL_UNDEF(&_9$$8); - ZEPHIR_INIT_NVAR(&_9$$8); - ZVAL_STRING(&_9$$8, "Validation: audience not allowed"); - zephir_update_property_array_append(this_ptr, SL("errors"), &_9$$8); + } else { + ZEPHIR_INIT_NVAR(&instance); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&instance, &className); + zephir_check_call_status(); + } + } + zephir_memory_observe(¶mCalls); + if (zephir_array_isset_string_fetch(¶mCalls, &definition, SL("calls"), 0)) { + if (UNEXPECTED(Z_TYPE_P(&instance) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "The definition has setter injection parameters but the constructor didn't return an instance", "phalcon/Di/Service/Builder.zep", 78); + return; + } + if (UNEXPECTED(Z_TYPE_P(¶mCalls) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "Setter injection parameters must be an array", "phalcon/Di/Service/Builder.zep", 84); + return; + } + zephir_is_iterable(¶mCalls, 0, "phalcon/Di/Service/Builder.zep", 143); + if (Z_TYPE_P(¶mCalls) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(¶mCalls), _3$$10, _4$$10, _1$$10) + { + ZEPHIR_INIT_NVAR(&methodPosition); + if (_4$$10 != NULL) { + ZVAL_STR_COPY(&methodPosition, _4$$10); + } else { + ZVAL_LONG(&methodPosition, _3$$10); } - ZEPHIR_CALL_METHOD(NULL, audience, "next", NULL, 0); + ZEPHIR_INIT_NVAR(&method); + ZVAL_COPY(&method, _1$$10); + if (UNEXPECTED(Z_TYPE_P(&method) != IS_ARRAY)) { + ZEPHIR_INIT_NVAR(&_5$$14); + object_init_ex(&_5$$14, phalcon_di_exception_ce); + ZEPHIR_INIT_NVAR(&_6$$14); + ZEPHIR_CONCAT_SV(&_6$$14, "Method call must be an array on position ", &methodPosition); + ZEPHIR_CALL_METHOD(NULL, &_5$$14, "__construct", &_7, 33, &_6$$14); + zephir_check_call_status(); + zephir_throw_exception_debug(&_5$$14, "phalcon/Di/Service/Builder.zep", 97); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_OBS_NVAR(&methodName); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&methodName, &method, SL("method"), 0)))) { + ZEPHIR_INIT_NVAR(&_8$$15); + object_init_ex(&_8$$15, phalcon_di_exception_ce); + ZEPHIR_INIT_NVAR(&_9$$15); + ZEPHIR_CONCAT_SV(&_9$$15, "The method name is required on position ", &methodPosition); + ZEPHIR_CALL_METHOD(NULL, &_8$$15, "__construct", &_7, 33, &_9$$15); + zephir_check_call_status(); + zephir_throw_exception_debug(&_8$$15, "phalcon/Di/Service/Builder.zep", 106); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_NVAR(&methodCall); + zephir_create_array(&methodCall, 2, 0); + zephir_array_fast_append(&methodCall, &instance); + zephir_array_fast_append(&methodCall, &methodName); + ZEPHIR_OBS_NVAR(&arguments); + if (zephir_array_isset_string_fetch(&arguments, &method, SL("arguments"), 0)) { + if (UNEXPECTED(Z_TYPE_P(&arguments) != IS_ARRAY)) { + ZEPHIR_INIT_NVAR(&_10$$17); + object_init_ex(&_10$$17, phalcon_di_exception_ce); + zephir_cast_to_string(&_11$$17, &methodPosition); + ZEPHIR_INIT_NVAR(&_12$$17); + ZEPHIR_CONCAT_SV(&_12$$17, "Call arguments must be an array on position ", &_11$$17); + ZEPHIR_CALL_METHOD(NULL, &_10$$17, "__construct", &_7, 33, &_12$$17); + zephir_check_call_status(); + zephir_throw_exception_debug(&_10$$17, "phalcon/Di/Service/Builder.zep", 119); + ZEPHIR_MM_RESTORE(); + return; + } + if (zephir_fast_count_int(&arguments)) { + ZEPHIR_INIT_NVAR(&_13$$18); + ZEPHIR_CALL_METHOD(&_14$$18, this_ptr, "buildparameters", NULL, 223, container, &arguments); + zephir_check_call_status(); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_13$$18, &methodCall, &_14$$18); + zephir_check_call_status(); + continue; + } + } + ZEPHIR_INIT_NVAR(&_15$$13); + ZEPHIR_CALL_USER_FUNC(&_15$$13, &methodCall); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, ¶mCalls, "rewind", NULL, 0); zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2$$10, ¶mCalls, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2$$10)) { + break; + } + ZEPHIR_CALL_METHOD(&methodPosition, ¶mCalls, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&method, ¶mCalls, "current", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&method) != IS_ARRAY)) { + ZEPHIR_INIT_NVAR(&_16$$20); + object_init_ex(&_16$$20, phalcon_di_exception_ce); + ZEPHIR_INIT_NVAR(&_17$$20); + ZEPHIR_CONCAT_SV(&_17$$20, "Method call must be an array on position ", &methodPosition); + ZEPHIR_CALL_METHOD(NULL, &_16$$20, "__construct", &_7, 33, &_17$$20); + zephir_check_call_status(); + zephir_throw_exception_debug(&_16$$20, "phalcon/Di/Service/Builder.zep", 97); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_OBS_NVAR(&methodName); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&methodName, &method, SL("method"), 0)))) { + ZEPHIR_INIT_NVAR(&_18$$21); + object_init_ex(&_18$$21, phalcon_di_exception_ce); + ZEPHIR_INIT_NVAR(&_19$$21); + ZEPHIR_CONCAT_SV(&_19$$21, "The method name is required on position ", &methodPosition); + ZEPHIR_CALL_METHOD(NULL, &_18$$21, "__construct", &_7, 33, &_19$$21); + zephir_check_call_status(); + zephir_throw_exception_debug(&_18$$21, "phalcon/Di/Service/Builder.zep", 106); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_NVAR(&_20$$19); + zephir_create_array(&_20$$19, 2, 0); + zephir_array_fast_append(&_20$$19, &instance); + zephir_array_fast_append(&_20$$19, &methodName); + ZEPHIR_CPY_WRT(&methodCall, &_20$$19); + ZEPHIR_OBS_NVAR(&arguments); + if (zephir_array_isset_string_fetch(&arguments, &method, SL("arguments"), 0)) { + if (UNEXPECTED(Z_TYPE_P(&arguments) != IS_ARRAY)) { + ZEPHIR_INIT_NVAR(&_21$$23); + object_init_ex(&_21$$23, phalcon_di_exception_ce); + zephir_cast_to_string(&_22$$23, &methodPosition); + ZEPHIR_INIT_NVAR(&_23$$23); + ZEPHIR_CONCAT_SV(&_23$$23, "Call arguments must be an array on position ", &_22$$23); + ZEPHIR_CALL_METHOD(NULL, &_21$$23, "__construct", &_7, 33, &_23$$23); + zephir_check_call_status(); + zephir_throw_exception_debug(&_21$$23, "phalcon/Di/Service/Builder.zep", 119); + ZEPHIR_MM_RESTORE(); + return; + } + if (zephir_fast_count_int(&arguments)) { + ZEPHIR_INIT_NVAR(&_24$$24); + ZEPHIR_CALL_METHOD(&_25$$24, this_ptr, "buildparameters", NULL, 223, container, &arguments); + zephir_check_call_status(); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_24$$24, &methodCall, &_25$$24); + zephir_check_call_status(); + continue; + } + } + ZEPHIR_INIT_NVAR(&_26$$19); + ZEPHIR_CALL_USER_FUNC(&_26$$19, &methodCall); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, ¶mCalls, "next", NULL, 0); + zephir_check_call_status(); + } } + ZEPHIR_INIT_NVAR(&method); + ZEPHIR_INIT_NVAR(&methodPosition); } - ZEPHIR_INIT_NVAR(&item); - RETURN_THIS(); + ZEPHIR_OBS_NVAR(¶mCalls); + if (zephir_array_isset_string_fetch(¶mCalls, &definition, SL("properties"), 0)) { + if (UNEXPECTED(Z_TYPE_P(&instance) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "The definition has properties injection parameters but the constructor didn't return an instance", "phalcon/Di/Service/Builder.zep", 152); + return; + } + if (UNEXPECTED(Z_TYPE_P(¶mCalls) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "Setter injection parameters must be an array", "phalcon/Di/Service/Builder.zep", 158); + return; + } + zephir_is_iterable(¶mCalls, 0, "phalcon/Di/Service/Builder.zep", 201); + if (Z_TYPE_P(¶mCalls) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(¶mCalls), _29$$25, _30$$25, _27$$25) + { + ZEPHIR_INIT_NVAR(&propertyPosition); + if (_30$$25 != NULL) { + ZVAL_STR_COPY(&propertyPosition, _30$$25); + } else { + ZVAL_LONG(&propertyPosition, _29$$25); + } + ZEPHIR_INIT_NVAR(&property); + ZVAL_COPY(&property, _27$$25); + if (UNEXPECTED(Z_TYPE_P(&property) != IS_ARRAY)) { + ZEPHIR_INIT_NVAR(&_31$$29); + object_init_ex(&_31$$29, phalcon_di_exception_ce); + ZEPHIR_INIT_NVAR(&_32$$29); + ZEPHIR_CONCAT_SV(&_32$$29, "Property must be an array on position ", &propertyPosition); + ZEPHIR_CALL_METHOD(NULL, &_31$$29, "__construct", &_7, 33, &_32$$29); + zephir_check_call_status(); + zephir_throw_exception_debug(&_31$$29, "phalcon/Di/Service/Builder.zep", 171); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_OBS_NVAR(&propertyName); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&propertyName, &property, SL("name"), 0)))) { + ZEPHIR_INIT_NVAR(&_33$$30); + object_init_ex(&_33$$30, phalcon_di_exception_ce); + ZEPHIR_INIT_NVAR(&_34$$30); + ZEPHIR_CONCAT_SV(&_34$$30, "The property name is required on position ", &propertyPosition); + ZEPHIR_CALL_METHOD(NULL, &_33$$30, "__construct", &_7, 33, &_34$$30); + zephir_check_call_status(); + zephir_throw_exception_debug(&_33$$30, "phalcon/Di/Service/Builder.zep", 180); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_OBS_NVAR(&propertyValue); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&propertyValue, &property, SL("value"), 0)))) { + ZEPHIR_INIT_NVAR(&_35$$31); + object_init_ex(&_35$$31, phalcon_di_exception_ce); + ZEPHIR_INIT_NVAR(&_36$$31); + ZEPHIR_CONCAT_SV(&_36$$31, "The property value is required on position ", &propertyPosition); + ZEPHIR_CALL_METHOD(NULL, &_35$$31, "__construct", &_7, 33, &_36$$31); + zephir_check_call_status(); + zephir_throw_exception_debug(&_35$$31, "phalcon/Di/Service/Builder.zep", 189); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&_37$$28, this_ptr, "buildparameter", &_38, 224, container, &propertyPosition, &propertyValue); + zephir_check_call_status(); + zephir_update_property_zval_zval(&instance, &propertyName, &_37$$28); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, ¶mCalls, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_28$$25, ¶mCalls, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_28$$25)) { + break; + } + ZEPHIR_CALL_METHOD(&propertyPosition, ¶mCalls, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&property, ¶mCalls, "current", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&property) != IS_ARRAY)) { + ZEPHIR_INIT_NVAR(&_39$$33); + object_init_ex(&_39$$33, phalcon_di_exception_ce); + ZEPHIR_INIT_NVAR(&_40$$33); + ZEPHIR_CONCAT_SV(&_40$$33, "Property must be an array on position ", &propertyPosition); + ZEPHIR_CALL_METHOD(NULL, &_39$$33, "__construct", &_7, 33, &_40$$33); + zephir_check_call_status(); + zephir_throw_exception_debug(&_39$$33, "phalcon/Di/Service/Builder.zep", 171); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_OBS_NVAR(&propertyName); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&propertyName, &property, SL("name"), 0)))) { + ZEPHIR_INIT_NVAR(&_41$$34); + object_init_ex(&_41$$34, phalcon_di_exception_ce); + ZEPHIR_INIT_NVAR(&_42$$34); + ZEPHIR_CONCAT_SV(&_42$$34, "The property name is required on position ", &propertyPosition); + ZEPHIR_CALL_METHOD(NULL, &_41$$34, "__construct", &_7, 33, &_42$$34); + zephir_check_call_status(); + zephir_throw_exception_debug(&_41$$34, "phalcon/Di/Service/Builder.zep", 180); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_OBS_NVAR(&propertyValue); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&propertyValue, &property, SL("value"), 0)))) { + ZEPHIR_INIT_NVAR(&_43$$35); + object_init_ex(&_43$$35, phalcon_di_exception_ce); + ZEPHIR_INIT_NVAR(&_44$$35); + ZEPHIR_CONCAT_SV(&_44$$35, "The property value is required on position ", &propertyPosition); + ZEPHIR_CALL_METHOD(NULL, &_43$$35, "__construct", &_7, 33, &_44$$35); + zephir_check_call_status(); + zephir_throw_exception_debug(&_43$$35, "phalcon/Di/Service/Builder.zep", 189); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&_45$$32, this_ptr, "buildparameter", &_38, 224, container, &propertyPosition, &propertyValue); + zephir_check_call_status(); + zephir_update_property_zval_zval(&instance, &propertyName, &_45$$32); + ZEPHIR_CALL_METHOD(NULL, ¶mCalls, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&property); + ZEPHIR_INIT_NVAR(&propertyPosition); + } + RETURN_CCTOR(&instance); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateExpiration) +static PHP_METHOD(Phalcon_Di_Service_Builder, buildParameter) { - zend_bool _7; + zval _2$$3, _5$$5, _8$$7, _11$$9, _14$$11; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *timestamp_param = NULL, _0, _1, _2, _3, _4, _5, _6, _8, _9, _10$$3; - zend_long timestamp, ZEPHIR_LAST_CALL_STATUS, tokenExpirationTime = 0; - zval *this_ptr = getThis(); + zval argument; + zend_long position, ZEPHIR_LAST_CALL_STATUS; + zval *container, container_sub, *position_param = NULL, *argument_param = NULL, type, name, value, instanceArguments, _0$$3, _1$$3, _3$$5, _4$$5, _6$$7, _7$$7, _9$$9, _10$$9, _12$$11, _13$$11; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(timestamp) + ZVAL_UNDEF(&container_sub); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&instanceArguments); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_7$$7); + ZVAL_UNDEF(&_9$$9); + ZVAL_UNDEF(&_10$$9); + ZVAL_UNDEF(&_12$$11); + ZVAL_UNDEF(&_13$$11); + ZVAL_UNDEF(&argument); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_8$$7); + ZVAL_UNDEF(&_11$$9); + ZVAL_UNDEF(&_14$$11); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + Z_PARAM_LONG(position) + Z_PARAM_ARRAY(argument) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, ×tamp_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_1, &_0, "getclaims", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "exp"); - ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_3); - zephir_check_call_status(); - tokenExpirationTime = zephir_get_intval(&_2); - zephir_read_property(&_4, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_5, &_4, "getclaims", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_3); - ZVAL_STRING(&_3, "exp"); - ZEPHIR_CALL_METHOD(&_6, &_5, "has", NULL, 0, &_3); - zephir_check_call_status(); - _7 = zephir_is_true(&_6); - if (_7) { - ZVAL_LONG(&_9, timestamp); - ZEPHIR_CALL_METHOD(&_8, this_ptr, "gettimestamp", NULL, 266, &_9); + zephir_fetch_params(1, 3, 0, &container, &position_param, &argument_param); + ZEPHIR_OBS_COPY_OR_DUP(&argument, argument_param); + zephir_memory_observe(&type); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&type, &argument, SL("type"), 0)))) { + ZEPHIR_INIT_VAR(&_0$$3); + object_init_ex(&_0$$3, phalcon_di_exception_ce); + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_LONG(&_1$$3, position); + ZEPHIR_INIT_VAR(&_2$$3); + ZEPHIR_CONCAT_SVS(&_2$$3, "Argument at position ", &_1$$3, " must have a type"); + ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 33, &_2$$3); zephir_check_call_status(); - _7 = ZEPHIR_GT_LONG(&_8, tokenExpirationTime); - } - if (_7) { - ZVAL_UNDEF(&_10$$3); - ZEPHIR_INIT_VAR(&_10$$3); - ZVAL_STRING(&_10$$3, "Validation: the token has expired"); - zephir_update_property_array_append(this_ptr, SL("errors"), &_10$$3); + zephir_throw_exception_debug(&_0$$3, "phalcon/Di/Service/Builder.zep", 221); + ZEPHIR_MM_RESTORE(); + return; } - RETURN_THIS(); + do { + if (ZEPHIR_IS_STRING(&type, "service")) { + zephir_memory_observe(&name); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&name, &argument, SL("name"), 0)))) { + ZEPHIR_INIT_VAR(&_3$$5); + object_init_ex(&_3$$5, phalcon_di_exception_ce); + ZEPHIR_INIT_VAR(&_4$$5); + ZVAL_LONG(&_4$$5, position); + ZEPHIR_INIT_VAR(&_5$$5); + ZEPHIR_CONCAT_SV(&_5$$5, "Service 'name' is required in parameter on position ", &_4$$5); + ZEPHIR_CALL_METHOD(NULL, &_3$$5, "__construct", NULL, 33, &_5$$5); + zephir_check_call_status(); + zephir_throw_exception_debug(&_3$$5, "phalcon/Di/Service/Builder.zep", 233); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_RETURN_CALL_METHOD(container, "get", NULL, 0, &name); + zephir_check_call_status(); + RETURN_MM(); + } + if (ZEPHIR_IS_STRING(&type, "parameter")) { + zephir_memory_observe(&value); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&value, &argument, SL("value"), 0)))) { + ZEPHIR_INIT_VAR(&_6$$7); + object_init_ex(&_6$$7, phalcon_di_exception_ce); + ZEPHIR_INIT_VAR(&_7$$7); + ZVAL_LONG(&_7$$7, position); + ZEPHIR_INIT_VAR(&_8$$7); + ZEPHIR_CONCAT_SV(&_8$$7, "Service 'value' is required in parameter on position ", &_7$$7); + ZEPHIR_CALL_METHOD(NULL, &_6$$7, "__construct", NULL, 33, &_8$$7); + zephir_check_call_status(); + zephir_throw_exception_debug(&_6$$7, "phalcon/Di/Service/Builder.zep", 245); + ZEPHIR_MM_RESTORE(); + return; + } + RETURN_CCTOR(&value); + } + if (ZEPHIR_IS_STRING(&type, "instance")) { + ZEPHIR_OBS_NVAR(&name); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&name, &argument, SL("className"), 0)))) { + ZEPHIR_INIT_VAR(&_9$$9); + object_init_ex(&_9$$9, phalcon_di_exception_ce); + ZEPHIR_INIT_VAR(&_10$$9); + ZVAL_LONG(&_10$$9, position); + ZEPHIR_INIT_VAR(&_11$$9); + ZEPHIR_CONCAT_SV(&_11$$9, "Service 'className' is required in parameter on position ", &_10$$9); + ZEPHIR_CALL_METHOD(NULL, &_9$$9, "__construct", NULL, 33, &_11$$9); + zephir_check_call_status(); + zephir_throw_exception_debug(&_9$$9, "phalcon/Di/Service/Builder.zep", 257); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_memory_observe(&instanceArguments); + if (zephir_array_isset_string_fetch(&instanceArguments, &argument, SL("arguments"), 0)) { + ZEPHIR_RETURN_CALL_METHOD(container, "get", NULL, 0, &name, &instanceArguments); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_RETURN_CALL_METHOD(container, "get", NULL, 0, &name); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_INIT_VAR(&_12$$11); + object_init_ex(&_12$$11, phalcon_di_exception_ce); + ZEPHIR_INIT_VAR(&_13$$11); + ZVAL_LONG(&_13$$11, position); + ZEPHIR_INIT_VAR(&_14$$11); + ZEPHIR_CONCAT_SV(&_14$$11, "Unknown service type in parameter on position ", &_13$$11); + ZEPHIR_CALL_METHOD(NULL, &_12$$11, "__construct", NULL, 33, &_14$$11); + zephir_check_call_status(); + zephir_throw_exception_debug(&_12$$11, "phalcon/Di/Service/Builder.zep", 279); + ZEPHIR_MM_RESTORE(); + return; + } while(0); + + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateId) +static PHP_METHOD(Phalcon_Di_Service_Builder, buildParameters) { + zend_string *_3; + zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_5 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *id_param = NULL, tokenId, _0, _1, _2, _3, _5$$3; - zval id, _4; + zval arguments, buildArguments; + zval *container, container_sub, *arguments_param = NULL, position, argument, *_0, _1, _4$$3, _6$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&id); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&tokenId); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&container_sub); + ZVAL_UNDEF(&position); + ZVAL_UNDEF(&argument); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(id) + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&arguments); + ZVAL_UNDEF(&buildArguments); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + Z_PARAM_ARRAY(arguments) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &id_param); - zephir_get_strval(&id, id_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_1, &_0, "getclaims", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "jti"); - ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_3); - zephir_check_call_status(); - zephir_cast_to_string(&_4, &_2); - ZEPHIR_CPY_WRT(&tokenId, &_4); - if (!ZEPHIR_IS_IDENTICAL(&id, &tokenId)) { - ZVAL_UNDEF(&_5$$3); - ZEPHIR_INIT_VAR(&_5$$3); - ZVAL_STRING(&_5$$3, "Validation: incorrect Id"); - zephir_update_property_array_append(this_ptr, SL("errors"), &_5$$3); + zephir_fetch_params(1, 2, 0, &container, &arguments_param); + ZEPHIR_OBS_COPY_OR_DUP(&arguments, arguments_param); + ZEPHIR_INIT_VAR(&buildArguments); + array_init(&buildArguments); + zephir_is_iterable(&arguments, 0, "phalcon/Di/Service/Builder.zep", 301); + if (Z_TYPE_P(&arguments) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&arguments), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&position); + if (_3 != NULL) { + ZVAL_STR_COPY(&position, _3); + } else { + ZVAL_LONG(&position, _2); + } + ZEPHIR_INIT_NVAR(&argument); + ZVAL_COPY(&argument, _0); + ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "buildparameter", &_5, 224, container, &position, &argument); + zephir_check_call_status(); + zephir_array_append(&buildArguments, &_4$$3, PH_SEPARATE, "phalcon/Di/Service/Builder.zep", 298); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &arguments, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &arguments, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&position, &arguments, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&argument, &arguments, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_6$$4, this_ptr, "buildparameter", &_5, 224, container, &position, &argument); + zephir_check_call_status(); + zephir_array_append(&buildArguments, &_6$$4, PH_SEPARATE, "phalcon/Di/Service/Builder.zep", 298); + ZEPHIR_CALL_METHOD(NULL, &arguments, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_THIS(); + ZEPHIR_INIT_NVAR(&argument); + ZEPHIR_INIT_NVAR(&position); + RETURN_CTOR(&buildArguments); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateIssuedAt) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Di_FactoryDefault_Cli) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Di\\FactoryDefault, Cli, phalcon, di_factorydefault_cli, phalcon_di_factorydefault_ce, phalcon_di_factorydefault_cli_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Di_FactoryDefault_Cli, __construct) { + zval _0, _5, _6, _7; + zval filter, _1, _2, _3, _4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *timestamp_param = NULL, _0, _1, _2, _3, _4, _5, _6$$3; - zend_long timestamp, ZEPHIR_LAST_CALL_STATUS, tokenIssuedAt = 0; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&filter); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(timestamp) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, ×tamp_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_1, &_0, "getclaims", NULL, 0); + + ZEPHIR_CALL_PARENT(NULL, phalcon_di_factorydefault_cli_ce, getThis(), "__construct", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "iat"); - ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_3); + ZEPHIR_INIT_VAR(&filter); + object_init_ex(&filter, phalcon_filter_filterfactory_ce); + if (zephir_has_constructor(&filter)) { + ZEPHIR_CALL_METHOD(NULL, &filter, "__construct", NULL, 0); + zephir_check_call_status(); + } + + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 12, 0); + ZEPHIR_INIT_VAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Annotations\\Adapter\\Memory"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); zephir_check_call_status(); - tokenIssuedAt = zephir_get_intval(&_2); - ZVAL_LONG(&_5, timestamp); - ZEPHIR_CALL_METHOD(&_4, this_ptr, "gettimestamp", NULL, 266, &_5); + zephir_array_update_string(&_0, SL("annotations"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Cli\\Dispatcher"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); zephir_check_call_status(); - if (ZEPHIR_LE_LONG(&_4, tokenIssuedAt)) { - ZVAL_UNDEF(&_6$$3); - ZEPHIR_INIT_VAR(&_6$$3); - ZVAL_STRING(&_6$$3, "Validation: the token cannot be used yet (future)"); - zephir_update_property_array_append(this_ptr, SL("errors"), &_6$$3); - } - RETURN_THIS(); + zephir_array_update_string(&_0, SL("dispatcher"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Html\\Escaper"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); + zephir_check_call_status(); + zephir_array_update_string(&_0, SL("escaper"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Events\\Manager"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); + zephir_check_call_status(); + zephir_array_update_string(&_0, SL("eventsManager"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_CALL_METHOD(&_4, &filter, "newinstance", NULL, 94); + zephir_check_call_status(); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_4, &_3); + zephir_check_call_status(); + zephir_array_update_string(&_0, SL("filter"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Support\\HelperFactory"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); + zephir_check_call_status(); + zephir_array_update_string(&_0, SL("helper"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Mvc\\Model\\Manager"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); + zephir_check_call_status(); + zephir_array_update_string(&_0, SL("modelsManager"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Mvc\\Model\\MetaData\\Memory"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); + zephir_check_call_status(); + zephir_array_update_string(&_0, SL("modelsMetadata"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Cli\\Router"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); + zephir_check_call_status(); + zephir_array_update_string(&_0, SL("router"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Encryption\\Security"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); + zephir_check_call_status(); + zephir_array_update_string(&_0, SL("security"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_VAR(&_5); + zephir_create_array(&_5, 2, 0); + add_assoc_stringl_ex(&_5, SL("className"), SL("Phalcon\\Html\\TagFactory")); + ZEPHIR_INIT_VAR(&_6); + zephir_create_array(&_6, 1, 0); + ZEPHIR_INIT_VAR(&_7); + zephir_create_array(&_7, 2, 0); + add_assoc_stringl_ex(&_7, SL("type"), SL("service")); + add_assoc_stringl_ex(&_7, SL("name"), SL("escaper")); + zephir_array_fast_append(&_6, &_7); + zephir_array_update_string(&_5, SL("arguments"), &_6, PH_COPY | PH_SEPARATE); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_5, &_3); + zephir_check_call_status(); + zephir_array_update_string(&_0, SL("tag"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_di_service_ce); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "Phalcon\\Mvc\\Model\\Transaction\\Manager"); + ZVAL_BOOL(&_3, 1); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); + zephir_check_call_status(); + zephir_array_update_string(&_0, SL("transactionManager"), &_1, PH_COPY | PH_SEPARATE); + zephir_update_property_zval(this_ptr, ZEND_STRL("services"), &_0); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateIssuer) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Application) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Application, phalcon, mvc_application, phalcon_application_abstractapplication_ce, phalcon_mvc_application_method_entry, 0); + + zend_declare_property_bool(phalcon_mvc_application_ce, SL("implicitView"), 1, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_mvc_application_ce, SL("sendCookies"), 1, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_mvc_application_ce, SL("sendHeaders"), 1, ZEND_ACC_PROTECTED); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Mvc_Application, handle) { + zval _17$$20; + zend_class_entry *_6$$7; + zend_bool returnedResponse = 0, _1, _10$$6, _13$$11, _31$$30, _33$$30; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *issuer_param = NULL, tokenIssuer, _0, _1, _2, _3, _5$$3; - zval issuer, _4; + zval *uri_param = NULL, __$false, container, eventsManager, router, dispatcher, response, view, module, moduleObject, moduleName, className, path, implicitView, controller, possibleResponse, renderStatus, matchedRoute, match, _0, _2, _3, _4, _21, _22, _23, _24, _41, _5$$7, _7$$6, _8$$8, _9$$8, _11$$12, _12$$12, _14$$18, _15$$18, _16$$15, _18$$22, _19$$23, _20$$23, _25$$25, _26$$25, _27$$27, _28$$27, _29$$29, _30$$29, _32$$31, _34$$34, _35$$35, _36$$35, _37$$38, _38$$38, _39$$39, _40$$40; + zval uri; zval *this_ptr = getThis(); - ZVAL_UNDEF(&issuer); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&tokenIssuer); + ZVAL_UNDEF(&uri); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&router); + ZVAL_UNDEF(&dispatcher); + ZVAL_UNDEF(&response); + ZVAL_UNDEF(&view); + ZVAL_UNDEF(&module); + ZVAL_UNDEF(&moduleObject); + ZVAL_UNDEF(&moduleName); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&path); + ZVAL_UNDEF(&implicitView); + ZVAL_UNDEF(&controller); + ZVAL_UNDEF(&possibleResponse); + ZVAL_UNDEF(&renderStatus); + ZVAL_UNDEF(&matchedRoute); + ZVAL_UNDEF(&match); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_21); + ZVAL_UNDEF(&_22); + ZVAL_UNDEF(&_23); + ZVAL_UNDEF(&_24); + ZVAL_UNDEF(&_41); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_8$$8); + ZVAL_UNDEF(&_9$$8); + ZVAL_UNDEF(&_11$$12); + ZVAL_UNDEF(&_12$$12); + ZVAL_UNDEF(&_14$$18); + ZVAL_UNDEF(&_15$$18); + ZVAL_UNDEF(&_16$$15); + ZVAL_UNDEF(&_18$$22); + ZVAL_UNDEF(&_19$$23); + ZVAL_UNDEF(&_20$$23); + ZVAL_UNDEF(&_25$$25); + ZVAL_UNDEF(&_26$$25); + ZVAL_UNDEF(&_27$$27); + ZVAL_UNDEF(&_28$$27); + ZVAL_UNDEF(&_29$$29); + ZVAL_UNDEF(&_30$$29); + ZVAL_UNDEF(&_32$$31); + ZVAL_UNDEF(&_34$$34); + ZVAL_UNDEF(&_35$$35); + ZVAL_UNDEF(&_36$$35); + ZVAL_UNDEF(&_37$$38); + ZVAL_UNDEF(&_38$$38); + ZVAL_UNDEF(&_39$$39); + ZVAL_UNDEF(&_40$$40); + ZVAL_UNDEF(&_17$$20); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(issuer) + Z_PARAM_STR(uri) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &issuer_param); - if (UNEXPECTED(Z_TYPE_P(issuer_param) != IS_STRING && Z_TYPE_P(issuer_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'issuer' must be of the type string")); + zephir_fetch_params(1, 1, 0, &uri_param); + if (UNEXPECTED(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 of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(issuer_param) == IS_STRING)) { - zephir_get_strval(&issuer, issuer_param); + if (EXPECTED(Z_TYPE_P(uri_param) == IS_STRING)) { + zephir_get_strval(&uri, uri_param); } else { - ZEPHIR_INIT_VAR(&issuer); + ZEPHIR_INIT_VAR(&uri); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_1, &_0, "getclaims", NULL, 0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_0); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_application_exception_ce, "A dependency injection container is required to access internal services", "phalcon/Mvc/Application.zep", 100); + return; + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_0); + _1 = Z_TYPE_P(&eventsManager) != IS_NULL; + if (_1) { + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "application:boot"); + ZEPHIR_CALL_METHOD(&_2, &eventsManager, "fire", NULL, 0, &_3, this_ptr); + zephir_check_call_status(); + _1 = ZEPHIR_IS_FALSE_IDENTICAL(&_2); + } + if (_1) { + RETURN_MM_BOOL(0); + } + ZEPHIR_INIT_NVAR(&_3); + ZVAL_STRING(&_3, "router"); + ZEPHIR_CALL_METHOD(&_4, &container, "getshared", NULL, 0, &_3); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "iss"); - ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_3); + ZEPHIR_CPY_WRT(&router, &_4); + ZEPHIR_CALL_METHOD(NULL, &router, "handle", NULL, 0, &uri); zephir_check_call_status(); - zephir_cast_to_string(&_4, &_2); - ZEPHIR_CPY_WRT(&tokenIssuer, &_4); - if (!ZEPHIR_IS_IDENTICAL(&issuer, &tokenIssuer)) { - ZVAL_UNDEF(&_5$$3); - ZEPHIR_INIT_VAR(&_5$$3); - ZVAL_STRING(&_5$$3, "Validation: incorrect issuer"); - zephir_update_property_array_append(this_ptr, SL("errors"), &_5$$3); + ZEPHIR_CALL_METHOD(&matchedRoute, &router, "getmatchedroute", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&matchedRoute) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(&match, &matchedRoute, "getmatch", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&match) != IS_NULL) { + if (zephir_is_instance_of(&match, SL("Closure"))) { + _6$$7 = zephir_fetch_class_str_ex(SL("Closure"), ZEND_FETCH_CLASS_AUTO); + ZEPHIR_CALL_CE_STATIC(&_5$$7, _6$$7, "bind", NULL, 0, &match, &container); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&match, &_5$$7); + } + ZEPHIR_CALL_METHOD(&_7$$6, &router, "getparams", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&possibleResponse); + ZEPHIR_CALL_USER_FUNC_ARRAY(&possibleResponse, &match, &_7$$6); + zephir_check_call_status(); + if (Z_TYPE_P(&possibleResponse) == IS_STRING) { + ZEPHIR_INIT_VAR(&_9$$8); + ZVAL_STRING(&_9$$8, "response"); + ZEPHIR_CALL_METHOD(&_8$$8, &container, "getshared", NULL, 0, &_9$$8); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&response, &_8$$8); + ZEPHIR_CALL_METHOD(NULL, &response, "setcontent", NULL, 0, &possibleResponse); + zephir_check_call_status(); + RETURN_CCTOR(&response); + } + _10$$6 = Z_TYPE_P(&possibleResponse) == IS_OBJECT; + if (_10$$6) { + _10$$6 = zephir_instance_of_ev(&possibleResponse, phalcon_http_responseinterface_ce); + } + if (_10$$6) { + ZEPHIR_CALL_METHOD(NULL, &possibleResponse, "sendheaders", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &possibleResponse, "sendcookies", NULL, 0); + zephir_check_call_status(); + RETURN_CCTOR(&possibleResponse); + } + } } - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateNotBefore) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *timestamp_param = NULL, _0, _1, _2, _3, _4, _5, _6$$3; - zend_long timestamp, ZEPHIR_LAST_CALL_STATUS, tokenNotBefore = 0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(timestamp) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, ×tamp_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_1, &_0, "getclaims", NULL, 0); + ZEPHIR_CALL_METHOD(&moduleName, &router, "getmodulename", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "nbf"); - ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_3); + if (!(zephir_is_true(&moduleName))) { + ZEPHIR_OBS_NVAR(&moduleName); + zephir_read_property(&moduleName, this_ptr, ZEND_STRL("defaultModule"), PH_NOISY_CC); + } + ZEPHIR_INIT_VAR(&moduleObject); + ZVAL_NULL(&moduleObject); + if (zephir_is_true(&moduleName)) { + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_12$$12); + ZVAL_STRING(&_12$$12, "application:beforeStartModule"); + ZEPHIR_CALL_METHOD(&_11$$12, &eventsManager, "fire", NULL, 0, &_12$$12, this_ptr, &moduleName); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_11$$12)) { + RETURN_MM_BOOL(0); + } + } + ZEPHIR_CALL_METHOD(&module, this_ptr, "getmodule", NULL, 0, &moduleName); + zephir_check_call_status(); + _13$$11 = Z_TYPE_P(&module) != IS_ARRAY; + if (_13$$11) { + _13$$11 = Z_TYPE_P(&module) != IS_OBJECT; + } + if (UNEXPECTED(_13$$11)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_application_exception_ce, "Invalid module definition", "phalcon/Mvc/Application.zep", 196); + return; + } + if (Z_TYPE_P(&module) == IS_ARRAY) { + zephir_memory_observe(&className); + if (!(zephir_array_isset_string_fetch(&className, &module, SL("className"), 0))) { + ZEPHIR_INIT_NVAR(&className); + ZVAL_STRING(&className, "Module"); + } + zephir_memory_observe(&path); + if (zephir_array_isset_string_fetch(&path, &module, SL("path"), 0)) { + if (UNEXPECTED(!((zephir_file_exists(&path) == SUCCESS)))) { + ZEPHIR_INIT_VAR(&_14$$18); + object_init_ex(&_14$$18, phalcon_mvc_application_exception_ce); + ZEPHIR_INIT_VAR(&_15$$18); + ZEPHIR_CONCAT_SVS(&_15$$18, "Module definition path '", &path, "' doesn't exist"); + ZEPHIR_CALL_METHOD(NULL, &_14$$18, "__construct", NULL, 33, &_15$$18); + zephir_check_call_status(); + zephir_throw_exception_debug(&_14$$18, "phalcon/Mvc/Application.zep", 218); + ZEPHIR_MM_RESTORE(); + return; + } + if (!(zephir_class_exists(&className, zephir_is_true(&__$false) ))) { + if (zephir_require_once_zval(&path) == FAILURE) { + RETURN_MM_NULL(); + } + } + } + ZEPHIR_CALL_METHOD(&_16$$15, &container, "get", NULL, 0, &className); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&moduleObject, &_16$$15); + ZEPHIR_CALL_METHOD(NULL, &moduleObject, "registerautoloaders", NULL, 0, &container); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &moduleObject, "registerservices", NULL, 0, &container); + zephir_check_call_status(); + } else { + if (UNEXPECTED(!((zephir_is_instance_of(&module, SL("Closure")))))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_application_exception_ce, "Invalid module definition", "phalcon/Mvc/Application.zep", 239); + return; + } + ZEPHIR_INIT_VAR(&_17$$20); + zephir_create_array(&_17$$20, 1, 0); + zephir_array_fast_append(&_17$$20, &container); + ZEPHIR_INIT_NVAR(&moduleObject); + ZEPHIR_CALL_USER_FUNC_ARRAY(&moduleObject, &module, &_17$$20); + zephir_check_call_status(); + } + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_18$$22); + ZVAL_STRING(&_18$$22, "application:afterStartModule"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_18$$22, this_ptr, &moduleObject); + zephir_check_call_status(); + } + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("implicitView"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&implicitView, &_0); + if (ZEPHIR_IS_TRUE_IDENTICAL(&implicitView)) { + ZEPHIR_INIT_VAR(&_20$$23); + ZVAL_STRING(&_20$$23, "view"); + ZEPHIR_CALL_METHOD(&_19$$23, &container, "getshared", NULL, 0, &_20$$23); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&view, &_19$$23); + } + ZEPHIR_INIT_NVAR(&_3); + ZVAL_STRING(&_3, "dispatcher"); + ZEPHIR_CALL_METHOD(&_4, &container, "getshared", NULL, 0, &_3); zephir_check_call_status(); - tokenNotBefore = zephir_get_intval(&_2); - ZVAL_LONG(&_5, timestamp); - ZEPHIR_CALL_METHOD(&_4, this_ptr, "gettimestamp", NULL, 266, &_5); + ZEPHIR_CPY_WRT(&dispatcher, &_4); + ZEPHIR_CALL_METHOD(&_4, &router, "getmodulename", NULL, 0); zephir_check_call_status(); - if (ZEPHIR_LE_LONG(&_4, tokenNotBefore)) { - ZVAL_UNDEF(&_6$$3); - ZEPHIR_INIT_VAR(&_6$$3); - ZVAL_STRING(&_6$$3, "Validation: the token cannot be used yet (not before)"); - zephir_update_property_array_append(this_ptr, SL("errors"), &_6$$3); + ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setmodulename", NULL, 0, &_4); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_21, &router, "getnamespacename", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setnamespacename", NULL, 0, &_21); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_22, &router, "getcontrollername", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setcontrollername", NULL, 0, &_22); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_23, &router, "getactionname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setactionname", NULL, 0, &_23); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_24, &router, "getparams", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setparams", NULL, 0, &_24); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&implicitView)) { + ZEPHIR_CALL_METHOD(NULL, &view, "start", NULL, 0); + zephir_check_call_status(); } - RETURN_THIS(); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_26$$25); + ZVAL_STRING(&_26$$25, "application:beforeHandleRequest"); + ZEPHIR_CALL_METHOD(&_25$$25, &eventsManager, "fire", NULL, 0, &_26$$25, this_ptr, &dispatcher); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_25$$25)) { + RETURN_MM_BOOL(0); + } + } + ZEPHIR_CALL_METHOD(&controller, &dispatcher, "dispatch", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&possibleResponse, &dispatcher, "getreturnedvalue", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&possibleResponse)) { + ZEPHIR_INIT_VAR(&_28$$27); + ZVAL_STRING(&_28$$27, "response"); + ZEPHIR_CALL_METHOD(&_27$$27, &container, "getshared", NULL, 0, &_28$$27); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&response, &_27$$27); + } else { + if (Z_TYPE_P(&possibleResponse) == IS_STRING) { + ZEPHIR_INIT_VAR(&_30$$29); + ZVAL_STRING(&_30$$29, "response"); + ZEPHIR_CALL_METHOD(&_29$$29, &container, "getshared", NULL, 0, &_30$$29); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&response, &_29$$29); + ZEPHIR_CALL_METHOD(NULL, &response, "setcontent", NULL, 0, &possibleResponse); + zephir_check_call_status(); + } else { + _31$$30 = (Z_TYPE_P(&possibleResponse) == IS_OBJECT); + if (_31$$30) { + _31$$30 = (zephir_instance_of_ev(&possibleResponse, phalcon_http_responseinterface_ce)); + } + returnedResponse = _31$$30; + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_32$$31); + ZVAL_STRING(&_32$$31, "application:afterHandleRequest"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_32$$31, this_ptr, &controller); + zephir_check_call_status(); + } + _33$$30 = returnedResponse == 0; + if (_33$$30) { + _33$$30 = ZEPHIR_IS_TRUE_IDENTICAL(&implicitView); + } + if (_33$$30) { + if (Z_TYPE_P(&controller) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&renderStatus); + ZVAL_BOOL(&renderStatus, 1); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_34$$34); + ZVAL_STRING(&_34$$34, "application:viewRender"); + ZEPHIR_CALL_METHOD(&renderStatus, &eventsManager, "fire", NULL, 0, &_34$$34, this_ptr, &view); + zephir_check_call_status(); + } + if (!ZEPHIR_IS_FALSE_IDENTICAL(&renderStatus)) { + ZEPHIR_CALL_METHOD(&_35$$35, &dispatcher, "getcontrollername", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_36$$35, &dispatcher, "getactionname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &view, "render", NULL, 0, &_35$$35, &_36$$35); + zephir_check_call_status(); + } + } + } + if (ZEPHIR_IS_TRUE_IDENTICAL(&implicitView)) { + ZEPHIR_CALL_METHOD(NULL, &view, "finish", NULL, 0); + zephir_check_call_status(); + } + if (returnedResponse == 1) { + ZEPHIR_CPY_WRT(&response, &possibleResponse); + } else { + ZEPHIR_INIT_VAR(&_38$$38); + ZVAL_STRING(&_38$$38, "response"); + ZEPHIR_CALL_METHOD(&_37$$38, &container, "getshared", NULL, 0, &_38$$38); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&response, &_37$$38); + if (ZEPHIR_IS_TRUE_IDENTICAL(&implicitView)) { + ZEPHIR_CALL_METHOD(&_39$$39, &view, "getcontent", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &response, "setcontent", NULL, 0, &_39$$39); + zephir_check_call_status(); + } + } + } + } + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_40$$40); + ZVAL_STRING(&_40$$40, "application:beforeSendResponse"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_40$$40, this_ptr, &response); + zephir_check_call_status(); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("sendHeaders"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_0)) { + ZEPHIR_CALL_METHOD(NULL, &response, "sendheaders", NULL, 0); + zephir_check_call_status(); + } + zephir_read_property(&_41, this_ptr, ZEND_STRL("sendCookies"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_41)) { + ZEPHIR_CALL_METHOD(NULL, &response, "sendcookies", NULL, 0); + zephir_check_call_status(); + } + RETURN_CCTOR(&response); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateSignature) +static PHP_METHOD(Phalcon_Mvc_Application, sendCookiesOnHandleRequest) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval passphrase; - zval *signer, signer_sub, *passphrase_param = NULL, _0, _1, _2, _3, _4, _5, _6$$3; + zval *sendCookies_param = NULL, __$true, __$false; + zend_bool sendCookies; zval *this_ptr = getThis(); - ZVAL_UNDEF(&signer_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&passphrase); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(signer, phalcon_encryption_security_jwt_signer_signerinterface_ce) - Z_PARAM_STR(passphrase) + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(sendCookies) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &signer, &passphrase_param); - zephir_get_strval(&passphrase, passphrase_param); - zephir_read_property(&_1, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_2, &_1, "getsignature", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_3, &_2, "gethash", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_4, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_5, &_4, "getpayload", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, signer, "verify", NULL, 0, &_3, &_5, &passphrase); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - ZVAL_UNDEF(&_6$$3); - ZEPHIR_INIT_VAR(&_6$$3); - ZVAL_STRING(&_6$$3, "Validation: the signature does not match"); - zephir_update_property_array_append(this_ptr, SL("errors"), &_6$$3); + zephir_fetch_params_without_memory_grow(1, 0, &sendCookies_param); + if (sendCookies) { + zephir_update_property_zval(this_ptr, ZEND_STRL("sendCookies"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("sendCookies"), &__$false); } - RETURN_THIS(); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, getTimestamp) +static PHP_METHOD(Phalcon_Mvc_Application, sendHeadersOnHandleRequest) { - zval *timestamp_param = NULL, _0; - zend_long timestamp; + zval *sendHeaders_param = NULL, __$true, __$false; + zend_bool sendHeaders; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(timestamp) + Z_PARAM_BOOL(sendHeaders) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, ×tamp_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("timeShift"), PH_NOISY_CC | PH_READONLY); - RETURN_LONG((timestamp + zephir_get_numberval(&_0))); + zephir_fetch_params_without_memory_grow(1, 0, &sendHeaders_param); + if (sendHeaders) { + zephir_update_property_zval(this_ptr, ZEND_STRL("sendHeaders"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("sendHeaders"), &__$false); + } + RETURN_THISW(); } -zend_object *zephir_init_properties_Phalcon_Encryption_Security_JWT_Validator(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Mvc_Application, useImplicitView) { - zval _0, _2, _1$$3, _3$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - + zval *implicitView_param = NULL, __$true, __$false; + zend_bool implicitView; + zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("errors"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("errors"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("claims"), &_3$$4); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(implicitView) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &implicitView_param); + if (implicitView) { + zephir_update_property_zval(this_ptr, ZEND_STRL("implicitView"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("implicitView"), &__$false); } + RETURN_THISW(); } @@ -20930,51 +21500,27 @@ zend_object *zephir_init_properties_Phalcon_Encryption_Security_JWT_Validator(ze -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_AbstractItem) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Controller) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT\\Token, AbstractItem, phalcon, encryption_security_jwt_token_abstractitem, phalcon_encryption_security_jwt_token_abstractitem_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_encryption_security_jwt_token_abstractitem_ce, SL("data"), ZEND_ACC_PROTECTED); - phalcon_encryption_security_jwt_token_abstractitem_ce->create_object = zephir_init_properties_Phalcon_Encryption_Security_JWT_Token_AbstractItem; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Controller, phalcon, mvc_controller, phalcon_di_injectable_ce, phalcon_mvc_controller_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + zend_class_implements(phalcon_mvc_controller_ce, 1, phalcon_mvc_controllerinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_AbstractItem, getEncoded) -{ - zval _0, _1; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_1, &_0, SL("encoded"), PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/JWT/Token/AbstractItem.zep", 28); - RETURN_CTORW(&_1); -} - -zend_object *zephir_init_properties_Phalcon_Encryption_Security_JWT_Token_AbstractItem(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Mvc_Controller, __construct) { - zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("data"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("onconstruct")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "onconstruct", NULL, 0); + zephir_check_call_status(); } + ZEPHIR_MM_RESTORE(); } @@ -20987,29 +21533,9 @@ zend_object *zephir_init_properties_Phalcon_Encryption_Security_JWT_Token_Abstra -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_Enum) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_ControllerInterface) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT\\Token, Enum, phalcon, encryption_security_jwt_token_enum, NULL, 0); - - zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("TYPE"), "typ"); - - zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("ALGO"), "alg"); - - zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("CONTENT_TYPE"), "cty"); - - zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("AUDIENCE"), "aud"); - - zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("EXPIRATION_TIME"), "exp"); - - zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("ID"), "jti"); - - zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("ISSUED_AT"), "iat"); - - zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("ISSUER"), "iss"); - - zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("NOT_BEFORE"), "nbf"); - - zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("SUBJECT"), "sub"); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ControllerInterface, phalcon, mvc_controllerinterface, NULL); return SUCCESS; } @@ -21024,471 +21550,287 @@ ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_Enum) -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_Item) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Dispatcher) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Security\\JWT\\Token, Item, phalcon, encryption_security_jwt_token_item, phalcon_encryption_security_jwt_token_abstractitem_ce, phalcon_encryption_security_jwt_token_item_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Dispatcher, phalcon, mvc_dispatcher, phalcon_dispatcher_abstractdispatcher_ce, phalcon_mvc_dispatcher_method_entry, 0); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Item, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval encoded; - zval *payload_param = NULL, *encoded_param = NULL, _0, _1; - zval payload; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&payload); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&encoded); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ARRAY(payload) - Z_PARAM_STR(encoded) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &payload_param, &encoded_param); - ZEPHIR_OBS_COPY_OR_DUP(&payload, payload_param); - if (UNEXPECTED(Z_TYPE_P(encoded_param) != IS_STRING && Z_TYPE_P(encoded_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'encoded' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(encoded_param) == IS_STRING)) { - zephir_get_strval(&encoded, encoded_param); - } else { - ZEPHIR_INIT_VAR(&encoded); - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "encoded"); - zephir_update_property_array(this_ptr, SL("data"), &_0, &encoded); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "payload"); - zephir_update_property_array(this_ptr, SL("data"), &_1, &payload); - ZEPHIR_MM_RESTORE(); + zend_declare_property_string(phalcon_mvc_dispatcher_ce, SL("defaultAction"), "index", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_mvc_dispatcher_ce, SL("defaultHandler"), "index", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_mvc_dispatcher_ce, SL("handlerSuffix"), "Controller", ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_mvc_dispatcher_ce, 1, phalcon_mvc_dispatcherinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Item, get) +static PHP_METHOD(Phalcon_Mvc_Dispatcher, forward) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null, _0, _1, _2, _3; - zval name; + zval *forward_param = NULL, eventsManager, _0, _1$$3; + zval forward; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&forward); + ZVAL_UNDEF(&eventsManager); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(name) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(forward) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &name_param, &defaultValue); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; + zephir_fetch_params(1, 1, 0, &forward_param); + zephir_get_arrval(&forward, forward_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_0); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "dispatch:beforeForward"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_1$$3, this_ptr, &forward); + zephir_check_call_status(); } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, 0, &name); + ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_dispatcher_ce, getThis(), "forward", NULL, 0, &forward); zephir_check_call_status(); - if (!(zephir_is_true(&_0))) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); - } - zephir_read_property(&_1, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_2, &_1, SL("payload"), PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/JWT/Token/Item.zep", 42); - zephir_array_fetch(&_3, &_2, &name, PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/JWT/Token/Item.zep", 42); - RETURN_CTOR(&_3); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Item, getPayload) +static PHP_METHOD(Phalcon_Mvc_Dispatcher, getActiveController) { - zval _0, _1; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_1, &_0, SL("payload"), PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/JWT/Token/Item.zep", 50); - RETURN_CTORW(&_1); + RETURN_MEMBER(getThis(), "activeHandler"); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Item, has) +static PHP_METHOD(Phalcon_Mvc_Dispatcher, getControllerClass) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, _0, _1; - zval name; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_1, &_0, SL("payload"), PH_READONLY, "phalcon/Encryption/Security/JWT/Token/Item.zep", 60); - RETURN_MM_BOOL(zephir_array_isset(&_1, &name)); -} - + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "gethandlerclass", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); +} +static PHP_METHOD(Phalcon_Mvc_Dispatcher, getControllerName) +{ -#ifdef HAVE_CONFIG_H -#endif + RETURN_MEMBER(getThis(), "handlerName"); +} +static PHP_METHOD(Phalcon_Mvc_Dispatcher, getLastController) +{ + RETURN_MEMBER(getThis(), "lastHandler"); +} +static PHP_METHOD(Phalcon_Mvc_Dispatcher, getPreviousActionName) +{ + RETURN_MEMBER(getThis(), "previousActionName"); +} -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_Parser) +static PHP_METHOD(Phalcon_Mvc_Dispatcher, getPreviousControllerName) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT\\Token, Parser, phalcon, encryption_security_jwt_token_parser, phalcon_encryption_security_jwt_token_parser_method_entry, 0); - zend_declare_property_null(phalcon_encryption_security_jwt_token_parser_ce, SL("decode"), ZEND_ACC_PRIVATE); - return SUCCESS; + RETURN_MEMBER(getThis(), "previousHandlerName"); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, __construct) +static PHP_METHOD(Phalcon_Mvc_Dispatcher, getPreviousNamespaceName) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *decode = NULL, decode_sub, __$null, service; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&decode_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&service); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(decode, phalcon_support_helper_json_decode_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &decode); - if (!decode) { - decode = &decode_sub; - decode = &__$null; - } - ZEPHIR_CPY_WRT(&service, decode); - if (Z_TYPE_P(&service) == IS_NULL) { - ZEPHIR_INIT_NVAR(&service); - object_init_ex(&service, phalcon_support_helper_json_decode_ce); - if (zephir_has_constructor(&service)) { - ZEPHIR_CALL_METHOD(NULL, &service, "__construct", NULL, 0); - zephir_check_call_status(); - } - } - zephir_update_property_zval(this_ptr, ZEND_STRL("decode"), &service); - ZEPHIR_MM_RESTORE(); + RETURN_MEMBER(getThis(), "previousNamespaceName"); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, parse) +static PHP_METHOD(Phalcon_Mvc_Dispatcher, setControllerName) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *token_param = NULL, claims, encodedClaims, encodedHeaders, encodedSignature, headers, results, signature; - zval token; + zval *controllerName_param = NULL; + zval controllerName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&token); - ZVAL_UNDEF(&claims); - ZVAL_UNDEF(&encodedClaims); - ZVAL_UNDEF(&encodedHeaders); - ZVAL_UNDEF(&encodedSignature); - ZVAL_UNDEF(&headers); - ZVAL_UNDEF(&results); - ZVAL_UNDEF(&signature); + ZVAL_UNDEF(&controllerName); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(token) + Z_PARAM_STR(controllerName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &token_param); - if (UNEXPECTED(Z_TYPE_P(token_param) != IS_STRING && Z_TYPE_P(token_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'token' must be of the type string")); + zephir_fetch_params(1, 1, 0, &controllerName_param); + if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(token_param) == IS_STRING)) { - zephir_get_strval(&token, token_param); + if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { + zephir_get_strval(&controllerName, controllerName_param); } else { - ZEPHIR_INIT_VAR(&token); + ZEPHIR_INIT_VAR(&controllerName); } - ZEPHIR_CALL_METHOD(&results, this_ptr, "parsetoken", NULL, 261, &token); - zephir_check_call_status(); - zephir_memory_observe(&encodedHeaders); - zephir_array_fetch_long(&encodedHeaders, &results, 0, PH_NOISY, "phalcon/Encryption/Security/JWT/Token/Parser.zep", 55); - zephir_memory_observe(&encodedClaims); - zephir_array_fetch_long(&encodedClaims, &results, 1, PH_NOISY, "phalcon/Encryption/Security/JWT/Token/Parser.zep", 56); - zephir_memory_observe(&encodedSignature); - zephir_array_fetch_long(&encodedSignature, &results, 2, PH_NOISY, "phalcon/Encryption/Security/JWT/Token/Parser.zep", 57); - ZEPHIR_CALL_METHOD(&headers, this_ptr, "decodeheaders", NULL, 262, &encodedHeaders); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&claims, this_ptr, "decodeclaims", NULL, 263, &encodedClaims); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&signature, this_ptr, "decodesignature", NULL, 264, &headers, &encodedSignature); - zephir_check_call_status(); - object_init_ex(return_value, phalcon_encryption_security_jwt_token_token_ce); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 259, &headers, &claims, &signature); - zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("handlerName"), &controllerName); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, decodeClaims) +static PHP_METHOD(Phalcon_Mvc_Dispatcher, setControllerSuffix) { - zval _5$$4; - zend_bool _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *claims_param = NULL, decoded, _0, _1, _2, _4, _6$$4; - zval claims; + zval *controllerSuffix_param = NULL; + zval controllerSuffix; zval *this_ptr = getThis(); - ZVAL_UNDEF(&claims); - ZVAL_UNDEF(&decoded); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&controllerSuffix); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(claims) + Z_PARAM_STR(controllerSuffix) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &claims_param); - zephir_get_strval(&claims, claims_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("decode"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "decodeurl", NULL, 265, &claims); - zephir_check_call_status(); - ZVAL_BOOL(&_2, 1); - ZEPHIR_CALL_METHOD(&decoded, &_0, "__invoke", NULL, 0, &_1, &_2); - zephir_check_call_status(); - if (Z_TYPE_P(&decoded) != IS_ARRAY) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Invalid Claims (not an array)", "phalcon/Encryption/Security/JWT/Token/Parser.zep", 81); - return; - } - _3 = zephir_array_isset_string(&decoded, SL("aud")); - if (_3) { - zephir_memory_observe(&_4); - zephir_array_fetch_string(&_4, &decoded, SL("aud"), PH_NOISY, "phalcon/Encryption/Security/JWT/Token/Parser.zep", 87); - _3 = Z_TYPE_P(&_4) != IS_ARRAY; + zephir_fetch_params(1, 1, 0, &controllerSuffix_param); + if (UNEXPECTED(Z_TYPE_P(controllerSuffix_param) != IS_STRING && Z_TYPE_P(controllerSuffix_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerSuffix' must be of the type string")); + RETURN_MM_NULL(); } - if (_3) { - ZEPHIR_INIT_VAR(&_5$$4); - zephir_create_array(&_5$$4, 1, 0); - zephir_memory_observe(&_6$$4); - zephir_array_fetch_string(&_6$$4, &decoded, SL("aud"), PH_NOISY, "phalcon/Encryption/Security/JWT/Token/Parser.zep", 88); - zephir_array_fast_append(&_5$$4, &_6$$4); - zephir_array_update_string(&decoded, SL("aud"), &_5$$4, PH_COPY | PH_SEPARATE); + if (EXPECTED(Z_TYPE_P(controllerSuffix_param) == IS_STRING)) { + zephir_get_strval(&controllerSuffix, controllerSuffix_param); + } else { + ZEPHIR_INIT_VAR(&controllerSuffix); } - object_init_ex(return_value, phalcon_encryption_security_jwt_token_item_ce); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 257, &decoded, &claims); - zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("handlerSuffix"), &controllerSuffix); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, decodeHeaders) +static PHP_METHOD(Phalcon_Mvc_Dispatcher, setDefaultController) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *headers_param = NULL, decoded, _0, _1, _2; - zval headers; + zval *controllerName_param = NULL; + zval controllerName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&headers); - ZVAL_UNDEF(&decoded); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&controllerName); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(headers) + Z_PARAM_STR(controllerName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &headers_param); - zephir_get_strval(&headers, headers_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("decode"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "decodeurl", NULL, 265, &headers); - zephir_check_call_status(); - ZVAL_BOOL(&_2, 1); - ZEPHIR_CALL_METHOD(&decoded, &_0, "__invoke", NULL, 0, &_1, &_2); - zephir_check_call_status(); - if (Z_TYPE_P(&decoded) != IS_ARRAY) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Invalid Header (not an array)", "phalcon/Encryption/Security/JWT/Token/Parser.zep", 110); - return; + zephir_fetch_params(1, 1, 0, &controllerName_param); + if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); + RETURN_MM_NULL(); } - if (!(zephir_array_isset_string(&decoded, SL("typ")))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Invalid Header (missing 'typ' element)", "phalcon/Encryption/Security/JWT/Token/Parser.zep", 116); - return; + if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { + zephir_get_strval(&controllerName, controllerName_param); + } else { + ZEPHIR_INIT_VAR(&controllerName); } - object_init_ex(return_value, phalcon_encryption_security_jwt_token_item_ce); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 257, &decoded, &headers); - zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultHandler"), &controllerName); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, decodeSignature) +static PHP_METHOD(Phalcon_Mvc_Dispatcher, handleException) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval signature; - zval *headers, headers_sub, *signature_param = NULL, algo, decoded, _0, _1, _2; + zval *exception, exception_sub, eventsManager, _0, _1$$3, _2$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&headers_sub); - ZVAL_UNDEF(&algo); - ZVAL_UNDEF(&decoded); + ZVAL_UNDEF(&exception_sub); + ZVAL_UNDEF(&eventsManager); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&signature); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(headers, phalcon_encryption_security_jwt_token_item_ce) - Z_PARAM_STR(signature) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &headers, &signature_param); - zephir_get_strval(&signature, signature_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "alg"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "none"); - ZEPHIR_CALL_METHOD(&algo, headers, "get", NULL, 0, &_0, &_1); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "none"); - if (ZEPHIR_IS_IDENTICAL(&_2, &algo)) { - ZEPHIR_INIT_VAR(&decoded); - ZVAL_STRING(&decoded, ""); - ZEPHIR_INIT_NVAR(&signature); - } else { - ZEPHIR_CALL_METHOD(&decoded, this_ptr, "decodeurl", NULL, 265, &signature); - zephir_check_call_status(); - } - object_init_ex(return_value, phalcon_encryption_security_jwt_token_signature_ce); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 258, &decoded, &signature); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, parseToken) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *token_param = NULL, parts; - zval token; - - ZVAL_UNDEF(&token); - ZVAL_UNDEF(&parts); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(token) + Z_PARAM_OBJECT_OF_CLASS(exception, zend_ce_exception) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &token_param); - if (UNEXPECTED(Z_TYPE_P(token_param) != IS_STRING && Z_TYPE_P(token_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'token' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(token_param) == IS_STRING)) { - zephir_get_strval(&token, token_param); - } else { - ZEPHIR_INIT_VAR(&token); - } - ZEPHIR_INIT_VAR(&parts); - zephir_fast_explode_str(&parts, SL("."), &token, LONG_MAX); - if (zephir_fast_count_int(&parts) != 3) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Invalid JWT string (dots misalignment)", "phalcon/Encryption/Security/JWT/Token/Parser.zep", 162); - return; + zephir_fetch_params(1, 1, 0, &exception); + zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_0); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "dispatch:beforeException"); + ZEPHIR_CALL_METHOD(&_1$$3, &eventsManager, "fire", NULL, 0, &_2$$3, this_ptr, exception); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$3)) { + RETURN_MM_BOOL(0); + } } - RETURN_CCTOR(&parts); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, decodeUrl) +static PHP_METHOD(Phalcon_Mvc_Dispatcher, throwDispatchException) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, remainder = 0; - zval *input_param = NULL, data, _3, _4, _5, _0$$3, _1$$3, _2$$3; - zval input; + zend_long exceptionCode, ZEPHIR_LAST_CALL_STATUS; + zval *message_param = NULL, *exceptionCode_param = NULL, container, response, exception, _0, _4, _5, _1$$3, _2$$3, _3$$3; + zval message; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&response); + ZVAL_UNDEF(&exception); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_2$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(input) + ZVAL_UNDEF(&_3$$3); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(exceptionCode) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &input_param); - if (UNEXPECTED(Z_TYPE_P(input_param) != IS_STRING && Z_TYPE_P(input_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'input' must be of the type string")); + zephir_fetch_params(1, 1, 1, &message_param, &exceptionCode_param); + if (UNEXPECTED(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(input_param) == IS_STRING)) { - zephir_get_strval(&input, input_param); + if (EXPECTED(Z_TYPE_P(message_param) == IS_STRING)) { + zephir_get_strval(&message, message_param); } else { - ZEPHIR_INIT_VAR(&input); + ZEPHIR_INIT_VAR(&message); } - remainder = (long) (zephir_safe_mod_long_long(zephir_fast_strlen_ev(&input), 4)); - if (remainder) { - ZEPHIR_INIT_VAR(&_0$$3); - ZVAL_STRING(&_0$$3, "="); - ZVAL_LONG(&_1$$3, (4 - remainder)); - ZEPHIR_CALL_FUNCTION(&_2$$3, "str_repeat", NULL, 1, &_0$$3, &_1$$3); + if (!exceptionCode_param) { + exceptionCode = 0; + } else { + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_0); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_mvc_dispatcher_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "A dependency injection container is required to access the 'response' service"); + ZVAL_LONG(&_3$$3, 0); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3, &_3$$3); zephir_check_call_status(); - zephir_concat_self(&input, &_2$$3); + zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Dispatcher.zep", 228); + ZEPHIR_MM_RESTORE(); + return; } - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "-_"); - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, "+/"); - ZEPHIR_CALL_FUNCTION(&_5, "strtr", NULL, 5, &input, &_3, &_4); + ZEPHIR_INIT_VAR(&_5); + ZVAL_STRING(&_5, "response"); + ZEPHIR_CALL_METHOD(&_4, &container, "getshared", NULL, 0, &_5); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&data, "base64_decode", NULL, 230, &_5); + ZEPHIR_CPY_WRT(&response, &_4); + ZVAL_LONG(&_0, 404); + ZEPHIR_INIT_NVAR(&_5); + ZVAL_STRING(&_5, "Not Found"); + ZEPHIR_CALL_METHOD(NULL, &response, "setstatuscode", NULL, 0, &_0, &_5); zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&data)) { - ZEPHIR_INIT_NVAR(&data); - ZVAL_STRING(&data, ""); + ZEPHIR_INIT_VAR(&exception); + object_init_ex(&exception, phalcon_mvc_dispatcher_exception_ce); + ZVAL_LONG(&_0, exceptionCode); + ZEPHIR_CALL_METHOD(NULL, &exception, "__construct", NULL, 33, &message, &_0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "handleexception", NULL, 0, &exception); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_4)) { + RETURN_MM_BOOL(0); } - RETURN_CCTOR(&data); + zephir_throw_exception_debug(&exception, "phalcon/Mvc/Dispatcher.zep", 250); + ZEPHIR_MM_RESTORE(); + return; } @@ -21501,81 +21843,39 @@ static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, decodeUrl) -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_Signature) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_DispatcherInterface) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Security\\JWT\\Token, Signature, phalcon, encryption_security_jwt_token_signature, phalcon_encryption_security_jwt_token_abstractitem_ce, phalcon_encryption_security_jwt_token_signature_method_entry, 0); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, DispatcherInterface, phalcon, mvc_dispatcherinterface, phalcon_mvc_dispatcherinterface_method_entry); + zend_class_implements(phalcon_mvc_dispatcherinterface_ce, 1, phalcon_dispatcher_dispatcherinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Signature, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *hash_param = NULL, *encoded_param = NULL, _0, _1; - zval hash, encoded; - zval *this_ptr = getThis(); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_DispatcherInterface, getActiveController); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_DispatcherInterface, getControllerName); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_DispatcherInterface, getLastController); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_DispatcherInterface, setControllerSuffix); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_DispatcherInterface, setControllerName); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_DispatcherInterface, setDefaultController); - ZVAL_UNDEF(&hash); - ZVAL_UNDEF(&encoded); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_STR(hash) - Z_PARAM_STR(encoded) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &hash_param, &encoded_param); - if (!hash_param) { - ZEPHIR_INIT_VAR(&hash); - ZVAL_STRING(&hash, ""); - } else { - if (UNEXPECTED(Z_TYPE_P(hash_param) != IS_STRING && Z_TYPE_P(hash_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'hash' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(hash_param) == IS_STRING)) { - zephir_get_strval(&hash, hash_param); - } else { - ZEPHIR_INIT_VAR(&hash); - } - } - if (!encoded_param) { - ZEPHIR_INIT_VAR(&encoded); - ZVAL_STRING(&encoded, ""); - } else { - if (UNEXPECTED(Z_TYPE_P(encoded_param) != IS_STRING && Z_TYPE_P(encoded_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'encoded' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(encoded_param) == IS_STRING)) { - zephir_get_strval(&encoded, encoded_param); - } else { - ZEPHIR_INIT_VAR(&encoded); - } - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "encoded"); - zephir_update_property_array(this_ptr, SL("data"), &_0, &encoded); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "hash"); - zephir_update_property_array(this_ptr, SL("data"), &_1, &hash); - ZEPHIR_MM_RESTORE(); -} -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Signature, getHash) + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_EntityInterface) { - zval _0, _1; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, EntityInterface, phalcon, mvc_entityinterface, phalcon_mvc_entityinterface_method_entry); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_1, &_0, SL("hash"), PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/JWT/Token/Signature.zep", 35); - RETURN_CTORW(&_1); + return SUCCESS; } +ZEPHIR_DOC_METHOD(Phalcon_Mvc_EntityInterface, readAttribute); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_EntityInterface, writeAttribute); @@ -21586,1118 +21886,1915 @@ static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Signature, getHash) -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_Token) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT\\Token, Token, phalcon, encryption_security_jwt_token_token, phalcon_encryption_security_jwt_token_token_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Micro, phalcon, mvc_micro, phalcon_di_injectable_ce, phalcon_mvc_micro_method_entry, 0); - zend_declare_property_null(phalcon_encryption_security_jwt_token_token_ce, SL("claims"), ZEND_ACC_PRIVATE); - zend_declare_property_null(phalcon_encryption_security_jwt_token_token_ce, SL("headers"), ZEND_ACC_PRIVATE); - zend_declare_property_null(phalcon_encryption_security_jwt_token_token_ce, SL("signature"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_mvc_micro_ce, SL("activeHandler"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_micro_ce, SL("afterBindingHandlers"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_micro_ce, SL("afterHandlers"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_micro_ce, SL("beforeHandlers"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_micro_ce, SL("container"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_micro_ce, SL("errorHandler"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_micro_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_micro_ce, SL("finishHandlers"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_micro_ce, SL("handlers"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_micro_ce, SL("modelBinder"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_micro_ce, SL("notFoundHandler"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_micro_ce, SL("responseHandler"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_micro_ce, SL("returnedValue"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_micro_ce, SL("router"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_mvc_micro_ce, SL("stopped"), 0, ZEND_ACC_PROTECTED); + phalcon_mvc_micro_ce->create_object = zephir_init_properties_Phalcon_Mvc_Micro; + + zend_class_implements(phalcon_mvc_micro_ce, 1, zend_ce_arrayaccess); + zend_class_implements(phalcon_mvc_micro_ce, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, __construct) +static PHP_METHOD(Phalcon_Mvc_Micro, __construct) { - zval *headers, headers_sub, *claims, claims_sub, *signature, signature_sub; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *container = NULL, container_sub, __$null; zval *this_ptr = getThis(); - ZVAL_UNDEF(&headers_sub); - ZVAL_UNDEF(&claims_sub); - ZVAL_UNDEF(&signature_sub); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_OBJECT_OF_CLASS(headers, phalcon_encryption_security_jwt_token_item_ce) - Z_PARAM_OBJECT_OF_CLASS(claims, phalcon_encryption_security_jwt_token_item_ce) - Z_PARAM_OBJECT_OF_CLASS(signature, phalcon_encryption_security_jwt_token_signature_ce) + ZVAL_UNDEF(&container_sub); + ZVAL_NULL(&__$null); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(container, phalcon_di_diinterface_ce) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(3, 0, &headers, &claims, &signature); - zephir_update_property_zval(this_ptr, ZEND_STRL("headers"), headers); - zephir_update_property_zval(this_ptr, ZEND_STRL("claims"), claims); - zephir_update_property_zval(this_ptr, ZEND_STRL("signature"), signature); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &container); + if (!container) { + container = &container_sub; + container = &__$null; + } + if (Z_TYPE_P(container) != IS_NULL) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdi", NULL, 0, container); + zephir_check_call_status(); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, getClaims) +static PHP_METHOD(Phalcon_Mvc_Micro, after) { + zval *handler, handler_sub; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "claims"); + ZVAL_UNDEF(&handler_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(handler) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &handler); + zephir_update_property_array_append(this_ptr, SL("afterHandlers"), handler); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, getHeaders) +static PHP_METHOD(Phalcon_Mvc_Micro, afterBinding) { + zval *handler, handler_sub; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "headers"); + ZVAL_UNDEF(&handler_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(handler) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &handler); + zephir_update_property_array_append(this_ptr, SL("afterBindingHandlers"), handler); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, getPayload) +static PHP_METHOD(Phalcon_Mvc_Micro, before) +{ + zval *handler, handler_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&handler_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(handler) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &handler); + zephir_update_property_array_append(this_ptr, SL("beforeHandlers"), handler); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Mvc_Micro, delete) { - zval _0, _1, _2, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *routePattern_param = NULL, *handler, handler_sub, router, route, _0; + zval routePattern; zval *this_ptr = getThis(); + ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&router); + ZVAL_UNDEF(&route); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(routePattern) + Z_PARAM_ZVAL(handler) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_1, &_0, "getencoded", NULL, 0); + zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); + if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { + zephir_get_strval(&routePattern, routePattern_param); + } else { + ZEPHIR_INIT_VAR(&routePattern); + } + ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); zephir_check_call_status(); - zephir_read_property(&_2, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_3, &_2, "getencoded", NULL, 0); + ZEPHIR_CALL_METHOD(&route, &router, "adddelete", NULL, 0, &routePattern); zephir_check_call_status(); - ZEPHIR_CONCAT_VSV(return_value, &_1, ".", &_3); - RETURN_MM(); + ZEPHIR_CALL_METHOD(&_0, &route, "getrouteid", NULL, 0); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("handlers"), &_0, handler); + RETURN_CCTOR(&route); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, getSignature) +static PHP_METHOD(Phalcon_Mvc_Micro, error) { + zval *handler, handler_sub; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "signature"); + ZVAL_UNDEF(&handler_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(handler) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &handler); + zephir_update_property_zval(this_ptr, ZEND_STRL("errorHandler"), handler); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, getToken) +static PHP_METHOD(Phalcon_Mvc_Micro, finish) { - zval _0, _1, _2; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *handler, handler_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getpayload", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getsignature", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_2, &_1, "getencoded", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CONCAT_VSV(return_value, &_0, ".", &_2); - RETURN_MM(); + ZVAL_UNDEF(&handler_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(handler) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &handler); + zephir_update_property_array_append(this_ptr, SL("finishHandlers"), handler); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, validate) +static PHP_METHOD(Phalcon_Mvc_Micro, get) { - zend_string *_5; - zend_ulong _4; - zval methods; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *validator, validator_sub, claimId, method, _0, _1, *_2, _3; + zval *routePattern_param = NULL, *handler, handler_sub, router, route, _0; + zval routePattern; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&validator_sub); - ZVAL_UNDEF(&claimId); - ZVAL_UNDEF(&method); + ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&router); + ZVAL_UNDEF(&route); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&methods); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(validator, phalcon_encryption_security_jwt_validator_ce) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(routePattern) + Z_PARAM_ZVAL(handler) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &validator); - ZEPHIR_INIT_VAR(&methods); - zephir_create_array(&methods, 6, 0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "aud"); - ZEPHIR_CALL_METHOD(&_0, validator, "get", NULL, 0, &_1); - zephir_check_call_status(); - zephir_array_update_string(&methods, SL("validateAudience"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "exp"); - ZEPHIR_CALL_METHOD(&_0, validator, "get", NULL, 0, &_1); - zephir_check_call_status(); - zephir_array_update_string(&methods, SL("validateExpiration"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "jti"); - ZEPHIR_CALL_METHOD(&_0, validator, "get", NULL, 0, &_1); - zephir_check_call_status(); - zephir_array_update_string(&methods, SL("validateId"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "iat"); - ZEPHIR_CALL_METHOD(&_0, validator, "get", NULL, 0, &_1); - zephir_check_call_status(); - zephir_array_update_string(&methods, SL("validateIssuedAt"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "iss"); - ZEPHIR_CALL_METHOD(&_0, validator, "get", NULL, 0, &_1); - zephir_check_call_status(); - zephir_array_update_string(&methods, SL("validateIssuer"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "nbf"); - ZEPHIR_CALL_METHOD(&_0, validator, "get", NULL, 0, &_1); - zephir_check_call_status(); - zephir_array_update_string(&methods, SL("validateNotBefore"), &_0, PH_COPY | PH_SEPARATE); - zephir_is_iterable(&methods, 0, "phalcon/Encryption/Security/JWT/Token/Token.zep", 131); - if (Z_TYPE_P(&methods) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&methods), _4, _5, _2) - { - ZEPHIR_INIT_NVAR(&method); - if (_5 != NULL) { - ZVAL_STR_COPY(&method, _5); - } else { - ZVAL_LONG(&method, _4); - } - ZEPHIR_INIT_NVAR(&claimId); - ZVAL_COPY(&claimId, _2); - ZEPHIR_CALL_METHOD_ZVAL(NULL, validator, &method, NULL, 0, &claimId); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); + if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { + zephir_get_strval(&routePattern, routePattern_param); } else { - ZEPHIR_CALL_METHOD(NULL, &methods, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &methods, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3)) { - break; - } - ZEPHIR_CALL_METHOD(&method, &methods, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&claimId, &methods, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD_ZVAL(NULL, validator, &method, NULL, 0, &claimId); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &methods, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&routePattern); } - ZEPHIR_INIT_NVAR(&claimId); - ZEPHIR_INIT_NVAR(&method); - ZEPHIR_RETURN_CALL_METHOD(validator, "geterrors", NULL, 0); + ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_CALL_METHOD(&route, &router, "addget", NULL, 0, &routePattern); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, &route, "getrouteid", NULL, 0); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("handlers"), &_0, handler); + RETURN_CCTOR(&route); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, verify) +static PHP_METHOD(Phalcon_Mvc_Micro, getActiveHandler) +{ + + RETURN_MEMBER(getThis(), "activeHandler"); +} + +static PHP_METHOD(Phalcon_Mvc_Micro, getBoundModels) { + zval modelBinder, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval key; - zval *signer, signer_sub, *key_param = NULL, _0, _1, _2, _3, _4, _5, _6; zval *this_ptr = getThis(); - ZVAL_UNDEF(&signer_sub); + ZVAL_UNDEF(&modelBinder); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&key); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(signer, phalcon_encryption_security_jwt_signer_signerinterface_ce) - Z_PARAM_STR(key) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &signer, &key_param); - zephir_get_strval(&key, key_param); - ZEPHIR_CALL_METHOD(&_0, signer, "getalgheader", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getheaders", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "alg"); - ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_3); - zephir_check_call_status(); - if (!ZEPHIR_IS_IDENTICAL(&_0, &_2)) { - RETURN_MM_BOOL(0); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelBinder"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&modelBinder, &_0); + if (Z_TYPE_P(&modelBinder) == IS_NULL) { + array_init(return_value); + RETURN_MM(); } - zephir_read_property(&_4, this_ptr, ZEND_STRL("signature"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_5, &_4, "gethash", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_6, this_ptr, "getpayload", NULL, 0); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(signer, "verify", NULL, 0, &_5, &_6, &key); + ZEPHIR_RETURN_CALL_METHOD(&modelBinder, "getboundmodels", NULL, 0); zephir_check_call_status(); RETURN_MM(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Signer_AbstractSigner) +static PHP_METHOD(Phalcon_Mvc_Micro, getEventsManager) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT\\Signer, AbstractSigner, phalcon, encryption_security_jwt_signer_abstractsigner, phalcon_encryption_security_jwt_signer_abstractsigner_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zend_declare_property_string(phalcon_encryption_security_jwt_signer_abstractsigner_ce, SL("algorithm"), "", ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_encryption_security_jwt_signer_abstractsigner_ce, 1, phalcon_encryption_security_jwt_signer_signerinterface_ce); - return SUCCESS; + RETURN_MEMBER(getThis(), "eventsManager"); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_AbstractSigner, getAlgorithm) +static PHP_METHOD(Phalcon_Mvc_Micro, setEventsManager) { + zval *eventsManager, eventsManager_sub; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "algorithm"); + ZVAL_UNDEF(&eventsManager_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); + zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); } +static PHP_METHOD(Phalcon_Mvc_Micro, getHandlers) +{ + RETURN_MEMBER(getThis(), "handlers"); +} +static PHP_METHOD(Phalcon_Mvc_Micro, getModelBinder) +{ -#ifdef HAVE_CONFIG_H -#endif - - - - + RETURN_MEMBER(getThis(), "modelBinder"); +} -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Signer_Hmac) +static PHP_METHOD(Phalcon_Mvc_Micro, getReturnedValue) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Security\\JWT\\Signer, Hmac, phalcon, encryption_security_jwt_signer_hmac, phalcon_encryption_security_jwt_signer_abstractsigner_ce, phalcon_encryption_security_jwt_signer_hmac_method_entry, 0); - return SUCCESS; + RETURN_MEMBER(getThis(), "returnedValue"); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_Hmac, __construct) +static PHP_METHOD(Phalcon_Mvc_Micro, getRouter) { - zval supported; + zval _0, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *algo_param = NULL; - zval algo; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&algo); - ZVAL_UNDEF(&supported); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_STR(algo) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &algo_param); - if (!algo_param) { - ZEPHIR_INIT_VAR(&algo); - ZVAL_STRING(&algo, "sha512"); - } else { - if (UNEXPECTED(Z_TYPE_P(algo_param) != IS_STRING && Z_TYPE_P(algo_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'algo' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(algo_param) == IS_STRING)) { - zephir_get_strval(&algo, algo_param); - } else { - ZEPHIR_INIT_VAR(&algo); - } - } - ZEPHIR_INIT_VAR(&supported); - zephir_create_array(&supported, 3, 0); - add_assoc_long_ex(&supported, SL("sha512"), 1); - add_assoc_long_ex(&supported, SL("sha384"), 1); - add_assoc_long_ex(&supported, SL("sha256"), 1); - if (!(zephir_array_isset(&supported, &algo))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_unsupportedalgorithmexception_ce, "Unsupported HMAC algorithm", "phalcon/Encryption/Security/JWT/Signer/Hmac.zep", 40); - return; + + zephir_read_property(&_0, this_ptr, ZEND_STRL("router"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "router"); + ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "getsharedservice", NULL, 0, &_2$$3); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("router"), &_1$$3); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("router"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_3$$3, "clear", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("router"), PH_NOISY_CC | PH_READONLY); + ZVAL_BOOL(&_5$$3, 1); + ZEPHIR_CALL_METHOD(NULL, &_4$$3, "removeextraslashes", NULL, 0, &_5$$3); + zephir_check_call_status(); } - zephir_update_property_zval(this_ptr, ZEND_STRL("algorithm"), &algo); - ZEPHIR_MM_RESTORE(); + RETURN_MM_MEMBER(getThis(), "router"); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_Hmac, getAlgHeader) +static PHP_METHOD(Phalcon_Mvc_Micro, getService) { - zval _0, _1, _2, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *serviceName_param = NULL, _0, _2, _1$$3; + zval serviceName; zval *this_ptr = getThis(); + ZVAL_UNDEF(&serviceName); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("algorithm"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "sha"); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, ""); - zephir_fast_str_replace(&_0, &_2, &_3, &_1); - ZEPHIR_CONCAT_SV(return_value, "HS", &_0); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_Hmac, sign) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *payload_param = NULL, *passphrase_param = NULL; - zval payload, passphrase; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&payload); - ZVAL_UNDEF(&passphrase); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(payload) - Z_PARAM_STR(passphrase) + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(serviceName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &payload_param, &passphrase_param); - if (UNEXPECTED(Z_TYPE_P(payload_param) != IS_STRING && Z_TYPE_P(payload_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'payload' must be of the type string")); + zephir_fetch_params(1, 1, 0, &serviceName_param); + if (UNEXPECTED(Z_TYPE_P(serviceName_param) != IS_STRING && Z_TYPE_P(serviceName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'serviceName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(payload_param) == IS_STRING)) { - zephir_get_strval(&payload, payload_param); + if (EXPECTED(Z_TYPE_P(serviceName_param) == IS_STRING)) { + zephir_get_strval(&serviceName, serviceName_param); } else { - ZEPHIR_INIT_VAR(&payload); - } - if (UNEXPECTED(Z_TYPE_P(passphrase_param) != IS_STRING && Z_TYPE_P(passphrase_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'passphrase' must be of the type string")); - RETURN_MM_NULL(); + ZEPHIR_INIT_VAR(&serviceName); } - if (EXPECTED(Z_TYPE_P(passphrase_param) == IS_STRING)) { - zephir_get_strval(&passphrase, passphrase_param); - } else { - ZEPHIR_INIT_VAR(&passphrase); + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_di_factorydefault_ce); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 416); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &_1$$3); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "gethash", NULL, 260, &payload, &passphrase); + zephir_read_property(&_2, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_2, "get", NULL, 0, &serviceName); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_Hmac, verify) +static PHP_METHOD(Phalcon_Mvc_Micro, getSharedService) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *source_param = NULL, *payload_param = NULL, *passphrase_param = NULL, _0; - zval source, payload, passphrase; + zval *serviceName_param = NULL, _0, _2, _1$$3; + zval serviceName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&payload); - ZVAL_UNDEF(&passphrase); + ZVAL_UNDEF(&serviceName); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_STR(source) - Z_PARAM_STR(payload) - Z_PARAM_STR(passphrase) + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(serviceName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &source_param, &payload_param, &passphrase_param); - zephir_get_strval(&source, source_param); - zephir_get_strval(&payload, payload_param); - zephir_get_strval(&passphrase, passphrase_param); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "gethash", NULL, 260, &payload, &passphrase); + zephir_fetch_params(1, 1, 0, &serviceName_param); + if (UNEXPECTED(Z_TYPE_P(serviceName_param) != IS_STRING && Z_TYPE_P(serviceName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'serviceName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(serviceName_param) == IS_STRING)) { + zephir_get_strval(&serviceName, serviceName_param); + } else { + ZEPHIR_INIT_VAR(&serviceName); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_di_factorydefault_ce); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 416); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &_1$$3); + } + zephir_read_property(&_2, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_2, "getshared", NULL, 0, &serviceName); zephir_check_call_status(); - RETURN_MM_BOOL(zephir_hash_equals(&source, &_0)); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_Hmac, getHash) +static PHP_METHOD(Phalcon_Mvc_Micro, handle) { + zval _81$$59, _86$$64, _95$$69; + zend_class_entry *_28$$21; + zend_bool _26$$7, _37$$7, _18$$11, _22$$16, _33$$25, _44$$31, _48$$36, _57$$42, _61$$47, _78$$57, _83$$62, _100$$79, _101$$79; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *payload_param = NULL, *passphrase_param = NULL, __$true, _0; - zval payload, passphrase; + zval *uri_param = NULL, __$true, __$false, container, status, router, matchedRoute, handler, beforeHandlers, params, returnedValue, e, afterHandlers, notFoundHandler, finishHandlers, finish, before, after, response, modelBinder, routeName, realHandler, methodName, lazyReturned, afterBindingHandlers, afterBinding, _0, _88, _1$$4, _5$$4, _6$$4, _72$$4, _75$$4, *_76$$4, _77$$4, _2$$5, _3$$5, _4$$5, _7$$7, _8$$7, _11$$7, _15$$7, *_16$$7, _17$$7, _41$$7, *_42$$7, _43$$7, _54$$7, *_55$$7, _56$$7, _9$$8, _10$$8, _12$$9, _13$$9, _14$$9, _21$$11, _19$$14, _20$$14, _25$$16, _23$$19, _24$$19, _27$$21, _29$$23, _30$$24, _31$$24, _32$$22, _34$$26, _35$$26, _36$$26, _38$$29, _39$$29, _40$$29, _47$$31, _45$$34, _46$$34, _51$$36, _49$$39, _50$$39, _52$$41, _53$$41, _60$$42, _58$$45, _59$$45, _64$$47, _62$$50, _63$$50, _65$$52, _69$$52, _66$$53, _67$$53, _68$$53, _70$$55, _71$$55, _73$$56, _74$$56, _82$$57, _79$$60, _80$$60, _87$$62, _84$$65, _85$$65, _89$$67, _92$$67, _90$$68, _91$$68, _93$$69, _94$$69, _96$$77, _97$$77, _98$$80, _99$$80, _102$$79; + zval uri, bindCacheKey; zval *this_ptr = getThis(); - ZVAL_UNDEF(&payload); - ZVAL_UNDEF(&passphrase); + ZVAL_UNDEF(&uri); + ZVAL_UNDEF(&bindCacheKey); ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&status); + ZVAL_UNDEF(&router); + ZVAL_UNDEF(&matchedRoute); + ZVAL_UNDEF(&handler); + ZVAL_UNDEF(&beforeHandlers); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&returnedValue); + ZVAL_UNDEF(&e); + ZVAL_UNDEF(&afterHandlers); + ZVAL_UNDEF(¬FoundHandler); + ZVAL_UNDEF(&finishHandlers); + ZVAL_UNDEF(&finish); + ZVAL_UNDEF(&before); + ZVAL_UNDEF(&after); + ZVAL_UNDEF(&response); + ZVAL_UNDEF(&modelBinder); + ZVAL_UNDEF(&routeName); + ZVAL_UNDEF(&realHandler); + ZVAL_UNDEF(&methodName); + ZVAL_UNDEF(&lazyReturned); + ZVAL_UNDEF(&afterBindingHandlers); + ZVAL_UNDEF(&afterBinding); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(payload) - Z_PARAM_STR(passphrase) + ZVAL_UNDEF(&_88); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_72$$4); + ZVAL_UNDEF(&_75$$4); + ZVAL_UNDEF(&_77$$4); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_7$$7); + ZVAL_UNDEF(&_8$$7); + ZVAL_UNDEF(&_11$$7); + ZVAL_UNDEF(&_15$$7); + ZVAL_UNDEF(&_17$$7); + ZVAL_UNDEF(&_41$$7); + ZVAL_UNDEF(&_43$$7); + ZVAL_UNDEF(&_54$$7); + ZVAL_UNDEF(&_56$$7); + ZVAL_UNDEF(&_9$$8); + ZVAL_UNDEF(&_10$$8); + ZVAL_UNDEF(&_12$$9); + ZVAL_UNDEF(&_13$$9); + ZVAL_UNDEF(&_14$$9); + ZVAL_UNDEF(&_21$$11); + ZVAL_UNDEF(&_19$$14); + ZVAL_UNDEF(&_20$$14); + ZVAL_UNDEF(&_25$$16); + ZVAL_UNDEF(&_23$$19); + ZVAL_UNDEF(&_24$$19); + ZVAL_UNDEF(&_27$$21); + ZVAL_UNDEF(&_29$$23); + ZVAL_UNDEF(&_30$$24); + ZVAL_UNDEF(&_31$$24); + ZVAL_UNDEF(&_32$$22); + ZVAL_UNDEF(&_34$$26); + ZVAL_UNDEF(&_35$$26); + ZVAL_UNDEF(&_36$$26); + ZVAL_UNDEF(&_38$$29); + ZVAL_UNDEF(&_39$$29); + ZVAL_UNDEF(&_40$$29); + ZVAL_UNDEF(&_47$$31); + ZVAL_UNDEF(&_45$$34); + ZVAL_UNDEF(&_46$$34); + ZVAL_UNDEF(&_51$$36); + ZVAL_UNDEF(&_49$$39); + ZVAL_UNDEF(&_50$$39); + ZVAL_UNDEF(&_52$$41); + ZVAL_UNDEF(&_53$$41); + ZVAL_UNDEF(&_60$$42); + ZVAL_UNDEF(&_58$$45); + ZVAL_UNDEF(&_59$$45); + ZVAL_UNDEF(&_64$$47); + ZVAL_UNDEF(&_62$$50); + ZVAL_UNDEF(&_63$$50); + ZVAL_UNDEF(&_65$$52); + ZVAL_UNDEF(&_69$$52); + ZVAL_UNDEF(&_66$$53); + ZVAL_UNDEF(&_67$$53); + ZVAL_UNDEF(&_68$$53); + ZVAL_UNDEF(&_70$$55); + ZVAL_UNDEF(&_71$$55); + ZVAL_UNDEF(&_73$$56); + ZVAL_UNDEF(&_74$$56); + ZVAL_UNDEF(&_82$$57); + ZVAL_UNDEF(&_79$$60); + ZVAL_UNDEF(&_80$$60); + ZVAL_UNDEF(&_87$$62); + ZVAL_UNDEF(&_84$$65); + ZVAL_UNDEF(&_85$$65); + ZVAL_UNDEF(&_89$$67); + ZVAL_UNDEF(&_92$$67); + ZVAL_UNDEF(&_90$$68); + ZVAL_UNDEF(&_91$$68); + ZVAL_UNDEF(&_93$$69); + ZVAL_UNDEF(&_94$$69); + ZVAL_UNDEF(&_96$$77); + ZVAL_UNDEF(&_97$$77); + ZVAL_UNDEF(&_98$$80); + ZVAL_UNDEF(&_99$$80); + ZVAL_UNDEF(&_102$$79); + ZVAL_UNDEF(&_81$$59); + ZVAL_UNDEF(&_86$$64); + ZVAL_UNDEF(&_95$$69); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(uri) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &payload_param, &passphrase_param); - zephir_get_strval(&payload, payload_param); - zephir_get_strval(&passphrase, passphrase_param); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getalgorithm", NULL, 0); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_FUNCTION("hash_hmac", NULL, 229, &_0, &payload, &passphrase, &__$true); - zephir_check_call_status(); - RETURN_MM(); -} + zephir_fetch_params(1, 1, 0, &uri_param); + if (UNEXPECTED(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 of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(uri_param) == IS_STRING)) { + zephir_get_strval(&uri, uri_param); + } else { + ZEPHIR_INIT_VAR(&uri); + } + ZEPHIR_INIT_VAR(&status); + ZVAL_NULL(&status); + ZEPHIR_INIT_VAR(&realHandler); + ZVAL_NULL(&realHandler); + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_0); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "A dependency injection container is required to access micro services", "phalcon/Mvc/Micro.zep", 398); + return; + } + /* try_start_1: */ + ZEPHIR_INIT_VAR(&returnedValue); + ZVAL_NULL(&returnedValue); + zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_1$$4) != IS_NULL) { + zephir_read_property(&_2$$5, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_4$$5); + ZVAL_STRING(&_4$$5, "micro:beforeHandleRoute"); + ZEPHIR_CALL_METHOD(&_3$$5, &_2$$5, "fire", NULL, 0, &_4$$5, this_ptr); + zephir_check_call_status_or_jump(try_end_1); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_3$$5)) { + RETURN_MM_BOOL(0); + } + } + ZEPHIR_INIT_VAR(&_6$$4); + ZVAL_STRING(&_6$$4, "router"); + ZEPHIR_CALL_METHOD(&_5$$4, &container, "getshared", NULL, 0, &_6$$4); + zephir_check_call_status_or_jump(try_end_1); + ZEPHIR_CPY_WRT(&router, &_5$$4); + ZEPHIR_CALL_METHOD(NULL, &router, "handle", NULL, 0, &uri); + zephir_check_call_status_or_jump(try_end_1); + ZEPHIR_CALL_METHOD(&matchedRoute, &router, "getmatchedroute", NULL, 0); + zephir_check_call_status_or_jump(try_end_1); + if (Z_TYPE_P(&matchedRoute) != IS_NULL) { + zephir_memory_observe(&handler); + zephir_read_property(&_7$$7, this_ptr, ZEND_STRL("handlers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_8$$7, &matchedRoute, "getrouteid", NULL, 0); + zephir_check_call_status_or_jump(try_end_1); + if (UNEXPECTED(!(zephir_array_isset_fetch(&handler, &_7$$7, &_8$$7, 0)))) { + ZEPHIR_INIT_VAR(&_9$$8); + object_init_ex(&_9$$8, phalcon_mvc_micro_exception_ce); + ZEPHIR_INIT_VAR(&_10$$8); + ZVAL_STRING(&_10$$8, "Matched route doesn't have an associated handler"); + ZEPHIR_CALL_METHOD(NULL, &_9$$8, "__construct", NULL, 33, &_10$$8); + zephir_check_call_status_or_jump(try_end_1); + zephir_throw_exception_debug(&_9$$8, "phalcon/Mvc/Micro.zep", 432); + goto try_end_1; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("activeHandler"), &handler); + zephir_read_property(&_11$$7, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_11$$7) != IS_NULL) { + zephir_read_property(&_12$$9, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_14$$9); + ZVAL_STRING(&_14$$9, "micro:beforeExecuteRoute"); + ZEPHIR_CALL_METHOD(&_13$$9, &_12$$9, "fire", NULL, 0, &_14$$9, this_ptr); + zephir_check_call_status_or_jump(try_end_1); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_13$$9)) { + RETURN_MM_BOOL(0); + } + ZEPHIR_OBS_NVAR(&handler); + zephir_read_property(&handler, this_ptr, ZEND_STRL("activeHandler"), PH_NOISY_CC); + } + zephir_read_property(&_15$$7, this_ptr, ZEND_STRL("beforeHandlers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&beforeHandlers, &_15$$7); + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$false); + } + zephir_is_iterable(&beforeHandlers, 0, "phalcon/Mvc/Micro.zep", 484); + if (Z_TYPE_P(&beforeHandlers) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&beforeHandlers), _16$$7) + { + ZEPHIR_INIT_NVAR(&before); + ZVAL_COPY(&before, _16$$7); + _18$$11 = Z_TYPE_P(&before) == IS_OBJECT; + if (_18$$11) { + _18$$11 = zephir_instance_of_ev(&before, phalcon_mvc_micro_middlewareinterface_ce); + } + if (_18$$11) { + ZEPHIR_CALL_METHOD(&status, &before, "call", NULL, 0, this_ptr); + zephir_check_call_status_or_jump(try_end_1); + } else { + if (UNEXPECTED(!(zephir_is_callable(&before)))) { + ZEPHIR_INIT_NVAR(&_19$$14); + object_init_ex(&_19$$14, phalcon_mvc_micro_exception_ce); + ZEPHIR_INIT_NVAR(&_20$$14); + ZVAL_STRING(&_20$$14, "'before' handler is not callable"); + ZEPHIR_CALL_METHOD(NULL, &_19$$14, "__construct", NULL, 33, &_20$$14); + zephir_check_call_status_or_jump(try_end_1); + zephir_throw_exception_debug(&_19$$14, "phalcon/Mvc/Micro.zep", 467); + goto try_end_1; -#ifdef HAVE_CONFIG_H -#endif + } + ZEPHIR_INIT_NVAR(&status); + ZEPHIR_CALL_USER_FUNC(&status, &before); + zephir_check_call_status_or_jump(try_end_1); + } + zephir_read_property(&_21$$11, this_ptr, ZEND_STRL("stopped"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_21$$11)) { + RETURN_CCTOR(&status); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &beforeHandlers, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_17$$7, &beforeHandlers, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_17$$7)) { + break; + } + ZEPHIR_CALL_METHOD(&before, &beforeHandlers, "current", NULL, 0); + zephir_check_call_status(); + _22$$16 = Z_TYPE_P(&before) == IS_OBJECT; + if (_22$$16) { + _22$$16 = zephir_instance_of_ev(&before, phalcon_mvc_micro_middlewareinterface_ce); + } + if (_22$$16) { + ZEPHIR_CALL_METHOD(&status, &before, "call", NULL, 0, this_ptr); + zephir_check_call_status_or_jump(try_end_1); + } else { + if (UNEXPECTED(!(zephir_is_callable(&before)))) { + ZEPHIR_INIT_NVAR(&_23$$19); + object_init_ex(&_23$$19, phalcon_mvc_micro_exception_ce); + ZEPHIR_INIT_NVAR(&_24$$19); + ZVAL_STRING(&_24$$19, "'before' handler is not callable"); + ZEPHIR_CALL_METHOD(NULL, &_23$$19, "__construct", NULL, 33, &_24$$19); + zephir_check_call_status_or_jump(try_end_1); + zephir_throw_exception_debug(&_23$$19, "phalcon/Mvc/Micro.zep", 467); + goto try_end_1; + } + ZEPHIR_INIT_NVAR(&status); + ZEPHIR_CALL_USER_FUNC(&status, &before); + zephir_check_call_status_or_jump(try_end_1); + } + zephir_read_property(&_25$$16, this_ptr, ZEND_STRL("stopped"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_25$$16)) { + RETURN_CCTOR(&status); + } + ZEPHIR_CALL_METHOD(NULL, &beforeHandlers, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&before); + ZEPHIR_CALL_METHOD(¶ms, &router, "getparams", NULL, 0); + zephir_check_call_status_or_jump(try_end_1); + zephir_read_property(&_15$$7, this_ptr, ZEND_STRL("modelBinder"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&modelBinder, &_15$$7); + _26$$7 = Z_TYPE_P(&handler) == IS_OBJECT; + if (_26$$7) { + _26$$7 = zephir_is_instance_of(&handler, SL("Closure")); + } + if (_26$$7) { + _28$$21 = zephir_fetch_class_str_ex(SL("Closure"), ZEND_FETCH_CLASS_AUTO); + ZEPHIR_CALL_CE_STATIC(&_27$$21, _28$$21, "bind", NULL, 0, &handler, this_ptr); + zephir_check_call_status_or_jump(try_end_1); + ZEPHIR_CPY_WRT(&handler, &_27$$21); + if (Z_TYPE_P(&modelBinder) != IS_NULL) { + ZEPHIR_CALL_METHOD(&routeName, &matchedRoute, "getname", NULL, 0); + zephir_check_call_status_or_jump(try_end_1); + if (Z_TYPE_P(&routeName) != IS_NULL) { + ZEPHIR_INIT_VAR(&_29$$23); + ZEPHIR_CONCAT_SV(&_29$$23, "_PHMB_", &routeName); + zephir_get_strval(&bindCacheKey, &_29$$23); + } else { + ZEPHIR_CALL_METHOD(&_30$$24, &matchedRoute, "getpattern", NULL, 0); + zephir_check_call_status_or_jump(try_end_1); + ZEPHIR_INIT_VAR(&_31$$24); + ZEPHIR_CONCAT_SV(&_31$$24, "_PHMB_", &_30$$24); + zephir_get_strval(&bindCacheKey, &_31$$24); + } + ZEPHIR_CALL_METHOD(&_32$$22, &modelBinder, "bindtohandler", NULL, 0, &handler, ¶ms, &bindCacheKey); + zephir_check_call_status_or_jump(try_end_1); + ZEPHIR_CPY_WRT(¶ms, &_32$$22); + } + } + if (Z_TYPE_P(&handler) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&realHandler); + zephir_array_fetch_long(&realHandler, &handler, 0, PH_NOISY, "phalcon/Mvc/Micro.zep", 515); + _33$$25 = zephir_instance_of_ev(&realHandler, phalcon_mvc_controller_ce); + if (_33$$25) { + _33$$25 = Z_TYPE_P(&modelBinder) != IS_NULL; + } + if (_33$$25) { + zephir_memory_observe(&methodName); + zephir_array_fetch_long(&methodName, &handler, 1, PH_NOISY, "phalcon/Mvc/Micro.zep", 518); + ZEPHIR_INIT_VAR(&_34$$26); + zephir_get_class(&_34$$26, &realHandler, 0); + ZEPHIR_INIT_VAR(&_35$$26); + ZEPHIR_CONCAT_SVSV(&_35$$26, "_PHMB_", &_34$$26, "_", &methodName); + zephir_get_strval(&bindCacheKey, &_35$$26); + ZEPHIR_CALL_METHOD(&_36$$26, &modelBinder, "bindtohandler", NULL, 0, &realHandler, ¶ms, &bindCacheKey, &methodName); + zephir_check_call_status_or_jump(try_end_1); + ZEPHIR_CPY_WRT(¶ms, &_36$$26); + } + } + _37$$7 = Z_TYPE_P(&realHandler) != IS_NULL; + if (_37$$7) { + _37$$7 = zephir_instance_of_ev(&realHandler, phalcon_mvc_micro_lazyloader_ce); + } + if (_37$$7) { + ZEPHIR_OBS_NVAR(&methodName); + zephir_array_fetch_long(&methodName, &handler, 1, PH_NOISY, "phalcon/Mvc/Micro.zep", 535); + ZEPHIR_CALL_METHOD(&lazyReturned, &realHandler, "callmethod", NULL, 0, &methodName, ¶ms, &modelBinder); + zephir_check_call_status_or_jump(try_end_1); + } else { + ZEPHIR_INIT_NVAR(&lazyReturned); + ZEPHIR_CALL_USER_FUNC_ARRAY(&lazyReturned, &handler, ¶ms); + zephir_check_call_status_or_jump(try_end_1); + } + ZEPHIR_CPY_WRT(&returnedValue, &lazyReturned); + zephir_read_property(&_15$$7, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_15$$7) != IS_NULL) { + zephir_read_property(&_38$$29, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_40$$29); + ZVAL_STRING(&_40$$29, "micro:afterBinding"); + ZEPHIR_CALL_METHOD(&_39$$29, &_38$$29, "fire", NULL, 0, &_40$$29, this_ptr); + zephir_check_call_status_or_jump(try_end_1); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_39$$29)) { + RETURN_MM_BOOL(0); + } + } + zephir_read_property(&_41$$7, this_ptr, ZEND_STRL("afterBindingHandlers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&afterBindingHandlers, &_41$$7); + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$false); + } + zephir_is_iterable(&afterBindingHandlers, 0, "phalcon/Mvc/Micro.zep", 598); + if (Z_TYPE_P(&afterBindingHandlers) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&afterBindingHandlers), _42$$7) + { + ZEPHIR_INIT_NVAR(&afterBinding); + ZVAL_COPY(&afterBinding, _42$$7); + _44$$31 = Z_TYPE_P(&afterBinding) == IS_OBJECT; + if (_44$$31) { + _44$$31 = zephir_instance_of_ev(&afterBinding, phalcon_mvc_micro_middlewareinterface_ce); + } + if (_44$$31) { + ZEPHIR_CALL_METHOD(&status, &afterBinding, "call", NULL, 0, this_ptr); + zephir_check_call_status_or_jump(try_end_1); + } else { + if (UNEXPECTED(!(zephir_is_callable(&afterBinding)))) { + ZEPHIR_INIT_NVAR(&_45$$34); + object_init_ex(&_45$$34, phalcon_mvc_micro_exception_ce); + ZEPHIR_INIT_NVAR(&_46$$34); + ZVAL_STRING(&_46$$34, "'afterBinding' handler is not callable"); + ZEPHIR_CALL_METHOD(NULL, &_45$$34, "__construct", NULL, 33, &_46$$34); + zephir_check_call_status_or_jump(try_end_1); + zephir_throw_exception_debug(&_45$$34, "phalcon/Mvc/Micro.zep", 578); + goto try_end_1; + } + ZEPHIR_INIT_NVAR(&status); + ZEPHIR_CALL_USER_FUNC(&status, &afterBinding); + zephir_check_call_status_or_jump(try_end_1); + } + zephir_read_property(&_47$$31, this_ptr, ZEND_STRL("stopped"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_47$$31)) { + RETURN_CCTOR(&status); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &afterBindingHandlers, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_43$$7, &afterBindingHandlers, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_43$$7)) { + break; + } + ZEPHIR_CALL_METHOD(&afterBinding, &afterBindingHandlers, "current", NULL, 0); + zephir_check_call_status(); + _48$$36 = Z_TYPE_P(&afterBinding) == IS_OBJECT; + if (_48$$36) { + _48$$36 = zephir_instance_of_ev(&afterBinding, phalcon_mvc_micro_middlewareinterface_ce); + } + if (_48$$36) { + ZEPHIR_CALL_METHOD(&status, &afterBinding, "call", NULL, 0, this_ptr); + zephir_check_call_status_or_jump(try_end_1); + } else { + if (UNEXPECTED(!(zephir_is_callable(&afterBinding)))) { + ZEPHIR_INIT_NVAR(&_49$$39); + object_init_ex(&_49$$39, phalcon_mvc_micro_exception_ce); + ZEPHIR_INIT_NVAR(&_50$$39); + ZVAL_STRING(&_50$$39, "'afterBinding' handler is not callable"); + ZEPHIR_CALL_METHOD(NULL, &_49$$39, "__construct", NULL, 33, &_50$$39); + zephir_check_call_status_or_jump(try_end_1); + zephir_throw_exception_debug(&_49$$39, "phalcon/Mvc/Micro.zep", 578); + goto try_end_1; + } + ZEPHIR_INIT_NVAR(&status); + ZEPHIR_CALL_USER_FUNC(&status, &afterBinding); + zephir_check_call_status_or_jump(try_end_1); + } + zephir_read_property(&_51$$36, this_ptr, ZEND_STRL("stopped"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_51$$36)) { + RETURN_CCTOR(&status); + } + ZEPHIR_CALL_METHOD(NULL, &afterBindingHandlers, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&afterBinding); + zephir_update_property_zval(this_ptr, ZEND_STRL("returnedValue"), &returnedValue); + zephir_read_property(&_41$$7, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_41$$7) != IS_NULL) { + zephir_read_property(&_52$$41, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_53$$41); + ZVAL_STRING(&_53$$41, "micro:afterExecuteRoute"); + ZEPHIR_CALL_METHOD(NULL, &_52$$41, "fire", NULL, 0, &_53$$41, this_ptr); + zephir_check_call_status_or_jump(try_end_1); + } + zephir_read_property(&_54$$7, this_ptr, ZEND_STRL("afterHandlers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&afterHandlers, &_54$$7); + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$false); + } + zephir_is_iterable(&afterHandlers, 0, "phalcon/Mvc/Micro.zep", 637); + if (Z_TYPE_P(&afterHandlers) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&afterHandlers), _55$$7) + { + ZEPHIR_INIT_NVAR(&after); + ZVAL_COPY(&after, _55$$7); + _57$$42 = Z_TYPE_P(&after) == IS_OBJECT; + if (_57$$42) { + _57$$42 = zephir_instance_of_ev(&after, phalcon_mvc_micro_middlewareinterface_ce); + } + if (_57$$42) { + ZEPHIR_CALL_METHOD(&status, &after, "call", NULL, 0, this_ptr); + zephir_check_call_status_or_jump(try_end_1); + } else { + if (UNEXPECTED(!(zephir_is_callable(&after)))) { + ZEPHIR_INIT_NVAR(&_58$$45); + object_init_ex(&_58$$45, phalcon_mvc_micro_exception_ce); + ZEPHIR_INIT_NVAR(&_59$$45); + ZVAL_STRING(&_59$$45, "One of the 'after' handlers is not callable"); + ZEPHIR_CALL_METHOD(NULL, &_58$$45, "__construct", NULL, 33, &_59$$45); + zephir_check_call_status_or_jump(try_end_1); + zephir_throw_exception_debug(&_58$$45, "phalcon/Mvc/Micro.zep", 624); + goto try_end_1; + } + ZEPHIR_INIT_NVAR(&status); + ZEPHIR_CALL_USER_FUNC(&status, &after); + zephir_check_call_status_or_jump(try_end_1); + } + zephir_read_property(&_60$$42, this_ptr, ZEND_STRL("stopped"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_60$$42)) { + break; + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &afterHandlers, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_56$$7, &afterHandlers, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_56$$7)) { + break; + } + ZEPHIR_CALL_METHOD(&after, &afterHandlers, "current", NULL, 0); + zephir_check_call_status(); + _61$$47 = Z_TYPE_P(&after) == IS_OBJECT; + if (_61$$47) { + _61$$47 = zephir_instance_of_ev(&after, phalcon_mvc_micro_middlewareinterface_ce); + } + if (_61$$47) { + ZEPHIR_CALL_METHOD(&status, &after, "call", NULL, 0, this_ptr); + zephir_check_call_status_or_jump(try_end_1); + } else { + if (UNEXPECTED(!(zephir_is_callable(&after)))) { + ZEPHIR_INIT_NVAR(&_62$$50); + object_init_ex(&_62$$50, phalcon_mvc_micro_exception_ce); + ZEPHIR_INIT_NVAR(&_63$$50); + ZVAL_STRING(&_63$$50, "One of the 'after' handlers is not callable"); + ZEPHIR_CALL_METHOD(NULL, &_62$$50, "__construct", NULL, 33, &_63$$50); + zephir_check_call_status_or_jump(try_end_1); + zephir_throw_exception_debug(&_62$$50, "phalcon/Mvc/Micro.zep", 624); + goto try_end_1; -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Signer_None) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT\\Signer, None, phalcon, encryption_security_jwt_signer_none, phalcon_encryption_security_jwt_signer_none_method_entry, 0); + } + ZEPHIR_INIT_NVAR(&status); + ZEPHIR_CALL_USER_FUNC(&status, &after); + zephir_check_call_status_or_jump(try_end_1); + } + zephir_read_property(&_64$$47, this_ptr, ZEND_STRL("stopped"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_64$$47)) { + break; + } + ZEPHIR_CALL_METHOD(NULL, &afterHandlers, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&after); + } else { + zephir_read_property(&_65$$52, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_65$$52) != IS_NULL) { + zephir_read_property(&_66$$53, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_68$$53); + ZVAL_STRING(&_68$$53, "micro:beforeNotFound"); + ZEPHIR_CALL_METHOD(&_67$$53, &_66$$53, "fire", NULL, 0, &_68$$53, this_ptr); + zephir_check_call_status_or_jump(try_end_1); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_67$$53)) { + RETURN_MM_BOOL(0); + } + } + zephir_read_property(&_69$$52, this_ptr, ZEND_STRL("notFoundHandler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(¬FoundHandler, &_69$$52); + if (UNEXPECTED(!(zephir_is_callable(¬FoundHandler)))) { + ZEPHIR_INIT_VAR(&_70$$55); + object_init_ex(&_70$$55, phalcon_mvc_micro_exception_ce); + ZEPHIR_INIT_VAR(&_71$$55); + ZVAL_STRING(&_71$$55, "Not-Found handler is not callable or is not defined"); + ZEPHIR_CALL_METHOD(NULL, &_70$$55, "__construct", NULL, 33, &_71$$55); + zephir_check_call_status_or_jump(try_end_1); + zephir_throw_exception_debug(&_70$$55, "phalcon/Mvc/Micro.zep", 655); + goto try_end_1; - zend_class_implements(phalcon_encryption_security_jwt_signer_none_ce, 1, phalcon_encryption_security_jwt_signer_signerinterface_ce); - return SUCCESS; -} + } + ZEPHIR_INIT_NVAR(&returnedValue); + ZEPHIR_CALL_USER_FUNC(&returnedValue, ¬FoundHandler); + zephir_check_call_status_or_jump(try_end_1); + } + zephir_read_property(&_72$$4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_72$$4) != IS_NULL) { + zephir_read_property(&_73$$56, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_74$$56); + ZVAL_STRING(&_74$$56, "micro:afterHandleRoute"); + ZEPHIR_CALL_METHOD(NULL, &_73$$56, "fire", NULL, 0, &_74$$56, this_ptr, &returnedValue); + zephir_check_call_status_or_jump(try_end_1); + } + zephir_read_property(&_75$$4, this_ptr, ZEND_STRL("finishHandlers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&finishHandlers, &_75$$4); + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$false); + } + zephir_is_iterable(&finishHandlers, 0, "phalcon/Mvc/Micro.zep", 709); + if (Z_TYPE_P(&finishHandlers) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&finishHandlers), _76$$4) + { + ZEPHIR_INIT_NVAR(&finish); + ZVAL_COPY(&finish, _76$$4); + _78$$57 = Z_TYPE_P(&finish) == IS_OBJECT; + if (_78$$57) { + _78$$57 = zephir_instance_of_ev(&finish, phalcon_mvc_micro_middlewareinterface_ce); + } + if (_78$$57) { + ZEPHIR_CALL_METHOD(&status, &finish, "call", NULL, 0, this_ptr); + zephir_check_call_status_or_jump(try_end_1); + } else { + if (UNEXPECTED(!(zephir_is_callable(&finish)))) { + ZEPHIR_INIT_NVAR(&_79$$60); + object_init_ex(&_79$$60, phalcon_mvc_micro_exception_ce); + ZEPHIR_INIT_NVAR(&_80$$60); + ZVAL_STRING(&_80$$60, "One of the 'finish' handlers is not callable"); + ZEPHIR_CALL_METHOD(NULL, &_79$$60, "__construct", NULL, 33, &_80$$60); + zephir_check_call_status_or_jump(try_end_1); + zephir_throw_exception_debug(&_79$$60, "phalcon/Mvc/Micro.zep", 690); + goto try_end_1; -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_None, getAlgHeader) -{ + } + ZEPHIR_INIT_NVAR(&_81$$59); + zephir_create_array(&_81$$59, 1, 0); + zephir_array_fast_append(&_81$$59, this_ptr); + ZEPHIR_INIT_NVAR(&status); + ZEPHIR_CALL_USER_FUNC_ARRAY(&status, &finish, &_81$$59); + zephir_check_call_status_or_jump(try_end_1); + } + zephir_read_property(&_82$$57, this_ptr, ZEND_STRL("stopped"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_82$$57)) { + break; + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &finishHandlers, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_77$$4, &finishHandlers, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_77$$4)) { + break; + } + ZEPHIR_CALL_METHOD(&finish, &finishHandlers, "current", NULL, 0); + zephir_check_call_status(); + _83$$62 = Z_TYPE_P(&finish) == IS_OBJECT; + if (_83$$62) { + _83$$62 = zephir_instance_of_ev(&finish, phalcon_mvc_micro_middlewareinterface_ce); + } + if (_83$$62) { + ZEPHIR_CALL_METHOD(&status, &finish, "call", NULL, 0, this_ptr); + zephir_check_call_status_or_jump(try_end_1); + } else { + if (UNEXPECTED(!(zephir_is_callable(&finish)))) { + ZEPHIR_INIT_NVAR(&_84$$65); + object_init_ex(&_84$$65, phalcon_mvc_micro_exception_ce); + ZEPHIR_INIT_NVAR(&_85$$65); + ZVAL_STRING(&_85$$65, "One of the 'finish' handlers is not callable"); + ZEPHIR_CALL_METHOD(NULL, &_84$$65, "__construct", NULL, 33, &_85$$65); + zephir_check_call_status_or_jump(try_end_1); + zephir_throw_exception_debug(&_84$$65, "phalcon/Mvc/Micro.zep", 690); + goto try_end_1; - RETURN_STRING("none"); -} + } + ZEPHIR_INIT_NVAR(&_86$$64); + zephir_create_array(&_86$$64, 1, 0); + zephir_array_fast_append(&_86$$64, this_ptr); + ZEPHIR_INIT_NVAR(&status); + ZEPHIR_CALL_USER_FUNC_ARRAY(&status, &finish, &_86$$64); + zephir_check_call_status_or_jump(try_end_1); + } + zephir_read_property(&_87$$62, this_ptr, ZEND_STRL("stopped"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_87$$62)) { + break; + } + ZEPHIR_CALL_METHOD(NULL, &finishHandlers, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&finish); -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_None, getAlgorithm) -{ + try_end_1: - RETURN_STRING("None"); + if (EG(exception)) { + ZEPHIR_INIT_VAR(&_88); + ZVAL_OBJ(&_88, EG(exception)); + Z_ADDREF_P(&_88); + if (zephir_is_instance_of(&_88, SL("Throwable"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&e, &_88); + zephir_read_property(&_89$$67, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_89$$67) != IS_NULL) { + zephir_read_property(&_90$$68, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_91$$68); + ZVAL_STRING(&_91$$68, "micro:beforeException"); + ZEPHIR_CALL_METHOD(&returnedValue, &_90$$68, "fire", NULL, 0, &_91$$68, this_ptr, &e); + zephir_check_call_status(); + } + zephir_read_property(&_92$$67, this_ptr, ZEND_STRL("errorHandler"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_92$$67) != IS_NULL) { + zephir_read_property(&_93$$69, this_ptr, ZEND_STRL("errorHandler"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(!(zephir_is_callable(&_93$$69)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "Error handler is not callable", "phalcon/Mvc/Micro.zep", 726); + return; + } + zephir_read_property(&_94$$69, this_ptr, ZEND_STRL("errorHandler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_95$$69); + zephir_create_array(&_95$$69, 1, 0); + zephir_array_fast_append(&_95$$69, &e); + ZEPHIR_INIT_NVAR(&returnedValue); + ZEPHIR_CALL_USER_FUNC_ARRAY(&returnedValue, &_94$$69, &_95$$69); + zephir_check_call_status(); + if (Z_TYPE_P(&returnedValue) == IS_OBJECT) { + if (!(zephir_instance_of_ev(&returnedValue, phalcon_http_responseinterface_ce))) { + zephir_throw_exception_debug(&e, "phalcon/Mvc/Micro.zep", 739); + ZEPHIR_MM_RESTORE(); + return; + } + } else { + if (!ZEPHIR_IS_FALSE_IDENTICAL(&returnedValue)) { + zephir_throw_exception_debug(&e, "phalcon/Mvc/Micro.zep", 743); + ZEPHIR_MM_RESTORE(); + return; + } + } + } else { + if (!ZEPHIR_IS_FALSE_IDENTICAL(&returnedValue)) { + zephir_throw_exception_debug(&e, "phalcon/Mvc/Micro.zep", 748); + ZEPHIR_MM_RESTORE(); + return; + } + } + } + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("responseHandler"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_0)) { + zephir_read_property(&_96$$77, this_ptr, ZEND_STRL("responseHandler"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(!(zephir_is_callable(&_96$$77)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "Response handler is not callable or is not defined", "phalcon/Mvc/Micro.zep", 761); + return; + } + zephir_read_property(&_97$$77, this_ptr, ZEND_STRL("responseHandler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&returnedValue); + ZEPHIR_CALL_USER_FUNC(&returnedValue, &_97$$77); + zephir_check_call_status(); + } else { + if (Z_TYPE_P(&returnedValue) == IS_STRING) { + ZEPHIR_INIT_VAR(&_99$$80); + ZVAL_STRING(&_99$$80, "response"); + ZEPHIR_CALL_METHOD(&_98$$80, &container, "getshared", NULL, 0, &_99$$80); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&response, &_98$$80); + ZEPHIR_CALL_METHOD(&_98$$80, &response, "issent", NULL, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&_98$$80))) { + ZEPHIR_CALL_METHOD(NULL, &response, "setcontent", NULL, 0, &returnedValue); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &response, "send", NULL, 0); + zephir_check_call_status(); + } + } + _100$$79 = Z_TYPE_P(&returnedValue) == IS_OBJECT; + if (_100$$79) { + _100$$79 = zephir_instance_of_ev(&returnedValue, phalcon_http_responseinterface_ce); + } + _101$$79 = _100$$79; + if (_101$$79) { + ZEPHIR_CALL_METHOD(&_102$$79, &returnedValue, "issent", NULL, 0); + zephir_check_call_status(); + _101$$79 = !zephir_is_true(&_102$$79); + } + if (_101$$79) { + ZEPHIR_CALL_METHOD(NULL, &returnedValue, "send", NULL, 0); + zephir_check_call_status(); + } + } + RETURN_CCTOR(&returnedValue); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_None, sign) +static PHP_METHOD(Phalcon_Mvc_Micro, hasService) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *payload_param = NULL, *passphrase_param = NULL; - zval payload, passphrase; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *serviceName_param = NULL, _0, _2, _1$$3; + zval serviceName; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&payload); - ZVAL_UNDEF(&passphrase); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(payload) - Z_PARAM_STR(passphrase) + ZVAL_UNDEF(&serviceName); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(serviceName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &payload_param, &passphrase_param); - if (UNEXPECTED(Z_TYPE_P(payload_param) != IS_STRING && Z_TYPE_P(payload_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'payload' must be of the type string")); + zephir_fetch_params(1, 1, 0, &serviceName_param); + if (UNEXPECTED(Z_TYPE_P(serviceName_param) != IS_STRING && Z_TYPE_P(serviceName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'serviceName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(payload_param) == IS_STRING)) { - zephir_get_strval(&payload, payload_param); + if (EXPECTED(Z_TYPE_P(serviceName_param) == IS_STRING)) { + zephir_get_strval(&serviceName, serviceName_param); } else { - ZEPHIR_INIT_VAR(&payload); + ZEPHIR_INIT_VAR(&serviceName); } - zephir_get_strval(&passphrase, passphrase_param); - RETURN_MM_STRING(""); + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_di_factorydefault_ce); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 416); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &_1$$3); + } + zephir_read_property(&_2, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_2, "has", NULL, 0, &serviceName); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_None, verify) +static PHP_METHOD(Phalcon_Mvc_Micro, head) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *source_param = NULL, *payload_param = NULL, *passphrase_param = NULL, _0; - zval source, payload, passphrase; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *routePattern_param = NULL, *handler, handler_sub, router, route, _0; + zval routePattern; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&payload); - ZVAL_UNDEF(&passphrase); + ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&router); + ZVAL_UNDEF(&route); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_STR(source) - Z_PARAM_STR(payload) - Z_PARAM_STR(passphrase) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(routePattern) + Z_PARAM_ZVAL(handler) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &source_param, &payload_param, &passphrase_param); - zephir_get_strval(&source, source_param); - zephir_get_strval(&payload, payload_param); - zephir_get_strval(&passphrase, passphrase_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, ""); - RETURN_MM_BOOL(ZEPHIR_IS_IDENTICAL(&_0, &source)); + zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); + if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { + zephir_get_strval(&routePattern, routePattern_param); + } else { + ZEPHIR_INIT_VAR(&routePattern); + } + ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&route, &router, "addhead", NULL, 0, &routePattern); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, &route, "getrouteid", NULL, 0); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("handlers"), &_0, handler); + RETURN_CCTOR(&route); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Signer_SignerInterface) +static PHP_METHOD(Phalcon_Mvc_Micro, map) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Encryption\\Security\\JWT\\Signer, SignerInterface, phalcon, encryption_security_jwt_signer_signerinterface, phalcon_encryption_security_jwt_signer_signerinterface_method_entry); - - return SUCCESS; -} + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *routePattern_param = NULL, *handler, handler_sub, router, route, _0; + zval routePattern; + zval *this_ptr = getThis(); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Security_JWT_Signer_SignerInterface, getAlgHeader); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Security_JWT_Signer_SignerInterface, getAlgorithm); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Security_JWT_Signer_SignerInterface, sign); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Security_JWT_Signer_SignerInterface, verify); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Exceptions_UnsupportedAlgorithmException) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Security\\JWT\\Exceptions, UnsupportedAlgorithmException, phalcon, encryption_security_jwt_exceptions_unsupportedalgorithmexception, zend_ce_exception, NULL, 0); - - return SUCCESS; + ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&router); + ZVAL_UNDEF(&route); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(routePattern) + Z_PARAM_ZVAL(handler) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); + if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { + zephir_get_strval(&routePattern, routePattern_param); + } else { + ZEPHIR_INIT_VAR(&routePattern); + } + ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&route, &router, "add", NULL, 0, &routePattern); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, &route, "getrouteid", NULL, 0); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("handlers"), &_0, handler); + RETURN_CCTOR(&route); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Exceptions_ValidatorException) +static PHP_METHOD(Phalcon_Mvc_Micro, mount) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Security\\JWT\\Exceptions, ValidatorException, phalcon, encryption_security_jwt_exceptions_validatorexception, zend_ce_exception, NULL, 0); + zend_bool _4$$7, _5$$7, _7$$15, _8$$15; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_3 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *collection, collection_sub, mainHandler, handlers, lazyHandler, prefix, methods, pattern, subHandler, realHandler, prefixedPattern, route, handler, name, _0, *_1, _2, _6$$15; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&collection_sub); + ZVAL_UNDEF(&mainHandler); + ZVAL_UNDEF(&handlers); + ZVAL_UNDEF(&lazyHandler); + ZVAL_UNDEF(&prefix); + ZVAL_UNDEF(&methods); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&subHandler); + ZVAL_UNDEF(&realHandler); + ZVAL_UNDEF(&prefixedPattern); + ZVAL_UNDEF(&route); + ZVAL_UNDEF(&handler); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_6$$15); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(collection, phalcon_mvc_micro_collectioninterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &collection); + ZEPHIR_CALL_METHOD(&mainHandler, collection, "gethandler", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(ZEPHIR_IS_EMPTY(&mainHandler))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "Collection requires a main handler", "phalcon/Mvc/Micro.zep", 876); + return; + } + ZEPHIR_CALL_METHOD(&handlers, collection, "gethandlers", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(!(zephir_fast_count_int(&handlers)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "There are no handlers to mount", "phalcon/Mvc/Micro.zep", 882); + return; + } + ZEPHIR_CALL_METHOD(&_0, collection, "islazy", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + ZEPHIR_INIT_VAR(&lazyHandler); + object_init_ex(&lazyHandler, phalcon_mvc_micro_lazyloader_ce); + ZEPHIR_CALL_METHOD(NULL, &lazyHandler, "__construct", NULL, 417, &mainHandler); + zephir_check_call_status(); + } else { + ZEPHIR_CPY_WRT(&lazyHandler, &mainHandler); + } + ZEPHIR_CALL_METHOD(&prefix, collection, "getprefix", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&handlers, 0, "phalcon/Mvc/Micro.zep", 940); + if (Z_TYPE_P(&handlers) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&handlers), _1) + { + ZEPHIR_INIT_NVAR(&handler); + ZVAL_COPY(&handler, _1); + if (UNEXPECTED(Z_TYPE_P(&handler) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "One of the registered handlers is invalid", "phalcon/Mvc/Micro.zep", 903); + return; + } + ZEPHIR_OBS_NVAR(&methods); + zephir_array_fetch_long(&methods, &handler, 0, PH_NOISY, "phalcon/Mvc/Micro.zep", 906); + ZEPHIR_OBS_NVAR(&pattern); + zephir_array_fetch_long(&pattern, &handler, 1, PH_NOISY, "phalcon/Mvc/Micro.zep", 907); + ZEPHIR_OBS_NVAR(&subHandler); + zephir_array_fetch_long(&subHandler, &handler, 2, PH_NOISY, "phalcon/Mvc/Micro.zep", 908); + ZEPHIR_OBS_NVAR(&name); + zephir_array_fetch_long(&name, &handler, 3, PH_NOISY, "phalcon/Mvc/Micro.zep", 909); + ZEPHIR_INIT_NVAR(&realHandler); + zephir_create_array(&realHandler, 2, 0); + zephir_array_fast_append(&realHandler, &lazyHandler); + zephir_array_fast_append(&realHandler, &subHandler); + if (!(ZEPHIR_IS_EMPTY(&prefix))) { + if (ZEPHIR_IS_STRING_IDENTICAL(&pattern, "/")) { + ZEPHIR_CPY_WRT(&prefixedPattern, &prefix); + } else { + ZEPHIR_INIT_NVAR(&prefixedPattern); + ZEPHIR_CONCAT_VV(&prefixedPattern, &prefix, &pattern); + } + } else { + ZEPHIR_CPY_WRT(&prefixedPattern, &pattern); + } + ZEPHIR_CALL_METHOD(&route, this_ptr, "map", &_3, 0, &prefixedPattern, &realHandler); + zephir_check_call_status(); + _4$$7 = Z_TYPE_P(&methods) == IS_STRING; + if (_4$$7) { + _4$$7 = !ZEPHIR_IS_STRING_IDENTICAL(&methods, ""); + } + _5$$7 = _4$$7; + if (!(_5$$7)) { + _5$$7 = Z_TYPE_P(&methods) == IS_ARRAY; + } + if (_5$$7) { + ZEPHIR_CALL_METHOD(NULL, &route, "via", NULL, 0, &methods); + zephir_check_call_status(); + } + if (Z_TYPE_P(&name) == IS_STRING) { + ZEPHIR_CALL_METHOD(NULL, &route, "setname", NULL, 0, &name); + zephir_check_call_status(); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &handlers, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &handlers, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&handler, &handlers, "current", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&handler) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "One of the registered handlers is invalid", "phalcon/Mvc/Micro.zep", 903); + return; + } + ZEPHIR_OBS_NVAR(&methods); + zephir_array_fetch_long(&methods, &handler, 0, PH_NOISY, "phalcon/Mvc/Micro.zep", 906); + ZEPHIR_OBS_NVAR(&pattern); + zephir_array_fetch_long(&pattern, &handler, 1, PH_NOISY, "phalcon/Mvc/Micro.zep", 907); + ZEPHIR_OBS_NVAR(&subHandler); + zephir_array_fetch_long(&subHandler, &handler, 2, PH_NOISY, "phalcon/Mvc/Micro.zep", 908); + ZEPHIR_OBS_NVAR(&name); + zephir_array_fetch_long(&name, &handler, 3, PH_NOISY, "phalcon/Mvc/Micro.zep", 909); + ZEPHIR_INIT_NVAR(&_6$$15); + zephir_create_array(&_6$$15, 2, 0); + zephir_array_fast_append(&_6$$15, &lazyHandler); + zephir_array_fast_append(&_6$$15, &subHandler); + ZEPHIR_CPY_WRT(&realHandler, &_6$$15); + if (!(ZEPHIR_IS_EMPTY(&prefix))) { + if (ZEPHIR_IS_STRING_IDENTICAL(&pattern, "/")) { + ZEPHIR_CPY_WRT(&prefixedPattern, &prefix); + } else { + ZEPHIR_INIT_NVAR(&prefixedPattern); + ZEPHIR_CONCAT_VV(&prefixedPattern, &prefix, &pattern); + } + } else { + ZEPHIR_CPY_WRT(&prefixedPattern, &pattern); + } + ZEPHIR_CALL_METHOD(&route, this_ptr, "map", &_3, 0, &prefixedPattern, &realHandler); + zephir_check_call_status(); + _7$$15 = Z_TYPE_P(&methods) == IS_STRING; + if (_7$$15) { + _7$$15 = !ZEPHIR_IS_STRING_IDENTICAL(&methods, ""); + } + _8$$15 = _7$$15; + if (!(_8$$15)) { + _8$$15 = Z_TYPE_P(&methods) == IS_ARRAY; + } + if (_8$$15) { + ZEPHIR_CALL_METHOD(NULL, &route, "via", NULL, 0, &methods); + zephir_check_call_status(); + } + if (Z_TYPE_P(&name) == IS_STRING) { + ZEPHIR_CALL_METHOD(NULL, &route, "setname", NULL, 0, &name); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(NULL, &handlers, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&handler); + RETURN_THIS(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_CryptInterface) +static PHP_METHOD(Phalcon_Mvc_Micro, notFound) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Encryption\\Crypt, CryptInterface, phalcon, encryption_crypt_cryptinterface, phalcon_encryption_crypt_cryptinterface_method_entry); + zval *handler, handler_sub; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&handler_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(handler) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &handler); + zephir_update_property_zval(this_ptr, ZEND_STRL("notFoundHandler"), handler); + RETURN_THISW(); } -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, decrypt); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, decryptBase64); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, encrypt); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, encryptBase64); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, getAvailableCiphers); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, getAuthTag); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, getAuthData); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, getAuthTagLength); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, getCipher); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, getKey); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, setAuthTag); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, setAuthData); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, setAuthTagLength); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, setCipher); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, setKey); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, setPadding); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, useSigning); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_PadFactory) +static PHP_METHOD(Phalcon_Mvc_Micro, offsetExists) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Crypt, PadFactory, phalcon, encryption_crypt_padfactory, phalcon_factory_abstractfactory_ce, phalcon_encryption_crypt_padfactory_method_entry, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval offset_sub; + zval *offset; + zval *this_ptr = getThis(); - zend_declare_property_string(phalcon_encryption_crypt_padfactory_ce, SL("exception"), "Phalcon\\Encryption\\Crypt\\Exception\\Exception", ZEND_ACC_PROTECTED); - return SUCCESS; + ZVAL_UNDEF(&offset_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(offset) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &offset); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hasservice", NULL, 0, offset); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Crypt_PadFactory, __construct) +static PHP_METHOD(Phalcon_Mvc_Micro, offsetGet) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *services_param = NULL; - zval services; + zval offset_sub; + zval *offset; zval *this_ptr = getThis(); - ZVAL_UNDEF(&services); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(services) + ZVAL_UNDEF(&offset_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(offset) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &services_param); - if (!services_param) { - ZEPHIR_INIT_VAR(&services); - array_init(&services); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); + zephir_fetch_params(1, 1, 0, &offset); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getservice", NULL, 0, offset); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Crypt_PadFactory, newInstance) +static PHP_METHOD(Phalcon_Mvc_Micro, offsetSet) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, definition; - zval name; + zval offset_sub, value_sub; + zval *offset, *value; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&definition); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + ZVAL_UNDEF(&offset_sub); + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(offset) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); - zephir_check_call_status(); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(return_value, &definition); + zephir_fetch_params(1, 2, 0, &offset, &value); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setservice", NULL, 0, offset, value); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Crypt_PadFactory, padNumberToService) +static PHP_METHOD(Phalcon_Mvc_Micro, offsetUnset) { - zval map; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *number_param = NULL, _0, _1, _2; - zend_long number, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval offset_sub, _0, _2, _1$$3; + zval *offset; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&offset_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&map); + ZVAL_UNDEF(&_1$$3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(number) + Z_PARAM_ZVAL(offset) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &number_param); - ZEPHIR_INIT_VAR(&map); - zephir_create_array(&map, 6, 0); - add_index_stringl(&map, 1, SL("ansi")); - add_index_stringl(&map, 3, SL("iso10126")); - add_index_stringl(&map, 4, SL("isoiek")); - add_index_stringl(&map, 2, SL("pjcs7")); - add_index_stringl(&map, 6, SL("space")); - add_index_stringl(&map, 5, SL("zero")); - ZEPHIR_INIT_VAR(&_0); - object_init_ex(&_0, phalcon_support_helper_arr_get_ce); - if (zephir_has_constructor(&_0)) { - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); + zephir_fetch_params(1, 1, 0, &offset); + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_di_factorydefault_ce); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 416); zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &_1$$3); } - - ZVAL_LONG(&_1, number); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "noop"); - ZEPHIR_RETURN_CALL_METHOD(&_0, "__invoke", NULL, 159, &map, &_1, &_2); + zephir_read_property(&_2, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_2, "remove", NULL, 0, offset); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Encryption_Crypt_PadFactory, getServices) -{ - - zephir_create_array(return_value, 7, 0); - add_assoc_stringl_ex(return_value, SL("ansi"), SL("Phalcon\\Encryption\\Crypt\\Padding\\Ansi")); - add_assoc_stringl_ex(return_value, SL("iso10126"), SL("Phalcon\\Encryption\\Crypt\\Padding\\Iso10126")); - add_assoc_stringl_ex(return_value, SL("isoiek"), SL("Phalcon\\Encryption\\Crypt\\Padding\\IsoIek")); - add_assoc_stringl_ex(return_value, SL("noop"), SL("Phalcon\\Encryption\\Crypt\\Padding\\Noop")); - add_assoc_stringl_ex(return_value, SL("pjcs7"), SL("Phalcon\\Encryption\\Crypt\\Padding\\Pkcs7")); - add_assoc_stringl_ex(return_value, SL("space"), SL("Phalcon\\Encryption\\Crypt\\Padding\\Space")); - add_assoc_stringl_ex(return_value, SL("zero"), SL("Phalcon\\Encryption\\Crypt\\Padding\\Zero")); - return; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_Ansi) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, Ansi, phalcon, encryption_crypt_padding_ansi, phalcon_encryption_crypt_padding_ansi_method_entry, 0); - - zend_class_implements(phalcon_encryption_crypt_padding_ansi_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); - return SUCCESS; + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Ansi, pad) +static PHP_METHOD(Phalcon_Mvc_Micro, options) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *paddingSize_param = NULL, _0, _1, _2, _3; - zend_long paddingSize, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *routePattern_param = NULL, *handler, handler_sub, router, route, _0; + zval routePattern; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&router); + ZVAL_UNDEF(&route); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(paddingSize) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(routePattern) + Z_PARAM_ZVAL(handler) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &paddingSize_param); - ZVAL_LONG(&_0, 0); - ZEPHIR_CALL_FUNCTION(&_1, "chr", NULL, 244, &_0); + zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); + if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { + zephir_get_strval(&routePattern, routePattern_param); + } else { + ZEPHIR_INIT_VAR(&routePattern); + } + ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); zephir_check_call_status(); - ZVAL_LONG(&_0, (paddingSize - 1)); - ZEPHIR_CALL_FUNCTION(&_2, "str_repeat", NULL, 1, &_1, &_0); + ZEPHIR_CALL_METHOD(&route, &router, "addoptions", NULL, 0, &routePattern); zephir_check_call_status(); - ZVAL_LONG(&_0, paddingSize); - ZEPHIR_CALL_FUNCTION(&_3, "chr", NULL, 244, &_0); + ZEPHIR_CALL_METHOD(&_0, &route, "getrouteid", NULL, 0); zephir_check_call_status(); - ZEPHIR_CONCAT_VV(return_value, &_2, &_3); - RETURN_MM(); + zephir_update_property_array(this_ptr, SL("handlers"), &_0, handler); + RETURN_CCTOR(&route); } -static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Ansi, unpad) +static PHP_METHOD(Phalcon_Mvc_Micro, patch) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long blockSize, ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL, *blockSize_param = NULL, last, length, ord, padding, paddingSize, repeat, _0, _1, _2$$4, _3$$4, _4$$3, _5$$3; - zval input; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *routePattern_param = NULL, *handler, handler_sub, router, route, _0; + zval routePattern; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&last); - ZVAL_UNDEF(&length); - ZVAL_UNDEF(&ord); - ZVAL_UNDEF(&padding); - ZVAL_UNDEF(&paddingSize); - ZVAL_UNDEF(&repeat); + ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&router); + ZVAL_UNDEF(&route); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(input) - Z_PARAM_LONG(blockSize) + Z_PARAM_STR(routePattern) + Z_PARAM_ZVAL(handler) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); - zephir_get_strval(&input, input_param); - ZEPHIR_INIT_VAR(&paddingSize); - ZVAL_LONG(&paddingSize, 0); - ZEPHIR_INIT_VAR(&length); - ZVAL_LONG(&length, zephir_fast_strlen_ev(&input)); - ZVAL_LONG(&_0, (zephir_get_numberval(&length) - 1)); - ZVAL_LONG(&_1, 1); - ZEPHIR_INIT_VAR(&last); - zephir_substr(&last, &input, zephir_get_intval(&_0), 1 , 0); - ZEPHIR_CALL_FUNCTION(&ord, "ord", NULL, 245, &last); - zephir_check_call_status(); - if (ZEPHIR_LE_LONG(&ord, blockSize)) { - ZEPHIR_CPY_WRT(&paddingSize, &ord); - ZEPHIR_INIT_VAR(&repeat); - ZVAL_STRING(&repeat, ""); - if (ZEPHIR_GT_LONG(&paddingSize, 1)) { - ZVAL_LONG(&_2$$4, 0); - ZEPHIR_CALL_FUNCTION(&_3$$4, "chr", NULL, 244, &_2$$4); - zephir_check_call_status(); - ZVAL_LONG(&_2$$4, (zephir_get_numberval(&paddingSize) - 1)); - ZEPHIR_CALL_FUNCTION(&repeat, "str_repeat", NULL, 1, &_3$$4, &_2$$4); - zephir_check_call_status(); - } - ZEPHIR_INIT_VAR(&padding); - ZEPHIR_CONCAT_VV(&padding, &repeat, &last); - ZEPHIR_INIT_VAR(&_4$$3); - zephir_sub_function(&_4$$3, &length, &paddingSize); - ZEPHIR_INIT_VAR(&_5$$3); - zephir_substr(&_5$$3, &input, zephir_get_intval(&_4$$3), 0, ZEPHIR_SUBSTR_NO_LENGTH); - if (!ZEPHIR_IS_IDENTICAL(&_5$$3, &padding)) { - ZEPHIR_INIT_NVAR(&paddingSize); - ZVAL_LONG(&paddingSize, 0); - } + zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); + if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + RETURN_MM_NULL(); } - RETURN_CCTOR(&paddingSize); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_Iso10126) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, Iso10126, phalcon, encryption_crypt_padding_iso10126, phalcon_encryption_crypt_padding_iso10126_method_entry, 0); - - zend_class_implements(phalcon_encryption_crypt_padding_iso10126_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); - return SUCCESS; + if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { + zephir_get_strval(&routePattern, routePattern_param); + } else { + ZEPHIR_INIT_VAR(&routePattern); + } + ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&route, &router, "addpatch", NULL, 0, &routePattern); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, &route, "getrouteid", NULL, 0); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("handlers"), &_0, handler); + RETURN_CCTOR(&route); } -static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Iso10126, pad) +static PHP_METHOD(Phalcon_Mvc_Micro, post) { - zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL; - zval *paddingSize_param = NULL, counter, padding, _7, _8, _3$$3, _5$$3; - zend_long paddingSize, ZEPHIR_LAST_CALL_STATUS, _1, _2; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *routePattern_param = NULL, *handler, handler_sub, router, route, _0; + zval routePattern; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&counter); - ZVAL_UNDEF(&padding); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_5$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(paddingSize) + ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&router); + ZVAL_UNDEF(&route); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(routePattern) + Z_PARAM_ZVAL(handler) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &paddingSize_param); - ZEPHIR_INIT_VAR(&padding); - ZVAL_STRING(&padding, ""); - _2 = (paddingSize - 2); - _1 = 0; - _0 = 0; - if (_1 <= _2) { - while (1) { - if (_0) { - _1++; - if (!(_1 <= _2)) { - break; - } - } else { - _0 = 1; - } - ZEPHIR_INIT_NVAR(&counter); - ZVAL_LONG(&counter, _1); - ZEPHIR_CALL_FUNCTION(&_3$$3, "rand", &_4, 246); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_5$$3, "chr", &_6, 244, &_3$$3); - zephir_check_call_status(); - zephir_concat_self(&padding, &_5$$3); - } + zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); + if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + RETURN_MM_NULL(); } - ZVAL_LONG(&_7, paddingSize); - ZEPHIR_CALL_FUNCTION(&_8, "chr", &_6, 244, &_7); + if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { + zephir_get_strval(&routePattern, routePattern_param); + } else { + ZEPHIR_INIT_VAR(&routePattern); + } + ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); zephir_check_call_status(); - zephir_concat_self(&padding, &_8); - RETURN_CCTOR(&padding); + ZEPHIR_CALL_METHOD(&route, &router, "addpost", NULL, 0, &routePattern); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, &route, "getrouteid", NULL, 0); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("handlers"), &_0, handler); + RETURN_CCTOR(&route); } -static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Iso10126, unpad) +static PHP_METHOD(Phalcon_Mvc_Micro, put) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long blockSize, ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL, *blockSize_param = NULL, last, length, _0, _1; - zval input; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *routePattern_param = NULL, *handler, handler_sub, router, route, _0; + zval routePattern; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&last); - ZVAL_UNDEF(&length); + ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&router); + ZVAL_UNDEF(&route); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(input) - Z_PARAM_LONG(blockSize) + Z_PARAM_STR(routePattern) + Z_PARAM_ZVAL(handler) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); - zephir_get_strval(&input, input_param); - ZEPHIR_INIT_VAR(&length); - ZVAL_LONG(&length, zephir_fast_strlen_ev(&input)); - ZVAL_LONG(&_0, (zephir_get_numberval(&length) - 1)); - ZVAL_LONG(&_1, 1); - ZEPHIR_INIT_VAR(&last); - zephir_substr(&last, &input, zephir_get_intval(&_0), 1 , 0); - ZEPHIR_RETURN_CALL_FUNCTION("ord", NULL, 245, &last); + zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); + if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { + zephir_get_strval(&routePattern, routePattern_param); + } else { + ZEPHIR_INIT_VAR(&routePattern); + } + ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_CALL_METHOD(&route, &router, "addput", NULL, 0, &routePattern); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, &route, "getrouteid", NULL, 0); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("handlers"), &_0, handler); + RETURN_CCTOR(&route); } +static PHP_METHOD(Phalcon_Mvc_Micro, setActiveHandler) +{ + zval *activeHandler, activeHandler_sub; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&activeHandler_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(activeHandler) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &activeHandler); + zephir_update_property_zval(this_ptr, ZEND_STRL("activeHandler"), activeHandler); +} - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_IsoIek) +static PHP_METHOD(Phalcon_Mvc_Micro, setDI) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, IsoIek, phalcon, encryption_crypt_padding_isoiek, phalcon_encryption_crypt_padding_isoiek_method_entry, 0); + zval *container, container_sub; + zval *this_ptr = getThis(); - zend_class_implements(phalcon_encryption_crypt_padding_isoiek_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); - return SUCCESS; + ZVAL_UNDEF(&container_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &container); + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); } -static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_IsoIek, pad) +static PHP_METHOD(Phalcon_Mvc_Micro, setModelBinder) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *paddingSize_param = NULL, _0, _1, _2, _3; - zend_long paddingSize, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *modelBinder, modelBinder_sub, *cache = NULL, cache_sub, __$null, _0$$3; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(paddingSize) + ZVAL_UNDEF(&modelBinder_sub); + ZVAL_UNDEF(&cache_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0$$3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(modelBinder, phalcon_mvc_model_binderinterface_ce) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(cache) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &paddingSize_param); - ZVAL_LONG(&_0, 0x80); - ZEPHIR_CALL_FUNCTION(&_1, "chr", NULL, 244, &_0); - zephir_check_call_status(); - ZVAL_LONG(&_0, 0); - ZEPHIR_CALL_FUNCTION(&_2, "chr", NULL, 244, &_0); - zephir_check_call_status(); - ZVAL_LONG(&_0, (paddingSize - 1)); - ZEPHIR_CALL_FUNCTION(&_3, "str_repeat", NULL, 1, &_2, &_0); - zephir_check_call_status(); - ZEPHIR_CONCAT_VV(return_value, &_1, &_3); - RETURN_MM(); + zephir_fetch_params(1, 1, 1, &modelBinder, &cache); + if (!cache) { + cache = &cache_sub; + ZEPHIR_CPY_WRT(cache, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(cache); + } + if (Z_TYPE_P(cache) == IS_STRING) { + ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "getservice", NULL, 0, cache); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(cache, &_0$$3); + } + if (Z_TYPE_P(cache) != IS_NULL) { + ZEPHIR_CALL_METHOD(NULL, modelBinder, "setcache", NULL, 0, cache); + zephir_check_call_status(); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("modelBinder"), modelBinder); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_IsoIek, unpad) +static PHP_METHOD(Phalcon_Mvc_Micro, setResponseHandler) +{ + zval *handler, handler_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&handler_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(handler) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &handler); + zephir_update_property_zval(this_ptr, ZEND_STRL("responseHandler"), handler); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Mvc_Micro, setService) { - zend_bool _0, _5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL; - zend_long blockSize, ZEPHIR_LAST_CALL_STATUS, counter = 0, paddingSize = 0; - zval *input_param = NULL, *blockSize_param = NULL, length, inputArray, _1, _2, _3, _6, _7; - zval input; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool shared; + zval *serviceName_param = NULL, *definition, definition_sub, *shared_param = NULL, _0, _2, _3, _1$$3; + zval serviceName; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&length); - ZVAL_UNDEF(&inputArray); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&serviceName); + ZVAL_UNDEF(&definition_sub); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(input) - Z_PARAM_LONG(blockSize) + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(serviceName) + Z_PARAM_ZVAL(definition) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(shared) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); - zephir_get_strval(&input, input_param); - paddingSize = 0; - ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 234, &input); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&inputArray, "str_split", NULL, 88, &input); - zephir_check_call_status(); - counter = (zephir_get_numberval(&length) - 1); - while (1) { - _0 = counter > 0; - if (_0) { - zephir_array_fetch_long(&_1, &inputArray, counter, PH_NOISY | PH_READONLY, "phalcon/Encryption/Crypt/Padding/IsoIek.zep", 48); - ZVAL_LONG(&_2, 0); - ZEPHIR_CALL_FUNCTION(&_3, "chr", &_4, 244, &_2); - zephir_check_call_status(); - _0 = ZEPHIR_IS_IDENTICAL(&_1, &_3); - } - _5 = _0; - if (_5) { - _5 = paddingSize < blockSize; - } - if (!(_5)) { - break; + zephir_fetch_params(1, 2, 1, &serviceName_param, &definition, &shared_param); + if (UNEXPECTED(Z_TYPE_P(serviceName_param) != IS_STRING && Z_TYPE_P(serviceName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'serviceName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(serviceName_param) == IS_STRING)) { + zephir_get_strval(&serviceName, serviceName_param); + } else { + ZEPHIR_INIT_VAR(&serviceName); + } + if (!shared_param) { + shared = 0; + } else { } - paddingSize++; - counter--; + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_di_factorydefault_ce); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 416); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &_1$$3); } - zephir_array_fetch_long(&_6, &inputArray, counter, PH_NOISY | PH_READONLY, "phalcon/Encryption/Crypt/Padding/IsoIek.zep", 55); - ZVAL_LONG(&_2, 0x80); - ZEPHIR_CALL_FUNCTION(&_7, "chr", &_4, 244, &_2); - zephir_check_call_status(); - if (ZEPHIR_IS_EQUAL(&_6, &_7)) { - paddingSize++; + zephir_read_property(&_2, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + if (shared) { + ZVAL_BOOL(&_3, 1); } else { - paddingSize = 0; + ZVAL_BOOL(&_3, 0); } - RETURN_MM_LONG(paddingSize); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_Noop) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, Noop, phalcon, encryption_crypt_padding_noop, phalcon_encryption_crypt_padding_noop_method_entry, 0); - - zend_class_implements(phalcon_encryption_crypt_padding_noop_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); - return SUCCESS; + ZEPHIR_RETURN_CALL_METHOD(&_2, "set", NULL, 0, &serviceName, definition, &_3); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Noop, pad) +static PHP_METHOD(Phalcon_Mvc_Micro, stop) { - zval *paddingSize_param = NULL; - zend_long paddingSize; + zval __$true, __$false; + zval *this_ptr = getThis(); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(paddingSize) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &paddingSize_param); - RETURN_STRING(""); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$false); + } } -static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Noop, unpad) +zend_object *zephir_init_properties_Phalcon_Mvc_Micro(zend_class_entry *class_type) { + zval _0, _2, _4, _6, _8, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long blockSize; - zval *input_param = NULL, *blockSize_param = NULL; - zval input; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_9$$7); + - ZVAL_UNDEF(&input); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(input) - Z_PARAM_LONG(blockSize) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); - zephir_get_strval(&input, input_param); - RETURN_MM_LONG(0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("handlers"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("handlers"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("finishHandlers"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("finishHandlers"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("beforeHandlers"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("beforeHandlers"), &_5$$5); + } + zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("afterHandlers"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_6) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$6); + array_init(&_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("afterHandlers"), &_7$$6); + } + zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("afterBindingHandlers"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_8) == IS_NULL) { + ZEPHIR_INIT_VAR(&_9$$7); + array_init(&_9$$7); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("afterBindingHandlers"), &_9$$7); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } } @@ -22710,7487 +23807,9630 @@ static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Noop, unpad) -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_PadInterface) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Encryption\\Crypt\\Padding, PadInterface, phalcon, encryption_crypt_padding_padinterface, phalcon_encryption_crypt_padding_padinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_Padding_PadInterface, pad); -ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_Padding_PadInterface, unpad); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Model, phalcon, mvc_model, phalcon_di_abstractinjectionaware_ce, phalcon_mvc_model_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + zend_declare_property_long(phalcon_mvc_model_ce, SL("dirtyState"), 1, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_ce, SL("dirtyRelated"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_ce, SL("errorMessages"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_ce, SL("modelsManager"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_ce, SL("modelsMetaData"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_ce, SL("related"), ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_mvc_model_ce, SL("operationMade"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_ce, SL("oldSnapshot"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_mvc_model_ce, SL("skipped"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_ce, SL("snapshot"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_ce, SL("transaction"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_ce, SL("uniqueKey"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_ce, SL("uniqueParams"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_ce, SL("uniqueTypes"), ZEND_ACC_PROTECTED); + phalcon_mvc_model_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model; + zephir_declare_class_constant_long(phalcon_mvc_model_ce, SL("DIRTY_STATE_DETACHED"), 2); + zephir_declare_class_constant_long(phalcon_mvc_model_ce, SL("DIRTY_STATE_PERSISTENT"), 0); -#ifdef HAVE_CONFIG_H -#endif + zephir_declare_class_constant_long(phalcon_mvc_model_ce, SL("DIRTY_STATE_TRANSIENT"), 1); + zephir_declare_class_constant_long(phalcon_mvc_model_ce, SL("OP_CREATE"), 1); + zephir_declare_class_constant_long(phalcon_mvc_model_ce, SL("OP_DELETE"), 3); + zephir_declare_class_constant_long(phalcon_mvc_model_ce, SL("OP_NONE"), 0); + zephir_declare_class_constant_long(phalcon_mvc_model_ce, SL("OP_UPDATE"), 2); -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_Pkcs7) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, Pkcs7, phalcon, encryption_crypt_padding_pkcs7, phalcon_encryption_crypt_padding_pkcs7_method_entry, 0); + zephir_declare_class_constant_string(phalcon_mvc_model_ce, SL("TRANSACTION_INDEX"), "transaction"); - zend_class_implements(phalcon_encryption_crypt_padding_pkcs7_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); + zend_class_implements(phalcon_mvc_model_ce, 1, phalcon_mvc_entityinterface_ce); + zend_class_implements(phalcon_mvc_model_ce, 1, phalcon_mvc_modelinterface_ce); + zend_class_implements(phalcon_mvc_model_ce, 1, phalcon_mvc_model_resultinterface_ce); + zend_class_implements(phalcon_mvc_model_ce, 1, zend_ce_serializable); + zend_class_implements(phalcon_mvc_model_ce, 1, php_json_serializable_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Pkcs7, pad) +static PHP_METHOD(Phalcon_Mvc_Model, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *paddingSize_param = NULL, _0, _1; - zend_long paddingSize, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *data = NULL, data_sub, *container = NULL, container_sub, *modelsManager = NULL, modelsManager_sub, __$null, _0$$4, _1$$4, _2$$4, _3$$5, _4$$5, _5$$6, _6$$6, _7$$6; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(paddingSize) + ZVAL_UNDEF(&data_sub); + ZVAL_UNDEF(&container_sub); + ZVAL_UNDEF(&modelsManager_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_6$$6); + ZVAL_UNDEF(&_7$$6); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 3) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(data) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(container, phalcon_di_diinterface_ce) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(modelsManager, phalcon_mvc_model_managerinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &paddingSize_param); - ZVAL_LONG(&_0, paddingSize); - ZEPHIR_CALL_FUNCTION(&_1, "chr", NULL, 244, &_0); - zephir_check_call_status(); - ZVAL_LONG(&_0, paddingSize); - ZEPHIR_RETURN_CALL_FUNCTION("str_repeat", NULL, 1, &_1, &_0); + zephir_fetch_params(1, 0, 3, &data, &container, &modelsManager); + if (!data) { + data = &data_sub; + data = &__$null; + } + if (!container) { + container = &container_sub; + ZEPHIR_CPY_WRT(container, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(container); + } + if (!modelsManager) { + modelsManager = &modelsManager_sub; + ZEPHIR_CPY_WRT(modelsManager, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(modelsManager); + } + if (Z_TYPE_P(container) == IS_NULL) { + ZEPHIR_CALL_CE_STATIC(container, phalcon_di_di_ce, "getdefault", NULL, 0); + zephir_check_call_status(); + } + if (Z_TYPE_P(container) == IS_NULL) { + ZEPHIR_INIT_VAR(&_0$$4); + object_init_ex(&_0$$4, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_1$$4); + zephir_get_class(&_1$$4, this_ptr, 0); + ZEPHIR_INIT_VAR(&_2$$4); + ZEPHIR_CONCAT_SVS(&_2$$4, "A dependency injection container is required to access the services related to the ODM in '", &_1$$4, "'"); + ZEPHIR_CALL_METHOD(NULL, &_0$$4, "__construct", NULL, 33, &_2$$4); + zephir_check_call_status(); + zephir_throw_exception_debug(&_0$$4, "phalcon/Mvc/Model.zep", 185); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); + if (Z_TYPE_P(modelsManager) == IS_NULL) { + ZEPHIR_INIT_VAR(&_4$$5); + ZVAL_STRING(&_4$$5, "modelsManager"); + ZEPHIR_CALL_METHOD(&_3$$5, container, "getshared", NULL, 0, &_4$$5); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(modelsManager, &_3$$5); + if (Z_TYPE_P(modelsManager) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$6); + object_init_ex(&_5$$6, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_6$$6); + zephir_get_class(&_6$$6, this_ptr, 0); + ZEPHIR_INIT_VAR(&_7$$6); + ZEPHIR_CONCAT_SVS(&_7$$6, "The injected service 'modelsManager' is not valid in '", &_6$$6, "'"); + ZEPHIR_CALL_METHOD(NULL, &_5$$6, "__construct", NULL, 33, &_7$$6); + zephir_check_call_status(); + zephir_throw_exception_debug(&_5$$6, "phalcon/Mvc/Model.zep", 198); + ZEPHIR_MM_RESTORE(); + return; + } + } + zephir_update_property_zval(this_ptr, ZEND_STRL("modelsManager"), modelsManager); + ZEPHIR_CALL_METHOD(NULL, modelsManager, "initialize", NULL, 0, this_ptr); zephir_check_call_status(); - RETURN_MM(); + if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("onconstruct")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "onconstruct", NULL, 0, data); + zephir_check_call_status(); + } + if (Z_TYPE_P(data) == IS_ARRAY) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "assign", NULL, 0, data); + zephir_check_call_status(); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Pkcs7, unpad) +static PHP_METHOD(Phalcon_Mvc_Model, __call) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long blockSize, ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL, *blockSize_param = NULL, last, length, ord, padding, paddingSize, _0, _1, _2$$3, _3$$3, _4$$3; - zval input; + zend_long ZEPHIR_LAST_CALL_STATUS; + zephir_fcall_cache_entry *_0 = NULL; + zval arguments; + zval *method_param = NULL, *arguments_param = NULL, modelName, status, records, _1, _2, _3; + zval method; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&last); - ZVAL_UNDEF(&length); - ZVAL_UNDEF(&ord); - ZVAL_UNDEF(&padding); - ZVAL_UNDEF(&paddingSize); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&status); + ZVAL_UNDEF(&records); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&arguments); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(input) - Z_PARAM_LONG(blockSize) + Z_PARAM_STR(method) + Z_PARAM_ARRAY(arguments) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); - zephir_get_strval(&input, input_param); - ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 234, &input); + zephir_fetch_params(1, 2, 0, &method_param, &arguments_param); + zephir_get_strval(&method, method_param); + zephir_get_arrval(&arguments, arguments_param); + ZEPHIR_CALL_SELF(&records, "invokefinder", &_0, 418, &method, &arguments); zephir_check_call_status(); - ZVAL_LONG(&_0, (zephir_get_numberval(&length) - 1)); - ZVAL_LONG(&_1, 1); - ZEPHIR_INIT_VAR(&last); - zephir_substr(&last, &input, zephir_get_intval(&_0), 1 , 0); - ZEPHIR_CALL_FUNCTION(&ord, "ord", NULL, 245, &last); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&records)) { + RETURN_CCTOR(&records); + } + ZEPHIR_INIT_VAR(&modelName); + zephir_get_class(&modelName, this_ptr, 0); + ZEPHIR_CALL_METHOD(&records, this_ptr, "getrelatedrecords", NULL, 0, &modelName, &method, &arguments); zephir_check_call_status(); - if (ZEPHIR_LE_LONG(&ord, blockSize)) { - ZEPHIR_CPY_WRT(&paddingSize, &ord); - ZEPHIR_CALL_FUNCTION(&_2$$3, "chr", NULL, 244, &paddingSize); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&padding, "str_repeat", NULL, 1, &_2$$3, &paddingSize); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_3$$3); - zephir_sub_function(&_3$$3, &length, &paddingSize); - ZEPHIR_INIT_VAR(&_4$$3); - zephir_substr(&_4$$3, &input, zephir_get_intval(&_3$$3), 0, ZEPHIR_SUBSTR_NO_LENGTH); - if (!ZEPHIR_IS_IDENTICAL(&_4$$3, &padding)) { - ZEPHIR_INIT_NVAR(&paddingSize); - ZVAL_LONG(&paddingSize, 0); - } + if (!ZEPHIR_IS_FALSE_IDENTICAL(&records)) { + RETURN_CCTOR(&records); } - RETURN_CCTOR(&paddingSize); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_Space) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, Space, phalcon, encryption_crypt_padding_space, phalcon_encryption_crypt_padding_space_method_entry, 0); - - zend_class_implements(phalcon_encryption_crypt_padding_space_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); - return SUCCESS; + zephir_read_property(&_1, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&status, &_1, "missingmethod", NULL, 0, this_ptr, &method, &arguments); + zephir_check_call_status(); + if (Z_TYPE_P(&status) != IS_NULL) { + RETURN_CCTOR(&status); + } + ZEPHIR_INIT_VAR(&_2); + object_init_ex(&_2, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_3); + ZEPHIR_CONCAT_SVSVS(&_3, "The method '", &method, "' doesn't exist on model '", &modelName, "'"); + ZEPHIR_CALL_METHOD(NULL, &_2, "__construct", NULL, 33, &_3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_2, "phalcon/Mvc/Model.zep", 267); + ZEPHIR_MM_RESTORE(); + return; } -static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Space, pad) +static PHP_METHOD(Phalcon_Mvc_Model, __callStatic) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *paddingSize_param = NULL, _0, _1; - zend_long paddingSize, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zephir_fcall_cache_entry *_0 = NULL; + zval arguments; + zval *method_param = NULL, *arguments_param = NULL, modelName, records, _1, _2; + zval method; - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&records); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(paddingSize) + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&arguments); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(method) + Z_PARAM_ARRAY(arguments) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &paddingSize_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, " "); - ZVAL_LONG(&_1, paddingSize); - ZEPHIR_RETURN_CALL_FUNCTION("str_repeat", NULL, 1, &_0, &_1); + zephir_fetch_params(1, 2, 0, &method_param, &arguments_param); + zephir_get_strval(&method, method_param); + zephir_get_arrval(&arguments, arguments_param); + ZEPHIR_CALL_SELF(&records, "invokefinder", &_0, 418, &method, &arguments); zephir_check_call_status(); - RETURN_MM(); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&records)) { + RETURN_CCTOR(&records); + } + ZEPHIR_INIT_VAR(&modelName); + zephir_get_called_class(&modelName); + ZEPHIR_INIT_VAR(&_1); + object_init_ex(&_1, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_CONCAT_SVSVS(&_2, "The method '", &method, "' doesn't exist on model '", &modelName, "'"); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 33, &_2); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1, "phalcon/Mvc/Model.zep", 293); + ZEPHIR_MM_RESTORE(); + return; } -static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Space, unpad) +static PHP_METHOD(Phalcon_Mvc_Model, __get) { - zend_bool _0, _5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL; - zend_long blockSize, ZEPHIR_LAST_CALL_STATUS, counter = 0, paddingSize = 0; - zval *input_param = NULL, *blockSize_param = NULL, length, inputArray, _1, _2, _3; - zval input; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *property_param = NULL, modelName, manager, lowerProperty, relation, _0, _4, _5, _6, _1$$3, _2$$4, _3$$4; + zval property, method; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&length); - ZVAL_UNDEF(&inputArray); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(input) - Z_PARAM_LONG(blockSize) + ZVAL_UNDEF(&property); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&lowerProperty); + ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(property) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); - zephir_get_strval(&input, input_param); - ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 234, &input); + zephir_fetch_params(1, 1, 0, &property_param); + if (UNEXPECTED(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(property_param) == IS_STRING)) { + zephir_get_strval(&property, property_param); + } else { + ZEPHIR_INIT_VAR(&property); + } + ZEPHIR_INIT_VAR(&modelName); + zephir_get_class(&modelName, this_ptr, 0); + ZEPHIR_CALL_METHOD(&manager, this_ptr, "getmodelsmanager", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&inputArray, "str_split", NULL, 88, &input); + ZEPHIR_INIT_VAR(&lowerProperty); + zephir_fast_strtolower(&lowerProperty, &property); + ZEPHIR_CALL_METHOD(&_0, &manager, "getrelationbyalias", NULL, 0, &modelName, &lowerProperty); zephir_check_call_status(); - counter = (zephir_get_numberval(&length) - 1); - paddingSize = 0; - while (1) { - _0 = counter >= 0; - if (_0) { - zephir_array_fetch_long(&_1, &inputArray, counter, PH_NOISY | PH_READONLY, "phalcon/Encryption/Crypt/Padding/Space.zep", 48); - ZVAL_LONG(&_2, 32); - ZEPHIR_CALL_FUNCTION(&_3, "chr", &_4, 244, &_2); - zephir_check_call_status(); - _0 = ZEPHIR_IS_EQUAL(&_1, &_3); - } - _5 = _0; - if (_5) { - _5 = paddingSize <= blockSize; - } - if (!(_5)) { - break; + ZEPHIR_CPY_WRT(&relation, &_0); + if (Z_TYPE_P(&relation) == IS_OBJECT) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("dirtyRelated"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset(&_1$$3, &lowerProperty)) { + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("dirtyRelated"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_3$$4, &_2$$4, &lowerProperty, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 325); + RETURN_CTOR(&_3$$4); } - paddingSize++; - counter--; + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelated", NULL, 0, &lowerProperty); + zephir_check_call_status(); + RETURN_MM(); } - RETURN_MM_LONG(paddingSize); + ZEPHIR_INIT_VAR(&_4); + zephir_camelize(&_4, &property, NULL ); + ZEPHIR_INIT_VAR(&_5); + ZEPHIR_CONCAT_SV(&_5, "get", &_4); + zephir_get_strval(&method, &_5); + if ((zephir_method_exists(this_ptr, &method) == SUCCESS)) { + ZEPHIR_RETURN_CALL_METHOD_ZVAL(this_ptr, &method, NULL, 0); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_INIT_VAR(&_6); + ZEPHIR_CONCAT_SVSV(&_6, "Access to undefined property ", &modelName, "::", &property); + ZEPHIR_CALL_FUNCTION(NULL, "trigger_error", NULL, 7, &_6); + zephir_check_call_status(); + RETURN_MM_NULL(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_Zero) +static PHP_METHOD(Phalcon_Mvc_Model, __isset) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, Zero, phalcon, encryption_crypt_padding_zero, phalcon_encryption_crypt_padding_zero_method_entry, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *property_param = NULL, manager, method, modelName, relation, result, _0, _1$$4; + zval property; + zval *this_ptr = getThis(); - zend_class_implements(phalcon_encryption_crypt_padding_zero_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); - return SUCCESS; + ZVAL_UNDEF(&property); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(property) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &property_param); + if (UNEXPECTED(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(property_param) == IS_STRING)) { + zephir_get_strval(&property, property_param); + } else { + ZEPHIR_INIT_VAR(&property); + } + ZEPHIR_INIT_VAR(&modelName); + zephir_get_class(&modelName, this_ptr, 0); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmodelsmanager", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&manager, &_0); + ZEPHIR_CALL_METHOD(&_0, &manager, "getrelationbyalias", NULL, 0, &modelName, &property); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&relation, &_0); + if (Z_TYPE_P(&relation) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&result); + ZVAL_BOOL(&result, 1); + } else { + ZEPHIR_INIT_VAR(&_1$$4); + zephir_camelize(&_1$$4, &property, NULL ); + ZEPHIR_INIT_VAR(&method); + ZEPHIR_CONCAT_SV(&method, "get", &_1$$4); + ZEPHIR_INIT_NVAR(&result); + ZVAL_BOOL(&result, (zephir_method_exists(this_ptr, &method) == SUCCESS)); + } + RETURN_CCTOR(&result); } -static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Zero, pad) +static PHP_METHOD(Phalcon_Mvc_Model, __serialize) { + zend_bool _3, _4; + zval attributes, manager, dirtyState, snapshot, _0, _1, _2, _5$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *paddingSize_param = NULL, _0, _1; - zend_long paddingSize, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&dirtyState); + ZVAL_UNDEF(&snapshot); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(paddingSize) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_5$$3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &paddingSize_param); - ZVAL_LONG(&_0, 0); - ZEPHIR_CALL_FUNCTION(&_1, "chr", NULL, 244, &_0); + + ZEPHIR_INIT_VAR(&snapshot); + ZVAL_NULL(&snapshot); + ZVAL_NULL(&_0); + ZVAL_BOOL(&_1, 0); + ZEPHIR_CALL_METHOD(&attributes, this_ptr, "toarray", NULL, 0, &_0, &_1); zephir_check_call_status(); - ZVAL_LONG(&_0, paddingSize); - ZEPHIR_RETURN_CALL_FUNCTION("str_repeat", NULL, 1, &_1, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dirtyState"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&dirtyState, &_0); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "getmodelsmanager", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&manager, &_2); + ZEPHIR_CALL_METHOD(&_2, &manager, "iskeepingsnapshots", NULL, 0, this_ptr); zephir_check_call_status(); + _3 = zephir_is_true(&_2); + if (_3) { + zephir_read_property(&_0, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); + _3 = Z_TYPE_P(&_0) != IS_NULL; + } + _4 = _3; + if (_4) { + zephir_read_property(&_1, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); + _4 = !ZEPHIR_IS_EQUAL(&attributes, &_1); + } + if (_4) { + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&snapshot, &_5$$3); + } + zephir_create_array(return_value, 3, 0); + zephir_array_update_string(return_value, SL("attributes"), &attributes, PH_COPY | PH_SEPARATE); + zephir_array_update_string(return_value, SL("snapshot"), &snapshot, PH_COPY | PH_SEPARATE); + zephir_array_update_string(return_value, SL("dirtyState"), &dirtyState, PH_COPY | PH_SEPARATE); RETURN_MM(); } -static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Zero, unpad) +static PHP_METHOD(Phalcon_Mvc_Model, __set) { - zend_bool _0, _5; + zend_bool _0; + zval related; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL; - zend_long blockSize, ZEPHIR_LAST_CALL_STATUS, counter = 0, paddingSize = 0; - zval *input_param = NULL, *blockSize_param = NULL, length, inputArray, _1, _2, _3; - zval input; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *property_param = NULL, *value, value_sub, lowerProperty, modelName, manager, relation, referencedModel, item, dirtyState, _14, _15, _1$$3, _2$$4, _3$$4, _4$$6, _5$$7, _6$$8, _7$$9, _8$$9, *_9$$10, _10$$10, _11$$10, _12$$17, _13$$18, _16$$20, _17$$21, _18$$21, _19$$21; + zval property; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&length); - ZVAL_UNDEF(&inputArray); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&property); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&lowerProperty); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&referencedModel); + ZVAL_UNDEF(&item); + ZVAL_UNDEF(&dirtyState); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_15); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$6); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_6$$8); + ZVAL_UNDEF(&_7$$9); + ZVAL_UNDEF(&_8$$9); + ZVAL_UNDEF(&_10$$10); + ZVAL_UNDEF(&_11$$10); + ZVAL_UNDEF(&_12$$17); + ZVAL_UNDEF(&_13$$18); + ZVAL_UNDEF(&_16$$20); + ZVAL_UNDEF(&_17$$21); + ZVAL_UNDEF(&_18$$21); + ZVAL_UNDEF(&_19$$21); + ZVAL_UNDEF(&related); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(input) - Z_PARAM_LONG(blockSize) + Z_PARAM_STR(property) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); - zephir_get_strval(&input, input_param); - ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 234, &input); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&inputArray, "str_split", NULL, 88, &input); - zephir_check_call_status(); - counter = (zephir_get_numberval(&length) - 1); - paddingSize = 0; - while (1) { - _0 = counter >= 0; - if (_0) { - zephir_array_fetch_long(&_1, &inputArray, counter, PH_NOISY | PH_READONLY, "phalcon/Encryption/Crypt/Padding/Zero.zep", 48); - ZVAL_LONG(&_2, 0); - ZEPHIR_CALL_FUNCTION(&_3, "chr", &_4, 244, &_2); + zephir_fetch_params(1, 2, 0, &property_param, &value); + zephir_get_strval(&property, property_param); + _0 = Z_TYPE_P(value) == IS_OBJECT; + if (_0) { + _0 = zephir_instance_of_ev(value, phalcon_mvc_modelinterface_ce); + } + if (_0) { + ZEPHIR_INIT_VAR(&lowerProperty); + zephir_fast_strtolower(&lowerProperty, &property); + ZEPHIR_INIT_VAR(&modelName); + zephir_get_class(&modelName, this_ptr, 0); + ZEPHIR_CALL_METHOD(&manager, this_ptr, "getmodelsmanager", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1$$3, &manager, "getrelationbyalias", NULL, 0, &modelName, &lowerProperty); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&relation, &_1$$3); + if (Z_TYPE_P(&relation) == IS_OBJECT) { + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("dirtyState"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&dirtyState, &_2$$4); + ZEPHIR_CALL_METHOD(&_3$$4, value, "getdirtystate", NULL, 0); zephir_check_call_status(); - _0 = ZEPHIR_IS_EQUAL(&_1, &_3); + if (!ZEPHIR_IS_EQUAL(&_3$$4, &dirtyState)) { + ZEPHIR_INIT_NVAR(&dirtyState); + ZVAL_LONG(&dirtyState, 1); + } + zephir_unset_property_array(this_ptr, ZEND_STRL("related"), &lowerProperty); + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("related"), PH_NOISY_CC | PH_READONLY); + zephir_array_unset(&_2$$4, &lowerProperty, PH_SEPARATE); + zephir_update_property_array(this_ptr, SL("dirtyRelated"), &lowerProperty, value); + zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &dirtyState); + RETVAL_ZVAL(value, 1, 0); + RETURN_MM(); } - _5 = _0; - if (_5) { - _5 = paddingSize <= blockSize; + } else if (Z_TYPE_P(value) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&lowerProperty); + zephir_fast_strtolower(&lowerProperty, &property); + ZEPHIR_INIT_NVAR(&modelName); + zephir_get_class(&modelName, this_ptr, 0); + ZEPHIR_CALL_METHOD(&manager, this_ptr, "getmodelsmanager", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4$$6, &manager, "getrelationbyalias", NULL, 0, &modelName, &lowerProperty); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&relation, &_4$$6); + if (Z_TYPE_P(&relation) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(&_5$$7, &relation, "gettype", NULL, 0); + zephir_check_call_status(); + do { + if (ZEPHIR_IS_LONG(&_5$$7, 0) || ZEPHIR_IS_LONG(&_5$$7, 1)) { + ZEPHIR_CALL_METHOD(&_6$$8, &relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&referencedModel, &manager, "load", NULL, 0, &_6$$8); + zephir_check_call_status(); + if (Z_TYPE_P(&referencedModel) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(NULL, &referencedModel, "assign", NULL, 0, value); + zephir_check_call_status(); + zephir_unset_property_array(this_ptr, ZEND_STRL("related"), &lowerProperty); + zephir_read_property(&_7$$9, this_ptr, ZEND_STRL("related"), PH_NOISY_CC | PH_READONLY); + zephir_array_unset(&_7$$9, &lowerProperty, PH_SEPARATE); + zephir_update_property_array(this_ptr, SL("dirtyRelated"), &lowerProperty, &referencedModel); + ZVAL_UNDEF(&_8$$9); + ZVAL_LONG(&_8$$9, 1); + zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &_8$$9); + RETVAL_ZVAL(value, 1, 0); + RETURN_MM(); + } + break; + } + if (ZEPHIR_IS_LONG(&_5$$7, 2) || ZEPHIR_IS_LONG(&_5$$7, 4)) { + ZEPHIR_INIT_VAR(&related); + array_init(&related); + zephir_is_iterable(value, 0, "phalcon/Mvc/Model.zep", 496); + if (Z_TYPE_P(value) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(value), _9$$10) + { + ZEPHIR_INIT_NVAR(&item); + ZVAL_COPY(&item, _9$$10); + if (Z_TYPE_P(&item) == IS_OBJECT) { + if (zephir_instance_of_ev(&item, phalcon_mvc_modelinterface_ce)) { + zephir_array_append(&related, &item, PH_SEPARATE, "phalcon/Mvc/Model.zep", 491); + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, value, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_10$$10, value, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_10$$10)) { + break; + } + ZEPHIR_CALL_METHOD(&item, value, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&item) == IS_OBJECT) { + if (zephir_instance_of_ev(&item, phalcon_mvc_modelinterface_ce)) { + zephir_array_append(&related, &item, PH_SEPARATE, "phalcon/Mvc/Model.zep", 491); + } + } + ZEPHIR_CALL_METHOD(NULL, value, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&item); + zephir_unset_property_array(this_ptr, ZEND_STRL("related"), &lowerProperty); + zephir_read_property(&_11$$10, this_ptr, ZEND_STRL("related"), PH_NOISY_CC | PH_READONLY); + zephir_array_unset(&_11$$10, &lowerProperty, PH_SEPARATE); + if (zephir_fast_count_int(&related) > 0) { + zephir_update_property_array(this_ptr, SL("dirtyRelated"), &lowerProperty, &related); + ZVAL_UNDEF(&_12$$17); + ZVAL_LONG(&_12$$17, 1); + zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &_12$$17); + } else { + zephir_unset_property_array(this_ptr, ZEND_STRL("dirtyRelated"), &lowerProperty); + zephir_read_property(&_13$$18, this_ptr, ZEND_STRL("dirtyRelated"), PH_NOISY_CC | PH_READONLY); + zephir_array_unset(&_13$$18, &lowerProperty, PH_SEPARATE); + } + RETVAL_ZVAL(value, 1, 0); + RETURN_MM(); + } + } while(0); + } - if (!(_5)) { - break; + } + ZEPHIR_CALL_METHOD(&_14, this_ptr, "possiblesetter", NULL, 419, &property, value); + zephir_check_call_status(); + if (zephir_is_true(&_14)) { + RETVAL_ZVAL(value, 1, 0); + RETURN_MM(); + } + ZEPHIR_CALL_FUNCTION(&_15, "property_exists", NULL, 290, this_ptr, &property); + zephir_check_call_status(); + if (zephir_is_true(&_15)) { + ZEPHIR_CALL_METHOD(&manager, this_ptr, "getmodelsmanager", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_16$$20, &manager, "isvisiblemodelproperty", NULL, 0, this_ptr, &property); + zephir_check_call_status(); + if (UNEXPECTED(!zephir_is_true(&_16$$20))) { + ZEPHIR_INIT_VAR(&_17$$21); + object_init_ex(&_17$$21, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_18$$21); + zephir_get_class(&_18$$21, this_ptr, 0); + ZEPHIR_INIT_VAR(&_19$$21); + ZEPHIR_CONCAT_SVSVS(&_19$$21, "Cannot access property '", &property, "' (not public) in '", &_18$$21, "'"); + ZEPHIR_CALL_METHOD(NULL, &_17$$21, "__construct", NULL, 33, &_19$$21); + zephir_check_call_status(); + zephir_throw_exception_debug(&_17$$21, "phalcon/Mvc/Model.zep", 525); + ZEPHIR_MM_RESTORE(); + return; } - paddingSize++; - counter--; } - RETURN_MM_LONG(paddingSize); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Exception_Exception) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Crypt\\Exception, Exception, phalcon, encryption_crypt_exception_exception, zend_ce_exception, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Exception_Mismatch) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Crypt\\Exception, Mismatch, phalcon, encryption_crypt_exception_mismatch, phalcon_encryption_crypt_exception_exception_ce, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Messages_Exception) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Messages, Exception, phalcon, messages_exception, zend_ce_exception, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Messages_Message) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Messages, Message, phalcon, messages_message, phalcon_messages_message_method_entry, 0); - - zend_declare_property_null(phalcon_messages_message_ce, SL("code"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_messages_message_ce, SL("field"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_messages_message_ce, SL("message"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_messages_message_ce, SL("type"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_messages_message_ce, SL("metaData"), ZEND_ACC_PROTECTED); - phalcon_messages_message_ce->create_object = zephir_init_properties_Phalcon_Messages_Message; - - zend_class_implements(phalcon_messages_message_ce, 1, phalcon_messages_messageinterface_ce); - zend_class_implements(phalcon_messages_message_ce, 1, php_json_serializable_ce); - return SUCCESS; + zephir_update_property_zval_zval(this_ptr, &property, value); + RETVAL_ZVAL(value, 1, 0); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Messages_Message, __construct) +static PHP_METHOD(Phalcon_Mvc_Model, __unserialize) { + zend_string *_12$$6; + zend_ulong _11$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval metaData; - zend_long code; - zval *message_param = NULL, *field = NULL, field_sub, *type_param = NULL, *code_param = NULL, *metaData_param = NULL, _0; - zval message, type; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *data_param = NULL, container, manager, key, value, snapshot, properties, dirtyState, _4, _5, _0$$3, _1$$4, _2$$4, _3$$4, _6$$5, _7$$5, _8$$5, *_9$$6, _10$$6; + zval data; zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&field_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&metaData); - ZEND_PARSE_PARAMETERS_START(1, 5) - Z_PARAM_STR(message) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL(field) - Z_PARAM_STR(type) - Z_PARAM_LONG(code) - Z_PARAM_ARRAY(metaData) + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&snapshot); + ZVAL_UNDEF(&properties); + ZVAL_UNDEF(&dirtyState); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_10$$6); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(data) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 4, &message_param, &field, &type_param, &code_param, &metaData_param); - if (UNEXPECTED(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 0, &data_param); + zephir_get_arrval(&data, data_param); + if (!(zephir_array_isset_string(&data, SL("attributes")))) { + ZEPHIR_INIT_VAR(&_0$$3); + zephir_create_array(&_0$$3, 1, 0); + zephir_array_update_string(&_0$$3, SL("attributes"), &data, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&data, &_0$$3); } - if (EXPECTED(Z_TYPE_P(message_param) == IS_STRING)) { - zephir_get_strval(&message, message_param); - } else { - ZEPHIR_INIT_VAR(&message); + ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$4); + object_init_ex(&_1$$4, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_2$$4); + zephir_get_class(&_2$$4, this_ptr, 0); + ZEPHIR_INIT_VAR(&_3$$4); + ZEPHIR_CONCAT_SVS(&_3$$4, "A dependency injection container is required to access the services related to the ODM in '", &_2$$4, "'"); + ZEPHIR_CALL_METHOD(NULL, &_1$$4, "__construct", NULL, 33, &_3$$4); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$4, "phalcon/Mvc/Model.zep", 554); + ZEPHIR_MM_RESTORE(); + return; } - if (!field) { - field = &field_sub; - ZEPHIR_INIT_VAR(field); - ZVAL_STRING(field, ""); + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &container); + ZEPHIR_INIT_VAR(&_5); + ZVAL_STRING(&_5, "modelsManager"); + ZEPHIR_CALL_METHOD(&_4, &container, "getshared", NULL, 0, &_5); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&manager, &_4); + if (Z_TYPE_P(&manager) == IS_NULL) { + ZEPHIR_INIT_VAR(&_6$$5); + object_init_ex(&_6$$5, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_7$$5); + zephir_get_class(&_7$$5, this_ptr, 0); + ZEPHIR_INIT_VAR(&_8$$5); + ZEPHIR_CONCAT_SVS(&_8$$5, "The injected service 'modelsManager' is not valid in '", &_7$$5, "'"); + ZEPHIR_CALL_METHOD(NULL, &_6$$5, "__construct", NULL, 33, &_8$$5); + zephir_check_call_status(); + zephir_throw_exception_debug(&_6$$5, "phalcon/Mvc/Model.zep", 569); + ZEPHIR_MM_RESTORE(); + return; } - if (!type_param) { - ZEPHIR_INIT_VAR(&type); - ZVAL_STRING(&type, ""); + zephir_update_property_zval(this_ptr, ZEND_STRL("modelsManager"), &manager); + ZEPHIR_CALL_METHOD(NULL, &manager, "initialize", NULL, 0, this_ptr); + zephir_check_call_status(); + zephir_memory_observe(&properties); + if (zephir_array_isset_string_fetch(&properties, &data, SL("attributes"), 0)) { + zephir_is_iterable(&properties, 0, "phalcon/Mvc/Model.zep", 592); + if (Z_TYPE_P(&properties) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&properties), _11$$6, _12$$6, _9$$6) + { + ZEPHIR_INIT_NVAR(&key); + if (_12$$6 != NULL) { + ZVAL_STR_COPY(&key, _12$$6); + } else { + ZVAL_LONG(&key, _11$$6); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _9$$6); + zephir_update_property_zval_zval(this_ptr, &key, &value); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &properties, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_10$$6, &properties, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_10$$6)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &properties, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &properties, "current", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval_zval(this_ptr, &key, &value); + ZEPHIR_CALL_METHOD(NULL, &properties, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); } else { - zephir_get_strval(&type, type_param); + ZEPHIR_INIT_NVAR(&properties); + array_init(&properties); } - if (!code_param) { - code = 0; - } else { + zephir_memory_observe(&dirtyState); + if (zephir_array_isset_string_fetch(&dirtyState, &data, SL("dirtyState"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &dirtyState); + } + ZEPHIR_CALL_METHOD(&_4, &manager, "iskeepingsnapshots", NULL, 0, this_ptr); + zephir_check_call_status(); + if (zephir_is_true(&_4)) { + if (zephir_array_isset_string_fetch(&snapshot, &data, SL("snapshot"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("snapshot"), &snapshot); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("snapshot"), &properties); } - if (!metaData_param) { - ZEPHIR_INIT_VAR(&metaData); - array_init(&metaData); - } else { - zephir_get_arrval(&metaData, metaData_param); } - zephir_update_property_zval(this_ptr, ZEND_STRL("message"), &message); - zephir_update_property_zval(this_ptr, ZEND_STRL("field"), field); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &type); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, code); - zephir_update_property_zval(this_ptr, ZEND_STRL("code"), &_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("metaData"), &metaData); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Messages_Message, __toString) -{ - - RETURN_MEMBER(getThis(), "message"); -} - -static PHP_METHOD(Phalcon_Messages_Message, getCode) -{ - - RETURN_MEMBER(getThis(), "code"); -} - -static PHP_METHOD(Phalcon_Messages_Message, getField) -{ - - RETURN_MEMBER(getThis(), "field"); -} - -static PHP_METHOD(Phalcon_Messages_Message, getMessage) -{ - - RETURN_MEMBER(getThis(), "message"); -} - -static PHP_METHOD(Phalcon_Messages_Message, getType) -{ - - RETURN_MEMBER(getThis(), "type"); -} - -static PHP_METHOD(Phalcon_Messages_Message, getMetaData) -{ - - RETURN_MEMBER(getThis(), "metaData"); -} - -static PHP_METHOD(Phalcon_Messages_Message, jsonSerialize) +static PHP_METHOD(Phalcon_Mvc_Model, addBehavior) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *behavior, behavior_sub, _0; zval *this_ptr = getThis(); + ZVAL_UNDEF(&behavior_sub); ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(behavior, phalcon_mvc_model_behaviorinterface_ce) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_create_array(return_value, 5, 0); - zephir_memory_observe(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("field"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("field"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("message"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("message"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("type"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("type"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("code"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("code"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("metaData"), &_0, PH_COPY | PH_SEPARATE); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &behavior); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "addbehavior", NULL, 0, this_ptr, behavior); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Messages_Message, setCode) +static PHP_METHOD(Phalcon_Mvc_Model, appendMessage) { - zval *code_param = NULL, _0; - zend_long code; + zval *message, message_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&message_sub); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(code) + Z_PARAM_OBJECT_OF_CLASS(message, phalcon_messages_messageinterface_ce) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &code_param); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, code); - zephir_update_property_zval(this_ptr, ZEND_STRL("code"), &_0); + zephir_fetch_params_without_memory_grow(1, 0, &message); + zephir_update_property_array_append(this_ptr, SL("errorMessages"), message); RETURN_THISW(); } -static PHP_METHOD(Phalcon_Messages_Message, setField) +static PHP_METHOD(Phalcon_Mvc_Model, assign) { - zval *field, field_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&field_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(field) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &field); - zephir_update_property_zval(this_ptr, ZEND_STRL("field"), field); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Messages_Message, setMessage) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *message_param = NULL; - zval message; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&message); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(message) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &message_param); - if (UNEXPECTED(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(message_param) == IS_STRING)) { - zephir_get_strval(&message, message_param); - } else { - ZEPHIR_INIT_VAR(&message); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("message"), &message); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Messages_Message, setMetaData) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *metaData_param = NULL; - zval metaData; + zend_bool _7$$12, _14$$18, _17$$22, _22$$28; + zend_string *_3$$3; + zend_ulong _2$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_9 = NULL, *_13 = NULL, *_16 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *data_param = NULL, *whiteList = NULL, whiteList_sub, *dataColumnMap = NULL, dataColumnMap_sub, __$null, key, keyMapped, value, attribute, attributeField, metaData, columnMap, disableAssignSetters, _4, *_5, _6, *_0$$3, _1$$3, _8$$13, _10$$16, _11$$16, _12$$16, _15$$18, _18$$23, _19$$26, _20$$26, _21$$26, _23$$28; + zval data, dataMapped; zval *this_ptr = getThis(); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&dataMapped); + ZVAL_UNDEF(&whiteList_sub); + ZVAL_UNDEF(&dataColumnMap_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&keyMapped); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&attributeField); ZVAL_UNDEF(&metaData); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(metaData) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &metaData_param); - ZEPHIR_OBS_COPY_OR_DUP(&metaData, metaData_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("metaData"), &metaData); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Messages_Message, setType) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *type_param = NULL; - zval type; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&type); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(type) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &type_param); - if (UNEXPECTED(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(type_param) == IS_STRING)) { - zephir_get_strval(&type, type_param); - } else { - ZEPHIR_INIT_VAR(&type); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &type); - RETURN_THIS(); -} - -zend_object *zephir_init_properties_Phalcon_Messages_Message(zend_class_entry *class_type) -{ - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&columnMap); + ZVAL_UNDEF(&disableAssignSetters); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); ZVAL_UNDEF(&_1$$3); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("metaData"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Messages_MessageInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Messages, MessageInterface, phalcon, messages_messageinterface, phalcon_messages_messageinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, __toString); -ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, getCode); -ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, getField); -ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, getMessage); -ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, getMetaData); -ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, getType); -ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, setCode); -ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, setField); -ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, setMessage); -ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, setMetaData); -ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, setType); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Messages_Messages) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Messages, Messages, phalcon, messages_messages, phalcon_messages_messages_method_entry, 0); - - zend_declare_property_long(phalcon_messages_messages_ce, SL("position"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_messages_messages_ce, SL("messages"), ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_messages_messages_ce, 1, zend_ce_arrayaccess); - zend_class_implements(phalcon_messages_messages_ce, 1, zend_ce_countable); - zend_class_implements(phalcon_messages_messages_ce, 1, zend_ce_iterator); - zend_class_implements(phalcon_messages_messages_ce, 1, php_json_serializable_ce); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Messages_Messages, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *messages_param = NULL; - zval messages; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&messages); - ZEND_PARSE_PARAMETERS_START(0, 1) + ZVAL_UNDEF(&_8$$13); + ZVAL_UNDEF(&_10$$16); + ZVAL_UNDEF(&_11$$16); + ZVAL_UNDEF(&_12$$16); + ZVAL_UNDEF(&_15$$18); + ZVAL_UNDEF(&_18$$23); + ZVAL_UNDEF(&_19$$26); + ZVAL_UNDEF(&_20$$26); + ZVAL_UNDEF(&_21$$26); + ZVAL_UNDEF(&_23$$28); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ARRAY(data) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(messages) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &messages_param); - if (!messages_param) { - ZEPHIR_INIT_VAR(&messages); - array_init(&messages); - } else { - zephir_get_arrval(&messages, messages_param); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), &messages); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Messages_Messages, appendMessage) -{ - zval *message, message_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&message_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(message, phalcon_messages_messageinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &message); - zephir_update_property_array_append(this_ptr, SL("messages"), message); -} - -static PHP_METHOD(Phalcon_Messages_Messages, appendMessages) -{ - zend_bool _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_2 = NULL, *_3 = NULL, *_4 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *messages, messages_sub, currentMessages, finalMessages, message, _1$$7; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&messages_sub); - ZVAL_UNDEF(¤tMessages); - ZVAL_UNDEF(&finalMessages); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&_1$$7); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(messages) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &messages); - _0 = Z_TYPE_P(messages) != IS_ARRAY; - if (_0) { - _0 = Z_TYPE_P(messages) != IS_OBJECT; - } - if (_0) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_messages_exception_ce, "The messages must be iterable", "phalcon/Messages/Messages.zep", 69); - return; - } - zephir_memory_observe(¤tMessages); - zephir_read_property(¤tMessages, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC); - if (Z_TYPE_P(messages) == IS_ARRAY) { - if (Z_TYPE_P(¤tMessages) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&finalMessages); - zephir_fast_array_merge(&finalMessages, ¤tMessages, messages); - } else { - ZEPHIR_CPY_WRT(&finalMessages, messages); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), &finalMessages); - } else { - ZEPHIR_CALL_METHOD(NULL, messages, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1$$7, messages, "valid", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_1$$7))) { - break; - } - ZEPHIR_CALL_METHOD(&message, messages, "current", &_2, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_3, 0, &message); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, messages, "next", &_4, 0); - zephir_check_call_status(); - } - } - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Messages_Messages, count) -{ - zval _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); - RETURN_LONG(zephir_fast_count_int(&_0)); -} - -static PHP_METHOD(Phalcon_Messages_Messages, current) -{ - zval _0, _1, _2; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&_2); - zephir_read_property(&_2, this_ptr, ZEND_STRL("position"), PH_NOISY_CC); - zephir_array_fetch(&_1, &_0, &_2, PH_NOISY | PH_READONLY, "phalcon/Messages/Messages.zep", 117); - RETURN_CTOR(&_1); -} - -static PHP_METHOD(Phalcon_Messages_Messages, filter) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *fieldName_param = NULL, filtered, messages, message, _0, *_1$$3, _2$$3, _3$$5, _4$$8; - zval fieldName; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&fieldName); - ZVAL_UNDEF(&filtered); - ZVAL_UNDEF(&messages); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_4$$8); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(fieldName) + Z_PARAM_ZVAL_OR_NULL(whiteList) + Z_PARAM_ZVAL_OR_NULL(dataColumnMap) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &fieldName_param); - if (UNEXPECTED(Z_TYPE_P(fieldName_param) != IS_STRING && Z_TYPE_P(fieldName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'fieldName' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 2, &data_param, &whiteList, &dataColumnMap); + ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); + if (!whiteList) { + whiteList = &whiteList_sub; + whiteList = &__$null; } - if (EXPECTED(Z_TYPE_P(fieldName_param) == IS_STRING)) { - zephir_get_strval(&fieldName, fieldName_param); - } else { - ZEPHIR_INIT_VAR(&fieldName); + if (!dataColumnMap) { + dataColumnMap = &dataColumnMap_sub; + dataColumnMap = &__$null; } - ZEPHIR_INIT_VAR(&filtered); - array_init(&filtered); - zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&messages, &_0); - if (Z_TYPE_P(&messages) == IS_ARRAY) { - zephir_is_iterable(&messages, 0, "phalcon/Messages/Messages.zep", 145); - if (Z_TYPE_P(&messages) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&messages), _1$$3) + ZEPHIR_INIT_VAR(&disableAssignSetters); + ZVAL_BOOL(&disableAssignSetters, ZEPHIR_GLOBAL(orm).disable_assign_setters); + if (Z_TYPE_P(dataColumnMap) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&dataMapped); + array_init(&dataMapped); + zephir_is_iterable(&data, 0, "phalcon/Mvc/Model.zep", 752); + if (Z_TYPE_P(&data) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _2$$3, _3$$3, _0$$3) { - ZEPHIR_INIT_NVAR(&message); - ZVAL_COPY(&message, _1$$3); - if ((zephir_method_exists_ex(&message, ZEND_STRL("getfield")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(&_3$$5, &message, "getfield", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_EQUAL(&fieldName, &_3$$5)) { - zephir_array_append(&filtered, &message, PH_SEPARATE, "phalcon/Messages/Messages.zep", 141); - } + ZEPHIR_INIT_NVAR(&key); + if (_3$$3 != NULL) { + ZVAL_STR_COPY(&key, _3$$3); + } else { + ZVAL_LONG(&key, _2$$3); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0$$3); + ZEPHIR_OBS_NVAR(&keyMapped); + if (zephir_array_isset_fetch(&keyMapped, dataColumnMap, &key, 0)) { + zephir_array_update_zval(&dataMapped, &keyMapped, &value, PH_COPY | PH_SEPARATE); } } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &messages, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_2$$3, &messages, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_1$$3, &data, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_2$$3)) { + if (!zend_is_true(&_1$$3)) { break; } - ZEPHIR_CALL_METHOD(&message, &messages, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&key, &data, "key", NULL, 0); zephir_check_call_status(); - if ((zephir_method_exists_ex(&message, ZEND_STRL("getfield")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(&_4$$8, &message, "getfield", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_EQUAL(&fieldName, &_4$$8)) { - zephir_array_append(&filtered, &message, PH_SEPARATE, "phalcon/Messages/Messages.zep", 141); - } + ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&keyMapped); + if (zephir_array_isset_fetch(&keyMapped, dataColumnMap, &key, 0)) { + zephir_array_update_zval(&dataMapped, &keyMapped, &value, PH_COPY | PH_SEPARATE); } - ZEPHIR_CALL_METHOD(NULL, &messages, "next", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&message); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + } else { + ZEPHIR_CPY_WRT(&dataMapped, &data); } - RETURN_CCTOR(&filtered); -} - -static PHP_METHOD(Phalcon_Messages_Messages, jsonSerialize) -{ - zend_bool _3$$3, _5$$6; - zval records; - zval message, _0, *_1, _2, _4$$4, _6$$7; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&records); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&records); - array_init(&records); - zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_0, 0, "phalcon/Messages/Messages.zep", 174); - if (Z_TYPE_P(&_0) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) + if (zephir_fast_count_int(&dataMapped) == 0) { + RETURN_THIS(); + } + ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_GLOBAL(orm).column_renaming) { + ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", NULL, 0, this_ptr); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&columnMap); + ZVAL_NULL(&columnMap); + } + ZEPHIR_CALL_METHOD(&_4, &metaData, "getattributes", NULL, 0, this_ptr); + zephir_check_call_status(); + zephir_is_iterable(&_4, 0, "phalcon/Mvc/Model.zep", 809); + if (Z_TYPE_P(&_4) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_4), _5) { - ZEPHIR_INIT_NVAR(&message); - ZVAL_COPY(&message, _1); - _3$$3 = Z_TYPE_P(&message) == IS_OBJECT; - if (_3$$3) { - _3$$3 = (zephir_method_exists_ex(&message, ZEND_STRL("jsonserialize")) == SUCCESS); + ZEPHIR_INIT_NVAR(&attribute); + ZVAL_COPY(&attribute, _5); + _7$$12 = !(zephir_array_isset(&columnMap, &attribute)); + if (_7$$12) { + _7$$12 = ZEPHIR_GLOBAL(orm).case_insensitive_column_map; } - if (_3$$3) { - ZEPHIR_CALL_METHOD(&_4$$4, &message, "jsonserialize", NULL, 0); + if (_7$$12) { + ZEPHIR_CALL_SELF(&_8$$13, "caseinsensitivecolumnmap", &_9, 420, &columnMap, &attribute); zephir_check_call_status(); - zephir_array_append(&records, &_4$$4, PH_SEPARATE, "phalcon/Messages/Messages.zep", 168); + ZEPHIR_CPY_WRT(&attribute, &_8$$13); + } + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeField); + if (!(zephir_array_isset_fetch(&attributeField, &columnMap, &attribute, 0))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_10$$16); + object_init_ex(&_10$$16, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_11$$16); + zephir_get_class(&_11$$16, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_12$$16); + ZEPHIR_CONCAT_SVSVS(&_12$$16, "Column '", &attribute, "' doesn't make part of the column map in '", &_11$$16, "'"); + ZEPHIR_CALL_METHOD(NULL, &_10$$16, "__construct", &_13, 33, &_12$$16); + zephir_check_call_status(); + zephir_throw_exception_debug(&_10$$16, "phalcon/Mvc/Model.zep", 783); + ZEPHIR_MM_RESTORE(); + return; + } + continue; + } } else { - zephir_array_append(&records, &message, PH_SEPARATE, "phalcon/Messages/Messages.zep", 170); + ZEPHIR_CPY_WRT(&attributeField, &attribute); + } + ZEPHIR_OBS_NVAR(&value); + if (zephir_array_isset_fetch(&value, &dataMapped, &attributeField, 0)) { + if (Z_TYPE_P(whiteList) == IS_ARRAY) { + if (!(zephir_fast_in_array(&attributeField, whiteList))) { + continue; + } + } + _14$$18 = zephir_is_true(&disableAssignSetters); + if (!(_14$$18)) { + ZEPHIR_CALL_METHOD(&_15$$18, this_ptr, "possiblesetter", &_16, 419, &attributeField, &value); + zephir_check_call_status(); + _14$$18 = !zephir_is_true(&_15$$18); + } + if (_14$$18) { + zephir_update_property_zval_zval(this_ptr, &attributeField, &value); + } } } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &_4, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_6, &_4, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_2)) { + if (!zend_is_true(&_6)) { break; } - ZEPHIR_CALL_METHOD(&message, &_0, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&attribute, &_4, "current", NULL, 0); zephir_check_call_status(); - _5$$6 = Z_TYPE_P(&message) == IS_OBJECT; - if (_5$$6) { - _5$$6 = (zephir_method_exists_ex(&message, ZEND_STRL("jsonserialize")) == SUCCESS); + _17$$22 = !(zephir_array_isset(&columnMap, &attribute)); + if (_17$$22) { + _17$$22 = ZEPHIR_GLOBAL(orm).case_insensitive_column_map; } - if (_5$$6) { - ZEPHIR_CALL_METHOD(&_6$$7, &message, "jsonserialize", NULL, 0); + if (_17$$22) { + ZEPHIR_CALL_SELF(&_18$$23, "caseinsensitivecolumnmap", &_9, 420, &columnMap, &attribute); zephir_check_call_status(); - zephir_array_append(&records, &_6$$7, PH_SEPARATE, "phalcon/Messages/Messages.zep", 168); + ZEPHIR_CPY_WRT(&attribute, &_18$$23); + } + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeField); + if (!(zephir_array_isset_fetch(&attributeField, &columnMap, &attribute, 0))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_19$$26); + object_init_ex(&_19$$26, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_20$$26); + zephir_get_class(&_20$$26, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_21$$26); + ZEPHIR_CONCAT_SVSVS(&_21$$26, "Column '", &attribute, "' doesn't make part of the column map in '", &_20$$26, "'"); + ZEPHIR_CALL_METHOD(NULL, &_19$$26, "__construct", &_13, 33, &_21$$26); + zephir_check_call_status(); + zephir_throw_exception_debug(&_19$$26, "phalcon/Mvc/Model.zep", 783); + ZEPHIR_MM_RESTORE(); + return; + } + continue; + } } else { - zephir_array_append(&records, &message, PH_SEPARATE, "phalcon/Messages/Messages.zep", 170); + ZEPHIR_CPY_WRT(&attributeField, &attribute); } - ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); + ZEPHIR_OBS_NVAR(&value); + if (zephir_array_isset_fetch(&value, &dataMapped, &attributeField, 0)) { + if (Z_TYPE_P(whiteList) == IS_ARRAY) { + if (!(zephir_fast_in_array(&attributeField, whiteList))) { + continue; + } + } + _22$$28 = zephir_is_true(&disableAssignSetters); + if (!(_22$$28)) { + ZEPHIR_CALL_METHOD(&_23$$28, this_ptr, "possiblesetter", &_16, 419, &attributeField, &value); + zephir_check_call_status(); + _22$$28 = !zephir_is_true(&_23$$28); + } + if (_22$$28) { + zephir_update_property_zval_zval(this_ptr, &attributeField, &value); + } + } + ZEPHIR_CALL_METHOD(NULL, &_4, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&message); - RETURN_CTOR(&records); -} - -static PHP_METHOD(Phalcon_Messages_Messages, key) -{ - - RETURN_MEMBER(getThis(), "position"); -} - -static PHP_METHOD(Phalcon_Messages_Messages, next) -{ - zval *this_ptr = getThis(); - RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("position"))); -} - -static PHP_METHOD(Phalcon_Messages_Messages, offsetExists) -{ - zval index_sub, _0; - zval *index; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&index_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(index) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &index); - zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); - RETURN_BOOL(zephir_array_isset(&_0, index)); -} - -static PHP_METHOD(Phalcon_Messages_Messages, offsetGet) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval index_sub, message, returnValue, _0; - zval *index; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&index_sub); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&returnValue); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(index) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &index); - ZEPHIR_INIT_VAR(&returnValue); - ZVAL_NULL(&returnValue); - zephir_memory_observe(&message); - zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&message, &_0, index, 0)) { - ZEPHIR_CPY_WRT(&returnValue, &message); - } - RETURN_CCTOR(&returnValue); -} - -static PHP_METHOD(Phalcon_Messages_Messages, offsetSet) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval offset_sub, value_sub, _0; - zval *offset, *value; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&offset_sub); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(offset) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &offset, &value); - ZEPHIR_INIT_VAR(&_0); - zephir_gettype(&_0, value); - if (!ZEPHIR_IS_STRING_IDENTICAL(&_0, "object")) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_messages_exception_ce, "The message must be an object", "phalcon/Messages/Messages.zep", 241); - return; - } - zephir_update_property_array(this_ptr, SL("messages"), offset, value); - ZEPHIR_MM_RESTORE(); + ZEPHIR_INIT_NVAR(&attribute); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Messages_Messages, offsetUnset) +static PHP_METHOD(Phalcon_Mvc_Model, average) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval index_sub, _0, _1$$3, _2$$3; - zval *index; - zval *this_ptr = getThis(); + zval *parameters_param = NULL, result, _0, _1; + zval parameters; - ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(¶meters); + ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(index) + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(parameters) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &index); - zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset(&_0, index)) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_2$$3, 1); - ZEPHIR_MAKE_REF(&_1$$3); - ZEPHIR_CALL_FUNCTION(NULL, "array_splice", NULL, 415, &_1$$3, index, &_2$$3); - ZEPHIR_UNREF(&_1$$3); - zephir_check_call_status(); + zephir_fetch_params(1, 0, 1, ¶meters_param); + if (!parameters_param) { + ZEPHIR_INIT_VAR(¶meters); + array_init(¶meters); + } else { + zephir_get_arrval(¶meters, parameters_param); } - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Messages_Messages, rewind) -{ - zval _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, 0); - zephir_update_property_zval(this_ptr, ZEND_STRL("position"), &_0); -} - -static PHP_METHOD(Phalcon_Messages_Messages, valid) -{ - zval _0, _1; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_1, this_ptr, ZEND_STRL("position"), PH_NOISY_CC | PH_READONLY); - RETURN_BOOL(zephir_array_isset(&_0, &_1)); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Di_AbstractInjectionAware) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Di, AbstractInjectionAware, phalcon, di_abstractinjectionaware, zend_standard_class_def, phalcon_di_abstractinjectionaware_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_di_abstractinjectionaware_ce, SL("container"), ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_di_abstractinjectionaware_ce, 1, phalcon_di_injectionawareinterface_ce); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Di_AbstractInjectionAware, getDI) -{ - - RETURN_MEMBER(getThis(), "container"); -} - -static PHP_METHOD(Phalcon_Di_AbstractInjectionAware, setDI) -{ - zval *container, container_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &container); - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Di_Di) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Di, Di, phalcon, di_di, phalcon_di_di_method_entry, 0); - - zend_declare_property_null(phalcon_di_di_ce, SL("services"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_di_di_ce, SL("sharedInstances"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_di_di_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_di_di_ce, SL("defaultDi"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC); - phalcon_di_di_ce->create_object = zephir_init_properties_Phalcon_Di_Di; - - zend_class_implements(phalcon_di_di_ce, 1, phalcon_di_diinterface_ce); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Di_Di, __construct) -{ - zval _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - zephir_read_static_property_ce(&_0, phalcon_di_di_ce, SL("defaultDi"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_is_true(&_0))) { - zephir_update_static_property_ce(phalcon_di_di_ce, ZEND_STRL("defaultDi"), this_ptr); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "AVG"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "average"); + ZEPHIR_CALL_SELF(&result, "groupresult", NULL, 0, &_0, &_1, ¶meters); + zephir_check_call_status(); + if (Z_TYPE_P(&result) == IS_STRING) { + RETURN_MM_DOUBLE(zephir_get_doubleval(&result)); } + RETURN_CCTOR(&result); } -static PHP_METHOD(Phalcon_Di_Di, __call) +static PHP_METHOD(Phalcon_Mvc_Model, cloneResult) { + zend_string *_4; + zend_ulong _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval arguments; - zval *method_param = NULL, *arguments_param = NULL, instance, possibleService, definition, _6, _0$$3, _1$$3, _2$$3, _3$$6, _4$$6, _5$$6; - zval method, _7; - zval *this_ptr = getThis(); + zephir_fcall_cache_entry *_8 = NULL; + zend_long dirtyState, ZEPHIR_LAST_CALL_STATUS; + zval data; + zval *base, base_sub, *data_param = NULL, *dirtyState_param = NULL, instance, key, value, _0, *_1, _2, _12, _5$$4, _6$$4, _7$$4, _9$$6, _10$$6, _11$$6; - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&base_sub); ZVAL_UNDEF(&instance); - ZVAL_UNDEF(&possibleService); - ZVAL_UNDEF(&definition); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$6); - ZVAL_UNDEF(&_4$$6); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&arguments); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(method) + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_9$$6); + ZVAL_UNDEF(&_10$$6); + ZVAL_UNDEF(&_11$$6); + ZVAL_UNDEF(&data); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_OBJECT_OF_CLASS(base, phalcon_mvc_modelinterface_ce) + Z_PARAM_ARRAY(data) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(arguments) + Z_PARAM_LONG(dirtyState) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &method_param, &arguments_param); - if (UNEXPECTED(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 of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(method_param) == IS_STRING)) { - zephir_get_strval(&method, method_param); + zephir_fetch_params(1, 2, 1, &base, &data_param, &dirtyState_param); + ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); + if (!dirtyState_param) { + dirtyState = 0; } else { - ZEPHIR_INIT_VAR(&method); + } + ZEPHIR_INIT_VAR(&instance); + if (zephir_clone(&instance, base) == FAILURE) { + RETURN_MM(); } - if (!arguments_param) { - ZEPHIR_INIT_VAR(&arguments); - array_init(&arguments); + ZVAL_LONG(&_0, dirtyState); + ZEPHIR_CALL_METHOD(NULL, &instance, "setdirtystate", NULL, 0, &_0); + zephir_check_call_status(); + zephir_is_iterable(&data, 0, "phalcon/Mvc/Model.zep", 899); + if (Z_TYPE_P(&data) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _3, _4, _1) + { + ZEPHIR_INIT_NVAR(&key); + if (_4 != NULL) { + ZVAL_STR_COPY(&key, _4); + } else { + ZVAL_LONG(&key, _3); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _1); + if (UNEXPECTED(Z_TYPE_P(&key) != IS_STRING)) { + ZEPHIR_INIT_NVAR(&_5$$4); + object_init_ex(&_5$$4, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_6$$4); + zephir_get_class(&_6$$4, base, 0); + ZEPHIR_INIT_NVAR(&_7$$4); + ZEPHIR_CONCAT_SVS(&_7$$4, "Invalid key in array data provided to dumpResult() in '", &_6$$4, "'"); + ZEPHIR_CALL_METHOD(NULL, &_5$$4, "__construct", &_8, 33, &_7$$4); + zephir_check_call_status(); + zephir_throw_exception_debug(&_5$$4, "phalcon/Mvc/Model.zep", 889); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_update_property_zval_zval(&instance, &key, &value); + } ZEND_HASH_FOREACH_END(); } else { - zephir_get_arrval(&arguments, arguments_param); - } - if (zephir_start_with_str(&method, SL("get"))) { - ZVAL_LONG(&_0$$3, 3); - ZEPHIR_INIT_VAR(&_1$$3); - zephir_substr(&_1$$3, &method, 3 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - ZEPHIR_CALL_FUNCTION(&possibleService, "lcfirst", NULL, 76, &_1$$3); + ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); zephir_check_call_status(); - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset(&_2$$3, &possibleService)) { - ZEPHIR_CALL_METHOD(&instance, this_ptr, "get", NULL, 0, &possibleService, &arguments); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &data, "valid", NULL, 0); zephir_check_call_status(); - RETURN_CCTOR(&instance); - } - } - if (zephir_start_with_str(&method, SL("set"))) { - zephir_memory_observe(&definition); - if (zephir_array_isset_long_fetch(&definition, &arguments, 0, 0)) { - ZVAL_LONG(&_3$$6, 3); - ZEPHIR_INIT_VAR(&_4$$6); - zephir_substr(&_4$$6, &method, 3 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - ZEPHIR_CALL_FUNCTION(&_5$$6, "lcfirst", NULL, 76, &_4$$6); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &data, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, 0, &_5$$6, &definition); + ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&key) != IS_STRING)) { + ZEPHIR_INIT_NVAR(&_9$$6); + object_init_ex(&_9$$6, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_10$$6); + zephir_get_class(&_10$$6, base, 0); + ZEPHIR_INIT_NVAR(&_11$$6); + ZEPHIR_CONCAT_SVS(&_11$$6, "Invalid key in array data provided to dumpResult() in '", &_10$$6, "'"); + ZEPHIR_CALL_METHOD(NULL, &_9$$6, "__construct", &_8, 33, &_11$$6); + zephir_check_call_status(); + zephir_throw_exception_debug(&_9$$6, "phalcon/Mvc/Model.zep", 889); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_update_property_zval_zval(&instance, &key, &value); + ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); zephir_check_call_status(); - RETURN_MM_NULL(); } } - ZEPHIR_INIT_VAR(&_6); - object_init_ex(&_6, phalcon_di_exception_ce); - ZEPHIR_INIT_VAR(&_7); - ZEPHIR_CONCAT_SVS(&_7, "Call to undefined method or service '", &method, "'"); - ZEPHIR_CALL_METHOD(NULL, &_6, "__construct", NULL, 33, &_7); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + ZEPHIR_INIT_VAR(&_12); + ZVAL_STRING(&_12, "afterFetch"); + ZEPHIR_CALL_METHOD(NULL, &instance, "fireevent", NULL, 0, &_12); zephir_check_call_status(); - zephir_throw_exception_debug(&_6, "phalcon/Di/Di.zep", 147); - ZEPHIR_MM_RESTORE(); - return; + RETURN_CCTOR(&instance); } -static PHP_METHOD(Phalcon_Di_Di, attempt) +static PHP_METHOD(Phalcon_Mvc_Model, cloneResultMap) { + zend_string *_4; + zend_ulong _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool shared; - zval *name_param = NULL, *definition, definition_sub, *shared_param = NULL, _0, _1, _2, _3, _4; - zval name; - zval *this_ptr = getThis(); + zephir_fcall_cache_entry *_9 = NULL, *_16 = NULL; + zend_bool keepSnapshots, _5$$6, _13$$3, _18$$24, _25$$21; + zend_long dirtyState, ZEPHIR_LAST_CALL_STATUS; + zval data; + zval *base, base_sub, *data_param = NULL, *columnMap, columnMap_sub, *dirtyState_param = NULL, *keepSnapshots_param = NULL, instance, attribute, key, value, castValue, attributeName, metaData, reverseMap, _0, *_1, _2, _6$$9, _7$$9, _8$$9, _10$$11, _11$$11, _12$$11, _14$$13, _15$$14, _17$$18, _19$$27, _20$$27, _21$$27, _22$$29, _23$$29, _24$$29, _26$$31, _27$$32, _28$$36, _29$$40; - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&definition_sub); + ZVAL_UNDEF(&base_sub); + ZVAL_UNDEF(&columnMap_sub); + ZVAL_UNDEF(&instance); + ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&castValue); + ZVAL_UNDEF(&attributeName); + ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&reverseMap); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(name) - Z_PARAM_ZVAL(definition) + ZVAL_UNDEF(&_6$$9); + ZVAL_UNDEF(&_7$$9); + ZVAL_UNDEF(&_8$$9); + ZVAL_UNDEF(&_10$$11); + ZVAL_UNDEF(&_11$$11); + ZVAL_UNDEF(&_12$$11); + ZVAL_UNDEF(&_14$$13); + ZVAL_UNDEF(&_15$$14); + ZVAL_UNDEF(&_17$$18); + ZVAL_UNDEF(&_19$$27); + ZVAL_UNDEF(&_20$$27); + ZVAL_UNDEF(&_21$$27); + ZVAL_UNDEF(&_22$$29); + ZVAL_UNDEF(&_23$$29); + ZVAL_UNDEF(&_24$$29); + ZVAL_UNDEF(&_26$$31); + ZVAL_UNDEF(&_27$$32); + ZVAL_UNDEF(&_28$$36); + ZVAL_UNDEF(&_29$$40); + ZVAL_UNDEF(&data); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(3, 5) + Z_PARAM_ZVAL(base) + Z_PARAM_ARRAY(data) + Z_PARAM_ZVAL(columnMap) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(shared) + Z_PARAM_LONG(dirtyState) + Z_PARAM_BOOL_OR_NULL(keepSnapshots, is_null_true) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &name_param, &definition, &shared_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - if (!shared_param) { - shared = 0; + zephir_fetch_params(1, 3, 2, &base, &data_param, &columnMap, &dirtyState_param, &keepSnapshots_param); + ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); + if (!dirtyState_param) { + dirtyState = 0; } else { } - zephir_read_property(&_0, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset(&_0, &name)) { - RETURN_MM_BOOL(0); - } - ZEPHIR_INIT_VAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - if (shared) { - ZVAL_BOOL(&_2, 1); + if (!keepSnapshots_param) { + keepSnapshots = 0; } else { - ZVAL_BOOL(&_2, 0); + } + ZEPHIR_INIT_VAR(&instance); + if (zephir_clone(&instance, base) == FAILURE) { + RETURN_MM(); } - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, definition, &_2); + ZVAL_LONG(&_0, dirtyState); + ZEPHIR_CALL_METHOD(NULL, &instance, "setdirtystate", NULL, 0, &_0); zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("services"), &name, &_1); - zephir_read_property(&_3, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_4, &_3, &name, PH_NOISY | PH_READONLY, "phalcon/Di/Di.zep", 163); - RETURN_CTOR(&_4); -} - -static PHP_METHOD(Phalcon_Di_Di, get) -{ - zval _7$$5, _18$$18; - zend_bool _1$$3, _15$$11; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, *parameters = NULL, parameters_sub, __$null, service, isShared, instance, _0, _5, _16, _2$$3, _3$$4, _4$$4, _6$$5, _8$$5, _9$$7, _10$$7, _11$$9, _13$$12, _17$$18, _19$$18; - zval name, _12$$9, _14$$12; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_12$$9); - ZVAL_UNDEF(&_14$$12); - ZVAL_UNDEF(¶meters_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&service); - ZVAL_UNDEF(&isShared); - ZVAL_UNDEF(&instance); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_16); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_8$$5); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_10$$7); - ZVAL_UNDEF(&_11$$9); - ZVAL_UNDEF(&_13$$12); - ZVAL_UNDEF(&_17$$18); - ZVAL_UNDEF(&_19$$18); - ZVAL_UNDEF(&_7$$5); - ZVAL_UNDEF(&_18$$18); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(name) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(parameters) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &name_param, ¶meters); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - if (!parameters) { - parameters = ¶meters_sub; - parameters = &__$null; - } - ZEPHIR_INIT_VAR(&instance); - ZVAL_NULL(&instance); - zephir_memory_observe(&service); - zephir_read_property(&_0, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&service, &_0, &name, 0)) { - ZEPHIR_CALL_METHOD(&isShared, &service, "isshared", NULL, 0); - zephir_check_call_status(); - _1$$3 = zephir_is_true(&isShared); - if (_1$$3) { - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("sharedInstances"), PH_NOISY_CC | PH_READONLY); - _1$$3 = zephir_array_isset(&_2$$3, &name); - } - if (_1$$3) { - zephir_read_property(&_3$$4, this_ptr, ZEND_STRL("sharedInstances"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_4$$4, &_3$$4, &name, PH_NOISY | PH_READONLY, "phalcon/Di/Di.zep", 181); - RETURN_CTOR(&_4$$4); - } - } - zephir_read_property(&_5, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_5) != IS_NULL) { - zephir_read_property(&_6$$5, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_7$$5); - zephir_create_array(&_7$$5, 2, 0); - zephir_array_update_string(&_7$$5, SL("name"), &name, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_7$$5, SL("parameters"), parameters, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_8$$5); - ZVAL_STRING(&_8$$5, "di:beforeServiceResolve"); - ZEPHIR_CALL_METHOD(&instance, &_6$$5, "fire", NULL, 0, &_8$$5, this_ptr, &_7$$5); - zephir_check_call_status(); - } - if (Z_TYPE_P(&instance) == IS_NULL) { - if (Z_TYPE_P(&service) != IS_NULL) { - - /* try_start_1: */ - - ZEPHIR_CALL_METHOD(&instance, &service, "resolve", NULL, 0, parameters, this_ptr); - zephir_check_call_status_or_jump(try_end_1); - - try_end_1: - - if (EG(exception)) { - ZEPHIR_INIT_VAR(&_9$$7); - ZVAL_OBJ(&_9$$7, EG(exception)); - Z_ADDREF_P(&_9$$7); - ZEPHIR_INIT_VAR(&_10$$7); - if (zephir_instance_of_ev(&_9$$7, phalcon_di_exception_serviceresolutionexception_ce)) { - zend_clear_exception(); - ZEPHIR_CPY_WRT(&_10$$7, &_9$$7); - ZEPHIR_INIT_VAR(&_11$$9); - object_init_ex(&_11$$9, phalcon_di_exception_ce); - ZEPHIR_INIT_VAR(&_12$$9); - ZEPHIR_CONCAT_SVS(&_12$$9, "Service '", &name, "' cannot be resolved"); - ZEPHIR_CALL_METHOD(NULL, &_11$$9, "__construct", NULL, 33, &_12$$9); + zephir_is_iterable(&data, 1, "phalcon/Mvc/Model.zep", 1032); + if (Z_TYPE_P(&data) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _3, _4, _1) + { + ZEPHIR_INIT_NVAR(&key); + if (_4 != NULL) { + ZVAL_STR_COPY(&key, _4); + } else { + ZVAL_LONG(&key, _3); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _1); + if (Z_TYPE_P(&key) != IS_STRING) { + continue; + } + if (Z_TYPE_P(columnMap) != IS_ARRAY) { + zephir_update_property_zval_zval(&instance, &key, &value); + continue; + } + ZEPHIR_OBS_NVAR(&attribute); + if (!(zephir_array_isset_fetch(&attribute, columnMap, &key, 0))) { + _5$$6 = Z_TYPE_P(columnMap) == IS_ARRAY; + if (_5$$6) { + _5$$6 = !(ZEPHIR_IS_EMPTY(columnMap)); + } + if (_5$$6) { + ZEPHIR_CALL_METHOD(&metaData, &instance, "getmodelsmetadata", NULL, 0); zephir_check_call_status(); - zephir_throw_exception_debug(&_11$$9, "phalcon/Di/Di.zep", 208); - ZEPHIR_MM_RESTORE(); - return; + ZEPHIR_CALL_METHOD(&reverseMap, &metaData, "getreversecolumnmap", NULL, 0, &instance); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&attribute); + if (!(zephir_array_isset_fetch(&attribute, &reverseMap, &key, 0))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_6$$9); + object_init_ex(&_6$$9, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_7$$9); + zephir_get_class(&_7$$9, base, 0); + ZEPHIR_INIT_NVAR(&_8$$9); + ZEPHIR_CONCAT_SVSVS(&_8$$9, "Column '", &key, "' doesn't make part of the column map in '", &_7$$9, "'"); + ZEPHIR_CALL_METHOD(NULL, &_6$$9, "__construct", &_9, 33, &_8$$9); + zephir_check_call_status(); + zephir_throw_exception_debug(&_6$$9, "phalcon/Mvc/Model.zep", 959); + ZEPHIR_MM_RESTORE(); + return; + } + continue; + } + } else { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_10$$11); + object_init_ex(&_10$$11, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_11$$11); + zephir_get_class(&_11$$11, base, 0); + ZEPHIR_INIT_NVAR(&_12$$11); + ZEPHIR_CONCAT_SVSVS(&_12$$11, "Column '", &key, "' doesn't make part of the column map in '", &_11$$11, "'"); + ZEPHIR_CALL_METHOD(NULL, &_10$$11, "__construct", &_9, 33, &_12$$11); + zephir_check_call_status(); + zephir_throw_exception_debug(&_10$$11, "phalcon/Mvc/Model.zep", 968); + ZEPHIR_MM_RESTORE(); + return; + } + continue; } } - if (zephir_is_true(&isShared)) { - zephir_update_property_array(this_ptr, SL("sharedInstances"), &name, &instance); - } - } else { - if (UNEXPECTED(!(zephir_class_exists(&name, 1)))) { - ZEPHIR_INIT_VAR(&_13$$12); - object_init_ex(&_13$$12, phalcon_di_exception_ce); - ZEPHIR_INIT_VAR(&_14$$12); - ZEPHIR_CONCAT_SVS(&_14$$12, "Service '", &name, "' was not found in the dependency injection container"); - ZEPHIR_CALL_METHOD(NULL, &_13$$12, "__construct", NULL, 33, &_14$$12); - zephir_check_call_status(); - zephir_throw_exception_debug(&_13$$12, "phalcon/Di/Di.zep", 223); - ZEPHIR_MM_RESTORE(); - return; + if (Z_TYPE_P(&attribute) != IS_ARRAY) { + zephir_update_property_zval_zval(&instance, &attribute, &value); + continue; } - _15$$11 = Z_TYPE_P(parameters) == IS_ARRAY; - if (_15$$11) { - _15$$11 = ((zephir_fast_count_int(parameters)) ? 1 : 0); + _13$$3 = !ZEPHIR_IS_STRING(&value, ""); + if (_13$$3) { + _13$$3 = Z_TYPE_P(&value) != IS_NULL; } - if (_15$$11) { - ZEPHIR_INIT_NVAR(&instance); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&instance, &name, parameters); - zephir_check_call_status(); + if (_13$$3) { + zephir_array_fetch_long(&_14$$13, &attribute, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 982); + do { + if (ZEPHIR_IS_LONG(&_14$$13, 0) || ZEPHIR_IS_LONG(&_14$$13, 21) || ZEPHIR_IS_LONG(&_14$$13, 22) || ZEPHIR_IS_LONG(&_14$$13, 26)) { + ZVAL_LONG(&_15$$14, 10); + ZEPHIR_CALL_FUNCTION(&castValue, "intval", &_16, 42, &value, &_15$$14); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_LONG(&_14$$13, 3) || ZEPHIR_IS_LONG(&_14$$13, 9) || ZEPHIR_IS_LONG(&_14$$13, 7)) { + ZEPHIR_INIT_NVAR(&castValue); + ZVAL_DOUBLE(&castValue, zephir_get_doubleval(&value)); + break; + } + if (ZEPHIR_IS_LONG(&_14$$13, 8)) { + ZEPHIR_INIT_NVAR(&castValue); + ZVAL_BOOL(&castValue, zephir_get_boolval(&value)); + break; + } + ZEPHIR_CPY_WRT(&castValue, &value); + break; + } while(0); + } else { - ZEPHIR_INIT_NVAR(&instance); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&instance, &name); - zephir_check_call_status(); + zephir_array_fetch_long(&_17$$18, &attribute, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 1005); + do { + if (ZEPHIR_IS_LONG(&_17$$18, 14) || ZEPHIR_IS_LONG(&_17$$18, 8) || ZEPHIR_IS_LONG(&_17$$18, 3) || ZEPHIR_IS_LONG(&_17$$18, 9) || ZEPHIR_IS_LONG(&_17$$18, 7) || ZEPHIR_IS_LONG(&_17$$18, 0) || ZEPHIR_IS_LONG(&_17$$18, 21) || ZEPHIR_IS_LONG(&_17$$18, 22) || ZEPHIR_IS_LONG(&_17$$18, 26)) { + ZEPHIR_INIT_NVAR(&castValue); + ZVAL_NULL(&castValue); + break; + } + ZEPHIR_CPY_WRT(&castValue, &value); + break; + } while(0); + } - } - } - if (Z_TYPE_P(&instance) == IS_OBJECT) { - if (zephir_instance_of_ev(&instance, phalcon_di_injectionawareinterface_ce)) { - ZEPHIR_CALL_METHOD(NULL, &instance, "setdi", NULL, 0, this_ptr); + ZEPHIR_OBS_NVAR(&attributeName); + zephir_array_fetch_long(&attributeName, &attribute, 0, PH_NOISY, "phalcon/Mvc/Model.zep", 1024); + zephir_update_property_zval_zval(&instance, &attributeName, &castValue); + zephir_array_update_zval(&data, &key, &castValue, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &data, "valid", NULL, 0); zephir_check_call_status(); - } - if (zephir_instance_of_ev(&instance, phalcon_di_initializationawareinterface_ce)) { - ZEPHIR_CALL_METHOD(NULL, &instance, "initialize", NULL, 0); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &data, "key", NULL, 0); zephir_check_call_status(); - } - } - zephir_read_property(&_16, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_16) != IS_NULL) { - zephir_read_property(&_17$$18, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_18$$18); - zephir_create_array(&_18$$18, 3, 0); - zephir_array_update_string(&_18$$18, SL("name"), &name, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_18$$18, SL("parameters"), parameters, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_18$$18, SL("instance"), &instance, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_19$$18); - ZVAL_STRING(&_19$$18, "di:afterServiceResolve"); - ZEPHIR_CALL_METHOD(NULL, &_17$$18, "fire", NULL, 0, &_19$$18, this_ptr, &_18$$18); - zephir_check_call_status(); - } - RETURN_CCTOR(&instance); -} - -static PHP_METHOD(Phalcon_Di_Di, getDefault) -{ - zval _0; - - ZVAL_UNDEF(&_0); - zephir_read_static_property_ce(&_0, phalcon_di_di_ce, SL("defaultDi"), PH_NOISY_CC | PH_READONLY); - RETURN_CTORW(&_0); -} - -static PHP_METHOD(Phalcon_Di_Di, getInternalEventsManager) -{ - - RETURN_MEMBER(getThis(), "eventsManager"); -} + ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&key) != IS_STRING) { + continue; + } + if (Z_TYPE_P(columnMap) != IS_ARRAY) { + zephir_update_property_zval_zval(&instance, &key, &value); + continue; + } + ZEPHIR_OBS_NVAR(&attribute); + if (!(zephir_array_isset_fetch(&attribute, columnMap, &key, 0))) { + _18$$24 = Z_TYPE_P(columnMap) == IS_ARRAY; + if (_18$$24) { + _18$$24 = !(ZEPHIR_IS_EMPTY(columnMap)); + } + if (_18$$24) { + ZEPHIR_CALL_METHOD(&metaData, &instance, "getmodelsmetadata", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&reverseMap, &metaData, "getreversecolumnmap", NULL, 0, &instance); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&attribute); + if (!(zephir_array_isset_fetch(&attribute, &reverseMap, &key, 0))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_19$$27); + object_init_ex(&_19$$27, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_20$$27); + zephir_get_class(&_20$$27, base, 0); + ZEPHIR_INIT_NVAR(&_21$$27); + ZEPHIR_CONCAT_SVSVS(&_21$$27, "Column '", &key, "' doesn't make part of the column map in '", &_20$$27, "'"); + ZEPHIR_CALL_METHOD(NULL, &_19$$27, "__construct", &_9, 33, &_21$$27); + zephir_check_call_status(); + zephir_throw_exception_debug(&_19$$27, "phalcon/Mvc/Model.zep", 959); + ZEPHIR_MM_RESTORE(); + return; + } + continue; + } + } else { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_22$$29); + object_init_ex(&_22$$29, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_23$$29); + zephir_get_class(&_23$$29, base, 0); + ZEPHIR_INIT_NVAR(&_24$$29); + ZEPHIR_CONCAT_SVSVS(&_24$$29, "Column '", &key, "' doesn't make part of the column map in '", &_23$$29, "'"); + ZEPHIR_CALL_METHOD(NULL, &_22$$29, "__construct", &_9, 33, &_24$$29); + zephir_check_call_status(); + zephir_throw_exception_debug(&_22$$29, "phalcon/Mvc/Model.zep", 968); + ZEPHIR_MM_RESTORE(); + return; + } + continue; + } + } + if (Z_TYPE_P(&attribute) != IS_ARRAY) { + zephir_update_property_zval_zval(&instance, &attribute, &value); + continue; + } + _25$$21 = !ZEPHIR_IS_STRING(&value, ""); + if (_25$$21) { + _25$$21 = Z_TYPE_P(&value) != IS_NULL; + } + if (_25$$21) { + zephir_array_fetch_long(&_26$$31, &attribute, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 982); + do { + if (ZEPHIR_IS_LONG(&_26$$31, 0) || ZEPHIR_IS_LONG(&_26$$31, 21) || ZEPHIR_IS_LONG(&_26$$31, 22) || ZEPHIR_IS_LONG(&_26$$31, 26)) { + ZVAL_LONG(&_27$$32, 10); + ZEPHIR_CALL_FUNCTION(&castValue, "intval", &_16, 42, &value, &_27$$32); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_LONG(&_26$$31, 3) || ZEPHIR_IS_LONG(&_26$$31, 9) || ZEPHIR_IS_LONG(&_26$$31, 7)) { + ZEPHIR_INIT_NVAR(&castValue); + ZVAL_DOUBLE(&castValue, zephir_get_doubleval(&value)); + break; + } + if (ZEPHIR_IS_LONG(&_26$$31, 8)) { + ZEPHIR_INIT_NVAR(&castValue); + ZVAL_BOOL(&castValue, zephir_get_boolval(&value)); + break; + } + ZEPHIR_CPY_WRT(&castValue, &value); + break; + } while(0); -static PHP_METHOD(Phalcon_Di_Di, getRaw) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, service, _0, _1$$3; - zval name, _2$$3; - zval *this_ptr = getThis(); + } else { + zephir_array_fetch_long(&_28$$36, &attribute, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 1005); + do { + if (ZEPHIR_IS_LONG(&_28$$36, 14) || ZEPHIR_IS_LONG(&_28$$36, 8) || ZEPHIR_IS_LONG(&_28$$36, 3) || ZEPHIR_IS_LONG(&_28$$36, 9) || ZEPHIR_IS_LONG(&_28$$36, 7) || ZEPHIR_IS_LONG(&_28$$36, 0) || ZEPHIR_IS_LONG(&_28$$36, 21) || ZEPHIR_IS_LONG(&_28$$36, 22) || ZEPHIR_IS_LONG(&_28$$36, 26)) { + ZEPHIR_INIT_NVAR(&castValue); + ZVAL_NULL(&castValue); + break; + } + ZEPHIR_CPY_WRT(&castValue, &value); + break; + } while(0); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&service); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); + } + ZEPHIR_OBS_NVAR(&attributeName); + zephir_array_fetch_long(&attributeName, &attribute, 0, PH_NOISY, "phalcon/Mvc/Model.zep", 1024); + zephir_update_property_zval_zval(&instance, &attributeName, &castValue); + zephir_array_update_zval(&data, &key, &castValue, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); + zephir_check_call_status(); + } } - zephir_memory_observe(&service); - zephir_read_property(&_0, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(!(zephir_array_isset_fetch(&service, &_0, &name, 0)))) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_di_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - ZEPHIR_CONCAT_SVS(&_2$$3, "Service '", &name, "' was not found in the dependency injection container"); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + if (keepSnapshots) { + ZEPHIR_CALL_METHOD(NULL, &instance, "setsnapshotdata", NULL, 0, &data, columnMap); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &instance, "setoldsnapshotdata", NULL, 0, &data, columnMap); zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Di/Di.zep", 293); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_RETURN_CALL_METHOD(&service, "getdefinition", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Di_Di, getService) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, service, _0, _1$$3; - zval name, _2$$3; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&service); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); } - zephir_memory_observe(&service); - zephir_read_property(&_0, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(!(zephir_array_isset_fetch(&service, &_0, &name, 0)))) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_di_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - ZEPHIR_CONCAT_SVS(&_2$$3, "Service '", &name, "' was not found in the dependency injection container"); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3); + if ((zephir_method_exists_ex(&instance, ZEND_STRL("fireevent")) == SUCCESS)) { + ZEPHIR_INIT_VAR(&_29$$40); + ZVAL_STRING(&_29$$40, "afterFetch"); + ZEPHIR_CALL_METHOD(NULL, &instance, "fireevent", NULL, 0, &_29$$40); zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Di/Di.zep", 309); - ZEPHIR_MM_RESTORE(); - return; } - RETURN_CCTOR(&service); -} - -static PHP_METHOD(Phalcon_Di_Di, getServices) -{ - - RETURN_MEMBER(getThis(), "services"); + RETURN_CCTOR(&instance); } -static PHP_METHOD(Phalcon_Di_Di, getShared) +static PHP_METHOD(Phalcon_Mvc_Model, cloneResultMapHydrate) { + zend_bool _4$$7, _10$$16; + zend_string *_3; + zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, *parameters = NULL, parameters_sub, __$null, instance, _0; - zval name; - zval *this_ptr = getThis(); + zephir_fcall_cache_entry *_6 = NULL, *_9 = NULL; + zend_long hydrationMode, ZEPHIR_LAST_CALL_STATUS; + zval *data_param = NULL, *columnMap, columnMap_sub, *hydrationMode_param = NULL, key, value, attribute, attributeName, *_0, _1, _5$$8, _7$$10, _8$$10, _11$$17, _12$$19, _13$$19; + zval data, hydrateArray; - ZVAL_UNDEF(&name); - ZVAL_UNDEF(¶meters_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&instance); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(name) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(parameters) + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&hydrateArray); + ZVAL_UNDEF(&columnMap_sub); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&attributeName); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_5$$8); + ZVAL_UNDEF(&_7$$10); + ZVAL_UNDEF(&_8$$10); + ZVAL_UNDEF(&_11$$17); + ZVAL_UNDEF(&_12$$19); + ZVAL_UNDEF(&_13$$19); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ARRAY(data) + Z_PARAM_ZVAL(columnMap) + Z_PARAM_LONG(hydrationMode) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &name_param, ¶meters); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 3, 0, &data_param, &columnMap, &hydrationMode_param); + ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); + if (Z_TYPE_P(columnMap) != IS_ARRAY) { + if (hydrationMode == 1) { + RETURN_CTOR(&data); + } } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + ZEPHIR_INIT_VAR(&hydrateArray); + array_init(&hydrateArray); + zephir_is_iterable(&data, 0, "phalcon/Mvc/Model.zep", 1119); + if (Z_TYPE_P(&data) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&key); + if (_3 != NULL) { + ZVAL_STR_COPY(&key, _3); + } else { + ZVAL_LONG(&key, _2); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0); + if (Z_TYPE_P(&key) != IS_STRING) { + continue; + } + if (Z_TYPE_P(columnMap) == IS_ARRAY) { + _4$$7 = !(zephir_array_isset(columnMap, &key)); + if (_4$$7) { + _4$$7 = ZEPHIR_GLOBAL(orm).case_insensitive_column_map; + } + if (_4$$7) { + ZEPHIR_CALL_SELF(&_5$$8, "caseinsensitivecolumnmap", &_6, 420, columnMap, &key); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&key, &_5$$8); + } + ZEPHIR_OBS_NVAR(&attribute); + if (!(zephir_array_isset_fetch(&attribute, columnMap, &key, 0))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_7$$10); + object_init_ex(&_7$$10, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_8$$10); + ZEPHIR_CONCAT_SVS(&_8$$10, "Column '", &key, "' doesn't make part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_7$$10, "__construct", &_9, 33, &_8$$10); + zephir_check_call_status(); + zephir_throw_exception_debug(&_7$$10, "phalcon/Mvc/Model.zep", 1098); + ZEPHIR_MM_RESTORE(); + return; + } + continue; + } + if (Z_TYPE_P(&attribute) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeName); + zephir_array_fetch_long(&attributeName, &attribute, 0, PH_NOISY, "phalcon/Mvc/Model.zep", 1108); + } else { + ZEPHIR_CPY_WRT(&attributeName, &attribute); + } + zephir_array_update_zval(&hydrateArray, &attributeName, &value, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&hydrateArray, &key, &value, PH_COPY | PH_SEPARATE); + } + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_INIT_VAR(&name); - } - if (!parameters) { - parameters = ¶meters_sub; - parameters = &__$null; - } - zephir_memory_observe(&instance); - zephir_read_property(&_0, this_ptr, ZEND_STRL("sharedInstances"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&instance, &_0, &name, 0))) { - ZEPHIR_CALL_METHOD(&instance, this_ptr, "get", NULL, 0, &name, parameters); + ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("sharedInstances"), &name, &instance); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &data, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &data, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&key) != IS_STRING) { + continue; + } + if (Z_TYPE_P(columnMap) == IS_ARRAY) { + _10$$16 = !(zephir_array_isset(columnMap, &key)); + if (_10$$16) { + _10$$16 = ZEPHIR_GLOBAL(orm).case_insensitive_column_map; + } + if (_10$$16) { + ZEPHIR_CALL_SELF(&_11$$17, "caseinsensitivecolumnmap", &_6, 420, columnMap, &key); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&key, &_11$$17); + } + ZEPHIR_OBS_NVAR(&attribute); + if (!(zephir_array_isset_fetch(&attribute, columnMap, &key, 0))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_12$$19); + object_init_ex(&_12$$19, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_13$$19); + ZEPHIR_CONCAT_SVS(&_13$$19, "Column '", &key, "' doesn't make part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_12$$19, "__construct", &_9, 33, &_13$$19); + zephir_check_call_status(); + zephir_throw_exception_debug(&_12$$19, "phalcon/Mvc/Model.zep", 1098); + ZEPHIR_MM_RESTORE(); + return; + } + continue; + } + if (Z_TYPE_P(&attribute) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeName); + zephir_array_fetch_long(&attributeName, &attribute, 0, PH_NOISY, "phalcon/Mvc/Model.zep", 1108); + } else { + ZEPHIR_CPY_WRT(&attributeName, &attribute); + } + zephir_array_update_zval(&hydrateArray, &attributeName, &value, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&hydrateArray, &key, &value, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_CCTOR(&instance); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + if (hydrationMode != 1) { + zephir_convert_to_object(&hydrateArray); + RETURN_CTOR(&hydrateArray); + } + RETURN_CTOR(&hydrateArray); } -static PHP_METHOD(Phalcon_Di_Di, loadFromConfig) +static PHP_METHOD(Phalcon_Mvc_Model, collectRelatedToSave) { - zend_bool _4$$3, _8$$4; - zend_string *_3; - zend_ulong _2; + zend_bool _6$$3, _8$$6; + zend_string *_5; + zend_ulong _4; + zval related, dirtyRelated; + zval name, record, _0, _1, *_2, _3, _7$$3, _9$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *config, config_sub, services, name, service, *_0, _1, _5$$3, _6$$3, _9$$4, _10$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&config_sub); - ZVAL_UNDEF(&services); ZVAL_UNDEF(&name); - ZVAL_UNDEF(&service); + ZVAL_UNDEF(&record); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_10$$4); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(config, phalcon_config_configinterface_ce) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_9$$6); + ZVAL_UNDEF(&related); + ZVAL_UNDEF(&dirtyRelated); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &config); - ZEPHIR_CALL_METHOD(&services, config, "toarray", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&services, 0, "phalcon/Di/Di.zep", 359); - if (Z_TYPE_P(&services) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&services), _2, _3, _0) + + zephir_read_property(&_0, this_ptr, ZEND_STRL("related"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&related, &_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("dirtyRelated"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&dirtyRelated, &_1); + zephir_is_iterable(&related, 0, "phalcon/Mvc/Model.zep", 1160); + if (Z_TYPE_P(&related) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&related), _4, _5, _2) { ZEPHIR_INIT_NVAR(&name); - if (_3 != NULL) { - ZVAL_STR_COPY(&name, _3); + if (_5 != NULL) { + ZVAL_STR_COPY(&name, _5); } else { - ZVAL_LONG(&name, _2); + ZVAL_LONG(&name, _4); } - ZEPHIR_INIT_NVAR(&service); - ZVAL_COPY(&service, _0); - _4$$3 = zephir_array_isset_string(&service, SL("shared")); - if (_4$$3) { - ZEPHIR_OBS_NVAR(&_5$$3); - zephir_array_fetch_string(&_5$$3, &service, SL("shared"), PH_NOISY, "phalcon/Di/Di.zep", 357); - _4$$3 = zephir_is_true(&_5$$3); + ZEPHIR_INIT_NVAR(&record); + ZVAL_COPY(&record, _2); + if (zephir_array_isset(&dirtyRelated, &name)) { + continue; } - ZVAL_BOOL(&_6$$3, _4$$3); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", &_7, 0, &name, &service, &_6$$3); + _6$$3 = Z_TYPE_P(&record) != IS_OBJECT; + if (!(_6$$3)) { + _6$$3 = !((zephir_instance_of_ev(&record, phalcon_mvc_modelinterface_ce))); + } + if (_6$$3) { + continue; + } + ZVAL_LONG(&_7$$3, 1); + ZEPHIR_CALL_METHOD(NULL, &record, "setdirtystate", NULL, 0, &_7$$3); zephir_check_call_status(); + zephir_array_update_zval(&dirtyRelated, &name, &record, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &services, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &related, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_1, &services, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_3, &related, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_1)) { + if (!zend_is_true(&_3)) { break; } - ZEPHIR_CALL_METHOD(&name, &services, "key", NULL, 0); + ZEPHIR_CALL_METHOD(&name, &related, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&service, &services, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&record, &related, "current", NULL, 0); zephir_check_call_status(); - _8$$4 = zephir_array_isset_string(&service, SL("shared")); - if (_8$$4) { - ZEPHIR_OBS_NVAR(&_9$$4); - zephir_array_fetch_string(&_9$$4, &service, SL("shared"), PH_NOISY, "phalcon/Di/Di.zep", 357); - _8$$4 = zephir_is_true(&_9$$4); + if (zephir_array_isset(&dirtyRelated, &name)) { + continue; } - ZVAL_BOOL(&_10$$4, _8$$4); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", &_7, 0, &name, &service, &_10$$4); + _8$$6 = Z_TYPE_P(&record) != IS_OBJECT; + if (!(_8$$6)) { + _8$$6 = !((zephir_instance_of_ev(&record, phalcon_mvc_modelinterface_ce))); + } + if (_8$$6) { + continue; + } + ZVAL_LONG(&_9$$6, 1); + ZEPHIR_CALL_METHOD(NULL, &record, "setdirtystate", NULL, 0, &_9$$6); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &services, "next", NULL, 0); + zephir_array_update_zval(&dirtyRelated, &name, &record, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &related, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&service); + ZEPHIR_INIT_NVAR(&record); ZEPHIR_INIT_NVAR(&name); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Di_Di, loadFromPhp) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *filePath_param = NULL, services; - zval filePath; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&filePath); - ZVAL_UNDEF(&services); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(filePath) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &filePath_param); - if (UNEXPECTED(Z_TYPE_P(filePath_param) != IS_STRING && Z_TYPE_P(filePath_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'filePath' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(filePath_param) == IS_STRING)) { - zephir_get_strval(&filePath, filePath_param); - } else { - ZEPHIR_INIT_VAR(&filePath); - } - ZEPHIR_INIT_VAR(&services); - object_init_ex(&services, phalcon_config_adapter_php_ce); - ZEPHIR_CALL_METHOD(NULL, &services, "__construct", NULL, 78, &filePath); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "loadfromconfig", NULL, 0, &services); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_CTOR(&dirtyRelated); } -static PHP_METHOD(Phalcon_Di_Di, loadFromYaml) +static PHP_METHOD(Phalcon_Mvc_Model, count) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval callbacks; - zval *filePath_param = NULL, *callbacks_param = NULL, services; - zval filePath; - zval *this_ptr = getThis(); + zval *parameters = NULL, parameters_sub, __$null, result, _0, _1; - ZVAL_UNDEF(&filePath); - ZVAL_UNDEF(&services); - ZVAL_UNDEF(&callbacks); + ZVAL_UNDEF(¶meters_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(filePath) + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY_OR_NULL(callbacks) + Z_PARAM_ZVAL_OR_NULL(parameters) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &filePath_param, &callbacks_param); - if (UNEXPECTED(Z_TYPE_P(filePath_param) != IS_STRING && Z_TYPE_P(filePath_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'filePath' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(filePath_param) == IS_STRING)) { - zephir_get_strval(&filePath, filePath_param); + zephir_fetch_params(1, 0, 1, ¶meters); + if (!parameters) { + parameters = ¶meters_sub; + ZEPHIR_CPY_WRT(parameters, &__$null); } else { - ZEPHIR_INIT_VAR(&filePath); + ZEPHIR_SEPARATE_PARAM(parameters); } - if (!callbacks_param) { - ZEPHIR_INIT_VAR(&callbacks); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&callbacks, callbacks_param); + if (zephir_array_isset_string(parameters, SL("order"))) { + zephir_array_unset_string(parameters, SL("order"), PH_SEPARATE); } - ZEPHIR_INIT_VAR(&services); - object_init_ex(&services, phalcon_config_adapter_yaml_ce); - ZEPHIR_CALL_METHOD(NULL, &services, "__construct", NULL, 79, &filePath, &callbacks); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "loadfromconfig", NULL, 0, &services); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "COUNT"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "rowcount"); + ZEPHIR_CALL_SELF(&result, "groupresult", NULL, 0, &_0, &_1, parameters); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Di_Di, has) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, _0; - zval name; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); + if (Z_TYPE_P(&result) == IS_STRING) { + RETURN_MM_LONG(zephir_get_intval(&result)); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); - RETURN_MM_BOOL(zephir_array_isset(&_0, &name)); + RETURN_CCTOR(&result); } -static PHP_METHOD(Phalcon_Di_Di, offsetGet) +static PHP_METHOD(Phalcon_Mvc_Model, create) { + zval _2$$3, _4$$3; + zval metaData, _0, _1, _3$$3, _5$$3, _6$$3, _7$$3, _8$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval name_sub; - zval *name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(name) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_4$$3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getshared", NULL, 0, name); + + ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getwriteconnection", NULL, 421); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, 0, &metaData, &_1); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + ZEPHIR_INIT_VAR(&_2$$3); + zephir_create_array(&_2$$3, 1, 0); + ZEPHIR_INIT_VAR(&_3$$3); + object_init_ex(&_3$$3, phalcon_messages_message_ce); + ZEPHIR_INIT_VAR(&_4$$3); + zephir_create_array(&_4$$3, 1, 0); + ZEPHIR_INIT_VAR(&_5$$3); + zephir_get_class(&_5$$3, this_ptr, 0); + zephir_array_update_string(&_4$$3, SL("model"), &_5$$3, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_5$$3); + ZVAL_STRING(&_5$$3, "Record cannot be created because it already exists"); + ZVAL_NULL(&_6$$3); + ZEPHIR_INIT_VAR(&_7$$3); + ZVAL_STRING(&_7$$3, "InvalidCreateAttempt"); + ZVAL_LONG(&_8$$3, 0); + ZEPHIR_CALL_METHOD(NULL, &_3$$3, "__construct", NULL, 6, &_5$$3, &_6$$3, &_7$$3, &_8$$3, &_4$$3); + zephir_check_call_status(); + zephir_array_fast_append(&_2$$3, &_3$$3); + zephir_update_property_zval(this_ptr, ZEND_STRL("errorMessages"), &_2$$3); + RETURN_MM_BOOL(0); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "save", NULL, 0); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Di_Di, offsetExists) +static PHP_METHOD(Phalcon_Mvc_Model, delete) { + zval values, bindTypes, conditions; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval __$true, __$false, metaData, writeConnection, primaryKeys, bindDataTypes, columnMap, attributeField, primaryKey, bindType, value, schema, source, table, success, _0, _1, *_6, _7, _35, _2$$3, _3$$7, _4$$7, _5$$7, _8$$9, _9$$9, _10$$9, _11$$11, _12$$11, _13$$11, _14$$13, _15$$13, _16$$13, _17$$8, _19$$8, _20$$15, _21$$15, _22$$15, _23$$17, _24$$17, _25$$17, _26$$19, _27$$19, _28$$19, _29$$14, _31$$14, _32$$20, _33$$20, _34$$20, _36$$25, _37$$28, _38$$29, _39$$29; + zephir_fcall_cache_entry *_18 = NULL, *_30 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval name_sub; - zval *name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(name) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&writeConnection); + ZVAL_UNDEF(&primaryKeys); + ZVAL_UNDEF(&bindDataTypes); + ZVAL_UNDEF(&columnMap); + ZVAL_UNDEF(&attributeField); + ZVAL_UNDEF(&primaryKey); + ZVAL_UNDEF(&bindType); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&success); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_35); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$7); + ZVAL_UNDEF(&_4$$7); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_8$$9); + ZVAL_UNDEF(&_9$$9); + ZVAL_UNDEF(&_10$$9); + ZVAL_UNDEF(&_11$$11); + ZVAL_UNDEF(&_12$$11); + ZVAL_UNDEF(&_13$$11); + ZVAL_UNDEF(&_14$$13); + ZVAL_UNDEF(&_15$$13); + ZVAL_UNDEF(&_16$$13); + ZVAL_UNDEF(&_17$$8); + ZVAL_UNDEF(&_19$$8); + ZVAL_UNDEF(&_20$$15); + ZVAL_UNDEF(&_21$$15); + ZVAL_UNDEF(&_22$$15); + ZVAL_UNDEF(&_23$$17); + ZVAL_UNDEF(&_24$$17); + ZVAL_UNDEF(&_25$$17); + ZVAL_UNDEF(&_26$$19); + ZVAL_UNDEF(&_27$$19); + ZVAL_UNDEF(&_28$$19); + ZVAL_UNDEF(&_29$$14); + ZVAL_UNDEF(&_31$$14); + ZVAL_UNDEF(&_32$$20); + ZVAL_UNDEF(&_33$$20); + ZVAL_UNDEF(&_34$$20); + ZVAL_UNDEF(&_36$$25); + ZVAL_UNDEF(&_37$$28); + ZVAL_UNDEF(&_38$$29); + ZVAL_UNDEF(&_39$$29); + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&conditions); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, name); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Di_Di, offsetSet) + ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&writeConnection, this_ptr, "getwriteconnection", NULL, 421); + zephir_check_call_status(); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, 3); + zephir_update_property_zval(this_ptr, ZEND_STRL("operationMade"), &_0); + ZEPHIR_INIT_VAR(&_1); + array_init(&_1); + zephir_update_property_zval(this_ptr, ZEND_STRL("errorMessages"), &_1); + if (ZEPHIR_GLOBAL(orm).virtual_foreign_keys) { + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "checkforeignkeysreverserestrict", NULL, 422); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_2$$3)) { + RETURN_MM_BOOL(0); + } + } + ZEPHIR_INIT_VAR(&values); + array_init(&values); + ZEPHIR_INIT_VAR(&bindTypes); + array_init(&bindTypes); + ZEPHIR_INIT_VAR(&conditions); + array_init(&conditions); + ZEPHIR_CALL_METHOD(&primaryKeys, &metaData, "getprimarykeyattributes", NULL, 0, this_ptr); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&bindDataTypes, &metaData, "getbindtypes", NULL, 0, this_ptr); + zephir_check_call_status(); + if (ZEPHIR_GLOBAL(orm).column_renaming) { + ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", NULL, 0, this_ptr); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&columnMap); + ZVAL_NULL(&columnMap); + } + if (UNEXPECTED(!(zephir_fast_count_int(&primaryKeys)))) { + ZEPHIR_INIT_VAR(&_3$$7); + object_init_ex(&_3$$7, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_4$$7); + zephir_get_class(&_4$$7, this_ptr, 0); + ZEPHIR_INIT_VAR(&_5$$7); + ZEPHIR_CONCAT_SVS(&_5$$7, "A primary key must be defined in the model in order to perform the operation in '", &_4$$7, "'"); + ZEPHIR_CALL_METHOD(NULL, &_3$$7, "__construct", NULL, 33, &_5$$7); + zephir_check_call_status(); + zephir_throw_exception_debug(&_3$$7, "phalcon/Mvc/Model.zep", 1324); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_is_iterable(&primaryKeys, 0, "phalcon/Mvc/Model.zep", 1373); + if (Z_TYPE_P(&primaryKeys) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&primaryKeys), _6) + { + ZEPHIR_INIT_NVAR(&primaryKey); + ZVAL_COPY(&primaryKey, _6); + ZEPHIR_OBS_NVAR(&bindType); + if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, &bindDataTypes, &primaryKey, 0)))) { + ZEPHIR_INIT_NVAR(&_8$$9); + object_init_ex(&_8$$9, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_9$$9); + zephir_get_class(&_9$$9, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_10$$9); + ZEPHIR_CONCAT_SVSVS(&_10$$9, "Column '", &primaryKey, "' have not defined a bind data type in '", &_9$$9, "'"); + ZEPHIR_CALL_METHOD(NULL, &_8$$9, "__construct", NULL, 33, &_10$$9); + zephir_check_call_status(); + zephir_throw_exception_debug(&_8$$9, "phalcon/Mvc/Model.zep", 1338); + ZEPHIR_MM_RESTORE(); + return; + } + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeField); + if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &primaryKey, 0)))) { + ZEPHIR_INIT_NVAR(&_11$$11); + object_init_ex(&_11$$11, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_12$$11); + zephir_get_class(&_12$$11, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_13$$11); + ZEPHIR_CONCAT_SVSVS(&_13$$11, "Column '", &primaryKey, "' isn't part of the column map in '", &_12$$11, "'"); + ZEPHIR_CALL_METHOD(NULL, &_11$$11, "__construct", NULL, 33, &_13$$11); + zephir_check_call_status(); + zephir_throw_exception_debug(&_11$$11, "phalcon/Mvc/Model.zep", 1348); + ZEPHIR_MM_RESTORE(); + return; + } + } else { + ZEPHIR_CPY_WRT(&attributeField, &primaryKey); + } + ZEPHIR_OBS_NVAR(&value); + if (UNEXPECTED(!(zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)))) { + ZEPHIR_INIT_NVAR(&_14$$13); + object_init_ex(&_14$$13, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_15$$13); + zephir_get_class(&_15$$13, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_16$$13); + ZEPHIR_CONCAT_SVSVS(&_16$$13, "Cannot delete the record because the primary key attribute: '", &attributeField, "' was not set in '", &_15$$13, "'"); + ZEPHIR_CALL_METHOD(NULL, &_14$$13, "__construct", NULL, 33, &_16$$13); + zephir_check_call_status(); + zephir_throw_exception_debug(&_14$$13, "phalcon/Mvc/Model.zep", 1362); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1368); + ZEPHIR_CALL_METHOD(&_17$$8, &writeConnection, "escapeidentifier", &_18, 0, &primaryKey); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_19$$8); + ZEPHIR_CONCAT_VS(&_19$$8, &_17$$8, " = ?"); + zephir_array_append(&conditions, &_19$$8, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1369); + zephir_array_append(&bindTypes, &bindType, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1370); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &primaryKeys, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_7, &primaryKeys, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_7)) { + break; + } + ZEPHIR_CALL_METHOD(&primaryKey, &primaryKeys, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&bindType); + if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, &bindDataTypes, &primaryKey, 0)))) { + ZEPHIR_INIT_NVAR(&_20$$15); + object_init_ex(&_20$$15, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_21$$15); + zephir_get_class(&_21$$15, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_22$$15); + ZEPHIR_CONCAT_SVSVS(&_22$$15, "Column '", &primaryKey, "' have not defined a bind data type in '", &_21$$15, "'"); + ZEPHIR_CALL_METHOD(NULL, &_20$$15, "__construct", NULL, 33, &_22$$15); + zephir_check_call_status(); + zephir_throw_exception_debug(&_20$$15, "phalcon/Mvc/Model.zep", 1338); + ZEPHIR_MM_RESTORE(); + return; + } + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeField); + if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &primaryKey, 0)))) { + ZEPHIR_INIT_NVAR(&_23$$17); + object_init_ex(&_23$$17, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_24$$17); + zephir_get_class(&_24$$17, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_25$$17); + ZEPHIR_CONCAT_SVSVS(&_25$$17, "Column '", &primaryKey, "' isn't part of the column map in '", &_24$$17, "'"); + ZEPHIR_CALL_METHOD(NULL, &_23$$17, "__construct", NULL, 33, &_25$$17); + zephir_check_call_status(); + zephir_throw_exception_debug(&_23$$17, "phalcon/Mvc/Model.zep", 1348); + ZEPHIR_MM_RESTORE(); + return; + } + } else { + ZEPHIR_CPY_WRT(&attributeField, &primaryKey); + } + ZEPHIR_OBS_NVAR(&value); + if (UNEXPECTED(!(zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)))) { + ZEPHIR_INIT_NVAR(&_26$$19); + object_init_ex(&_26$$19, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_27$$19); + zephir_get_class(&_27$$19, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_28$$19); + ZEPHIR_CONCAT_SVSVS(&_28$$19, "Cannot delete the record because the primary key attribute: '", &attributeField, "' was not set in '", &_27$$19, "'"); + ZEPHIR_CALL_METHOD(NULL, &_26$$19, "__construct", NULL, 33, &_28$$19); + zephir_check_call_status(); + zephir_throw_exception_debug(&_26$$19, "phalcon/Mvc/Model.zep", 1362); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1368); + ZEPHIR_CALL_METHOD(&_29$$14, &writeConnection, "escapeidentifier", &_30, 0, &primaryKey); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_31$$14); + ZEPHIR_CONCAT_VS(&_31$$14, &_29$$14, " = ?"); + zephir_array_append(&conditions, &_31$$14, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1369); + zephir_array_append(&bindTypes, &bindType, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1370); + ZEPHIR_CALL_METHOD(NULL, &primaryKeys, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&primaryKey); + if (ZEPHIR_GLOBAL(orm).events) { + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("skipped"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("skipped"), &__$false); + } + ZEPHIR_INIT_VAR(&_33$$20); + ZVAL_STRING(&_33$$20, "beforeDelete"); + ZEPHIR_CALL_METHOD(&_32$$20, this_ptr, "fireeventcancel", NULL, 0, &_33$$20); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_32$$20)) { + RETURN_MM_BOOL(0); + } + zephir_read_property(&_34$$20, this_ptr, ZEND_STRL("skipped"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_34$$20)) { + RETURN_MM_BOOL(1); + } + } + ZEPHIR_CALL_METHOD(&schema, this_ptr, "getschema", NULL, 423); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 424); + zephir_check_call_status(); + if (zephir_is_true(&schema)) { + ZEPHIR_INIT_VAR(&table); + zephir_create_array(&table, 2, 0); + zephir_array_fast_append(&table, &schema); + zephir_array_fast_append(&table, &source); + } else { + ZEPHIR_CPY_WRT(&table, &source); + } + ZEPHIR_INIT_VAR(&_35); + zephir_fast_join_str(&_35, SL(" AND "), &conditions); + ZEPHIR_CALL_METHOD(&success, &writeConnection, "delete", NULL, 0, &table, &_35, &values, &bindTypes); + zephir_check_call_status(); + if (ZEPHIR_GLOBAL(orm).virtual_foreign_keys) { + ZEPHIR_CALL_METHOD(&_36$$25, this_ptr, "checkforeignkeysreversecascade", NULL, 425); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_36$$25)) { + RETURN_MM_BOOL(0); + } + } + if (ZEPHIR_GLOBAL(orm).events) { + if (zephir_is_true(&success)) { + ZEPHIR_INIT_VAR(&_37$$28); + ZVAL_STRING(&_37$$28, "afterDelete"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_37$$28); + zephir_check_call_status(); + } + } + if (zephir_is_true(&success)) { + ZEPHIR_INIT_VAR(&_38$$29); + array_init(&_38$$29); + zephir_update_property_zval(this_ptr, ZEND_STRL("related"), &_38$$29); + zephir_read_property(&_39$$29, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_39$$29, "clearreusableobjects", NULL, 0); + zephir_check_call_status(); + } + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, 2); + zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &_0); + RETURN_CCTOR(&success); +} + +static PHP_METHOD(Phalcon_Mvc_Model, dump) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval offset_sub, value_sub; - zval *offset, *value; zval *this_ptr = getThis(); - - ZVAL_UNDEF(&offset_sub); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(offset) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &offset, &value); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setshared", NULL, 0, offset, value); + + ZEPHIR_RETURN_CALL_FUNCTION("get_object_vars", NULL, 426, this_ptr); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Di_Di, offsetUnset) +static PHP_METHOD(Phalcon_Mvc_Model, find) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval name_sub; - zval *name; - zval *this_ptr = getThis(); + zephir_fcall_cache_entry *_0 = NULL; + zval *parameters = NULL, parameters_sub, __$null, params, query, resultset, hydration; - ZVAL_UNDEF(&name_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(name) + ZVAL_UNDEF(¶meters_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&query); + ZVAL_UNDEF(&resultset); + ZVAL_UNDEF(&hydration); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(parameters) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "remove", NULL, 0, name); + zephir_fetch_params(1, 0, 1, ¶meters); + if (!parameters) { + parameters = ¶meters_sub; + parameters = &__$null; + } + if (Z_TYPE_P(parameters) != IS_ARRAY) { + ZEPHIR_INIT_VAR(¶ms); + array_init(¶ms); + if (Z_TYPE_P(parameters) != IS_NULL) { + zephir_array_append(¶ms, parameters, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1644); + } + } else { + ZEPHIR_CPY_WRT(¶ms, parameters); + } + ZEPHIR_CALL_STATIC(&query, "getpreparedquery", &_0, 427, ¶ms); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + ZEPHIR_CALL_METHOD(&resultset, &query, "execute", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&resultset) == IS_OBJECT) { + zephir_memory_observe(&hydration); + if (zephir_array_isset_string_fetch(&hydration, ¶ms, SL("hydration"), 0)) { + ZEPHIR_CALL_METHOD(NULL, &resultset, "sethydratemode", NULL, 0, &hydration); + zephir_check_call_status(); + } + } + RETURN_CCTOR(&resultset); } -static PHP_METHOD(Phalcon_Di_Di, register) +static PHP_METHOD(Phalcon_Mvc_Model, findFirst) { + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_5 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *provider, provider_sub; - zval *this_ptr = getThis(); + zval *parameters = NULL, parameters_sub, __$null, params, query, _6, _1$$5, _2$$6, _3$$6, _4$$6; - ZVAL_UNDEF(&provider_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(provider, phalcon_di_serviceproviderinterface_ce) + ZVAL_UNDEF(¶meters_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&query); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_1$$5); + ZVAL_UNDEF(&_2$$6); + ZVAL_UNDEF(&_3$$6); + ZVAL_UNDEF(&_4$$6); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(parameters) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &provider); - ZEPHIR_CALL_METHOD(NULL, provider, "register", NULL, 0, this_ptr); + zephir_fetch_params(1, 0, 1, ¶meters); + if (!parameters) { + parameters = ¶meters_sub; + parameters = &__$null; + } + _0 = Z_TYPE_P(parameters) == IS_STRING; + if (!(_0)) { + _0 = zephir_is_numeric(parameters); + } + if (Z_TYPE_P(parameters) == IS_NULL) { + ZEPHIR_INIT_VAR(¶ms); + array_init(¶ms); + } else if (Z_TYPE_P(parameters) == IS_ARRAY) { + ZEPHIR_CPY_WRT(¶ms, parameters); + } else if (_0) { + ZEPHIR_INIT_VAR(&_1$$5); + zephir_create_array(&_1$$5, 1, 0); + zephir_array_fast_append(&_1$$5, parameters); + ZEPHIR_CPY_WRT(¶ms, &_1$$5); + } else { + ZEPHIR_INIT_VAR(&_2$$6); + object_init_ex(&_2$$6, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_3$$6); + zephir_get_called_class(&_3$$6); + ZEPHIR_INIT_VAR(&_4$$6); + ZEPHIR_CONCAT_SVS(&_4$$6, "Parameters passed must be of type array, string, numeric or null in '", &_3$$6, "'"); + ZEPHIR_CALL_METHOD(NULL, &_2$$6, "__construct", NULL, 33, &_4$$6); + zephir_check_call_status(); + zephir_throw_exception_debug(&_2$$6, "phalcon/Mvc/Model.zep", 1768); + ZEPHIR_MM_RESTORE(); + return; + } + ZVAL_LONG(&_6, 1); + ZEPHIR_CALL_STATIC(&query, "getpreparedquery", &_5, 427, ¶ms, &_6); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + ZVAL_BOOL(&_6, 1); + ZEPHIR_CALL_METHOD(NULL, &query, "setuniquerow", NULL, 0, &_6); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(&query, "execute", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Di_Di, remove) +static PHP_METHOD(Phalcon_Mvc_Model, fireEvent) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, services, _0, sharedInstances; - zval name; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *eventName_param = NULL, _0; + zval eventName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&services); + ZVAL_UNDEF(&eventName); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&sharedInstances); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + Z_PARAM_STR(eventName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + zephir_fetch_params(1, 1, 0, &eventName_param); + if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { + zephir_get_strval(&eventName, eventName_param); } else { - ZEPHIR_INIT_VAR(&name); + ZEPHIR_INIT_VAR(&eventName); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&services, &_0); - zephir_array_unset(&services, &name, PH_SEPARATE); - zephir_update_property_zval(this_ptr, ZEND_STRL("services"), &services); - zephir_read_property(&_0, this_ptr, ZEND_STRL("sharedInstances"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&sharedInstances, &_0); - zephir_array_unset(&sharedInstances, &name, PH_SEPARATE); - zephir_update_property_zval(this_ptr, ZEND_STRL("sharedInstances"), &sharedInstances); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Di_Di, reset) -{ - zval __$null; - - ZVAL_NULL(&__$null); - zephir_update_static_property_ce(phalcon_di_di_ce, ZEND_STRL("defaultDi"), &__$null); + if ((zephir_method_exists(this_ptr, &eventName) == SUCCESS)) { + ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &eventName, NULL, 0); + zephir_check_call_status(); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "notifyevent", NULL, 0, &eventName, this_ptr); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Di_Di, set) +static PHP_METHOD(Phalcon_Mvc_Model, fireEventCancel) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool shared; - zval *name_param = NULL, *definition, definition_sub, *shared_param = NULL, _0, _1, _2, _3; - zval name; + zval *eventName_param = NULL, _0$$3, _1; + zval eventName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&definition_sub); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&eventName); + ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(name) - Z_PARAM_ZVAL(definition) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(shared) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(eventName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &name_param, &definition, &shared_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + zephir_fetch_params(1, 1, 0, &eventName_param); + if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { + zephir_get_strval(&eventName, eventName_param); } else { - ZEPHIR_INIT_VAR(&name); + ZEPHIR_INIT_VAR(&eventName); } - if (!shared_param) { - shared = 0; - } else { + if ((zephir_method_exists(this_ptr, &eventName) == SUCCESS)) { + ZEPHIR_CALL_METHOD_ZVAL(&_0$$3, this_ptr, &eventName, NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_0$$3)) { + RETURN_MM_BOOL(0); } - ZEPHIR_INIT_VAR(&_0); - object_init_ex(&_0, phalcon_di_service_ce); - if (shared) { - ZVAL_BOOL(&_1, 1); - } else { - ZVAL_BOOL(&_1, 0); } - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 77, definition, &_1); + zephir_read_property(&_1, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_1, "notifyevent", NULL, 0, &eventName, this_ptr); zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("services"), &name, &_0); - zephir_read_property(&_2, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_3, &_2, &name, PH_NOISY | PH_READONLY, "phalcon/Di/Di.zep", 550); - RETURN_CTOR(&_3); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Di_Di, setDefault) +static PHP_METHOD(Phalcon_Mvc_Model, getChangedFields) { - zval *container, container_sub; + zend_string *_8; + zend_ulong _7; + zval changed; + zval metaData, name, snapshot, columnMap, allAttributes, value, _0, _4, *_5, _6, _1$$3, _2$$3, _3$$3, _9$$6, _10$$10; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&container_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &container); - zephir_update_static_property_ce(phalcon_di_di_ce, ZEND_STRL("defaultDi"), container); + ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&snapshot); + ZVAL_UNDEF(&columnMap); + ZVAL_UNDEF(&allAttributes); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_9$$6); + ZVAL_UNDEF(&_10$$10); + ZVAL_UNDEF(&changed); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&snapshot, &_0); + if (UNEXPECTED(Z_TYPE_P(&snapshot) != IS_ARRAY)) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + zephir_get_class(&_2$$3, this_ptr, 0); + ZEPHIR_INIT_VAR(&_3$$3); + ZEPHIR_CONCAT_SVS(&_3$$3, "The 'keepSnapshots' option must be enabled to track changes in '", &_2$$3, "'"); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_3$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model.zep", 1854); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getreversecolumnmap", NULL, 0, this_ptr); + zephir_check_call_status(); + if (Z_TYPE_P(&columnMap) != IS_ARRAY) { + ZEPHIR_CALL_METHOD(&allAttributes, &metaData, "getdatatypes", NULL, 0, this_ptr); + zephir_check_call_status(); + } else { + ZEPHIR_CPY_WRT(&allAttributes, &columnMap); + } + ZEPHIR_INIT_VAR(&changed); + array_init(&changed); + ZEPHIR_INIT_VAR(&_4); + zephir_is_iterable(&allAttributes, 0, "phalcon/Mvc/Model.zep", 1912); + if (Z_TYPE_P(&allAttributes) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&allAttributes), _7, _8, _5) + { + ZEPHIR_INIT_NVAR(&name); + if (_8 != NULL) { + ZVAL_STR_COPY(&name, _8); + } else { + ZVAL_LONG(&name, _7); + } + ZEPHIR_INIT_NVAR(&_4); + ZVAL_COPY(&_4, _5); + if (!(zephir_array_isset(&snapshot, &name))) { + zephir_array_append(&changed, &name, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1887); + continue; + } + ZEPHIR_OBS_NVAR(&value); + if (!(zephir_fetch_property_zval(&value, this_ptr, &name, PH_SILENT_CC))) { + zephir_array_append(&changed, &name, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1897); + continue; + } + zephir_array_fetch(&_9$$6, &snapshot, &name, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 1905); + if (!ZEPHIR_IS_IDENTICAL(&value, &_9$$6)) { + zephir_array_append(&changed, &name, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1906); + continue; + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &allAttributes, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_6, &allAttributes, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_6)) { + break; + } + ZEPHIR_CALL_METHOD(&name, &allAttributes, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4, &allAttributes, "current", NULL, 0); + zephir_check_call_status(); + if (!(zephir_array_isset(&snapshot, &name))) { + zephir_array_append(&changed, &name, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1887); + continue; + } + ZEPHIR_OBS_NVAR(&value); + if (!(zephir_fetch_property_zval(&value, this_ptr, &name, PH_SILENT_CC))) { + zephir_array_append(&changed, &name, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1897); + continue; + } + zephir_array_fetch(&_10$$10, &snapshot, &name, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 1905); + if (!ZEPHIR_IS_IDENTICAL(&value, &_10$$10)) { + zephir_array_append(&changed, &name, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1906); + continue; + } + ZEPHIR_CALL_METHOD(NULL, &allAttributes, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&_4); + ZEPHIR_INIT_NVAR(&name); + RETURN_CTOR(&changed); } -static PHP_METHOD(Phalcon_Di_Di, setInternalEventsManager) +static PHP_METHOD(Phalcon_Mvc_Model, getDirtyState) { - zval *eventsManager, eventsManager_sub; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&eventsManager_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); - zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); + RETURN_MEMBER(getThis(), "dirtyState"); } -static PHP_METHOD(Phalcon_Di_Di, setService) +static PHP_METHOD(Phalcon_Mvc_Model, getEventsManager) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, *rawDefinition, rawDefinition_sub; - zval name; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&rawDefinition_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_OBJECT_OF_CLASS(rawDefinition, phalcon_di_serviceinterface_ce) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &rawDefinition); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - zephir_update_property_array(this_ptr, SL("services"), &name, rawDefinition); - RETVAL_ZVAL(rawDefinition, 1, 0); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "getcustomeventsmanager", NULL, 0, this_ptr); + zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Di_Di, setShared) +static PHP_METHOD(Phalcon_Mvc_Model, getMessages) { + zend_bool _0, _1; + zval filtered; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, *definition, definition_sub, _0; - zval name; + zval *filter = NULL, filter_sub, __$null, message, _2$$4, _3$$3, *_4$$3, _5$$3, _6$$5, _7$$7; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&definition_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_ZVAL(definition) + ZVAL_UNDEF(&filter_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_7$$7); + ZVAL_UNDEF(&filtered); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(filter) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &definition); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + zephir_fetch_params(1, 0, 1, &filter); + if (!filter) { + filter = &filter_sub; + ZEPHIR_CPY_WRT(filter, &__$null); } else { - ZEPHIR_INIT_VAR(&name); + ZEPHIR_SEPARATE_PARAM(filter); } - ZVAL_BOOL(&_0, 1); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "set", NULL, 0, &name, definition, &_0); - zephir_check_call_status(); - RETURN_MM(); + _0 = Z_TYPE_P(filter) == IS_STRING; + if (!(_0)) { + _0 = Z_TYPE_P(filter) == IS_ARRAY; + } + _1 = _0; + if (_1) { + _1 = !(ZEPHIR_IS_EMPTY(filter)); + } + if (_1) { + ZEPHIR_INIT_VAR(&filtered); + array_init(&filtered); + if (Z_TYPE_P(filter) == IS_STRING) { + ZEPHIR_INIT_VAR(&_2$$4); + zephir_create_array(&_2$$4, 1, 0); + zephir_array_fast_append(&_2$$4, filter); + ZEPHIR_CPY_WRT(filter, &_2$$4); + } + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("errorMessages"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_3$$3, 0, "phalcon/Mvc/Model.zep", 1976); + if (Z_TYPE_P(&_3$$3) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_3$$3), _4$$3) + { + ZEPHIR_INIT_NVAR(&message); + ZVAL_COPY(&message, _4$$3); + ZEPHIR_CALL_METHOD(&_6$$5, &message, "getfield", NULL, 0); + zephir_check_call_status(); + if (zephir_fast_in_array(&_6$$5, filter)) { + zephir_array_append(&filtered, &message, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1972); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_3$$3, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5$$3, &_3$$3, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&message, &_3$$3, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_7$$7, &message, "getfield", NULL, 0); + zephir_check_call_status(); + if (zephir_fast_in_array(&_7$$7, filter)) { + zephir_array_append(&filtered, &message, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1972); + } + ZEPHIR_CALL_METHOD(NULL, &_3$$3, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&message); + RETURN_CTOR(&filtered); + } + RETURN_MM_MEMBER(getThis(), "errorMessages"); } -zend_object *zephir_init_properties_Phalcon_Di_Di(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Mvc_Model, getModelsManager) { - zval _0, _2, _1$$3, _3$$4; + + RETURN_MEMBER(getThis(), "modelsManager"); +} + +static PHP_METHOD(Phalcon_Mvc_Model, getModelsMetaData) +{ + zval metaData, container, _0$$3, _1$$3, _2$$3, _3$$4, _4$$4, _5$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$4); - + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$4); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("sharedInstances"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sharedInstances"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { + zephir_memory_observe(&metaData); + zephir_read_property(&metaData, this_ptr, ZEND_STRL("modelsMetaData"), PH_NOISY_CC); + if (Z_TYPE_P(&metaData) == IS_NULL) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_0$$3); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "modelsMetadata"); + ZEPHIR_CALL_METHOD(&_1$$3, &container, "getshared", NULL, 0, &_2$$3); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&metaData, &_1$$3); + if (UNEXPECTED(Z_TYPE_P(&metaData) != IS_OBJECT)) { ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("services"), &_3$$4); + object_init_ex(&_3$$4, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_4$$4); + zephir_get_class(&_4$$4, this_ptr, 0); + ZEPHIR_INIT_VAR(&_5$$4); + ZEPHIR_CONCAT_SVS(&_5$$4, "The injected service 'modelsMetadata' is not valid in '", &_4$$4, "'"); + ZEPHIR_CALL_METHOD(NULL, &_3$$4, "__construct", NULL, 33, &_5$$4); + zephir_check_call_status(); + zephir_throw_exception_debug(&_3$$4, "phalcon/Mvc/Model.zep", 2010); + ZEPHIR_MM_RESTORE(); + return; } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + zephir_update_property_zval(this_ptr, ZEND_STRL("modelsMetaData"), &metaData); } + RETURN_CCTOR(&metaData); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Di_DiInterface) +static PHP_METHOD(Phalcon_Mvc_Model, getOperationMade) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Di, DiInterface, phalcon, di_diinterface, phalcon_di_diinterface_method_entry); - zend_class_implements(phalcon_di_diinterface_ce, 1, zend_ce_arrayaccess); - return SUCCESS; + RETURN_MEMBER(getThis(), "operationMade"); } -ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, attempt); -ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, get); -ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, getDefault); -ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, getRaw); -ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, getService); -ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, getServices); -ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, getShared); -ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, has); -ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, remove); -ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, reset); -ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, set); -ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, setDefault); -ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, setService); -ZEPHIR_DOC_METHOD(Phalcon_Di_DiInterface, setShared); +static PHP_METHOD(Phalcon_Mvc_Model, getOldSnapshotData) +{ + RETURN_MEMBER(getThis(), "oldSnapshot"); +} +static PHP_METHOD(Phalcon_Mvc_Model, getReadConnection) +{ + zval _0, _2, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H -#endif + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_1$$3); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_read_property(&_0, this_ptr, ZEND_STRL("transaction"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) != IS_NULL) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("transaction"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_1$$3, "getconnection", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); + } + zephir_read_property(&_2, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_2, "getreadconnection", NULL, 0, this_ptr); + zephir_check_call_status(); + RETURN_MM(); +} +static PHP_METHOD(Phalcon_Mvc_Model, getReadConnectionService) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "getreadconnectionservice", NULL, 0, this_ptr); + zephir_check_call_status(); + RETURN_MM(); +} -ZEPHIR_INIT_CLASS(Phalcon_Di_Exception) +static PHP_METHOD(Phalcon_Mvc_Model, getRelated) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Di, Exception, phalcon, di_exception, zend_ce_exception, NULL, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *alias_param = NULL, *arguments = NULL, arguments_sub, __$null, relation, className, manager, result, lowerAlias, _0, _1, _2$$3, _3$$3; + zval alias; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&alias); + ZVAL_UNDEF(&arguments_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&lowerAlias); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(alias) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(arguments) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &alias_param, &arguments); + zephir_get_strval(&alias, alias_param); + if (!arguments) { + arguments = &arguments_sub; + arguments = &__$null; + } + ZEPHIR_INIT_VAR(&className); + zephir_get_class(&className, this_ptr, 0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&manager, &_0); + ZEPHIR_INIT_VAR(&lowerAlias); + zephir_fast_strtolower(&lowerAlias, &alias); + ZEPHIR_CALL_METHOD(&_1, &manager, "getrelationbyalias", NULL, 0, &className, &lowerAlias); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&relation, &_1); + if (UNEXPECTED(Z_TYPE_P(&relation) != IS_OBJECT)) { + ZEPHIR_INIT_VAR(&_2$$3); + object_init_ex(&_2$$3, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_3$$3); + ZEPHIR_CONCAT_SVSVS(&_3$$3, "There is no defined relations for the model '", &className, "' using alias '", &alias, "'"); + ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 33, &_3$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_2$$3, "phalcon/Mvc/Model.zep", 2086); + ZEPHIR_MM_RESTORE(); + return; + } + if (Z_TYPE_P(arguments) == IS_NULL) { + ZEPHIR_CALL_METHOD(&result, &manager, "getrelationrecords", NULL, 0, &relation, this_ptr, arguments); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("related"), &lowerAlias, &result); + } else { + ZEPHIR_CALL_METHOD(&result, &manager, "getrelationrecords", NULL, 0, &relation, this_ptr, arguments); + zephir_check_call_status(); + } + RETURN_CCTOR(&result); } +static PHP_METHOD(Phalcon_Mvc_Model, isRelationshipLoaded) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *relationshipAlias_param = NULL, _0, _1; + zval relationshipAlias; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&relationshipAlias); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(relationshipAlias) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &relationshipAlias_param); + zephir_get_strval(&relationshipAlias, relationshipAlias_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("related"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + zephir_fast_strtolower(&_1, &relationshipAlias); + RETURN_MM_BOOL(zephir_array_isset(&_0, &_1)); +} +static PHP_METHOD(Phalcon_Mvc_Model, getSchema) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H -#endif - + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "getmodelschema", NULL, 0, this_ptr); + zephir_check_call_status(); + RETURN_MM(); +} +static PHP_METHOD(Phalcon_Mvc_Model, getSnapshotData) +{ + RETURN_MEMBER(getThis(), "snapshot"); +} -ZEPHIR_INIT_CLASS(Phalcon_Di_FactoryDefault) +static PHP_METHOD(Phalcon_Mvc_Model, getSource) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Di, FactoryDefault, phalcon, di_factorydefault, phalcon_di_di_ce, phalcon_di_factorydefault_method_entry, 0); + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "getmodelsource", NULL, 0, this_ptr); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Di_FactoryDefault, __construct) +static PHP_METHOD(Phalcon_Mvc_Model, getUpdatedFields) { - zval _0, _4, _5, _6, _8; - zval filter, _1, _2, _3, _7; + zend_bool _11$$6, _13$$8; + zend_string *_10; + zend_ulong _9; + zval updated; + zval name, snapshot, oldSnapshot, value, _0, *_7, _8, _1$$3, _2$$3, _3$$3, _4$$5, _5$$5, _6$$5, _12$$6, _14$$8; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&filter); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&snapshot); + ZVAL_UNDEF(&oldSnapshot); + ZVAL_UNDEF(&value); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_12$$6); + ZVAL_UNDEF(&_14$$8); + ZVAL_UNDEF(&updated); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_CALL_PARENT(NULL, phalcon_di_factorydefault_ce, getThis(), "__construct", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&filter); - object_init_ex(&filter, phalcon_filter_filterfactory_ce); - if (zephir_has_constructor(&filter)) { - ZEPHIR_CALL_METHOD(NULL, &filter, "__construct", NULL, 0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&snapshot, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("oldSnapshot"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&oldSnapshot, &_0); + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).update_snapshot_on_save))) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + zephir_get_class(&_2$$3, this_ptr, 0); + ZEPHIR_INIT_VAR(&_3$$3); + ZEPHIR_CONCAT_SVS(&_3$$3, "The 'updateSnapshotOnSave' option must be enabled for this method to work properly in '", &_2$$3, "'"); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_3$$3); zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model.zep", 2210); + ZEPHIR_MM_RESTORE(); + return; } - - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 20, 0); - ZEPHIR_INIT_VAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Annotations\\Adapter\\Memory"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("annotations"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_VAR(&_4); - zephir_create_array(&_4, 2, 0); - add_assoc_stringl_ex(&_4, SL("className"), SL("Phalcon\\Assets\\Manager")); - ZEPHIR_INIT_VAR(&_5); - zephir_create_array(&_5, 1, 0); - ZEPHIR_INIT_VAR(&_6); - zephir_create_array(&_6, 2, 0); - add_assoc_stringl_ex(&_6, SL("type"), SL("service")); - add_assoc_stringl_ex(&_6, SL("name"), SL("tag")); - zephir_array_fast_append(&_5, &_6); - zephir_array_update_string(&_4, SL("arguments"), &_5, PH_COPY | PH_SEPARATE); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_4, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("assets"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Encryption\\Crypt"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("crypt"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Http\\Response\\Cookies"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("cookies"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Mvc\\Dispatcher"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("dispatcher"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Html\\Escaper"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("escaper"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Events\\Manager"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("eventsManager"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Flash\\Direct"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("flash"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Flash\\Session"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("flashSession"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_CALL_METHOD(&_7, &filter, "newinstance", NULL, 94); - zephir_check_call_status(); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_7, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("filter"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Support\\HelperFactory"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("helper"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Mvc\\Model\\Manager"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("modelsManager"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Mvc\\Model\\MetaData\\Memory"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("modelsMetadata"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Http\\Request"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("request"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Http\\Response"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("response"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Mvc\\Router"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("router"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Encryption\\Security"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("security"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_5); - zephir_create_array(&_5, 2, 0); - add_assoc_stringl_ex(&_5, SL("className"), SL("Phalcon\\Html\\TagFactory")); - ZEPHIR_INIT_NVAR(&_6); - zephir_create_array(&_6, 1, 0); - ZEPHIR_INIT_VAR(&_8); - zephir_create_array(&_8, 2, 0); - add_assoc_stringl_ex(&_8, SL("type"), SL("service")); - add_assoc_stringl_ex(&_8, SL("name"), SL("escaper")); - zephir_array_fast_append(&_6, &_8); - zephir_array_update_string(&_5, SL("arguments"), &_6, PH_COPY | PH_SEPARATE); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_5, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("tag"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Mvc\\Model\\Transaction\\Manager"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("transactionManager"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Mvc\\Url"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("url"), &_1, PH_COPY | PH_SEPARATE); - zephir_update_property_zval(this_ptr, ZEND_STRL("services"), &_0); - ZEPHIR_MM_RESTORE(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Di_InitializationAwareInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Di, InitializationAwareInterface, phalcon, di_initializationawareinterface, phalcon_di_initializationawareinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Di_InitializationAwareInterface, initialize); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Di_Injectable) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Di, Injectable, phalcon, di_injectable, zend_standard_class_def, phalcon_di_injectable_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_di_injectable_ce, SL("container"), ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_di_injectable_ce, 1, phalcon_di_injectionawareinterface_ce); - return SUCCESS; + if (UNEXPECTED(Z_TYPE_P(&snapshot) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The 'keepSnapshots' option must be enabled to track changes", "phalcon/Mvc/Model.zep", 2216); + return; + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("dirtyState"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(!ZEPHIR_IS_LONG(&_0, 0))) { + ZEPHIR_INIT_VAR(&_4$$5); + object_init_ex(&_4$$5, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_5$$5); + zephir_get_class(&_5$$5, this_ptr, 0); + ZEPHIR_INIT_VAR(&_6$$5); + ZEPHIR_CONCAT_SVS(&_6$$5, "Change checking cannot be performed because the object has not been persisted or is deleted in '", &_5$$5, "'"); + ZEPHIR_CALL_METHOD(NULL, &_4$$5, "__construct", NULL, 33, &_6$$5); + zephir_check_call_status(); + zephir_throw_exception_debug(&_4$$5, "phalcon/Mvc/Model.zep", 2225); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_VAR(&updated); + array_init(&updated); + zephir_is_iterable(&snapshot, 0, "phalcon/Mvc/Model.zep", 2240); + if (Z_TYPE_P(&snapshot) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&snapshot), _9, _10, _7) + { + ZEPHIR_INIT_NVAR(&name); + if (_10 != NULL) { + ZVAL_STR_COPY(&name, _10); + } else { + ZVAL_LONG(&name, _9); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _7); + _11$$6 = !(zephir_array_isset(&oldSnapshot, &name)); + if (!(_11$$6)) { + zephir_array_fetch(&_12$$6, &oldSnapshot, &name, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 2235); + _11$$6 = !ZEPHIR_IS_IDENTICAL(&value, &_12$$6); + } + if (_11$$6) { + zephir_array_append(&updated, &name, PH_SEPARATE, "phalcon/Mvc/Model.zep", 2236); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &snapshot, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_8, &snapshot, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_8)) { + break; + } + ZEPHIR_CALL_METHOD(&name, &snapshot, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &snapshot, "current", NULL, 0); + zephir_check_call_status(); + _13$$8 = !(zephir_array_isset(&oldSnapshot, &name)); + if (!(_13$$8)) { + zephir_array_fetch(&_14$$8, &oldSnapshot, &name, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 2235); + _13$$8 = !ZEPHIR_IS_IDENTICAL(&value, &_14$$8); + } + if (_13$$8) { + zephir_array_append(&updated, &name, PH_SEPARATE, "phalcon/Mvc/Model.zep", 2236); + } + ZEPHIR_CALL_METHOD(NULL, &snapshot, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&name); + RETURN_CTOR(&updated); } -static PHP_METHOD(Phalcon_Di_Injectable, __get) +static PHP_METHOD(Phalcon_Mvc_Model, getWriteConnection) { - zval _2$$4; + zval _0, _2, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *propertyName_param = NULL, container, service, _0, _1$$4, _3$$4, _4$$4; - zval propertyName, _5; zval *this_ptr = getThis(); - ZVAL_UNDEF(&propertyName); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&service); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_2$$4); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(propertyName) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_1$$3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &propertyName_param); - if (UNEXPECTED(Z_TYPE_P(propertyName_param) != IS_STRING && Z_TYPE_P(propertyName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'propertyName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(propertyName_param) == IS_STRING)) { - zephir_get_strval(&propertyName, propertyName_param); - } else { - ZEPHIR_INIT_VAR(&propertyName); - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getdi", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&container, &_0); - if (ZEPHIR_IS_STRING_IDENTICAL(&propertyName, "di")) { - zephir_update_property_zval(this_ptr, ZEND_STRL("di"), &container); - RETURN_CCTOR(&container); - } - if (ZEPHIR_IS_STRING_IDENTICAL(&propertyName, "persistent")) { - ZEPHIR_INIT_VAR(&_2$$4); - zephir_create_array(&_2$$4, 2, 0); - ZEPHIR_INIT_VAR(&_3$$4); - zephir_get_class(&_3$$4, this_ptr, 0); - zephir_array_fast_append(&_2$$4, &_3$$4); - zephir_array_fast_append(&_2$$4, &container); - ZEPHIR_INIT_NVAR(&_3$$4); - ZVAL_STRING(&_3$$4, "sessionBag"); - ZEPHIR_CALL_METHOD(&_1$$4, &container, "get", NULL, 0, &_3$$4, &_2$$4); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("persistent"), &_1$$4); - zephir_memory_observe(&_4$$4); - zephir_read_property(&_4$$4, this_ptr, ZEND_STRL("persistent"), PH_NOISY_CC); - RETURN_CCTOR(&_4$$4); - } - ZEPHIR_CALL_METHOD(&_0, &container, "has", NULL, 0, &propertyName); - zephir_check_call_status(); - if (zephir_is_true(&_0)) { - ZEPHIR_CALL_METHOD(&service, &container, "getshared", NULL, 0, &propertyName); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("transaction"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) != IS_NULL) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("transaction"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_1$$3, "getconnection", NULL, 0); zephir_check_call_status(); - zephir_update_property_zval_zval(this_ptr, &propertyName, &service); - RETURN_CCTOR(&service); + RETURN_MM(); } - ZEPHIR_INIT_VAR(&_5); - ZEPHIR_CONCAT_SV(&_5, "Access to undefined property ", &propertyName); - ZEPHIR_CALL_FUNCTION(NULL, "trigger_error", NULL, 7, &_5); + zephir_read_property(&_2, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_2, "getwriteconnection", NULL, 0, this_ptr); zephir_check_call_status(); - RETURN_MM_NULL(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Di_Injectable, __isset) +static PHP_METHOD(Phalcon_Mvc_Model, getWriteConnectionService) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, _0; - zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getdi", NULL, 0); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&_0, "has", NULL, 0, &name); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "getwriteconnectionservice", NULL, 0, this_ptr); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Di_Injectable, getDI) +static PHP_METHOD(Phalcon_Mvc_Model, hasChanged) { - zval container, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool allFields; + zval *fieldName = NULL, fieldName_sub, *allFields_param = NULL, __$null, changedFields, intersect; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&fieldName_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&changedFields); + ZVAL_UNDEF(&intersect); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(fieldName) + Z_PARAM_BOOL(allFields) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "A dependency injection container is required to access internal services", "phalcon/Di/Injectable.zep", 126); - return; + zephir_fetch_params(1, 0, 2, &fieldName, &allFields_param); + if (!fieldName) { + fieldName = &fieldName_sub; + fieldName = &__$null; + } + if (!allFields_param) { + allFields = 0; + } else { } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdi", NULL, 0, &container); + ZEPHIR_CALL_METHOD(&changedFields, this_ptr, "getchangedfields", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(fieldName) == IS_STRING) { + RETURN_MM_BOOL(zephir_fast_in_array(fieldName, &changedFields)); + } + if (Z_TYPE_P(fieldName) == IS_ARRAY) { + ZEPHIR_CALL_FUNCTION(&intersect, "array_intersect", NULL, 428, fieldName, &changedFields); zephir_check_call_status(); + if (allFields) { + RETURN_MM_BOOL(ZEPHIR_IS_EQUAL(&intersect, fieldName)); + } + RETURN_MM_BOOL(zephir_fast_count_int(&intersect) > 0); } - RETURN_CCTOR(&container); + RETURN_MM_BOOL(zephir_fast_count_int(&changedFields) > 0); } -static PHP_METHOD(Phalcon_Di_Injectable, setDI) +static PHP_METHOD(Phalcon_Mvc_Model, hasSnapshotData) { - zval *container, container_sub; + zval _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &container); - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Di_InjectionAwareInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Di, InjectionAwareInterface, phalcon, di_injectionawareinterface, phalcon_di_injectionawareinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Di_InjectionAwareInterface, setDI); -ZEPHIR_DOC_METHOD(Phalcon_Di_InjectionAwareInterface, getDI); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Di_Service) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Di, Service, phalcon, di_service, phalcon_di_service_method_entry, 0); - - zend_declare_property_null(phalcon_di_service_ce, SL("definition"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_di_service_ce, SL("resolved"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_di_service_ce, SL("shared"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_di_service_ce, SL("sharedInstance"), ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_di_service_ce, 1, phalcon_di_serviceinterface_ce); - return SUCCESS; + ZVAL_UNDEF(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); + RETURN_BOOL(!(ZEPHIR_IS_EMPTY(&_0))); } -static PHP_METHOD(Phalcon_Di_Service, __construct) +static PHP_METHOD(Phalcon_Mvc_Model, hasUpdated) { - zend_bool shared; - zval *definition, definition_sub, *shared_param = NULL, __$true, __$false; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool allFields; + zval *fieldName = NULL, fieldName_sub, *allFields_param = NULL, __$null, updatedFields, intersect; zval *this_ptr = getThis(); - ZVAL_UNDEF(&definition_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(definition) + ZVAL_UNDEF(&fieldName_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&updatedFields); + ZVAL_UNDEF(&intersect); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(shared) + Z_PARAM_ZVAL_OR_NULL(fieldName) + Z_PARAM_BOOL(allFields) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 1, &definition, &shared_param); - if (!shared_param) { - shared = 0; + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 2, &fieldName, &allFields_param); + if (!fieldName) { + fieldName = &fieldName_sub; + fieldName = &__$null; + } + if (!allFields_param) { + allFields = 0; } else { } - zephir_update_property_zval(this_ptr, ZEND_STRL("definition"), definition); - if (shared) { - zephir_update_property_zval(this_ptr, ZEND_STRL("shared"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("shared"), &__$false); + ZEPHIR_CALL_METHOD(&updatedFields, this_ptr, "getupdatedfields", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(fieldName) == IS_STRING) { + RETURN_MM_BOOL(zephir_fast_in_array(fieldName, &updatedFields)); + } + if (Z_TYPE_P(fieldName) == IS_ARRAY) { + ZEPHIR_CALL_FUNCTION(&intersect, "array_intersect", NULL, 428, fieldName, &updatedFields); + zephir_check_call_status(); + if (allFields) { + RETURN_MM_BOOL(ZEPHIR_IS_EQUAL(&intersect, fieldName)); + } + RETURN_MM_BOOL(zephir_fast_count_int(&intersect) > 0); } + RETURN_MM_BOOL(zephir_fast_count_int(&updatedFields) > 0); } -static PHP_METHOD(Phalcon_Di_Service, getDefinition) +static PHP_METHOD(Phalcon_Mvc_Model, jsonSerialize) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - RETURN_MEMBER(getThis(), "definition"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "toarray", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Di_Service, getParameter) +static PHP_METHOD(Phalcon_Mvc_Model, maximum) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *position_param = NULL, arguments, parameter, _0, _1; - zend_long position; - zval *this_ptr = getThis(); + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *parameters = NULL, parameters_sub, __$null, _0, _1; - ZVAL_UNDEF(&arguments); - ZVAL_UNDEF(¶meter); + ZVAL_UNDEF(¶meters_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(position) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(parameters) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &position_param); - zephir_memory_observe(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("definition"), PH_NOISY_CC); - if (UNEXPECTED(Z_TYPE_P(&_0) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "Definition must be an array to obtain its parameters", "phalcon/Di/Service.zep", 80); - return; - } - zephir_read_property(&_1, this_ptr, ZEND_STRL("definition"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_string_fetch(&arguments, &_1, SL("arguments"), 1)) { - if (zephir_array_isset_long_fetch(¶meter, &arguments, position, 1)) { - RETURN_CTOR(¶meter); - } + zephir_fetch_params(1, 0, 1, ¶meters); + if (!parameters) { + parameters = ¶meters_sub; + parameters = &__$null; } - RETURN_MM_NULL(); -} - -static PHP_METHOD(Phalcon_Di_Service, isResolved) -{ - - RETURN_MEMBER(getThis(), "resolved"); -} - -static PHP_METHOD(Phalcon_Di_Service, isShared) -{ - - RETURN_MEMBER(getThis(), "shared"); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "MAX"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "maximum"); + ZEPHIR_RETURN_CALL_SELF("groupresult", NULL, 0, &_0, &_1, parameters); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Di_Service, resolve) +static PHP_METHOD(Phalcon_Mvc_Model, minimum) { - zend_class_entry *_6$$12; - zend_bool found = 0, _1, _4$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *parameters = NULL, parameters_sub, *container = NULL, container_sub, __$true, __$false, __$null, definition, instance, builder, _0, _2, _3, _5$$12, _7$$19; - zval *this_ptr = getThis(); + zval *parameters = NULL, parameters_sub, __$null, _0, _1; ZVAL_UNDEF(¶meters_sub); - ZVAL_UNDEF(&container_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&definition); - ZVAL_UNDEF(&instance); - ZVAL_UNDEF(&builder); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5$$12); - ZVAL_UNDEF(&_7$$19); + ZVAL_UNDEF(&_1); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL Z_PARAM_ZVAL_OR_NULL(parameters) - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(container, phalcon_di_diinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, ¶meters, &container); + zephir_fetch_params(1, 0, 1, ¶meters); if (!parameters) { parameters = ¶meters_sub; parameters = &__$null; } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "MIN"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "minimum"); + ZEPHIR_RETURN_CALL_SELF("groupresult", NULL, 0, &_0, &_1, parameters); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Mvc_Model, query) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *container = NULL, container_sub, __$null, criteria, _2, _0$$4, _1$$4; + + ZVAL_UNDEF(&container_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&criteria); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&_1$$4); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(container, phalcon_di_diinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &container); if (!container) { container = &container_sub; - container = &__$null; - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("shared"), PH_NOISY_CC | PH_READONLY); - _1 = zephir_is_true(&_0); - if (_1) { - zephir_read_property(&_2, this_ptr, ZEND_STRL("sharedInstance"), PH_NOISY_CC | PH_READONLY); - _1 = Z_TYPE_P(&_2) != IS_NULL; - } - if (_1) { - RETURN_MM_MEMBER(getThis(), "sharedInstance"); - } - found = 1; - ZEPHIR_INIT_VAR(&instance); - ZVAL_NULL(&instance); - zephir_read_property(&_3, this_ptr, ZEND_STRL("definition"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&definition, &_3); - if (Z_TYPE_P(&definition) == IS_STRING) { - if (zephir_class_exists(&definition, 1)) { - _4$$5 = Z_TYPE_P(parameters) == IS_ARRAY; - if (_4$$5) { - _4$$5 = ((zephir_fast_count_int(parameters)) ? 1 : 0); - } - if (_4$$5) { - ZEPHIR_INIT_NVAR(&instance); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&instance, &definition, parameters); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&instance); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&instance, &definition); - zephir_check_call_status(); - } - } else { - found = 0; - } + ZEPHIR_CPY_WRT(container, &__$null); } else { - if (Z_TYPE_P(&definition) == IS_OBJECT) { - if (zephir_is_instance_of(&definition, SL("Closure"))) { - if (Z_TYPE_P(container) != IS_NULL) { - _6$$12 = zephir_fetch_class_str_ex(SL("Closure"), ZEND_FETCH_CLASS_AUTO); - ZEPHIR_CALL_CE_STATIC(&_5$$12, _6$$12, "bind", NULL, 0, &definition, container); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&definition, &_5$$12); - } - if (Z_TYPE_P(parameters) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&instance); - ZEPHIR_CALL_USER_FUNC_ARRAY(&instance, &definition, parameters); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&instance); - ZEPHIR_CALL_USER_FUNC(&instance, &definition); - zephir_check_call_status(); - } - } else { - ZEPHIR_CPY_WRT(&instance, &definition); - } - } else { - if (Z_TYPE_P(&definition) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&builder); - object_init_ex(&builder, phalcon_di_service_builder_ce); - if (zephir_has_constructor(&builder)) { - ZEPHIR_CALL_METHOD(NULL, &builder, "__construct", NULL, 0); - zephir_check_call_status(); - } - - ZEPHIR_CALL_METHOD(&instance, &builder, "build", NULL, 222, container, &definition, parameters); - zephir_check_call_status(); - } else { - found = 0; - } - } + ZEPHIR_SEPARATE_PARAM(container); } - if (UNEXPECTED(found == 0)) { - ZEPHIR_INIT_VAR(&_7$$19); - object_init_ex(&_7$$19, phalcon_di_exception_serviceresolutionexception_ce); - ZEPHIR_CALL_METHOD(NULL, &_7$$19, "__construct", NULL, 33); + if (Z_TYPE_P(container) != IS_OBJECT) { + ZEPHIR_CALL_CE_STATIC(container, phalcon_di_di_ce, "getdefault", NULL, 0); zephir_check_call_status(); - zephir_throw_exception_debug(&_7$$19, "phalcon/Di/Service.zep", 195); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_read_property(&_3, this_ptr, ZEND_STRL("shared"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_3)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("sharedInstance"), &instance); } - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("resolved"), &__$true); + ZEPHIR_INIT_VAR(&criteria); + if (zephir_instance_of_ev(container, phalcon_di_diinterface_ce)) { + ZEPHIR_INIT_VAR(&_1$$4); + ZVAL_STRING(&_1$$4, "Phalcon\\Mvc\\Model\\Criteria"); + ZEPHIR_CALL_METHOD(&_0$$4, container, "get", NULL, 0, &_1$$4); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&criteria, &_0$$4); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("resolved"), &__$false); - } - RETURN_CCTOR(&instance); -} - -static PHP_METHOD(Phalcon_Di_Service, setDefinition) -{ - zval *definition, definition_sub; - zval *this_ptr = getThis(); + object_init_ex(&criteria, phalcon_mvc_model_criteria_ce); + if (zephir_has_constructor(&criteria)) { + ZEPHIR_CALL_METHOD(NULL, &criteria, "__construct", NULL, 0); + zephir_check_call_status(); + } - ZVAL_UNDEF(&definition_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(definition) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &definition); - zephir_update_property_zval(this_ptr, ZEND_STRL("definition"), definition); + ZEPHIR_CALL_METHOD(NULL, &criteria, "setdi", NULL, 429, container); + zephir_check_call_status(); + } + ZEPHIR_INIT_VAR(&_2); + zephir_get_called_class(&_2); + ZEPHIR_CALL_METHOD(NULL, &criteria, "setmodelname", NULL, 430, &_2); + zephir_check_call_status(); + RETURN_CCTOR(&criteria); } -static PHP_METHOD(Phalcon_Di_Service, setParameter) +static PHP_METHOD(Phalcon_Mvc_Model, readAttribute) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval parameter; - zval *position_param = NULL, *parameter_param = NULL, arguments, _0, _1, _3, _2$$5; - zend_long position; + zval *attribute_param = NULL, _0; + zval attribute; zval *this_ptr = getThis(); - ZVAL_UNDEF(&arguments); + ZVAL_UNDEF(&attribute); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(¶meter); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_LONG(position) - Z_PARAM_ARRAY(parameter) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(attribute) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &position_param, ¶meter_param); - ZEPHIR_OBS_COPY_OR_DUP(¶meter, parameter_param); - zephir_memory_observe(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("definition"), PH_NOISY_CC); - if (UNEXPECTED(Z_TYPE_P(&_0) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "Definition must be an array to update its parameters", "phalcon/Di/Service.zep", 228); - return; + zephir_fetch_params(1, 1, 0, &attribute_param); + if (UNEXPECTED(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be of the type string")); + RETURN_MM_NULL(); } - zephir_memory_observe(&arguments); - zephir_read_property(&_1, this_ptr, ZEND_STRL("definition"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_string_fetch(&arguments, &_1, SL("arguments"), 0)) { - zephir_array_update_long(&arguments, position, ¶meter, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + if (EXPECTED(Z_TYPE_P(attribute_param) == IS_STRING)) { + zephir_get_strval(&attribute, attribute_param); } else { - ZEPHIR_INIT_VAR(&_2$$5); - zephir_create_array(&_2$$5, 1, 0); - zephir_array_update_long(&_2$$5, position, ¶meter, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - ZEPHIR_CPY_WRT(&arguments, &_2$$5); + ZEPHIR_INIT_VAR(&attribute); } - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "arguments"); - zephir_update_property_array(this_ptr, SL("definition"), &_3, &arguments); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Di_Service, setShared) -{ - zval *shared_param = NULL, __$true, __$false; - zend_bool shared; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(shared) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &shared_param); - if (shared) { - zephir_update_property_zval(this_ptr, ZEND_STRL("shared"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("shared"), &__$false); + if (!(zephir_isset_property_zval(this_ptr, &attribute))) { + RETURN_MM_NULL(); } + zephir_memory_observe(&_0); + zephir_read_property_zval(&_0, this_ptr, &attribute, PH_NOISY_CC); + RETURN_CCTOR(&_0); } -static PHP_METHOD(Phalcon_Di_Service, setSharedInstance) -{ - zval *sharedInstance, sharedInstance_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&sharedInstance_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(sharedInstance) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &sharedInstance); - zephir_update_property_zval(this_ptr, ZEND_STRL("sharedInstance"), sharedInstance); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Di_ServiceInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Di, ServiceInterface, phalcon, di_serviceinterface, phalcon_di_serviceinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, getDefinition); -ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, getParameter); -ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, isResolved); -ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, isShared); -ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, resolve); -ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, setDefinition); -ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, setParameter); -ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceInterface, setShared); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Di_ServiceProviderInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Di, ServiceProviderInterface, phalcon, di_serviceproviderinterface, phalcon_di_serviceproviderinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Di_ServiceProviderInterface, register); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Di_FactoryDefault_Cli) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Di\\FactoryDefault, Cli, phalcon, di_factorydefault_cli, phalcon_di_factorydefault_ce, phalcon_di_factorydefault_cli_method_entry, 0); - - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Di_FactoryDefault_Cli, __construct) +static PHP_METHOD(Phalcon_Mvc_Model, refresh) { - zval _0, _5, _6, _7; - zval filter, _1, _2, _3, _4; + zval fields, _18, _16$$9, _17$$10; + zval metaData, readConnection, schema, source, table, uniqueKey, tables, uniqueParams, dialect, row, attribute, manager, columnMap, _0, _4, _13, *_14, _15, _19, _20, _23, _1$$3, _2$$3, _3$$3, _5$$6, _9$$6, _6$$7, _7$$7, _8$$7, _10$$8, _11$$8, _12$$8, _21$$11, _22$$11; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&filter); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&readConnection); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&uniqueKey); + ZVAL_UNDEF(&tables); + ZVAL_UNDEF(&uniqueParams); + ZVAL_UNDEF(&dialect); + ZVAL_UNDEF(&row); + ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&columnMap); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_13); + ZVAL_UNDEF(&_15); + ZVAL_UNDEF(&_19); + ZVAL_UNDEF(&_20); + ZVAL_UNDEF(&_23); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_9$$6); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_7$$7); + ZVAL_UNDEF(&_8$$7); + ZVAL_UNDEF(&_10$$8); + ZVAL_UNDEF(&_11$$8); + ZVAL_UNDEF(&_12$$8); + ZVAL_UNDEF(&_21$$11); + ZVAL_UNDEF(&_22$$11); + ZVAL_UNDEF(&fields); + ZVAL_UNDEF(&_18); + ZVAL_UNDEF(&_16$$9); + ZVAL_UNDEF(&_17$$10); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_CALL_PARENT(NULL, phalcon_di_factorydefault_cli_ce, getThis(), "__construct", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&filter); - object_init_ex(&filter, phalcon_filter_filterfactory_ce); - if (zephir_has_constructor(&filter)) { - ZEPHIR_CALL_METHOD(NULL, &filter, "__construct", NULL, 0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dirtyState"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(!ZEPHIR_IS_LONG(&_0, 0))) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + zephir_get_class(&_2$$3, this_ptr, 0); + ZEPHIR_INIT_VAR(&_3$$3); + ZEPHIR_CONCAT_SVS(&_3$$3, "The record cannot be refreshed because it does not exist or is deleted in '", &_2$$3, "'"); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_3$$3); zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model.zep", 2491); + ZEPHIR_MM_RESTORE(); + return; } - - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 12, 0); - ZEPHIR_INIT_VAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Annotations\\Adapter\\Memory"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); + ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); zephir_check_call_status(); - zephir_array_update_string(&_0, SL("annotations"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Cli\\Dispatcher"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); + ZEPHIR_CALL_METHOD(&readConnection, this_ptr, "getreadconnection", NULL, 431); zephir_check_call_status(); - zephir_array_update_string(&_0, SL("dispatcher"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Html\\Escaper"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("escaper"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Events\\Manager"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL("eventsManager"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_CALL_METHOD(&_4, &filter, "newinstance", NULL, 94); - zephir_check_call_status(); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_4, &_3); + zephir_read_property(&_4, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&manager, &_4); + ZEPHIR_CALL_METHOD(&schema, this_ptr, "getschema", NULL, 423); zephir_check_call_status(); - zephir_array_update_string(&_0, SL("filter"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Support\\HelperFactory"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); + ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 424); zephir_check_call_status(); - zephir_array_update_string(&_0, SL("helper"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Mvc\\Model\\Manager"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); + if (zephir_is_true(&schema)) { + ZEPHIR_INIT_VAR(&table); + zephir_create_array(&table, 2, 0); + zephir_array_fast_append(&table, &schema); + zephir_array_fast_append(&table, &source); + } else { + ZEPHIR_CPY_WRT(&table, &source); + } + zephir_read_property(&_4, this_ptr, ZEND_STRL("uniqueKey"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&uniqueKey, &_4); + if (!(zephir_is_true(&uniqueKey))) { + ZEPHIR_CALL_METHOD(&_5$$6, this_ptr, "has", NULL, 0, &metaData, &readConnection); + zephir_check_call_status(); + if (UNEXPECTED(!zephir_is_true(&_5$$6))) { + ZEPHIR_INIT_VAR(&_6$$7); + object_init_ex(&_6$$7, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_7$$7); + zephir_get_class(&_7$$7, this_ptr, 0); + ZEPHIR_INIT_VAR(&_8$$7); + ZEPHIR_CONCAT_SVS(&_8$$7, "The record cannot be refreshed because it does not exist or is deleted in '", &_7$$7, "'"); + ZEPHIR_CALL_METHOD(NULL, &_6$$7, "__construct", NULL, 33, &_8$$7); + zephir_check_call_status(); + zephir_throw_exception_debug(&_6$$7, "phalcon/Mvc/Model.zep", 2516); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_read_property(&_9$$6, this_ptr, ZEND_STRL("uniqueKey"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&uniqueKey, &_9$$6); + } + zephir_read_property(&_4, this_ptr, ZEND_STRL("uniqueParams"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&uniqueParams, &_4); + if (UNEXPECTED(Z_TYPE_P(&uniqueParams) != IS_ARRAY)) { + ZEPHIR_INIT_VAR(&_10$$8); + object_init_ex(&_10$$8, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_11$$8); + zephir_get_class(&_11$$8, this_ptr, 0); + ZEPHIR_INIT_VAR(&_12$$8); + ZEPHIR_CONCAT_SVS(&_12$$8, "The record cannot be refreshed because it does not exist or is deleted in '", &_11$$8, "'"); + ZEPHIR_CALL_METHOD(NULL, &_10$$8, "__construct", NULL, 33, &_12$$8); + zephir_check_call_status(); + zephir_throw_exception_debug(&_10$$8, "phalcon/Mvc/Model.zep", 2527); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_VAR(&fields); + array_init(&fields); + ZEPHIR_CALL_METHOD(&_13, &metaData, "getattributes", NULL, 0, this_ptr); zephir_check_call_status(); - zephir_array_update_string(&_0, SL("modelsManager"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Mvc\\Model\\MetaData\\Memory"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); + zephir_is_iterable(&_13, 0, "phalcon/Mvc/Model.zep", 2542); + if (Z_TYPE_P(&_13) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_13), _14) + { + ZEPHIR_INIT_NVAR(&attribute); + ZVAL_COPY(&attribute, _14); + ZEPHIR_INIT_NVAR(&_16$$9); + zephir_create_array(&_16$$9, 1, 0); + zephir_array_fast_append(&_16$$9, &attribute); + zephir_array_append(&fields, &_16$$9, PH_SEPARATE, "phalcon/Mvc/Model.zep", 2536); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_13, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_15, &_13, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_15)) { + break; + } + ZEPHIR_CALL_METHOD(&attribute, &_13, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_17$$10); + zephir_create_array(&_17$$10, 1, 0); + zephir_array_fast_append(&_17$$10, &attribute); + zephir_array_append(&fields, &_17$$10, PH_SEPARATE, "phalcon/Mvc/Model.zep", 2536); + ZEPHIR_CALL_METHOD(NULL, &_13, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&attribute); + ZEPHIR_CALL_METHOD(&dialect, &readConnection, "getdialect", NULL, 0); zephir_check_call_status(); - zephir_array_update_string(&_0, SL("modelsMetadata"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Cli\\Router"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); + ZEPHIR_INIT_VAR(&_18); + zephir_create_array(&_18, 3, 0); + zephir_array_update_string(&_18, SL("columns"), &fields, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_19, &readConnection, "escapeidentifier", NULL, 0, &table); zephir_check_call_status(); - zephir_array_update_string(&_0, SL("router"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Encryption\\Security"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); + zephir_array_update_string(&_18, SL("tables"), &_19, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_18, SL("where"), &uniqueKey, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&tables, &dialect, "select", NULL, 0, &_18); zephir_check_call_status(); - zephir_array_update_string(&_0, SL("security"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_VAR(&_5); - zephir_create_array(&_5, 2, 0); - add_assoc_stringl_ex(&_5, SL("className"), SL("Phalcon\\Html\\TagFactory")); - ZEPHIR_INIT_VAR(&_6); - zephir_create_array(&_6, 1, 0); - ZEPHIR_INIT_VAR(&_7); - zephir_create_array(&_7, 2, 0); - add_assoc_stringl_ex(&_7, SL("type"), SL("service")); - add_assoc_stringl_ex(&_7, SL("name"), SL("escaper")); - zephir_array_fast_append(&_6, &_7); - zephir_array_update_string(&_5, SL("arguments"), &_6, PH_COPY | PH_SEPARATE); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_5, &_3); + zephir_read_property(&_4, this_ptr, ZEND_STRL("uniqueTypes"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_20, 2); + ZEPHIR_CALL_METHOD(&row, &readConnection, "fetchone", NULL, 0, &tables, &_20, &uniqueParams, &_4); zephir_check_call_status(); - zephir_array_update_string(&_0, SL("tag"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_di_service_ce); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "Phalcon\\Mvc\\Model\\Transaction\\Manager"); - ZVAL_BOOL(&_3, 1); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 77, &_2, &_3); + if (Z_TYPE_P(&row) == IS_ARRAY) { + ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", NULL, 0, this_ptr); + zephir_check_call_status(); + ZVAL_NULL(&_21$$11); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "assign", NULL, 0, &row, &_21$$11, &columnMap); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_22$$11, &manager, "iskeepingsnapshots", NULL, 0, this_ptr); + zephir_check_call_status(); + if (zephir_is_true(&_22$$11)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setsnapshotdata", NULL, 0, &row, &columnMap); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setoldsnapshotdata", NULL, 0, &row, &columnMap); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_VAR(&_23); + ZVAL_STRING(&_23, "afterFetch"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_23); zephir_check_call_status(); - zephir_array_update_string(&_0, SL("transactionManager"), &_1, PH_COPY | PH_SEPARATE); - zephir_update_property_zval(this_ptr, ZEND_STRL("services"), &_0); - ZEPHIR_MM_RESTORE(); + RETURN_THIS(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Di_Service_Builder) +static PHP_METHOD(Phalcon_Mvc_Model, save) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Di\\Service, Builder, phalcon, di_service_builder, phalcon_di_service_builder_method_entry, 0); + zval visited; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&visited); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&visited); + object_init_ex(&visited, phalcon_support_collection_ce); + ZEPHIR_CALL_METHOD(NULL, &visited, "__construct", NULL, 23); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dosave", NULL, 0, &visited); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Di_Service_Builder, build) +static PHP_METHOD(Phalcon_Mvc_Model, doSave) { - zval _11$$17, _12$$17, _22$$23, _23$$23; - zend_string *_4$$10, *_30$$25; - zend_ulong _3$$10, _29$$25; + zend_bool hasRelatedToSave = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL, *_38 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval definition; - zval *container, container_sub, *definition_param = NULL, *parameters = NULL, parameters_sub, __$null, className, arguments, paramCalls, methodPosition, method, methodName, methodCall, instance, propertyPosition, property, propertyName, propertyValue, _0$$8, *_1$$10, _2$$10, _5$$14, _6$$14, _8$$15, _9$$15, _10$$17, _13$$18, _14$$18, _15$$13, _16$$20, _17$$20, _18$$21, _19$$21, _20$$19, _26$$19, _21$$23, _24$$24, _25$$24, *_27$$25, _28$$25, _31$$29, _32$$29, _33$$30, _34$$30, _35$$31, _36$$31, _37$$28, _39$$33, _40$$33, _41$$34, _42$$34, _43$$35, _44$$35, _45$$32; + zval *visited, visited_sub, metaData, schema, writeConnection, readConnection, source, table, identityField, exists, success, relatedToSave, objId, _0, _1, _5, _2$$4, _3$$8, _4$$9, _6$$11, _7$$12, _8$$12, _9$$15, _10$$17, _11$$19, _12$$22, _13$$21; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container_sub); - ZVAL_UNDEF(¶meters_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&arguments); - ZVAL_UNDEF(¶mCalls); - ZVAL_UNDEF(&methodPosition); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&methodName); - ZVAL_UNDEF(&methodCall); - ZVAL_UNDEF(&instance); - ZVAL_UNDEF(&propertyPosition); - ZVAL_UNDEF(&property); - ZVAL_UNDEF(&propertyName); - ZVAL_UNDEF(&propertyValue); - ZVAL_UNDEF(&_0$$8); - ZVAL_UNDEF(&_2$$10); - ZVAL_UNDEF(&_5$$14); - ZVAL_UNDEF(&_6$$14); - ZVAL_UNDEF(&_8$$15); + ZVAL_UNDEF(&visited_sub); + ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&writeConnection); + ZVAL_UNDEF(&readConnection); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&identityField); + ZVAL_UNDEF(&exists); + ZVAL_UNDEF(&success); + ZVAL_UNDEF(&relatedToSave); + ZVAL_UNDEF(&objId); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$8); + ZVAL_UNDEF(&_4$$9); + ZVAL_UNDEF(&_6$$11); + ZVAL_UNDEF(&_7$$12); + ZVAL_UNDEF(&_8$$12); ZVAL_UNDEF(&_9$$15); ZVAL_UNDEF(&_10$$17); - ZVAL_UNDEF(&_13$$18); - ZVAL_UNDEF(&_14$$18); - ZVAL_UNDEF(&_15$$13); - ZVAL_UNDEF(&_16$$20); - ZVAL_UNDEF(&_17$$20); - ZVAL_UNDEF(&_18$$21); - ZVAL_UNDEF(&_19$$21); - ZVAL_UNDEF(&_20$$19); - ZVAL_UNDEF(&_26$$19); - ZVAL_UNDEF(&_21$$23); - ZVAL_UNDEF(&_24$$24); - ZVAL_UNDEF(&_25$$24); - ZVAL_UNDEF(&_28$$25); - ZVAL_UNDEF(&_31$$29); - ZVAL_UNDEF(&_32$$29); - ZVAL_UNDEF(&_33$$30); - ZVAL_UNDEF(&_34$$30); - ZVAL_UNDEF(&_35$$31); - ZVAL_UNDEF(&_36$$31); - ZVAL_UNDEF(&_37$$28); - ZVAL_UNDEF(&_39$$33); - ZVAL_UNDEF(&_40$$33); - ZVAL_UNDEF(&_41$$34); - ZVAL_UNDEF(&_42$$34); - ZVAL_UNDEF(&_43$$35); - ZVAL_UNDEF(&_44$$35); - ZVAL_UNDEF(&_45$$32); - ZVAL_UNDEF(&definition); - ZVAL_UNDEF(&_11$$17); - ZVAL_UNDEF(&_12$$17); - ZVAL_UNDEF(&_22$$23); - ZVAL_UNDEF(&_23$$23); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) - Z_PARAM_ARRAY(definition) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(parameters) + ZVAL_UNDEF(&_11$$19); + ZVAL_UNDEF(&_12$$22); + ZVAL_UNDEF(&_13$$21); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(visited, phalcon_support_collection_collectioninterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &container, &definition_param, ¶meters); - ZEPHIR_OBS_COPY_OR_DUP(&definition, definition_param); - if (!parameters) { - parameters = ¶meters_sub; - parameters = &__$null; + zephir_fetch_params(1, 1, 0, &visited); + ZEPHIR_CALL_FUNCTION(&objId, "spl_object_id", NULL, 432, this_ptr); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, visited, "has", NULL, 0, &objId); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + RETURN_MM_BOOL(1); } - zephir_memory_observe(&className); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&className, &definition, SL("className"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "Invalid service definition. Missing 'className' parameter", "phalcon/Di/Service/Builder.zep", 41); - return; + ZEPHIR_CALL_METHOD(NULL, visited, "set", NULL, 0, &objId, this_ptr); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&writeConnection, this_ptr, "getwriteconnection", NULL, 421); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "prepareSave"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_1); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&relatedToSave, this_ptr, "collectrelatedtosave", NULL, 0); + zephir_check_call_status(); + hasRelatedToSave = zephir_fast_count_int(&relatedToSave) > 0; + if (hasRelatedToSave) { + ZEPHIR_CALL_METHOD(&_2$$4, this_ptr, "presaverelatedrecords", NULL, 0, &writeConnection, &relatedToSave, visited); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_2$$4)) { + RETURN_MM_BOOL(0); + } } - if (Z_TYPE_P(parameters) == IS_ARRAY) { - if (zephir_fast_count_int(parameters)) { - ZEPHIR_INIT_VAR(&instance); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&instance, &className, parameters); + ZEPHIR_CALL_METHOD(&schema, this_ptr, "getschema", NULL, 423); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 424); + zephir_check_call_status(); + if (zephir_is_true(&schema)) { + ZEPHIR_INIT_VAR(&table); + zephir_create_array(&table, 2, 0); + zephir_array_fast_append(&table, &schema); + zephir_array_fast_append(&table, &source); + } else { + ZEPHIR_CPY_WRT(&table, &source); + } + ZEPHIR_CALL_METHOD(&readConnection, this_ptr, "getreadconnection", NULL, 431); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&exists, this_ptr, "has", NULL, 0, &metaData, &readConnection); + zephir_check_call_status(); + if (zephir_is_true(&exists)) { + ZVAL_UNDEF(&_3$$8); + ZVAL_LONG(&_3$$8, 2); + zephir_update_property_zval(this_ptr, ZEND_STRL("operationMade"), &_3$$8); + } else { + ZVAL_UNDEF(&_4$$9); + ZVAL_LONG(&_4$$9, 1); + zephir_update_property_zval(this_ptr, ZEND_STRL("operationMade"), &_4$$9); + } + ZEPHIR_INIT_NVAR(&_1); + array_init(&_1); + zephir_update_property_zval(this_ptr, ZEND_STRL("errorMessages"), &_1); + ZEPHIR_CALL_METHOD(&identityField, &metaData, "getidentityfield", NULL, 0, this_ptr); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "presave", NULL, 0, &metaData, &exists, &identityField); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_5)) { + if (hasRelatedToSave) { + ZVAL_BOOL(&_6$$11, 0); + ZEPHIR_CALL_METHOD(NULL, &writeConnection, "rollback", NULL, 0, &_6$$11); zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&instance); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&instance, &className); + } + if (UNEXPECTED(ZEPHIR_GLOBAL(orm).exception_on_failed_save)) { + ZEPHIR_INIT_VAR(&_7$$12); + object_init_ex(&_7$$12, phalcon_mvc_model_validationfailed_ce); + ZEPHIR_CALL_METHOD(&_8$$12, this_ptr, "getmessages", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_7$$12, "__construct", NULL, 433, this_ptr, &_8$$12); zephir_check_call_status(); + zephir_throw_exception_debug(&_7$$12, "phalcon/Mvc/Model.zep", 2716); + ZEPHIR_MM_RESTORE(); + return; } + RETURN_MM_BOOL(0); + } + if (zephir_is_true(&exists)) { + ZEPHIR_CALL_METHOD(&success, this_ptr, "dolowupdate", NULL, 0, &metaData, &writeConnection, &table); + zephir_check_call_status(); } else { - zephir_memory_observe(&arguments); - if (zephir_array_isset_string_fetch(&arguments, &definition, SL("arguments"), 0)) { - ZEPHIR_CALL_METHOD(&_0$$8, this_ptr, "buildparameters", NULL, 223, container, &arguments); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&instance); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&instance, &className, &_0$$8); + ZEPHIR_CALL_METHOD(&success, this_ptr, "dolowinsert", NULL, 0, &metaData, &writeConnection, &table, &identityField); + zephir_check_call_status(); + } + if (ZEPHIR_IS_TRUE_IDENTICAL(&success)) { + ZVAL_UNDEF(&_9$$15); + ZVAL_LONG(&_9$$15, 0); + zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &_9$$15); + } + if (hasRelatedToSave) { + if (ZEPHIR_IS_FALSE_IDENTICAL(&success)) { + ZVAL_BOOL(&_10$$17, 0); + ZEPHIR_CALL_METHOD(NULL, &writeConnection, "rollback", NULL, 0, &_10$$17); zephir_check_call_status(); } else { - ZEPHIR_INIT_NVAR(&instance); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&instance, &className); + ZEPHIR_CALL_METHOD(&success, this_ptr, "postsaverelatedrecords", NULL, 0, &writeConnection, &relatedToSave, visited); zephir_check_call_status(); } } - zephir_memory_observe(¶mCalls); - if (zephir_array_isset_string_fetch(¶mCalls, &definition, SL("calls"), 0)) { - if (UNEXPECTED(Z_TYPE_P(&instance) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "The definition has setter injection parameters but the constructor didn't return an instance", "phalcon/Di/Service/Builder.zep", 78); + if (ZEPHIR_GLOBAL(orm).events) { + ZEPHIR_CALL_METHOD(&_11$$19, this_ptr, "postsave", NULL, 0, &success, &exists); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&success, &_11$$19); + } + if (ZEPHIR_IS_FALSE_IDENTICAL(&success)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "canceloperation", NULL, 0); + zephir_check_call_status(); + } else { + if (hasRelatedToSave) { + ZEPHIR_INIT_VAR(&_12$$22); + array_init(&_12$$22); + zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyRelated"), &_12$$22); + } + ZEPHIR_INIT_VAR(&_13$$21); + ZVAL_STRING(&_13$$21, "afterSave"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_13$$21); + zephir_check_call_status(); + } + RETURN_CCTOR(&success); +} + +static PHP_METHOD(Phalcon_Mvc_Model, serialize) +{ + zval _6; + zend_bool _3, _4; + zval attributes, manager, dirtyState, snapshot, _0, _1, _2, _5$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&dirtyState); + ZVAL_UNDEF(&snapshot); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&snapshot); + ZVAL_NULL(&snapshot); + ZVAL_NULL(&_0); + ZVAL_BOOL(&_1, 0); + ZEPHIR_CALL_METHOD(&attributes, this_ptr, "toarray", NULL, 0, &_0, &_1); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dirtyState"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&dirtyState, &_0); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "getmodelsmanager", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&manager, &_2); + ZEPHIR_CALL_METHOD(&_2, &manager, "iskeepingsnapshots", NULL, 0, this_ptr); + zephir_check_call_status(); + _3 = zephir_is_true(&_2); + if (_3) { + zephir_read_property(&_0, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); + _3 = Z_TYPE_P(&_0) != IS_NULL; + } + _4 = _3; + if (_4) { + zephir_read_property(&_1, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); + _4 = !ZEPHIR_IS_EQUAL(&attributes, &_1); + } + if (_4) { + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&snapshot, &_5$$3); + } + ZEPHIR_INIT_VAR(&_6); + zephir_create_array(&_6, 3, 0); + zephir_array_update_string(&_6, SL("attributes"), &attributes, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_6, SL("snapshot"), &snapshot, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_6, SL("dirtyState"), &dirtyState, PH_COPY | PH_SEPARATE); + ZEPHIR_RETURN_CALL_FUNCTION("serialize", NULL, 15, &_6); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Mvc_Model, unserialize) +{ + zend_string *_12$$7; + zend_ulong _11$$7; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *data_param = NULL, attributes, container, manager, key, value, snapshot, properties, dirtyState, _0$$4, _1$$5, _2$$5, _3$$5, _4$$3, _5$$3, _6$$6, _7$$6, _8$$6, *_9$$7, _10$$7; + zval data; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&snapshot); + ZVAL_UNDEF(&properties); + ZVAL_UNDEF(&dirtyState); + ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&_1$$5); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$6); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&_10$$7); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(data) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &data_param); + zephir_get_strval(&data, data_param); + ZEPHIR_CALL_FUNCTION(&attributes, "unserialize", NULL, 16, &data); + zephir_check_call_status(); + if (Z_TYPE_P(&attributes) == IS_ARRAY) { + if (!(zephir_array_isset_string(&attributes, SL("attributes")))) { + ZEPHIR_INIT_VAR(&_0$$4); + zephir_create_array(&_0$$4, 1, 0); + zephir_array_update_string(&_0$$4, SL("attributes"), &attributes, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&attributes, &_0$$4); + } + ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$5); + object_init_ex(&_1$$5, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_2$$5); + zephir_get_class(&_2$$5, this_ptr, 0); + ZEPHIR_INIT_VAR(&_3$$5); + ZEPHIR_CONCAT_SVS(&_3$$5, "A dependency injection container is required to access the services related to the ODM in '", &_2$$5, "'"); + ZEPHIR_CALL_METHOD(NULL, &_1$$5, "__construct", NULL, 33, &_3$$5); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$5, "phalcon/Mvc/Model.zep", 2836); + ZEPHIR_MM_RESTORE(); return; } - if (UNEXPECTED(Z_TYPE_P(¶mCalls) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "Setter injection parameters must be an array", "phalcon/Di/Service/Builder.zep", 84); + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &container); + ZEPHIR_INIT_VAR(&_5$$3); + ZVAL_STRING(&_5$$3, "modelsManager"); + ZEPHIR_CALL_METHOD(&_4$$3, &container, "getshared", NULL, 0, &_5$$3); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&manager, &_4$$3); + if (UNEXPECTED(Z_TYPE_P(&manager) != IS_OBJECT)) { + ZEPHIR_INIT_VAR(&_6$$6); + object_init_ex(&_6$$6, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_7$$6); + zephir_get_class(&_7$$6, this_ptr, 0); + ZEPHIR_INIT_VAR(&_8$$6); + ZEPHIR_CONCAT_SVS(&_8$$6, "The injected service 'modelsManager' is not valid in '", &_7$$6, "'"); + ZEPHIR_CALL_METHOD(NULL, &_6$$6, "__construct", NULL, 33, &_8$$6); + zephir_check_call_status(); + zephir_throw_exception_debug(&_6$$6, "phalcon/Mvc/Model.zep", 2852); + ZEPHIR_MM_RESTORE(); return; } - zephir_is_iterable(¶mCalls, 0, "phalcon/Di/Service/Builder.zep", 143); - if (Z_TYPE_P(¶mCalls) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(¶mCalls), _3$$10, _4$$10, _1$$10) + zephir_update_property_zval(this_ptr, ZEND_STRL("modelsManager"), &manager); + ZEPHIR_CALL_METHOD(NULL, &manager, "initialize", NULL, 0, this_ptr); + zephir_check_call_status(); + zephir_memory_observe(&properties); + if (zephir_array_isset_string_fetch(&properties, &attributes, SL("attributes"), 0)) { + zephir_is_iterable(&properties, 0, "phalcon/Mvc/Model.zep", 2875); + if (Z_TYPE_P(&properties) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&properties), _11$$7, _12$$7, _9$$7) + { + ZEPHIR_INIT_NVAR(&key); + if (_12$$7 != NULL) { + ZVAL_STR_COPY(&key, _12$$7); + } else { + ZVAL_LONG(&key, _11$$7); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _9$$7); + zephir_update_property_zval_zval(this_ptr, &key, &value); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &properties, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_10$$7, &properties, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_10$$7)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &properties, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &properties, "current", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval_zval(this_ptr, &key, &value); + ZEPHIR_CALL_METHOD(NULL, &properties, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + } else { + ZEPHIR_INIT_NVAR(&properties); + array_init(&properties); + } + zephir_memory_observe(&dirtyState); + if (zephir_array_isset_string_fetch(&dirtyState, &attributes, SL("dirtyState"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &dirtyState); + } + ZEPHIR_CALL_METHOD(&_4$$3, &manager, "iskeepingsnapshots", NULL, 0, this_ptr); + zephir_check_call_status(); + if (zephir_is_true(&_4$$3)) { + if (zephir_array_isset_string_fetch(&snapshot, &attributes, SL("snapshot"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("snapshot"), &snapshot); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("snapshot"), &properties); + } + } + } + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model, setConnectionService) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *connectionService_param = NULL, _0; + zval connectionService; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&connectionService); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(connectionService) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &connectionService_param); + if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) { + zephir_get_strval(&connectionService, connectionService_param); + } else { + ZEPHIR_INIT_VAR(&connectionService); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "setconnectionservice", NULL, 0, this_ptr, &connectionService); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model, setDirtyState) +{ + zval *dirtyState_param = NULL, _0; + zend_long dirtyState; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(dirtyState) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &dirtyState_param); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, dirtyState); + zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &_0); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Mvc_Model, setEventsManager) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *eventsManager, eventsManager_sub, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&eventsManager_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &eventsManager); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "setcustomeventsmanager", NULL, 0, this_ptr, eventsManager); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model, setReadConnectionService) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *connectionService_param = NULL, _0; + zval connectionService; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&connectionService); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(connectionService) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &connectionService_param); + if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) { + zephir_get_strval(&connectionService, connectionService_param); + } else { + ZEPHIR_INIT_VAR(&connectionService); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "setreadconnectionservice", NULL, 0, this_ptr, &connectionService); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model, setOldSnapshotData) +{ + zend_string *_3$$3; + zend_ulong _2$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_7 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *data_param = NULL, *columnMap = NULL, columnMap_sub, __$null, key, value, attribute, *_0$$3, _1$$3, _4$$7, _5$$7, _6$$7, _8$$10, _9$$10, _10$$10, _11$$14, _12$$14, _13$$14, _14$$17, _15$$17, _16$$17; + zval data, snapshot; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&snapshot); + ZVAL_UNDEF(&columnMap_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_4$$7); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_8$$10); + ZVAL_UNDEF(&_9$$10); + ZVAL_UNDEF(&_10$$10); + ZVAL_UNDEF(&_11$$14); + ZVAL_UNDEF(&_12$$14); + ZVAL_UNDEF(&_13$$14); + ZVAL_UNDEF(&_14$$17); + ZVAL_UNDEF(&_15$$17); + ZVAL_UNDEF(&_16$$17); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(data) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(columnMap) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &data_param, &columnMap); + ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); + if (!columnMap) { + columnMap = &columnMap_sub; + columnMap = &__$null; + } + if (Z_TYPE_P(columnMap) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&snapshot); + array_init(&snapshot); + zephir_is_iterable(&data, 0, "phalcon/Mvc/Model.zep", 2993); + if (Z_TYPE_P(&data) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _2$$3, _3$$3, _0$$3) { - ZEPHIR_INIT_NVAR(&methodPosition); - if (_4$$10 != NULL) { - ZVAL_STR_COPY(&methodPosition, _4$$10); + ZEPHIR_INIT_NVAR(&key); + if (_3$$3 != NULL) { + ZVAL_STR_COPY(&key, _3$$3); } else { - ZVAL_LONG(&methodPosition, _3$$10); - } - ZEPHIR_INIT_NVAR(&method); - ZVAL_COPY(&method, _1$$10); - if (UNEXPECTED(Z_TYPE_P(&method) != IS_ARRAY)) { - ZEPHIR_INIT_NVAR(&_5$$14); - object_init_ex(&_5$$14, phalcon_di_exception_ce); - ZEPHIR_INIT_NVAR(&_6$$14); - ZEPHIR_CONCAT_SV(&_6$$14, "Method call must be an array on position ", &methodPosition); - ZEPHIR_CALL_METHOD(NULL, &_5$$14, "__construct", &_7, 33, &_6$$14); - zephir_check_call_status(); - zephir_throw_exception_debug(&_5$$14, "phalcon/Di/Service/Builder.zep", 97); - ZEPHIR_MM_RESTORE(); - return; + ZVAL_LONG(&key, _2$$3); } - ZEPHIR_OBS_NVAR(&methodName); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&methodName, &method, SL("method"), 0)))) { - ZEPHIR_INIT_NVAR(&_8$$15); - object_init_ex(&_8$$15, phalcon_di_exception_ce); - ZEPHIR_INIT_NVAR(&_9$$15); - ZEPHIR_CONCAT_SV(&_9$$15, "The method name is required on position ", &methodPosition); - ZEPHIR_CALL_METHOD(NULL, &_8$$15, "__construct", &_7, 33, &_9$$15); - zephir_check_call_status(); - zephir_throw_exception_debug(&_8$$15, "phalcon/Di/Service/Builder.zep", 106); - ZEPHIR_MM_RESTORE(); - return; + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0$$3); + if (Z_TYPE_P(&key) != IS_STRING) { + continue; } - ZEPHIR_INIT_NVAR(&methodCall); - zephir_create_array(&methodCall, 2, 0); - zephir_array_fast_append(&methodCall, &instance); - zephir_array_fast_append(&methodCall, &methodName); - ZEPHIR_OBS_NVAR(&arguments); - if (zephir_array_isset_string_fetch(&arguments, &method, SL("arguments"), 0)) { - if (UNEXPECTED(Z_TYPE_P(&arguments) != IS_ARRAY)) { - ZEPHIR_INIT_NVAR(&_10$$17); - object_init_ex(&_10$$17, phalcon_di_exception_ce); - zephir_cast_to_string(&_11$$17, &methodPosition); - ZEPHIR_INIT_NVAR(&_12$$17); - ZEPHIR_CONCAT_SV(&_12$$17, "Call arguments must be an array on position ", &_11$$17); - ZEPHIR_CALL_METHOD(NULL, &_10$$17, "__construct", &_7, 33, &_12$$17); + ZEPHIR_OBS_NVAR(&attribute); + if (!(zephir_array_isset_fetch(&attribute, columnMap, &key, 0))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_4$$7); + object_init_ex(&_4$$7, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_5$$7); + zephir_get_class(&_5$$7, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_6$$7); + ZEPHIR_CONCAT_SVSVS(&_6$$7, "Column '", &key, "' doesn't make part of the column map in '", &_5$$7, "'"); + ZEPHIR_CALL_METHOD(NULL, &_4$$7, "__construct", &_7, 33, &_6$$7); zephir_check_call_status(); - zephir_throw_exception_debug(&_10$$17, "phalcon/Di/Service/Builder.zep", 119); + zephir_throw_exception_debug(&_4$$7, "phalcon/Mvc/Model.zep", 2973); ZEPHIR_MM_RESTORE(); return; } - if (zephir_fast_count_int(&arguments)) { - ZEPHIR_INIT_NVAR(&_13$$18); - ZEPHIR_CALL_METHOD(&_14$$18, this_ptr, "buildparameters", NULL, 223, container, &arguments); - zephir_check_call_status(); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_13$$18, &methodCall, &_14$$18); - zephir_check_call_status(); + continue; + } + if (Z_TYPE_P(&attribute) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attribute); + if (!(zephir_array_isset_long_fetch(&attribute, &attribute, 0, 0))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_8$$10); + object_init_ex(&_8$$10, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_9$$10); + zephir_get_class(&_9$$10, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_10$$10); + ZEPHIR_CONCAT_SVSVS(&_10$$10, "Column '", &key, "' doesn't make part of the column map in '", &_9$$10, "'"); + ZEPHIR_CALL_METHOD(NULL, &_8$$10, "__construct", &_7, 33, &_10$$10); + zephir_check_call_status(); + zephir_throw_exception_debug(&_8$$10, "phalcon/Mvc/Model.zep", 2984); + ZEPHIR_MM_RESTORE(); + return; + } continue; } } - ZEPHIR_INIT_NVAR(&_15$$13); - ZEPHIR_CALL_USER_FUNC(&_15$$13, &methodCall); - zephir_check_call_status(); + zephir_array_update_zval(&snapshot, &attribute, &value, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, ¶mCalls, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_2$$10, ¶mCalls, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_1$$3, &data, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_2$$10)) { + if (!zend_is_true(&_1$$3)) { break; } - ZEPHIR_CALL_METHOD(&methodPosition, ¶mCalls, "key", NULL, 0); + ZEPHIR_CALL_METHOD(&key, &data, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&method, ¶mCalls, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&method) != IS_ARRAY)) { - ZEPHIR_INIT_NVAR(&_16$$20); - object_init_ex(&_16$$20, phalcon_di_exception_ce); - ZEPHIR_INIT_NVAR(&_17$$20); - ZEPHIR_CONCAT_SV(&_17$$20, "Method call must be an array on position ", &methodPosition); - ZEPHIR_CALL_METHOD(NULL, &_16$$20, "__construct", &_7, 33, &_17$$20); - zephir_check_call_status(); - zephir_throw_exception_debug(&_16$$20, "phalcon/Di/Service/Builder.zep", 97); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_OBS_NVAR(&methodName); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&methodName, &method, SL("method"), 0)))) { - ZEPHIR_INIT_NVAR(&_18$$21); - object_init_ex(&_18$$21, phalcon_di_exception_ce); - ZEPHIR_INIT_NVAR(&_19$$21); - ZEPHIR_CONCAT_SV(&_19$$21, "The method name is required on position ", &methodPosition); - ZEPHIR_CALL_METHOD(NULL, &_18$$21, "__construct", &_7, 33, &_19$$21); - zephir_check_call_status(); - zephir_throw_exception_debug(&_18$$21, "phalcon/Di/Service/Builder.zep", 106); - ZEPHIR_MM_RESTORE(); - return; + if (Z_TYPE_P(&key) != IS_STRING) { + continue; } - ZEPHIR_INIT_NVAR(&_20$$19); - zephir_create_array(&_20$$19, 2, 0); - zephir_array_fast_append(&_20$$19, &instance); - zephir_array_fast_append(&_20$$19, &methodName); - ZEPHIR_CPY_WRT(&methodCall, &_20$$19); - ZEPHIR_OBS_NVAR(&arguments); - if (zephir_array_isset_string_fetch(&arguments, &method, SL("arguments"), 0)) { - if (UNEXPECTED(Z_TYPE_P(&arguments) != IS_ARRAY)) { - ZEPHIR_INIT_NVAR(&_21$$23); - object_init_ex(&_21$$23, phalcon_di_exception_ce); - zephir_cast_to_string(&_22$$23, &methodPosition); - ZEPHIR_INIT_NVAR(&_23$$23); - ZEPHIR_CONCAT_SV(&_23$$23, "Call arguments must be an array on position ", &_22$$23); - ZEPHIR_CALL_METHOD(NULL, &_21$$23, "__construct", &_7, 33, &_23$$23); + ZEPHIR_OBS_NVAR(&attribute); + if (!(zephir_array_isset_fetch(&attribute, columnMap, &key, 0))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_11$$14); + object_init_ex(&_11$$14, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_12$$14); + zephir_get_class(&_12$$14, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_13$$14); + ZEPHIR_CONCAT_SVSVS(&_13$$14, "Column '", &key, "' doesn't make part of the column map in '", &_12$$14, "'"); + ZEPHIR_CALL_METHOD(NULL, &_11$$14, "__construct", &_7, 33, &_13$$14); zephir_check_call_status(); - zephir_throw_exception_debug(&_21$$23, "phalcon/Di/Service/Builder.zep", 119); + zephir_throw_exception_debug(&_11$$14, "phalcon/Mvc/Model.zep", 2973); ZEPHIR_MM_RESTORE(); return; } - if (zephir_fast_count_int(&arguments)) { - ZEPHIR_INIT_NVAR(&_24$$24); - ZEPHIR_CALL_METHOD(&_25$$24, this_ptr, "buildparameters", NULL, 223, container, &arguments); - zephir_check_call_status(); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_24$$24, &methodCall, &_25$$24); - zephir_check_call_status(); + continue; + } + if (Z_TYPE_P(&attribute) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attribute); + if (!(zephir_array_isset_long_fetch(&attribute, &attribute, 0, 0))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_14$$17); + object_init_ex(&_14$$17, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_15$$17); + zephir_get_class(&_15$$17, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_16$$17); + ZEPHIR_CONCAT_SVSVS(&_16$$17, "Column '", &key, "' doesn't make part of the column map in '", &_15$$17, "'"); + ZEPHIR_CALL_METHOD(NULL, &_14$$17, "__construct", &_7, 33, &_16$$17); + zephir_check_call_status(); + zephir_throw_exception_debug(&_14$$17, "phalcon/Mvc/Model.zep", 2984); + ZEPHIR_MM_RESTORE(); + return; + } continue; } } - ZEPHIR_INIT_NVAR(&_26$$19); - ZEPHIR_CALL_USER_FUNC(&_26$$19, &methodCall); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, ¶mCalls, "next", NULL, 0); + zephir_array_update_zval(&snapshot, &attribute, &value, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&method); - ZEPHIR_INIT_NVAR(&methodPosition); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + } else { + ZEPHIR_CPY_WRT(&snapshot, &data); } - ZEPHIR_OBS_NVAR(¶mCalls); - if (zephir_array_isset_string_fetch(¶mCalls, &definition, SL("properties"), 0)) { - if (UNEXPECTED(Z_TYPE_P(&instance) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "The definition has properties injection parameters but the constructor didn't return an instance", "phalcon/Di/Service/Builder.zep", 152); - return; - } - if (UNEXPECTED(Z_TYPE_P(¶mCalls) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_di_exception_ce, "Setter injection parameters must be an array", "phalcon/Di/Service/Builder.zep", 158); - return; - } - zephir_is_iterable(¶mCalls, 0, "phalcon/Di/Service/Builder.zep", 201); - if (Z_TYPE_P(¶mCalls) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(¶mCalls), _29$$25, _30$$25, _27$$25) - { - ZEPHIR_INIT_NVAR(&propertyPosition); - if (_30$$25 != NULL) { - ZVAL_STR_COPY(&propertyPosition, _30$$25); - } else { - ZVAL_LONG(&propertyPosition, _29$$25); - } - ZEPHIR_INIT_NVAR(&property); - ZVAL_COPY(&property, _27$$25); - if (UNEXPECTED(Z_TYPE_P(&property) != IS_ARRAY)) { - ZEPHIR_INIT_NVAR(&_31$$29); - object_init_ex(&_31$$29, phalcon_di_exception_ce); - ZEPHIR_INIT_NVAR(&_32$$29); - ZEPHIR_CONCAT_SV(&_32$$29, "Property must be an array on position ", &propertyPosition); - ZEPHIR_CALL_METHOD(NULL, &_31$$29, "__construct", &_7, 33, &_32$$29); - zephir_check_call_status(); - zephir_throw_exception_debug(&_31$$29, "phalcon/Di/Service/Builder.zep", 171); - ZEPHIR_MM_RESTORE(); - return; + zephir_update_property_zval(this_ptr, ZEND_STRL("oldSnapshot"), &snapshot); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model, setSnapshotData) +{ + zend_bool _4$$4, _14$$12; + zend_string *_3$$3; + zend_ulong _2$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_6 = NULL, *_10 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *data_param = NULL, *columnMap = NULL, columnMap_sub, __$null, key, value, attribute, *_0$$3, _1$$3, _5$$6, _7$$8, _8$$8, _9$$8, _11$$11, _12$$11, _13$$11, _15$$14, _16$$16, _17$$16, _18$$16, _19$$19, _20$$19, _21$$19; + zval data, snapshot; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&snapshot); + ZVAL_UNDEF(&columnMap_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_7$$8); + ZVAL_UNDEF(&_8$$8); + ZVAL_UNDEF(&_9$$8); + ZVAL_UNDEF(&_11$$11); + ZVAL_UNDEF(&_12$$11); + ZVAL_UNDEF(&_13$$11); + ZVAL_UNDEF(&_15$$14); + ZVAL_UNDEF(&_16$$16); + ZVAL_UNDEF(&_17$$16); + ZVAL_UNDEF(&_18$$16); + ZVAL_UNDEF(&_19$$19); + ZVAL_UNDEF(&_20$$19); + ZVAL_UNDEF(&_21$$19); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(data) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(columnMap) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &data_param, &columnMap); + ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); + if (!columnMap) { + columnMap = &columnMap_sub; + columnMap = &__$null; + } + if (Z_TYPE_P(columnMap) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&snapshot); + array_init(&snapshot); + zephir_is_iterable(&data, 0, "phalcon/Mvc/Model.zep", 3058); + if (Z_TYPE_P(&data) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _2$$3, _3$$3, _0$$3) + { + ZEPHIR_INIT_NVAR(&key); + if (_3$$3 != NULL) { + ZVAL_STR_COPY(&key, _3$$3); + } else { + ZVAL_LONG(&key, _2$$3); } - ZEPHIR_OBS_NVAR(&propertyName); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&propertyName, &property, SL("name"), 0)))) { - ZEPHIR_INIT_NVAR(&_33$$30); - object_init_ex(&_33$$30, phalcon_di_exception_ce); - ZEPHIR_INIT_NVAR(&_34$$30); - ZEPHIR_CONCAT_SV(&_34$$30, "The property name is required on position ", &propertyPosition); - ZEPHIR_CALL_METHOD(NULL, &_33$$30, "__construct", &_7, 33, &_34$$30); - zephir_check_call_status(); - zephir_throw_exception_debug(&_33$$30, "phalcon/Di/Service/Builder.zep", 180); - ZEPHIR_MM_RESTORE(); - return; + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0$$3); + if (Z_TYPE_P(&key) != IS_STRING) { + continue; } - ZEPHIR_OBS_NVAR(&propertyValue); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&propertyValue, &property, SL("value"), 0)))) { - ZEPHIR_INIT_NVAR(&_35$$31); - object_init_ex(&_35$$31, phalcon_di_exception_ce); - ZEPHIR_INIT_NVAR(&_36$$31); - ZEPHIR_CONCAT_SV(&_36$$31, "The property value is required on position ", &propertyPosition); - ZEPHIR_CALL_METHOD(NULL, &_35$$31, "__construct", &_7, 33, &_36$$31); + _4$$4 = !(zephir_array_isset(columnMap, &key)); + if (_4$$4) { + _4$$4 = ZEPHIR_GLOBAL(orm).case_insensitive_column_map; + } + if (_4$$4) { + ZEPHIR_CALL_SELF(&_5$$6, "caseinsensitivecolumnmap", &_6, 420, columnMap, &key); zephir_check_call_status(); - zephir_throw_exception_debug(&_35$$31, "phalcon/Di/Service/Builder.zep", 189); - ZEPHIR_MM_RESTORE(); - return; + ZEPHIR_CPY_WRT(&key, &_5$$6); } - ZEPHIR_CALL_METHOD(&_37$$28, this_ptr, "buildparameter", &_38, 224, container, &propertyPosition, &propertyValue); - zephir_check_call_status(); - zephir_update_property_zval_zval(&instance, &propertyName, &_37$$28); + ZEPHIR_OBS_NVAR(&attribute); + if (!(zephir_array_isset_fetch(&attribute, columnMap, &key, 0))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_7$$8); + object_init_ex(&_7$$8, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_8$$8); + zephir_get_class(&_8$$8, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_9$$8); + ZEPHIR_CONCAT_SVSVS(&_9$$8, "Column '", &key, "' doesn't make part of the column map in '", &_8$$8, "'"); + ZEPHIR_CALL_METHOD(NULL, &_7$$8, "__construct", &_10, 33, &_9$$8); + zephir_check_call_status(); + zephir_throw_exception_debug(&_7$$8, "phalcon/Mvc/Model.zep", 3038); + ZEPHIR_MM_RESTORE(); + return; + } + continue; + } + if (Z_TYPE_P(&attribute) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attribute); + if (!(zephir_array_isset_long_fetch(&attribute, &attribute, 0, 0))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_11$$11); + object_init_ex(&_11$$11, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_12$$11); + zephir_get_class(&_12$$11, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_13$$11); + ZEPHIR_CONCAT_SVSVS(&_13$$11, "Column '", &key, "' doesn't make part of the column map in '", &_12$$11, "'"); + ZEPHIR_CALL_METHOD(NULL, &_11$$11, "__construct", &_10, 33, &_13$$11); + zephir_check_call_status(); + zephir_throw_exception_debug(&_11$$11, "phalcon/Mvc/Model.zep", 3049); + ZEPHIR_MM_RESTORE(); + return; + } + continue; + } + } + zephir_array_update_zval(&snapshot, &attribute, &value, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, ¶mCalls, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_28$$25, ¶mCalls, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_1$$3, &data, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_28$$25)) { + if (!zend_is_true(&_1$$3)) { break; } - ZEPHIR_CALL_METHOD(&propertyPosition, ¶mCalls, "key", NULL, 0); + ZEPHIR_CALL_METHOD(&key, &data, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&property, ¶mCalls, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&property) != IS_ARRAY)) { - ZEPHIR_INIT_NVAR(&_39$$33); - object_init_ex(&_39$$33, phalcon_di_exception_ce); - ZEPHIR_INIT_NVAR(&_40$$33); - ZEPHIR_CONCAT_SV(&_40$$33, "Property must be an array on position ", &propertyPosition); - ZEPHIR_CALL_METHOD(NULL, &_39$$33, "__construct", &_7, 33, &_40$$33); - zephir_check_call_status(); - zephir_throw_exception_debug(&_39$$33, "phalcon/Di/Service/Builder.zep", 171); - ZEPHIR_MM_RESTORE(); - return; + if (Z_TYPE_P(&key) != IS_STRING) { + continue; } - ZEPHIR_OBS_NVAR(&propertyName); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&propertyName, &property, SL("name"), 0)))) { - ZEPHIR_INIT_NVAR(&_41$$34); - object_init_ex(&_41$$34, phalcon_di_exception_ce); - ZEPHIR_INIT_NVAR(&_42$$34); - ZEPHIR_CONCAT_SV(&_42$$34, "The property name is required on position ", &propertyPosition); - ZEPHIR_CALL_METHOD(NULL, &_41$$34, "__construct", &_7, 33, &_42$$34); - zephir_check_call_status(); - zephir_throw_exception_debug(&_41$$34, "phalcon/Di/Service/Builder.zep", 180); - ZEPHIR_MM_RESTORE(); - return; + _14$$12 = !(zephir_array_isset(columnMap, &key)); + if (_14$$12) { + _14$$12 = ZEPHIR_GLOBAL(orm).case_insensitive_column_map; } - ZEPHIR_OBS_NVAR(&propertyValue); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&propertyValue, &property, SL("value"), 0)))) { - ZEPHIR_INIT_NVAR(&_43$$35); - object_init_ex(&_43$$35, phalcon_di_exception_ce); - ZEPHIR_INIT_NVAR(&_44$$35); - ZEPHIR_CONCAT_SV(&_44$$35, "The property value is required on position ", &propertyPosition); - ZEPHIR_CALL_METHOD(NULL, &_43$$35, "__construct", &_7, 33, &_44$$35); + if (_14$$12) { + ZEPHIR_CALL_SELF(&_15$$14, "caseinsensitivecolumnmap", &_6, 420, columnMap, &key); zephir_check_call_status(); - zephir_throw_exception_debug(&_43$$35, "phalcon/Di/Service/Builder.zep", 189); - ZEPHIR_MM_RESTORE(); - return; + ZEPHIR_CPY_WRT(&key, &_15$$14); } - ZEPHIR_CALL_METHOD(&_45$$32, this_ptr, "buildparameter", &_38, 224, container, &propertyPosition, &propertyValue); - zephir_check_call_status(); - zephir_update_property_zval_zval(&instance, &propertyName, &_45$$32); - ZEPHIR_CALL_METHOD(NULL, ¶mCalls, "next", NULL, 0); + ZEPHIR_OBS_NVAR(&attribute); + if (!(zephir_array_isset_fetch(&attribute, columnMap, &key, 0))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_16$$16); + object_init_ex(&_16$$16, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_17$$16); + zephir_get_class(&_17$$16, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_18$$16); + ZEPHIR_CONCAT_SVSVS(&_18$$16, "Column '", &key, "' doesn't make part of the column map in '", &_17$$16, "'"); + ZEPHIR_CALL_METHOD(NULL, &_16$$16, "__construct", &_10, 33, &_18$$16); + zephir_check_call_status(); + zephir_throw_exception_debug(&_16$$16, "phalcon/Mvc/Model.zep", 3038); + ZEPHIR_MM_RESTORE(); + return; + } + continue; + } + if (Z_TYPE_P(&attribute) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attribute); + if (!(zephir_array_isset_long_fetch(&attribute, &attribute, 0, 0))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_19$$19); + object_init_ex(&_19$$19, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_20$$19); + zephir_get_class(&_20$$19, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_21$$19); + ZEPHIR_CONCAT_SVSVS(&_21$$19, "Column '", &key, "' doesn't make part of the column map in '", &_20$$19, "'"); + ZEPHIR_CALL_METHOD(NULL, &_19$$19, "__construct", &_10, 33, &_21$$19); + zephir_check_call_status(); + zephir_throw_exception_debug(&_19$$19, "phalcon/Mvc/Model.zep", 3049); + ZEPHIR_MM_RESTORE(); + return; + } + continue; + } + } + zephir_array_update_zval(&snapshot, &attribute, &value, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&property); - ZEPHIR_INIT_NVAR(&propertyPosition); - } - RETURN_CCTOR(&instance); -} - -static PHP_METHOD(Phalcon_Di_Service_Builder, buildParameter) -{ - zval _2$$3, _5$$5, _8$$7, _11$$9, _14$$11; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval argument; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *container, container_sub, *position_param = NULL, *argument_param = NULL, type, name, value, instanceArguments, _0$$3, _1$$3, _3$$5, _4$$5, _6$$7, _7$$7, _9$$9, _10$$9, _12$$11, _13$$11; - - ZVAL_UNDEF(&container_sub); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&instanceArguments); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_7$$7); - ZVAL_UNDEF(&_9$$9); - ZVAL_UNDEF(&_10$$9); - ZVAL_UNDEF(&_12$$11); - ZVAL_UNDEF(&_13$$11); - ZVAL_UNDEF(&argument); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_8$$7); - ZVAL_UNDEF(&_11$$9); - ZVAL_UNDEF(&_14$$11); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) - Z_PARAM_LONG(position) - Z_PARAM_ARRAY(argument) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &container, &position_param, &argument_param); - ZEPHIR_OBS_COPY_OR_DUP(&argument, argument_param); - zephir_memory_observe(&type); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&type, &argument, SL("type"), 0)))) { - ZEPHIR_INIT_VAR(&_0$$3); - object_init_ex(&_0$$3, phalcon_di_exception_ce); - ZEPHIR_INIT_VAR(&_1$$3); - ZVAL_LONG(&_1$$3, position); - ZEPHIR_INIT_VAR(&_2$$3); - ZEPHIR_CONCAT_SVS(&_2$$3, "Argument at position ", &_1$$3, " must have a type"); - ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 33, &_2$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_0$$3, "phalcon/Di/Service/Builder.zep", 221); - ZEPHIR_MM_RESTORE(); - return; + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + } else { + ZEPHIR_CPY_WRT(&snapshot, &data); } - do { - if (ZEPHIR_IS_STRING(&type, "service")) { - zephir_memory_observe(&name); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&name, &argument, SL("name"), 0)))) { - ZEPHIR_INIT_VAR(&_3$$5); - object_init_ex(&_3$$5, phalcon_di_exception_ce); - ZEPHIR_INIT_VAR(&_4$$5); - ZVAL_LONG(&_4$$5, position); - ZEPHIR_INIT_VAR(&_5$$5); - ZEPHIR_CONCAT_SV(&_5$$5, "Service 'name' is required in parameter on position ", &_4$$5); - ZEPHIR_CALL_METHOD(NULL, &_3$$5, "__construct", NULL, 33, &_5$$5); - zephir_check_call_status(); - zephir_throw_exception_debug(&_3$$5, "phalcon/Di/Service/Builder.zep", 233); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_RETURN_CALL_METHOD(container, "get", NULL, 0, &name); - zephir_check_call_status(); - RETURN_MM(); - } - if (ZEPHIR_IS_STRING(&type, "parameter")) { - zephir_memory_observe(&value); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&value, &argument, SL("value"), 0)))) { - ZEPHIR_INIT_VAR(&_6$$7); - object_init_ex(&_6$$7, phalcon_di_exception_ce); - ZEPHIR_INIT_VAR(&_7$$7); - ZVAL_LONG(&_7$$7, position); - ZEPHIR_INIT_VAR(&_8$$7); - ZEPHIR_CONCAT_SV(&_8$$7, "Service 'value' is required in parameter on position ", &_7$$7); - ZEPHIR_CALL_METHOD(NULL, &_6$$7, "__construct", NULL, 33, &_8$$7); - zephir_check_call_status(); - zephir_throw_exception_debug(&_6$$7, "phalcon/Di/Service/Builder.zep", 245); - ZEPHIR_MM_RESTORE(); - return; - } - RETURN_CCTOR(&value); - } - if (ZEPHIR_IS_STRING(&type, "instance")) { - ZEPHIR_OBS_NVAR(&name); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&name, &argument, SL("className"), 0)))) { - ZEPHIR_INIT_VAR(&_9$$9); - object_init_ex(&_9$$9, phalcon_di_exception_ce); - ZEPHIR_INIT_VAR(&_10$$9); - ZVAL_LONG(&_10$$9, position); - ZEPHIR_INIT_VAR(&_11$$9); - ZEPHIR_CONCAT_SV(&_11$$9, "Service 'className' is required in parameter on position ", &_10$$9); - ZEPHIR_CALL_METHOD(NULL, &_9$$9, "__construct", NULL, 33, &_11$$9); - zephir_check_call_status(); - zephir_throw_exception_debug(&_9$$9, "phalcon/Di/Service/Builder.zep", 257); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_memory_observe(&instanceArguments); - if (zephir_array_isset_string_fetch(&instanceArguments, &argument, SL("arguments"), 0)) { - ZEPHIR_RETURN_CALL_METHOD(container, "get", NULL, 0, &name, &instanceArguments); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_RETURN_CALL_METHOD(container, "get", NULL, 0, &name); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_INIT_VAR(&_12$$11); - object_init_ex(&_12$$11, phalcon_di_exception_ce); - ZEPHIR_INIT_VAR(&_13$$11); - ZVAL_LONG(&_13$$11, position); - ZEPHIR_INIT_VAR(&_14$$11); - ZEPHIR_CONCAT_SV(&_14$$11, "Unknown service type in parameter on position ", &_13$$11); - ZEPHIR_CALL_METHOD(NULL, &_12$$11, "__construct", NULL, 33, &_14$$11); - zephir_check_call_status(); - zephir_throw_exception_debug(&_12$$11, "phalcon/Di/Service/Builder.zep", 279); - ZEPHIR_MM_RESTORE(); - return; - } while(0); - + zephir_update_property_zval(this_ptr, ZEND_STRL("snapshot"), &snapshot); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Di_Service_Builder, buildParameters) +static PHP_METHOD(Phalcon_Mvc_Model, setTransaction) { - zend_string *_3; - zend_ulong _2; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval arguments, buildArguments; - zval *container, container_sub, *arguments_param = NULL, position, argument, *_0, _1, _4$$3, _6$$4; + zval *transaction, transaction_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container_sub); - ZVAL_UNDEF(&position); - ZVAL_UNDEF(&argument); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&arguments); - ZVAL_UNDEF(&buildArguments); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) - Z_PARAM_ARRAY(arguments) + ZVAL_UNDEF(&transaction_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(transaction, phalcon_mvc_model_transactioninterface_ce) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &container, &arguments_param); - ZEPHIR_OBS_COPY_OR_DUP(&arguments, arguments_param); - ZEPHIR_INIT_VAR(&buildArguments); - array_init(&buildArguments); - zephir_is_iterable(&arguments, 0, "phalcon/Di/Service/Builder.zep", 301); - if (Z_TYPE_P(&arguments) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&arguments), _2, _3, _0) - { - ZEPHIR_INIT_NVAR(&position); - if (_3 != NULL) { - ZVAL_STR_COPY(&position, _3); - } else { - ZVAL_LONG(&position, _2); - } - ZEPHIR_INIT_NVAR(&argument); - ZVAL_COPY(&argument, _0); - ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "buildparameter", &_5, 224, container, &position, &argument); - zephir_check_call_status(); - zephir_array_append(&buildArguments, &_4$$3, PH_SEPARATE, "phalcon/Di/Service/Builder.zep", 298); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &arguments, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &arguments, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&position, &arguments, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&argument, &arguments, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_6$$4, this_ptr, "buildparameter", &_5, 224, container, &position, &argument); - zephir_check_call_status(); - zephir_array_append(&buildArguments, &_6$$4, PH_SEPARATE, "phalcon/Di/Service/Builder.zep", 298); - ZEPHIR_CALL_METHOD(NULL, &arguments, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&argument); - ZEPHIR_INIT_NVAR(&position); - RETURN_CTOR(&buildArguments); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Di_Exception_ServiceResolutionException) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Di\\Exception, ServiceResolutionException, phalcon, di_exception_serviceresolutionexception, phalcon_di_exception_ce, NULL, 0); - - return SUCCESS; + zephir_fetch_params_without_memory_grow(1, 0, &transaction); + zephir_update_property_zval(this_ptr, ZEND_STRL("transaction"), transaction); + RETURN_THISW(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Forms_Exception) +static PHP_METHOD(Phalcon_Mvc_Model, getTransaction) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms, Exception, phalcon, forms_exception, zend_ce_exception, NULL, 0); - return SUCCESS; + RETURN_MEMBER(getThis(), "transaction"); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Forms_Form) +static PHP_METHOD(Phalcon_Mvc_Model, setup) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms, Form, phalcon, forms_form, phalcon_di_injectable_ce, phalcon_forms_form_method_entry, 0); - - zend_declare_property_null(phalcon_forms_form_ce, SL("attributes"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_form_ce, SL("data"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_form_ce, SL("filteredData"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_form_ce, SL("elements"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_form_ce, SL("elementsIndexed"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_form_ce, SL("entity"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_form_ce, SL("messages"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_forms_form_ce, SL("position"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_form_ce, SL("options"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_form_ce, SL("tagFactory"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_form_ce, SL("validation"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_form_ce, SL("whitelist"), ZEND_ACC_PROTECTED); - phalcon_forms_form_ce->create_object = zephir_init_properties_Phalcon_Forms_Form; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *options_param = NULL, disableEvents, columnRenaming, notNullValidations, exceptionOnFailedSave, exceptionOnFailedMetaDataSave, phqlLiterals, virtualForeignKeys, lateStateBinding, castOnHydrate, ignoreUnknownColumns, updateSnapshotOnSave, disableAssignSetters, caseInsensitiveColumnMap, prefetchRecords, lastInsertId; + zval options; - zend_class_implements(phalcon_forms_form_ce, 1, zend_ce_countable); - zend_class_implements(phalcon_forms_form_ce, 1, zend_ce_iterator); - zend_class_implements(phalcon_forms_form_ce, 1, phalcon_html_attributes_attributesinterface_ce); - return SUCCESS; + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&disableEvents); + ZVAL_UNDEF(&columnRenaming); + ZVAL_UNDEF(¬NullValidations); + ZVAL_UNDEF(&exceptionOnFailedSave); + ZVAL_UNDEF(&exceptionOnFailedMetaDataSave); + ZVAL_UNDEF(&phqlLiterals); + ZVAL_UNDEF(&virtualForeignKeys); + ZVAL_UNDEF(&lateStateBinding); + ZVAL_UNDEF(&castOnHydrate); + ZVAL_UNDEF(&ignoreUnknownColumns); + ZVAL_UNDEF(&updateSnapshotOnSave); + ZVAL_UNDEF(&disableAssignSetters); + ZVAL_UNDEF(&caseInsensitiveColumnMap); + ZVAL_UNDEF(&prefetchRecords); + ZVAL_UNDEF(&lastInsertId); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &options_param); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + zephir_memory_observe(&disableEvents); + if (zephir_array_isset_string_fetch(&disableEvents, &options, SL("events"), 0)) { + ZEPHIR_GLOBAL(orm).events = zend_is_true(&disableEvents); + } + zephir_memory_observe(&virtualForeignKeys); + if (zephir_array_isset_string_fetch(&virtualForeignKeys, &options, SL("virtualForeignKeys"), 0)) { + ZEPHIR_GLOBAL(orm).virtual_foreign_keys = zend_is_true(&virtualForeignKeys); + } + zephir_memory_observe(&columnRenaming); + if (zephir_array_isset_string_fetch(&columnRenaming, &options, SL("columnRenaming"), 0)) { + ZEPHIR_GLOBAL(orm).column_renaming = zend_is_true(&columnRenaming); + } + zephir_memory_observe(¬NullValidations); + if (zephir_array_isset_string_fetch(¬NullValidations, &options, SL("notNullValidations"), 0)) { + ZEPHIR_GLOBAL(orm).not_null_validations = zend_is_true(¬NullValidations); + } + zephir_memory_observe(&exceptionOnFailedSave); + if (zephir_array_isset_string_fetch(&exceptionOnFailedSave, &options, SL("exceptionOnFailedSave"), 0)) { + ZEPHIR_GLOBAL(orm).exception_on_failed_save = zend_is_true(&exceptionOnFailedSave); + } + zephir_memory_observe(&exceptionOnFailedMetaDataSave); + if (zephir_array_isset_string_fetch(&exceptionOnFailedMetaDataSave, &options, SL("exceptionOnFailedMetaDataSave"), 0)) { + ZEPHIR_GLOBAL(orm).exception_on_failed_metadata_save = zend_is_true(&exceptionOnFailedMetaDataSave); + } + zephir_memory_observe(&phqlLiterals); + if (zephir_array_isset_string_fetch(&phqlLiterals, &options, SL("phqlLiterals"), 0)) { + ZEPHIR_GLOBAL(orm).enable_literals = zend_is_true(&phqlLiterals); + } + zephir_memory_observe(&lateStateBinding); + if (zephir_array_isset_string_fetch(&lateStateBinding, &options, SL("lateStateBinding"), 0)) { + ZEPHIR_GLOBAL(orm).late_state_binding = zend_is_true(&lateStateBinding); + } + zephir_memory_observe(&castOnHydrate); + if (zephir_array_isset_string_fetch(&castOnHydrate, &options, SL("castOnHydrate"), 0)) { + ZEPHIR_GLOBAL(orm).cast_on_hydrate = zend_is_true(&castOnHydrate); + } + zephir_memory_observe(&ignoreUnknownColumns); + if (zephir_array_isset_string_fetch(&ignoreUnknownColumns, &options, SL("ignoreUnknownColumns"), 0)) { + ZEPHIR_GLOBAL(orm).ignore_unknown_columns = zend_is_true(&ignoreUnknownColumns); + } + zephir_memory_observe(&caseInsensitiveColumnMap); + if (zephir_array_isset_string_fetch(&caseInsensitiveColumnMap, &options, SL("caseInsensitiveColumnMap"), 0)) { + ZEPHIR_GLOBAL(orm).case_insensitive_column_map = zend_is_true(&caseInsensitiveColumnMap); + } + zephir_memory_observe(&updateSnapshotOnSave); + if (zephir_array_isset_string_fetch(&updateSnapshotOnSave, &options, SL("updateSnapshotOnSave"), 0)) { + ZEPHIR_GLOBAL(orm).update_snapshot_on_save = zend_is_true(&updateSnapshotOnSave); + } + zephir_memory_observe(&disableAssignSetters); + if (zephir_array_isset_string_fetch(&disableAssignSetters, &options, SL("disableAssignSetters"), 0)) { + ZEPHIR_GLOBAL(orm).disable_assign_setters = zend_is_true(&disableAssignSetters); + } + zephir_memory_observe(&prefetchRecords); + if (zephir_array_isset_string_fetch(&prefetchRecords, &options, SL("prefetchRecords"), 0)) { + ZEPHIR_GLOBAL(orm).resultset_prefetch_records = ZSTR_VAL(zval_get_string(&prefetchRecords)); + } + zephir_memory_observe(&lastInsertId); + if (zephir_array_isset_string_fetch(&lastInsertId, &options, SL("castLastInsertIdToInt"), 0)) { + ZEPHIR_GLOBAL(orm).cast_last_insert_id_to_int = zend_is_true(&lastInsertId); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Forms_Form, __construct) +static PHP_METHOD(Phalcon_Mvc_Model, setWriteConnectionService) { - zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval userOptions; - zval *entity = NULL, entity_sub, *userOptions_param = NULL, __$null, _1; + zval *connectionService_param = NULL, _0; + zval connectionService; zval *this_ptr = getThis(); - ZVAL_UNDEF(&entity_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&userOptions); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(entity) - Z_PARAM_ARRAY(userOptions) + ZVAL_UNDEF(&connectionService); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(connectionService) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &entity, &userOptions_param); - if (!entity) { - entity = &entity_sub; - entity = &__$null; + zephir_fetch_params(1, 1, 0, &connectionService_param); + if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string")); + RETURN_MM_NULL(); } - if (!userOptions_param) { - ZEPHIR_INIT_VAR(&userOptions); - array_init(&userOptions); + if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) { + zephir_get_strval(&connectionService, connectionService_param); } else { - zephir_get_arrval(&userOptions, userOptions_param); - } - _0 = Z_TYPE_P(entity) != IS_NULL; - if (_0) { - _0 = Z_TYPE_P(entity) != IS_OBJECT; - } - if (UNEXPECTED(_0)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_forms_exception_ce, "The base entity is not valid", "phalcon/Forms/Form.zep", 98); - return; + ZEPHIR_INIT_VAR(&connectionService); } - zephir_update_property_zval(this_ptr, ZEND_STRL("entity"), entity); - zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &userOptions); - ZEPHIR_INIT_VAR(&_1); - object_init_ex(&_1, phalcon_html_attributes_ce); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 23); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "setwriteconnectionservice", NULL, 0, this_ptr, &connectionService); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &_1); - if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("initialize")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0, entity, &userOptions); - zephir_check_call_status(); - } ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Forms_Form, add) +static PHP_METHOD(Phalcon_Mvc_Model, skipOperation) +{ + zval *skip_param = NULL, __$true, __$false; + zend_bool skip; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(skip) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &skip_param); + if (skip) { + zephir_update_property_zval(this_ptr, ZEND_STRL("skipped"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("skipped"), &__$false); + } +} + +static PHP_METHOD(Phalcon_Mvc_Model, sum) { - zend_string *_9$$5; - zend_ulong _8$$5; - zval elements; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool type, _0, _3; - zval position; - zval *element, element_sub, *position_param = NULL, *type_param = NULL, name, key, value, _1, _4, _2$$3, _5$$5, *_6$$5, _7$$5; - zval *this_ptr = getThis(); + zval *parameters = NULL, parameters_sub, __$null, _0, _1; - ZVAL_UNDEF(&element_sub); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); + ZVAL_UNDEF(¶meters_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$5); - ZVAL_UNDEF(&position); - ZVAL_UNDEF(&elements); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_OBJECT_OF_CLASS(element, phalcon_forms_element_elementinterface_ce) + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(position) - Z_PARAM_BOOL_OR_NULL(type, is_null_true) + Z_PARAM_ZVAL_OR_NULL(parameters) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &element, &position_param, &type_param); - if (!position_param) { - ZEPHIR_INIT_VAR(&position); - } else { - zephir_get_strval(&position, position_param); + zephir_fetch_params(1, 0, 1, ¶meters); + if (!parameters) { + parameters = ¶meters_sub; + parameters = &__$null; } - if (!type_param) { - type = 0; - } else { - } - ZEPHIR_CALL_METHOD(&name, element, "getname", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, element, "setform", NULL, 0, this_ptr); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "SUM"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "sumatory"); + ZEPHIR_RETURN_CALL_SELF("groupresult", NULL, 0, &_0, &_1, parameters); zephir_check_call_status(); - _0 = (zephir_method_exists_ex(element, ZEND_STRL("settagfactory")) == SUCCESS); - if (_0) { - zephir_read_property(&_1, this_ptr, ZEND_STRL("tagFactory"), PH_NOISY_CC | PH_READONLY); - _0 = Z_TYPE_P(&_1) != IS_NULL; - } - if (_0) { - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("tagFactory"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, element, "settagfactory", NULL, 0, &_2$$3); - zephir_check_call_status(); - } - _3 = ZEPHIR_IS_NULL(&position); - if (!(_3)) { - zephir_read_property(&_4, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - _3 = ZEPHIR_IS_EMPTY(&_4); - } - if (_3) { - zephir_update_property_array(this_ptr, SL("elements"), &name, element); - } else { - ZEPHIR_INIT_VAR(&elements); - array_init(&elements); - zephir_read_property(&_5$$5, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_5$$5, 0, "phalcon/Forms/Form.zep", 176); - if (Z_TYPE_P(&_5$$5) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_5$$5), _8$$5, _9$$5, _6$$5) - { - ZEPHIR_INIT_NVAR(&key); - if (_9$$5 != NULL) { - ZVAL_STR_COPY(&key, _9$$5); - } else { - ZVAL_LONG(&key, _8$$5); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _6$$5); - if (ZEPHIR_IS_EQUAL(&key, &position)) { - if (type) { - zephir_array_update_zval(&elements, &name, element, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&elements, &key, &value, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&elements, &key, &value, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&elements, &name, element, PH_COPY | PH_SEPARATE); - } - } else { - zephir_array_update_zval(&elements, &key, &value, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_5$$5, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_7$$5, &_5$$5, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_7$$5)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &_5$$5, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &_5$$5, "current", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_EQUAL(&key, &position)) { - if (type) { - zephir_array_update_zval(&elements, &name, element, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&elements, &key, &value, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&elements, &key, &value, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&elements, &name, element, PH_COPY | PH_SEPARATE); - } - } else { - zephir_array_update_zval(&elements, &key, &value, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &_5$$5, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - zephir_update_property_zval(this_ptr, ZEND_STRL("elements"), &elements); - } - RETURN_THIS(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Forms_Form, bind) +static PHP_METHOD(Phalcon_Mvc_Model, toArray) { - zend_bool _7$$5, _16$$15; - zend_string *_5; - zend_ulong _4; - zval method; + zend_bool _3$$4, _11$$3, _13$$3, _16$$15, _22$$14, _24$$14; + zval data; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_8 = NULL, *_14 = NULL; + zephir_fcall_cache_entry *_5 = NULL, *_9 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *data_param = NULL, *entity = NULL, entity_sub, *whitelist_param = NULL, __$null, filter, key, value, element, filters, container, filteredValue, _0, *_2, _3, _1$$4, _6$$5, _9$$9, _10$$9, _11$$11, _12$$11, _13$$11, _15$$15, _17$$19, _18$$19, _19$$21, _20$$21, _21$$21; - zval data, whitelist, assignData, filteredData; + zval *columns = NULL, columns_sub, *useGetter = NULL, useGetter_sub, __$null, __$true, attribute, attributeField, columnMap, metaData, method, _0, *_1, _2, _4$$5, _6$$7, _7$$7, _8$$7, _10$$3, _12$$3, _14$$11, _15$$12, _17$$16, _18$$18, _19$$18, _20$$18, _21$$14, _23$$14, _25$$22, _26$$23; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&whitelist); - ZVAL_UNDEF(&assignData); - ZVAL_UNDEF(&filteredData); - ZVAL_UNDEF(&entity_sub); + ZVAL_UNDEF(&columns_sub); + ZVAL_UNDEF(&useGetter_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&filter); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&filters); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&filteredValue); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_9$$9); - ZVAL_UNDEF(&_10$$9); - ZVAL_UNDEF(&_11$$11); - ZVAL_UNDEF(&_12$$11); - ZVAL_UNDEF(&_13$$11); - ZVAL_UNDEF(&_15$$15); - ZVAL_UNDEF(&_17$$19); - ZVAL_UNDEF(&_18$$19); - ZVAL_UNDEF(&_19$$21); - ZVAL_UNDEF(&_20$$21); - ZVAL_UNDEF(&_21$$21); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&attributeField); + ZVAL_UNDEF(&columnMap); + ZVAL_UNDEF(&metaData); ZVAL_UNDEF(&method); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_7$$7); + ZVAL_UNDEF(&_8$$7); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_12$$3); + ZVAL_UNDEF(&_14$$11); + ZVAL_UNDEF(&_15$$12); + ZVAL_UNDEF(&_17$$16); + ZVAL_UNDEF(&_18$$18); + ZVAL_UNDEF(&_19$$18); + ZVAL_UNDEF(&_20$$18); + ZVAL_UNDEF(&_21$$14); + ZVAL_UNDEF(&_23$$14); + ZVAL_UNDEF(&_25$$22); + ZVAL_UNDEF(&_26$$23); + ZVAL_UNDEF(&data); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ARRAY(data) + ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(entity) - Z_PARAM_ARRAY(whitelist) + Z_PARAM_ZVAL_OR_NULL(columns) + Z_PARAM_ZVAL(useGetter) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &data_param, &entity, &whitelist_param); - ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); - if (!entity) { - entity = &entity_sub; - ZEPHIR_CPY_WRT(entity, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(entity); - } - if (!whitelist_param) { - ZEPHIR_INIT_VAR(&whitelist); - array_init(&whitelist); - } else { - zephir_get_arrval(&whitelist, whitelist_param); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(ZEPHIR_IS_EMPTY(&_0))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_forms_exception_ce, "There are no elements in the form", "phalcon/Forms/Form.zep", 195); - return; + zephir_fetch_params(1, 0, 2, &columns, &useGetter); + if (!columns) { + columns = &columns_sub; + columns = &__$null; } - if (ZEPHIR_IS_EMPTY(&whitelist)) { - zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("whitelist"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&whitelist, &_1$$4); + if (!useGetter) { + useGetter = &useGetter_sub; + useGetter = &__$true; } - ZEPHIR_INIT_VAR(&filter); - ZVAL_NULL(&filter); - ZEPHIR_INIT_VAR(&assignData); - array_init(&assignData); - ZEPHIR_INIT_VAR(&filteredData); - array_init(&filteredData); - zephir_is_iterable(&data, 0, "phalcon/Forms/Form.zep", 269); - if (Z_TYPE_P(&data) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _4, _5, _2) + ZEPHIR_INIT_VAR(&data); + array_init(&data); + ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", NULL, 0, this_ptr); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, &metaData, "getattributes", NULL, 0, this_ptr); + zephir_check_call_status(); + zephir_is_iterable(&_0, 0, "phalcon/Mvc/Model.zep", 3345); + if (Z_TYPE_P(&_0) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) { - ZEPHIR_INIT_NVAR(&key); - if (_5 != NULL) { - ZVAL_STR_COPY(&key, _5); - } else { - ZVAL_LONG(&key, _4); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _2); - ZEPHIR_OBS_NVAR(&element); - zephir_read_property(&_6$$5, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&element, &_6$$5, &key, 0))) { - continue; - } - _7$$5 = !(ZEPHIR_IS_EMPTY(&whitelist)); - if (_7$$5) { - _7$$5 = !(zephir_fast_in_array(&key, &whitelist)); - } - if (_7$$5) { - continue; - } - ZEPHIR_CALL_METHOD(&filters, &element, "getfilters", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&filters)) { - if (Z_TYPE_P(&filter) != IS_OBJECT) { - ZEPHIR_CALL_METHOD(&container, this_ptr, "getdi", &_8, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_10$$9); - ZVAL_STRING(&_10$$9, "filter"); - ZEPHIR_CALL_METHOD(&_9$$9, &container, "getshared", NULL, 0, &_10$$9); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&filter, &_9$$9); + ZEPHIR_INIT_NVAR(&attribute); + ZVAL_COPY(&attribute, _1); + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + _3$$4 = !(zephir_array_isset(&columnMap, &attribute)); + if (_3$$4) { + _3$$4 = ZEPHIR_GLOBAL(orm).case_insensitive_column_map; } - ZEPHIR_CALL_METHOD(&filteredValue, &filter, "sanitize", NULL, 0, &value, &filters); - zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&filteredValue, &value); - } - zephir_array_update_zval(&assignData, &key, &value, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&filteredData, &key, &filteredValue, PH_COPY | PH_SEPARATE); - if (Z_TYPE_P(entity) != IS_NULL) { - ZEPHIR_INIT_NVAR(&_11$$11); - zephir_camelize(&_11$$11, &key, NULL ); - ZEPHIR_INIT_NVAR(&_12$$11); - ZEPHIR_CONCAT_SV(&_12$$11, "set", &_11$$11); - zephir_get_strval(&method, &_12$$11); - if ((zephir_method_exists(entity, &method) == SUCCESS)) { - ZEPHIR_CALL_METHOD_ZVAL(NULL, entity, &method, NULL, 0, &filteredValue); + if (_3$$4) { + ZEPHIR_CALL_SELF(&_4$$5, "caseinsensitivecolumnmap", &_5, 420, &columnMap, &attribute); zephir_check_call_status(); + ZEPHIR_CPY_WRT(&attribute, &_4$$5); + } + ZEPHIR_OBS_NVAR(&attributeField); + if (!(zephir_array_isset_fetch(&attributeField, &columnMap, &attribute, 0))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_6$$7); + object_init_ex(&_6$$7, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_7$$7); + zephir_get_class(&_7$$7, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_8$$7); + ZEPHIR_CONCAT_SVSVS(&_8$$7, "Column '", &attribute, "' doesn't make part of the column map in '", &_7$$7, "'"); + ZEPHIR_CALL_METHOD(NULL, &_6$$7, "__construct", &_9, 33, &_8$$7); + zephir_check_call_status(); + zephir_throw_exception_debug(&_6$$7, "phalcon/Mvc/Model.zep", 3313); + ZEPHIR_MM_RESTORE(); + return; + } continue; } - if (!(ZEPHIR_GLOBAL(form).strict_entity_property_check)) { - zephir_update_property_zval_zval(entity, &key, &filteredValue); + } else { + ZEPHIR_CPY_WRT(&attributeField, &attribute); + } + if (Z_TYPE_P(columns) == IS_ARRAY) { + if (!(zephir_fast_in_array(&attributeField, columns))) { continue; } - ZEPHIR_CALL_FUNCTION(&_13$$11, "property_exists", &_14, 290, entity, &key); + } + ZEPHIR_INIT_NVAR(&_10$$3); + zephir_camelize(&_10$$3, &attributeField, NULL ); + ZEPHIR_INIT_NVAR(&method); + ZEPHIR_CONCAT_SV(&method, "get", &_10$$3); + _11$$3 = ZEPHIR_IS_TRUE_IDENTICAL(useGetter); + if (_11$$3) { + ZEPHIR_INIT_NVAR(&_12$$3); + ZVAL_STRING(&_12$$3, "getSource"); + _11$$3 = !ZEPHIR_IS_IDENTICAL(&_12$$3, &method); + } + _13$$3 = _11$$3; + if (_13$$3) { + _13$$3 = (zephir_method_exists(this_ptr, &method) == SUCCESS); + } + if (_13$$3) { + ZEPHIR_CALL_METHOD_ZVAL(&_14$$11, this_ptr, &method, NULL, 0); zephir_check_call_status(); - if (zephir_is_true(&_13$$11)) { - zephir_update_property_zval_zval(entity, &key, &filteredValue); - } + zephir_array_update_zval(&data, &attributeField, &_14$$11, PH_COPY | PH_SEPARATE); + } else if (zephir_isset_property_zval(this_ptr, &attributeField)) { + ZEPHIR_OBS_NVAR(&_15$$12); + zephir_read_property_zval(&_15$$12, this_ptr, &attributeField, PH_NOISY_CC); + zephir_array_update_zval(&data, &attributeField, &_15$$12, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&data, &attributeField, &__$null, PH_COPY | PH_SEPARATE); } } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_3, &data, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_3)) { + if (!zend_is_true(&_2)) { break; } - ZEPHIR_CALL_METHOD(&key, &data, "key", NULL, 0); + ZEPHIR_CALL_METHOD(&attribute, &_0, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&element); - zephir_read_property(&_15$$15, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&element, &_15$$15, &key, 0))) { - continue; - } - _16$$15 = !(ZEPHIR_IS_EMPTY(&whitelist)); - if (_16$$15) { - _16$$15 = !(zephir_fast_in_array(&key, &whitelist)); - } - if (_16$$15) { - continue; - } - ZEPHIR_CALL_METHOD(&filters, &element, "getfilters", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&filters)) { - if (Z_TYPE_P(&filter) != IS_OBJECT) { - ZEPHIR_CALL_METHOD(&container, this_ptr, "getdi", &_8, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_18$$19); - ZVAL_STRING(&_18$$19, "filter"); - ZEPHIR_CALL_METHOD(&_17$$19, &container, "getshared", NULL, 0, &_18$$19); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&filter, &_17$$19); + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + _16$$15 = !(zephir_array_isset(&columnMap, &attribute)); + if (_16$$15) { + _16$$15 = ZEPHIR_GLOBAL(orm).case_insensitive_column_map; } - ZEPHIR_CALL_METHOD(&filteredValue, &filter, "sanitize", NULL, 0, &value, &filters); - zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&filteredValue, &value); - } - zephir_array_update_zval(&assignData, &key, &value, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&filteredData, &key, &filteredValue, PH_COPY | PH_SEPARATE); - if (Z_TYPE_P(entity) != IS_NULL) { - ZEPHIR_INIT_NVAR(&_19$$21); - zephir_camelize(&_19$$21, &key, NULL ); - ZEPHIR_INIT_NVAR(&_20$$21); - ZEPHIR_CONCAT_SV(&_20$$21, "set", &_19$$21); - zephir_get_strval(&method, &_20$$21); - if ((zephir_method_exists(entity, &method) == SUCCESS)) { - ZEPHIR_CALL_METHOD_ZVAL(NULL, entity, &method, NULL, 0, &filteredValue); + if (_16$$15) { + ZEPHIR_CALL_SELF(&_17$$16, "caseinsensitivecolumnmap", &_5, 420, &columnMap, &attribute); zephir_check_call_status(); + ZEPHIR_CPY_WRT(&attribute, &_17$$16); + } + ZEPHIR_OBS_NVAR(&attributeField); + if (!(zephir_array_isset_fetch(&attributeField, &columnMap, &attribute, 0))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_18$$18); + object_init_ex(&_18$$18, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_19$$18); + zephir_get_class(&_19$$18, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_20$$18); + ZEPHIR_CONCAT_SVSVS(&_20$$18, "Column '", &attribute, "' doesn't make part of the column map in '", &_19$$18, "'"); + ZEPHIR_CALL_METHOD(NULL, &_18$$18, "__construct", &_9, 33, &_20$$18); + zephir_check_call_status(); + zephir_throw_exception_debug(&_18$$18, "phalcon/Mvc/Model.zep", 3313); + ZEPHIR_MM_RESTORE(); + return; + } continue; } - if (!(ZEPHIR_GLOBAL(form).strict_entity_property_check)) { - zephir_update_property_zval_zval(entity, &key, &filteredValue); + } else { + ZEPHIR_CPY_WRT(&attributeField, &attribute); + } + if (Z_TYPE_P(columns) == IS_ARRAY) { + if (!(zephir_fast_in_array(&attributeField, columns))) { continue; } - ZEPHIR_CALL_FUNCTION(&_21$$21, "property_exists", &_14, 290, entity, &key); + } + ZEPHIR_INIT_NVAR(&_21$$14); + zephir_camelize(&_21$$14, &attributeField, NULL ); + ZEPHIR_INIT_NVAR(&method); + ZEPHIR_CONCAT_SV(&method, "get", &_21$$14); + _22$$14 = ZEPHIR_IS_TRUE_IDENTICAL(useGetter); + if (_22$$14) { + ZEPHIR_INIT_NVAR(&_23$$14); + ZVAL_STRING(&_23$$14, "getSource"); + _22$$14 = !ZEPHIR_IS_IDENTICAL(&_23$$14, &method); + } + _24$$14 = _22$$14; + if (_24$$14) { + _24$$14 = (zephir_method_exists(this_ptr, &method) == SUCCESS); + } + if (_24$$14) { + ZEPHIR_CALL_METHOD_ZVAL(&_25$$22, this_ptr, &method, NULL, 0); zephir_check_call_status(); - if (zephir_is_true(&_21$$21)) { - zephir_update_property_zval_zval(entity, &key, &filteredValue); - } + zephir_array_update_zval(&data, &attributeField, &_25$$22, PH_COPY | PH_SEPARATE); + } else if (zephir_isset_property_zval(this_ptr, &attributeField)) { + ZEPHIR_OBS_NVAR(&_26$$23); + zephir_read_property_zval(&_26$$23, this_ptr, &attributeField, PH_NOISY_CC); + zephir_array_update_zval(&data, &attributeField, &_26$$23, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&data, &attributeField, &__$null, PH_COPY | PH_SEPARATE); } - ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - zephir_update_property_zval(this_ptr, ZEND_STRL("data"), &assignData); - zephir_update_property_zval(this_ptr, ZEND_STRL("filteredData"), &filteredData); - RETURN_THIS(); + ZEPHIR_INIT_NVAR(&attribute); + RETURN_CTOR(&data); } -static PHP_METHOD(Phalcon_Forms_Form, clear) +static PHP_METHOD(Phalcon_Mvc_Model, update) { + zval _3$$4, _5$$4; + zval metaData, _0, _1$$3, _2$$3, _4$$4, _6$$4, _7$$4, _8$$4, _9$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *fields = NULL, fields_sub, __$null, elements, element, data, field, _0, *_1$$3, _2$$3, _3$$4, _4$$4, _5$$5, _6$$5, _7$$7, *_8$$6, _9$$6, _10$$10, _11$$10, _12$$13, _13$$13; zval *this_ptr = getThis(); - ZVAL_UNDEF(&fields_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&elements); - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&field); + ZVAL_UNDEF(&metaData); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$4); ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_7$$7); - ZVAL_UNDEF(&_9$$6); - ZVAL_UNDEF(&_10$$10); - ZVAL_UNDEF(&_11$$10); - ZVAL_UNDEF(&_12$$13); - ZVAL_UNDEF(&_13$$13); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(fields) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$4); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$4); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &fields); - if (!fields) { - fields = &fields_sub; - ZEPHIR_CPY_WRT(fields, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(fields); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&data, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&elements, &_0); - if (Z_TYPE_P(fields) == IS_NULL) { - ZEPHIR_INIT_NVAR(&data); - array_init(&data); - zephir_is_iterable(&elements, 0, "phalcon/Forms/Form.zep", 298); - if (Z_TYPE_P(&elements) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&elements), _1$$3) - { - ZEPHIR_INIT_NVAR(&element); - ZVAL_COPY(&element, _1$$3); - ZEPHIR_CALL_METHOD(&_3$$4, &element, "getdefault", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$4, &element, "getname", NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&data, &_4$$4, &_3$$4, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &elements, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2$$3, &elements, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&element, &elements, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_5$$5, &element, "getdefault", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_6$$5, &element, "getname", NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&data, &_6$$5, &_5$$5, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &elements, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&element); - } else { - if (Z_TYPE_P(fields) != IS_ARRAY) { - ZEPHIR_INIT_VAR(&_7$$7); - zephir_create_array(&_7$$7, 1, 0); - zephir_array_fast_append(&_7$$7, fields); - ZEPHIR_CPY_WRT(fields, &_7$$7); - } - zephir_is_iterable(fields, 0, "phalcon/Forms/Form.zep", 312); - if (Z_TYPE_P(fields) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(fields), _8$$6) - { - ZEPHIR_INIT_NVAR(&field); - ZVAL_COPY(&field, _8$$6); - if (zephir_array_isset(&data, &field)) { - zephir_array_unset(&data, &field, PH_SEPARATE); - } - ZEPHIR_OBS_NVAR(&element); - if (zephir_array_isset_fetch(&element, &elements, &field, 0)) { - ZEPHIR_CALL_METHOD(&_10$$10, &element, "getdefault", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_11$$10, &element, "getname", NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&data, &_11$$10, &_10$$10, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, fields, "rewind", NULL, 0); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("dirtyState"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_0)) { + ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "getreadconnection", NULL, 431); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "has", NULL, 0, &metaData, &_2$$3); + zephir_check_call_status(); + if (!(zephir_is_true(&_1$$3))) { + ZEPHIR_INIT_VAR(&_3$$4); + zephir_create_array(&_3$$4, 1, 0); + ZEPHIR_INIT_VAR(&_4$$4); + object_init_ex(&_4$$4, phalcon_messages_message_ce); + ZEPHIR_INIT_VAR(&_5$$4); + zephir_create_array(&_5$$4, 1, 0); + ZEPHIR_INIT_VAR(&_6$$4); + zephir_get_class(&_6$$4, this_ptr, 0); + zephir_array_update_string(&_5$$4, SL("model"), &_6$$4, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_6$$4); + ZVAL_STRING(&_6$$4, "Record cannot be updated because it does not exist"); + ZVAL_NULL(&_7$$4); + ZEPHIR_INIT_VAR(&_8$$4); + ZVAL_STRING(&_8$$4, "InvalidUpdateAttempt"); + ZVAL_LONG(&_9$$4, 0); + ZEPHIR_CALL_METHOD(NULL, &_4$$4, "__construct", NULL, 6, &_6$$4, &_7$$4, &_8$$4, &_9$$4, &_5$$4); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_9$$6, fields, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_9$$6)) { - break; - } - ZEPHIR_CALL_METHOD(&field, fields, "current", NULL, 0); - zephir_check_call_status(); - if (zephir_array_isset(&data, &field)) { - zephir_array_unset(&data, &field, PH_SEPARATE); - } - ZEPHIR_OBS_NVAR(&element); - if (zephir_array_isset_fetch(&element, &elements, &field, 0)) { - ZEPHIR_CALL_METHOD(&_12$$13, &element, "getdefault", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_13$$13, &element, "getname", NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&data, &_13$$13, &_12$$13, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, fields, "next", NULL, 0); - zephir_check_call_status(); - } + zephir_array_fast_append(&_3$$4, &_4$$4); + zephir_update_property_zval(this_ptr, ZEND_STRL("errorMessages"), &_3$$4); + RETURN_MM_BOOL(0); } - ZEPHIR_INIT_NVAR(&field); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("data"), &data); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Forms_Form, count) -{ - zval _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - RETURN_LONG(zephir_fast_count_int(&_0)); -} - -static PHP_METHOD(Phalcon_Forms_Form, current) -{ - zval element, _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_memory_observe(&element); - zephir_read_property(&_0, this_ptr, ZEND_STRL("elementsIndexed"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_1, this_ptr, ZEND_STRL("position"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&element, &_0, &_1, 0))) { - RETURN_MM_BOOL(0); } - RETURN_CCTOR(&element); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "save", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Forms_Form, get) +static PHP_METHOD(Phalcon_Mvc_Model, writeAttribute) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, element, _0, _1$$3; - zval name, _2$$3; + zval *attribute_param = NULL, *value, value_sub; + zval attribute; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(attribute) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + zephir_fetch_params(1, 2, 0, &attribute_param, &value); + if (UNEXPECTED(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + if (EXPECTED(Z_TYPE_P(attribute_param) == IS_STRING)) { + zephir_get_strval(&attribute, attribute_param); } else { - ZEPHIR_INIT_VAR(&name); - } - zephir_memory_observe(&element); - zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(!(zephir_array_isset_fetch(&element, &_0, &name, 0)))) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_forms_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - ZEPHIR_CONCAT_SVS(&_2$$3, "Element with ID=", &name, " is not part of the form"); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Forms/Form.zep", 351); - ZEPHIR_MM_RESTORE(); - return; + ZEPHIR_INIT_VAR(&attribute); } - RETURN_CCTOR(&element); + zephir_update_property_zval_zval(this_ptr, &attribute, value); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Forms_Form, getAction) +static PHP_METHOD(Phalcon_Mvc_Model, checkForeignKeysRestrict) { - zval _3; - zval _0, _1, _2; + zend_string *_9$$7, *_33$$26; + zend_ulong _8$$7, _32$$26; + zend_bool error = 0, validateWithNulls = 0, _15$$3, _39$$22; + zval conditions, _17$$3, _21$$18, _41$$22, _45$$37; + zval manager, belongsTo, foreignKey, relation, position, bindParams, extraConditions, message, fields, referencedFields, field, referencedModel, value, allowNulls, _0, *_1, _2, _3$$5, _4$$3, _16$$3, _18$$3, *_6$$7, _7$$7, _10$$8, _11$$8, _12$$10, _13$$10, _14$$12, _19$$20, _20$$18, _22$$18, _23$$18, _24$$18, _27$$24, _28$$22, _40$$22, _42$$22, *_30$$26, _31$$26, _34$$27, _35$$27, _36$$29, _37$$29, _38$$31, _43$$39, _44$$37, _46$$37, _47$$37, _48$$37, _49$$42; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zephir_fcall_cache_entry *_5 = NULL, *_25 = NULL, *_26 = NULL, *_29 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, action = 0, numberNull = 0; zval *this_ptr = getThis(); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&belongsTo); + ZVAL_UNDEF(&foreignKey); + ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&position); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&extraConditions); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&fields); + ZVAL_UNDEF(&referencedFields); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&referencedModel); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&allowNulls); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_16$$3); + ZVAL_UNDEF(&_18$$3); + ZVAL_UNDEF(&_7$$7); + ZVAL_UNDEF(&_10$$8); + ZVAL_UNDEF(&_11$$8); + ZVAL_UNDEF(&_12$$10); + ZVAL_UNDEF(&_13$$10); + ZVAL_UNDEF(&_14$$12); + ZVAL_UNDEF(&_19$$20); + ZVAL_UNDEF(&_20$$18); + ZVAL_UNDEF(&_22$$18); + ZVAL_UNDEF(&_23$$18); + ZVAL_UNDEF(&_24$$18); + ZVAL_UNDEF(&_27$$24); + ZVAL_UNDEF(&_28$$22); + ZVAL_UNDEF(&_40$$22); + ZVAL_UNDEF(&_42$$22); + ZVAL_UNDEF(&_31$$26); + ZVAL_UNDEF(&_34$$27); + ZVAL_UNDEF(&_35$$27); + ZVAL_UNDEF(&_36$$29); + ZVAL_UNDEF(&_37$$29); + ZVAL_UNDEF(&_38$$31); + ZVAL_UNDEF(&_43$$39); + ZVAL_UNDEF(&_44$$37); + ZVAL_UNDEF(&_46$$37); + ZVAL_UNDEF(&_47$$37); + ZVAL_UNDEF(&_48$$37); + ZVAL_UNDEF(&_49$$42); + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(&_17$$3); + ZVAL_UNDEF(&_21$$18); + ZVAL_UNDEF(&_41$$22); + ZVAL_UNDEF(&_45$$37); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getattributes", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "action"); - ZEPHIR_CALL_METHOD(&_1, &_0, "get", NULL, 0, &_2); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&manager, &_0); + ZEPHIR_CALL_METHOD(&belongsTo, &manager, "getbelongsto", NULL, 0, this_ptr); zephir_check_call_status(); - zephir_cast_to_string(&_3, &_1); - RETURN_CTOR(&_3); -} - -static PHP_METHOD(Phalcon_Forms_Form, getAttributes) -{ - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(Z_TYPE_P(&_0) == IS_NULL)) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_html_attributes_ce); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 23); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &_1$$3); - } - RETURN_MM_MEMBER(getThis(), "attributes"); -} - -static PHP_METHOD(Phalcon_Forms_Form, getElements) -{ - - RETURN_MEMBER(getThis(), "elements"); -} - -static PHP_METHOD(Phalcon_Forms_Form, getEntity) -{ - - RETURN_MEMBER(getThis(), "entity"); -} - -static PHP_METHOD(Phalcon_Forms_Form, getFilteredValue) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, filteredData, value, _0; - zval name; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&filteredData); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + error = 0; + zephir_is_iterable(&belongsTo, 0, "phalcon/Mvc/Model.zep", 3574); + if (Z_TYPE_P(&belongsTo) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&belongsTo), _1) + { + ZEPHIR_INIT_NVAR(&relation); + ZVAL_COPY(&relation, _1); + validateWithNulls = 0; + ZEPHIR_CALL_METHOD(&foreignKey, &relation, "getforeignkey", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&foreignKey)) { + continue; + } + action = 1; + if (zephir_array_isset_string(&foreignKey, SL("action"))) { + ZEPHIR_OBS_NVAR(&_3$$5); + zephir_array_fetch_string(&_3$$5, &foreignKey, SL("action"), PH_NOISY, "phalcon/Mvc/Model.zep", 3460); + action = zephir_get_intval(&_3$$5); + } + if (action != 1) { + continue; + } + ZEPHIR_CALL_METHOD(&_4$$3, &relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&referencedModel, &manager, "load", &_5, 0, &_4$$3); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&conditions); + array_init(&conditions); + ZEPHIR_INIT_NVAR(&bindParams); + array_init(&bindParams); + numberNull = 0; + ZEPHIR_CALL_METHOD(&fields, &relation, "getfields", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&referencedFields, &relation, "getreferencedfields", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&fields) == IS_ARRAY) { + zephir_is_iterable(&fields, 0, "phalcon/Mvc/Model.zep", 3503); + if (Z_TYPE_P(&fields) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&fields), _8$$7, _9$$7, _6$$7) + { + ZEPHIR_INIT_NVAR(&position); + if (_9$$7 != NULL) { + ZVAL_STR_COPY(&position, _9$$7); + } else { + ZVAL_LONG(&position, _8$$7); + } + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _6$$7); + ZEPHIR_OBS_NVAR(&value); + zephir_fetch_property_zval(&value, this_ptr, &field, PH_SILENT_CC); + zephir_array_fetch(&_10$$8, &referencedFields, &position, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3495); + ZEPHIR_INIT_NVAR(&_11$$8); + ZEPHIR_CONCAT_SVSV(&_11$$8, "[", &_10$$8, "] = ?", &position); + zephir_array_append(&conditions, &_11$$8, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3495); + zephir_array_append(&bindParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3496); + if (Z_TYPE_P(&value) == IS_NULL) { + numberNull++; + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_7$$7, &fields, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_7$$7)) { + break; + } + ZEPHIR_CALL_METHOD(&position, &fields, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&field, &fields, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&value); + zephir_fetch_property_zval(&value, this_ptr, &field, PH_SILENT_CC); + zephir_array_fetch(&_12$$10, &referencedFields, &position, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3495); + ZEPHIR_INIT_NVAR(&_13$$10); + ZEPHIR_CONCAT_SVSV(&_13$$10, "[", &_12$$10, "] = ?", &position); + zephir_array_append(&conditions, &_13$$10, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3495); + zephir_array_append(&bindParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3496); + if (Z_TYPE_P(&value) == IS_NULL) { + numberNull++; + } + ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&field); + ZEPHIR_INIT_NVAR(&position); + validateWithNulls = numberNull == zephir_fast_count_int(&fields); + } else { + ZEPHIR_OBS_NVAR(&value); + zephir_fetch_property_zval(&value, this_ptr, &fields, PH_SILENT_CC); + ZEPHIR_INIT_NVAR(&_14$$12); + ZEPHIR_CONCAT_SVS(&_14$$12, "[", &referencedFields, "] = ?0"); + zephir_array_append(&conditions, &_14$$12, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3507); + zephir_array_append(&bindParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3508); + if (Z_TYPE_P(&value) == IS_NULL) { + validateWithNulls = 1; + } + } + ZEPHIR_OBS_NVAR(&extraConditions); + if (zephir_array_isset_string_fetch(&extraConditions, &foreignKey, SL("conditions"), 0)) { + zephir_array_append(&conditions, &extraConditions, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3519); + } + if (validateWithNulls) { + ZEPHIR_OBS_NVAR(&allowNulls); + if (zephir_array_isset_string_fetch(&allowNulls, &foreignKey, SL("allowNulls"), 0)) { + validateWithNulls = zephir_get_boolval(&allowNulls); + } else { + validateWithNulls = 0; + } + } + _15$$3 = !validateWithNulls; + if (_15$$3) { + ZEPHIR_INIT_NVAR(&_17$$3); + zephir_create_array(&_17$$3, 2, 0); + ZEPHIR_INIT_NVAR(&_18$$3); + zephir_fast_join_str(&_18$$3, SL(" AND "), &conditions); + zephir_array_fast_append(&_17$$3, &_18$$3); + zephir_array_update_string(&_17$$3, SL("bind"), &bindParams, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_16$$3, &referencedModel, "count", NULL, 0, &_17$$3); + zephir_check_call_status(); + _15$$3 = !zephir_is_true(&_16$$3); + } + if (_15$$3) { + ZEPHIR_OBS_NVAR(&message); + if (!(zephir_array_isset_string_fetch(&message, &foreignKey, SL("message"), 0))) { + ZEPHIR_INIT_NVAR(&message); + if (Z_TYPE_P(&fields) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&_19$$20); + zephir_fast_join_str(&_19$$20, SL(", "), &fields); + ZEPHIR_CONCAT_SVS(&message, "Value of fields \"", &_19$$20, "\" does not exist on referenced table"); + } else { + ZEPHIR_CONCAT_SVS(&message, "Value of field \"", &fields, "\" does not exist on referenced table"); + } + } + ZEPHIR_INIT_NVAR(&_20$$18); + object_init_ex(&_20$$18, phalcon_messages_message_ce); + ZEPHIR_INIT_NVAR(&_21$$18); + zephir_create_array(&_21$$18, 2, 0); + ZEPHIR_INIT_NVAR(&_22$$18); + zephir_get_class(&_22$$18, this_ptr, 0); + zephir_array_update_string(&_21$$18, SL("model"), &_22$$18, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_23$$18, &relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + zephir_array_update_string(&_21$$18, SL("referenceModel"), &_23$$18, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_22$$18); + ZVAL_STRING(&_22$$18, "ConstraintViolation"); + ZVAL_LONG(&_24$$18, 0); + ZEPHIR_CALL_METHOD(NULL, &_20$$18, "__construct", &_25, 6, &message, &fields, &_22$$18, &_24$$18, &_21$$18); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_26, 0, &_20$$18); + zephir_check_call_status(); + error = 1; + break; + } + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_INIT_VAR(&name); + ZEPHIR_CALL_METHOD(NULL, &belongsTo, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &belongsTo, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&relation, &belongsTo, "current", NULL, 0); + zephir_check_call_status(); + validateWithNulls = 0; + ZEPHIR_CALL_METHOD(&foreignKey, &relation, "getforeignkey", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&foreignKey)) { + continue; + } + action = 1; + if (zephir_array_isset_string(&foreignKey, SL("action"))) { + ZEPHIR_OBS_NVAR(&_27$$24); + zephir_array_fetch_string(&_27$$24, &foreignKey, SL("action"), PH_NOISY, "phalcon/Mvc/Model.zep", 3460); + action = zephir_get_intval(&_27$$24); + } + if (action != 1) { + continue; + } + ZEPHIR_CALL_METHOD(&_28$$22, &relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&referencedModel, &manager, "load", &_29, 0, &_28$$22); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&conditions); + array_init(&conditions); + ZEPHIR_INIT_NVAR(&bindParams); + array_init(&bindParams); + numberNull = 0; + ZEPHIR_CALL_METHOD(&fields, &relation, "getfields", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&referencedFields, &relation, "getreferencedfields", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&fields) == IS_ARRAY) { + zephir_is_iterable(&fields, 0, "phalcon/Mvc/Model.zep", 3503); + if (Z_TYPE_P(&fields) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&fields), _32$$26, _33$$26, _30$$26) + { + ZEPHIR_INIT_NVAR(&position); + if (_33$$26 != NULL) { + ZVAL_STR_COPY(&position, _33$$26); + } else { + ZVAL_LONG(&position, _32$$26); + } + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _30$$26); + ZEPHIR_OBS_NVAR(&value); + zephir_fetch_property_zval(&value, this_ptr, &field, PH_SILENT_CC); + zephir_array_fetch(&_34$$27, &referencedFields, &position, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3495); + ZEPHIR_INIT_NVAR(&_35$$27); + ZEPHIR_CONCAT_SVSV(&_35$$27, "[", &_34$$27, "] = ?", &position); + zephir_array_append(&conditions, &_35$$27, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3495); + zephir_array_append(&bindParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3496); + if (Z_TYPE_P(&value) == IS_NULL) { + numberNull++; + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_31$$26, &fields, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_31$$26)) { + break; + } + ZEPHIR_CALL_METHOD(&position, &fields, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&field, &fields, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&value); + zephir_fetch_property_zval(&value, this_ptr, &field, PH_SILENT_CC); + zephir_array_fetch(&_36$$29, &referencedFields, &position, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3495); + ZEPHIR_INIT_NVAR(&_37$$29); + ZEPHIR_CONCAT_SVSV(&_37$$29, "[", &_36$$29, "] = ?", &position); + zephir_array_append(&conditions, &_37$$29, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3495); + zephir_array_append(&bindParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3496); + if (Z_TYPE_P(&value) == IS_NULL) { + numberNull++; + } + ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&field); + ZEPHIR_INIT_NVAR(&position); + validateWithNulls = numberNull == zephir_fast_count_int(&fields); + } else { + ZEPHIR_OBS_NVAR(&value); + zephir_fetch_property_zval(&value, this_ptr, &fields, PH_SILENT_CC); + ZEPHIR_INIT_NVAR(&_38$$31); + ZEPHIR_CONCAT_SVS(&_38$$31, "[", &referencedFields, "] = ?0"); + zephir_array_append(&conditions, &_38$$31, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3507); + zephir_array_append(&bindParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3508); + if (Z_TYPE_P(&value) == IS_NULL) { + validateWithNulls = 1; + } + } + ZEPHIR_OBS_NVAR(&extraConditions); + if (zephir_array_isset_string_fetch(&extraConditions, &foreignKey, SL("conditions"), 0)) { + zephir_array_append(&conditions, &extraConditions, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3519); + } + if (validateWithNulls) { + ZEPHIR_OBS_NVAR(&allowNulls); + if (zephir_array_isset_string_fetch(&allowNulls, &foreignKey, SL("allowNulls"), 0)) { + validateWithNulls = zephir_get_boolval(&allowNulls); + } else { + validateWithNulls = 0; + } + } + _39$$22 = !validateWithNulls; + if (_39$$22) { + ZEPHIR_INIT_NVAR(&_41$$22); + zephir_create_array(&_41$$22, 2, 0); + ZEPHIR_INIT_NVAR(&_42$$22); + zephir_fast_join_str(&_42$$22, SL(" AND "), &conditions); + zephir_array_fast_append(&_41$$22, &_42$$22); + zephir_array_update_string(&_41$$22, SL("bind"), &bindParams, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_40$$22, &referencedModel, "count", NULL, 0, &_41$$22); + zephir_check_call_status(); + _39$$22 = !zephir_is_true(&_40$$22); + } + if (_39$$22) { + ZEPHIR_OBS_NVAR(&message); + if (!(zephir_array_isset_string_fetch(&message, &foreignKey, SL("message"), 0))) { + ZEPHIR_INIT_NVAR(&message); + if (Z_TYPE_P(&fields) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&_43$$39); + zephir_fast_join_str(&_43$$39, SL(", "), &fields); + ZEPHIR_CONCAT_SVS(&message, "Value of fields \"", &_43$$39, "\" does not exist on referenced table"); + } else { + ZEPHIR_CONCAT_SVS(&message, "Value of field \"", &fields, "\" does not exist on referenced table"); + } + } + ZEPHIR_INIT_NVAR(&_44$$37); + object_init_ex(&_44$$37, phalcon_messages_message_ce); + ZEPHIR_INIT_NVAR(&_45$$37); + zephir_create_array(&_45$$37, 2, 0); + ZEPHIR_INIT_NVAR(&_46$$37); + zephir_get_class(&_46$$37, this_ptr, 0); + zephir_array_update_string(&_45$$37, SL("model"), &_46$$37, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_47$$37, &relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + zephir_array_update_string(&_45$$37, SL("referenceModel"), &_47$$37, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_46$$37); + ZVAL_STRING(&_46$$37, "ConstraintViolation"); + ZVAL_LONG(&_48$$37, 0); + ZEPHIR_CALL_METHOD(NULL, &_44$$37, "__construct", &_25, 6, &message, &fields, &_46$$37, &_48$$37, &_45$$37); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_26, 0, &_44$$37); + zephir_check_call_status(); + error = 1; + break; + } + ZEPHIR_CALL_METHOD(NULL, &belongsTo, "next", NULL, 0); + zephir_check_call_status(); + } } - zephir_read_property(&_0, this_ptr, ZEND_STRL("filteredData"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&filteredData, &_0); - if (Z_TYPE_P(&filteredData) == IS_ARRAY) { - zephir_memory_observe(&value); - if (zephir_array_isset_fetch(&value, &filteredData, &name, 0)) { - RETURN_CCTOR(&value); + ZEPHIR_INIT_NVAR(&relation); + if (error) { + if (ZEPHIR_GLOBAL(orm).events) { + ZEPHIR_INIT_VAR(&_49$$42); + ZVAL_STRING(&_49$$42, "onValidationFails"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_49$$42); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "canceloperation", NULL, 0); + zephir_check_call_status(); } + RETURN_MM_BOOL(0); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getvalue", NULL, 0, &name); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Forms_Form, getLabel) +static PHP_METHOD(Phalcon_Mvc_Model, checkForeignKeysReverseCascade) { + zend_bool _3$$3, _7$$9; + zval manager, relations, relation, foreignKey, related, _0, *_1, _2, _4$$5, _6$$7, _8$$11, _10$$13; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, element, label, _0, _1$$3; - zval name, _2$$3; + zephir_fcall_cache_entry *_5 = NULL, *_9 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, action = 0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&label); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&relations); + ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&foreignKey); + ZVAL_UNDEF(&related); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_8$$11); + ZVAL_UNDEF(&_10$$13); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&manager, &_0); + ZEPHIR_CALL_METHOD(&relations, &manager, "gethasoneandhasmany", NULL, 0, this_ptr); + zephir_check_call_status(); + zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model.zep", 3650); + if (Z_TYPE_P(&relations) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _1) + { + ZEPHIR_INIT_NVAR(&relation); + ZVAL_COPY(&relation, _1); + ZEPHIR_CALL_METHOD(&foreignKey, &relation, "getforeignkey", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&foreignKey)) { + continue; + } + action = 0; + _3$$3 = Z_TYPE_P(&foreignKey) == IS_ARRAY; + if (_3$$3) { + _3$$3 = zephir_array_isset_string(&foreignKey, SL("action")); + } + if (_3$$3) { + ZEPHIR_OBS_NVAR(&_4$$5); + zephir_array_fetch_string(&_4$$5, &foreignKey, SL("action"), PH_NOISY, "phalcon/Mvc/Model.zep", 3624); + action = zephir_get_intval(&_4$$5); + } + if (action != 2) { + continue; + } + ZEPHIR_CALL_METHOD(&related, &manager, "getrelationrecords", &_5, 0, &relation, this_ptr); + zephir_check_call_status(); + if (zephir_is_true(&related)) { + ZEPHIR_CALL_METHOD(&_6$$7, &related, "delete", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_6$$7)) { + RETURN_MM_BOOL(0); + } + } + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_INIT_VAR(&name); - } - zephir_memory_observe(&element); - zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(!(zephir_array_isset_fetch(&element, &_0, &name, 0)))) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_forms_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - ZEPHIR_CONCAT_SVS(&_2$$3, "Element with ID=", &name, " is not part of the form"); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3); + ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0); zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Forms/Form.zep", 426); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CALL_METHOD(&label, &element, "getlabel", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&label))) { - RETURN_CTOR(&name); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &relations, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&foreignKey, &relation, "getforeignkey", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&foreignKey)) { + continue; + } + action = 0; + _7$$9 = Z_TYPE_P(&foreignKey) == IS_ARRAY; + if (_7$$9) { + _7$$9 = zephir_array_isset_string(&foreignKey, SL("action")); + } + if (_7$$9) { + ZEPHIR_OBS_NVAR(&_8$$11); + zephir_array_fetch_string(&_8$$11, &foreignKey, SL("action"), PH_NOISY, "phalcon/Mvc/Model.zep", 3624); + action = zephir_get_intval(&_8$$11); + } + if (action != 2) { + continue; + } + ZEPHIR_CALL_METHOD(&related, &manager, "getrelationrecords", &_9, 0, &relation, this_ptr); + zephir_check_call_status(); + if (zephir_is_true(&related)) { + ZEPHIR_CALL_METHOD(&_10$$13, &related, "delete", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_10$$13)) { + RETURN_MM_BOOL(0); + } + } + ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_CCTOR(&label); + ZEPHIR_INIT_NVAR(&relation); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Forms_Form, getMessages) +static PHP_METHOD(Phalcon_Mvc_Model, checkForeignKeysReverseRestrict) { - zend_bool _1; - zval messages, _0; + zval _10$$7, _22$$13; + zval manager, relations, foreignKey, relation, relationClass, fields, message, _0, *_1, _2, _5$$3, _6$$3, _7$$3, _4$$5, _9$$7, _11$$7, _12$$7, _17$$9, _18$$9, _19$$9, _16$$11, _21$$13, _23$$13, _24$$13, _25$$16; + zend_bool error = 0, _3$$3, _15$$9; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zephir_fcall_cache_entry *_8 = NULL, *_13 = NULL, *_14 = NULL, *_20 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, action = 0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&messages); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&relations); + ZVAL_UNDEF(&foreignKey); + ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&relationClass); + ZVAL_UNDEF(&fields); + ZVAL_UNDEF(&message); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_9$$7); + ZVAL_UNDEF(&_11$$7); + ZVAL_UNDEF(&_12$$7); + ZVAL_UNDEF(&_17$$9); + ZVAL_UNDEF(&_18$$9); + ZVAL_UNDEF(&_19$$9); + ZVAL_UNDEF(&_16$$11); + ZVAL_UNDEF(&_21$$13); + ZVAL_UNDEF(&_23$$13); + ZVAL_UNDEF(&_24$$13); + ZVAL_UNDEF(&_25$$16); + ZVAL_UNDEF(&_10$$7); + ZVAL_UNDEF(&_22$$13); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&messages, &_0); - _1 = Z_TYPE_P(&messages) == IS_OBJECT; - if (_1) { - _1 = zephir_instance_of_ev(&messages, phalcon_messages_messages_ce); - } - if (!(_1)) { - object_init_ex(return_value, phalcon_messages_messages_ce); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 8); - zephir_check_call_status(); - RETURN_MM(); - } - RETURN_CCTOR(&messages); -} - -static PHP_METHOD(Phalcon_Forms_Form, getMessagesFor) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, _0, _1; - zval name; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, 0, &name); - zephir_check_call_status(); - if (!(zephir_is_true(&_0))) { - object_init_ex(return_value, phalcon_messages_messages_ce); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 8); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(&_1, this_ptr, "get", NULL, 0, &name); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&_1, "getmessages", NULL, 0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&manager, &_0); + ZEPHIR_CALL_METHOD(&relations, &manager, "gethasoneandhasmany", NULL, 0, this_ptr); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Forms_Form, getTagFactory) -{ - - RETURN_MEMBER(getThis(), "tagFactory"); -} - -static PHP_METHOD(Phalcon_Forms_Form, getUserOption) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *option_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null, value, _0; - zval option; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&option); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(option) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &option_param, &defaultValue); - zephir_get_strval(&option, option_param); - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; - } - zephir_memory_observe(&value); - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&value, &_0, &option, 0))) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); - } - RETURN_CCTOR(&value); -} - -static PHP_METHOD(Phalcon_Forms_Form, getUserOptions) -{ - - RETURN_MEMBER(getThis(), "options"); -} - -static PHP_METHOD(Phalcon_Forms_Form, getValue) -{ - zval forbidden; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, __$true, entity, value, data, internalEntity, element, _0, _3, _4, _1$$4, _2$$4; - zval name, method; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&method); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&entity); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&internalEntity); - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&forbidden); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + error = 0; + zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model.zep", 3741); + if (Z_TYPE_P(&relations) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _1) + { + ZEPHIR_INIT_NVAR(&relation); + ZVAL_COPY(&relation, _1); + ZEPHIR_CALL_METHOD(&foreignKey, &relation, "getforeignkey", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&foreignKey)) { + continue; + } + action = 1; + _3$$3 = Z_TYPE_P(&foreignKey) == IS_ARRAY; + if (_3$$3) { + _3$$3 = zephir_array_isset_string(&foreignKey, SL("action")); + } + if (_3$$3) { + ZEPHIR_OBS_NVAR(&_4$$5); + zephir_array_fetch_string(&_4$$5, &foreignKey, SL("action"), PH_NOISY, "phalcon/Mvc/Model.zep", 3695); + action = zephir_get_intval(&_4$$5); + } + if (action != 1) { + continue; + } + ZEPHIR_CALL_METHOD(&relationClass, &relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&fields, &relation, "getfields", NULL, 0); + zephir_check_call_status(); + ZVAL_NULL(&_6$$3); + ZEPHIR_INIT_NVAR(&_7$$3); + ZVAL_STRING(&_7$$3, "count"); + ZEPHIR_CALL_METHOD(&_5$$3, &manager, "getrelationrecords", &_8, 0, &relation, this_ptr, &_6$$3, &_7$$3); + zephir_check_call_status(); + if (zephir_is_true(&_5$$3)) { + ZEPHIR_OBS_NVAR(&message); + if (!(zephir_array_isset_string_fetch(&message, &foreignKey, SL("message"), 0))) { + ZEPHIR_INIT_NVAR(&message); + ZEPHIR_CONCAT_SV(&message, "Record is referenced by model ", &relationClass); + } + ZEPHIR_INIT_NVAR(&_9$$7); + object_init_ex(&_9$$7, phalcon_messages_message_ce); + ZEPHIR_INIT_NVAR(&_10$$7); + zephir_create_array(&_10$$7, 2, 0); + ZEPHIR_INIT_NVAR(&_11$$7); + zephir_get_class(&_11$$7, this_ptr, 0); + zephir_array_update_string(&_10$$7, SL("model"), &_11$$7, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_10$$7, SL("referenceModel"), &relationClass, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_11$$7); + ZVAL_STRING(&_11$$7, "ConstraintViolation"); + ZVAL_LONG(&_12$$7, 0); + ZEPHIR_CALL_METHOD(NULL, &_9$$7, "__construct", &_13, 6, &message, &fields, &_11$$7, &_12$$7, &_10$$7); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_14, 0, &_9$$7); + zephir_check_call_status(); + error = 1; + break; + } + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_INIT_VAR(&name); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("entity"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&entity, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&data, &_0); - if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("getcustomvalue")) == SUCCESS)) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getcustomvalue", NULL, 0, &name, &entity, &data); + ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0); zephir_check_call_status(); - RETURN_MM(); - } - if (Z_TYPE_P(&entity) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_1$$4); - zephir_camelize(&_1$$4, &name, NULL ); - ZEPHIR_INIT_VAR(&_2$$4); - ZEPHIR_CONCAT_SV(&_2$$4, "get", &_1$$4); - zephir_get_strval(&method, &_2$$4); - if ((zephir_method_exists(&entity, &method) == SUCCESS)) { - ZEPHIR_RETURN_CALL_METHOD_ZVAL(&entity, &method, NULL, 0); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &relations, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&foreignKey, &relation, "getforeignkey", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&foreignKey)) { + continue; + } + action = 1; + _15$$9 = Z_TYPE_P(&foreignKey) == IS_ARRAY; + if (_15$$9) { + _15$$9 = zephir_array_isset_string(&foreignKey, SL("action")); + } + if (_15$$9) { + ZEPHIR_OBS_NVAR(&_16$$11); + zephir_array_fetch_string(&_16$$11, &foreignKey, SL("action"), PH_NOISY, "phalcon/Mvc/Model.zep", 3695); + action = zephir_get_intval(&_16$$11); + } + if (action != 1) { + continue; + } + ZEPHIR_CALL_METHOD(&relationClass, &relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&fields, &relation, "getfields", NULL, 0); + zephir_check_call_status(); + ZVAL_NULL(&_18$$9); + ZEPHIR_INIT_NVAR(&_19$$9); + ZVAL_STRING(&_19$$9, "count"); + ZEPHIR_CALL_METHOD(&_17$$9, &manager, "getrelationrecords", &_20, 0, &relation, this_ptr, &_18$$9, &_19$$9); + zephir_check_call_status(); + if (zephir_is_true(&_17$$9)) { + ZEPHIR_OBS_NVAR(&message); + if (!(zephir_array_isset_string_fetch(&message, &foreignKey, SL("message"), 0))) { + ZEPHIR_INIT_NVAR(&message); + ZEPHIR_CONCAT_SV(&message, "Record is referenced by model ", &relationClass); + } + ZEPHIR_INIT_NVAR(&_21$$13); + object_init_ex(&_21$$13, phalcon_messages_message_ce); + ZEPHIR_INIT_NVAR(&_22$$13); + zephir_create_array(&_22$$13, 2, 0); + ZEPHIR_INIT_NVAR(&_23$$13); + zephir_get_class(&_23$$13, this_ptr, 0); + zephir_array_update_string(&_22$$13, SL("model"), &_23$$13, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_22$$13, SL("referenceModel"), &relationClass, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_23$$13); + ZVAL_STRING(&_23$$13, "ConstraintViolation"); + ZVAL_LONG(&_24$$13, 0); + ZEPHIR_CALL_METHOD(NULL, &_21$$13, "__construct", &_13, 6, &message, &fields, &_23$$13, &_24$$13, &_22$$13); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_14, 0, &_21$$13); + zephir_check_call_status(); + error = 1; + break; + } + ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0); zephir_check_call_status(); - RETURN_MM(); - } - zephir_memory_observe(&value); - if (zephir_fetch_property_zval(&value, &entity, &name, PH_SILENT_CC)) { - RETURN_CCTOR(&value); } } - if (Z_TYPE_P(&data) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&value); - if (zephir_array_isset_fetch(&value, &data, &name, 0)) { - RETURN_CCTOR(&value); + ZEPHIR_INIT_NVAR(&relation); + if (error) { + if (ZEPHIR_GLOBAL(orm).events) { + ZEPHIR_INIT_VAR(&_25$$16); + ZVAL_STRING(&_25$$16, "onValidationFails"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_25$$16); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "canceloperation", NULL, 0); + zephir_check_call_status(); } + RETURN_MM_BOOL(0); } - ZEPHIR_INIT_VAR(&forbidden); - zephir_create_array(&forbidden, 14, 0); - zephir_array_update_string(&forbidden, SL("attributes"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&forbidden, SL("validation"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&forbidden, SL("action"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&forbidden, SL("useroption"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&forbidden, SL("useroptions"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&forbidden, SL("entity"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&forbidden, SL("elements"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&forbidden, SL("messages"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&forbidden, SL("messagesfor"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&forbidden, SL("label"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&forbidden, SL("value"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&forbidden, SL("di"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&forbidden, SL("tagFactory"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&forbidden, SL("eventsmanager"), &__$true, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&internalEntity); - zephir_fast_strtolower(&internalEntity, &name); - if (zephir_array_isset(&forbidden, &internalEntity)) { - RETURN_MM_NULL(); - } - ZEPHIR_INIT_VAR(&_3); - zephir_camelize(&_3, &name, NULL ); - ZEPHIR_INIT_VAR(&_4); - ZEPHIR_CONCAT_SV(&_4, "get", &_3); - zephir_get_strval(&method, &_4); - if ((zephir_method_exists(this_ptr, &method) == SUCCESS)) { - ZEPHIR_RETURN_CALL_METHOD_ZVAL(this_ptr, &method, NULL, 0); - zephir_check_call_status(); - RETURN_MM(); - } - zephir_memory_observe(&element); - zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&element, &_0, &name, 0)) { - ZEPHIR_RETURN_CALL_METHOD(&element, "getdefault", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); - } - RETURN_MM_NULL(); -} - -static PHP_METHOD(Phalcon_Forms_Form, getValidation) -{ - - RETURN_MEMBER(getThis(), "validation"); -} - -static PHP_METHOD(Phalcon_Forms_Form, getWhitelist) -{ - - RETURN_MEMBER(getThis(), "whitelist"); -} - -static PHP_METHOD(Phalcon_Forms_Form, has) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, _0; - zval name; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - RETURN_MM_BOOL(zephir_array_isset(&_0, &name)); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Forms_Form, hasMessagesFor) +static PHP_METHOD(Phalcon_Mvc_Model, doLowInsert) { + zend_string *_58$$56; + zend_ulong _57$$56; + zend_bool useExplicitIdentity = 0, _51, _7$$11, _25$$26, _44$$40, _60$$56; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_6 = NULL, *_11 = NULL, *_12 = NULL, *_19 = NULL, *_21 = NULL, *_29 = NULL, *_30 = NULL, *_37 = NULL, *_39 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, _0, _1; - zval name; + zval *metaData, metaData_sub, *connection, connection_sub, *table = NULL, table_sub, *identityField, identityField_sub, __$null, attributeField, attributes, automaticAttributes, bindDataTypes, bindSkip, bindType, bindTypes, columnMap, defaultValue, defaultValues, field, fields, lastInsertedId, manager, sequenceName, schema, snapshot, source, success, unsetDefaultValues, value, values, _0, *_1, _2, _3$$7, _4$$7, _5$$7, _8$$12, _9$$12, _10$$12, _13$$15, _14$$15, _15$$15, _16$$17, _17$$17, _18$$17, _20$$17, _22$$22, _23$$22, _24$$22, _26$$27, _27$$27, _28$$27, _31$$30, _32$$30, _33$$30, _34$$32, _35$$32, _36$$32, _38$$32, _40$$35, _41$$38, _42$$38, _43$$38, _45$$45, _46$$45, _47$$45, _48$$48, _49$$48, _50$$48, _52$$49, _53$$55, _54$$55, *_55$$56, _56$$56, _59$$56; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); + ZVAL_UNDEF(&metaData_sub); + ZVAL_UNDEF(&connection_sub); + ZVAL_UNDEF(&table_sub); + ZVAL_UNDEF(&identityField_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&attributeField); + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&automaticAttributes); + ZVAL_UNDEF(&bindDataTypes); + ZVAL_UNDEF(&bindSkip); + ZVAL_UNDEF(&bindType); + ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&columnMap); + ZVAL_UNDEF(&defaultValue); + ZVAL_UNDEF(&defaultValues); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&fields); + ZVAL_UNDEF(&lastInsertedId); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&sequenceName); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&snapshot); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&success); + ZVAL_UNDEF(&unsetDefaultValues); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&values); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$7); + ZVAL_UNDEF(&_4$$7); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_8$$12); + ZVAL_UNDEF(&_9$$12); + ZVAL_UNDEF(&_10$$12); + ZVAL_UNDEF(&_13$$15); + ZVAL_UNDEF(&_14$$15); + ZVAL_UNDEF(&_15$$15); + ZVAL_UNDEF(&_16$$17); + ZVAL_UNDEF(&_17$$17); + ZVAL_UNDEF(&_18$$17); + ZVAL_UNDEF(&_20$$17); + ZVAL_UNDEF(&_22$$22); + ZVAL_UNDEF(&_23$$22); + ZVAL_UNDEF(&_24$$22); + ZVAL_UNDEF(&_26$$27); + ZVAL_UNDEF(&_27$$27); + ZVAL_UNDEF(&_28$$27); + ZVAL_UNDEF(&_31$$30); + ZVAL_UNDEF(&_32$$30); + ZVAL_UNDEF(&_33$$30); + ZVAL_UNDEF(&_34$$32); + ZVAL_UNDEF(&_35$$32); + ZVAL_UNDEF(&_36$$32); + ZVAL_UNDEF(&_38$$32); + ZVAL_UNDEF(&_40$$35); + ZVAL_UNDEF(&_41$$38); + ZVAL_UNDEF(&_42$$38); + ZVAL_UNDEF(&_43$$38); + ZVAL_UNDEF(&_45$$45); + ZVAL_UNDEF(&_46$$45); + ZVAL_UNDEF(&_47$$45); + ZVAL_UNDEF(&_48$$48); + ZVAL_UNDEF(&_49$$48); + ZVAL_UNDEF(&_50$$48); + ZVAL_UNDEF(&_52$$49); + ZVAL_UNDEF(&_53$$55); + ZVAL_UNDEF(&_54$$55); + ZVAL_UNDEF(&_56$$56); + ZVAL_UNDEF(&_59$$56); + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_OBJECT_OF_CLASS(metaData, phalcon_mvc_model_metadatainterface_ce) + Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_db_adapter_adapterinterface_ce) + Z_PARAM_ZVAL(table) + Z_PARAM_ZVAL(identityField) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmessagesfor", NULL, 0, &name); + zephir_fetch_params(1, 4, 0, &metaData, &connection, &table, &identityField); + ZEPHIR_SEPARATE_PARAM(table); + ZEPHIR_INIT_VAR(&bindSkip); + ZVAL_LONG(&bindSkip, 1024); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&manager, &_0); + ZEPHIR_INIT_VAR(&fields); + array_init(&fields); + ZEPHIR_INIT_VAR(&values); + array_init(&values); + ZEPHIR_INIT_VAR(&snapshot); + array_init(&snapshot); + ZEPHIR_INIT_VAR(&bindTypes); + array_init(&bindTypes); + ZEPHIR_INIT_VAR(&unsetDefaultValues); + array_init(&unsetDefaultValues); + ZEPHIR_CALL_METHOD(&attributes, metaData, "getattributes", NULL, 0, this_ptr); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, &_0, "count", NULL, 0); + ZEPHIR_CALL_METHOD(&bindDataTypes, metaData, "getbindtypes", NULL, 0, this_ptr); zephir_check_call_status(); - RETURN_MM_BOOL(ZEPHIR_GT_LONG(&_1, 0)); -} - -static PHP_METHOD(Phalcon_Forms_Form, isValid) -{ - zend_object_iterator *_18$$20; - zend_bool validationStatus = 0, _3, _7; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_13 = NULL, *_14 = NULL, *_21 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval whitelist; - zval *data = NULL, data_sub, *entity = NULL, entity_sub, *whitelist_param = NULL, __$null, messages, element, validators, name, filters, validator, validation, elementMessage, _0, _4, _8, *_9, _10, _17, _1$$4, _2$$5, _5$$6, _6$$7, *_11$$10, _12$$10, *_15$$15, _16$$15, _19$$21, _20$$21; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&data_sub); - ZVAL_UNDEF(&entity_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&messages); - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&validators); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&filters); - ZVAL_UNDEF(&validator); - ZVAL_UNDEF(&validation); - ZVAL_UNDEF(&elementMessage); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_17); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_12$$10); - ZVAL_UNDEF(&_16$$15); - ZVAL_UNDEF(&_19$$21); - ZVAL_UNDEF(&_20$$21); - ZVAL_UNDEF(&whitelist); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 3) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(data) - Z_PARAM_ZVAL_OR_NULL(entity) - Z_PARAM_ARRAY(whitelist) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 3, &data, &entity, &whitelist_param); - if (!data) { - data = &data_sub; - ZEPHIR_CPY_WRT(data, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(data); - } - if (!entity) { - entity = &entity_sub; - ZEPHIR_CPY_WRT(entity, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(entity); - } - if (!whitelist_param) { - ZEPHIR_INIT_VAR(&whitelist); - array_init(&whitelist); - } else { - zephir_get_arrval(&whitelist, whitelist_param); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_EMPTY(&_0)) { - RETURN_MM_BOOL(1); - } - if (ZEPHIR_IS_EMPTY(&whitelist)) { - zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("whitelist"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&whitelist, &_1$$4); - } - if (Z_TYPE_P(data) != IS_ARRAY) { - zephir_read_property(&_2$$5, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(data, &_2$$5); - } - _3 = Z_TYPE_P(entity) != IS_OBJECT; - if (_3) { - zephir_memory_observe(&_4); - zephir_read_property(&_4, this_ptr, ZEND_STRL("entity"), PH_NOISY_CC); - _3 = Z_TYPE_P(&_4) == IS_OBJECT; - } - if (_3) { - zephir_read_property(&_5$$6, this_ptr, ZEND_STRL("entity"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(entity, &_5$$6); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "bind", NULL, 0, data, entity, &whitelist); + ZEPHIR_CALL_METHOD(&automaticAttributes, metaData, "getautomaticcreateattributes", NULL, 0, this_ptr); zephir_check_call_status(); - if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("beforevalidation")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(&_6$$7, this_ptr, "beforevalidation", NULL, 0, data, entity); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_6$$7)) { - RETURN_MM_BOOL(0); - } - } - validationStatus = 1; - ZEPHIR_CALL_METHOD(&validation, this_ptr, "getvalidation", NULL, 0); + ZEPHIR_CALL_METHOD(&defaultValues, metaData, "getdefaultvalues", NULL, 0, this_ptr); zephir_check_call_status(); - _7 = Z_TYPE_P(&validation) != IS_OBJECT; - if (!(_7)) { - _7 = !((zephir_instance_of_ev(&validation, phalcon_filter_validation_validationinterface_ce))); - } - if (_7) { - ZEPHIR_INIT_NVAR(&validation); - object_init_ex(&validation, phalcon_filter_validation_ce); - ZEPHIR_CALL_METHOD(NULL, &validation, "__construct", NULL, 315); + if (ZEPHIR_GLOBAL(orm).column_renaming) { + ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, this_ptr); zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&columnMap); + ZVAL_NULL(&columnMap); } - zephir_read_property(&_8, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_8, 0, "phalcon/Forms/Form.zep", 722); - if (Z_TYPE_P(&_8) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_8), _9) + zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model.zep", 3863); + if (Z_TYPE_P(&attributes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _1) { - ZEPHIR_INIT_NVAR(&element); - ZVAL_COPY(&element, _9); - ZEPHIR_CALL_METHOD(&validators, &element, "getvalidators", NULL, 0); - zephir_check_call_status(); - if (zephir_fast_count_int(&validators) == 0) { - continue; - } - ZEPHIR_CALL_METHOD(&name, &element, "getname", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&validators, 0, "phalcon/Forms/Form.zep", 709); - if (Z_TYPE_P(&validators) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&validators), _11$$10) - { - ZEPHIR_INIT_NVAR(&validator); - ZVAL_COPY(&validator, _11$$10); - ZEPHIR_CALL_METHOD(NULL, &validation, "add", &_13, 316, &name, &validator); + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _1); + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeField); + if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { + ZEPHIR_INIT_NVAR(&_3$$7); + object_init_ex(&_3$$7, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_4$$7); + zephir_get_class(&_4$$7, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_5$$7); + ZEPHIR_CONCAT_SVSVS(&_5$$7, "Column '", &field, "' in '", &_4$$7, "' isn't part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_3$$7, "__construct", &_6, 33, &_5$$7); zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); + zephir_throw_exception_debug(&_3$$7, "phalcon/Mvc/Model.zep", 3797); + ZEPHIR_MM_RESTORE(); + return; + } } else { - ZEPHIR_CALL_METHOD(NULL, &validators, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_12$$10, &validators, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_12$$10)) { - break; + ZEPHIR_CPY_WRT(&attributeField, &field); + } + if (!(zephir_array_isset(&automaticAttributes, &attributeField))) { + if (!ZEPHIR_IS_EQUAL(&field, identityField)) { + ZEPHIR_OBS_NVAR(&value); + if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { + _7$$11 = Z_TYPE_P(&value) == IS_NULL; + if (_7$$11) { + _7$$11 = zephir_array_isset(&defaultValues, &field); + } + if (_7$$11) { + zephir_array_fetch(&_8$$12, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3814); + zephir_array_update_zval(&snapshot, &attributeField, &_8$$12, PH_COPY | PH_SEPARATE); + zephir_array_fetch(&_9$$12, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3815); + zephir_array_update_zval(&unsetDefaultValues, &attributeField, &_9$$12, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_10$$12, connection, "supportsdefaultvalue", &_11, 0); + zephir_check_call_status(); + if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&_10$$12))) { + continue; + } + ZEPHIR_CALL_METHOD(&value, connection, "getdefaultvalue", &_12, 0); + zephir_check_call_status(); + } else { + zephir_array_update_zval(&snapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); + } + ZEPHIR_OBS_NVAR(&bindType); + if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, &bindDataTypes, &field, 0)))) { + ZEPHIR_INIT_NVAR(&_13$$15); + object_init_ex(&_13$$15, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_14$$15); + zephir_get_class(&_14$$15, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_15$$15); + ZEPHIR_CONCAT_SVSVS(&_15$$15, "Column '", &field, "' in '", &_14$$15, "' have not defined a bind data type"); + ZEPHIR_CALL_METHOD(NULL, &_13$$15, "__construct", &_6, 33, &_15$$15); + zephir_check_call_status(); + zephir_throw_exception_debug(&_13$$15, "phalcon/Mvc/Model.zep", 3832); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3835); + zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3836); + zephir_array_append(&bindTypes, &bindType, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3837); + } else { + if (zephir_array_isset(&defaultValues, &field)) { + zephir_array_fetch(&_16$$17, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3840); + zephir_array_update_zval(&snapshot, &attributeField, &_16$$17, PH_COPY | PH_SEPARATE); + zephir_array_fetch(&_17$$17, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3841); + zephir_array_update_zval(&unsetDefaultValues, &attributeField, &_17$$17, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_18$$17, connection, "supportsdefaultvalue", &_19, 0); + zephir_check_call_status(); + if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&_18$$17))) { + continue; + } + ZEPHIR_CALL_METHOD(&_20$$17, connection, "getdefaultvalue", &_21, 0); + zephir_check_call_status(); + zephir_array_append(&values, &_20$$17, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3847); + } else { + zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3849); + zephir_array_update_zval(&snapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); + } + zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3853); + zephir_array_append(&bindTypes, &bindSkip, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3854); } - ZEPHIR_CALL_METHOD(&validator, &validators, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &validation, "add", &_13, 316, &name, &validator); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &validators, "next", NULL, 0); - zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&validator); - ZEPHIR_CALL_METHOD(&filters, &element, "getfilters", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&filters) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(NULL, &validation, "setfilters", &_14, 317, &name, &filters); - zephir_check_call_status(); - } } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &_8, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_10, &_8, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_2, &attributes, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_10)) { + if (!zend_is_true(&_2)) { break; } - ZEPHIR_CALL_METHOD(&element, &_8, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&field, &attributes, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&validators, &element, "getvalidators", NULL, 0); - zephir_check_call_status(); - if (zephir_fast_count_int(&validators) == 0) { - continue; - } - ZEPHIR_CALL_METHOD(&name, &element, "getname", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&validators, 0, "phalcon/Forms/Form.zep", 709); - if (Z_TYPE_P(&validators) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&validators), _15$$15) - { - ZEPHIR_INIT_NVAR(&validator); - ZVAL_COPY(&validator, _15$$15); - ZEPHIR_CALL_METHOD(NULL, &validation, "add", &_13, 316, &name, &validator); + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeField); + if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { + ZEPHIR_INIT_NVAR(&_22$$22); + object_init_ex(&_22$$22, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_23$$22); + zephir_get_class(&_23$$22, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_24$$22); + ZEPHIR_CONCAT_SVSVS(&_24$$22, "Column '", &field, "' in '", &_23$$22, "' isn't part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_22$$22, "__construct", &_6, 33, &_24$$22); zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); + zephir_throw_exception_debug(&_22$$22, "phalcon/Mvc/Model.zep", 3797); + ZEPHIR_MM_RESTORE(); + return; + } } else { - ZEPHIR_CALL_METHOD(NULL, &validators, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_16$$15, &validators, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_16$$15)) { - break; + ZEPHIR_CPY_WRT(&attributeField, &field); + } + if (!(zephir_array_isset(&automaticAttributes, &attributeField))) { + if (!ZEPHIR_IS_EQUAL(&field, identityField)) { + ZEPHIR_OBS_NVAR(&value); + if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { + _25$$26 = Z_TYPE_P(&value) == IS_NULL; + if (_25$$26) { + _25$$26 = zephir_array_isset(&defaultValues, &field); + } + if (_25$$26) { + zephir_array_fetch(&_26$$27, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3814); + zephir_array_update_zval(&snapshot, &attributeField, &_26$$27, PH_COPY | PH_SEPARATE); + zephir_array_fetch(&_27$$27, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3815); + zephir_array_update_zval(&unsetDefaultValues, &attributeField, &_27$$27, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_28$$27, connection, "supportsdefaultvalue", &_29, 0); + zephir_check_call_status(); + if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&_28$$27))) { + continue; + } + ZEPHIR_CALL_METHOD(&value, connection, "getdefaultvalue", &_30, 0); + zephir_check_call_status(); + } else { + zephir_array_update_zval(&snapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); + } + ZEPHIR_OBS_NVAR(&bindType); + if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, &bindDataTypes, &field, 0)))) { + ZEPHIR_INIT_NVAR(&_31$$30); + object_init_ex(&_31$$30, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_32$$30); + zephir_get_class(&_32$$30, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_33$$30); + ZEPHIR_CONCAT_SVSVS(&_33$$30, "Column '", &field, "' in '", &_32$$30, "' have not defined a bind data type"); + ZEPHIR_CALL_METHOD(NULL, &_31$$30, "__construct", &_6, 33, &_33$$30); + zephir_check_call_status(); + zephir_throw_exception_debug(&_31$$30, "phalcon/Mvc/Model.zep", 3832); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3835); + zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3836); + zephir_array_append(&bindTypes, &bindType, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3837); + } else { + if (zephir_array_isset(&defaultValues, &field)) { + zephir_array_fetch(&_34$$32, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3840); + zephir_array_update_zval(&snapshot, &attributeField, &_34$$32, PH_COPY | PH_SEPARATE); + zephir_array_fetch(&_35$$32, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3841); + zephir_array_update_zval(&unsetDefaultValues, &attributeField, &_35$$32, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_36$$32, connection, "supportsdefaultvalue", &_37, 0); + zephir_check_call_status(); + if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&_36$$32))) { + continue; + } + ZEPHIR_CALL_METHOD(&_38$$32, connection, "getdefaultvalue", &_39, 0); + zephir_check_call_status(); + zephir_array_append(&values, &_38$$32, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3847); + } else { + zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3849); + zephir_array_update_zval(&snapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); + } + zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3853); + zephir_array_append(&bindTypes, &bindSkip, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3854); } - ZEPHIR_CALL_METHOD(&validator, &validators, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &validation, "add", &_13, 316, &name, &validator); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &validators, "next", NULL, 0); - zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&validator); - ZEPHIR_CALL_METHOD(&filters, &element, "getfilters", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&field); + if (!ZEPHIR_IS_FALSE_IDENTICAL(identityField)) { + ZEPHIR_CALL_METHOD(&defaultValue, connection, "getdefaultidvalue", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_40$$35, connection, "useexplicitidvalue", NULL, 0); + zephir_check_call_status(); + useExplicitIdentity = zephir_get_boolval(&_40$$35); + if (useExplicitIdentity) { + zephir_array_append(&fields, identityField, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3873); + } + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeField); + if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, identityField, 0)))) { + ZEPHIR_INIT_VAR(&_41$$38); + object_init_ex(&_41$$38, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_42$$38); + zephir_get_class(&_42$$38, this_ptr, 0); + ZEPHIR_INIT_VAR(&_43$$38); + ZEPHIR_CONCAT_SVSVS(&_43$$38, "Identity column '", identityField, "' isn't part of the column map in '", &_42$$38, "'"); + ZEPHIR_CALL_METHOD(NULL, &_41$$38, "__construct", &_6, 33, &_43$$38); zephir_check_call_status(); - if (Z_TYPE_P(&filters) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(NULL, &validation, "setfilters", &_14, 317, &name, &filters); + zephir_throw_exception_debug(&_41$$38, "phalcon/Mvc/Model.zep", 3883); + ZEPHIR_MM_RESTORE(); + return; + } + } else { + ZEPHIR_CPY_WRT(&attributeField, identityField); + } + ZEPHIR_OBS_NVAR(&value); + if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { + _44$$40 = Z_TYPE_P(&value) == IS_NULL; + if (!(_44$$40)) { + _44$$40 = ZEPHIR_IS_STRING_IDENTICAL(&value, ""); + } + if (_44$$40) { + if (useExplicitIdentity) { + zephir_array_append(&values, &defaultValue, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3895); + zephir_array_append(&bindTypes, &bindSkip, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3895); + } + } else { + if (!(useExplicitIdentity)) { + zephir_array_append(&fields, identityField, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3903); + } + ZEPHIR_OBS_NVAR(&bindType); + if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, &bindDataTypes, identityField, 0)))) { + ZEPHIR_INIT_VAR(&_45$$45); + object_init_ex(&_45$$45, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_46$$45); + zephir_get_class(&_46$$45, this_ptr, 0); + ZEPHIR_INIT_VAR(&_47$$45); + ZEPHIR_CONCAT_SVSVS(&_47$$45, "Identity column '", identityField, "' isn\'t part of the table columns in '", &_46$$45, "'"); + ZEPHIR_CALL_METHOD(NULL, &_45$$45, "__construct", &_6, 33, &_47$$45); zephir_check_call_status(); + zephir_throw_exception_debug(&_45$$45, "phalcon/Mvc/Model.zep", 3912); + ZEPHIR_MM_RESTORE(); + return; } - ZEPHIR_CALL_METHOD(NULL, &_8, "next", NULL, 0); - zephir_check_call_status(); + zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3915); + zephir_array_append(&bindTypes, &bindType, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3916); + } + } else { + if (useExplicitIdentity) { + zephir_array_append(&values, &defaultValue, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3920); + zephir_array_append(&bindTypes, &bindSkip, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3921); + } } } - ZEPHIR_INIT_NVAR(&element); - ZEPHIR_CALL_METHOD(&messages, &validation, "validate", NULL, 318, data, entity); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_17, &messages, "count", NULL, 0); + if (Z_TYPE_P(table) == IS_ARRAY) { + zephir_array_fetch_long(&_48$$48, table, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3930); + zephir_array_fetch_long(&_49$$48, table, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3930); + ZEPHIR_INIT_VAR(&_50$$48); + ZEPHIR_CONCAT_VSV(&_50$$48, &_48$$48, ".", &_49$$48); + ZEPHIR_CPY_WRT(table, &_50$$48); + } + ZEPHIR_CALL_METHOD(&success, connection, "insert", NULL, 0, table, &values, &fields, &bindTypes); zephir_check_call_status(); - if (zephir_is_true(&_17)) { - _18$$20 = zephir_get_iterator(&messages); - _18$$20->funcs->rewind(_18$$20); - for (;_18$$20->funcs->valid(_18$$20) == SUCCESS && !EG(exception); _18$$20->funcs->move_forward(_18$$20)) { - { - ZEPHIR_ITERATOR_COPY(&elementMessage, _18$$20); + _51 = zephir_is_true(&success); + if (_51) { + _51 = !ZEPHIR_IS_FALSE_IDENTICAL(identityField); + } + if (_51) { + ZEPHIR_INIT_VAR(&sequenceName); + ZVAL_NULL(&sequenceName); + ZEPHIR_CALL_METHOD(&_52$$49, connection, "supportsequences", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_52$$49)) { + if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("getsequencename")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(&sequenceName, this_ptr, "getsequencename", NULL, 0); + zephir_check_call_status(); + } else { + ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 424); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&schema, this_ptr, "getschema", NULL, 423); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&sequenceName); + if (ZEPHIR_IS_EMPTY(&schema)) { + ZEPHIR_CONCAT_VSVS(&sequenceName, &source, "_", identityField, "_seq"); + } else { + ZEPHIR_CONCAT_VSVSVS(&sequenceName, &schema, ".", &source, "_", identityField, "_seq"); + } } - ZEPHIR_CALL_METHOD(&_20$$21, &elementMessage, "getfield", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_19$$21, this_ptr, "get", &_21, 0, &_20$$21); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_19$$21, "appendmessage", NULL, 0, &elementMessage); - zephir_check_call_status(); } - zend_iterator_dtor(_18$$20); - ZEPHIR_CALL_METHOD(NULL, &messages, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(&lastInsertedId, connection, "lastinsertid", NULL, 0, &sequenceName); zephir_check_call_status(); - validationStatus = 0; - } - if (!(validationStatus)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), &messages); + if (UNEXPECTED(ZEPHIR_GLOBAL(orm).cast_last_insert_id_to_int)) { + ZVAL_LONG(&_53$$55, 10); + ZEPHIR_CALL_FUNCTION(&_54$$55, "intval", NULL, 42, &lastInsertedId, &_53$$55); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&lastInsertedId, &_54$$55); + } + zephir_update_property_zval_zval(this_ptr, &attributeField, &lastInsertedId); + zephir_array_update_zval(&snapshot, &attributeField, &lastInsertedId, PH_COPY | PH_SEPARATE); + zephir_update_property_zval(this_ptr, ZEND_STRL("uniqueParams"), &__$null); } - if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("aftervalidation")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "aftervalidation", NULL, 0, &messages); + if (zephir_is_true(&success)) { + zephir_is_iterable(&unsetDefaultValues, 0, "phalcon/Mvc/Model.zep", 3991); + if (Z_TYPE_P(&unsetDefaultValues) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&unsetDefaultValues), _57$$56, _58$$56, _55$$56) + { + ZEPHIR_INIT_NVAR(&attributeField); + if (_58$$56 != NULL) { + ZVAL_STR_COPY(&attributeField, _58$$56); + } else { + ZVAL_LONG(&attributeField, _57$$56); + } + ZEPHIR_INIT_NVAR(&defaultValue); + ZVAL_COPY(&defaultValue, _55$$56); + zephir_update_property_zval_zval(this_ptr, &attributeField, &defaultValue); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &unsetDefaultValues, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_56$$56, &unsetDefaultValues, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_56$$56)) { + break; + } + ZEPHIR_CALL_METHOD(&attributeField, &unsetDefaultValues, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&defaultValue, &unsetDefaultValues, "current", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval_zval(this_ptr, &attributeField, &defaultValue); + ZEPHIR_CALL_METHOD(NULL, &unsetDefaultValues, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&defaultValue); + ZEPHIR_INIT_NVAR(&attributeField); + ZEPHIR_CALL_METHOD(&_59$$56, &manager, "iskeepingsnapshots", NULL, 0, this_ptr); zephir_check_call_status(); + _60$$56 = zephir_is_true(&_59$$56); + if (_60$$56) { + _60$$56 = ZEPHIR_GLOBAL(orm).update_snapshot_on_save; + } + if (_60$$56) { + zephir_update_property_zval(this_ptr, ZEND_STRL("snapshot"), &snapshot); + } } - RETURN_MM_BOOL(validationStatus); -} - -static PHP_METHOD(Phalcon_Forms_Form, key) -{ - - RETURN_MEMBER(getThis(), "position"); + RETURN_CCTOR(&success); } -static PHP_METHOD(Phalcon_Forms_Form, label) +static PHP_METHOD(Phalcon_Mvc_Model, doLowUpdate) { + zval _21$$25, _22$$25, _37$$48, _38$$48; + zval _67; + zend_bool changed = 0, useDynamicUpdate = 0, _2, _69, _70, _15$$19, _17$$19, _32$$42, _34$$42; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_8 = NULL, *_19 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes; - zval *name_param = NULL, *attributes_param = NULL, element, _0, _1$$3; - zval name, _2$$3; + zval *metaData, metaData_sub, *connection, connection_sub, *table = NULL, table_sub, __$null, automaticAttributes, attributeField, bindSkip, bindDataTypes, bindType, bindTypes, columnMap, dataType, dataTypes, field, fields, manager, nonPrimary, newSnapshot, success, primaryKeys, snapshot, snapshotValue, uniqueKey, uniqueParams, value, values, updateValue, _0, _1, _68, *_3$$5, _4$$5, _5$$9, _6$$9, _7$$9, _9$$12, _10$$12, _11$$12, _12$$20, _13$$20, _14$$20, _16$$21, _18$$24, _20$$24, _23$$32, _24$$32, _25$$32, _26$$35, _27$$35, _28$$35, _29$$43, _30$$43, _31$$43, _33$$44, _35$$47, _36$$47, *_39$$53, _40$$53, _41$$57, _42$$57, _43$$57, _44$$60, _45$$60, _46$$60, _47$$66, _48$$66, _49$$66, _50$$69, _51$$69, _52$$69, _53$$74, _54$$74, _55$$74, *_56$$73, _57$$73, _58$$77, _59$$77, _60$$77, _61$$83, _62$$83, _63$$83, _64$$87, _65$$87, _66$$87, _71$$89, _72$$90; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(name) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &name_param, &attributes_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + ZVAL_UNDEF(&metaData_sub); + ZVAL_UNDEF(&connection_sub); + ZVAL_UNDEF(&table_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&automaticAttributes); + ZVAL_UNDEF(&attributeField); + ZVAL_UNDEF(&bindSkip); + ZVAL_UNDEF(&bindDataTypes); + ZVAL_UNDEF(&bindType); + ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&columnMap); + ZVAL_UNDEF(&dataType); + ZVAL_UNDEF(&dataTypes); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&fields); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&nonPrimary); + ZVAL_UNDEF(&newSnapshot); + ZVAL_UNDEF(&success); + ZVAL_UNDEF(&primaryKeys); + ZVAL_UNDEF(&snapshot); + ZVAL_UNDEF(&snapshotValue); + ZVAL_UNDEF(&uniqueKey); + ZVAL_UNDEF(&uniqueParams); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&updateValue); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_68); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$9); + ZVAL_UNDEF(&_6$$9); + ZVAL_UNDEF(&_7$$9); + ZVAL_UNDEF(&_9$$12); + ZVAL_UNDEF(&_10$$12); + ZVAL_UNDEF(&_11$$12); + ZVAL_UNDEF(&_12$$20); + ZVAL_UNDEF(&_13$$20); + ZVAL_UNDEF(&_14$$20); + ZVAL_UNDEF(&_16$$21); + ZVAL_UNDEF(&_18$$24); + ZVAL_UNDEF(&_20$$24); + ZVAL_UNDEF(&_23$$32); + ZVAL_UNDEF(&_24$$32); + ZVAL_UNDEF(&_25$$32); + ZVAL_UNDEF(&_26$$35); + ZVAL_UNDEF(&_27$$35); + ZVAL_UNDEF(&_28$$35); + ZVAL_UNDEF(&_29$$43); + ZVAL_UNDEF(&_30$$43); + ZVAL_UNDEF(&_31$$43); + ZVAL_UNDEF(&_33$$44); + ZVAL_UNDEF(&_35$$47); + ZVAL_UNDEF(&_36$$47); + ZVAL_UNDEF(&_40$$53); + ZVAL_UNDEF(&_41$$57); + ZVAL_UNDEF(&_42$$57); + ZVAL_UNDEF(&_43$$57); + ZVAL_UNDEF(&_44$$60); + ZVAL_UNDEF(&_45$$60); + ZVAL_UNDEF(&_46$$60); + ZVAL_UNDEF(&_47$$66); + ZVAL_UNDEF(&_48$$66); + ZVAL_UNDEF(&_49$$66); + ZVAL_UNDEF(&_50$$69); + ZVAL_UNDEF(&_51$$69); + ZVAL_UNDEF(&_52$$69); + ZVAL_UNDEF(&_53$$74); + ZVAL_UNDEF(&_54$$74); + ZVAL_UNDEF(&_55$$74); + ZVAL_UNDEF(&_57$$73); + ZVAL_UNDEF(&_58$$77); + ZVAL_UNDEF(&_59$$77); + ZVAL_UNDEF(&_60$$77); + ZVAL_UNDEF(&_61$$83); + ZVAL_UNDEF(&_62$$83); + ZVAL_UNDEF(&_63$$83); + ZVAL_UNDEF(&_64$$87); + ZVAL_UNDEF(&_65$$87); + ZVAL_UNDEF(&_66$$87); + ZVAL_UNDEF(&_71$$89); + ZVAL_UNDEF(&_72$$90); + ZVAL_UNDEF(&_67); + ZVAL_UNDEF(&_21$$25); + ZVAL_UNDEF(&_22$$25); + ZVAL_UNDEF(&_37$$48); + ZVAL_UNDEF(&_38$$48); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_OBJECT_OF_CLASS(metaData, phalcon_mvc_model_metadatainterface_ce) + Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_db_adapter_adapterinterface_ce) + Z_PARAM_ZVAL(table) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 0, &metaData, &connection, &table); + ZEPHIR_SEPARATE_PARAM(table); + ZEPHIR_INIT_VAR(&bindSkip); + ZVAL_LONG(&bindSkip, 1024); + ZEPHIR_INIT_VAR(&fields); + array_init(&fields); + ZEPHIR_INIT_VAR(&values); + array_init(&values); + ZEPHIR_INIT_VAR(&bindTypes); + array_init(&bindTypes); + ZEPHIR_INIT_VAR(&newSnapshot); + array_init(&newSnapshot); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&manager, &_0); + ZEPHIR_CALL_METHOD(&_1, &manager, "isusingdynamicupdate", NULL, 0, this_ptr); + zephir_check_call_status(); + useDynamicUpdate = zephir_get_boolval(&_1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&snapshot, &_0); + ZEPHIR_CALL_METHOD(&dataTypes, metaData, "getdatatypes", NULL, 0, this_ptr); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&bindDataTypes, metaData, "getbindtypes", NULL, 0, this_ptr); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&nonPrimary, metaData, "getnonprimarykeyattributes", NULL, 0, this_ptr); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&automaticAttributes, metaData, "getautomaticupdateattributes", NULL, 0, this_ptr); + zephir_check_call_status(); + if (ZEPHIR_GLOBAL(orm).column_renaming) { + ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, this_ptr); + zephir_check_call_status(); } else { - ZEPHIR_INIT_VAR(&name); + ZEPHIR_INIT_NVAR(&columnMap); + ZVAL_NULL(&columnMap); } - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); + _2 = useDynamicUpdate; + if (_2) { + _2 = Z_TYPE_P(&snapshot) == IS_ARRAY; + } + if (EXPECTED(_2)) { + zephir_is_iterable(&nonPrimary, 0, "phalcon/Mvc/Model.zep", 4151); + if (Z_TYPE_P(&nonPrimary) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&nonPrimary), _3$$5) + { + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _3$$5); + changed = 0; + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeField); + if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_5$$9); + object_init_ex(&_5$$9, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_6$$9); + zephir_get_class(&_6$$9, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_7$$9); + ZEPHIR_CONCAT_SVSVS(&_7$$9, "Column '", &field, "' in '", &_6$$9, "' isn't part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_5$$9, "__construct", &_8, 33, &_7$$9); + zephir_check_call_status(); + zephir_throw_exception_debug(&_5$$9, "phalcon/Mvc/Model.zep", 4045); + ZEPHIR_MM_RESTORE(); + return; + } + } + } else { + ZEPHIR_CPY_WRT(&attributeField, &field); + } + if (!(zephir_array_isset(&automaticAttributes, &attributeField))) { + ZEPHIR_OBS_NVAR(&bindType); + if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, &bindDataTypes, &field, 0)))) { + ZEPHIR_INIT_NVAR(&_9$$12); + object_init_ex(&_9$$12, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_10$$12); + zephir_get_class(&_10$$12, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_11$$12); + ZEPHIR_CONCAT_SVSVS(&_11$$12, "Column '", &field, "' in '", &_10$$12, "' have not defined a bind data type"); + ZEPHIR_CALL_METHOD(NULL, &_9$$12, "__construct", &_8, 33, &_11$$12); + zephir_check_call_status(); + zephir_throw_exception_debug(&_9$$12, "phalcon/Mvc/Model.zep", 4058); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_OBS_NVAR(&value); + if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { + ZEPHIR_OBS_NVAR(&snapshotValue); + if (!(zephir_array_isset_fetch(&snapshotValue, &snapshot, &attributeField, 0))) { + changed = 1; + } else { + if (Z_TYPE_P(&value) == IS_NULL) { + changed = Z_TYPE_P(&snapshotValue) != IS_NULL; + } else { + if (Z_TYPE_P(&snapshotValue) == IS_NULL) { + changed = 1; + } else { + ZEPHIR_OBS_NVAR(&dataType); + if (UNEXPECTED(!(zephir_array_isset_fetch(&dataType, &dataTypes, &field, 0)))) { + ZEPHIR_INIT_NVAR(&_12$$20); + object_init_ex(&_12$$20, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_13$$20); + zephir_get_class(&_13$$20, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_14$$20); + ZEPHIR_CONCAT_SVSVS(&_14$$20, "Column '", &field, "' in '", &_13$$20, "' have not defined a data type"); + ZEPHIR_CALL_METHOD(NULL, &_12$$20, "__construct", &_8, 33, &_14$$20); + zephir_check_call_status(); + zephir_throw_exception_debug(&_12$$20, "phalcon/Mvc/Model.zep", 4088); + ZEPHIR_MM_RESTORE(); + return; + } + _15$$19 = Z_TYPE_P(&snapshotValue) == IS_OBJECT; + if (_15$$19) { + _15$$19 = zephir_instance_of_ev(&snapshotValue, phalcon_db_rawvalue_ce); + } + if (_15$$19) { + ZEPHIR_CALL_METHOD(&_16$$21, &snapshotValue, "getvalue", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&snapshotValue, &_16$$21); + } + ZEPHIR_CPY_WRT(&updateValue, &value); + _17$$19 = Z_TYPE_P(&value) == IS_OBJECT; + if (_17$$19) { + _17$$19 = zephir_instance_of_ev(&value, phalcon_db_rawvalue_ce); + } + if (_17$$19) { + ZEPHIR_CALL_METHOD(&updateValue, &value, "getvalue", NULL, 0); + zephir_check_call_status(); + } + do { + if (ZEPHIR_IS_LONG(&dataType, 8)) { + changed = zephir_get_boolval(&snapshotValue) != zephir_get_boolval(&updateValue); + break; + } + if (ZEPHIR_IS_LONG(&dataType, 3) || ZEPHIR_IS_LONG(&dataType, 7)) { + ZEPHIR_CALL_FUNCTION(&_18$$24, "floatval", &_19, 18, &snapshotValue); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_20$$24, "floatval", &_19, 18, &updateValue); + zephir_check_call_status(); + changed = !ZEPHIR_IS_IDENTICAL(&_18$$24, &_20$$24); + break; + } + if (ZEPHIR_IS_LONG(&dataType, 0) || ZEPHIR_IS_LONG(&dataType, 1) || ZEPHIR_IS_LONG(&dataType, 2) || ZEPHIR_IS_LONG(&dataType, 4) || ZEPHIR_IS_LONG(&dataType, 5) || ZEPHIR_IS_LONG(&dataType, 6) || ZEPHIR_IS_LONG(&dataType, 2) || ZEPHIR_IS_LONG(&dataType, 14)) { + zephir_cast_to_string(&_21$$25, &snapshotValue); + zephir_cast_to_string(&_22$$25, &updateValue); + changed = !ZEPHIR_IS_IDENTICAL(&_21$$25, &_22$$25); + break; + } + changed = !ZEPHIR_IS_EQUAL(&updateValue, &snapshotValue); + } while(0); + + } + } + } + if (changed) { + zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4138); + zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4139); + zephir_array_append(&bindTypes, &bindType, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4140); + } + zephir_array_update_zval(&newSnapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&newSnapshot, &attributeField, &__$null, PH_COPY | PH_SEPARATE); + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &nonPrimary, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_4$$5, &nonPrimary, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_4$$5)) { + break; + } + ZEPHIR_CALL_METHOD(&field, &nonPrimary, "current", NULL, 0); + zephir_check_call_status(); + changed = 0; + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeField); + if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_23$$32); + object_init_ex(&_23$$32, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_24$$32); + zephir_get_class(&_24$$32, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_25$$32); + ZEPHIR_CONCAT_SVSVS(&_25$$32, "Column '", &field, "' in '", &_24$$32, "' isn't part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_23$$32, "__construct", &_8, 33, &_25$$32); + zephir_check_call_status(); + zephir_throw_exception_debug(&_23$$32, "phalcon/Mvc/Model.zep", 4045); + ZEPHIR_MM_RESTORE(); + return; + } + } + } else { + ZEPHIR_CPY_WRT(&attributeField, &field); + } + if (!(zephir_array_isset(&automaticAttributes, &attributeField))) { + ZEPHIR_OBS_NVAR(&bindType); + if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, &bindDataTypes, &field, 0)))) { + ZEPHIR_INIT_NVAR(&_26$$35); + object_init_ex(&_26$$35, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_27$$35); + zephir_get_class(&_27$$35, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_28$$35); + ZEPHIR_CONCAT_SVSVS(&_28$$35, "Column '", &field, "' in '", &_27$$35, "' have not defined a bind data type"); + ZEPHIR_CALL_METHOD(NULL, &_26$$35, "__construct", &_8, 33, &_28$$35); + zephir_check_call_status(); + zephir_throw_exception_debug(&_26$$35, "phalcon/Mvc/Model.zep", 4058); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_OBS_NVAR(&value); + if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { + ZEPHIR_OBS_NVAR(&snapshotValue); + if (!(zephir_array_isset_fetch(&snapshotValue, &snapshot, &attributeField, 0))) { + changed = 1; + } else { + if (Z_TYPE_P(&value) == IS_NULL) { + changed = Z_TYPE_P(&snapshotValue) != IS_NULL; + } else { + if (Z_TYPE_P(&snapshotValue) == IS_NULL) { + changed = 1; + } else { + ZEPHIR_OBS_NVAR(&dataType); + if (UNEXPECTED(!(zephir_array_isset_fetch(&dataType, &dataTypes, &field, 0)))) { + ZEPHIR_INIT_NVAR(&_29$$43); + object_init_ex(&_29$$43, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_30$$43); + zephir_get_class(&_30$$43, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_31$$43); + ZEPHIR_CONCAT_SVSVS(&_31$$43, "Column '", &field, "' in '", &_30$$43, "' have not defined a data type"); + ZEPHIR_CALL_METHOD(NULL, &_29$$43, "__construct", &_8, 33, &_31$$43); + zephir_check_call_status(); + zephir_throw_exception_debug(&_29$$43, "phalcon/Mvc/Model.zep", 4088); + ZEPHIR_MM_RESTORE(); + return; + } + _32$$42 = Z_TYPE_P(&snapshotValue) == IS_OBJECT; + if (_32$$42) { + _32$$42 = zephir_instance_of_ev(&snapshotValue, phalcon_db_rawvalue_ce); + } + if (_32$$42) { + ZEPHIR_CALL_METHOD(&_33$$44, &snapshotValue, "getvalue", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&snapshotValue, &_33$$44); + } + ZEPHIR_CPY_WRT(&updateValue, &value); + _34$$42 = Z_TYPE_P(&value) == IS_OBJECT; + if (_34$$42) { + _34$$42 = zephir_instance_of_ev(&value, phalcon_db_rawvalue_ce); + } + if (_34$$42) { + ZEPHIR_CALL_METHOD(&updateValue, &value, "getvalue", NULL, 0); + zephir_check_call_status(); + } + do { + if (ZEPHIR_IS_LONG(&dataType, 8)) { + changed = zephir_get_boolval(&snapshotValue) != zephir_get_boolval(&updateValue); + break; + } + if (ZEPHIR_IS_LONG(&dataType, 3) || ZEPHIR_IS_LONG(&dataType, 7)) { + ZEPHIR_CALL_FUNCTION(&_35$$47, "floatval", &_19, 18, &snapshotValue); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_36$$47, "floatval", &_19, 18, &updateValue); + zephir_check_call_status(); + changed = !ZEPHIR_IS_IDENTICAL(&_35$$47, &_36$$47); + break; + } + if (ZEPHIR_IS_LONG(&dataType, 0) || ZEPHIR_IS_LONG(&dataType, 1) || ZEPHIR_IS_LONG(&dataType, 2) || ZEPHIR_IS_LONG(&dataType, 4) || ZEPHIR_IS_LONG(&dataType, 5) || ZEPHIR_IS_LONG(&dataType, 6) || ZEPHIR_IS_LONG(&dataType, 2) || ZEPHIR_IS_LONG(&dataType, 14)) { + zephir_cast_to_string(&_37$$48, &snapshotValue); + zephir_cast_to_string(&_38$$48, &updateValue); + changed = !ZEPHIR_IS_IDENTICAL(&_37$$48, &_38$$48); + break; + } + changed = !ZEPHIR_IS_EQUAL(&updateValue, &snapshotValue); + } while(0); + + } + } + } + if (changed) { + zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4138); + zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4139); + zephir_array_append(&bindTypes, &bindType, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4140); + } + zephir_array_update_zval(&newSnapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&newSnapshot, &attributeField, &__$null, PH_COPY | PH_SEPARATE); + } + } + ZEPHIR_CALL_METHOD(NULL, &nonPrimary, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&field); + if (!(zephir_fast_count_int(&fields))) { + zephir_update_property_zval(this_ptr, ZEND_STRL("oldSnapshot"), &snapshot); + RETURN_MM_BOOL(1); + } } else { - zephir_get_arrval(&attributes, attributes_param); + zephir_is_iterable(&nonPrimary, 0, "phalcon/Mvc/Model.zep", 4206); + if (Z_TYPE_P(&nonPrimary) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&nonPrimary), _39$$53) + { + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _39$$53); + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeField); + if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_41$$57); + object_init_ex(&_41$$57, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_42$$57); + zephir_get_class(&_42$$57, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_43$$57); + ZEPHIR_CONCAT_SVSVS(&_43$$57, "Column '", &field, "' in '", &_42$$57, "' isn't part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_41$$57, "__construct", &_8, 33, &_43$$57); + zephir_check_call_status(); + zephir_throw_exception_debug(&_41$$57, "phalcon/Mvc/Model.zep", 4169); + ZEPHIR_MM_RESTORE(); + return; + } + } + } else { + ZEPHIR_CPY_WRT(&attributeField, &field); + } + if (!(zephir_array_isset(&automaticAttributes, &attributeField))) { + ZEPHIR_OBS_NVAR(&bindType); + if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, &bindDataTypes, &field, 0)))) { + ZEPHIR_INIT_NVAR(&_44$$60); + object_init_ex(&_44$$60, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_45$$60); + zephir_get_class(&_45$$60, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_46$$60); + ZEPHIR_CONCAT_SVSVS(&_46$$60, "Column '", &field, "' in '", &_45$$60, "' have not defined a bind data type"); + ZEPHIR_CALL_METHOD(NULL, &_44$$60, "__construct", &_8, 33, &_46$$60); + zephir_check_call_status(); + zephir_throw_exception_debug(&_44$$60, "phalcon/Mvc/Model.zep", 4183); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_OBS_NVAR(&value); + if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { + zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4194); + zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4195); + zephir_array_append(&bindTypes, &bindType, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4196); + zephir_array_update_zval(&newSnapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&newSnapshot, &attributeField, &__$null, PH_COPY | PH_SEPARATE); + zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4200); + zephir_array_append(&values, &__$null, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4201); + zephir_array_append(&bindTypes, &bindSkip, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4202); + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &nonPrimary, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_40$$53, &nonPrimary, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_40$$53)) { + break; + } + ZEPHIR_CALL_METHOD(&field, &nonPrimary, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeField); + if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_47$$66); + object_init_ex(&_47$$66, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_48$$66); + zephir_get_class(&_48$$66, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_49$$66); + ZEPHIR_CONCAT_SVSVS(&_49$$66, "Column '", &field, "' in '", &_48$$66, "' isn't part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_47$$66, "__construct", &_8, 33, &_49$$66); + zephir_check_call_status(); + zephir_throw_exception_debug(&_47$$66, "phalcon/Mvc/Model.zep", 4169); + ZEPHIR_MM_RESTORE(); + return; + } + } + } else { + ZEPHIR_CPY_WRT(&attributeField, &field); + } + if (!(zephir_array_isset(&automaticAttributes, &attributeField))) { + ZEPHIR_OBS_NVAR(&bindType); + if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, &bindDataTypes, &field, 0)))) { + ZEPHIR_INIT_NVAR(&_50$$69); + object_init_ex(&_50$$69, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_51$$69); + zephir_get_class(&_51$$69, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_52$$69); + ZEPHIR_CONCAT_SVSVS(&_52$$69, "Column '", &field, "' in '", &_51$$69, "' have not defined a bind data type"); + ZEPHIR_CALL_METHOD(NULL, &_50$$69, "__construct", &_8, 33, &_52$$69); + zephir_check_call_status(); + zephir_throw_exception_debug(&_50$$69, "phalcon/Mvc/Model.zep", 4183); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_OBS_NVAR(&value); + if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { + zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4194); + zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4195); + zephir_array_append(&bindTypes, &bindType, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4196); + zephir_array_update_zval(&newSnapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&newSnapshot, &attributeField, &__$null, PH_COPY | PH_SEPARATE); + zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4200); + zephir_array_append(&values, &__$null, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4201); + zephir_array_append(&bindTypes, &bindSkip, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4202); + } + } + ZEPHIR_CALL_METHOD(NULL, &nonPrimary, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&field); } - zephir_memory_observe(&element); - zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(!(zephir_array_isset_fetch(&element, &_0, &name, 0)))) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_forms_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - ZEPHIR_CONCAT_SVS(&_2$$3, "Element with ID=", &name, " is not part of the form"); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3); + if (!(zephir_fast_count_int(&fields))) { + RETURN_MM_BOOL(1); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("uniqueKey"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&uniqueKey, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("uniqueParams"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&uniqueParams, &_0); + if (Z_TYPE_P(&uniqueParams) != IS_ARRAY) { + ZEPHIR_CALL_METHOD(&primaryKeys, metaData, "getprimarykeyattributes", NULL, 0, this_ptr); zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Forms/Form.zep", 772); - ZEPHIR_MM_RESTORE(); - return; + if (UNEXPECTED(!(zephir_fast_count_int(&primaryKeys)))) { + ZEPHIR_INIT_VAR(&_53$$74); + object_init_ex(&_53$$74, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_54$$74); + zephir_get_class(&_54$$74, this_ptr, 0); + ZEPHIR_INIT_VAR(&_55$$74); + ZEPHIR_CONCAT_SVS(&_55$$74, "A primary key must be defined in the model in order to perform the operation in '", &_54$$74, "'"); + ZEPHIR_CALL_METHOD(NULL, &_53$$74, "__construct", &_8, 33, &_55$$74); + zephir_check_call_status(); + zephir_throw_exception_debug(&_53$$74, "phalcon/Mvc/Model.zep", 4229); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_NVAR(&uniqueParams); + array_init(&uniqueParams); + zephir_is_iterable(&primaryKeys, 0, "phalcon/Mvc/Model.zep", 4256); + if (Z_TYPE_P(&primaryKeys) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&primaryKeys), _56$$73) + { + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _56$$73); + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeField); + if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { + ZEPHIR_INIT_NVAR(&_58$$77); + object_init_ex(&_58$$77, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_59$$77); + zephir_get_class(&_59$$77, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_60$$77); + ZEPHIR_CONCAT_SVSVS(&_60$$77, "Column '", &field, "' in '", &_59$$77, "' isn't part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_58$$77, "__construct", &_8, 33, &_60$$77); + zephir_check_call_status(); + zephir_throw_exception_debug(&_58$$77, "phalcon/Mvc/Model.zep", 4242); + ZEPHIR_MM_RESTORE(); + return; + } + } else { + ZEPHIR_CPY_WRT(&attributeField, &field); + } + ZEPHIR_OBS_NVAR(&value); + if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { + zephir_array_update_zval(&newSnapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); + zephir_array_append(&uniqueParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4250); + } else { + zephir_array_update_zval(&newSnapshot, &attributeField, &__$null, PH_COPY | PH_SEPARATE); + zephir_array_append(&uniqueParams, &__$null, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4253); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &primaryKeys, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_57$$73, &primaryKeys, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_57$$73)) { + break; + } + ZEPHIR_CALL_METHOD(&field, &primaryKeys, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeField); + if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { + ZEPHIR_INIT_NVAR(&_61$$83); + object_init_ex(&_61$$83, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_62$$83); + zephir_get_class(&_62$$83, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_63$$83); + ZEPHIR_CONCAT_SVSVS(&_63$$83, "Column '", &field, "' in '", &_62$$83, "' isn't part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_61$$83, "__construct", &_8, 33, &_63$$83); + zephir_check_call_status(); + zephir_throw_exception_debug(&_61$$83, "phalcon/Mvc/Model.zep", 4242); + ZEPHIR_MM_RESTORE(); + return; + } + } else { + ZEPHIR_CPY_WRT(&attributeField, &field); + } + ZEPHIR_OBS_NVAR(&value); + if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { + zephir_array_update_zval(&newSnapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); + zephir_array_append(&uniqueParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4250); + } else { + zephir_array_update_zval(&newSnapshot, &attributeField, &__$null, PH_COPY | PH_SEPARATE); + zephir_array_append(&uniqueParams, &__$null, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4253); + } + ZEPHIR_CALL_METHOD(NULL, &primaryKeys, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&field); } - ZEPHIR_RETURN_CALL_METHOD(&element, "label", NULL, 0, &attributes); + if (Z_TYPE_P(table) == IS_ARRAY) { + zephir_array_fetch_long(&_64$$87, table, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 4262); + zephir_array_fetch_long(&_65$$87, table, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 4262); + ZEPHIR_INIT_VAR(&_66$$87); + ZEPHIR_CONCAT_VSV(&_66$$87, &_64$$87, ".", &_65$$87); + ZEPHIR_CPY_WRT(table, &_66$$87); + } + ZEPHIR_INIT_VAR(&_67); + zephir_create_array(&_67, 3, 0); + zephir_array_update_string(&_67, SL("conditions"), &uniqueKey, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_67, SL("bind"), &uniqueParams, PH_COPY | PH_SEPARATE); + zephir_memory_observe(&_68); + zephir_read_property(&_68, this_ptr, ZEND_STRL("uniqueTypes"), PH_NOISY_CC); + zephir_array_update_string(&_67, SL("bindTypes"), &_68, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&success, connection, "update", NULL, 0, table, &fields, &values, &_67, &bindTypes); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Forms_Form, next) -{ - zval *this_ptr = getThis(); - RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("position"))); + _69 = zephir_is_true(&success); + if (_69) { + ZEPHIR_CALL_METHOD(&_1, &manager, "iskeepingsnapshots", NULL, 0, this_ptr); + zephir_check_call_status(); + _69 = zephir_is_true(&_1); + } + _70 = _69; + if (_70) { + _70 = ZEPHIR_GLOBAL(orm).update_snapshot_on_save; + } + if (_70) { + if (Z_TYPE_P(&snapshot) == IS_ARRAY) { + zephir_update_property_zval(this_ptr, ZEND_STRL("oldSnapshot"), &snapshot); + ZEPHIR_INIT_VAR(&_71$$89); + zephir_fast_array_merge(&_71$$89, &snapshot, &newSnapshot); + zephir_update_property_zval(this_ptr, ZEND_STRL("snapshot"), &_71$$89); + } else { + ZEPHIR_INIT_VAR(&_72$$90); + array_init(&_72$$90); + zephir_update_property_zval(this_ptr, ZEND_STRL("oldSnapshot"), &_72$$90); + zephir_update_property_zval(this_ptr, ZEND_STRL("snapshot"), &newSnapshot); + } + } + RETURN_CCTOR(&success); } -static PHP_METHOD(Phalcon_Forms_Form, render) +static PHP_METHOD(Phalcon_Mvc_Model, has) { + zend_bool _7$$11, _17$$19; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes; - zval *name_param = NULL, *attributes_param = NULL, element, _0, _1$$3; - zval name, _2$$3; + zephir_fcall_cache_entry *_6 = NULL, *_12 = NULL, *_22 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, numberEmpty = 0, numberPrimary = 0; + zval *metaData, metaData_sub, *connection, connection_sub, __$null, attributeField, bindDataTypes, columnMap, field, joinWhere, num, primaryKeys, schema, source, table, type, uniqueKey, uniqueParams, uniqueTypes, value, wherePk, _0, _27, _28, _29, _30, *_1$$3, _2$$3, _3$$9, _4$$9, _5$$9, _8$$14, _9$$14, _10$$14, _11$$7, _13$$7, _14$$17, _15$$17, _16$$17, _18$$22, _19$$22, _20$$22, _21$$15, _23$$15, _24$$25, _25$$26, _26$$27, _31$$30, _32$$31; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&element); + ZVAL_UNDEF(&metaData_sub); + ZVAL_UNDEF(&connection_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&attributeField); + ZVAL_UNDEF(&bindDataTypes); + ZVAL_UNDEF(&columnMap); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&joinWhere); + ZVAL_UNDEF(&num); + ZVAL_UNDEF(&primaryKeys); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&uniqueKey); + ZVAL_UNDEF(&uniqueParams); + ZVAL_UNDEF(&uniqueTypes); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&wherePk); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(name) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) + ZVAL_UNDEF(&_27); + ZVAL_UNDEF(&_28); + ZVAL_UNDEF(&_29); + ZVAL_UNDEF(&_30); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$9); + ZVAL_UNDEF(&_4$$9); + ZVAL_UNDEF(&_5$$9); + ZVAL_UNDEF(&_8$$14); + ZVAL_UNDEF(&_9$$14); + ZVAL_UNDEF(&_10$$14); + ZVAL_UNDEF(&_11$$7); + ZVAL_UNDEF(&_13$$7); + ZVAL_UNDEF(&_14$$17); + ZVAL_UNDEF(&_15$$17); + ZVAL_UNDEF(&_16$$17); + ZVAL_UNDEF(&_18$$22); + ZVAL_UNDEF(&_19$$22); + ZVAL_UNDEF(&_20$$22); + ZVAL_UNDEF(&_21$$15); + ZVAL_UNDEF(&_23$$15); + ZVAL_UNDEF(&_24$$25); + ZVAL_UNDEF(&_25$$26); + ZVAL_UNDEF(&_26$$27); + ZVAL_UNDEF(&_31$$30); + ZVAL_UNDEF(&_32$$31); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(metaData, phalcon_mvc_model_metadatainterface_ce) + Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_db_adapter_adapterinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &name_param, &attributes_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 2, 0, &metaData, &connection); + ZEPHIR_INIT_VAR(&uniqueParams); + ZVAL_NULL(&uniqueParams); + ZEPHIR_INIT_VAR(&uniqueTypes); + ZVAL_NULL(&uniqueTypes); + zephir_read_property(&_0, this_ptr, ZEND_STRL("uniqueKey"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&uniqueKey, &_0); + if (Z_TYPE_P(&uniqueKey) == IS_NULL) { + ZEPHIR_CALL_METHOD(&primaryKeys, metaData, "getprimarykeyattributes", NULL, 0, this_ptr); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&bindDataTypes, metaData, "getbindtypes", NULL, 0, this_ptr); + zephir_check_call_status(); + numberPrimary = zephir_fast_count_int(&primaryKeys); + if (!(numberPrimary)) { + RETURN_MM_BOOL(0); + } + if (ZEPHIR_GLOBAL(orm).column_renaming) { + ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, this_ptr); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&columnMap); + ZVAL_NULL(&columnMap); + } + numberEmpty = 0; + ZEPHIR_INIT_VAR(&wherePk); + array_init(&wherePk); + ZEPHIR_INIT_NVAR(&uniqueParams); + array_init(&uniqueParams); + ZEPHIR_INIT_NVAR(&uniqueTypes); + array_init(&uniqueTypes); + zephir_is_iterable(&primaryKeys, 0, "phalcon/Mvc/Model.zep", 4386); + if (Z_TYPE_P(&primaryKeys) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&primaryKeys), _1$$3) + { + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _1$$3); + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeField); + if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { + ZEPHIR_INIT_NVAR(&_3$$9); + object_init_ex(&_3$$9, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_4$$9); + zephir_get_class(&_4$$9, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_5$$9); + ZEPHIR_CONCAT_SVSVS(&_5$$9, "Column '", &field, "' in '", &_4$$9, "' isn't part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_3$$9, "__construct", &_6, 33, &_5$$9); + zephir_check_call_status(); + zephir_throw_exception_debug(&_3$$9, "phalcon/Mvc/Model.zep", 4345); + ZEPHIR_MM_RESTORE(); + return; + } + } else { + ZEPHIR_CPY_WRT(&attributeField, &field); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_NULL(&value); + ZEPHIR_OBS_NVAR(&value); + if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { + _7$$11 = Z_TYPE_P(&value) == IS_NULL; + if (!(_7$$11)) { + _7$$11 = ZEPHIR_IS_STRING_IDENTICAL(&value, ""); + } + if (_7$$11) { + numberEmpty++; + } + zephir_array_append(&uniqueParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4366); + } else { + zephir_array_append(&uniqueParams, &__$null, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4368); + numberEmpty++; + } + ZEPHIR_OBS_NVAR(&type); + if (UNEXPECTED(!(zephir_array_isset_fetch(&type, &bindDataTypes, &field, 0)))) { + ZEPHIR_INIT_NVAR(&_8$$14); + object_init_ex(&_8$$14, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_9$$14); + zephir_get_class(&_9$$14, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_10$$14); + ZEPHIR_CONCAT_SVSVS(&_10$$14, "Column '", &field, "' in '", &_9$$14, "' isn't part of the table columns"); + ZEPHIR_CALL_METHOD(NULL, &_8$$14, "__construct", &_6, 33, &_10$$14); + zephir_check_call_status(); + zephir_throw_exception_debug(&_8$$14, "phalcon/Mvc/Model.zep", 4375); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_array_append(&uniqueTypes, &type, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4378); + ZEPHIR_CALL_METHOD(&_11$$7, connection, "escapeidentifier", &_12, 0, &field); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_13$$7); + ZEPHIR_CONCAT_VS(&_13$$7, &_11$$7, " = ?"); + zephir_array_append(&wherePk, &_13$$7, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4379); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &primaryKeys, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2$$3, &primaryKeys, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&field, &primaryKeys, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeField); + if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { + ZEPHIR_INIT_NVAR(&_14$$17); + object_init_ex(&_14$$17, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_15$$17); + zephir_get_class(&_15$$17, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_16$$17); + ZEPHIR_CONCAT_SVSVS(&_16$$17, "Column '", &field, "' in '", &_15$$17, "' isn't part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_14$$17, "__construct", &_6, 33, &_16$$17); + zephir_check_call_status(); + zephir_throw_exception_debug(&_14$$17, "phalcon/Mvc/Model.zep", 4345); + ZEPHIR_MM_RESTORE(); + return; + } + } else { + ZEPHIR_CPY_WRT(&attributeField, &field); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_NULL(&value); + ZEPHIR_OBS_NVAR(&value); + if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { + _17$$19 = Z_TYPE_P(&value) == IS_NULL; + if (!(_17$$19)) { + _17$$19 = ZEPHIR_IS_STRING_IDENTICAL(&value, ""); + } + if (_17$$19) { + numberEmpty++; + } + zephir_array_append(&uniqueParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4366); + } else { + zephir_array_append(&uniqueParams, &__$null, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4368); + numberEmpty++; + } + ZEPHIR_OBS_NVAR(&type); + if (UNEXPECTED(!(zephir_array_isset_fetch(&type, &bindDataTypes, &field, 0)))) { + ZEPHIR_INIT_NVAR(&_18$$22); + object_init_ex(&_18$$22, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_19$$22); + zephir_get_class(&_19$$22, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_20$$22); + ZEPHIR_CONCAT_SVSVS(&_20$$22, "Column '", &field, "' in '", &_19$$22, "' isn't part of the table columns"); + ZEPHIR_CALL_METHOD(NULL, &_18$$22, "__construct", &_6, 33, &_20$$22); + zephir_check_call_status(); + zephir_throw_exception_debug(&_18$$22, "phalcon/Mvc/Model.zep", 4375); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_array_append(&uniqueTypes, &type, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4378); + ZEPHIR_CALL_METHOD(&_21$$15, connection, "escapeidentifier", &_22, 0, &field); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_23$$15); + ZEPHIR_CONCAT_VS(&_23$$15, &_21$$15, " = ?"); + zephir_array_append(&wherePk, &_23$$15, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4379); + ZEPHIR_CALL_METHOD(NULL, &primaryKeys, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&field); + if (numberPrimary == numberEmpty) { + RETURN_MM_BOOL(0); + } + ZEPHIR_INIT_VAR(&joinWhere); + zephir_fast_join_str(&joinWhere, SL(" AND "), &wherePk); + zephir_update_property_zval(this_ptr, ZEND_STRL("uniqueKey"), &joinWhere); + zephir_update_property_zval(this_ptr, ZEND_STRL("uniqueParams"), &uniqueParams); + zephir_update_property_zval(this_ptr, ZEND_STRL("uniqueTypes"), &uniqueTypes); + ZEPHIR_CPY_WRT(&uniqueKey, &joinWhere); } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); + zephir_read_property(&_0, this_ptr, ZEND_STRL("dirtyState"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_is_true(&_0))) { + RETURN_MM_BOOL(1); } - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - } else { - zephir_get_arrval(&attributes, attributes_param); + if (Z_TYPE_P(&uniqueKey) == IS_NULL) { + zephir_read_property(&_24$$25, this_ptr, ZEND_STRL("uniqueKey"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&uniqueKey, &_24$$25); } - zephir_memory_observe(&element); - zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(!(zephir_array_isset_fetch(&element, &_0, &name, 0)))) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_forms_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - ZEPHIR_CONCAT_SVS(&_2$$3, "Element with ID=", &name, " is not part of the form"); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Forms/Form.zep", 796); - ZEPHIR_MM_RESTORE(); - return; + if (Z_TYPE_P(&uniqueParams) == IS_NULL) { + zephir_read_property(&_25$$26, this_ptr, ZEND_STRL("uniqueParams"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&uniqueParams, &_25$$26); } - ZEPHIR_RETURN_CALL_METHOD(&element, "render", NULL, 0, &attributes); + if (Z_TYPE_P(&uniqueTypes) == IS_NULL) { + zephir_read_property(&_26$$27, this_ptr, ZEND_STRL("uniqueTypes"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&uniqueTypes, &_26$$27); + } + ZEPHIR_CALL_METHOD(&schema, this_ptr, "getschema", NULL, 423); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 424); + zephir_check_call_status(); + if (zephir_is_true(&schema)) { + ZEPHIR_INIT_VAR(&table); + zephir_create_array(&table, 2, 0); + zephir_array_fast_append(&table, &schema); + zephir_array_fast_append(&table, &source); + } else { + ZEPHIR_CPY_WRT(&table, &source); + } + ZEPHIR_CALL_METHOD(&_27, connection, "escapeidentifier", NULL, 0, &table); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_28); + ZEPHIR_CONCAT_SVSV(&_28, "SELECT COUNT(*) \"rowcount\" FROM ", &_27, " WHERE ", &uniqueKey); + ZVAL_NULL(&_29); + ZEPHIR_CALL_METHOD(&num, connection, "fetchone", NULL, 0, &_28, &_29, &uniqueParams, &uniqueTypes); + zephir_check_call_status(); + zephir_array_fetch_string(&_30, &num, SL("rowcount"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 4440); + if (zephir_is_true(&_30)) { + ZVAL_UNDEF(&_31$$30); + ZVAL_LONG(&_31$$30, 0); + zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &_31$$30); + RETURN_MM_BOOL(1); + } else { + ZVAL_UNDEF(&_32$$31); + ZVAL_LONG(&_32$$31, 1); + zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &_32$$31); + } + RETURN_MM_BOOL(0); } -static PHP_METHOD(Phalcon_Forms_Form, remove) +static PHP_METHOD(Phalcon_Mvc_Model, getRelatedRecords) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, __$null, _0, _1$$3; - zval name; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval arguments; + zval *modelName_param = NULL, *method_param = NULL, *arguments_param = NULL, manager, relation, queryMethod, extraArgs, alias, _0, _1$$3, _2$$3, _3$$5, _4$$5, _5$$5; + zval modelName, method; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&queryMethod); + ZVAL_UNDEF(&extraArgs); + ZVAL_UNDEF(&alias); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&arguments); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(modelName) + Z_PARAM_STR(method) + Z_PARAM_ARRAY(arguments) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + zephir_fetch_params(1, 3, 0, &modelName_param, &method_param, &arguments_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); } else { - ZEPHIR_INIT_VAR(&name); + ZEPHIR_INIT_VAR(&modelName); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset(&_0, &name)) { - zephir_unset_property_array(this_ptr, ZEND_STRL("elements"), &name); - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - zephir_array_unset(&_1$$3, &name, PH_SEPARATE); - RETURN_MM_BOOL(1); + if (UNEXPECTED(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 of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(method_param) == IS_STRING)) { + zephir_get_strval(&method, method_param); + } else { + ZEPHIR_INIT_VAR(&method); + } + ZEPHIR_OBS_COPY_OR_DUP(&arguments, arguments_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&manager, &_0); + ZEPHIR_INIT_VAR(&relation); + ZVAL_BOOL(&relation, 0); + ZEPHIR_INIT_VAR(&queryMethod); + ZVAL_NULL(&queryMethod); + zephir_memory_observe(&extraArgs); + zephir_array_isset_long_fetch(&extraArgs, &arguments, 0, 0); + if (zephir_start_with_str(&method, SL("get"))) { + ZVAL_LONG(&_1$$3, 3); + ZEPHIR_INIT_VAR(&alias); + zephir_substr(&alias, &method, 3 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + ZEPHIR_CALL_METHOD(&_2$$3, &manager, "getrelationbyalias", NULL, 0, &modelName, &alias); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&relation, &_2$$3); + if (Z_TYPE_P(&relation) != IS_OBJECT) { + RETURN_MM_BOOL(0); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelated", NULL, 0, &alias, &extraArgs); + zephir_check_call_status(); + RETURN_MM(); + } + if (zephir_start_with_str(&method, SL("count"))) { + ZEPHIR_INIT_NVAR(&queryMethod); + ZVAL_STRING(&queryMethod, "count"); + ZVAL_LONG(&_4$$5, 5); + ZEPHIR_INIT_VAR(&_5$$5); + zephir_substr(&_5$$5, &method, 5 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + ZEPHIR_CALL_METHOD(&_3$$5, &manager, "getrelationbyalias", NULL, 0, &modelName, &_5$$5); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&relation, &_3$$5); + if (Z_TYPE_P(&relation) != IS_OBJECT) { + RETURN_MM_BOOL(0); + } + ZEPHIR_RETURN_CALL_METHOD(&manager, "getrelationrecords", NULL, 0, &relation, this_ptr, &extraArgs, &queryMethod); + zephir_check_call_status(); + RETURN_MM(); } - zephir_update_property_zval(this_ptr, ZEND_STRL("elementsIndexed"), &__$null); RETURN_MM_BOOL(0); } -static PHP_METHOD(Phalcon_Forms_Form, rewind) -{ - zval _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, 0); - zephir_update_property_zval(this_ptr, ZEND_STRL("position"), &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_1, "array_values", NULL, 14, &_0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("elementsIndexed"), &_1); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Forms_Form, setAction) +static PHP_METHOD(Phalcon_Mvc_Model, groupResult) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *action_param = NULL, _0, _1; - zval action; - zval *this_ptr = getThis(); + zval *functionName_param = NULL, *alias_param = NULL, *parameters = NULL, parameters_sub, __$null, params, distinctColumn, groupColumn, columns, resultset, cache, firstRow, groupColumns, builder, query, container, manager, transaction, bindParams, bindTypes, _0, _1, _2; + zval functionName, alias; - ZVAL_UNDEF(&action); + ZVAL_UNDEF(&functionName); + ZVAL_UNDEF(&alias); + ZVAL_UNDEF(¶meters_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&distinctColumn); + ZVAL_UNDEF(&groupColumn); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&resultset); + ZVAL_UNDEF(&cache); + ZVAL_UNDEF(&firstRow); + ZVAL_UNDEF(&groupColumns); + ZVAL_UNDEF(&builder); + ZVAL_UNDEF(&query); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&transaction); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(action) + ZVAL_UNDEF(&_2); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(functionName) + Z_PARAM_STR(alias) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(parameters) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &action_param); - if (UNEXPECTED(Z_TYPE_P(action_param) != IS_STRING && Z_TYPE_P(action_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'action' must be of the type string")); + zephir_fetch_params(1, 2, 1, &functionName_param, &alias_param, ¶meters); + if (UNEXPECTED(Z_TYPE_P(functionName_param) != IS_STRING && Z_TYPE_P(functionName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'functionName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(action_param) == IS_STRING)) { - zephir_get_strval(&action, action_param); + if (EXPECTED(Z_TYPE_P(functionName_param) == IS_STRING)) { + zephir_get_strval(&functionName, functionName_param); } else { - ZEPHIR_INIT_VAR(&action); + ZEPHIR_INIT_VAR(&functionName); } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getattributes", NULL, 0); + if (UNEXPECTED(Z_TYPE_P(alias_param) != IS_STRING && Z_TYPE_P(alias_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'alias' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(alias_param) == IS_STRING)) { + zephir_get_strval(&alias, alias_param); + } else { + ZEPHIR_INIT_VAR(&alias); + } + if (!parameters) { + parameters = ¶meters_sub; + parameters = &__$null; + } + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); + ZEPHIR_INIT_VAR(&bindTypes); + array_init(&bindTypes); + ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "action"); - ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &_1, &action); + ZVAL_STRING(&_1, "modelsManager"); + ZEPHIR_CALL_METHOD(&_0, &container, "getshared", NULL, 0, &_1); zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Forms_Form, setAttributes) -{ - zval *attributes, attributes_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&attributes_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(attributes, phalcon_html_attributes_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &attributes); - zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), attributes); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Forms_Form, setEntity) -{ - zval *entity, entity_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&entity_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(entity) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &entity); - zephir_update_property_zval(this_ptr, ZEND_STRL("entity"), entity); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Forms_Form, setTagFactory) -{ - zval *tagFactory, tagFactory_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&tagFactory_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(tagFactory, phalcon_html_tagfactory_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &tagFactory); - zephir_update_property_zval(this_ptr, ZEND_STRL("tagFactory"), tagFactory); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Forms_Form, setValidation) -{ - zval *validation, validation_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&validation_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_validationinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &validation); - zephir_update_property_zval(this_ptr, ZEND_STRL("validation"), validation); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Forms_Form, setWhitelist) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *whitelist_param = NULL; - zval whitelist; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&whitelist); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(whitelist) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &whitelist_param); - zephir_get_arrval(&whitelist, whitelist_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("whitelist"), &whitelist); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Forms_Form, setUserOption) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *option_param = NULL, *value, value_sub; - zval option; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&option); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(option) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &option_param, &value); - zephir_get_strval(&option, option_param); - zephir_update_property_array(this_ptr, SL("options"), &option, value); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Forms_Form, setUserOptions) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *options_param = NULL; - zval options; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &options_param); - ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Forms_Form, valid) -{ - zval _0, _1; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("elementsIndexed"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_1, this_ptr, ZEND_STRL("position"), PH_NOISY_CC | PH_READONLY); - RETURN_BOOL(zephir_array_isset(&_0, &_1)); -} - -zend_object *zephir_init_properties_Phalcon_Forms_Form(zend_class_entry *class_type) -{ - zval _0, _2, _4, _6, _8, _10, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_11$$8); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("whitelist"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("whitelist"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("elementsIndexed"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("elementsIndexed"), &_5$$5); + ZEPHIR_CPY_WRT(&manager, &_0); + if (Z_TYPE_P(parameters) != IS_ARRAY) { + ZEPHIR_INIT_VAR(¶ms); + array_init(¶ms); + if (Z_TYPE_P(parameters) != IS_NULL) { + zephir_array_append(¶ms, parameters, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4545); } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("elements"), &_7$$6); + } else { + ZEPHIR_CPY_WRT(¶ms, parameters); + } + zephir_memory_observe(&groupColumn); + if (!(zephir_array_isset_string_fetch(&groupColumn, ¶ms, SL("column"), 0))) { + ZEPHIR_INIT_NVAR(&groupColumn); + ZVAL_STRING(&groupColumn, "*"); + } + zephir_memory_observe(&distinctColumn); + if (zephir_array_isset_string_fetch(&distinctColumn, ¶ms, SL("distinct"), 0)) { + ZEPHIR_INIT_VAR(&columns); + ZEPHIR_CONCAT_VSVSV(&columns, &functionName, "(DISTINCT ", &distinctColumn, ") AS ", &alias); + } else { + zephir_memory_observe(&groupColumns); + ZEPHIR_INIT_NVAR(&columns); + if (zephir_array_isset_string_fetch(&groupColumns, ¶ms, SL("group"), 0)) { + ZEPHIR_CONCAT_VSVSVSV(&columns, &groupColumns, ", ", &functionName, "(", &groupColumn, ") AS ", &alias); + } else { + ZEPHIR_CONCAT_VSVSV(&columns, &functionName, "(", &groupColumn, ") AS ", &alias); } - zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("filteredData"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_8) == IS_NULL) { - ZEPHIR_INIT_VAR(&_9$$7); - array_init(&_9$$7); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("filteredData"), &_9$$7); + } + ZEPHIR_CALL_METHOD(&_0, &manager, "createbuilder", NULL, 0, ¶ms); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&builder, &_0); + ZEPHIR_CALL_METHOD(NULL, &builder, "columns", NULL, 0, &columns); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_1); + zephir_get_called_class(&_1); + ZEPHIR_CALL_METHOD(NULL, &builder, "from", NULL, 0, &_1); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, &builder, "getquery", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&query, &_0); + zephir_memory_observe(&transaction); + if (zephir_array_isset_string_fetch(&transaction, ¶ms, SL("transaction"), 0)) { + if (zephir_instance_of_ev(&transaction, phalcon_mvc_model_transactioninterface_ce)) { + ZEPHIR_CALL_METHOD(NULL, &query, "settransaction", NULL, 0, &transaction); + zephir_check_call_status(); } - zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_10) == IS_NULL) { - ZEPHIR_INIT_VAR(&_11$$8); - array_init(&_11$$8); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("data"), &_11$$8); + } + if (zephir_array_isset_string(¶ms, SL("bind"))) { + ZEPHIR_OBS_NVAR(&bindParams); + zephir_array_fetch_string(&bindParams, ¶ms, SL("bind"), PH_NOISY, "phalcon/Mvc/Model.zep", 4588); + if (zephir_array_isset_string(¶ms, SL("bindTypes"))) { + ZEPHIR_OBS_NVAR(&bindTypes); + zephir_array_fetch_string(&bindTypes, ¶ms, SL("bindTypes"), PH_NOISY, "phalcon/Mvc/Model.zep", 4591); } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Forms_Manager) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Forms, Manager, phalcon, forms_manager, phalcon_forms_manager_method_entry, 0); - - zend_declare_property_null(phalcon_forms_manager_ce, SL("forms"), ZEND_ACC_PROTECTED); - phalcon_forms_manager_ce->create_object = zephir_init_properties_Phalcon_Forms_Manager; - - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Forms_Manager, create) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, *entity = NULL, entity_sub, __$null, form; - zval name; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&entity_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&form); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(name) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(entity) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &name_param, &entity); - zephir_get_strval(&name, name_param); - if (!entity) { - entity = &entity_sub; - entity = &__$null; + zephir_memory_observe(&cache); + if (zephir_array_isset_string_fetch(&cache, ¶ms, SL("cache"), 0)) { + ZEPHIR_CALL_METHOD(NULL, &query, "cache", NULL, 0, &cache); + zephir_check_call_status(); } - ZEPHIR_INIT_VAR(&form); - object_init_ex(&form, phalcon_forms_form_ce); - ZEPHIR_CALL_METHOD(NULL, &form, "__construct", NULL, 319, entity); + ZEPHIR_CALL_METHOD(&resultset, &query, "execute", NULL, 0, &bindParams, &bindTypes); zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("forms"), &name, &form); - RETURN_CCTOR(&form); + if (zephir_array_isset_string(¶ms, SL("group"))) { + RETURN_CCTOR(&resultset); + } + ZEPHIR_CALL_METHOD(&firstRow, &resultset, "getfirst", NULL, 0); + zephir_check_call_status(); + zephir_memory_observe(&_2); + zephir_read_property_zval(&_2, &firstRow, &alias, PH_NOISY_CC); + RETURN_CCTOR(&_2); } -static PHP_METHOD(Phalcon_Forms_Manager, get) +static PHP_METHOD(Phalcon_Mvc_Model, invokeFinder) { + zend_class_entry *_15; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, form, _0, _1$$3; - zval name, _2$$3; - zval *this_ptr = getThis(); + zval arguments, _11$$14; + zval *method_param = NULL, *arguments_param = NULL, extraMethod, type, modelName, value, model, attributes, field, extraMethodFirst, metaData, params, _14, _0$$3, _1$$4, _2$$5, _3$$7, _4$$7, _5$$7, _6$$13, _7$$13, _8$$13, _9$$14, _10$$14, _12$$15, _13$$15; + zval method; - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&form); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&extraMethod); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&extraMethodFirst); + ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_3$$7); + ZVAL_UNDEF(&_4$$7); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_6$$13); + ZVAL_UNDEF(&_7$$13); + ZVAL_UNDEF(&_8$$13); + ZVAL_UNDEF(&_9$$14); + ZVAL_UNDEF(&_10$$14); + ZVAL_UNDEF(&_12$$15); + ZVAL_UNDEF(&_13$$15); + ZVAL_UNDEF(&arguments); + ZVAL_UNDEF(&_11$$14); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(method) + Z_PARAM_ARRAY(arguments) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - zephir_get_strval(&name, name_param); - zephir_memory_observe(&form); - zephir_read_property(&_0, this_ptr, ZEND_STRL("forms"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(!(zephir_array_isset_fetch(&form, &_0, &name, 0)))) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_forms_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - ZEPHIR_CONCAT_SVS(&_2$$3, "There is no form with name='", &name, "'"); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3); + zephir_fetch_params(1, 2, 0, &method_param, &arguments_param); + zephir_get_strval(&method, method_param); + zephir_get_arrval(&arguments, arguments_param); + ZEPHIR_INIT_VAR(&extraMethod); + ZVAL_NULL(&extraMethod); + if (zephir_start_with_str(&method, SL("findFirstBy"))) { + ZEPHIR_INIT_VAR(&type); + ZVAL_STRING(&type, "findFirst"); + ZVAL_LONG(&_0$$3, 11); + ZEPHIR_INIT_NVAR(&extraMethod); + zephir_substr(&extraMethod, &method, 11 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + } else if (zephir_start_with_str(&method, SL("findBy"))) { + ZEPHIR_INIT_NVAR(&type); + ZVAL_STRING(&type, "find"); + ZVAL_LONG(&_1$$4, 6); + ZEPHIR_INIT_NVAR(&extraMethod); + zephir_substr(&extraMethod, &method, 6 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + } else if (zephir_start_with_str(&method, SL("countBy"))) { + ZEPHIR_INIT_NVAR(&type); + ZVAL_STRING(&type, "count"); + ZVAL_LONG(&_2$$5, 7); + ZEPHIR_INIT_NVAR(&extraMethod); + zephir_substr(&extraMethod, &method, 7 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + } + ZEPHIR_INIT_VAR(&modelName); + zephir_get_called_class(&modelName); + if (!(zephir_is_true(&extraMethod))) { + RETURN_MM_BOOL(0); + } + if (UNEXPECTED(!(zephir_array_isset_long(&arguments, 0)))) { + ZEPHIR_INIT_VAR(&_3$$7); + object_init_ex(&_3$$7, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_4$$7); + zephir_get_called_class(&_4$$7); + ZEPHIR_INIT_VAR(&_5$$7); + ZEPHIR_CONCAT_SVSVS(&_5$$7, "The static method '", &method, "' in '", &_4$$7, "' requires one argument"); + ZEPHIR_CALL_METHOD(NULL, &_3$$7, "__construct", NULL, 33, &_5$$7); zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Forms/Manager.zep", 46); + zephir_throw_exception_debug(&_3$$7, "phalcon/Mvc/Model.zep", 4670); ZEPHIR_MM_RESTORE(); return; } - RETURN_CCTOR(&form); -} - -static PHP_METHOD(Phalcon_Forms_Manager, has) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, _0; - zval name; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - zephir_get_strval(&name, name_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("forms"), PH_NOISY_CC | PH_READONLY); - RETURN_MM_BOOL(zephir_array_isset(&_0, &name)); -} - -static PHP_METHOD(Phalcon_Forms_Manager, set) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, *form, form_sub; - zval name; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&form_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_OBJECT_OF_CLASS(form, phalcon_forms_form_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &form); - zephir_get_strval(&name, name_param); - zephir_update_property_array(this_ptr, SL("forms"), &name, form); - RETURN_THIS(); -} - -zend_object *zephir_init_properties_Phalcon_Forms_Manager(zend_class_entry *class_type) -{ - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("forms"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("forms"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + ZEPHIR_INIT_VAR(&model); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&model, &modelName); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&metaData, &model, "getmodelsmetadata", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&attributes, &metaData, "getreversecolumnmap", NULL, 0, &model); + zephir_check_call_status(); + if (Z_TYPE_P(&attributes) != IS_ARRAY) { + ZEPHIR_CALL_METHOD(&attributes, &metaData, "getdatatypes", NULL, 0, &model); + zephir_check_call_status(); } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_AbstractElement) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Forms\\Element, AbstractElement, phalcon, forms_element_abstractelement, phalcon_forms_element_abstractelement_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("attributes"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("filters"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("form"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("label"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_forms_element_abstractelement_ce, SL("method"), "inputText", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("messages"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("name"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("options"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("tagFactory"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("validators"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("value"), ZEND_ACC_PROTECTED); - phalcon_forms_element_abstractelement_ce->create_object = zephir_init_properties_Phalcon_Forms_Element_AbstractElement; - - zend_class_implements(phalcon_forms_element_abstractelement_ce, 1, phalcon_forms_element_elementinterface_ce); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes; - zval *name_param = NULL, *attributes_param = NULL, _0, _1; - zval name; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(name) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &name_param, &attributes_param); - zephir_get_strval(&name, name_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); + if (zephir_array_isset(&attributes, &extraMethod)) { + ZEPHIR_CPY_WRT(&field, &extraMethod); } else { - zephir_get_arrval(&attributes, attributes_param); + ZEPHIR_CALL_FUNCTION(&extraMethodFirst, "lcfirst", NULL, 76, &extraMethod); + zephir_check_call_status(); + if (zephir_array_isset(&attributes, &extraMethodFirst)) { + ZEPHIR_CPY_WRT(&field, &extraMethodFirst); + } else { + ZEPHIR_INIT_NVAR(&field); + zephir_uncamelize(&field, &extraMethod, NULL ); + if (UNEXPECTED(!(zephir_array_isset(&attributes, &field)))) { + ZEPHIR_INIT_VAR(&_6$$13); + object_init_ex(&_6$$13, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_7$$13); + zephir_get_called_class(&_7$$13); + ZEPHIR_INIT_VAR(&_8$$13); + ZEPHIR_CONCAT_SVSVS(&_8$$13, "Cannot resolve attribute '", &extraMethod, "' in the model '", &_7$$13, "'"); + ZEPHIR_CALL_METHOD(NULL, &_6$$13, "__construct", NULL, 33, &_8$$13); + zephir_check_call_status(); + zephir_throw_exception_debug(&_6$$13, "phalcon/Mvc/Model.zep", 4707); + ZEPHIR_MM_RESTORE(); + return; + } + } } - ZEPHIR_INIT_VAR(&_0); - zephir_fast_trim(&_0, &name, NULL , ZEPHIR_TRIM_BOTH); - zephir_get_strval(&name, &_0); - if (UNEXPECTED(ZEPHIR_IS_EMPTY(&name))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Form element name is required", "phalcon/Forms/Element/AbstractElement.zep", 97); - return; + zephir_memory_observe(&value); + zephir_array_isset_long_fetch(&value, &arguments, 0, 0); + ZEPHIR_INIT_VAR(¶ms); + if (Z_TYPE_P(&value) != IS_NULL) { + ZEPHIR_INIT_VAR(&_9$$14); + zephir_create_array(&_9$$14, 2, 0); + ZEPHIR_INIT_VAR(&_10$$14); + ZEPHIR_CONCAT_SVS(&_10$$14, "[", &field, "] = ?0"); + zephir_array_update_string(&_9$$14, SL("conditions"), &_10$$14, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_11$$14); + zephir_create_array(&_11$$14, 1, 0); + zephir_array_fast_append(&_11$$14, &value); + zephir_array_update_string(&_9$$14, SL("bind"), &_11$$14, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(¶ms, &_9$$14); + } else { + ZEPHIR_INIT_VAR(&_12$$15); + zephir_create_array(&_12$$15, 1, 0); + ZEPHIR_INIT_VAR(&_13$$15); + ZEPHIR_CONCAT_SVS(&_13$$15, "[", &field, "] IS NULL"); + zephir_array_update_string(&_12$$15, SL("conditions"), &_13$$15, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(¶ms, &_12$$15); } - zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); - zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &attributes); - ZEPHIR_INIT_VAR(&_1); - object_init_ex(&_1, phalcon_messages_messages_ce); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 8); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), &_1); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, __toString) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "render", NULL, 0); + zephir_array_unset_long(&arguments, 0, PH_SEPARATE); + zephir_array_unset_string(&arguments, SL("conditions"), PH_SEPARATE); + zephir_array_unset_string(&arguments, SL("bind"), PH_SEPARATE); + ZEPHIR_INIT_VAR(&_14); + zephir_fast_array_merge(&_14, ¶ms, &arguments); + ZEPHIR_CPY_WRT(¶ms, &_14); + _15 = zephir_fetch_class(&modelName); + ZEPHIR_RETURN_CALL_CE_STATIC_ZVAL(_15, type, NULL, 0, ¶ms); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, addFilter) +static PHP_METHOD(Phalcon_Mvc_Model, possibleSetter) { - zval _1$$5, _2$$6; + zval localMethods; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *filter_param = NULL, filters, _0; - zval filter; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *property_param = NULL, *value, value_sub, possibleSetter, _0; + zval property; zval *this_ptr = getThis(); - ZVAL_UNDEF(&filter); - ZVAL_UNDEF(&filters); + ZVAL_UNDEF(&property); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&possibleSetter); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$5); - ZVAL_UNDEF(&_2$$6); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(filter) + ZVAL_UNDEF(&localMethods); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(property) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &filter_param); - zephir_get_strval(&filter, filter_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("filters"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&filters, &_0); - if (Z_TYPE_P(&filters) == IS_ARRAY) { - zephir_update_property_array_append(this_ptr, SL("filters"), &filter); - } else { - if (Z_TYPE_P(&filters) == IS_STRING) { - ZEPHIR_INIT_VAR(&_1$$5); - zephir_create_array(&_1$$5, 2, 0); - zephir_array_fast_append(&_1$$5, &filters); - zephir_array_fast_append(&_1$$5, &filter); - zephir_update_property_zval(this_ptr, ZEND_STRL("filters"), &_1$$5); - } else { - ZEPHIR_INIT_VAR(&_2$$6); - zephir_create_array(&_2$$6, 1, 0); - zephir_array_fast_append(&_2$$6, &filter); - zephir_update_property_zval(this_ptr, ZEND_STRL("filters"), &_2$$6); - } + zephir_fetch_params(1, 2, 0, &property_param, &value); + zephir_get_strval(&property, property_param); + ZEPHIR_INIT_VAR(&localMethods); + zephir_create_array(&localMethods, 10, 0); + add_assoc_long_ex(&localMethods, SL("setConnectionService"), 1); + add_assoc_long_ex(&localMethods, SL("setDirtyState"), 1); + add_assoc_long_ex(&localMethods, SL("setEventsManager"), 1); + add_assoc_long_ex(&localMethods, SL("setReadConnectionService"), 1); + add_assoc_long_ex(&localMethods, SL("setOldSnapshotData"), 1); + add_assoc_long_ex(&localMethods, SL("setSchema"), 1); + add_assoc_long_ex(&localMethods, SL("setSnapshotData"), 1); + add_assoc_long_ex(&localMethods, SL("setSource"), 1); + add_assoc_long_ex(&localMethods, SL("setTransaction"), 1); + add_assoc_long_ex(&localMethods, SL("setWriteConnectionService"), 1); + ZEPHIR_INIT_VAR(&_0); + zephir_camelize(&_0, &property, NULL ); + ZEPHIR_INIT_VAR(&possibleSetter); + ZEPHIR_CONCAT_SV(&possibleSetter, "set", &_0); + if (!((zephir_method_exists(this_ptr, &possibleSetter) == SUCCESS))) { + RETURN_MM_BOOL(0); } - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, addValidator) -{ - zval *validator, validator_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&validator_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(validator, phalcon_filter_validation_validatorinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &validator); - zephir_update_property_array_append(this_ptr, SL("validators"), validator); - RETURN_THISW(); + if (!(zephir_array_isset(&localMethods, &possibleSetter))) { + ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &possibleSetter, NULL, 0, value); + zephir_check_call_status(); + } + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, addValidators) +static PHP_METHOD(Phalcon_Mvc_Model, preSave) { + zval _16$$32, _29$$52; + zval eventName; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL; + zephir_fcall_cache_entry *_9 = NULL, *_19 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool merge; - zval *validators_param = NULL, *merge_param = NULL, validator, *_1, _2, _0$$3; - zval validators; + zend_bool exists, error = 0, isNull = 0, _10$$27, _11$$27, _12$$27, _23$$47, _24$$47, _25$$47; + zval *metaData, metaData_sub, *exists_param = NULL, *identityField, identityField_sub, __$true, __$false, notNull, columnMap, dataTypeNumeric, automaticAttributes, defaultValues, field, attributeField, value, emptyStringValues, _33, _34, _0$$3, _1$$3, _2$$3, _3$$8, *_4$$11, _5$$11, _6$$19, _7$$19, _8$$19, _13$$27, _14$$32, _15$$32, _17$$32, _18$$32, _20$$39, _21$$39, _22$$39, _26$$47, _27$$52, _28$$52, _30$$52, _31$$52, _32$$57, _35$$59, _36$$60, _37$$60, _38$$60, _39$$60, _40$$60, _41$$60; zval *this_ptr = getThis(); - ZVAL_UNDEF(&validators); - ZVAL_UNDEF(&validator); - ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&metaData_sub); + ZVAL_UNDEF(&identityField_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(¬Null); + ZVAL_UNDEF(&columnMap); + ZVAL_UNDEF(&dataTypeNumeric); + ZVAL_UNDEF(&automaticAttributes); + ZVAL_UNDEF(&defaultValues); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&attributeField); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&emptyStringValues); + ZVAL_UNDEF(&_33); + ZVAL_UNDEF(&_34); ZVAL_UNDEF(&_0$$3); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(validators) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(merge) + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$8); + ZVAL_UNDEF(&_5$$11); + ZVAL_UNDEF(&_6$$19); + ZVAL_UNDEF(&_7$$19); + ZVAL_UNDEF(&_8$$19); + ZVAL_UNDEF(&_13$$27); + ZVAL_UNDEF(&_14$$32); + ZVAL_UNDEF(&_15$$32); + ZVAL_UNDEF(&_17$$32); + ZVAL_UNDEF(&_18$$32); + ZVAL_UNDEF(&_20$$39); + ZVAL_UNDEF(&_21$$39); + ZVAL_UNDEF(&_22$$39); + ZVAL_UNDEF(&_26$$47); + ZVAL_UNDEF(&_27$$52); + ZVAL_UNDEF(&_28$$52); + ZVAL_UNDEF(&_30$$52); + ZVAL_UNDEF(&_31$$52); + ZVAL_UNDEF(&_32$$57); + ZVAL_UNDEF(&_35$$59); + ZVAL_UNDEF(&_36$$60); + ZVAL_UNDEF(&_37$$60); + ZVAL_UNDEF(&_38$$60); + ZVAL_UNDEF(&_39$$60); + ZVAL_UNDEF(&_40$$60); + ZVAL_UNDEF(&_41$$60); + ZVAL_UNDEF(&eventName); + ZVAL_UNDEF(&_16$$32); + ZVAL_UNDEF(&_29$$52); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_OBJECT_OF_CLASS(metaData, phalcon_mvc_model_metadatainterface_ce) + Z_PARAM_BOOL(exists) + Z_PARAM_ZVAL(identityField) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &validators_param, &merge_param); - ZEPHIR_OBS_COPY_OR_DUP(&validators, validators_param); - if (!merge_param) { - merge = 1; - } else { + zephir_fetch_params(1, 3, 0, &metaData, &exists_param, &identityField); + if (ZEPHIR_GLOBAL(orm).events) { + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "beforeValidation"); + ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "fireeventcancel", NULL, 0, &_1$$3); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_0$$3)) { + RETURN_MM_BOOL(0); + } + if (exists) { + ZEPHIR_INIT_VAR(&eventName); + ZVAL_STRING(&eventName, "beforeValidationOnUpdate"); + } else { + ZEPHIR_INIT_NVAR(&eventName); + ZVAL_STRING(&eventName, "beforeValidationOnCreate"); + } + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "fireeventcancel", NULL, 0, &eventName); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_2$$3)) { + RETURN_MM_BOOL(0); } - if (UNEXPECTED(!merge)) { - ZEPHIR_INIT_VAR(&_0$$3); - array_init(&_0$$3); - zephir_update_property_zval(this_ptr, ZEND_STRL("validators"), &_0$$3); } - zephir_is_iterable(&validators, 0, "phalcon/Forms/Element/AbstractElement.zep", 163); - if (Z_TYPE_P(&validators) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&validators), _1) - { - ZEPHIR_INIT_NVAR(&validator); - ZVAL_COPY(&validator, _1); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addvalidator", &_3, 0, &validator); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &validators, "rewind", NULL, 0); + if (ZEPHIR_GLOBAL(orm).virtual_foreign_keys) { + ZEPHIR_CALL_METHOD(&_3$$8, this_ptr, "checkforeignkeysrestrict", NULL, 434); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &validators, "valid", NULL, 0); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_3$$8)) { + RETURN_MM_BOOL(0); + } + } + if (ZEPHIR_GLOBAL(orm).not_null_validations) { + ZEPHIR_CALL_METHOD(¬Null, metaData, "getnotnullattributes", NULL, 0, this_ptr); + zephir_check_call_status(); + if (Z_TYPE_P(¬Null) == IS_ARRAY) { + ZEPHIR_CALL_METHOD(&dataTypeNumeric, metaData, "getdatatypesnumeric", NULL, 0, this_ptr); zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; + if (ZEPHIR_GLOBAL(orm).column_renaming) { + ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, this_ptr); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&columnMap); + ZVAL_NULL(&columnMap); } - ZEPHIR_CALL_METHOD(&validator, &validators, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addvalidator", &_3, 0, &validator); + if (exists) { + ZEPHIR_CALL_METHOD(&automaticAttributes, metaData, "getautomaticupdateattributes", NULL, 0, this_ptr); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &validators, "next", NULL, 0); + } else { + ZEPHIR_CALL_METHOD(&automaticAttributes, metaData, "getautomaticcreateattributes", NULL, 0, this_ptr); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(&defaultValues, metaData, "getdefaultvalues", NULL, 0, this_ptr); zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&validator); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, appendMessage) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *message, message_sub, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&message_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(message, phalcon_messages_messageinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &message); - zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "appendmessage", NULL, 0, message); - zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, clear) -{ - zval form, _0, name; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&form); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&name); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("form"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&form, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&name, &_0); - if (Z_TYPE_P(&form) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(NULL, &form, "clear", NULL, 0, &name); - zephir_check_call_status(); - } - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getAttribute) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *attribute_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null, attributes, value, _0; - zval attribute; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(attribute) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &attribute_param, &defaultValue); - zephir_get_strval(&attribute, attribute_param); - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&attributes, &_0); - zephir_memory_observe(&value); - if (!(zephir_array_isset_fetch(&value, &attributes, &attribute, 0))) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); - } - RETURN_CCTOR(&value); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getAttributes) -{ - zval attributes, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&attributes, &_0); - RETURN_CCTOR(&attributes); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getDefault) -{ - - RETURN_MEMBER(getThis(), "value"); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getFilters) -{ - - RETURN_MEMBER(getThis(), "filters"); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getForm) -{ - - RETURN_MEMBER(getThis(), "form"); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getLabel) -{ - - RETURN_MEMBER(getThis(), "label"); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getMessages) -{ - - RETURN_MEMBER(getThis(), "messages"); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getName) -{ - - RETURN_MEMBER(getThis(), "name"); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getTagFactory) -{ - - RETURN_MEMBER(getThis(), "tagFactory"); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getUserOption) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *option_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null, value, _0; - zval option; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&option); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(option) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &option_param, &defaultValue); - zephir_get_strval(&option, option_param); - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; - } - zephir_memory_observe(&value); - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&value, &_0, &option, 0))) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); - } - RETURN_CCTOR(&value); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getUserOptions) -{ - - RETURN_MEMBER(getThis(), "options"); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getValidators) -{ - - RETURN_MEMBER(getThis(), "validators"); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getValue) -{ - zval name, _0, form, value, _1$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&form); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_1$$4); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&name, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("form"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&form, &_0); - ZEPHIR_INIT_VAR(&value); - ZVAL_NULL(&value); - if (Z_TYPE_P(&form) == IS_OBJECT) { - ZEPHIR_RETURN_CALL_METHOD(&form, "getvalue", NULL, 0, &name); - zephir_check_call_status(); - RETURN_MM(); - } - if (Z_TYPE_P(&value) == IS_NULL) { - zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("value"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&value, &_1$$4); - } - RETURN_CCTOR(&value); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, hasMessages) -{ - zval _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); - RETURN_BOOL(zephir_fast_count_int(&_0) > 0); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, label) -{ - zend_bool _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *attributes_param = NULL, code, internalAttributes, labelName, name, tagFactory, _0$$3; - zval attributes; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&code); - ZVAL_UNDEF(&internalAttributes); - ZVAL_UNDEF(&labelName); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&tagFactory); - ZVAL_UNDEF(&_0$$3); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &attributes_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - } else { - zephir_get_arrval(&attributes, attributes_param); + ZEPHIR_CALL_METHOD(&emptyStringValues, metaData, "getemptystringattributes", NULL, 0, this_ptr); + zephir_check_call_status(); + error = 0; + zephir_is_iterable(¬Null, 0, "phalcon/Mvc/Model.zep", 4948); + if (Z_TYPE_P(¬Null) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(¬Null), _4$$11) + { + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _4$$11); + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeField); + if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_6$$19); + object_init_ex(&_6$$19, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_7$$19); + zephir_get_class(&_7$$19, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_8$$19); + ZEPHIR_CONCAT_SVSVS(&_8$$19, "Column '", &field, "' in '", &_7$$19, "' isn't part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_6$$19, "__construct", &_9, 33, &_8$$19); + zephir_check_call_status(); + zephir_throw_exception_debug(&_6$$19, "phalcon/Mvc/Model.zep", 4868); + ZEPHIR_MM_RESTORE(); + return; + } + } + } else { + ZEPHIR_CPY_WRT(&attributeField, &field); + } + if (!(zephir_array_isset(&automaticAttributes, &attributeField))) { + isNull = 0; + ZEPHIR_OBS_NVAR(&value); + if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { + if (Z_TYPE_P(&value) != IS_OBJECT) { + if (!(zephir_array_isset(&dataTypeNumeric, &field))) { + if (zephir_array_isset(&emptyStringValues, &field)) { + if (Z_TYPE_P(&value) == IS_NULL) { + isNull = 1; + } + } else { + _10$$27 = Z_TYPE_P(&value) == IS_NULL; + if (!(_10$$27)) { + _11$$27 = ZEPHIR_IS_STRING_IDENTICAL(&value, ""); + if (_11$$27) { + _12$$27 = !(zephir_array_isset(&defaultValues, &field)); + if (!(_12$$27)) { + zephir_array_fetch(&_13$$27, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 4898); + _12$$27 = !ZEPHIR_IS_IDENTICAL(&value, &_13$$27); + } + _11$$27 = _12$$27; + } + _10$$27 = _11$$27; + } + if (_10$$27) { + isNull = 1; + } + } + } else { + if (!(zephir_is_numeric(&value))) { + isNull = 1; + } + } + } + } else { + isNull = 1; + } + if (isNull) { + if (!(exists)) { + if (ZEPHIR_IS_EQUAL(&field, identityField)) { + continue; + } + if (zephir_array_isset(&defaultValues, &field)) { + continue; + } + } + ZEPHIR_INIT_NVAR(&_14$$32); + object_init_ex(&_14$$32, phalcon_messages_message_ce); + ZEPHIR_INIT_NVAR(&_15$$32); + ZEPHIR_CONCAT_VS(&_15$$32, &attributeField, " is required"); + ZEPHIR_INIT_NVAR(&_16$$32); + zephir_create_array(&_16$$32, 1, 0); + ZEPHIR_INIT_NVAR(&_17$$32); + zephir_get_class(&_17$$32, this_ptr, 0); + zephir_array_update_string(&_16$$32, SL("model"), &_17$$32, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_17$$32); + ZVAL_STRING(&_17$$32, "PresenceOf"); + ZVAL_LONG(&_18$$32, 0); + ZEPHIR_CALL_METHOD(NULL, &_14$$32, "__construct", &_19, 6, &_15$$32, &attributeField, &_17$$32, &_18$$32, &_16$$32); + zephir_check_call_status(); + zephir_update_property_array_append(this_ptr, SL("errorMessages"), &_14$$32); + error = 1; + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, ¬Null, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5$$11, ¬Null, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5$$11)) { + break; + } + ZEPHIR_CALL_METHOD(&field, ¬Null, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&attributeField); + if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { + if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { + ZEPHIR_INIT_NVAR(&_20$$39); + object_init_ex(&_20$$39, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_21$$39); + zephir_get_class(&_21$$39, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_22$$39); + ZEPHIR_CONCAT_SVSVS(&_22$$39, "Column '", &field, "' in '", &_21$$39, "' isn't part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_20$$39, "__construct", &_9, 33, &_22$$39); + zephir_check_call_status(); + zephir_throw_exception_debug(&_20$$39, "phalcon/Mvc/Model.zep", 4868); + ZEPHIR_MM_RESTORE(); + return; + } + } + } else { + ZEPHIR_CPY_WRT(&attributeField, &field); + } + if (!(zephir_array_isset(&automaticAttributes, &attributeField))) { + isNull = 0; + ZEPHIR_OBS_NVAR(&value); + if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { + if (Z_TYPE_P(&value) != IS_OBJECT) { + if (!(zephir_array_isset(&dataTypeNumeric, &field))) { + if (zephir_array_isset(&emptyStringValues, &field)) { + if (Z_TYPE_P(&value) == IS_NULL) { + isNull = 1; + } + } else { + _23$$47 = Z_TYPE_P(&value) == IS_NULL; + if (!(_23$$47)) { + _24$$47 = ZEPHIR_IS_STRING_IDENTICAL(&value, ""); + if (_24$$47) { + _25$$47 = !(zephir_array_isset(&defaultValues, &field)); + if (!(_25$$47)) { + zephir_array_fetch(&_26$$47, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 4898); + _25$$47 = !ZEPHIR_IS_IDENTICAL(&value, &_26$$47); + } + _24$$47 = _25$$47; + } + _23$$47 = _24$$47; + } + if (_23$$47) { + isNull = 1; + } + } + } else { + if (!(zephir_is_numeric(&value))) { + isNull = 1; + } + } + } + } else { + isNull = 1; + } + if (isNull) { + if (!(exists)) { + if (ZEPHIR_IS_EQUAL(&field, identityField)) { + continue; + } + if (zephir_array_isset(&defaultValues, &field)) { + continue; + } + } + ZEPHIR_INIT_NVAR(&_27$$52); + object_init_ex(&_27$$52, phalcon_messages_message_ce); + ZEPHIR_INIT_NVAR(&_28$$52); + ZEPHIR_CONCAT_VS(&_28$$52, &attributeField, " is required"); + ZEPHIR_INIT_NVAR(&_29$$52); + zephir_create_array(&_29$$52, 1, 0); + ZEPHIR_INIT_NVAR(&_30$$52); + zephir_get_class(&_30$$52, this_ptr, 0); + zephir_array_update_string(&_29$$52, SL("model"), &_30$$52, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_30$$52); + ZVAL_STRING(&_30$$52, "PresenceOf"); + ZVAL_LONG(&_31$$52, 0); + ZEPHIR_CALL_METHOD(NULL, &_27$$52, "__construct", &_19, 6, &_28$$52, &attributeField, &_30$$52, &_31$$52, &_29$$52); + zephir_check_call_status(); + zephir_update_property_array_append(this_ptr, SL("errorMessages"), &_27$$52); + error = 1; + } + } + ZEPHIR_CALL_METHOD(NULL, ¬Null, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&field); + if (error) { + if (ZEPHIR_GLOBAL(orm).events) { + ZEPHIR_INIT_VAR(&_32$$57); + ZVAL_STRING(&_32$$57, "onValidationFails"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_32$$57); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "canceloperation", NULL, 0); + zephir_check_call_status(); + } + RETURN_MM_BOOL(0); + } + } } - ZEPHIR_CALL_METHOD(&tagFactory, this_ptr, "getlocaltagfactory", NULL, 0); + ZEPHIR_INIT_VAR(&_34); + ZVAL_STRING(&_34, "validation"); + ZEPHIR_CALL_METHOD(&_33, this_ptr, "fireeventcancel", NULL, 0, &_34); zephir_check_call_status(); - zephir_memory_observe(&internalAttributes); - zephir_read_property(&internalAttributes, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC); - zephir_memory_observe(&name); - if (!(zephir_array_isset_string_fetch(&name, &internalAttributes, SL("id"), 0))) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&name, &_0$$3); - } - if (!(zephir_array_isset_string(&attributes, SL("for")))) { - zephir_array_update_string(&attributes, SL("for"), &name, PH_COPY | PH_SEPARATE); - } - zephir_memory_observe(&labelName); - zephir_read_property(&labelName, this_ptr, ZEND_STRL("label"), PH_NOISY_CC); - _1 = zephir_is_true(&labelName); - if (!(_1)) { - _1 = zephir_is_numeric(&labelName); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_33)) { + if (ZEPHIR_GLOBAL(orm).events) { + ZEPHIR_INIT_VAR(&_35$$59); + ZVAL_STRING(&_35$$59, "onValidationFails"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_35$$59); + zephir_check_call_status(); + } + RETURN_MM_BOOL(0); } - if (!(_1)) { - ZEPHIR_CPY_WRT(&labelName, &name); + if (ZEPHIR_GLOBAL(orm).events) { + if (exists) { + ZEPHIR_INIT_NVAR(&eventName); + ZVAL_STRING(&eventName, "afterValidationOnUpdate"); + } else { + ZEPHIR_INIT_NVAR(&eventName); + ZVAL_STRING(&eventName, "afterValidationOnCreate"); + } + ZEPHIR_CALL_METHOD(&_36$$60, this_ptr, "fireeventcancel", NULL, 0, &eventName); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_36$$60)) { + RETURN_MM_BOOL(0); + } + ZEPHIR_INIT_VAR(&_38$$60); + ZVAL_STRING(&_38$$60, "afterValidation"); + ZEPHIR_CALL_METHOD(&_37$$60, this_ptr, "fireeventcancel", NULL, 0, &_38$$60); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_37$$60)) { + RETURN_MM_BOOL(0); + } + ZEPHIR_INIT_NVAR(&_38$$60); + ZVAL_STRING(&_38$$60, "beforeSave"); + ZEPHIR_CALL_METHOD(&_39$$60, this_ptr, "fireeventcancel", NULL, 0, &_38$$60); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_39$$60)) { + RETURN_MM_BOOL(0); + } + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("skipped"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("skipped"), &__$false); + } + if (exists) { + ZEPHIR_INIT_NVAR(&eventName); + ZVAL_STRING(&eventName, "beforeUpdate"); + } else { + ZEPHIR_INIT_NVAR(&eventName); + ZVAL_STRING(&eventName, "beforeCreate"); + } + ZEPHIR_CALL_METHOD(&_40$$60, this_ptr, "fireeventcancel", NULL, 0, &eventName); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_40$$60)) { + RETURN_MM_BOOL(0); + } + zephir_read_property(&_41$$60, this_ptr, ZEND_STRL("skipped"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_41$$60)) { + RETURN_MM_BOOL(1); + } } - ZEPHIR_CALL_METHOD(&code, &tagFactory, "label", NULL, 0, &labelName, &attributes); - zephir_check_call_status(); - RETURN_CCTOR(&code); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, render) +static PHP_METHOD(Phalcon_Mvc_Model, preSaveRelatedRecords) { - zval _1; + zend_string *_5; + zend_ulong _4; + zend_bool nesting = 0, _20$$5, _39$$11; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_7 = NULL, *_9 = NULL, *_13 = NULL, *_15 = NULL, *_22 = NULL, *_24 = NULL, *_27 = NULL, *_29 = NULL, *_34 = NULL, *_42 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *attributes_param = NULL, helper, merged, method, name, result, tagFactory, value, _0; - zval attributes; + zval *connection, connection_sub, *related, related_sub, *visited, visited_sub, className, manager, type, relation, columns, referencedFields, name, record, _0, _1, *_2, _3, _6$$3, _8$$6, _10$$6, _11$$6, _12$$6, _14$$7, _16$$7, _17$$7, _18$$7, _19$$5, _21$$5, _25$$5, _23$$8, _26$$9, _28$$12, _30$$12, _31$$12, _32$$12, _33$$13, _35$$13, _36$$13, _37$$13, _38$$11, _40$$11, _43$$11, _41$$14; zval *this_ptr = getThis(); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&helper); - ZVAL_UNDEF(&merged); - ZVAL_UNDEF(&method); + ZVAL_UNDEF(&connection_sub); + ZVAL_UNDEF(&related_sub); + ZVAL_UNDEF(&visited_sub); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&referencedFields); ZVAL_UNDEF(&name); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&tagFactory); - ZVAL_UNDEF(&value); + ZVAL_UNDEF(&record); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&_10$$6); + ZVAL_UNDEF(&_11$$6); + ZVAL_UNDEF(&_12$$6); + ZVAL_UNDEF(&_14$$7); + ZVAL_UNDEF(&_16$$7); + ZVAL_UNDEF(&_17$$7); + ZVAL_UNDEF(&_18$$7); + ZVAL_UNDEF(&_19$$5); + ZVAL_UNDEF(&_21$$5); + ZVAL_UNDEF(&_25$$5); + ZVAL_UNDEF(&_23$$8); + ZVAL_UNDEF(&_26$$9); + ZVAL_UNDEF(&_28$$12); + ZVAL_UNDEF(&_30$$12); + ZVAL_UNDEF(&_31$$12); + ZVAL_UNDEF(&_32$$12); + ZVAL_UNDEF(&_33$$13); + ZVAL_UNDEF(&_35$$13); + ZVAL_UNDEF(&_36$$13); + ZVAL_UNDEF(&_37$$13); + ZVAL_UNDEF(&_38$$11); + ZVAL_UNDEF(&_40$$11); + ZVAL_UNDEF(&_43$$11); + ZVAL_UNDEF(&_41$$14); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_db_adapter_adapterinterface_ce) + Z_PARAM_ZVAL(related) + Z_PARAM_OBJECT_OF_CLASS(visited, phalcon_support_collection_collectioninterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &attributes_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); + zephir_fetch_params(1, 3, 0, &connection, &related, &visited); + nesting = 0; + if (nesting) { + ZVAL_BOOL(&_0, 1); } else { - zephir_get_arrval(&attributes, attributes_param); + ZVAL_BOOL(&_0, 0); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&name, &_0); - ZEPHIR_CALL_METHOD(&value, this_ptr, "getvalue", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("method"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&method, &_0); - ZEPHIR_CALL_METHOD(&tagFactory, this_ptr, "getlocaltagfactory", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, connection, "begin", NULL, 0, &_0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&helper, &tagFactory, "newinstance", NULL, 0, &method); + ZEPHIR_INIT_VAR(&className); + zephir_get_class(&className, this_ptr, 0); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getmodelsmanager", NULL, 0); zephir_check_call_status(); - if (zephir_array_isset_string(&attributes, SL("value"))) { - ZEPHIR_OBS_NVAR(&value); - zephir_array_fetch_string(&value, &attributes, SL("value"), PH_NOISY, "phalcon/Forms/Element/AbstractElement.zep", 391); - zephir_array_unset_string(&attributes, SL("value"), PH_SEPARATE); + ZEPHIR_CPY_WRT(&manager, &_1); + zephir_is_iterable(related, 0, "phalcon/Mvc/Model.zep", 5112); + if (Z_TYPE_P(related) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(related), _4, _5, _2) + { + ZEPHIR_INIT_NVAR(&name); + if (_5 != NULL) { + ZVAL_STR_COPY(&name, _5); + } else { + ZVAL_LONG(&name, _4); + } + ZEPHIR_INIT_NVAR(&record); + ZVAL_COPY(&record, _2); + ZEPHIR_CALL_METHOD(&_6$$3, &manager, "getrelationbyalias", &_7, 0, &className, &name); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&relation, &_6$$3); + if (Z_TYPE_P(&relation) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(&type, &relation, "gettype", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG(&type, 0)) { + if (UNEXPECTED(Z_TYPE_P(&record) != IS_OBJECT)) { + if (nesting) { + ZVAL_BOOL(&_8$$6, 1); + } else { + ZVAL_BOOL(&_8$$6, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_9, 0, &_8$$6); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_10$$6); + object_init_ex(&_10$$6, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_11$$6); + zephir_get_class(&_11$$6, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_12$$6); + ZEPHIR_CONCAT_SVSV(&_12$$6, "Only objects can be stored as part of belongs-to relations in '", &_11$$6, "' Relation ", &name); + ZEPHIR_CALL_METHOD(NULL, &_10$$6, "__construct", &_13, 33, &_12$$6); + zephir_check_call_status(); + zephir_throw_exception_debug(&_10$$6, "phalcon/Mvc/Model.zep", 5070); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&columns, &relation, "getfields", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&referencedFields, &relation, "getreferencedfields", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&columns) == IS_ARRAY)) { + if (nesting) { + ZVAL_BOOL(&_14$$7, 1); + } else { + ZVAL_BOOL(&_14$$7, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_15, 0, &_14$$7); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_16$$7); + object_init_ex(&_16$$7, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_17$$7); + zephir_get_class(&_17$$7, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_18$$7); + ZEPHIR_CONCAT_SVSV(&_18$$7, "Not implemented in '", &_17$$7, "' Relation ", &name); + ZEPHIR_CALL_METHOD(NULL, &_16$$7, "__construct", &_13, 33, &_18$$7); + zephir_check_call_status(); + zephir_throw_exception_debug(&_16$$7, "phalcon/Mvc/Model.zep", 5081); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_read_property(&_19$$5, &record, ZEND_STRL("dirtyState"), PH_NOISY_CC | PH_READONLY); + _20$$5 = !ZEPHIR_IS_LONG_IDENTICAL(&_19$$5, 0); + if (_20$$5) { + ZEPHIR_CALL_METHOD(&_21$$5, &record, "dosave", NULL, 0, visited); + zephir_check_call_status(); + _20$$5 = !zephir_is_true(&_21$$5); + } + if (_20$$5) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_22, 0, &record); + zephir_check_call_status(); + if (nesting) { + ZVAL_BOOL(&_23$$8, 1); + } else { + ZVAL_BOOL(&_23$$8, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_24, 0, &_23$$8); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_METHOD(&_25$$5, &record, "readattribute", NULL, 0, &referencedFields); + zephir_check_call_status(); + zephir_update_property_zval_zval(this_ptr, &columns, &_25$$5); + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, related, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, related, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&name, related, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&record, related, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_26$$9, &manager, "getrelationbyalias", &_27, 0, &className, &name); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&relation, &_26$$9); + if (Z_TYPE_P(&relation) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(&type, &relation, "gettype", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG(&type, 0)) { + if (UNEXPECTED(Z_TYPE_P(&record) != IS_OBJECT)) { + if (nesting) { + ZVAL_BOOL(&_28$$12, 1); + } else { + ZVAL_BOOL(&_28$$12, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_29, 0, &_28$$12); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_30$$12); + object_init_ex(&_30$$12, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_31$$12); + zephir_get_class(&_31$$12, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_32$$12); + ZEPHIR_CONCAT_SVSV(&_32$$12, "Only objects can be stored as part of belongs-to relations in '", &_31$$12, "' Relation ", &name); + ZEPHIR_CALL_METHOD(NULL, &_30$$12, "__construct", &_13, 33, &_32$$12); + zephir_check_call_status(); + zephir_throw_exception_debug(&_30$$12, "phalcon/Mvc/Model.zep", 5070); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&columns, &relation, "getfields", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&referencedFields, &relation, "getreferencedfields", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&columns) == IS_ARRAY)) { + if (nesting) { + ZVAL_BOOL(&_33$$13, 1); + } else { + ZVAL_BOOL(&_33$$13, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_34, 0, &_33$$13); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_35$$13); + object_init_ex(&_35$$13, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_36$$13); + zephir_get_class(&_36$$13, this_ptr, 0); + ZEPHIR_INIT_NVAR(&_37$$13); + ZEPHIR_CONCAT_SVSV(&_37$$13, "Not implemented in '", &_36$$13, "' Relation ", &name); + ZEPHIR_CALL_METHOD(NULL, &_35$$13, "__construct", &_13, 33, &_37$$13); + zephir_check_call_status(); + zephir_throw_exception_debug(&_35$$13, "phalcon/Mvc/Model.zep", 5081); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_read_property(&_38$$11, &record, ZEND_STRL("dirtyState"), PH_NOISY_CC | PH_READONLY); + _39$$11 = !ZEPHIR_IS_LONG_IDENTICAL(&_38$$11, 0); + if (_39$$11) { + ZEPHIR_CALL_METHOD(&_40$$11, &record, "dosave", NULL, 0, visited); + zephir_check_call_status(); + _39$$11 = !zephir_is_true(&_40$$11); + } + if (_39$$11) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_22, 0, &record); + zephir_check_call_status(); + if (nesting) { + ZVAL_BOOL(&_41$$14, 1); + } else { + ZVAL_BOOL(&_41$$14, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_42, 0, &_41$$14); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_METHOD(&_43$$11, &record, "readattribute", NULL, 0, &referencedFields); + zephir_check_call_status(); + zephir_update_property_zval_zval(this_ptr, &columns, &_43$$11); + } + } + ZEPHIR_CALL_METHOD(NULL, related, "next", NULL, 0); + zephir_check_call_status(); + } } - zephir_read_property(&_0, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&merged); - zephir_fast_array_merge(&merged, &_0, &attributes); - ZEPHIR_CALL_METHOD(&result, &helper, "__invoke", NULL, 0, &name, &value, &merged); - zephir_check_call_status(); - zephir_cast_to_string(&_1, &result); - RETURN_CTOR(&_1); + ZEPHIR_INIT_NVAR(&record); + ZEPHIR_INIT_NVAR(&name); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setAttribute) +static PHP_METHOD(Phalcon_Mvc_Model, postSave) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *attribute_param = NULL, *value, value_sub; - zval attribute; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *success_param = NULL, *exists_param = NULL, _0$$4, _1$$5; + zend_bool success, exists; zval *this_ptr = getThis(); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&_1$$5); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(attribute) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &attribute_param, &value); - zephir_get_strval(&attribute, attribute_param); - zephir_update_property_array(this_ptr, SL("attributes"), &attribute, value); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setAttributes) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *attributes_param = NULL; - zval attributes; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(attributes) + Z_PARAM_BOOL(success) + Z_PARAM_BOOL(exists) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &attributes_param); - ZEPHIR_OBS_COPY_OR_DUP(&attributes, attributes_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &attributes); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setDefault) -{ - zval *value, value_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &value); - zephir_update_property_zval(this_ptr, ZEND_STRL("value"), value); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setFilters) -{ - zend_bool _0; - zval *filters, filters_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&filters_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(filters) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &filters); - _0 = Z_TYPE_P(filters) != IS_STRING; - if (_0) { - _0 = Z_TYPE_P(filters) != IS_ARRAY; - } - if (UNEXPECTED(_0)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_forms_exception_ce, "The filter needs to be an array or string", "phalcon/Forms/Element/AbstractElement.zep", 440); - return; + zephir_fetch_params(1, 2, 0, &success_param, &exists_param); + if (success) { + if (exists) { + ZEPHIR_INIT_VAR(&_0$$4); + ZVAL_STRING(&_0$$4, "afterUpdate"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_0$$4); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_VAR(&_1$$5); + ZVAL_STRING(&_1$$5, "afterCreate"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_1$$5); + zephir_check_call_status(); + } } - zephir_update_property_zval(this_ptr, ZEND_STRL("filters"), filters); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setForm) -{ - zval *form, form_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&form_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(form, phalcon_forms_form_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &form); - zephir_update_property_zval(this_ptr, ZEND_STRL("form"), form); - RETURN_THISW(); + RETURN_MM_BOOL(success); } -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setLabel) +static PHP_METHOD(Phalcon_Mvc_Model, postSaveRelatedRecords) { + zval _32$$14, _34$$14, _44$$19, _46$$19, _88$$40, _90$$40, _100$$45, _102$$45; + zend_string *_4; + zend_ulong _3; + zend_bool nesting = 0, isThrough = 0, _8$$4, _65$$30; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *label_param = NULL; - zval label; + zephir_fcall_cache_entry *_6 = NULL, *_10 = NULL, *_13 = NULL, *_15 = NULL, *_19 = NULL, *_26 = NULL, *_28 = NULL, *_30 = NULL, *_31 = NULL, *_37 = NULL, *_40 = NULL, *_42 = NULL, *_43 = NULL, *_49 = NULL, *_54 = NULL, *_57 = NULL, *_59 = NULL, *_63 = NULL, *_67 = NULL, *_71 = NULL, *_76 = NULL, *_84 = NULL, *_86 = NULL, *_87 = NULL, *_93 = NULL, *_96 = NULL, *_98 = NULL, *_99 = NULL, *_105 = NULL, *_110 = NULL, *_113 = NULL, *_115 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *connection, connection_sub, *related, related_sub, *visited, visited_sub, className, manager, relation, name, record, columns, referencedModel, referencedFields, relatedRecords, value, recordAfter, intermediateModel, intermediateFields, intermediateValue, intermediateModelName, intermediateReferencedFields, existingIntermediateModel, _0, *_1, _2, _118, _5$$3, _7$$4, _22$$4, _9$$6, _11$$6, _12$$6, _14$$7, _16$$7, _17$$7, _18$$10, _20$$10, _21$$10, *_23$$11, _24$$11, _25$$12, _29$$12, _35$$12, _27$$13, _33$$14, _36$$16, _38$$17, _41$$17, _47$$17, _39$$18, _45$$19, _48$$21, *_50$$22, _51$$22, _52$$23, _53$$24, _55$$25, _56$$26, _58$$28, _60$$28, _61$$28, _62$$29, _64$$30, _79$$30, _66$$32, _68$$32, _69$$32, _70$$33, _72$$33, _73$$33, _74$$34, _75$$36, _77$$36, _78$$36, *_80$$37, _81$$37, _82$$38, _85$$38, _91$$38, _83$$39, _89$$40, _92$$42, _94$$43, _97$$43, _103$$43, _95$$44, _101$$45, _104$$47, *_106$$48, _107$$48, _108$$49, _109$$50, _111$$51, _112$$52, _114$$54, _116$$54, _117$$54; zval *this_ptr = getThis(); - ZVAL_UNDEF(&label); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(label) + ZVAL_UNDEF(&connection_sub); + ZVAL_UNDEF(&related_sub); + ZVAL_UNDEF(&visited_sub); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&record); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&referencedModel); + ZVAL_UNDEF(&referencedFields); + ZVAL_UNDEF(&relatedRecords); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&recordAfter); + ZVAL_UNDEF(&intermediateModel); + ZVAL_UNDEF(&intermediateFields); + ZVAL_UNDEF(&intermediateValue); + ZVAL_UNDEF(&intermediateModelName); + ZVAL_UNDEF(&intermediateReferencedFields); + ZVAL_UNDEF(&existingIntermediateModel); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_118); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_22$$4); + ZVAL_UNDEF(&_9$$6); + ZVAL_UNDEF(&_11$$6); + ZVAL_UNDEF(&_12$$6); + ZVAL_UNDEF(&_14$$7); + ZVAL_UNDEF(&_16$$7); + ZVAL_UNDEF(&_17$$7); + ZVAL_UNDEF(&_18$$10); + ZVAL_UNDEF(&_20$$10); + ZVAL_UNDEF(&_21$$10); + ZVAL_UNDEF(&_24$$11); + ZVAL_UNDEF(&_25$$12); + ZVAL_UNDEF(&_29$$12); + ZVAL_UNDEF(&_35$$12); + ZVAL_UNDEF(&_27$$13); + ZVAL_UNDEF(&_33$$14); + ZVAL_UNDEF(&_36$$16); + ZVAL_UNDEF(&_38$$17); + ZVAL_UNDEF(&_41$$17); + ZVAL_UNDEF(&_47$$17); + ZVAL_UNDEF(&_39$$18); + ZVAL_UNDEF(&_45$$19); + ZVAL_UNDEF(&_48$$21); + ZVAL_UNDEF(&_51$$22); + ZVAL_UNDEF(&_52$$23); + ZVAL_UNDEF(&_53$$24); + ZVAL_UNDEF(&_55$$25); + ZVAL_UNDEF(&_56$$26); + ZVAL_UNDEF(&_58$$28); + ZVAL_UNDEF(&_60$$28); + ZVAL_UNDEF(&_61$$28); + ZVAL_UNDEF(&_62$$29); + ZVAL_UNDEF(&_64$$30); + ZVAL_UNDEF(&_79$$30); + ZVAL_UNDEF(&_66$$32); + ZVAL_UNDEF(&_68$$32); + ZVAL_UNDEF(&_69$$32); + ZVAL_UNDEF(&_70$$33); + ZVAL_UNDEF(&_72$$33); + ZVAL_UNDEF(&_73$$33); + ZVAL_UNDEF(&_74$$34); + ZVAL_UNDEF(&_75$$36); + ZVAL_UNDEF(&_77$$36); + ZVAL_UNDEF(&_78$$36); + ZVAL_UNDEF(&_81$$37); + ZVAL_UNDEF(&_82$$38); + ZVAL_UNDEF(&_85$$38); + ZVAL_UNDEF(&_91$$38); + ZVAL_UNDEF(&_83$$39); + ZVAL_UNDEF(&_89$$40); + ZVAL_UNDEF(&_92$$42); + ZVAL_UNDEF(&_94$$43); + ZVAL_UNDEF(&_97$$43); + ZVAL_UNDEF(&_103$$43); + ZVAL_UNDEF(&_95$$44); + ZVAL_UNDEF(&_101$$45); + ZVAL_UNDEF(&_104$$47); + ZVAL_UNDEF(&_107$$48); + ZVAL_UNDEF(&_108$$49); + ZVAL_UNDEF(&_109$$50); + ZVAL_UNDEF(&_111$$51); + ZVAL_UNDEF(&_112$$52); + ZVAL_UNDEF(&_114$$54); + ZVAL_UNDEF(&_116$$54); + ZVAL_UNDEF(&_117$$54); + ZVAL_UNDEF(&_32$$14); + ZVAL_UNDEF(&_34$$14); + ZVAL_UNDEF(&_44$$19); + ZVAL_UNDEF(&_46$$19); + ZVAL_UNDEF(&_88$$40); + ZVAL_UNDEF(&_90$$40); + ZVAL_UNDEF(&_100$$45); + ZVAL_UNDEF(&_102$$45); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_db_adapter_adapterinterface_ce) + Z_PARAM_ZVAL(related) + Z_PARAM_OBJECT_OF_CLASS(visited, phalcon_support_collection_collectioninterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &label_param); - zephir_get_strval(&label, label_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("label"), &label); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setMessages) -{ - zval *messages, messages_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&messages_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(messages, phalcon_messages_messages_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &messages); - zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), messages); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setName) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL; - zval name; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 3, 0, &connection, &related, &visited); + nesting = 0; + ZEPHIR_INIT_VAR(&className); + zephir_get_class(&className, this_ptr, 0); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmodelsmanager", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&manager, &_0); + zephir_is_iterable(related, 0, "phalcon/Mvc/Model.zep", 5340); + if (Z_TYPE_P(related) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(related), _3, _4, _1) + { + ZEPHIR_INIT_NVAR(&name); + if (_4 != NULL) { + ZVAL_STR_COPY(&name, _4); + } else { + ZVAL_LONG(&name, _3); + } + ZEPHIR_INIT_NVAR(&record); + ZVAL_COPY(&record, _1); + ZEPHIR_CALL_METHOD(&_5$$3, &manager, "getrelationbyalias", &_6, 0, &className, &name); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&relation, &_5$$3); + if (Z_TYPE_P(&relation) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(&_7$$4, &relation, "gettype", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG(&_7$$4, 0)) { + continue; + } + _8$$4 = Z_TYPE_P(&record) != IS_OBJECT; + if (_8$$4) { + _8$$4 = Z_TYPE_P(&record) != IS_ARRAY; + } + if (UNEXPECTED(_8$$4)) { + if (nesting) { + ZVAL_BOOL(&_9$$6, 1); + } else { + ZVAL_BOOL(&_9$$6, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_10, 0, &_9$$6); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_11$$6); + object_init_ex(&_11$$6, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_12$$6); + ZEPHIR_CONCAT_SVSV(&_12$$6, "Only objects/arrays can be stored as part of has-many/has-one/has-one-through/has-many-to-many relations on model ", &className, " on Relation ", &name); + ZEPHIR_CALL_METHOD(NULL, &_11$$6, "__construct", &_13, 33, &_12$$6); + zephir_check_call_status(); + zephir_throw_exception_debug(&_11$$6, "phalcon/Mvc/Model.zep", 5175); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&columns, &relation, "getfields", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&referencedModel, &relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&referencedFields, &relation, "getreferencedfields", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&columns) == IS_ARRAY)) { + if (nesting) { + ZVAL_BOOL(&_14$$7, 1); + } else { + ZVAL_BOOL(&_14$$7, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_15, 0, &_14$$7); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_16$$7); + object_init_ex(&_16$$7, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_17$$7); + ZEPHIR_CONCAT_SVSV(&_17$$7, "Not implemented in '", &className, "' on Relation ", &name); + ZEPHIR_CALL_METHOD(NULL, &_16$$7, "__construct", &_13, 33, &_17$$7); + zephir_check_call_status(); + zephir_throw_exception_debug(&_16$$7, "phalcon/Mvc/Model.zep", 5185); + ZEPHIR_MM_RESTORE(); + return; + } + if (Z_TYPE_P(&record) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&relatedRecords); + zephir_create_array(&relatedRecords, 1, 0); + zephir_array_fast_append(&relatedRecords, &record); + } else { + ZEPHIR_CPY_WRT(&relatedRecords, &record); + } + ZEPHIR_OBS_NVAR(&value); + if (UNEXPECTED(!(zephir_fetch_property_zval(&value, this_ptr, &columns, PH_SILENT_CC)))) { + if (nesting) { + ZVAL_BOOL(&_18$$10, 1); + } else { + ZVAL_BOOL(&_18$$10, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_19, 0, &_18$$10); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_20$$10); + object_init_ex(&_20$$10, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_21$$10); + ZEPHIR_CONCAT_SVSVS(&_21$$10, "The column '", &columns, "' needs to be present in the model '", &className, "'"); + ZEPHIR_CALL_METHOD(NULL, &_20$$10, "__construct", &_13, 33, &_21$$10); + zephir_check_call_status(); + zephir_throw_exception_debug(&_20$$10, "phalcon/Mvc/Model.zep", 5202); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&_22$$4, &relation, "isthrough", NULL, 0); + zephir_check_call_status(); + isThrough = zephir_get_boolval(&_22$$4); + if (isThrough) { + ZEPHIR_CALL_METHOD(&intermediateModelName, &relation, "getintermediatemodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&intermediateFields, &relation, "getintermediatefields", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&intermediateReferencedFields, &relation, "getintermediatereferencedfields", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&relatedRecords, 0, "phalcon/Mvc/Model.zep", 5301); + if (Z_TYPE_P(&relatedRecords) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relatedRecords), _23$$11) + { + ZEPHIR_INIT_NVAR(&recordAfter); + ZVAL_COPY(&recordAfter, _23$$11); + ZEPHIR_CALL_METHOD(&_25$$12, &recordAfter, "dosave", NULL, 0, visited); + zephir_check_call_status(); + if (!(zephir_is_true(&_25$$12))) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &recordAfter); + zephir_check_call_status(); + if (nesting) { + ZVAL_BOOL(&_27$$13, 1); + } else { + ZVAL_BOOL(&_27$$13, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_28, 0, &_27$$13); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_METHOD(&_29$$12, &manager, "load", &_30, 0, &intermediateModelName); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&intermediateModel, &_29$$12); + ZEPHIR_CALL_METHOD(&_29$$12, &relation, "gettype", &_31, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG(&_29$$12, 3)) { + ZEPHIR_INIT_NVAR(&_32$$14); + zephir_create_array(&_32$$14, 2, 0); + ZEPHIR_INIT_NVAR(&_33$$14); + ZEPHIR_CONCAT_SVS(&_33$$14, "[", &intermediateFields, "] = ?0"); + zephir_array_fast_append(&_32$$14, &_33$$14); + ZEPHIR_INIT_NVAR(&_34$$14); + zephir_create_array(&_34$$14, 1, 0); + zephir_array_fast_append(&_34$$14, &value); + zephir_array_update_string(&_32$$14, SL("bind"), &_34$$14, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&existingIntermediateModel, &intermediateModel, "findfirst", NULL, 0, &_32$$14); + zephir_check_call_status(); + if (zephir_is_true(&existingIntermediateModel)) { + ZEPHIR_CPY_WRT(&intermediateModel, &existingIntermediateModel); + } + } + ZEPHIR_CALL_METHOD(NULL, &intermediateModel, "writeattribute", NULL, 0, &intermediateFields, &value); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&intermediateValue, &recordAfter, "readattribute", NULL, 0, &referencedFields); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &intermediateModel, "writeattribute", NULL, 0, &intermediateReferencedFields, &intermediateValue); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_35$$12, &intermediateModel, "dosave", NULL, 0, visited); + zephir_check_call_status(); + if (!(zephir_is_true(&_35$$12))) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &intermediateModel); + zephir_check_call_status(); + if (nesting) { + ZVAL_BOOL(&_36$$16, 1); + } else { + ZVAL_BOOL(&_36$$16, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_37, 0, &_36$$16); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &relatedRecords, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_24$$11, &relatedRecords, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_24$$11)) { + break; + } + ZEPHIR_CALL_METHOD(&recordAfter, &relatedRecords, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_38$$17, &recordAfter, "dosave", NULL, 0, visited); + zephir_check_call_status(); + if (!(zephir_is_true(&_38$$17))) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &recordAfter); + zephir_check_call_status(); + if (nesting) { + ZVAL_BOOL(&_39$$18, 1); + } else { + ZVAL_BOOL(&_39$$18, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_40, 0, &_39$$18); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_METHOD(&_41$$17, &manager, "load", &_42, 0, &intermediateModelName); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&intermediateModel, &_41$$17); + ZEPHIR_CALL_METHOD(&_41$$17, &relation, "gettype", &_43, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG(&_41$$17, 3)) { + ZEPHIR_INIT_NVAR(&_44$$19); + zephir_create_array(&_44$$19, 2, 0); + ZEPHIR_INIT_NVAR(&_45$$19); + ZEPHIR_CONCAT_SVS(&_45$$19, "[", &intermediateFields, "] = ?0"); + zephir_array_fast_append(&_44$$19, &_45$$19); + ZEPHIR_INIT_NVAR(&_46$$19); + zephir_create_array(&_46$$19, 1, 0); + zephir_array_fast_append(&_46$$19, &value); + zephir_array_update_string(&_44$$19, SL("bind"), &_46$$19, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&existingIntermediateModel, &intermediateModel, "findfirst", NULL, 0, &_44$$19); + zephir_check_call_status(); + if (zephir_is_true(&existingIntermediateModel)) { + ZEPHIR_CPY_WRT(&intermediateModel, &existingIntermediateModel); + } + } + ZEPHIR_CALL_METHOD(NULL, &intermediateModel, "writeattribute", NULL, 0, &intermediateFields, &value); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&intermediateValue, &recordAfter, "readattribute", NULL, 0, &referencedFields); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &intermediateModel, "writeattribute", NULL, 0, &intermediateReferencedFields, &intermediateValue); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_47$$17, &intermediateModel, "dosave", NULL, 0, visited); + zephir_check_call_status(); + if (!(zephir_is_true(&_47$$17))) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &intermediateModel); + zephir_check_call_status(); + if (nesting) { + ZVAL_BOOL(&_48$$21, 1); + } else { + ZVAL_BOOL(&_48$$21, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_49, 0, &_48$$21); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_METHOD(NULL, &relatedRecords, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&recordAfter); + } else { + zephir_is_iterable(&relatedRecords, 0, "phalcon/Mvc/Model.zep", 5325); + if (Z_TYPE_P(&relatedRecords) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relatedRecords), _50$$22) + { + ZEPHIR_INIT_NVAR(&recordAfter); + ZVAL_COPY(&recordAfter, _50$$22); + ZEPHIR_CALL_METHOD(NULL, &recordAfter, "writeattribute", NULL, 0, &referencedFields, &value); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_52$$23, &recordAfter, "dosave", NULL, 0, visited); + zephir_check_call_status(); + if (!(zephir_is_true(&_52$$23))) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &recordAfter); + zephir_check_call_status(); + if (nesting) { + ZVAL_BOOL(&_53$$24, 1); + } else { + ZVAL_BOOL(&_53$$24, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_54, 0, &_53$$24); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &relatedRecords, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_51$$22, &relatedRecords, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_51$$22)) { + break; + } + ZEPHIR_CALL_METHOD(&recordAfter, &relatedRecords, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &recordAfter, "writeattribute", NULL, 0, &referencedFields, &value); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_55$$25, &recordAfter, "dosave", NULL, 0, visited); + zephir_check_call_status(); + if (!(zephir_is_true(&_55$$25))) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &recordAfter); + zephir_check_call_status(); + if (nesting) { + ZVAL_BOOL(&_56$$26, 1); + } else { + ZVAL_BOOL(&_56$$26, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_57, 0, &_56$$26); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_METHOD(NULL, &relatedRecords, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&recordAfter); + } + } else { + if (UNEXPECTED(Z_TYPE_P(&record) != IS_ARRAY)) { + if (nesting) { + ZVAL_BOOL(&_58$$28, 1); + } else { + ZVAL_BOOL(&_58$$28, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_59, 0, &_58$$28); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_60$$28); + object_init_ex(&_60$$28, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_61$$28); + ZEPHIR_CONCAT_SVSVS(&_61$$28, "There are no defined relations for the model '", &className, "' using alias '", &name, "'"); + ZEPHIR_CALL_METHOD(NULL, &_60$$28, "__construct", &_13, 33, &_61$$28); + zephir_check_call_status(); + zephir_throw_exception_debug(&_60$$28, "phalcon/Mvc/Model.zep", 5332); + ZEPHIR_MM_RESTORE(); + return; + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, related, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, related, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&name, related, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&record, related, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_62$$29, &manager, "getrelationbyalias", &_63, 0, &className, &name); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&relation, &_62$$29); + if (Z_TYPE_P(&relation) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(&_64$$30, &relation, "gettype", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG(&_64$$30, 0)) { + continue; + } + _65$$30 = Z_TYPE_P(&record) != IS_OBJECT; + if (_65$$30) { + _65$$30 = Z_TYPE_P(&record) != IS_ARRAY; + } + if (UNEXPECTED(_65$$30)) { + if (nesting) { + ZVAL_BOOL(&_66$$32, 1); + } else { + ZVAL_BOOL(&_66$$32, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_67, 0, &_66$$32); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_68$$32); + object_init_ex(&_68$$32, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_69$$32); + ZEPHIR_CONCAT_SVSV(&_69$$32, "Only objects/arrays can be stored as part of has-many/has-one/has-one-through/has-many-to-many relations on model ", &className, " on Relation ", &name); + ZEPHIR_CALL_METHOD(NULL, &_68$$32, "__construct", &_13, 33, &_69$$32); + zephir_check_call_status(); + zephir_throw_exception_debug(&_68$$32, "phalcon/Mvc/Model.zep", 5175); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&columns, &relation, "getfields", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&referencedModel, &relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&referencedFields, &relation, "getreferencedfields", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&columns) == IS_ARRAY)) { + if (nesting) { + ZVAL_BOOL(&_70$$33, 1); + } else { + ZVAL_BOOL(&_70$$33, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_71, 0, &_70$$33); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_72$$33); + object_init_ex(&_72$$33, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_73$$33); + ZEPHIR_CONCAT_SVSV(&_73$$33, "Not implemented in '", &className, "' on Relation ", &name); + ZEPHIR_CALL_METHOD(NULL, &_72$$33, "__construct", &_13, 33, &_73$$33); + zephir_check_call_status(); + zephir_throw_exception_debug(&_72$$33, "phalcon/Mvc/Model.zep", 5185); + ZEPHIR_MM_RESTORE(); + return; + } + if (Z_TYPE_P(&record) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_74$$34); + zephir_create_array(&_74$$34, 1, 0); + zephir_array_fast_append(&_74$$34, &record); + ZEPHIR_CPY_WRT(&relatedRecords, &_74$$34); + } else { + ZEPHIR_CPY_WRT(&relatedRecords, &record); + } + ZEPHIR_OBS_NVAR(&value); + if (UNEXPECTED(!(zephir_fetch_property_zval(&value, this_ptr, &columns, PH_SILENT_CC)))) { + if (nesting) { + ZVAL_BOOL(&_75$$36, 1); + } else { + ZVAL_BOOL(&_75$$36, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_76, 0, &_75$$36); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_77$$36); + object_init_ex(&_77$$36, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_78$$36); + ZEPHIR_CONCAT_SVSVS(&_78$$36, "The column '", &columns, "' needs to be present in the model '", &className, "'"); + ZEPHIR_CALL_METHOD(NULL, &_77$$36, "__construct", &_13, 33, &_78$$36); + zephir_check_call_status(); + zephir_throw_exception_debug(&_77$$36, "phalcon/Mvc/Model.zep", 5202); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&_79$$30, &relation, "isthrough", NULL, 0); + zephir_check_call_status(); + isThrough = zephir_get_boolval(&_79$$30); + if (isThrough) { + ZEPHIR_CALL_METHOD(&intermediateModelName, &relation, "getintermediatemodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&intermediateFields, &relation, "getintermediatefields", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&intermediateReferencedFields, &relation, "getintermediatereferencedfields", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&relatedRecords, 0, "phalcon/Mvc/Model.zep", 5301); + if (Z_TYPE_P(&relatedRecords) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relatedRecords), _80$$37) + { + ZEPHIR_INIT_NVAR(&recordAfter); + ZVAL_COPY(&recordAfter, _80$$37); + ZEPHIR_CALL_METHOD(&_82$$38, &recordAfter, "dosave", NULL, 0, visited); + zephir_check_call_status(); + if (!(zephir_is_true(&_82$$38))) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &recordAfter); + zephir_check_call_status(); + if (nesting) { + ZVAL_BOOL(&_83$$39, 1); + } else { + ZVAL_BOOL(&_83$$39, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_84, 0, &_83$$39); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_METHOD(&_85$$38, &manager, "load", &_86, 0, &intermediateModelName); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&intermediateModel, &_85$$38); + ZEPHIR_CALL_METHOD(&_85$$38, &relation, "gettype", &_87, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG(&_85$$38, 3)) { + ZEPHIR_INIT_NVAR(&_88$$40); + zephir_create_array(&_88$$40, 2, 0); + ZEPHIR_INIT_NVAR(&_89$$40); + ZEPHIR_CONCAT_SVS(&_89$$40, "[", &intermediateFields, "] = ?0"); + zephir_array_fast_append(&_88$$40, &_89$$40); + ZEPHIR_INIT_NVAR(&_90$$40); + zephir_create_array(&_90$$40, 1, 0); + zephir_array_fast_append(&_90$$40, &value); + zephir_array_update_string(&_88$$40, SL("bind"), &_90$$40, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&existingIntermediateModel, &intermediateModel, "findfirst", NULL, 0, &_88$$40); + zephir_check_call_status(); + if (zephir_is_true(&existingIntermediateModel)) { + ZEPHIR_CPY_WRT(&intermediateModel, &existingIntermediateModel); + } + } + ZEPHIR_CALL_METHOD(NULL, &intermediateModel, "writeattribute", NULL, 0, &intermediateFields, &value); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&intermediateValue, &recordAfter, "readattribute", NULL, 0, &referencedFields); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &intermediateModel, "writeattribute", NULL, 0, &intermediateReferencedFields, &intermediateValue); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_91$$38, &intermediateModel, "dosave", NULL, 0, visited); + zephir_check_call_status(); + if (!(zephir_is_true(&_91$$38))) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &intermediateModel); + zephir_check_call_status(); + if (nesting) { + ZVAL_BOOL(&_92$$42, 1); + } else { + ZVAL_BOOL(&_92$$42, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_93, 0, &_92$$42); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &relatedRecords, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_81$$37, &relatedRecords, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_81$$37)) { + break; + } + ZEPHIR_CALL_METHOD(&recordAfter, &relatedRecords, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_94$$43, &recordAfter, "dosave", NULL, 0, visited); + zephir_check_call_status(); + if (!(zephir_is_true(&_94$$43))) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &recordAfter); + zephir_check_call_status(); + if (nesting) { + ZVAL_BOOL(&_95$$44, 1); + } else { + ZVAL_BOOL(&_95$$44, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_96, 0, &_95$$44); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_METHOD(&_97$$43, &manager, "load", &_98, 0, &intermediateModelName); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&intermediateModel, &_97$$43); + ZEPHIR_CALL_METHOD(&_97$$43, &relation, "gettype", &_99, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG(&_97$$43, 3)) { + ZEPHIR_INIT_NVAR(&_100$$45); + zephir_create_array(&_100$$45, 2, 0); + ZEPHIR_INIT_NVAR(&_101$$45); + ZEPHIR_CONCAT_SVS(&_101$$45, "[", &intermediateFields, "] = ?0"); + zephir_array_fast_append(&_100$$45, &_101$$45); + ZEPHIR_INIT_NVAR(&_102$$45); + zephir_create_array(&_102$$45, 1, 0); + zephir_array_fast_append(&_102$$45, &value); + zephir_array_update_string(&_100$$45, SL("bind"), &_102$$45, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&existingIntermediateModel, &intermediateModel, "findfirst", NULL, 0, &_100$$45); + zephir_check_call_status(); + if (zephir_is_true(&existingIntermediateModel)) { + ZEPHIR_CPY_WRT(&intermediateModel, &existingIntermediateModel); + } + } + ZEPHIR_CALL_METHOD(NULL, &intermediateModel, "writeattribute", NULL, 0, &intermediateFields, &value); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&intermediateValue, &recordAfter, "readattribute", NULL, 0, &referencedFields); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &intermediateModel, "writeattribute", NULL, 0, &intermediateReferencedFields, &intermediateValue); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_103$$43, &intermediateModel, "dosave", NULL, 0, visited); + zephir_check_call_status(); + if (!(zephir_is_true(&_103$$43))) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &intermediateModel); + zephir_check_call_status(); + if (nesting) { + ZVAL_BOOL(&_104$$47, 1); + } else { + ZVAL_BOOL(&_104$$47, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_105, 0, &_104$$47); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_METHOD(NULL, &relatedRecords, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&recordAfter); + } else { + zephir_is_iterable(&relatedRecords, 0, "phalcon/Mvc/Model.zep", 5325); + if (Z_TYPE_P(&relatedRecords) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relatedRecords), _106$$48) + { + ZEPHIR_INIT_NVAR(&recordAfter); + ZVAL_COPY(&recordAfter, _106$$48); + ZEPHIR_CALL_METHOD(NULL, &recordAfter, "writeattribute", NULL, 0, &referencedFields, &value); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_108$$49, &recordAfter, "dosave", NULL, 0, visited); + zephir_check_call_status(); + if (!(zephir_is_true(&_108$$49))) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &recordAfter); + zephir_check_call_status(); + if (nesting) { + ZVAL_BOOL(&_109$$50, 1); + } else { + ZVAL_BOOL(&_109$$50, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_110, 0, &_109$$50); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &relatedRecords, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_107$$48, &relatedRecords, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_107$$48)) { + break; + } + ZEPHIR_CALL_METHOD(&recordAfter, &relatedRecords, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &recordAfter, "writeattribute", NULL, 0, &referencedFields, &value); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_111$$51, &recordAfter, "dosave", NULL, 0, visited); + zephir_check_call_status(); + if (!(zephir_is_true(&_111$$51))) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &recordAfter); + zephir_check_call_status(); + if (nesting) { + ZVAL_BOOL(&_112$$52, 1); + } else { + ZVAL_BOOL(&_112$$52, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_113, 0, &_112$$52); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_METHOD(NULL, &relatedRecords, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&recordAfter); + } + } else { + if (UNEXPECTED(Z_TYPE_P(&record) != IS_ARRAY)) { + if (nesting) { + ZVAL_BOOL(&_114$$54, 1); + } else { + ZVAL_BOOL(&_114$$54, 0); + } + ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_115, 0, &_114$$54); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_116$$54); + object_init_ex(&_116$$54, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_117$$54); + ZEPHIR_CONCAT_SVSVS(&_117$$54, "There are no defined relations for the model '", &className, "' using alias '", &name, "'"); + ZEPHIR_CALL_METHOD(NULL, &_116$$54, "__construct", &_13, 33, &_117$$54); + zephir_check_call_status(); + zephir_throw_exception_debug(&_116$$54, "phalcon/Mvc/Model.zep", 5332); + ZEPHIR_MM_RESTORE(); + return; + } + } + ZEPHIR_CALL_METHOD(NULL, related, "next", NULL, 0); + zephir_check_call_status(); + } } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + ZEPHIR_INIT_NVAR(&record); + ZEPHIR_INIT_NVAR(&name); + if (nesting) { + ZVAL_BOOL(&_118, 1); } else { - ZEPHIR_INIT_VAR(&name); + ZVAL_BOOL(&_118, 0); } - zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); - RETURN_THIS(); + ZEPHIR_CALL_METHOD(NULL, connection, "commit", NULL, 0, &_118); + zephir_check_call_status(); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setTagFactory) +static PHP_METHOD(Phalcon_Mvc_Model, allowEmptyStringValues) { - zval *tagFactory, tagFactory_sub; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *attributes_param = NULL, __$true, keysAttributes, attribute, *_0, _1, _2; + zval attributes; zval *this_ptr = getThis(); - ZVAL_UNDEF(&tagFactory_sub); + ZVAL_UNDEF(&attributes); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&keysAttributes); + ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(tagFactory, phalcon_html_tagfactory_ce) + Z_PARAM_ARRAY(attributes) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &tagFactory); - zephir_update_property_zval(this_ptr, ZEND_STRL("tagFactory"), tagFactory); - RETURN_THISW(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &attributes_param); + ZEPHIR_OBS_COPY_OR_DUP(&attributes, attributes_param); + ZEPHIR_INIT_VAR(&keysAttributes); + array_init(&keysAttributes); + zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model.zep", 5373); + if (Z_TYPE_P(&attributes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _0) + { + ZEPHIR_INIT_NVAR(&attribute); + ZVAL_COPY(&attribute, _0); + zephir_array_update_zval(&keysAttributes, &attribute, &__$true, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &attributes, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_update_zval(&keysAttributes, &attribute, &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&attribute); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "getmodelsmetadata", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_2, "setemptystringattributes", NULL, 0, this_ptr, &keysAttributes); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setUserOption) +static PHP_METHOD(Phalcon_Mvc_Model, cancelOperation) { + zval _0, _1$$3, _2$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *option_param = NULL, *value, value_sub; - zval option; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&option); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(option) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &option_param, &value); - zephir_get_strval(&option, option_param); - zephir_update_property_array(this_ptr, SL("options"), &option, value); - RETURN_THIS(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("operationMade"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_LONG(&_0, 3)) { + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "notDeleted"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_1$$3); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_VAR(&_2$$4); + ZVAL_STRING(&_2$$4, "notSaved"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_2$$4); + zephir_check_call_status(); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setUserOptions) +static PHP_METHOD(Phalcon_Mvc_Model, belongsTo) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *options_param = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; zval options; + zval referenceModel; + zval *fields, fields_sub, *referenceModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, _0; zval *this_ptr = getThis(); + ZVAL_UNDEF(&fields_sub); + ZVAL_UNDEF(&referencedFields_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&referenceModel); ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(1, 1) + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_ZVAL(fields) + Z_PARAM_STR(referenceModel) + Z_PARAM_ZVAL(referencedFields) + Z_PARAM_OPTIONAL Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &options_param); - zephir_get_arrval(&options, options_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); - RETURN_THIS(); + zephir_fetch_params(1, 3, 1, &fields, &referenceModel_param, &referencedFields, &options_param); + if (UNEXPECTED(Z_TYPE_P(referenceModel_param) != IS_STRING && Z_TYPE_P(referenceModel_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceModel' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(referenceModel_param) == IS_STRING)) { + zephir_get_strval(&referenceModel, referenceModel_param); + } else { + ZEPHIR_INIT_VAR(&referenceModel); + } + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "addbelongsto", NULL, 0, this_ptr, fields, &referenceModel, referencedFields, &options); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getLocalTagFactory) +static PHP_METHOD(Phalcon_Mvc_Model, getPreparedQuery) { - zval container, escaper, tagFactory, _0, _1$$3, _2$$4, _3$$5, _4$$5, _5$$6, _6$$7, _7$$7, _8$$8; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + zval *params, params_sub, *limit = NULL, limit_sub, __$null, builder, bindParams, bindTypes, transaction, cache, manager, query, container, _0, _1, _2$$5, _3$$7; + ZVAL_UNDEF(¶ms_sub); + ZVAL_UNDEF(&limit_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&builder); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&transaction); + ZVAL_UNDEF(&cache); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&query); ZVAL_UNDEF(&container); - ZVAL_UNDEF(&escaper); - ZVAL_UNDEF(&tagFactory); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_7$$7); - ZVAL_UNDEF(&_8$$8); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_3$$7); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(params) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(limit) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&tagFactory); - ZVAL_NULL(&tagFactory); - zephir_read_property(&_0, this_ptr, ZEND_STRL("tagFactory"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(ZEPHIR_IS_EMPTY(&_0))) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("form"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_1$$3) != IS_NULL) { - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("form"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&tagFactory, &_2$$4, "gettagfactory", NULL, 0); + zephir_fetch_params(1, 1, 1, ¶ms, &limit); + if (!limit) { + limit = &limit_sub; + limit = &__$null; + } + ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "modelsManager"); + ZEPHIR_CALL_METHOD(&_0, &container, "getshared", NULL, 0, &_1); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&manager, &_0); + ZEPHIR_CALL_METHOD(&_0, &manager, "createbuilder", NULL, 0, params); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&builder, &_0); + ZEPHIR_INIT_NVAR(&_1); + zephir_get_called_class(&_1); + ZEPHIR_CALL_METHOD(NULL, &builder, "from", NULL, 0, &_1); + zephir_check_call_status(); + if (Z_TYPE_P(limit) != IS_NULL) { + ZEPHIR_CALL_METHOD(NULL, &builder, "limit", NULL, 0, limit); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(&_0, &builder, "getquery", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&query, &_0); + zephir_memory_observe(&bindParams); + if (zephir_array_isset_string_fetch(&bindParams, params, SL("bind"), 0)) { + if (Z_TYPE_P(&bindParams) == IS_ARRAY) { + ZVAL_BOOL(&_2$$5, 1); + ZEPHIR_CALL_METHOD(NULL, &query, "setbindparams", NULL, 0, &bindParams, &_2$$5); zephir_check_call_status(); } - if (Z_TYPE_P(&tagFactory) == IS_NULL) { - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_4$$5); - ZVAL_STRING(&_4$$5, "tag"); - ZEPHIR_CALL_METHOD(&_3$$5, &container, "has", NULL, 0, &_4$$5); - zephir_check_call_status(); - if (EXPECTED(ZEPHIR_IS_TRUE_IDENTICAL(&_3$$5))) { - ZEPHIR_INIT_VAR(&_5$$6); - ZVAL_STRING(&_5$$6, "tag"); - ZEPHIR_CALL_METHOD(&tagFactory, &container, "getshared", NULL, 0, &_5$$6); + zephir_memory_observe(&bindTypes); + if (zephir_array_isset_string_fetch(&bindTypes, params, SL("bindTypes"), 0)) { + if (Z_TYPE_P(&bindTypes) == IS_ARRAY) { + ZVAL_BOOL(&_3$$7, 1); + ZEPHIR_CALL_METHOD(NULL, &query, "setbindtypes", NULL, 0, &bindTypes, &_3$$7); zephir_check_call_status(); } } - if (Z_TYPE_P(&tagFactory) == IS_NULL) { - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_7$$7); - ZVAL_STRING(&_7$$7, "escaper"); - ZEPHIR_CALL_METHOD(&_6$$7, &container, "has", NULL, 0, &_7$$7); - zephir_check_call_status(); - if (EXPECTED(ZEPHIR_IS_TRUE_IDENTICAL(&_6$$7))) { - ZEPHIR_INIT_VAR(&_8$$8); - ZVAL_STRING(&_8$$8, "escaper"); - ZEPHIR_CALL_METHOD(&escaper, &container, "getshared", NULL, 0, &_8$$8); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&escaper); - object_init_ex(&escaper, phalcon_html_escaper_ce); - if (zephir_has_constructor(&escaper)) { - ZEPHIR_CALL_METHOD(NULL, &escaper, "__construct", NULL, 0); - zephir_check_call_status(); - } - - } - ZEPHIR_INIT_NVAR(&tagFactory); - object_init_ex(&tagFactory, phalcon_html_tagfactory_ce); - ZEPHIR_CALL_METHOD(NULL, &tagFactory, "__construct", NULL, 9, &escaper); + } + zephir_memory_observe(&transaction); + if (zephir_array_isset_string_fetch(&transaction, params, SL("transaction"), 0)) { + if (zephir_instance_of_ev(&transaction, phalcon_mvc_model_transactioninterface_ce)) { + ZEPHIR_CALL_METHOD(NULL, &query, "settransaction", NULL, 0, &transaction); zephir_check_call_status(); } - zephir_update_property_zval(this_ptr, ZEND_STRL("tagFactory"), &tagFactory); } - RETURN_MM_MEMBER(getThis(), "tagFactory"); + zephir_memory_observe(&cache); + if (zephir_array_isset_string_fetch(&cache, params, SL("cache"), 0)) { + ZEPHIR_CALL_METHOD(NULL, &query, "cache", NULL, 0, &cache); + zephir_check_call_status(); + } + RETURN_CCTOR(&query); } -zend_object *zephir_init_properties_Phalcon_Forms_Element_AbstractElement(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Mvc_Model, hasMany) { - zval _0, _2, _4, _6, _1$$3, _3$$4, _5$$5, _7$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - + zend_long ZEPHIR_LAST_CALL_STATUS; + zval options; + zval referenceModel; + zval *fields, fields_sub, *referenceModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, _0; + zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("validators"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("validators"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("filters"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("filters"), &_5$$5); - } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("attributes"), &_7$$6); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + ZVAL_UNDEF(&fields_sub); + ZVAL_UNDEF(&referencedFields_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&referenceModel); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_ZVAL(fields) + Z_PARAM_STR(referenceModel) + Z_PARAM_ZVAL(referencedFields) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 1, &fields, &referenceModel_param, &referencedFields, &options_param); + if (UNEXPECTED(Z_TYPE_P(referenceModel_param) != IS_STRING && Z_TYPE_P(referenceModel_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceModel' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(referenceModel_param) == IS_STRING)) { + zephir_get_strval(&referenceModel, referenceModel_param); + } else { + ZEPHIR_INIT_VAR(&referenceModel); + } + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); } + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "addhasmany", NULL, 0, this_ptr, fields, &referenceModel, referencedFields, &options); + zephir_check_call_status(); + RETURN_MM(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Check) +static PHP_METHOD(Phalcon_Mvc_Model, hasManyToMany) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Check, phalcon, forms_element_check, phalcon_forms_element_abstractelement_ce, NULL, 0); - - zend_declare_property_string(phalcon_forms_element_check_ce, SL("method"), "inputCheckbox", ZEND_ACC_PROTECTED); - return SUCCESS; -} + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval options; + zval intermediateModel, referenceModel; + zval *fields, fields_sub, *intermediateModel_param = NULL, *intermediateFields, intermediateFields_sub, *intermediateReferencedFields, intermediateReferencedFields_sub, *referenceModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, _0; + zval *this_ptr = getThis(); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Date) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Date, phalcon, forms_element_date, phalcon_forms_element_abstractelement_ce, NULL, 0); - - zend_declare_property_string(phalcon_forms_element_date_ce, SL("method"), "inputDate", ZEND_ACC_PROTECTED); - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_ElementInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Forms\\Element, ElementInterface, phalcon, forms_element_elementinterface, phalcon_forms_element_elementinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, addFilter); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, addValidator); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, addValidators); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, appendMessage); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, clear); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getAttribute); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getDefault); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getFilters); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getForm); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getLabel); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getMessages); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getName); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getUserOption); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getUserOptions); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getValidators); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getValue); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, hasMessages); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, label); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, render); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setAttribute); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setDefault); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setFilters); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setForm); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setLabel); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setMessages); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setName); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setUserOption); -ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setUserOptions); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Email) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Email, phalcon, forms_element_email, phalcon_forms_element_abstractelement_ce, NULL, 0); - - zend_declare_property_string(phalcon_forms_element_email_ce, SL("method"), "inputEmail", ZEND_ACC_PROTECTED); - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_File) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, File, phalcon, forms_element_file, phalcon_forms_element_abstractelement_ce, NULL, 0); - - zend_declare_property_string(phalcon_forms_element_file_ce, SL("method"), "inputFile", ZEND_ACC_PROTECTED); - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Hidden) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Hidden, phalcon, forms_element_hidden, phalcon_forms_element_abstractelement_ce, NULL, 0); - - zend_declare_property_string(phalcon_forms_element_hidden_ce, SL("method"), "inputHidden", ZEND_ACC_PROTECTED); - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Numeric) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Numeric, phalcon, forms_element_numeric, phalcon_forms_element_abstractelement_ce, NULL, 0); - - zend_declare_property_string(phalcon_forms_element_numeric_ce, SL("method"), "inputNumeric", ZEND_ACC_PROTECTED); - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Password) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Password, phalcon, forms_element_password, phalcon_forms_element_abstractelement_ce, NULL, 0); - - zend_declare_property_string(phalcon_forms_element_password_ce, SL("method"), "inputPassword", ZEND_ACC_PROTECTED); - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Radio) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Radio, phalcon, forms_element_radio, phalcon_forms_element_abstractelement_ce, NULL, 0); - - zend_declare_property_string(phalcon_forms_element_radio_ce, SL("method"), "inputRadio", ZEND_ACC_PROTECTED); - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Select) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Select, phalcon, forms_element_select, phalcon_forms_element_abstractelement_ce, phalcon_forms_element_select_method_entry, 0); - - zend_declare_property_null(phalcon_forms_element_select_ce, SL("optionsValues"), ZEND_ACC_PROTECTED); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Forms_Element_Select, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes; - zval *name_param = NULL, *options = NULL, options_sub, *attributes_param = NULL, __$null; - zval name; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&options_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&attributes); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(name) + ZVAL_UNDEF(&fields_sub); + ZVAL_UNDEF(&intermediateFields_sub); + ZVAL_UNDEF(&intermediateReferencedFields_sub); + ZVAL_UNDEF(&referencedFields_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&intermediateModel); + ZVAL_UNDEF(&referenceModel); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(6, 7) + Z_PARAM_ZVAL(fields) + Z_PARAM_STR(intermediateModel) + Z_PARAM_ZVAL(intermediateFields) + Z_PARAM_ZVAL(intermediateReferencedFields) + Z_PARAM_STR(referenceModel) + Z_PARAM_ZVAL(referencedFields) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(options) - Z_PARAM_ARRAY(attributes) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &name_param, &options, &attributes_param); - zephir_get_strval(&name, name_param); - if (!options) { - options = &options_sub; - options = &__$null; + zephir_fetch_params(1, 6, 1, &fields, &intermediateModel_param, &intermediateFields, &intermediateReferencedFields, &referenceModel_param, &referencedFields, &options_param); + if (UNEXPECTED(Z_TYPE_P(intermediateModel_param) != IS_STRING && Z_TYPE_P(intermediateModel_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'intermediateModel' must be of the type string")); + RETURN_MM_NULL(); } - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); + if (EXPECTED(Z_TYPE_P(intermediateModel_param) == IS_STRING)) { + zephir_get_strval(&intermediateModel, intermediateModel_param); } else { - zephir_get_arrval(&attributes, attributes_param); + ZEPHIR_INIT_VAR(&intermediateModel); } - zephir_update_property_zval(this_ptr, ZEND_STRL("optionsValues"), options); - ZEPHIR_CALL_PARENT(NULL, phalcon_forms_element_select_ce, getThis(), "__construct", NULL, 0, &name, &attributes); + if (UNEXPECTED(Z_TYPE_P(referenceModel_param) != IS_STRING && Z_TYPE_P(referenceModel_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceModel' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(referenceModel_param) == IS_STRING)) { + zephir_get_strval(&referenceModel, referenceModel_param); + } else { + ZEPHIR_INIT_VAR(&referenceModel); + } + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "addhasmanytomany", NULL, 0, this_ptr, fields, &intermediateModel, intermediateFields, intermediateReferencedFields, &referenceModel, referencedFields, &options); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Forms_Element_Select, addOption) +static PHP_METHOD(Phalcon_Mvc_Model, hasOne) { - zend_string *_3$$3; - zend_ulong _2$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *option, option_sub, key, value, *_0$$3, _1$$3; + zval options; + zval referenceModel; + zval *fields, fields_sub, *referenceModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&option_sub); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(option) + ZVAL_UNDEF(&fields_sub); + ZVAL_UNDEF(&referencedFields_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&referenceModel); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_ZVAL(fields) + Z_PARAM_STR(referenceModel) + Z_PARAM_ZVAL(referencedFields) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &option); - if (Z_TYPE_P(option) == IS_ARRAY) { - zephir_is_iterable(option, 0, "phalcon/Forms/Element/Select.zep", 51); - if (Z_TYPE_P(option) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(option), _2$$3, _3$$3, _0$$3) - { - ZEPHIR_INIT_NVAR(&key); - if (_3$$3 != NULL) { - ZVAL_STR_COPY(&key, _3$$3); - } else { - ZVAL_LONG(&key, _2$$3); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0$$3); - zephir_update_property_array(this_ptr, SL("optionsValues"), &key, &value); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, option, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1$$3, option, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&key, option, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, option, "current", NULL, 0); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("optionsValues"), &key, &value); - ZEPHIR_CALL_METHOD(NULL, option, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); + zephir_fetch_params(1, 3, 1, &fields, &referenceModel_param, &referencedFields, &options_param); + if (UNEXPECTED(Z_TYPE_P(referenceModel_param) != IS_STRING && Z_TYPE_P(referenceModel_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceModel' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(referenceModel_param) == IS_STRING)) { + zephir_get_strval(&referenceModel, referenceModel_param); } else { - zephir_update_property_array_append(this_ptr, SL("optionsValues"), option); + ZEPHIR_INIT_VAR(&referenceModel); } - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Forms_Element_Select, getOptions) -{ - - RETURN_MEMBER(getThis(), "optionsValues"); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "addhasone", NULL, 0, this_ptr, fields, &referenceModel, referencedFields, &options); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Forms_Element_Select, render) +static PHP_METHOD(Phalcon_Mvc_Model, hasOneThrough) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *attributes_param = NULL, _0, _1; - zval attributes; + zval options; + zval intermediateModel, referenceModel; + zval *fields, fields_sub, *intermediateModel_param = NULL, *intermediateFields, intermediateFields_sub, *intermediateReferencedFields, intermediateReferencedFields_sub, *referenceModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&fields_sub); + ZVAL_UNDEF(&intermediateFields_sub); + ZVAL_UNDEF(&intermediateReferencedFields_sub); + ZVAL_UNDEF(&referencedFields_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(0, 1) + ZVAL_UNDEF(&intermediateModel); + ZVAL_UNDEF(&referenceModel); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(6, 7) + Z_PARAM_ZVAL(fields) + Z_PARAM_STR(intermediateModel) + Z_PARAM_ZVAL(intermediateFields) + Z_PARAM_ZVAL(intermediateReferencedFields) + Z_PARAM_STR(referenceModel) + Z_PARAM_ZVAL(referencedFields) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &attributes_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); + zephir_fetch_params(1, 6, 1, &fields, &intermediateModel_param, &intermediateFields, &intermediateReferencedFields, &referenceModel_param, &referencedFields, &options_param); + if (UNEXPECTED(Z_TYPE_P(intermediateModel_param) != IS_STRING && Z_TYPE_P(intermediateModel_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'intermediateModel' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(intermediateModel_param) == IS_STRING)) { + zephir_get_strval(&intermediateModel, intermediateModel_param); } else { - zephir_get_arrval(&attributes, attributes_param); + ZEPHIR_INIT_VAR(&intermediateModel); } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "prepareattributes", NULL, 0, &attributes); - zephir_check_call_status(); - zephir_read_property(&_1, this_ptr, ZEND_STRL("optionsValues"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_CE_STATIC(phalcon_tag_select_ce, "selectfield", NULL, 0, &_0, &_1); + if (UNEXPECTED(Z_TYPE_P(referenceModel_param) != IS_STRING && Z_TYPE_P(referenceModel_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceModel' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(referenceModel_param) == IS_STRING)) { + zephir_get_strval(&referenceModel, referenceModel_param); + } else { + ZEPHIR_INIT_VAR(&referenceModel); + } + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "addhasonethrough", NULL, 0, this_ptr, fields, &intermediateModel, intermediateFields, intermediateReferencedFields, &referenceModel, referencedFields, &options); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Forms_Element_Select, setOptions) +static PHP_METHOD(Phalcon_Mvc_Model, keepSnapshots) { - zval *options, options_sub; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *keepSnapshot_param = NULL, _0, _1; + zend_bool keepSnapshot; zval *this_ptr = getThis(); - ZVAL_UNDEF(&options_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(options) + Z_PARAM_BOOL(keepSnapshot) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &options); - zephir_update_property_zval(this_ptr, ZEND_STRL("optionsValues"), options); - RETURN_THISW(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &keepSnapshot_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + if (keepSnapshot) { + ZVAL_BOOL(&_1, 1); + } else { + ZVAL_BOOL(&_1, 0); + } + ZEPHIR_CALL_METHOD(NULL, &_0, "keepsnapshots", NULL, 0, this_ptr, &_1); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Forms_Element_Select, prepareAttributes) +static PHP_METHOD(Phalcon_Mvc_Model, setSchema) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *attributes_param = NULL, value, name, mergedAttributes, defaultAttributes, _0; - zval attributes; + zval *schema_param = NULL, _0; + zval schema; zval *this_ptr = getThis(); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&mergedAttributes); - ZVAL_UNDEF(&defaultAttributes); + ZVAL_UNDEF(&schema); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(schema) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &attributes_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); + zephir_fetch_params(1, 1, 0, &schema_param); + if (UNEXPECTED(Z_TYPE_P(schema_param) != IS_STRING && Z_TYPE_P(schema_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schema' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(schema_param) == IS_STRING)) { + zephir_get_strval(&schema, schema_param); } else { - zephir_get_arrval(&attributes, attributes_param); + ZEPHIR_INIT_VAR(&schema); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&name, &_0); - zephir_array_update_long(&attributes, 0, &name, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_memory_observe(&defaultAttributes); - zephir_read_property(&defaultAttributes, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&mergedAttributes); - zephir_fast_array_merge(&mergedAttributes, &defaultAttributes, &attributes); - ZEPHIR_CALL_METHOD(&value, this_ptr, "getvalue", NULL, 0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "setmodelschema", NULL, 0, this_ptr, &schema); zephir_check_call_status(); - if (Z_TYPE_P(&value) != IS_NULL) { - zephir_array_update_string(&mergedAttributes, SL("value"), &value, PH_COPY | PH_SEPARATE); - } - RETURN_CCTOR(&mergedAttributes); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Submit) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Submit, phalcon, forms_element_submit, phalcon_forms_element_abstractelement_ce, NULL, 0); - - zend_declare_property_string(phalcon_forms_element_submit_ce, SL("method"), "inputSubmit", ZEND_ACC_PROTECTED); - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Text) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Text, phalcon, forms_element_text, phalcon_forms_element_abstractelement_ce, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_TextArea) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, TextArea, phalcon, forms_element_textarea, phalcon_forms_element_abstractelement_ce, NULL, 0); - - zend_declare_property_string(phalcon_forms_element_textarea_ce, SL("method"), "inputTextarea", ZEND_ACC_PROTECTED); - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Logger_AbstractLogger) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Logger, AbstractLogger, phalcon, logger_abstractlogger, phalcon_logger_abstractlogger_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_logger_abstractlogger_ce, SL("adapters"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_logger_abstractlogger_ce, SL("excluded"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_logger_abstractlogger_ce, SL("logLevel"), 8, ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_logger_abstractlogger_ce, SL("name"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_logger_abstractlogger_ce, SL("timezone"), ZEND_ACC_PROTECTED); - phalcon_logger_abstractlogger_ce->create_object = zephir_init_properties_Phalcon_Logger_AbstractLogger; - zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("ALERT"), 2); - - zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("CRITICAL"), 1); - - zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("CUSTOM"), 8); - - zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("DEBUG"), 7); - - zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("EMERGENCY"), 0); - - zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("ERROR"), 3); - - zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("INFO"), 6); - - zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("NOTICE"), 5); - - zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("WARNING"), 4); - - return SUCCESS; + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Logger_AbstractLogger, __construct) +static PHP_METHOD(Phalcon_Mvc_Model, setSource) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval adapters; - zval *name_param = NULL, *adapters_param = NULL, *timezone = NULL, timezone_sub, __$null, defaultTimezone; - zval name; + zval *source_param = NULL, _0; + zval source; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&timezone_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&defaultTimezone); - ZVAL_UNDEF(&adapters); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(name) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(adapters) - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(timezone, php_date_get_timezone_ce()) + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(source) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &name_param, &adapters_param, &timezone); - zephir_get_strval(&name, name_param); - if (!adapters_param) { - ZEPHIR_INIT_VAR(&adapters); - array_init(&adapters); - } else { - zephir_get_arrval(&adapters, adapters_param); + zephir_fetch_params(1, 1, 0, &source_param); + if (UNEXPECTED(Z_TYPE_P(source_param) != IS_STRING && Z_TYPE_P(source_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'source' must be of the type string")); + RETURN_MM_NULL(); } - if (!timezone) { - timezone = &timezone_sub; - ZEPHIR_CPY_WRT(timezone, &__$null); + if (EXPECTED(Z_TYPE_P(source_param) == IS_STRING)) { + zephir_get_strval(&source, source_param); } else { - ZEPHIR_SEPARATE_PARAM(timezone); - } - if (Z_TYPE_P(timezone) == IS_NULL) { - ZEPHIR_CALL_FUNCTION(&defaultTimezone, "date_default_timezone_get", NULL, 97); - zephir_check_call_status(); - if (UNEXPECTED(1 == ZEPHIR_IS_EMPTY(&defaultTimezone))) { - ZEPHIR_INIT_NVAR(&defaultTimezone); - ZVAL_STRING(&defaultTimezone, "UTC"); - } - ZEPHIR_INIT_NVAR(timezone); - object_init_ex(timezone, php_date_get_timezone_ce()); - ZEPHIR_CALL_METHOD(NULL, timezone, "__construct", NULL, 0, &defaultTimezone); - zephir_check_call_status(); + ZEPHIR_INIT_VAR(&source); } - zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); - zephir_update_property_zval(this_ptr, ZEND_STRL("timezone"), timezone); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setadapters", NULL, 0, &adapters); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "setmodelsource", NULL, 0, this_ptr, &source); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Logger_AbstractLogger, addAdapter) +static PHP_METHOD(Phalcon_Mvc_Model, skipAttributes) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, *adapter, adapter_sub; - zval name; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *attributes_param = NULL; + zval attributes; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&adapter_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_OBJECT_OF_CLASS(adapter, phalcon_logger_adapter_adapterinterface_ce) + ZVAL_UNDEF(&attributes); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(attributes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &adapter); - zephir_get_strval(&name, name_param); - zephir_update_property_array(this_ptr, SL("adapters"), &name, adapter); - RETURN_THIS(); + zephir_fetch_params(1, 1, 0, &attributes_param); + ZEPHIR_OBS_COPY_OR_DUP(&attributes, attributes_param); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "skipattributesoncreate", NULL, 0, &attributes); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "skipattributesonupdate", NULL, 0, &attributes); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Logger_AbstractLogger, excludeAdapters) +static PHP_METHOD(Phalcon_Mvc_Model, skipAttributesOnCreate) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *adapters_param = NULL, __$true, adapter, registered, *_0, _1; - zval adapters; + zval *attributes_param = NULL, __$null, attribute, *_0, _1, _2; + zval attributes, keysAttributes; zval *this_ptr = getThis(); - ZVAL_UNDEF(&adapters); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&adapter); - ZVAL_UNDEF(®istered); + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&keysAttributes); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&attribute); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(adapters) + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(attributes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &adapters_param); - if (!adapters_param) { - ZEPHIR_INIT_VAR(&adapters); - array_init(&adapters); - } else { - zephir_get_arrval(&adapters, adapters_param); - } - zephir_memory_observe(®istered); - zephir_read_property(®istered, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC); - zephir_is_iterable(&adapters, 0, "phalcon/Logger/AbstractLogger.zep", 153); - if (Z_TYPE_P(&adapters) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&adapters), _0) + zephir_fetch_params(1, 1, 0, &attributes_param); + ZEPHIR_OBS_COPY_OR_DUP(&attributes, attributes_param); + ZEPHIR_INIT_VAR(&keysAttributes); + array_init(&keysAttributes); + zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model.zep", 5832); + if (Z_TYPE_P(&attributes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _0) { - ZEPHIR_INIT_NVAR(&adapter); - ZVAL_COPY(&adapter, _0); - if (1 == zephir_array_isset(®istered, &adapter)) { - zephir_update_property_array(this_ptr, SL("excluded"), &adapter, &__$true); - } + ZEPHIR_INIT_NVAR(&attribute); + ZVAL_COPY(&attribute, _0); + zephir_array_update_zval(&keysAttributes, &attribute, &__$null, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &adapters, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_1, &adapters, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_1, &attributes, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_1)) { break; } - ZEPHIR_CALL_METHOD(&adapter, &adapters, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); zephir_check_call_status(); - if (1 == zephir_array_isset(®istered, &adapter)) { - zephir_update_property_array(this_ptr, SL("excluded"), &adapter, &__$true); - } - ZEPHIR_CALL_METHOD(NULL, &adapters, "next", NULL, 0); + zephir_array_update_zval(&keysAttributes, &attribute, &__$null, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&adapter); - RETURN_THIS(); + ZEPHIR_INIT_NVAR(&attribute); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "getmodelsmetadata", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_2, "setautomaticcreateattributes", NULL, 0, this_ptr, &keysAttributes); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Logger_AbstractLogger, getAdapter) +static PHP_METHOD(Phalcon_Mvc_Model, skipAttributesOnUpdate) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, _0, _1, _2; - zval name; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *attributes_param = NULL, __$null, attribute, *_0, _1, _2; + zval attributes, keysAttributes; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&keysAttributes); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&attribute); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + Z_PARAM_ARRAY(attributes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - zephir_get_strval(&name, name_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); - if (1 != zephir_array_isset(&_0, &name)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "Adapter does not exist for this logger", "phalcon/Logger/AbstractLogger.zep", 169); - return; + zephir_fetch_params(1, 1, 0, &attributes_param); + ZEPHIR_OBS_COPY_OR_DUP(&attributes, attributes_param); + ZEPHIR_INIT_VAR(&keysAttributes); + array_init(&keysAttributes); + zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model.zep", 5867); + if (Z_TYPE_P(&attributes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _0) + { + ZEPHIR_INIT_NVAR(&attribute); + ZVAL_COPY(&attribute, _0); + zephir_array_update_zval(&keysAttributes, &attribute, &__$null, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &attributes, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_update_zval(&keysAttributes, &attribute, &__$null, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); + zephir_check_call_status(); + } } - zephir_read_property(&_1, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_2, &_1, &name, PH_NOISY | PH_READONLY, "phalcon/Logger/AbstractLogger.zep", 172); - RETURN_CTOR(&_2); -} - -static PHP_METHOD(Phalcon_Logger_AbstractLogger, getAdapters) -{ - - RETURN_MEMBER(getThis(), "adapters"); -} - -static PHP_METHOD(Phalcon_Logger_AbstractLogger, getLogLevel) -{ - - RETURN_MEMBER(getThis(), "logLevel"); -} - -static PHP_METHOD(Phalcon_Logger_AbstractLogger, getName) -{ - - RETURN_MEMBER(getThis(), "name"); + ZEPHIR_INIT_NVAR(&attribute); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "getmodelsmetadata", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_2, "setautomaticupdateattributes", NULL, 0, this_ptr, &keysAttributes); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Logger_AbstractLogger, removeAdapter) +static PHP_METHOD(Phalcon_Mvc_Model, useDynamicUpdate) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, _0, _1; - zval name; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *dynamicUpdate_param = NULL, _0, _1; + zend_bool dynamicUpdate; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + Z_PARAM_BOOL(dynamicUpdate) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - zephir_get_strval(&name, name_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); - if (1 != zephir_array_isset(&_0, &name)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "Adapter does not exist for this logger", "phalcon/Logger/AbstractLogger.zep", 214); - return; + zephir_fetch_params(1, 1, 0, &dynamicUpdate_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); + if (dynamicUpdate) { + ZVAL_BOOL(&_1, 1); + } else { + ZVAL_BOOL(&_1, 0); } - zephir_unset_property_array(this_ptr, ZEND_STRL("adapters"), &name); - zephir_read_property(&_1, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); - zephir_array_unset(&_1, &name, PH_SEPARATE); - RETURN_THIS(); + ZEPHIR_CALL_METHOD(NULL, &_0, "usedynamicupdate", NULL, 0, this_ptr, &_1); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Logger_AbstractLogger, setAdapters) +static PHP_METHOD(Phalcon_Mvc_Model, validate) { + zend_object_iterator *_1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *adapters_param = NULL; - zval adapters; + zephir_fcall_cache_entry *_8 = NULL, *_9 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *validator, validator_sub, messages, message, _0, _2$$4, _3$$4, _4$$4, _5$$4, _6$$4, _7$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&adapters); + ZVAL_UNDEF(&validator_sub); + ZVAL_UNDEF(&messages); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$4); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(adapters) + Z_PARAM_OBJECT_OF_CLASS(validator, phalcon_filter_validation_validationinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &adapters_param); - zephir_get_arrval(&adapters, adapters_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("adapters"), &adapters); - RETURN_THIS(); + zephir_fetch_params(1, 1, 0, &validator); + ZVAL_NULL(&_0); + ZEPHIR_CALL_METHOD(&messages, validator, "validate", NULL, 0, &_0, this_ptr); + zephir_check_call_status(); + if (((Z_TYPE_P(&messages) == IS_TRUE || Z_TYPE_P(&messages) == IS_FALSE) == 1)) { + RETURN_CCTOR(&messages); + } + _1 = zephir_get_iterator(&messages); + _1->funcs->rewind(_1); + for (;_1->funcs->valid(_1) == SUCCESS && !EG(exception); _1->funcs->move_forward(_1)) { + { + ZEPHIR_ITERATOR_COPY(&message, _1); + } + ZEPHIR_INIT_NVAR(&_2$$4); + object_init_ex(&_2$$4, phalcon_messages_message_ce); + ZEPHIR_CALL_METHOD(&_3$$4, &message, "getmessage", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4$$4, &message, "getfield", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5$$4, &message, "gettype", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_6$$4, &message, "getcode", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_7$$4, &message, "getmetadata", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_2$$4, "__construct", &_8, 6, &_3$$4, &_4$$4, &_5$$4, &_6$$4, &_7$$4); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_9, 0, &_2$$4); + zephir_check_call_status(); + } + zend_iterator_dtor(_1); + RETURN_MM_BOOL(!(zephir_fast_count_int(&messages))); } -static PHP_METHOD(Phalcon_Logger_AbstractLogger, setLogLevel) +static PHP_METHOD(Phalcon_Mvc_Model, validationHasFailed) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *level_param = NULL, levels, _0; - zend_long level, ZEPHIR_LAST_CALL_STATUS; + zval _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&levels); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(level) + zephir_read_property(&_0, this_ptr, ZEND_STRL("errorMessages"), PH_NOISY_CC | PH_READONLY); + RETURN_BOOL(zephir_fast_count_int(&_0) > 0); +} + +static PHP_METHOD(Phalcon_Mvc_Model, caseInsensitiveColumnMap) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *columnMap, columnMap_sub, *key, key_sub, cmKey, _0, *_1, _2, _3$$3, _4$$3, _5$$5, _6$$5; + + ZVAL_UNDEF(&columnMap_sub); + ZVAL_UNDEF(&key_sub); + ZVAL_UNDEF(&cmKey); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_6$$5); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(columnMap) + Z_PARAM_ZVAL(key) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &level_param); - ZEPHIR_CALL_METHOD(&levels, this_ptr, "getlevels", NULL, 0); - zephir_check_call_status(); + zephir_fetch_params(1, 2, 0, &columnMap, &key); ZEPHIR_INIT_VAR(&_0); - if (1 == zephir_array_isset_long(&levels, level)) { - ZEPHIR_INIT_NVAR(&_0); - ZVAL_LONG(&_0, level); + zephir_array_keys(&_0, columnMap); + zephir_is_iterable(&_0, 0, "phalcon/Mvc/Model.zep", 6004); + if (Z_TYPE_P(&_0) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) + { + ZEPHIR_INIT_NVAR(&cmKey); + ZVAL_COPY(&cmKey, _1); + ZEPHIR_INIT_NVAR(&_3$$3); + zephir_fast_strtolower(&_3$$3, &cmKey); + ZEPHIR_INIT_NVAR(&_4$$3); + zephir_fast_strtolower(&_4$$3, key); + if (ZEPHIR_IS_EQUAL(&_3$$3, &_4$$3)) { + RETURN_CCTOR(&cmKey); + } + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_INIT_NVAR(&_0); - ZVAL_LONG(&_0, 8); + ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&cmKey, &_0, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_5$$5); + zephir_fast_strtolower(&_5$$5, &cmKey); + ZEPHIR_INIT_NVAR(&_6$$5); + zephir_fast_strtolower(&_6$$5, key); + if (ZEPHIR_IS_EQUAL(&_5$$5, &_6$$5)) { + RETURN_CCTOR(&cmKey); + } + ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); + zephir_check_call_status(); + } } - zephir_update_property_zval(this_ptr, ZEND_STRL("logLevel"), &_0); - RETURN_THIS(); + ZEPHIR_INIT_NVAR(&cmKey); + RETVAL_ZVAL(key, 1, 0); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Logger_AbstractLogger, addMessage) +/*** + * Append messages to this model from another Model. + */ +static PHP_METHOD(Phalcon_Mvc_Model, appendMessagesFrom) { + zval _2$$5, _4$$7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval context; - zval message; - zval *level_param = NULL, *message_param = NULL, *context_param = NULL, adapter, collection, item, levelName, levels, method, _0, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, *_7$$3, _8$$3, _9$$5, _10$$7; - zend_long level, ZEPHIR_LAST_CALL_STATUS; + zephir_fcall_cache_entry *_3 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, messages, message, *_0$$3, _1$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&adapter); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&item); - ZVAL_UNDEF(&levelName); - ZVAL_UNDEF(&levels); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_9$$5); - ZVAL_UNDEF(&_10$$7); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&messages); ZVAL_UNDEF(&message); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_LONG(level) - Z_PARAM_STR(message) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_4$$7); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(model) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &level_param, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); - } else { - zephir_get_arrval(&context, context_param); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("logLevel"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_GE_LONG(&_0, level)) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); - if (zephir_fast_count_int(&_1$$3) == 0) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "No adapters specified", "phalcon/Logger/AbstractLogger.zep", 273); - return; - } - ZEPHIR_CALL_METHOD(&levels, this_ptr, "getlevels", NULL, 0); - zephir_check_call_status(); - if (1 == zephir_array_isset_long(&levels, level)) { - zephir_memory_observe(&levelName); - zephir_array_fetch_long(&levelName, &levels, level, PH_NOISY, "phalcon/Logger/AbstractLogger.zep", 277); - } else { - ZEPHIR_OBS_NVAR(&levelName); - zephir_array_fetch_long(&levelName, &levels, 8, PH_NOISY, "phalcon/Logger/AbstractLogger.zep", 277); - } - ZEPHIR_INIT_VAR(&item); - object_init_ex(&item, phalcon_logger_item_ce); - ZEPHIR_INIT_VAR(&_2$$3); - object_init_ex(&_2$$3, php_date_get_immutable_ce()); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("timezone"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_4$$3); - ZVAL_STRING(&_4$$3, "now"); - ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 0, &_4$$3, &_3$$3); - zephir_check_call_status(); - ZVAL_LONG(&_5$$3, level); - ZEPHIR_CALL_METHOD(NULL, &item, "__construct", NULL, 98, &message, &levelName, &_5$$3, &_2$$3, &context); - zephir_check_call_status(); - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("excluded"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&collection, "array_diff_key", NULL, 99, &_5$$3, &_6$$3); - zephir_check_call_status(); - zephir_is_iterable(&collection, 0, "phalcon/Logger/AbstractLogger.zep", 303); - if (Z_TYPE_P(&collection) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&collection), _7$$3) + zephir_fetch_params(1, 1, 0, &model); + ZEPHIR_CALL_METHOD(&messages, model, "getmessages", NULL, 0); + zephir_check_call_status(); + if (0 == ZEPHIR_IS_EMPTY(&messages)) { + zephir_is_iterable(&messages, 0, "phalcon/Mvc/Model.zep", 6028); + if (Z_TYPE_P(&messages) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&messages), _0$$3) { - ZEPHIR_INIT_NVAR(&adapter); - ZVAL_COPY(&adapter, _7$$3); - ZEPHIR_INIT_NVAR(&method); - ZVAL_STRING(&method, "process"); - ZEPHIR_CALL_METHOD(&_9$$5, &adapter, "intransaction", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_9$$5)) { - ZEPHIR_INIT_NVAR(&method); - ZVAL_STRING(&method, "add"); + ZEPHIR_INIT_NVAR(&message); + ZVAL_COPY(&message, _0$$3); + if (Z_TYPE_P(&message) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_2$$5); + zephir_create_array(&_2$$5, 1, 0); + zephir_array_update_string(&_2$$5, SL("model"), model, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &message, "setmetadata", NULL, 0, &_2$$5); + zephir_check_call_status(); } - ZEPHIR_CALL_METHOD_ZVAL(NULL, &adapter, &method, NULL, 0, &item); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_3, 0, &message); zephir_check_call_status(); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &collection, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &messages, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_8$$3, &collection, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_1$$3, &messages, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_8$$3)) { + if (!zend_is_true(&_1$$3)) { break; } - ZEPHIR_CALL_METHOD(&adapter, &collection, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&message, &messages, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&method); - ZVAL_STRING(&method, "process"); - ZEPHIR_CALL_METHOD(&_10$$7, &adapter, "intransaction", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_10$$7)) { - ZEPHIR_INIT_NVAR(&method); - ZVAL_STRING(&method, "add"); + if (Z_TYPE_P(&message) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_4$$7); + zephir_create_array(&_4$$7, 1, 0); + zephir_array_update_string(&_4$$7, SL("model"), model, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &message, "setmetadata", NULL, 0, &_4$$7); + zephir_check_call_status(); } - ZEPHIR_CALL_METHOD_ZVAL(NULL, &adapter, &method, NULL, 0, &item); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_3, 0, &message); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &collection, "next", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &messages, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&adapter); - ZEPHIR_INIT_NVAR(&_4$$3); - array_init(&_4$$3); - zephir_update_property_zval(this_ptr, ZEND_STRL("excluded"), &_4$$3); - } - RETURN_MM_BOOL(1); -} - -static PHP_METHOD(Phalcon_Logger_AbstractLogger, getLevelNumber) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *level, level_sub, levelName, levels, _0$$3, _1$$4; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&level_sub); - ZVAL_UNDEF(&levelName); - ZVAL_UNDEF(&levels); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$4); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(level) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &level); - if (Z_TYPE_P(level) == IS_STRING) { - ZEPHIR_INIT_VAR(&levelName); - zephir_fast_strtoupper(&levelName, level); - ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "getlevels", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&levels, "array_flip", NULL, 100, &_0$$3); - zephir_check_call_status(); - if (zephir_array_isset(&levels, &levelName)) { - zephir_array_fetch(&_1$$4, &levels, &levelName, PH_NOISY | PH_READONLY, "phalcon/Logger/AbstractLogger.zep", 328); - RETURN_CTOR(&_1$$4); - } - } else if (1 == zephir_is_numeric(level)) { - ZEPHIR_CALL_METHOD(&levels, this_ptr, "getlevels", NULL, 0); - zephir_check_call_status(); - if (zephir_array_isset(&levels, level)) { - RETURN_MM_LONG(zephir_get_intval(level)); - } + ZEPHIR_INIT_NVAR(&message); } - RETURN_MM_LONG(8); -} - -static PHP_METHOD(Phalcon_Logger_AbstractLogger, getLevels) -{ - - zephir_create_array(return_value, 9, 0); - add_index_stringl(return_value, 2, SL("ALERT")); - add_index_stringl(return_value, 1, SL("CRITICAL")); - add_index_stringl(return_value, 7, SL("DEBUG")); - add_index_stringl(return_value, 0, SL("EMERGENCY")); - add_index_stringl(return_value, 3, SL("ERROR")); - add_index_stringl(return_value, 6, SL("INFO")); - add_index_stringl(return_value, 5, SL("NOTICE")); - add_index_stringl(return_value, 4, SL("WARNING")); - add_index_stringl(return_value, 8, SL("CUSTOM")); - return; + ZEPHIR_MM_RESTORE(); } -zend_object *zephir_init_properties_Phalcon_Logger_AbstractLogger(zend_class_entry *class_type) +zend_object *zephir_init_properties_Phalcon_Mvc_Model(zend_class_entry *class_type) { - zval _0, _2, _1$$3, _3$$4; + zval _0, _2, _4, _6, _8, _10, _12, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8, _13$$9; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_12); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_9$$7); + ZVAL_UNDEF(&_11$$8); + ZVAL_UNDEF(&_13$$9); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); @@ -30199,17 +33439,47 @@ zend_object *zephir_init_properties_Phalcon_Logger_AbstractLogger(zend_class_ent { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("excluded"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("uniqueTypes"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("excluded"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("uniqueTypes"), &_1$$3); } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("uniqueParams"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_2) == IS_NULL) { ZEPHIR_INIT_VAR(&_3$$4); array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("adapters"), &_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("uniqueParams"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("snapshot"), &_5$$5); + } + zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("oldSnapshot"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_6) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$6); + array_init(&_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("oldSnapshot"), &_7$$6); + } + zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("related"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_8) == IS_NULL) { + ZEPHIR_INIT_VAR(&_9$$7); + array_init(&_9$$7); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("related"), &_9$$7); + } + zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("errorMessages"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_10) == IS_NULL) { + ZEPHIR_INIT_VAR(&_11$$8); + array_init(&_11$$8); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("errorMessages"), &_11$$8); + } + zephir_read_property_ex(&_12, this_ptr, ZEND_STRL("dirtyRelated"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_12) == IS_NULL) { + ZEPHIR_INIT_VAR(&_13$$9); + array_init(&_13$$9); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("dirtyRelated"), &_13$$9); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -30226,114 +33496,52 @@ zend_object *zephir_init_properties_Phalcon_Logger_AbstractLogger(zend_class_ent -ZEPHIR_INIT_CLASS(Phalcon_Logger_AdapterFactory) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_ModelInterface) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger, AdapterFactory, phalcon, logger_adapterfactory, phalcon_factory_abstractfactory_ce, phalcon_logger_adapterfactory_method_entry, 0); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ModelInterface, phalcon, mvc_modelinterface, phalcon_mvc_modelinterface_method_entry); return SUCCESS; } -static PHP_METHOD(Phalcon_Logger_AdapterFactory, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *services_param = NULL; - zval services; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&services); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(services) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &services_param); - if (!services_param) { - ZEPHIR_INIT_VAR(&services); - array_init(&services); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Logger_AdapterFactory, newInstance) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval options, _0; - zval *name_param = NULL, *fileName_param = NULL, *options_param = NULL, definition; - zval name, fileName; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&fileName); - ZVAL_UNDEF(&definition); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(name) - Z_PARAM_STR(fileName) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &name_param, &fileName_param, &options_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - if (UNEXPECTED(Z_TYPE_P(fileName_param) != IS_STRING && Z_TYPE_P(fileName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'fileName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(fileName_param) == IS_STRING)) { - zephir_get_strval(&fileName, fileName_param); - } else { - ZEPHIR_INIT_VAR(&fileName); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 2, 0); - zephir_array_fast_append(&_0, &fileName); - zephir_array_fast_append(&_0, &options); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(return_value, &definition, &_0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Logger_AdapterFactory, getExceptionClass) -{ - - RETURN_STRING("Phalcon\\Logger\\Exception"); -} - -static PHP_METHOD(Phalcon_Logger_AdapterFactory, getServices) -{ - - zephir_create_array(return_value, 3, 0); - add_assoc_stringl_ex(return_value, SL("noop"), SL("Phalcon\\Logger\\Adapter\\Noop")); - add_assoc_stringl_ex(return_value, SL("stream"), SL("Phalcon\\Logger\\Adapter\\Stream")); - add_assoc_stringl_ex(return_value, SL("syslog"), SL("Phalcon\\Logger\\Adapter\\Syslog")); - return; -} - +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, appendMessage); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, assign); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, average); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, cloneResult); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, cloneResultMap); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, cloneResultMapHydrate); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, count); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, create); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, delete); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, find); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, findFirst); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, fireEvent); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, fireEventCancel); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getDirtyState); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getMessages); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getModelsMetaData); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getOperationMade); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getReadConnection); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getReadConnectionService); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getRelated); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getSchema); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getSource); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getWriteConnection); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getWriteConnectionService); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, maximum); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, minimum); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, query); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, refresh); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, save); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setConnectionService); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setDirtyState); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setReadConnectionService); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setSnapshotData); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setTransaction); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setWriteConnectionService); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, skipOperation); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, sum); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, validationHasFailed); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, update); @@ -30344,31 +33552,15 @@ static PHP_METHOD(Phalcon_Logger_AdapterFactory, getServices) -ZEPHIR_INIT_CLASS(Phalcon_Logger_Enum) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_ModuleDefinitionInterface) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Logger, Enum, phalcon, logger_enum, NULL, 0); - - zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("ALERT"), 2); - - zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("CRITICAL"), 1); - - zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("CUSTOM"), 8); - - zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("DEBUG"), 7); - - zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("EMERGENCY"), 0); - - zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("ERROR"), 3); - - zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("INFO"), 6); - - zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("NOTICE"), 5); - - zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("WARNING"), 4); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ModuleDefinitionInterface, phalcon, mvc_moduledefinitioninterface, phalcon_mvc_moduledefinitioninterface_method_entry); return SUCCESS; } +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModuleDefinitionInterface, registerAutoloaders); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModuleDefinitionInterface, registerServices); @@ -30379,1571 +33571,2165 @@ ZEPHIR_INIT_CLASS(Phalcon_Logger_Enum) -ZEPHIR_INIT_CLASS(Phalcon_Logger_Exception) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger, Exception, phalcon, logger_exception, zend_ce_exception, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Router, phalcon, mvc_router, phalcon_di_abstractinjectionaware_ce, phalcon_mvc_router_method_entry, 0); -ZEPHIR_INIT_CLASS(Phalcon_Logger_Item) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Logger, Item, phalcon, logger_item, phalcon_logger_item_method_entry, 0); + zend_declare_property_string(phalcon_mvc_router_ce, SL("action"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_mvc_router_ce, SL("controller"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_mvc_router_ce, SL("defaultAction"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_mvc_router_ce, SL("defaultController"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_mvc_router_ce, SL("defaultModule"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_mvc_router_ce, SL("defaultNamespace"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_router_ce, SL("defaultParams"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_router_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_router_ce, SL("keyRouteNames"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_router_ce, SL("keyRouteIds"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_router_ce, SL("matchedRoute"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_router_ce, SL("matches"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_mvc_router_ce, SL("module"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_mvc_router_ce, SL("namespaceName"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_router_ce, SL("notFoundPaths"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_router_ce, SL("params"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_mvc_router_ce, SL("removeExtraSlashes"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_router_ce, SL("routes"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_mvc_router_ce, SL("wasMatched"), 0, ZEND_ACC_PROTECTED); + phalcon_mvc_router_ce->create_object = zephir_init_properties_Phalcon_Mvc_Router; + zephir_declare_class_constant_long(phalcon_mvc_router_ce, SL("POSITION_FIRST"), 0); - zend_declare_property_null(phalcon_logger_item_ce, SL("context"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_logger_item_ce, SL("dateTime"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_logger_item_ce, SL("message"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_logger_item_ce, SL("level"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_logger_item_ce, SL("levelName"), ZEND_ACC_PROTECTED); - phalcon_logger_item_ce->create_object = zephir_init_properties_Phalcon_Logger_Item; + zephir_declare_class_constant_long(phalcon_mvc_router_ce, SL("POSITION_LAST"), 1); + zend_class_implements(phalcon_mvc_router_ce, 1, phalcon_mvc_routerinterface_ce); + zend_class_implements(phalcon_mvc_router_ce, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Logger_Item, __construct) +static PHP_METHOD(Phalcon_Mvc_Router, __construct) { + zval routes, _1$$3, _3$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval context; - zend_long level; - zval *message_param = NULL, *levelName_param = NULL, *level_param = NULL, *dateTime, dateTime_sub, *context_param = NULL, _0; - zval message, levelName; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *defaultRoutes_param = NULL, _0$$3, _2$$3, _4$$3; + zend_bool defaultRoutes; zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&levelName); - ZVAL_UNDEF(&dateTime_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(4, 5) - Z_PARAM_STR(message) - Z_PARAM_STR(levelName) - Z_PARAM_LONG(level) - Z_PARAM_OBJECT_OF_CLASS(dateTime, php_date_get_immutable_ce()) + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&routes); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$3); + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) + Z_PARAM_BOOL(defaultRoutes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 1, &message_param, &levelName_param, &level_param, &dateTime, &context_param); - zephir_get_strval(&message, message_param); - zephir_get_strval(&levelName, levelName_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); + zephir_fetch_params(1, 0, 1, &defaultRoutes_param); + if (!defaultRoutes_param) { + defaultRoutes = 1; } else { - zephir_get_arrval(&context, context_param); + if (UNEXPECTED(Z_TYPE_P(defaultRoutes_param) != IS_TRUE && Z_TYPE_P(defaultRoutes_param) != IS_FALSE)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'defaultRoutes' must be of the type bool")); + RETURN_MM_NULL(); } - zephir_update_property_zval(this_ptr, ZEND_STRL("message"), &message); - zephir_update_property_zval(this_ptr, ZEND_STRL("levelName"), &levelName); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, level); - zephir_update_property_zval(this_ptr, ZEND_STRL("level"), &_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("dateTime"), dateTime); - zephir_update_property_zval(this_ptr, ZEND_STRL("context"), &context); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Logger_Item, getContext) -{ - - RETURN_MEMBER(getThis(), "context"); -} - -static PHP_METHOD(Phalcon_Logger_Item, getDateTime) -{ - - RETURN_MEMBER(getThis(), "dateTime"); -} - -static PHP_METHOD(Phalcon_Logger_Item, getMessage) -{ - - RETURN_MEMBER(getThis(), "message"); -} - -static PHP_METHOD(Phalcon_Logger_Item, getLevel) -{ - - RETURN_MEMBER(getThis(), "level"); -} - -static PHP_METHOD(Phalcon_Logger_Item, getLevelName) -{ - - RETURN_MEMBER(getThis(), "levelName"); -} - -zend_object *zephir_init_properties_Phalcon_Logger_Item(zend_class_entry *class_type) -{ - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("context"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("context"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + defaultRoutes = (Z_TYPE_P(defaultRoutes_param) == IS_TRUE); } + ZEPHIR_INIT_VAR(&routes); + array_init(&routes); + if (defaultRoutes) { + ZEPHIR_INIT_VAR(&_0$$3); + object_init_ex(&_0$$3, phalcon_mvc_router_route_ce); + ZEPHIR_INIT_VAR(&_1$$3); + zephir_create_array(&_1$$3, 1, 0); + add_assoc_long_ex(&_1$$3, SL("controller"), 1); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "#^/([\\w0-9\\_\\-]+)[/]{0,1}$#u"); + ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 101, &_2$$3, &_1$$3); + zephir_check_call_status(); + zephir_array_append(&routes, &_0$$3, PH_SEPARATE, "phalcon/Mvc/Router.zep", 170); + ZEPHIR_INIT_NVAR(&_2$$3); + object_init_ex(&_2$$3, phalcon_mvc_router_route_ce); + ZEPHIR_INIT_VAR(&_3$$3); + zephir_create_array(&_3$$3, 3, 0); + add_assoc_long_ex(&_3$$3, SL("controller"), 1); + add_assoc_long_ex(&_3$$3, SL("action"), 2); + add_assoc_long_ex(&_3$$3, SL("params"), 3); + ZEPHIR_INIT_VAR(&_4$$3); + ZVAL_STRING(&_4$$3, "#^/([\\w0-9\\_\\-]+)/([\\w0-9\\.\\_]+)(/.*)*$#u"); + ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 101, &_4$$3, &_3$$3); + zephir_check_call_status(); + zephir_array_append(&routes, &_2$$3, PH_SEPARATE, "phalcon/Mvc/Router.zep", 179); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("routes"), &routes); + ZEPHIR_MM_RESTORE(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Logger_Logger) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger, Logger, phalcon, logger_logger, phalcon_logger_abstractlogger_ce, phalcon_logger_logger_method_entry, 0); - - zend_class_implements(phalcon_logger_logger_ce, 1, phalcon_logger_loggerinterface_ce); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Logger_Logger, alert) +static PHP_METHOD(Phalcon_Mvc_Router, add) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval context; - zval *message_param = NULL, *context_param = NULL, _0; - zval message; + zend_long position, ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, *httpMethods = NULL, httpMethods_sub, *position_param = NULL, __$null, route, _0; + zval pattern; zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_UNDEF(&httpMethods_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&route); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_STR(pattern) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) + Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_ZVAL_OR_NULL(httpMethods) + Z_PARAM_LONG(position) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); + zephir_fetch_params(1, 1, 3, &pattern_param, &paths, &httpMethods, &position_param); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - zephir_get_arrval(&context, context_param); + ZEPHIR_INIT_VAR(&pattern); } - ZVAL_LONG(&_0, 2); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + if (!httpMethods) { + httpMethods = &httpMethods_sub; + httpMethods = &__$null; + } + if (!position_param) { + position = 1; + } else { + } + ZEPHIR_INIT_VAR(&route); + object_init_ex(&route, phalcon_mvc_router_route_ce); + ZEPHIR_CALL_METHOD(NULL, &route, "__construct", NULL, 101, &pattern, paths, httpMethods); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + ZVAL_LONG(&_0, position); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "attach", NULL, 0, &route, &_0); + zephir_check_call_status(); + RETURN_CCTOR(&route); } -static PHP_METHOD(Phalcon_Logger_Logger, critical) +static PHP_METHOD(Phalcon_Mvc_Router, addConnect) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval context; - zval *message_param = NULL, *context_param = NULL, _0; - zval message; + zend_long position, ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; + zval pattern; zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) + ZVAL_UNDEF(&_1); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(pattern) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) + Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_LONG(position) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); + zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - zephir_get_arrval(&context, context_param); + ZEPHIR_INIT_VAR(&pattern); } - ZVAL_LONG(&_0, 1); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + if (!position_param) { + position = 1; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "CONNECT"); + ZVAL_LONG(&_1, position); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Logger_Logger, debug) +static PHP_METHOD(Phalcon_Mvc_Router, addDelete) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval context; - zval *message_param = NULL, *context_param = NULL, _0; - zval message; + zend_long position, ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; + zval pattern; zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) + ZVAL_UNDEF(&_1); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(pattern) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) + Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_LONG(position) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); + zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - zephir_get_arrval(&context, context_param); + ZEPHIR_INIT_VAR(&pattern); } - ZVAL_LONG(&_0, 7); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + if (!position_param) { + position = 1; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "DELETE"); + ZVAL_LONG(&_1, position); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Logger_Logger, emergency) +static PHP_METHOD(Phalcon_Mvc_Router, addGet) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval context; - zval *message_param = NULL, *context_param = NULL, _0; - zval message; + zend_long position, ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; + zval pattern; zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) + ZVAL_UNDEF(&_1); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(pattern) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) + Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_LONG(position) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); + zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - zephir_get_arrval(&context, context_param); + ZEPHIR_INIT_VAR(&pattern); } - ZVAL_LONG(&_0, 0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + if (!position_param) { + position = 1; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "GET"); + ZVAL_LONG(&_1, position); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Logger_Logger, error) +static PHP_METHOD(Phalcon_Mvc_Router, addHead) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval context; - zval *message_param = NULL, *context_param = NULL, _0; - zval message; + zend_long position, ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; + zval pattern; zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) + ZVAL_UNDEF(&_1); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(pattern) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) + Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_LONG(position) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); + zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - zephir_get_arrval(&context, context_param); + ZEPHIR_INIT_VAR(&pattern); } - ZVAL_LONG(&_0, 3); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + if (!position_param) { + position = 1; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "HEAD"); + ZVAL_LONG(&_1, position); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Logger_Logger, info) +static PHP_METHOD(Phalcon_Mvc_Router, addOptions) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval context; - zval *message_param = NULL, *context_param = NULL, _0; - zval message; + zend_long position, ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; + zval pattern; zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) + ZVAL_UNDEF(&_1); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(pattern) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) + Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_LONG(position) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); + zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - zephir_get_arrval(&context, context_param); + ZEPHIR_INIT_VAR(&pattern); } - ZVAL_LONG(&_0, 6); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + if (!position_param) { + position = 1; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "OPTIONS"); + ZVAL_LONG(&_1, position); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Logger_Logger, log) +static PHP_METHOD(Phalcon_Mvc_Router, addPatch) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval context; - zval message, _0; - zval *level, level_sub, *message_param = NULL, *context_param = NULL, intLevel; + zend_long position, ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; + zval pattern; zval *this_ptr = getThis(); - ZVAL_UNDEF(&level_sub); - ZVAL_UNDEF(&intLevel); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_ZVAL(level) - Z_PARAM_STR(message) + ZVAL_UNDEF(&_1); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(pattern) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) + Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_LONG(position) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &level, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); + zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - zephir_get_arrval(&context, context_param); + ZEPHIR_INIT_VAR(&pattern); } - ZEPHIR_CALL_METHOD(&intLevel, this_ptr, "getlevelnumber", NULL, 0, level); - zephir_check_call_status(); - zephir_cast_to_string(&_0, &message); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &intLevel, &_0, &context); + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + if (!position_param) { + position = 1; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "PATCH"); + ZVAL_LONG(&_1, position); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Logger_Logger, notice) +static PHP_METHOD(Phalcon_Mvc_Router, addPost) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval context; - zval *message_param = NULL, *context_param = NULL, _0; - zval message; + zend_long position, ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; + zval pattern; zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) + ZVAL_UNDEF(&_1); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(pattern) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) + Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_LONG(position) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); + zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - zephir_get_arrval(&context, context_param); + ZEPHIR_INIT_VAR(&pattern); } - ZVAL_LONG(&_0, 5); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + if (!position_param) { + position = 1; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "POST"); + ZVAL_LONG(&_1, position); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Logger_Logger, warning) +static PHP_METHOD(Phalcon_Mvc_Router, addPurge) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval context; - zval *message_param = NULL, *context_param = NULL, _0; - zval message; + zend_long position, ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; + zval pattern; zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) + ZVAL_UNDEF(&_1); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(pattern) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) + Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_LONG(position) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); + zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - zephir_get_arrval(&context, context_param); + ZEPHIR_INIT_VAR(&pattern); } - ZVAL_LONG(&_0, 4); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + if (!position_param) { + position = 1; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "PURGE"); + ZVAL_LONG(&_1, position); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Logger_LoggerFactory) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger, LoggerFactory, phalcon, logger_loggerfactory, phalcon_factory_abstractconfigfactory_ce, phalcon_logger_loggerfactory_method_entry, 0); - - zend_declare_property_null(phalcon_logger_loggerfactory_ce, SL("adapterFactory"), ZEND_ACC_PRIVATE); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Logger_LoggerFactory, __construct) -{ - zval *factory, factory_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&factory_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_logger_adapterfactory_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &factory); - zephir_update_property_zval(this_ptr, ZEND_STRL("adapterFactory"), factory); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Logger_LoggerFactory, load) +static PHP_METHOD(Phalcon_Mvc_Router, addPut) { - zend_string *_7; - zend_ulong _6; - zval data; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *config = NULL, config_sub, adapter, adapterClass, adapterFileName, adapterName, adapterOptions, adapters, name, timezone, options, _0, _1, _2, _3, *_4, _5, _8$$3, _9$$3, _10$$3, _11$$3, _12$$4, _13$$4, _14$$4, _15$$4; + zend_long position, ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; + zval pattern; zval *this_ptr = getThis(); - ZVAL_UNDEF(&config_sub); - ZVAL_UNDEF(&adapter); - ZVAL_UNDEF(&adapterClass); - ZVAL_UNDEF(&adapterFileName); - ZVAL_UNDEF(&adapterName); - ZVAL_UNDEF(&adapterOptions); - ZVAL_UNDEF(&adapters); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&timezone); - ZVAL_UNDEF(&options); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_9$$3); - ZVAL_UNDEF(&_10$$3); - ZVAL_UNDEF(&_11$$3); - ZVAL_UNDEF(&_12$$4); - ZVAL_UNDEF(&_13$$4); - ZVAL_UNDEF(&_14$$4); - ZVAL_UNDEF(&_15$$4); - ZVAL_UNDEF(&data); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(config) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(pattern) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_LONG(position) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &config); - ZEPHIR_SEPARATE_PARAM(config); - ZEPHIR_INIT_VAR(&data); - array_init(&data); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfig", NULL, 0, config); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(config, &_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "name"); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfigelement", NULL, 0, config, &_1); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(config, &_0); - zephir_memory_observe(&name); - zephir_array_fetch_string(&name, config, SL("name"), PH_NOISY, "phalcon/Logger/LoggerFactory.zep", 62); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "timezone"); - ZEPHIR_CALL_METHOD(&timezone, this_ptr, "getarrval", NULL, 0, config, &_1); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_1); - array_init(&_1); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "options"); - ZEPHIR_CALL_METHOD(&options, this_ptr, "getarrval", NULL, 0, config, &_2, &_1); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_2); - array_init(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "adapters"); - ZEPHIR_CALL_METHOD(&adapters, this_ptr, "getarrval", NULL, 0, &options, &_3, &_2); - zephir_check_call_status(); - zephir_is_iterable(&adapters, 0, "phalcon/Logger/LoggerFactory.zep", 81); - if (Z_TYPE_P(&adapters) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&adapters), _6, _7, _4) - { - ZEPHIR_INIT_NVAR(&adapterName); - if (_7 != NULL) { - ZVAL_STR_COPY(&adapterName, _7); - } else { - ZVAL_LONG(&adapterName, _6); - } - ZEPHIR_INIT_NVAR(&adapter); - ZVAL_COPY(&adapter, _4); - ZEPHIR_INIT_NVAR(&_8$$3); - ZVAL_STRING(&_8$$3, "adapter"); - ZEPHIR_CALL_METHOD(&adapterClass, this_ptr, "getarrval", NULL, 0, &adapter, &_8$$3); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_8$$3); - ZVAL_STRING(&_8$$3, "name"); - ZEPHIR_CALL_METHOD(&adapterFileName, this_ptr, "getarrval", NULL, 0, &adapter, &_8$$3); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_8$$3); - array_init(&_8$$3); - ZEPHIR_INIT_NVAR(&_9$$3); - ZVAL_STRING(&_9$$3, "options"); - ZEPHIR_CALL_METHOD(&adapterOptions, this_ptr, "getarrval", NULL, 0, &adapter, &_9$$3, &_8$$3); - zephir_check_call_status(); - zephir_read_property(&_10$$3, this_ptr, ZEND_STRL("adapterFactory"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_11$$3, &_10$$3, "newinstance", NULL, 0, &adapterClass, &adapterFileName, &adapterOptions); - zephir_check_call_status(); - zephir_array_update_zval(&data, &adapterName, &_11$$3, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - ZEPHIR_CALL_METHOD(NULL, &adapters, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5, &adapters, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5)) { - break; - } - ZEPHIR_CALL_METHOD(&adapterName, &adapters, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&adapter, &adapters, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_12$$4); - ZVAL_STRING(&_12$$4, "adapter"); - ZEPHIR_CALL_METHOD(&adapterClass, this_ptr, "getarrval", NULL, 0, &adapter, &_12$$4); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_12$$4); - ZVAL_STRING(&_12$$4, "name"); - ZEPHIR_CALL_METHOD(&adapterFileName, this_ptr, "getarrval", NULL, 0, &adapter, &_12$$4); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_12$$4); - array_init(&_12$$4); - ZEPHIR_INIT_NVAR(&_13$$4); - ZVAL_STRING(&_13$$4, "options"); - ZEPHIR_CALL_METHOD(&adapterOptions, this_ptr, "getarrval", NULL, 0, &adapter, &_13$$4, &_12$$4); - zephir_check_call_status(); - zephir_read_property(&_14$$4, this_ptr, ZEND_STRL("adapterFactory"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_15$$4, &_14$$4, "newinstance", NULL, 0, &adapterClass, &adapterFileName, &adapterOptions); - zephir_check_call_status(); - zephir_array_update_zval(&data, &adapterName, &_15$$4, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &adapters, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&pattern); } - ZEPHIR_INIT_NVAR(&adapter); - ZEPHIR_INIT_NVAR(&adapterName); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "newinstance", NULL, 0, &name, &data, &timezone); + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + if (!position_param) { + position = 1; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "PUT"); + ZVAL_LONG(&_1, position); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Logger_LoggerFactory, newInstance) +static PHP_METHOD(Phalcon_Mvc_Router, addTrace) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval adapters; - zval *name_param = NULL, *adapters_param = NULL, *timezone = NULL, timezone_sub, __$null; - zval name; + zend_long position, ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; + zval pattern; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&timezone_sub); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&adapters); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(name) + Z_PARAM_STR(pattern) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(adapters) - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(timezone, php_date_get_timezone_ce()) + Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_LONG(position) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &name_param, &adapters_param, &timezone); - zephir_get_strval(&name, name_param); - if (!adapters_param) { - ZEPHIR_INIT_VAR(&adapters); - array_init(&adapters); + zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - zephir_get_arrval(&adapters, adapters_param); + ZEPHIR_INIT_VAR(&pattern); } - if (!timezone) { - timezone = &timezone_sub; - timezone = &__$null; + if (!paths) { + paths = &paths_sub; + paths = &__$null; } - object_init_ex(return_value, phalcon_logger_logger_ce); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 414, &name, &adapters, timezone); + if (!position_param) { + position = 1; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "TRACE"); + ZVAL_LONG(&_1, position); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Logger_LoggerFactory, getArrVal) +static PHP_METHOD(Phalcon_Mvc_Router, attach) { + zval _1$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *collection_param = NULL, *index, index_sub, *defaultValue = NULL, defaultValue_sub, __$null, value; - zval collection; + zend_long position; + zval *route, route_sub, *position_param = NULL, _0$$4, _2$$4; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&index_sub); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&value); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_ARRAY(collection) - Z_PARAM_ZVAL(index) + ZVAL_UNDEF(&route_sub); + ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_1$$4); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(route, phalcon_mvc_router_routeinterface_ce) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) + Z_PARAM_LONG(position) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &collection_param, &index, &defaultValue); - ZEPHIR_OBS_COPY_OR_DUP(&collection, collection_param); - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; - } - zephir_memory_observe(&value); - if (UNEXPECTED(!(zephir_array_isset_fetch(&value, &collection, index, 0)))) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); - } - RETURN_CCTOR(&value); -} - -static PHP_METHOD(Phalcon_Logger_LoggerFactory, getExceptionClass) -{ - - RETURN_STRING("Phalcon\\Logger\\Exception"); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Logger_LoggerInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Logger, LoggerInterface, phalcon, logger_loggerinterface, phalcon_logger_loggerinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, alert); -ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, critical); -ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, debug); -ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, emergency); -ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, error); -ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, getAdapter); -ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, getAdapters); -ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, getLogLevel); -ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, getName); -ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, info); -ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, log); -ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, notice); -ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, warning); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_AbstractAdapter) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Logger\\Adapter, AbstractAdapter, phalcon, logger_adapter_abstractadapter, phalcon_logger_adapter_abstractadapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_string(phalcon_logger_adapter_abstractadapter_ce, SL("defaultFormatter"), "Phalcon\\Logger\\Formatter\\Line", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_logger_adapter_abstractadapter_ce, SL("formatter"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_logger_adapter_abstractadapter_ce, SL("inTransaction"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_logger_adapter_abstractadapter_ce, SL("queue"), ZEND_ACC_PROTECTED); - phalcon_logger_adapter_abstractadapter_ce->create_object = zephir_init_properties_Phalcon_Logger_Adapter_AbstractAdapter; + zephir_fetch_params(1, 1, 1, &route, &position_param); + if (!position_param) { + position = 1; + } else { + } + do { + if (position == 1) { + zephir_update_property_array_append(this_ptr, SL("routes"), route); + break; + } + if (position == 0) { + ZEPHIR_INIT_VAR(&_0$$4); + ZEPHIR_INIT_VAR(&_1$$4); + zephir_create_array(&_1$$4, 1, 0); + zephir_array_fast_append(&_1$$4, route); + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); + zephir_fast_array_merge(&_0$$4, &_1$$4, &_2$$4); + zephir_update_property_zval(this_ptr, ZEND_STRL("routes"), &_0$$4); + break; + } + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "Invalid route position", "phalcon/Mvc/Router.zep", 494); + return; + } while(0); - zend_class_implements(phalcon_logger_adapter_abstractadapter_ce, 1, phalcon_logger_adapter_adapterinterface_ce); - return SUCCESS; + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, __destruct) +static PHP_METHOD(Phalcon_Mvc_Router, clear) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("inTransaction"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_0)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "There is an active transaction", "phalcon/Logger/Adapter/AbstractAdapter.zep", 64); - return; - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "close", NULL, 0); - zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("routes"), &_0); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, __serialize) -{ - - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_logger_exception_ce, "This object cannot be serialized", "phalcon/Logger/Adapter/AbstractAdapter.zep", 75); - return; -} - -static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, __unserialize) +static PHP_METHOD(Phalcon_Mvc_Router, getEventsManager) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *data_param = NULL; - zval data; - ZVAL_UNDEF(&data); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(data) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &data_param); - zephir_get_arrval(&data, data_param); - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "This object cannot be unserialized", "phalcon/Logger/Adapter/AbstractAdapter.zep", 83); - return; + RETURN_MEMBER(getThis(), "eventsManager"); } -static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, add) +static PHP_METHOD(Phalcon_Mvc_Router, getActionName) { - zval *item, item_sub; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&item_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &item); - zephir_update_property_array_append(this_ptr, SL("queue"), item); - RETURN_THISW(); + RETURN_MEMBER(getThis(), "action"); } -static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, begin) +static PHP_METHOD(Phalcon_Mvc_Router, getControllerName) { - zval __$true, __$false; - zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("inTransaction"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("inTransaction"), &__$false); - } - RETURN_THISW(); + RETURN_MEMBER(getThis(), "controller"); } -static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, commit) +static PHP_METHOD(Phalcon_Mvc_Router, getDefaults) { - zval item, queue, _0, *_1, _2; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&item); - ZVAL_UNDEF(&queue); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "checktransaction", NULL, 68); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("queue"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&queue, &_0); - zephir_is_iterable(&queue, 0, "phalcon/Logger/Adapter/AbstractAdapter.zep", 132); - if (Z_TYPE_P(&queue) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&queue), _1) - { - ZEPHIR_INIT_NVAR(&item); - ZVAL_COPY(&item, _1); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "process", &_3, 0, &item); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &queue, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &queue, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&item, &queue, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "process", &_3, 0, &item); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &queue, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&item); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "resettransaction", NULL, 69); - zephir_check_call_status(); - RETURN_THIS(); + zephir_create_array(return_value, 5, 0); + zephir_memory_observe(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultNamespace"), PH_NOISY_CC); + zephir_array_update_string(return_value, SL("namespace"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultModule"), PH_NOISY_CC); + zephir_array_update_string(return_value, SL("module"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultController"), PH_NOISY_CC); + zephir_array_update_string(return_value, SL("controller"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultAction"), PH_NOISY_CC); + zephir_array_update_string(return_value, SL("action"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultParams"), PH_NOISY_CC); + zephir_array_update_string(return_value, SL("params"), &_0, PH_COPY | PH_SEPARATE); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, getFormatter) +static PHP_METHOD(Phalcon_Mvc_Router, getKeyRouteNames) { - zval _0, _1$$3, _2$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("formatter"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("defaultFormatter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&_1$$3, &_2$$3); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("formatter"), &_1$$3); - } - RETURN_MM_MEMBER(getThis(), "formatter"); + RETURN_MEMBER(getThis(), "keyRouteNames"); } -static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, inTransaction) +static PHP_METHOD(Phalcon_Mvc_Router, getKeyRouteIds) { - RETURN_MEMBER(getThis(), "inTransaction"); + RETURN_MEMBER(getThis(), "keyRouteIds"); } -static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, process) +static PHP_METHOD(Phalcon_Mvc_Router, getMatchedRoute) { + + RETURN_MEMBER(getThis(), "matchedRoute"); } -static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, rollback) +static PHP_METHOD(Phalcon_Mvc_Router, getMatches) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "checktransaction", NULL, 68); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "resettransaction", NULL, 69); - zephir_check_call_status(); - RETURN_THIS(); + RETURN_MEMBER(getThis(), "matches"); } -static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, setFormatter) +static PHP_METHOD(Phalcon_Mvc_Router, getModuleName) { - zval *formatter, formatter_sub; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&formatter_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(formatter, phalcon_logger_formatter_formatterinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &formatter); - zephir_update_property_zval(this_ptr, ZEND_STRL("formatter"), formatter); - RETURN_THISW(); + RETURN_MEMBER(getThis(), "module"); } -static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, getFormattedItem) +static PHP_METHOD(Phalcon_Mvc_Router, getNamespaceName) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *item, item_sub, formatter; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&item_sub); - ZVAL_UNDEF(&formatter); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &item); - ZEPHIR_CALL_METHOD(&formatter, this_ptr, "getformatter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&formatter, "format", NULL, 0, item); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MEMBER(getThis(), "namespaceName"); } -static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, checkTransaction) +static PHP_METHOD(Phalcon_Mvc_Router, getParams) { - zval _0; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("inTransaction"), PH_NOISY_CC | PH_READONLY); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_logger_exception_ce, "There is no active transaction", "phalcon/Logger/Adapter/AbstractAdapter.zep", 213); - return; - } + RETURN_MEMBER(getThis(), "params"); } -static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, resetTransaction) +static PHP_METHOD(Phalcon_Mvc_Router, getRouteById) { + zend_string *_7; + zend_ulong _6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$true, __$false, _0; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *id, id_sub, route, routeId, key, _0, _3, *_4, _5, _1$$3, _2$$3; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&id_sub); + ZVAL_UNDEF(&route); + ZVAL_UNDEF(&routeId); + ZVAL_UNDEF(&key); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(id) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("queue"), &_0); - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("inTransaction"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("inTransaction"), &__$false); + zephir_fetch_params(1, 1, 0, &id); + zephir_memory_observe(&key); + zephir_read_property(&_0, this_ptr, ZEND_STRL("keyRouteIds"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&key, &_0, id, 0)) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_2$$3, &_1$$3, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Router.zep", 614); + RETURN_CTOR(&_2$$3); } - ZEPHIR_MM_RESTORE(); -} - -zend_object *zephir_init_properties_Phalcon_Logger_Adapter_AbstractAdapter(zend_class_entry *class_type) -{ - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("queue"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("queue"), &_1$$3); + zephir_read_property(&_3, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_3, 0, "phalcon/Mvc/Router.zep", 626); + if (Z_TYPE_P(&_3) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_3), _6, _7, _4) + { + ZEPHIR_INIT_NVAR(&key); + if (_7 != NULL) { + ZVAL_STR_COPY(&key, _7); + } else { + ZVAL_LONG(&key, _6); + } + ZEPHIR_INIT_NVAR(&route); + ZVAL_COPY(&route, _4); + ZEPHIR_CALL_METHOD(&routeId, &route, "getrouteid", NULL, 0); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("keyRouteIds"), &routeId, &key); + if (ZEPHIR_IS_EQUAL(&routeId, id)) { + RETURN_CCTOR(&route); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_3, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5, &_3, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &_3, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&route, &_3, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&routeId, &route, "getrouteid", NULL, 0); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("keyRouteIds"), &routeId, &key); + if (ZEPHIR_IS_EQUAL(&routeId, id)) { + RETURN_CCTOR(&route); + } + ZEPHIR_CALL_METHOD(NULL, &_3, "next", NULL, 0); + zephir_check_call_status(); } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); } + ZEPHIR_INIT_NVAR(&route); + ZEPHIR_INIT_NVAR(&key); + RETURN_MM_BOOL(0); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_AdapterInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Logger\\Adapter, AdapterInterface, phalcon, logger_adapter_adapterinterface, phalcon_logger_adapter_adapterinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, add); -ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, begin); -ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, close); -ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, commit); -ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, getFormatter); -ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, inTransaction); -ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, process); -ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, rollback); -ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, setFormatter); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_Noop) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Adapter, Noop, phalcon, logger_adapter_noop, phalcon_logger_adapter_abstractadapter_ce, phalcon_logger_adapter_noop_method_entry, 0); - - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Logger_Adapter_Noop, close) -{ - - RETURN_BOOL(1); -} - -static PHP_METHOD(Phalcon_Logger_Adapter_Noop, process) -{ - zval *item, item_sub; - - ZVAL_UNDEF(&item_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &item); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_Stream) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Adapter, Stream, phalcon, logger_adapter_stream, phalcon_logger_adapter_abstractadapter_ce, phalcon_logger_adapter_stream_method_entry, 0); - - zend_declare_property_string(phalcon_logger_adapter_stream_ce, SL("mode"), "ab", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_logger_adapter_stream_ce, SL("name"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_logger_adapter_stream_ce, SL("options"), ZEND_ACC_PROTECTED); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Logger_Adapter_Stream, __construct) +static PHP_METHOD(Phalcon_Mvc_Router, getRouteByName) { + zend_string *_7; + zend_ulong _6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval *name_param = NULL, *options_param = NULL, mode, _0, _1; + zval *name_param = NULL, route, routeName, key, _0, _3, *_4, _5, _1$$3, _2$$3; zval name; zval *this_ptr = getThis(); ZVAL_UNDEF(&name); - ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&route); + ZVAL_UNDEF(&routeName); + ZVAL_UNDEF(&key); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(1, 2) + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(name) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &name_param, &options_param); - zephir_get_strval(&name, name_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); } - if (1 == zephir_array_isset_string(&options, SL("mode"))) { - zephir_memory_observe(&mode); - zephir_array_fetch_string(&mode, &options, SL("mode"), PH_NOISY, "phalcon/Logger/Adapter/Stream.zep", 74); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - ZEPHIR_INIT_NVAR(&mode); - ZVAL_STRING(&mode, "ab"); + ZEPHIR_INIT_VAR(&name); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "r"); - ZEPHIR_CALL_FUNCTION(&_1, "mb_strpos", NULL, 86, &mode, &_0); - zephir_check_call_status(); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_1)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "Adapter cannot be opened in read mode", "phalcon/Logger/Adapter/Stream.zep", 76); - return; + zephir_memory_observe(&key); + zephir_read_property(&_0, this_ptr, ZEND_STRL("keyRouteNames"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&key, &_0, &name, 0)) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_2$$3, &_1$$3, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Router.zep", 641); + RETURN_CTOR(&_2$$3); } - zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); - zephir_update_property_zval(this_ptr, ZEND_STRL("mode"), &mode); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Logger_Adapter_Stream, close) -{ - - RETURN_BOOL(1); + zephir_read_property(&_3, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_3, 0, "phalcon/Mvc/Router.zep", 656); + if (Z_TYPE_P(&_3) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_3), _6, _7, _4) + { + ZEPHIR_INIT_NVAR(&key); + if (_7 != NULL) { + ZVAL_STR_COPY(&key, _7); + } else { + ZVAL_LONG(&key, _6); + } + ZEPHIR_INIT_NVAR(&route); + ZVAL_COPY(&route, _4); + ZEPHIR_CALL_METHOD(&routeName, &route, "getname", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&routeName))) { + zephir_update_property_array(this_ptr, SL("keyRouteNames"), &routeName, &key); + if (ZEPHIR_IS_EQUAL(&routeName, &name)) { + RETURN_CCTOR(&route); + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_3, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5, &_3, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &_3, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&route, &_3, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&routeName, &route, "getname", NULL, 0); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&routeName))) { + zephir_update_property_array(this_ptr, SL("keyRouteNames"), &routeName, &key); + if (ZEPHIR_IS_EQUAL(&routeName, &name)) { + RETURN_CCTOR(&route); + } + } + ZEPHIR_CALL_METHOD(NULL, &_3, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&route); + ZEPHIR_INIT_NVAR(&key); + RETURN_MM_BOOL(0); } -static PHP_METHOD(Phalcon_Logger_Adapter_Stream, getName) +static PHP_METHOD(Phalcon_Mvc_Router, getRoutes) { - RETURN_MEMBER(getThis(), "name"); + RETURN_MEMBER(getThis(), "routes"); } -static PHP_METHOD(Phalcon_Logger_Adapter_Stream, process) +static PHP_METHOD(Phalcon_Mvc_Router, handle) { + zend_string *_25$$30, *_56$$75; + zend_ulong _24$$30, _55$$75; + zval _19$$25, _31$$36, _33$$39, _38$$47, _40$$50, _50$$70, _61$$81, _63$$84, _68$$92, _70$$95; + zend_bool _2, _29$$31, _36$$42, _59$$76, _66$$87; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_12 = NULL, *_13 = NULL, *_16 = NULL, *_18 = NULL, *_21 = NULL, *_28 = NULL, *_43 = NULL, *_44 = NULL, *_47 = NULL, *_49 = NULL, *_52 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *item, item_sub, handler, message, _0, _1, _6, _7, _8, _2$$3, _3$$3, _4$$3, _5$$3; + zval *uri_param = NULL, __$true, __$false, __$null, request, currentHostName, routeFound, parts, params, matches, notFoundPaths, vnamespace, module, controller, action, paramsStr, strParams, route, methods, container, hostname, regexHostName, matched, pattern, handledUri, beforeMatch, paths, converters, part, position, matchPosition, converter, eventsManager, _0, _1, _4, _6, _7, *_8, _9, _72, _73, _74, _75, _76, _3$$3, _5$$6, _10$$9, _11$$9, _14$$14, _15$$20, _17$$24, _20$$28, *_22$$30, _23$$30, _26$$32, _27$$32, _30$$36, _32$$39, _34$$43, _35$$43, _37$$47, _39$$50, _41$$54, _42$$54, _45$$59, _46$$65, _48$$69, _51$$73, *_53$$75, _54$$75, _57$$77, _58$$77, _60$$81, _62$$84, _64$$88, _65$$88, _67$$92, _69$$95, _71$$100, _77$$108, _78$$110, _79$$112; + zval uri; zval *this_ptr = getThis(); - ZVAL_UNDEF(&item_sub); - ZVAL_UNDEF(&handler); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&uri); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&request); + ZVAL_UNDEF(¤tHostName); + ZVAL_UNDEF(&routeFound); + ZVAL_UNDEF(&parts); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&matches); + ZVAL_UNDEF(¬FoundPaths); + ZVAL_UNDEF(&vnamespace); + ZVAL_UNDEF(&module); + ZVAL_UNDEF(&controller); + ZVAL_UNDEF(&action); + ZVAL_UNDEF(¶msStr); + ZVAL_UNDEF(&strParams); + ZVAL_UNDEF(&route); + ZVAL_UNDEF(&methods); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&hostname); + ZVAL_UNDEF(®exHostName); + ZVAL_UNDEF(&matched); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&handledUri); + ZVAL_UNDEF(&beforeMatch); + ZVAL_UNDEF(&paths); + ZVAL_UNDEF(&converters); + ZVAL_UNDEF(&part); + ZVAL_UNDEF(&position); + ZVAL_UNDEF(&matchPosition); + ZVAL_UNDEF(&converter); + ZVAL_UNDEF(&eventsManager); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_6); ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_72); + ZVAL_UNDEF(&_73); + ZVAL_UNDEF(&_74); + ZVAL_UNDEF(&_75); + ZVAL_UNDEF(&_76); ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_10$$9); + ZVAL_UNDEF(&_11$$9); + ZVAL_UNDEF(&_14$$14); + ZVAL_UNDEF(&_15$$20); + ZVAL_UNDEF(&_17$$24); + ZVAL_UNDEF(&_20$$28); + ZVAL_UNDEF(&_23$$30); + ZVAL_UNDEF(&_26$$32); + ZVAL_UNDEF(&_27$$32); + ZVAL_UNDEF(&_30$$36); + ZVAL_UNDEF(&_32$$39); + ZVAL_UNDEF(&_34$$43); + ZVAL_UNDEF(&_35$$43); + ZVAL_UNDEF(&_37$$47); + ZVAL_UNDEF(&_39$$50); + ZVAL_UNDEF(&_41$$54); + ZVAL_UNDEF(&_42$$54); + ZVAL_UNDEF(&_45$$59); + ZVAL_UNDEF(&_46$$65); + ZVAL_UNDEF(&_48$$69); + ZVAL_UNDEF(&_51$$73); + ZVAL_UNDEF(&_54$$75); + ZVAL_UNDEF(&_57$$77); + ZVAL_UNDEF(&_58$$77); + ZVAL_UNDEF(&_60$$81); + ZVAL_UNDEF(&_62$$84); + ZVAL_UNDEF(&_64$$88); + ZVAL_UNDEF(&_65$$88); + ZVAL_UNDEF(&_67$$92); + ZVAL_UNDEF(&_69$$95); + ZVAL_UNDEF(&_71$$100); + ZVAL_UNDEF(&_77$$108); + ZVAL_UNDEF(&_78$$110); + ZVAL_UNDEF(&_79$$112); + ZVAL_UNDEF(&_19$$25); + ZVAL_UNDEF(&_31$$36); + ZVAL_UNDEF(&_33$$39); + ZVAL_UNDEF(&_38$$47); + ZVAL_UNDEF(&_40$$50); + ZVAL_UNDEF(&_50$$70); + ZVAL_UNDEF(&_61$$81); + ZVAL_UNDEF(&_63$$84); + ZVAL_UNDEF(&_68$$92); + ZVAL_UNDEF(&_70$$95); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) + Z_PARAM_STR(uri) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &item); - zephir_read_property(&_0, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_1, this_ptr, ZEND_STRL("mode"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&handler, this_ptr, "phpfopen", NULL, 0, &_0, &_1); - zephir_check_call_status(); - if (!(Z_TYPE_P(&handler) == IS_RESOURCE)) { - ZEPHIR_INIT_VAR(&_2$$3); - object_init_ex(&_2$$3, spl_ce_LogicException); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("mode"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_5$$3); - ZEPHIR_CONCAT_SVSVS(&_5$$3, "The file '", &_3$$3, "' cannot be opened with mode '", &_4$$3, "'"); - ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 409, &_5$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_2$$3, "phalcon/Logger/Adapter/Stream.zep", 119); - ZEPHIR_MM_RESTORE(); - return; + zephir_fetch_params(1, 1, 0, &uri_param); + if (UNEXPECTED(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 of the type string")); + RETURN_MM_NULL(); } - ZVAL_LONG(&_6, 2); - ZEPHIR_CALL_FUNCTION(NULL, "flock", NULL, 132, &handler, &_6); + if (EXPECTED(Z_TYPE_P(uri_param) == IS_STRING)) { + zephir_get_strval(&uri, uri_param); + } else { + ZEPHIR_INIT_VAR(&uri); + } + ZVAL_LONG(&_0, 5); + ZEPHIR_CALL_FUNCTION(&_1, "parse_url", NULL, 102, &uri, &_0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_7, this_ptr, "getformatteditem", NULL, 0, item); + zephir_get_strval(&uri, &_1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("removeExtraSlashes"), PH_NOISY_CC | PH_READONLY); + _2 = zephir_is_true(&_0); + if (_2) { + _2 = !ZEPHIR_IS_STRING_IDENTICAL(&uri, "/"); + } + if (_2) { + ZEPHIR_INIT_VAR(&_3$$3); + ZVAL_STRING(&_3$$3, "/"); + ZEPHIR_INIT_VAR(&handledUri); + zephir_fast_trim(&handledUri, &uri, &_3$$3, ZEPHIR_TRIM_RIGHT); + } else { + ZEPHIR_CPY_WRT(&handledUri, &uri); + } + if (ZEPHIR_IS_EMPTY(&handledUri)) { + ZEPHIR_INIT_NVAR(&handledUri); + ZVAL_STRING(&handledUri, "/"); + } + ZEPHIR_INIT_VAR(¤tHostName); + ZVAL_NULL(¤tHostName); + ZEPHIR_INIT_VAR(&routeFound); + ZVAL_BOOL(&routeFound, 0); + ZEPHIR_INIT_VAR(&parts); + array_init(&parts); + ZEPHIR_INIT_VAR(¶ms); + array_init(¶ms); + ZEPHIR_INIT_VAR(&matches); + ZVAL_NULL(&matches); + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$false); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("matchedRoute"), &__$null); + zephir_read_property(&_4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_4); + if (Z_TYPE_P(&eventsManager) != IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$6); + ZVAL_STRING(&_5$$6, "router:beforeCheckRoutes"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_5$$6, this_ptr); + zephir_check_call_status(); + } + zephir_read_property(&_4, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_4); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'request' service", "phalcon/Mvc/Router.zep", 724); + return; + } + ZEPHIR_INIT_VAR(&_7); + ZVAL_STRING(&_7, "request"); + ZEPHIR_CALL_METHOD(&_6, &container, "get", NULL, 0, &_7); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_8); - ZEPHIR_GET_CONSTANT(&_8, "PHP_EOL"); - ZEPHIR_INIT_VAR(&message); - ZEPHIR_CONCAT_VV(&message, &_7, &_8); - zephir_fwrite(NULL, &handler, &message); - zephir_fclose(&handler); + ZEPHIR_CPY_WRT(&request, &_6); + zephir_read_property(&_4, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_4, 0, "phalcon/Mvc/Router.zep", 930); + if (Z_TYPE_P(&_4) == IS_ARRAY) { + ZEND_HASH_REVERSE_FOREACH_VAL(Z_ARRVAL_P(&_4), _8) + { + ZEPHIR_INIT_NVAR(&route); + ZVAL_COPY(&route, _8); + ZEPHIR_INIT_NVAR(¶ms); + array_init(¶ms); + ZEPHIR_INIT_NVAR(&matches); + ZVAL_NULL(&matches); + ZEPHIR_CALL_METHOD(&methods, &route, "gethttpmethods", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&methods) != IS_NULL) { + ZVAL_BOOL(&_11$$9, 1); + ZEPHIR_CALL_METHOD(&_10$$9, &request, "ismethod", &_12, 0, &methods, &_11$$9); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_10$$9)) { + continue; + } + } + ZEPHIR_CALL_METHOD(&hostname, &route, "gethostname", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&hostname) != IS_NULL) { + if (Z_TYPE_P(¤tHostName) == IS_NULL) { + ZEPHIR_CALL_METHOD(¤tHostName, &request, "gethttphost", &_13, 0); + zephir_check_call_status(); + } + if (!(zephir_is_true(¤tHostName))) { + continue; + } + if (zephir_memnstr_str(&hostname, SL("("), "phalcon/Mvc/Router.zep", 772)) { + if (!(zephir_memnstr_str(&hostname, SL("#"), "phalcon/Mvc/Router.zep", 773))) { + ZEPHIR_INIT_NVAR(®exHostName); + ZEPHIR_CONCAT_SV(®exHostName, "#^", &hostname); + if (!(zephir_memnstr_str(&hostname, SL(":"), "phalcon/Mvc/Router.zep", 776))) { + zephir_concat_self_str(®exHostName, SL("(:[[:digit:]]+)?")); + } + zephir_concat_self_str(®exHostName, SL("$#i")); + } else { + ZEPHIR_CPY_WRT(®exHostName, &hostname); + } + ZEPHIR_INIT_NVAR(&_14$$14); + ZEPHIR_INIT_NVAR(&matched); + zephir_preg_match(&matched, ®exHostName, ¤tHostName, &_14$$14, 0, 0 , 0 ); + } else { + ZEPHIR_INIT_NVAR(&matched); + ZVAL_BOOL(&matched, ZEPHIR_IS_EQUAL(¤tHostName, &hostname)); + } + if (!(zephir_is_true(&matched))) { + continue; + } + } + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_15$$20); + ZVAL_STRING(&_15$$20, "router:beforeCheckRoute"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_16, 0, &_15$$20, this_ptr, &route); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(&pattern, &route, "getcompiledpattern", NULL, 0); + zephir_check_call_status(); + if (zephir_memnstr_str(&pattern, SL("^"), "phalcon/Mvc/Router.zep", 804)) { + ZEPHIR_INIT_NVAR(&routeFound); + zephir_preg_match(&routeFound, &pattern, &handledUri, &matches, 0, 0 , 0 ); + } else { + ZEPHIR_INIT_NVAR(&routeFound); + ZVAL_BOOL(&routeFound, ZEPHIR_IS_EQUAL(&pattern, &handledUri)); + } + if (zephir_is_true(&routeFound)) { + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_17$$24); + ZVAL_STRING(&_17$$24, "router:matchedRoute"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_18, 0, &_17$$24, this_ptr, &route); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(&beforeMatch, &route, "getbeforematch", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&beforeMatch) != IS_NULL) { + if (UNEXPECTED(!(zephir_is_callable(&beforeMatch)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "Before-Match callback is not callable in matched route", "phalcon/Mvc/Router.zep", 826); + return; + } + ZEPHIR_INIT_NVAR(&_19$$25); + zephir_create_array(&_19$$25, 3, 0); + zephir_array_fast_append(&_19$$25, &handledUri); + zephir_array_fast_append(&_19$$25, &route); + zephir_array_fast_append(&_19$$25, this_ptr); + ZEPHIR_INIT_NVAR(&routeFound); + ZEPHIR_CALL_USER_FUNC_ARRAY(&routeFound, &beforeMatch, &_19$$25); + zephir_check_call_status(); + } + } else { + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_20$$28); + ZVAL_STRING(&_20$$28, "router:notMatchedRoute"); + ZEPHIR_CALL_METHOD(&routeFound, &eventsManager, "fire", &_21, 0, &_20$$28, this_ptr, &route); + zephir_check_call_status(); + } + } + if (zephir_is_true(&routeFound)) { + ZEPHIR_CALL_METHOD(&paths, &route, "getpaths", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&parts, &paths); + if (Z_TYPE_P(&matches) == IS_ARRAY) { + ZEPHIR_CALL_METHOD(&converters, &route, "getconverters", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&paths, 0, "phalcon/Mvc/Router.zep", 918); + if (Z_TYPE_P(&paths) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&paths), _24$$30, _25$$30, _22$$30) + { + ZEPHIR_INIT_NVAR(&part); + if (_25$$30 != NULL) { + ZVAL_STR_COPY(&part, _25$$30); + } else { + ZVAL_LONG(&part, _24$$30); + } + ZEPHIR_INIT_NVAR(&position); + ZVAL_COPY(&position, _22$$30); + if (UNEXPECTED(Z_TYPE_P(&part) != IS_STRING)) { + ZEPHIR_INIT_NVAR(&_26$$32); + object_init_ex(&_26$$32, phalcon_mvc_router_exception_ce); + ZEPHIR_INIT_NVAR(&_27$$32); + ZEPHIR_CONCAT_SV(&_27$$32, "Wrong key in paths: ", &part); + ZEPHIR_CALL_METHOD(NULL, &_26$$32, "__construct", &_28, 33, &_27$$32); + zephir_check_call_status(); + zephir_throw_exception_debug(&_26$$32, "phalcon/Mvc/Router.zep", 866); + ZEPHIR_MM_RESTORE(); + return; + } + _29$$31 = Z_TYPE_P(&position) != IS_STRING; + if (_29$$31) { + _29$$31 = Z_TYPE_P(&position) != IS_LONG; + } + if (_29$$31) { + continue; + } + ZEPHIR_OBS_NVAR(&matchPosition); + if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { + if (Z_TYPE_P(&converters) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&converter); + if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { + ZEPHIR_INIT_NVAR(&_30$$36); + ZEPHIR_INIT_NVAR(&_31$$36); + zephir_create_array(&_31$$36, 1, 0); + zephir_array_fast_append(&_31$$36, &matchPosition); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_30$$36, &converter, &_31$$36); + zephir_check_call_status(); + zephir_array_update_zval(&parts, &part, &_30$$36, PH_COPY | PH_SEPARATE); + continue; + } + } + zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); + } else { + if (Z_TYPE_P(&converters) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&converter); + if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { + ZEPHIR_INIT_NVAR(&_32$$39); + ZEPHIR_INIT_NVAR(&_33$$39); + zephir_create_array(&_33$$39, 1, 0); + zephir_array_fast_append(&_33$$39, &position); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_32$$39, &converter, &_33$$39); + zephir_check_call_status(); + zephir_array_update_zval(&parts, &part, &_32$$39, PH_COPY | PH_SEPARATE); + } + } else { + if (Z_TYPE_P(&position) == IS_LONG) { + zephir_array_unset(&parts, &part, PH_SEPARATE); + } + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &paths, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_23$$30, &paths, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_23$$30)) { + break; + } + ZEPHIR_CALL_METHOD(&part, &paths, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&position, &paths, "current", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&part) != IS_STRING)) { + ZEPHIR_INIT_NVAR(&_34$$43); + object_init_ex(&_34$$43, phalcon_mvc_router_exception_ce); + ZEPHIR_INIT_NVAR(&_35$$43); + ZEPHIR_CONCAT_SV(&_35$$43, "Wrong key in paths: ", &part); + ZEPHIR_CALL_METHOD(NULL, &_34$$43, "__construct", &_28, 33, &_35$$43); + zephir_check_call_status(); + zephir_throw_exception_debug(&_34$$43, "phalcon/Mvc/Router.zep", 866); + ZEPHIR_MM_RESTORE(); + return; + } + _36$$42 = Z_TYPE_P(&position) != IS_STRING; + if (_36$$42) { + _36$$42 = Z_TYPE_P(&position) != IS_LONG; + } + if (_36$$42) { + continue; + } + ZEPHIR_OBS_NVAR(&matchPosition); + if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { + if (Z_TYPE_P(&converters) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&converter); + if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { + ZEPHIR_INIT_NVAR(&_37$$47); + ZEPHIR_INIT_NVAR(&_38$$47); + zephir_create_array(&_38$$47, 1, 0); + zephir_array_fast_append(&_38$$47, &matchPosition); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_37$$47, &converter, &_38$$47); + zephir_check_call_status(); + zephir_array_update_zval(&parts, &part, &_37$$47, PH_COPY | PH_SEPARATE); + continue; + } + } + zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); + } else { + if (Z_TYPE_P(&converters) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&converter); + if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { + ZEPHIR_INIT_NVAR(&_39$$50); + ZEPHIR_INIT_NVAR(&_40$$50); + zephir_create_array(&_40$$50, 1, 0); + zephir_array_fast_append(&_40$$50, &position); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_39$$50, &converter, &_40$$50); + zephir_check_call_status(); + zephir_array_update_zval(&parts, &part, &_39$$50, PH_COPY | PH_SEPARATE); + } + } else { + if (Z_TYPE_P(&position) == IS_LONG) { + zephir_array_unset(&parts, &part, PH_SEPARATE); + } + } + } + ZEPHIR_CALL_METHOD(NULL, &paths, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&position); + ZEPHIR_INIT_NVAR(&part); + zephir_update_property_zval(this_ptr, ZEND_STRL("matches"), &matches); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("matchedRoute"), &route); + break; + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_4, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_9, &_4, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_9)) { + break; + } + ZEPHIR_CALL_METHOD(&route, &_4, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(¶ms); + array_init(¶ms); + ZEPHIR_INIT_NVAR(&matches); + ZVAL_NULL(&matches); + ZEPHIR_CALL_METHOD(&methods, &route, "gethttpmethods", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&methods) != IS_NULL) { + ZVAL_BOOL(&_42$$54, 1); + ZEPHIR_CALL_METHOD(&_41$$54, &request, "ismethod", &_43, 0, &methods, &_42$$54); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_41$$54)) { + continue; + } + } + ZEPHIR_CALL_METHOD(&hostname, &route, "gethostname", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&hostname) != IS_NULL) { + if (Z_TYPE_P(¤tHostName) == IS_NULL) { + ZEPHIR_CALL_METHOD(¤tHostName, &request, "gethttphost", &_44, 0); + zephir_check_call_status(); + } + if (!(zephir_is_true(¤tHostName))) { + continue; + } + if (zephir_memnstr_str(&hostname, SL("("), "phalcon/Mvc/Router.zep", 772)) { + if (!(zephir_memnstr_str(&hostname, SL("#"), "phalcon/Mvc/Router.zep", 773))) { + ZEPHIR_INIT_NVAR(®exHostName); + ZEPHIR_CONCAT_SV(®exHostName, "#^", &hostname); + if (!(zephir_memnstr_str(&hostname, SL(":"), "phalcon/Mvc/Router.zep", 776))) { + zephir_concat_self_str(®exHostName, SL("(:[[:digit:]]+)?")); + } + zephir_concat_self_str(®exHostName, SL("$#i")); + } else { + ZEPHIR_CPY_WRT(®exHostName, &hostname); + } + ZEPHIR_INIT_NVAR(&_45$$59); + ZEPHIR_INIT_NVAR(&matched); + zephir_preg_match(&matched, ®exHostName, ¤tHostName, &_45$$59, 0, 0 , 0 ); + } else { + ZEPHIR_INIT_NVAR(&matched); + ZVAL_BOOL(&matched, ZEPHIR_IS_EQUAL(¤tHostName, &hostname)); + } + if (!(zephir_is_true(&matched))) { + continue; + } + } + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_46$$65); + ZVAL_STRING(&_46$$65, "router:beforeCheckRoute"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_47, 0, &_46$$65, this_ptr, &route); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(&pattern, &route, "getcompiledpattern", NULL, 0); + zephir_check_call_status(); + if (zephir_memnstr_str(&pattern, SL("^"), "phalcon/Mvc/Router.zep", 804)) { + ZEPHIR_INIT_NVAR(&routeFound); + zephir_preg_match(&routeFound, &pattern, &handledUri, &matches, 0, 0 , 0 ); + } else { + ZEPHIR_INIT_NVAR(&routeFound); + ZVAL_BOOL(&routeFound, ZEPHIR_IS_EQUAL(&pattern, &handledUri)); + } + if (zephir_is_true(&routeFound)) { + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_48$$69); + ZVAL_STRING(&_48$$69, "router:matchedRoute"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_49, 0, &_48$$69, this_ptr, &route); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(&beforeMatch, &route, "getbeforematch", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&beforeMatch) != IS_NULL) { + if (UNEXPECTED(!(zephir_is_callable(&beforeMatch)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "Before-Match callback is not callable in matched route", "phalcon/Mvc/Router.zep", 826); + return; + } + ZEPHIR_INIT_NVAR(&_50$$70); + zephir_create_array(&_50$$70, 3, 0); + zephir_array_fast_append(&_50$$70, &handledUri); + zephir_array_fast_append(&_50$$70, &route); + zephir_array_fast_append(&_50$$70, this_ptr); + ZEPHIR_INIT_NVAR(&routeFound); + ZEPHIR_CALL_USER_FUNC_ARRAY(&routeFound, &beforeMatch, &_50$$70); + zephir_check_call_status(); + } + } else { + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_51$$73); + ZVAL_STRING(&_51$$73, "router:notMatchedRoute"); + ZEPHIR_CALL_METHOD(&routeFound, &eventsManager, "fire", &_52, 0, &_51$$73, this_ptr, &route); + zephir_check_call_status(); + } + } + if (zephir_is_true(&routeFound)) { + ZEPHIR_CALL_METHOD(&paths, &route, "getpaths", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&parts, &paths); + if (Z_TYPE_P(&matches) == IS_ARRAY) { + ZEPHIR_CALL_METHOD(&converters, &route, "getconverters", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&paths, 0, "phalcon/Mvc/Router.zep", 918); + if (Z_TYPE_P(&paths) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&paths), _55$$75, _56$$75, _53$$75) + { + ZEPHIR_INIT_NVAR(&part); + if (_56$$75 != NULL) { + ZVAL_STR_COPY(&part, _56$$75); + } else { + ZVAL_LONG(&part, _55$$75); + } + ZEPHIR_INIT_NVAR(&position); + ZVAL_COPY(&position, _53$$75); + if (UNEXPECTED(Z_TYPE_P(&part) != IS_STRING)) { + ZEPHIR_INIT_NVAR(&_57$$77); + object_init_ex(&_57$$77, phalcon_mvc_router_exception_ce); + ZEPHIR_INIT_NVAR(&_58$$77); + ZEPHIR_CONCAT_SV(&_58$$77, "Wrong key in paths: ", &part); + ZEPHIR_CALL_METHOD(NULL, &_57$$77, "__construct", &_28, 33, &_58$$77); + zephir_check_call_status(); + zephir_throw_exception_debug(&_57$$77, "phalcon/Mvc/Router.zep", 866); + ZEPHIR_MM_RESTORE(); + return; + } + _59$$76 = Z_TYPE_P(&position) != IS_STRING; + if (_59$$76) { + _59$$76 = Z_TYPE_P(&position) != IS_LONG; + } + if (_59$$76) { + continue; + } + ZEPHIR_OBS_NVAR(&matchPosition); + if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { + if (Z_TYPE_P(&converters) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&converter); + if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { + ZEPHIR_INIT_NVAR(&_60$$81); + ZEPHIR_INIT_NVAR(&_61$$81); + zephir_create_array(&_61$$81, 1, 0); + zephir_array_fast_append(&_61$$81, &matchPosition); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_60$$81, &converter, &_61$$81); + zephir_check_call_status(); + zephir_array_update_zval(&parts, &part, &_60$$81, PH_COPY | PH_SEPARATE); + continue; + } + } + zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); + } else { + if (Z_TYPE_P(&converters) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&converter); + if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { + ZEPHIR_INIT_NVAR(&_62$$84); + ZEPHIR_INIT_NVAR(&_63$$84); + zephir_create_array(&_63$$84, 1, 0); + zephir_array_fast_append(&_63$$84, &position); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_62$$84, &converter, &_63$$84); + zephir_check_call_status(); + zephir_array_update_zval(&parts, &part, &_62$$84, PH_COPY | PH_SEPARATE); + } + } else { + if (Z_TYPE_P(&position) == IS_LONG) { + zephir_array_unset(&parts, &part, PH_SEPARATE); + } + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &paths, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_54$$75, &paths, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_54$$75)) { + break; + } + ZEPHIR_CALL_METHOD(&part, &paths, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&position, &paths, "current", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&part) != IS_STRING)) { + ZEPHIR_INIT_NVAR(&_64$$88); + object_init_ex(&_64$$88, phalcon_mvc_router_exception_ce); + ZEPHIR_INIT_NVAR(&_65$$88); + ZEPHIR_CONCAT_SV(&_65$$88, "Wrong key in paths: ", &part); + ZEPHIR_CALL_METHOD(NULL, &_64$$88, "__construct", &_28, 33, &_65$$88); + zephir_check_call_status(); + zephir_throw_exception_debug(&_64$$88, "phalcon/Mvc/Router.zep", 866); + ZEPHIR_MM_RESTORE(); + return; + } + _66$$87 = Z_TYPE_P(&position) != IS_STRING; + if (_66$$87) { + _66$$87 = Z_TYPE_P(&position) != IS_LONG; + } + if (_66$$87) { + continue; + } + ZEPHIR_OBS_NVAR(&matchPosition); + if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { + if (Z_TYPE_P(&converters) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&converter); + if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { + ZEPHIR_INIT_NVAR(&_67$$92); + ZEPHIR_INIT_NVAR(&_68$$92); + zephir_create_array(&_68$$92, 1, 0); + zephir_array_fast_append(&_68$$92, &matchPosition); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_67$$92, &converter, &_68$$92); + zephir_check_call_status(); + zephir_array_update_zval(&parts, &part, &_67$$92, PH_COPY | PH_SEPARATE); + continue; + } + } + zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); + } else { + if (Z_TYPE_P(&converters) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&converter); + if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { + ZEPHIR_INIT_NVAR(&_69$$95); + ZEPHIR_INIT_NVAR(&_70$$95); + zephir_create_array(&_70$$95, 1, 0); + zephir_array_fast_append(&_70$$95, &position); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_69$$95, &converter, &_70$$95); + zephir_check_call_status(); + zephir_array_update_zval(&parts, &part, &_69$$95, PH_COPY | PH_SEPARATE); + } + } else { + if (Z_TYPE_P(&position) == IS_LONG) { + zephir_array_unset(&parts, &part, PH_SEPARATE); + } + } + } + ZEPHIR_CALL_METHOD(NULL, &paths, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&position); + ZEPHIR_INIT_NVAR(&part); + zephir_update_property_zval(this_ptr, ZEND_STRL("matches"), &matches); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("matchedRoute"), &route); + break; + } + ZEPHIR_CALL_METHOD(NULL, &_4, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&route); + if (zephir_is_true(&routeFound)) { + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$false); + } + } else { + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$false); + } + } + if (!(zephir_is_true(&routeFound))) { + zephir_read_property(&_71$$100, this_ptr, ZEND_STRL("notFoundPaths"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(¬FoundPaths, &_71$$100); + if (Z_TYPE_P(¬FoundPaths) != IS_NULL) { + ZEPHIR_CALL_CE_STATIC(&parts, phalcon_mvc_router_route_ce, "getroutepaths", NULL, 0, ¬FoundPaths); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&routeFound); + ZVAL_BOOL(&routeFound, 1); + } + } + zephir_read_property(&_72, this_ptr, ZEND_STRL("defaultNamespace"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("namespaceName"), &_72); + zephir_read_property(&_73, this_ptr, ZEND_STRL("defaultModule"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("module"), &_73); + zephir_read_property(&_74, this_ptr, ZEND_STRL("defaultController"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("controller"), &_74); + zephir_read_property(&_75, this_ptr, ZEND_STRL("defaultAction"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("action"), &_75); + zephir_read_property(&_76, this_ptr, ZEND_STRL("defaultParams"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("params"), &_76); + if (zephir_is_true(&routeFound)) { + zephir_memory_observe(&vnamespace); + if (zephir_array_isset_string_fetch(&vnamespace, &parts, SL("namespace"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("namespaceName"), &vnamespace); + zephir_array_unset_string(&parts, SL("namespace"), PH_SEPARATE); + } + zephir_memory_observe(&module); + if (zephir_array_isset_string_fetch(&module, &parts, SL("module"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("module"), &module); + zephir_array_unset_string(&parts, SL("module"), PH_SEPARATE); + } + zephir_memory_observe(&controller); + if (zephir_array_isset_string_fetch(&controller, &parts, SL("controller"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("controller"), &controller); + zephir_array_unset_string(&parts, SL("controller"), PH_SEPARATE); + } + zephir_memory_observe(&action); + if (zephir_array_isset_string_fetch(&action, &parts, SL("action"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("action"), &action); + zephir_array_unset_string(&parts, SL("action"), PH_SEPARATE); + } + zephir_memory_observe(¶msStr); + if (zephir_array_isset_string_fetch(¶msStr, &parts, SL("params"), 0)) { + if (Z_TYPE_P(¶msStr) == IS_STRING) { + ZEPHIR_INIT_VAR(&_77$$108); + ZVAL_STRING(&_77$$108, "/"); + ZEPHIR_INIT_VAR(&strParams); + zephir_fast_trim(&strParams, ¶msStr, &_77$$108, ZEPHIR_TRIM_BOTH); + if (!ZEPHIR_IS_STRING_IDENTICAL(&strParams, "")) { + ZEPHIR_INIT_NVAR(¶ms); + zephir_fast_explode_str(¶ms, SL("/"), &strParams, LONG_MAX); + } + } + zephir_array_unset_string(&parts, SL("params"), PH_SEPARATE); + } + if (zephir_fast_count_int(¶ms)) { + ZEPHIR_INIT_VAR(&_78$$110); + zephir_fast_array_merge(&_78$$110, ¶ms, &parts); + zephir_update_property_zval(this_ptr, ZEND_STRL("params"), &_78$$110); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("params"), &parts); + } + } + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_79$$112); + ZVAL_STRING(&_79$$112, "router:afterCheckRoutes"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_79$$112, this_ptr); + zephir_check_call_status(); + } ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Logger_Adapter_Stream, phpFopen) +static PHP_METHOD(Phalcon_Mvc_Router, isExactControllerName) +{ + + RETURN_BOOL(1); +} + +static PHP_METHOD(Phalcon_Mvc_Router, mount) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *filename_param = NULL, *mode_param = NULL; - zval filename, mode; + zval *group, group_sub, groupRoutes, beforeMatch, hostname, routes, route, eventsManager, _0, _6, _1$$3, *_2$$5, _3$$5, *_4$$8, _5$$8; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&filename); - ZVAL_UNDEF(&mode); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(filename) - Z_PARAM_STR(mode) + ZVAL_UNDEF(&group_sub); + ZVAL_UNDEF(&groupRoutes); + ZVAL_UNDEF(&beforeMatch); + ZVAL_UNDEF(&hostname); + ZVAL_UNDEF(&routes); + ZVAL_UNDEF(&route); + ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_5$$8); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(group, phalcon_mvc_router_groupinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &filename_param, &mode_param); - zephir_get_strval(&filename, filename_param); - zephir_get_strval(&mode, mode_param); - ZEPHIR_RETURN_CALL_FUNCTION("fopen", NULL, 140, &filename, &mode); + zephir_fetch_params(1, 1, 0, &group); + zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_0); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "router:beforeMount"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_1$$3, this_ptr, group); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(&groupRoutes, group, "getroutes", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + if (UNEXPECTED(!(zephir_fast_count_int(&groupRoutes)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "The group of routes does not contain any routes", "phalcon/Mvc/Router.zep", 1051); + return; + } + ZEPHIR_CALL_METHOD(&beforeMatch, group, "getbeforematch", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&beforeMatch) != IS_NULL) { + zephir_is_iterable(&groupRoutes, 0, "phalcon/Mvc/Router.zep", 1063); + if (Z_TYPE_P(&groupRoutes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&groupRoutes), _2$$5) + { + ZEPHIR_INIT_NVAR(&route); + ZVAL_COPY(&route, _2$$5); + ZEPHIR_CALL_METHOD(NULL, &route, "beforematch", NULL, 0, &beforeMatch); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &groupRoutes, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3$$5, &groupRoutes, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3$$5)) { + break; + } + ZEPHIR_CALL_METHOD(&route, &groupRoutes, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &route, "beforematch", NULL, 0, &beforeMatch); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &groupRoutes, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&route); + } + ZEPHIR_CALL_METHOD(&hostname, group, "gethostname", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&hostname) != IS_NULL) { + zephir_is_iterable(&groupRoutes, 0, "phalcon/Mvc/Router.zep", 1072); + if (Z_TYPE_P(&groupRoutes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&groupRoutes), _4$$8) + { + ZEPHIR_INIT_NVAR(&route); + ZVAL_COPY(&route, _4$$8); + ZEPHIR_CALL_METHOD(NULL, &route, "sethostname", NULL, 0, &hostname); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &groupRoutes, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5$$8, &groupRoutes, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5$$8)) { + break; + } + ZEPHIR_CALL_METHOD(&route, &groupRoutes, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &route, "sethostname", NULL, 0, &hostname); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &groupRoutes, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&route); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&routes, &_0); + ZEPHIR_INIT_VAR(&_6); + zephir_fast_array_merge(&_6, &routes, &groupRoutes); + zephir_update_property_zval(this_ptr, ZEND_STRL("routes"), &_6); + RETURN_THIS(); } +static PHP_METHOD(Phalcon_Mvc_Router, notFound) +{ + zend_bool _0; + zval *paths, paths_sub; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&paths_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(paths) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &paths); + _0 = Z_TYPE_P(paths) != IS_ARRAY; + if (_0) { + _0 = Z_TYPE_P(paths) != IS_STRING; + } + if (UNEXPECTED(_0)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_router_exception_ce, "The not-found paths must be an array or string", "phalcon/Mvc/Router.zep", 1094); + return; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("notFoundPaths"), paths); + RETURN_THISW(); +} - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_Syslog) +static PHP_METHOD(Phalcon_Mvc_Router, removeExtraSlashes) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Adapter, Syslog, phalcon, logger_adapter_syslog, phalcon_logger_adapter_abstractadapter_ce, phalcon_logger_adapter_syslog_method_entry, 0); + zval *remove_param = NULL, __$true, __$false; + zend_bool remove; + zval *this_ptr = getThis(); - zend_declare_property_long(phalcon_logger_adapter_syslog_ce, SL("facility"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_logger_adapter_syslog_ce, SL("name"), "", ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_logger_adapter_syslog_ce, SL("opened"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_logger_adapter_syslog_ce, SL("option"), 0, ZEND_ACC_PROTECTED); - return SUCCESS; + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(remove) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &remove_param); + if (UNEXPECTED(Z_TYPE_P(remove_param) != IS_TRUE && Z_TYPE_P(remove_param) != IS_FALSE)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'remove' must be of the type bool")); + RETURN_NULL(); + } + remove = (Z_TYPE_P(remove_param) == IS_TRUE); + if (remove) { + zephir_update_property_zval(this_ptr, ZEND_STRL("removeExtraSlashes"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("removeExtraSlashes"), &__$false); + } + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, __construct) +static PHP_METHOD(Phalcon_Mvc_Router, setDefaultAction) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval options; - zval *name_param = NULL, *options_param = NULL, facility, option; - zval name; + zval *actionName_param = NULL; + zval actionName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&facility); - ZVAL_UNDEF(&option); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(name) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZVAL_UNDEF(&actionName); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(actionName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &name_param, &options_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + zephir_fetch_params(1, 1, 0, &actionName_param); + if (UNEXPECTED(Z_TYPE_P(actionName_param) != IS_STRING && Z_TYPE_P(actionName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); + if (EXPECTED(Z_TYPE_P(actionName_param) == IS_STRING)) { + zephir_get_strval(&actionName, actionName_param); } else { - zephir_get_arrval(&options, options_param); - } - zephir_memory_observe(&facility); - if (!(zephir_array_isset_string_fetch(&facility, &options, SL("facility"), 0))) { - ZEPHIR_INIT_NVAR(&facility); - ZVAL_LONG(&facility, 8); - } - zephir_memory_observe(&option); - if (!(zephir_array_isset_string_fetch(&option, &options, SL("option"), 0))) { - ZEPHIR_INIT_NVAR(&option); - ZVAL_LONG(&option, 4); + ZEPHIR_INIT_VAR(&actionName); } - zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); - zephir_update_property_zval(this_ptr, ZEND_STRL("option"), &option); - zephir_update_property_zval(this_ptr, ZEND_STRL("facility"), &facility); - ZEPHIR_MM_RESTORE(); + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultAction"), &actionName); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, close) +static PHP_METHOD(Phalcon_Mvc_Router, setDefaultController) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *controllerName_param = NULL; + zval controllerName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&controllerName); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(controllerName) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("opened"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_is_true(&_0))) { - RETURN_MM_BOOL(1); + zephir_fetch_params(1, 1, 0, &controllerName_param); + if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_RETURN_CALL_FUNCTION("closelog", NULL, 410); - zephir_check_call_status(); - RETURN_MM(); + if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { + zephir_get_strval(&controllerName, controllerName_param); + } else { + ZEPHIR_INIT_VAR(&controllerName); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultController"), &controllerName); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, process) +static PHP_METHOD(Phalcon_Mvc_Router, setDefaultModule) { - zval _6$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *item, item_sub, __$true, __$false, level, message, result, _0, _1, _2, _9, _3$$3, _4$$3, _5$$3, _7$$3, _8$$3; + zval *moduleName_param = NULL; + zval moduleName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&item_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&level); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&moduleName); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) + Z_PARAM_STR(moduleName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &item); - ZEPHIR_CALL_METHOD(&message, this_ptr, "getformatteditem", NULL, 0, item); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_1, this_ptr, ZEND_STRL("option"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_2, this_ptr, ZEND_STRL("facility"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&result, this_ptr, "openlog", NULL, 0, &_0, &_1, &_2); - zephir_check_call_status(); - if (!zephir_is_true(&result)) { - ZEPHIR_INIT_VAR(&_3$$3); - object_init_ex(&_3$$3, spl_ce_LogicException); - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&_5$$3); - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("facility"), PH_NOISY_CC); - zephir_cast_to_string(&_6$$3, &_5$$3); - ZEPHIR_INIT_VAR(&_7$$3); - ZVAL_STRING(&_7$$3, "Cannot open syslog for name [%s] and facility [%s]"); - ZEPHIR_CALL_FUNCTION(&_8$$3, "sprintf", NULL, 117, &_7$$3, &_4$$3, &_6$$3); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_3$$3, "__construct", NULL, 409, &_8$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_3$$3, "phalcon/Logger/Adapter/Syslog.zep", 106); - ZEPHIR_MM_RESTORE(); - return; + zephir_fetch_params(1, 1, 0, &moduleName_param); + if (UNEXPECTED(Z_TYPE_P(moduleName_param) != IS_STRING && Z_TYPE_P(moduleName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'moduleName' must be of the type string")); + RETURN_MM_NULL(); } - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("opened"), &__$true); + if (EXPECTED(Z_TYPE_P(moduleName_param) == IS_STRING)) { + zephir_get_strval(&moduleName, moduleName_param); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("opened"), &__$false); + ZEPHIR_INIT_VAR(&moduleName); } - ZEPHIR_CALL_METHOD(&_9, item, "getlevel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&level, this_ptr, "logleveltosyslog", NULL, 411, &_9); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(NULL, "syslog", NULL, 412, &level, &message); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultModule"), &moduleName); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, openlog) +static PHP_METHOD(Phalcon_Mvc_Router, setDefaultNamespace) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long option, facility, ZEPHIR_LAST_CALL_STATUS; - zval *ident_param = NULL, *option_param = NULL, *facility_param = NULL, _0, _1; - zval ident; + zval *namespaceName_param = NULL; + zval namespaceName; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&ident); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_STR(ident) - Z_PARAM_LONG(option) - Z_PARAM_LONG(facility) + ZVAL_UNDEF(&namespaceName); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(namespaceName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &ident_param, &option_param, &facility_param); - zephir_get_strval(&ident, ident_param); - ZVAL_LONG(&_0, option); - ZVAL_LONG(&_1, facility); - ZEPHIR_RETURN_CALL_FUNCTION("openlog", NULL, 413, &ident, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &namespaceName_param); + if (UNEXPECTED(Z_TYPE_P(namespaceName_param) != IS_STRING && Z_TYPE_P(namespaceName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'namespaceName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(namespaceName_param) == IS_STRING)) { + zephir_get_strval(&namespaceName, namespaceName_param); + } else { + ZEPHIR_INIT_VAR(&namespaceName); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultNamespace"), &namespaceName); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, logLevelToSyslog) +static PHP_METHOD(Phalcon_Mvc_Router, setDefaults) { - zval levels; + zval _0$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *level_param = NULL, result; - zend_long level; - - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&levels); + zval *defaults_param = NULL, namespaceName, module, controller, action, params; + zval defaults; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&defaults); + ZVAL_UNDEF(&namespaceName); + ZVAL_UNDEF(&module); + ZVAL_UNDEF(&controller); + ZVAL_UNDEF(&action); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&_0$$3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(level) + Z_PARAM_ARRAY(defaults) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &level_param); - ZEPHIR_INIT_VAR(&levels); - zephir_create_array(&levels, 9, 0); - add_index_long(&levels, 2, 1); - add_index_long(&levels, 1, 2); - add_index_long(&levels, 8, 3); - add_index_long(&levels, 7, 7); - add_index_long(&levels, 0, 0); - add_index_long(&levels, 3, 3); - add_index_long(&levels, 6, 6); - add_index_long(&levels, 5, 5); - add_index_long(&levels, 4, 4); - zephir_memory_observe(&result); - if (!(zephir_array_isset_long_fetch(&result, &levels, level, 0))) { - ZEPHIR_INIT_NVAR(&result); - ZVAL_LONG(&result, 3); + zephir_fetch_params(1, 1, 0, &defaults_param); + ZEPHIR_OBS_COPY_OR_DUP(&defaults, defaults_param); + zephir_memory_observe(&namespaceName); + if (zephir_array_isset_string_fetch(&namespaceName, &defaults, SL("namespace"), 0)) { + zephir_cast_to_string(&_0$$3, &namespaceName); + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultNamespace"), &_0$$3); } - RETURN_CCTOR(&result); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Logger_Formatter_AbstractFormatter) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Formatter, AbstractFormatter, phalcon, logger_formatter_abstractformatter, phalcon_support_helper_str_abstractstr_ce, phalcon_logger_formatter_abstractformatter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_string(phalcon_logger_formatter_abstractformatter_ce, SL("dateFormat"), "c", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_logger_formatter_abstractformatter_ce, SL("interpolatorLeft"), "%", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_logger_formatter_abstractformatter_ce, SL("interpolatorRight"), "%", ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_logger_formatter_abstractformatter_ce, 1, phalcon_logger_formatter_formatterinterface_ce); - return SUCCESS; + zephir_memory_observe(&module); + if (zephir_array_isset_string_fetch(&module, &defaults, SL("module"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultModule"), &module); + } + zephir_memory_observe(&controller); + if (zephir_array_isset_string_fetch(&controller, &defaults, SL("controller"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultController"), &controller); + } + zephir_memory_observe(&action); + if (zephir_array_isset_string_fetch(&action, &defaults, SL("action"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultAction"), &action); + } + zephir_memory_observe(¶ms); + if (zephir_array_isset_string_fetch(¶ms, &defaults, SL("params"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultParams"), ¶ms); + } + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Logger_Formatter_AbstractFormatter, getDateFormat) +static PHP_METHOD(Phalcon_Mvc_Router, setEventsManager) { + zval *eventsManager, eventsManager_sub; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "dateFormat"); + ZVAL_UNDEF(&eventsManager_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); + zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); } -static PHP_METHOD(Phalcon_Logger_Formatter_AbstractFormatter, setDateFormat) +static PHP_METHOD(Phalcon_Mvc_Router, setKeyRouteNames) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *format_param = NULL; - zval format; + zval *routeNames_param = NULL; + zval routeNames; zval *this_ptr = getThis(); - ZVAL_UNDEF(&format); + ZVAL_UNDEF(&routeNames); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(format) + Z_PARAM_ARRAY(routeNames) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &format_param); - zephir_get_strval(&format, format_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("dateFormat"), &format); - ZEPHIR_MM_RESTORE(); + zephir_fetch_params(1, 1, 0, &routeNames_param); + zephir_get_arrval(&routeNames, routeNames_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("keyRouteNames"), &routeNames); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Logger_Formatter_AbstractFormatter, getFormattedDate) +static PHP_METHOD(Phalcon_Mvc_Router, setKeyRouteIds) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *item, item_sub, _0, _1; + zval *routeIds_param = NULL; + zval routeIds; zval *this_ptr = getThis(); - ZVAL_UNDEF(&item_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&routeIds); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) + Z_PARAM_ARRAY(routeIds) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &item); - ZEPHIR_CALL_METHOD(&_0, item, "getdatetime", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_1, this_ptr, ZEND_STRL("dateFormat"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "format", NULL, 0, &_1); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &routeIds_param); + zephir_get_arrval(&routeIds, routeIds_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("keyRouteIds"), &routeIds); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Logger_Formatter_AbstractFormatter, getInterpolatedMessage) +static PHP_METHOD(Phalcon_Mvc_Router, wasMatched) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval message; - zval *item, item_sub, *message_param = NULL, _0, _1, _2; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&item_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + RETURN_MEMBER(getThis(), "wasMatched"); +} + +zend_object *zephir_init_properties_Phalcon_Mvc_Router(zend_class_entry *class_type) +{ + zval _0, _2, _4, _6, _8, _10, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&message); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) - Z_PARAM_STR(message) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &item, &message_param); - zephir_get_strval(&message, message_param); - ZEPHIR_CALL_METHOD(&_0, item, "getcontext", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_1, this_ptr, ZEND_STRL("interpolatorLeft"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_2, this_ptr, ZEND_STRL("interpolatorRight"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "tointerpolate", NULL, 0, &message, &_0, &_1, &_2); - zephir_check_call_status(); - RETURN_MM(); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_9$$7); + ZVAL_UNDEF(&_11$$8); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("routes"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("matches"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("matches"), &_5$$5); + } + zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("keyRouteIds"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_6) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$6); + array_init(&_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("keyRouteIds"), &_7$$6); + } + zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("keyRouteNames"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_8) == IS_NULL) { + ZEPHIR_INIT_VAR(&_9$$7); + array_init(&_9$$7); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("keyRouteNames"), &_9$$7); + } + zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("defaultParams"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_10) == IS_NULL) { + ZEPHIR_INIT_VAR(&_11$$8); + array_init(&_11$$8); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("defaultParams"), &_11$$8); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } } @@ -31956,14 +35742,43 @@ static PHP_METHOD(Phalcon_Logger_Formatter_AbstractFormatter, getInterpolatedMes -ZEPHIR_INIT_CLASS(Phalcon_Logger_Formatter_FormatterInterface) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_RouterInterface) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Logger\\Formatter, FormatterInterface, phalcon, logger_formatter_formatterinterface, phalcon_logger_formatter_formatterinterface_method_entry); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, RouterInterface, phalcon, mvc_routerinterface, phalcon_mvc_routerinterface_method_entry); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Logger_Formatter_FormatterInterface, format); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, add); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addConnect); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addDelete); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addHead); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addGet); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addOptions); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addPatch); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addPost); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addPurge); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addPut); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addTrace); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, attach); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, clear); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getActionName); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getControllerName); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getMatchedRoute); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getMatches); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getModuleName); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getNamespaceName); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getParams); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getRoutes); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getRouteById); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getRouteByName); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, handle); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, mount); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, setDefaultAction); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, setDefaultController); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, setDefaultModule); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, setDefaults); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, wasMatched); @@ -31974,247 +35789,438 @@ ZEPHIR_DOC_METHOD(Phalcon_Logger_Formatter_FormatterInterface, format); -ZEPHIR_INIT_CLASS(Phalcon_Logger_Formatter_Json) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Url) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Formatter, Json, phalcon, logger_formatter_json, phalcon_logger_formatter_abstractformatter_ce, phalcon_logger_formatter_json_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Url, phalcon, mvc_url, phalcon_di_abstractinjectionaware_ce, phalcon_mvc_url_method_entry, 0); + zend_declare_property_null(phalcon_mvc_url_ce, SL("baseUri"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_url_ce, SL("basePath"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_url_ce, SL("router"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_url_ce, SL("staticBaseUri"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_mvc_url_ce, 1, phalcon_mvc_url_urlinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Logger_Formatter_Json, __construct) +static PHP_METHOD(Phalcon_Mvc_Url, __construct) +{ + zval *router = NULL, router_sub, __$null; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&router_sub); + ZVAL_NULL(&__$null); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(router, phalcon_mvc_routerinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(0, 1, &router); + if (!router) { + router = &router_sub; + router = &__$null; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("router"), router); +} + +static PHP_METHOD(Phalcon_Mvc_Url, get) { + zval strUri, _16$$15; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *dateFormat_param = NULL, *interpolatorLeft_param = NULL, *interpolatorRight_param = NULL; - zval dateFormat, interpolatorLeft, interpolatorRight; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool local, _0$$3, _1$$3, _20$$16; + zval *uri = NULL, uri_sub, *args = NULL, args_sub, *local_param = NULL, *baseUri = NULL, baseUri_sub, __$null, router, container, routeName, route, queryString, _2$$4, _3$$4, _4$$4, _5$$4, _6$$9, _11$$9, _14$$9, _15$$9, _7$$11, _8$$11, _9$$11, _10$$11, _12$$14, _13$$14, _17$$15, _18$$15, _19$$15, _21$$17, _22$$17, _23$$18, _24$$19; zval *this_ptr = getThis(); - ZVAL_UNDEF(&dateFormat); - ZVAL_UNDEF(&interpolatorLeft); - ZVAL_UNDEF(&interpolatorRight); - ZEND_PARSE_PARAMETERS_START(0, 3) + ZVAL_UNDEF(&uri_sub); + ZVAL_UNDEF(&args_sub); + ZVAL_UNDEF(&baseUri_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&router); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&routeName); + ZVAL_UNDEF(&route); + ZVAL_UNDEF(&queryString); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_6$$9); + ZVAL_UNDEF(&_11$$9); + ZVAL_UNDEF(&_14$$9); + ZVAL_UNDEF(&_15$$9); + ZVAL_UNDEF(&_7$$11); + ZVAL_UNDEF(&_8$$11); + ZVAL_UNDEF(&_9$$11); + ZVAL_UNDEF(&_10$$11); + ZVAL_UNDEF(&_12$$14); + ZVAL_UNDEF(&_13$$14); + ZVAL_UNDEF(&_17$$15); + ZVAL_UNDEF(&_18$$15); + ZVAL_UNDEF(&_19$$15); + ZVAL_UNDEF(&_21$$17); + ZVAL_UNDEF(&_22$$17); + ZVAL_UNDEF(&_23$$18); + ZVAL_UNDEF(&_24$$19); + ZVAL_UNDEF(&strUri); + ZVAL_UNDEF(&_16$$15); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 4) Z_PARAM_OPTIONAL - Z_PARAM_STR(dateFormat) - Z_PARAM_STR(interpolatorLeft) - Z_PARAM_STR(interpolatorRight) + Z_PARAM_ZVAL_OR_NULL(uri) + Z_PARAM_ZVAL_OR_NULL(args) + Z_PARAM_BOOL_OR_NULL(local, is_null_true) + Z_PARAM_ZVAL_OR_NULL(baseUri) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 3, &dateFormat_param, &interpolatorLeft_param, &interpolatorRight_param); - if (!dateFormat_param) { - ZEPHIR_INIT_VAR(&dateFormat); - ZVAL_STRING(&dateFormat, "c"); + zephir_fetch_params(1, 0, 4, &uri, &args, &local_param, &baseUri); + if (!uri) { + uri = &uri_sub; + ZEPHIR_CPY_WRT(uri, &__$null); } else { - zephir_get_strval(&dateFormat, dateFormat_param); + ZEPHIR_SEPARATE_PARAM(uri); } - if (!interpolatorLeft_param) { - ZEPHIR_INIT_VAR(&interpolatorLeft); - ZVAL_STRING(&interpolatorLeft, "%"); - } else { - zephir_get_strval(&interpolatorLeft, interpolatorLeft_param); + if (!args) { + args = &args_sub; + args = &__$null; } - if (!interpolatorRight_param) { - ZEPHIR_INIT_VAR(&interpolatorRight); - ZVAL_STRING(&interpolatorRight, "%"); + if (!local_param) { + local = 0; } else { - zephir_get_strval(&interpolatorRight, interpolatorRight_param); + } + if (!baseUri) { + baseUri = &baseUri_sub; + ZEPHIR_CPY_WRT(baseUri, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(baseUri); } - zephir_update_property_zval(this_ptr, ZEND_STRL("dateFormat"), &dateFormat); - zephir_update_property_zval(this_ptr, ZEND_STRL("interpolatorLeft"), &interpolatorLeft); - zephir_update_property_zval(this_ptr, ZEND_STRL("interpolatorRight"), &interpolatorRight); - ZEPHIR_MM_RESTORE(); + if (local == 0) { + _0$$3 = Z_TYPE_P(uri) == IS_STRING; + if (_0$$3) { + _1$$3 = zephir_memnstr_str(uri, SL("//"), "phalcon/Mvc/Url.zep", 107); + if (!(_1$$3)) { + _1$$3 = zephir_memnstr_str(uri, SL(":"), "phalcon/Mvc/Url.zep", 107); + } + _0$$3 = _1$$3; + } + if (_0$$3) { + ZEPHIR_INIT_VAR(&_2$$4); + ZEPHIR_INIT_VAR(&_3$$4); + ZVAL_STRING(&_3$$4, "#^((//)|([a-z0-9]+://)|([a-z0-9]+:))#i"); + ZEPHIR_INIT_VAR(&_4$$4); + ZEPHIR_INIT_VAR(&_5$$4); + ZVAL_STRING(&_5$$4, "#^((//)|([a-z0-9]+://)|([a-z0-9]+:))#i"); + zephir_preg_match(&_4$$4, &_5$$4, uri, &_2$$4, 0, 0 , 0 ); + if (zephir_is_true(&_4$$4)) { + local = 0; + } else { + local = 1; + } + } else { + local = 1; + } + } + if (Z_TYPE_P(baseUri) != IS_STRING) { + ZEPHIR_CALL_METHOD(baseUri, this_ptr, "getbaseuri", NULL, 0); + zephir_check_call_status(); + } + if (Z_TYPE_P(uri) == IS_ARRAY) { + zephir_memory_observe(&routeName); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&routeName, uri, SL("for"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "It's necessary to define the route name with the parameter 'for'", "phalcon/Mvc/Url.zep", 126); + return; + } + zephir_read_property(&_6$$9, this_ptr, ZEND_STRL("router"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&router, &_6$$9); + if (UNEXPECTED(!zephir_is_true(&router))) { + zephir_read_property(&_7$$11, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_7$$11); + if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "A dependency injection container is required to access the 'router' service", "phalcon/Mvc/Url.zep", 140); + return; + } + ZEPHIR_INIT_VAR(&_9$$11); + ZVAL_STRING(&_9$$11, "router"); + ZEPHIR_CALL_METHOD(&_8$$11, &container, "has", NULL, 0, &_9$$11); + zephir_check_call_status(); + if (UNEXPECTED(!zephir_is_true(&_8$$11))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "A dependency injection container is required to access the 'router' service", "phalcon/Mvc/Url.zep", 146); + return; + } + ZEPHIR_INIT_NVAR(&_9$$11); + ZVAL_STRING(&_9$$11, "router"); + ZEPHIR_CALL_METHOD(&_10$$11, &container, "getshared", NULL, 0, &_9$$11); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&router, &_10$$11); + zephir_update_property_zval(this_ptr, ZEND_STRL("router"), &router); + } + ZEPHIR_CALL_METHOD(&_11$$9, &router, "getroutebyname", NULL, 0, &routeName); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&route, &_11$$9); + if (UNEXPECTED(Z_TYPE_P(&route) != IS_OBJECT)) { + ZEPHIR_INIT_VAR(&_12$$14); + object_init_ex(&_12$$14, phalcon_mvc_url_exception_ce); + ZEPHIR_INIT_VAR(&_13$$14); + ZEPHIR_CONCAT_SVS(&_13$$14, "Cannot obtain a route using the name '", &routeName, "'"); + ZEPHIR_CALL_METHOD(NULL, &_12$$14, "__construct", NULL, 33, &_13$$14); + zephir_check_call_status(); + zephir_throw_exception_debug(&_12$$14, "phalcon/Mvc/Url.zep", 161); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_VAR(&_14$$9); + ZEPHIR_CALL_METHOD(&_11$$9, &route, "getpattern", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_15$$9, &route, "getreversedpaths", NULL, 0); + zephir_check_call_status(); + phalcon_replace_paths(&_14$$9, &_11$$9, &_15$$9, uri); + ZEPHIR_CPY_WRT(uri, &_14$$9); + } + if (local) { + zephir_cast_to_string(&_16$$15, uri); + ZEPHIR_CPY_WRT(&strUri, &_16$$15); + ZEPHIR_INIT_VAR(&_17$$15); + ZEPHIR_CONCAT_VV(&_17$$15, baseUri, &strUri); + ZEPHIR_INIT_VAR(&_18$$15); + ZVAL_STRING(&_18$$15, "#(?create_object = zephir_init_properties_Phalcon_Mvc_View; + zephir_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_ACTION_VIEW"), 1); + + zephir_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_BEFORE_TEMPLATE"), 2); + + zephir_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_LAYOUT"), 3); + + zephir_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_MAIN_LAYOUT"), 5); + + zephir_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_NO_RENDER"), 0); + + zephir_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_AFTER_TEMPLATE"), 4); + + zend_class_implements(phalcon_mvc_view_ce, 1, phalcon_mvc_viewinterface_ce); + zend_class_implements(phalcon_mvc_view_ce, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Cache_AbstractCache, __construct) +static PHP_METHOD(Phalcon_Mvc_View, __construct) { - zval *adapter, adapter_sub; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *options_param = NULL; + zval options; zval *this_ptr = getThis(); - ZVAL_UNDEF(&adapter_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(adapter, phalcon_cache_adapter_adapterinterface_ce) + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &adapter); - zephir_update_property_zval(this_ptr, ZEND_STRL("adapter"), adapter); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Cache_AbstractCache, getAdapter) +static PHP_METHOD(Phalcon_Mvc_View, __get) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL; + zval key; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "adapter"); + ZVAL_UNDEF(&key); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(key) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &key_param); + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); + } else { + ZEPHIR_INIT_VAR(&key); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getvar", NULL, 0, &key); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Cache_AbstractCache, checkKey) +static PHP_METHOD(Phalcon_Mvc_View, __isset) { - zend_class_entry *_6$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, exception, _0, _1, _2, _3, _4$$3, _5$$3, _7$$3; + zval *key_param = NULL, _0; zval key; zval *this_ptr = getThis(); ZVAL_UNDEF(&key); - ZVAL_UNDEF(&exception); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_7$$3); ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); zephir_fetch_params(1, 1, 0, &key_param); - zephir_get_strval(&key, key_param); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "/[^A-Za-z0-9-_.]/"); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "/[^A-Za-z0-9-_.]/"); - zephir_preg_match(&_2, &_3, &key, &_0, 0, 0 , 0 ); - if (zephir_is_true(&_2)) { - ZEPHIR_CALL_METHOD(&exception, this_ptr, "getexceptionclass", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_4$$3); - zephir_fetch_safe_class(&_5$$3, &exception); - _6$$3 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_5$$3), Z_STRLEN_P(&_5$$3), ZEND_FETCH_CLASS_AUTO); - if(!_6$$3) { - RETURN_MM_NULL(); - } - object_init_ex(&_4$$3, _6$$3); - ZEPHIR_INIT_VAR(&_7$$3); - ZVAL_STRING(&_7$$3, "The key contains invalid characters"); - ZEPHIR_CALL_METHOD(NULL, &_4$$3, "__construct", NULL, 0, &_7$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_4$$3, "phalcon/Cache/AbstractCache.zep", 65); - ZEPHIR_MM_RESTORE(); - return; + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_MM_RESTORE(); + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); + } else { + ZEPHIR_INIT_VAR(&key); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("viewParams"), PH_NOISY_CC | PH_READONLY); + RETURN_MM_BOOL(zephir_array_isset(&_0, &key)); } -static PHP_METHOD(Phalcon_Cache_AbstractCache, checkKeys) +static PHP_METHOD(Phalcon_Mvc_View, __set) { - zend_class_entry *_3$$3; - zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *keys, keys_sub, exception, _1$$3, _2$$3, _4$$3; + zval *key_param = NULL, *value, value_sub; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&keys_sub); - ZVAL_UNDEF(&exception); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(keys) + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(key) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &keys); - _0 = Z_TYPE_P(keys) == IS_ARRAY; - if (!(_0)) { - _0 = zephir_zval_is_traversable(keys); + zephir_fetch_params(1, 2, 0, &key_param, &value); + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + RETURN_MM_NULL(); } - if (!(_0)) { - ZEPHIR_CALL_METHOD(&exception, this_ptr, "getexceptionclass", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_1$$3); - zephir_fetch_safe_class(&_2$$3, &exception); - _3$$3 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_2$$3), Z_STRLEN_P(&_2$$3), ZEND_FETCH_CLASS_AUTO); - if(!_3$$3) { - RETURN_MM_NULL(); - } - object_init_ex(&_1$$3, _3$$3); - ZEPHIR_INIT_VAR(&_4$$3); - ZVAL_STRING(&_4$$3, "The keys need to be an array or instance of Traversable"); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 0, &_4$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Cache/AbstractCache.zep", 84); - ZEPHIR_MM_RESTORE(); - return; + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); + } else { + ZEPHIR_INIT_VAR(&key); } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setvar", NULL, 0, &key, value); + zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Cache_AbstractCache, doClear) +static PHP_METHOD(Phalcon_Mvc_View, cleanTemplateAfter) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "clear", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("templatesAfter"), &_0); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Cache_AbstractCache, doDelete) +static PHP_METHOD(Phalcon_Mvc_View, cleanTemplateBefore) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, _0; - zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - zephir_get_strval(&key, key_param); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkey", NULL, 0, &key); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "delete", NULL, 0, &key); - zephir_check_call_status(); - RETURN_MM(); + + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("templatesBefore"), &_0); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Cache_AbstractCache, doDeleteMultiple) +static PHP_METHOD(Phalcon_Mvc_View, disableLevel) { - zend_bool result = 0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *keys, keys_sub, key, *_0, _1, _2$$3, _3$$3, _4$$5, _5$$5; + zval *level, level_sub, __$true; zval *this_ptr = getThis(); - ZVAL_UNDEF(&keys_sub); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&level_sub); + ZVAL_BOOL(&__$true, 1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(keys) + Z_PARAM_ZVAL(level) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &keys); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkeys", NULL, 0, keys); - zephir_check_call_status(); - result = 1; - zephir_is_iterable(keys, 0, "phalcon/Cache/AbstractCache.zep", 132); - if (Z_TYPE_P(keys) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(keys), _0) - { - ZEPHIR_INIT_NVAR(&key); - ZVAL_COPY(&key, _0); - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_3$$3, &_2$$3, "delete", NULL, 0, &key); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_3$$3)) { - result = 0; - } - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params_without_memory_grow(1, 0, &level); + if (Z_TYPE_P(level) == IS_ARRAY) { + zephir_update_property_zval(this_ptr, ZEND_STRL("disabledLevels"), level); } else { - ZEPHIR_CALL_METHOD(NULL, keys, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, keys, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&key, keys, "current", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_4$$5, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_5$$5, &_4$$5, "delete", NULL, 0, &key); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_5$$5)) { - result = 0; - } - ZEPHIR_CALL_METHOD(NULL, keys, "next", NULL, 0); - zephir_check_call_status(); - } + zephir_update_property_array(this_ptr, SL("disabledLevels"), level, &__$true); } - ZEPHIR_INIT_NVAR(&key); - RETURN_MM_BOOL(result); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Cache_AbstractCache, doGet) +static PHP_METHOD(Phalcon_Mvc_View, disable) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null, _0; - zval key; + zval __$true, __$false; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(key) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key_param, &defaultValue); - zephir_get_strval(&key, key_param); - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("disabled"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("disabled"), &__$false); } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkey", NULL, 0, &key); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &key, defaultValue); - zephir_check_call_status(); - RETURN_MM(); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Cache_AbstractCache, doGetMultiple) +static PHP_METHOD(Phalcon_Mvc_View, enable) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL, *_5 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *keys, keys_sub, *defaultValue = NULL, defaultValue_sub, __$null, element, results, *_0, _1, _2$$3, _4$$4; + zval __$true, __$false; zval *this_ptr = getThis(); - ZVAL_UNDEF(&keys_sub); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&results); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(keys) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &keys, &defaultValue); - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkeys", NULL, 0, keys); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&results); - array_init(&results); - zephir_is_iterable(keys, 0, "phalcon/Cache/AbstractCache.zep", 168); - if (Z_TYPE_P(keys) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(keys), _0) - { - ZEPHIR_INIT_NVAR(&element); - ZVAL_COPY(&element, _0); - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "get", &_3, 0, &element, defaultValue); - zephir_check_call_status(); - zephir_array_update_zval(&results, &element, &_2$$3, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("disabled"), &__$true); } else { - ZEPHIR_CALL_METHOD(NULL, keys, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, keys, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&element, keys, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$4, this_ptr, "get", &_5, 0, &element, defaultValue); - zephir_check_call_status(); - zephir_array_update_zval(&results, &element, &_4$$4, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, keys, "next", NULL, 0); - zephir_check_call_status(); - } + zephir_update_property_zval(this_ptr, ZEND_STRL("disabled"), &__$false); } - ZEPHIR_INIT_NVAR(&element); - RETURN_CCTOR(&results); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Cache_AbstractCache, doHas) +static PHP_METHOD(Phalcon_Mvc_View, exists) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, _0; - zval key; + zval *view_param = NULL; + zval view; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&view); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + Z_PARAM_STR(view) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - zephir_get_strval(&key, key_param); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkey", NULL, 0, &key); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "has", NULL, 0, &key); + zephir_fetch_params(1, 1, 0, &view_param); + if (UNEXPECTED(Z_TYPE_P(view_param) != IS_STRING && Z_TYPE_P(view_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'view' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(view_param) == IS_STRING)) { + zephir_get_strval(&view, view_param); + } else { + ZEPHIR_INIT_VAR(&view); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, &view); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Cache_AbstractCache, doSet) +static PHP_METHOD(Phalcon_Mvc_View, finish) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub, *ttl = NULL, ttl_sub, __$null, _0; - zval key; zval *this_ptr = getThis(); - - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&ttl_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(ttl) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &key_param, &value, &ttl); - zephir_get_strval(&key, key_param); - if (!ttl) { - ttl = &ttl_sub; - ttl = &__$null; - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkey", NULL, 0, &key); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "set", NULL, 0, &key, value, ttl); + + ZEPHIR_CALL_FUNCTION(NULL, "ob_end_clean", NULL, 489); zephir_check_call_status(); - RETURN_MM(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Cache_AbstractCache, doSetMultiple) +static PHP_METHOD(Phalcon_Mvc_View, getActionName) { - zend_string *_3; - zend_ulong _2; - zend_bool result = 0; + + RETURN_MEMBER(getThis(), "actionName"); +} + +static PHP_METHOD(Phalcon_Mvc_View, getActiveRenderPath) +{ + zend_bool _1$$3; + zval activeRenderPath, _0, _2$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *values, values_sub, *ttl = NULL, ttl_sub, __$null, key, value, *_0, _1, _4$$3, _6$$5; + zend_long ZEPHIR_LAST_CALL_STATUS, viewsDirsCount = 0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&values_sub); - ZVAL_UNDEF(&ttl_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_6$$5); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(values) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(ttl) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&activeRenderPath); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2$$4); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &values, &ttl); - if (!ttl) { - ttl = &ttl_sub; - ttl = &__$null; - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkeys", NULL, 0, values); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getviewsdirs", NULL, 0); zephir_check_call_status(); - result = 1; - zephir_is_iterable(values, 0, "phalcon/Cache/AbstractCache.zep", 229); - if (Z_TYPE_P(values) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(values), _2, _3, _0) - { - ZEPHIR_INIT_NVAR(&key); - if (_3 != NULL) { - ZVAL_STR_COPY(&key, _3); - } else { - ZVAL_LONG(&key, _2); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0); - ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "set", &_5, 0, &key, &value, ttl); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_4$$3)) { - result = 0; - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, values, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, values, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&key, values, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, values, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_6$$5, this_ptr, "set", &_7, 0, &key, &value, ttl); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_6$$5)) { - result = 0; - } - ZEPHIR_CALL_METHOD(NULL, values, "next", NULL, 0); - zephir_check_call_status(); + viewsDirsCount = zephir_fast_count_int(&_0); + zephir_memory_observe(&activeRenderPath); + zephir_read_property(&activeRenderPath, this_ptr, ZEND_STRL("activeRenderPaths"), PH_NOISY_CC); + if (viewsDirsCount == 1) { + _1$$3 = Z_TYPE_P(&activeRenderPath) == IS_ARRAY; + if (_1$$3) { + _1$$3 = ((zephir_fast_count_int(&activeRenderPath)) ? 1 : 0); + } + if (_1$$3) { + zephir_array_fetch_long(&_2$$4, &activeRenderPath, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/View.zep", 339); + ZEPHIR_CPY_WRT(&activeRenderPath, &_2$$4); } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - RETURN_MM_BOOL(result); + if (Z_TYPE_P(&activeRenderPath) == IS_NULL) { + ZEPHIR_INIT_NVAR(&activeRenderPath); + ZVAL_STRING(&activeRenderPath, ""); + } + RETURN_CCTOR(&activeRenderPath); } -static PHP_METHOD(Phalcon_Cache_AbstractCache, getExceptionClass) +static PHP_METHOD(Phalcon_Mvc_View, getBasePath) { -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - + RETURN_MEMBER(getThis(), "basePath"); +} -ZEPHIR_INIT_CLASS(Phalcon_Cache_AdapterFactory) +static PHP_METHOD(Phalcon_Mvc_View, getContent) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache, AdapterFactory, phalcon, cache_adapterfactory, phalcon_factory_abstractfactory_ce, phalcon_cache_adapterfactory_method_entry, 0); - zend_declare_property_null(phalcon_cache_adapterfactory_ce, SL("serializerFactory"), ZEND_ACC_PRIVATE); - return SUCCESS; + RETURN_MEMBER(getThis(), "content"); } -static PHP_METHOD(Phalcon_Cache_AdapterFactory, __construct) +static PHP_METHOD(Phalcon_Mvc_View, getControllerName) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval services; - zval *factory, factory_sub, *services_param = NULL; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&factory_sub); - ZVAL_UNDEF(&services); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_storage_serializerfactory_ce) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(services) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &factory, &services_param); - if (!services_param) { - ZEPHIR_INIT_VAR(&services); - array_init(&services); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("serializerFactory"), factory); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MEMBER(getThis(), "controllerName"); } -static PHP_METHOD(Phalcon_Cache_AdapterFactory, newInstance) +static PHP_METHOD(Phalcon_Mvc_View, getCurrentRenderLevel) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval options, _0; - zval *name_param = NULL, *options_param = NULL, definition, _1; - zval name; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&definition); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(name) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &name_param, &options_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); - } - ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 2, 0); - zephir_memory_observe(&_1); - zephir_read_property(&_1, this_ptr, ZEND_STRL("serializerFactory"), PH_NOISY_CC); - zephir_array_fast_append(&_0, &_1); - zephir_array_fast_append(&_0, &options); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(return_value, &definition, &_0); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MEMBER(getThis(), "currentRenderLevel"); } -static PHP_METHOD(Phalcon_Cache_AdapterFactory, getExceptionClass) +static PHP_METHOD(Phalcon_Mvc_View, getRegisteredEngines) { - RETURN_STRING("Phalcon\\Cache\\Exception\\Exception"); + RETURN_MEMBER(getThis(), "registeredEngines"); } -static PHP_METHOD(Phalcon_Cache_AdapterFactory, getServices) +static PHP_METHOD(Phalcon_Mvc_View, getRenderLevel) { - zephir_create_array(return_value, 6, 0); - add_assoc_stringl_ex(return_value, SL("apcu"), SL("Phalcon\\Cache\\Adapter\\Apcu")); - add_assoc_stringl_ex(return_value, SL("libmemcached"), SL("Phalcon\\Cache\\Adapter\\Libmemcached")); - add_assoc_stringl_ex(return_value, SL("memory"), SL("Phalcon\\Cache\\Adapter\\Memory")); - add_assoc_stringl_ex(return_value, SL("redis"), SL("Phalcon\\Cache\\Adapter\\Redis")); - add_assoc_stringl_ex(return_value, SL("stream"), SL("Phalcon\\Cache\\Adapter\\Stream")); - add_assoc_stringl_ex(return_value, SL("weak"), SL("Phalcon\\Cache\\Adapter\\Weak")); - return; + RETURN_MEMBER(getThis(), "renderLevel"); } +static PHP_METHOD(Phalcon_Mvc_View, getEventsManager) +{ + RETURN_MEMBER(getThis(), "eventsManager"); +} - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Cache_Cache) +static PHP_METHOD(Phalcon_Mvc_View, getLayout) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache, Cache, phalcon, cache_cache, phalcon_cache_abstractcache_ce, phalcon_cache_cache_method_entry, 0); - return SUCCESS; + RETURN_MEMBER(getThis(), "layout"); } -static PHP_METHOD(Phalcon_Cache_Cache, clear) +static PHP_METHOD(Phalcon_Mvc_View, getLayoutsDir) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "doclear", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MEMBER(getThis(), "layoutsDir"); } -static PHP_METHOD(Phalcon_Cache_Cache, delete) +static PHP_METHOD(Phalcon_Mvc_View, getMainView) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL; - zval key; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - zephir_get_strval(&key, key_param); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dodelete", NULL, 0, &key); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MEMBER(getThis(), "mainView"); } -static PHP_METHOD(Phalcon_Cache_Cache, deleteMultiple) +static PHP_METHOD(Phalcon_Mvc_View, getParamsToView) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *keys, keys_sub; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&keys_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(keys) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &keys); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dodeletemultiple", NULL, 0, keys); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MEMBER(getThis(), "viewParams"); } -static PHP_METHOD(Phalcon_Cache_Cache, get) +static PHP_METHOD(Phalcon_Mvc_View, getPartial) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null; - zval key; + zval *partialPath_param = NULL, *params = NULL, params_sub, __$null; + zval partialPath; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&defaultValue_sub); + ZVAL_UNDEF(&partialPath); + ZVAL_UNDEF(¶ms_sub); ZVAL_NULL(&__$null); bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(key) + Z_PARAM_STR(partialPath) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) + Z_PARAM_ZVAL_OR_NULL(params) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key_param, &defaultValue); - zephir_get_strval(&key, key_param); - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; + zephir_fetch_params(1, 1, 1, &partialPath_param, ¶ms); + if (UNEXPECTED(Z_TYPE_P(partialPath_param) != IS_STRING && Z_TYPE_P(partialPath_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'partialPath' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "doget", NULL, 0, &key, defaultValue); + if (EXPECTED(Z_TYPE_P(partialPath_param) == IS_STRING)) { + zephir_get_strval(&partialPath, partialPath_param); + } else { + ZEPHIR_INIT_VAR(&partialPath); + } + if (!params) { + params = ¶ms_sub; + params = &__$null; + } + ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 387); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "partial", NULL, 0, &partialPath, params); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", NULL, 394); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Cache_Cache, getMultiple) +static PHP_METHOD(Phalcon_Mvc_View, getPartialsDir) +{ + + RETURN_MEMBER(getThis(), "partialsDir"); +} + +static PHP_METHOD(Phalcon_Mvc_View, getRender) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *keys, keys_sub, *defaultValue = NULL, defaultValue_sub, __$null; + zval params, _1$$3; + zval *controllerName_param = NULL, *actionName_param = NULL, *params_param = NULL, *configCallback = NULL, configCallback_sub, __$null, view, _0$$3; + zval controllerName, actionName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&keys_sub); - ZVAL_UNDEF(&defaultValue_sub); + ZVAL_UNDEF(&controllerName); + ZVAL_UNDEF(&actionName); + ZVAL_UNDEF(&configCallback_sub); ZVAL_NULL(&__$null); + ZVAL_UNDEF(&view); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&_1$$3); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(keys) + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_STR(controllerName) + Z_PARAM_STR(actionName) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) + Z_PARAM_ARRAY(params) + Z_PARAM_ZVAL_OR_NULL(configCallback) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &keys, &defaultValue); - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; + zephir_fetch_params(1, 2, 2, &controllerName_param, &actionName_param, ¶ms_param, &configCallback); + if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dogetmultiple", NULL, 0, keys, defaultValue); + if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { + zephir_get_strval(&controllerName, controllerName_param); + } else { + ZEPHIR_INIT_VAR(&controllerName); + } + if (UNEXPECTED(Z_TYPE_P(actionName_param) != IS_STRING && Z_TYPE_P(actionName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(actionName_param) == IS_STRING)) { + zephir_get_strval(&actionName, actionName_param); + } else { + ZEPHIR_INIT_VAR(&actionName); + } + if (!params_param) { + ZEPHIR_INIT_VAR(¶ms); + array_init(¶ms); + } else { + zephir_get_arrval(¶ms, params_param); + } + if (!configCallback) { + configCallback = &configCallback_sub; + configCallback = &__$null; + } + ZEPHIR_INIT_VAR(&view); + if (zephir_clone(&view, this_ptr) == FAILURE) { + RETURN_MM(); + } + ZEPHIR_CALL_METHOD(NULL, &view, "reset", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &view, "setvars", NULL, 0, ¶ms); + zephir_check_call_status(); + if (Z_TYPE_P(configCallback) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_0$$3); + ZEPHIR_INIT_VAR(&_1$$3); + zephir_create_array(&_1$$3, 1, 0); + zephir_array_fast_append(&_1$$3, &view); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_0$$3, configCallback, &_1$$3); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(NULL, &view, "start", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &view, "render", NULL, 0, &controllerName, &actionName); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &view, "finish", NULL, 0); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(&view, "getcontent", NULL, 0); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Cache_Cache, has) +static PHP_METHOD(Phalcon_Mvc_View, getVar) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL; + zval *key_param = NULL, value, _0; zval key; zval *this_ptr = getThis(); ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); zephir_fetch_params(1, 1, 0, &key_param); - zephir_get_strval(&key, key_param); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dohas", NULL, 0, &key); - zephir_check_call_status(); - RETURN_MM(); + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); + } else { + ZEPHIR_INIT_VAR(&key); + } + zephir_memory_observe(&value); + zephir_read_property(&_0, this_ptr, ZEND_STRL("viewParams"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&value, &_0, &key, 0))) { + RETURN_MM_NULL(); + } + RETURN_CCTOR(&value); } -static PHP_METHOD(Phalcon_Cache_Cache, set) +static PHP_METHOD(Phalcon_Mvc_View, getViewsDir) +{ + + RETURN_MEMBER(getThis(), "viewsDirs"); +} + +static PHP_METHOD(Phalcon_Mvc_View, getViewsDirs) { + zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub, *ttl = NULL, ttl_sub, __$null; - zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&ttl_sub); - ZVAL_NULL(&__$null); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(ttl) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &key_param, &value, &ttl); - zephir_get_strval(&key, key_param); - if (!ttl) { - ttl = &ttl_sub; - ttl = &__$null; + + zephir_memory_observe(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("viewsDirs"), PH_NOISY_CC); + if (Z_TYPE_P(&_0) == IS_STRING) { + zephir_create_array(return_value, 1, 0); + zephir_memory_observe(&_1$$3); + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("viewsDirs"), PH_NOISY_CC); + zephir_array_fast_append(return_value, &_1$$3); + RETURN_MM(); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "doset", NULL, 0, &key, value, ttl); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MM_MEMBER(getThis(), "viewsDirs"); } -static PHP_METHOD(Phalcon_Cache_Cache, setMultiple) +static PHP_METHOD(Phalcon_Mvc_View, has) { + zend_string *_9$$4, *_16$$9; + zend_ulong _8$$4, _15$$9; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *values, values_sub, *ttl = NULL, ttl_sub, __$null; + zval *view_param = NULL, basePath, viewsDir, engines, extension, _0, _2, *_3, _4, _1$$3, _5$$4, *_6$$4, _7$$4, _10$$5, _11$$7, _12$$9, *_13$$9, _14$$9, _17$$10, _18$$12; + zval view; zval *this_ptr = getThis(); - ZVAL_UNDEF(&values_sub); - ZVAL_UNDEF(&ttl_sub); - ZVAL_NULL(&__$null); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(values) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(ttl) + ZVAL_UNDEF(&view); + ZVAL_UNDEF(&basePath); + ZVAL_UNDEF(&viewsDir); + ZVAL_UNDEF(&engines); + ZVAL_UNDEF(&extension); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_10$$5); + ZVAL_UNDEF(&_11$$7); + ZVAL_UNDEF(&_12$$9); + ZVAL_UNDEF(&_14$$9); + ZVAL_UNDEF(&_17$$10); + ZVAL_UNDEF(&_18$$12); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(view) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &values, &ttl); - if (!ttl) { - ttl = &ttl_sub; - ttl = &__$null; + zephir_fetch_params(1, 1, 0, &view_param); + if (UNEXPECTED(Z_TYPE_P(view_param) != IS_STRING && Z_TYPE_P(view_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'view' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dosetmultiple", NULL, 0, values, ttl); + if (EXPECTED(Z_TYPE_P(view_param) == IS_STRING)) { + zephir_get_strval(&view, view_param); + } else { + ZEPHIR_INIT_VAR(&view); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("basePath"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&basePath, &_0); + zephir_memory_observe(&engines); + zephir_read_property(&engines, this_ptr, ZEND_STRL("registeredEngines"), PH_NOISY_CC); + if (ZEPHIR_IS_EMPTY(&engines)) { + ZEPHIR_INIT_VAR(&_1$$3); + zephir_create_array(&_1$$3, 1, 0); + add_assoc_stringl_ex(&_1$$3, SL(".phtml"), SL("Phalcon\\Mvc\\View\\Engine\\Php")); + ZEPHIR_CPY_WRT(&engines, &_1$$3); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "registerengines", NULL, 0, &engines); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(&_2, this_ptr, "getviewsdirs", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + zephir_is_iterable(&_2, 0, "phalcon/Mvc/View.zep", 599); + if (Z_TYPE_P(&_2) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_2), _3) + { + ZEPHIR_INIT_NVAR(&viewsDir); + ZVAL_COPY(&viewsDir, _3); + ZEPHIR_INIT_NVAR(&_5$$4); + zephir_is_iterable(&engines, 0, "phalcon/Mvc/View.zep", 597); + if (Z_TYPE_P(&engines) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&engines), _8$$4, _9$$4, _6$$4) + { + ZEPHIR_INIT_NVAR(&extension); + if (_9$$4 != NULL) { + ZVAL_STR_COPY(&extension, _9$$4); + } else { + ZVAL_LONG(&extension, _8$$4); + } + ZEPHIR_INIT_NVAR(&_5$$4); + ZVAL_COPY(&_5$$4, _6$$4); + ZEPHIR_INIT_NVAR(&_10$$5); + ZEPHIR_CONCAT_VVVV(&_10$$5, &basePath, &viewsDir, &view, &extension); + if ((zephir_file_exists(&_10$$5) == SUCCESS)) { + RETURN_MM_BOOL(1); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &engines, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_7$$4, &engines, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_7$$4)) { + break; + } + ZEPHIR_CALL_METHOD(&extension, &engines, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5$$4, &engines, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_11$$7); + ZEPHIR_CONCAT_VVVV(&_11$$7, &basePath, &viewsDir, &view, &extension); + if ((zephir_file_exists(&_11$$7) == SUCCESS)) { + RETURN_MM_BOOL(1); + } + ZEPHIR_CALL_METHOD(NULL, &engines, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&_5$$4); + ZEPHIR_INIT_NVAR(&extension); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_2, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_4, &_2, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_4)) { + break; + } + ZEPHIR_CALL_METHOD(&viewsDir, &_2, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_12$$9); + zephir_is_iterable(&engines, 0, "phalcon/Mvc/View.zep", 597); + if (Z_TYPE_P(&engines) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&engines), _15$$9, _16$$9, _13$$9) + { + ZEPHIR_INIT_NVAR(&extension); + if (_16$$9 != NULL) { + ZVAL_STR_COPY(&extension, _16$$9); + } else { + ZVAL_LONG(&extension, _15$$9); + } + ZEPHIR_INIT_NVAR(&_12$$9); + ZVAL_COPY(&_12$$9, _13$$9); + ZEPHIR_INIT_NVAR(&_17$$10); + ZEPHIR_CONCAT_VVVV(&_17$$10, &basePath, &viewsDir, &view, &extension); + if ((zephir_file_exists(&_17$$10) == SUCCESS)) { + RETURN_MM_BOOL(1); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &engines, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_14$$9, &engines, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_14$$9)) { + break; + } + ZEPHIR_CALL_METHOD(&extension, &engines, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_12$$9, &engines, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_18$$12); + ZEPHIR_CONCAT_VVVV(&_18$$12, &basePath, &viewsDir, &view, &extension); + if ((zephir_file_exists(&_18$$12) == SUCCESS)) { + RETURN_MM_BOOL(1); + } + ZEPHIR_CALL_METHOD(NULL, &engines, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&_12$$9); + ZEPHIR_INIT_NVAR(&extension); + ZEPHIR_CALL_METHOD(NULL, &_2, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&viewsDir); + RETURN_MM_BOOL(0); } -static PHP_METHOD(Phalcon_Cache_Cache, getExceptionClass) +static PHP_METHOD(Phalcon_Mvc_View, isDisabled) { - RETURN_STRING("Phalcon\\Cache\\Exception\\InvalidArgumentException"); + RETURN_MEMBER(getThis(), "disabled"); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Cache_CacheFactory) +static PHP_METHOD(Phalcon_Mvc_View, partial) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache, CacheFactory, phalcon, cache_cachefactory, phalcon_factory_abstractconfigfactory_ce, phalcon_cache_cachefactory_method_entry, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *partialPath_param = NULL, *params = NULL, params_sub, __$null, viewParams, _3, _4, _5, _6, _7, _0$$3, _1$$3, _2$$3; + zval partialPath; + zval *this_ptr = getThis(); - zend_declare_property_null(phalcon_cache_cachefactory_ce, SL("adapterFactory"), ZEND_ACC_PROTECTED); - return SUCCESS; + ZVAL_UNDEF(&partialPath); + ZVAL_UNDEF(¶ms_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&viewParams); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(partialPath) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(params) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &partialPath_param, ¶ms); + if (UNEXPECTED(Z_TYPE_P(partialPath_param) != IS_STRING && Z_TYPE_P(partialPath_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'partialPath' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(partialPath_param) == IS_STRING)) { + zephir_get_strval(&partialPath, partialPath_param); + } else { + ZEPHIR_INIT_VAR(&partialPath); + } + if (!params) { + params = ¶ms_sub; + params = &__$null; + } + if (Z_TYPE_P(params) == IS_ARRAY) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("viewParams"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&viewParams, &_0$$3); + ZEPHIR_INIT_VAR(&_1$$3); + zephir_fast_array_merge(&_1$$3, &viewParams, params); + zephir_update_property_zval(this_ptr, ZEND_STRL("viewParams"), &_1$$3); + ZEPHIR_INIT_VAR(&_2$$3); + ZEPHIR_CREATE_SYMBOL_TABLE(); + + } + ZEPHIR_CALL_METHOD(&_3, this_ptr, "loadtemplateengines", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_4, this_ptr, ZEND_STRL("partialsDir"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_5); + ZEPHIR_CONCAT_VV(&_5, &_4, &partialPath); + ZVAL_BOOL(&_6, 0); + ZVAL_BOOL(&_7, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &_3, &_5, &_6, &_7); + zephir_check_call_status(); + if (Z_TYPE_P(params) == IS_ARRAY) { + zephir_update_property_zval(this_ptr, ZEND_STRL("viewParams"), &viewParams); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Cache_CacheFactory, __construct) +static PHP_METHOD(Phalcon_Mvc_View, pick) { - zval *factory, factory_sub; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *renderView, renderView_sub, pickView, layout, parts, _0$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&factory_sub); + ZVAL_UNDEF(&renderView_sub); + ZVAL_UNDEF(&pickView); + ZVAL_UNDEF(&layout); + ZVAL_UNDEF(&parts); + ZVAL_UNDEF(&_0$$4); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_cache_adapterfactory_ce) + Z_PARAM_ZVAL(renderView) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &factory); - zephir_update_property_zval(this_ptr, ZEND_STRL("adapterFactory"), factory); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &renderView); + if (Z_TYPE_P(renderView) == IS_ARRAY) { + ZEPHIR_CPY_WRT(&pickView, renderView); + } else { + ZEPHIR_INIT_VAR(&layout); + ZVAL_NULL(&layout); + if (zephir_memnstr_str(renderView, SL("/"), "phalcon/Mvc/View.zep", 701)) { + ZEPHIR_INIT_VAR(&parts); + zephir_fast_explode_str(&parts, SL("/"), renderView, LONG_MAX); + ZEPHIR_OBS_NVAR(&layout); + zephir_array_fetch_long(&layout, &parts, 0, PH_NOISY, "phalcon/Mvc/View.zep", 703); + } + ZEPHIR_INIT_VAR(&_0$$4); + zephir_create_array(&_0$$4, 1, 0); + zephir_array_fast_append(&_0$$4, renderView); + ZEPHIR_CPY_WRT(&pickView, &_0$$4); + if (Z_TYPE_P(&layout) != IS_NULL) { + zephir_array_append(&pickView, &layout, PH_SEPARATE, "phalcon/Mvc/View.zep", 709); + } + } + zephir_update_property_zval(this_ptr, ZEND_STRL("pickView"), &pickView); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Cache_CacheFactory, load) +static PHP_METHOD(Phalcon_Mvc_View, registerEngines) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *config = NULL, config_sub, name, options, _0, _1; + zval *engines_param = NULL; + zval engines; zval *this_ptr = getThis(); - ZVAL_UNDEF(&config_sub); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&engines); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(config) + Z_PARAM_ARRAY(engines) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &config); - ZEPHIR_SEPARATE_PARAM(config); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfig", NULL, 0, config); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(config, &_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "adapter"); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfigelement", NULL, 0, config, &_1); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(config, &_0); - zephir_memory_observe(&name); - zephir_array_fetch_string(&name, config, SL("adapter"), PH_NOISY, "phalcon/Cache/CacheFactory.zep", 73); - zephir_memory_observe(&options); - if (!(zephir_array_isset_string_fetch(&options, config, SL("options"), 0))) { - ZEPHIR_INIT_NVAR(&options); - array_init(&options); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "newinstance", NULL, 0, &name, &options); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &engines_param); + ZEPHIR_OBS_COPY_OR_DUP(&engines, engines_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("registeredEngines"), &engines); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Cache_CacheFactory, newInstance) +static PHP_METHOD(Phalcon_Mvc_View, render) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval *name_param = NULL, *options_param = NULL, adapter, _0; - zval name; + zval params; + zval *controllerName_param = NULL, *actionName_param = NULL, *params_param = NULL, result; + zval controllerName, actionName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&adapter); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(name) + ZVAL_UNDEF(&controllerName); + ZVAL_UNDEF(&actionName); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(¶ms); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(controllerName) + Z_PARAM_STR(actionName) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + Z_PARAM_ARRAY(params) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &name_param, &options_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + zephir_fetch_params(1, 2, 1, &controllerName_param, &actionName_param, ¶ms_param); + if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { + zephir_get_strval(&controllerName, controllerName_param); } else { - ZEPHIR_INIT_VAR(&name); + ZEPHIR_INIT_VAR(&controllerName); } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); + if (UNEXPECTED(Z_TYPE_P(actionName_param) != IS_STRING && Z_TYPE_P(actionName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(actionName_param) == IS_STRING)) { + zephir_get_strval(&actionName, actionName_param); } else { - ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + ZEPHIR_INIT_VAR(&actionName); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("adapterFactory"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&adapter, &_0, "newinstance", NULL, 0, &name, &options); - zephir_check_call_status(); - object_init_ex(return_value, phalcon_cache_cache_ce); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 189, &adapter); + if (!params_param) { + ZEPHIR_INIT_VAR(¶ms); + array_init(¶ms); + } else { + zephir_get_arrval(¶ms, params_param); + } + ZEPHIR_CALL_METHOD(&result, this_ptr, "processrender", NULL, 0, &controllerName, &actionName, ¶ms); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Cache_CacheFactory, getExceptionClass) -{ - - RETURN_STRING("Phalcon\\Cache\\Exception\\Exception"); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Cache_CacheInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Cache, CacheInterface, phalcon, cache_cacheinterface, phalcon_cache_cacheinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, clear); -ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, delete); -ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, deleteMultiple); -ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, get); -ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, getMultiple); -ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, has); -ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, set); -ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, setMultiple); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Cache_Adapter_AdapterInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Cache\\Adapter, AdapterInterface, phalcon, cache_adapter_adapterinterface, NULL); - - zend_class_implements(phalcon_cache_adapter_adapterinterface_ce, 1, phalcon_storage_adapter_adapterinterface_ce); - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Cache_Adapter_Apcu) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Adapter, Apcu, phalcon, cache_adapter_apcu, phalcon_storage_adapter_apcu_ce, NULL, 0); - - zend_class_implements(phalcon_cache_adapter_apcu_ce, 1, phalcon_cache_adapter_adapterinterface_ce); - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Cache_Adapter_Libmemcached) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Adapter, Libmemcached, phalcon, cache_adapter_libmemcached, phalcon_storage_adapter_libmemcached_ce, NULL, 0); - - zend_class_implements(phalcon_cache_adapter_libmemcached_ce, 1, phalcon_cache_adapter_adapterinterface_ce); - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Cache_Adapter_Memory) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Adapter, Memory, phalcon, cache_adapter_memory, phalcon_storage_adapter_memory_ce, NULL, 0); - - zend_class_implements(phalcon_cache_adapter_memory_ce, 1, phalcon_cache_adapter_adapterinterface_ce); - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Cache_Adapter_Redis) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Adapter, Redis, phalcon, cache_adapter_redis, phalcon_storage_adapter_redis_ce, NULL, 0); - - zend_class_implements(phalcon_cache_adapter_redis_ce, 1, phalcon_cache_adapter_adapterinterface_ce); - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Cache_Adapter_Stream) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Adapter, Stream, phalcon, cache_adapter_stream, phalcon_storage_adapter_stream_ce, NULL, 0); - - zend_class_implements(phalcon_cache_adapter_stream_ce, 1, phalcon_cache_adapter_adapterinterface_ce); - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Cache_Adapter_Weak) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Adapter, Weak, phalcon, cache_adapter_weak, phalcon_storage_adapter_weak_ce, NULL, 0); - - zend_class_implements(phalcon_cache_adapter_weak_ce, 1, phalcon_cache_adapter_adapterinterface_ce); - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Cache_Exception_Exception) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Exception, Exception, phalcon, cache_exception_exception, zend_ce_exception, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Cache_Exception_InvalidArgumentException) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Exception, InvalidArgumentException, phalcon, cache_exception_invalidargumentexception, zend_ce_exception, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Application) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Application, phalcon, mvc_application, phalcon_application_abstractapplication_ce, phalcon_mvc_application_method_entry, 0); - - zend_declare_property_bool(phalcon_mvc_application_ce, SL("implicitView"), 1, ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_application_ce, SL("sendCookies"), 1, ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_application_ce, SL("sendHeaders"), 1, ZEND_ACC_PROTECTED); - return SUCCESS; + if (!(zephir_is_true(&result))) { + RETURN_MM_BOOL(0); + } + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Application, handle) +static PHP_METHOD(Phalcon_Mvc_View, reset) { - zval _17$$20; - zend_class_entry *_6$$7; - zend_bool returnedResponse = 0, _1, _10$$6, _13$$11, _31$$30, _33$$30; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *uri_param = NULL, __$false, container, eventsManager, router, dispatcher, response, view, module, moduleObject, moduleName, className, path, implicitView, controller, possibleResponse, renderStatus, matchedRoute, match, _0, _2, _3, _4, _21, _22, _23, _24, _41, _5$$7, _7$$6, _8$$8, _9$$8, _11$$12, _12$$12, _14$$18, _15$$18, _16$$15, _18$$22, _19$$23, _20$$23, _25$$25, _26$$25, _27$$27, _28$$27, _29$$29, _30$$29, _32$$31, _34$$34, _35$$35, _36$$35, _37$$38, _38$$38, _39$$39, _40$$40; - zval uri; + zval __$true, __$false, _0, _1, _2; zval *this_ptr = getThis(); - ZVAL_UNDEF(&uri); + ZVAL_BOOL(&__$true, 1); ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&router); - ZVAL_UNDEF(&dispatcher); - ZVAL_UNDEF(&response); - ZVAL_UNDEF(&view); - ZVAL_UNDEF(&module); - ZVAL_UNDEF(&moduleObject); - ZVAL_UNDEF(&moduleName); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&path); - ZVAL_UNDEF(&implicitView); - ZVAL_UNDEF(&controller); - ZVAL_UNDEF(&possibleResponse); - ZVAL_UNDEF(&renderStatus); - ZVAL_UNDEF(&matchedRoute); - ZVAL_UNDEF(&match); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_21); - ZVAL_UNDEF(&_22); - ZVAL_UNDEF(&_23); - ZVAL_UNDEF(&_24); - ZVAL_UNDEF(&_41); - ZVAL_UNDEF(&_5$$7); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_8$$8); - ZVAL_UNDEF(&_9$$8); - ZVAL_UNDEF(&_11$$12); - ZVAL_UNDEF(&_12$$12); - ZVAL_UNDEF(&_14$$18); - ZVAL_UNDEF(&_15$$18); - ZVAL_UNDEF(&_16$$15); - ZVAL_UNDEF(&_18$$22); - ZVAL_UNDEF(&_19$$23); - ZVAL_UNDEF(&_20$$23); - ZVAL_UNDEF(&_25$$25); - ZVAL_UNDEF(&_26$$25); - ZVAL_UNDEF(&_27$$27); - ZVAL_UNDEF(&_28$$27); - ZVAL_UNDEF(&_29$$29); - ZVAL_UNDEF(&_30$$29); - ZVAL_UNDEF(&_32$$31); - ZVAL_UNDEF(&_34$$34); - ZVAL_UNDEF(&_35$$35); - ZVAL_UNDEF(&_36$$35); - ZVAL_UNDEF(&_37$$38); - ZVAL_UNDEF(&_38$$38); - ZVAL_UNDEF(&_39$$39); - ZVAL_UNDEF(&_40$$40); - ZVAL_UNDEF(&_17$$20); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(uri) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &uri_param); - if (UNEXPECTED(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 of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(uri_param) == IS_STRING)) { - zephir_get_strval(&uri, uri_param); + + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("disabled"), &__$true); } else { - ZEPHIR_INIT_VAR(&uri); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_application_exception_ce, "A dependency injection container is required to access internal services", "phalcon/Mvc/Application.zep", 100); - return; - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - _1 = Z_TYPE_P(&eventsManager) != IS_NULL; - if (_1) { - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "application:boot"); - ZEPHIR_CALL_METHOD(&_2, &eventsManager, "fire", NULL, 0, &_3, this_ptr); - zephir_check_call_status(); - _1 = ZEPHIR_IS_FALSE_IDENTICAL(&_2); - } - if (_1) { - RETURN_MM_BOOL(0); - } - ZEPHIR_INIT_NVAR(&_3); - ZVAL_STRING(&_3, "router"); - ZEPHIR_CALL_METHOD(&_4, &container, "getshared", NULL, 0, &_3); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&router, &_4); - ZEPHIR_CALL_METHOD(NULL, &router, "handle", NULL, 0, &uri); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&matchedRoute, &router, "getmatchedroute", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&matchedRoute) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(&match, &matchedRoute, "getmatch", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&match) != IS_NULL) { - if (zephir_is_instance_of(&match, SL("Closure"))) { - _6$$7 = zephir_fetch_class_str_ex(SL("Closure"), ZEND_FETCH_CLASS_AUTO); - ZEPHIR_CALL_CE_STATIC(&_5$$7, _6$$7, "bind", NULL, 0, &match, &container); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&match, &_5$$7); - } - ZEPHIR_CALL_METHOD(&_7$$6, &router, "getparams", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&possibleResponse); - ZEPHIR_CALL_USER_FUNC_ARRAY(&possibleResponse, &match, &_7$$6); - zephir_check_call_status(); - if (Z_TYPE_P(&possibleResponse) == IS_STRING) { - ZEPHIR_INIT_VAR(&_9$$8); - ZVAL_STRING(&_9$$8, "response"); - ZEPHIR_CALL_METHOD(&_8$$8, &container, "getshared", NULL, 0, &_9$$8); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&response, &_8$$8); - ZEPHIR_CALL_METHOD(NULL, &response, "setcontent", NULL, 0, &possibleResponse); - zephir_check_call_status(); - RETURN_CCTOR(&response); - } - _10$$6 = Z_TYPE_P(&possibleResponse) == IS_OBJECT; - if (_10$$6) { - _10$$6 = zephir_instance_of_ev(&possibleResponse, phalcon_http_responseinterface_ce); - } - if (_10$$6) { - ZEPHIR_CALL_METHOD(NULL, &possibleResponse, "sendheaders", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &possibleResponse, "sendcookies", NULL, 0); - zephir_check_call_status(); - RETURN_CCTOR(&possibleResponse); - } - } - } - ZEPHIR_CALL_METHOD(&moduleName, &router, "getmodulename", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&moduleName))) { - ZEPHIR_OBS_NVAR(&moduleName); - zephir_read_property(&moduleName, this_ptr, ZEND_STRL("defaultModule"), PH_NOISY_CC); - } - ZEPHIR_INIT_VAR(&moduleObject); - ZVAL_NULL(&moduleObject); - if (zephir_is_true(&moduleName)) { - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_12$$12); - ZVAL_STRING(&_12$$12, "application:beforeStartModule"); - ZEPHIR_CALL_METHOD(&_11$$12, &eventsManager, "fire", NULL, 0, &_12$$12, this_ptr, &moduleName); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_11$$12)) { - RETURN_MM_BOOL(0); - } - } - ZEPHIR_CALL_METHOD(&module, this_ptr, "getmodule", NULL, 0, &moduleName); - zephir_check_call_status(); - _13$$11 = Z_TYPE_P(&module) != IS_ARRAY; - if (_13$$11) { - _13$$11 = Z_TYPE_P(&module) != IS_OBJECT; - } - if (UNEXPECTED(_13$$11)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_application_exception_ce, "Invalid module definition", "phalcon/Mvc/Application.zep", 196); - return; - } - if (Z_TYPE_P(&module) == IS_ARRAY) { - zephir_memory_observe(&className); - if (!(zephir_array_isset_string_fetch(&className, &module, SL("className"), 0))) { - ZEPHIR_INIT_NVAR(&className); - ZVAL_STRING(&className, "Module"); - } - zephir_memory_observe(&path); - if (zephir_array_isset_string_fetch(&path, &module, SL("path"), 0)) { - if (UNEXPECTED(!((zephir_file_exists(&path) == SUCCESS)))) { - ZEPHIR_INIT_VAR(&_14$$18); - object_init_ex(&_14$$18, phalcon_mvc_application_exception_ce); - ZEPHIR_INIT_VAR(&_15$$18); - ZEPHIR_CONCAT_SVS(&_15$$18, "Module definition path '", &path, "' doesn't exist"); - ZEPHIR_CALL_METHOD(NULL, &_14$$18, "__construct", NULL, 33, &_15$$18); - zephir_check_call_status(); - zephir_throw_exception_debug(&_14$$18, "phalcon/Mvc/Application.zep", 218); - ZEPHIR_MM_RESTORE(); - return; - } - if (!(zephir_class_exists(&className, zephir_is_true(&__$false) ))) { - if (zephir_require_once_zval(&path) == FAILURE) { - RETURN_MM_NULL(); - } - } - } - ZEPHIR_CALL_METHOD(&_16$$15, &container, "get", NULL, 0, &className); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&moduleObject, &_16$$15); - ZEPHIR_CALL_METHOD(NULL, &moduleObject, "registerautoloaders", NULL, 0, &container); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &moduleObject, "registerservices", NULL, 0, &container); - zephir_check_call_status(); - } else { - if (UNEXPECTED(!((zephir_is_instance_of(&module, SL("Closure")))))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_application_exception_ce, "Invalid module definition", "phalcon/Mvc/Application.zep", 239); - return; - } - ZEPHIR_INIT_VAR(&_17$$20); - zephir_create_array(&_17$$20, 1, 0); - zephir_array_fast_append(&_17$$20, &container); - ZEPHIR_INIT_NVAR(&moduleObject); - ZEPHIR_CALL_USER_FUNC_ARRAY(&moduleObject, &module, &_17$$20); - zephir_check_call_status(); - } - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_18$$22); - ZVAL_STRING(&_18$$22, "application:afterStartModule"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_18$$22, this_ptr, &moduleObject); - zephir_check_call_status(); - } - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("implicitView"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&implicitView, &_0); - if (ZEPHIR_IS_TRUE_IDENTICAL(&implicitView)) { - ZEPHIR_INIT_VAR(&_20$$23); - ZVAL_STRING(&_20$$23, "view"); - ZEPHIR_CALL_METHOD(&_19$$23, &container, "getshared", NULL, 0, &_20$$23); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&view, &_19$$23); - } - ZEPHIR_INIT_NVAR(&_3); - ZVAL_STRING(&_3, "dispatcher"); - ZEPHIR_CALL_METHOD(&_4, &container, "getshared", NULL, 0, &_3); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&dispatcher, &_4); - ZEPHIR_CALL_METHOD(&_4, &router, "getmodulename", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setmodulename", NULL, 0, &_4); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_21, &router, "getnamespacename", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setnamespacename", NULL, 0, &_21); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_22, &router, "getcontrollername", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setcontrollername", NULL, 0, &_22); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_23, &router, "getactionname", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setactionname", NULL, 0, &_23); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_24, &router, "getparams", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setparams", NULL, 0, &_24); - zephir_check_call_status(); - if (ZEPHIR_IS_TRUE_IDENTICAL(&implicitView)) { - ZEPHIR_CALL_METHOD(NULL, &view, "start", NULL, 0); - zephir_check_call_status(); - } - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_26$$25); - ZVAL_STRING(&_26$$25, "application:beforeHandleRequest"); - ZEPHIR_CALL_METHOD(&_25$$25, &eventsManager, "fire", NULL, 0, &_26$$25, this_ptr, &dispatcher); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_25$$25)) { - RETURN_MM_BOOL(0); - } + zephir_update_property_zval(this_ptr, ZEND_STRL("disabled"), &__$false); } - ZEPHIR_CALL_METHOD(&controller, &dispatcher, "dispatch", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&possibleResponse, &dispatcher, "getreturnedvalue", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&possibleResponse)) { - ZEPHIR_INIT_VAR(&_28$$27); - ZVAL_STRING(&_28$$27, "response"); - ZEPHIR_CALL_METHOD(&_27$$27, &container, "getshared", NULL, 0, &_28$$27); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&response, &_27$$27); + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("engines"), &__$true); } else { - if (Z_TYPE_P(&possibleResponse) == IS_STRING) { - ZEPHIR_INIT_VAR(&_30$$29); - ZVAL_STRING(&_30$$29, "response"); - ZEPHIR_CALL_METHOD(&_29$$29, &container, "getshared", NULL, 0, &_30$$29); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&response, &_29$$29); - ZEPHIR_CALL_METHOD(NULL, &response, "setcontent", NULL, 0, &possibleResponse); - zephir_check_call_status(); - } else { - _31$$30 = (Z_TYPE_P(&possibleResponse) == IS_OBJECT); - if (_31$$30) { - _31$$30 = (zephir_instance_of_ev(&possibleResponse, phalcon_http_responseinterface_ce)); - } - returnedResponse = _31$$30; - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_32$$31); - ZVAL_STRING(&_32$$31, "application:afterHandleRequest"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_32$$31, this_ptr, &controller); - zephir_check_call_status(); - } - _33$$30 = returnedResponse == 0; - if (_33$$30) { - _33$$30 = ZEPHIR_IS_TRUE_IDENTICAL(&implicitView); - } - if (_33$$30) { - if (Z_TYPE_P(&controller) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&renderStatus); - ZVAL_BOOL(&renderStatus, 1); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_34$$34); - ZVAL_STRING(&_34$$34, "application:viewRender"); - ZEPHIR_CALL_METHOD(&renderStatus, &eventsManager, "fire", NULL, 0, &_34$$34, this_ptr, &view); - zephir_check_call_status(); - } - if (!ZEPHIR_IS_FALSE_IDENTICAL(&renderStatus)) { - ZEPHIR_CALL_METHOD(&_35$$35, &dispatcher, "getcontrollername", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_36$$35, &dispatcher, "getactionname", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &view, "render", NULL, 0, &_35$$35, &_36$$35); - zephir_check_call_status(); - } - } - } - if (ZEPHIR_IS_TRUE_IDENTICAL(&implicitView)) { - ZEPHIR_CALL_METHOD(NULL, &view, "finish", NULL, 0); - zephir_check_call_status(); - } - if (returnedResponse == 1) { - ZEPHIR_CPY_WRT(&response, &possibleResponse); - } else { - ZEPHIR_INIT_VAR(&_38$$38); - ZVAL_STRING(&_38$$38, "response"); - ZEPHIR_CALL_METHOD(&_37$$38, &container, "getshared", NULL, 0, &_38$$38); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&response, &_37$$38); - if (ZEPHIR_IS_TRUE_IDENTICAL(&implicitView)) { - ZEPHIR_CALL_METHOD(&_39$$39, &view, "getcontent", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &response, "setcontent", NULL, 0, &_39$$39); - zephir_check_call_status(); - } - } - } - } - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_40$$40); - ZVAL_STRING(&_40$$40, "application:beforeSendResponse"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_40$$40, this_ptr, &response); - zephir_check_call_status(); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("sendHeaders"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_0)) { - ZEPHIR_CALL_METHOD(NULL, &response, "sendheaders", NULL, 0); - zephir_check_call_status(); - } - zephir_read_property(&_41, this_ptr, ZEND_STRL("sendCookies"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_41)) { - ZEPHIR_CALL_METHOD(NULL, &response, "sendcookies", NULL, 0); - zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("engines"), &__$false); } - RETURN_CCTOR(&response); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, 5); + zephir_update_property_zval(this_ptr, ZEND_STRL("renderLevel"), &_0); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, ""); + zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &_1); + ZEPHIR_INIT_NVAR(&_1); + array_init(&_1); + zephir_update_property_zval(this_ptr, ZEND_STRL("templatesBefore"), &_1); + ZEPHIR_INIT_VAR(&_2); + array_init(&_2); + zephir_update_property_zval(this_ptr, ZEND_STRL("templatesAfter"), &_2); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Application, sendCookiesOnHandleRequest) +static PHP_METHOD(Phalcon_Mvc_View, setBasePath) { - zval *sendCookies_param = NULL, __$true, __$false; - zend_bool sendCookies; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *basePath_param = NULL; + zval basePath; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&basePath); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(sendCookies) + Z_PARAM_STR(basePath) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &sendCookies_param); - if (sendCookies) { - zephir_update_property_zval(this_ptr, ZEND_STRL("sendCookies"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("sendCookies"), &__$false); - } - RETURN_THISW(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &basePath_param); + zephir_get_strval(&basePath, basePath_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("basePath"), &basePath); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Application, sendHeadersOnHandleRequest) +static PHP_METHOD(Phalcon_Mvc_View, setContent) { - zval *sendHeaders_param = NULL, __$true, __$false; - zend_bool sendHeaders; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *content_param = NULL; + zval content; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&content); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(sendHeaders) + Z_PARAM_STR(content) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &sendHeaders_param); - if (sendHeaders) { - zephir_update_property_zval(this_ptr, ZEND_STRL("sendHeaders"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("sendHeaders"), &__$false); - } - RETURN_THISW(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &content_param); + zephir_get_strval(&content, content_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &content); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Application, useImplicitView) +static PHP_METHOD(Phalcon_Mvc_View, setEventsManager) { - zval *implicitView_param = NULL, __$true, __$false; - zend_bool implicitView; + zval *eventsManager, eventsManager_sub; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&eventsManager_sub); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(implicitView) + Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &implicitView_param); - if (implicitView) { - zephir_update_property_zval(this_ptr, ZEND_STRL("implicitView"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("implicitView"), &__$false); - } - RETURN_THISW(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Controller) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Controller, phalcon, mvc_controller, phalcon_di_injectable_ce, phalcon_mvc_controller_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_class_implements(phalcon_mvc_controller_ce, 1, phalcon_mvc_controllerinterface_ce); - return SUCCESS; + zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); + zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); } -static PHP_METHOD(Phalcon_Mvc_Controller, __construct) +static PHP_METHOD(Phalcon_Mvc_View, setLayout) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *layout_param = NULL; + zval layout; zval *this_ptr = getThis(); + + ZVAL_UNDEF(&layout); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(layout) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("onconstruct")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "onconstruct", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_MM_RESTORE(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_ControllerInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ControllerInterface, phalcon, mvc_controllerinterface, NULL); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Dispatcher) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Dispatcher, phalcon, mvc_dispatcher, phalcon_dispatcher_abstractdispatcher_ce, phalcon_mvc_dispatcher_method_entry, 0); - - zend_declare_property_string(phalcon_mvc_dispatcher_ce, SL("defaultAction"), "index", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_dispatcher_ce, SL("defaultHandler"), "index", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_dispatcher_ce, SL("handlerSuffix"), "Controller", ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_mvc_dispatcher_ce, 1, phalcon_mvc_dispatcherinterface_ce); - return SUCCESS; + zephir_fetch_params(1, 1, 0, &layout_param); + zephir_get_strval(&layout, layout_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("layout"), &layout); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Dispatcher, forward) +static PHP_METHOD(Phalcon_Mvc_View, setLayoutsDir) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *forward_param = NULL, eventsManager, _0, _1$$3; - zval forward; + zval *layoutsDir_param = NULL; + zval layoutsDir; zval *this_ptr = getThis(); - ZVAL_UNDEF(&forward); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&layoutsDir); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(forward) + Z_PARAM_STR(layoutsDir) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &forward_param); - zephir_get_arrval(&forward, forward_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_1$$3); - ZVAL_STRING(&_1$$3, "dispatch:beforeForward"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_1$$3, this_ptr, &forward); - zephir_check_call_status(); - } - ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_dispatcher_ce, getThis(), "forward", NULL, 0, &forward); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Dispatcher, getActiveController) -{ - - RETURN_MEMBER(getThis(), "activeHandler"); + zephir_fetch_params(1, 1, 0, &layoutsDir_param); + zephir_get_strval(&layoutsDir, layoutsDir_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("layoutsDir"), &layoutsDir); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Dispatcher, getControllerClass) +static PHP_METHOD(Phalcon_Mvc_View, setMainView) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *viewPath_param = NULL; + zval viewPath; zval *this_ptr = getThis(); + + ZVAL_UNDEF(&viewPath); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(viewPath) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "gethandlerclass", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Dispatcher, getControllerName) -{ - - RETURN_MEMBER(getThis(), "handlerName"); -} - -static PHP_METHOD(Phalcon_Mvc_Dispatcher, getLastController) -{ - - RETURN_MEMBER(getThis(), "lastHandler"); + zephir_fetch_params(1, 1, 0, &viewPath_param); + zephir_get_strval(&viewPath, viewPath_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("mainView"), &viewPath); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Dispatcher, getPreviousActionName) +static PHP_METHOD(Phalcon_Mvc_View, setPartialsDir) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *partialsDir_param = NULL; + zval partialsDir; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "previousActionName"); + ZVAL_UNDEF(&partialsDir); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(partialsDir) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &partialsDir_param); + zephir_get_strval(&partialsDir, partialsDir_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("partialsDir"), &partialsDir); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Dispatcher, getPreviousControllerName) +static PHP_METHOD(Phalcon_Mvc_View, setParamToView) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *key_param = NULL, *value, value_sub; + zval key; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "previousHandlerName"); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(key) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &key_param, &value); + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); + } else { + ZEPHIR_INIT_VAR(&key); + } + zephir_update_property_array(this_ptr, SL("viewParams"), &key, value); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Dispatcher, getPreviousNamespaceName) +static PHP_METHOD(Phalcon_Mvc_View, setRenderLevel) { + zval *level_param = NULL, _0; + zend_long level; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "previousNamespaceName"); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(level) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &level_param); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, level); + zephir_update_property_zval(this_ptr, ZEND_STRL("renderLevel"), &_0); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_Dispatcher, setControllerName) +static PHP_METHOD(Phalcon_Mvc_View, setTemplateAfter) { + zval _0$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *controllerName_param = NULL; - zval controllerName; + zval *templateAfter, templateAfter_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&controllerName); + ZVAL_UNDEF(&templateAfter_sub); + ZVAL_UNDEF(&_0$$3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(controllerName) + Z_PARAM_ZVAL(templateAfter) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &controllerName_param); - if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { - zephir_get_strval(&controllerName, controllerName_param); + zephir_fetch_params(1, 1, 0, &templateAfter); + if (Z_TYPE_P(templateAfter) != IS_ARRAY) { + ZEPHIR_INIT_VAR(&_0$$3); + zephir_create_array(&_0$$3, 1, 0); + zephir_array_fast_append(&_0$$3, templateAfter); + zephir_update_property_zval(this_ptr, ZEND_STRL("templatesAfter"), &_0$$3); } else { - ZEPHIR_INIT_VAR(&controllerName); + zephir_update_property_zval(this_ptr, ZEND_STRL("templatesAfter"), templateAfter); } - zephir_update_property_zval(this_ptr, ZEND_STRL("handlerName"), &controllerName); - ZEPHIR_MM_RESTORE(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Dispatcher, setControllerSuffix) +static PHP_METHOD(Phalcon_Mvc_View, setTemplateBefore) { + zval _0$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *controllerSuffix_param = NULL; - zval controllerSuffix; + zval *templateBefore, templateBefore_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&controllerSuffix); + ZVAL_UNDEF(&templateBefore_sub); + ZVAL_UNDEF(&_0$$3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(controllerSuffix) + Z_PARAM_ZVAL(templateBefore) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &controllerSuffix_param); - if (UNEXPECTED(Z_TYPE_P(controllerSuffix_param) != IS_STRING && Z_TYPE_P(controllerSuffix_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerSuffix' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(controllerSuffix_param) == IS_STRING)) { - zephir_get_strval(&controllerSuffix, controllerSuffix_param); + zephir_fetch_params(1, 1, 0, &templateBefore); + if (Z_TYPE_P(templateBefore) != IS_ARRAY) { + ZEPHIR_INIT_VAR(&_0$$3); + zephir_create_array(&_0$$3, 1, 0); + zephir_array_fast_append(&_0$$3, templateBefore); + zephir_update_property_zval(this_ptr, ZEND_STRL("templatesBefore"), &_0$$3); } else { - ZEPHIR_INIT_VAR(&controllerSuffix); + zephir_update_property_zval(this_ptr, ZEND_STRL("templatesBefore"), templateBefore); } - zephir_update_property_zval(this_ptr, ZEND_STRL("handlerSuffix"), &controllerSuffix); - ZEPHIR_MM_RESTORE(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Dispatcher, setDefaultController) +static PHP_METHOD(Phalcon_Mvc_View, setVar) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *controllerName_param = NULL; - zval controllerName; + zval *key_param = NULL, *value, value_sub; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&controllerName); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(controllerName) + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(key) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &controllerName_param); - if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); + zephir_fetch_params(1, 2, 0, &key_param, &value); + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { - zephir_get_strval(&controllerName, controllerName_param); + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); } else { - ZEPHIR_INIT_VAR(&controllerName); + ZEPHIR_INIT_VAR(&key); } - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultHandler"), &controllerName); - ZEPHIR_MM_RESTORE(); + zephir_update_property_array(this_ptr, SL("viewParams"), &key, value); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Dispatcher, handleException) +static PHP_METHOD(Phalcon_Mvc_View, setVars) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *exception, exception_sub, eventsManager, _0, _1$$3, _2$$3; + zend_bool merge; + zval *params_param = NULL, *merge_param = NULL, _0$$3, _1$$3; + zval params; zval *this_ptr = getThis(); - ZVAL_UNDEF(&exception_sub); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(exception, zend_ce_exception) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(params) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(merge) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &exception); - zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "dispatch:beforeException"); - ZEPHIR_CALL_METHOD(&_1$$3, &eventsManager, "fire", NULL, 0, &_2$$3, this_ptr, exception); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$3)) { - RETURN_MM_BOOL(0); + zephir_fetch_params(1, 1, 1, ¶ms_param, &merge_param); + ZEPHIR_OBS_COPY_OR_DUP(¶ms, params_param); + if (!merge_param) { + merge = 1; + } else { } + if (merge) { + ZEPHIR_INIT_VAR(&_0$$3); + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("viewParams"), PH_NOISY_CC | PH_READONLY); + zephir_fast_array_merge(&_0$$3, &_1$$3, ¶ms); + zephir_update_property_zval(this_ptr, ZEND_STRL("viewParams"), &_0$$3); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("viewParams"), ¶ms); } - ZEPHIR_MM_RESTORE(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Dispatcher, throwDispatchException) +static PHP_METHOD(Phalcon_Mvc_View, setViewsDir) { + zend_string *_5$$5; + zend_ulong _4$$5; + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long exceptionCode, ZEPHIR_LAST_CALL_STATUS; - zval *message_param = NULL, *exceptionCode_param = NULL, container, response, exception, _0, _4, _5, _1$$3, _2$$3, _3$$3; - zval message; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *viewsDir, viewsDir_sub, position, directory, newViewsDir, _1$$4, *_2$$5, _3$$5, _6$$6, _7$$8; zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&response); - ZVAL_UNDEF(&exception); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(exceptionCode) + ZVAL_UNDEF(&viewsDir_sub); + ZVAL_UNDEF(&position); + ZVAL_UNDEF(&directory); + ZVAL_UNDEF(&newViewsDir); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_6$$6); + ZVAL_UNDEF(&_7$$8); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(viewsDir) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &exceptionCode_param); - if (UNEXPECTED(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 0, &viewsDir); + _0 = Z_TYPE_P(viewsDir) != IS_STRING; + if (_0) { + _0 = Z_TYPE_P(viewsDir) != IS_ARRAY; } - if (EXPECTED(Z_TYPE_P(message_param) == IS_STRING)) { - zephir_get_strval(&message, message_param); - } else { - ZEPHIR_INIT_VAR(&message); + if (_0) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "Views directory must be a string or an array", "phalcon/Mvc/View.zep", 982); + return; } - if (!exceptionCode_param) { - exceptionCode = 0; + if (Z_TYPE_P(viewsDir) == IS_STRING) { + ZEPHIR_CALL_METHOD(&_1$$4, this_ptr, "getdirseparator", NULL, 490, viewsDir); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("viewsDirs"), &_1$$4); } else { + ZEPHIR_INIT_VAR(&newViewsDir); + array_init(&newViewsDir); + zephir_is_iterable(viewsDir, 0, "phalcon/Mvc/View.zep", 1000); + if (Z_TYPE_P(viewsDir) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(viewsDir), _4$$5, _5$$5, _2$$5) + { + ZEPHIR_INIT_NVAR(&position); + if (_5$$5 != NULL) { + ZVAL_STR_COPY(&position, _5$$5); + } else { + ZVAL_LONG(&position, _4$$5); + } + ZEPHIR_INIT_NVAR(&directory); + ZVAL_COPY(&directory, _2$$5); + if (Z_TYPE_P(&directory) != IS_STRING) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "Views directory item must be a string", "phalcon/Mvc/View.zep", 994); + return; + } + ZEPHIR_CALL_METHOD(&_6$$6, this_ptr, "getdirseparator", NULL, 490, &directory); + zephir_check_call_status(); + zephir_array_update_zval(&newViewsDir, &position, &_6$$6, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, viewsDir, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3$$5, viewsDir, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3$$5)) { + break; + } + ZEPHIR_CALL_METHOD(&position, viewsDir, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&directory, viewsDir, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&directory) != IS_STRING) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "Views directory item must be a string", "phalcon/Mvc/View.zep", 994); + return; + } + ZEPHIR_CALL_METHOD(&_7$$8, this_ptr, "getdirseparator", NULL, 490, &directory); + zephir_check_call_status(); + zephir_array_update_zval(&newViewsDir, &position, &_7$$8, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, viewsDir, "next", NULL, 0); + zephir_check_call_status(); + } } - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_mvc_dispatcher_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "A dependency injection container is required to access the 'response' service"); - ZVAL_LONG(&_3$$3, 0); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3, &_3$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Dispatcher.zep", 228); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_VAR(&_5); - ZVAL_STRING(&_5, "response"); - ZEPHIR_CALL_METHOD(&_4, &container, "getshared", NULL, 0, &_5); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&response, &_4); - ZVAL_LONG(&_0, 404); - ZEPHIR_INIT_NVAR(&_5); - ZVAL_STRING(&_5, "Not Found"); - ZEPHIR_CALL_METHOD(NULL, &response, "setstatuscode", NULL, 0, &_0, &_5); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&exception); - object_init_ex(&exception, phalcon_mvc_dispatcher_exception_ce); - ZVAL_LONG(&_0, exceptionCode); - ZEPHIR_CALL_METHOD(NULL, &exception, "__construct", NULL, 33, &message, &_0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4, this_ptr, "handleexception", NULL, 0, &exception); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_4)) { - RETURN_MM_BOOL(0); + ZEPHIR_INIT_NVAR(&directory); + ZEPHIR_INIT_NVAR(&position); + zephir_update_property_zval(this_ptr, ZEND_STRL("viewsDirs"), &newViewsDir); } - zephir_throw_exception_debug(&exception, "phalcon/Mvc/Dispatcher.zep", 250); - ZEPHIR_MM_RESTORE(); - return; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_DispatcherInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, DispatcherInterface, phalcon, mvc_dispatcherinterface, phalcon_mvc_dispatcherinterface_method_entry); - - zend_class_implements(phalcon_mvc_dispatcherinterface_ce, 1, phalcon_dispatcher_dispatcherinterface_ce); - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_DispatcherInterface, getActiveController); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_DispatcherInterface, getControllerName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_DispatcherInterface, getLastController); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_DispatcherInterface, setControllerSuffix); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_DispatcherInterface, setControllerName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_DispatcherInterface, setDefaultController); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_EntityInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, EntityInterface, phalcon, mvc_entityinterface, phalcon_mvc_entityinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_EntityInterface, readAttribute); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_EntityInterface, writeAttribute); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Micro, phalcon, mvc_micro, phalcon_di_injectable_ce, phalcon_mvc_micro_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_micro_ce, SL("activeHandler"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_micro_ce, SL("afterBindingHandlers"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_micro_ce, SL("afterHandlers"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_micro_ce, SL("beforeHandlers"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_micro_ce, SL("container"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_micro_ce, SL("errorHandler"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_micro_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_micro_ce, SL("finishHandlers"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_micro_ce, SL("handlers"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_micro_ce, SL("modelBinder"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_micro_ce, SL("notFoundHandler"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_micro_ce, SL("responseHandler"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_micro_ce, SL("returnedValue"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_micro_ce, SL("router"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_micro_ce, SL("stopped"), 0, ZEND_ACC_PROTECTED); - phalcon_mvc_micro_ce->create_object = zephir_init_properties_Phalcon_Mvc_Micro; - - zend_class_implements(phalcon_mvc_micro_ce, 1, zend_ce_arrayaccess); - zend_class_implements(phalcon_mvc_micro_ce, 1, phalcon_events_eventsawareinterface_ce); - return SUCCESS; + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Micro, __construct) +static PHP_METHOD(Phalcon_Mvc_View, start) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval __$null; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *container = NULL, container_sub, __$null; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container_sub); ZVAL_NULL(&__$null); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(container, phalcon_di_diinterface_ce) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &container); - if (!container) { - container = &container_sub; - container = &__$null; - } - if (Z_TYPE_P(container) != IS_NULL) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdi", NULL, 0, container); - zephir_check_call_status(); - } - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Micro, after) -{ - zval *handler, handler_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&handler_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(handler) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &handler); - zephir_update_property_array_append(this_ptr, SL("afterHandlers"), handler); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_Micro, afterBinding) -{ - zval *handler, handler_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&handler_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(handler) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &handler); - zephir_update_property_array_append(this_ptr, SL("afterBindingHandlers"), handler); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_Micro, before) -{ - zval *handler, handler_sub; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&handler_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(handler) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &handler); - zephir_update_property_array_append(this_ptr, SL("beforeHandlers"), handler); - RETURN_THISW(); + ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 387); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &__$null); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Micro, delete) +static PHP_METHOD(Phalcon_Mvc_View, toString) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, router, route, _0; - zval routePattern; + zval params; + zval *controllerName_param = NULL, *actionName_param = NULL, *params_param = NULL, result, _0; + zval controllerName, actionName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&router); - ZVAL_UNDEF(&route); + ZVAL_UNDEF(&controllerName); + ZVAL_UNDEF(&actionName); + ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) + ZVAL_UNDEF(¶ms); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(controllerName) + Z_PARAM_STR(actionName) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(params) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + zephir_fetch_params(1, 2, 1, &controllerName_param, &actionName_param, ¶ms_param); + if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); + if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { + zephir_get_strval(&controllerName, controllerName_param); } else { - ZEPHIR_INIT_VAR(&routePattern); + ZEPHIR_INIT_VAR(&controllerName); } - ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&route, &router, "adddelete", NULL, 0, &routePattern); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, &route, "getrouteid", NULL, 0); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("handlers"), &_0, handler); - RETURN_CCTOR(&route); -} - -static PHP_METHOD(Phalcon_Mvc_Micro, error) -{ - zval *handler, handler_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&handler_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(handler) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &handler); - zephir_update_property_zval(this_ptr, ZEND_STRL("errorHandler"), handler); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_Micro, finish) -{ - zval *handler, handler_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&handler_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(handler) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &handler); - zephir_update_property_array_append(this_ptr, SL("finishHandlers"), handler); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_Micro, get) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, router, route, _0; - zval routePattern; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&router); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + if (UNEXPECTED(Z_TYPE_P(actionName_param) != IS_STRING && Z_TYPE_P(actionName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); + if (EXPECTED(Z_TYPE_P(actionName_param) == IS_STRING)) { + zephir_get_strval(&actionName, actionName_param); } else { - ZEPHIR_INIT_VAR(&routePattern); + ZEPHIR_INIT_VAR(&actionName); } - ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); + if (!params_param) { + ZEPHIR_INIT_VAR(¶ms); + array_init(¶ms); + } else { + zephir_get_arrval(¶ms, params_param); + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "start", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&route, &router, "addget", NULL, 0, &routePattern); + ZVAL_BOOL(&_0, 0); + ZEPHIR_CALL_METHOD(&result, this_ptr, "processrender", NULL, 0, &controllerName, &actionName, ¶ms, &_0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, &route, "getrouteid", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "finish", NULL, 0); zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("handlers"), &_0, handler); - RETURN_CCTOR(&route); -} - -static PHP_METHOD(Phalcon_Mvc_Micro, getActiveHandler) -{ - - RETURN_MEMBER(getThis(), "activeHandler"); -} - -static PHP_METHOD(Phalcon_Mvc_Micro, getBoundModels) -{ - zval modelBinder, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&modelBinder); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelBinder"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&modelBinder, &_0); - if (Z_TYPE_P(&modelBinder) == IS_NULL) { - array_init(return_value); - RETURN_MM(); + if (!(zephir_is_true(&result))) { + RETURN_MM_STRING(""); } - ZEPHIR_RETURN_CALL_METHOD(&modelBinder, "getboundmodels", NULL, 0); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getcontent", NULL, 0); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Micro, getEventsManager) -{ - - RETURN_MEMBER(getThis(), "eventsManager"); -} - -static PHP_METHOD(Phalcon_Mvc_Micro, setEventsManager) -{ - zval *eventsManager, eventsManager_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&eventsManager_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); - zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); -} - -static PHP_METHOD(Phalcon_Mvc_Micro, getHandlers) -{ - - RETURN_MEMBER(getThis(), "handlers"); -} - -static PHP_METHOD(Phalcon_Mvc_Micro, getModelBinder) -{ - - RETURN_MEMBER(getThis(), "modelBinder"); -} - -static PHP_METHOD(Phalcon_Mvc_Micro, getReturnedValue) -{ - - RETURN_MEMBER(getThis(), "returnedValue"); -} - -static PHP_METHOD(Phalcon_Mvc_Micro, getRouter) +static PHP_METHOD(Phalcon_Mvc_View, engineRender) { - zval _0, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3; + zend_string *_9$$3, *_28$$16; + zend_ulong _8$$3, _27$$16; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_5 = NULL, *_13 = NULL, *_16 = NULL, *_20 = NULL, *_23 = NULL, *_32 = NULL, *_35 = NULL, *_39 = NULL, *_42 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool silence, mustClean; + zval viewPath, _45$$30; + zval *engines_param = NULL, *viewPath_param = NULL, *silence_param = NULL, *mustClean_param = NULL, basePath, engine, eventsManager, extension, viewsDir, viewsDirPath, viewEnginePath, viewEnginePaths, viewParams, _0, _1, *_2, _3, _4$$3, *_6$$3, _7$$3, _11$$8, _12$$8, _14$$7, _15$$10, _18$$13, _19$$13, _21$$12, _22$$15, _24$$16, *_25$$16, _26$$16, _30$$21, _31$$21, _33$$20, _34$$23, _37$$26, _38$$26, _40$$25, _41$$28, _43$$29, _44$$30; + zval engines, _10$$8, _17$$13, _29$$21, _36$$26; zval *this_ptr = getThis(); + ZVAL_UNDEF(&engines); + ZVAL_UNDEF(&_10$$8); + ZVAL_UNDEF(&_17$$13); + ZVAL_UNDEF(&_29$$21); + ZVAL_UNDEF(&_36$$26); + ZVAL_UNDEF(&basePath); + ZVAL_UNDEF(&engine); + ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&extension); + ZVAL_UNDEF(&viewsDir); + ZVAL_UNDEF(&viewsDirPath); + ZVAL_UNDEF(&viewEnginePath); + ZVAL_UNDEF(&viewEnginePaths); + ZVAL_UNDEF(&viewParams); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_11$$8); + ZVAL_UNDEF(&_12$$8); + ZVAL_UNDEF(&_14$$7); + ZVAL_UNDEF(&_15$$10); + ZVAL_UNDEF(&_18$$13); + ZVAL_UNDEF(&_19$$13); + ZVAL_UNDEF(&_21$$12); + ZVAL_UNDEF(&_22$$15); + ZVAL_UNDEF(&_24$$16); + ZVAL_UNDEF(&_26$$16); + ZVAL_UNDEF(&_30$$21); + ZVAL_UNDEF(&_31$$21); + ZVAL_UNDEF(&_33$$20); + ZVAL_UNDEF(&_34$$23); + ZVAL_UNDEF(&_37$$26); + ZVAL_UNDEF(&_38$$26); + ZVAL_UNDEF(&_40$$25); + ZVAL_UNDEF(&_41$$28); + ZVAL_UNDEF(&_43$$29); + ZVAL_UNDEF(&_44$$30); + ZVAL_UNDEF(&viewPath); + ZVAL_UNDEF(&_45$$30); + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_ARRAY(engines) + Z_PARAM_STR(viewPath) + Z_PARAM_BOOL(silence) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(mustClean) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("router"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "router"); - ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "getsharedservice", NULL, 0, &_2$$3); + zephir_fetch_params(1, 3, 1, &engines_param, &viewPath_param, &silence_param, &mustClean_param); + zephir_get_arrval(&engines, engines_param); + zephir_get_strval(&viewPath, viewPath_param); + if (!mustClean_param) { + mustClean = 1; + } else { + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("basePath"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&basePath, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("viewParams"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&viewParams, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_0); + ZEPHIR_INIT_VAR(&viewEnginePaths); + array_init(&viewEnginePaths); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getviewsdirs", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&_1, 0, "phalcon/Mvc/View.zep", 1106); + if (Z_TYPE_P(&_1) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_1), _2) + { + ZEPHIR_INIT_NVAR(&viewsDir); + ZVAL_COPY(&viewsDir, _2); + ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "isabsolutepath", &_5, 491, &viewPath); + zephir_check_call_status(); + if (!(zephir_is_true(&_4$$3))) { + ZEPHIR_INIT_NVAR(&viewsDirPath); + ZEPHIR_CONCAT_VVV(&viewsDirPath, &basePath, &viewsDir, &viewPath); + } else { + ZEPHIR_CPY_WRT(&viewsDirPath, &viewPath); + } + zephir_is_iterable(&engines, 0, "phalcon/Mvc/View.zep", 1101); + if (Z_TYPE_P(&engines) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&engines), _8$$3, _9$$3, _6$$3) + { + ZEPHIR_INIT_NVAR(&extension); + if (_9$$3 != NULL) { + ZVAL_STR_COPY(&extension, _9$$3); + } else { + ZVAL_LONG(&extension, _8$$3); + } + ZEPHIR_INIT_NVAR(&engine); + ZVAL_COPY(&engine, _6$$3); + ZEPHIR_INIT_NVAR(&viewEnginePath); + ZEPHIR_CONCAT_VV(&viewEnginePath, &viewsDirPath, &extension); + if ((zephir_file_exists(&viewEnginePath) == SUCCESS)) { + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_10$$8); + zephir_create_array(&_10$$8, 1, 0); + zephir_array_fast_append(&_10$$8, &viewEnginePath); + zephir_update_property_zval(this_ptr, ZEND_STRL("activeRenderPaths"), &_10$$8); + ZEPHIR_INIT_NVAR(&_12$$8); + ZVAL_STRING(&_12$$8, "view:beforeRenderView"); + ZEPHIR_CALL_METHOD(&_11$$8, &eventsManager, "fire", &_13, 0, &_12$$8, this_ptr, &viewEnginePath); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_11$$8)) { + continue; + } + } + if (mustClean) { + ZVAL_BOOL(&_14$$7, 1); + } else { + ZVAL_BOOL(&_14$$7, 0); + } + ZEPHIR_CALL_METHOD(NULL, &engine, "render", NULL, 0, &viewEnginePath, &viewParams, &_14$$7); + zephir_check_call_status(); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_15$$10); + ZVAL_STRING(&_15$$10, "view:afterRenderView"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_16, 0, &_15$$10, this_ptr); + zephir_check_call_status(); + } + RETURN_MM_NULL(); + } + zephir_array_append(&viewEnginePaths, &viewEnginePath, PH_SEPARATE, "phalcon/Mvc/View.zep", 1099); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &engines, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_7$$3, &engines, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_7$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&extension, &engines, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&engine, &engines, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&viewEnginePath); + ZEPHIR_CONCAT_VV(&viewEnginePath, &viewsDirPath, &extension); + if ((zephir_file_exists(&viewEnginePath) == SUCCESS)) { + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_17$$13); + zephir_create_array(&_17$$13, 1, 0); + zephir_array_fast_append(&_17$$13, &viewEnginePath); + zephir_update_property_zval(this_ptr, ZEND_STRL("activeRenderPaths"), &_17$$13); + ZEPHIR_INIT_NVAR(&_19$$13); + ZVAL_STRING(&_19$$13, "view:beforeRenderView"); + ZEPHIR_CALL_METHOD(&_18$$13, &eventsManager, "fire", &_20, 0, &_19$$13, this_ptr, &viewEnginePath); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_18$$13)) { + continue; + } + } + if (mustClean) { + ZVAL_BOOL(&_21$$12, 1); + } else { + ZVAL_BOOL(&_21$$12, 0); + } + ZEPHIR_CALL_METHOD(NULL, &engine, "render", NULL, 0, &viewEnginePath, &viewParams, &_21$$12); + zephir_check_call_status(); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_22$$15); + ZVAL_STRING(&_22$$15, "view:afterRenderView"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_23, 0, &_22$$15, this_ptr); + zephir_check_call_status(); + } + RETURN_MM_NULL(); + } + zephir_array_append(&viewEnginePaths, &viewEnginePath, PH_SEPARATE, "phalcon/Mvc/View.zep", 1099); + ZEPHIR_CALL_METHOD(NULL, &engines, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&engine); + ZEPHIR_INIT_NVAR(&extension); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_1, "rewind", NULL, 0); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("router"), &_1$$3); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("router"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_3$$3, "clear", NULL, 0); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &_1, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&viewsDir, &_1, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_24$$16, this_ptr, "isabsolutepath", &_5, 491, &viewPath); + zephir_check_call_status(); + if (!(zephir_is_true(&_24$$16))) { + ZEPHIR_INIT_NVAR(&viewsDirPath); + ZEPHIR_CONCAT_VVV(&viewsDirPath, &basePath, &viewsDir, &viewPath); + } else { + ZEPHIR_CPY_WRT(&viewsDirPath, &viewPath); + } + zephir_is_iterable(&engines, 0, "phalcon/Mvc/View.zep", 1101); + if (Z_TYPE_P(&engines) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&engines), _27$$16, _28$$16, _25$$16) + { + ZEPHIR_INIT_NVAR(&extension); + if (_28$$16 != NULL) { + ZVAL_STR_COPY(&extension, _28$$16); + } else { + ZVAL_LONG(&extension, _27$$16); + } + ZEPHIR_INIT_NVAR(&engine); + ZVAL_COPY(&engine, _25$$16); + ZEPHIR_INIT_NVAR(&viewEnginePath); + ZEPHIR_CONCAT_VV(&viewEnginePath, &viewsDirPath, &extension); + if ((zephir_file_exists(&viewEnginePath) == SUCCESS)) { + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_29$$21); + zephir_create_array(&_29$$21, 1, 0); + zephir_array_fast_append(&_29$$21, &viewEnginePath); + zephir_update_property_zval(this_ptr, ZEND_STRL("activeRenderPaths"), &_29$$21); + ZEPHIR_INIT_NVAR(&_31$$21); + ZVAL_STRING(&_31$$21, "view:beforeRenderView"); + ZEPHIR_CALL_METHOD(&_30$$21, &eventsManager, "fire", &_32, 0, &_31$$21, this_ptr, &viewEnginePath); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_30$$21)) { + continue; + } + } + if (mustClean) { + ZVAL_BOOL(&_33$$20, 1); + } else { + ZVAL_BOOL(&_33$$20, 0); + } + ZEPHIR_CALL_METHOD(NULL, &engine, "render", NULL, 0, &viewEnginePath, &viewParams, &_33$$20); + zephir_check_call_status(); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_34$$23); + ZVAL_STRING(&_34$$23, "view:afterRenderView"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_35, 0, &_34$$23, this_ptr); + zephir_check_call_status(); + } + RETURN_MM_NULL(); + } + zephir_array_append(&viewEnginePaths, &viewEnginePath, PH_SEPARATE, "phalcon/Mvc/View.zep", 1099); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &engines, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_26$$16, &engines, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_26$$16)) { + break; + } + ZEPHIR_CALL_METHOD(&extension, &engines, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&engine, &engines, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&viewEnginePath); + ZEPHIR_CONCAT_VV(&viewEnginePath, &viewsDirPath, &extension); + if ((zephir_file_exists(&viewEnginePath) == SUCCESS)) { + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_36$$26); + zephir_create_array(&_36$$26, 1, 0); + zephir_array_fast_append(&_36$$26, &viewEnginePath); + zephir_update_property_zval(this_ptr, ZEND_STRL("activeRenderPaths"), &_36$$26); + ZEPHIR_INIT_NVAR(&_38$$26); + ZVAL_STRING(&_38$$26, "view:beforeRenderView"); + ZEPHIR_CALL_METHOD(&_37$$26, &eventsManager, "fire", &_39, 0, &_38$$26, this_ptr, &viewEnginePath); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_37$$26)) { + continue; + } + } + if (mustClean) { + ZVAL_BOOL(&_40$$25, 1); + } else { + ZVAL_BOOL(&_40$$25, 0); + } + ZEPHIR_CALL_METHOD(NULL, &engine, "render", NULL, 0, &viewEnginePath, &viewParams, &_40$$25); + zephir_check_call_status(); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_41$$28); + ZVAL_STRING(&_41$$28, "view:afterRenderView"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_42, 0, &_41$$28, this_ptr); + zephir_check_call_status(); + } + RETURN_MM_NULL(); + } + zephir_array_append(&viewEnginePaths, &viewEnginePath, PH_SEPARATE, "phalcon/Mvc/View.zep", 1099); + ZEPHIR_CALL_METHOD(NULL, &engines, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&engine); + ZEPHIR_INIT_NVAR(&extension); + ZEPHIR_CALL_METHOD(NULL, &_1, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&viewsDir); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + zephir_update_property_zval(this_ptr, ZEND_STRL("activeRenderPaths"), &viewEnginePaths); + ZEPHIR_INIT_VAR(&_43$$29); + ZVAL_STRING(&_43$$29, "view:notFoundView"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_43$$29, this_ptr, &viewEnginePath); zephir_check_call_status(); - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("router"), PH_NOISY_CC | PH_READONLY); - ZVAL_BOOL(&_5$$3, 1); - ZEPHIR_CALL_METHOD(NULL, &_4$$3, "removeextraslashes", NULL, 0, &_5$$3); + } + if (!(silence)) { + ZEPHIR_INIT_VAR(&_44$$30); + object_init_ex(&_44$$30, phalcon_mvc_view_exception_ce); + ZEPHIR_INIT_VAR(&_45$$30); + ZEPHIR_CONCAT_SVS(&_45$$30, "View '", &viewPath, "' was not found in any of the views directory"); + ZEPHIR_CALL_METHOD(NULL, &_44$$30, "__construct", NULL, 33, &_45$$30); zephir_check_call_status(); + zephir_throw_exception_debug(&_44$$30, "phalcon/Mvc/View.zep", 1115); + ZEPHIR_MM_RESTORE(); + return; } - RETURN_MM_MEMBER(getThis(), "router"); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Micro, getService) +static PHP_METHOD(Phalcon_Mvc_View, isAbsolutePath) { + unsigned char _6, _2$$3, _4$$3; + zend_bool _5, _1$$3, _3$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *serviceName_param = NULL, _0, _2, _1$$3; - zval serviceName; - zval *this_ptr = getThis(); + zval *path_param = NULL, _0; + zval path; - ZVAL_UNDEF(&serviceName); + ZVAL_UNDEF(&path); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_1$$3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(serviceName) + Z_PARAM_STR(path) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &serviceName_param); - if (UNEXPECTED(Z_TYPE_P(serviceName_param) != IS_STRING && Z_TYPE_P(serviceName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'serviceName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(serviceName_param) == IS_STRING)) { - zephir_get_strval(&serviceName, serviceName_param); - } else { - ZEPHIR_INIT_VAR(&serviceName); + zephir_fetch_params(1, 1, 0, &path_param); + zephir_get_strval(&path, path_param); + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_GET_CONSTANT(&_0, "PHP_OS"); + if (ZEPHIR_IS_STRING_IDENTICAL(&_0, "WINNT")) { + _1$$3 = zephir_fast_strlen_ev(&path) >= 3; + if (_1$$3) { + _2$$3 = ZEPHIR_STRING_OFFSET(&path, 1); + _1$$3 = _2$$3 == ':'; + } + _3$$3 = _1$$3; + if (_3$$3) { + _4$$3 = ZEPHIR_STRING_OFFSET(&path, 2); + _3$$3 = _4$$3 == '\\'; + } + RETURN_MM_BOOL(_3$$3); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_di_factorydefault_ce); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 416); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &_1$$3); + _5 = zephir_fast_strlen_ev(&path) >= 1; + if (_5) { + _6 = ZEPHIR_STRING_OFFSET(&path, 0); + _5 = _6 == '/'; } - zephir_read_property(&_2, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_2, "get", NULL, 0, &serviceName); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MM_BOOL(_5); } -static PHP_METHOD(Phalcon_Mvc_Micro, getSharedService) +static PHP_METHOD(Phalcon_Mvc_View, loadTemplateEngines) { + zval _15$$11, _21$$17; + zend_class_entry *_8$$9, *_17$$15; + zend_string *_6$$5; + zend_ulong _5$$5; + zval engines, di, registeredEngines, engineService, extension, _0, _1$$3, _2$$4, *_3$$5, _4$$5, _7$$9, _11$$12, _12$$12, _14$$11, _16$$15, _18$$18, _19$$18, _20$$17; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_9 = NULL, *_10 = NULL, *_13 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *serviceName_param = NULL, _0, _2, _1$$3; - zval serviceName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&serviceName); + ZVAL_UNDEF(&engines); + ZVAL_UNDEF(&di); + ZVAL_UNDEF(®isteredEngines); + ZVAL_UNDEF(&engineService); + ZVAL_UNDEF(&extension); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(serviceName) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_7$$9); + ZVAL_UNDEF(&_11$$12); + ZVAL_UNDEF(&_12$$12); + ZVAL_UNDEF(&_14$$11); + ZVAL_UNDEF(&_16$$15); + ZVAL_UNDEF(&_18$$18); + ZVAL_UNDEF(&_19$$18); + ZVAL_UNDEF(&_20$$17); + ZVAL_UNDEF(&_15$$11); + ZVAL_UNDEF(&_21$$17); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &serviceName_param); - if (UNEXPECTED(Z_TYPE_P(serviceName_param) != IS_STRING && Z_TYPE_P(serviceName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'serviceName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(serviceName_param) == IS_STRING)) { - zephir_get_strval(&serviceName, serviceName_param); - } else { - ZEPHIR_INIT_VAR(&serviceName); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_di_factorydefault_ce); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 416); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &_1$$3); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("engines"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&engines, &_0); + if (ZEPHIR_IS_FALSE_IDENTICAL(&engines)) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&di, &_1$$3); + ZEPHIR_INIT_NVAR(&engines); + array_init(&engines); + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("registeredEngines"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(®isteredEngines, &_1$$3); + if (ZEPHIR_IS_EMPTY(®isteredEngines)) { + ZEPHIR_INIT_VAR(&_2$$4); + object_init_ex(&_2$$4, phalcon_mvc_view_engine_php_ce); + ZEPHIR_CALL_METHOD(NULL, &_2$$4, "__construct", NULL, 492, this_ptr, &di); + zephir_check_call_status(); + zephir_array_update_string(&engines, SL(".phtml"), &_2$$4, PH_COPY | PH_SEPARATE); + } else { + if (Z_TYPE_P(&di) != IS_OBJECT) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "A dependency injection container is required to access application services", "phalcon/Mvc/View.zep", 1159); + return; + } + zephir_is_iterable(®isteredEngines, 0, "phalcon/Mvc/View.zep", 1196); + if (Z_TYPE_P(®isteredEngines) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(®isteredEngines), _5$$5, _6$$5, _3$$5) + { + ZEPHIR_INIT_NVAR(&extension); + if (_6$$5 != NULL) { + ZVAL_STR_COPY(&extension, _6$$5); + } else { + ZVAL_LONG(&extension, _5$$5); + } + ZEPHIR_INIT_NVAR(&engineService); + ZVAL_COPY(&engineService, _3$$5); + if (Z_TYPE_P(&engineService) == IS_OBJECT) { + if (zephir_is_instance_of(&engineService, SL("Closure"))) { + _8$$9 = zephir_fetch_class_str_ex(SL("Closure"), ZEND_FETCH_CLASS_AUTO); + ZEPHIR_CALL_CE_STATIC(&_7$$9, _8$$9, "bind", &_9, 0, &engineService, &di); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&engineService, &_7$$9); + ZEPHIR_CALL_FUNCTION(&_7$$9, "call_user_func", &_10, 188, &engineService, this_ptr); + zephir_check_call_status(); + zephir_array_update_zval(&engines, &extension, &_7$$9, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&engines, &extension, &engineService, PH_COPY | PH_SEPARATE); + } + } else { + if (Z_TYPE_P(&engineService) != IS_STRING) { + ZEPHIR_INIT_NVAR(&_11$$12); + object_init_ex(&_11$$12, phalcon_mvc_view_exception_ce); + ZEPHIR_INIT_NVAR(&_12$$12); + ZEPHIR_CONCAT_SV(&_12$$12, "Invalid template engine registration for extension: ", &extension); + ZEPHIR_CALL_METHOD(NULL, &_11$$12, "__construct", &_13, 33, &_12$$12); + zephir_check_call_status(); + zephir_throw_exception_debug(&_11$$12, "phalcon/Mvc/View.zep", 1187); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_NVAR(&_15$$11); + zephir_create_array(&_15$$11, 1, 0); + zephir_array_fast_append(&_15$$11, this_ptr); + ZEPHIR_CALL_METHOD(&_14$$11, &di, "get", NULL, 0, &engineService, &_15$$11); + zephir_check_call_status(); + zephir_array_update_zval(&engines, &extension, &_14$$11, PH_COPY | PH_SEPARATE); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, ®isteredEngines, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_4$$5, ®isteredEngines, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_4$$5)) { + break; + } + ZEPHIR_CALL_METHOD(&extension, ®isteredEngines, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&engineService, ®isteredEngines, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&engineService) == IS_OBJECT) { + if (zephir_is_instance_of(&engineService, SL("Closure"))) { + _17$$15 = zephir_fetch_class_str_ex(SL("Closure"), ZEND_FETCH_CLASS_AUTO); + ZEPHIR_CALL_CE_STATIC(&_16$$15, _17$$15, "bind", &_9, 0, &engineService, &di); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&engineService, &_16$$15); + ZEPHIR_CALL_FUNCTION(&_16$$15, "call_user_func", &_10, 188, &engineService, this_ptr); + zephir_check_call_status(); + zephir_array_update_zval(&engines, &extension, &_16$$15, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&engines, &extension, &engineService, PH_COPY | PH_SEPARATE); + } + } else { + if (Z_TYPE_P(&engineService) != IS_STRING) { + ZEPHIR_INIT_NVAR(&_18$$18); + object_init_ex(&_18$$18, phalcon_mvc_view_exception_ce); + ZEPHIR_INIT_NVAR(&_19$$18); + ZEPHIR_CONCAT_SV(&_19$$18, "Invalid template engine registration for extension: ", &extension); + ZEPHIR_CALL_METHOD(NULL, &_18$$18, "__construct", &_13, 33, &_19$$18); + zephir_check_call_status(); + zephir_throw_exception_debug(&_18$$18, "phalcon/Mvc/View.zep", 1187); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_NVAR(&_21$$17); + zephir_create_array(&_21$$17, 1, 0); + zephir_array_fast_append(&_21$$17, this_ptr); + ZEPHIR_CALL_METHOD(&_20$$17, &di, "get", NULL, 0, &engineService, &_21$$17); + zephir_check_call_status(); + zephir_array_update_zval(&engines, &extension, &_20$$17, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, ®isteredEngines, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&engineService); + ZEPHIR_INIT_NVAR(&extension); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("engines"), &engines); } - zephir_read_property(&_2, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_2, "getshared", NULL, 0, &serviceName); - zephir_check_call_status(); - RETURN_MM(); + RETURN_CCTOR(&engines); } -static PHP_METHOD(Phalcon_Mvc_Micro, handle) +static PHP_METHOD(Phalcon_Mvc_View, processRender) { - zval _81$$59, _86$$64, _95$$69; - zend_class_entry *_28$$21; - zend_bool _26$$7, _37$$7, _18$$11, _22$$16, _33$$25, _44$$31, _48$$36, _57$$42, _61$$47, _78$$57, _83$$62, _100$$79, _101$$79; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *uri_param = NULL, __$true, __$false, container, status, router, matchedRoute, handler, beforeHandlers, params, returnedValue, e, afterHandlers, notFoundHandler, finishHandlers, finish, before, after, response, modelBinder, routeName, realHandler, methodName, lazyReturned, afterBindingHandlers, afterBinding, _0, _88, _1$$4, _5$$4, _6$$4, _72$$4, _75$$4, *_76$$4, _77$$4, _2$$5, _3$$5, _4$$5, _7$$7, _8$$7, _11$$7, _15$$7, *_16$$7, _17$$7, _41$$7, *_42$$7, _43$$7, _54$$7, *_55$$7, _56$$7, _9$$8, _10$$8, _12$$9, _13$$9, _14$$9, _21$$11, _19$$14, _20$$14, _25$$16, _23$$19, _24$$19, _27$$21, _29$$23, _30$$24, _31$$24, _32$$22, _34$$26, _35$$26, _36$$26, _38$$29, _39$$29, _40$$29, _47$$31, _45$$34, _46$$34, _51$$36, _49$$39, _50$$39, _52$$41, _53$$41, _60$$42, _58$$45, _59$$45, _64$$47, _62$$50, _63$$50, _65$$52, _69$$52, _66$$53, _67$$53, _68$$53, _70$$55, _71$$55, _73$$56, _74$$56, _82$$57, _79$$60, _80$$60, _87$$62, _84$$65, _85$$65, _89$$67, _92$$67, _90$$68, _91$$68, _93$$69, _94$$69, _96$$77, _97$$77, _98$$80, _99$$80, _102$$79; - zval uri, bindCacheKey; - zval *this_ptr = getThis(); + zend_long ZEPHIR_LAST_CALL_STATUS, renderLevel = 0; + zend_bool fireEvents, silence = 0, _5, _30; + zval params; + zval *controllerName_param = NULL, *actionName_param = NULL, *params_param = NULL, *fireEvents_param = NULL, layoutsDir, layout, pickView, layoutName, engines, renderView, pickViewAction, eventsManager, disabledLevels, templatesBefore, templatesAfter, templateBefore, templateAfter, _0, _2, _4, _8, _9, _1$$3, _6$$11, _7$$11, _10$$15, _11$$17, *_12$$17, _13$$17, _14$$18, _15$$18, _16$$19, _17$$19, _18$$21, _19$$21, _20$$23, *_21$$23, _22$$23, _23$$24, _24$$24, _25$$25, _26$$25, _27$$27, _28$$27, _29$$13, _31$$28; + zval controllerName, actionName, _3$$7; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&uri); - ZVAL_UNDEF(&bindCacheKey); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&status); - ZVAL_UNDEF(&router); - ZVAL_UNDEF(&matchedRoute); - ZVAL_UNDEF(&handler); - ZVAL_UNDEF(&beforeHandlers); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&returnedValue); - ZVAL_UNDEF(&e); - ZVAL_UNDEF(&afterHandlers); - ZVAL_UNDEF(¬FoundHandler); - ZVAL_UNDEF(&finishHandlers); - ZVAL_UNDEF(&finish); - ZVAL_UNDEF(&before); - ZVAL_UNDEF(&after); - ZVAL_UNDEF(&response); - ZVAL_UNDEF(&modelBinder); - ZVAL_UNDEF(&routeName); - ZVAL_UNDEF(&realHandler); - ZVAL_UNDEF(&methodName); - ZVAL_UNDEF(&lazyReturned); - ZVAL_UNDEF(&afterBindingHandlers); - ZVAL_UNDEF(&afterBinding); + ZVAL_UNDEF(&controllerName); + ZVAL_UNDEF(&actionName); + ZVAL_UNDEF(&_3$$7); + ZVAL_UNDEF(&layoutsDir); + ZVAL_UNDEF(&layout); + ZVAL_UNDEF(&pickView); + ZVAL_UNDEF(&layoutName); + ZVAL_UNDEF(&engines); + ZVAL_UNDEF(&renderView); + ZVAL_UNDEF(&pickViewAction); + ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&disabledLevels); + ZVAL_UNDEF(&templatesBefore); + ZVAL_UNDEF(&templatesAfter); + ZVAL_UNDEF(&templateBefore); + ZVAL_UNDEF(&templateAfter); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_88); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_72$$4); - ZVAL_UNDEF(&_75$$4); - ZVAL_UNDEF(&_77$$4); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_7$$7); - ZVAL_UNDEF(&_8$$7); - ZVAL_UNDEF(&_11$$7); - ZVAL_UNDEF(&_15$$7); - ZVAL_UNDEF(&_17$$7); - ZVAL_UNDEF(&_41$$7); - ZVAL_UNDEF(&_43$$7); - ZVAL_UNDEF(&_54$$7); - ZVAL_UNDEF(&_56$$7); - ZVAL_UNDEF(&_9$$8); - ZVAL_UNDEF(&_10$$8); - ZVAL_UNDEF(&_12$$9); - ZVAL_UNDEF(&_13$$9); - ZVAL_UNDEF(&_14$$9); - ZVAL_UNDEF(&_21$$11); - ZVAL_UNDEF(&_19$$14); - ZVAL_UNDEF(&_20$$14); - ZVAL_UNDEF(&_25$$16); - ZVAL_UNDEF(&_23$$19); - ZVAL_UNDEF(&_24$$19); - ZVAL_UNDEF(&_27$$21); - ZVAL_UNDEF(&_29$$23); - ZVAL_UNDEF(&_30$$24); - ZVAL_UNDEF(&_31$$24); - ZVAL_UNDEF(&_32$$22); - ZVAL_UNDEF(&_34$$26); - ZVAL_UNDEF(&_35$$26); - ZVAL_UNDEF(&_36$$26); - ZVAL_UNDEF(&_38$$29); - ZVAL_UNDEF(&_39$$29); - ZVAL_UNDEF(&_40$$29); - ZVAL_UNDEF(&_47$$31); - ZVAL_UNDEF(&_45$$34); - ZVAL_UNDEF(&_46$$34); - ZVAL_UNDEF(&_51$$36); - ZVAL_UNDEF(&_49$$39); - ZVAL_UNDEF(&_50$$39); - ZVAL_UNDEF(&_52$$41); - ZVAL_UNDEF(&_53$$41); - ZVAL_UNDEF(&_60$$42); - ZVAL_UNDEF(&_58$$45); - ZVAL_UNDEF(&_59$$45); - ZVAL_UNDEF(&_64$$47); - ZVAL_UNDEF(&_62$$50); - ZVAL_UNDEF(&_63$$50); - ZVAL_UNDEF(&_65$$52); - ZVAL_UNDEF(&_69$$52); - ZVAL_UNDEF(&_66$$53); - ZVAL_UNDEF(&_67$$53); - ZVAL_UNDEF(&_68$$53); - ZVAL_UNDEF(&_70$$55); - ZVAL_UNDEF(&_71$$55); - ZVAL_UNDEF(&_73$$56); - ZVAL_UNDEF(&_74$$56); - ZVAL_UNDEF(&_82$$57); - ZVAL_UNDEF(&_79$$60); - ZVAL_UNDEF(&_80$$60); - ZVAL_UNDEF(&_87$$62); - ZVAL_UNDEF(&_84$$65); - ZVAL_UNDEF(&_85$$65); - ZVAL_UNDEF(&_89$$67); - ZVAL_UNDEF(&_92$$67); - ZVAL_UNDEF(&_90$$68); - ZVAL_UNDEF(&_91$$68); - ZVAL_UNDEF(&_93$$69); - ZVAL_UNDEF(&_94$$69); - ZVAL_UNDEF(&_96$$77); - ZVAL_UNDEF(&_97$$77); - ZVAL_UNDEF(&_98$$80); - ZVAL_UNDEF(&_99$$80); - ZVAL_UNDEF(&_102$$79); - ZVAL_UNDEF(&_81$$59); - ZVAL_UNDEF(&_86$$64); - ZVAL_UNDEF(&_95$$69); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(uri) + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_6$$11); + ZVAL_UNDEF(&_7$$11); + ZVAL_UNDEF(&_10$$15); + ZVAL_UNDEF(&_11$$17); + ZVAL_UNDEF(&_13$$17); + ZVAL_UNDEF(&_14$$18); + ZVAL_UNDEF(&_15$$18); + ZVAL_UNDEF(&_16$$19); + ZVAL_UNDEF(&_17$$19); + ZVAL_UNDEF(&_18$$21); + ZVAL_UNDEF(&_19$$21); + ZVAL_UNDEF(&_20$$23); + ZVAL_UNDEF(&_22$$23); + ZVAL_UNDEF(&_23$$24); + ZVAL_UNDEF(&_24$$24); + ZVAL_UNDEF(&_25$$25); + ZVAL_UNDEF(&_26$$25); + ZVAL_UNDEF(&_27$$27); + ZVAL_UNDEF(&_28$$27); + ZVAL_UNDEF(&_29$$13); + ZVAL_UNDEF(&_31$$28); + ZVAL_UNDEF(¶ms); + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_STR(controllerName) + Z_PARAM_STR(actionName) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(params) + Z_PARAM_BOOL(fireEvents) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &uri_param); - if (UNEXPECTED(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 of the type string")); + zephir_fetch_params(1, 2, 2, &controllerName_param, &actionName_param, ¶ms_param, &fireEvents_param); + if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(uri_param) == IS_STRING)) { - zephir_get_strval(&uri, uri_param); + if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { + zephir_get_strval(&controllerName, controllerName_param); } else { - ZEPHIR_INIT_VAR(&uri); + ZEPHIR_INIT_VAR(&controllerName); } - ZEPHIR_INIT_VAR(&status); - ZVAL_NULL(&status); - ZEPHIR_INIT_VAR(&realHandler); - ZVAL_NULL(&realHandler); - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "A dependency injection container is required to access micro services", "phalcon/Mvc/Micro.zep", 398); - return; + if (UNEXPECTED(Z_TYPE_P(actionName_param) != IS_STRING && Z_TYPE_P(actionName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionName' must be of the type string")); + RETURN_MM_NULL(); } - - /* try_start_1: */ - - ZEPHIR_INIT_VAR(&returnedValue); - ZVAL_NULL(&returnedValue); - zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_1$$4) != IS_NULL) { - zephir_read_property(&_2$$5, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_4$$5); - ZVAL_STRING(&_4$$5, "micro:beforeHandleRoute"); - ZEPHIR_CALL_METHOD(&_3$$5, &_2$$5, "fire", NULL, 0, &_4$$5, this_ptr); - zephir_check_call_status_or_jump(try_end_1); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_3$$5)) { - RETURN_MM_BOOL(0); - } + if (EXPECTED(Z_TYPE_P(actionName_param) == IS_STRING)) { + zephir_get_strval(&actionName, actionName_param); + } else { + ZEPHIR_INIT_VAR(&actionName); + } + if (!params_param) { + ZEPHIR_INIT_VAR(¶ms); + array_init(¶ms); + } else { + zephir_get_arrval(¶ms, params_param); + } + if (!fireEvents_param) { + fireEvents = 1; + } else { } - ZEPHIR_INIT_VAR(&_6$$4); - ZVAL_STRING(&_6$$4, "router"); - ZEPHIR_CALL_METHOD(&_5$$4, &container, "getshared", NULL, 0, &_6$$4); - zephir_check_call_status_or_jump(try_end_1); - ZEPHIR_CPY_WRT(&router, &_5$$4); - ZEPHIR_CALL_METHOD(NULL, &router, "handle", NULL, 0, &uri); - zephir_check_call_status_or_jump(try_end_1); - ZEPHIR_CALL_METHOD(&matchedRoute, &router, "getmatchedroute", NULL, 0); - zephir_check_call_status_or_jump(try_end_1); - if (Z_TYPE_P(&matchedRoute) != IS_NULL) { - zephir_memory_observe(&handler); - zephir_read_property(&_7$$7, this_ptr, ZEND_STRL("handlers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_8$$7, &matchedRoute, "getrouteid", NULL, 0); - zephir_check_call_status_or_jump(try_end_1); - if (UNEXPECTED(!(zephir_array_isset_fetch(&handler, &_7$$7, &_8$$7, 0)))) { - ZEPHIR_INIT_VAR(&_9$$8); - object_init_ex(&_9$$8, phalcon_mvc_micro_exception_ce); - ZEPHIR_INIT_VAR(&_10$$8); - ZVAL_STRING(&_10$$8, "Matched route doesn't have an associated handler"); - ZEPHIR_CALL_METHOD(NULL, &_9$$8, "__construct", NULL, 33, &_10$$8); - zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception_debug(&_9$$8, "phalcon/Mvc/Micro.zep", 432); - goto try_end_1; - + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, 0); + zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("disabled"), PH_NOISY_CC | PH_READONLY); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_0)) { + ZEPHIR_CALL_FUNCTION(&_1$$3, "ob_get_contents", NULL, 493); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &_1$$3); + RETURN_MM_BOOL(0); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("controllerName"), &controllerName); + zephir_update_property_zval(this_ptr, ZEND_STRL("actionName"), &actionName); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setvars", NULL, 0, ¶ms); + zephir_check_call_status(); + zephir_read_property(&_2, this_ptr, ZEND_STRL("layoutsDir"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&layoutsDir, &_2); + if (!(zephir_is_true(&layoutsDir))) { + ZEPHIR_INIT_NVAR(&layoutsDir); + ZVAL_STRING(&layoutsDir, "layouts/"); + } + zephir_read_property(&_2, this_ptr, ZEND_STRL("layout"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&layout, &_2); + if (zephir_is_true(&layout)) { + ZEPHIR_CPY_WRT(&layoutName, &layout); + } else { + ZEPHIR_CPY_WRT(&layoutName, &controllerName); + } + ZEPHIR_CALL_METHOD(&engines, this_ptr, "loadtemplateengines", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_2, this_ptr, ZEND_STRL("pickView"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&pickView, &_2); + if (Z_TYPE_P(&pickView) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$7); + ZEPHIR_CONCAT_VSV(&_3$$7, &controllerName, "/", &actionName); + ZEPHIR_CPY_WRT(&renderView, &_3$$7); + } else { + ZEPHIR_OBS_NVAR(&renderView); + zephir_array_fetch_long(&renderView, &pickView, 0, PH_NOISY, "phalcon/Mvc/View.zep", 1274); + if (Z_TYPE_P(&layoutName) == IS_NULL) { + zephir_memory_observe(&pickViewAction); + if (zephir_array_isset_long_fetch(&pickViewAction, &pickView, 1, 0)) { + ZEPHIR_CPY_WRT(&layoutName, &pickViewAction); } - zephir_update_property_zval(this_ptr, ZEND_STRL("activeHandler"), &handler); - zephir_read_property(&_11$$7, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_11$$7) != IS_NULL) { - zephir_read_property(&_12$$9, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_14$$9); - ZVAL_STRING(&_14$$9, "micro:beforeExecuteRoute"); - ZEPHIR_CALL_METHOD(&_13$$9, &_12$$9, "fire", NULL, 0, &_14$$9, this_ptr); - zephir_check_call_status_or_jump(try_end_1); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_13$$9)) { - RETURN_MM_BOOL(0); + } + } + zephir_read_property(&_2, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_2); + ZEPHIR_INIT_VAR(&_4); + ZEPHIR_CREATE_SYMBOL_TABLE(); + + _5 = fireEvents; + if (_5) { + _5 = Z_TYPE_P(&eventsManager) == IS_OBJECT; + } + if (_5) { + ZEPHIR_INIT_VAR(&_7$$11); + ZVAL_STRING(&_7$$11, "view:beforeRender"); + ZEPHIR_CALL_METHOD(&_6$$11, &eventsManager, "fire", NULL, 0, &_7$$11, this_ptr); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_6$$11)) { + RETURN_MM_BOOL(0); + } + } + ZEPHIR_CALL_FUNCTION(&_8, "ob_get_contents", NULL, 493); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &_8); + silence = 1; + zephir_read_property(&_2, this_ptr, ZEND_STRL("disabledLevels"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&disabledLevels, &_2); + zephir_memory_observe(&_9); + zephir_read_property(&_9, this_ptr, ZEND_STRL("renderLevel"), PH_NOISY_CC); + renderLevel = zephir_get_intval(&_9); + if (renderLevel) { + if (renderLevel >= 1) { + if (!(zephir_array_isset_long(&disabledLevels, 1))) { + ZVAL_UNDEF(&_10$$15); + ZVAL_LONG(&_10$$15, 1); + zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_10$$15); + if (silence) { + ZVAL_BOOL(&_10$$15, 1); + } else { + ZVAL_BOOL(&_10$$15, 0); } - ZEPHIR_OBS_NVAR(&handler); - zephir_read_property(&handler, this_ptr, ZEND_STRL("activeHandler"), PH_NOISY_CC); - } - zephir_read_property(&_15$$7, this_ptr, ZEND_STRL("beforeHandlers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&beforeHandlers, &_15$$7); - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$false); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &renderView, &_10$$15); + zephir_check_call_status(); } - zephir_is_iterable(&beforeHandlers, 0, "phalcon/Mvc/Micro.zep", 484); - if (Z_TYPE_P(&beforeHandlers) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&beforeHandlers), _16$$7) - { - ZEPHIR_INIT_NVAR(&before); - ZVAL_COPY(&before, _16$$7); - _18$$11 = Z_TYPE_P(&before) == IS_OBJECT; - if (_18$$11) { - _18$$11 = zephir_instance_of_ev(&before, phalcon_mvc_micro_middlewareinterface_ce); - } - if (_18$$11) { - ZEPHIR_CALL_METHOD(&status, &before, "call", NULL, 0, this_ptr); - zephir_check_call_status_or_jump(try_end_1); - } else { - if (UNEXPECTED(!(zephir_is_callable(&before)))) { - ZEPHIR_INIT_NVAR(&_19$$14); - object_init_ex(&_19$$14, phalcon_mvc_micro_exception_ce); - ZEPHIR_INIT_NVAR(&_20$$14); - ZVAL_STRING(&_20$$14, "'before' handler is not callable"); - ZEPHIR_CALL_METHOD(NULL, &_19$$14, "__construct", NULL, 33, &_20$$14); - zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception_debug(&_19$$14, "phalcon/Mvc/Micro.zep", 467); - goto try_end_1; - + } + if (renderLevel >= 2) { + if (!(zephir_array_isset_long(&disabledLevels, 2))) { + ZVAL_UNDEF(&_11$$17); + ZVAL_LONG(&_11$$17, 2); + zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_11$$17); + zephir_read_property(&_11$$17, this_ptr, ZEND_STRL("templatesBefore"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&templatesBefore, &_11$$17); + silence = 0; + zephir_is_iterable(&templatesBefore, 0, "phalcon/Mvc/View.zep", 1350); + if (Z_TYPE_P(&templatesBefore) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&templatesBefore), _12$$17) + { + ZEPHIR_INIT_NVAR(&templateBefore); + ZVAL_COPY(&templateBefore, _12$$17); + ZEPHIR_INIT_NVAR(&_14$$18); + ZEPHIR_CONCAT_VV(&_14$$18, &layoutsDir, &templateBefore); + if (silence) { + ZVAL_BOOL(&_15$$18, 1); + } else { + ZVAL_BOOL(&_15$$18, 0); } - ZEPHIR_INIT_NVAR(&status); - ZEPHIR_CALL_USER_FUNC(&status, &before); - zephir_check_call_status_or_jump(try_end_1); - } - zephir_read_property(&_21$$11, this_ptr, ZEND_STRL("stopped"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_21$$11)) { - RETURN_CCTOR(&status); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &beforeHandlers, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_17$$7, &beforeHandlers, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_17$$7)) { - break; - } - ZEPHIR_CALL_METHOD(&before, &beforeHandlers, "current", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &_14$$18, &_15$$18); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &templatesBefore, "rewind", NULL, 0); zephir_check_call_status(); - _22$$16 = Z_TYPE_P(&before) == IS_OBJECT; - if (_22$$16) { - _22$$16 = zephir_instance_of_ev(&before, phalcon_mvc_micro_middlewareinterface_ce); + while (1) { + ZEPHIR_CALL_METHOD(&_13$$17, &templatesBefore, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_13$$17)) { + break; } - if (_22$$16) { - ZEPHIR_CALL_METHOD(&status, &before, "call", NULL, 0, this_ptr); - zephir_check_call_status_or_jump(try_end_1); - } else { - if (UNEXPECTED(!(zephir_is_callable(&before)))) { - ZEPHIR_INIT_NVAR(&_23$$19); - object_init_ex(&_23$$19, phalcon_mvc_micro_exception_ce); - ZEPHIR_INIT_NVAR(&_24$$19); - ZVAL_STRING(&_24$$19, "'before' handler is not callable"); - ZEPHIR_CALL_METHOD(NULL, &_23$$19, "__construct", NULL, 33, &_24$$19); - zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception_debug(&_23$$19, "phalcon/Mvc/Micro.zep", 467); - goto try_end_1; - + ZEPHIR_CALL_METHOD(&templateBefore, &templatesBefore, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_16$$19); + ZEPHIR_CONCAT_VV(&_16$$19, &layoutsDir, &templateBefore); + if (silence) { + ZVAL_BOOL(&_17$$19, 1); + } else { + ZVAL_BOOL(&_17$$19, 0); } - ZEPHIR_INIT_NVAR(&status); - ZEPHIR_CALL_USER_FUNC(&status, &before); - zephir_check_call_status_or_jump(try_end_1); - } - zephir_read_property(&_25$$16, this_ptr, ZEND_STRL("stopped"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_25$$16)) { - RETURN_CCTOR(&status); - } - ZEPHIR_CALL_METHOD(NULL, &beforeHandlers, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&before); - ZEPHIR_CALL_METHOD(¶ms, &router, "getparams", NULL, 0); - zephir_check_call_status_or_jump(try_end_1); - zephir_read_property(&_15$$7, this_ptr, ZEND_STRL("modelBinder"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&modelBinder, &_15$$7); - _26$$7 = Z_TYPE_P(&handler) == IS_OBJECT; - if (_26$$7) { - _26$$7 = zephir_is_instance_of(&handler, SL("Closure")); - } - if (_26$$7) { - _28$$21 = zephir_fetch_class_str_ex(SL("Closure"), ZEND_FETCH_CLASS_AUTO); - ZEPHIR_CALL_CE_STATIC(&_27$$21, _28$$21, "bind", NULL, 0, &handler, this_ptr); - zephir_check_call_status_or_jump(try_end_1); - ZEPHIR_CPY_WRT(&handler, &_27$$21); - if (Z_TYPE_P(&modelBinder) != IS_NULL) { - ZEPHIR_CALL_METHOD(&routeName, &matchedRoute, "getname", NULL, 0); - zephir_check_call_status_or_jump(try_end_1); - if (Z_TYPE_P(&routeName) != IS_NULL) { - ZEPHIR_INIT_VAR(&_29$$23); - ZEPHIR_CONCAT_SV(&_29$$23, "_PHMB_", &routeName); - zephir_get_strval(&bindCacheKey, &_29$$23); - } else { - ZEPHIR_CALL_METHOD(&_30$$24, &matchedRoute, "getpattern", NULL, 0); - zephir_check_call_status_or_jump(try_end_1); - ZEPHIR_INIT_VAR(&_31$$24); - ZEPHIR_CONCAT_SV(&_31$$24, "_PHMB_", &_30$$24); - zephir_get_strval(&bindCacheKey, &_31$$24); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &_16$$19, &_17$$19); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &templatesBefore, "next", NULL, 0); + zephir_check_call_status(); } - ZEPHIR_CALL_METHOD(&_32$$22, &modelBinder, "bindtohandler", NULL, 0, &handler, ¶ms, &bindCacheKey); - zephir_check_call_status_or_jump(try_end_1); - ZEPHIR_CPY_WRT(¶ms, &_32$$22); - } - } - if (Z_TYPE_P(&handler) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&realHandler); - zephir_array_fetch_long(&realHandler, &handler, 0, PH_NOISY, "phalcon/Mvc/Micro.zep", 515); - _33$$25 = zephir_instance_of_ev(&realHandler, phalcon_mvc_controller_ce); - if (_33$$25) { - _33$$25 = Z_TYPE_P(&modelBinder) != IS_NULL; - } - if (_33$$25) { - zephir_memory_observe(&methodName); - zephir_array_fetch_long(&methodName, &handler, 1, PH_NOISY, "phalcon/Mvc/Micro.zep", 518); - ZEPHIR_INIT_VAR(&_34$$26); - zephir_get_class(&_34$$26, &realHandler, 0); - ZEPHIR_INIT_VAR(&_35$$26); - ZEPHIR_CONCAT_SVSV(&_35$$26, "_PHMB_", &_34$$26, "_", &methodName); - zephir_get_strval(&bindCacheKey, &_35$$26); - ZEPHIR_CALL_METHOD(&_36$$26, &modelBinder, "bindtohandler", NULL, 0, &realHandler, ¶ms, &bindCacheKey, &methodName); - zephir_check_call_status_or_jump(try_end_1); - ZEPHIR_CPY_WRT(¶ms, &_36$$26); } + ZEPHIR_INIT_NVAR(&templateBefore); + silence = 1; } - _37$$7 = Z_TYPE_P(&realHandler) != IS_NULL; - if (_37$$7) { - _37$$7 = zephir_instance_of_ev(&realHandler, phalcon_mvc_micro_lazyloader_ce); - } - if (_37$$7) { - ZEPHIR_OBS_NVAR(&methodName); - zephir_array_fetch_long(&methodName, &handler, 1, PH_NOISY, "phalcon/Mvc/Micro.zep", 535); - ZEPHIR_CALL_METHOD(&lazyReturned, &realHandler, "callmethod", NULL, 0, &methodName, ¶ms, &modelBinder); - zephir_check_call_status_or_jump(try_end_1); - } else { - ZEPHIR_INIT_NVAR(&lazyReturned); - ZEPHIR_CALL_USER_FUNC_ARRAY(&lazyReturned, &handler, ¶ms); - zephir_check_call_status_or_jump(try_end_1); - } - ZEPHIR_CPY_WRT(&returnedValue, &lazyReturned); - zephir_read_property(&_15$$7, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_15$$7) != IS_NULL) { - zephir_read_property(&_38$$29, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_40$$29); - ZVAL_STRING(&_40$$29, "micro:afterBinding"); - ZEPHIR_CALL_METHOD(&_39$$29, &_38$$29, "fire", NULL, 0, &_40$$29, this_ptr); - zephir_check_call_status_or_jump(try_end_1); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_39$$29)) { - RETURN_MM_BOOL(0); + } + if (renderLevel >= 3) { + if (!(zephir_array_isset_long(&disabledLevels, 3))) { + ZVAL_UNDEF(&_18$$21); + ZVAL_LONG(&_18$$21, 3); + zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_18$$21); + ZEPHIR_INIT_VAR(&_19$$21); + ZEPHIR_CONCAT_VV(&_19$$21, &layoutsDir, &layoutName); + if (silence) { + ZVAL_BOOL(&_18$$21, 1); + } else { + ZVAL_BOOL(&_18$$21, 0); } - } - zephir_read_property(&_41$$7, this_ptr, ZEND_STRL("afterBindingHandlers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&afterBindingHandlers, &_41$$7); - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$false); - } - zephir_is_iterable(&afterBindingHandlers, 0, "phalcon/Mvc/Micro.zep", 598); - if (Z_TYPE_P(&afterBindingHandlers) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&afterBindingHandlers), _42$$7) - { - ZEPHIR_INIT_NVAR(&afterBinding); - ZVAL_COPY(&afterBinding, _42$$7); - _44$$31 = Z_TYPE_P(&afterBinding) == IS_OBJECT; - if (_44$$31) { - _44$$31 = zephir_instance_of_ev(&afterBinding, phalcon_mvc_micro_middlewareinterface_ce); - } - if (_44$$31) { - ZEPHIR_CALL_METHOD(&status, &afterBinding, "call", NULL, 0, this_ptr); - zephir_check_call_status_or_jump(try_end_1); - } else { - if (UNEXPECTED(!(zephir_is_callable(&afterBinding)))) { - ZEPHIR_INIT_NVAR(&_45$$34); - object_init_ex(&_45$$34, phalcon_mvc_micro_exception_ce); - ZEPHIR_INIT_NVAR(&_46$$34); - ZVAL_STRING(&_46$$34, "'afterBinding' handler is not callable"); - ZEPHIR_CALL_METHOD(NULL, &_45$$34, "__construct", NULL, 33, &_46$$34); - zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception_debug(&_45$$34, "phalcon/Mvc/Micro.zep", 578); - goto try_end_1; - - } - ZEPHIR_INIT_NVAR(&status); - ZEPHIR_CALL_USER_FUNC(&status, &afterBinding); - zephir_check_call_status_or_jump(try_end_1); - } - zephir_read_property(&_47$$31, this_ptr, ZEND_STRL("stopped"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_47$$31)) { - RETURN_CCTOR(&status); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &afterBindingHandlers, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &_19$$21, &_18$$21); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_43$$7, &afterBindingHandlers, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_43$$7)) { - break; - } - ZEPHIR_CALL_METHOD(&afterBinding, &afterBindingHandlers, "current", NULL, 0); - zephir_check_call_status(); - _48$$36 = Z_TYPE_P(&afterBinding) == IS_OBJECT; - if (_48$$36) { - _48$$36 = zephir_instance_of_ev(&afterBinding, phalcon_mvc_micro_middlewareinterface_ce); - } - if (_48$$36) { - ZEPHIR_CALL_METHOD(&status, &afterBinding, "call", NULL, 0, this_ptr); - zephir_check_call_status_or_jump(try_end_1); - } else { - if (UNEXPECTED(!(zephir_is_callable(&afterBinding)))) { - ZEPHIR_INIT_NVAR(&_49$$39); - object_init_ex(&_49$$39, phalcon_mvc_micro_exception_ce); - ZEPHIR_INIT_NVAR(&_50$$39); - ZVAL_STRING(&_50$$39, "'afterBinding' handler is not callable"); - ZEPHIR_CALL_METHOD(NULL, &_49$$39, "__construct", NULL, 33, &_50$$39); - zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception_debug(&_49$$39, "phalcon/Mvc/Micro.zep", 578); - goto try_end_1; - - } - ZEPHIR_INIT_NVAR(&status); - ZEPHIR_CALL_USER_FUNC(&status, &afterBinding); - zephir_check_call_status_or_jump(try_end_1); - } - zephir_read_property(&_51$$36, this_ptr, ZEND_STRL("stopped"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_51$$36)) { - RETURN_CCTOR(&status); - } - ZEPHIR_CALL_METHOD(NULL, &afterBindingHandlers, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&afterBinding); - zephir_update_property_zval(this_ptr, ZEND_STRL("returnedValue"), &returnedValue); - zephir_read_property(&_41$$7, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_41$$7) != IS_NULL) { - zephir_read_property(&_52$$41, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_53$$41); - ZVAL_STRING(&_53$$41, "micro:afterExecuteRoute"); - ZEPHIR_CALL_METHOD(NULL, &_52$$41, "fire", NULL, 0, &_53$$41, this_ptr); - zephir_check_call_status_or_jump(try_end_1); - } - zephir_read_property(&_54$$7, this_ptr, ZEND_STRL("afterHandlers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&afterHandlers, &_54$$7); - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$false); } - zephir_is_iterable(&afterHandlers, 0, "phalcon/Mvc/Micro.zep", 637); - if (Z_TYPE_P(&afterHandlers) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&afterHandlers), _55$$7) - { - ZEPHIR_INIT_NVAR(&after); - ZVAL_COPY(&after, _55$$7); - _57$$42 = Z_TYPE_P(&after) == IS_OBJECT; - if (_57$$42) { - _57$$42 = zephir_instance_of_ev(&after, phalcon_mvc_micro_middlewareinterface_ce); - } - if (_57$$42) { - ZEPHIR_CALL_METHOD(&status, &after, "call", NULL, 0, this_ptr); - zephir_check_call_status_or_jump(try_end_1); - } else { - if (UNEXPECTED(!(zephir_is_callable(&after)))) { - ZEPHIR_INIT_NVAR(&_58$$45); - object_init_ex(&_58$$45, phalcon_mvc_micro_exception_ce); - ZEPHIR_INIT_NVAR(&_59$$45); - ZVAL_STRING(&_59$$45, "One of the 'after' handlers is not callable"); - ZEPHIR_CALL_METHOD(NULL, &_58$$45, "__construct", NULL, 33, &_59$$45); - zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception_debug(&_58$$45, "phalcon/Mvc/Micro.zep", 624); - goto try_end_1; - - } - ZEPHIR_INIT_NVAR(&status); - ZEPHIR_CALL_USER_FUNC(&status, &after); - zephir_check_call_status_or_jump(try_end_1); - } - zephir_read_property(&_60$$42, this_ptr, ZEND_STRL("stopped"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_60$$42)) { - break; - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &afterHandlers, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_56$$7, &afterHandlers, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_56$$7)) { - break; - } - ZEPHIR_CALL_METHOD(&after, &afterHandlers, "current", NULL, 0); - zephir_check_call_status(); - _61$$47 = Z_TYPE_P(&after) == IS_OBJECT; - if (_61$$47) { - _61$$47 = zephir_instance_of_ev(&after, phalcon_mvc_micro_middlewareinterface_ce); - } - if (_61$$47) { - ZEPHIR_CALL_METHOD(&status, &after, "call", NULL, 0, this_ptr); - zephir_check_call_status_or_jump(try_end_1); + } + if (renderLevel >= 4) { + if (!(zephir_array_isset_long(&disabledLevels, 4))) { + ZVAL_UNDEF(&_20$$23); + ZVAL_LONG(&_20$$23, 4); + zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_20$$23); + zephir_read_property(&_20$$23, this_ptr, ZEND_STRL("templatesAfter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&templatesAfter, &_20$$23); + silence = 0; + zephir_is_iterable(&templatesAfter, 0, "phalcon/Mvc/View.zep", 1386); + if (Z_TYPE_P(&templatesAfter) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&templatesAfter), _21$$23) + { + ZEPHIR_INIT_NVAR(&templateAfter); + ZVAL_COPY(&templateAfter, _21$$23); + ZEPHIR_INIT_NVAR(&_23$$24); + ZEPHIR_CONCAT_VV(&_23$$24, &layoutsDir, &templateAfter); + if (silence) { + ZVAL_BOOL(&_24$$24, 1); } else { - if (UNEXPECTED(!(zephir_is_callable(&after)))) { - ZEPHIR_INIT_NVAR(&_62$$50); - object_init_ex(&_62$$50, phalcon_mvc_micro_exception_ce); - ZEPHIR_INIT_NVAR(&_63$$50); - ZVAL_STRING(&_63$$50, "One of the 'after' handlers is not callable"); - ZEPHIR_CALL_METHOD(NULL, &_62$$50, "__construct", NULL, 33, &_63$$50); - zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception_debug(&_62$$50, "phalcon/Mvc/Micro.zep", 624); - goto try_end_1; - - } - ZEPHIR_INIT_NVAR(&status); - ZEPHIR_CALL_USER_FUNC(&status, &after); - zephir_check_call_status_or_jump(try_end_1); + ZVAL_BOOL(&_24$$24, 0); } - zephir_read_property(&_64$$47, this_ptr, ZEND_STRL("stopped"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_64$$47)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &_23$$24, &_24$$24); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &templatesAfter, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_22$$23, &templatesAfter, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_22$$23)) { break; } - ZEPHIR_CALL_METHOD(NULL, &afterHandlers, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&after); - } else { - zephir_read_property(&_65$$52, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_65$$52) != IS_NULL) { - zephir_read_property(&_66$$53, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_68$$53); - ZVAL_STRING(&_68$$53, "micro:beforeNotFound"); - ZEPHIR_CALL_METHOD(&_67$$53, &_66$$53, "fire", NULL, 0, &_68$$53, this_ptr); - zephir_check_call_status_or_jump(try_end_1); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_67$$53)) { - RETURN_MM_BOOL(0); - } - } - zephir_read_property(&_69$$52, this_ptr, ZEND_STRL("notFoundHandler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(¬FoundHandler, &_69$$52); - if (UNEXPECTED(!(zephir_is_callable(¬FoundHandler)))) { - ZEPHIR_INIT_VAR(&_70$$55); - object_init_ex(&_70$$55, phalcon_mvc_micro_exception_ce); - ZEPHIR_INIT_VAR(&_71$$55); - ZVAL_STRING(&_71$$55, "Not-Found handler is not callable or is not defined"); - ZEPHIR_CALL_METHOD(NULL, &_70$$55, "__construct", NULL, 33, &_71$$55); - zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception_debug(&_70$$55, "phalcon/Mvc/Micro.zep", 655); - goto try_end_1; - - } - ZEPHIR_INIT_NVAR(&returnedValue); - ZEPHIR_CALL_USER_FUNC(&returnedValue, ¬FoundHandler); - zephir_check_call_status_or_jump(try_end_1); - } - zephir_read_property(&_72$$4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_72$$4) != IS_NULL) { - zephir_read_property(&_73$$56, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_74$$56); - ZVAL_STRING(&_74$$56, "micro:afterHandleRoute"); - ZEPHIR_CALL_METHOD(NULL, &_73$$56, "fire", NULL, 0, &_74$$56, this_ptr, &returnedValue); - zephir_check_call_status_or_jump(try_end_1); - } - zephir_read_property(&_75$$4, this_ptr, ZEND_STRL("finishHandlers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&finishHandlers, &_75$$4); - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$false); - } - zephir_is_iterable(&finishHandlers, 0, "phalcon/Mvc/Micro.zep", 709); - if (Z_TYPE_P(&finishHandlers) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&finishHandlers), _76$$4) - { - ZEPHIR_INIT_NVAR(&finish); - ZVAL_COPY(&finish, _76$$4); - _78$$57 = Z_TYPE_P(&finish) == IS_OBJECT; - if (_78$$57) { - _78$$57 = zephir_instance_of_ev(&finish, phalcon_mvc_micro_middlewareinterface_ce); - } - if (_78$$57) { - ZEPHIR_CALL_METHOD(&status, &finish, "call", NULL, 0, this_ptr); - zephir_check_call_status_or_jump(try_end_1); - } else { - if (UNEXPECTED(!(zephir_is_callable(&finish)))) { - ZEPHIR_INIT_NVAR(&_79$$60); - object_init_ex(&_79$$60, phalcon_mvc_micro_exception_ce); - ZEPHIR_INIT_NVAR(&_80$$60); - ZVAL_STRING(&_80$$60, "One of the 'finish' handlers is not callable"); - ZEPHIR_CALL_METHOD(NULL, &_79$$60, "__construct", NULL, 33, &_80$$60); - zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception_debug(&_79$$60, "phalcon/Mvc/Micro.zep", 690); - goto try_end_1; - + ZEPHIR_CALL_METHOD(&templateAfter, &templatesAfter, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_25$$25); + ZEPHIR_CONCAT_VV(&_25$$25, &layoutsDir, &templateAfter); + if (silence) { + ZVAL_BOOL(&_26$$25, 1); + } else { + ZVAL_BOOL(&_26$$25, 0); + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &_25$$25, &_26$$25); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &templatesAfter, "next", NULL, 0); + zephir_check_call_status(); } - ZEPHIR_INIT_NVAR(&_81$$59); - zephir_create_array(&_81$$59, 1, 0); - zephir_array_fast_append(&_81$$59, this_ptr); - ZEPHIR_INIT_NVAR(&status); - ZEPHIR_CALL_USER_FUNC_ARRAY(&status, &finish, &_81$$59); - zephir_check_call_status_or_jump(try_end_1); - } - zephir_read_property(&_82$$57, this_ptr, ZEND_STRL("stopped"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_82$$57)) { - break; - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &finishHandlers, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_77$$4, &finishHandlers, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_77$$4)) { - break; } - ZEPHIR_CALL_METHOD(&finish, &finishHandlers, "current", NULL, 0); - zephir_check_call_status(); - _83$$62 = Z_TYPE_P(&finish) == IS_OBJECT; - if (_83$$62) { - _83$$62 = zephir_instance_of_ev(&finish, phalcon_mvc_micro_middlewareinterface_ce); - } - if (_83$$62) { - ZEPHIR_CALL_METHOD(&status, &finish, "call", NULL, 0, this_ptr); - zephir_check_call_status_or_jump(try_end_1); - } else { - if (UNEXPECTED(!(zephir_is_callable(&finish)))) { - ZEPHIR_INIT_NVAR(&_84$$65); - object_init_ex(&_84$$65, phalcon_mvc_micro_exception_ce); - ZEPHIR_INIT_NVAR(&_85$$65); - ZVAL_STRING(&_85$$65, "One of the 'finish' handlers is not callable"); - ZEPHIR_CALL_METHOD(NULL, &_84$$65, "__construct", NULL, 33, &_85$$65); - zephir_check_call_status_or_jump(try_end_1); - zephir_throw_exception_debug(&_84$$65, "phalcon/Mvc/Micro.zep", 690); - goto try_end_1; - - } - ZEPHIR_INIT_NVAR(&_86$$64); - zephir_create_array(&_86$$64, 1, 0); - zephir_array_fast_append(&_86$$64, this_ptr); - ZEPHIR_INIT_NVAR(&status); - ZEPHIR_CALL_USER_FUNC_ARRAY(&status, &finish, &_86$$64); - zephir_check_call_status_or_jump(try_end_1); - } - zephir_read_property(&_87$$62, this_ptr, ZEND_STRL("stopped"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_87$$62)) { - break; - } - ZEPHIR_CALL_METHOD(NULL, &finishHandlers, "next", NULL, 0); - zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&templateAfter); + silence = 1; } } - ZEPHIR_INIT_NVAR(&finish); - - try_end_1: - - if (EG(exception)) { - ZEPHIR_INIT_VAR(&_88); - ZVAL_OBJ(&_88, EG(exception)); - Z_ADDREF_P(&_88); - if (zephir_is_instance_of(&_88, SL("Throwable"))) { - zend_clear_exception(); - ZEPHIR_CPY_WRT(&e, &_88); - zephir_read_property(&_89$$67, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_89$$67) != IS_NULL) { - zephir_read_property(&_90$$68, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_91$$68); - ZVAL_STRING(&_91$$68, "micro:beforeException"); - ZEPHIR_CALL_METHOD(&returnedValue, &_90$$68, "fire", NULL, 0, &_91$$68, this_ptr, &e); - zephir_check_call_status(); - } - zephir_read_property(&_92$$67, this_ptr, ZEND_STRL("errorHandler"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_92$$67) != IS_NULL) { - zephir_read_property(&_93$$69, this_ptr, ZEND_STRL("errorHandler"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(!(zephir_is_callable(&_93$$69)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "Error handler is not callable", "phalcon/Mvc/Micro.zep", 726); - return; - } - zephir_read_property(&_94$$69, this_ptr, ZEND_STRL("errorHandler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_95$$69); - zephir_create_array(&_95$$69, 1, 0); - zephir_array_fast_append(&_95$$69, &e); - ZEPHIR_INIT_NVAR(&returnedValue); - ZEPHIR_CALL_USER_FUNC_ARRAY(&returnedValue, &_94$$69, &_95$$69); - zephir_check_call_status(); - if (Z_TYPE_P(&returnedValue) == IS_OBJECT) { - if (!(zephir_instance_of_ev(&returnedValue, phalcon_http_responseinterface_ce))) { - zephir_throw_exception_debug(&e, "phalcon/Mvc/Micro.zep", 739); - ZEPHIR_MM_RESTORE(); - return; - } + if (renderLevel >= 5) { + if (!(zephir_array_isset_long(&disabledLevels, 5))) { + ZVAL_UNDEF(&_27$$27); + ZVAL_LONG(&_27$$27, 5); + zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_27$$27); + zephir_read_property(&_27$$27, this_ptr, ZEND_STRL("mainView"), PH_NOISY_CC | PH_READONLY); + if (silence) { + ZVAL_BOOL(&_28$$27, 1); } else { - if (!ZEPHIR_IS_FALSE_IDENTICAL(&returnedValue)) { - zephir_throw_exception_debug(&e, "phalcon/Mvc/Micro.zep", 743); - ZEPHIR_MM_RESTORE(); - return; - } - } - } else { - if (!ZEPHIR_IS_FALSE_IDENTICAL(&returnedValue)) { - zephir_throw_exception_debug(&e, "phalcon/Mvc/Micro.zep", 748); - ZEPHIR_MM_RESTORE(); - return; + ZVAL_BOOL(&_28$$27, 0); } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &_27$$27, &_28$$27); + zephir_check_call_status(); } } + ZVAL_UNDEF(&_29$$13); + ZVAL_LONG(&_29$$13, 0); + zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_29$$13); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("responseHandler"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_0)) { - zephir_read_property(&_96$$77, this_ptr, ZEND_STRL("responseHandler"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(!(zephir_is_callable(&_96$$77)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "Response handler is not callable or is not defined", "phalcon/Mvc/Micro.zep", 761); - return; - } - zephir_read_property(&_97$$77, this_ptr, ZEND_STRL("responseHandler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&returnedValue); - ZEPHIR_CALL_USER_FUNC(&returnedValue, &_97$$77); + _30 = fireEvents; + if (_30) { + _30 = Z_TYPE_P(&eventsManager) == IS_OBJECT; + } + if (_30) { + ZEPHIR_INIT_VAR(&_31$$28); + ZVAL_STRING(&_31$$28, "view:afterRender"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_31$$28, this_ptr); zephir_check_call_status(); - } else { - if (Z_TYPE_P(&returnedValue) == IS_STRING) { - ZEPHIR_INIT_VAR(&_99$$80); - ZVAL_STRING(&_99$$80, "response"); - ZEPHIR_CALL_METHOD(&_98$$80, &container, "getshared", NULL, 0, &_99$$80); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&response, &_98$$80); - ZEPHIR_CALL_METHOD(&_98$$80, &response, "issent", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_98$$80))) { - ZEPHIR_CALL_METHOD(NULL, &response, "setcontent", NULL, 0, &returnedValue); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &response, "send", NULL, 0); - zephir_check_call_status(); - } - } - _100$$79 = Z_TYPE_P(&returnedValue) == IS_OBJECT; - if (_100$$79) { - _100$$79 = zephir_instance_of_ev(&returnedValue, phalcon_http_responseinterface_ce); - } - _101$$79 = _100$$79; - if (_101$$79) { - ZEPHIR_CALL_METHOD(&_102$$79, &returnedValue, "issent", NULL, 0); - zephir_check_call_status(); - _101$$79 = !zephir_is_true(&_102$$79); - } - if (_101$$79) { - ZEPHIR_CALL_METHOD(NULL, &returnedValue, "send", NULL, 0); - zephir_check_call_status(); - } } - RETURN_CCTOR(&returnedValue); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_Micro, hasService) +static PHP_METHOD(Phalcon_Mvc_View, getDirSeparator) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *serviceName_param = NULL, _0, _2, _1$$3; - zval serviceName; - zval *this_ptr = getThis(); + zval *directory_param = NULL, _0, _1; + zval directory; - ZVAL_UNDEF(&serviceName); + ZVAL_UNDEF(&directory); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(serviceName) + Z_PARAM_STR(directory) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &serviceName_param); - if (UNEXPECTED(Z_TYPE_P(serviceName_param) != IS_STRING && Z_TYPE_P(serviceName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'serviceName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(serviceName_param) == IS_STRING)) { - zephir_get_strval(&serviceName, serviceName_param); - } else { - ZEPHIR_INIT_VAR(&serviceName); + zephir_fetch_params(1, 1, 0, &directory_param); + if (UNEXPECTED(Z_TYPE_P(directory_param) != IS_STRING && Z_TYPE_P(directory_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'directory' must be of the type string")); + RETURN_MM_NULL(); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_di_factorydefault_ce); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 416); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &_1$$3); + if (EXPECTED(Z_TYPE_P(directory_param) == IS_STRING)) { + zephir_get_strval(&directory, directory_param); + } else { + ZEPHIR_INIT_VAR(&directory); } - zephir_read_property(&_2, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_2, "has", NULL, 0, &serviceName); - zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "/"); + zephir_fast_trim(&_0, &directory, &_1, ZEPHIR_TRIM_RIGHT); + ZEPHIR_CONCAT_VS(return_value, &_0, "/"); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Micro, head) +zend_object *zephir_init_properties_Phalcon_Mvc_View(zend_class_entry *class_type) { + zval _0, _2, _4, _6, _8, _10, _12, _14, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8, _13$$9, _15$$10; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, router, route, _0; - zval routePattern; - zval *this_ptr = getThis(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_9$$7); + ZVAL_UNDEF(&_11$$8); + ZVAL_UNDEF(&_13$$9); + ZVAL_UNDEF(&_15$$10); + - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&router); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); - } else { - ZEPHIR_INIT_VAR(&routePattern); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("viewParams"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("viewParams"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("viewsDirs"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("viewsDirs"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("templatesBefore"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("templatesBefore"), &_5$$5); + } + zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("templatesAfter"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_6) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$6); + array_init(&_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("templatesAfter"), &_7$$6); + } + zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("registeredEngines"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_8) == IS_NULL) { + ZEPHIR_INIT_VAR(&_9$$7); + array_init(&_9$$7); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("registeredEngines"), &_9$$7); + } + zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_10) == IS_NULL) { + ZEPHIR_INIT_VAR(&_11$$8); + array_init(&_11$$8); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_11$$8); + } + zephir_read_property_ex(&_12, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_12) == IS_NULL) { + ZEPHIR_INIT_VAR(&_13$$9); + array_init(&_13$$9); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_13$$9); + } + zephir_read_property_ex(&_14, this_ptr, ZEND_STRL("disabledLevels"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_14) == IS_NULL) { + ZEPHIR_INIT_VAR(&_15$$10); + array_init(&_15$$10); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("disabledLevels"), &_15$$10); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } - ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&route, &router, "addhead", NULL, 0, &routePattern); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, &route, "getrouteid", NULL, 0); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("handlers"), &_0, handler); - RETURN_CCTOR(&route); } -static PHP_METHOD(Phalcon_Mvc_Micro, map) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, router, route, _0; - zval routePattern; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&router); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); - } else { - ZEPHIR_INIT_VAR(&routePattern); - } - ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&route, &router, "add", NULL, 0, &routePattern); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, &route, "getrouteid", NULL, 0); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("handlers"), &_0, handler); - RETURN_CCTOR(&route); -} -static PHP_METHOD(Phalcon_Mvc_Micro, mount) -{ - zend_bool _4$$7, _5$$7, _7$$15, _8$$15; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collection, collection_sub, mainHandler, handlers, lazyHandler, prefix, methods, pattern, subHandler, realHandler, prefixedPattern, route, handler, name, _0, *_1, _2, _6$$15; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection_sub); - ZVAL_UNDEF(&mainHandler); - ZVAL_UNDEF(&handlers); - ZVAL_UNDEF(&lazyHandler); - ZVAL_UNDEF(&prefix); - ZVAL_UNDEF(&methods); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&subHandler); - ZVAL_UNDEF(&realHandler); - ZVAL_UNDEF(&prefixedPattern); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&handler); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_6$$15); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(collection, phalcon_mvc_micro_collectioninterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &collection); - ZEPHIR_CALL_METHOD(&mainHandler, collection, "gethandler", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(ZEPHIR_IS_EMPTY(&mainHandler))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "Collection requires a main handler", "phalcon/Mvc/Micro.zep", 876); - return; - } - ZEPHIR_CALL_METHOD(&handlers, collection, "gethandlers", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(!(zephir_fast_count_int(&handlers)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "There are no handlers to mount", "phalcon/Mvc/Micro.zep", 882); - return; - } - ZEPHIR_CALL_METHOD(&_0, collection, "islazy", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&_0)) { - ZEPHIR_INIT_VAR(&lazyHandler); - object_init_ex(&lazyHandler, phalcon_mvc_micro_lazyloader_ce); - ZEPHIR_CALL_METHOD(NULL, &lazyHandler, "__construct", NULL, 417, &mainHandler); - zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&lazyHandler, &mainHandler); - } - ZEPHIR_CALL_METHOD(&prefix, collection, "getprefix", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&handlers, 0, "phalcon/Mvc/Micro.zep", 940); - if (Z_TYPE_P(&handlers) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&handlers), _1) - { - ZEPHIR_INIT_NVAR(&handler); - ZVAL_COPY(&handler, _1); - if (UNEXPECTED(Z_TYPE_P(&handler) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "One of the registered handlers is invalid", "phalcon/Mvc/Micro.zep", 903); - return; - } - ZEPHIR_OBS_NVAR(&methods); - zephir_array_fetch_long(&methods, &handler, 0, PH_NOISY, "phalcon/Mvc/Micro.zep", 906); - ZEPHIR_OBS_NVAR(&pattern); - zephir_array_fetch_long(&pattern, &handler, 1, PH_NOISY, "phalcon/Mvc/Micro.zep", 907); - ZEPHIR_OBS_NVAR(&subHandler); - zephir_array_fetch_long(&subHandler, &handler, 2, PH_NOISY, "phalcon/Mvc/Micro.zep", 908); - ZEPHIR_OBS_NVAR(&name); - zephir_array_fetch_long(&name, &handler, 3, PH_NOISY, "phalcon/Mvc/Micro.zep", 909); - ZEPHIR_INIT_NVAR(&realHandler); - zephir_create_array(&realHandler, 2, 0); - zephir_array_fast_append(&realHandler, &lazyHandler); - zephir_array_fast_append(&realHandler, &subHandler); - if (!(ZEPHIR_IS_EMPTY(&prefix))) { - if (ZEPHIR_IS_STRING_IDENTICAL(&pattern, "/")) { - ZEPHIR_CPY_WRT(&prefixedPattern, &prefix); - } else { - ZEPHIR_INIT_NVAR(&prefixedPattern); - ZEPHIR_CONCAT_VV(&prefixedPattern, &prefix, &pattern); - } - } else { - ZEPHIR_CPY_WRT(&prefixedPattern, &pattern); - } - ZEPHIR_CALL_METHOD(&route, this_ptr, "map", &_3, 0, &prefixedPattern, &realHandler); - zephir_check_call_status(); - _4$$7 = Z_TYPE_P(&methods) == IS_STRING; - if (_4$$7) { - _4$$7 = !ZEPHIR_IS_STRING_IDENTICAL(&methods, ""); - } - _5$$7 = _4$$7; - if (!(_5$$7)) { - _5$$7 = Z_TYPE_P(&methods) == IS_ARRAY; - } - if (_5$$7) { - ZEPHIR_CALL_METHOD(NULL, &route, "via", NULL, 0, &methods); - zephir_check_call_status(); - } - if (Z_TYPE_P(&name) == IS_STRING) { - ZEPHIR_CALL_METHOD(NULL, &route, "setname", NULL, 0, &name); - zephir_check_call_status(); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &handlers, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &handlers, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&handler, &handlers, "current", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&handler) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_micro_exception_ce, "One of the registered handlers is invalid", "phalcon/Mvc/Micro.zep", 903); - return; - } - ZEPHIR_OBS_NVAR(&methods); - zephir_array_fetch_long(&methods, &handler, 0, PH_NOISY, "phalcon/Mvc/Micro.zep", 906); - ZEPHIR_OBS_NVAR(&pattern); - zephir_array_fetch_long(&pattern, &handler, 1, PH_NOISY, "phalcon/Mvc/Micro.zep", 907); - ZEPHIR_OBS_NVAR(&subHandler); - zephir_array_fetch_long(&subHandler, &handler, 2, PH_NOISY, "phalcon/Mvc/Micro.zep", 908); - ZEPHIR_OBS_NVAR(&name); - zephir_array_fetch_long(&name, &handler, 3, PH_NOISY, "phalcon/Mvc/Micro.zep", 909); - ZEPHIR_INIT_NVAR(&_6$$15); - zephir_create_array(&_6$$15, 2, 0); - zephir_array_fast_append(&_6$$15, &lazyHandler); - zephir_array_fast_append(&_6$$15, &subHandler); - ZEPHIR_CPY_WRT(&realHandler, &_6$$15); - if (!(ZEPHIR_IS_EMPTY(&prefix))) { - if (ZEPHIR_IS_STRING_IDENTICAL(&pattern, "/")) { - ZEPHIR_CPY_WRT(&prefixedPattern, &prefix); - } else { - ZEPHIR_INIT_NVAR(&prefixedPattern); - ZEPHIR_CONCAT_VV(&prefixedPattern, &prefix, &pattern); - } - } else { - ZEPHIR_CPY_WRT(&prefixedPattern, &pattern); - } - ZEPHIR_CALL_METHOD(&route, this_ptr, "map", &_3, 0, &prefixedPattern, &realHandler); - zephir_check_call_status(); - _7$$15 = Z_TYPE_P(&methods) == IS_STRING; - if (_7$$15) { - _7$$15 = !ZEPHIR_IS_STRING_IDENTICAL(&methods, ""); - } - _8$$15 = _7$$15; - if (!(_8$$15)) { - _8$$15 = Z_TYPE_P(&methods) == IS_ARRAY; - } - if (_8$$15) { - ZEPHIR_CALL_METHOD(NULL, &route, "via", NULL, 0, &methods); - zephir_check_call_status(); - } - if (Z_TYPE_P(&name) == IS_STRING) { - ZEPHIR_CALL_METHOD(NULL, &route, "setname", NULL, 0, &name); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(NULL, &handlers, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&handler); - RETURN_THIS(); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Mvc_Micro, notFound) + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_ViewBaseInterface) { - zval *handler, handler_sub; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ViewBaseInterface, phalcon, mvc_viewbaseinterface, phalcon_mvc_viewbaseinterface_method_entry); - ZVAL_UNDEF(&handler_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(handler) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &handler); - zephir_update_property_zval(this_ptr, ZEND_STRL("notFoundHandler"), handler); - RETURN_THISW(); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Micro, offsetExists) +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, getContent); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, getParamsToView); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, getViewsDir); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, partial); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, setContent); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, setParamToView); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, setVar); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, setViewsDir); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_ViewInterface) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval offset_sub; - zval *offset; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ViewInterface, phalcon, mvc_viewinterface, phalcon_mvc_viewinterface_method_entry); - ZVAL_UNDEF(&offset_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(offset) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &offset); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hasservice", NULL, 0, offset); - zephir_check_call_status(); - RETURN_MM(); + zend_class_implements(phalcon_mvc_viewinterface_ce, 1, phalcon_mvc_viewbaseinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Micro, offsetGet) +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, cleanTemplateAfter); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, cleanTemplateBefore); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, disable); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, enable); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, finish); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getActionName); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getActiveRenderPath); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getBasePath); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getControllerName); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getLayout); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getLayoutsDir); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getMainView); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getPartialsDir); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, isDisabled); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, pick); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, registerEngines); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, render); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, reset); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setBasePath); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setLayout); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setLayoutsDir); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setMainView); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setPartialsDir); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setRenderLevel); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setTemplateAfter); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setTemplateBefore); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, start); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Dispatcher_Exception) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval offset_sub; - zval *offset; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Dispatcher, Exception, phalcon, mvc_dispatcher_exception, phalcon_dispatcher_exception_ce, NULL, 0); - ZVAL_UNDEF(&offset_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(offset) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &offset); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getservice", NULL, 0, offset); - zephir_check_call_status(); - RETURN_MM(); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Micro, offsetSet) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Behavior) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval offset_sub, value_sub; - zval *offset, *value; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Behavior, phalcon, mvc_model_behavior, phalcon_mvc_model_behavior_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - ZVAL_UNDEF(&offset_sub); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(offset) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &offset, &value); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setservice", NULL, 0, offset, value); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + zend_declare_property_null(phalcon_mvc_model_behavior_ce, SL("options"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_mvc_model_behavior_ce, 1, phalcon_mvc_model_behaviorinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Micro, offsetUnset) +static PHP_METHOD(Phalcon_Mvc_Model_Behavior, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval offset_sub, _0, _2, _1$$3; - zval *offset; + zval *options_param = NULL; + zval options; zval *this_ptr = getThis(); - ZVAL_UNDEF(&offset_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(offset) + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &offset); - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_di_factorydefault_ce); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 416); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &_1$$3); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); } - zephir_read_property(&_2, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_2, "remove", NULL, 0, offset); - zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Micro, options) +static PHP_METHOD(Phalcon_Mvc_Model_Behavior, getOptions) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, router, route, _0; - zval routePattern; + zval *eventName_param = NULL, options, eventOptions, _0; + zval eventName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&router); - ZVAL_UNDEF(&route); + ZVAL_UNDEF(&eventName); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&eventOptions); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(eventName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + zephir_fetch_params(1, 0, 1, &eventName_param); + if (!eventName_param) { + ZEPHIR_INIT_VAR(&eventName); + } else { + if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); + if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { + zephir_get_strval(&eventName, eventName_param); } else { - ZEPHIR_INIT_VAR(&routePattern); + ZEPHIR_INIT_VAR(&eventName); } - ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&route, &router, "addoptions", NULL, 0, &routePattern); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, &route, "getrouteid", NULL, 0); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("handlers"), &_0, handler); - RETURN_CCTOR(&route); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&options, &_0); + if (!ZEPHIR_IS_NULL(&eventName)) { + zephir_memory_observe(&eventOptions); + if (!(zephir_array_isset_fetch(&eventOptions, &options, &eventName, 0))) { + RETURN_MM_NULL(); + } + RETURN_CCTOR(&eventOptions); + } + RETURN_CCTOR(&options); } -static PHP_METHOD(Phalcon_Mvc_Micro, patch) +static PHP_METHOD(Phalcon_Mvc_Model_Behavior, missingMethod) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, router, route, _0; - zval routePattern; - zval *this_ptr = getThis(); + zval arguments; + zval method; + zval *model, model_sub, *method_param = NULL, *arguments_param = NULL; - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&router); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&arguments); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_STR(method) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(arguments) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); + zephir_fetch_params(1, 2, 1, &model, &method_param, &arguments_param); + zephir_get_strval(&method, method_param); + if (!arguments_param) { + ZEPHIR_INIT_VAR(&arguments); + array_init(&arguments); } else { - ZEPHIR_INIT_VAR(&routePattern); + zephir_get_arrval(&arguments, arguments_param); } - ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&route, &router, "addpatch", NULL, 0, &routePattern); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, &route, "getrouteid", NULL, 0); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("handlers"), &_0, handler); - RETURN_CCTOR(&route); + RETURN_MM_NULL(); } -static PHP_METHOD(Phalcon_Mvc_Micro, post) +static PHP_METHOD(Phalcon_Mvc_Model_Behavior, mustTakeAction) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, router, route, _0; - zval routePattern; + zval *eventName_param = NULL, _0; + zval eventName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&router); - ZVAL_UNDEF(&route); + ZVAL_UNDEF(&eventName); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(eventName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + zephir_fetch_params(1, 1, 0, &eventName_param); + if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); + if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { + zephir_get_strval(&eventName, eventName_param); } else { - ZEPHIR_INIT_VAR(&routePattern); + ZEPHIR_INIT_VAR(&eventName); } - ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&route, &router, "addpost", NULL, 0, &routePattern); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, &route, "getrouteid", NULL, 0); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("handlers"), &_0, handler); - RETURN_CCTOR(&route); + zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + RETURN_MM_BOOL(zephir_array_isset(&_0, &eventName)); } -static PHP_METHOD(Phalcon_Mvc_Micro, put) +static PHP_METHOD(Phalcon_Mvc_Model_Behavior, notify) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, router, route, _0; - zval routePattern; - zval *this_ptr = getThis(); + zval *type_param = NULL, *model, model_sub; + zval type; - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&router); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&model_sub); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) + Z_PARAM_STR(type) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &routePattern_param, &handler); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); - } else { - ZEPHIR_INIT_VAR(&routePattern); - } - ZEPHIR_CALL_METHOD(&router, this_ptr, "getrouter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&route, &router, "addput", NULL, 0, &routePattern); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, &route, "getrouteid", NULL, 0); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("handlers"), &_0, handler); - RETURN_CCTOR(&route); + zephir_fetch_params(1, 2, 0, &type_param, &model); + zephir_get_strval(&type, type_param); + RETURN_MM_NULL(); } -static PHP_METHOD(Phalcon_Mvc_Micro, setActiveHandler) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_BehaviorInterface) { - zval *activeHandler, activeHandler_sub; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, BehaviorInterface, phalcon, mvc_model_behaviorinterface, phalcon_mvc_model_behaviorinterface_method_entry); - ZVAL_UNDEF(&activeHandler_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(activeHandler) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &activeHandler); - zephir_update_property_zval(this_ptr, ZEND_STRL("activeHandler"), activeHandler); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Micro, setDI) +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BehaviorInterface, missingMethod); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BehaviorInterface, notify); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Binder) { - zval *container, container_sub; + ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Binder, phalcon, mvc_model_binder, phalcon_mvc_model_binder_method_entry, 0); + + zend_declare_property_null(phalcon_mvc_model_binder_ce, SL("boundModels"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_binder_ce, SL("cache"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_binder_ce, SL("internalCache"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_binder_ce, SL("originalValues"), ZEND_ACC_PROTECTED); + phalcon_mvc_model_binder_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Binder; + + zend_class_implements(phalcon_mvc_model_binder_ce, 1, phalcon_mvc_model_binderinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Mvc_Model_Binder, __construct) +{ + zval *cache = NULL, cache_sub, __$null; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + ZVAL_UNDEF(&cache_sub); + ZVAL_NULL(&__$null); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(cache, phalcon_cache_adapter_adapterinterface_ce) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &container); - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); + zephir_fetch_params_without_memory_grow(0, 1, &cache); + if (!cache) { + cache = &cache_sub; + cache = &__$null; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), cache); } -static PHP_METHOD(Phalcon_Mvc_Micro, setModelBinder) +static PHP_METHOD(Phalcon_Mvc_Model_Binder, bindToHandler) { + zend_string *_6$$4; + zend_ulong _5$$4; + zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_7 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelBinder, modelBinder_sub, *cache = NULL, cache_sub, __$null, _0$$3; + zval cacheKey, methodName; + zval params; + zval *handler, handler_sub, *params_param = NULL, *cacheKey_param = NULL, *methodName_param = NULL, paramKey, className, boundModel, paramsCache, paramValue, _0, _2, *_3$$4, _4$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelBinder_sub); - ZVAL_UNDEF(&cache_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(¶mKey); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&boundModel); + ZVAL_UNDEF(¶msCache); + ZVAL_UNDEF(¶mValue); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&cacheKey); + ZVAL_UNDEF(&methodName); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(modelBinder, phalcon_mvc_model_binderinterface_ce) + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_OBJECT(handler) + Z_PARAM_ARRAY(params) + Z_PARAM_STR(cacheKey) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(cache) + Z_PARAM_STR_OR_NULL(methodName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &modelBinder, &cache); - if (!cache) { - cache = &cache_sub; - ZEPHIR_CPY_WRT(cache, &__$null); + zephir_fetch_params(1, 3, 1, &handler, ¶ms_param, &cacheKey_param, &methodName_param); + zephir_get_arrval(¶ms, params_param); + zephir_get_strval(&cacheKey, cacheKey_param); + if (!methodName_param) { + ZEPHIR_INIT_VAR(&methodName); } else { - ZEPHIR_SEPARATE_PARAM(cache); + if (UNEXPECTED(Z_TYPE_P(methodName_param) != IS_STRING && Z_TYPE_P(methodName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'methodName' must be of the type string")); + RETURN_MM_NULL(); } - if (Z_TYPE_P(cache) == IS_STRING) { - ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "getservice", NULL, 0, cache); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(cache, &_0$$3); + if (EXPECTED(Z_TYPE_P(methodName_param) == IS_STRING)) { + zephir_get_strval(&methodName, methodName_param); + } else { + ZEPHIR_INIT_VAR(&methodName); } - if (Z_TYPE_P(cache) != IS_NULL) { - ZEPHIR_CALL_METHOD(NULL, modelBinder, "setcache", NULL, 0, cache); - zephir_check_call_status(); } - zephir_update_property_zval(this_ptr, ZEND_STRL("modelBinder"), modelBinder); - RETURN_THIS(); + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("originalValues"), &_0); + _1 = !((zephir_is_instance_of(handler, SL("Closure")))); + if (_1) { + _1 = ZEPHIR_IS_NULL(&methodName); + } + if (UNEXPECTED(_1)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "You must specify methodName for handler or pass Closure as handler", "phalcon/Mvc/Model/Binder.zep", 75); + return; + } + ZEPHIR_INIT_VAR(&_2); + array_init(&_2); + zephir_update_property_zval(this_ptr, ZEND_STRL("boundModels"), &_2); + ZEPHIR_CALL_METHOD(¶msCache, this_ptr, "getparamsfromcache", NULL, 0, &cacheKey); + zephir_check_call_status(); + if (Z_TYPE_P(¶msCache) == IS_ARRAY) { + zephir_is_iterable(¶msCache, 0, "phalcon/Mvc/Model/Binder.zep", 90); + if (Z_TYPE_P(¶msCache) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(¶msCache), _5$$4, _6$$4, _3$$4) + { + ZEPHIR_INIT_NVAR(¶mKey); + if (_6$$4 != NULL) { + ZVAL_STR_COPY(¶mKey, _6$$4); + } else { + ZVAL_LONG(¶mKey, _5$$4); + } + ZEPHIR_INIT_NVAR(&className); + ZVAL_COPY(&className, _3$$4); + ZEPHIR_OBS_NVAR(¶mValue); + zephir_array_fetch(¶mValue, ¶ms, ¶mKey, PH_NOISY, "phalcon/Mvc/Model/Binder.zep", 83); + ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_7, 0, ¶mValue, &className); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("originalValues"), ¶mKey, ¶mValue); + zephir_array_update_zval(¶ms, ¶mKey, &boundModel, PH_COPY | PH_SEPARATE); + zephir_update_property_array(this_ptr, SL("boundModels"), ¶mKey, &boundModel); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, ¶msCache, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_4$$4, ¶msCache, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_4$$4)) { + break; + } + ZEPHIR_CALL_METHOD(¶mKey, ¶msCache, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&className, ¶msCache, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(¶mValue); + zephir_array_fetch(¶mValue, ¶ms, ¶mKey, PH_NOISY, "phalcon/Mvc/Model/Binder.zep", 83); + ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_7, 0, ¶mValue, &className); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("originalValues"), ¶mKey, ¶mValue); + zephir_array_update_zval(¶ms, ¶mKey, &boundModel, PH_COPY | PH_SEPARATE); + zephir_update_property_array(this_ptr, SL("boundModels"), ¶mKey, &boundModel); + ZEPHIR_CALL_METHOD(NULL, ¶msCache, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&className); + ZEPHIR_INIT_NVAR(¶mKey); + RETURN_CTOR(¶ms); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getparamsfromreflection", NULL, 0, handler, ¶ms, &cacheKey, &methodName); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Micro, setResponseHandler) +static PHP_METHOD(Phalcon_Mvc_Model_Binder, findBoundModel) { - zval *handler, handler_sub; - zval *this_ptr = getThis(); + zend_class_entry *_0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval className; + zval *paramValue, paramValue_sub, *className_param = NULL; - ZVAL_UNDEF(&handler_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(handler) + ZVAL_UNDEF(¶mValue_sub); + ZVAL_UNDEF(&className); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(paramValue) + Z_PARAM_STR(className) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &handler); - zephir_update_property_zval(this_ptr, ZEND_STRL("responseHandler"), handler); - RETURN_THISW(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, ¶mValue, &className_param); + zephir_get_strval(&className, className_param); + _0 = zephir_fetch_class(&className); + ZEPHIR_RETURN_CALL_CE_STATIC(_0, "findfirst", NULL, 0, paramValue); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Micro, setService) +static PHP_METHOD(Phalcon_Mvc_Model_Binder, getBoundModels) +{ + + RETURN_MEMBER(getThis(), "boundModels"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Binder, getOriginalValues) +{ + + RETURN_MEMBER(getThis(), "originalValues"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Binder, getCache) +{ + + RETURN_MEMBER(getThis(), "cache"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Binder, getParamsFromCache) { + zend_bool _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool shared; - zval *serviceName_param = NULL, *definition, definition_sub, *shared_param = NULL, _0, _2, _3, _1$$3; - zval serviceName; + zval *cacheKey_param = NULL, cache, internalParams, _0, _1, _3; + zval cacheKey; zval *this_ptr = getThis(); - ZVAL_UNDEF(&serviceName); - ZVAL_UNDEF(&definition_sub); + ZVAL_UNDEF(&cacheKey); + ZVAL_UNDEF(&cache); + ZVAL_UNDEF(&internalParams); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(serviceName) - Z_PARAM_ZVAL(definition) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(shared) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(cacheKey) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &serviceName_param, &definition, &shared_param); - if (UNEXPECTED(Z_TYPE_P(serviceName_param) != IS_STRING && Z_TYPE_P(serviceName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'serviceName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(serviceName_param) == IS_STRING)) { - zephir_get_strval(&serviceName, serviceName_param); - } else { - ZEPHIR_INIT_VAR(&serviceName); + zephir_fetch_params(1, 1, 0, &cacheKey_param); + zephir_get_strval(&cacheKey, cacheKey_param); + zephir_memory_observe(&internalParams); + zephir_read_property(&_0, this_ptr, ZEND_STRL("internalCache"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&internalParams, &_0, &cacheKey, 0)) { + RETURN_CCTOR(&internalParams); } - if (!shared_param) { - shared = 0; - } else { - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_di_factorydefault_ce); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 416); + zephir_read_property(&_1, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&cache, &_1); + _2 = Z_TYPE_P(&cache) == IS_NULL; + if (!(_2)) { + ZEPHIR_CALL_METHOD(&_3, &cache, "has", NULL, 0, &cacheKey); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &_1$$3); + _2 = !zephir_is_true(&_3); } - zephir_read_property(&_2, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - if (shared) { - ZVAL_BOOL(&_3, 1); - } else { - ZVAL_BOOL(&_3, 0); + if (_2) { + RETURN_MM_NULL(); } - ZEPHIR_RETURN_CALL_METHOD(&_2, "set", NULL, 0, &serviceName, definition, &_3); + ZEPHIR_CALL_METHOD(&internalParams, &cache, "get", NULL, 0, &cacheKey); zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_array(this_ptr, SL("internalCache"), &cacheKey, &internalParams); + RETURN_CCTOR(&internalParams); } -static PHP_METHOD(Phalcon_Mvc_Micro, stop) +static PHP_METHOD(Phalcon_Mvc_Model_Binder, getParamsFromReflection) { - zval __$true, __$false; + zend_class_entry *_9$$10, *_17$$24; + zend_string *_4; + zend_ulong _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_8 = NULL, *_12 = NULL, *_13 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval cacheKey, methodName; + zval params, paramsCache; + zval *handler, handler_sub, *params_param = NULL, *cacheKey_param = NULL, *methodName_param = NULL, methodParams, reflection, paramKey, methodParam, className, realClasses, boundModel, cache, handlerClass, reflectionClass, paramsKeys, paramValue, _0, *_1, _2, _5$$7, _6$$5, _7$$5, _10$$14, _11$$14, _14$$21, _15$$19, _16$$19, _18$$28, _19$$28; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$true); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&methodParams); + ZVAL_UNDEF(&reflection); + ZVAL_UNDEF(¶mKey); + ZVAL_UNDEF(&methodParam); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&realClasses); + ZVAL_UNDEF(&boundModel); + ZVAL_UNDEF(&cache); + ZVAL_UNDEF(&handlerClass); + ZVAL_UNDEF(&reflectionClass); + ZVAL_UNDEF(¶msKeys); + ZVAL_UNDEF(¶mValue); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_10$$14); + ZVAL_UNDEF(&_11$$14); + ZVAL_UNDEF(&_14$$21); + ZVAL_UNDEF(&_15$$19); + ZVAL_UNDEF(&_16$$19); + ZVAL_UNDEF(&_18$$28); + ZVAL_UNDEF(&_19$$28); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(¶msCache); + ZVAL_UNDEF(&cacheKey); + ZVAL_UNDEF(&methodName); + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_OBJECT(handler) + Z_PARAM_ARRAY(params) + Z_PARAM_STR(cacheKey) + Z_PARAM_STR(methodName) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 4, 0, &handler, ¶ms_param, &cacheKey_param, &methodName_param); + zephir_get_arrval(¶ms, params_param); + zephir_get_strval(&cacheKey, cacheKey_param); + if (UNEXPECTED(Z_TYPE_P(methodName_param) != IS_STRING && Z_TYPE_P(methodName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'methodName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(methodName_param) == IS_STRING)) { + zephir_get_strval(&methodName, methodName_param); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$false); + ZEPHIR_INIT_VAR(&methodName); + } + ZEPHIR_INIT_VAR(&realClasses); + ZVAL_NULL(&realClasses); + ZEPHIR_INIT_VAR(¶msCache); + array_init(¶msCache); + ZEPHIR_INIT_VAR(&reflection); + if (!ZEPHIR_IS_NULL(&methodName)) { + object_init_ex(&reflection, zephir_get_internal_ce(SL("reflectionmethod"))); + ZEPHIR_CALL_METHOD(NULL, &reflection, "__construct", NULL, 437, handler, &methodName); + zephir_check_call_status(); + } else { + object_init_ex(&reflection, zephir_get_internal_ce(SL("reflectionfunction"))); + ZEPHIR_CALL_METHOD(NULL, &reflection, "__construct", NULL, 151, handler); + zephir_check_call_status(); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&cache, &_0); + ZEPHIR_CALL_METHOD(&methodParams, &reflection, "getparameters", NULL, 152); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(¶msKeys); + zephir_array_keys(¶msKeys, ¶ms); + zephir_is_iterable(&methodParams, 0, "phalcon/Mvc/Model/Binder.zep", 243); + if (Z_TYPE_P(&methodParams) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&methodParams), _3, _4, _1) + { + ZEPHIR_INIT_NVAR(¶mKey); + if (_4 != NULL) { + ZVAL_STR_COPY(¶mKey, _4); + } else { + ZVAL_LONG(¶mKey, _3); + } + ZEPHIR_INIT_NVAR(&methodParam); + ZVAL_COPY(&methodParam, _1); + ZEPHIR_CALL_METHOD(&reflectionClass, &methodParam, "getclass", NULL, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&reflectionClass))) { + continue; + } + ZEPHIR_CALL_METHOD(&className, &reflectionClass, "getname", NULL, 0); + zephir_check_call_status(); + if (!(zephir_array_isset(¶ms, ¶mKey))) { + zephir_array_fetch(&_5$$7, ¶msKeys, ¶mKey, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Binder.zep", 195); + ZEPHIR_CPY_WRT(¶mKey, &_5$$7); + } + ZEPHIR_INIT_NVAR(&boundModel); + ZVAL_NULL(&boundModel); + ZEPHIR_OBS_NVAR(¶mValue); + zephir_array_fetch(¶mValue, ¶ms, ¶mKey, PH_NOISY, "phalcon/Mvc/Model/Binder.zep", 199); + ZEPHIR_INIT_NVAR(&_6$$5); + ZVAL_STRING(&_6$$5, "Phalcon\\Mvc\\Model"); + ZEPHIR_CALL_FUNCTION(&_7$$5, "is_subclass_of", &_8, 438, &className, &_6$$5); + zephir_check_call_status(); + if (ZEPHIR_IS_STRING(&className, "Phalcon\\Mvc\\Model")) { + if (Z_TYPE_P(&realClasses) == IS_NULL) { + if (zephir_instance_of_ev(handler, phalcon_mvc_controller_bindmodelinterface_ce)) { + ZEPHIR_INIT_NVAR(&handlerClass); + zephir_get_class(&handlerClass, handler, 0); + _9$$10 = zephir_fetch_class(&handlerClass); + ZEPHIR_CALL_CE_STATIC(&realClasses, _9$$10, "getmodelname", NULL, 0); + zephir_check_call_status(); + } else if (zephir_instance_of_ev(handler, phalcon_mvc_model_binder_bindableinterface_ce)) { + ZEPHIR_CALL_METHOD(&realClasses, handler, "getmodelname", NULL, 0); + zephir_check_call_status(); + } else { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Handler must implement Phalcon\\Mvc\\Model\\Binder\\BindableInterface in order to use Phalcon\\Mvc\\Model as parameter", "phalcon/Mvc/Model/Binder.zep", 211); + return; + } + } + if (Z_TYPE_P(&realClasses) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&className); + if (UNEXPECTED(!(zephir_array_isset_fetch(&className, &realClasses, ¶mKey, 0)))) { + ZEPHIR_INIT_NVAR(&_10$$14); + object_init_ex(&_10$$14, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_11$$14); + ZEPHIR_CONCAT_SVS(&_11$$14, "You should provide model class name for ", ¶mKey, " parameter"); + ZEPHIR_CALL_METHOD(NULL, &_10$$14, "__construct", &_12, 33, &_11$$14); + zephir_check_call_status(); + zephir_throw_exception_debug(&_10$$14, "phalcon/Mvc/Model/Binder.zep", 219); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_13, 0, ¶mValue, &className); + zephir_check_call_status(); + } else if (Z_TYPE_P(&realClasses) == IS_STRING) { + ZEPHIR_CPY_WRT(&className, &realClasses); + ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_13, 0, ¶mValue, &className); + zephir_check_call_status(); + } else { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "getModelName should return array or string", "phalcon/Mvc/Model/Binder.zep", 229); + return; + } + } else if (zephir_is_true(&_7$$5)) { + ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_13, 0, ¶mValue, &className); + zephir_check_call_status(); + } + if (Z_TYPE_P(&boundModel) != IS_NULL) { + zephir_update_property_array(this_ptr, SL("originalValues"), ¶mKey, ¶mValue); + zephir_array_update_zval(¶ms, ¶mKey, &boundModel, PH_COPY | PH_SEPARATE); + zephir_update_property_array(this_ptr, SL("boundModels"), ¶mKey, &boundModel); + zephir_array_update_zval(¶msCache, ¶mKey, &className, PH_COPY | PH_SEPARATE); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &methodParams, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &methodParams, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(¶mKey, &methodParams, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&methodParam, &methodParams, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&reflectionClass, &methodParam, "getclass", NULL, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&reflectionClass))) { + continue; + } + ZEPHIR_CALL_METHOD(&className, &reflectionClass, "getname", NULL, 0); + zephir_check_call_status(); + if (!(zephir_array_isset(¶ms, ¶mKey))) { + zephir_array_fetch(&_14$$21, ¶msKeys, ¶mKey, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Binder.zep", 195); + ZEPHIR_CPY_WRT(¶mKey, &_14$$21); + } + ZEPHIR_INIT_NVAR(&boundModel); + ZVAL_NULL(&boundModel); + ZEPHIR_OBS_NVAR(¶mValue); + zephir_array_fetch(¶mValue, ¶ms, ¶mKey, PH_NOISY, "phalcon/Mvc/Model/Binder.zep", 199); + ZEPHIR_INIT_NVAR(&_15$$19); + ZVAL_STRING(&_15$$19, "Phalcon\\Mvc\\Model"); + ZEPHIR_CALL_FUNCTION(&_16$$19, "is_subclass_of", &_8, 438, &className, &_15$$19); + zephir_check_call_status(); + if (ZEPHIR_IS_STRING(&className, "Phalcon\\Mvc\\Model")) { + if (Z_TYPE_P(&realClasses) == IS_NULL) { + if (zephir_instance_of_ev(handler, phalcon_mvc_controller_bindmodelinterface_ce)) { + ZEPHIR_INIT_NVAR(&handlerClass); + zephir_get_class(&handlerClass, handler, 0); + _17$$24 = zephir_fetch_class(&handlerClass); + ZEPHIR_CALL_CE_STATIC(&realClasses, _17$$24, "getmodelname", NULL, 0); + zephir_check_call_status(); + } else if (zephir_instance_of_ev(handler, phalcon_mvc_model_binder_bindableinterface_ce)) { + ZEPHIR_CALL_METHOD(&realClasses, handler, "getmodelname", NULL, 0); + zephir_check_call_status(); + } else { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Handler must implement Phalcon\\Mvc\\Model\\Binder\\BindableInterface in order to use Phalcon\\Mvc\\Model as parameter", "phalcon/Mvc/Model/Binder.zep", 211); + return; + } + } + if (Z_TYPE_P(&realClasses) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&className); + if (UNEXPECTED(!(zephir_array_isset_fetch(&className, &realClasses, ¶mKey, 0)))) { + ZEPHIR_INIT_NVAR(&_18$$28); + object_init_ex(&_18$$28, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_19$$28); + ZEPHIR_CONCAT_SVS(&_19$$28, "You should provide model class name for ", ¶mKey, " parameter"); + ZEPHIR_CALL_METHOD(NULL, &_18$$28, "__construct", &_12, 33, &_19$$28); + zephir_check_call_status(); + zephir_throw_exception_debug(&_18$$28, "phalcon/Mvc/Model/Binder.zep", 219); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_13, 0, ¶mValue, &className); + zephir_check_call_status(); + } else if (Z_TYPE_P(&realClasses) == IS_STRING) { + ZEPHIR_CPY_WRT(&className, &realClasses); + ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_13, 0, ¶mValue, &className); + zephir_check_call_status(); + } else { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "getModelName should return array or string", "phalcon/Mvc/Model/Binder.zep", 229); + return; + } + } else if (zephir_is_true(&_16$$19)) { + ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_13, 0, ¶mValue, &className); + zephir_check_call_status(); + } + if (Z_TYPE_P(&boundModel) != IS_NULL) { + zephir_update_property_array(this_ptr, SL("originalValues"), ¶mKey, ¶mValue); + zephir_array_update_zval(¶ms, ¶mKey, &boundModel, PH_COPY | PH_SEPARATE); + zephir_update_property_array(this_ptr, SL("boundModels"), ¶mKey, &boundModel); + zephir_array_update_zval(¶msCache, ¶mKey, &className, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, &methodParams, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&methodParam); + ZEPHIR_INIT_NVAR(¶mKey); + if (Z_TYPE_P(&cache) != IS_NULL) { + ZEPHIR_CALL_METHOD(NULL, &cache, "set", NULL, 0, &cacheKey, ¶msCache); + zephir_check_call_status(); } + zephir_update_property_array(this_ptr, SL("internalCache"), &cacheKey, ¶msCache); + RETURN_CTOR(¶ms); } -zend_object *zephir_init_properties_Phalcon_Mvc_Micro(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Mvc_Model_Binder, setCache) { - zval _0, _2, _4, _6, _8, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7; + zval *cache, cache_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&cache_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(cache, phalcon_cache_adapter_adapterinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &cache); + zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), cache); + RETURN_THISW(); +} + +zend_object *zephir_init_properties_Phalcon_Mvc_Model_Binder(zend_class_entry *class_type) +{ + zval _0, _2, _4, _1$$3, _3$$4, _5$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_3$$4); ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_9$$7); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); @@ -36059,35 +39448,23 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Micro(zend_class_entry *class_ty { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("handlers"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("originalValues"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("handlers"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("originalValues"), &_1$$3); } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("finishHandlers"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("internalCache"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_2) == IS_NULL) { ZEPHIR_INIT_VAR(&_3$$4); array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("finishHandlers"), &_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("internalCache"), &_3$$4); } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("beforeHandlers"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("boundModels"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_4) == IS_NULL) { ZEPHIR_INIT_VAR(&_5$$5); array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("beforeHandlers"), &_5$$5); - } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("afterHandlers"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("afterHandlers"), &_7$$6); - } - zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("afterBindingHandlers"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_8) == IS_NULL) { - ZEPHIR_INIT_VAR(&_9$$7); - array_init(&_9$$7); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("afterBindingHandlers"), &_9$$7); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("boundModels"), &_5$$5); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -36104,6882 +39481,4994 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Micro(zend_class_entry *class_ty -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_BinderInterface) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Model, phalcon, mvc_model, phalcon_di_abstractinjectionaware_ce, phalcon_mvc_model_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, BinderInterface, phalcon, mvc_model_binderinterface, phalcon_mvc_model_binderinterface_method_entry); - zend_declare_property_long(phalcon_mvc_model_ce, SL("dirtyState"), 1, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_ce, SL("dirtyRelated"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_ce, SL("errorMessages"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_ce, SL("modelsManager"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_ce, SL("modelsMetaData"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_ce, SL("related"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_model_ce, SL("operationMade"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_ce, SL("oldSnapshot"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_ce, SL("skipped"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_ce, SL("snapshot"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_ce, SL("transaction"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_ce, SL("uniqueKey"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_ce, SL("uniqueParams"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_ce, SL("uniqueTypes"), ZEND_ACC_PROTECTED); - phalcon_mvc_model_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model; - zephir_declare_class_constant_long(phalcon_mvc_model_ce, SL("DIRTY_STATE_DETACHED"), 2); + return SUCCESS; +} - zephir_declare_class_constant_long(phalcon_mvc_model_ce, SL("DIRTY_STATE_PERSISTENT"), 0); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BinderInterface, bindToHandler); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BinderInterface, getBoundModels); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BinderInterface, getCache); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BinderInterface, setCache); - zephir_declare_class_constant_long(phalcon_mvc_model_ce, SL("DIRTY_STATE_TRANSIENT"), 1); - zephir_declare_class_constant_long(phalcon_mvc_model_ce, SL("OP_CREATE"), 1); - zephir_declare_class_constant_long(phalcon_mvc_model_ce, SL("OP_DELETE"), 3); +#ifdef HAVE_CONFIG_H +#endif - zephir_declare_class_constant_long(phalcon_mvc_model_ce, SL("OP_NONE"), 0); - zephir_declare_class_constant_long(phalcon_mvc_model_ce, SL("OP_UPDATE"), 2); - zephir_declare_class_constant_string(phalcon_mvc_model_ce, SL("TRANSACTION_INDEX"), "transaction"); - zend_class_implements(phalcon_mvc_model_ce, 1, phalcon_mvc_entityinterface_ce); - zend_class_implements(phalcon_mvc_model_ce, 1, phalcon_mvc_modelinterface_ce); - zend_class_implements(phalcon_mvc_model_ce, 1, phalcon_mvc_model_resultinterface_ce); - zend_class_implements(phalcon_mvc_model_ce, 1, zend_ce_serializable); - zend_class_implements(phalcon_mvc_model_ce, 1, php_json_serializable_ce); + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Criteria) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Criteria, phalcon, mvc_model_criteria, phalcon_mvc_model_criteria_method_entry, 0); + + zend_declare_property_null(phalcon_mvc_model_criteria_ce, SL("bindParams"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_criteria_ce, SL("bindTypes"), ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_mvc_model_criteria_ce, SL("hiddenParamNumber"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_criteria_ce, SL("model"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_criteria_ce, SL("params"), ZEND_ACC_PROTECTED); + phalcon_mvc_model_criteria_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Criteria; + + zend_class_implements(phalcon_mvc_model_criteria_ce, 1, phalcon_mvc_model_criteriainterface_ce); + zend_class_implements(phalcon_mvc_model_criteria_ce, 1, phalcon_di_injectionawareinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model, __construct) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, andWhere) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *data = NULL, data_sub, *container = NULL, container_sub, *modelsManager = NULL, modelsManager_sub, __$null, _0$$4, _1$$4, _2$$4, _3$$5, _4$$5, _5$$6, _6$$6, _7$$6; + zval *conditions_param = NULL, *bindParams = NULL, bindParams_sub, *bindTypes = NULL, bindTypes_sub, __$null, currentConditions, _0, _1$$3; + zval conditions; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data_sub); - ZVAL_UNDEF(&container_sub); - ZVAL_UNDEF(&modelsManager_sub); + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(&bindParams_sub); + ZVAL_UNDEF(&bindTypes_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_6$$6); - ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(¤tConditions); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 3) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(conditions) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(data) - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(container, phalcon_di_diinterface_ce) - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(modelsManager, phalcon_mvc_model_managerinterface_ce) + Z_PARAM_ZVAL_OR_NULL(bindParams) + Z_PARAM_ZVAL_OR_NULL(bindTypes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 3, &data, &container, &modelsManager); - if (!data) { - data = &data_sub; - data = &__$null; - } - if (!container) { - container = &container_sub; - ZEPHIR_CPY_WRT(container, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(container); + zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams, &bindTypes); + if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); + RETURN_MM_NULL(); } - if (!modelsManager) { - modelsManager = &modelsManager_sub; - ZEPHIR_CPY_WRT(modelsManager, &__$null); + if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { + zephir_get_strval(&conditions, conditions_param); } else { - ZEPHIR_SEPARATE_PARAM(modelsManager); + ZEPHIR_INIT_VAR(&conditions); } - if (Z_TYPE_P(container) == IS_NULL) { - ZEPHIR_CALL_CE_STATIC(container, phalcon_di_di_ce, "getdefault", NULL, 0); - zephir_check_call_status(); + if (!bindParams) { + bindParams = &bindParams_sub; + bindParams = &__$null; } - if (Z_TYPE_P(container) == IS_NULL) { - ZEPHIR_INIT_VAR(&_0$$4); - object_init_ex(&_0$$4, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_1$$4); - zephir_get_class(&_1$$4, this_ptr, 0); - ZEPHIR_INIT_VAR(&_2$$4); - ZEPHIR_CONCAT_SVS(&_2$$4, "A dependency injection container is required to access the services related to the ODM in '", &_1$$4, "'"); - ZEPHIR_CALL_METHOD(NULL, &_0$$4, "__construct", NULL, 33, &_2$$4); - zephir_check_call_status(); - zephir_throw_exception_debug(&_0$$4, "phalcon/Mvc/Model.zep", 185); - ZEPHIR_MM_RESTORE(); - return; + if (!bindTypes) { + bindTypes = &bindTypes_sub; + bindTypes = &__$null; } - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); - if (Z_TYPE_P(modelsManager) == IS_NULL) { - ZEPHIR_INIT_VAR(&_4$$5); - ZVAL_STRING(&_4$$5, "modelsManager"); - ZEPHIR_CALL_METHOD(&_3$$5, container, "getshared", NULL, 0, &_4$$5); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(modelsManager, &_3$$5); - if (Z_TYPE_P(modelsManager) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$6); - object_init_ex(&_5$$6, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_6$$6); - zephir_get_class(&_6$$6, this_ptr, 0); - ZEPHIR_INIT_VAR(&_7$$6); - ZEPHIR_CONCAT_SVS(&_7$$6, "The injected service 'modelsManager' is not valid in '", &_6$$6, "'"); - ZEPHIR_CALL_METHOD(NULL, &_5$$6, "__construct", NULL, 33, &_7$$6); - zephir_check_call_status(); - zephir_throw_exception_debug(&_5$$6, "phalcon/Mvc/Model.zep", 198); - ZEPHIR_MM_RESTORE(); - return; - } + zephir_memory_observe(¤tConditions); + zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_string_fetch(¤tConditions, &_0, SL("conditions"), 0)) { + ZEPHIR_INIT_VAR(&_1$$3); + ZEPHIR_CONCAT_SVSVS(&_1$$3, "(", ¤tConditions, ") AND (", &conditions, ")"); + zephir_get_strval(&conditions, &_1$$3); } - zephir_update_property_zval(this_ptr, ZEND_STRL("modelsManager"), modelsManager); - ZEPHIR_CALL_METHOD(NULL, modelsManager, "initialize", NULL, 0, this_ptr); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "where", NULL, 0, &conditions, bindParams, bindTypes); zephir_check_call_status(); - if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("onconstruct")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "onconstruct", NULL, 0, data); - zephir_check_call_status(); - } - if (Z_TYPE_P(data) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "assign", NULL, 0, data); - zephir_check_call_status(); - } - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, __call) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, betweenWhere) { + zval _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_0 = NULL; - zval arguments; - zval *method_param = NULL, *arguments_param = NULL, modelName, status, records, _1, _2, _3; - zval method; + zval *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, hiddenParam, minimumKey, nextHiddenParam, maximumKey, _0; + zval expr; zval *this_ptr = getThis(); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&status); - ZVAL_UNDEF(&records); + ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&minimum_sub); + ZVAL_UNDEF(&maximum_sub); + ZVAL_UNDEF(&hiddenParam); + ZVAL_UNDEF(&minimumKey); + ZVAL_UNDEF(&nextHiddenParam); + ZVAL_UNDEF(&maximumKey); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&arguments); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(method) - Z_PARAM_ARRAY(arguments) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(expr) + Z_PARAM_ZVAL(minimum) + Z_PARAM_ZVAL(maximum) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &method_param, &arguments_param); - zephir_get_strval(&method, method_param); - zephir_get_arrval(&arguments, arguments_param); - ZEPHIR_CALL_SELF(&records, "invokefinder", &_0, 418, &method, &arguments); - zephir_check_call_status(); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&records)) { - RETURN_CCTOR(&records); - } - ZEPHIR_INIT_VAR(&modelName); - zephir_get_class(&modelName, this_ptr, 0); - ZEPHIR_CALL_METHOD(&records, this_ptr, "getrelatedrecords", NULL, 0, &modelName, &method, &arguments); - zephir_check_call_status(); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&records)) { - RETURN_CCTOR(&records); + zephir_fetch_params(1, 3, 0, &expr_param, &minimum, &maximum); + if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + RETURN_MM_NULL(); } - zephir_read_property(&_1, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&status, &_1, "missingmethod", NULL, 0, this_ptr, &method, &arguments); - zephir_check_call_status(); - if (Z_TYPE_P(&status) != IS_NULL) { - RETURN_CCTOR(&status); + if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { + zephir_get_strval(&expr, expr_param); + } else { + ZEPHIR_INIT_VAR(&expr); } - ZEPHIR_INIT_VAR(&_2); - object_init_ex(&_2, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_3); - ZEPHIR_CONCAT_SVSVS(&_3, "The method '", &method, "' doesn't exist on model '", &modelName, "'"); - ZEPHIR_CALL_METHOD(NULL, &_2, "__construct", NULL, 33, &_3); + zephir_memory_observe(&hiddenParam); + zephir_read_property(&hiddenParam, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(&nextHiddenParam); + ZVAL_LONG(&nextHiddenParam, (zephir_get_numberval(&hiddenParam) + 1)); + ZEPHIR_INIT_VAR(&minimumKey); + ZEPHIR_CONCAT_SV(&minimumKey, "ACP", &hiddenParam); + ZEPHIR_INIT_VAR(&maximumKey); + ZEPHIR_CONCAT_SV(&maximumKey, "ACP", &nextHiddenParam); + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_CONCAT_VSVSVS(&_0, &expr, " BETWEEN :", &minimumKey, ": AND :", &maximumKey, ":"); + ZEPHIR_INIT_VAR(&_1); + zephir_create_array(&_1, 2, 0); + zephir_array_update_zval(&_1, &minimumKey, minimum, PH_COPY); + zephir_array_update_zval(&_1, &maximumKey, maximum, PH_COPY); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, &_0, &_1); zephir_check_call_status(); - zephir_throw_exception_debug(&_2, "phalcon/Mvc/Model.zep", 267); - ZEPHIR_MM_RESTORE(); - return; + SEPARATE_ZVAL(&nextHiddenParam); + zephir_increment(&nextHiddenParam); + zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &nextHiddenParam); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model, __callStatic) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, bind) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_0 = NULL; - zval arguments; - zval *method_param = NULL, *arguments_param = NULL, modelName, records, _1, _2; - zval method; + zend_bool merge, _5; + zval *bindParams_param = NULL, *merge_param = NULL, _0, _3, _4, _1$$3, _2$$3, _6$$4, _7$$4, _8$$4, _9$$4, _10$$5; + zval bindParams; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&records); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&arguments); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(method) - Z_PARAM_ARRAY(arguments) + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$4); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&_10$$5); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(bindParams) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(merge) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &method_param, &arguments_param); - zephir_get_strval(&method, method_param); - zephir_get_arrval(&arguments, arguments_param); - ZEPHIR_CALL_SELF(&records, "invokefinder", &_0, 418, &method, &arguments); - zephir_check_call_status(); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&records)) { - RETURN_CCTOR(&records); + zephir_fetch_params(1, 1, 1, &bindParams_param, &merge_param); + ZEPHIR_OBS_COPY_OR_DUP(&bindParams, bindParams_param); + if (!merge_param) { + merge = 0; + } else { + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_string(&_0, SL("bind")))) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "bind"); + zephir_update_property_array(this_ptr, SL("params"), &_2$$3, &_1$$3); } - ZEPHIR_INIT_VAR(&modelName); - zephir_get_called_class(&modelName); - ZEPHIR_INIT_VAR(&_1); - object_init_ex(&_1, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_SVSVS(&_2, "The method '", &method, "' doesn't exist on model '", &modelName, "'"); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 33, &_2); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1, "phalcon/Mvc/Model.zep", 293); - ZEPHIR_MM_RESTORE(); - return; + zephir_read_property(&_3, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + zephir_memory_observe(&_4); + zephir_array_fetch_string(&_4, &_3, SL("bind"), PH_NOISY, "phalcon/Mvc/Model/Criteria.zep", 129); + _5 = Z_TYPE_P(&_4) == IS_ARRAY; + if (_5) { + _5 = merge; + } + if (_5) { + zephir_read_property(&_6$$4, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_7$$4, &_6$$4, SL("bind"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Criteria.zep", 130); + ZEPHIR_INIT_VAR(&_8$$4); + zephir_add_function(&_8$$4, &_7$$4, &bindParams); + ZEPHIR_INIT_VAR(&_9$$4); + ZVAL_STRING(&_9$$4, "bind"); + zephir_update_property_array(this_ptr, SL("params"), &_9$$4, &_8$$4); + } else { + ZEPHIR_INIT_VAR(&_10$$5); + ZVAL_STRING(&_10$$5, "bind"); + zephir_update_property_array(this_ptr, SL("params"), &_10$$5, &bindParams); + } + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model, __get) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, bindTypes) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *property_param = NULL, modelName, manager, lowerProperty, relation, _0, _4, _5, _6, _1$$3, _2$$4, _3$$4; - zval property, method; + zval *bindTypes_param = NULL, _0; + zval bindTypes; zval *this_ptr = getThis(); - ZVAL_UNDEF(&property); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&lowerProperty); - ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&bindTypes); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(property) + Z_PARAM_ARRAY(bindTypes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &property_param); - if (UNEXPECTED(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be of the type string")); + zephir_fetch_params(1, 1, 0, &bindTypes_param); + ZEPHIR_OBS_COPY_OR_DUP(&bindTypes, bindTypes_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "bindTypes"); + zephir_update_property_array(this_ptr, SL("params"), &_0, &bindTypes); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, cache) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *cache_param = NULL, _0; + zval cache; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&cache); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(cache) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &cache_param); + ZEPHIR_OBS_COPY_OR_DUP(&cache, cache_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "cache"); + zephir_update_property_array(this_ptr, SL("params"), &_0, &cache); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, columns) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *columns, columns_sub, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&columns_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(columns) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &columns); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "columns"); + zephir_update_property_array(this_ptr, SL("params"), &_0, columns); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, conditions) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *conditions_param = NULL, _0; + zval conditions; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(conditions) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &conditions_param); + if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(property_param) == IS_STRING)) { - zephir_get_strval(&property, property_param); + if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { + zephir_get_strval(&conditions, conditions_param); } else { - ZEPHIR_INIT_VAR(&property); + ZEPHIR_INIT_VAR(&conditions); } - ZEPHIR_INIT_VAR(&modelName); - zephir_get_class(&modelName, this_ptr, 0); - ZEPHIR_CALL_METHOD(&manager, this_ptr, "getmodelsmanager", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&lowerProperty); - zephir_fast_strtolower(&lowerProperty, &property); - ZEPHIR_CALL_METHOD(&_0, &manager, "getrelationbyalias", NULL, 0, &modelName, &lowerProperty); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "conditions"); + zephir_update_property_array(this_ptr, SL("params"), &_0, &conditions); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, createBuilder) +{ + zval container, manager, builder, _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&builder); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_CALL_METHOD(&container, this_ptr, "getdi", NULL, 0); zephir_check_call_status(); - ZEPHIR_CPY_WRT(&relation, &_0); - if (Z_TYPE_P(&relation) == IS_OBJECT) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("dirtyRelated"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset(&_1$$3, &lowerProperty)) { - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("dirtyRelated"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_3$$4, &_2$$4, &lowerProperty, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 325); - RETURN_CTOR(&_3$$4); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelated", NULL, 0, &lowerProperty); + if (Z_TYPE_P(&container) != IS_OBJECT) { + ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_INIT_VAR(&_4); - zephir_camelize(&_4, &property, NULL ); - ZEPHIR_INIT_VAR(&_5); - ZEPHIR_CONCAT_SV(&_5, "get", &_4); - zephir_get_strval(&method, &_5); - if ((zephir_method_exists(this_ptr, &method) == SUCCESS)) { - ZEPHIR_RETURN_CALL_METHOD_ZVAL(this_ptr, &method, NULL, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdi", NULL, 0, &container); zephir_check_call_status(); - RETURN_MM(); } - ZEPHIR_INIT_VAR(&_6); - ZEPHIR_CONCAT_SVSV(&_6, "Access to undefined property ", &modelName, "::", &property); - ZEPHIR_CALL_FUNCTION(NULL, "trigger_error", NULL, 7, &_6); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "modelsManager"); + ZEPHIR_CALL_METHOD(&_0, &container, "getshared", NULL, 0, &_1); zephir_check_call_status(); - RETURN_MM_NULL(); + ZEPHIR_CPY_WRT(&manager, &_0); + zephir_read_property(&_2, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&builder, &manager, "createbuilder", NULL, 0, &_2); + zephir_check_call_status(); + zephir_read_property(&_3, this_ptr, ZEND_STRL("model"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &builder, "from", NULL, 0, &_3); + zephir_check_call_status(); + RETURN_CCTOR(&builder); } -static PHP_METHOD(Phalcon_Mvc_Model, __isset) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, distinct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *property_param = NULL, manager, method, modelName, relation, result, _0, _1$$4; - zval property; + zval *distinct, distinct_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&property); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&result); + ZVAL_UNDEF(&distinct_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$4); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(property) + Z_PARAM_ZVAL(distinct) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &property_param); - if (UNEXPECTED(Z_TYPE_P(property_param) != IS_STRING && Z_TYPE_P(property_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'property' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(property_param) == IS_STRING)) { - zephir_get_strval(&property, property_param); - } else { - ZEPHIR_INIT_VAR(&property); - } - ZEPHIR_INIT_VAR(&modelName); - zephir_get_class(&modelName, this_ptr, 0); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmodelsmanager", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&manager, &_0); - ZEPHIR_CALL_METHOD(&_0, &manager, "getrelationbyalias", NULL, 0, &modelName, &property); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&relation, &_0); - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&result); - ZVAL_BOOL(&result, 1); - } else { - ZEPHIR_INIT_VAR(&_1$$4); - zephir_camelize(&_1$$4, &property, NULL ); - ZEPHIR_INIT_VAR(&method); - ZEPHIR_CONCAT_SV(&method, "get", &_1$$4); - ZEPHIR_INIT_NVAR(&result); - ZVAL_BOOL(&result, (zephir_method_exists(this_ptr, &method) == SUCCESS)); - } - RETURN_CCTOR(&result); + zephir_fetch_params(1, 1, 0, &distinct); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "distinct"); + zephir_update_property_array(this_ptr, SL("params"), &_0, distinct); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model, __serialize) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, execute) { - zend_bool _3, _4; - zval attributes, manager, dirtyState, snapshot, _0, _1, _2, _5$$3; + zend_class_entry *_1; + zval model, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&dirtyState); - ZVAL_UNDEF(&snapshot); + ZVAL_UNDEF(&model); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_5$$3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_INIT_VAR(&snapshot); - ZVAL_NULL(&snapshot); - ZVAL_NULL(&_0); - ZVAL_BOOL(&_1, 0); - ZEPHIR_CALL_METHOD(&attributes, this_ptr, "toarray", NULL, 0, &_0, &_1); + ZEPHIR_CALL_METHOD(&model, this_ptr, "getmodelname", NULL, 0); zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("dirtyState"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&dirtyState, &_0); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getmodelsmanager", NULL, 0); + if (UNEXPECTED(Z_TYPE_P(&model) != IS_STRING)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Model name must be string", "phalcon/Mvc/Model/Criteria.zep", 279); + return; + } + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getparams", NULL, 0); zephir_check_call_status(); - ZEPHIR_CPY_WRT(&manager, &_2); - ZEPHIR_CALL_METHOD(&_2, &manager, "iskeepingsnapshots", NULL, 0, this_ptr); + _1 = zephir_fetch_class(&model); + ZEPHIR_RETURN_CALL_CE_STATIC(_1, "find", NULL, 0, &_0); zephir_check_call_status(); - _3 = zephir_is_true(&_2); - if (_3) { - zephir_read_property(&_0, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); - _3 = Z_TYPE_P(&_0) != IS_NULL; - } - _4 = _3; - if (_4) { - zephir_read_property(&_1, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); - _4 = !ZEPHIR_IS_EQUAL(&attributes, &_1); - } - if (_4) { - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&snapshot, &_5$$3); - } - zephir_create_array(return_value, 3, 0); - zephir_array_update_string(return_value, SL("attributes"), &attributes, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("snapshot"), &snapshot, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("dirtyState"), &dirtyState, PH_COPY | PH_SEPARATE); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, __set) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, forUpdate) { - zend_bool _0; - zval related; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *property_param = NULL, *value, value_sub, lowerProperty, modelName, manager, relation, referencedModel, item, dirtyState, _14, _15, _1$$3, _2$$4, _3$$4, _4$$6, _5$$7, _6$$8, _7$$9, _8$$9, *_9$$10, _10$$10, _11$$10, _12$$17, _13$$18, _16$$20, _17$$21, _18$$21, _19$$21; - zval property; + zval *forUpdate_param = NULL, _0, _1; + zend_bool forUpdate; zval *this_ptr = getThis(); - ZVAL_UNDEF(&property); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&lowerProperty); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(forUpdate) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &forUpdate_param); + if (!forUpdate_param) { + forUpdate = 1; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "for_update"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_BOOL(&_1, forUpdate); + zephir_update_property_array(this_ptr, SL("params"), &_0, &_1); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, fromInput) +{ + zend_bool _6$$4, _7$$7, _11$$10, _12$$13; + zend_string *_5$$3; + zend_ulong _4$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval data, conditions, bind, _1$$3; + zval modelName, operator, _17$$16; + zval *container, container_sub, *modelName_param = NULL, *data_param = NULL, *operator_param = NULL, __$null, attribute, field, value, type, metaData, model, dataTypes, criteria, columnMap, _0$$3, *_2$$3, _3$$3, _8$$9, _9$$9, _10$$8, _13$$15, _14$$15, _15$$14, _16$$16; + + ZVAL_UNDEF(&container_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&dataTypes); + ZVAL_UNDEF(&criteria); + ZVAL_UNDEF(&columnMap); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_8$$9); + ZVAL_UNDEF(&_9$$9); + ZVAL_UNDEF(&_10$$8); + ZVAL_UNDEF(&_13$$15); + ZVAL_UNDEF(&_14$$15); + ZVAL_UNDEF(&_15$$14); + ZVAL_UNDEF(&_16$$16); ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&referencedModel); - ZVAL_UNDEF(&item); - ZVAL_UNDEF(&dirtyState); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_15); + ZVAL_UNDEF(&operator); + ZVAL_UNDEF(&_17$$16); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(&bind); ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$6); - ZVAL_UNDEF(&_5$$7); - ZVAL_UNDEF(&_6$$8); - ZVAL_UNDEF(&_7$$9); - ZVAL_UNDEF(&_8$$9); - ZVAL_UNDEF(&_10$$10); - ZVAL_UNDEF(&_11$$10); - ZVAL_UNDEF(&_12$$17); - ZVAL_UNDEF(&_13$$18); - ZVAL_UNDEF(&_16$$20); - ZVAL_UNDEF(&_17$$21); - ZVAL_UNDEF(&_18$$21); - ZVAL_UNDEF(&_19$$21); - ZVAL_UNDEF(&related); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(property) - Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + Z_PARAM_STR(modelName) + Z_PARAM_ARRAY(data) + Z_PARAM_OPTIONAL + Z_PARAM_STR(operator) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &property_param, &value); - zephir_get_strval(&property, property_param); - _0 = Z_TYPE_P(value) == IS_OBJECT; - if (_0) { - _0 = zephir_instance_of_ev(value, phalcon_mvc_modelinterface_ce); + zephir_fetch_params(1, 3, 1, &container, &modelName_param, &data_param, &operator_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + RETURN_MM_NULL(); } - if (_0) { - ZEPHIR_INIT_VAR(&lowerProperty); - zephir_fast_strtolower(&lowerProperty, &property); + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); + } else { ZEPHIR_INIT_VAR(&modelName); - zephir_get_class(&modelName, this_ptr, 0); - ZEPHIR_CALL_METHOD(&manager, this_ptr, "getmodelsmanager", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1$$3, &manager, "getrelationbyalias", NULL, 0, &modelName, &lowerProperty); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&relation, &_1$$3); - if (Z_TYPE_P(&relation) == IS_OBJECT) { - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("dirtyState"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&dirtyState, &_2$$4); - ZEPHIR_CALL_METHOD(&_3$$4, value, "getdirtystate", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_EQUAL(&_3$$4, &dirtyState)) { - ZEPHIR_INIT_NVAR(&dirtyState); - ZVAL_LONG(&dirtyState, 1); - } - zephir_unset_property_array(this_ptr, ZEND_STRL("related"), &lowerProperty); - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("related"), PH_NOISY_CC | PH_READONLY); - zephir_array_unset(&_2$$4, &lowerProperty, PH_SEPARATE); - zephir_update_property_array(this_ptr, SL("dirtyRelated"), &lowerProperty, value); - zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &dirtyState); - RETVAL_ZVAL(value, 1, 0); - RETURN_MM(); - } - } else if (Z_TYPE_P(value) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&lowerProperty); - zephir_fast_strtolower(&lowerProperty, &property); - ZEPHIR_INIT_NVAR(&modelName); - zephir_get_class(&modelName, this_ptr, 0); - ZEPHIR_CALL_METHOD(&manager, this_ptr, "getmodelsmanager", NULL, 0); + } + ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); + if (!operator_param) { + ZEPHIR_INIT_VAR(&operator); + ZVAL_STRING(&operator, "AND"); + } else { + if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { + zephir_get_strval(&operator, operator_param); + } else { + ZEPHIR_INIT_VAR(&operator); + } + } + ZEPHIR_INIT_VAR(&conditions); + array_init(&conditions); + if (zephir_fast_count_int(&data)) { + ZEPHIR_INIT_VAR(&_0$$3); + ZVAL_STRING(&_0$$3, "modelsMetadata"); + ZEPHIR_CALL_METHOD(&metaData, container, "getshared", NULL, 0, &_0$$3); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$6, &manager, "getrelationbyalias", NULL, 0, &modelName, &lowerProperty); + ZEPHIR_INIT_VAR(&_1$$3); + zephir_create_array(&_1$$3, 2, 0); + zephir_array_fast_append(&_1$$3, &__$null); + zephir_array_fast_append(&_1$$3, container); + ZEPHIR_INIT_VAR(&model); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&model, &modelName, &_1$$3); zephir_check_call_status(); - ZEPHIR_CPY_WRT(&relation, &_4$$6); - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(&_5$$7, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - do { - if (ZEPHIR_IS_LONG(&_5$$7, 0) || ZEPHIR_IS_LONG(&_5$$7, 1)) { - ZEPHIR_CALL_METHOD(&_6$$8, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedModel, &manager, "load", NULL, 0, &_6$$8); - zephir_check_call_status(); - if (Z_TYPE_P(&referencedModel) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(NULL, &referencedModel, "assign", NULL, 0, value); - zephir_check_call_status(); - zephir_unset_property_array(this_ptr, ZEND_STRL("related"), &lowerProperty); - zephir_read_property(&_7$$9, this_ptr, ZEND_STRL("related"), PH_NOISY_CC | PH_READONLY); - zephir_array_unset(&_7$$9, &lowerProperty, PH_SEPARATE); - zephir_update_property_array(this_ptr, SL("dirtyRelated"), &lowerProperty, &referencedModel); - ZVAL_UNDEF(&_8$$9); - ZVAL_LONG(&_8$$9, 1); - zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &_8$$9); - RETVAL_ZVAL(value, 1, 0); - RETURN_MM(); + ZEPHIR_CALL_METHOD(&dataTypes, &metaData, "getdatatypes", NULL, 0, &model); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getreversecolumnmap", NULL, 0, &model); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&bind); + array_init(&bind); + zephir_is_iterable(&data, 0, "phalcon/Mvc/Model/Criteria.zep", 356); + if (Z_TYPE_P(&data) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _4$$3, _5$$3, _2$$3) + { + ZEPHIR_INIT_NVAR(&field); + if (_5$$3 != NULL) { + ZVAL_STR_COPY(&field, _5$$3); + } else { + ZVAL_LONG(&field, _4$$3); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _2$$3); + _6$$4 = Z_TYPE_P(&columnMap) == IS_ARRAY; + if (_6$$4) { + _6$$4 = ((zephir_fast_count_int(&columnMap)) ? 1 : 0); + } + if (_6$$4) { + ZEPHIR_OBS_NVAR(&attribute); + zephir_array_fetch(&attribute, &columnMap, &field, PH_NOISY, "phalcon/Mvc/Model/Criteria.zep", 331); + } else { + ZEPHIR_CPY_WRT(&attribute, &field); + } + ZEPHIR_OBS_NVAR(&type); + if (zephir_array_isset_fetch(&type, &dataTypes, &attribute, 0)) { + _7$$7 = Z_TYPE_P(&value) != IS_NULL; + if (_7$$7) { + _7$$7 = !ZEPHIR_IS_STRING_IDENTICAL(&value, ""); + } + if (_7$$7) { + if (ZEPHIR_IS_LONG(&type, 2)) { + ZEPHIR_INIT_NVAR(&_8$$9); + ZEPHIR_CONCAT_SVSVS(&_8$$9, "[", &field, "] LIKE :", &field, ":"); + zephir_array_append(&conditions, &_8$$9, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 342); + ZEPHIR_INIT_NVAR(&_9$$9); + ZEPHIR_CONCAT_SVS(&_9$$9, "%", &value, "%"); + zephir_array_update_zval(&bind, &field, &_9$$9, PH_COPY | PH_SEPARATE); + continue; + } + ZEPHIR_INIT_NVAR(&_10$$8); + ZEPHIR_CONCAT_SVSVS(&_10$$8, "[", &field, "] = :", &field, ":"); + zephir_array_append(&conditions, &_10$$8, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 351); + zephir_array_update_zval(&bind, &field, &value, PH_COPY | PH_SEPARATE); } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3$$3, &data, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3$$3)) { break; } - if (ZEPHIR_IS_LONG(&_5$$7, 2) || ZEPHIR_IS_LONG(&_5$$7, 4)) { - ZEPHIR_INIT_VAR(&related); - array_init(&related); - zephir_is_iterable(value, 0, "phalcon/Mvc/Model.zep", 496); - if (Z_TYPE_P(value) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(value), _9$$10) - { - ZEPHIR_INIT_NVAR(&item); - ZVAL_COPY(&item, _9$$10); - if (Z_TYPE_P(&item) == IS_OBJECT) { - if (zephir_instance_of_ev(&item, phalcon_mvc_modelinterface_ce)) { - zephir_array_append(&related, &item, PH_SEPARATE, "phalcon/Mvc/Model.zep", 491); - } - } - } ZEND_HASH_FOREACH_END(); + ZEPHIR_CALL_METHOD(&field, &data, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); + zephir_check_call_status(); + _11$$10 = Z_TYPE_P(&columnMap) == IS_ARRAY; + if (_11$$10) { + _11$$10 = ((zephir_fast_count_int(&columnMap)) ? 1 : 0); + } + if (_11$$10) { + ZEPHIR_OBS_NVAR(&attribute); + zephir_array_fetch(&attribute, &columnMap, &field, PH_NOISY, "phalcon/Mvc/Model/Criteria.zep", 331); } else { - ZEPHIR_CALL_METHOD(NULL, value, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_10$$10, value, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_10$$10)) { - break; + ZEPHIR_CPY_WRT(&attribute, &field); + } + ZEPHIR_OBS_NVAR(&type); + if (zephir_array_isset_fetch(&type, &dataTypes, &attribute, 0)) { + _12$$13 = Z_TYPE_P(&value) != IS_NULL; + if (_12$$13) { + _12$$13 = !ZEPHIR_IS_STRING_IDENTICAL(&value, ""); + } + if (_12$$13) { + if (ZEPHIR_IS_LONG(&type, 2)) { + ZEPHIR_INIT_NVAR(&_13$$15); + ZEPHIR_CONCAT_SVSVS(&_13$$15, "[", &field, "] LIKE :", &field, ":"); + zephir_array_append(&conditions, &_13$$15, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 342); + ZEPHIR_INIT_NVAR(&_14$$15); + ZEPHIR_CONCAT_SVS(&_14$$15, "%", &value, "%"); + zephir_array_update_zval(&bind, &field, &_14$$15, PH_COPY | PH_SEPARATE); + continue; } - ZEPHIR_CALL_METHOD(&item, value, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&item) == IS_OBJECT) { - if (zephir_instance_of_ev(&item, phalcon_mvc_modelinterface_ce)) { - zephir_array_append(&related, &item, PH_SEPARATE, "phalcon/Mvc/Model.zep", 491); - } - } - ZEPHIR_CALL_METHOD(NULL, value, "next", NULL, 0); - zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_15$$14); + ZEPHIR_CONCAT_SVSVS(&_15$$14, "[", &field, "] = :", &field, ":"); + zephir_array_append(&conditions, &_15$$14, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 351); + zephir_array_update_zval(&bind, &field, &value, PH_COPY | PH_SEPARATE); } } - ZEPHIR_INIT_NVAR(&item); - zephir_unset_property_array(this_ptr, ZEND_STRL("related"), &lowerProperty); - zephir_read_property(&_11$$10, this_ptr, ZEND_STRL("related"), PH_NOISY_CC | PH_READONLY); - zephir_array_unset(&_11$$10, &lowerProperty, PH_SEPARATE); - if (zephir_fast_count_int(&related) > 0) { - zephir_update_property_array(this_ptr, SL("dirtyRelated"), &lowerProperty, &related); - ZVAL_UNDEF(&_12$$17); - ZVAL_LONG(&_12$$17, 1); - zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &_12$$17); - } else { - zephir_unset_property_array(this_ptr, ZEND_STRL("dirtyRelated"), &lowerProperty); - zephir_read_property(&_13$$18, this_ptr, ZEND_STRL("dirtyRelated"), PH_NOISY_CC | PH_READONLY); - zephir_array_unset(&_13$$18, &lowerProperty, PH_SEPARATE); - } - RETVAL_ZVAL(value, 1, 0); - RETURN_MM(); - } - } while(0); - + ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); + zephir_check_call_status(); + } } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&field); } - ZEPHIR_CALL_METHOD(&_14, this_ptr, "possiblesetter", NULL, 419, &property, value); - zephir_check_call_status(); - if (zephir_is_true(&_14)) { - RETVAL_ZVAL(value, 1, 0); - RETURN_MM(); + ZEPHIR_INIT_VAR(&criteria); + object_init_ex(&criteria, phalcon_mvc_model_criteria_ce); + if (zephir_has_constructor(&criteria)) { + ZEPHIR_CALL_METHOD(NULL, &criteria, "__construct", NULL, 0); + zephir_check_call_status(); } - ZEPHIR_CALL_FUNCTION(&_15, "property_exists", NULL, 290, this_ptr, &property); + + ZEPHIR_CALL_METHOD(NULL, &criteria, "setdi", NULL, 429, container); zephir_check_call_status(); - if (zephir_is_true(&_15)) { - ZEPHIR_CALL_METHOD(&manager, this_ptr, "getmodelsmanager", NULL, 0); + if (zephir_fast_count_int(&conditions)) { + ZEPHIR_INIT_VAR(&_16$$16); + ZEPHIR_INIT_VAR(&_17$$16); + ZEPHIR_CONCAT_SVS(&_17$$16, " ", &operator, " "); + zephir_fast_join(&_16$$16, &_17$$16, &conditions); + ZEPHIR_CALL_METHOD(NULL, &criteria, "where", NULL, 439, &_16$$16); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_16$$20, &manager, "isvisiblemodelproperty", NULL, 0, this_ptr, &property); + ZEPHIR_CALL_METHOD(NULL, &criteria, "bind", NULL, 440, &bind); zephir_check_call_status(); - if (UNEXPECTED(!zephir_is_true(&_16$$20))) { - ZEPHIR_INIT_VAR(&_17$$21); - object_init_ex(&_17$$21, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_18$$21); - zephir_get_class(&_18$$21, this_ptr, 0); - ZEPHIR_INIT_VAR(&_19$$21); - ZEPHIR_CONCAT_SVSVS(&_19$$21, "Cannot access property '", &property, "' (not public) in '", &_18$$21, "'"); - ZEPHIR_CALL_METHOD(NULL, &_17$$21, "__construct", NULL, 33, &_19$$21); - zephir_check_call_status(); - zephir_throw_exception_debug(&_17$$21, "phalcon/Mvc/Model.zep", 525); - ZEPHIR_MM_RESTORE(); - return; - } } - zephir_update_property_zval_zval(this_ptr, &property, value); - RETVAL_ZVAL(value, 1, 0); - RETURN_MM(); + ZEPHIR_CALL_METHOD(NULL, &criteria, "setmodelname", NULL, 430, &modelName); + zephir_check_call_status(); + RETURN_CCTOR(&criteria); } -static PHP_METHOD(Phalcon_Mvc_Model, __unserialize) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getColumns) { - zend_string *_12$$6; - zend_ulong _11$$6; + zval columns, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *data_param = NULL, container, manager, key, value, snapshot, properties, dirtyState, _4, _5, _0$$3, _1$$4, _2$$4, _3$$4, _6$$5, _7$$5, _8$$5, *_9$$6, _10$$6; - zval data; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&snapshot); - ZVAL_UNDEF(&properties); - ZVAL_UNDEF(&dirtyState); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_7$$5); - ZVAL_UNDEF(&_8$$5); - ZVAL_UNDEF(&_10$$6); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(data) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &data_param); - zephir_get_arrval(&data, data_param); - if (!(zephir_array_isset_string(&data, SL("attributes")))) { - ZEPHIR_INIT_VAR(&_0$$3); - zephir_create_array(&_0$$3, 1, 0); - zephir_array_update_string(&_0$$3, SL("attributes"), &data, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&data, &_0$$3); + + zephir_memory_observe(&columns); + zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_string_fetch(&columns, &_0, SL("columns"), 0))) { + RETURN_MM_NULL(); } - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$4); - object_init_ex(&_1$$4, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_2$$4); - zephir_get_class(&_2$$4, this_ptr, 0); - ZEPHIR_INIT_VAR(&_3$$4); - ZEPHIR_CONCAT_SVS(&_3$$4, "A dependency injection container is required to access the services related to the ODM in '", &_2$$4, "'"); - ZEPHIR_CALL_METHOD(NULL, &_1$$4, "__construct", NULL, 33, &_3$$4); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$4, "phalcon/Mvc/Model.zep", 554); - ZEPHIR_MM_RESTORE(); - return; + RETURN_CCTOR(&columns); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getConditions) +{ + zval conditions, _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_memory_observe(&conditions); + zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_string_fetch(&conditions, &_0, SL("conditions"), 0))) { + RETURN_MM_NULL(); } - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &container); - ZEPHIR_INIT_VAR(&_5); - ZVAL_STRING(&_5, "modelsManager"); - ZEPHIR_CALL_METHOD(&_4, &container, "getshared", NULL, 0, &_5); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&manager, &_4); - if (Z_TYPE_P(&manager) == IS_NULL) { - ZEPHIR_INIT_VAR(&_6$$5); - object_init_ex(&_6$$5, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_7$$5); - zephir_get_class(&_7$$5, this_ptr, 0); - ZEPHIR_INIT_VAR(&_8$$5); - ZEPHIR_CONCAT_SVS(&_8$$5, "The injected service 'modelsManager' is not valid in '", &_7$$5, "'"); - ZEPHIR_CALL_METHOD(NULL, &_6$$5, "__construct", NULL, 33, &_8$$5); - zephir_check_call_status(); - zephir_throw_exception_debug(&_6$$5, "phalcon/Mvc/Model.zep", 569); - ZEPHIR_MM_RESTORE(); - return; + RETURN_CCTOR(&conditions); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getDI) +{ + zval _0, _1; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_1, &_0, SL("di"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Criteria.zep", 413); + RETURN_CTORW(&_1); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getGroupBy) +{ + zval group, _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&group); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_memory_observe(&group); + zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_string_fetch(&group, &_0, SL("group"), 0))) { + RETURN_MM_NULL(); } - zephir_update_property_zval(this_ptr, ZEND_STRL("modelsManager"), &manager); - ZEPHIR_CALL_METHOD(NULL, &manager, "initialize", NULL, 0, this_ptr); - zephir_check_call_status(); - zephir_memory_observe(&properties); - if (zephir_array_isset_string_fetch(&properties, &data, SL("attributes"), 0)) { - zephir_is_iterable(&properties, 0, "phalcon/Mvc/Model.zep", 592); - if (Z_TYPE_P(&properties) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&properties), _11$$6, _12$$6, _9$$6) - { - ZEPHIR_INIT_NVAR(&key); - if (_12$$6 != NULL) { - ZVAL_STR_COPY(&key, _12$$6); - } else { - ZVAL_LONG(&key, _11$$6); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _9$$6); - zephir_update_property_zval_zval(this_ptr, &key, &value); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &properties, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_10$$6, &properties, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_10$$6)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &properties, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &properties, "current", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval_zval(this_ptr, &key, &value); - ZEPHIR_CALL_METHOD(NULL, &properties, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - } else { - ZEPHIR_INIT_NVAR(&properties); - array_init(&properties); + RETURN_CCTOR(&group); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getHaving) +{ + zval having, _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&having); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_memory_observe(&having); + zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_string_fetch(&having, &_0, SL("having"), 0))) { + RETURN_MM_NULL(); } - zephir_memory_observe(&dirtyState); - if (zephir_array_isset_string_fetch(&dirtyState, &data, SL("dirtyState"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &dirtyState); + RETURN_CCTOR(&having); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getLimit) +{ + zval limit, _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&limit); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_memory_observe(&limit); + zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_string_fetch(&limit, &_0, SL("limit"), 0))) { + RETURN_MM_NULL(); } - ZEPHIR_CALL_METHOD(&_4, &manager, "iskeepingsnapshots", NULL, 0, this_ptr); - zephir_check_call_status(); - if (zephir_is_true(&_4)) { - if (zephir_array_isset_string_fetch(&snapshot, &data, SL("snapshot"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("snapshot"), &snapshot); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("snapshot"), &properties); - } + RETURN_CCTOR(&limit); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getModelName) +{ + + RETURN_MEMBER(getThis(), "model"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getOrderBy) +{ + zval order, _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&order); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_memory_observe(&order); + zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_string_fetch(&order, &_0, SL("order"), 0))) { + RETURN_MM_NULL(); } - ZEPHIR_MM_RESTORE(); + RETURN_CCTOR(&order); } -static PHP_METHOD(Phalcon_Mvc_Model, addBehavior) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getParams) +{ + + RETURN_MEMBER(getThis(), "params"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getWhere) { + zval conditions, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *behavior, behavior_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&behavior_sub); + ZVAL_UNDEF(&conditions); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(behavior, phalcon_mvc_model_behaviorinterface_ce) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &behavior); - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "addbehavior", NULL, 0, this_ptr, behavior); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + + zephir_memory_observe(&conditions); + zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_string_fetch(&conditions, &_0, SL("conditions"), 0))) { + RETURN_MM_NULL(); + } + RETURN_CCTOR(&conditions); } -static PHP_METHOD(Phalcon_Mvc_Model, appendMessage) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, groupBy) { - zval *message, message_sub; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *group, group_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&message_sub); + ZVAL_UNDEF(&group_sub); + ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(message, phalcon_messages_messageinterface_ce) + Z_PARAM_ZVAL(group) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &message); - zephir_update_property_array_append(this_ptr, SL("errorMessages"), message); - RETURN_THISW(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &group); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "group"); + zephir_update_property_array(this_ptr, SL("params"), &_0, group); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model, assign) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, having) { - zend_bool _7$$12, _14$$18, _17$$22, _22$$28; - zend_string *_3$$3; - zend_ulong _2$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_9 = NULL, *_13 = NULL, *_16 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *data_param = NULL, *whiteList = NULL, whiteList_sub, *dataColumnMap = NULL, dataColumnMap_sub, __$null, key, keyMapped, value, attribute, attributeField, metaData, columnMap, disableAssignSetters, _4, *_5, _6, *_0$$3, _1$$3, _8$$13, _10$$16, _11$$16, _12$$16, _15$$18, _18$$23, _19$$26, _20$$26, _21$$26, _23$$28; - zval data, dataMapped; + zval *having, having_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&dataMapped); - ZVAL_UNDEF(&whiteList_sub); - ZVAL_UNDEF(&dataColumnMap_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&keyMapped); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&attributeField); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&disableAssignSetters); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_8$$13); - ZVAL_UNDEF(&_10$$16); - ZVAL_UNDEF(&_11$$16); - ZVAL_UNDEF(&_12$$16); - ZVAL_UNDEF(&_15$$18); - ZVAL_UNDEF(&_18$$23); - ZVAL_UNDEF(&_19$$26); - ZVAL_UNDEF(&_20$$26); - ZVAL_UNDEF(&_21$$26); - ZVAL_UNDEF(&_23$$28); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ARRAY(data) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(whiteList) - Z_PARAM_ZVAL_OR_NULL(dataColumnMap) + ZVAL_UNDEF(&having_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(having) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &data_param, &whiteList, &dataColumnMap); - ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); - if (!whiteList) { - whiteList = &whiteList_sub; - whiteList = &__$null; - } - if (!dataColumnMap) { - dataColumnMap = &dataColumnMap_sub; - dataColumnMap = &__$null; - } - ZEPHIR_INIT_VAR(&disableAssignSetters); - ZVAL_BOOL(&disableAssignSetters, ZEPHIR_GLOBAL(orm).disable_assign_setters); - if (Z_TYPE_P(dataColumnMap) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&dataMapped); - array_init(&dataMapped); - zephir_is_iterable(&data, 0, "phalcon/Mvc/Model.zep", 752); - if (Z_TYPE_P(&data) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _2$$3, _3$$3, _0$$3) - { - ZEPHIR_INIT_NVAR(&key); - if (_3$$3 != NULL) { - ZVAL_STR_COPY(&key, _3$$3); - } else { - ZVAL_LONG(&key, _2$$3); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0$$3); - ZEPHIR_OBS_NVAR(&keyMapped); - if (zephir_array_isset_fetch(&keyMapped, dataColumnMap, &key, 0)) { - zephir_array_update_zval(&dataMapped, &keyMapped, &value, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1$$3, &data, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &data, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&keyMapped); - if (zephir_array_isset_fetch(&keyMapped, dataColumnMap, &key, 0)) { - zephir_array_update_zval(&dataMapped, &keyMapped, &value, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - } else { - ZEPHIR_CPY_WRT(&dataMapped, &data); - } - if (zephir_fast_count_int(&dataMapped) == 0) { - RETURN_THIS(); - } - ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_GLOBAL(orm).column_renaming) { - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", NULL, 0, this_ptr); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&columnMap); - ZVAL_NULL(&columnMap); - } - ZEPHIR_CALL_METHOD(&_4, &metaData, "getattributes", NULL, 0, this_ptr); - zephir_check_call_status(); - zephir_is_iterable(&_4, 0, "phalcon/Mvc/Model.zep", 809); - if (Z_TYPE_P(&_4) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_4), _5) - { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _5); - _7$$12 = !(zephir_array_isset(&columnMap, &attribute)); - if (_7$$12) { - _7$$12 = ZEPHIR_GLOBAL(orm).case_insensitive_column_map; - } - if (_7$$12) { - ZEPHIR_CALL_SELF(&_8$$13, "caseinsensitivecolumnmap", &_9, 420, &columnMap, &attribute); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&attribute, &_8$$13); - } - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeField); - if (!(zephir_array_isset_fetch(&attributeField, &columnMap, &attribute, 0))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_10$$16); - object_init_ex(&_10$$16, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_11$$16); - zephir_get_class(&_11$$16, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_12$$16); - ZEPHIR_CONCAT_SVSVS(&_12$$16, "Column '", &attribute, "' doesn't make part of the column map in '", &_11$$16, "'"); - ZEPHIR_CALL_METHOD(NULL, &_10$$16, "__construct", &_13, 33, &_12$$16); - zephir_check_call_status(); - zephir_throw_exception_debug(&_10$$16, "phalcon/Mvc/Model.zep", 783); - ZEPHIR_MM_RESTORE(); - return; - } - continue; - } - } else { - ZEPHIR_CPY_WRT(&attributeField, &attribute); - } - ZEPHIR_OBS_NVAR(&value); - if (zephir_array_isset_fetch(&value, &dataMapped, &attributeField, 0)) { - if (Z_TYPE_P(whiteList) == IS_ARRAY) { - if (!(zephir_fast_in_array(&attributeField, whiteList))) { - continue; - } - } - _14$$18 = zephir_is_true(&disableAssignSetters); - if (!(_14$$18)) { - ZEPHIR_CALL_METHOD(&_15$$18, this_ptr, "possiblesetter", &_16, 419, &attributeField, &value); - zephir_check_call_status(); - _14$$18 = !zephir_is_true(&_15$$18); - } - if (_14$$18) { - zephir_update_property_zval_zval(this_ptr, &attributeField, &value); - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_4, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_6, &_4, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_6)) { - break; - } - ZEPHIR_CALL_METHOD(&attribute, &_4, "current", NULL, 0); - zephir_check_call_status(); - _17$$22 = !(zephir_array_isset(&columnMap, &attribute)); - if (_17$$22) { - _17$$22 = ZEPHIR_GLOBAL(orm).case_insensitive_column_map; - } - if (_17$$22) { - ZEPHIR_CALL_SELF(&_18$$23, "caseinsensitivecolumnmap", &_9, 420, &columnMap, &attribute); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&attribute, &_18$$23); - } - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeField); - if (!(zephir_array_isset_fetch(&attributeField, &columnMap, &attribute, 0))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_19$$26); - object_init_ex(&_19$$26, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_20$$26); - zephir_get_class(&_20$$26, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_21$$26); - ZEPHIR_CONCAT_SVSVS(&_21$$26, "Column '", &attribute, "' doesn't make part of the column map in '", &_20$$26, "'"); - ZEPHIR_CALL_METHOD(NULL, &_19$$26, "__construct", &_13, 33, &_21$$26); - zephir_check_call_status(); - zephir_throw_exception_debug(&_19$$26, "phalcon/Mvc/Model.zep", 783); - ZEPHIR_MM_RESTORE(); - return; - } - continue; - } - } else { - ZEPHIR_CPY_WRT(&attributeField, &attribute); - } - ZEPHIR_OBS_NVAR(&value); - if (zephir_array_isset_fetch(&value, &dataMapped, &attributeField, 0)) { - if (Z_TYPE_P(whiteList) == IS_ARRAY) { - if (!(zephir_fast_in_array(&attributeField, whiteList))) { - continue; - } - } - _22$$28 = zephir_is_true(&disableAssignSetters); - if (!(_22$$28)) { - ZEPHIR_CALL_METHOD(&_23$$28, this_ptr, "possiblesetter", &_16, 419, &attributeField, &value); - zephir_check_call_status(); - _22$$28 = !zephir_is_true(&_23$$28); - } - if (_22$$28) { - zephir_update_property_zval_zval(this_ptr, &attributeField, &value); - } - } - ZEPHIR_CALL_METHOD(NULL, &_4, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&attribute); + zephir_fetch_params(1, 1, 0, &having); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "having"); + zephir_update_property_array(this_ptr, SL("params"), &_0, having); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model, average) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, innerJoin) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *parameters_param = NULL, result, _0, _1; - zval parameters; + zval *model_param = NULL, *conditions = NULL, conditions_sub, *alias = NULL, alias_sub, __$null, _0; + zval model; + zval *this_ptr = getThis(); - ZVAL_UNDEF(¶meters); - ZVAL_UNDEF(&result); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&conditions_sub); + ZVAL_UNDEF(&alias_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(0, 1) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(model) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(parameters) + Z_PARAM_ZVAL_OR_NULL(conditions) + Z_PARAM_ZVAL_OR_NULL(alias) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, ¶meters_param); - if (!parameters_param) { - ZEPHIR_INIT_VAR(¶meters); - array_init(¶meters); + zephir_fetch_params(1, 1, 2, &model_param, &conditions, &alias); + if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { + zephir_get_strval(&model, model_param); } else { - zephir_get_arrval(¶meters, parameters_param); + ZEPHIR_INIT_VAR(&model); + } + if (!conditions) { + conditions = &conditions_sub; + conditions = &__$null; + } + if (!alias) { + alias = &alias_sub; + alias = &__$null; } ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "AVG"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "average"); - ZEPHIR_CALL_SELF(&result, "groupresult", NULL, 0, &_0, &_1, ¶meters); + ZVAL_STRING(&_0, "INNER"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "join", NULL, 0, &model, conditions, alias, &_0); zephir_check_call_status(); - if (Z_TYPE_P(&result) == IS_STRING) { - RETURN_MM_DOUBLE(zephir_get_doubleval(&result)); - } - RETURN_CCTOR(&result); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, cloneResult) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, inWhere) { - zend_string *_4; - zend_ulong _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_8 = NULL; - zend_long dirtyState, ZEPHIR_LAST_CALL_STATUS; - zval data; - zval *base, base_sub, *data_param = NULL, *dirtyState_param = NULL, instance, key, value, _0, *_1, _2, _12, _5$$4, _6$$4, _7$$4, _9$$6, _10$$6, _11$$6; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval values, bindParams, bindKeys; + zval *expr_param = NULL, *values_param = NULL, hiddenParam, value, *_1, _2, _5, _6, _3$$4, _4$$5; + zval expr, key, queryKey, _0$$3; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&base_sub); - ZVAL_UNDEF(&instance); + ZVAL_UNDEF(&expr); ZVAL_UNDEF(&key); + ZVAL_UNDEF(&queryKey); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&hiddenParam); ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_9$$6); - ZVAL_UNDEF(&_10$$6); - ZVAL_UNDEF(&_11$$6); - ZVAL_UNDEF(&data); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_OBJECT_OF_CLASS(base, phalcon_mvc_modelinterface_ce) - Z_PARAM_ARRAY(data) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(dirtyState) + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindKeys); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(expr) + Z_PARAM_ARRAY(values) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &base, &data_param, &dirtyState_param); - ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); - if (!dirtyState_param) { - dirtyState = 0; + zephir_fetch_params(1, 2, 0, &expr_param, &values_param); + if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { + zephir_get_strval(&expr, expr_param); } else { - } - ZEPHIR_INIT_VAR(&instance); - if (zephir_clone(&instance, base) == FAILURE) { - RETURN_MM(); + ZEPHIR_INIT_VAR(&expr); } - ZVAL_LONG(&_0, dirtyState); - ZEPHIR_CALL_METHOD(NULL, &instance, "setdirtystate", NULL, 0, &_0); - zephir_check_call_status(); - zephir_is_iterable(&data, 0, "phalcon/Mvc/Model.zep", 899); - if (Z_TYPE_P(&data) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _3, _4, _1) + ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); + if (!(zephir_fast_count_int(&values))) { + ZEPHIR_INIT_VAR(&_0$$3); + ZEPHIR_CONCAT_VSV(&_0$$3, &expr, " != ", &expr); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, &_0$$3); + zephir_check_call_status(); + RETURN_THIS(); + } + zephir_memory_observe(&hiddenParam); + zephir_read_property(&hiddenParam, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); + ZEPHIR_INIT_VAR(&bindKeys); + array_init(&bindKeys); + zephir_is_iterable(&values, 0, "phalcon/Mvc/Model/Criteria.zep", 595); + if (Z_TYPE_P(&values) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&values), _1) { - ZEPHIR_INIT_NVAR(&key); - if (_4 != NULL) { - ZVAL_STR_COPY(&key, _4); - } else { - ZVAL_LONG(&key, _3); - } ZEPHIR_INIT_NVAR(&value); ZVAL_COPY(&value, _1); - if (UNEXPECTED(Z_TYPE_P(&key) != IS_STRING)) { - ZEPHIR_INIT_NVAR(&_5$$4); - object_init_ex(&_5$$4, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_6$$4); - zephir_get_class(&_6$$4, base, 0); - ZEPHIR_INIT_NVAR(&_7$$4); - ZEPHIR_CONCAT_SVS(&_7$$4, "Invalid key in array data provided to dumpResult() in '", &_6$$4, "'"); - ZEPHIR_CALL_METHOD(NULL, &_5$$4, "__construct", &_8, 33, &_7$$4); - zephir_check_call_status(); - zephir_throw_exception_debug(&_5$$4, "phalcon/Mvc/Model.zep", 889); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_update_property_zval_zval(&instance, &key, &value); + ZEPHIR_INIT_NVAR(&_3$$4); + ZEPHIR_CONCAT_SV(&_3$$4, "ACP", &hiddenParam); + zephir_get_strval(&key, &_3$$4); + ZEPHIR_INIT_NVAR(&queryKey); + ZEPHIR_CONCAT_SVS(&queryKey, ":", &key, ":"); + zephir_array_append(&bindKeys, &queryKey, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 585); + zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); + SEPARATE_ZVAL(&hiddenParam); + zephir_increment(&hiddenParam); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_2, &data, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_2, &values, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_2)) { break; } - ZEPHIR_CALL_METHOD(&key, &data, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&key) != IS_STRING)) { - ZEPHIR_INIT_NVAR(&_9$$6); - object_init_ex(&_9$$6, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_10$$6); - zephir_get_class(&_10$$6, base, 0); - ZEPHIR_INIT_NVAR(&_11$$6); - ZEPHIR_CONCAT_SVS(&_11$$6, "Invalid key in array data provided to dumpResult() in '", &_10$$6, "'"); - ZEPHIR_CALL_METHOD(NULL, &_9$$6, "__construct", &_8, 33, &_11$$6); - zephir_check_call_status(); - zephir_throw_exception_debug(&_9$$6, "phalcon/Mvc/Model.zep", 889); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_update_property_zval_zval(&instance, &key, &value); - ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); + ZEPHIR_INIT_NVAR(&_4$$5); + ZEPHIR_CONCAT_SV(&_4$$5, "ACP", &hiddenParam); + zephir_get_strval(&key, &_4$$5); + ZEPHIR_INIT_NVAR(&queryKey); + ZEPHIR_CONCAT_SVS(&queryKey, ":", &key, ":"); + zephir_array_append(&bindKeys, &queryKey, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 585); + zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); + SEPARATE_ZVAL(&hiddenParam); + zephir_increment(&hiddenParam); + ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - ZEPHIR_INIT_VAR(&_12); - ZVAL_STRING(&_12, "afterFetch"); - ZEPHIR_CALL_METHOD(NULL, &instance, "fireevent", NULL, 0, &_12); + ZEPHIR_INIT_VAR(&_5); + zephir_fast_join_str(&_5, SL(", "), &bindKeys); + ZEPHIR_INIT_VAR(&_6); + ZEPHIR_CONCAT_VSVS(&_6, &expr, " IN (", &_5, ")"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, &_6, &bindParams); zephir_check_call_status(); - RETURN_CCTOR(&instance); + zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &hiddenParam); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model, cloneResultMap) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, join) { - zend_string *_4; - zend_ulong _3; + zval join, _1$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_9 = NULL, *_16 = NULL; - zend_bool keepSnapshots, _5$$6, _13$$3, _18$$24, _25$$21; - zend_long dirtyState, ZEPHIR_LAST_CALL_STATUS; - zval data; - zval *base, base_sub, *data_param = NULL, *columnMap, columnMap_sub, *dirtyState_param = NULL, *keepSnapshots_param = NULL, instance, attribute, key, value, castValue, attributeName, metaData, reverseMap, _0, *_1, _2, _6$$9, _7$$9, _8$$9, _10$$11, _11$$11, _12$$11, _14$$13, _15$$14, _17$$18, _19$$27, _20$$27, _21$$27, _22$$29, _23$$29, _24$$29, _26$$31, _27$$32, _28$$36, _29$$40; + zval *model_param = NULL, *conditions = NULL, conditions_sub, *alias = NULL, alias_sub, *type = NULL, type_sub, __$null, mergedJoins, currentJoins, _0, _4, _2$$5, _3$$6; + zval model; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&base_sub); - ZVAL_UNDEF(&columnMap_sub); - ZVAL_UNDEF(&instance); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&castValue); - ZVAL_UNDEF(&attributeName); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&reverseMap); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&conditions_sub); + ZVAL_UNDEF(&alias_sub); + ZVAL_UNDEF(&type_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&mergedJoins); + ZVAL_UNDEF(¤tJoins); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_6$$9); - ZVAL_UNDEF(&_7$$9); - ZVAL_UNDEF(&_8$$9); - ZVAL_UNDEF(&_10$$11); - ZVAL_UNDEF(&_11$$11); - ZVAL_UNDEF(&_12$$11); - ZVAL_UNDEF(&_14$$13); - ZVAL_UNDEF(&_15$$14); - ZVAL_UNDEF(&_17$$18); - ZVAL_UNDEF(&_19$$27); - ZVAL_UNDEF(&_20$$27); - ZVAL_UNDEF(&_21$$27); - ZVAL_UNDEF(&_22$$29); - ZVAL_UNDEF(&_23$$29); - ZVAL_UNDEF(&_24$$29); - ZVAL_UNDEF(&_26$$31); - ZVAL_UNDEF(&_27$$32); - ZVAL_UNDEF(&_28$$36); - ZVAL_UNDEF(&_29$$40); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_3$$6); + ZVAL_UNDEF(&join); + ZVAL_UNDEF(&_1$$4); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 5) - Z_PARAM_ZVAL(base) - Z_PARAM_ARRAY(data) - Z_PARAM_ZVAL(columnMap) + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_STR(model) Z_PARAM_OPTIONAL - Z_PARAM_LONG(dirtyState) - Z_PARAM_BOOL_OR_NULL(keepSnapshots, is_null_true) + Z_PARAM_ZVAL_OR_NULL(conditions) + Z_PARAM_ZVAL_OR_NULL(alias) + Z_PARAM_ZVAL_OR_NULL(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 2, &base, &data_param, &columnMap, &dirtyState_param, &keepSnapshots_param); - ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); - if (!dirtyState_param) { - dirtyState = 0; + zephir_fetch_params(1, 1, 3, &model_param, &conditions, &alias, &type); + if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { + zephir_get_strval(&model, model_param); } else { + ZEPHIR_INIT_VAR(&model); + } + if (!conditions) { + conditions = &conditions_sub; + conditions = &__$null; + } + if (!alias) { + alias = &alias_sub; + alias = &__$null; + } + if (!type) { + type = &type_sub; + type = &__$null; + } + ZEPHIR_INIT_VAR(&join); + zephir_create_array(&join, 4, 0); + zephir_array_fast_append(&join, &model); + zephir_array_fast_append(&join, conditions); + zephir_array_fast_append(&join, alias); + zephir_array_fast_append(&join, type); + zephir_memory_observe(¤tJoins); + zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_string_fetch(¤tJoins, &_0, SL("joins"), 0)) { + if (Z_TYPE_P(¤tJoins) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&_1$$4); + zephir_create_array(&_1$$4, 1, 0); + zephir_array_fast_append(&_1$$4, &join); + ZEPHIR_INIT_VAR(&mergedJoins); + zephir_fast_array_merge(&mergedJoins, ¤tJoins, &_1$$4); + } else { + ZEPHIR_INIT_VAR(&_2$$5); + zephir_create_array(&_2$$5, 1, 0); + zephir_array_fast_append(&_2$$5, &join); + ZEPHIR_CPY_WRT(&mergedJoins, &_2$$5); } - if (!keepSnapshots_param) { - keepSnapshots = 0; } else { - } - ZEPHIR_INIT_VAR(&instance); - if (zephir_clone(&instance, base) == FAILURE) { - RETURN_MM(); + ZEPHIR_INIT_VAR(&_3$$6); + zephir_create_array(&_3$$6, 1, 0); + zephir_array_fast_append(&_3$$6, &join); + ZEPHIR_CPY_WRT(&mergedJoins, &_3$$6); } - ZVAL_LONG(&_0, dirtyState); - ZEPHIR_CALL_METHOD(NULL, &instance, "setdirtystate", NULL, 0, &_0); - zephir_check_call_status(); - zephir_is_iterable(&data, 1, "phalcon/Mvc/Model.zep", 1032); - if (Z_TYPE_P(&data) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _3, _4, _1) - { - ZEPHIR_INIT_NVAR(&key); - if (_4 != NULL) { - ZVAL_STR_COPY(&key, _4); - } else { - ZVAL_LONG(&key, _3); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _1); - if (Z_TYPE_P(&key) != IS_STRING) { - continue; - } - if (Z_TYPE_P(columnMap) != IS_ARRAY) { - zephir_update_property_zval_zval(&instance, &key, &value); - continue; - } - ZEPHIR_OBS_NVAR(&attribute); - if (!(zephir_array_isset_fetch(&attribute, columnMap, &key, 0))) { - _5$$6 = Z_TYPE_P(columnMap) == IS_ARRAY; - if (_5$$6) { - _5$$6 = !(ZEPHIR_IS_EMPTY(columnMap)); - } - if (_5$$6) { - ZEPHIR_CALL_METHOD(&metaData, &instance, "getmodelsmetadata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&reverseMap, &metaData, "getreversecolumnmap", NULL, 0, &instance); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&attribute); - if (!(zephir_array_isset_fetch(&attribute, &reverseMap, &key, 0))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_6$$9); - object_init_ex(&_6$$9, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_7$$9); - zephir_get_class(&_7$$9, base, 0); - ZEPHIR_INIT_NVAR(&_8$$9); - ZEPHIR_CONCAT_SVSVS(&_8$$9, "Column '", &key, "' doesn't make part of the column map in '", &_7$$9, "'"); - ZEPHIR_CALL_METHOD(NULL, &_6$$9, "__construct", &_9, 33, &_8$$9); - zephir_check_call_status(); - zephir_throw_exception_debug(&_6$$9, "phalcon/Mvc/Model.zep", 959); - ZEPHIR_MM_RESTORE(); - return; - } - continue; - } - } else { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_10$$11); - object_init_ex(&_10$$11, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_11$$11); - zephir_get_class(&_11$$11, base, 0); - ZEPHIR_INIT_NVAR(&_12$$11); - ZEPHIR_CONCAT_SVSVS(&_12$$11, "Column '", &key, "' doesn't make part of the column map in '", &_11$$11, "'"); - ZEPHIR_CALL_METHOD(NULL, &_10$$11, "__construct", &_9, 33, &_12$$11); - zephir_check_call_status(); - zephir_throw_exception_debug(&_10$$11, "phalcon/Mvc/Model.zep", 968); - ZEPHIR_MM_RESTORE(); - return; - } - continue; - } - } - if (Z_TYPE_P(&attribute) != IS_ARRAY) { - zephir_update_property_zval_zval(&instance, &attribute, &value); - continue; - } - _13$$3 = !ZEPHIR_IS_STRING(&value, ""); - if (_13$$3) { - _13$$3 = Z_TYPE_P(&value) != IS_NULL; - } - if (_13$$3) { - zephir_array_fetch_long(&_14$$13, &attribute, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 982); - do { - if (ZEPHIR_IS_LONG(&_14$$13, 0) || ZEPHIR_IS_LONG(&_14$$13, 21) || ZEPHIR_IS_LONG(&_14$$13, 22) || ZEPHIR_IS_LONG(&_14$$13, 26)) { - ZVAL_LONG(&_15$$14, 10); - ZEPHIR_CALL_FUNCTION(&castValue, "intval", &_16, 42, &value, &_15$$14); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&_14$$13, 3) || ZEPHIR_IS_LONG(&_14$$13, 9) || ZEPHIR_IS_LONG(&_14$$13, 7)) { - ZEPHIR_INIT_NVAR(&castValue); - ZVAL_DOUBLE(&castValue, zephir_get_doubleval(&value)); - break; - } - if (ZEPHIR_IS_LONG(&_14$$13, 8)) { - ZEPHIR_INIT_NVAR(&castValue); - ZVAL_BOOL(&castValue, zephir_get_boolval(&value)); - break; - } - ZEPHIR_CPY_WRT(&castValue, &value); - break; - } while(0); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "joins"); + zephir_update_property_array(this_ptr, SL("params"), &_4, &mergedJoins); + RETURN_THIS(); +} - } else { - zephir_array_fetch_long(&_17$$18, &attribute, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 1005); - do { - if (ZEPHIR_IS_LONG(&_17$$18, 14) || ZEPHIR_IS_LONG(&_17$$18, 8) || ZEPHIR_IS_LONG(&_17$$18, 3) || ZEPHIR_IS_LONG(&_17$$18, 9) || ZEPHIR_IS_LONG(&_17$$18, 7) || ZEPHIR_IS_LONG(&_17$$18, 0) || ZEPHIR_IS_LONG(&_17$$18, 21) || ZEPHIR_IS_LONG(&_17$$18, 22) || ZEPHIR_IS_LONG(&_17$$18, 26)) { - ZEPHIR_INIT_NVAR(&castValue); - ZVAL_NULL(&castValue); - break; - } - ZEPHIR_CPY_WRT(&castValue, &value); - break; - } while(0); +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, leftJoin) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model_param = NULL, *conditions = NULL, conditions_sub, *alias = NULL, alias_sub, __$null, _0; + zval model; + zval *this_ptr = getThis(); - } - ZEPHIR_OBS_NVAR(&attributeName); - zephir_array_fetch_long(&attributeName, &attribute, 0, PH_NOISY, "phalcon/Mvc/Model.zep", 1024); - zephir_update_property_zval_zval(&instance, &attributeName, &castValue); - zephir_array_update_zval(&data, &key, &castValue, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&conditions_sub); + ZVAL_UNDEF(&alias_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(model) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(conditions) + Z_PARAM_ZVAL_OR_NULL(alias) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &model_param, &conditions, &alias); + if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { + zephir_get_strval(&model, model_param); } else { - ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &data, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &data, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&key) != IS_STRING) { - continue; - } - if (Z_TYPE_P(columnMap) != IS_ARRAY) { - zephir_update_property_zval_zval(&instance, &key, &value); - continue; - } - ZEPHIR_OBS_NVAR(&attribute); - if (!(zephir_array_isset_fetch(&attribute, columnMap, &key, 0))) { - _18$$24 = Z_TYPE_P(columnMap) == IS_ARRAY; - if (_18$$24) { - _18$$24 = !(ZEPHIR_IS_EMPTY(columnMap)); - } - if (_18$$24) { - ZEPHIR_CALL_METHOD(&metaData, &instance, "getmodelsmetadata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&reverseMap, &metaData, "getreversecolumnmap", NULL, 0, &instance); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&attribute); - if (!(zephir_array_isset_fetch(&attribute, &reverseMap, &key, 0))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_19$$27); - object_init_ex(&_19$$27, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_20$$27); - zephir_get_class(&_20$$27, base, 0); - ZEPHIR_INIT_NVAR(&_21$$27); - ZEPHIR_CONCAT_SVSVS(&_21$$27, "Column '", &key, "' doesn't make part of the column map in '", &_20$$27, "'"); - ZEPHIR_CALL_METHOD(NULL, &_19$$27, "__construct", &_9, 33, &_21$$27); - zephir_check_call_status(); - zephir_throw_exception_debug(&_19$$27, "phalcon/Mvc/Model.zep", 959); - ZEPHIR_MM_RESTORE(); - return; - } - continue; - } - } else { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_22$$29); - object_init_ex(&_22$$29, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_23$$29); - zephir_get_class(&_23$$29, base, 0); - ZEPHIR_INIT_NVAR(&_24$$29); - ZEPHIR_CONCAT_SVSVS(&_24$$29, "Column '", &key, "' doesn't make part of the column map in '", &_23$$29, "'"); - ZEPHIR_CALL_METHOD(NULL, &_22$$29, "__construct", &_9, 33, &_24$$29); - zephir_check_call_status(); - zephir_throw_exception_debug(&_22$$29, "phalcon/Mvc/Model.zep", 968); - ZEPHIR_MM_RESTORE(); - return; - } - continue; - } - } - if (Z_TYPE_P(&attribute) != IS_ARRAY) { - zephir_update_property_zval_zval(&instance, &attribute, &value); - continue; - } - _25$$21 = !ZEPHIR_IS_STRING(&value, ""); - if (_25$$21) { - _25$$21 = Z_TYPE_P(&value) != IS_NULL; - } - if (_25$$21) { - zephir_array_fetch_long(&_26$$31, &attribute, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 982); - do { - if (ZEPHIR_IS_LONG(&_26$$31, 0) || ZEPHIR_IS_LONG(&_26$$31, 21) || ZEPHIR_IS_LONG(&_26$$31, 22) || ZEPHIR_IS_LONG(&_26$$31, 26)) { - ZVAL_LONG(&_27$$32, 10); - ZEPHIR_CALL_FUNCTION(&castValue, "intval", &_16, 42, &value, &_27$$32); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&_26$$31, 3) || ZEPHIR_IS_LONG(&_26$$31, 9) || ZEPHIR_IS_LONG(&_26$$31, 7)) { - ZEPHIR_INIT_NVAR(&castValue); - ZVAL_DOUBLE(&castValue, zephir_get_doubleval(&value)); - break; - } - if (ZEPHIR_IS_LONG(&_26$$31, 8)) { - ZEPHIR_INIT_NVAR(&castValue); - ZVAL_BOOL(&castValue, zephir_get_boolval(&value)); - break; - } - ZEPHIR_CPY_WRT(&castValue, &value); - break; - } while(0); + ZEPHIR_INIT_VAR(&model); + } + if (!conditions) { + conditions = &conditions_sub; + conditions = &__$null; + } + if (!alias) { + alias = &alias_sub; + alias = &__$null; + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "LEFT"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "join", NULL, 0, &model, conditions, alias, &_0); + zephir_check_call_status(); + RETURN_MM(); +} - } else { - zephir_array_fetch_long(&_28$$36, &attribute, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 1005); - do { - if (ZEPHIR_IS_LONG(&_28$$36, 14) || ZEPHIR_IS_LONG(&_28$$36, 8) || ZEPHIR_IS_LONG(&_28$$36, 3) || ZEPHIR_IS_LONG(&_28$$36, 9) || ZEPHIR_IS_LONG(&_28$$36, 7) || ZEPHIR_IS_LONG(&_28$$36, 0) || ZEPHIR_IS_LONG(&_28$$36, 21) || ZEPHIR_IS_LONG(&_28$$36, 22) || ZEPHIR_IS_LONG(&_28$$36, 26)) { - ZEPHIR_INIT_NVAR(&castValue); - ZVAL_NULL(&castValue); - break; - } - ZEPHIR_CPY_WRT(&castValue, &value); - break; - } while(0); +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, limit) +{ + zval _5$$5; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *limit_param = NULL, *offset_param = NULL, _0, _1, _2, _3$$4, _4$$4, _6$$5; + zend_long limit, offset, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - } - ZEPHIR_OBS_NVAR(&attributeName); - zephir_array_fetch_long(&attributeName, &attribute, 0, PH_NOISY, "phalcon/Mvc/Model.zep", 1024); - zephir_update_property_zval_zval(&instance, &attributeName, &castValue); - zephir_array_update_zval(&data, &key, &castValue, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); - zephir_check_call_status(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_5$$5); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_LONG(limit) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(offset) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &limit_param, &offset_param); + if (!offset_param) { + offset = 0; + } else { } + ZVAL_LONG(&_0, limit); + ZEPHIR_CALL_FUNCTION(&_1, "abs", NULL, 284, &_0); + zephir_check_call_status(); + limit = zephir_get_numberval(&_1); + ZVAL_LONG(&_0, offset); + ZEPHIR_CALL_FUNCTION(&_2, "abs", NULL, 284, &_0); + zephir_check_call_status(); + offset = zephir_get_numberval(&_2); + if (UNEXPECTED(limit == 0)) { + RETURN_THIS(); } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - if (keepSnapshots) { - ZEPHIR_CALL_METHOD(NULL, &instance, "setsnapshotdata", NULL, 0, &data, columnMap); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &instance, "setoldsnapshotdata", NULL, 0, &data, columnMap); - zephir_check_call_status(); + if (offset == 0) { + ZEPHIR_INIT_VAR(&_3$$4); + ZVAL_STRING(&_3$$4, "limit"); + ZEPHIR_INIT_VAR(&_4$$4); + ZVAL_LONG(&_4$$4, limit); + zephir_update_property_array(this_ptr, SL("params"), &_3$$4, &_4$$4); + } else { + ZEPHIR_INIT_VAR(&_5$$5); + zephir_create_array(&_5$$5, 2, 0); + ZEPHIR_INIT_VAR(&_6$$5); + ZVAL_LONG(&_6$$5, limit); + zephir_array_update_string(&_5$$5, SL("number"), &_6$$5, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_6$$5); + ZVAL_LONG(&_6$$5, offset); + zephir_array_update_string(&_5$$5, SL("offset"), &_6$$5, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_6$$5); + ZVAL_STRING(&_6$$5, "limit"); + zephir_update_property_array(this_ptr, SL("params"), &_6$$5, &_5$$5); } - if ((zephir_method_exists_ex(&instance, ZEND_STRL("fireevent")) == SUCCESS)) { - ZEPHIR_INIT_VAR(&_29$$40); - ZVAL_STRING(&_29$$40, "afterFetch"); - ZEPHIR_CALL_METHOD(NULL, &instance, "fireevent", NULL, 0, &_29$$40); - zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, notBetweenWhere) +{ + zval _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, hiddenParam, nextHiddenParam, _0, _1; + zval expr, minimumKey, maximumKey, _2; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&minimumKey); + ZVAL_UNDEF(&maximumKey); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&minimum_sub); + ZVAL_UNDEF(&maximum_sub); + ZVAL_UNDEF(&hiddenParam); + ZVAL_UNDEF(&nextHiddenParam); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(expr) + Z_PARAM_ZVAL(minimum) + Z_PARAM_ZVAL(maximum) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 0, &expr_param, &minimum, &maximum); + if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + RETURN_MM_NULL(); } - RETURN_CCTOR(&instance); + if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { + zephir_get_strval(&expr, expr_param); + } else { + ZEPHIR_INIT_VAR(&expr); + } + zephir_memory_observe(&hiddenParam); + zephir_read_property(&hiddenParam, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(&nextHiddenParam); + ZVAL_LONG(&nextHiddenParam, (zephir_get_numberval(&hiddenParam) + 1)); + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_CONCAT_SV(&_0, "ACP", &hiddenParam); + zephir_get_strval(&minimumKey, &_0); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_SV(&_1, "ACP", &nextHiddenParam); + zephir_get_strval(&maximumKey, &_1); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_CONCAT_VSVSVS(&_2, &expr, " NOT BETWEEN :", &minimumKey, ": AND :", &maximumKey, ":"); + ZEPHIR_INIT_VAR(&_3); + zephir_create_array(&_3, 2, 0); + zephir_array_update_zval(&_3, &minimumKey, minimum, PH_COPY); + zephir_array_update_zval(&_3, &maximumKey, maximum, PH_COPY); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, &_2, &_3); + zephir_check_call_status(); + SEPARATE_ZVAL(&nextHiddenParam); + zephir_increment(&nextHiddenParam); + zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &nextHiddenParam); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model, cloneResultMapHydrate) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, notInWhere) { - zend_bool _4$$7, _10$$16; - zend_string *_3; - zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_6 = NULL, *_9 = NULL; - zend_long hydrationMode, ZEPHIR_LAST_CALL_STATUS; - zval *data_param = NULL, *columnMap, columnMap_sub, *hydrationMode_param = NULL, key, value, attribute, attributeName, *_0, _1, _5$$8, _7$$10, _8$$10, _11$$17, _12$$19, _13$$19; - zval data, hydrateArray; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval values, bindParams, bindKeys; + zval *expr_param = NULL, *values_param = NULL, hiddenParam, value, *_0, _1, _6, _7, _2$$3, _4$$4; + zval expr, key, _3$$3, _5$$4; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&hydrateArray); - ZVAL_UNDEF(&columnMap_sub); + ZVAL_UNDEF(&expr); ZVAL_UNDEF(&key); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&hiddenParam); ZVAL_UNDEF(&value); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&attributeName); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_5$$8); - ZVAL_UNDEF(&_7$$10); - ZVAL_UNDEF(&_8$$10); - ZVAL_UNDEF(&_11$$17); - ZVAL_UNDEF(&_12$$19); - ZVAL_UNDEF(&_13$$19); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ARRAY(data) - Z_PARAM_ZVAL(columnMap) - Z_PARAM_LONG(hydrationMode) + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindKeys); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(expr) + Z_PARAM_ARRAY(values) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &data_param, &columnMap, &hydrationMode_param); - ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); - if (Z_TYPE_P(columnMap) != IS_ARRAY) { - if (hydrationMode == 1) { - RETURN_CTOR(&data); - } + zephir_fetch_params(1, 2, 0, &expr_param, &values_param); + if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_INIT_VAR(&hydrateArray); - array_init(&hydrateArray); - zephir_is_iterable(&data, 0, "phalcon/Mvc/Model.zep", 1119); - if (Z_TYPE_P(&data) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _2, _3, _0) + if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { + zephir_get_strval(&expr, expr_param); + } else { + ZEPHIR_INIT_VAR(&expr); + } + ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); + zephir_memory_observe(&hiddenParam); + zephir_read_property(&hiddenParam, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); + ZEPHIR_INIT_VAR(&bindKeys); + array_init(&bindKeys); + zephir_is_iterable(&values, 0, "phalcon/Mvc/Model/Criteria.zep", 782); + if (Z_TYPE_P(&values) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&values), _0) { - ZEPHIR_INIT_NVAR(&key); - if (_3 != NULL) { - ZVAL_STR_COPY(&key, _3); - } else { - ZVAL_LONG(&key, _2); - } ZEPHIR_INIT_NVAR(&value); ZVAL_COPY(&value, _0); - if (Z_TYPE_P(&key) != IS_STRING) { - continue; - } - if (Z_TYPE_P(columnMap) == IS_ARRAY) { - _4$$7 = !(zephir_array_isset(columnMap, &key)); - if (_4$$7) { - _4$$7 = ZEPHIR_GLOBAL(orm).case_insensitive_column_map; - } - if (_4$$7) { - ZEPHIR_CALL_SELF(&_5$$8, "caseinsensitivecolumnmap", &_6, 420, columnMap, &key); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&key, &_5$$8); - } - ZEPHIR_OBS_NVAR(&attribute); - if (!(zephir_array_isset_fetch(&attribute, columnMap, &key, 0))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_7$$10); - object_init_ex(&_7$$10, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_8$$10); - ZEPHIR_CONCAT_SVS(&_8$$10, "Column '", &key, "' doesn't make part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_7$$10, "__construct", &_9, 33, &_8$$10); - zephir_check_call_status(); - zephir_throw_exception_debug(&_7$$10, "phalcon/Mvc/Model.zep", 1098); - ZEPHIR_MM_RESTORE(); - return; - } - continue; - } - if (Z_TYPE_P(&attribute) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeName); - zephir_array_fetch_long(&attributeName, &attribute, 0, PH_NOISY, "phalcon/Mvc/Model.zep", 1108); - } else { - ZEPHIR_CPY_WRT(&attributeName, &attribute); - } - zephir_array_update_zval(&hydrateArray, &attributeName, &value, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&hydrateArray, &key, &value, PH_COPY | PH_SEPARATE); - } + ZEPHIR_INIT_NVAR(&_2$$3); + ZEPHIR_CONCAT_SV(&_2$$3, "ACP", &hiddenParam); + zephir_get_strval(&key, &_2$$3); + ZEPHIR_INIT_NVAR(&_3$$3); + ZEPHIR_CONCAT_SVS(&_3$$3, ":", &key, ":"); + zephir_array_append(&bindKeys, &_3$$3, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 772); + zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); + SEPARATE_ZVAL(&hiddenParam); + zephir_increment(&hiddenParam); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_1, &data, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_1, &values, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_1)) { break; } - ZEPHIR_CALL_METHOD(&key, &data, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); zephir_check_call_status(); - if (Z_TYPE_P(&key) != IS_STRING) { - continue; - } - if (Z_TYPE_P(columnMap) == IS_ARRAY) { - _10$$16 = !(zephir_array_isset(columnMap, &key)); - if (_10$$16) { - _10$$16 = ZEPHIR_GLOBAL(orm).case_insensitive_column_map; - } - if (_10$$16) { - ZEPHIR_CALL_SELF(&_11$$17, "caseinsensitivecolumnmap", &_6, 420, columnMap, &key); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&key, &_11$$17); - } - ZEPHIR_OBS_NVAR(&attribute); - if (!(zephir_array_isset_fetch(&attribute, columnMap, &key, 0))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_12$$19); - object_init_ex(&_12$$19, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_13$$19); - ZEPHIR_CONCAT_SVS(&_13$$19, "Column '", &key, "' doesn't make part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_12$$19, "__construct", &_9, 33, &_13$$19); - zephir_check_call_status(); - zephir_throw_exception_debug(&_12$$19, "phalcon/Mvc/Model.zep", 1098); - ZEPHIR_MM_RESTORE(); - return; - } - continue; - } - if (Z_TYPE_P(&attribute) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeName); - zephir_array_fetch_long(&attributeName, &attribute, 0, PH_NOISY, "phalcon/Mvc/Model.zep", 1108); - } else { - ZEPHIR_CPY_WRT(&attributeName, &attribute); - } - zephir_array_update_zval(&hydrateArray, &attributeName, &value, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&hydrateArray, &key, &value, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); + ZEPHIR_INIT_NVAR(&_4$$4); + ZEPHIR_CONCAT_SV(&_4$$4, "ACP", &hiddenParam); + zephir_get_strval(&key, &_4$$4); + ZEPHIR_INIT_NVAR(&_5$$4); + ZEPHIR_CONCAT_SVS(&_5$$4, ":", &key, ":"); + zephir_array_append(&bindKeys, &_5$$4, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 772); + zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); + SEPARATE_ZVAL(&hiddenParam); + zephir_increment(&hiddenParam); + ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - if (hydrationMode != 1) { - zephir_convert_to_object(&hydrateArray); - RETURN_CTOR(&hydrateArray); - } - RETURN_CTOR(&hydrateArray); + ZEPHIR_INIT_VAR(&_6); + zephir_fast_join_str(&_6, SL(", "), &bindKeys); + ZEPHIR_INIT_VAR(&_7); + ZEPHIR_CONCAT_VSVS(&_7, &expr, " NOT IN (", &_6, ")"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, &_7, &bindParams); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &hiddenParam); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model, collectRelatedToSave) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, orderBy) { - zend_bool _6$$3, _8$$6; - zend_string *_5; - zend_ulong _4; - zval related, dirtyRelated; - zval name, record, _0, _1, *_2, _3, _7$$3, _9$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *orderColumns_param = NULL, _0; + zval orderColumns; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&record); + ZVAL_UNDEF(&orderColumns); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_9$$6); - ZVAL_UNDEF(&related); - ZVAL_UNDEF(&dirtyRelated); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(orderColumns) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("related"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&related, &_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("dirtyRelated"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&dirtyRelated, &_1); - zephir_is_iterable(&related, 0, "phalcon/Mvc/Model.zep", 1160); - if (Z_TYPE_P(&related) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&related), _4, _5, _2) - { - ZEPHIR_INIT_NVAR(&name); - if (_5 != NULL) { - ZVAL_STR_COPY(&name, _5); - } else { - ZVAL_LONG(&name, _4); - } - ZEPHIR_INIT_NVAR(&record); - ZVAL_COPY(&record, _2); - if (zephir_array_isset(&dirtyRelated, &name)) { - continue; - } - _6$$3 = Z_TYPE_P(&record) != IS_OBJECT; - if (!(_6$$3)) { - _6$$3 = !((zephir_instance_of_ev(&record, phalcon_mvc_modelinterface_ce))); - } - if (_6$$3) { - continue; - } - ZVAL_LONG(&_7$$3, 1); - ZEPHIR_CALL_METHOD(NULL, &record, "setdirtystate", NULL, 0, &_7$$3); - zephir_check_call_status(); - zephir_array_update_zval(&dirtyRelated, &name, &record, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 1, 0, &orderColumns_param); + if (UNEXPECTED(Z_TYPE_P(orderColumns_param) != IS_STRING && Z_TYPE_P(orderColumns_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'orderColumns' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(orderColumns_param) == IS_STRING)) { + zephir_get_strval(&orderColumns, orderColumns_param); } else { - ZEPHIR_CALL_METHOD(NULL, &related, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &related, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3)) { - break; - } - ZEPHIR_CALL_METHOD(&name, &related, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&record, &related, "current", NULL, 0); - zephir_check_call_status(); - if (zephir_array_isset(&dirtyRelated, &name)) { - continue; - } - _8$$6 = Z_TYPE_P(&record) != IS_OBJECT; - if (!(_8$$6)) { - _8$$6 = !((zephir_instance_of_ev(&record, phalcon_mvc_modelinterface_ce))); - } - if (_8$$6) { - continue; - } - ZVAL_LONG(&_9$$6, 1); - ZEPHIR_CALL_METHOD(NULL, &record, "setdirtystate", NULL, 0, &_9$$6); - zephir_check_call_status(); - zephir_array_update_zval(&dirtyRelated, &name, &record, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &related, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&orderColumns); } - ZEPHIR_INIT_NVAR(&record); - ZEPHIR_INIT_NVAR(&name); - RETURN_CTOR(&dirtyRelated); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "order"); + zephir_update_property_array(this_ptr, SL("params"), &_0, &orderColumns); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model, count) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, orWhere) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *parameters = NULL, parameters_sub, __$null, result, _0, _1; + zval *conditions_param = NULL, *bindParams = NULL, bindParams_sub, *bindTypes = NULL, bindTypes_sub, __$null, currentConditions, _0, _1$$3; + zval conditions; + zval *this_ptr = getThis(); - ZVAL_UNDEF(¶meters_sub); + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(&bindParams_sub); + ZVAL_UNDEF(&bindTypes_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&result); + ZVAL_UNDEF(¤tConditions); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_1$$3); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(conditions) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(parameters) + Z_PARAM_ZVAL_OR_NULL(bindParams) + Z_PARAM_ZVAL_OR_NULL(bindTypes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, ¶meters); - if (!parameters) { - parameters = ¶meters_sub; - ZEPHIR_CPY_WRT(parameters, &__$null); + zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams, &bindTypes); + if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { + zephir_get_strval(&conditions, conditions_param); } else { - ZEPHIR_SEPARATE_PARAM(parameters); + ZEPHIR_INIT_VAR(&conditions); } - if (zephir_array_isset_string(parameters, SL("order"))) { - zephir_array_unset_string(parameters, SL("order"), PH_SEPARATE); + if (!bindParams) { + bindParams = &bindParams_sub; + bindParams = &__$null; } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "COUNT"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "rowcount"); - ZEPHIR_CALL_SELF(&result, "groupresult", NULL, 0, &_0, &_1, parameters); - zephir_check_call_status(); - if (Z_TYPE_P(&result) == IS_STRING) { - RETURN_MM_LONG(zephir_get_intval(&result)); + if (!bindTypes) { + bindTypes = &bindTypes_sub; + bindTypes = &__$null; } - RETURN_CCTOR(&result); + zephir_memory_observe(¤tConditions); + zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_string_fetch(¤tConditions, &_0, SL("conditions"), 0)) { + ZEPHIR_INIT_VAR(&_1$$3); + ZEPHIR_CONCAT_SVSVS(&_1$$3, "(", ¤tConditions, ") OR (", &conditions, ")"); + zephir_get_strval(&conditions, &_1$$3); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "where", NULL, 0, &conditions, bindParams, bindTypes); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, create) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, rightJoin) { - zval _2$$3, _4$$3; - zval metaData, _0, _1, _3$$3, _5$$3, _6$$3, _7$$3, _8$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model_param = NULL, *conditions = NULL, conditions_sub, *alias = NULL, alias_sub, __$null, _0; + zval model; zval *this_ptr = getThis(); - ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&conditions_sub); + ZVAL_UNDEF(&alias_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(model) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(conditions) + Z_PARAM_ZVAL_OR_NULL(alias) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getwriteconnection", NULL, 421); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, 0, &metaData, &_1); - zephir_check_call_status(); - if (zephir_is_true(&_0)) { - ZEPHIR_INIT_VAR(&_2$$3); - zephir_create_array(&_2$$3, 1, 0); - ZEPHIR_INIT_VAR(&_3$$3); - object_init_ex(&_3$$3, phalcon_messages_message_ce); - ZEPHIR_INIT_VAR(&_4$$3); - zephir_create_array(&_4$$3, 1, 0); - ZEPHIR_INIT_VAR(&_5$$3); - zephir_get_class(&_5$$3, this_ptr, 0); - zephir_array_update_string(&_4$$3, SL("model"), &_5$$3, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_5$$3); - ZVAL_STRING(&_5$$3, "Record cannot be created because it already exists"); - ZVAL_NULL(&_6$$3); - ZEPHIR_INIT_VAR(&_7$$3); - ZVAL_STRING(&_7$$3, "InvalidCreateAttempt"); - ZVAL_LONG(&_8$$3, 0); - ZEPHIR_CALL_METHOD(NULL, &_3$$3, "__construct", NULL, 6, &_5$$3, &_6$$3, &_7$$3, &_8$$3, &_4$$3); - zephir_check_call_status(); - zephir_array_fast_append(&_2$$3, &_3$$3); - zephir_update_property_zval(this_ptr, ZEND_STRL("errorMessages"), &_2$$3); - RETURN_MM_BOOL(0); + zephir_fetch_params(1, 1, 2, &model_param, &conditions, &alias); + if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "save", NULL, 0); + if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { + zephir_get_strval(&model, model_param); + } else { + ZEPHIR_INIT_VAR(&model); + } + if (!conditions) { + conditions = &conditions_sub; + conditions = &__$null; + } + if (!alias) { + alias = &alias_sub; + alias = &__$null; + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "RIGHT"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "join", NULL, 0, &model, conditions, alias, &_0); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, delete) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, setDI) { - zval values, bindTypes, conditions; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$true, __$false, metaData, writeConnection, primaryKeys, bindDataTypes, columnMap, attributeField, primaryKey, bindType, value, schema, source, table, success, _0, _1, *_6, _7, _35, _2$$3, _3$$7, _4$$7, _5$$7, _8$$9, _9$$9, _10$$9, _11$$11, _12$$11, _13$$11, _14$$13, _15$$13, _16$$13, _17$$8, _19$$8, _20$$15, _21$$15, _22$$15, _23$$17, _24$$17, _25$$17, _26$$19, _27$$19, _28$$19, _29$$14, _31$$14, _32$$20, _33$$20, _34$$20, _36$$25, _37$$28, _38$$29, _39$$29; - zephir_fcall_cache_entry *_18 = NULL, *_30 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *container, container_sub, _0; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&writeConnection); - ZVAL_UNDEF(&primaryKeys); - ZVAL_UNDEF(&bindDataTypes); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&attributeField); - ZVAL_UNDEF(&primaryKey); - ZVAL_UNDEF(&bindType); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&table); - ZVAL_UNDEF(&success); + ZVAL_UNDEF(&container_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_35); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$7); - ZVAL_UNDEF(&_4$$7); - ZVAL_UNDEF(&_5$$7); - ZVAL_UNDEF(&_8$$9); - ZVAL_UNDEF(&_9$$9); - ZVAL_UNDEF(&_10$$9); - ZVAL_UNDEF(&_11$$11); - ZVAL_UNDEF(&_12$$11); - ZVAL_UNDEF(&_13$$11); - ZVAL_UNDEF(&_14$$13); - ZVAL_UNDEF(&_15$$13); - ZVAL_UNDEF(&_16$$13); - ZVAL_UNDEF(&_17$$8); - ZVAL_UNDEF(&_19$$8); - ZVAL_UNDEF(&_20$$15); - ZVAL_UNDEF(&_21$$15); - ZVAL_UNDEF(&_22$$15); - ZVAL_UNDEF(&_23$$17); - ZVAL_UNDEF(&_24$$17); - ZVAL_UNDEF(&_25$$17); - ZVAL_UNDEF(&_26$$19); - ZVAL_UNDEF(&_27$$19); - ZVAL_UNDEF(&_28$$19); - ZVAL_UNDEF(&_29$$14); - ZVAL_UNDEF(&_31$$14); - ZVAL_UNDEF(&_32$$20); - ZVAL_UNDEF(&_33$$20); - ZVAL_UNDEF(&_34$$20); - ZVAL_UNDEF(&_36$$25); - ZVAL_UNDEF(&_37$$28); - ZVAL_UNDEF(&_38$$29); - ZVAL_UNDEF(&_39$$29); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&conditions); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &container); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "di"); + zephir_update_property_array(this_ptr, SL("params"), &_0, container); + ZEPHIR_MM_RESTORE(); +} - ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&writeConnection, this_ptr, "getwriteconnection", NULL, 421); - zephir_check_call_status(); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, 3); - zephir_update_property_zval(this_ptr, ZEND_STRL("operationMade"), &_0); - ZEPHIR_INIT_VAR(&_1); - array_init(&_1); - zephir_update_property_zval(this_ptr, ZEND_STRL("errorMessages"), &_1); - if (ZEPHIR_GLOBAL(orm).virtual_foreign_keys) { - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "checkforeignkeysreverserestrict", NULL, 422); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_2$$3)) { - RETURN_MM_BOOL(0); - } +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, setModelName) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *modelName_param = NULL; + zval modelName; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&modelName); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(modelName) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &modelName_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_INIT_VAR(&values); - array_init(&values); - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - ZEPHIR_INIT_VAR(&conditions); - array_init(&conditions); - ZEPHIR_CALL_METHOD(&primaryKeys, &metaData, "getprimarykeyattributes", NULL, 0, this_ptr); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&bindDataTypes, &metaData, "getbindtypes", NULL, 0, this_ptr); - zephir_check_call_status(); - if (ZEPHIR_GLOBAL(orm).column_renaming) { - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", NULL, 0, this_ptr); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&columnMap); - ZVAL_NULL(&columnMap); - } - if (UNEXPECTED(!(zephir_fast_count_int(&primaryKeys)))) { - ZEPHIR_INIT_VAR(&_3$$7); - object_init_ex(&_3$$7, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_4$$7); - zephir_get_class(&_4$$7, this_ptr, 0); - ZEPHIR_INIT_VAR(&_5$$7); - ZEPHIR_CONCAT_SVS(&_5$$7, "A primary key must be defined in the model in order to perform the operation in '", &_4$$7, "'"); - ZEPHIR_CALL_METHOD(NULL, &_3$$7, "__construct", NULL, 33, &_5$$7); - zephir_check_call_status(); - zephir_throw_exception_debug(&_3$$7, "phalcon/Mvc/Model.zep", 1324); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_is_iterable(&primaryKeys, 0, "phalcon/Mvc/Model.zep", 1373); - if (Z_TYPE_P(&primaryKeys) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&primaryKeys), _6) - { - ZEPHIR_INIT_NVAR(&primaryKey); - ZVAL_COPY(&primaryKey, _6); - ZEPHIR_OBS_NVAR(&bindType); - if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, &bindDataTypes, &primaryKey, 0)))) { - ZEPHIR_INIT_NVAR(&_8$$9); - object_init_ex(&_8$$9, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_9$$9); - zephir_get_class(&_9$$9, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_10$$9); - ZEPHIR_CONCAT_SVSVS(&_10$$9, "Column '", &primaryKey, "' have not defined a bind data type in '", &_9$$9, "'"); - ZEPHIR_CALL_METHOD(NULL, &_8$$9, "__construct", NULL, 33, &_10$$9); - zephir_check_call_status(); - zephir_throw_exception_debug(&_8$$9, "phalcon/Mvc/Model.zep", 1338); - ZEPHIR_MM_RESTORE(); - return; - } - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &primaryKey, 0)))) { - ZEPHIR_INIT_NVAR(&_11$$11); - object_init_ex(&_11$$11, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_12$$11); - zephir_get_class(&_12$$11, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_13$$11); - ZEPHIR_CONCAT_SVSVS(&_13$$11, "Column '", &primaryKey, "' isn't part of the column map in '", &_12$$11, "'"); - ZEPHIR_CALL_METHOD(NULL, &_11$$11, "__construct", NULL, 33, &_13$$11); - zephir_check_call_status(); - zephir_throw_exception_debug(&_11$$11, "phalcon/Mvc/Model.zep", 1348); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&attributeField, &primaryKey); - } - ZEPHIR_OBS_NVAR(&value); - if (UNEXPECTED(!(zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)))) { - ZEPHIR_INIT_NVAR(&_14$$13); - object_init_ex(&_14$$13, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_15$$13); - zephir_get_class(&_15$$13, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_16$$13); - ZEPHIR_CONCAT_SVSVS(&_16$$13, "Cannot delete the record because the primary key attribute: '", &attributeField, "' was not set in '", &_15$$13, "'"); - ZEPHIR_CALL_METHOD(NULL, &_14$$13, "__construct", NULL, 33, &_16$$13); - zephir_check_call_status(); - zephir_throw_exception_debug(&_14$$13, "phalcon/Mvc/Model.zep", 1362); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1368); - ZEPHIR_CALL_METHOD(&_17$$8, &writeConnection, "escapeidentifier", &_18, 0, &primaryKey); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_19$$8); - ZEPHIR_CONCAT_VS(&_19$$8, &_17$$8, " = ?"); - zephir_array_append(&conditions, &_19$$8, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1369); - zephir_array_append(&bindTypes, &bindType, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1370); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &primaryKeys, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_7, &primaryKeys, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_7)) { - break; - } - ZEPHIR_CALL_METHOD(&primaryKey, &primaryKeys, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&bindType); - if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, &bindDataTypes, &primaryKey, 0)))) { - ZEPHIR_INIT_NVAR(&_20$$15); - object_init_ex(&_20$$15, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_21$$15); - zephir_get_class(&_21$$15, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_22$$15); - ZEPHIR_CONCAT_SVSVS(&_22$$15, "Column '", &primaryKey, "' have not defined a bind data type in '", &_21$$15, "'"); - ZEPHIR_CALL_METHOD(NULL, &_20$$15, "__construct", NULL, 33, &_22$$15); - zephir_check_call_status(); - zephir_throw_exception_debug(&_20$$15, "phalcon/Mvc/Model.zep", 1338); - ZEPHIR_MM_RESTORE(); - return; - } - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &primaryKey, 0)))) { - ZEPHIR_INIT_NVAR(&_23$$17); - object_init_ex(&_23$$17, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_24$$17); - zephir_get_class(&_24$$17, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_25$$17); - ZEPHIR_CONCAT_SVSVS(&_25$$17, "Column '", &primaryKey, "' isn't part of the column map in '", &_24$$17, "'"); - ZEPHIR_CALL_METHOD(NULL, &_23$$17, "__construct", NULL, 33, &_25$$17); - zephir_check_call_status(); - zephir_throw_exception_debug(&_23$$17, "phalcon/Mvc/Model.zep", 1348); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&attributeField, &primaryKey); - } - ZEPHIR_OBS_NVAR(&value); - if (UNEXPECTED(!(zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)))) { - ZEPHIR_INIT_NVAR(&_26$$19); - object_init_ex(&_26$$19, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_27$$19); - zephir_get_class(&_27$$19, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_28$$19); - ZEPHIR_CONCAT_SVSVS(&_28$$19, "Cannot delete the record because the primary key attribute: '", &attributeField, "' was not set in '", &_27$$19, "'"); - ZEPHIR_CALL_METHOD(NULL, &_26$$19, "__construct", NULL, 33, &_28$$19); - zephir_check_call_status(); - zephir_throw_exception_debug(&_26$$19, "phalcon/Mvc/Model.zep", 1362); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1368); - ZEPHIR_CALL_METHOD(&_29$$14, &writeConnection, "escapeidentifier", &_30, 0, &primaryKey); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_31$$14); - ZEPHIR_CONCAT_VS(&_31$$14, &_29$$14, " = ?"); - zephir_array_append(&conditions, &_31$$14, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1369); - zephir_array_append(&bindTypes, &bindType, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1370); - ZEPHIR_CALL_METHOD(NULL, &primaryKeys, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&primaryKey); - if (ZEPHIR_GLOBAL(orm).events) { - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("skipped"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("skipped"), &__$false); - } - ZEPHIR_INIT_VAR(&_33$$20); - ZVAL_STRING(&_33$$20, "beforeDelete"); - ZEPHIR_CALL_METHOD(&_32$$20, this_ptr, "fireeventcancel", NULL, 0, &_33$$20); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_32$$20)) { - RETURN_MM_BOOL(0); - } - zephir_read_property(&_34$$20, this_ptr, ZEND_STRL("skipped"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_34$$20)) { - RETURN_MM_BOOL(1); - } - } - ZEPHIR_CALL_METHOD(&schema, this_ptr, "getschema", NULL, 423); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 424); - zephir_check_call_status(); - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_VAR(&table); - zephir_create_array(&table, 2, 0); - zephir_array_fast_append(&table, &schema); - zephir_array_fast_append(&table, &source); + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); } else { - ZEPHIR_CPY_WRT(&table, &source); - } - ZEPHIR_INIT_VAR(&_35); - zephir_fast_join_str(&_35, SL(" AND "), &conditions); - ZEPHIR_CALL_METHOD(&success, &writeConnection, "delete", NULL, 0, &table, &_35, &values, &bindTypes); - zephir_check_call_status(); - if (ZEPHIR_GLOBAL(orm).virtual_foreign_keys) { - ZEPHIR_CALL_METHOD(&_36$$25, this_ptr, "checkforeignkeysreversecascade", NULL, 425); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_36$$25)) { - RETURN_MM_BOOL(0); - } - } - if (ZEPHIR_GLOBAL(orm).events) { - if (zephir_is_true(&success)) { - ZEPHIR_INIT_VAR(&_37$$28); - ZVAL_STRING(&_37$$28, "afterDelete"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_37$$28); - zephir_check_call_status(); - } - } - if (zephir_is_true(&success)) { - ZEPHIR_INIT_VAR(&_38$$29); - array_init(&_38$$29); - zephir_update_property_zval(this_ptr, ZEND_STRL("related"), &_38$$29); - zephir_read_property(&_39$$29, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_39$$29, "clearreusableobjects", NULL, 0); - zephir_check_call_status(); + ZEPHIR_INIT_VAR(&modelName); } - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, 2); - zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &_0); - RETURN_CCTOR(&success); + zephir_update_property_zval(this_ptr, ZEND_STRL("model"), &modelName); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model, dump) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, sharedLock) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *sharedLock_param = NULL, _0, _1; + zend_bool sharedLock; zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_RETURN_CALL_FUNCTION("get_object_vars", NULL, 426, this_ptr); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model, find) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zephir_fcall_cache_entry *_0 = NULL; - zval *parameters = NULL, parameters_sub, __$null, params, query, resultset, hydration; - ZVAL_UNDEF(¶meters_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&query); - ZVAL_UNDEF(&resultset); - ZVAL_UNDEF(&hydration); - bool is_null_true = 1; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(parameters) + Z_PARAM_BOOL(sharedLock) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, ¶meters); - if (!parameters) { - parameters = ¶meters_sub; - parameters = &__$null; - } - if (Z_TYPE_P(parameters) != IS_ARRAY) { - ZEPHIR_INIT_VAR(¶ms); - array_init(¶ms); - if (Z_TYPE_P(parameters) != IS_NULL) { - zephir_array_append(¶ms, parameters, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1644); - } + zephir_fetch_params(1, 0, 1, &sharedLock_param); + if (!sharedLock_param) { + sharedLock = 1; } else { - ZEPHIR_CPY_WRT(¶ms, parameters); - } - ZEPHIR_CALL_STATIC(&query, "getpreparedquery", &_0, 427, ¶ms); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&resultset, &query, "execute", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&resultset) == IS_OBJECT) { - zephir_memory_observe(&hydration); - if (zephir_array_isset_string_fetch(&hydration, ¶ms, SL("hydration"), 0)) { - ZEPHIR_CALL_METHOD(NULL, &resultset, "sethydratemode", NULL, 0, &hydration); - zephir_check_call_status(); } - } - RETURN_CCTOR(&resultset); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "shared_lock"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_BOOL(&_1, sharedLock); + zephir_update_property_array(this_ptr, SL("params"), &_0, &_1); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model, findFirst) +static PHP_METHOD(Phalcon_Mvc_Model_Criteria, where) { - zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *parameters = NULL, parameters_sub, __$null, params, query, _6, _1$$5, _2$$6, _3$$6, _4$$6; + zval *conditions_param = NULL, *bindParams = NULL, bindParams_sub, *bindTypes = NULL, bindTypes_sub, __$null, currentBindParams, currentBindTypes, _0, _1$$3, _2$$4, _3$$4, _4$$5, _5$$6, _6$$7, _7$$7, _8$$8; + zval conditions; + zval *this_ptr = getThis(); - ZVAL_UNDEF(¶meters_sub); + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(&bindParams_sub); + ZVAL_UNDEF(&bindTypes_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&query); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_1$$5); - ZVAL_UNDEF(&_2$$6); - ZVAL_UNDEF(&_3$$6); - ZVAL_UNDEF(&_4$$6); + ZVAL_UNDEF(¤tBindParams); + ZVAL_UNDEF(¤tBindTypes); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_7$$7); + ZVAL_UNDEF(&_8$$8); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(conditions) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(parameters) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, ¶meters); - if (!parameters) { - parameters = ¶meters_sub; - parameters = &__$null; - } - _0 = Z_TYPE_P(parameters) == IS_STRING; - if (!(_0)) { - _0 = zephir_is_numeric(parameters); - } - if (Z_TYPE_P(parameters) == IS_NULL) { - ZEPHIR_INIT_VAR(¶ms); - array_init(¶ms); - } else if (Z_TYPE_P(parameters) == IS_ARRAY) { - ZEPHIR_CPY_WRT(¶ms, parameters); - } else if (_0) { - ZEPHIR_INIT_VAR(&_1$$5); - zephir_create_array(&_1$$5, 1, 0); - zephir_array_fast_append(&_1$$5, parameters); - ZEPHIR_CPY_WRT(¶ms, &_1$$5); - } else { - ZEPHIR_INIT_VAR(&_2$$6); - object_init_ex(&_2$$6, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_3$$6); - zephir_get_called_class(&_3$$6); - ZEPHIR_INIT_VAR(&_4$$6); - ZEPHIR_CONCAT_SVS(&_4$$6, "Parameters passed must be of type array, string, numeric or null in '", &_3$$6, "'"); - ZEPHIR_CALL_METHOD(NULL, &_2$$6, "__construct", NULL, 33, &_4$$6); - zephir_check_call_status(); - zephir_throw_exception_debug(&_2$$6, "phalcon/Mvc/Model.zep", 1768); - ZEPHIR_MM_RESTORE(); - return; - } - ZVAL_LONG(&_6, 1); - ZEPHIR_CALL_STATIC(&query, "getpreparedquery", &_5, 427, ¶ms, &_6); - zephir_check_call_status(); - ZVAL_BOOL(&_6, 1); - ZEPHIR_CALL_METHOD(NULL, &query, "setuniquerow", NULL, 0, &_6); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&query, "execute", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model, fireEvent) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *eventName_param = NULL, _0; - zval eventName; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(eventName) + Z_PARAM_ZVAL_OR_NULL(bindParams) + Z_PARAM_ZVAL_OR_NULL(bindTypes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &eventName_param); - if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string")); + zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams, &bindTypes); + if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { - zephir_get_strval(&eventName, eventName_param); + if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { + zephir_get_strval(&conditions, conditions_param); } else { - ZEPHIR_INIT_VAR(&eventName); + ZEPHIR_INIT_VAR(&conditions); } - if ((zephir_method_exists(this_ptr, &eventName) == SUCCESS)) { - ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &eventName, NULL, 0); - zephir_check_call_status(); + if (!bindParams) { + bindParams = &bindParams_sub; + bindParams = &__$null; } - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "notifyevent", NULL, 0, &eventName, this_ptr); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model, fireEventCancel) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *eventName_param = NULL, _0$$3, _1; - zval eventName; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(eventName) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &eventName_param); - if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string")); - RETURN_MM_NULL(); + if (!bindTypes) { + bindTypes = &bindTypes_sub; + bindTypes = &__$null; } - if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { - zephir_get_strval(&eventName, eventName_param); - } else { - ZEPHIR_INIT_VAR(&eventName); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "conditions"); + zephir_update_property_array(this_ptr, SL("params"), &_0, &conditions); + if (Z_TYPE_P(bindParams) == IS_ARRAY) { + zephir_memory_observe(¤tBindParams); + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_string_fetch(¤tBindParams, &_1$$3, SL("bind"), 0)) { + ZEPHIR_INIT_VAR(&_2$$4); + zephir_fast_array_merge(&_2$$4, ¤tBindParams, bindParams); + ZEPHIR_INIT_VAR(&_3$$4); + ZVAL_STRING(&_3$$4, "bind"); + zephir_update_property_array(this_ptr, SL("params"), &_3$$4, &_2$$4); + } else { + ZEPHIR_INIT_VAR(&_4$$5); + ZVAL_STRING(&_4$$5, "bind"); + zephir_update_property_array(this_ptr, SL("params"), &_4$$5, bindParams); + } } - if ((zephir_method_exists(this_ptr, &eventName) == SUCCESS)) { - ZEPHIR_CALL_METHOD_ZVAL(&_0$$3, this_ptr, &eventName, NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_0$$3)) { - RETURN_MM_BOOL(0); + if (Z_TYPE_P(bindTypes) == IS_ARRAY) { + zephir_memory_observe(¤tBindTypes); + zephir_read_property(&_5$$6, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_string_fetch(¤tBindTypes, &_5$$6, SL("bindTypes"), 0)) { + ZEPHIR_INIT_VAR(&_6$$7); + zephir_fast_array_merge(&_6$$7, ¤tBindTypes, bindTypes); + ZEPHIR_INIT_VAR(&_7$$7); + ZVAL_STRING(&_7$$7, "bindTypes"); + zephir_update_property_array(this_ptr, SL("params"), &_7$$7, &_6$$7); + } else { + ZEPHIR_INIT_VAR(&_8$$8); + ZVAL_STRING(&_8$$8, "bindTypes"); + zephir_update_property_array(this_ptr, SL("params"), &_8$$8, bindTypes); } } - zephir_read_property(&_1, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_1, "notifyevent", NULL, 0, &eventName, this_ptr); - zephir_check_call_status(); - RETURN_MM(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model, getChangedFields) +zend_object *zephir_init_properties_Phalcon_Mvc_Model_Criteria(zend_class_entry *class_type) { - zend_string *_8; - zend_ulong _7; - zval changed; - zval metaData, name, snapshot, columnMap, allAttributes, value, _0, _4, *_5, _6, _1$$3, _2$$3, _3$$3, _9$$6, _10$$10; + zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&snapshot); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&allAttributes); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_9$$6); - ZVAL_UNDEF(&_10$$10); - ZVAL_UNDEF(&changed); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + - zephir_read_property(&_0, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&snapshot, &_0); - if (UNEXPECTED(Z_TYPE_P(&snapshot) != IS_ARRAY)) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - zephir_get_class(&_2$$3, this_ptr, 0); - ZEPHIR_INIT_VAR(&_3$$3); - ZEPHIR_CONCAT_SVS(&_3$$3, "The 'keepSnapshots' option must be enabled to track changes in '", &_2$$3, "'"); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_3$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model.zep", 1854); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getreversecolumnmap", NULL, 0, this_ptr); - zephir_check_call_status(); - if (Z_TYPE_P(&columnMap) != IS_ARRAY) { - ZEPHIR_CALL_METHOD(&allAttributes, &metaData, "getdatatypes", NULL, 0, this_ptr); - zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&allAttributes, &columnMap); - } - ZEPHIR_INIT_VAR(&changed); - array_init(&changed); - ZEPHIR_INIT_VAR(&_4); - zephir_is_iterable(&allAttributes, 0, "phalcon/Mvc/Model.zep", 1912); - if (Z_TYPE_P(&allAttributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&allAttributes), _7, _8, _5) - { - ZEPHIR_INIT_NVAR(&name); - if (_8 != NULL) { - ZVAL_STR_COPY(&name, _8); - } else { - ZVAL_LONG(&name, _7); - } - ZEPHIR_INIT_NVAR(&_4); - ZVAL_COPY(&_4, _5); - if (!(zephir_array_isset(&snapshot, &name))) { - zephir_array_append(&changed, &name, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1887); - continue; - } - ZEPHIR_OBS_NVAR(&value); - if (!(zephir_fetch_property_zval(&value, this_ptr, &name, PH_SILENT_CC))) { - zephir_array_append(&changed, &name, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1897); - continue; - } - zephir_array_fetch(&_9$$6, &snapshot, &name, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 1905); - if (!ZEPHIR_IS_IDENTICAL(&value, &_9$$6)) { - zephir_array_append(&changed, &name, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1906); - continue; - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &allAttributes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_6, &allAttributes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_6)) { - break; - } - ZEPHIR_CALL_METHOD(&name, &allAttributes, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4, &allAttributes, "current", NULL, 0); - zephir_check_call_status(); - if (!(zephir_array_isset(&snapshot, &name))) { - zephir_array_append(&changed, &name, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1887); - continue; - } - ZEPHIR_OBS_NVAR(&value); - if (!(zephir_fetch_property_zval(&value, this_ptr, &name, PH_SILENT_CC))) { - zephir_array_append(&changed, &name, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1897); - continue; - } - zephir_array_fetch(&_10$$10, &snapshot, &name, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 1905); - if (!ZEPHIR_IS_IDENTICAL(&value, &_10$$10)) { - zephir_array_append(&changed, &name, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1906); - continue; - } - ZEPHIR_CALL_METHOD(NULL, &allAttributes, "next", NULL, 0); - zephir_check_call_status(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_1$$3); } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } - ZEPHIR_INIT_NVAR(&_4); - ZEPHIR_INIT_NVAR(&name); - RETURN_CTOR(&changed); } -static PHP_METHOD(Phalcon_Mvc_Model, getDirtyState) -{ - RETURN_MEMBER(getThis(), "dirtyState"); -} -static PHP_METHOD(Phalcon_Mvc_Model, getEventsManager) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); +#ifdef HAVE_CONFIG_H +#endif - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "getcustomeventsmanager", NULL, 0, this_ptr); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Mvc_Model, getMessages) + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_CriteriaInterface) { - zend_bool _0, _1; - zval filtered; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *filter = NULL, filter_sub, __$null, message, _2$$4, _3$$3, *_4$$3, _5$$3, _6$$5, _7$$7; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, CriteriaInterface, phalcon, mvc_model_criteriainterface, phalcon_mvc_model_criteriainterface_method_entry); - ZVAL_UNDEF(&filter_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_7$$7); - ZVAL_UNDEF(&filtered); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(filter) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &filter); - if (!filter) { - filter = &filter_sub; - ZEPHIR_CPY_WRT(filter, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(filter); - } - _0 = Z_TYPE_P(filter) == IS_STRING; - if (!(_0)) { - _0 = Z_TYPE_P(filter) == IS_ARRAY; - } - _1 = _0; - if (_1) { - _1 = !(ZEPHIR_IS_EMPTY(filter)); - } - if (_1) { - ZEPHIR_INIT_VAR(&filtered); - array_init(&filtered); - if (Z_TYPE_P(filter) == IS_STRING) { - ZEPHIR_INIT_VAR(&_2$$4); - zephir_create_array(&_2$$4, 1, 0); - zephir_array_fast_append(&_2$$4, filter); - ZEPHIR_CPY_WRT(filter, &_2$$4); - } - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("errorMessages"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_3$$3, 0, "phalcon/Mvc/Model.zep", 1976); - if (Z_TYPE_P(&_3$$3) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_3$$3), _4$$3) - { - ZEPHIR_INIT_NVAR(&message); - ZVAL_COPY(&message, _4$$3); - ZEPHIR_CALL_METHOD(&_6$$5, &message, "getfield", NULL, 0); - zephir_check_call_status(); - if (zephir_fast_in_array(&_6$$5, filter)) { - zephir_array_append(&filtered, &message, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1972); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_3$$3, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5$$3, &_3$$3, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&message, &_3$$3, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_7$$7, &message, "getfield", NULL, 0); - zephir_check_call_status(); - if (zephir_fast_in_array(&_7$$7, filter)) { - zephir_array_append(&filtered, &message, PH_SEPARATE, "phalcon/Mvc/Model.zep", 1972); - } - ZEPHIR_CALL_METHOD(NULL, &_3$$3, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&message); - RETURN_CTOR(&filtered); - } - RETURN_MM_MEMBER(getThis(), "errorMessages"); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model, getModelsManager) +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, andWhere); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, betweenWhere); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, bind); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, bindTypes); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, cache); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, conditions); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, distinct); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, execute); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, forUpdate); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getColumns); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getConditions); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getGroupBy); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getHaving); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getLimit); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getModelName); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getOrderBy); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getParams); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getWhere); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, groupBy); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, having); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, innerJoin); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, inWhere); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, leftJoin); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, limit); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, notBetweenWhere); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, notInWhere); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, orderBy); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, orWhere); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, rightJoin); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, setModelName); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, sharedLock); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, where); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Exception) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model, Exception, phalcon, mvc_model_exception, zend_ce_exception, NULL, 0); - RETURN_MEMBER(getThis(), "modelsManager"); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model, getModelsMetaData) -{ - zval metaData, container, _0$$3, _1$$3, _2$$3, _3$$4, _4$$4, _5$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$4); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_memory_observe(&metaData); - zephir_read_property(&metaData, this_ptr, ZEND_STRL("modelsMetaData"), PH_NOISY_CC); - if (Z_TYPE_P(&metaData) == IS_NULL) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0$$3); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "modelsMetadata"); - ZEPHIR_CALL_METHOD(&_1$$3, &container, "getshared", NULL, 0, &_2$$3); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&metaData, &_1$$3); - if (UNEXPECTED(Z_TYPE_P(&metaData) != IS_OBJECT)) { - ZEPHIR_INIT_VAR(&_3$$4); - object_init_ex(&_3$$4, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_4$$4); - zephir_get_class(&_4$$4, this_ptr, 0); - ZEPHIR_INIT_VAR(&_5$$4); - ZEPHIR_CONCAT_SVS(&_5$$4, "The injected service 'modelsMetadata' is not valid in '", &_4$$4, "'"); - ZEPHIR_CALL_METHOD(NULL, &_3$$4, "__construct", NULL, 33, &_5$$4); - zephir_check_call_status(); - zephir_throw_exception_debug(&_3$$4, "phalcon/Mvc/Model.zep", 2010); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_update_property_zval(this_ptr, ZEND_STRL("modelsMetaData"), &metaData); - } - RETURN_CCTOR(&metaData); -} -static PHP_METHOD(Phalcon_Mvc_Model, getOperationMade) +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Manager) { + ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Manager, phalcon, mvc_model_manager, phalcon_mvc_model_manager_method_entry, 0); - RETURN_MEMBER(getThis(), "operationMade"); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("aliases"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("behaviors"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("belongsTo"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("belongsToSingle"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("builder"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("container"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("customEventsManager"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("dynamicUpdate"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasMany"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasManySingle"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasManyToMany"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasManyToManySingle"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasOne"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasOneSingle"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasOneThrough"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasOneThroughSingle"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("initialized"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("keepSnapshots"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("lastInitialized"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("lastQuery"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("modelVisibility"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_mvc_model_manager_ce, SL("prefix"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("readConnectionServices"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("sources"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("schemas"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("writeConnectionServices"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("reusable"), ZEND_ACC_PROTECTED); + phalcon_mvc_model_manager_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Manager; + + zend_class_implements(phalcon_mvc_model_manager_ce, 1, phalcon_mvc_model_managerinterface_ce); + zend_class_implements(phalcon_mvc_model_manager_ce, 1, phalcon_di_injectionawareinterface_ce); + zend_class_implements(phalcon_mvc_model_manager_ce, 1, phalcon_events_eventsawareinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model, getOldSnapshotData) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, __destruct) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - RETURN_MEMBER(getThis(), "oldSnapshot"); + phalcon_orm_destroy_cache(); + ZEPHIR_CALL_CE_STATIC(NULL, phalcon_mvc_model_query_ce, "clean", NULL, 0); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model, getReadConnection) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, addBehavior) { - zval _0, _2, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, *behavior, behavior_sub, entityName, _0, _1$$3; zval *this_ptr = getThis(); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&behavior_sub); + ZVAL_UNDEF(&entityName); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_OBJECT_OF_CLASS(behavior, phalcon_mvc_model_behaviorinterface_ce) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("transaction"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) != IS_NULL) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("transaction"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_1$$3, "getconnection", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 2, 0, &model, &behavior); + ZEPHIR_INIT_VAR(&entityName); + zephir_get_class(&entityName, model, 1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("behaviors"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset(&_0, &entityName))) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_array(this_ptr, SL("behaviors"), &entityName, &_1$$3); } - zephir_read_property(&_2, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_2, "getreadconnection", NULL, 0, this_ptr); - zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_array_multi(this_ptr, SL("behaviors"), behavior, SL("za"), 2, &entityName); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model, getReadConnectionService) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, addBelongsTo) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval options; + zval referencedModel, keyRelation; + zval *model, model_sub, *fields, fields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, entityName, referencedEntity, relation, relations, alias, lowerAlias, singleRelations, _0, _1, _2, _3; zval *this_ptr = getThis(); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&fields_sub); + ZVAL_UNDEF(&referencedFields_sub); + ZVAL_UNDEF(&entityName); + ZVAL_UNDEF(&referencedEntity); + ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&relations); + ZVAL_UNDEF(&alias); + ZVAL_UNDEF(&lowerAlias); + ZVAL_UNDEF(&singleRelations); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&referencedModel); + ZVAL_UNDEF(&keyRelation); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(4, 5) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ZVAL(fields) + Z_PARAM_STR(referencedModel) + Z_PARAM_ZVAL(referencedFields) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "getreadconnectionservice", NULL, 0, this_ptr); + zephir_fetch_params(1, 4, 1, &model, &fields, &referencedModel_param, &referencedFields, &options_param); + if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) { + zephir_get_strval(&referencedModel, referencedModel_param); + } else { + ZEPHIR_INIT_VAR(&referencedModel); + } + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + ZEPHIR_INIT_VAR(&entityName); + zephir_get_class(&entityName, model, 1); + ZEPHIR_INIT_VAR(&referencedEntity); + zephir_fast_strtolower(&referencedEntity, &referencedModel); + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity); + zephir_get_strval(&keyRelation, &_0); + zephir_memory_observe(&relations); + zephir_read_property(&_1, this_ptr, ZEND_STRL("belongsTo"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&relations, &_1, &keyRelation, 0))) { + ZEPHIR_INIT_NVAR(&relations); + array_init(&relations); + } + if (Z_TYPE_P(referencedFields) == IS_ARRAY) { + if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(referencedFields))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 296); + return; + } + } + ZEPHIR_INIT_VAR(&relation); + object_init_ex(&relation, phalcon_mvc_model_relation_ce); + ZVAL_LONG(&_2, 0); + ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 441, &_2, &referencedModel, fields, referencedFields, &options); zephir_check_call_status(); - RETURN_MM(); + zephir_memory_observe(&alias); + if (zephir_array_isset_string_fetch(&alias, &options, SL("alias"), 0)) { + if (UNEXPECTED(Z_TYPE_P(&alias) != IS_STRING)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 316); + return; + } + ZEPHIR_INIT_VAR(&lowerAlias); + zephir_fast_strtolower(&lowerAlias, &alias); + } else { + ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity); + } + zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 329); + ZEPHIR_INIT_VAR(&_3); + ZEPHIR_CONCAT_VSV(&_3, &entityName, "$", &lowerAlias); + zephir_update_property_array(this_ptr, SL("aliases"), &_3, &relation); + zephir_update_property_array(this_ptr, SL("belongsTo"), &keyRelation, &relations); + zephir_memory_observe(&singleRelations); + zephir_read_property(&_2, this_ptr, ZEND_STRL("belongsToSingle"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&singleRelations, &_2, &entityName, 0))) { + ZEPHIR_INIT_NVAR(&singleRelations); + array_init(&singleRelations); + } + zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 343); + zephir_update_property_array(this_ptr, SL("belongsToSingle"), &entityName, &singleRelations); + RETURN_CCTOR(&relation); } -static PHP_METHOD(Phalcon_Mvc_Model, getRelated) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasMany) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *alias_param = NULL, *arguments = NULL, arguments_sub, __$null, relation, className, manager, result, lowerAlias, _0, _1, _2$$3, _3$$3; - zval alias; + zval options; + zval referencedModel, keyRelation; + zval *model, model_sub, *fields, fields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, entityName, referencedEntity, hasMany, relation, relations, alias, lowerAlias, singleRelations, _0, _1, _2; zval *this_ptr = getThis(); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&arguments_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&fields_sub); + ZVAL_UNDEF(&referencedFields_sub); + ZVAL_UNDEF(&entityName); + ZVAL_UNDEF(&referencedEntity); + ZVAL_UNDEF(&hasMany); ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&result); + ZVAL_UNDEF(&relations); + ZVAL_UNDEF(&alias); ZVAL_UNDEF(&lowerAlias); + ZVAL_UNDEF(&singleRelations); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(alias) + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&referencedModel); + ZVAL_UNDEF(&keyRelation); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(4, 5) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ZVAL(fields) + Z_PARAM_STR(referencedModel) + Z_PARAM_ZVAL(referencedFields) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(arguments) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &alias_param, &arguments); - zephir_get_strval(&alias, alias_param); - if (!arguments) { - arguments = &arguments_sub; - arguments = &__$null; + zephir_fetch_params(1, 4, 1, &model, &fields, &referencedModel_param, &referencedFields, &options_param); + if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_INIT_VAR(&className); - zephir_get_class(&className, this_ptr, 0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - ZEPHIR_INIT_VAR(&lowerAlias); - zephir_fast_strtolower(&lowerAlias, &alias); - ZEPHIR_CALL_METHOD(&_1, &manager, "getrelationbyalias", NULL, 0, &className, &lowerAlias); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&relation, &_1); - if (UNEXPECTED(Z_TYPE_P(&relation) != IS_OBJECT)) { - ZEPHIR_INIT_VAR(&_2$$3); - object_init_ex(&_2$$3, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_3$$3); - ZEPHIR_CONCAT_SVSVS(&_3$$3, "There is no defined relations for the model '", &className, "' using alias '", &alias, "'"); - ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 33, &_3$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_2$$3, "phalcon/Mvc/Model.zep", 2086); - ZEPHIR_MM_RESTORE(); - return; + if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) { + zephir_get_strval(&referencedModel, referencedModel_param); + } else { + ZEPHIR_INIT_VAR(&referencedModel); } - if (Z_TYPE_P(arguments) == IS_NULL) { - ZEPHIR_CALL_METHOD(&result, &manager, "getrelationrecords", NULL, 0, &relation, this_ptr, arguments); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("related"), &lowerAlias, &result); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - ZEPHIR_CALL_METHOD(&result, &manager, "getrelationrecords", NULL, 0, &relation, this_ptr, arguments); - zephir_check_call_status(); + zephir_get_arrval(&options, options_param); } - RETURN_CCTOR(&result); + ZEPHIR_INIT_VAR(&entityName); + zephir_get_class(&entityName, model, 1); + ZEPHIR_INIT_VAR(&referencedEntity); + zephir_fast_strtolower(&referencedEntity, &referencedModel); + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity); + zephir_get_strval(&keyRelation, &_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&hasMany, &_1); + zephir_memory_observe(&relations); + if (!(zephir_array_isset_fetch(&relations, &hasMany, &keyRelation, 0))) { + ZEPHIR_INIT_NVAR(&relations); + array_init(&relations); + } + if (Z_TYPE_P(referencedFields) == IS_ARRAY) { + if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(referencedFields))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 392); + return; + } + } + ZEPHIR_INIT_VAR(&relation); + object_init_ex(&relation, phalcon_mvc_model_relation_ce); + ZVAL_LONG(&_1, 2); + ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 441, &_1, &referencedModel, fields, referencedFields, &options); + zephir_check_call_status(); + zephir_memory_observe(&alias); + if (zephir_array_isset_string_fetch(&alias, &options, SL("alias"), 0)) { + if (UNEXPECTED(Z_TYPE_P(&alias) != IS_STRING)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 412); + return; + } + ZEPHIR_INIT_VAR(&lowerAlias); + zephir_fast_strtolower(&lowerAlias, &alias); + } else { + ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity); + } + zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 425); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_CONCAT_VSV(&_2, &entityName, "$", &lowerAlias); + zephir_update_property_array(this_ptr, SL("aliases"), &_2, &relation); + zephir_update_property_array(this_ptr, SL("hasMany"), &keyRelation, &relations); + zephir_memory_observe(&singleRelations); + zephir_read_property(&_1, this_ptr, ZEND_STRL("hasManySingle"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&singleRelations, &_1, &entityName, 0))) { + ZEPHIR_INIT_NVAR(&singleRelations); + array_init(&singleRelations); + } + zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 439); + zephir_update_property_array(this_ptr, SL("hasManySingle"), &entityName, &singleRelations); + RETURN_CCTOR(&relation); } -static PHP_METHOD(Phalcon_Mvc_Model, isRelationshipLoaded) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasManyToMany) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *relationshipAlias_param = NULL, _0, _1; - zval relationshipAlias; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval options; + zval intermediateModel, referencedModel, keyRelation; + zval *model, model_sub, *fields, fields_sub, *intermediateModel_param = NULL, *intermediateFields, intermediateFields_sub, *intermediateReferencedFields, intermediateReferencedFields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, entityName, referencedEntity, hasManyToMany, relation, relations, alias, lowerAlias, singleRelations, intermediateEntity, _0, _1, _2; zval *this_ptr = getThis(); - ZVAL_UNDEF(&relationshipAlias); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&fields_sub); + ZVAL_UNDEF(&intermediateFields_sub); + ZVAL_UNDEF(&intermediateReferencedFields_sub); + ZVAL_UNDEF(&referencedFields_sub); + ZVAL_UNDEF(&entityName); + ZVAL_UNDEF(&referencedEntity); + ZVAL_UNDEF(&hasManyToMany); + ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&relations); + ZVAL_UNDEF(&alias); + ZVAL_UNDEF(&lowerAlias); + ZVAL_UNDEF(&singleRelations); + ZVAL_UNDEF(&intermediateEntity); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(relationshipAlias) + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&intermediateModel); + ZVAL_UNDEF(&referencedModel); + ZVAL_UNDEF(&keyRelation); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(7, 8) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ZVAL(fields) + Z_PARAM_STR(intermediateModel) + Z_PARAM_ZVAL(intermediateFields) + Z_PARAM_ZVAL(intermediateReferencedFields) + Z_PARAM_STR(referencedModel) + Z_PARAM_ZVAL(referencedFields) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &relationshipAlias_param); - zephir_get_strval(&relationshipAlias, relationshipAlias_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("related"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_fast_strtolower(&_1, &relationshipAlias); - RETURN_MM_BOOL(zephir_array_isset(&_0, &_1)); + zephir_fetch_params(1, 7, 1, &model, &fields, &intermediateModel_param, &intermediateFields, &intermediateReferencedFields, &referencedModel_param, &referencedFields, &options_param); + if (UNEXPECTED(Z_TYPE_P(intermediateModel_param) != IS_STRING && Z_TYPE_P(intermediateModel_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'intermediateModel' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(intermediateModel_param) == IS_STRING)) { + zephir_get_strval(&intermediateModel, intermediateModel_param); + } else { + ZEPHIR_INIT_VAR(&intermediateModel); + } + if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) { + zephir_get_strval(&referencedModel, referencedModel_param); + } else { + ZEPHIR_INIT_VAR(&referencedModel); + } + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + ZEPHIR_INIT_VAR(&entityName); + zephir_get_class(&entityName, model, 1); + ZEPHIR_INIT_VAR(&intermediateEntity); + zephir_fast_strtolower(&intermediateEntity, &intermediateModel); + ZEPHIR_INIT_VAR(&referencedEntity); + zephir_fast_strtolower(&referencedEntity, &referencedModel); + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity); + zephir_get_strval(&keyRelation, &_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("hasManyToMany"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&hasManyToMany, &_1); + zephir_memory_observe(&relations); + if (!(zephir_array_isset_fetch(&relations, &hasManyToMany, &keyRelation, 0))) { + ZEPHIR_INIT_NVAR(&relations); + array_init(&relations); + } + if (Z_TYPE_P(intermediateFields) == IS_ARRAY) { + if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(intermediateFields))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 496); + return; + } + } + if (Z_TYPE_P(intermediateReferencedFields) == IS_ARRAY) { + if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(intermediateFields))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 508); + return; + } + } + ZEPHIR_INIT_VAR(&relation); + object_init_ex(&relation, phalcon_mvc_model_relation_ce); + ZVAL_LONG(&_1, 4); + ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 441, &_1, &referencedModel, fields, referencedFields, &options); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &relation, "setintermediaterelation", NULL, 442, intermediateFields, &intermediateModel, intermediateReferencedFields); + zephir_check_call_status(); + zephir_memory_observe(&alias); + if (zephir_array_isset_string_fetch(&alias, &options, SL("alias"), 0)) { + if (Z_TYPE_P(&alias) != IS_STRING) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 537); + return; + } + ZEPHIR_INIT_VAR(&lowerAlias); + zephir_fast_strtolower(&lowerAlias, &alias); + } else { + ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity); + } + zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 548); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_CONCAT_VSV(&_2, &entityName, "$", &lowerAlias); + zephir_update_property_array(this_ptr, SL("aliases"), &_2, &relation); + zephir_update_property_array(this_ptr, SL("hasManyToMany"), &keyRelation, &relations); + zephir_memory_observe(&singleRelations); + zephir_read_property(&_1, this_ptr, ZEND_STRL("hasManyToManySingle"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&singleRelations, &_1, &entityName, 0))) { + ZEPHIR_INIT_NVAR(&singleRelations); + array_init(&singleRelations); + } + zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 570); + zephir_update_property_array(this_ptr, SL("hasManyToManySingle"), &entityName, &singleRelations); + RETURN_CCTOR(&relation); } -static PHP_METHOD(Phalcon_Mvc_Model, getSchema) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasOne) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval options; + zval referencedModel, keyRelation; + zval *model, model_sub, *fields, fields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, entityName, referencedEntity, relation, relations, alias, lowerAlias, singleRelations, _0, _1, _2, _3; zval *this_ptr = getThis(); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&fields_sub); + ZVAL_UNDEF(&referencedFields_sub); + ZVAL_UNDEF(&entityName); + ZVAL_UNDEF(&referencedEntity); + ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&relations); + ZVAL_UNDEF(&alias); + ZVAL_UNDEF(&lowerAlias); + ZVAL_UNDEF(&singleRelations); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&referencedModel); + ZVAL_UNDEF(&keyRelation); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(4, 5) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ZVAL(fields) + Z_PARAM_STR(referencedModel) + Z_PARAM_ZVAL(referencedFields) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "getmodelschema", NULL, 0, this_ptr); + zephir_fetch_params(1, 4, 1, &model, &fields, &referencedModel_param, &referencedFields, &options_param); + if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) { + zephir_get_strval(&referencedModel, referencedModel_param); + } else { + ZEPHIR_INIT_VAR(&referencedModel); + } + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + ZEPHIR_INIT_VAR(&entityName); + zephir_get_class(&entityName, model, 1); + ZEPHIR_INIT_VAR(&referencedEntity); + zephir_fast_strtolower(&referencedEntity, &referencedModel); + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity); + zephir_get_strval(&keyRelation, &_0); + zephir_memory_observe(&relations); + zephir_read_property(&_1, this_ptr, ZEND_STRL("hasOne"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&relations, &_1, &keyRelation, 0))) { + ZEPHIR_INIT_NVAR(&relations); + array_init(&relations); + } + if (Z_TYPE_P(referencedFields) == IS_ARRAY) { + if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(referencedFields))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 618); + return; + } + } + ZEPHIR_INIT_VAR(&relation); + object_init_ex(&relation, phalcon_mvc_model_relation_ce); + ZVAL_LONG(&_2, 1); + ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 441, &_2, &referencedModel, fields, referencedFields, &options); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model, getSnapshotData) -{ - - RETURN_MEMBER(getThis(), "snapshot"); + zephir_memory_observe(&alias); + if (zephir_array_isset_string_fetch(&alias, &options, SL("alias"), 0)) { + if (UNEXPECTED(Z_TYPE_P(&alias) != IS_STRING)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 638); + return; + } + ZEPHIR_INIT_VAR(&lowerAlias); + zephir_fast_strtolower(&lowerAlias, &alias); + } else { + ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity); + } + zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 651); + ZEPHIR_INIT_VAR(&_3); + ZEPHIR_CONCAT_VSV(&_3, &entityName, "$", &lowerAlias); + zephir_update_property_array(this_ptr, SL("aliases"), &_3, &relation); + zephir_update_property_array(this_ptr, SL("hasOne"), &keyRelation, &relations); + zephir_memory_observe(&singleRelations); + zephir_read_property(&_2, this_ptr, ZEND_STRL("hasOneSingle"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&singleRelations, &_2, &entityName, 0))) { + ZEPHIR_INIT_NVAR(&singleRelations); + array_init(&singleRelations); + } + zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 665); + zephir_update_property_array(this_ptr, SL("hasOneSingle"), &entityName, &singleRelations); + RETURN_CCTOR(&relation); } -static PHP_METHOD(Phalcon_Mvc_Model, getSource) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasOneThrough) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval options; + zval intermediateModel, referencedModel, keyRelation; + zval *model, model_sub, *fields, fields_sub, *intermediateModel_param = NULL, *intermediateFields, intermediateFields_sub, *intermediateReferencedFields, intermediateReferencedFields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, entityName, referencedEntity, hasOneThrough, relation, relations, alias, lowerAlias, singleRelations, intermediateEntity, _0, _1, _2; zval *this_ptr = getThis(); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&fields_sub); + ZVAL_UNDEF(&intermediateFields_sub); + ZVAL_UNDEF(&intermediateReferencedFields_sub); + ZVAL_UNDEF(&referencedFields_sub); + ZVAL_UNDEF(&entityName); + ZVAL_UNDEF(&referencedEntity); + ZVAL_UNDEF(&hasOneThrough); + ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&relations); + ZVAL_UNDEF(&alias); + ZVAL_UNDEF(&lowerAlias); + ZVAL_UNDEF(&singleRelations); + ZVAL_UNDEF(&intermediateEntity); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&intermediateModel); + ZVAL_UNDEF(&referencedModel); + ZVAL_UNDEF(&keyRelation); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(7, 8) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ZVAL(fields) + Z_PARAM_STR(intermediateModel) + Z_PARAM_ZVAL(intermediateFields) + Z_PARAM_ZVAL(intermediateReferencedFields) + Z_PARAM_STR(referencedModel) + Z_PARAM_ZVAL(referencedFields) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "getmodelsource", NULL, 0, this_ptr); + zephir_fetch_params(1, 7, 1, &model, &fields, &intermediateModel_param, &intermediateFields, &intermediateReferencedFields, &referencedModel_param, &referencedFields, &options_param); + if (UNEXPECTED(Z_TYPE_P(intermediateModel_param) != IS_STRING && Z_TYPE_P(intermediateModel_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'intermediateModel' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(intermediateModel_param) == IS_STRING)) { + zephir_get_strval(&intermediateModel, intermediateModel_param); + } else { + ZEPHIR_INIT_VAR(&intermediateModel); + } + if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) { + zephir_get_strval(&referencedModel, referencedModel_param); + } else { + ZEPHIR_INIT_VAR(&referencedModel); + } + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + ZEPHIR_INIT_VAR(&entityName); + zephir_get_class(&entityName, model, 1); + ZEPHIR_INIT_VAR(&intermediateEntity); + zephir_fast_strtolower(&intermediateEntity, &intermediateModel); + ZEPHIR_INIT_VAR(&referencedEntity); + zephir_fast_strtolower(&referencedEntity, &referencedModel); + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity); + zephir_get_strval(&keyRelation, &_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("hasOneThrough"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&hasOneThrough, &_1); + zephir_memory_observe(&relations); + if (!(zephir_array_isset_fetch(&relations, &hasOneThrough, &keyRelation, 0))) { + ZEPHIR_INIT_NVAR(&relations); + array_init(&relations); + } + if (Z_TYPE_P(intermediateFields) == IS_ARRAY) { + if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(intermediateFields))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 722); + return; + } + } + if (Z_TYPE_P(intermediateReferencedFields) == IS_ARRAY) { + if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(intermediateFields))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 734); + return; + } + } + ZEPHIR_INIT_VAR(&relation); + object_init_ex(&relation, phalcon_mvc_model_relation_ce); + ZVAL_LONG(&_1, 3); + ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 441, &_1, &referencedModel, fields, referencedFields, &options); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_CALL_METHOD(NULL, &relation, "setintermediaterelation", NULL, 442, intermediateFields, &intermediateModel, intermediateReferencedFields); + zephir_check_call_status(); + zephir_memory_observe(&alias); + if (zephir_array_isset_string_fetch(&alias, &options, SL("alias"), 0)) { + if (Z_TYPE_P(&alias) != IS_STRING) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 763); + return; + } + ZEPHIR_INIT_VAR(&lowerAlias); + zephir_fast_strtolower(&lowerAlias, &alias); + } else { + ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity); + } + zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 774); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_CONCAT_VSV(&_2, &entityName, "$", &lowerAlias); + zephir_update_property_array(this_ptr, SL("aliases"), &_2, &relation); + zephir_update_property_array(this_ptr, SL("hasOneThrough"), &keyRelation, &relations); + zephir_memory_observe(&singleRelations); + zephir_read_property(&_1, this_ptr, ZEND_STRL("hasOneThroughSingle"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&singleRelations, &_1, &entityName, 0))) { + ZEPHIR_INIT_NVAR(&singleRelations); + array_init(&singleRelations); + } + zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 796); + zephir_update_property_array(this_ptr, SL("hasOneThroughSingle"), &entityName, &singleRelations); + RETURN_CCTOR(&relation); } -static PHP_METHOD(Phalcon_Mvc_Model, getUpdatedFields) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, clearReusableObjects) { - zend_bool _11$$6, _13$$8; - zend_string *_10; - zend_ulong _9; - zval updated; - zval name, snapshot, oldSnapshot, value, _0, *_7, _8, _1$$3, _2$$3, _3$$3, _4$$5, _5$$5, _6$$5, _12$$6, _14$$8; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&snapshot); - ZVAL_UNDEF(&oldSnapshot); - ZVAL_UNDEF(&value); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_12$$6); - ZVAL_UNDEF(&_14$$8); - ZVAL_UNDEF(&updated); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&snapshot, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("oldSnapshot"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&oldSnapshot, &_0); - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).update_snapshot_on_save))) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - zephir_get_class(&_2$$3, this_ptr, 0); - ZEPHIR_INIT_VAR(&_3$$3); - ZEPHIR_CONCAT_SVS(&_3$$3, "The 'updateSnapshotOnSave' option must be enabled for this method to work properly in '", &_2$$3, "'"); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_3$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model.zep", 2210); - ZEPHIR_MM_RESTORE(); - return; - } - if (UNEXPECTED(Z_TYPE_P(&snapshot) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The 'keepSnapshots' option must be enabled to track changes", "phalcon/Mvc/Model.zep", 2216); - return; - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("dirtyState"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(!ZEPHIR_IS_LONG(&_0, 0))) { - ZEPHIR_INIT_VAR(&_4$$5); - object_init_ex(&_4$$5, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_5$$5); - zephir_get_class(&_5$$5, this_ptr, 0); - ZEPHIR_INIT_VAR(&_6$$5); - ZEPHIR_CONCAT_SVS(&_6$$5, "Change checking cannot be performed because the object has not been persisted or is deleted in '", &_5$$5, "'"); - ZEPHIR_CALL_METHOD(NULL, &_4$$5, "__construct", NULL, 33, &_6$$5); - zephir_check_call_status(); - zephir_throw_exception_debug(&_4$$5, "phalcon/Mvc/Model.zep", 2225); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_VAR(&updated); - array_init(&updated); - zephir_is_iterable(&snapshot, 0, "phalcon/Mvc/Model.zep", 2240); - if (Z_TYPE_P(&snapshot) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&snapshot), _9, _10, _7) - { - ZEPHIR_INIT_NVAR(&name); - if (_10 != NULL) { - ZVAL_STR_COPY(&name, _10); - } else { - ZVAL_LONG(&name, _9); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _7); - _11$$6 = !(zephir_array_isset(&oldSnapshot, &name)); - if (!(_11$$6)) { - zephir_array_fetch(&_12$$6, &oldSnapshot, &name, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 2235); - _11$$6 = !ZEPHIR_IS_IDENTICAL(&value, &_12$$6); - } - if (_11$$6) { - zephir_array_append(&updated, &name, PH_SEPARATE, "phalcon/Mvc/Model.zep", 2236); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &snapshot, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_8, &snapshot, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_8)) { - break; - } - ZEPHIR_CALL_METHOD(&name, &snapshot, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &snapshot, "current", NULL, 0); - zephir_check_call_status(); - _13$$8 = !(zephir_array_isset(&oldSnapshot, &name)); - if (!(_13$$8)) { - zephir_array_fetch(&_14$$8, &oldSnapshot, &name, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 2235); - _13$$8 = !ZEPHIR_IS_IDENTICAL(&value, &_14$$8); - } - if (_13$$8) { - zephir_array_append(&updated, &name, PH_SEPARATE, "phalcon/Mvc/Model.zep", 2236); - } - ZEPHIR_CALL_METHOD(NULL, &snapshot, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&name); - RETURN_CTOR(&updated); + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("reusable"), &_0); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model, getWriteConnection) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, createBuilder) { - zval _0, _2, _1$$3; + zval _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *params = NULL, params_sub, __$null, container, _0, _1, _3; zval *this_ptr = getThis(); + ZVAL_UNDEF(¶ms_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&container); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_1$$3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(params) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("transaction"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) != IS_NULL) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("transaction"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_1$$3, "getconnection", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 0, 1, ¶ms); + if (!params) { + params = ¶ms_sub; + params = &__$null; } - zephir_read_property(&_2, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_2, "getwriteconnection", NULL, 0, this_ptr); + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_0); + if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injection container is required to access the services related to the ORM", "phalcon/Mvc/Model/Manager.zep", 828); + return; + } + ZEPHIR_INIT_VAR(&_2); + zephir_create_array(&_2, 2, 0); + zephir_array_fast_append(&_2, params); + zephir_array_fast_append(&_2, &container); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "Phalcon\\Mvc\\Model\\Query\\Builder"); + ZEPHIR_CALL_METHOD(&_1, &container, "get", NULL, 0, &_3, &_2); zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("builder"), &_1); + RETURN_MM_MEMBER(getThis(), "builder"); } -static PHP_METHOD(Phalcon_Mvc_Model, getWriteConnectionService) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, createQuery) { - zval _0; + zval _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *phql_param = NULL, container, query, _0, _1, _3; + zval phql; zval *this_ptr = getThis(); + ZVAL_UNDEF(&phql); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&query); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(phql) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "getwriteconnectionservice", NULL, 0, this_ptr); + zephir_fetch_params(1, 1, 0, &phql_param); + if (UNEXPECTED(Z_TYPE_P(phql_param) != IS_STRING && Z_TYPE_P(phql_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'phql' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(phql_param) == IS_STRING)) { + zephir_get_strval(&phql, phql_param); + } else { + ZEPHIR_INIT_VAR(&phql); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_0); + if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injection container is required to access the services related to the ORM", "phalcon/Mvc/Model/Manager.zep", 861); + return; + } + ZEPHIR_INIT_VAR(&_2); + zephir_create_array(&_2, 2, 0); + zephir_array_fast_append(&_2, &phql); + zephir_array_fast_append(&_2, &container); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "Phalcon\\Mvc\\Model\\Query"); + ZEPHIR_CALL_METHOD(&_1, &container, "get", NULL, 0, &_3, &_2); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_CPY_WRT(&query, &_1); + zephir_update_property_zval(this_ptr, ZEND_STRL("lastQuery"), &query); + RETURN_CCTOR(&query); } -static PHP_METHOD(Phalcon_Mvc_Model, hasChanged) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, executeQuery) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool allFields; - zval *fieldName = NULL, fieldName_sub, *allFields_param = NULL, __$null, changedFields, intersect; + zval *phql_param = NULL, *placeholders = NULL, placeholders_sub, *types = NULL, types_sub, __$null, query; + zval phql; zval *this_ptr = getThis(); - ZVAL_UNDEF(&fieldName_sub); + ZVAL_UNDEF(&phql); + ZVAL_UNDEF(&placeholders_sub); + ZVAL_UNDEF(&types_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&changedFields); - ZVAL_UNDEF(&intersect); + ZVAL_UNDEF(&query); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(phql) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(fieldName) - Z_PARAM_BOOL(allFields) + Z_PARAM_ZVAL_OR_NULL(placeholders) + Z_PARAM_ZVAL_OR_NULL(types) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &fieldName, &allFields_param); - if (!fieldName) { - fieldName = &fieldName_sub; - fieldName = &__$null; + zephir_fetch_params(1, 1, 2, &phql_param, &placeholders, &types); + if (UNEXPECTED(Z_TYPE_P(phql_param) != IS_STRING && Z_TYPE_P(phql_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'phql' must be of the type string")); + RETURN_MM_NULL(); } - if (!allFields_param) { - allFields = 0; + if (EXPECTED(Z_TYPE_P(phql_param) == IS_STRING)) { + zephir_get_strval(&phql, phql_param); } else { - } - ZEPHIR_CALL_METHOD(&changedFields, this_ptr, "getchangedfields", NULL, 0); + ZEPHIR_INIT_VAR(&phql); + } + if (!placeholders) { + placeholders = &placeholders_sub; + placeholders = &__$null; + } + if (!types) { + types = &types_sub; + types = &__$null; + } + ZEPHIR_CALL_METHOD(&query, this_ptr, "createquery", NULL, 0, &phql); zephir_check_call_status(); - if (Z_TYPE_P(fieldName) == IS_STRING) { - RETURN_MM_BOOL(zephir_fast_in_array(fieldName, &changedFields)); + if (Z_TYPE_P(placeholders) == IS_ARRAY) { + ZEPHIR_CALL_METHOD(NULL, &query, "setbindparams", NULL, 0, placeholders); + zephir_check_call_status(); } - if (Z_TYPE_P(fieldName) == IS_ARRAY) { - ZEPHIR_CALL_FUNCTION(&intersect, "array_intersect", NULL, 428, fieldName, &changedFields); + if (Z_TYPE_P(types) == IS_ARRAY) { + ZEPHIR_CALL_METHOD(NULL, &query, "setbindtypes", NULL, 0, types); zephir_check_call_status(); - if (allFields) { - RETURN_MM_BOOL(ZEPHIR_IS_EQUAL(&intersect, fieldName)); - } - RETURN_MM_BOOL(zephir_fast_count_int(&intersect) > 0); } - RETURN_MM_BOOL(zephir_fast_count_int(&changedFields) > 0); -} - -static PHP_METHOD(Phalcon_Mvc_Model, hasSnapshotData) -{ - zval _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); - RETURN_BOOL(!(ZEPHIR_IS_EMPTY(&_0))); + ZEPHIR_RETURN_CALL_METHOD(&query, "execute", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, hasUpdated) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsBelongsTo) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool allFields; - zval *fieldName = NULL, fieldName_sub, *allFields_param = NULL, __$null, updatedFields, intersect; + zval *modelName_param = NULL, *modelRelation_param = NULL; + zval modelName, modelRelation; zval *this_ptr = getThis(); - ZVAL_UNDEF(&fieldName_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&updatedFields); - ZVAL_UNDEF(&intersect); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(fieldName) - Z_PARAM_BOOL(allFields) + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&modelRelation); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(modelName) + Z_PARAM_STR(modelRelation) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &fieldName, &allFields_param); - if (!fieldName) { - fieldName = &fieldName_sub; - fieldName = &__$null; + zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + RETURN_MM_NULL(); } - if (!allFields_param) { - allFields = 0; + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); } else { - } - ZEPHIR_CALL_METHOD(&updatedFields, this_ptr, "getupdatedfields", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(fieldName) == IS_STRING) { - RETURN_MM_BOOL(zephir_fast_in_array(fieldName, &updatedFields)); + ZEPHIR_INIT_VAR(&modelName); } - if (Z_TYPE_P(fieldName) == IS_ARRAY) { - ZEPHIR_CALL_FUNCTION(&intersect, "array_intersect", NULL, 428, fieldName, &updatedFields); - zephir_check_call_status(); - if (allFields) { - RETURN_MM_BOOL(ZEPHIR_IS_EQUAL(&intersect, fieldName)); - } - RETURN_MM_BOOL(zephir_fast_count_int(&intersect) > 0); + if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + RETURN_MM_NULL(); } - RETURN_MM_BOOL(zephir_fast_count_int(&updatedFields) > 0); + if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { + zephir_get_strval(&modelRelation, modelRelation_param); + } else { + ZEPHIR_INIT_VAR(&modelRelation); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hasbelongsto", NULL, 0, &modelName, &modelRelation); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, jsonSerialize) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasMany) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *modelName_param = NULL, *modelRelation_param = NULL; + zval modelName, modelRelation; zval *this_ptr = getThis(); + + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&modelRelation); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(modelName) + Z_PARAM_STR(modelRelation) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "toarray", NULL, 0); + zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); + } else { + ZEPHIR_INIT_VAR(&modelName); + } + if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { + zephir_get_strval(&modelRelation, modelRelation_param); + } else { + ZEPHIR_INIT_VAR(&modelRelation); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hashasmany", NULL, 0, &modelName, &modelRelation); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, maximum) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasManyToMany) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *parameters = NULL, parameters_sub, __$null, _0, _1; + zval *modelName_param = NULL, *modelRelation_param = NULL; + zval modelName, modelRelation; + zval *this_ptr = getThis(); - ZVAL_UNDEF(¶meters_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(parameters) + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&modelRelation); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(modelName) + Z_PARAM_STR(modelRelation) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, ¶meters); - if (!parameters) { - parameters = ¶meters_sub; - parameters = &__$null; + zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "MAX"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "maximum"); - ZEPHIR_RETURN_CALL_SELF("groupresult", NULL, 0, &_0, &_1, parameters); + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); + } else { + ZEPHIR_INIT_VAR(&modelName); + } + if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { + zephir_get_strval(&modelRelation, modelRelation_param); + } else { + ZEPHIR_INIT_VAR(&modelRelation); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hashasmanytomany", NULL, 0, &modelName, &modelRelation); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, minimum) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasOne) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *parameters = NULL, parameters_sub, __$null, _0, _1; + zval *modelName_param = NULL, *modelRelation_param = NULL; + zval modelName, modelRelation; + zval *this_ptr = getThis(); - ZVAL_UNDEF(¶meters_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(parameters) + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&modelRelation); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(modelName) + Z_PARAM_STR(modelRelation) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, ¶meters); - if (!parameters) { - parameters = ¶meters_sub; - parameters = &__$null; + zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "MIN"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "minimum"); - ZEPHIR_RETURN_CALL_SELF("groupresult", NULL, 0, &_0, &_1, parameters); + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); + } else { + ZEPHIR_INIT_VAR(&modelName); + } + if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { + zephir_get_strval(&modelRelation, modelRelation_param); + } else { + ZEPHIR_INIT_VAR(&modelRelation); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hashasone", NULL, 0, &modelName, &modelRelation); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, query) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasOneThrough) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *container = NULL, container_sub, __$null, criteria, _2, _0$$4, _1$$4; + zval *modelName_param = NULL, *modelRelation_param = NULL; + zval modelName, modelRelation; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&container_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&criteria); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(container, phalcon_di_diinterface_ce) + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&modelRelation); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(modelName) + Z_PARAM_STR(modelRelation) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &container); - if (!container) { - container = &container_sub; - ZEPHIR_CPY_WRT(container, &__$null); + zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); } else { - ZEPHIR_SEPARATE_PARAM(container); + ZEPHIR_INIT_VAR(&modelName); } - if (Z_TYPE_P(container) != IS_OBJECT) { - ZEPHIR_CALL_CE_STATIC(container, phalcon_di_di_ce, "getdefault", NULL, 0); - zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_INIT_VAR(&criteria); - if (zephir_instance_of_ev(container, phalcon_di_diinterface_ce)) { - ZEPHIR_INIT_VAR(&_1$$4); - ZVAL_STRING(&_1$$4, "Phalcon\\Mvc\\Model\\Criteria"); - ZEPHIR_CALL_METHOD(&_0$$4, container, "get", NULL, 0, &_1$$4); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&criteria, &_0$$4); + if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { + zephir_get_strval(&modelRelation, modelRelation_param); } else { - object_init_ex(&criteria, phalcon_mvc_model_criteria_ce); - if (zephir_has_constructor(&criteria)) { - ZEPHIR_CALL_METHOD(NULL, &criteria, "__construct", NULL, 0); - zephir_check_call_status(); - } - - ZEPHIR_CALL_METHOD(NULL, &criteria, "setdi", NULL, 429, container); - zephir_check_call_status(); + ZEPHIR_INIT_VAR(&modelRelation); } - ZEPHIR_INIT_VAR(&_2); - zephir_get_called_class(&_2); - ZEPHIR_CALL_METHOD(NULL, &criteria, "setmodelname", NULL, 430, &_2); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hashasonethrough", NULL, 0, &modelName, &modelRelation); zephir_check_call_status(); - RETURN_CCTOR(&criteria); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, readAttribute) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getBelongsTo) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *attribute_param = NULL, _0; - zval attribute; + zval *model, model_sub, relations, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&relations); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(attribute) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &attribute_param); - if (UNEXPECTED(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(attribute_param) == IS_STRING)) { - zephir_get_strval(&attribute, attribute_param); - } else { - ZEPHIR_INIT_VAR(&attribute); - } - if (!(zephir_isset_property_zval(this_ptr, &attribute))) { - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 0, &model); + zephir_memory_observe(&relations); + zephir_read_property(&_0, this_ptr, ZEND_STRL("belongsToSingle"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + zephir_get_class(&_1, model, 1); + if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 0))) { + array_init(return_value); + RETURN_MM(); } - zephir_memory_observe(&_0); - zephir_read_property_zval(&_0, this_ptr, &attribute, PH_NOISY_CC); - RETURN_CCTOR(&_0); + RETURN_CCTOR(&relations); } -static PHP_METHOD(Phalcon_Mvc_Model, refresh) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getBelongsToRecords) { - zval fields, _18, _16$$9, _17$$10; - zval metaData, readConnection, schema, source, table, uniqueKey, tables, uniqueParams, dialect, row, attribute, manager, columnMap, _0, _4, _13, *_14, _15, _19, _20, _23, _1$$3, _2$$3, _3$$3, _5$$6, _9$$6, _6$$7, _7$$7, _8$$7, _10$$8, _11$$8, _12$$8, _21$$11, _22$$11; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *modelName_param = NULL, *modelRelation_param = NULL, *record, record_sub, *parameters = NULL, parameters_sub, *method_param = NULL, __$null, relations, _0, _1, _2, _3, _4; + zval modelName, modelRelation, method, keyRelation; zval *this_ptr = getThis(); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&readConnection); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&table); - ZVAL_UNDEF(&uniqueKey); - ZVAL_UNDEF(&tables); - ZVAL_UNDEF(&uniqueParams); - ZVAL_UNDEF(&dialect); - ZVAL_UNDEF(&row); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&columnMap); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&modelRelation); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&keyRelation); + ZVAL_UNDEF(&record_sub); + ZVAL_UNDEF(¶meters_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&relations); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_13); - ZVAL_UNDEF(&_15); - ZVAL_UNDEF(&_19); - ZVAL_UNDEF(&_20); - ZVAL_UNDEF(&_23); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_9$$6); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_7$$7); - ZVAL_UNDEF(&_8$$7); - ZVAL_UNDEF(&_10$$8); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_12$$8); - ZVAL_UNDEF(&_21$$11); - ZVAL_UNDEF(&_22$$11); - ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&_18); - ZVAL_UNDEF(&_16$$9); - ZVAL_UNDEF(&_17$$10); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(3, 5) + Z_PARAM_STR(modelName) + Z_PARAM_STR(modelRelation) + Z_PARAM_OBJECT_OF_CLASS(record, phalcon_mvc_modelinterface_ce) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(parameters) + Z_PARAM_STR_OR_NULL(method) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("dirtyState"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(!ZEPHIR_IS_LONG(&_0, 0))) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - zephir_get_class(&_2$$3, this_ptr, 0); - ZEPHIR_INIT_VAR(&_3$$3); - ZEPHIR_CONCAT_SVS(&_3$$3, "The record cannot be refreshed because it does not exist or is deleted in '", &_2$$3, "'"); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_3$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model.zep", 2491); - ZEPHIR_MM_RESTORE(); - return; + zephir_fetch_params(1, 3, 2, &modelName_param, &modelRelation_param, &record, ¶meters, &method_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&readConnection, this_ptr, "getreadconnection", NULL, 431); - zephir_check_call_status(); - zephir_read_property(&_4, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_4); - ZEPHIR_CALL_METHOD(&schema, this_ptr, "getschema", NULL, 423); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 424); - zephir_check_call_status(); - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_VAR(&table); - zephir_create_array(&table, 2, 0); - zephir_array_fast_append(&table, &schema); - zephir_array_fast_append(&table, &source); + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); } else { - ZEPHIR_CPY_WRT(&table, &source); + ZEPHIR_INIT_VAR(&modelName); } - zephir_read_property(&_4, this_ptr, ZEND_STRL("uniqueKey"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&uniqueKey, &_4); - if (!(zephir_is_true(&uniqueKey))) { - ZEPHIR_CALL_METHOD(&_5$$6, this_ptr, "has", NULL, 0, &metaData, &readConnection); - zephir_check_call_status(); - if (UNEXPECTED(!zephir_is_true(&_5$$6))) { - ZEPHIR_INIT_VAR(&_6$$7); - object_init_ex(&_6$$7, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_7$$7); - zephir_get_class(&_7$$7, this_ptr, 0); - ZEPHIR_INIT_VAR(&_8$$7); - ZEPHIR_CONCAT_SVS(&_8$$7, "The record cannot be refreshed because it does not exist or is deleted in '", &_7$$7, "'"); - ZEPHIR_CALL_METHOD(NULL, &_6$$7, "__construct", NULL, 33, &_8$$7); - zephir_check_call_status(); - zephir_throw_exception_debug(&_6$$7, "phalcon/Mvc/Model.zep", 2516); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_read_property(&_9$$6, this_ptr, ZEND_STRL("uniqueKey"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&uniqueKey, &_9$$6); + if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + RETURN_MM_NULL(); } - zephir_read_property(&_4, this_ptr, ZEND_STRL("uniqueParams"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&uniqueParams, &_4); - if (UNEXPECTED(Z_TYPE_P(&uniqueParams) != IS_ARRAY)) { - ZEPHIR_INIT_VAR(&_10$$8); - object_init_ex(&_10$$8, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_11$$8); - zephir_get_class(&_11$$8, this_ptr, 0); - ZEPHIR_INIT_VAR(&_12$$8); - ZEPHIR_CONCAT_SVS(&_12$$8, "The record cannot be refreshed because it does not exist or is deleted in '", &_11$$8, "'"); - ZEPHIR_CALL_METHOD(NULL, &_10$$8, "__construct", NULL, 33, &_12$$8); - zephir_check_call_status(); - zephir_throw_exception_debug(&_10$$8, "phalcon/Mvc/Model.zep", 2527); - ZEPHIR_MM_RESTORE(); - return; + if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { + zephir_get_strval(&modelRelation, modelRelation_param); + } else { + ZEPHIR_INIT_VAR(&modelRelation); } - ZEPHIR_INIT_VAR(&fields); - array_init(&fields); - ZEPHIR_CALL_METHOD(&_13, &metaData, "getattributes", NULL, 0, this_ptr); - zephir_check_call_status(); - zephir_is_iterable(&_13, 0, "phalcon/Mvc/Model.zep", 2542); - if (Z_TYPE_P(&_13) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_13), _14) - { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _14); - ZEPHIR_INIT_NVAR(&_16$$9); - zephir_create_array(&_16$$9, 1, 0); - zephir_array_fast_append(&_16$$9, &attribute); - zephir_array_append(&fields, &_16$$9, PH_SEPARATE, "phalcon/Mvc/Model.zep", 2536); - } ZEND_HASH_FOREACH_END(); + if (!parameters) { + parameters = ¶meters_sub; + parameters = &__$null; + } + if (!method_param) { + ZEPHIR_INIT_VAR(&method); } else { - ZEPHIR_CALL_METHOD(NULL, &_13, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_15, &_13, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_15)) { - break; - } - ZEPHIR_CALL_METHOD(&attribute, &_13, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_17$$10); - zephir_create_array(&_17$$10, 1, 0); - zephir_array_fast_append(&_17$$10, &attribute); - zephir_array_append(&fields, &_17$$10, PH_SEPARATE, "phalcon/Mvc/Model.zep", 2536); - ZEPHIR_CALL_METHOD(NULL, &_13, "next", NULL, 0); - zephir_check_call_status(); - } + zephir_get_strval(&method, method_param); } - ZEPHIR_INIT_NVAR(&attribute); - ZEPHIR_CALL_METHOD(&dialect, &readConnection, "getdialect", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_18); - zephir_create_array(&_18, 3, 0); - zephir_array_update_string(&_18, SL("columns"), &fields, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_19, &readConnection, "escapeidentifier", NULL, 0, &table); - zephir_check_call_status(); - zephir_array_update_string(&_18, SL("tables"), &_19, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_18, SL("where"), &uniqueKey, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&tables, &dialect, "select", NULL, 0, &_18); - zephir_check_call_status(); - zephir_read_property(&_4, this_ptr, ZEND_STRL("uniqueTypes"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_20, 2); - ZEPHIR_CALL_METHOD(&row, &readConnection, "fetchone", NULL, 0, &tables, &_20, &uniqueParams, &_4); - zephir_check_call_status(); - if (Z_TYPE_P(&row) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", NULL, 0, this_ptr); - zephir_check_call_status(); - ZVAL_NULL(&_21$$11); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "assign", NULL, 0, &row, &_21$$11, &columnMap); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_22$$11, &manager, "iskeepingsnapshots", NULL, 0, this_ptr); - zephir_check_call_status(); - if (zephir_is_true(&_22$$11)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setsnapshotdata", NULL, 0, &row, &columnMap); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setoldsnapshotdata", NULL, 0, &row, &columnMap); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&_0); + zephir_fast_strtolower(&_0, &modelName); + ZEPHIR_INIT_VAR(&_1); + zephir_fast_strtolower(&_1, &modelRelation); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_CONCAT_VSV(&_2, &_0, "$", &_1); + zephir_get_strval(&keyRelation, &_2); + zephir_memory_observe(&relations); + zephir_read_property(&_3, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&relations, &_3, &keyRelation, 0))) { + RETURN_MM_BOOL(0); } - ZEPHIR_INIT_VAR(&_23); - ZVAL_STRING(&_23, "afterFetch"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_23); + zephir_array_fetch_long(&_4, &relations, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1030); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelationrecords", NULL, 0, &_4, record, parameters, &method); zephir_check_call_status(); - RETURN_THIS(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, save) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getBuilder) +{ + + RETURN_MEMBER(getThis(), "builder"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getConnectionService) { - zval visited; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval connectionServices; + zval *model, model_sub, *connectionServices_param = NULL, connection, _0; + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&connection); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&connectionServices); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ARRAY(connectionServices) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &model, &connectionServices_param); + zephir_get_arrval(&connectionServices, connectionServices_param); + zephir_memory_observe(&connection); + ZEPHIR_INIT_VAR(&_0); + zephir_get_class(&_0, model, 1); + if (!(zephir_array_isset_fetch(&connection, &connectionServices, &_0, 0))) { + RETURN_MM_STRING("db"); + } + RETURN_CCTOR(&connection); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getCustomEventsManager) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *model, model_sub, eventsManager, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&visited); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + zephir_memory_observe(&eventsManager); + zephir_read_property(&_0, this_ptr, ZEND_STRL("customEventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + zephir_get_class(&_1, model, 1); + if (zephir_array_isset_fetch(&eventsManager, &_0, &_1, 0)) { + RETURN_CCTOR(&eventsManager); + } + RETURN_MM_NULL(); +} - ZEPHIR_INIT_VAR(&visited); - object_init_ex(&visited, phalcon_support_collection_ce); - ZEPHIR_CALL_METHOD(NULL, &visited, "__construct", NULL, 23); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dosave", NULL, 0, &visited); - zephir_check_call_status(); - RETURN_MM(); +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getDI) +{ + + RETURN_MEMBER(getThis(), "container"); } -static PHP_METHOD(Phalcon_Mvc_Model, doSave) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getEventsManager) +{ + + RETURN_MEMBER(getThis(), "eventsManager"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasMany) { - zend_bool hasRelatedToSave = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *visited, visited_sub, metaData, schema, writeConnection, readConnection, source, table, identityField, exists, success, relatedToSave, objId, _0, _1, _5, _2$$4, _3$$8, _4$$9, _6$$11, _7$$12, _8$$12, _9$$15, _10$$17, _11$$19, _12$$22, _13$$21; + zval *model, model_sub, relations, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&visited_sub); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&writeConnection); - ZVAL_UNDEF(&readConnection); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&table); - ZVAL_UNDEF(&identityField); - ZVAL_UNDEF(&exists); - ZVAL_UNDEF(&success); - ZVAL_UNDEF(&relatedToSave); - ZVAL_UNDEF(&objId); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&relations); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$8); - ZVAL_UNDEF(&_4$$9); - ZVAL_UNDEF(&_6$$11); - ZVAL_UNDEF(&_7$$12); - ZVAL_UNDEF(&_8$$12); - ZVAL_UNDEF(&_9$$15); - ZVAL_UNDEF(&_10$$17); - ZVAL_UNDEF(&_11$$19); - ZVAL_UNDEF(&_12$$22); - ZVAL_UNDEF(&_13$$21); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(visited, phalcon_support_collection_collectioninterface_ce) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &visited); - ZEPHIR_CALL_FUNCTION(&objId, "spl_object_id", NULL, 432, this_ptr); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, visited, "has", NULL, 0, &objId); - zephir_check_call_status(); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - RETURN_MM_BOOL(1); - } - ZEPHIR_CALL_METHOD(NULL, visited, "set", NULL, 0, &objId, this_ptr); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&writeConnection, this_ptr, "getwriteconnection", NULL, 421); - zephir_check_call_status(); + zephir_fetch_params(1, 1, 0, &model); + zephir_memory_observe(&relations); + zephir_read_property(&_0, this_ptr, ZEND_STRL("hasManySingle"), PH_NOISY_CC | PH_READONLY); ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "prepareSave"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_1); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&relatedToSave, this_ptr, "collectrelatedtosave", NULL, 0); - zephir_check_call_status(); - hasRelatedToSave = zephir_fast_count_int(&relatedToSave) > 0; - if (hasRelatedToSave) { - ZEPHIR_CALL_METHOD(&_2$$4, this_ptr, "presaverelatedrecords", NULL, 0, &writeConnection, &relatedToSave, visited); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_2$$4)) { - RETURN_MM_BOOL(0); - } + zephir_get_class(&_1, model, 1); + if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 0))) { + array_init(return_value); + RETURN_MM(); } - ZEPHIR_CALL_METHOD(&schema, this_ptr, "getschema", NULL, 423); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 424); - zephir_check_call_status(); - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_VAR(&table); - zephir_create_array(&table, 2, 0); - zephir_array_fast_append(&table, &schema); - zephir_array_fast_append(&table, &source); - } else { - ZEPHIR_CPY_WRT(&table, &source); + RETURN_CCTOR(&relations); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasManyRecords) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *modelName_param = NULL, *modelRelation_param = NULL, *record, record_sub, *parameters = NULL, parameters_sub, *method_param = NULL, __$null, relations, _0, _1, _2, _3, _4; + zval modelName, modelRelation, method, keyRelation; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&modelRelation); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&keyRelation); + ZVAL_UNDEF(&record_sub); + ZVAL_UNDEF(¶meters_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&relations); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(3, 5) + Z_PARAM_STR(modelName) + Z_PARAM_STR(modelRelation) + Z_PARAM_OBJECT_OF_CLASS(record, phalcon_mvc_modelinterface_ce) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(parameters) + Z_PARAM_STR_OR_NULL(method) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 2, &modelName_param, &modelRelation_param, &record, ¶meters, &method_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_CALL_METHOD(&readConnection, this_ptr, "getreadconnection", NULL, 431); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&exists, this_ptr, "has", NULL, 0, &metaData, &readConnection); - zephir_check_call_status(); - if (zephir_is_true(&exists)) { - ZVAL_UNDEF(&_3$$8); - ZVAL_LONG(&_3$$8, 2); - zephir_update_property_zval(this_ptr, ZEND_STRL("operationMade"), &_3$$8); + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); } else { - ZVAL_UNDEF(&_4$$9); - ZVAL_LONG(&_4$$9, 1); - zephir_update_property_zval(this_ptr, ZEND_STRL("operationMade"), &_4$$9); + ZEPHIR_INIT_VAR(&modelName); } - ZEPHIR_INIT_NVAR(&_1); - array_init(&_1); - zephir_update_property_zval(this_ptr, ZEND_STRL("errorMessages"), &_1); - ZEPHIR_CALL_METHOD(&identityField, &metaData, "getidentityfield", NULL, 0, this_ptr); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_5, this_ptr, "presave", NULL, 0, &metaData, &exists, &identityField); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_5)) { - if (hasRelatedToSave) { - ZVAL_BOOL(&_6$$11, 0); - ZEPHIR_CALL_METHOD(NULL, &writeConnection, "rollback", NULL, 0, &_6$$11); - zephir_check_call_status(); - } - if (UNEXPECTED(ZEPHIR_GLOBAL(orm).exception_on_failed_save)) { - ZEPHIR_INIT_VAR(&_7$$12); - object_init_ex(&_7$$12, phalcon_mvc_model_validationfailed_ce); - ZEPHIR_CALL_METHOD(&_8$$12, this_ptr, "getmessages", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_7$$12, "__construct", NULL, 433, this_ptr, &_8$$12); - zephir_check_call_status(); - zephir_throw_exception_debug(&_7$$12, "phalcon/Mvc/Model.zep", 2716); - ZEPHIR_MM_RESTORE(); - return; - } - RETURN_MM_BOOL(0); + if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + RETURN_MM_NULL(); } - if (zephir_is_true(&exists)) { - ZEPHIR_CALL_METHOD(&success, this_ptr, "dolowupdate", NULL, 0, &metaData, &writeConnection, &table); - zephir_check_call_status(); + if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { + zephir_get_strval(&modelRelation, modelRelation_param); } else { - ZEPHIR_CALL_METHOD(&success, this_ptr, "dolowinsert", NULL, 0, &metaData, &writeConnection, &table, &identityField); - zephir_check_call_status(); + ZEPHIR_INIT_VAR(&modelRelation); } - if (ZEPHIR_IS_TRUE_IDENTICAL(&success)) { - ZVAL_UNDEF(&_9$$15); - ZVAL_LONG(&_9$$15, 0); - zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &_9$$15); + if (!parameters) { + parameters = ¶meters_sub; + parameters = &__$null; } - if (hasRelatedToSave) { - if (ZEPHIR_IS_FALSE_IDENTICAL(&success)) { - ZVAL_BOOL(&_10$$17, 0); - ZEPHIR_CALL_METHOD(NULL, &writeConnection, "rollback", NULL, 0, &_10$$17); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&success, this_ptr, "postsaverelatedrecords", NULL, 0, &writeConnection, &relatedToSave, visited); - zephir_check_call_status(); - } + if (!method_param) { + ZEPHIR_INIT_VAR(&method); + } else { + zephir_get_strval(&method, method_param); } - if (ZEPHIR_GLOBAL(orm).events) { - ZEPHIR_CALL_METHOD(&_11$$19, this_ptr, "postsave", NULL, 0, &success, &exists); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&success, &_11$$19); + ZEPHIR_INIT_VAR(&_0); + zephir_fast_strtolower(&_0, &modelName); + ZEPHIR_INIT_VAR(&_1); + zephir_fast_strtolower(&_1, &modelRelation); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_CONCAT_VSV(&_2, &_0, "$", &_1); + zephir_get_strval(&keyRelation, &_2); + zephir_memory_observe(&relations); + zephir_read_property(&_3, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&relations, &_3, &keyRelation, 0))) { + RETURN_MM_BOOL(0); } - if (ZEPHIR_IS_FALSE_IDENTICAL(&success)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "canceloperation", NULL, 0); - zephir_check_call_status(); - } else { - if (hasRelatedToSave) { - ZEPHIR_INIT_VAR(&_12$$22); - array_init(&_12$$22); - zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyRelated"), &_12$$22); - } - ZEPHIR_INIT_VAR(&_13$$21); - ZVAL_STRING(&_13$$21, "afterSave"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_13$$21); - zephir_check_call_status(); + zephir_array_fetch_long(&_4, &relations, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1141); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelationrecords", NULL, 0, &_4, record, parameters, &method); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasManyToMany) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *model, model_sub, relations, _0, _1; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&relations); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + zephir_memory_observe(&relations); + zephir_read_property(&_0, this_ptr, ZEND_STRL("hasManyToManySingle"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + zephir_get_class(&_1, model, 1); + if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 0))) { + array_init(return_value); + RETURN_MM(); } - RETURN_CCTOR(&success); + RETURN_CCTOR(&relations); } -static PHP_METHOD(Phalcon_Mvc_Model, serialize) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOne) { - zval _6; - zend_bool _3, _4; - zval attributes, manager, dirtyState, snapshot, _0, _1, _2, _5$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, relations, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&dirtyState); - ZVAL_UNDEF(&snapshot); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&relations); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + zephir_memory_observe(&relations); + zephir_read_property(&_0, this_ptr, ZEND_STRL("hasOneSingle"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + zephir_get_class(&_1, model, 1); + if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 0))) { + array_init(return_value); + RETURN_MM(); + } + RETURN_CCTOR(&relations); +} - ZEPHIR_INIT_VAR(&snapshot); - ZVAL_NULL(&snapshot); - ZVAL_NULL(&_0); - ZVAL_BOOL(&_1, 0); - ZEPHIR_CALL_METHOD(&attributes, this_ptr, "toarray", NULL, 0, &_0, &_1); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("dirtyState"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&dirtyState, &_0); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getmodelsmanager", NULL, 0); +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOneAndHasMany) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, _0, _1; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "gethasone", NULL, 0, model); zephir_check_call_status(); - ZEPHIR_CPY_WRT(&manager, &_2); - ZEPHIR_CALL_METHOD(&_2, &manager, "iskeepingsnapshots", NULL, 0, this_ptr); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "gethasmany", NULL, 0, model); zephir_check_call_status(); - _3 = zephir_is_true(&_2); - if (_3) { - zephir_read_property(&_0, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); - _3 = Z_TYPE_P(&_0) != IS_NULL; + zephir_fast_array_merge(return_value, &_0, &_1); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOneRecords) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *modelName_param = NULL, *modelRelation_param = NULL, *record, record_sub, *parameters = NULL, parameters_sub, *method_param = NULL, __$null, relations, _0, _1, _2, _3, _4; + zval modelName, modelRelation, method, keyRelation; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&modelRelation); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&keyRelation); + ZVAL_UNDEF(&record_sub); + ZVAL_UNDEF(¶meters_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&relations); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(3, 5) + Z_PARAM_STR(modelName) + Z_PARAM_STR(modelRelation) + Z_PARAM_OBJECT_OF_CLASS(record, phalcon_mvc_modelinterface_ce) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(parameters) + Z_PARAM_STR_OR_NULL(method) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 2, &modelName_param, &modelRelation_param, &record, ¶meters, &method_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + RETURN_MM_NULL(); } - _4 = _3; - if (_4) { - zephir_read_property(&_1, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); - _4 = !ZEPHIR_IS_EQUAL(&attributes, &_1); + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); + } else { + ZEPHIR_INIT_VAR(&modelName); } - if (_4) { - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&snapshot, &_5$$3); + if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_INIT_VAR(&_6); - zephir_create_array(&_6, 3, 0); - zephir_array_update_string(&_6, SL("attributes"), &attributes, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_6, SL("snapshot"), &snapshot, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_6, SL("dirtyState"), &dirtyState, PH_COPY | PH_SEPARATE); - ZEPHIR_RETURN_CALL_FUNCTION("serialize", NULL, 15, &_6); + if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { + zephir_get_strval(&modelRelation, modelRelation_param); + } else { + ZEPHIR_INIT_VAR(&modelRelation); + } + if (!parameters) { + parameters = ¶meters_sub; + parameters = &__$null; + } + if (!method_param) { + ZEPHIR_INIT_VAR(&method); + } else { + zephir_get_strval(&method, method_param); + } + ZEPHIR_INIT_VAR(&_0); + zephir_fast_strtolower(&_0, &modelName); + ZEPHIR_INIT_VAR(&_1); + zephir_fast_strtolower(&_1, &modelRelation); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_CONCAT_VSV(&_2, &_0, "$", &_1); + zephir_get_strval(&keyRelation, &_2); + zephir_memory_observe(&relations); + zephir_read_property(&_3, this_ptr, ZEND_STRL("hasOne"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&relations, &_3, &keyRelation, 0))) { + RETURN_MM_BOOL(0); + } + zephir_array_fetch_long(&_4, &relations, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1210); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelationrecords", NULL, 0, &_4, record, parameters, &method); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, unserialize) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOneThrough) { - zend_string *_12$$7; - zend_ulong _11$$7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *data_param = NULL, attributes, container, manager, key, value, snapshot, properties, dirtyState, _0$$4, _1$$5, _2$$5, _3$$5, _4$$3, _5$$3, _6$$6, _7$$6, _8$$6, *_9$$7, _10$$7; - zval data; + zval *model, model_sub, relations, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&snapshot); - ZVAL_UNDEF(&properties); - ZVAL_UNDEF(&dirtyState); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$5); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$6); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_8$$6); - ZVAL_UNDEF(&_10$$7); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&relations); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(data) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &data_param); - zephir_get_strval(&data, data_param); - ZEPHIR_CALL_FUNCTION(&attributes, "unserialize", NULL, 16, &data); - zephir_check_call_status(); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - if (!(zephir_array_isset_string(&attributes, SL("attributes")))) { - ZEPHIR_INIT_VAR(&_0$$4); - zephir_create_array(&_0$$4, 1, 0); - zephir_array_update_string(&_0$$4, SL("attributes"), &attributes, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&attributes, &_0$$4); - } - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$5); - object_init_ex(&_1$$5, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_2$$5); - zephir_get_class(&_2$$5, this_ptr, 0); - ZEPHIR_INIT_VAR(&_3$$5); - ZEPHIR_CONCAT_SVS(&_3$$5, "A dependency injection container is required to access the services related to the ODM in '", &_2$$5, "'"); - ZEPHIR_CALL_METHOD(NULL, &_1$$5, "__construct", NULL, 33, &_3$$5); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$5, "phalcon/Mvc/Model.zep", 2836); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &container); - ZEPHIR_INIT_VAR(&_5$$3); - ZVAL_STRING(&_5$$3, "modelsManager"); - ZEPHIR_CALL_METHOD(&_4$$3, &container, "getshared", NULL, 0, &_5$$3); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&manager, &_4$$3); - if (UNEXPECTED(Z_TYPE_P(&manager) != IS_OBJECT)) { - ZEPHIR_INIT_VAR(&_6$$6); - object_init_ex(&_6$$6, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_7$$6); - zephir_get_class(&_7$$6, this_ptr, 0); - ZEPHIR_INIT_VAR(&_8$$6); - ZEPHIR_CONCAT_SVS(&_8$$6, "The injected service 'modelsManager' is not valid in '", &_7$$6, "'"); - ZEPHIR_CALL_METHOD(NULL, &_6$$6, "__construct", NULL, 33, &_8$$6); - zephir_check_call_status(); - zephir_throw_exception_debug(&_6$$6, "phalcon/Mvc/Model.zep", 2852); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_update_property_zval(this_ptr, ZEND_STRL("modelsManager"), &manager); - ZEPHIR_CALL_METHOD(NULL, &manager, "initialize", NULL, 0, this_ptr); - zephir_check_call_status(); - zephir_memory_observe(&properties); - if (zephir_array_isset_string_fetch(&properties, &attributes, SL("attributes"), 0)) { - zephir_is_iterable(&properties, 0, "phalcon/Mvc/Model.zep", 2875); - if (Z_TYPE_P(&properties) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&properties), _11$$7, _12$$7, _9$$7) - { - ZEPHIR_INIT_NVAR(&key); - if (_12$$7 != NULL) { - ZVAL_STR_COPY(&key, _12$$7); - } else { - ZVAL_LONG(&key, _11$$7); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _9$$7); - zephir_update_property_zval_zval(this_ptr, &key, &value); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &properties, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_10$$7, &properties, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_10$$7)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &properties, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &properties, "current", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval_zval(this_ptr, &key, &value); - ZEPHIR_CALL_METHOD(NULL, &properties, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - } else { - ZEPHIR_INIT_NVAR(&properties); - array_init(&properties); - } - zephir_memory_observe(&dirtyState); - if (zephir_array_isset_string_fetch(&dirtyState, &attributes, SL("dirtyState"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &dirtyState); - } - ZEPHIR_CALL_METHOD(&_4$$3, &manager, "iskeepingsnapshots", NULL, 0, this_ptr); - zephir_check_call_status(); - if (zephir_is_true(&_4$$3)) { - if (zephir_array_isset_string_fetch(&snapshot, &attributes, SL("snapshot"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("snapshot"), &snapshot); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("snapshot"), &properties); - } - } + zephir_fetch_params(1, 1, 0, &model); + zephir_memory_observe(&relations); + zephir_read_property(&_0, this_ptr, ZEND_STRL("hasOneThroughSingle"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + zephir_get_class(&_1, model, 1); + if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 0))) { + array_init(return_value); + RETURN_MM(); } - ZEPHIR_MM_RESTORE(); + RETURN_CCTOR(&relations); } -static PHP_METHOD(Phalcon_Mvc_Model, setConnectionService) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getLastInitialized) +{ + + RETURN_MEMBER(getThis(), "lastInitialized"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getLastQuery) +{ + + RETURN_MEMBER(getThis(), "lastQuery"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getModelPrefix) +{ + + RETURN_MEMBER(getThis(), "prefix"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getModelSchema) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connectionService_param = NULL, _0; - zval connectionService; + zval *model, model_sub, schema, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connectionService); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&schema); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(connectionService) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &connectionService_param); - if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string")); + zephir_fetch_params(1, 1, 0, &model); + zephir_memory_observe(&schema); + zephir_read_property(&_0, this_ptr, ZEND_STRL("schemas"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + zephir_get_class(&_1, model, 1); + if (!(zephir_array_isset_fetch(&schema, &_0, &_1, 0))) { RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) { - zephir_get_strval(&connectionService, connectionService_param); - } else { - ZEPHIR_INIT_VAR(&connectionService); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "setconnectionservice", NULL, 0, this_ptr, &connectionService); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_CCTOR(&schema); } -static PHP_METHOD(Phalcon_Mvc_Model, setDirtyState) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getModelSource) { - zval *dirtyState_param = NULL, _0; - zend_long dirtyState; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, entityName, _0, _3, _4, _5, _1$$3, _2$$3; zval *this_ptr = getThis(); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&entityName); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(dirtyState) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &dirtyState_param); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, dirtyState); - zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &_0); - RETURN_THISW(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + ZEPHIR_INIT_VAR(&entityName); + zephir_get_class(&entityName, model, 1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("sources"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset(&_0, &entityName))) { + ZEPHIR_INIT_VAR(&_1$$3); + ZEPHIR_INIT_VAR(&_2$$3); + zephir_get_class_ns(&_2$$3, model, 0); + zephir_uncamelize(&_1$$3, &_2$$3, NULL ); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setmodelsource", NULL, 0, model, &_1$$3); + zephir_check_call_status(); + } + zephir_read_property(&_3, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_4, this_ptr, ZEND_STRL("sources"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_5, &_4, &entityName, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1287); + ZEPHIR_CONCAT_VV(return_value, &_3, &_5); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, setEventsManager) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getReadConnection) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *eventsManager, eventsManager_sub, _0; + zval *model, model_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&eventsManager_sub); + ZVAL_UNDEF(&model_sub); ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &eventsManager); - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "setcustomeventsmanager", NULL, 0, this_ptr, eventsManager); + zephir_fetch_params(1, 1, 0, &model); + zephir_read_property(&_0, this_ptr, ZEND_STRL("readConnectionServices"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getconnection", NULL, 0, model, &_0); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, setReadConnectionService) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getReadConnectionService) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connectionService_param = NULL, _0; - zval connectionService; + zval *model, model_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connectionService); + ZVAL_UNDEF(&model_sub); ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(connectionService) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &connectionService_param); - if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string")); + zephir_fetch_params(1, 1, 0, &model); + zephir_read_property(&_0, this_ptr, ZEND_STRL("readConnectionServices"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getconnectionservice", NULL, 0, model, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getRelationByAlias) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *modelName_param = NULL, *alias_param = NULL, relation, _0, _1; + zval modelName, alias, _2; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&alias); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(modelName) + Z_PARAM_STR(alias) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &modelName_param, &alias_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) { - zephir_get_strval(&connectionService, connectionService_param); + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); } else { - ZEPHIR_INIT_VAR(&connectionService); + ZEPHIR_INIT_VAR(&modelName); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "setreadconnectionservice", NULL, 0, this_ptr, &connectionService); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + if (UNEXPECTED(Z_TYPE_P(alias_param) != IS_STRING && Z_TYPE_P(alias_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'alias' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(alias_param) == IS_STRING)) { + zephir_get_strval(&alias, alias_param); + } else { + ZEPHIR_INIT_VAR(&alias); + } + zephir_memory_observe(&relation); + zephir_read_property(&_0, this_ptr, ZEND_STRL("aliases"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_CONCAT_VSV(&_2, &modelName, "$", &alias); + zephir_fast_strtolower(&_1, &_2); + if (!(zephir_array_isset_fetch(&relation, &_0, &_1, 0))) { + RETURN_MM_BOOL(0); + } + RETURN_CCTOR(&relation); } -static PHP_METHOD(Phalcon_Mvc_Model, setOldSnapshotData) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getRelationRecords) { - zend_string *_3$$3; - zend_ulong _2$$3; + zend_string *_20$$11; + zend_ulong _19$$11; + zend_bool reusable = 0, _35$$21; + zval placeholders, conditions, joinConditions, _36, _34$$21; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL; + zephir_fcall_cache_entry *_24 = NULL, *_29 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *data_param = NULL, *columnMap = NULL, columnMap_sub, __$null, key, value, attribute, *_0$$3, _1$$3, _4$$7, _5$$7, _6$$7, _8$$10, _9$$10, _10$$10, _11$$14, _12$$14, _13$$14, _14$$17, _15$$17, _16$$17; - zval data, snapshot; + zval method, retrieveMethod; + zval *relation, relation_sub, *record, record_sub, *parameters = NULL, parameters_sub, *method_param = NULL, __$null, referencedModel, intermediateModel, intermediateFields, fields, builder, extraParameters, refPosition, field, referencedFields, findParams, findArguments, uniqueKey, records, arguments, rows, firstRow, query, _0, _31, _32, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, _7$$3, _11$$3, _8$$6, _9$$6, _10$$6, _12$$8, _13$$8, _14$$10, _15$$10, _16$$11, *_17$$11, _18$$11, _21$$12, _22$$12, _23$$12, _25$$12, _26$$13, _27$$13, _28$$13, _30$$13, _33$$16; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&snapshot); - ZVAL_UNDEF(&columnMap_sub); + ZVAL_UNDEF(&relation_sub); + ZVAL_UNDEF(&record_sub); + ZVAL_UNDEF(¶meters_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&referencedModel); + ZVAL_UNDEF(&intermediateModel); + ZVAL_UNDEF(&intermediateFields); + ZVAL_UNDEF(&fields); + ZVAL_UNDEF(&builder); + ZVAL_UNDEF(&extraParameters); + ZVAL_UNDEF(&refPosition); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&referencedFields); + ZVAL_UNDEF(&findParams); + ZVAL_UNDEF(&findArguments); + ZVAL_UNDEF(&uniqueKey); + ZVAL_UNDEF(&records); + ZVAL_UNDEF(&arguments); + ZVAL_UNDEF(&rows); + ZVAL_UNDEF(&firstRow); + ZVAL_UNDEF(&query); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_31); + ZVAL_UNDEF(&_32); ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_4$$7); - ZVAL_UNDEF(&_5$$7); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_8$$10); - ZVAL_UNDEF(&_9$$10); - ZVAL_UNDEF(&_10$$10); - ZVAL_UNDEF(&_11$$14); - ZVAL_UNDEF(&_12$$14); - ZVAL_UNDEF(&_13$$14); - ZVAL_UNDEF(&_14$$17); - ZVAL_UNDEF(&_15$$17); - ZVAL_UNDEF(&_16$$17); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_11$$3); + ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&_9$$6); + ZVAL_UNDEF(&_10$$6); + ZVAL_UNDEF(&_12$$8); + ZVAL_UNDEF(&_13$$8); + ZVAL_UNDEF(&_14$$10); + ZVAL_UNDEF(&_15$$10); + ZVAL_UNDEF(&_16$$11); + ZVAL_UNDEF(&_18$$11); + ZVAL_UNDEF(&_21$$12); + ZVAL_UNDEF(&_22$$12); + ZVAL_UNDEF(&_23$$12); + ZVAL_UNDEF(&_25$$12); + ZVAL_UNDEF(&_26$$13); + ZVAL_UNDEF(&_27$$13); + ZVAL_UNDEF(&_28$$13); + ZVAL_UNDEF(&_30$$13); + ZVAL_UNDEF(&_33$$16); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&retrieveMethod); + ZVAL_UNDEF(&placeholders); + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(&joinConditions); + ZVAL_UNDEF(&_36); + ZVAL_UNDEF(&_34$$21); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(data) + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_OBJECT_OF_CLASS(relation, phalcon_mvc_model_relationinterface_ce) + Z_PARAM_OBJECT_OF_CLASS(record, phalcon_mvc_modelinterface_ce) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(columnMap) + Z_PARAM_ZVAL_OR_NULL(parameters) + Z_PARAM_STR_OR_NULL(method) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &data_param, &columnMap); - ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); - if (!columnMap) { - columnMap = &columnMap_sub; - columnMap = &__$null; + zephir_fetch_params(1, 2, 2, &relation, &record, ¶meters, &method_param); + if (!parameters) { + parameters = ¶meters_sub; + parameters = &__$null; } - if (Z_TYPE_P(columnMap) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&snapshot); - array_init(&snapshot); - zephir_is_iterable(&data, 0, "phalcon/Mvc/Model.zep", 2993); - if (Z_TYPE_P(&data) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _2$$3, _3$$3, _0$$3) + if (!method_param) { + ZEPHIR_INIT_VAR(&method); + } else { + zephir_get_strval(&method, method_param); + } + ZEPHIR_INIT_VAR(&placeholders); + array_init(&placeholders); + ZEPHIR_CALL_METHOD(&extraParameters, relation, "getparams", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&referencedModel, relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, relation, "isthrough", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + ZEPHIR_INIT_VAR(&conditions); + array_init(&conditions); + ZEPHIR_CALL_METHOD(&intermediateModel, relation, "getintermediatemodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&intermediateFields, relation, "getintermediatefields", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&fields) == IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Not supported", "phalcon/Mvc/Model/Manager.zep", 1384); + return; + } + ZEPHIR_INIT_VAR(&_1$$3); + ZEPHIR_CONCAT_SVSVS(&_1$$3, "[", &intermediateModel, "].[", &intermediateFields, "] = :APR0:"); + zephir_array_append(&conditions, &_1$$3, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1387); + ZEPHIR_CALL_METHOD(&_2$$3, record, "readattribute", NULL, 0, &fields); + zephir_check_call_status(); + zephir_array_update_string(&placeholders, SL("APR0"), &_2$$3, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&joinConditions); + array_init(&joinConditions); + ZEPHIR_CALL_METHOD(&intermediateFields, relation, "getintermediatereferencedfields", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&intermediateFields) == IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Not supported", "phalcon/Mvc/Model/Manager.zep", 1398); + return; + } + ZEPHIR_CALL_METHOD(&_3$$3, relation, "getreferencedfields", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4$$3); + ZEPHIR_CONCAT_SVSVSVSVS(&_4$$3, "[", &intermediateModel, "].[", &intermediateFields, "] = [", &referencedModel, "].[", &_3$$3, "]"); + zephir_array_append(&joinConditions, &_4$$3, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1401); + ZEPHIR_CALL_METHOD(&_5$$3, this_ptr, "mergefindparameters", NULL, 443, &extraParameters, parameters); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&builder, this_ptr, "createbuilder", NULL, 0, &_5$$3); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &builder, "from", NULL, 0, &referencedModel); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_6$$3); + zephir_fast_join_str(&_6$$3, SL(" AND "), &joinConditions); + ZEPHIR_CALL_METHOD(NULL, &builder, "innerjoin", NULL, 0, &intermediateModel, &_6$$3); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_7$$3); + zephir_fast_join_str(&_7$$3, SL(" AND "), &conditions); + ZEPHIR_CALL_METHOD(NULL, &builder, "andwhere", NULL, 0, &_7$$3, &placeholders); + zephir_check_call_status(); + if (ZEPHIR_IS_STRING(&method, "count")) { + ZEPHIR_INIT_VAR(&_8$$6); + ZVAL_STRING(&_8$$6, "COUNT(*) AS rowcount"); + ZEPHIR_CALL_METHOD(NULL, &builder, "columns", NULL, 0, &_8$$6); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_9$$6, &builder, "getquery", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&rows, &_9$$6, "execute", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&firstRow, &rows, "getfirst", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_8$$6); + ZVAL_STRING(&_8$$6, "rowcount"); + ZEPHIR_CALL_METHOD(&_10$$6, &firstRow, "readattribute", NULL, 0, &_8$$6); + zephir_check_call_status(); + RETURN_MM_LONG(zephir_get_intval(&_10$$6)); + } + ZEPHIR_CALL_METHOD(&_11$$3, &builder, "getquery", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&query, &_11$$3); + ZEPHIR_CALL_METHOD(&_11$$3, relation, "gettype", NULL, 0); + zephir_check_call_status(); + do { + if (ZEPHIR_IS_LONG(&_11$$3, 4)) { + ZEPHIR_RETURN_CALL_METHOD(&query, "execute", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); + } + if (ZEPHIR_IS_LONG(&_11$$3, 3)) { + ZVAL_BOOL(&_13$$8, 1); + ZEPHIR_CALL_METHOD(&_12$$8, &query, "setuniquerow", NULL, 0, &_13$$8); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(&_12$$8, "execute", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Unknown relation type", "phalcon/Mvc/Model/Manager.zep", 1446); + return; + } while(0); + + } + ZEPHIR_INIT_NVAR(&conditions); + array_init(&conditions); + ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&referencedFields, relation, "getreferencedfields", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&fields) != IS_ARRAY) { + ZEPHIR_INIT_VAR(&_14$$10); + ZEPHIR_CONCAT_SVS(&_14$$10, "[", &referencedFields, "] = :APR0:"); + zephir_array_append(&conditions, &_14$$10, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1463); + ZEPHIR_CALL_METHOD(&_15$$10, record, "readattribute", NULL, 0, &fields); + zephir_check_call_status(); + zephir_array_update_string(&placeholders, SL("APR0"), &_15$$10, PH_COPY | PH_SEPARATE); + } else { + ZEPHIR_CALL_METHOD(&_16$$11, relation, "getfields", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&_16$$11, 0, "phalcon/Mvc/Model/Manager.zep", 1470); + if (Z_TYPE_P(&_16$$11) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_16$$11), _19$$11, _20$$11, _17$$11) { - ZEPHIR_INIT_NVAR(&key); - if (_3$$3 != NULL) { - ZVAL_STR_COPY(&key, _3$$3); + ZEPHIR_INIT_NVAR(&refPosition); + if (_20$$11 != NULL) { + ZVAL_STR_COPY(&refPosition, _20$$11); } else { - ZVAL_LONG(&key, _2$$3); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0$$3); - if (Z_TYPE_P(&key) != IS_STRING) { - continue; - } - ZEPHIR_OBS_NVAR(&attribute); - if (!(zephir_array_isset_fetch(&attribute, columnMap, &key, 0))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_4$$7); - object_init_ex(&_4$$7, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_5$$7); - zephir_get_class(&_5$$7, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_6$$7); - ZEPHIR_CONCAT_SVSVS(&_6$$7, "Column '", &key, "' doesn't make part of the column map in '", &_5$$7, "'"); - ZEPHIR_CALL_METHOD(NULL, &_4$$7, "__construct", &_7, 33, &_6$$7); - zephir_check_call_status(); - zephir_throw_exception_debug(&_4$$7, "phalcon/Mvc/Model.zep", 2973); - ZEPHIR_MM_RESTORE(); - return; - } - continue; - } - if (Z_TYPE_P(&attribute) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attribute); - if (!(zephir_array_isset_long_fetch(&attribute, &attribute, 0, 0))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_8$$10); - object_init_ex(&_8$$10, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_9$$10); - zephir_get_class(&_9$$10, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_10$$10); - ZEPHIR_CONCAT_SVSVS(&_10$$10, "Column '", &key, "' doesn't make part of the column map in '", &_9$$10, "'"); - ZEPHIR_CALL_METHOD(NULL, &_8$$10, "__construct", &_7, 33, &_10$$10); - zephir_check_call_status(); - zephir_throw_exception_debug(&_8$$10, "phalcon/Mvc/Model.zep", 2984); - ZEPHIR_MM_RESTORE(); - return; - } - continue; - } + ZVAL_LONG(&refPosition, _19$$11); } - zephir_array_update_zval(&snapshot, &attribute, &value, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _17$$11); + zephir_array_fetch(&_21$$12, &referencedFields, &refPosition, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1467); + ZEPHIR_INIT_NVAR(&_22$$12); + ZEPHIR_CONCAT_SVSVS(&_22$$12, "[", &_21$$12, "] = :APR", &refPosition, ":"); + zephir_array_append(&conditions, &_22$$12, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1467); + ZEPHIR_CALL_METHOD(&_23$$12, record, "readattribute", &_24, 0, &field); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_25$$12); + ZEPHIR_CONCAT_SV(&_25$$12, "APR", &refPosition); + zephir_array_update_zval(&placeholders, &_25$$12, &_23$$12, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &_16$$11, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_1$$3, &data, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_18$$11, &_16$$11, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_1$$3)) { + if (!zend_is_true(&_18$$11)) { break; } - ZEPHIR_CALL_METHOD(&key, &data, "key", NULL, 0); + ZEPHIR_CALL_METHOD(&refPosition, &_16$$11, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&field, &_16$$11, "current", NULL, 0); zephir_check_call_status(); - if (Z_TYPE_P(&key) != IS_STRING) { - continue; - } - ZEPHIR_OBS_NVAR(&attribute); - if (!(zephir_array_isset_fetch(&attribute, columnMap, &key, 0))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_11$$14); - object_init_ex(&_11$$14, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_12$$14); - zephir_get_class(&_12$$14, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_13$$14); - ZEPHIR_CONCAT_SVSVS(&_13$$14, "Column '", &key, "' doesn't make part of the column map in '", &_12$$14, "'"); - ZEPHIR_CALL_METHOD(NULL, &_11$$14, "__construct", &_7, 33, &_13$$14); - zephir_check_call_status(); - zephir_throw_exception_debug(&_11$$14, "phalcon/Mvc/Model.zep", 2973); - ZEPHIR_MM_RESTORE(); - return; - } - continue; - } - if (Z_TYPE_P(&attribute) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attribute); - if (!(zephir_array_isset_long_fetch(&attribute, &attribute, 0, 0))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_14$$17); - object_init_ex(&_14$$17, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_15$$17); - zephir_get_class(&_15$$17, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_16$$17); - ZEPHIR_CONCAT_SVSVS(&_16$$17, "Column '", &key, "' doesn't make part of the column map in '", &_15$$17, "'"); - ZEPHIR_CALL_METHOD(NULL, &_14$$17, "__construct", &_7, 33, &_16$$17); - zephir_check_call_status(); - zephir_throw_exception_debug(&_14$$17, "phalcon/Mvc/Model.zep", 2984); - ZEPHIR_MM_RESTORE(); - return; - } - continue; - } - } - zephir_array_update_zval(&snapshot, &attribute, &value, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); + zephir_array_fetch(&_26$$13, &referencedFields, &refPosition, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1467); + ZEPHIR_INIT_NVAR(&_27$$13); + ZEPHIR_CONCAT_SVSVS(&_27$$13, "[", &_26$$13, "] = :APR", &refPosition, ":"); + zephir_array_append(&conditions, &_27$$13, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1467); + ZEPHIR_CALL_METHOD(&_28$$13, record, "readattribute", &_29, 0, &field); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_30$$13); + ZEPHIR_CONCAT_SV(&_30$$13, "APR", &refPosition); + zephir_array_update_zval(&placeholders, &_30$$13, &_28$$13, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &_16$$11, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); + ZEPHIR_INIT_NVAR(&field); + ZEPHIR_INIT_NVAR(&refPosition); + } + ZEPHIR_INIT_VAR(&findParams); + zephir_create_array(&findParams, 3, 0); + ZEPHIR_INIT_VAR(&_31); + zephir_fast_join_str(&_31, SL(" AND "), &conditions); + zephir_array_fast_append(&findParams, &_31); + zephir_array_update_string(&findParams, SL("bind"), &placeholders, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_32, record, "getdi", NULL, 0); + zephir_check_call_status(); + zephir_array_update_string(&findParams, SL("di"), &_32, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&findArguments, this_ptr, "mergefindparameters", NULL, 443, &findParams, parameters); + zephir_check_call_status(); + if (Z_TYPE_P(&extraParameters) == IS_ARRAY) { + ZEPHIR_CALL_METHOD(&findParams, this_ptr, "mergefindparameters", NULL, 443, &extraParameters, &findArguments); + zephir_check_call_status(); } else { - ZEPHIR_CPY_WRT(&snapshot, &data); + ZEPHIR_CPY_WRT(&findParams, &findArguments); } - zephir_update_property_zval(this_ptr, ZEND_STRL("oldSnapshot"), &snapshot); - ZEPHIR_MM_RESTORE(); + if (ZEPHIR_IS_NULL(&method)) { + ZEPHIR_CALL_METHOD(&_33$$16, relation, "gettype", NULL, 0); + zephir_check_call_status(); + do { + if (ZEPHIR_IS_LONG(&_33$$16, 0) || ZEPHIR_IS_LONG(&_33$$16, 1)) { + ZEPHIR_INIT_VAR(&retrieveMethod); + ZVAL_STRING(&retrieveMethod, "findFirst"); + break; + } + if (ZEPHIR_IS_LONG(&_33$$16, 2)) { + ZEPHIR_INIT_NVAR(&retrieveMethod); + ZVAL_STRING(&retrieveMethod, "find"); + break; + } + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Unknown relation type", "phalcon/Mvc/Model/Manager.zep", 1508); + return; + } while(0); + + } else { + ZEPHIR_CPY_WRT(&retrieveMethod, &method); + } + ZEPHIR_CALL_METHOD(&_32, relation, "isreusable", NULL, 0); + zephir_check_call_status(); + reusable = zephir_get_boolval(&_32); + if (reusable) { + ZEPHIR_INIT_VAR(&_34$$21); + zephir_create_array(&_34$$21, 2, 0); + zephir_array_fast_append(&_34$$21, &findParams); + zephir_array_fast_append(&_34$$21, &retrieveMethod); + ZEPHIR_INIT_VAR(&uniqueKey); + zephir_unique_key(&uniqueKey, &referencedModel, &_34$$21); + ZEPHIR_CALL_METHOD(&records, this_ptr, "getreusablerecords", NULL, 0, &referencedModel, &uniqueKey); + zephir_check_call_status(); + _35$$21 = Z_TYPE_P(&records) == IS_ARRAY; + if (!(_35$$21)) { + _35$$21 = Z_TYPE_P(&records) == IS_OBJECT; + } + if (_35$$21) { + RETURN_CCTOR(&records); + } + } + ZEPHIR_INIT_VAR(&arguments); + zephir_create_array(&arguments, 1, 0); + zephir_array_fast_append(&arguments, &findParams); + ZEPHIR_INIT_VAR(&_36); + zephir_create_array(&_36, 2, 0); + ZEPHIR_CALL_METHOD(&_32, this_ptr, "load", NULL, 0, &referencedModel); + zephir_check_call_status(); + zephir_array_fast_append(&_36, &_32); + zephir_array_fast_append(&_36, &retrieveMethod); + ZEPHIR_INIT_NVAR(&records); + ZEPHIR_CALL_USER_FUNC_ARRAY(&records, &_36, &arguments); + zephir_check_call_status(); + if (reusable) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setreusablerecords", NULL, 0, &referencedModel, &uniqueKey, &records); + zephir_check_call_status(); + } + RETURN_CCTOR(&records); } -static PHP_METHOD(Phalcon_Mvc_Model, setSnapshotData) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getRelations) { - zend_bool _4$$4, _14$$12; - zend_string *_3$$3; - zend_ulong _2$$3; + zval allRelations; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_6 = NULL, *_10 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *data_param = NULL, *columnMap = NULL, columnMap_sub, __$null, key, value, attribute, *_0$$3, _1$$3, _5$$6, _7$$8, _8$$8, _9$$8, _11$$11, _12$$11, _13$$11, _15$$14, _16$$16, _17$$16, _18$$16, _19$$19, _20$$19, _21$$19; - zval data, snapshot; + zval *modelName_param = NULL, entityName, relations, relation, _0, _3, _6, _9, _12, *_1$$3, _2$$3, *_4$$6, _5$$6, *_7$$9, _8$$9, *_10$$12, _11$$12, *_13$$15, _14$$15; + zval modelName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&snapshot); - ZVAL_UNDEF(&columnMap_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&entityName); + ZVAL_UNDEF(&relations); + ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_7$$8); - ZVAL_UNDEF(&_8$$8); - ZVAL_UNDEF(&_9$$8); - ZVAL_UNDEF(&_11$$11); - ZVAL_UNDEF(&_12$$11); - ZVAL_UNDEF(&_13$$11); - ZVAL_UNDEF(&_15$$14); - ZVAL_UNDEF(&_16$$16); - ZVAL_UNDEF(&_17$$16); - ZVAL_UNDEF(&_18$$16); - ZVAL_UNDEF(&_19$$19); - ZVAL_UNDEF(&_20$$19); - ZVAL_UNDEF(&_21$$19); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(data) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(columnMap) + ZVAL_UNDEF(&_8$$9); + ZVAL_UNDEF(&_11$$12); + ZVAL_UNDEF(&_14$$15); + ZVAL_UNDEF(&allRelations); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(modelName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &data_param, &columnMap); - ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); - if (!columnMap) { - columnMap = &columnMap_sub; - columnMap = &__$null; + zephir_fetch_params(1, 1, 0, &modelName_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + RETURN_MM_NULL(); } - if (Z_TYPE_P(columnMap) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&snapshot); - array_init(&snapshot); - zephir_is_iterable(&data, 0, "phalcon/Mvc/Model.zep", 3058); - if (Z_TYPE_P(&data) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _2$$3, _3$$3, _0$$3) + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); + } else { + ZEPHIR_INIT_VAR(&modelName); + } + ZEPHIR_INIT_VAR(&entityName); + zephir_fast_strtolower(&entityName, &modelName); + ZEPHIR_INIT_VAR(&allRelations); + array_init(&allRelations); + zephir_memory_observe(&relations); + zephir_read_property(&_0, this_ptr, ZEND_STRL("belongsToSingle"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&relations, &_0, &entityName, 0)) { + zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model/Manager.zep", 1574); + if (Z_TYPE_P(&relations) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _1$$3) { - ZEPHIR_INIT_NVAR(&key); - if (_3$$3 != NULL) { - ZVAL_STR_COPY(&key, _3$$3); - } else { - ZVAL_LONG(&key, _2$$3); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0$$3); - if (Z_TYPE_P(&key) != IS_STRING) { - continue; - } - _4$$4 = !(zephir_array_isset(columnMap, &key)); - if (_4$$4) { - _4$$4 = ZEPHIR_GLOBAL(orm).case_insensitive_column_map; - } - if (_4$$4) { - ZEPHIR_CALL_SELF(&_5$$6, "caseinsensitivecolumnmap", &_6, 420, columnMap, &key); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&key, &_5$$6); + ZEPHIR_INIT_NVAR(&relation); + ZVAL_COPY(&relation, _1$$3); + zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1572); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2$$3, &relations, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2$$3)) { + break; } - ZEPHIR_OBS_NVAR(&attribute); - if (!(zephir_array_isset_fetch(&attribute, columnMap, &key, 0))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_7$$8); - object_init_ex(&_7$$8, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_8$$8); - zephir_get_class(&_8$$8, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_9$$8); - ZEPHIR_CONCAT_SVSVS(&_9$$8, "Column '", &key, "' doesn't make part of the column map in '", &_8$$8, "'"); - ZEPHIR_CALL_METHOD(NULL, &_7$$8, "__construct", &_10, 33, &_9$$8); - zephir_check_call_status(); - zephir_throw_exception_debug(&_7$$8, "phalcon/Mvc/Model.zep", 3038); - ZEPHIR_MM_RESTORE(); - return; - } - continue; + ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1572); + ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&relation); + } + ZEPHIR_OBS_NVAR(&relations); + zephir_read_property(&_3, this_ptr, ZEND_STRL("hasManySingle"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&relations, &_3, &entityName, 0)) { + zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model/Manager.zep", 1583); + if (Z_TYPE_P(&relations) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _4$$6) + { + ZEPHIR_INIT_NVAR(&relation); + ZVAL_COPY(&relation, _4$$6); + zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1581); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5$$6, &relations, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5$$6)) { + break; } - if (Z_TYPE_P(&attribute) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attribute); - if (!(zephir_array_isset_long_fetch(&attribute, &attribute, 0, 0))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_11$$11); - object_init_ex(&_11$$11, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_12$$11); - zephir_get_class(&_12$$11, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_13$$11); - ZEPHIR_CONCAT_SVSVS(&_13$$11, "Column '", &key, "' doesn't make part of the column map in '", &_12$$11, "'"); - ZEPHIR_CALL_METHOD(NULL, &_11$$11, "__construct", &_10, 33, &_13$$11); - zephir_check_call_status(); - zephir_throw_exception_debug(&_11$$11, "phalcon/Mvc/Model.zep", 3049); - ZEPHIR_MM_RESTORE(); - return; - } - continue; - } + ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1581); + ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&relation); + } + ZEPHIR_OBS_NVAR(&relations); + zephir_read_property(&_6, this_ptr, ZEND_STRL("hasOneSingle"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&relations, &_6, &entityName, 0)) { + zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model/Manager.zep", 1592); + if (Z_TYPE_P(&relations) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _7$$9) + { + ZEPHIR_INIT_NVAR(&relation); + ZVAL_COPY(&relation, _7$$9); + zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1590); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_8$$9, &relations, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_8$$9)) { + break; } - zephir_array_update_zval(&snapshot, &attribute, &value, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1590); + ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&relation); + } + ZEPHIR_OBS_NVAR(&relations); + zephir_read_property(&_9, this_ptr, ZEND_STRL("hasOneThroughSingle"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&relations, &_9, &entityName, 0)) { + zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model/Manager.zep", 1601); + if (Z_TYPE_P(&relations) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _10$$12) + { + ZEPHIR_INIT_NVAR(&relation); + ZVAL_COPY(&relation, _10$$12); + zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1599); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_1$$3, &data, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_11$$12, &relations, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_1$$3)) { + if (!zend_is_true(&_11$$12)) { break; } - ZEPHIR_CALL_METHOD(&key, &data, "key", NULL, 0); + ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); + zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1599); + ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0); zephir_check_call_status(); - if (Z_TYPE_P(&key) != IS_STRING) { - continue; - } - _14$$12 = !(zephir_array_isset(columnMap, &key)); - if (_14$$12) { - _14$$12 = ZEPHIR_GLOBAL(orm).case_insensitive_column_map; - } - if (_14$$12) { - ZEPHIR_CALL_SELF(&_15$$14, "caseinsensitivecolumnmap", &_6, 420, columnMap, &key); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&key, &_15$$14); - } - ZEPHIR_OBS_NVAR(&attribute); - if (!(zephir_array_isset_fetch(&attribute, columnMap, &key, 0))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_16$$16); - object_init_ex(&_16$$16, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_17$$16); - zephir_get_class(&_17$$16, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_18$$16); - ZEPHIR_CONCAT_SVSVS(&_18$$16, "Column '", &key, "' doesn't make part of the column map in '", &_17$$16, "'"); - ZEPHIR_CALL_METHOD(NULL, &_16$$16, "__construct", &_10, 33, &_18$$16); - zephir_check_call_status(); - zephir_throw_exception_debug(&_16$$16, "phalcon/Mvc/Model.zep", 3038); - ZEPHIR_MM_RESTORE(); - return; - } - continue; - } - if (Z_TYPE_P(&attribute) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attribute); - if (!(zephir_array_isset_long_fetch(&attribute, &attribute, 0, 0))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_19$$19); - object_init_ex(&_19$$19, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_20$$19); - zephir_get_class(&_20$$19, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_21$$19); - ZEPHIR_CONCAT_SVSVS(&_21$$19, "Column '", &key, "' doesn't make part of the column map in '", &_20$$19, "'"); - ZEPHIR_CALL_METHOD(NULL, &_19$$19, "__construct", &_10, 33, &_21$$19); - zephir_check_call_status(); - zephir_throw_exception_debug(&_19$$19, "phalcon/Mvc/Model.zep", 3049); - ZEPHIR_MM_RESTORE(); - return; - } - continue; - } - } - zephir_array_update_zval(&snapshot, &attribute, &value, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); + } + } + ZEPHIR_INIT_NVAR(&relation); + } + ZEPHIR_OBS_NVAR(&relations); + zephir_read_property(&_12, this_ptr, ZEND_STRL("hasManyToManySingle"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&relations, &_12, &entityName, 0)) { + zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model/Manager.zep", 1610); + if (Z_TYPE_P(&relations) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _13$$15) + { + ZEPHIR_INIT_NVAR(&relation); + ZVAL_COPY(&relation, _13$$15); + zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1608); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_14$$15, &relations, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_14$$15)) { + break; + } + ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_append(&allRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 1608); + ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - } else { - ZEPHIR_CPY_WRT(&snapshot, &data); + ZEPHIR_INIT_NVAR(&relation); } - zephir_update_property_zval(this_ptr, ZEND_STRL("snapshot"), &snapshot); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model, setTransaction) -{ - zval *transaction, transaction_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&transaction_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(transaction, phalcon_mvc_model_transactioninterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &transaction); - zephir_update_property_zval(this_ptr, ZEND_STRL("transaction"), transaction); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_Model, getTransaction) -{ - - RETURN_MEMBER(getThis(), "transaction"); + RETURN_CTOR(&allRelations); } -static PHP_METHOD(Phalcon_Mvc_Model, setup) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getRelationsBetween) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *options_param = NULL, disableEvents, columnRenaming, notNullValidations, exceptionOnFailedSave, exceptionOnFailedMetaDataSave, phqlLiterals, virtualForeignKeys, lateStateBinding, castOnHydrate, ignoreUnknownColumns, updateSnapshotOnSave, disableAssignSetters, caseInsensitiveColumnMap, prefetchRecords, lastInsertId; - zval options; + zval *first_param = NULL, *second_param = NULL, relations, _0, _1, _2, _3, _4, _5, _6, _7; + zval first, second, keyRelation; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&disableEvents); - ZVAL_UNDEF(&columnRenaming); - ZVAL_UNDEF(¬NullValidations); - ZVAL_UNDEF(&exceptionOnFailedSave); - ZVAL_UNDEF(&exceptionOnFailedMetaDataSave); - ZVAL_UNDEF(&phqlLiterals); - ZVAL_UNDEF(&virtualForeignKeys); - ZVAL_UNDEF(&lateStateBinding); - ZVAL_UNDEF(&castOnHydrate); - ZVAL_UNDEF(&ignoreUnknownColumns); - ZVAL_UNDEF(&updateSnapshotOnSave); - ZVAL_UNDEF(&disableAssignSetters); - ZVAL_UNDEF(&caseInsensitiveColumnMap); - ZVAL_UNDEF(&prefetchRecords); - ZVAL_UNDEF(&lastInsertId); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(options) + ZVAL_UNDEF(&first); + ZVAL_UNDEF(&second); + ZVAL_UNDEF(&keyRelation); + ZVAL_UNDEF(&relations); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(first) + Z_PARAM_STR(second) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &options_param); - ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); - zephir_memory_observe(&disableEvents); - if (zephir_array_isset_string_fetch(&disableEvents, &options, SL("events"), 0)) { - ZEPHIR_GLOBAL(orm).events = zend_is_true(&disableEvents); - } - zephir_memory_observe(&virtualForeignKeys); - if (zephir_array_isset_string_fetch(&virtualForeignKeys, &options, SL("virtualForeignKeys"), 0)) { - ZEPHIR_GLOBAL(orm).virtual_foreign_keys = zend_is_true(&virtualForeignKeys); + zephir_fetch_params(1, 2, 0, &first_param, &second_param); + if (UNEXPECTED(Z_TYPE_P(first_param) != IS_STRING && Z_TYPE_P(first_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'first' must be of the type string")); + RETURN_MM_NULL(); } - zephir_memory_observe(&columnRenaming); - if (zephir_array_isset_string_fetch(&columnRenaming, &options, SL("columnRenaming"), 0)) { - ZEPHIR_GLOBAL(orm).column_renaming = zend_is_true(&columnRenaming); + if (EXPECTED(Z_TYPE_P(first_param) == IS_STRING)) { + zephir_get_strval(&first, first_param); + } else { + ZEPHIR_INIT_VAR(&first); } - zephir_memory_observe(¬NullValidations); - if (zephir_array_isset_string_fetch(¬NullValidations, &options, SL("notNullValidations"), 0)) { - ZEPHIR_GLOBAL(orm).not_null_validations = zend_is_true(¬NullValidations); + if (UNEXPECTED(Z_TYPE_P(second_param) != IS_STRING && Z_TYPE_P(second_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'second' must be of the type string")); + RETURN_MM_NULL(); } - zephir_memory_observe(&exceptionOnFailedSave); - if (zephir_array_isset_string_fetch(&exceptionOnFailedSave, &options, SL("exceptionOnFailedSave"), 0)) { - ZEPHIR_GLOBAL(orm).exception_on_failed_save = zend_is_true(&exceptionOnFailedSave); + if (EXPECTED(Z_TYPE_P(second_param) == IS_STRING)) { + zephir_get_strval(&second, second_param); + } else { + ZEPHIR_INIT_VAR(&second); } - zephir_memory_observe(&exceptionOnFailedMetaDataSave); - if (zephir_array_isset_string_fetch(&exceptionOnFailedMetaDataSave, &options, SL("exceptionOnFailedMetaDataSave"), 0)) { - ZEPHIR_GLOBAL(orm).exception_on_failed_metadata_save = zend_is_true(&exceptionOnFailedMetaDataSave); + ZEPHIR_INIT_VAR(&_0); + zephir_fast_strtolower(&_0, &first); + ZEPHIR_INIT_VAR(&_1); + zephir_fast_strtolower(&_1, &second); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_CONCAT_VSV(&_2, &_0, "$", &_1); + zephir_get_strval(&keyRelation, &_2); + zephir_memory_observe(&relations); + zephir_read_property(&_3, this_ptr, ZEND_STRL("belongsTo"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&relations, &_3, &keyRelation, 0)) { + RETURN_CCTOR(&relations); } - zephir_memory_observe(&phqlLiterals); - if (zephir_array_isset_string_fetch(&phqlLiterals, &options, SL("phqlLiterals"), 0)) { - ZEPHIR_GLOBAL(orm).enable_literals = zend_is_true(&phqlLiterals); + ZEPHIR_OBS_NVAR(&relations); + zephir_read_property(&_4, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&relations, &_4, &keyRelation, 0)) { + RETURN_CCTOR(&relations); } - zephir_memory_observe(&lateStateBinding); - if (zephir_array_isset_string_fetch(&lateStateBinding, &options, SL("lateStateBinding"), 0)) { - ZEPHIR_GLOBAL(orm).late_state_binding = zend_is_true(&lateStateBinding); + ZEPHIR_OBS_NVAR(&relations); + zephir_read_property(&_5, this_ptr, ZEND_STRL("hasOne"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&relations, &_5, &keyRelation, 0)) { + RETURN_CCTOR(&relations); } - zephir_memory_observe(&castOnHydrate); - if (zephir_array_isset_string_fetch(&castOnHydrate, &options, SL("castOnHydrate"), 0)) { - ZEPHIR_GLOBAL(orm).cast_on_hydrate = zend_is_true(&castOnHydrate); + ZEPHIR_OBS_NVAR(&relations); + zephir_read_property(&_6, this_ptr, ZEND_STRL("hasOneThrough"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&relations, &_6, &keyRelation, 0)) { + RETURN_CCTOR(&relations); } - zephir_memory_observe(&ignoreUnknownColumns); - if (zephir_array_isset_string_fetch(&ignoreUnknownColumns, &options, SL("ignoreUnknownColumns"), 0)) { - ZEPHIR_GLOBAL(orm).ignore_unknown_columns = zend_is_true(&ignoreUnknownColumns); + ZEPHIR_OBS_NVAR(&relations); + zephir_read_property(&_7, this_ptr, ZEND_STRL("hasManyToMany"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&relations, &_7, &keyRelation, 0)) { + RETURN_CCTOR(&relations); } - zephir_memory_observe(&caseInsensitiveColumnMap); - if (zephir_array_isset_string_fetch(&caseInsensitiveColumnMap, &options, SL("caseInsensitiveColumnMap"), 0)) { - ZEPHIR_GLOBAL(orm).case_insensitive_column_map = zend_is_true(&caseInsensitiveColumnMap); + RETURN_MM_BOOL(0); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getReusableRecords) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *modelName_param = NULL, *key_param = NULL, records, _0; + zval modelName, key; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&records); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(modelName) + Z_PARAM_STR(key) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &modelName_param, &key_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + RETURN_MM_NULL(); } - zephir_memory_observe(&updateSnapshotOnSave); - if (zephir_array_isset_string_fetch(&updateSnapshotOnSave, &options, SL("updateSnapshotOnSave"), 0)) { - ZEPHIR_GLOBAL(orm).update_snapshot_on_save = zend_is_true(&updateSnapshotOnSave); + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); + } else { + ZEPHIR_INIT_VAR(&modelName); } - zephir_memory_observe(&disableAssignSetters); - if (zephir_array_isset_string_fetch(&disableAssignSetters, &options, SL("disableAssignSetters"), 0)) { - ZEPHIR_GLOBAL(orm).disable_assign_setters = zend_is_true(&disableAssignSetters); + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + RETURN_MM_NULL(); } - zephir_memory_observe(&prefetchRecords); - if (zephir_array_isset_string_fetch(&prefetchRecords, &options, SL("prefetchRecords"), 0)) { - ZEPHIR_GLOBAL(orm).resultset_prefetch_records = ZSTR_VAL(zval_get_string(&prefetchRecords)); + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); + } else { + ZEPHIR_INIT_VAR(&key); } - zephir_memory_observe(&lastInsertId); - if (zephir_array_isset_string_fetch(&lastInsertId, &options, SL("castLastInsertIdToInt"), 0)) { - ZEPHIR_GLOBAL(orm).cast_last_insert_id_to_int = zend_is_true(&lastInsertId); + zephir_memory_observe(&records); + zephir_read_property(&_0, this_ptr, ZEND_STRL("reusable"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&records, &_0, &key, 0))) { + RETURN_MM_NULL(); } - ZEPHIR_MM_RESTORE(); + RETURN_CCTOR(&records); } -static PHP_METHOD(Phalcon_Mvc_Model, setWriteConnectionService) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getWriteConnection) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connectionService_param = NULL, _0; - zval connectionService; + zval *model, model_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connectionService); + ZVAL_UNDEF(&model_sub); ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(connectionService) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &connectionService_param); - if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) { - zephir_get_strval(&connectionService, connectionService_param); - } else { - ZEPHIR_INIT_VAR(&connectionService); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "setwriteconnectionservice", NULL, 0, this_ptr, &connectionService); + zephir_fetch_params(1, 1, 0, &model); + zephir_read_property(&_0, this_ptr, ZEND_STRL("writeConnectionServices"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getconnection", NULL, 0, model, &_0); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, skipOperation) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getWriteConnectionService) { - zval *skip_param = NULL, __$true, __$false; - zend_bool skip; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, _0; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(skip) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &skip_param); - if (skip) { - zephir_update_property_zval(this_ptr, ZEND_STRL("skipped"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("skipped"), &__$false); - } + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + zephir_read_property(&_0, this_ptr, ZEND_STRL("writeConnectionServices"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getconnectionservice", NULL, 0, model, &_0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, sum) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, hasBelongsTo) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *parameters = NULL, parameters_sub, __$null, _0, _1; + zval *modelName_param = NULL, *modelRelation_param = NULL, _0; + zval modelName, modelRelation; + zval *this_ptr = getThis(); - ZVAL_UNDEF(¶meters_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&modelRelation); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(parameters) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(modelName) + Z_PARAM_STR(modelRelation) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, ¶meters); - if (!parameters) { - parameters = ¶meters_sub; - parameters = &__$null; + zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); + } else { + ZEPHIR_INIT_VAR(&modelName); + } + if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { + zephir_get_strval(&modelRelation, modelRelation_param); + } else { + ZEPHIR_INIT_VAR(&modelRelation); } ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "SUM"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "sumatory"); - ZEPHIR_RETURN_CALL_SELF("groupresult", NULL, 0, &_0, &_1, parameters); + ZVAL_STRING(&_0, "belongsTo"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checkhasrelationship", NULL, 444, &_0, &modelName, &modelRelation); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, toArray) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, hasHasMany) { - zend_bool _3$$4, _11$$3, _13$$3, _16$$15, _22$$14, _24$$14; - zval data; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL, *_9 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *columns = NULL, columns_sub, *useGetter = NULL, useGetter_sub, __$null, __$true, attribute, attributeField, columnMap, metaData, method, _0, *_1, _2, _4$$5, _6$$7, _7$$7, _8$$7, _10$$3, _12$$3, _14$$11, _15$$12, _17$$16, _18$$18, _19$$18, _20$$18, _21$$14, _23$$14, _25$$22, _26$$23; + zval *modelName_param = NULL, *modelRelation_param = NULL, _0; + zval modelName, modelRelation; zval *this_ptr = getThis(); - ZVAL_UNDEF(&columns_sub); - ZVAL_UNDEF(&useGetter_sub); - ZVAL_NULL(&__$null); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&attributeField); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&method); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&modelRelation); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_7$$7); - ZVAL_UNDEF(&_8$$7); - ZVAL_UNDEF(&_10$$3); - ZVAL_UNDEF(&_12$$3); - ZVAL_UNDEF(&_14$$11); - ZVAL_UNDEF(&_15$$12); - ZVAL_UNDEF(&_17$$16); - ZVAL_UNDEF(&_18$$18); - ZVAL_UNDEF(&_19$$18); - ZVAL_UNDEF(&_20$$18); - ZVAL_UNDEF(&_21$$14); - ZVAL_UNDEF(&_23$$14); - ZVAL_UNDEF(&_25$$22); - ZVAL_UNDEF(&_26$$23); - ZVAL_UNDEF(&data); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(columns) - Z_PARAM_ZVAL(useGetter) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(modelName) + Z_PARAM_STR(modelRelation) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &columns, &useGetter); - if (!columns) { - columns = &columns_sub; - columns = &__$null; + zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + RETURN_MM_NULL(); } - if (!useGetter) { - useGetter = &useGetter_sub; - useGetter = &__$true; + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); + } else { + ZEPHIR_INIT_VAR(&modelName); } - ZEPHIR_INIT_VAR(&data); - array_init(&data); - ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", NULL, 0, this_ptr); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, &metaData, "getattributes", NULL, 0, this_ptr); - zephir_check_call_status(); - zephir_is_iterable(&_0, 0, "phalcon/Mvc/Model.zep", 3345); - if (Z_TYPE_P(&_0) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) - { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _1); - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - _3$$4 = !(zephir_array_isset(&columnMap, &attribute)); - if (_3$$4) { - _3$$4 = ZEPHIR_GLOBAL(orm).case_insensitive_column_map; - } - if (_3$$4) { - ZEPHIR_CALL_SELF(&_4$$5, "caseinsensitivecolumnmap", &_5, 420, &columnMap, &attribute); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&attribute, &_4$$5); - } - ZEPHIR_OBS_NVAR(&attributeField); - if (!(zephir_array_isset_fetch(&attributeField, &columnMap, &attribute, 0))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_6$$7); - object_init_ex(&_6$$7, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_7$$7); - zephir_get_class(&_7$$7, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_8$$7); - ZEPHIR_CONCAT_SVSVS(&_8$$7, "Column '", &attribute, "' doesn't make part of the column map in '", &_7$$7, "'"); - ZEPHIR_CALL_METHOD(NULL, &_6$$7, "__construct", &_9, 33, &_8$$7); - zephir_check_call_status(); - zephir_throw_exception_debug(&_6$$7, "phalcon/Mvc/Model.zep", 3313); - ZEPHIR_MM_RESTORE(); - return; - } - continue; - } - } else { - ZEPHIR_CPY_WRT(&attributeField, &attribute); - } - if (Z_TYPE_P(columns) == IS_ARRAY) { - if (!(zephir_fast_in_array(&attributeField, columns))) { - continue; - } - } - ZEPHIR_INIT_NVAR(&_10$$3); - zephir_camelize(&_10$$3, &attributeField, NULL ); - ZEPHIR_INIT_NVAR(&method); - ZEPHIR_CONCAT_SV(&method, "get", &_10$$3); - _11$$3 = ZEPHIR_IS_TRUE_IDENTICAL(useGetter); - if (_11$$3) { - ZEPHIR_INIT_NVAR(&_12$$3); - ZVAL_STRING(&_12$$3, "getSource"); - _11$$3 = !ZEPHIR_IS_IDENTICAL(&_12$$3, &method); - } - _13$$3 = _11$$3; - if (_13$$3) { - _13$$3 = (zephir_method_exists(this_ptr, &method) == SUCCESS); - } - if (_13$$3) { - ZEPHIR_CALL_METHOD_ZVAL(&_14$$11, this_ptr, &method, NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&data, &attributeField, &_14$$11, PH_COPY | PH_SEPARATE); - } else if (zephir_isset_property_zval(this_ptr, &attributeField)) { - ZEPHIR_OBS_NVAR(&_15$$12); - zephir_read_property_zval(&_15$$12, this_ptr, &attributeField, PH_NOISY_CC); - zephir_array_update_zval(&data, &attributeField, &_15$$12, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&data, &attributeField, &__$null, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); + if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { + zephir_get_strval(&modelRelation, modelRelation_param); } else { - ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&attribute, &_0, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - _16$$15 = !(zephir_array_isset(&columnMap, &attribute)); - if (_16$$15) { - _16$$15 = ZEPHIR_GLOBAL(orm).case_insensitive_column_map; - } - if (_16$$15) { - ZEPHIR_CALL_SELF(&_17$$16, "caseinsensitivecolumnmap", &_5, 420, &columnMap, &attribute); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&attribute, &_17$$16); - } - ZEPHIR_OBS_NVAR(&attributeField); - if (!(zephir_array_isset_fetch(&attributeField, &columnMap, &attribute, 0))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_18$$18); - object_init_ex(&_18$$18, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_19$$18); - zephir_get_class(&_19$$18, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_20$$18); - ZEPHIR_CONCAT_SVSVS(&_20$$18, "Column '", &attribute, "' doesn't make part of the column map in '", &_19$$18, "'"); - ZEPHIR_CALL_METHOD(NULL, &_18$$18, "__construct", &_9, 33, &_20$$18); - zephir_check_call_status(); - zephir_throw_exception_debug(&_18$$18, "phalcon/Mvc/Model.zep", 3313); - ZEPHIR_MM_RESTORE(); - return; - } - continue; - } - } else { - ZEPHIR_CPY_WRT(&attributeField, &attribute); - } - if (Z_TYPE_P(columns) == IS_ARRAY) { - if (!(zephir_fast_in_array(&attributeField, columns))) { - continue; - } - } - ZEPHIR_INIT_NVAR(&_21$$14); - zephir_camelize(&_21$$14, &attributeField, NULL ); - ZEPHIR_INIT_NVAR(&method); - ZEPHIR_CONCAT_SV(&method, "get", &_21$$14); - _22$$14 = ZEPHIR_IS_TRUE_IDENTICAL(useGetter); - if (_22$$14) { - ZEPHIR_INIT_NVAR(&_23$$14); - ZVAL_STRING(&_23$$14, "getSource"); - _22$$14 = !ZEPHIR_IS_IDENTICAL(&_23$$14, &method); - } - _24$$14 = _22$$14; - if (_24$$14) { - _24$$14 = (zephir_method_exists(this_ptr, &method) == SUCCESS); - } - if (_24$$14) { - ZEPHIR_CALL_METHOD_ZVAL(&_25$$22, this_ptr, &method, NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&data, &attributeField, &_25$$22, PH_COPY | PH_SEPARATE); - } else if (zephir_isset_property_zval(this_ptr, &attributeField)) { - ZEPHIR_OBS_NVAR(&_26$$23); - zephir_read_property_zval(&_26$$23, this_ptr, &attributeField, PH_NOISY_CC); - zephir_array_update_zval(&data, &attributeField, &_26$$23, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&data, &attributeField, &__$null, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&modelRelation); } - ZEPHIR_INIT_NVAR(&attribute); - RETURN_CTOR(&data); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "hasMany"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checkhasrelationship", NULL, 444, &_0, &modelName, &modelRelation); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, update) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, hasHasManyToMany) { - zval _3$$4, _5$$4; - zval metaData, _0, _1$$3, _2$$3, _4$$4, _6$$4, _7$$4, _8$$4, _9$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *modelName_param = NULL, *modelRelation_param = NULL, _0; + zval modelName, modelRelation; zval *this_ptr = getThis(); - ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&modelRelation); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$4); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(modelName) + Z_PARAM_STR(modelRelation) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("dirtyState"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_0)) { - ZEPHIR_CALL_METHOD(&metaData, this_ptr, "getmodelsmetadata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "getreadconnection", NULL, 431); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "has", NULL, 0, &metaData, &_2$$3); - zephir_check_call_status(); - if (!(zephir_is_true(&_1$$3))) { - ZEPHIR_INIT_VAR(&_3$$4); - zephir_create_array(&_3$$4, 1, 0); - ZEPHIR_INIT_VAR(&_4$$4); - object_init_ex(&_4$$4, phalcon_messages_message_ce); - ZEPHIR_INIT_VAR(&_5$$4); - zephir_create_array(&_5$$4, 1, 0); - ZEPHIR_INIT_VAR(&_6$$4); - zephir_get_class(&_6$$4, this_ptr, 0); - zephir_array_update_string(&_5$$4, SL("model"), &_6$$4, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_6$$4); - ZVAL_STRING(&_6$$4, "Record cannot be updated because it does not exist"); - ZVAL_NULL(&_7$$4); - ZEPHIR_INIT_VAR(&_8$$4); - ZVAL_STRING(&_8$$4, "InvalidUpdateAttempt"); - ZVAL_LONG(&_9$$4, 0); - ZEPHIR_CALL_METHOD(NULL, &_4$$4, "__construct", NULL, 6, &_6$$4, &_7$$4, &_8$$4, &_9$$4, &_5$$4); - zephir_check_call_status(); - zephir_array_fast_append(&_3$$4, &_4$$4); - zephir_update_property_zval(this_ptr, ZEND_STRL("errorMessages"), &_3$$4); - RETURN_MM_BOOL(0); - } + zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "save", NULL, 0); + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); + } else { + ZEPHIR_INIT_VAR(&modelName); + } + if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { + zephir_get_strval(&modelRelation, modelRelation_param); + } else { + ZEPHIR_INIT_VAR(&modelRelation); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "hasManyToMany"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checkhasrelationship", NULL, 444, &_0, &modelName, &modelRelation); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, writeAttribute) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, hasHasOne) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *attribute_param = NULL, *value, value_sub; - zval attribute; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *modelName_param = NULL, *modelRelation_param = NULL, _0; + zval modelName, modelRelation; zval *this_ptr = getThis(); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&modelRelation); + ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(attribute) - Z_PARAM_ZVAL(value) + Z_PARAM_STR(modelName) + Z_PARAM_STR(modelRelation) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &attribute_param, &value); - if (UNEXPECTED(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be of the type string")); + zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(attribute_param) == IS_STRING)) { - zephir_get_strval(&attribute, attribute_param); + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); } else { - ZEPHIR_INIT_VAR(&attribute); + ZEPHIR_INIT_VAR(&modelName); } - zephir_update_property_zval_zval(this_ptr, &attribute, value); - ZEPHIR_MM_RESTORE(); + if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { + zephir_get_strval(&modelRelation, modelRelation_param); + } else { + ZEPHIR_INIT_VAR(&modelRelation); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "hasOne"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checkhasrelationship", NULL, 444, &_0, &modelName, &modelRelation); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, checkForeignKeysRestrict) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, hasHasOneThrough) { - zend_string *_9$$7, *_33$$26; - zend_ulong _8$$7, _32$$26; - zend_bool error = 0, validateWithNulls = 0, _15$$3, _39$$22; - zval conditions, _17$$3, _21$$18, _41$$22, _45$$37; - zval manager, belongsTo, foreignKey, relation, position, bindParams, extraConditions, message, fields, referencedFields, field, referencedModel, value, allowNulls, _0, *_1, _2, _3$$5, _4$$3, _16$$3, _18$$3, *_6$$7, _7$$7, _10$$8, _11$$8, _12$$10, _13$$10, _14$$12, _19$$20, _20$$18, _22$$18, _23$$18, _24$$18, _27$$24, _28$$22, _40$$22, _42$$22, *_30$$26, _31$$26, _34$$27, _35$$27, _36$$29, _37$$29, _38$$31, _43$$39, _44$$37, _46$$37, _47$$37, _48$$37, _49$$42; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL, *_25 = NULL, *_26 = NULL, *_29 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, action = 0, numberNull = 0; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *modelName_param = NULL, *modelRelation_param = NULL, _0; + zval modelName, modelRelation; zval *this_ptr = getThis(); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&belongsTo); - ZVAL_UNDEF(&foreignKey); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&position); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&extraConditions); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&referencedFields); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&referencedModel); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&allowNulls); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&modelRelation); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_16$$3); - ZVAL_UNDEF(&_18$$3); - ZVAL_UNDEF(&_7$$7); - ZVAL_UNDEF(&_10$$8); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_12$$10); - ZVAL_UNDEF(&_13$$10); - ZVAL_UNDEF(&_14$$12); - ZVAL_UNDEF(&_19$$20); - ZVAL_UNDEF(&_20$$18); - ZVAL_UNDEF(&_22$$18); - ZVAL_UNDEF(&_23$$18); - ZVAL_UNDEF(&_24$$18); - ZVAL_UNDEF(&_27$$24); - ZVAL_UNDEF(&_28$$22); - ZVAL_UNDEF(&_40$$22); - ZVAL_UNDEF(&_42$$22); - ZVAL_UNDEF(&_31$$26); - ZVAL_UNDEF(&_34$$27); - ZVAL_UNDEF(&_35$$27); - ZVAL_UNDEF(&_36$$29); - ZVAL_UNDEF(&_37$$29); - ZVAL_UNDEF(&_38$$31); - ZVAL_UNDEF(&_43$$39); - ZVAL_UNDEF(&_44$$37); - ZVAL_UNDEF(&_46$$37); - ZVAL_UNDEF(&_47$$37); - ZVAL_UNDEF(&_48$$37); - ZVAL_UNDEF(&_49$$42); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&_17$$3); - ZVAL_UNDEF(&_21$$18); - ZVAL_UNDEF(&_41$$22); - ZVAL_UNDEF(&_45$$37); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(modelName) + Z_PARAM_STR(modelRelation) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - ZEPHIR_CALL_METHOD(&belongsTo, &manager, "getbelongsto", NULL, 0, this_ptr); - zephir_check_call_status(); - error = 0; - zephir_is_iterable(&belongsTo, 0, "phalcon/Mvc/Model.zep", 3574); - if (Z_TYPE_P(&belongsTo) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&belongsTo), _1) - { - ZEPHIR_INIT_NVAR(&relation); - ZVAL_COPY(&relation, _1); - validateWithNulls = 0; - ZEPHIR_CALL_METHOD(&foreignKey, &relation, "getforeignkey", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&foreignKey)) { - continue; - } - action = 1; - if (zephir_array_isset_string(&foreignKey, SL("action"))) { - ZEPHIR_OBS_NVAR(&_3$$5); - zephir_array_fetch_string(&_3$$5, &foreignKey, SL("action"), PH_NOISY, "phalcon/Mvc/Model.zep", 3460); - action = zephir_get_intval(&_3$$5); - } - if (action != 1) { - continue; - } - ZEPHIR_CALL_METHOD(&_4$$3, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedModel, &manager, "load", &_5, 0, &_4$$3); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&conditions); - array_init(&conditions); - ZEPHIR_INIT_NVAR(&bindParams); - array_init(&bindParams); - numberNull = 0; - ZEPHIR_CALL_METHOD(&fields, &relation, "getfields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedFields, &relation, "getreferencedfields", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&fields) == IS_ARRAY) { - zephir_is_iterable(&fields, 0, "phalcon/Mvc/Model.zep", 3503); - if (Z_TYPE_P(&fields) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&fields), _8$$7, _9$$7, _6$$7) - { - ZEPHIR_INIT_NVAR(&position); - if (_9$$7 != NULL) { - ZVAL_STR_COPY(&position, _9$$7); - } else { - ZVAL_LONG(&position, _8$$7); - } - ZEPHIR_INIT_NVAR(&field); - ZVAL_COPY(&field, _6$$7); - ZEPHIR_OBS_NVAR(&value); - zephir_fetch_property_zval(&value, this_ptr, &field, PH_SILENT_CC); - zephir_array_fetch(&_10$$8, &referencedFields, &position, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3495); - ZEPHIR_INIT_NVAR(&_11$$8); - ZEPHIR_CONCAT_SVSV(&_11$$8, "[", &_10$$8, "] = ?", &position); - zephir_array_append(&conditions, &_11$$8, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3495); - zephir_array_append(&bindParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3496); - if (Z_TYPE_P(&value) == IS_NULL) { - numberNull++; - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_7$$7, &fields, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_7$$7)) { - break; - } - ZEPHIR_CALL_METHOD(&position, &fields, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&field, &fields, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&value); - zephir_fetch_property_zval(&value, this_ptr, &field, PH_SILENT_CC); - zephir_array_fetch(&_12$$10, &referencedFields, &position, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3495); - ZEPHIR_INIT_NVAR(&_13$$10); - ZEPHIR_CONCAT_SVSV(&_13$$10, "[", &_12$$10, "] = ?", &position); - zephir_array_append(&conditions, &_13$$10, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3495); - zephir_array_append(&bindParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3496); - if (Z_TYPE_P(&value) == IS_NULL) { - numberNull++; - } - ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&field); - ZEPHIR_INIT_NVAR(&position); - validateWithNulls = numberNull == zephir_fast_count_int(&fields); - } else { - ZEPHIR_OBS_NVAR(&value); - zephir_fetch_property_zval(&value, this_ptr, &fields, PH_SILENT_CC); - ZEPHIR_INIT_NVAR(&_14$$12); - ZEPHIR_CONCAT_SVS(&_14$$12, "[", &referencedFields, "] = ?0"); - zephir_array_append(&conditions, &_14$$12, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3507); - zephir_array_append(&bindParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3508); - if (Z_TYPE_P(&value) == IS_NULL) { - validateWithNulls = 1; - } - } - ZEPHIR_OBS_NVAR(&extraConditions); - if (zephir_array_isset_string_fetch(&extraConditions, &foreignKey, SL("conditions"), 0)) { - zephir_array_append(&conditions, &extraConditions, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3519); - } - if (validateWithNulls) { - ZEPHIR_OBS_NVAR(&allowNulls); - if (zephir_array_isset_string_fetch(&allowNulls, &foreignKey, SL("allowNulls"), 0)) { - validateWithNulls = zephir_get_boolval(&allowNulls); - } else { - validateWithNulls = 0; - } - } - _15$$3 = !validateWithNulls; - if (_15$$3) { - ZEPHIR_INIT_NVAR(&_17$$3); - zephir_create_array(&_17$$3, 2, 0); - ZEPHIR_INIT_NVAR(&_18$$3); - zephir_fast_join_str(&_18$$3, SL(" AND "), &conditions); - zephir_array_fast_append(&_17$$3, &_18$$3); - zephir_array_update_string(&_17$$3, SL("bind"), &bindParams, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_16$$3, &referencedModel, "count", NULL, 0, &_17$$3); - zephir_check_call_status(); - _15$$3 = !zephir_is_true(&_16$$3); - } - if (_15$$3) { - ZEPHIR_OBS_NVAR(&message); - if (!(zephir_array_isset_string_fetch(&message, &foreignKey, SL("message"), 0))) { - ZEPHIR_INIT_NVAR(&message); - if (Z_TYPE_P(&fields) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_19$$20); - zephir_fast_join_str(&_19$$20, SL(", "), &fields); - ZEPHIR_CONCAT_SVS(&message, "Value of fields \"", &_19$$20, "\" does not exist on referenced table"); - } else { - ZEPHIR_CONCAT_SVS(&message, "Value of field \"", &fields, "\" does not exist on referenced table"); - } - } - ZEPHIR_INIT_NVAR(&_20$$18); - object_init_ex(&_20$$18, phalcon_messages_message_ce); - ZEPHIR_INIT_NVAR(&_21$$18); - zephir_create_array(&_21$$18, 2, 0); - ZEPHIR_INIT_NVAR(&_22$$18); - zephir_get_class(&_22$$18, this_ptr, 0); - zephir_array_update_string(&_21$$18, SL("model"), &_22$$18, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_23$$18, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - zephir_array_update_string(&_21$$18, SL("referenceModel"), &_23$$18, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_22$$18); - ZVAL_STRING(&_22$$18, "ConstraintViolation"); - ZVAL_LONG(&_24$$18, 0); - ZEPHIR_CALL_METHOD(NULL, &_20$$18, "__construct", &_25, 6, &message, &fields, &_22$$18, &_24$$18, &_21$$18); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_26, 0, &_20$$18); - zephir_check_call_status(); - error = 1; - break; - } - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); } else { - ZEPHIR_CALL_METHOD(NULL, &belongsTo, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &belongsTo, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&relation, &belongsTo, "current", NULL, 0); - zephir_check_call_status(); - validateWithNulls = 0; - ZEPHIR_CALL_METHOD(&foreignKey, &relation, "getforeignkey", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&foreignKey)) { - continue; - } - action = 1; - if (zephir_array_isset_string(&foreignKey, SL("action"))) { - ZEPHIR_OBS_NVAR(&_27$$24); - zephir_array_fetch_string(&_27$$24, &foreignKey, SL("action"), PH_NOISY, "phalcon/Mvc/Model.zep", 3460); - action = zephir_get_intval(&_27$$24); - } - if (action != 1) { - continue; - } - ZEPHIR_CALL_METHOD(&_28$$22, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedModel, &manager, "load", &_29, 0, &_28$$22); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&conditions); - array_init(&conditions); - ZEPHIR_INIT_NVAR(&bindParams); - array_init(&bindParams); - numberNull = 0; - ZEPHIR_CALL_METHOD(&fields, &relation, "getfields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedFields, &relation, "getreferencedfields", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&fields) == IS_ARRAY) { - zephir_is_iterable(&fields, 0, "phalcon/Mvc/Model.zep", 3503); - if (Z_TYPE_P(&fields) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&fields), _32$$26, _33$$26, _30$$26) - { - ZEPHIR_INIT_NVAR(&position); - if (_33$$26 != NULL) { - ZVAL_STR_COPY(&position, _33$$26); - } else { - ZVAL_LONG(&position, _32$$26); - } - ZEPHIR_INIT_NVAR(&field); - ZVAL_COPY(&field, _30$$26); - ZEPHIR_OBS_NVAR(&value); - zephir_fetch_property_zval(&value, this_ptr, &field, PH_SILENT_CC); - zephir_array_fetch(&_34$$27, &referencedFields, &position, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3495); - ZEPHIR_INIT_NVAR(&_35$$27); - ZEPHIR_CONCAT_SVSV(&_35$$27, "[", &_34$$27, "] = ?", &position); - zephir_array_append(&conditions, &_35$$27, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3495); - zephir_array_append(&bindParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3496); - if (Z_TYPE_P(&value) == IS_NULL) { - numberNull++; - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_31$$26, &fields, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_31$$26)) { - break; - } - ZEPHIR_CALL_METHOD(&position, &fields, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&field, &fields, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&value); - zephir_fetch_property_zval(&value, this_ptr, &field, PH_SILENT_CC); - zephir_array_fetch(&_36$$29, &referencedFields, &position, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3495); - ZEPHIR_INIT_NVAR(&_37$$29); - ZEPHIR_CONCAT_SVSV(&_37$$29, "[", &_36$$29, "] = ?", &position); - zephir_array_append(&conditions, &_37$$29, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3495); - zephir_array_append(&bindParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3496); - if (Z_TYPE_P(&value) == IS_NULL) { - numberNull++; - } - ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&field); - ZEPHIR_INIT_NVAR(&position); - validateWithNulls = numberNull == zephir_fast_count_int(&fields); - } else { - ZEPHIR_OBS_NVAR(&value); - zephir_fetch_property_zval(&value, this_ptr, &fields, PH_SILENT_CC); - ZEPHIR_INIT_NVAR(&_38$$31); - ZEPHIR_CONCAT_SVS(&_38$$31, "[", &referencedFields, "] = ?0"); - zephir_array_append(&conditions, &_38$$31, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3507); - zephir_array_append(&bindParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3508); - if (Z_TYPE_P(&value) == IS_NULL) { - validateWithNulls = 1; - } - } - ZEPHIR_OBS_NVAR(&extraConditions); - if (zephir_array_isset_string_fetch(&extraConditions, &foreignKey, SL("conditions"), 0)) { - zephir_array_append(&conditions, &extraConditions, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3519); - } - if (validateWithNulls) { - ZEPHIR_OBS_NVAR(&allowNulls); - if (zephir_array_isset_string_fetch(&allowNulls, &foreignKey, SL("allowNulls"), 0)) { - validateWithNulls = zephir_get_boolval(&allowNulls); - } else { - validateWithNulls = 0; - } - } - _39$$22 = !validateWithNulls; - if (_39$$22) { - ZEPHIR_INIT_NVAR(&_41$$22); - zephir_create_array(&_41$$22, 2, 0); - ZEPHIR_INIT_NVAR(&_42$$22); - zephir_fast_join_str(&_42$$22, SL(" AND "), &conditions); - zephir_array_fast_append(&_41$$22, &_42$$22); - zephir_array_update_string(&_41$$22, SL("bind"), &bindParams, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_40$$22, &referencedModel, "count", NULL, 0, &_41$$22); - zephir_check_call_status(); - _39$$22 = !zephir_is_true(&_40$$22); - } - if (_39$$22) { - ZEPHIR_OBS_NVAR(&message); - if (!(zephir_array_isset_string_fetch(&message, &foreignKey, SL("message"), 0))) { - ZEPHIR_INIT_NVAR(&message); - if (Z_TYPE_P(&fields) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_43$$39); - zephir_fast_join_str(&_43$$39, SL(", "), &fields); - ZEPHIR_CONCAT_SVS(&message, "Value of fields \"", &_43$$39, "\" does not exist on referenced table"); - } else { - ZEPHIR_CONCAT_SVS(&message, "Value of field \"", &fields, "\" does not exist on referenced table"); - } - } - ZEPHIR_INIT_NVAR(&_44$$37); - object_init_ex(&_44$$37, phalcon_messages_message_ce); - ZEPHIR_INIT_NVAR(&_45$$37); - zephir_create_array(&_45$$37, 2, 0); - ZEPHIR_INIT_NVAR(&_46$$37); - zephir_get_class(&_46$$37, this_ptr, 0); - zephir_array_update_string(&_45$$37, SL("model"), &_46$$37, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_47$$37, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - zephir_array_update_string(&_45$$37, SL("referenceModel"), &_47$$37, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_46$$37); - ZVAL_STRING(&_46$$37, "ConstraintViolation"); - ZVAL_LONG(&_48$$37, 0); - ZEPHIR_CALL_METHOD(NULL, &_44$$37, "__construct", &_25, 6, &message, &fields, &_46$$37, &_48$$37, &_45$$37); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_26, 0, &_44$$37); - zephir_check_call_status(); - error = 1; - break; - } - ZEPHIR_CALL_METHOD(NULL, &belongsTo, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&modelName); } - ZEPHIR_INIT_NVAR(&relation); - if (error) { - if (ZEPHIR_GLOBAL(orm).events) { - ZEPHIR_INIT_VAR(&_49$$42); - ZVAL_STRING(&_49$$42, "onValidationFails"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_49$$42); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "canceloperation", NULL, 0); - zephir_check_call_status(); - } + if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { + zephir_get_strval(&modelRelation, modelRelation_param); + } else { + ZEPHIR_INIT_VAR(&modelRelation); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "hasOneThrough"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checkhasrelationship", NULL, 444, &_0, &modelName, &modelRelation); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, initialize) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, __$true, className, eventsManager, _0, _1, _2$$5; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$5); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + ZEPHIR_INIT_VAR(&className); + zephir_get_class(&className, model, 1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset(&_0, &className)) { RETURN_MM_BOOL(0); } + zephir_update_property_array(this_ptr, SL("initialized"), &className, &__$true); + if ((zephir_method_exists_ex(model, ZEND_STRL("initialize")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(NULL, model, "initialize", NULL, 0); + zephir_check_call_status(); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("lastInitialized"), model); + zephir_read_property(&_1, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_1); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_2$$5); + ZVAL_STRING(&_2$$5, "modelsManager:afterInitialize"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_2$$5, this_ptr, model); + zephir_check_call_status(); + } RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_Model, checkForeignKeysReverseCascade) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, isInitialized) { - zend_bool _3$$3, _7$$9; - zval manager, relations, relation, foreignKey, related, _0, *_1, _2, _4$$5, _6$$7, _8$$11, _10$$13; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL, *_9 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, action = 0; + zval *className_param = NULL, _0, _1; + zval className; zval *this_ptr = getThis(); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&foreignKey); - ZVAL_UNDEF(&related); + ZVAL_UNDEF(&className); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_8$$11); - ZVAL_UNDEF(&_10$$13); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(className) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - ZEPHIR_CALL_METHOD(&relations, &manager, "gethasoneandhasmany", NULL, 0, this_ptr); - zephir_check_call_status(); - zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model.zep", 3650); - if (Z_TYPE_P(&relations) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _1) - { - ZEPHIR_INIT_NVAR(&relation); - ZVAL_COPY(&relation, _1); - ZEPHIR_CALL_METHOD(&foreignKey, &relation, "getforeignkey", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&foreignKey)) { - continue; - } - action = 0; - _3$$3 = Z_TYPE_P(&foreignKey) == IS_ARRAY; - if (_3$$3) { - _3$$3 = zephir_array_isset_string(&foreignKey, SL("action")); - } - if (_3$$3) { - ZEPHIR_OBS_NVAR(&_4$$5); - zephir_array_fetch_string(&_4$$5, &foreignKey, SL("action"), PH_NOISY, "phalcon/Mvc/Model.zep", 3624); - action = zephir_get_intval(&_4$$5); - } - if (action != 2) { - continue; - } - ZEPHIR_CALL_METHOD(&related, &manager, "getrelationrecords", &_5, 0, &relation, this_ptr); - zephir_check_call_status(); - if (zephir_is_true(&related)) { - ZEPHIR_CALL_METHOD(&_6$$7, &related, "delete", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_6$$7)) { - RETURN_MM_BOOL(0); - } - } - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 1, 0, &className_param); + if (UNEXPECTED(Z_TYPE_P(className_param) != IS_STRING && Z_TYPE_P(className_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'className' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(className_param) == IS_STRING)) { + zephir_get_strval(&className, className_param); } else { - ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &relations, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&foreignKey, &relation, "getforeignkey", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&foreignKey)) { - continue; - } - action = 0; - _7$$9 = Z_TYPE_P(&foreignKey) == IS_ARRAY; - if (_7$$9) { - _7$$9 = zephir_array_isset_string(&foreignKey, SL("action")); - } - if (_7$$9) { - ZEPHIR_OBS_NVAR(&_8$$11); - zephir_array_fetch_string(&_8$$11, &foreignKey, SL("action"), PH_NOISY, "phalcon/Mvc/Model.zep", 3624); - action = zephir_get_intval(&_8$$11); - } - if (action != 2) { - continue; - } - ZEPHIR_CALL_METHOD(&related, &manager, "getrelationrecords", &_9, 0, &relation, this_ptr); - zephir_check_call_status(); - if (zephir_is_true(&related)) { - ZEPHIR_CALL_METHOD(&_10$$13, &related, "delete", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_10$$13)) { - RETURN_MM_BOOL(0); - } - } - ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&className); } - ZEPHIR_INIT_NVAR(&relation); - RETURN_MM_BOOL(1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + zephir_fast_strtolower(&_1, &className); + RETURN_MM_BOOL(zephir_array_isset(&_0, &_1)); } -static PHP_METHOD(Phalcon_Mvc_Model, checkForeignKeysReverseRestrict) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, isKeepingSnapshots) { - zval _10$$7, _22$$13; - zval manager, relations, foreignKey, relation, relationClass, fields, message, _0, *_1, _2, _5$$3, _6$$3, _7$$3, _4$$5, _9$$7, _11$$7, _12$$7, _17$$9, _18$$9, _19$$9, _16$$11, _21$$13, _23$$13, _24$$13, _25$$16; - zend_bool error = 0, _3$$3, _15$$9; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_8 = NULL, *_13 = NULL, *_14 = NULL, *_20 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, action = 0; + zval *model, model_sub, isKeeping, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&foreignKey); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&relationClass); - ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&isKeeping); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_11$$7); - ZVAL_UNDEF(&_12$$7); - ZVAL_UNDEF(&_17$$9); - ZVAL_UNDEF(&_18$$9); - ZVAL_UNDEF(&_19$$9); - ZVAL_UNDEF(&_16$$11); - ZVAL_UNDEF(&_21$$13); - ZVAL_UNDEF(&_23$$13); - ZVAL_UNDEF(&_24$$13); - ZVAL_UNDEF(&_25$$16); - ZVAL_UNDEF(&_10$$7); - ZVAL_UNDEF(&_22$$13); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + if (ZEPHIR_GLOBAL(orm).dynamic_update) { + RETURN_MM_BOOL(1); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + zephir_get_class(&_1, model, 1); + if (!(zephir_array_isset_fetch(&isKeeping, &_0, &_1, 1))) { + RETURN_MM_BOOL(0); + } + RETURN_CTOR(&isKeeping); +} - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - ZEPHIR_CALL_METHOD(&relations, &manager, "gethasoneandhasmany", NULL, 0, this_ptr); - zephir_check_call_status(); - error = 0; - zephir_is_iterable(&relations, 0, "phalcon/Mvc/Model.zep", 3741); - if (Z_TYPE_P(&relations) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relations), _1) - { - ZEPHIR_INIT_NVAR(&relation); - ZVAL_COPY(&relation, _1); - ZEPHIR_CALL_METHOD(&foreignKey, &relation, "getforeignkey", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&foreignKey)) { - continue; - } - action = 1; - _3$$3 = Z_TYPE_P(&foreignKey) == IS_ARRAY; - if (_3$$3) { - _3$$3 = zephir_array_isset_string(&foreignKey, SL("action")); - } - if (_3$$3) { - ZEPHIR_OBS_NVAR(&_4$$5); - zephir_array_fetch_string(&_4$$5, &foreignKey, SL("action"), PH_NOISY, "phalcon/Mvc/Model.zep", 3695); - action = zephir_get_intval(&_4$$5); - } - if (action != 1) { - continue; - } - ZEPHIR_CALL_METHOD(&relationClass, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&fields, &relation, "getfields", NULL, 0); - zephir_check_call_status(); - ZVAL_NULL(&_6$$3); - ZEPHIR_INIT_NVAR(&_7$$3); - ZVAL_STRING(&_7$$3, "count"); - ZEPHIR_CALL_METHOD(&_5$$3, &manager, "getrelationrecords", &_8, 0, &relation, this_ptr, &_6$$3, &_7$$3); - zephir_check_call_status(); - if (zephir_is_true(&_5$$3)) { - ZEPHIR_OBS_NVAR(&message); - if (!(zephir_array_isset_string_fetch(&message, &foreignKey, SL("message"), 0))) { - ZEPHIR_INIT_NVAR(&message); - ZEPHIR_CONCAT_SV(&message, "Record is referenced by model ", &relationClass); - } - ZEPHIR_INIT_NVAR(&_9$$7); - object_init_ex(&_9$$7, phalcon_messages_message_ce); - ZEPHIR_INIT_NVAR(&_10$$7); - zephir_create_array(&_10$$7, 2, 0); - ZEPHIR_INIT_NVAR(&_11$$7); - zephir_get_class(&_11$$7, this_ptr, 0); - zephir_array_update_string(&_10$$7, SL("model"), &_11$$7, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_10$$7, SL("referenceModel"), &relationClass, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_11$$7); - ZVAL_STRING(&_11$$7, "ConstraintViolation"); - ZVAL_LONG(&_12$$7, 0); - ZEPHIR_CALL_METHOD(NULL, &_9$$7, "__construct", &_13, 6, &message, &fields, &_11$$7, &_12$$7, &_10$$7); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_14, 0, &_9$$7); - zephir_check_call_status(); - error = 1; - break; - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &relations, "rewind", NULL, 0); +static PHP_METHOD(Phalcon_Mvc_Model_Manager, isUsingDynamicUpdate) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *model, model_sub, isUsing, _0, _1; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&isUsing); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + if (ZEPHIR_GLOBAL(orm).dynamic_update) { + RETURN_MM_BOOL(1); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("dynamicUpdate"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + zephir_get_class(&_1, model, 1); + if (!(zephir_array_isset_fetch(&isUsing, &_0, &_1, 1))) { + RETURN_MM_BOOL(0); + } + RETURN_CTOR(&isUsing); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, isVisibleModelProperty) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval property; + zval *model, model_sub, *property_param = NULL, __$true, properties, className, publicProperties, classReflection, reflectionProperties, reflectionProperty, _0, _6, _1$$3, *_2$$3, _3$$3, _4$$4, _5$$5; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&properties); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&publicProperties); + ZVAL_UNDEF(&classReflection); + ZVAL_UNDEF(&reflectionProperties); + ZVAL_UNDEF(&reflectionProperty); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&property); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_STR(property) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &model, &property_param); + zephir_get_strval(&property, property_param); + ZEPHIR_INIT_VAR(&className); + zephir_get_class(&className, model, 0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelVisibility"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset(&_0, &className))) { + ZEPHIR_INIT_VAR(&publicProperties); + array_init(&publicProperties); + ZEPHIR_INIT_VAR(&classReflection); + object_init_ex(&classReflection, zephir_get_internal_ce(SL("reflectionclass"))); + ZEPHIR_CALL_METHOD(NULL, &classReflection, "__construct", NULL, 154, &className); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &relations, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&relation, &relations, "current", NULL, 0); + ZVAL_LONG(&_1$$3, 1); + ZEPHIR_CALL_METHOD(&reflectionProperties, &classReflection, "getproperties", NULL, 165, &_1$$3); + zephir_check_call_status(); + zephir_is_iterable(&reflectionProperties, 0, "phalcon/Mvc/Model/Manager.zep", 1915); + if (Z_TYPE_P(&reflectionProperties) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&reflectionProperties), _2$$3) + { + ZEPHIR_INIT_NVAR(&reflectionProperty); + ZVAL_COPY(&reflectionProperty, _2$$3); + ZEPHIR_OBS_NVAR(&_4$$4); + zephir_read_property(&_4$$4, &reflectionProperty, ZEND_STRL("name"), PH_NOISY_CC); + zephir_array_update_zval(&publicProperties, &_4$$4, &__$true, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &reflectionProperties, "rewind", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&foreignKey, &relation, "getforeignkey", NULL, 0); + while (1) { + ZEPHIR_CALL_METHOD(&_3$$3, &reflectionProperties, "valid", NULL, 0); zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&foreignKey)) { - continue; - } - action = 1; - _15$$9 = Z_TYPE_P(&foreignKey) == IS_ARRAY; - if (_15$$9) { - _15$$9 = zephir_array_isset_string(&foreignKey, SL("action")); - } - if (_15$$9) { - ZEPHIR_OBS_NVAR(&_16$$11); - zephir_array_fetch_string(&_16$$11, &foreignKey, SL("action"), PH_NOISY, "phalcon/Mvc/Model.zep", 3695); - action = zephir_get_intval(&_16$$11); - } - if (action != 1) { - continue; + if (!zend_is_true(&_3$$3)) { + break; } - ZEPHIR_CALL_METHOD(&relationClass, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&fields, &relation, "getfields", NULL, 0); + ZEPHIR_CALL_METHOD(&reflectionProperty, &reflectionProperties, "current", NULL, 0); zephir_check_call_status(); - ZVAL_NULL(&_18$$9); - ZEPHIR_INIT_NVAR(&_19$$9); - ZVAL_STRING(&_19$$9, "count"); - ZEPHIR_CALL_METHOD(&_17$$9, &manager, "getrelationrecords", &_20, 0, &relation, this_ptr, &_18$$9, &_19$$9); + ZEPHIR_OBS_NVAR(&_5$$5); + zephir_read_property(&_5$$5, &reflectionProperty, ZEND_STRL("name"), PH_NOISY_CC); + zephir_array_update_zval(&publicProperties, &_5$$5, &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &reflectionProperties, "next", NULL, 0); zephir_check_call_status(); - if (zephir_is_true(&_17$$9)) { - ZEPHIR_OBS_NVAR(&message); - if (!(zephir_array_isset_string_fetch(&message, &foreignKey, SL("message"), 0))) { - ZEPHIR_INIT_NVAR(&message); - ZEPHIR_CONCAT_SV(&message, "Record is referenced by model ", &relationClass); - } - ZEPHIR_INIT_NVAR(&_21$$13); - object_init_ex(&_21$$13, phalcon_messages_message_ce); - ZEPHIR_INIT_NVAR(&_22$$13); - zephir_create_array(&_22$$13, 2, 0); - ZEPHIR_INIT_NVAR(&_23$$13); - zephir_get_class(&_23$$13, this_ptr, 0); - zephir_array_update_string(&_22$$13, SL("model"), &_23$$13, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_22$$13, SL("referenceModel"), &relationClass, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_23$$13); - ZVAL_STRING(&_23$$13, "ConstraintViolation"); - ZVAL_LONG(&_24$$13, 0); - ZEPHIR_CALL_METHOD(NULL, &_21$$13, "__construct", &_13, 6, &message, &fields, &_23$$13, &_24$$13, &_22$$13); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_14, 0, &_21$$13); - zephir_check_call_status(); - error = 1; - break; - } - ZEPHIR_CALL_METHOD(NULL, &relations, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&relation); - if (error) { - if (ZEPHIR_GLOBAL(orm).events) { - ZEPHIR_INIT_VAR(&_25$$16); - ZVAL_STRING(&_25$$16, "onValidationFails"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_25$$16); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "canceloperation", NULL, 0); - zephir_check_call_status(); + } } - RETURN_MM_BOOL(0); + ZEPHIR_INIT_NVAR(&reflectionProperty); + zephir_update_property_array(this_ptr, SL("modelVisibility"), &className, &publicProperties); } - RETURN_MM_BOOL(1); + zephir_read_property(&_6, this_ptr, ZEND_STRL("modelVisibility"), PH_NOISY_CC | PH_READONLY); + zephir_memory_observe(&properties); + zephir_array_fetch(&properties, &_6, &className, PH_NOISY, "phalcon/Mvc/Model/Manager.zep", 1918); + RETURN_MM_BOOL(zephir_array_key_exists(&properties, &property)); } -static PHP_METHOD(Phalcon_Mvc_Model, doLowInsert) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, keepSnapshots) { - zend_string *_58$$56; - zend_ulong _57$$56; - zend_bool useExplicitIdentity = 0, _51, _7$$11, _25$$26, _44$$40, _60$$56; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_6 = NULL, *_11 = NULL, *_12 = NULL, *_19 = NULL, *_21 = NULL, *_29 = NULL, *_30 = NULL, *_37 = NULL, *_39 = NULL; + zend_bool keepSnapshots; + zval *model, model_sub, *keepSnapshots_param = NULL, _0, _1; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_BOOL(keepSnapshots) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &model, &keepSnapshots_param); + ZEPHIR_INIT_VAR(&_0); + zephir_get_class(&_0, model, 1); + ZEPHIR_INIT_VAR(&_1); + ZVAL_BOOL(&_1, keepSnapshots); + zephir_update_property_array(this_ptr, SL("keepSnapshots"), &_0, &_1); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, load) +{ + zval _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *metaData, metaData_sub, *connection, connection_sub, *table = NULL, table_sub, *identityField, identityField_sub, __$null, attributeField, attributes, automaticAttributes, bindDataTypes, bindSkip, bindType, bindTypes, columnMap, defaultValue, defaultValues, field, fields, lastInsertedId, manager, sequenceName, schema, snapshot, source, success, unsetDefaultValues, value, values, _0, *_1, _2, _3$$7, _4$$7, _5$$7, _8$$12, _9$$12, _10$$12, _13$$15, _14$$15, _15$$15, _16$$17, _17$$17, _18$$17, _20$$17, _22$$22, _23$$22, _24$$22, _26$$27, _27$$27, _28$$27, _31$$30, _32$$30, _33$$30, _34$$32, _35$$32, _36$$32, _38$$32, _40$$35, _41$$38, _42$$38, _43$$38, _45$$45, _46$$45, _47$$45, _48$$48, _49$$48, _50$$48, _52$$49, _53$$55, _54$$55, *_55$$56, _56$$56, _59$$56; + zval *modelName_param = NULL, __$null, model, _3, _0$$3; + zval modelName, _1$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&metaData_sub); - ZVAL_UNDEF(&connection_sub); - ZVAL_UNDEF(&table_sub); - ZVAL_UNDEF(&identityField_sub); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&_1$$3); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&attributeField); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&automaticAttributes); - ZVAL_UNDEF(&bindDataTypes); - ZVAL_UNDEF(&bindSkip); - ZVAL_UNDEF(&bindType); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&defaultValue); - ZVAL_UNDEF(&defaultValues); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&lastInsertedId); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&sequenceName); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&snapshot); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&success); - ZVAL_UNDEF(&unsetDefaultValues); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$7); - ZVAL_UNDEF(&_4$$7); - ZVAL_UNDEF(&_5$$7); - ZVAL_UNDEF(&_8$$12); - ZVAL_UNDEF(&_9$$12); - ZVAL_UNDEF(&_10$$12); - ZVAL_UNDEF(&_13$$15); - ZVAL_UNDEF(&_14$$15); - ZVAL_UNDEF(&_15$$15); - ZVAL_UNDEF(&_16$$17); - ZVAL_UNDEF(&_17$$17); - ZVAL_UNDEF(&_18$$17); - ZVAL_UNDEF(&_20$$17); - ZVAL_UNDEF(&_22$$22); - ZVAL_UNDEF(&_23$$22); - ZVAL_UNDEF(&_24$$22); - ZVAL_UNDEF(&_26$$27); - ZVAL_UNDEF(&_27$$27); - ZVAL_UNDEF(&_28$$27); - ZVAL_UNDEF(&_31$$30); - ZVAL_UNDEF(&_32$$30); - ZVAL_UNDEF(&_33$$30); - ZVAL_UNDEF(&_34$$32); - ZVAL_UNDEF(&_35$$32); - ZVAL_UNDEF(&_36$$32); - ZVAL_UNDEF(&_38$$32); - ZVAL_UNDEF(&_40$$35); - ZVAL_UNDEF(&_41$$38); - ZVAL_UNDEF(&_42$$38); - ZVAL_UNDEF(&_43$$38); - ZVAL_UNDEF(&_45$$45); - ZVAL_UNDEF(&_46$$45); - ZVAL_UNDEF(&_47$$45); - ZVAL_UNDEF(&_48$$48); - ZVAL_UNDEF(&_49$$48); - ZVAL_UNDEF(&_50$$48); - ZVAL_UNDEF(&_52$$49); - ZVAL_UNDEF(&_53$$55); - ZVAL_UNDEF(&_54$$55); - ZVAL_UNDEF(&_56$$56); - ZVAL_UNDEF(&_59$$56); - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_OBJECT_OF_CLASS(metaData, phalcon_mvc_model_metadatainterface_ce) - Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_db_adapter_adapterinterface_ce) - Z_PARAM_ZVAL(table) - Z_PARAM_ZVAL(identityField) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(modelName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 0, &metaData, &connection, &table, &identityField); - ZEPHIR_SEPARATE_PARAM(table); - ZEPHIR_INIT_VAR(&bindSkip); - ZVAL_LONG(&bindSkip, 1024); - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - ZEPHIR_INIT_VAR(&fields); - array_init(&fields); - ZEPHIR_INIT_VAR(&values); - array_init(&values); - ZEPHIR_INIT_VAR(&snapshot); - array_init(&snapshot); - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - ZEPHIR_INIT_VAR(&unsetDefaultValues); - array_init(&unsetDefaultValues); - ZEPHIR_CALL_METHOD(&attributes, metaData, "getattributes", NULL, 0, this_ptr); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&bindDataTypes, metaData, "getbindtypes", NULL, 0, this_ptr); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&automaticAttributes, metaData, "getautomaticcreateattributes", NULL, 0, this_ptr); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&defaultValues, metaData, "getdefaultvalues", NULL, 0, this_ptr); - zephir_check_call_status(); - if (ZEPHIR_GLOBAL(orm).column_renaming) { - ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, this_ptr); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&columnMap); - ZVAL_NULL(&columnMap); + zephir_fetch_params(1, 1, 0, &modelName_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + RETURN_MM_NULL(); } - zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model.zep", 3863); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _1) - { - ZEPHIR_INIT_NVAR(&field); - ZVAL_COPY(&field, _1); - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { - ZEPHIR_INIT_NVAR(&_3$$7); - object_init_ex(&_3$$7, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_4$$7); - zephir_get_class(&_4$$7, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_5$$7); - ZEPHIR_CONCAT_SVSVS(&_5$$7, "Column '", &field, "' in '", &_4$$7, "' isn't part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_3$$7, "__construct", &_6, 33, &_5$$7); - zephir_check_call_status(); - zephir_throw_exception_debug(&_3$$7, "phalcon/Mvc/Model.zep", 3797); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&attributeField, &field); - } - if (!(zephir_array_isset(&automaticAttributes, &attributeField))) { - if (!ZEPHIR_IS_EQUAL(&field, identityField)) { - ZEPHIR_OBS_NVAR(&value); - if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { - _7$$11 = Z_TYPE_P(&value) == IS_NULL; - if (_7$$11) { - _7$$11 = zephir_array_isset(&defaultValues, &field); - } - if (_7$$11) { - zephir_array_fetch(&_8$$12, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3814); - zephir_array_update_zval(&snapshot, &attributeField, &_8$$12, PH_COPY | PH_SEPARATE); - zephir_array_fetch(&_9$$12, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3815); - zephir_array_update_zval(&unsetDefaultValues, &attributeField, &_9$$12, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_10$$12, connection, "supportsdefaultvalue", &_11, 0); - zephir_check_call_status(); - if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&_10$$12))) { - continue; - } - ZEPHIR_CALL_METHOD(&value, connection, "getdefaultvalue", &_12, 0); - zephir_check_call_status(); - } else { - zephir_array_update_zval(&snapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); - } - ZEPHIR_OBS_NVAR(&bindType); - if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, &bindDataTypes, &field, 0)))) { - ZEPHIR_INIT_NVAR(&_13$$15); - object_init_ex(&_13$$15, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_14$$15); - zephir_get_class(&_14$$15, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_15$$15); - ZEPHIR_CONCAT_SVSVS(&_15$$15, "Column '", &field, "' in '", &_14$$15, "' have not defined a bind data type"); - ZEPHIR_CALL_METHOD(NULL, &_13$$15, "__construct", &_6, 33, &_15$$15); - zephir_check_call_status(); - zephir_throw_exception_debug(&_13$$15, "phalcon/Mvc/Model.zep", 3832); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3835); - zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3836); - zephir_array_append(&bindTypes, &bindType, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3837); - } else { - if (zephir_array_isset(&defaultValues, &field)) { - zephir_array_fetch(&_16$$17, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3840); - zephir_array_update_zval(&snapshot, &attributeField, &_16$$17, PH_COPY | PH_SEPARATE); - zephir_array_fetch(&_17$$17, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3841); - zephir_array_update_zval(&unsetDefaultValues, &attributeField, &_17$$17, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_18$$17, connection, "supportsdefaultvalue", &_19, 0); - zephir_check_call_status(); - if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&_18$$17))) { - continue; - } - ZEPHIR_CALL_METHOD(&_20$$17, connection, "getdefaultvalue", &_21, 0); - zephir_check_call_status(); - zephir_array_append(&values, &_20$$17, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3847); - } else { - zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3849); - zephir_array_update_zval(&snapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); - } - zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3853); - zephir_array_append(&bindTypes, &bindSkip, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3854); - } - } - } - } ZEND_HASH_FOREACH_END(); + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &attributes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&field, &attributes, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { - ZEPHIR_INIT_NVAR(&_22$$22); - object_init_ex(&_22$$22, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_23$$22); - zephir_get_class(&_23$$22, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_24$$22); - ZEPHIR_CONCAT_SVSVS(&_24$$22, "Column '", &field, "' in '", &_23$$22, "' isn't part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_22$$22, "__construct", &_6, 33, &_24$$22); - zephir_check_call_status(); - zephir_throw_exception_debug(&_22$$22, "phalcon/Mvc/Model.zep", 3797); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&attributeField, &field); - } - if (!(zephir_array_isset(&automaticAttributes, &attributeField))) { - if (!ZEPHIR_IS_EQUAL(&field, identityField)) { - ZEPHIR_OBS_NVAR(&value); - if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { - _25$$26 = Z_TYPE_P(&value) == IS_NULL; - if (_25$$26) { - _25$$26 = zephir_array_isset(&defaultValues, &field); - } - if (_25$$26) { - zephir_array_fetch(&_26$$27, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3814); - zephir_array_update_zval(&snapshot, &attributeField, &_26$$27, PH_COPY | PH_SEPARATE); - zephir_array_fetch(&_27$$27, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3815); - zephir_array_update_zval(&unsetDefaultValues, &attributeField, &_27$$27, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_28$$27, connection, "supportsdefaultvalue", &_29, 0); - zephir_check_call_status(); - if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&_28$$27))) { - continue; - } - ZEPHIR_CALL_METHOD(&value, connection, "getdefaultvalue", &_30, 0); - zephir_check_call_status(); - } else { - zephir_array_update_zval(&snapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); - } - ZEPHIR_OBS_NVAR(&bindType); - if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, &bindDataTypes, &field, 0)))) { - ZEPHIR_INIT_NVAR(&_31$$30); - object_init_ex(&_31$$30, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_32$$30); - zephir_get_class(&_32$$30, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_33$$30); - ZEPHIR_CONCAT_SVSVS(&_33$$30, "Column '", &field, "' in '", &_32$$30, "' have not defined a bind data type"); - ZEPHIR_CALL_METHOD(NULL, &_31$$30, "__construct", &_6, 33, &_33$$30); - zephir_check_call_status(); - zephir_throw_exception_debug(&_31$$30, "phalcon/Mvc/Model.zep", 3832); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3835); - zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3836); - zephir_array_append(&bindTypes, &bindType, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3837); - } else { - if (zephir_array_isset(&defaultValues, &field)) { - zephir_array_fetch(&_34$$32, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3840); - zephir_array_update_zval(&snapshot, &attributeField, &_34$$32, PH_COPY | PH_SEPARATE); - zephir_array_fetch(&_35$$32, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3841); - zephir_array_update_zval(&unsetDefaultValues, &attributeField, &_35$$32, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_36$$32, connection, "supportsdefaultvalue", &_37, 0); - zephir_check_call_status(); - if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&_36$$32))) { - continue; - } - ZEPHIR_CALL_METHOD(&_38$$32, connection, "getdefaultvalue", &_39, 0); - zephir_check_call_status(); - zephir_array_append(&values, &_38$$32, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3847); - } else { - zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3849); - zephir_array_update_zval(&snapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); - } - zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3853); - zephir_array_append(&bindTypes, &bindSkip, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3854); - } - } - } - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&modelName); } - ZEPHIR_INIT_NVAR(&field); - if (!ZEPHIR_IS_FALSE_IDENTICAL(identityField)) { - ZEPHIR_CALL_METHOD(&defaultValue, connection, "getdefaultidvalue", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_40$$35, connection, "useexplicitidvalue", NULL, 0); + if (UNEXPECTED(!(zephir_class_exists(&modelName, 1)))) { + ZEPHIR_INIT_VAR(&_0$$3); + object_init_ex(&_0$$3, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_1$$3); + ZEPHIR_CONCAT_SVS(&_1$$3, "Model '", &modelName, "' could not be loaded"); + ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 33, &_1$$3); zephir_check_call_status(); - useExplicitIdentity = zephir_get_boolval(&_40$$35); - if (useExplicitIdentity) { - zephir_array_append(&fields, identityField, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3873); - } - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, identityField, 0)))) { - ZEPHIR_INIT_VAR(&_41$$38); - object_init_ex(&_41$$38, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_42$$38); - zephir_get_class(&_42$$38, this_ptr, 0); - ZEPHIR_INIT_VAR(&_43$$38); - ZEPHIR_CONCAT_SVSVS(&_43$$38, "Identity column '", identityField, "' isn't part of the column map in '", &_42$$38, "'"); - ZEPHIR_CALL_METHOD(NULL, &_41$$38, "__construct", &_6, 33, &_43$$38); - zephir_check_call_status(); - zephir_throw_exception_debug(&_41$$38, "phalcon/Mvc/Model.zep", 3883); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&attributeField, identityField); - } - ZEPHIR_OBS_NVAR(&value); - if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { - _44$$40 = Z_TYPE_P(&value) == IS_NULL; - if (!(_44$$40)) { - _44$$40 = ZEPHIR_IS_STRING_IDENTICAL(&value, ""); - } - if (_44$$40) { - if (useExplicitIdentity) { - zephir_array_append(&values, &defaultValue, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3895); - zephir_array_append(&bindTypes, &bindSkip, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3895); - } - } else { - if (!(useExplicitIdentity)) { - zephir_array_append(&fields, identityField, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3903); - } - ZEPHIR_OBS_NVAR(&bindType); - if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, &bindDataTypes, identityField, 0)))) { - ZEPHIR_INIT_VAR(&_45$$45); - object_init_ex(&_45$$45, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_46$$45); - zephir_get_class(&_46$$45, this_ptr, 0); - ZEPHIR_INIT_VAR(&_47$$45); - ZEPHIR_CONCAT_SVSVS(&_47$$45, "Identity column '", identityField, "' isn\'t part of the table columns in '", &_46$$45, "'"); - ZEPHIR_CALL_METHOD(NULL, &_45$$45, "__construct", &_6, 33, &_47$$45); - zephir_check_call_status(); - zephir_throw_exception_debug(&_45$$45, "phalcon/Mvc/Model.zep", 3912); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3915); - zephir_array_append(&bindTypes, &bindType, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3916); - } - } else { - if (useExplicitIdentity) { - zephir_array_append(&values, &defaultValue, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3920); - zephir_array_append(&bindTypes, &bindSkip, PH_SEPARATE, "phalcon/Mvc/Model.zep", 3921); - } - } - } - if (Z_TYPE_P(table) == IS_ARRAY) { - zephir_array_fetch_long(&_48$$48, table, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3930); - zephir_array_fetch_long(&_49$$48, table, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 3930); - ZEPHIR_INIT_VAR(&_50$$48); - ZEPHIR_CONCAT_VSV(&_50$$48, &_48$$48, ".", &_49$$48); - ZEPHIR_CPY_WRT(table, &_50$$48); + zephir_throw_exception_debug(&_0$$3, "phalcon/Mvc/Model/Manager.zep", 1953); + ZEPHIR_MM_RESTORE(); + return; } - ZEPHIR_CALL_METHOD(&success, connection, "insert", NULL, 0, table, &values, &fields, &bindTypes); + ZEPHIR_INIT_VAR(&_2); + zephir_create_array(&_2, 3, 0); + zephir_array_fast_append(&_2, &__$null); + zephir_memory_observe(&_3); + zephir_read_property(&_3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC); + zephir_array_fast_append(&_2, &_3); + zephir_array_fast_append(&_2, this_ptr); + ZEPHIR_INIT_VAR(&model); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&model, &modelName, &_2); zephir_check_call_status(); - _51 = zephir_is_true(&success); - if (_51) { - _51 = !ZEPHIR_IS_FALSE_IDENTICAL(identityField); + RETURN_CCTOR(&model); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, notifyEvent) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *eventName_param = NULL, *model, model_sub, status, behavior, modelsBehaviors, eventsManager, customEventsManager, _0, _1, _4, _6, *_2$$3, _3$$3; + zval eventName, _5$$8, _7$$10; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&eventName); + ZVAL_UNDEF(&_5$$8); + ZVAL_UNDEF(&_7$$10); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&status); + ZVAL_UNDEF(&behavior); + ZVAL_UNDEF(&modelsBehaviors); + ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&customEventsManager); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_3$$3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(eventName) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &eventName_param, &model); + if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string")); + RETURN_MM_NULL(); } - if (_51) { - ZEPHIR_INIT_VAR(&sequenceName); - ZVAL_NULL(&sequenceName); - ZEPHIR_CALL_METHOD(&_52$$49, connection, "supportsequences", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&_52$$49)) { - if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("getsequencename")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(&sequenceName, this_ptr, "getsequencename", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 424); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, this_ptr, "getschema", NULL, 423); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&sequenceName); - if (ZEPHIR_IS_EMPTY(&schema)) { - ZEPHIR_CONCAT_VSVS(&sequenceName, &source, "_", identityField, "_seq"); - } else { - ZEPHIR_CONCAT_VSVSVS(&sequenceName, &schema, ".", &source, "_", identityField, "_seq"); - } - } - } - ZEPHIR_CALL_METHOD(&lastInsertedId, connection, "lastinsertid", NULL, 0, &sequenceName); - zephir_check_call_status(); - if (UNEXPECTED(ZEPHIR_GLOBAL(orm).cast_last_insert_id_to_int)) { - ZVAL_LONG(&_53$$55, 10); - ZEPHIR_CALL_FUNCTION(&_54$$55, "intval", NULL, 42, &lastInsertedId, &_53$$55); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&lastInsertedId, &_54$$55); - } - zephir_update_property_zval_zval(this_ptr, &attributeField, &lastInsertedId); - zephir_array_update_zval(&snapshot, &attributeField, &lastInsertedId, PH_COPY | PH_SEPARATE); - zephir_update_property_zval(this_ptr, ZEND_STRL("uniqueParams"), &__$null); + if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { + zephir_get_strval(&eventName, eventName_param); + } else { + ZEPHIR_INIT_VAR(&eventName); } - if (zephir_is_true(&success)) { - zephir_is_iterable(&unsetDefaultValues, 0, "phalcon/Mvc/Model.zep", 3991); - if (Z_TYPE_P(&unsetDefaultValues) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&unsetDefaultValues), _57$$56, _58$$56, _55$$56) + ZEPHIR_INIT_VAR(&status); + ZVAL_BOOL(&status, 1); + zephir_memory_observe(&modelsBehaviors); + zephir_read_property(&_0, this_ptr, ZEND_STRL("behaviors"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + zephir_get_class(&_1, model, 1); + if (zephir_array_isset_fetch(&modelsBehaviors, &_0, &_1, 0)) { + zephir_is_iterable(&modelsBehaviors, 0, "phalcon/Mvc/Model/Manager.zep", 2000); + if (Z_TYPE_P(&modelsBehaviors) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&modelsBehaviors), _2$$3) { - ZEPHIR_INIT_NVAR(&attributeField); - if (_58$$56 != NULL) { - ZVAL_STR_COPY(&attributeField, _58$$56); - } else { - ZVAL_LONG(&attributeField, _57$$56); + ZEPHIR_INIT_NVAR(&behavior); + ZVAL_COPY(&behavior, _2$$3); + ZEPHIR_CALL_METHOD(&status, &behavior, "notify", NULL, 0, &eventName, model); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) { + RETURN_MM_BOOL(0); } - ZEPHIR_INIT_NVAR(&defaultValue); - ZVAL_COPY(&defaultValue, _55$$56); - zephir_update_property_zval_zval(this_ptr, &attributeField, &defaultValue); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &unsetDefaultValues, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_56$$56, &unsetDefaultValues, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_3$$3, &modelsBehaviors, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_56$$56)) { + if (!zend_is_true(&_3$$3)) { break; } - ZEPHIR_CALL_METHOD(&attributeField, &unsetDefaultValues, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&defaultValue, &unsetDefaultValues, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&behavior, &modelsBehaviors, "current", NULL, 0); zephir_check_call_status(); - zephir_update_property_zval_zval(this_ptr, &attributeField, &defaultValue); - ZEPHIR_CALL_METHOD(NULL, &unsetDefaultValues, "next", NULL, 0); + ZEPHIR_CALL_METHOD(&status, &behavior, "notify", NULL, 0, &eventName, model); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) { + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&defaultValue); - ZEPHIR_INIT_NVAR(&attributeField); - ZEPHIR_CALL_METHOD(&_59$$56, &manager, "iskeepingsnapshots", NULL, 0, this_ptr); + ZEPHIR_INIT_NVAR(&behavior); + } + zephir_read_property(&_4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_4); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_5$$8); + ZEPHIR_CONCAT_SV(&_5$$8, "model:", &eventName); + ZEPHIR_CALL_METHOD(&status, &eventsManager, "fire", NULL, 0, &_5$$8, model); zephir_check_call_status(); - _60$$56 = zephir_is_true(&_59$$56); - if (_60$$56) { - _60$$56 = ZEPHIR_GLOBAL(orm).update_snapshot_on_save; + if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) { + RETURN_CCTOR(&status); } - if (_60$$56) { - zephir_update_property_zval(this_ptr, ZEND_STRL("snapshot"), &snapshot); + } + zephir_memory_observe(&customEventsManager); + zephir_read_property(&_4, this_ptr, ZEND_STRL("customEventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_6); + zephir_get_class(&_6, model, 1); + if (zephir_array_isset_fetch(&customEventsManager, &_4, &_6, 0)) { + ZEPHIR_INIT_VAR(&_7$$10); + ZEPHIR_CONCAT_SV(&_7$$10, "model:", &eventName); + ZEPHIR_CALL_METHOD(&status, &customEventsManager, "fire", NULL, 0, &_7$$10, model); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) { + RETURN_MM_BOOL(0); } } - RETURN_CCTOR(&success); + RETURN_CCTOR(&status); } -static PHP_METHOD(Phalcon_Mvc_Model, doLowUpdate) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, missingMethod) { - zval _21$$25, _22$$25, _37$$48, _38$$48; - zval _67; - zend_bool changed = 0, useDynamicUpdate = 0, _2, _69, _70, _15$$19, _17$$19, _32$$42, _34$$42; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_8 = NULL, *_19 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *metaData, metaData_sub, *connection, connection_sub, *table = NULL, table_sub, __$null, automaticAttributes, attributeField, bindSkip, bindDataTypes, bindType, bindTypes, columnMap, dataType, dataTypes, field, fields, manager, nonPrimary, newSnapshot, success, primaryKeys, snapshot, snapshotValue, uniqueKey, uniqueParams, value, values, updateValue, _0, _1, _68, *_3$$5, _4$$5, _5$$9, _6$$9, _7$$9, _9$$12, _10$$12, _11$$12, _12$$20, _13$$20, _14$$20, _16$$21, _18$$24, _20$$24, _23$$32, _24$$32, _25$$32, _26$$35, _27$$35, _28$$35, _29$$43, _30$$43, _31$$43, _33$$44, _35$$47, _36$$47, *_39$$53, _40$$53, _41$$57, _42$$57, _43$$57, _44$$60, _45$$60, _46$$60, _47$$66, _48$$66, _49$$66, _50$$69, _51$$69, _52$$69, _53$$74, _54$$74, _55$$74, *_56$$73, _57$$73, _58$$77, _59$$77, _60$$77, _61$$83, _62$$83, _63$$83, _64$$87, _65$$87, _66$$87, _71$$89, _72$$90; + zval eventName, _5$$8; + zval *model, model_sub, *eventName_param = NULL, *data, data_sub, modelsBehaviors, result, eventsManager, behavior, _0, _1, _4, *_2$$3, _3$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&metaData_sub); - ZVAL_UNDEF(&connection_sub); - ZVAL_UNDEF(&table_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&automaticAttributes); - ZVAL_UNDEF(&attributeField); - ZVAL_UNDEF(&bindSkip); - ZVAL_UNDEF(&bindDataTypes); - ZVAL_UNDEF(&bindType); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&dataType); - ZVAL_UNDEF(&dataTypes); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&nonPrimary); - ZVAL_UNDEF(&newSnapshot); - ZVAL_UNDEF(&success); - ZVAL_UNDEF(&primaryKeys); - ZVAL_UNDEF(&snapshot); - ZVAL_UNDEF(&snapshotValue); - ZVAL_UNDEF(&uniqueKey); - ZVAL_UNDEF(&uniqueParams); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&updateValue); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&data_sub); + ZVAL_UNDEF(&modelsBehaviors); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&behavior); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_68); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$9); - ZVAL_UNDEF(&_6$$9); - ZVAL_UNDEF(&_7$$9); - ZVAL_UNDEF(&_9$$12); - ZVAL_UNDEF(&_10$$12); - ZVAL_UNDEF(&_11$$12); - ZVAL_UNDEF(&_12$$20); - ZVAL_UNDEF(&_13$$20); - ZVAL_UNDEF(&_14$$20); - ZVAL_UNDEF(&_16$$21); - ZVAL_UNDEF(&_18$$24); - ZVAL_UNDEF(&_20$$24); - ZVAL_UNDEF(&_23$$32); - ZVAL_UNDEF(&_24$$32); - ZVAL_UNDEF(&_25$$32); - ZVAL_UNDEF(&_26$$35); - ZVAL_UNDEF(&_27$$35); - ZVAL_UNDEF(&_28$$35); - ZVAL_UNDEF(&_29$$43); - ZVAL_UNDEF(&_30$$43); - ZVAL_UNDEF(&_31$$43); - ZVAL_UNDEF(&_33$$44); - ZVAL_UNDEF(&_35$$47); - ZVAL_UNDEF(&_36$$47); - ZVAL_UNDEF(&_40$$53); - ZVAL_UNDEF(&_41$$57); - ZVAL_UNDEF(&_42$$57); - ZVAL_UNDEF(&_43$$57); - ZVAL_UNDEF(&_44$$60); - ZVAL_UNDEF(&_45$$60); - ZVAL_UNDEF(&_46$$60); - ZVAL_UNDEF(&_47$$66); - ZVAL_UNDEF(&_48$$66); - ZVAL_UNDEF(&_49$$66); - ZVAL_UNDEF(&_50$$69); - ZVAL_UNDEF(&_51$$69); - ZVAL_UNDEF(&_52$$69); - ZVAL_UNDEF(&_53$$74); - ZVAL_UNDEF(&_54$$74); - ZVAL_UNDEF(&_55$$74); - ZVAL_UNDEF(&_57$$73); - ZVAL_UNDEF(&_58$$77); - ZVAL_UNDEF(&_59$$77); - ZVAL_UNDEF(&_60$$77); - ZVAL_UNDEF(&_61$$83); - ZVAL_UNDEF(&_62$$83); - ZVAL_UNDEF(&_63$$83); - ZVAL_UNDEF(&_64$$87); - ZVAL_UNDEF(&_65$$87); - ZVAL_UNDEF(&_66$$87); - ZVAL_UNDEF(&_71$$89); - ZVAL_UNDEF(&_72$$90); - ZVAL_UNDEF(&_67); - ZVAL_UNDEF(&_21$$25); - ZVAL_UNDEF(&_22$$25); - ZVAL_UNDEF(&_37$$48); - ZVAL_UNDEF(&_38$$48); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&eventName); + ZVAL_UNDEF(&_5$$8); ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_OBJECT_OF_CLASS(metaData, phalcon_mvc_model_metadatainterface_ce) - Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_db_adapter_adapterinterface_ce) - Z_PARAM_ZVAL(table) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_STR(eventName) + Z_PARAM_ZVAL(data) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &metaData, &connection, &table); - ZEPHIR_SEPARATE_PARAM(table); - ZEPHIR_INIT_VAR(&bindSkip); - ZVAL_LONG(&bindSkip, 1024); - ZEPHIR_INIT_VAR(&fields); - array_init(&fields); - ZEPHIR_INIT_VAR(&values); - array_init(&values); - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - ZEPHIR_INIT_VAR(&newSnapshot); - array_init(&newSnapshot); - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - ZEPHIR_CALL_METHOD(&_1, &manager, "isusingdynamicupdate", NULL, 0, this_ptr); - zephir_check_call_status(); - useDynamicUpdate = zephir_get_boolval(&_1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&snapshot, &_0); - ZEPHIR_CALL_METHOD(&dataTypes, metaData, "getdatatypes", NULL, 0, this_ptr); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&bindDataTypes, metaData, "getbindtypes", NULL, 0, this_ptr); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&nonPrimary, metaData, "getnonprimarykeyattributes", NULL, 0, this_ptr); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&automaticAttributes, metaData, "getautomaticupdateattributes", NULL, 0, this_ptr); - zephir_check_call_status(); - if (ZEPHIR_GLOBAL(orm).column_renaming) { - ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, this_ptr); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&columnMap); - ZVAL_NULL(&columnMap); + zephir_fetch_params(1, 3, 0, &model, &eventName_param, &data); + if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string")); + RETURN_MM_NULL(); } - _2 = useDynamicUpdate; - if (_2) { - _2 = Z_TYPE_P(&snapshot) == IS_ARRAY; + if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { + zephir_get_strval(&eventName, eventName_param); + } else { + ZEPHIR_INIT_VAR(&eventName); } - if (EXPECTED(_2)) { - zephir_is_iterable(&nonPrimary, 0, "phalcon/Mvc/Model.zep", 4151); - if (Z_TYPE_P(&nonPrimary) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&nonPrimary), _3$$5) + zephir_memory_observe(&modelsBehaviors); + zephir_read_property(&_0, this_ptr, ZEND_STRL("behaviors"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + zephir_get_class(&_1, model, 1); + if (zephir_array_isset_fetch(&modelsBehaviors, &_0, &_1, 0)) { + zephir_is_iterable(&modelsBehaviors, 0, "phalcon/Mvc/Model/Manager.zep", 2062); + if (Z_TYPE_P(&modelsBehaviors) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&modelsBehaviors), _2$$3) { - ZEPHIR_INIT_NVAR(&field); - ZVAL_COPY(&field, _3$$5); - changed = 0; - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_5$$9); - object_init_ex(&_5$$9, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_6$$9); - zephir_get_class(&_6$$9, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_7$$9); - ZEPHIR_CONCAT_SVSVS(&_7$$9, "Column '", &field, "' in '", &_6$$9, "' isn't part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_5$$9, "__construct", &_8, 33, &_7$$9); - zephir_check_call_status(); - zephir_throw_exception_debug(&_5$$9, "phalcon/Mvc/Model.zep", 4045); - ZEPHIR_MM_RESTORE(); - return; - } - } - } else { - ZEPHIR_CPY_WRT(&attributeField, &field); + ZEPHIR_INIT_NVAR(&behavior); + ZVAL_COPY(&behavior, _2$$3); + ZEPHIR_CALL_METHOD(&result, &behavior, "missingmethod", NULL, 0, model, &eventName, data); + zephir_check_call_status(); + if (Z_TYPE_P(&result) != IS_NULL) { + RETURN_CCTOR(&result); } - if (!(zephir_array_isset(&automaticAttributes, &attributeField))) { - ZEPHIR_OBS_NVAR(&bindType); - if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, &bindDataTypes, &field, 0)))) { - ZEPHIR_INIT_NVAR(&_9$$12); - object_init_ex(&_9$$12, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_10$$12); - zephir_get_class(&_10$$12, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_11$$12); - ZEPHIR_CONCAT_SVSVS(&_11$$12, "Column '", &field, "' in '", &_10$$12, "' have not defined a bind data type"); - ZEPHIR_CALL_METHOD(NULL, &_9$$12, "__construct", &_8, 33, &_11$$12); - zephir_check_call_status(); - zephir_throw_exception_debug(&_9$$12, "phalcon/Mvc/Model.zep", 4058); - ZEPHIR_MM_RESTORE(); - return; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3$$3, &modelsBehaviors, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&behavior, &modelsBehaviors, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&result, &behavior, "missingmethod", NULL, 0, model, &eventName, data); + zephir_check_call_status(); + if (Z_TYPE_P(&result) != IS_NULL) { + RETURN_CCTOR(&result); } - ZEPHIR_OBS_NVAR(&value); - if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { - ZEPHIR_OBS_NVAR(&snapshotValue); - if (!(zephir_array_isset_fetch(&snapshotValue, &snapshot, &attributeField, 0))) { - changed = 1; - } else { - if (Z_TYPE_P(&value) == IS_NULL) { - changed = Z_TYPE_P(&snapshotValue) != IS_NULL; - } else { - if (Z_TYPE_P(&snapshotValue) == IS_NULL) { - changed = 1; - } else { - ZEPHIR_OBS_NVAR(&dataType); - if (UNEXPECTED(!(zephir_array_isset_fetch(&dataType, &dataTypes, &field, 0)))) { - ZEPHIR_INIT_NVAR(&_12$$20); - object_init_ex(&_12$$20, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_13$$20); - zephir_get_class(&_13$$20, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_14$$20); - ZEPHIR_CONCAT_SVSVS(&_14$$20, "Column '", &field, "' in '", &_13$$20, "' have not defined a data type"); - ZEPHIR_CALL_METHOD(NULL, &_12$$20, "__construct", &_8, 33, &_14$$20); - zephir_check_call_status(); - zephir_throw_exception_debug(&_12$$20, "phalcon/Mvc/Model.zep", 4088); - ZEPHIR_MM_RESTORE(); - return; - } - _15$$19 = Z_TYPE_P(&snapshotValue) == IS_OBJECT; - if (_15$$19) { - _15$$19 = zephir_instance_of_ev(&snapshotValue, phalcon_db_rawvalue_ce); - } - if (_15$$19) { - ZEPHIR_CALL_METHOD(&_16$$21, &snapshotValue, "getvalue", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&snapshotValue, &_16$$21); - } - ZEPHIR_CPY_WRT(&updateValue, &value); - _17$$19 = Z_TYPE_P(&value) == IS_OBJECT; - if (_17$$19) { - _17$$19 = zephir_instance_of_ev(&value, phalcon_db_rawvalue_ce); - } - if (_17$$19) { - ZEPHIR_CALL_METHOD(&updateValue, &value, "getvalue", NULL, 0); - zephir_check_call_status(); - } - do { - if (ZEPHIR_IS_LONG(&dataType, 8)) { - changed = zephir_get_boolval(&snapshotValue) != zephir_get_boolval(&updateValue); - break; - } - if (ZEPHIR_IS_LONG(&dataType, 3) || ZEPHIR_IS_LONG(&dataType, 7)) { - ZEPHIR_CALL_FUNCTION(&_18$$24, "floatval", &_19, 18, &snapshotValue); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_20$$24, "floatval", &_19, 18, &updateValue); - zephir_check_call_status(); - changed = !ZEPHIR_IS_IDENTICAL(&_18$$24, &_20$$24); - break; - } - if (ZEPHIR_IS_LONG(&dataType, 0) || ZEPHIR_IS_LONG(&dataType, 1) || ZEPHIR_IS_LONG(&dataType, 2) || ZEPHIR_IS_LONG(&dataType, 4) || ZEPHIR_IS_LONG(&dataType, 5) || ZEPHIR_IS_LONG(&dataType, 6) || ZEPHIR_IS_LONG(&dataType, 2) || ZEPHIR_IS_LONG(&dataType, 14)) { - zephir_cast_to_string(&_21$$25, &snapshotValue); - zephir_cast_to_string(&_22$$25, &updateValue); - changed = !ZEPHIR_IS_IDENTICAL(&_21$$25, &_22$$25); - break; - } - changed = !ZEPHIR_IS_EQUAL(&updateValue, &snapshotValue); - } while(0); - - } - } - } - if (changed) { - zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4138); - zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4139); - zephir_array_append(&bindTypes, &bindType, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4140); - } - zephir_array_update_zval(&newSnapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&newSnapshot, &attributeField, &__$null, PH_COPY | PH_SEPARATE); - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &nonPrimary, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_4$$5, &nonPrimary, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_4$$5)) { - break; - } - ZEPHIR_CALL_METHOD(&field, &nonPrimary, "current", NULL, 0); - zephir_check_call_status(); - changed = 0; - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_23$$32); - object_init_ex(&_23$$32, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_24$$32); - zephir_get_class(&_24$$32, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_25$$32); - ZEPHIR_CONCAT_SVSVS(&_25$$32, "Column '", &field, "' in '", &_24$$32, "' isn't part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_23$$32, "__construct", &_8, 33, &_25$$32); - zephir_check_call_status(); - zephir_throw_exception_debug(&_23$$32, "phalcon/Mvc/Model.zep", 4045); - ZEPHIR_MM_RESTORE(); - return; - } - } - } else { - ZEPHIR_CPY_WRT(&attributeField, &field); - } - if (!(zephir_array_isset(&automaticAttributes, &attributeField))) { - ZEPHIR_OBS_NVAR(&bindType); - if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, &bindDataTypes, &field, 0)))) { - ZEPHIR_INIT_NVAR(&_26$$35); - object_init_ex(&_26$$35, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_27$$35); - zephir_get_class(&_27$$35, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_28$$35); - ZEPHIR_CONCAT_SVSVS(&_28$$35, "Column '", &field, "' in '", &_27$$35, "' have not defined a bind data type"); - ZEPHIR_CALL_METHOD(NULL, &_26$$35, "__construct", &_8, 33, &_28$$35); - zephir_check_call_status(); - zephir_throw_exception_debug(&_26$$35, "phalcon/Mvc/Model.zep", 4058); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_OBS_NVAR(&value); - if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { - ZEPHIR_OBS_NVAR(&snapshotValue); - if (!(zephir_array_isset_fetch(&snapshotValue, &snapshot, &attributeField, 0))) { - changed = 1; - } else { - if (Z_TYPE_P(&value) == IS_NULL) { - changed = Z_TYPE_P(&snapshotValue) != IS_NULL; - } else { - if (Z_TYPE_P(&snapshotValue) == IS_NULL) { - changed = 1; - } else { - ZEPHIR_OBS_NVAR(&dataType); - if (UNEXPECTED(!(zephir_array_isset_fetch(&dataType, &dataTypes, &field, 0)))) { - ZEPHIR_INIT_NVAR(&_29$$43); - object_init_ex(&_29$$43, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_30$$43); - zephir_get_class(&_30$$43, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_31$$43); - ZEPHIR_CONCAT_SVSVS(&_31$$43, "Column '", &field, "' in '", &_30$$43, "' have not defined a data type"); - ZEPHIR_CALL_METHOD(NULL, &_29$$43, "__construct", &_8, 33, &_31$$43); - zephir_check_call_status(); - zephir_throw_exception_debug(&_29$$43, "phalcon/Mvc/Model.zep", 4088); - ZEPHIR_MM_RESTORE(); - return; - } - _32$$42 = Z_TYPE_P(&snapshotValue) == IS_OBJECT; - if (_32$$42) { - _32$$42 = zephir_instance_of_ev(&snapshotValue, phalcon_db_rawvalue_ce); - } - if (_32$$42) { - ZEPHIR_CALL_METHOD(&_33$$44, &snapshotValue, "getvalue", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&snapshotValue, &_33$$44); - } - ZEPHIR_CPY_WRT(&updateValue, &value); - _34$$42 = Z_TYPE_P(&value) == IS_OBJECT; - if (_34$$42) { - _34$$42 = zephir_instance_of_ev(&value, phalcon_db_rawvalue_ce); - } - if (_34$$42) { - ZEPHIR_CALL_METHOD(&updateValue, &value, "getvalue", NULL, 0); - zephir_check_call_status(); - } - do { - if (ZEPHIR_IS_LONG(&dataType, 8)) { - changed = zephir_get_boolval(&snapshotValue) != zephir_get_boolval(&updateValue); - break; - } - if (ZEPHIR_IS_LONG(&dataType, 3) || ZEPHIR_IS_LONG(&dataType, 7)) { - ZEPHIR_CALL_FUNCTION(&_35$$47, "floatval", &_19, 18, &snapshotValue); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_36$$47, "floatval", &_19, 18, &updateValue); - zephir_check_call_status(); - changed = !ZEPHIR_IS_IDENTICAL(&_35$$47, &_36$$47); - break; - } - if (ZEPHIR_IS_LONG(&dataType, 0) || ZEPHIR_IS_LONG(&dataType, 1) || ZEPHIR_IS_LONG(&dataType, 2) || ZEPHIR_IS_LONG(&dataType, 4) || ZEPHIR_IS_LONG(&dataType, 5) || ZEPHIR_IS_LONG(&dataType, 6) || ZEPHIR_IS_LONG(&dataType, 2) || ZEPHIR_IS_LONG(&dataType, 14)) { - zephir_cast_to_string(&_37$$48, &snapshotValue); - zephir_cast_to_string(&_38$$48, &updateValue); - changed = !ZEPHIR_IS_IDENTICAL(&_37$$48, &_38$$48); - break; - } - changed = !ZEPHIR_IS_EQUAL(&updateValue, &snapshotValue); - } while(0); - - } - } - } - if (changed) { - zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4138); - zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4139); - zephir_array_append(&bindTypes, &bindType, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4140); - } - zephir_array_update_zval(&newSnapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&newSnapshot, &attributeField, &__$null, PH_COPY | PH_SEPARATE); - } - } - ZEPHIR_CALL_METHOD(NULL, &nonPrimary, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&field); - if (!(zephir_fast_count_int(&fields))) { - zephir_update_property_zval(this_ptr, ZEND_STRL("oldSnapshot"), &snapshot); - RETURN_MM_BOOL(1); - } - } else { - zephir_is_iterable(&nonPrimary, 0, "phalcon/Mvc/Model.zep", 4206); - if (Z_TYPE_P(&nonPrimary) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&nonPrimary), _39$$53) - { - ZEPHIR_INIT_NVAR(&field); - ZVAL_COPY(&field, _39$$53); - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_41$$57); - object_init_ex(&_41$$57, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_42$$57); - zephir_get_class(&_42$$57, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_43$$57); - ZEPHIR_CONCAT_SVSVS(&_43$$57, "Column '", &field, "' in '", &_42$$57, "' isn't part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_41$$57, "__construct", &_8, 33, &_43$$57); - zephir_check_call_status(); - zephir_throw_exception_debug(&_41$$57, "phalcon/Mvc/Model.zep", 4169); - ZEPHIR_MM_RESTORE(); - return; - } - } - } else { - ZEPHIR_CPY_WRT(&attributeField, &field); - } - if (!(zephir_array_isset(&automaticAttributes, &attributeField))) { - ZEPHIR_OBS_NVAR(&bindType); - if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, &bindDataTypes, &field, 0)))) { - ZEPHIR_INIT_NVAR(&_44$$60); - object_init_ex(&_44$$60, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_45$$60); - zephir_get_class(&_45$$60, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_46$$60); - ZEPHIR_CONCAT_SVSVS(&_46$$60, "Column '", &field, "' in '", &_45$$60, "' have not defined a bind data type"); - ZEPHIR_CALL_METHOD(NULL, &_44$$60, "__construct", &_8, 33, &_46$$60); - zephir_check_call_status(); - zephir_throw_exception_debug(&_44$$60, "phalcon/Mvc/Model.zep", 4183); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_OBS_NVAR(&value); - if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { - zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4194); - zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4195); - zephir_array_append(&bindTypes, &bindType, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4196); - zephir_array_update_zval(&newSnapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&newSnapshot, &attributeField, &__$null, PH_COPY | PH_SEPARATE); - zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4200); - zephir_array_append(&values, &__$null, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4201); - zephir_array_append(&bindTypes, &bindSkip, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4202); - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &nonPrimary, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_40$$53, &nonPrimary, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_40$$53)) { - break; - } - ZEPHIR_CALL_METHOD(&field, &nonPrimary, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_47$$66); - object_init_ex(&_47$$66, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_48$$66); - zephir_get_class(&_48$$66, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_49$$66); - ZEPHIR_CONCAT_SVSVS(&_49$$66, "Column '", &field, "' in '", &_48$$66, "' isn't part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_47$$66, "__construct", &_8, 33, &_49$$66); - zephir_check_call_status(); - zephir_throw_exception_debug(&_47$$66, "phalcon/Mvc/Model.zep", 4169); - ZEPHIR_MM_RESTORE(); - return; - } - } - } else { - ZEPHIR_CPY_WRT(&attributeField, &field); - } - if (!(zephir_array_isset(&automaticAttributes, &attributeField))) { - ZEPHIR_OBS_NVAR(&bindType); - if (UNEXPECTED(!(zephir_array_isset_fetch(&bindType, &bindDataTypes, &field, 0)))) { - ZEPHIR_INIT_NVAR(&_50$$69); - object_init_ex(&_50$$69, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_51$$69); - zephir_get_class(&_51$$69, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_52$$69); - ZEPHIR_CONCAT_SVSVS(&_52$$69, "Column '", &field, "' in '", &_51$$69, "' have not defined a bind data type"); - ZEPHIR_CALL_METHOD(NULL, &_50$$69, "__construct", &_8, 33, &_52$$69); - zephir_check_call_status(); - zephir_throw_exception_debug(&_50$$69, "phalcon/Mvc/Model.zep", 4183); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_OBS_NVAR(&value); - if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { - zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4194); - zephir_array_append(&values, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4195); - zephir_array_append(&bindTypes, &bindType, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4196); - zephir_array_update_zval(&newSnapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&newSnapshot, &attributeField, &__$null, PH_COPY | PH_SEPARATE); - zephir_array_append(&fields, &field, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4200); - zephir_array_append(&values, &__$null, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4201); - zephir_array_append(&bindTypes, &bindSkip, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4202); - } - } - ZEPHIR_CALL_METHOD(NULL, &nonPrimary, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&field); - } - if (!(zephir_fast_count_int(&fields))) { - RETURN_MM_BOOL(1); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("uniqueKey"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&uniqueKey, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("uniqueParams"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&uniqueParams, &_0); - if (Z_TYPE_P(&uniqueParams) != IS_ARRAY) { - ZEPHIR_CALL_METHOD(&primaryKeys, metaData, "getprimarykeyattributes", NULL, 0, this_ptr); - zephir_check_call_status(); - if (UNEXPECTED(!(zephir_fast_count_int(&primaryKeys)))) { - ZEPHIR_INIT_VAR(&_53$$74); - object_init_ex(&_53$$74, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_54$$74); - zephir_get_class(&_54$$74, this_ptr, 0); - ZEPHIR_INIT_VAR(&_55$$74); - ZEPHIR_CONCAT_SVS(&_55$$74, "A primary key must be defined in the model in order to perform the operation in '", &_54$$74, "'"); - ZEPHIR_CALL_METHOD(NULL, &_53$$74, "__construct", &_8, 33, &_55$$74); - zephir_check_call_status(); - zephir_throw_exception_debug(&_53$$74, "phalcon/Mvc/Model.zep", 4229); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_NVAR(&uniqueParams); - array_init(&uniqueParams); - zephir_is_iterable(&primaryKeys, 0, "phalcon/Mvc/Model.zep", 4256); - if (Z_TYPE_P(&primaryKeys) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&primaryKeys), _56$$73) - { - ZEPHIR_INIT_NVAR(&field); - ZVAL_COPY(&field, _56$$73); - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { - ZEPHIR_INIT_NVAR(&_58$$77); - object_init_ex(&_58$$77, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_59$$77); - zephir_get_class(&_59$$77, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_60$$77); - ZEPHIR_CONCAT_SVSVS(&_60$$77, "Column '", &field, "' in '", &_59$$77, "' isn't part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_58$$77, "__construct", &_8, 33, &_60$$77); - zephir_check_call_status(); - zephir_throw_exception_debug(&_58$$77, "phalcon/Mvc/Model.zep", 4242); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&attributeField, &field); - } - ZEPHIR_OBS_NVAR(&value); - if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { - zephir_array_update_zval(&newSnapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); - zephir_array_append(&uniqueParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4250); - } else { - zephir_array_update_zval(&newSnapshot, &attributeField, &__$null, PH_COPY | PH_SEPARATE); - zephir_array_append(&uniqueParams, &__$null, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4253); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &primaryKeys, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_57$$73, &primaryKeys, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_57$$73)) { - break; - } - ZEPHIR_CALL_METHOD(&field, &primaryKeys, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { - ZEPHIR_INIT_NVAR(&_61$$83); - object_init_ex(&_61$$83, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_62$$83); - zephir_get_class(&_62$$83, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_63$$83); - ZEPHIR_CONCAT_SVSVS(&_63$$83, "Column '", &field, "' in '", &_62$$83, "' isn't part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_61$$83, "__construct", &_8, 33, &_63$$83); - zephir_check_call_status(); - zephir_throw_exception_debug(&_61$$83, "phalcon/Mvc/Model.zep", 4242); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&attributeField, &field); - } - ZEPHIR_OBS_NVAR(&value); - if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { - zephir_array_update_zval(&newSnapshot, &attributeField, &value, PH_COPY | PH_SEPARATE); - zephir_array_append(&uniqueParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4250); - } else { - zephir_array_update_zval(&newSnapshot, &attributeField, &__$null, PH_COPY | PH_SEPARATE); - zephir_array_append(&uniqueParams, &__$null, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4253); - } - ZEPHIR_CALL_METHOD(NULL, &primaryKeys, "next", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&field); - } - if (Z_TYPE_P(table) == IS_ARRAY) { - zephir_array_fetch_long(&_64$$87, table, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 4262); - zephir_array_fetch_long(&_65$$87, table, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 4262); - ZEPHIR_INIT_VAR(&_66$$87); - ZEPHIR_CONCAT_VSV(&_66$$87, &_64$$87, ".", &_65$$87); - ZEPHIR_CPY_WRT(table, &_66$$87); + ZEPHIR_INIT_NVAR(&behavior); } - ZEPHIR_INIT_VAR(&_67); - zephir_create_array(&_67, 3, 0); - zephir_array_update_string(&_67, SL("conditions"), &uniqueKey, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_67, SL("bind"), &uniqueParams, PH_COPY | PH_SEPARATE); - zephir_memory_observe(&_68); - zephir_read_property(&_68, this_ptr, ZEND_STRL("uniqueTypes"), PH_NOISY_CC); - zephir_array_update_string(&_67, SL("bindTypes"), &_68, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&success, connection, "update", NULL, 0, table, &fields, &values, &_67, &bindTypes); - zephir_check_call_status(); - _69 = zephir_is_true(&success); - if (_69) { - ZEPHIR_CALL_METHOD(&_1, &manager, "iskeepingsnapshots", NULL, 0, this_ptr); + zephir_read_property(&_4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_4); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_5$$8); + ZEPHIR_CONCAT_SV(&_5$$8, "model:", &eventName); + ZEPHIR_RETURN_CALL_METHOD(&eventsManager, "fire", NULL, 0, &_5$$8, model, data); zephir_check_call_status(); - _69 = zephir_is_true(&_1); + RETURN_MM(); } - _70 = _69; - if (_70) { - _70 = ZEPHIR_GLOBAL(orm).update_snapshot_on_save; + RETURN_MM_NULL(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, setConnectionService) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval connectionService; + zval *model, model_sub, *connectionService_param = NULL; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&connectionService); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_STR(connectionService) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &model, &connectionService_param); + if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string")); + RETURN_MM_NULL(); } - if (_70) { - if (Z_TYPE_P(&snapshot) == IS_ARRAY) { - zephir_update_property_zval(this_ptr, ZEND_STRL("oldSnapshot"), &snapshot); - ZEPHIR_INIT_VAR(&_71$$89); - zephir_fast_array_merge(&_71$$89, &snapshot, &newSnapshot); - zephir_update_property_zval(this_ptr, ZEND_STRL("snapshot"), &_71$$89); - } else { - ZEPHIR_INIT_VAR(&_72$$90); - array_init(&_72$$90); - zephir_update_property_zval(this_ptr, ZEND_STRL("oldSnapshot"), &_72$$90); - zephir_update_property_zval(this_ptr, ZEND_STRL("snapshot"), &newSnapshot); - } + if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) { + zephir_get_strval(&connectionService, connectionService_param); + } else { + ZEPHIR_INIT_VAR(&connectionService); } - RETURN_CCTOR(&success); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setreadconnectionservice", NULL, 0, model, &connectionService); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setwriteconnectionservice", NULL, 0, model, &connectionService); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model, has) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, setCustomEventsManager) { - zend_bool _7$$11, _17$$19; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_6 = NULL, *_12 = NULL, *_22 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, numberEmpty = 0, numberPrimary = 0; - zval *metaData, metaData_sub, *connection, connection_sub, __$null, attributeField, bindDataTypes, columnMap, field, joinWhere, num, primaryKeys, schema, source, table, type, uniqueKey, uniqueParams, uniqueTypes, value, wherePk, _0, _27, _28, _29, _30, *_1$$3, _2$$3, _3$$9, _4$$9, _5$$9, _8$$14, _9$$14, _10$$14, _11$$7, _13$$7, _14$$17, _15$$17, _16$$17, _18$$22, _19$$22, _20$$22, _21$$15, _23$$15, _24$$25, _25$$26, _26$$27, _31$$30, _32$$31; + zval *model, model_sub, *eventsManager, eventsManager_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&metaData_sub); - ZVAL_UNDEF(&connection_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&attributeField); - ZVAL_UNDEF(&bindDataTypes); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&joinWhere); - ZVAL_UNDEF(&num); - ZVAL_UNDEF(&primaryKeys); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&table); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&uniqueKey); - ZVAL_UNDEF(&uniqueParams); - ZVAL_UNDEF(&uniqueTypes); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&wherePk); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&eventsManager_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_27); - ZVAL_UNDEF(&_28); - ZVAL_UNDEF(&_29); - ZVAL_UNDEF(&_30); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$9); - ZVAL_UNDEF(&_4$$9); - ZVAL_UNDEF(&_5$$9); - ZVAL_UNDEF(&_8$$14); - ZVAL_UNDEF(&_9$$14); - ZVAL_UNDEF(&_10$$14); - ZVAL_UNDEF(&_11$$7); - ZVAL_UNDEF(&_13$$7); - ZVAL_UNDEF(&_14$$17); - ZVAL_UNDEF(&_15$$17); - ZVAL_UNDEF(&_16$$17); - ZVAL_UNDEF(&_18$$22); - ZVAL_UNDEF(&_19$$22); - ZVAL_UNDEF(&_20$$22); - ZVAL_UNDEF(&_21$$15); - ZVAL_UNDEF(&_23$$15); - ZVAL_UNDEF(&_24$$25); - ZVAL_UNDEF(&_25$$26); - ZVAL_UNDEF(&_26$$27); - ZVAL_UNDEF(&_31$$30); - ZVAL_UNDEF(&_32$$31); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(metaData, phalcon_mvc_model_metadatainterface_ce) - Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_db_adapter_adapterinterface_ce) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &metaData, &connection); - ZEPHIR_INIT_VAR(&uniqueParams); - ZVAL_NULL(&uniqueParams); - ZEPHIR_INIT_VAR(&uniqueTypes); - ZVAL_NULL(&uniqueTypes); - zephir_read_property(&_0, this_ptr, ZEND_STRL("uniqueKey"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&uniqueKey, &_0); - if (Z_TYPE_P(&uniqueKey) == IS_NULL) { - ZEPHIR_CALL_METHOD(&primaryKeys, metaData, "getprimarykeyattributes", NULL, 0, this_ptr); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&bindDataTypes, metaData, "getbindtypes", NULL, 0, this_ptr); - zephir_check_call_status(); - numberPrimary = zephir_fast_count_int(&primaryKeys); - if (!(numberPrimary)) { - RETURN_MM_BOOL(0); - } - if (ZEPHIR_GLOBAL(orm).column_renaming) { - ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, this_ptr); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&columnMap); - ZVAL_NULL(&columnMap); - } - numberEmpty = 0; - ZEPHIR_INIT_VAR(&wherePk); - array_init(&wherePk); - ZEPHIR_INIT_NVAR(&uniqueParams); - array_init(&uniqueParams); - ZEPHIR_INIT_NVAR(&uniqueTypes); - array_init(&uniqueTypes); - zephir_is_iterable(&primaryKeys, 0, "phalcon/Mvc/Model.zep", 4386); - if (Z_TYPE_P(&primaryKeys) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&primaryKeys), _1$$3) - { - ZEPHIR_INIT_NVAR(&field); - ZVAL_COPY(&field, _1$$3); - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { - ZEPHIR_INIT_NVAR(&_3$$9); - object_init_ex(&_3$$9, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_4$$9); - zephir_get_class(&_4$$9, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_5$$9); - ZEPHIR_CONCAT_SVSVS(&_5$$9, "Column '", &field, "' in '", &_4$$9, "' isn't part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_3$$9, "__construct", &_6, 33, &_5$$9); - zephir_check_call_status(); - zephir_throw_exception_debug(&_3$$9, "phalcon/Mvc/Model.zep", 4345); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&attributeField, &field); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_NULL(&value); - ZEPHIR_OBS_NVAR(&value); - if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { - _7$$11 = Z_TYPE_P(&value) == IS_NULL; - if (!(_7$$11)) { - _7$$11 = ZEPHIR_IS_STRING_IDENTICAL(&value, ""); - } - if (_7$$11) { - numberEmpty++; - } - zephir_array_append(&uniqueParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4366); - } else { - zephir_array_append(&uniqueParams, &__$null, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4368); - numberEmpty++; - } - ZEPHIR_OBS_NVAR(&type); - if (UNEXPECTED(!(zephir_array_isset_fetch(&type, &bindDataTypes, &field, 0)))) { - ZEPHIR_INIT_NVAR(&_8$$14); - object_init_ex(&_8$$14, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_9$$14); - zephir_get_class(&_9$$14, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_10$$14); - ZEPHIR_CONCAT_SVSVS(&_10$$14, "Column '", &field, "' in '", &_9$$14, "' isn't part of the table columns"); - ZEPHIR_CALL_METHOD(NULL, &_8$$14, "__construct", &_6, 33, &_10$$14); - zephir_check_call_status(); - zephir_throw_exception_debug(&_8$$14, "phalcon/Mvc/Model.zep", 4375); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_append(&uniqueTypes, &type, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4378); - ZEPHIR_CALL_METHOD(&_11$$7, connection, "escapeidentifier", &_12, 0, &field); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_13$$7); - ZEPHIR_CONCAT_VS(&_13$$7, &_11$$7, " = ?"); - zephir_array_append(&wherePk, &_13$$7, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4379); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &primaryKeys, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2$$3, &primaryKeys, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&field, &primaryKeys, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { - ZEPHIR_INIT_NVAR(&_14$$17); - object_init_ex(&_14$$17, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_15$$17); - zephir_get_class(&_15$$17, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_16$$17); - ZEPHIR_CONCAT_SVSVS(&_16$$17, "Column '", &field, "' in '", &_15$$17, "' isn't part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_14$$17, "__construct", &_6, 33, &_16$$17); - zephir_check_call_status(); - zephir_throw_exception_debug(&_14$$17, "phalcon/Mvc/Model.zep", 4345); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&attributeField, &field); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_NULL(&value); - ZEPHIR_OBS_NVAR(&value); - if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { - _17$$19 = Z_TYPE_P(&value) == IS_NULL; - if (!(_17$$19)) { - _17$$19 = ZEPHIR_IS_STRING_IDENTICAL(&value, ""); - } - if (_17$$19) { - numberEmpty++; - } - zephir_array_append(&uniqueParams, &value, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4366); - } else { - zephir_array_append(&uniqueParams, &__$null, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4368); - numberEmpty++; - } - ZEPHIR_OBS_NVAR(&type); - if (UNEXPECTED(!(zephir_array_isset_fetch(&type, &bindDataTypes, &field, 0)))) { - ZEPHIR_INIT_NVAR(&_18$$22); - object_init_ex(&_18$$22, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_19$$22); - zephir_get_class(&_19$$22, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_20$$22); - ZEPHIR_CONCAT_SVSVS(&_20$$22, "Column '", &field, "' in '", &_19$$22, "' isn't part of the table columns"); - ZEPHIR_CALL_METHOD(NULL, &_18$$22, "__construct", &_6, 33, &_20$$22); - zephir_check_call_status(); - zephir_throw_exception_debug(&_18$$22, "phalcon/Mvc/Model.zep", 4375); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_append(&uniqueTypes, &type, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4378); - ZEPHIR_CALL_METHOD(&_21$$15, connection, "escapeidentifier", &_22, 0, &field); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_23$$15); - ZEPHIR_CONCAT_VS(&_23$$15, &_21$$15, " = ?"); - zephir_array_append(&wherePk, &_23$$15, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4379); - ZEPHIR_CALL_METHOD(NULL, &primaryKeys, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&field); - if (numberPrimary == numberEmpty) { - RETURN_MM_BOOL(0); - } - ZEPHIR_INIT_VAR(&joinWhere); - zephir_fast_join_str(&joinWhere, SL(" AND "), &wherePk); - zephir_update_property_zval(this_ptr, ZEND_STRL("uniqueKey"), &joinWhere); - zephir_update_property_zval(this_ptr, ZEND_STRL("uniqueParams"), &uniqueParams); - zephir_update_property_zval(this_ptr, ZEND_STRL("uniqueTypes"), &uniqueTypes); - ZEPHIR_CPY_WRT(&uniqueKey, &joinWhere); + zephir_fetch_params(1, 2, 0, &model, &eventsManager); + ZEPHIR_INIT_VAR(&_0); + zephir_get_class(&_0, model, 1); + zephir_update_property_array(this_ptr, SL("customEventsManager"), &_0, eventsManager); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, setDI) +{ + zval *container, container_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&container_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &container); + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, setEventsManager) +{ + zval *eventsManager, eventsManager_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&eventsManager_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); + zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, setModelPrefix) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *prefix_param = NULL; + zval prefix; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&prefix); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(prefix) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &prefix_param); + if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be of the type string")); + RETURN_MM_NULL(); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("dirtyState"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_is_true(&_0))) { - RETURN_MM_BOOL(1); + if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) { + zephir_get_strval(&prefix, prefix_param); + } else { + ZEPHIR_INIT_VAR(&prefix); } - if (Z_TYPE_P(&uniqueKey) == IS_NULL) { - zephir_read_property(&_24$$25, this_ptr, ZEND_STRL("uniqueKey"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&uniqueKey, &_24$$25); + zephir_update_property_zval(this_ptr, ZEND_STRL("prefix"), &prefix); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, setModelSchema) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval schema; + zval *model, model_sub, *schema_param = NULL, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&schema); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_STR(schema) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &model, &schema_param); + if (UNEXPECTED(Z_TYPE_P(schema_param) != IS_STRING && Z_TYPE_P(schema_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schema' must be of the type string")); + RETURN_MM_NULL(); } - if (Z_TYPE_P(&uniqueParams) == IS_NULL) { - zephir_read_property(&_25$$26, this_ptr, ZEND_STRL("uniqueParams"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&uniqueParams, &_25$$26); + if (EXPECTED(Z_TYPE_P(schema_param) == IS_STRING)) { + zephir_get_strval(&schema, schema_param); + } else { + ZEPHIR_INIT_VAR(&schema); } - if (Z_TYPE_P(&uniqueTypes) == IS_NULL) { - zephir_read_property(&_26$$27, this_ptr, ZEND_STRL("uniqueTypes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&uniqueTypes, &_26$$27); + ZEPHIR_INIT_VAR(&_0); + zephir_get_class(&_0, model, 1); + zephir_update_property_array(this_ptr, SL("schemas"), &_0, &schema); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, setModelSource) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval source; + zval *model, model_sub, *source_param = NULL, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&source); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_STR(source) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &model, &source_param); + if (UNEXPECTED(Z_TYPE_P(source_param) != IS_STRING && Z_TYPE_P(source_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'source' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_CALL_METHOD(&schema, this_ptr, "getschema", NULL, 423); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, this_ptr, "getsource", NULL, 424); - zephir_check_call_status(); - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_VAR(&table); - zephir_create_array(&table, 2, 0); - zephir_array_fast_append(&table, &schema); - zephir_array_fast_append(&table, &source); + if (EXPECTED(Z_TYPE_P(source_param) == IS_STRING)) { + zephir_get_strval(&source, source_param); } else { - ZEPHIR_CPY_WRT(&table, &source); + ZEPHIR_INIT_VAR(&source); } - ZEPHIR_CALL_METHOD(&_27, connection, "escapeidentifier", NULL, 0, &table); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_28); - ZEPHIR_CONCAT_SVSV(&_28, "SELECT COUNT(*) \"rowcount\" FROM ", &_27, " WHERE ", &uniqueKey); - ZVAL_NULL(&_29); - ZEPHIR_CALL_METHOD(&num, connection, "fetchone", NULL, 0, &_28, &_29, &uniqueParams, &uniqueTypes); - zephir_check_call_status(); - zephir_array_fetch_string(&_30, &num, SL("rowcount"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 4440); - if (zephir_is_true(&_30)) { - ZVAL_UNDEF(&_31$$30); - ZVAL_LONG(&_31$$30, 0); - zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &_31$$30); - RETURN_MM_BOOL(1); + ZEPHIR_INIT_VAR(&_0); + zephir_get_class(&_0, model, 1); + zephir_update_property_array(this_ptr, SL("sources"), &_0, &source); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Manager, setReadConnectionService) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval connectionService; + zval *model, model_sub, *connectionService_param = NULL, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&connectionService); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_STR(connectionService) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &model, &connectionService_param); + if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) { + zephir_get_strval(&connectionService, connectionService_param); } else { - ZVAL_UNDEF(&_32$$31); - ZVAL_LONG(&_32$$31, 1); - zephir_update_property_zval(this_ptr, ZEND_STRL("dirtyState"), &_32$$31); + ZEPHIR_INIT_VAR(&connectionService); } - RETURN_MM_BOOL(0); + ZEPHIR_INIT_VAR(&_0); + zephir_get_class(&_0, model, 1); + zephir_update_property_array(this_ptr, SL("readConnectionServices"), &_0, &connectionService); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model, getRelatedRecords) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, setReusableRecords) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval arguments; - zval *modelName_param = NULL, *method_param = NULL, *arguments_param = NULL, manager, relation, queryMethod, extraArgs, alias, _0, _1$$3, _2$$3, _3$$5, _4$$5, _5$$5; - zval modelName, method; + zval *modelName_param = NULL, *key_param = NULL, *records, records_sub; + zval modelName, key; zval *this_ptr = getThis(); ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&queryMethod); - ZVAL_UNDEF(&extraArgs); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&arguments); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&records_sub); ZEND_PARSE_PARAMETERS_START(3, 3) Z_PARAM_STR(modelName) - Z_PARAM_STR(method) - Z_PARAM_ARRAY(arguments) + Z_PARAM_STR(key) + Z_PARAM_ZVAL(records) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &modelName_param, &method_param, &arguments_param); + zephir_fetch_params(1, 3, 0, &modelName_param, &key_param, &records); if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); RETURN_MM_NULL(); @@ -42989,2745 +44478,1837 @@ static PHP_METHOD(Phalcon_Mvc_Model, getRelatedRecords) } else { ZEPHIR_INIT_VAR(&modelName); } - if (UNEXPECTED(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 of the type string")); + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(method_param) == IS_STRING)) { - zephir_get_strval(&method, method_param); + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); } else { - ZEPHIR_INIT_VAR(&method); - } - ZEPHIR_OBS_COPY_OR_DUP(&arguments, arguments_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - ZEPHIR_INIT_VAR(&relation); - ZVAL_BOOL(&relation, 0); - ZEPHIR_INIT_VAR(&queryMethod); - ZVAL_NULL(&queryMethod); - zephir_memory_observe(&extraArgs); - zephir_array_isset_long_fetch(&extraArgs, &arguments, 0, 0); - if (zephir_start_with_str(&method, SL("get"))) { - ZVAL_LONG(&_1$$3, 3); - ZEPHIR_INIT_VAR(&alias); - zephir_substr(&alias, &method, 3 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - ZEPHIR_CALL_METHOD(&_2$$3, &manager, "getrelationbyalias", NULL, 0, &modelName, &alias); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&relation, &_2$$3); - if (Z_TYPE_P(&relation) != IS_OBJECT) { - RETURN_MM_BOOL(0); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelated", NULL, 0, &alias, &extraArgs); - zephir_check_call_status(); - RETURN_MM(); - } - if (zephir_start_with_str(&method, SL("count"))) { - ZEPHIR_INIT_NVAR(&queryMethod); - ZVAL_STRING(&queryMethod, "count"); - ZVAL_LONG(&_4$$5, 5); - ZEPHIR_INIT_VAR(&_5$$5); - zephir_substr(&_5$$5, &method, 5 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - ZEPHIR_CALL_METHOD(&_3$$5, &manager, "getrelationbyalias", NULL, 0, &modelName, &_5$$5); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&relation, &_3$$5); - if (Z_TYPE_P(&relation) != IS_OBJECT) { - RETURN_MM_BOOL(0); - } - ZEPHIR_RETURN_CALL_METHOD(&manager, "getrelationrecords", NULL, 0, &relation, this_ptr, &extraArgs, &queryMethod); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_INIT_VAR(&key); } - RETURN_MM_BOOL(0); + zephir_update_property_array(this_ptr, SL("reusable"), &key, records); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model, groupResult) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, setWriteConnectionService) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *functionName_param = NULL, *alias_param = NULL, *parameters = NULL, parameters_sub, __$null, params, distinctColumn, groupColumn, columns, resultset, cache, firstRow, groupColumns, builder, query, container, manager, transaction, bindParams, bindTypes, _0, _1, _2; - zval functionName, alias; + zval connectionService; + zval *model, model_sub, *connectionService_param = NULL, _0; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&functionName); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(¶meters_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&distinctColumn); - ZVAL_UNDEF(&groupColumn); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&resultset); - ZVAL_UNDEF(&cache); - ZVAL_UNDEF(&firstRow); - ZVAL_UNDEF(&groupColumns); - ZVAL_UNDEF(&builder); - ZVAL_UNDEF(&query); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&transaction); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&model_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(functionName) - Z_PARAM_STR(alias) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(parameters) + ZVAL_UNDEF(&connectionService); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_STR(connectionService) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &functionName_param, &alias_param, ¶meters); - if (UNEXPECTED(Z_TYPE_P(functionName_param) != IS_STRING && Z_TYPE_P(functionName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'functionName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(functionName_param) == IS_STRING)) { - zephir_get_strval(&functionName, functionName_param); - } else { - ZEPHIR_INIT_VAR(&functionName); - } - if (UNEXPECTED(Z_TYPE_P(alias_param) != IS_STRING && Z_TYPE_P(alias_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'alias' must be of the type string")); + zephir_fetch_params(1, 2, 0, &model, &connectionService_param); + if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(alias_param) == IS_STRING)) { - zephir_get_strval(&alias, alias_param); + if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) { + zephir_get_strval(&connectionService, connectionService_param); } else { - ZEPHIR_INIT_VAR(&alias); + ZEPHIR_INIT_VAR(&connectionService); } - if (!parameters) { - parameters = ¶meters_sub; - parameters = &__$null; - } - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "modelsManager"); - ZEPHIR_CALL_METHOD(&_0, &container, "getshared", NULL, 0, &_1); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&manager, &_0); - if (Z_TYPE_P(parameters) != IS_ARRAY) { - ZEPHIR_INIT_VAR(¶ms); - array_init(¶ms); - if (Z_TYPE_P(parameters) != IS_NULL) { - zephir_array_append(¶ms, parameters, PH_SEPARATE, "phalcon/Mvc/Model.zep", 4545); - } - } else { - ZEPHIR_CPY_WRT(¶ms, parameters); - } - zephir_memory_observe(&groupColumn); - if (!(zephir_array_isset_string_fetch(&groupColumn, ¶ms, SL("column"), 0))) { - ZEPHIR_INIT_NVAR(&groupColumn); - ZVAL_STRING(&groupColumn, "*"); - } - zephir_memory_observe(&distinctColumn); - if (zephir_array_isset_string_fetch(&distinctColumn, ¶ms, SL("distinct"), 0)) { - ZEPHIR_INIT_VAR(&columns); - ZEPHIR_CONCAT_VSVSV(&columns, &functionName, "(DISTINCT ", &distinctColumn, ") AS ", &alias); - } else { - zephir_memory_observe(&groupColumns); - ZEPHIR_INIT_NVAR(&columns); - if (zephir_array_isset_string_fetch(&groupColumns, ¶ms, SL("group"), 0)) { - ZEPHIR_CONCAT_VSVSVSV(&columns, &groupColumns, ", ", &functionName, "(", &groupColumn, ") AS ", &alias); - } else { - ZEPHIR_CONCAT_VSVSV(&columns, &functionName, "(", &groupColumn, ") AS ", &alias); - } - } - ZEPHIR_CALL_METHOD(&_0, &manager, "createbuilder", NULL, 0, ¶ms); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&builder, &_0); - ZEPHIR_CALL_METHOD(NULL, &builder, "columns", NULL, 0, &columns); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_1); - zephir_get_called_class(&_1); - ZEPHIR_CALL_METHOD(NULL, &builder, "from", NULL, 0, &_1); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, &builder, "getquery", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&query, &_0); - zephir_memory_observe(&transaction); - if (zephir_array_isset_string_fetch(&transaction, ¶ms, SL("transaction"), 0)) { - if (zephir_instance_of_ev(&transaction, phalcon_mvc_model_transactioninterface_ce)) { - ZEPHIR_CALL_METHOD(NULL, &query, "settransaction", NULL, 0, &transaction); - zephir_check_call_status(); - } - } - if (zephir_array_isset_string(¶ms, SL("bind"))) { - ZEPHIR_OBS_NVAR(&bindParams); - zephir_array_fetch_string(&bindParams, ¶ms, SL("bind"), PH_NOISY, "phalcon/Mvc/Model.zep", 4588); - if (zephir_array_isset_string(¶ms, SL("bindTypes"))) { - ZEPHIR_OBS_NVAR(&bindTypes); - zephir_array_fetch_string(&bindTypes, ¶ms, SL("bindTypes"), PH_NOISY, "phalcon/Mvc/Model.zep", 4591); - } - } - zephir_memory_observe(&cache); - if (zephir_array_isset_string_fetch(&cache, ¶ms, SL("cache"), 0)) { - ZEPHIR_CALL_METHOD(NULL, &query, "cache", NULL, 0, &cache); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&resultset, &query, "execute", NULL, 0, &bindParams, &bindTypes); - zephir_check_call_status(); - if (zephir_array_isset_string(¶ms, SL("group"))) { - RETURN_CCTOR(&resultset); - } - ZEPHIR_CALL_METHOD(&firstRow, &resultset, "getfirst", NULL, 0); - zephir_check_call_status(); - zephir_memory_observe(&_2); - zephir_read_property_zval(&_2, &firstRow, &alias, PH_NOISY_CC); - RETURN_CCTOR(&_2); + ZEPHIR_INIT_VAR(&_0); + zephir_get_class(&_0, model, 1); + zephir_update_property_array(this_ptr, SL("writeConnectionServices"), &_0, &connectionService); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model, invokeFinder) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, useDynamicUpdate) { - zend_class_entry *_15; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval arguments, _11$$14; - zval *method_param = NULL, *arguments_param = NULL, extraMethod, type, modelName, value, model, attributes, field, extraMethodFirst, metaData, params, _14, _0$$3, _1$$4, _2$$5, _3$$7, _4$$7, _5$$7, _6$$13, _7$$13, _8$$13, _9$$14, _10$$14, _12$$15, _13$$15; - zval method; + zend_bool dynamicUpdate; + zval *model, model_sub, *dynamicUpdate_param = NULL, entityName, _0, _1; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&extraMethod); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&extraMethodFirst); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_3$$7); - ZVAL_UNDEF(&_4$$7); - ZVAL_UNDEF(&_5$$7); - ZVAL_UNDEF(&_6$$13); - ZVAL_UNDEF(&_7$$13); - ZVAL_UNDEF(&_8$$13); - ZVAL_UNDEF(&_9$$14); - ZVAL_UNDEF(&_10$$14); - ZVAL_UNDEF(&_12$$15); - ZVAL_UNDEF(&_13$$15); - ZVAL_UNDEF(&arguments); - ZVAL_UNDEF(&_11$$14); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&entityName); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(method) - Z_PARAM_ARRAY(arguments) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_BOOL(dynamicUpdate) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &method_param, &arguments_param); - zephir_get_strval(&method, method_param); - zephir_get_arrval(&arguments, arguments_param); - ZEPHIR_INIT_VAR(&extraMethod); - ZVAL_NULL(&extraMethod); - if (zephir_start_with_str(&method, SL("findFirstBy"))) { - ZEPHIR_INIT_VAR(&type); - ZVAL_STRING(&type, "findFirst"); - ZVAL_LONG(&_0$$3, 11); - ZEPHIR_INIT_NVAR(&extraMethod); - zephir_substr(&extraMethod, &method, 11 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - } else if (zephir_start_with_str(&method, SL("findBy"))) { - ZEPHIR_INIT_NVAR(&type); - ZVAL_STRING(&type, "find"); - ZVAL_LONG(&_1$$4, 6); - ZEPHIR_INIT_NVAR(&extraMethod); - zephir_substr(&extraMethod, &method, 6 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - } else if (zephir_start_with_str(&method, SL("countBy"))) { - ZEPHIR_INIT_NVAR(&type); - ZVAL_STRING(&type, "count"); - ZVAL_LONG(&_2$$5, 7); - ZEPHIR_INIT_NVAR(&extraMethod); - zephir_substr(&extraMethod, &method, 7 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - } - ZEPHIR_INIT_VAR(&modelName); - zephir_get_called_class(&modelName); - if (!(zephir_is_true(&extraMethod))) { - RETURN_MM_BOOL(0); - } - if (UNEXPECTED(!(zephir_array_isset_long(&arguments, 0)))) { - ZEPHIR_INIT_VAR(&_3$$7); - object_init_ex(&_3$$7, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_4$$7); - zephir_get_called_class(&_4$$7); - ZEPHIR_INIT_VAR(&_5$$7); - ZEPHIR_CONCAT_SVSVS(&_5$$7, "The static method '", &method, "' in '", &_4$$7, "' requires one argument"); - ZEPHIR_CALL_METHOD(NULL, &_3$$7, "__construct", NULL, 33, &_5$$7); - zephir_check_call_status(); - zephir_throw_exception_debug(&_3$$7, "phalcon/Mvc/Model.zep", 4670); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_VAR(&model); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&model, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&metaData, &model, "getmodelsmetadata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&attributes, &metaData, "getreversecolumnmap", NULL, 0, &model); - zephir_check_call_status(); - if (Z_TYPE_P(&attributes) != IS_ARRAY) { - ZEPHIR_CALL_METHOD(&attributes, &metaData, "getdatatypes", NULL, 0, &model); - zephir_check_call_status(); - } - if (zephir_array_isset(&attributes, &extraMethod)) { - ZEPHIR_CPY_WRT(&field, &extraMethod); - } else { - ZEPHIR_CALL_FUNCTION(&extraMethodFirst, "lcfirst", NULL, 76, &extraMethod); - zephir_check_call_status(); - if (zephir_array_isset(&attributes, &extraMethodFirst)) { - ZEPHIR_CPY_WRT(&field, &extraMethodFirst); - } else { - ZEPHIR_INIT_NVAR(&field); - zephir_uncamelize(&field, &extraMethod, NULL ); - if (UNEXPECTED(!(zephir_array_isset(&attributes, &field)))) { - ZEPHIR_INIT_VAR(&_6$$13); - object_init_ex(&_6$$13, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_7$$13); - zephir_get_called_class(&_7$$13); - ZEPHIR_INIT_VAR(&_8$$13); - ZEPHIR_CONCAT_SVSVS(&_8$$13, "Cannot resolve attribute '", &extraMethod, "' in the model '", &_7$$13, "'"); - ZEPHIR_CALL_METHOD(NULL, &_6$$13, "__construct", NULL, 33, &_8$$13); - zephir_check_call_status(); - zephir_throw_exception_debug(&_6$$13, "phalcon/Mvc/Model.zep", 4707); - ZEPHIR_MM_RESTORE(); - return; - } - } - } - zephir_memory_observe(&value); - zephir_array_isset_long_fetch(&value, &arguments, 0, 0); - ZEPHIR_INIT_VAR(¶ms); - if (Z_TYPE_P(&value) != IS_NULL) { - ZEPHIR_INIT_VAR(&_9$$14); - zephir_create_array(&_9$$14, 2, 0); - ZEPHIR_INIT_VAR(&_10$$14); - ZEPHIR_CONCAT_SVS(&_10$$14, "[", &field, "] = ?0"); - zephir_array_update_string(&_9$$14, SL("conditions"), &_10$$14, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_11$$14); - zephir_create_array(&_11$$14, 1, 0); - zephir_array_fast_append(&_11$$14, &value); - zephir_array_update_string(&_9$$14, SL("bind"), &_11$$14, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(¶ms, &_9$$14); - } else { - ZEPHIR_INIT_VAR(&_12$$15); - zephir_create_array(&_12$$15, 1, 0); - ZEPHIR_INIT_VAR(&_13$$15); - ZEPHIR_CONCAT_SVS(&_13$$15, "[", &field, "] IS NULL"); - zephir_array_update_string(&_12$$15, SL("conditions"), &_13$$15, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(¶ms, &_12$$15); - } - zephir_array_unset_long(&arguments, 0, PH_SEPARATE); - zephir_array_unset_string(&arguments, SL("conditions"), PH_SEPARATE); - zephir_array_unset_string(&arguments, SL("bind"), PH_SEPARATE); - ZEPHIR_INIT_VAR(&_14); - zephir_fast_array_merge(&_14, ¶ms, &arguments); - ZEPHIR_CPY_WRT(¶ms, &_14); - _15 = zephir_fetch_class(&modelName); - ZEPHIR_RETURN_CALL_CE_STATIC_ZVAL(_15, type, NULL, 0, ¶ms); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 2, 0, &model, &dynamicUpdate_param); + ZEPHIR_INIT_VAR(&entityName); + zephir_get_class(&entityName, model, 1); + ZEPHIR_INIT_VAR(&_0); + ZVAL_BOOL(&_0, dynamicUpdate); + zephir_update_property_array(this_ptr, SL("dynamicUpdate"), &entityName, &_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_BOOL(&_1, dynamicUpdate); + zephir_update_property_array(this_ptr, SL("keepSnapshots"), &entityName, &_1); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model, possibleSetter) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, getConnection) { - zval localMethods; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *property_param = NULL, *value, value_sub, possibleSetter, _0; - zval property; + zval connectionServices; + zval *model, model_sub, *connectionServices_param = NULL, container, service, connection, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&property); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&possibleSetter); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&service); + ZVAL_UNDEF(&connection); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&localMethods); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&connectionServices); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(property) - Z_PARAM_ZVAL(value) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ARRAY(connectionServices) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &property_param, &value); - zephir_get_strval(&property, property_param); - ZEPHIR_INIT_VAR(&localMethods); - zephir_create_array(&localMethods, 10, 0); - add_assoc_long_ex(&localMethods, SL("setConnectionService"), 1); - add_assoc_long_ex(&localMethods, SL("setDirtyState"), 1); - add_assoc_long_ex(&localMethods, SL("setEventsManager"), 1); - add_assoc_long_ex(&localMethods, SL("setReadConnectionService"), 1); - add_assoc_long_ex(&localMethods, SL("setOldSnapshotData"), 1); - add_assoc_long_ex(&localMethods, SL("setSchema"), 1); - add_assoc_long_ex(&localMethods, SL("setSnapshotData"), 1); - add_assoc_long_ex(&localMethods, SL("setSource"), 1); - add_assoc_long_ex(&localMethods, SL("setTransaction"), 1); - add_assoc_long_ex(&localMethods, SL("setWriteConnectionService"), 1); - ZEPHIR_INIT_VAR(&_0); - zephir_camelize(&_0, &property, NULL ); - ZEPHIR_INIT_VAR(&possibleSetter); - ZEPHIR_CONCAT_SV(&possibleSetter, "set", &_0); - if (!((zephir_method_exists(this_ptr, &possibleSetter) == SUCCESS))) { - RETURN_MM_BOOL(0); + zephir_fetch_params(1, 2, 0, &model, &connectionServices_param); + zephir_get_arrval(&connectionServices, connectionServices_param); + ZEPHIR_CALL_METHOD(&service, this_ptr, "getconnectionservice", NULL, 0, model, &connectionServices); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_0); + if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injection container is required to access the services related to the ORM", "phalcon/Mvc/Model/Manager.zep", 2267); + return; } - if (!(zephir_array_isset(&localMethods, &possibleSetter))) { - ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &possibleSetter, NULL, 0, value); - zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, &container, "getshared", NULL, 0, &service); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&connection, &_1); + if (UNEXPECTED(Z_TYPE_P(&connection) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid injected connection service", "phalcon/Mvc/Model/Manager.zep", 2276); + return; } - RETURN_MM_BOOL(1); + RETURN_CCTOR(&connection); } -static PHP_METHOD(Phalcon_Mvc_Model, preSave) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, mergeFindParameters) { - zval _16$$32, _29$$52; - zval eventName; + zend_bool _6$$6, _9$$11, _16$$17, _17$$17, _22$$26, _23$$26; + zend_string *_5$$5, *_15$$16; + zend_ulong _4$$5, _14$$16; + zval findParams; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_9 = NULL, *_19 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool exists, error = 0, isNull = 0, _10$$27, _11$$27, _12$$27, _23$$47, _24$$47, _25$$47; - zval *metaData, metaData_sub, *exists_param = NULL, *identityField, identityField_sub, __$true, __$false, notNull, columnMap, dataTypeNumeric, automaticAttributes, defaultValues, field, attributeField, value, emptyStringValues, _33, _34, _0$$3, _1$$3, _2$$3, _3$$8, *_4$$11, _5$$11, _6$$19, _7$$19, _8$$19, _13$$27, _14$$32, _15$$32, _17$$32, _18$$32, _20$$39, _21$$39, _22$$39, _26$$47, _27$$52, _28$$52, _30$$52, _31$$52, _32$$57, _35$$59, _36$$60, _37$$60, _38$$60, _39$$60, _40$$60, _41$$60; - zval *this_ptr = getThis(); + zval *findParamsOne = NULL, findParamsOne_sub, *findParamsTwo = NULL, findParamsTwo_sub, key, value, _0$$3, _1$$4, *_2$$5, _3$$5, _7$$9, _8$$9, _10$$14, _11$$14, *_12$$16, _13$$16, _18$$20, _19$$20, _20$$24, _21$$24, _24$$29, _25$$29, _26$$33, _27$$33; - ZVAL_UNDEF(&metaData_sub); - ZVAL_UNDEF(&identityField_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(¬Null); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&dataTypeNumeric); - ZVAL_UNDEF(&automaticAttributes); - ZVAL_UNDEF(&defaultValues); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&attributeField); + ZVAL_UNDEF(&findParamsOne_sub); + ZVAL_UNDEF(&findParamsTwo_sub); + ZVAL_UNDEF(&key); ZVAL_UNDEF(&value); - ZVAL_UNDEF(&emptyStringValues); - ZVAL_UNDEF(&_33); - ZVAL_UNDEF(&_34); ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$8); - ZVAL_UNDEF(&_5$$11); - ZVAL_UNDEF(&_6$$19); - ZVAL_UNDEF(&_7$$19); - ZVAL_UNDEF(&_8$$19); - ZVAL_UNDEF(&_13$$27); - ZVAL_UNDEF(&_14$$32); - ZVAL_UNDEF(&_15$$32); - ZVAL_UNDEF(&_17$$32); - ZVAL_UNDEF(&_18$$32); - ZVAL_UNDEF(&_20$$39); - ZVAL_UNDEF(&_21$$39); - ZVAL_UNDEF(&_22$$39); - ZVAL_UNDEF(&_26$$47); - ZVAL_UNDEF(&_27$$52); - ZVAL_UNDEF(&_28$$52); - ZVAL_UNDEF(&_30$$52); - ZVAL_UNDEF(&_31$$52); - ZVAL_UNDEF(&_32$$57); - ZVAL_UNDEF(&_35$$59); - ZVAL_UNDEF(&_36$$60); - ZVAL_UNDEF(&_37$$60); - ZVAL_UNDEF(&_38$$60); - ZVAL_UNDEF(&_39$$60); - ZVAL_UNDEF(&_40$$60); - ZVAL_UNDEF(&_41$$60); - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&_16$$32); - ZVAL_UNDEF(&_29$$52); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_OBJECT_OF_CLASS(metaData, phalcon_mvc_model_metadatainterface_ce) - Z_PARAM_BOOL(exists) - Z_PARAM_ZVAL(identityField) + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_7$$9); + ZVAL_UNDEF(&_8$$9); + ZVAL_UNDEF(&_10$$14); + ZVAL_UNDEF(&_11$$14); + ZVAL_UNDEF(&_13$$16); + ZVAL_UNDEF(&_18$$20); + ZVAL_UNDEF(&_19$$20); + ZVAL_UNDEF(&_20$$24); + ZVAL_UNDEF(&_21$$24); + ZVAL_UNDEF(&_24$$29); + ZVAL_UNDEF(&_25$$29); + ZVAL_UNDEF(&_26$$33); + ZVAL_UNDEF(&_27$$33); + ZVAL_UNDEF(&findParams); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(findParamsOne) + Z_PARAM_ZVAL(findParamsTwo) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &metaData, &exists_param, &identityField); - if (ZEPHIR_GLOBAL(orm).events) { - ZEPHIR_INIT_VAR(&_1$$3); - ZVAL_STRING(&_1$$3, "beforeValidation"); - ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "fireeventcancel", NULL, 0, &_1$$3); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_0$$3)) { - RETURN_MM_BOOL(0); - } - if (exists) { - ZEPHIR_INIT_VAR(&eventName); - ZVAL_STRING(&eventName, "beforeValidationOnUpdate"); - } else { - ZEPHIR_INIT_NVAR(&eventName); - ZVAL_STRING(&eventName, "beforeValidationOnCreate"); - } - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "fireeventcancel", NULL, 0, &eventName); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_2$$3)) { - RETURN_MM_BOOL(0); - } + zephir_fetch_params(1, 2, 0, &findParamsOne, &findParamsTwo); + ZEPHIR_SEPARATE_PARAM(findParamsOne); + ZEPHIR_SEPARATE_PARAM(findParamsTwo); + ZEPHIR_INIT_VAR(&findParams); + array_init(&findParams); + if (Z_TYPE_P(findParamsOne) == IS_STRING) { + ZEPHIR_INIT_VAR(&_0$$3); + zephir_create_array(&_0$$3, 1, 0); + zephir_array_update_string(&_0$$3, SL("conditions"), findParamsOne, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(findParamsOne, &_0$$3); } - if (ZEPHIR_GLOBAL(orm).virtual_foreign_keys) { - ZEPHIR_CALL_METHOD(&_3$$8, this_ptr, "checkforeignkeysrestrict", NULL, 434); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_3$$8)) { - RETURN_MM_BOOL(0); - } + if (Z_TYPE_P(findParamsTwo) == IS_STRING) { + ZEPHIR_INIT_VAR(&_1$$4); + zephir_create_array(&_1$$4, 1, 0); + zephir_array_update_string(&_1$$4, SL("conditions"), findParamsTwo, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(findParamsTwo, &_1$$4); } - if (ZEPHIR_GLOBAL(orm).not_null_validations) { - ZEPHIR_CALL_METHOD(¬Null, metaData, "getnotnullattributes", NULL, 0, this_ptr); - zephir_check_call_status(); - if (Z_TYPE_P(¬Null) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(&dataTypeNumeric, metaData, "getdatatypesnumeric", NULL, 0, this_ptr); + if (Z_TYPE_P(findParamsOne) == IS_ARRAY) { + zephir_is_iterable(findParamsOne, 0, "phalcon/Mvc/Model/Manager.zep", 2321); + if (Z_TYPE_P(findParamsOne) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(findParamsOne), _4$$5, _5$$5, _2$$5) + { + ZEPHIR_INIT_NVAR(&key); + if (_5$$5 != NULL) { + ZVAL_STR_COPY(&key, _5$$5); + } else { + ZVAL_LONG(&key, _4$$5); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _2$$5); + _6$$6 = ZEPHIR_IS_LONG_IDENTICAL(&key, 0); + if (!(_6$$6)) { + _6$$6 = ZEPHIR_IS_STRING_IDENTICAL(&key, "conditions"); + } + if (_6$$6) { + if (!(zephir_array_isset_long(&findParams, 0))) { + zephir_array_update_long(&findParams, 0, &value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + } else { + zephir_array_fetch_long(&_7$$9, &findParams, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 2315); + ZEPHIR_INIT_NVAR(&_8$$9); + ZEPHIR_CONCAT_SVSVS(&_8$$9, "(", &_7$$9, ") AND (", &value, ")"); + zephir_array_update_long(&findParams, 0, &_8$$9, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + } + } else { + zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, findParamsOne, "rewind", NULL, 0); zephir_check_call_status(); - if (ZEPHIR_GLOBAL(orm).column_renaming) { - ZEPHIR_CALL_METHOD(&columnMap, metaData, "getcolumnmap", NULL, 0, this_ptr); + while (1) { + ZEPHIR_CALL_METHOD(&_3$$5, findParamsOne, "valid", NULL, 0); zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&columnMap); - ZVAL_NULL(&columnMap); - } - if (exists) { - ZEPHIR_CALL_METHOD(&automaticAttributes, metaData, "getautomaticupdateattributes", NULL, 0, this_ptr); + if (!zend_is_true(&_3$$5)) { + break; + } + ZEPHIR_CALL_METHOD(&key, findParamsOne, "key", NULL, 0); zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&automaticAttributes, metaData, "getautomaticcreateattributes", NULL, 0, this_ptr); + ZEPHIR_CALL_METHOD(&value, findParamsOne, "current", NULL, 0); zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&defaultValues, metaData, "getdefaultvalues", NULL, 0, this_ptr); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&emptyStringValues, metaData, "getemptystringattributes", NULL, 0, this_ptr); - zephir_check_call_status(); - error = 0; - zephir_is_iterable(¬Null, 0, "phalcon/Mvc/Model.zep", 4948); - if (Z_TYPE_P(¬Null) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(¬Null), _4$$11) - { - ZEPHIR_INIT_NVAR(&field); - ZVAL_COPY(&field, _4$$11); - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_6$$19); - object_init_ex(&_6$$19, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_7$$19); - zephir_get_class(&_7$$19, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_8$$19); - ZEPHIR_CONCAT_SVSVS(&_8$$19, "Column '", &field, "' in '", &_7$$19, "' isn't part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_6$$19, "__construct", &_9, 33, &_8$$19); - zephir_check_call_status(); - zephir_throw_exception_debug(&_6$$19, "phalcon/Mvc/Model.zep", 4868); - ZEPHIR_MM_RESTORE(); - return; - } + _9$$11 = ZEPHIR_IS_LONG_IDENTICAL(&key, 0); + if (!(_9$$11)) { + _9$$11 = ZEPHIR_IS_STRING_IDENTICAL(&key, "conditions"); + } + if (_9$$11) { + if (!(zephir_array_isset_long(&findParams, 0))) { + zephir_array_update_long(&findParams, 0, &value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + } else { + zephir_array_fetch_long(&_10$$14, &findParams, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 2315); + ZEPHIR_INIT_NVAR(&_11$$14); + ZEPHIR_CONCAT_SVSVS(&_11$$14, "(", &_10$$14, ") AND (", &value, ")"); + zephir_array_update_long(&findParams, 0, &_11$$14, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } } else { - ZEPHIR_CPY_WRT(&attributeField, &field); + zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE); } - if (!(zephir_array_isset(&automaticAttributes, &attributeField))) { - isNull = 0; - ZEPHIR_OBS_NVAR(&value); - if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { - if (Z_TYPE_P(&value) != IS_OBJECT) { - if (!(zephir_array_isset(&dataTypeNumeric, &field))) { - if (zephir_array_isset(&emptyStringValues, &field)) { - if (Z_TYPE_P(&value) == IS_NULL) { - isNull = 1; - } - } else { - _10$$27 = Z_TYPE_P(&value) == IS_NULL; - if (!(_10$$27)) { - _11$$27 = ZEPHIR_IS_STRING_IDENTICAL(&value, ""); - if (_11$$27) { - _12$$27 = !(zephir_array_isset(&defaultValues, &field)); - if (!(_12$$27)) { - zephir_array_fetch(&_13$$27, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 4898); - _12$$27 = !ZEPHIR_IS_IDENTICAL(&value, &_13$$27); - } - _11$$27 = _12$$27; - } - _10$$27 = _11$$27; - } - if (_10$$27) { - isNull = 1; - } - } - } else { - if (!(zephir_is_numeric(&value))) { - isNull = 1; - } - } - } + ZEPHIR_CALL_METHOD(NULL, findParamsOne, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + } + if (Z_TYPE_P(findParamsTwo) == IS_ARRAY) { + zephir_is_iterable(findParamsTwo, 0, "phalcon/Mvc/Model/Manager.zep", 2346); + if (Z_TYPE_P(findParamsTwo) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(findParamsTwo), _14$$16, _15$$16, _12$$16) + { + ZEPHIR_INIT_NVAR(&key); + if (_15$$16 != NULL) { + ZVAL_STR_COPY(&key, _15$$16); + } else { + ZVAL_LONG(&key, _14$$16); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _12$$16); + _16$$17 = ZEPHIR_IS_LONG_IDENTICAL(&key, 0); + if (!(_16$$17)) { + _16$$17 = ZEPHIR_IS_STRING_IDENTICAL(&key, "conditions"); + } + _17$$17 = ZEPHIR_IS_STRING_IDENTICAL(&key, "bind"); + if (!(_17$$17)) { + _17$$17 = ZEPHIR_IS_STRING_IDENTICAL(&key, "bindTypes"); + } + if (_16$$17) { + if (!(zephir_array_isset_long(&findParams, 0))) { + zephir_array_update_long(&findParams, 0, &value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + } else { + zephir_array_fetch_long(&_18$$20, &findParams, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 2329); + ZEPHIR_INIT_NVAR(&_19$$20); + ZEPHIR_CONCAT_SVSVS(&_19$$20, "(", &_18$$20, ") AND (", &value, ")"); + zephir_array_update_long(&findParams, 0, &_19$$20, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + } + } else if (_17$$17) { + if (Z_TYPE_P(&value) == IS_ARRAY) { + if (!(zephir_array_isset(&findParams, &key))) { + zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE); } else { - isNull = 1; - } - if (isNull) { - if (!(exists)) { - if (ZEPHIR_IS_EQUAL(&field, identityField)) { - continue; - } - if (zephir_array_isset(&defaultValues, &field)) { - continue; - } - } - ZEPHIR_INIT_NVAR(&_14$$32); - object_init_ex(&_14$$32, phalcon_messages_message_ce); - ZEPHIR_INIT_NVAR(&_15$$32); - ZEPHIR_CONCAT_VS(&_15$$32, &attributeField, " is required"); - ZEPHIR_INIT_NVAR(&_16$$32); - zephir_create_array(&_16$$32, 1, 0); - ZEPHIR_INIT_NVAR(&_17$$32); - zephir_get_class(&_17$$32, this_ptr, 0); - zephir_array_update_string(&_16$$32, SL("model"), &_17$$32, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_17$$32); - ZVAL_STRING(&_17$$32, "PresenceOf"); - ZVAL_LONG(&_18$$32, 0); - ZEPHIR_CALL_METHOD(NULL, &_14$$32, "__construct", &_19, 6, &_15$$32, &attributeField, &_17$$32, &_18$$32, &_16$$32); - zephir_check_call_status(); - zephir_update_property_array_append(this_ptr, SL("errorMessages"), &_14$$32); - error = 1; + ZEPHIR_INIT_NVAR(&_20$$24); + zephir_array_fetch(&_21$$24, &findParams, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 2337); + zephir_fast_array_merge(&_20$$24, &_21$$24, &value); + zephir_array_update_zval(&findParams, &key, &_20$$24, PH_COPY | PH_SEPARATE); } } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, ¬Null, "rewind", NULL, 0); + } else { + zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, findParamsTwo, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_13$$16, findParamsTwo, "valid", NULL, 0); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5$$11, ¬Null, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5$$11)) { - break; + if (!zend_is_true(&_13$$16)) { + break; + } + ZEPHIR_CALL_METHOD(&key, findParamsTwo, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, findParamsTwo, "current", NULL, 0); + zephir_check_call_status(); + _22$$26 = ZEPHIR_IS_LONG_IDENTICAL(&key, 0); + if (!(_22$$26)) { + _22$$26 = ZEPHIR_IS_STRING_IDENTICAL(&key, "conditions"); } - ZEPHIR_CALL_METHOD(&field, ¬Null, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&attributeField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &field, 0)))) { - if (UNEXPECTED(!(ZEPHIR_GLOBAL(orm).ignore_unknown_columns))) { - ZEPHIR_INIT_NVAR(&_20$$39); - object_init_ex(&_20$$39, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_21$$39); - zephir_get_class(&_21$$39, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_22$$39); - ZEPHIR_CONCAT_SVSVS(&_22$$39, "Column '", &field, "' in '", &_21$$39, "' isn't part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_20$$39, "__construct", &_9, 33, &_22$$39); - zephir_check_call_status(); - zephir_throw_exception_debug(&_20$$39, "phalcon/Mvc/Model.zep", 4868); - ZEPHIR_MM_RESTORE(); - return; - } - } + _23$$26 = ZEPHIR_IS_STRING_IDENTICAL(&key, "bind"); + if (!(_23$$26)) { + _23$$26 = ZEPHIR_IS_STRING_IDENTICAL(&key, "bindTypes"); + } + if (_22$$26) { + if (!(zephir_array_isset_long(&findParams, 0))) { + zephir_array_update_long(&findParams, 0, &value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } else { - ZEPHIR_CPY_WRT(&attributeField, &field); + zephir_array_fetch_long(&_24$$29, &findParams, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 2329); + ZEPHIR_INIT_NVAR(&_25$$29); + ZEPHIR_CONCAT_SVSVS(&_25$$29, "(", &_24$$29, ") AND (", &value, ")"); + zephir_array_update_long(&findParams, 0, &_25$$29, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } - if (!(zephir_array_isset(&automaticAttributes, &attributeField))) { - isNull = 0; - ZEPHIR_OBS_NVAR(&value); - if (zephir_fetch_property_zval(&value, this_ptr, &attributeField, PH_SILENT_CC)) { - if (Z_TYPE_P(&value) != IS_OBJECT) { - if (!(zephir_array_isset(&dataTypeNumeric, &field))) { - if (zephir_array_isset(&emptyStringValues, &field)) { - if (Z_TYPE_P(&value) == IS_NULL) { - isNull = 1; - } - } else { - _23$$47 = Z_TYPE_P(&value) == IS_NULL; - if (!(_23$$47)) { - _24$$47 = ZEPHIR_IS_STRING_IDENTICAL(&value, ""); - if (_24$$47) { - _25$$47 = !(zephir_array_isset(&defaultValues, &field)); - if (!(_25$$47)) { - zephir_array_fetch(&_26$$47, &defaultValues, &field, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model.zep", 4898); - _25$$47 = !ZEPHIR_IS_IDENTICAL(&value, &_26$$47); - } - _24$$47 = _25$$47; - } - _23$$47 = _24$$47; - } - if (_23$$47) { - isNull = 1; - } - } - } else { - if (!(zephir_is_numeric(&value))) { - isNull = 1; - } - } - } + } else if (_23$$26) { + if (Z_TYPE_P(&value) == IS_ARRAY) { + if (!(zephir_array_isset(&findParams, &key))) { + zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE); } else { - isNull = 1; - } - if (isNull) { - if (!(exists)) { - if (ZEPHIR_IS_EQUAL(&field, identityField)) { - continue; - } - if (zephir_array_isset(&defaultValues, &field)) { - continue; - } - } - ZEPHIR_INIT_NVAR(&_27$$52); - object_init_ex(&_27$$52, phalcon_messages_message_ce); - ZEPHIR_INIT_NVAR(&_28$$52); - ZEPHIR_CONCAT_VS(&_28$$52, &attributeField, " is required"); - ZEPHIR_INIT_NVAR(&_29$$52); - zephir_create_array(&_29$$52, 1, 0); - ZEPHIR_INIT_NVAR(&_30$$52); - zephir_get_class(&_30$$52, this_ptr, 0); - zephir_array_update_string(&_29$$52, SL("model"), &_30$$52, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_30$$52); - ZVAL_STRING(&_30$$52, "PresenceOf"); - ZVAL_LONG(&_31$$52, 0); - ZEPHIR_CALL_METHOD(NULL, &_27$$52, "__construct", &_19, 6, &_28$$52, &attributeField, &_30$$52, &_31$$52, &_29$$52); - zephir_check_call_status(); - zephir_update_property_array_append(this_ptr, SL("errorMessages"), &_27$$52); - error = 1; + ZEPHIR_INIT_NVAR(&_26$$33); + zephir_array_fetch(&_27$$33, &findParams, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 2337); + zephir_fast_array_merge(&_26$$33, &_27$$33, &value); + zephir_array_update_zval(&findParams, &key, &_26$$33, PH_COPY | PH_SEPARATE); } } - ZEPHIR_CALL_METHOD(NULL, ¬Null, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&field); - if (error) { - if (ZEPHIR_GLOBAL(orm).events) { - ZEPHIR_INIT_VAR(&_32$$57); - ZVAL_STRING(&_32$$57, "onValidationFails"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_32$$57); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "canceloperation", NULL, 0); - zephir_check_call_status(); - } - RETURN_MM_BOOL(0); + } else { + zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, findParamsTwo, "next", NULL, 0); + zephir_check_call_status(); } } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); } - ZEPHIR_INIT_VAR(&_34); - ZVAL_STRING(&_34, "validation"); - ZEPHIR_CALL_METHOD(&_33, this_ptr, "fireeventcancel", NULL, 0, &_34); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_33)) { - if (ZEPHIR_GLOBAL(orm).events) { - ZEPHIR_INIT_VAR(&_35$$59); - ZVAL_STRING(&_35$$59, "onValidationFails"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_35$$59); - zephir_check_call_status(); - } - RETURN_MM_BOOL(0); - } - if (ZEPHIR_GLOBAL(orm).events) { - if (exists) { - ZEPHIR_INIT_NVAR(&eventName); - ZVAL_STRING(&eventName, "afterValidationOnUpdate"); - } else { - ZEPHIR_INIT_NVAR(&eventName); - ZVAL_STRING(&eventName, "afterValidationOnCreate"); - } - ZEPHIR_CALL_METHOD(&_36$$60, this_ptr, "fireeventcancel", NULL, 0, &eventName); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_36$$60)) { - RETURN_MM_BOOL(0); - } - ZEPHIR_INIT_VAR(&_38$$60); - ZVAL_STRING(&_38$$60, "afterValidation"); - ZEPHIR_CALL_METHOD(&_37$$60, this_ptr, "fireeventcancel", NULL, 0, &_38$$60); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_37$$60)) { - RETURN_MM_BOOL(0); - } - ZEPHIR_INIT_NVAR(&_38$$60); - ZVAL_STRING(&_38$$60, "beforeSave"); - ZEPHIR_CALL_METHOD(&_39$$60, this_ptr, "fireeventcancel", NULL, 0, &_38$$60); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_39$$60)) { - RETURN_MM_BOOL(0); - } - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("skipped"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("skipped"), &__$false); - } - if (exists) { - ZEPHIR_INIT_NVAR(&eventName); - ZVAL_STRING(&eventName, "beforeUpdate"); - } else { - ZEPHIR_INIT_NVAR(&eventName); - ZVAL_STRING(&eventName, "beforeCreate"); - } - ZEPHIR_CALL_METHOD(&_40$$60, this_ptr, "fireeventcancel", NULL, 0, &eventName); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_40$$60)) { - RETURN_MM_BOOL(0); - } - zephir_read_property(&_41$$60, this_ptr, ZEND_STRL("skipped"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_41$$60)) { - RETURN_MM_BOOL(1); - } - } - RETURN_MM_BOOL(1); + RETURN_CTOR(&findParams); } -static PHP_METHOD(Phalcon_Mvc_Model, preSaveRelatedRecords) +static PHP_METHOD(Phalcon_Mvc_Model_Manager, checkHasRelationship) { - zend_string *_5; - zend_ulong _4; - zend_bool nesting = 0, _20$$5, _39$$11; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL, *_9 = NULL, *_13 = NULL, *_15 = NULL, *_22 = NULL, *_24 = NULL, *_27 = NULL, *_29 = NULL, *_34 = NULL, *_42 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connection, connection_sub, *related, related_sub, *visited, visited_sub, className, manager, type, relation, columns, referencedFields, name, record, _0, _1, *_2, _3, _6$$3, _8$$6, _10$$6, _11$$6, _12$$6, _14$$7, _16$$7, _17$$7, _18$$7, _19$$5, _21$$5, _25$$5, _23$$8, _26$$9, _28$$12, _30$$12, _31$$12, _32$$12, _33$$13, _35$$13, _36$$13, _37$$13, _38$$11, _40$$11, _43$$11, _41$$14; + zval *collection_param = NULL, *modelName_param = NULL, *modelRelation_param = NULL, entityName, _0, _1, _2, _3; + zval collection, modelName, modelRelation, keyRelation; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connection_sub); - ZVAL_UNDEF(&related_sub); - ZVAL_UNDEF(&visited_sub); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&referencedFields); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&record); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&modelRelation); + ZVAL_UNDEF(&keyRelation); + ZVAL_UNDEF(&entityName); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_8$$6); - ZVAL_UNDEF(&_10$$6); - ZVAL_UNDEF(&_11$$6); - ZVAL_UNDEF(&_12$$6); - ZVAL_UNDEF(&_14$$7); - ZVAL_UNDEF(&_16$$7); - ZVAL_UNDEF(&_17$$7); - ZVAL_UNDEF(&_18$$7); - ZVAL_UNDEF(&_19$$5); - ZVAL_UNDEF(&_21$$5); - ZVAL_UNDEF(&_25$$5); - ZVAL_UNDEF(&_23$$8); - ZVAL_UNDEF(&_26$$9); - ZVAL_UNDEF(&_28$$12); - ZVAL_UNDEF(&_30$$12); - ZVAL_UNDEF(&_31$$12); - ZVAL_UNDEF(&_32$$12); - ZVAL_UNDEF(&_33$$13); - ZVAL_UNDEF(&_35$$13); - ZVAL_UNDEF(&_36$$13); - ZVAL_UNDEF(&_37$$13); - ZVAL_UNDEF(&_38$$11); - ZVAL_UNDEF(&_40$$11); - ZVAL_UNDEF(&_43$$11); - ZVAL_UNDEF(&_41$$14); ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_db_adapter_adapterinterface_ce) - Z_PARAM_ZVAL(related) - Z_PARAM_OBJECT_OF_CLASS(visited, phalcon_support_collection_collectioninterface_ce) + Z_PARAM_STR(collection) + Z_PARAM_STR(modelName) + Z_PARAM_STR(modelRelation) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &connection, &related, &visited); - nesting = 0; - if (nesting) { - ZVAL_BOOL(&_0, 1); - } else { - ZVAL_BOOL(&_0, 0); + zephir_fetch_params(1, 3, 0, &collection_param, &modelName_param, &modelRelation_param); + zephir_get_strval(&collection, collection_param); + if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_CALL_METHOD(NULL, connection, "begin", NULL, 0, &_0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&className); - zephir_get_class(&className, this_ptr, 0); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getmodelsmanager", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&manager, &_1); - zephir_is_iterable(related, 0, "phalcon/Mvc/Model.zep", 5112); - if (Z_TYPE_P(related) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(related), _4, _5, _2) - { - ZEPHIR_INIT_NVAR(&name); - if (_5 != NULL) { - ZVAL_STR_COPY(&name, _5); - } else { - ZVAL_LONG(&name, _4); - } - ZEPHIR_INIT_NVAR(&record); - ZVAL_COPY(&record, _2); - ZEPHIR_CALL_METHOD(&_6$$3, &manager, "getrelationbyalias", &_7, 0, &className, &name); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&relation, &_6$$3); - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(&type, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_LONG(&type, 0)) { - if (UNEXPECTED(Z_TYPE_P(&record) != IS_OBJECT)) { - if (nesting) { - ZVAL_BOOL(&_8$$6, 1); - } else { - ZVAL_BOOL(&_8$$6, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_9, 0, &_8$$6); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_10$$6); - object_init_ex(&_10$$6, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_11$$6); - zephir_get_class(&_11$$6, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_12$$6); - ZEPHIR_CONCAT_SVSV(&_12$$6, "Only objects can be stored as part of belongs-to relations in '", &_11$$6, "' Relation ", &name); - ZEPHIR_CALL_METHOD(NULL, &_10$$6, "__construct", &_13, 33, &_12$$6); - zephir_check_call_status(); - zephir_throw_exception_debug(&_10$$6, "phalcon/Mvc/Model.zep", 5070); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CALL_METHOD(&columns, &relation, "getfields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedFields, &relation, "getreferencedfields", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&columns) == IS_ARRAY)) { - if (nesting) { - ZVAL_BOOL(&_14$$7, 1); - } else { - ZVAL_BOOL(&_14$$7, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_15, 0, &_14$$7); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_16$$7); - object_init_ex(&_16$$7, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_17$$7); - zephir_get_class(&_17$$7, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_18$$7); - ZEPHIR_CONCAT_SVSV(&_18$$7, "Not implemented in '", &_17$$7, "' Relation ", &name); - ZEPHIR_CALL_METHOD(NULL, &_16$$7, "__construct", &_13, 33, &_18$$7); - zephir_check_call_status(); - zephir_throw_exception_debug(&_16$$7, "phalcon/Mvc/Model.zep", 5081); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_read_property(&_19$$5, &record, ZEND_STRL("dirtyState"), PH_NOISY_CC | PH_READONLY); - _20$$5 = !ZEPHIR_IS_LONG_IDENTICAL(&_19$$5, 0); - if (_20$$5) { - ZEPHIR_CALL_METHOD(&_21$$5, &record, "dosave", NULL, 0, visited); - zephir_check_call_status(); - _20$$5 = !zephir_is_true(&_21$$5); - } - if (_20$$5) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_22, 0, &record); - zephir_check_call_status(); - if (nesting) { - ZVAL_BOOL(&_23$$8, 1); - } else { - ZVAL_BOOL(&_23$$8, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_24, 0, &_23$$8); - zephir_check_call_status(); - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(&_25$$5, &record, "readattribute", NULL, 0, &referencedFields); - zephir_check_call_status(); - zephir_update_property_zval_zval(this_ptr, &columns, &_25$$5); - } - } - } ZEND_HASH_FOREACH_END(); + if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { + zephir_get_strval(&modelName, modelName_param); } else { - ZEPHIR_CALL_METHOD(NULL, related, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, related, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3)) { - break; - } - ZEPHIR_CALL_METHOD(&name, related, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&record, related, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_26$$9, &manager, "getrelationbyalias", &_27, 0, &className, &name); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&relation, &_26$$9); - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(&type, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_LONG(&type, 0)) { - if (UNEXPECTED(Z_TYPE_P(&record) != IS_OBJECT)) { - if (nesting) { - ZVAL_BOOL(&_28$$12, 1); - } else { - ZVAL_BOOL(&_28$$12, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_29, 0, &_28$$12); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_30$$12); - object_init_ex(&_30$$12, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_31$$12); - zephir_get_class(&_31$$12, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_32$$12); - ZEPHIR_CONCAT_SVSV(&_32$$12, "Only objects can be stored as part of belongs-to relations in '", &_31$$12, "' Relation ", &name); - ZEPHIR_CALL_METHOD(NULL, &_30$$12, "__construct", &_13, 33, &_32$$12); - zephir_check_call_status(); - zephir_throw_exception_debug(&_30$$12, "phalcon/Mvc/Model.zep", 5070); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CALL_METHOD(&columns, &relation, "getfields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedFields, &relation, "getreferencedfields", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&columns) == IS_ARRAY)) { - if (nesting) { - ZVAL_BOOL(&_33$$13, 1); - } else { - ZVAL_BOOL(&_33$$13, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_34, 0, &_33$$13); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_35$$13); - object_init_ex(&_35$$13, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_36$$13); - zephir_get_class(&_36$$13, this_ptr, 0); - ZEPHIR_INIT_NVAR(&_37$$13); - ZEPHIR_CONCAT_SVSV(&_37$$13, "Not implemented in '", &_36$$13, "' Relation ", &name); - ZEPHIR_CALL_METHOD(NULL, &_35$$13, "__construct", &_13, 33, &_37$$13); - zephir_check_call_status(); - zephir_throw_exception_debug(&_35$$13, "phalcon/Mvc/Model.zep", 5081); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_read_property(&_38$$11, &record, ZEND_STRL("dirtyState"), PH_NOISY_CC | PH_READONLY); - _39$$11 = !ZEPHIR_IS_LONG_IDENTICAL(&_38$$11, 0); - if (_39$$11) { - ZEPHIR_CALL_METHOD(&_40$$11, &record, "dosave", NULL, 0, visited); - zephir_check_call_status(); - _39$$11 = !zephir_is_true(&_40$$11); - } - if (_39$$11) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_22, 0, &record); - zephir_check_call_status(); - if (nesting) { - ZVAL_BOOL(&_41$$14, 1); - } else { - ZVAL_BOOL(&_41$$14, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_42, 0, &_41$$14); - zephir_check_call_status(); - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(&_43$$11, &record, "readattribute", NULL, 0, &referencedFields); - zephir_check_call_status(); - zephir_update_property_zval_zval(this_ptr, &columns, &_43$$11); - } - } - ZEPHIR_CALL_METHOD(NULL, related, "next", NULL, 0); - zephir_check_call_status(); + ZEPHIR_INIT_VAR(&modelName); + } + if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { + zephir_get_strval(&modelRelation, modelRelation_param); + } else { + ZEPHIR_INIT_VAR(&modelRelation); + } + ZEPHIR_INIT_VAR(&entityName); + zephir_fast_strtolower(&entityName, &modelName); + ZEPHIR_INIT_VAR(&_0); + zephir_fast_strtolower(&_0, &modelRelation); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_VSV(&_1, &entityName, "$", &_0); + zephir_get_strval(&keyRelation, &_1); + zephir_read_property(&_2, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset(&_2, &entityName))) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "load", NULL, 0, &modelName); + zephir_check_call_status(); + } + zephir_memory_observe(&_3); + zephir_read_property_zval(&_3, this_ptr, &collection, PH_NOISY_CC); + RETURN_MM_BOOL(zephir_array_isset(&_3, &keyRelation)); +} + +zend_object *zephir_init_properties_Phalcon_Mvc_Model_Manager(zend_class_entry *class_type) +{ + zval _0, _2, _4, _6, _8, _10, _12, _14, _16, _18, _20, _22, _24, _26, _28, _30, _32, _34, _36, _38, _40, _42, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8, _13$$9, _15$$10, _17$$11, _19$$12, _21$$13, _23$$14, _25$$15, _27$$16, _29$$17, _31$$18, _33$$19, _35$$20, _37$$21, _39$$22, _41$$23, _43$$24; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_16); + ZVAL_UNDEF(&_18); + ZVAL_UNDEF(&_20); + ZVAL_UNDEF(&_22); + ZVAL_UNDEF(&_24); + ZVAL_UNDEF(&_26); + ZVAL_UNDEF(&_28); + ZVAL_UNDEF(&_30); + ZVAL_UNDEF(&_32); + ZVAL_UNDEF(&_34); + ZVAL_UNDEF(&_36); + ZVAL_UNDEF(&_38); + ZVAL_UNDEF(&_40); + ZVAL_UNDEF(&_42); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_9$$7); + ZVAL_UNDEF(&_11$$8); + ZVAL_UNDEF(&_13$$9); + ZVAL_UNDEF(&_15$$10); + ZVAL_UNDEF(&_17$$11); + ZVAL_UNDEF(&_19$$12); + ZVAL_UNDEF(&_21$$13); + ZVAL_UNDEF(&_23$$14); + ZVAL_UNDEF(&_25$$15); + ZVAL_UNDEF(&_27$$16); + ZVAL_UNDEF(&_29$$17); + ZVAL_UNDEF(&_31$$18); + ZVAL_UNDEF(&_33$$19); + ZVAL_UNDEF(&_35$$20); + ZVAL_UNDEF(&_37$$21); + ZVAL_UNDEF(&_39$$22); + ZVAL_UNDEF(&_41$$23); + ZVAL_UNDEF(&_43$$24); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("reusable"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("reusable"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("writeConnectionServices"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("writeConnectionServices"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("schemas"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("schemas"), &_5$$5); + } + zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("sources"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_6) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$6); + array_init(&_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sources"), &_7$$6); + } + zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("readConnectionServices"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_8) == IS_NULL) { + ZEPHIR_INIT_VAR(&_9$$7); + array_init(&_9$$7); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("readConnectionServices"), &_9$$7); + } + zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("modelVisibility"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_10) == IS_NULL) { + ZEPHIR_INIT_VAR(&_11$$8); + array_init(&_11$$8); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("modelVisibility"), &_11$$8); + } + zephir_read_property_ex(&_12, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_12) == IS_NULL) { + ZEPHIR_INIT_VAR(&_13$$9); + array_init(&_13$$9); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("keepSnapshots"), &_13$$9); + } + zephir_read_property_ex(&_14, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_14) == IS_NULL) { + ZEPHIR_INIT_VAR(&_15$$10); + array_init(&_15$$10); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("initialized"), &_15$$10); + } + zephir_read_property_ex(&_16, this_ptr, ZEND_STRL("hasOneThroughSingle"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_16) == IS_NULL) { + ZEPHIR_INIT_VAR(&_17$$11); + array_init(&_17$$11); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasOneThroughSingle"), &_17$$11); + } + zephir_read_property_ex(&_18, this_ptr, ZEND_STRL("hasOneThrough"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_18) == IS_NULL) { + ZEPHIR_INIT_VAR(&_19$$12); + array_init(&_19$$12); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasOneThrough"), &_19$$12); + } + zephir_read_property_ex(&_20, this_ptr, ZEND_STRL("hasOneSingle"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_20) == IS_NULL) { + ZEPHIR_INIT_VAR(&_21$$13); + array_init(&_21$$13); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasOneSingle"), &_21$$13); + } + zephir_read_property_ex(&_22, this_ptr, ZEND_STRL("hasOne"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_22) == IS_NULL) { + ZEPHIR_INIT_VAR(&_23$$14); + array_init(&_23$$14); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasOne"), &_23$$14); + } + zephir_read_property_ex(&_24, this_ptr, ZEND_STRL("hasManyToManySingle"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_24) == IS_NULL) { + ZEPHIR_INIT_VAR(&_25$$15); + array_init(&_25$$15); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasManyToManySingle"), &_25$$15); + } + zephir_read_property_ex(&_26, this_ptr, ZEND_STRL("hasManyToMany"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_26) == IS_NULL) { + ZEPHIR_INIT_VAR(&_27$$16); + array_init(&_27$$16); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasManyToMany"), &_27$$16); + } + zephir_read_property_ex(&_28, this_ptr, ZEND_STRL("hasManySingle"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_28) == IS_NULL) { + ZEPHIR_INIT_VAR(&_29$$17); + array_init(&_29$$17); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasManySingle"), &_29$$17); } + zephir_read_property_ex(&_30, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_30) == IS_NULL) { + ZEPHIR_INIT_VAR(&_31$$18); + array_init(&_31$$18); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasMany"), &_31$$18); + } + zephir_read_property_ex(&_32, this_ptr, ZEND_STRL("dynamicUpdate"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_32) == IS_NULL) { + ZEPHIR_INIT_VAR(&_33$$19); + array_init(&_33$$19); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("dynamicUpdate"), &_33$$19); + } + zephir_read_property_ex(&_34, this_ptr, ZEND_STRL("customEventsManager"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_34) == IS_NULL) { + ZEPHIR_INIT_VAR(&_35$$20); + array_init(&_35$$20); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("customEventsManager"), &_35$$20); + } + zephir_read_property_ex(&_36, this_ptr, ZEND_STRL("belongsToSingle"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_36) == IS_NULL) { + ZEPHIR_INIT_VAR(&_37$$21); + array_init(&_37$$21); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("belongsToSingle"), &_37$$21); + } + zephir_read_property_ex(&_38, this_ptr, ZEND_STRL("belongsTo"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_38) == IS_NULL) { + ZEPHIR_INIT_VAR(&_39$$22); + array_init(&_39$$22); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("belongsTo"), &_39$$22); + } + zephir_read_property_ex(&_40, this_ptr, ZEND_STRL("behaviors"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_40) == IS_NULL) { + ZEPHIR_INIT_VAR(&_41$$23); + array_init(&_41$$23); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("behaviors"), &_41$$23); + } + zephir_read_property_ex(&_42, this_ptr, ZEND_STRL("aliases"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_42) == IS_NULL) { + ZEPHIR_INIT_VAR(&_43$$24); + array_init(&_43$$24); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("aliases"), &_43$$24); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } - ZEPHIR_INIT_NVAR(&record); - ZEPHIR_INIT_NVAR(&name); - RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_Model, postSave) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_ManagerInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, ManagerInterface, phalcon, mvc_model_managerinterface, phalcon_mvc_model_managerinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addBehavior); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addBelongsTo); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addHasMany); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addHasOne); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addHasOneThrough); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addHasManyToMany); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, createBuilder); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, createQuery); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, executeQuery); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getBelongsTo); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getBelongsToRecords); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getBuilder); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasMany); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasManyRecords); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasManyToMany); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasOne); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasOneThrough); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasOneAndHasMany); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasOneRecords); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getLastInitialized); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getLastQuery); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getModelSchema); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getModelSource); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getReadConnection); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getReadConnectionService); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getRelationByAlias); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getRelationRecords); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getRelations); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getRelationsBetween); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getWriteConnection); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getWriteConnectionService); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, hasBelongsTo); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, hasHasMany); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, hasHasOne); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, hasHasOneThrough); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, hasHasManyToMany); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, load); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, initialize); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, isInitialized); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, isKeepingSnapshots); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, isUsingDynamicUpdate); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, isVisibleModelProperty); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, keepSnapshots); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, missingMethod); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, notifyEvent); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setConnectionService); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setReadConnectionService); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setModelSchema); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setModelSource); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setWriteConnectionService); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, useDynamicUpdate); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, MetaData, phalcon, mvc_model_metadata, phalcon_mvc_model_metadata_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("adapter"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("columnMap"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("container"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("metaData"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("strategy"), ZEND_ACC_PROTECTED); + phalcon_mvc_model_metadata_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_MetaData; + zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_ATTRIBUTES"), 0); + + zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_AUTOMATIC_DEFAULT_INSERT"), 10); + + zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_AUTOMATIC_DEFAULT_UPDATE"), 11); + + zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_COLUMN_MAP"), 0); + + zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATE_AT"), 6); + + zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATE_IN"), 7); + + zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATA_TYPES"), 4); + + zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATA_TYPES_BIND"), 9); + + zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATA_TYPES_NUMERIC"), 5); + + zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DEFAULT_VALUES"), 12); + + zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_EMPTY_STRING_VALUES"), 13); + + zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_IDENTITY_COLUMN"), 8); + + zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_NON_PRIMARY_KEY"), 2); + + zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_NOT_NULL"), 3); + + zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_PRIMARY_KEY"), 1); + + zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_REVERSE_COLUMN_MAP"), 1); + + zend_class_implements(phalcon_mvc_model_metadata_ce, 1, phalcon_di_injectionawareinterface_ce); + zend_class_implements(phalcon_mvc_model_metadata_ce, 1, phalcon_mvc_model_metadatainterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getAdapter) +{ + + RETURN_MEMBER(getThis(), "adapter"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getAttributes) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *success_param = NULL, *exists_param = NULL, _0$$4, _1$$5; - zend_bool success, exists; + zval *model, model_sub, data, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$5); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_BOOL(success) - Z_PARAM_BOOL(exists) + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &success_param, &exists_param); - if (success) { - if (exists) { - ZEPHIR_INIT_VAR(&_0$$4); - ZVAL_STRING(&_0$$4, "afterUpdate"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_0$$4); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_VAR(&_1$$5); - ZVAL_STRING(&_1$$5, "afterCreate"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_1$$5); + zephir_fetch_params(1, 1, 0, &model); + ZVAL_LONG(&_0, 0); + ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 110); + return; + } + RETURN_CCTOR(&data); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getAutomaticCreateAttributes) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, data, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + ZVAL_LONG(&_0, 10); + ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 137); + return; + } + RETURN_CCTOR(&data); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getAutomaticUpdateAttributes) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, data, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + ZVAL_LONG(&_0, 11); + ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 164); + return; + } + RETURN_CCTOR(&data); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getBindTypes) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, data, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + ZVAL_LONG(&_0, 9); + ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 191); + return; + } + RETURN_CCTOR(&data); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getColumnMap) +{ + zend_bool _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, data, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + ZVAL_LONG(&_0, 0); + ZEPHIR_CALL_METHOD(&data, this_ptr, "readcolumnmapindex", NULL, 25, model, &_0); + zephir_check_call_status(); + _1 = Z_TYPE_P(&data) != IS_NULL; + if (_1) { + _1 = Z_TYPE_P(&data) != IS_ARRAY; + } + if (UNEXPECTED(_1)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 215); + return; + } + RETURN_CCTOR(&data); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getDefaultValues) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, data, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + ZVAL_LONG(&_0, 12); + ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 239); + return; + } + RETURN_CCTOR(&data); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getDataTypes) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, data, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + ZVAL_LONG(&_0, 4); + ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 263); + return; + } + RETURN_CCTOR(&data); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getDataTypesNumeric) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, data, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + ZVAL_LONG(&_0, 5); + ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 290); + return; + } + RETURN_CCTOR(&data); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getDI) +{ + zval container, _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_0); + if (Z_TYPE_P(&container) != IS_OBJECT) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injection container is required to access internal services", "phalcon/Mvc/Model/MetaData.zep", 308); + return; + } + RETURN_CCTOR(&container); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getEmptyStringAttributes) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, data, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + ZVAL_LONG(&_0, 13); + ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 335); + return; + } + RETURN_CCTOR(&data); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getIdentityField) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + ZVAL_LONG(&_0, 8); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "readmetadataindex", NULL, 24, model, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getNonPrimaryKeyAttributes) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, data, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + ZVAL_LONG(&_0, 2); + ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 375); + return; + } + RETURN_CCTOR(&data); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getNotNullAttributes) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, data, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + ZVAL_LONG(&_0, 3); + ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 399); + return; + } + RETURN_CCTOR(&data); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getPrimaryKeyAttributes) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, data, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + ZVAL_LONG(&_0, 1); + ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 423); + return; + } + RETURN_CCTOR(&data); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getReverseColumnMap) +{ + zend_bool _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, data, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &model); + ZVAL_LONG(&_0, 1); + ZEPHIR_CALL_METHOD(&data, this_ptr, "readcolumnmapindex", NULL, 25, model, &_0); + zephir_check_call_status(); + _1 = Z_TYPE_P(&data) != IS_NULL; + if (_1) { + _1 = Z_TYPE_P(&data) != IS_ARRAY; + } + if (UNEXPECTED(_1)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 450); + return; + } + RETURN_CCTOR(&data); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getStrategy) +{ + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("strategy"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_mvc_model_metadata_strategy_introspection_ce); + if (zephir_has_constructor(&_1$$3)) { + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 0); zephir_check_call_status(); } + + zephir_update_property_zval(this_ptr, ZEND_STRL("strategy"), &_1$$3); } - RETURN_MM_BOOL(success); + RETURN_MM_MEMBER(getThis(), "strategy"); } -static PHP_METHOD(Phalcon_Mvc_Model, postSaveRelatedRecords) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, hasAttribute) { - zval _32$$14, _34$$14, _44$$19, _46$$19, _88$$40, _90$$40, _100$$45, _102$$45; - zend_string *_4; - zend_ulong _3; - zend_bool nesting = 0, isThrough = 0, _8$$4, _65$$30; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_6 = NULL, *_10 = NULL, *_13 = NULL, *_15 = NULL, *_19 = NULL, *_26 = NULL, *_28 = NULL, *_30 = NULL, *_31 = NULL, *_37 = NULL, *_40 = NULL, *_42 = NULL, *_43 = NULL, *_49 = NULL, *_54 = NULL, *_57 = NULL, *_59 = NULL, *_63 = NULL, *_67 = NULL, *_71 = NULL, *_76 = NULL, *_84 = NULL, *_86 = NULL, *_87 = NULL, *_93 = NULL, *_96 = NULL, *_98 = NULL, *_99 = NULL, *_105 = NULL, *_110 = NULL, *_113 = NULL, *_115 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connection, connection_sub, *related, related_sub, *visited, visited_sub, className, manager, relation, name, record, columns, referencedModel, referencedFields, relatedRecords, value, recordAfter, intermediateModel, intermediateFields, intermediateValue, intermediateModelName, intermediateReferencedFields, existingIntermediateModel, _0, *_1, _2, _118, _5$$3, _7$$4, _22$$4, _9$$6, _11$$6, _12$$6, _14$$7, _16$$7, _17$$7, _18$$10, _20$$10, _21$$10, *_23$$11, _24$$11, _25$$12, _29$$12, _35$$12, _27$$13, _33$$14, _36$$16, _38$$17, _41$$17, _47$$17, _39$$18, _45$$19, _48$$21, *_50$$22, _51$$22, _52$$23, _53$$24, _55$$25, _56$$26, _58$$28, _60$$28, _61$$28, _62$$29, _64$$30, _79$$30, _66$$32, _68$$32, _69$$32, _70$$33, _72$$33, _73$$33, _74$$34, _75$$36, _77$$36, _78$$36, *_80$$37, _81$$37, _82$$38, _85$$38, _91$$38, _83$$39, _89$$40, _92$$42, _94$$43, _97$$43, _103$$43, _95$$44, _101$$45, _104$$47, *_106$$48, _107$$48, _108$$49, _109$$50, _111$$51, _112$$52, _114$$54, _116$$54, _117$$54; + zval attribute; + zval *model, model_sub, *attribute_param = NULL, columnMap, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connection_sub); - ZVAL_UNDEF(&related_sub); - ZVAL_UNDEF(&visited_sub); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&record); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&referencedModel); - ZVAL_UNDEF(&referencedFields); - ZVAL_UNDEF(&relatedRecords); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&recordAfter); - ZVAL_UNDEF(&intermediateModel); - ZVAL_UNDEF(&intermediateFields); - ZVAL_UNDEF(&intermediateValue); - ZVAL_UNDEF(&intermediateModelName); - ZVAL_UNDEF(&intermediateReferencedFields); - ZVAL_UNDEF(&existingIntermediateModel); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&columnMap); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_118); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_22$$4); - ZVAL_UNDEF(&_9$$6); - ZVAL_UNDEF(&_11$$6); - ZVAL_UNDEF(&_12$$6); - ZVAL_UNDEF(&_14$$7); - ZVAL_UNDEF(&_16$$7); - ZVAL_UNDEF(&_17$$7); - ZVAL_UNDEF(&_18$$10); - ZVAL_UNDEF(&_20$$10); - ZVAL_UNDEF(&_21$$10); - ZVAL_UNDEF(&_24$$11); - ZVAL_UNDEF(&_25$$12); - ZVAL_UNDEF(&_29$$12); - ZVAL_UNDEF(&_35$$12); - ZVAL_UNDEF(&_27$$13); - ZVAL_UNDEF(&_33$$14); - ZVAL_UNDEF(&_36$$16); - ZVAL_UNDEF(&_38$$17); - ZVAL_UNDEF(&_41$$17); - ZVAL_UNDEF(&_47$$17); - ZVAL_UNDEF(&_39$$18); - ZVAL_UNDEF(&_45$$19); - ZVAL_UNDEF(&_48$$21); - ZVAL_UNDEF(&_51$$22); - ZVAL_UNDEF(&_52$$23); - ZVAL_UNDEF(&_53$$24); - ZVAL_UNDEF(&_55$$25); - ZVAL_UNDEF(&_56$$26); - ZVAL_UNDEF(&_58$$28); - ZVAL_UNDEF(&_60$$28); - ZVAL_UNDEF(&_61$$28); - ZVAL_UNDEF(&_62$$29); - ZVAL_UNDEF(&_64$$30); - ZVAL_UNDEF(&_79$$30); - ZVAL_UNDEF(&_66$$32); - ZVAL_UNDEF(&_68$$32); - ZVAL_UNDEF(&_69$$32); - ZVAL_UNDEF(&_70$$33); - ZVAL_UNDEF(&_72$$33); - ZVAL_UNDEF(&_73$$33); - ZVAL_UNDEF(&_74$$34); - ZVAL_UNDEF(&_75$$36); - ZVAL_UNDEF(&_77$$36); - ZVAL_UNDEF(&_78$$36); - ZVAL_UNDEF(&_81$$37); - ZVAL_UNDEF(&_82$$38); - ZVAL_UNDEF(&_85$$38); - ZVAL_UNDEF(&_91$$38); - ZVAL_UNDEF(&_83$$39); - ZVAL_UNDEF(&_89$$40); - ZVAL_UNDEF(&_92$$42); - ZVAL_UNDEF(&_94$$43); - ZVAL_UNDEF(&_97$$43); - ZVAL_UNDEF(&_103$$43); - ZVAL_UNDEF(&_95$$44); - ZVAL_UNDEF(&_101$$45); - ZVAL_UNDEF(&_104$$47); - ZVAL_UNDEF(&_107$$48); - ZVAL_UNDEF(&_108$$49); - ZVAL_UNDEF(&_109$$50); - ZVAL_UNDEF(&_111$$51); - ZVAL_UNDEF(&_112$$52); - ZVAL_UNDEF(&_114$$54); - ZVAL_UNDEF(&_116$$54); - ZVAL_UNDEF(&_117$$54); - ZVAL_UNDEF(&_32$$14); - ZVAL_UNDEF(&_34$$14); - ZVAL_UNDEF(&_44$$19); - ZVAL_UNDEF(&_46$$19); - ZVAL_UNDEF(&_88$$40); - ZVAL_UNDEF(&_90$$40); - ZVAL_UNDEF(&_100$$45); - ZVAL_UNDEF(&_102$$45); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_db_adapter_adapterinterface_ce) - Z_PARAM_ZVAL(related) - Z_PARAM_OBJECT_OF_CLASS(visited, phalcon_support_collection_collectioninterface_ce) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&attribute); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_STR(attribute) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &connection, &related, &visited); - nesting = 0; - ZEPHIR_INIT_VAR(&className); - zephir_get_class(&className, this_ptr, 0); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmodelsmanager", NULL, 0); + zephir_fetch_params(1, 2, 0, &model, &attribute_param); + zephir_get_strval(&attribute, attribute_param); + ZEPHIR_CALL_METHOD(&columnMap, this_ptr, "getreversecolumnmap", NULL, 0, model); zephir_check_call_status(); - ZEPHIR_CPY_WRT(&manager, &_0); - zephir_is_iterable(related, 0, "phalcon/Mvc/Model.zep", 5340); - if (Z_TYPE_P(related) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(related), _3, _4, _1) - { - ZEPHIR_INIT_NVAR(&name); - if (_4 != NULL) { - ZVAL_STR_COPY(&name, _4); - } else { - ZVAL_LONG(&name, _3); - } - ZEPHIR_INIT_NVAR(&record); - ZVAL_COPY(&record, _1); - ZEPHIR_CALL_METHOD(&_5$$3, &manager, "getrelationbyalias", &_6, 0, &className, &name); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&relation, &_5$$3); - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(&_7$$4, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_LONG(&_7$$4, 0)) { - continue; - } - _8$$4 = Z_TYPE_P(&record) != IS_OBJECT; - if (_8$$4) { - _8$$4 = Z_TYPE_P(&record) != IS_ARRAY; - } - if (UNEXPECTED(_8$$4)) { - if (nesting) { - ZVAL_BOOL(&_9$$6, 1); - } else { - ZVAL_BOOL(&_9$$6, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_10, 0, &_9$$6); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_11$$6); - object_init_ex(&_11$$6, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_12$$6); - ZEPHIR_CONCAT_SVSV(&_12$$6, "Only objects/arrays can be stored as part of has-many/has-one/has-one-through/has-many-to-many relations on model ", &className, " on Relation ", &name); - ZEPHIR_CALL_METHOD(NULL, &_11$$6, "__construct", &_13, 33, &_12$$6); - zephir_check_call_status(); - zephir_throw_exception_debug(&_11$$6, "phalcon/Mvc/Model.zep", 5175); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CALL_METHOD(&columns, &relation, "getfields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedModel, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedFields, &relation, "getreferencedfields", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&columns) == IS_ARRAY)) { - if (nesting) { - ZVAL_BOOL(&_14$$7, 1); - } else { - ZVAL_BOOL(&_14$$7, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_15, 0, &_14$$7); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_16$$7); - object_init_ex(&_16$$7, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_17$$7); - ZEPHIR_CONCAT_SVSV(&_17$$7, "Not implemented in '", &className, "' on Relation ", &name); - ZEPHIR_CALL_METHOD(NULL, &_16$$7, "__construct", &_13, 33, &_17$$7); - zephir_check_call_status(); - zephir_throw_exception_debug(&_16$$7, "phalcon/Mvc/Model.zep", 5185); - ZEPHIR_MM_RESTORE(); - return; - } - if (Z_TYPE_P(&record) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&relatedRecords); - zephir_create_array(&relatedRecords, 1, 0); - zephir_array_fast_append(&relatedRecords, &record); - } else { - ZEPHIR_CPY_WRT(&relatedRecords, &record); - } - ZEPHIR_OBS_NVAR(&value); - if (UNEXPECTED(!(zephir_fetch_property_zval(&value, this_ptr, &columns, PH_SILENT_CC)))) { - if (nesting) { - ZVAL_BOOL(&_18$$10, 1); - } else { - ZVAL_BOOL(&_18$$10, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_19, 0, &_18$$10); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_20$$10); - object_init_ex(&_20$$10, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_21$$10); - ZEPHIR_CONCAT_SVSVS(&_21$$10, "The column '", &columns, "' needs to be present in the model '", &className, "'"); - ZEPHIR_CALL_METHOD(NULL, &_20$$10, "__construct", &_13, 33, &_21$$10); - zephir_check_call_status(); - zephir_throw_exception_debug(&_20$$10, "phalcon/Mvc/Model.zep", 5202); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CALL_METHOD(&_22$$4, &relation, "isthrough", NULL, 0); - zephir_check_call_status(); - isThrough = zephir_get_boolval(&_22$$4); - if (isThrough) { - ZEPHIR_CALL_METHOD(&intermediateModelName, &relation, "getintermediatemodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&intermediateFields, &relation, "getintermediatefields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&intermediateReferencedFields, &relation, "getintermediatereferencedfields", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&relatedRecords, 0, "phalcon/Mvc/Model.zep", 5301); - if (Z_TYPE_P(&relatedRecords) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relatedRecords), _23$$11) - { - ZEPHIR_INIT_NVAR(&recordAfter); - ZVAL_COPY(&recordAfter, _23$$11); - ZEPHIR_CALL_METHOD(&_25$$12, &recordAfter, "dosave", NULL, 0, visited); - zephir_check_call_status(); - if (!(zephir_is_true(&_25$$12))) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &recordAfter); - zephir_check_call_status(); - if (nesting) { - ZVAL_BOOL(&_27$$13, 1); - } else { - ZVAL_BOOL(&_27$$13, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_28, 0, &_27$$13); - zephir_check_call_status(); - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(&_29$$12, &manager, "load", &_30, 0, &intermediateModelName); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&intermediateModel, &_29$$12); - ZEPHIR_CALL_METHOD(&_29$$12, &relation, "gettype", &_31, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_LONG(&_29$$12, 3)) { - ZEPHIR_INIT_NVAR(&_32$$14); - zephir_create_array(&_32$$14, 2, 0); - ZEPHIR_INIT_NVAR(&_33$$14); - ZEPHIR_CONCAT_SVS(&_33$$14, "[", &intermediateFields, "] = ?0"); - zephir_array_fast_append(&_32$$14, &_33$$14); - ZEPHIR_INIT_NVAR(&_34$$14); - zephir_create_array(&_34$$14, 1, 0); - zephir_array_fast_append(&_34$$14, &value); - zephir_array_update_string(&_32$$14, SL("bind"), &_34$$14, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&existingIntermediateModel, &intermediateModel, "findfirst", NULL, 0, &_32$$14); - zephir_check_call_status(); - if (zephir_is_true(&existingIntermediateModel)) { - ZEPHIR_CPY_WRT(&intermediateModel, &existingIntermediateModel); - } - } - ZEPHIR_CALL_METHOD(NULL, &intermediateModel, "writeattribute", NULL, 0, &intermediateFields, &value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&intermediateValue, &recordAfter, "readattribute", NULL, 0, &referencedFields); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &intermediateModel, "writeattribute", NULL, 0, &intermediateReferencedFields, &intermediateValue); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_35$$12, &intermediateModel, "dosave", NULL, 0, visited); - zephir_check_call_status(); - if (!(zephir_is_true(&_35$$12))) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &intermediateModel); - zephir_check_call_status(); - if (nesting) { - ZVAL_BOOL(&_36$$16, 1); - } else { - ZVAL_BOOL(&_36$$16, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_37, 0, &_36$$16); - zephir_check_call_status(); - RETURN_MM_BOOL(0); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &relatedRecords, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_24$$11, &relatedRecords, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_24$$11)) { - break; - } - ZEPHIR_CALL_METHOD(&recordAfter, &relatedRecords, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_38$$17, &recordAfter, "dosave", NULL, 0, visited); - zephir_check_call_status(); - if (!(zephir_is_true(&_38$$17))) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &recordAfter); - zephir_check_call_status(); - if (nesting) { - ZVAL_BOOL(&_39$$18, 1); - } else { - ZVAL_BOOL(&_39$$18, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_40, 0, &_39$$18); - zephir_check_call_status(); - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(&_41$$17, &manager, "load", &_42, 0, &intermediateModelName); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&intermediateModel, &_41$$17); - ZEPHIR_CALL_METHOD(&_41$$17, &relation, "gettype", &_43, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_LONG(&_41$$17, 3)) { - ZEPHIR_INIT_NVAR(&_44$$19); - zephir_create_array(&_44$$19, 2, 0); - ZEPHIR_INIT_NVAR(&_45$$19); - ZEPHIR_CONCAT_SVS(&_45$$19, "[", &intermediateFields, "] = ?0"); - zephir_array_fast_append(&_44$$19, &_45$$19); - ZEPHIR_INIT_NVAR(&_46$$19); - zephir_create_array(&_46$$19, 1, 0); - zephir_array_fast_append(&_46$$19, &value); - zephir_array_update_string(&_44$$19, SL("bind"), &_46$$19, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&existingIntermediateModel, &intermediateModel, "findfirst", NULL, 0, &_44$$19); - zephir_check_call_status(); - if (zephir_is_true(&existingIntermediateModel)) { - ZEPHIR_CPY_WRT(&intermediateModel, &existingIntermediateModel); - } - } - ZEPHIR_CALL_METHOD(NULL, &intermediateModel, "writeattribute", NULL, 0, &intermediateFields, &value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&intermediateValue, &recordAfter, "readattribute", NULL, 0, &referencedFields); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &intermediateModel, "writeattribute", NULL, 0, &intermediateReferencedFields, &intermediateValue); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_47$$17, &intermediateModel, "dosave", NULL, 0, visited); - zephir_check_call_status(); - if (!(zephir_is_true(&_47$$17))) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &intermediateModel); - zephir_check_call_status(); - if (nesting) { - ZVAL_BOOL(&_48$$21, 1); - } else { - ZVAL_BOOL(&_48$$21, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_49, 0, &_48$$21); - zephir_check_call_status(); - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(NULL, &relatedRecords, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&recordAfter); - } else { - zephir_is_iterable(&relatedRecords, 0, "phalcon/Mvc/Model.zep", 5325); - if (Z_TYPE_P(&relatedRecords) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relatedRecords), _50$$22) - { - ZEPHIR_INIT_NVAR(&recordAfter); - ZVAL_COPY(&recordAfter, _50$$22); - ZEPHIR_CALL_METHOD(NULL, &recordAfter, "writeattribute", NULL, 0, &referencedFields, &value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_52$$23, &recordAfter, "dosave", NULL, 0, visited); - zephir_check_call_status(); - if (!(zephir_is_true(&_52$$23))) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &recordAfter); - zephir_check_call_status(); - if (nesting) { - ZVAL_BOOL(&_53$$24, 1); - } else { - ZVAL_BOOL(&_53$$24, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_54, 0, &_53$$24); - zephir_check_call_status(); - RETURN_MM_BOOL(0); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &relatedRecords, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_51$$22, &relatedRecords, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_51$$22)) { - break; - } - ZEPHIR_CALL_METHOD(&recordAfter, &relatedRecords, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &recordAfter, "writeattribute", NULL, 0, &referencedFields, &value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_55$$25, &recordAfter, "dosave", NULL, 0, visited); - zephir_check_call_status(); - if (!(zephir_is_true(&_55$$25))) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &recordAfter); - zephir_check_call_status(); - if (nesting) { - ZVAL_BOOL(&_56$$26, 1); - } else { - ZVAL_BOOL(&_56$$26, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_57, 0, &_56$$26); - zephir_check_call_status(); - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(NULL, &relatedRecords, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&recordAfter); - } - } else { - if (UNEXPECTED(Z_TYPE_P(&record) != IS_ARRAY)) { - if (nesting) { - ZVAL_BOOL(&_58$$28, 1); - } else { - ZVAL_BOOL(&_58$$28, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_59, 0, &_58$$28); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_60$$28); - object_init_ex(&_60$$28, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_61$$28); - ZEPHIR_CONCAT_SVSVS(&_61$$28, "There are no defined relations for the model '", &className, "' using alias '", &name, "'"); - ZEPHIR_CALL_METHOD(NULL, &_60$$28, "__construct", &_13, 33, &_61$$28); - zephir_check_call_status(); - zephir_throw_exception_debug(&_60$$28, "phalcon/Mvc/Model.zep", 5332); - ZEPHIR_MM_RESTORE(); - return; - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, related, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, related, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&name, related, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&record, related, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_62$$29, &manager, "getrelationbyalias", &_63, 0, &className, &name); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&relation, &_62$$29); - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(&_64$$30, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_LONG(&_64$$30, 0)) { - continue; - } - _65$$30 = Z_TYPE_P(&record) != IS_OBJECT; - if (_65$$30) { - _65$$30 = Z_TYPE_P(&record) != IS_ARRAY; - } - if (UNEXPECTED(_65$$30)) { - if (nesting) { - ZVAL_BOOL(&_66$$32, 1); - } else { - ZVAL_BOOL(&_66$$32, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_67, 0, &_66$$32); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_68$$32); - object_init_ex(&_68$$32, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_69$$32); - ZEPHIR_CONCAT_SVSV(&_69$$32, "Only objects/arrays can be stored as part of has-many/has-one/has-one-through/has-many-to-many relations on model ", &className, " on Relation ", &name); - ZEPHIR_CALL_METHOD(NULL, &_68$$32, "__construct", &_13, 33, &_69$$32); - zephir_check_call_status(); - zephir_throw_exception_debug(&_68$$32, "phalcon/Mvc/Model.zep", 5175); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CALL_METHOD(&columns, &relation, "getfields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedModel, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedFields, &relation, "getreferencedfields", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&columns) == IS_ARRAY)) { - if (nesting) { - ZVAL_BOOL(&_70$$33, 1); - } else { - ZVAL_BOOL(&_70$$33, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_71, 0, &_70$$33); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_72$$33); - object_init_ex(&_72$$33, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_73$$33); - ZEPHIR_CONCAT_SVSV(&_73$$33, "Not implemented in '", &className, "' on Relation ", &name); - ZEPHIR_CALL_METHOD(NULL, &_72$$33, "__construct", &_13, 33, &_73$$33); - zephir_check_call_status(); - zephir_throw_exception_debug(&_72$$33, "phalcon/Mvc/Model.zep", 5185); - ZEPHIR_MM_RESTORE(); - return; - } - if (Z_TYPE_P(&record) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_74$$34); - zephir_create_array(&_74$$34, 1, 0); - zephir_array_fast_append(&_74$$34, &record); - ZEPHIR_CPY_WRT(&relatedRecords, &_74$$34); - } else { - ZEPHIR_CPY_WRT(&relatedRecords, &record); - } - ZEPHIR_OBS_NVAR(&value); - if (UNEXPECTED(!(zephir_fetch_property_zval(&value, this_ptr, &columns, PH_SILENT_CC)))) { - if (nesting) { - ZVAL_BOOL(&_75$$36, 1); - } else { - ZVAL_BOOL(&_75$$36, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_76, 0, &_75$$36); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_77$$36); - object_init_ex(&_77$$36, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_78$$36); - ZEPHIR_CONCAT_SVSVS(&_78$$36, "The column '", &columns, "' needs to be present in the model '", &className, "'"); - ZEPHIR_CALL_METHOD(NULL, &_77$$36, "__construct", &_13, 33, &_78$$36); - zephir_check_call_status(); - zephir_throw_exception_debug(&_77$$36, "phalcon/Mvc/Model.zep", 5202); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CALL_METHOD(&_79$$30, &relation, "isthrough", NULL, 0); - zephir_check_call_status(); - isThrough = zephir_get_boolval(&_79$$30); - if (isThrough) { - ZEPHIR_CALL_METHOD(&intermediateModelName, &relation, "getintermediatemodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&intermediateFields, &relation, "getintermediatefields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&intermediateReferencedFields, &relation, "getintermediatereferencedfields", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&relatedRecords, 0, "phalcon/Mvc/Model.zep", 5301); - if (Z_TYPE_P(&relatedRecords) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relatedRecords), _80$$37) - { - ZEPHIR_INIT_NVAR(&recordAfter); - ZVAL_COPY(&recordAfter, _80$$37); - ZEPHIR_CALL_METHOD(&_82$$38, &recordAfter, "dosave", NULL, 0, visited); - zephir_check_call_status(); - if (!(zephir_is_true(&_82$$38))) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &recordAfter); - zephir_check_call_status(); - if (nesting) { - ZVAL_BOOL(&_83$$39, 1); - } else { - ZVAL_BOOL(&_83$$39, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_84, 0, &_83$$39); - zephir_check_call_status(); - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(&_85$$38, &manager, "load", &_86, 0, &intermediateModelName); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&intermediateModel, &_85$$38); - ZEPHIR_CALL_METHOD(&_85$$38, &relation, "gettype", &_87, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_LONG(&_85$$38, 3)) { - ZEPHIR_INIT_NVAR(&_88$$40); - zephir_create_array(&_88$$40, 2, 0); - ZEPHIR_INIT_NVAR(&_89$$40); - ZEPHIR_CONCAT_SVS(&_89$$40, "[", &intermediateFields, "] = ?0"); - zephir_array_fast_append(&_88$$40, &_89$$40); - ZEPHIR_INIT_NVAR(&_90$$40); - zephir_create_array(&_90$$40, 1, 0); - zephir_array_fast_append(&_90$$40, &value); - zephir_array_update_string(&_88$$40, SL("bind"), &_90$$40, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&existingIntermediateModel, &intermediateModel, "findfirst", NULL, 0, &_88$$40); - zephir_check_call_status(); - if (zephir_is_true(&existingIntermediateModel)) { - ZEPHIR_CPY_WRT(&intermediateModel, &existingIntermediateModel); - } - } - ZEPHIR_CALL_METHOD(NULL, &intermediateModel, "writeattribute", NULL, 0, &intermediateFields, &value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&intermediateValue, &recordAfter, "readattribute", NULL, 0, &referencedFields); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &intermediateModel, "writeattribute", NULL, 0, &intermediateReferencedFields, &intermediateValue); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_91$$38, &intermediateModel, "dosave", NULL, 0, visited); - zephir_check_call_status(); - if (!(zephir_is_true(&_91$$38))) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &intermediateModel); - zephir_check_call_status(); - if (nesting) { - ZVAL_BOOL(&_92$$42, 1); - } else { - ZVAL_BOOL(&_92$$42, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_93, 0, &_92$$42); - zephir_check_call_status(); - RETURN_MM_BOOL(0); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &relatedRecords, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_81$$37, &relatedRecords, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_81$$37)) { - break; - } - ZEPHIR_CALL_METHOD(&recordAfter, &relatedRecords, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_94$$43, &recordAfter, "dosave", NULL, 0, visited); - zephir_check_call_status(); - if (!(zephir_is_true(&_94$$43))) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &recordAfter); - zephir_check_call_status(); - if (nesting) { - ZVAL_BOOL(&_95$$44, 1); - } else { - ZVAL_BOOL(&_95$$44, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_96, 0, &_95$$44); - zephir_check_call_status(); - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(&_97$$43, &manager, "load", &_98, 0, &intermediateModelName); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&intermediateModel, &_97$$43); - ZEPHIR_CALL_METHOD(&_97$$43, &relation, "gettype", &_99, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_LONG(&_97$$43, 3)) { - ZEPHIR_INIT_NVAR(&_100$$45); - zephir_create_array(&_100$$45, 2, 0); - ZEPHIR_INIT_NVAR(&_101$$45); - ZEPHIR_CONCAT_SVS(&_101$$45, "[", &intermediateFields, "] = ?0"); - zephir_array_fast_append(&_100$$45, &_101$$45); - ZEPHIR_INIT_NVAR(&_102$$45); - zephir_create_array(&_102$$45, 1, 0); - zephir_array_fast_append(&_102$$45, &value); - zephir_array_update_string(&_100$$45, SL("bind"), &_102$$45, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&existingIntermediateModel, &intermediateModel, "findfirst", NULL, 0, &_100$$45); - zephir_check_call_status(); - if (zephir_is_true(&existingIntermediateModel)) { - ZEPHIR_CPY_WRT(&intermediateModel, &existingIntermediateModel); - } - } - ZEPHIR_CALL_METHOD(NULL, &intermediateModel, "writeattribute", NULL, 0, &intermediateFields, &value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&intermediateValue, &recordAfter, "readattribute", NULL, 0, &referencedFields); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &intermediateModel, "writeattribute", NULL, 0, &intermediateReferencedFields, &intermediateValue); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_103$$43, &intermediateModel, "dosave", NULL, 0, visited); - zephir_check_call_status(); - if (!(zephir_is_true(&_103$$43))) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &intermediateModel); - zephir_check_call_status(); - if (nesting) { - ZVAL_BOOL(&_104$$47, 1); - } else { - ZVAL_BOOL(&_104$$47, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_105, 0, &_104$$47); - zephir_check_call_status(); - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(NULL, &relatedRecords, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&recordAfter); - } else { - zephir_is_iterable(&relatedRecords, 0, "phalcon/Mvc/Model.zep", 5325); - if (Z_TYPE_P(&relatedRecords) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&relatedRecords), _106$$48) - { - ZEPHIR_INIT_NVAR(&recordAfter); - ZVAL_COPY(&recordAfter, _106$$48); - ZEPHIR_CALL_METHOD(NULL, &recordAfter, "writeattribute", NULL, 0, &referencedFields, &value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_108$$49, &recordAfter, "dosave", NULL, 0, visited); - zephir_check_call_status(); - if (!(zephir_is_true(&_108$$49))) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &recordAfter); - zephir_check_call_status(); - if (nesting) { - ZVAL_BOOL(&_109$$50, 1); - } else { - ZVAL_BOOL(&_109$$50, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_110, 0, &_109$$50); - zephir_check_call_status(); - RETURN_MM_BOOL(0); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &relatedRecords, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_107$$48, &relatedRecords, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_107$$48)) { - break; - } - ZEPHIR_CALL_METHOD(&recordAfter, &relatedRecords, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &recordAfter, "writeattribute", NULL, 0, &referencedFields, &value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_111$$51, &recordAfter, "dosave", NULL, 0, visited); - zephir_check_call_status(); - if (!(zephir_is_true(&_111$$51))) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessagesfrom", &_26, 0, &recordAfter); - zephir_check_call_status(); - if (nesting) { - ZVAL_BOOL(&_112$$52, 1); - } else { - ZVAL_BOOL(&_112$$52, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_113, 0, &_112$$52); - zephir_check_call_status(); - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(NULL, &relatedRecords, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&recordAfter); - } - } else { - if (UNEXPECTED(Z_TYPE_P(&record) != IS_ARRAY)) { - if (nesting) { - ZVAL_BOOL(&_114$$54, 1); - } else { - ZVAL_BOOL(&_114$$54, 0); - } - ZEPHIR_CALL_METHOD(NULL, connection, "rollback", &_115, 0, &_114$$54); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_116$$54); - object_init_ex(&_116$$54, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_117$$54); - ZEPHIR_CONCAT_SVSVS(&_117$$54, "There are no defined relations for the model '", &className, "' using alias '", &name, "'"); - ZEPHIR_CALL_METHOD(NULL, &_116$$54, "__construct", &_13, 33, &_117$$54); - zephir_check_call_status(); - zephir_throw_exception_debug(&_116$$54, "phalcon/Mvc/Model.zep", 5332); - ZEPHIR_MM_RESTORE(); - return; - } - } - ZEPHIR_CALL_METHOD(NULL, related, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&record); - ZEPHIR_INIT_NVAR(&name); - if (nesting) { - ZVAL_BOOL(&_118, 1); - } else { - ZVAL_BOOL(&_118, 0); + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + RETURN_MM_BOOL(zephir_array_isset(&columnMap, &attribute)); } - ZEPHIR_CALL_METHOD(NULL, connection, "commit", NULL, 0, &_118); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "readmetadata", NULL, 26, model); zephir_check_call_status(); - RETURN_MM_BOOL(1); + zephir_array_fetch_long(&_1, &_0, 4, PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 490); + RETURN_MM_BOOL(zephir_array_isset(&_1, &attribute)); } -static PHP_METHOD(Phalcon_Mvc_Model, allowEmptyStringValues) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, isEmpty) +{ + zval _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); + RETURN_BOOL(zephir_fast_count_int(&_0) == 0); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, read) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *attributes_param = NULL, __$true, keysAttributes, attribute, *_0, _1, _2; - zval attributes; + zval *key_param = NULL, _0; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&attributes); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&keysAttributes); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(attributes) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &attributes_param); - ZEPHIR_OBS_COPY_OR_DUP(&attributes, attributes_param); - ZEPHIR_INIT_VAR(&keysAttributes); - array_init(&keysAttributes); - zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model.zep", 5373); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _0) - { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _0); - zephir_array_update_zval(&keysAttributes, &attribute, &__$true, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 1, 0, &key_param); + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &attributes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&keysAttributes, &attribute, &__$true, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&key); } - ZEPHIR_INIT_NVAR(&attribute); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getmodelsmetadata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_2, "setemptystringattributes", NULL, 0, this_ptr, &keysAttributes); + zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &key); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model, cancelOperation) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, readColumnMap) { - zval _0, _1$$3, _2$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, keyName, _0$$4, _1$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&keyName); + ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&_1$$4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("operationMade"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_LONG(&_0, 3)) { - ZEPHIR_INIT_VAR(&_1$$3); - ZVAL_STRING(&_1$$3, "notDeleted"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_1$$3); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_VAR(&_2$$4); - ZVAL_STRING(&_2$$4, "notSaved"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "fireevent", NULL, 0, &_2$$4); - zephir_check_call_status(); + zephir_fetch_params(1, 1, 0, &model); + if (!(ZEPHIR_GLOBAL(orm).column_renaming)) { + RETURN_MM_NULL(); } - ZEPHIR_MM_RESTORE(); + ZEPHIR_CALL_METHOD(&keyName, this_ptr, "getcolumnmapuniquekey", NULL, 27, model); + zephir_check_call_status(); + if (EXPECTED(Z_TYPE_P(&keyName) != IS_NULL)) { + zephir_read_property(&_0$$4, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_1$$4, &_0$$4, &keyName, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 535); + RETURN_CTOR(&_1$$4); + } + RETURN_MM_NULL(); } -static PHP_METHOD(Phalcon_Mvc_Model, belongsTo) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, readColumnMapIndex) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval referenceModel; - zval *fields, fields_sub, *referenceModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, _0; + zend_long index, ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, *index_param = NULL, keyName, _0$$4, _1$$4, _2$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&fields_sub); - ZVAL_UNDEF(&referencedFields_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&referenceModel); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_ZVAL(fields) - Z_PARAM_STR(referenceModel) - Z_PARAM_ZVAL(referencedFields) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&keyName); + ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$4); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_LONG(index) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 1, &fields, &referenceModel_param, &referencedFields, &options_param); - if (UNEXPECTED(Z_TYPE_P(referenceModel_param) != IS_STRING && Z_TYPE_P(referenceModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceModel' must be of the type string")); + zephir_fetch_params(1, 2, 0, &model, &index_param); + if (!(ZEPHIR_GLOBAL(orm).column_renaming)) { RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(referenceModel_param) == IS_STRING)) { - zephir_get_strval(&referenceModel, referenceModel_param); - } else { - ZEPHIR_INIT_VAR(&referenceModel); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "addbelongsto", NULL, 0, this_ptr, fields, &referenceModel, referencedFields, &options); + ZEPHIR_CALL_METHOD(&keyName, this_ptr, "getcolumnmapuniquekey", NULL, 27, model); zephir_check_call_status(); - RETURN_MM(); + if (EXPECTED(Z_TYPE_P(&keyName) != IS_NULL)) { + zephir_read_property(&_0$$4, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_1$$4, &_0$$4, &keyName, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 561); + zephir_array_fetch_long(&_2$$4, &_1$$4, index, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 561); + RETURN_CTOR(&_2$$4); + } + RETURN_MM_NULL(); } -static PHP_METHOD(Phalcon_Mvc_Model, getPreparedQuery) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, readMetaData) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *params, params_sub, *limit = NULL, limit_sub, __$null, builder, bindParams, bindTypes, transaction, cache, manager, query, container, _0, _1, _2$$5, _3$$7; + zval *model, model_sub, key, _0$$3, _1$$3; + zval *this_ptr = getThis(); - ZVAL_UNDEF(¶ms_sub); - ZVAL_UNDEF(&limit_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&builder); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&transaction); - ZVAL_UNDEF(&cache); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&query); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_3$$7); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(params) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(limit) + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, ¶ms, &limit); - if (!limit) { - limit = &limit_sub; - limit = &__$null; - } - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "modelsManager"); - ZEPHIR_CALL_METHOD(&_0, &container, "getshared", NULL, 0, &_1); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&manager, &_0); - ZEPHIR_CALL_METHOD(&_0, &manager, "createbuilder", NULL, 0, params); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&builder, &_0); - ZEPHIR_INIT_NVAR(&_1); - zephir_get_called_class(&_1); - ZEPHIR_CALL_METHOD(NULL, &builder, "from", NULL, 0, &_1); - zephir_check_call_status(); - if (Z_TYPE_P(limit) != IS_NULL) { - ZEPHIR_CALL_METHOD(NULL, &builder, "limit", NULL, 0, limit); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&_0, &builder, "getquery", NULL, 0); + zephir_fetch_params(1, 1, 0, &model); + ZEPHIR_CALL_METHOD(&key, this_ptr, "getmetadatauniquekey", NULL, 28, model); zephir_check_call_status(); - ZEPHIR_CPY_WRT(&query, &_0); - zephir_memory_observe(&bindParams); - if (zephir_array_isset_string_fetch(&bindParams, params, SL("bind"), 0)) { - if (Z_TYPE_P(&bindParams) == IS_ARRAY) { - ZVAL_BOOL(&_2$$5, 1); - ZEPHIR_CALL_METHOD(NULL, &query, "setbindparams", NULL, 0, &bindParams, &_2$$5); - zephir_check_call_status(); - } - zephir_memory_observe(&bindTypes); - if (zephir_array_isset_string_fetch(&bindTypes, params, SL("bindTypes"), 0)) { - if (Z_TYPE_P(&bindTypes) == IS_ARRAY) { - ZVAL_BOOL(&_3$$7, 1); - ZEPHIR_CALL_METHOD(NULL, &query, "setbindtypes", NULL, 0, &bindTypes, &_3$$7); - zephir_check_call_status(); - } - } - } - zephir_memory_observe(&transaction); - if (zephir_array_isset_string_fetch(&transaction, params, SL("transaction"), 0)) { - if (zephir_instance_of_ev(&transaction, phalcon_mvc_model_transactioninterface_ce)) { - ZEPHIR_CALL_METHOD(NULL, &query, "settransaction", NULL, 0, &transaction); - zephir_check_call_status(); - } - } - zephir_memory_observe(&cache); - if (zephir_array_isset_string_fetch(&cache, params, SL("cache"), 0)) { - ZEPHIR_CALL_METHOD(NULL, &query, "cache", NULL, 0, &cache); - zephir_check_call_status(); + if (EXPECTED(Z_TYPE_P(&key) != IS_NULL)) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_1$$3, &_0$$3, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 582); + RETURN_CTOR(&_1$$3); } - RETURN_CCTOR(&query); + RETURN_MM_NULL(); } -static PHP_METHOD(Phalcon_Mvc_Model, hasMany) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, readMetaDataIndex) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval referenceModel; - zval *fields, fields_sub, *referenceModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, _0; + zend_long index, ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, *index_param = NULL, key, _0$$3, _1$$3, _2$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&fields_sub); - ZVAL_UNDEF(&referencedFields_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&referenceModel); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_ZVAL(fields) - Z_PARAM_STR(referenceModel) - Z_PARAM_ZVAL(referencedFields) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_LONG(index) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 1, &fields, &referenceModel_param, &referencedFields, &options_param); - if (UNEXPECTED(Z_TYPE_P(referenceModel_param) != IS_STRING && Z_TYPE_P(referenceModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceModel' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(referenceModel_param) == IS_STRING)) { - zephir_get_strval(&referenceModel, referenceModel_param); - } else { - ZEPHIR_INIT_VAR(&referenceModel); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "addhasmany", NULL, 0, this_ptr, fields, &referenceModel, referencedFields, &options); + zephir_fetch_params(1, 2, 0, &model, &index_param); + ZEPHIR_CALL_METHOD(&key, this_ptr, "getmetadatauniquekey", NULL, 28, model); zephir_check_call_status(); - RETURN_MM(); + if (EXPECTED(Z_TYPE_P(&key) != IS_NULL)) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_1$$3, &_0$$3, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 604); + zephir_array_fetch_long(&_2$$3, &_1$$3, index, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 604); + RETURN_CTOR(&_2$$3); + } + RETURN_MM_NULL(); } -static PHP_METHOD(Phalcon_Mvc_Model, hasManyToMany) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, reset) { + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval intermediateModel, referenceModel; - zval *fields, fields_sub, *intermediateModel_param = NULL, *intermediateFields, intermediateFields_sub, *intermediateReferencedFields, intermediateReferencedFields_sub, *referenceModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&fields_sub); - ZVAL_UNDEF(&intermediateFields_sub); - ZVAL_UNDEF(&intermediateReferencedFields_sub); - ZVAL_UNDEF(&referencedFields_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&intermediateModel); - ZVAL_UNDEF(&referenceModel); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(6, 7) - Z_PARAM_ZVAL(fields) - Z_PARAM_STR(intermediateModel) - Z_PARAM_ZVAL(intermediateFields) - Z_PARAM_ZVAL(intermediateReferencedFields) - Z_PARAM_STR(referenceModel) - Z_PARAM_ZVAL(referencedFields) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 6, 1, &fields, &intermediateModel_param, &intermediateFields, &intermediateReferencedFields, &referenceModel_param, &referencedFields, &options_param); - if (UNEXPECTED(Z_TYPE_P(intermediateModel_param) != IS_STRING && Z_TYPE_P(intermediateModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'intermediateModel' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(intermediateModel_param) == IS_STRING)) { - zephir_get_strval(&intermediateModel, intermediateModel_param); - } else { - ZEPHIR_INIT_VAR(&intermediateModel); - } - if (UNEXPECTED(Z_TYPE_P(referenceModel_param) != IS_STRING && Z_TYPE_P(referenceModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceModel' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(referenceModel_param) == IS_STRING)) { - zephir_get_strval(&referenceModel, referenceModel_param); - } else { - ZEPHIR_INIT_VAR(&referenceModel); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "addhasmanytomany", NULL, 0, this_ptr, fields, &intermediateModel, intermediateFields, intermediateReferencedFields, &referenceModel, referencedFields, &options); - zephir_check_call_status(); - RETURN_MM(); + + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("metaData"), &_0); + ZEPHIR_INIT_VAR(&_1); + array_init(&_1); + zephir_update_property_zval(this_ptr, ZEND_STRL("columnMap"), &_1); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model, hasOne) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setAutomaticCreateAttributes) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval referenceModel; - zval *fields, fields_sub, *referenceModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, _0; + zval attributes; + zval *model, model_sub, *attributes_param = NULL, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&fields_sub); - ZVAL_UNDEF(&referencedFields_sub); + ZVAL_UNDEF(&model_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&referenceModel); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_ZVAL(fields) - Z_PARAM_STR(referenceModel) - Z_PARAM_ZVAL(referencedFields) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZVAL_UNDEF(&attributes); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ARRAY(attributes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 1, &fields, &referenceModel_param, &referencedFields, &options_param); - if (UNEXPECTED(Z_TYPE_P(referenceModel_param) != IS_STRING && Z_TYPE_P(referenceModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceModel' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(referenceModel_param) == IS_STRING)) { - zephir_get_strval(&referenceModel, referenceModel_param); - } else { - ZEPHIR_INIT_VAR(&referenceModel); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "addhasone", NULL, 0, this_ptr, fields, &referenceModel, referencedFields, &options); + zephir_fetch_params(1, 2, 0, &model, &attributes_param); + zephir_get_arrval(&attributes, attributes_param); + ZVAL_LONG(&_0, 10); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "writemetadataindex", NULL, 29, model, &_0, &attributes); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model, hasOneThrough) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setAutomaticUpdateAttributes) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval intermediateModel, referenceModel; - zval *fields, fields_sub, *intermediateModel_param = NULL, *intermediateFields, intermediateFields_sub, *intermediateReferencedFields, intermediateReferencedFields_sub, *referenceModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, _0; + zval attributes; + zval *model, model_sub, *attributes_param = NULL, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&fields_sub); - ZVAL_UNDEF(&intermediateFields_sub); - ZVAL_UNDEF(&intermediateReferencedFields_sub); - ZVAL_UNDEF(&referencedFields_sub); + ZVAL_UNDEF(&model_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&intermediateModel); - ZVAL_UNDEF(&referenceModel); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(6, 7) - Z_PARAM_ZVAL(fields) - Z_PARAM_STR(intermediateModel) - Z_PARAM_ZVAL(intermediateFields) - Z_PARAM_ZVAL(intermediateReferencedFields) - Z_PARAM_STR(referenceModel) - Z_PARAM_ZVAL(referencedFields) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZVAL_UNDEF(&attributes); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ARRAY(attributes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 6, 1, &fields, &intermediateModel_param, &intermediateFields, &intermediateReferencedFields, &referenceModel_param, &referencedFields, &options_param); - if (UNEXPECTED(Z_TYPE_P(intermediateModel_param) != IS_STRING && Z_TYPE_P(intermediateModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'intermediateModel' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(intermediateModel_param) == IS_STRING)) { - zephir_get_strval(&intermediateModel, intermediateModel_param); - } else { - ZEPHIR_INIT_VAR(&intermediateModel); - } - if (UNEXPECTED(Z_TYPE_P(referenceModel_param) != IS_STRING && Z_TYPE_P(referenceModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referenceModel' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(referenceModel_param) == IS_STRING)) { - zephir_get_strval(&referenceModel, referenceModel_param); - } else { - ZEPHIR_INIT_VAR(&referenceModel); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "addhasonethrough", NULL, 0, this_ptr, fields, &intermediateModel, intermediateFields, intermediateReferencedFields, &referenceModel, referencedFields, &options); + zephir_fetch_params(1, 2, 0, &model, &attributes_param); + zephir_get_arrval(&attributes, attributes_param); + ZVAL_LONG(&_0, 11); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "writemetadataindex", NULL, 29, model, &_0, &attributes); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model, keepSnapshots) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setEmptyStringAttributes) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *keepSnapshot_param = NULL, _0, _1; - zend_bool keepSnapshot; + zval attributes; + zval *model, model_sub, *attributes_param = NULL, _0; zval *this_ptr = getThis(); + ZVAL_UNDEF(&model_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(keepSnapshot) + ZVAL_UNDEF(&attributes); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ARRAY(attributes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &keepSnapshot_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - if (keepSnapshot) { - ZVAL_BOOL(&_1, 1); - } else { - ZVAL_BOOL(&_1, 0); - } - ZEPHIR_CALL_METHOD(NULL, &_0, "keepsnapshots", NULL, 0, this_ptr, &_1); + zephir_fetch_params(1, 2, 0, &model, &attributes_param); + zephir_get_arrval(&attributes, attributes_param); + ZVAL_LONG(&_0, 13); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "writemetadataindex", NULL, 29, model, &_0, &attributes); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model, setSchema) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setDI) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *schema_param = NULL, _0; - zval schema; + zval *container, container_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&container_sub); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(schema) + Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &schema_param); - if (UNEXPECTED(Z_TYPE_P(schema_param) != IS_STRING && Z_TYPE_P(schema_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schema' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(schema_param) == IS_STRING)) { - zephir_get_strval(&schema, schema_param); - } else { - ZEPHIR_INIT_VAR(&schema); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "setmodelschema", NULL, 0, this_ptr, &schema); - zephir_check_call_status(); - RETURN_THIS(); + zephir_fetch_params_without_memory_grow(1, 0, &container); + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); } -static PHP_METHOD(Phalcon_Mvc_Model, setSource) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setStrategy) +{ + zval *strategy, strategy_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&strategy_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(strategy, phalcon_mvc_model_metadata_strategy_strategyinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &strategy); + zephir_update_property_zval(this_ptr, ZEND_STRL("strategy"), strategy); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, write) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *source_param = NULL, _0; - zval source; + zval data; + zval *key_param = NULL, *data_param = NULL, result, option, _1, _2, _0$$3; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(source) + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&option); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&data); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(key) + Z_PARAM_ARRAY(data) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &source_param); - if (UNEXPECTED(Z_TYPE_P(source_param) != IS_STRING && Z_TYPE_P(source_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'source' must be of the type string")); + zephir_fetch_params(1, 2, 0, &key_param, &data_param); + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(source_param) == IS_STRING)) { - zephir_get_strval(&source, source_param); + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); } else { - ZEPHIR_INIT_VAR(&source); + ZEPHIR_INIT_VAR(&key); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "setmodelsource", NULL, 0, this_ptr, &source); - zephir_check_call_status(); - RETURN_THIS(); + zephir_get_arrval(&data, data_param); + /* try_start_1: */ + + ZEPHIR_INIT_VAR(&option); + ZVAL_BOOL(&option, ZEPHIR_GLOBAL(orm).exception_on_failed_metadata_save); + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&result, &_0$$3, "set", NULL, 0, &key, &data); + zephir_check_call_status_or_jump(try_end_1); + if (ZEPHIR_IS_FALSE_IDENTICAL(&result)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwwriteexception", NULL, 30, &option); + zephir_check_call_status_or_jump(try_end_1); + } + + try_end_1: + + if (EG(exception)) { + ZEPHIR_INIT_VAR(&_1); + ZVAL_OBJ(&_1, EG(exception)); + Z_ADDREF_P(&_1); + ZEPHIR_INIT_VAR(&_2); + if (zephir_is_instance_of(&_1, SL("Exception"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&_2, &_1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwwriteexception", NULL, 30, &option); + zephir_check_call_status(); + } + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model, skipAttributes) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, writeMetaDataIndex) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *attributes_param = NULL; - zval attributes; + zend_long index, ZEPHIR_LAST_CALL_STATUS; + zval *model, model_sub, *index_param = NULL, *data, data_sub, key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(attributes) + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&data_sub); + ZVAL_UNDEF(&key); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_LONG(index) + Z_PARAM_ZVAL(data) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &attributes_param); - ZEPHIR_OBS_COPY_OR_DUP(&attributes, attributes_param); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "skipattributesoncreate", NULL, 0, &attributes); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "skipattributesonupdate", NULL, 0, &attributes); + zephir_fetch_params(1, 3, 0, &model, &index_param, &data); + ZEPHIR_CALL_METHOD(&key, this_ptr, "getmetadatauniquekey", NULL, 28, model); zephir_check_call_status(); + if (EXPECTED(Z_TYPE_P(&key) != IS_NULL)) { + zephir_update_property_array_multi(this_ptr, SL("metaData"), data, SL("zl"), 2, &key, index); + } ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model, skipAttributesOnCreate) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, initialize) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *attributes_param = NULL, __$null, attribute, *_0, _1, _2; - zval attributes, keysAttributes; + zval *model, model_sub, *key, key_sub, *table, table_sub, *schema, schema_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&keysAttributes); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(attributes) + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&key_sub); + ZVAL_UNDEF(&table_sub); + ZVAL_UNDEF(&schema_sub); + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ZVAL(key) + Z_PARAM_ZVAL(table) + Z_PARAM_ZVAL(schema) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &attributes_param); - ZEPHIR_OBS_COPY_OR_DUP(&attributes, attributes_param); - ZEPHIR_INIT_VAR(&keysAttributes); - array_init(&keysAttributes); - zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model.zep", 5832); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _0) - { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _0); - zephir_array_update_zval(&keysAttributes, &attribute, &__$null, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &attributes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&keysAttributes, &attribute, &__$null, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&attribute); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getmodelsmetadata", NULL, 0); + zephir_fetch_params(1, 4, 0, &model, &key, &table, &schema); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "initializemetadata", NULL, 31, model, key); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_2, "setautomaticcreateattributes", NULL, 0, this_ptr, &keysAttributes); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "initializecolumnmap", NULL, 32, model, key); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model, skipAttributesOnUpdate) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, initializeMetaData) { + zval prefixKey; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *attributes_param = NULL, __$null, attribute, *_0, _1, _2; - zval attributes, keysAttributes; + zval *model, model_sub, *key, key_sub, strategy, metaData, data, modelMetadata, container, _0$$3, _1$$4, _2$$8, _3$$8, _4$$8; zval *this_ptr = getThis(); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&keysAttributes); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(attributes) + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&key_sub); + ZVAL_UNDEF(&strategy); + ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&modelMetadata); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$8); + ZVAL_UNDEF(&_3$$8); + ZVAL_UNDEF(&_4$$8); + ZVAL_UNDEF(&prefixKey); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ZVAL(key) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &attributes_param); - ZEPHIR_OBS_COPY_OR_DUP(&attributes, attributes_param); - ZEPHIR_INIT_VAR(&keysAttributes); - array_init(&keysAttributes); - zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model.zep", 5867); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _0) - { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _0); - zephir_array_update_zval(&keysAttributes, &attribute, &__$null, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &attributes, "valid", NULL, 0); + zephir_fetch_params(1, 2, 0, &model, &key); + ZEPHIR_INIT_VAR(&strategy); + ZVAL_NULL(&strategy); + if (EXPECTED(Z_TYPE_P(key) != IS_NULL)) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&metaData, &_0$$3); + if (0 == zephir_array_isset(&metaData, key)) { + ZEPHIR_INIT_VAR(&_1$$4); + ZEPHIR_CONCAT_SV(&_1$$4, "meta-", key); + zephir_get_strval(&prefixKey, &_1$$4); + ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, &prefixKey); zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; + if (Z_TYPE_P(&data) != IS_NULL) { + zephir_update_property_array(this_ptr, SL("metaData"), key, &data); + } else { + if ((zephir_method_exists_ex(model, ZEND_STRL("metadata")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(&modelMetadata, model, "metadata", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&modelMetadata) != IS_ARRAY)) { + ZEPHIR_INIT_VAR(&_2$$8); + object_init_ex(&_2$$8, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_3$$8); + zephir_get_class(&_3$$8, model, 0); + ZEPHIR_INIT_VAR(&_4$$8); + ZEPHIR_CONCAT_SV(&_4$$8, "Invalid meta-data for model ", &_3$$8); + ZEPHIR_CALL_METHOD(NULL, &_2$$8, "__construct", NULL, 33, &_4$$8); + zephir_check_call_status(); + zephir_throw_exception_debug(&_2$$8, "phalcon/Mvc/Model/MetaData.zep", 785); + ZEPHIR_MM_RESTORE(); + return; + } + } else { + ZEPHIR_CALL_METHOD(&container, this_ptr, "getdi", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&modelMetadata, &strategy, "getmetadata", NULL, 0, model, &container); + zephir_check_call_status(); + } + zephir_update_property_array(this_ptr, SL("metaData"), key, &modelMetadata); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, &prefixKey, &modelMetadata); + zephir_check_call_status(); } - ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&keysAttributes, &attribute, &__$null, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); - zephir_check_call_status(); } + RETURN_MM_BOOL(1); } - ZEPHIR_INIT_NVAR(&attribute); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getmodelsmetadata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_2, "setautomaticupdateattributes", NULL, 0, this_ptr, &keysAttributes); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM_BOOL(0); } -static PHP_METHOD(Phalcon_Mvc_Model, useDynamicUpdate) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, initializeColumnMap) { + zval prefixKey; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *dynamicUpdate_param = NULL, _0, _1; - zend_bool dynamicUpdate; + zval *model, model_sub, *key, key_sub, strategy, data, modelColumnMap, container, _0, _1; zval *this_ptr = getThis(); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&key_sub); + ZVAL_UNDEF(&strategy); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&modelColumnMap); + ZVAL_UNDEF(&container); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(dynamicUpdate) + ZVAL_UNDEF(&prefixKey); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ZVAL(key) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &dynamicUpdate_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsManager"), PH_NOISY_CC | PH_READONLY); - if (dynamicUpdate) { - ZVAL_BOOL(&_1, 1); - } else { - ZVAL_BOOL(&_1, 0); + zephir_fetch_params(1, 2, 0, &model, &key); + if (UNEXPECTED(Z_TYPE_P(key) == IS_NULL)) { + RETURN_MM_BOOL(0); } - ZEPHIR_CALL_METHOD(NULL, &_0, "usedynamicupdate", NULL, 0, this_ptr, &_1); + if (!(ZEPHIR_GLOBAL(orm).column_renaming)) { + RETURN_MM_BOOL(0); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); + if (1 == zephir_array_isset(&_0, key)) { + RETURN_MM_BOOL(1); + } + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_SV(&_1, "map-", key); + zephir_get_strval(&prefixKey, &_1); + ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, &prefixKey); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + if (Z_TYPE_P(&data) != IS_NULL) { + zephir_update_property_array(this_ptr, SL("columnMap"), key, &data); + RETURN_MM_BOOL(1); + } + ZEPHIR_CALL_METHOD(&container, this_ptr, "getdi", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&modelColumnMap, &strategy, "getcolumnmaps", NULL, 0, model, &container); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("columnMap"), key, &modelColumnMap); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, &prefixKey, &modelColumnMap); + zephir_check_call_status(); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_Model, validate) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, throwWriteException) { - zend_object_iterator *_1; + zval message; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_8 = NULL, *_9 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *validator, validator_sub, messages, message, _0, _2$$4, _3$$4, _4$$4, _5$$4, _6$$4, _7$$4; - zval *this_ptr = getThis(); + zval *option, option_sub, _0$$3; - ZVAL_UNDEF(&validator_sub); - ZVAL_UNDEF(&messages); + ZVAL_UNDEF(&option_sub); + ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&message); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(validator, phalcon_filter_validation_validationinterface_ce) + Z_PARAM_ZVAL(option) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &validator); - ZVAL_NULL(&_0); - ZEPHIR_CALL_METHOD(&messages, validator, "validate", NULL, 0, &_0, this_ptr); - zephir_check_call_status(); - if (((Z_TYPE_P(&messages) == IS_TRUE || Z_TYPE_P(&messages) == IS_FALSE) == 1)) { - RETURN_CCTOR(&messages); - } - _1 = zephir_get_iterator(&messages); - _1->funcs->rewind(_1); - for (;_1->funcs->valid(_1) == SUCCESS && !EG(exception); _1->funcs->move_forward(_1)) { - { - ZEPHIR_ITERATOR_COPY(&message, _1); - } - ZEPHIR_INIT_NVAR(&_2$$4); - object_init_ex(&_2$$4, phalcon_messages_message_ce); - ZEPHIR_CALL_METHOD(&_3$$4, &message, "getmessage", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$4, &message, "getfield", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_5$$4, &message, "gettype", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_6$$4, &message, "getcode", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_7$$4, &message, "getmetadata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_2$$4, "__construct", &_8, 6, &_3$$4, &_4$$4, &_5$$4, &_6$$4, &_7$$4); + zephir_fetch_params(1, 1, 0, &option); + ZEPHIR_INIT_VAR(&message); + ZVAL_STRING(&message, "Failed to store metaData to the cache adapter"); + if (zephir_is_true(option)) { + ZEPHIR_INIT_VAR(&_0$$3); + object_init_ex(&_0$$3, phalcon_mvc_model_exception_ce); + ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 33, &message); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_9, 0, &_2$$4); + zephir_throw_exception_debug(&_0$$3, "phalcon/Mvc/Model/MetaData.zep", 882); + ZEPHIR_MM_RESTORE(); + return; + } else { + ZEPHIR_CALL_FUNCTION(NULL, "trigger_error", NULL, 7, &message); zephir_check_call_status(); } - zend_iterator_dtor(_1); - RETURN_MM_BOOL(!(zephir_fast_count_int(&messages))); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model, validationHasFailed) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getArrVal) { - zval _0; - zval *this_ptr = getThis(); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *collection_param = NULL, *index, index_sub, *defaultValue = NULL, defaultValue_sub, __$null, value; + zval collection; - ZVAL_UNDEF(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("errorMessages"), PH_NOISY_CC | PH_READONLY); - RETURN_BOOL(zephir_fast_count_int(&_0) > 0); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&value); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ARRAY(collection) + Z_PARAM_ZVAL(index) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(defaultValue) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 1, &collection_param, &index, &defaultValue); + ZEPHIR_OBS_COPY_OR_DUP(&collection, collection_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } + zephir_memory_observe(&value); + if (UNEXPECTED(!(zephir_array_isset_fetch(&value, &collection, index, 0)))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + RETURN_CCTOR(&value); } -static PHP_METHOD(Phalcon_Mvc_Model, caseInsensitiveColumnMap) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getMetaDataUniqueKey) { + zval key; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *columnMap, columnMap_sub, *key, key_sub, cmKey, _0, *_1, _2, _3$$3, _4$$3, _5$$5, _6$$5; + zval *model, model_sub, _0, _1$$3; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&columnMap_sub); - ZVAL_UNDEF(&key_sub); - ZVAL_UNDEF(&cmKey); + ZVAL_UNDEF(&model_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_6$$5); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(columnMap) - Z_PARAM_ZVAL(key) + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&key); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &columnMap, &key); - ZEPHIR_INIT_VAR(&_0); - zephir_array_keys(&_0, columnMap); - zephir_is_iterable(&_0, 0, "phalcon/Mvc/Model.zep", 6004); - if (Z_TYPE_P(&_0) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) - { - ZEPHIR_INIT_NVAR(&cmKey); - ZVAL_COPY(&cmKey, _1); - ZEPHIR_INIT_NVAR(&_3$$3); - zephir_fast_strtolower(&_3$$3, &cmKey); - ZEPHIR_INIT_NVAR(&_4$$3); - zephir_fast_strtolower(&_4$$3, key); - if (ZEPHIR_IS_EQUAL(&_3$$3, &_4$$3)) { - RETURN_CCTOR(&cmKey); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + zephir_fetch_params(1, 1, 0, &model); + ZEPHIR_INIT_VAR(&key); + zephir_get_class(&key, model, 1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); + if (0 == zephir_array_isset(&_0, &key)) { + ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "initializemetadata", NULL, 31, model, &key); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&cmKey, &_0, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_5$$5); - zephir_fast_strtolower(&_5$$5, &cmKey); - ZEPHIR_INIT_NVAR(&_6$$5); - zephir_fast_strtolower(&_6$$5, key); - if (ZEPHIR_IS_EQUAL(&_5$$5, &_6$$5)) { - RETURN_CCTOR(&cmKey); - } - ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); - zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$3)) { + RETURN_MM_NULL(); } } - ZEPHIR_INIT_NVAR(&cmKey); - RETVAL_ZVAL(key, 1, 0); - RETURN_MM(); + RETURN_CTOR(&key); } -/*** - * Append messages to this model from another Model. - */ -static PHP_METHOD(Phalcon_Mvc_Model, appendMessagesFrom) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getColumnMapUniqueKey) { - zval _2$$5, _4$$7; + zval key; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, messages, message, *_0$$3, _1$$3; + zval *model, model_sub, _0, _1$$3; zval *this_ptr = getThis(); ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&messages); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_4$$7); + ZVAL_UNDEF(&key); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(model) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); zephir_fetch_params(1, 1, 0, &model); - ZEPHIR_CALL_METHOD(&messages, model, "getmessages", NULL, 0); - zephir_check_call_status(); - if (0 == ZEPHIR_IS_EMPTY(&messages)) { - zephir_is_iterable(&messages, 0, "phalcon/Mvc/Model.zep", 6028); - if (Z_TYPE_P(&messages) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&messages), _0$$3) - { - ZEPHIR_INIT_NVAR(&message); - ZVAL_COPY(&message, _0$$3); - if (Z_TYPE_P(&message) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_2$$5); - zephir_create_array(&_2$$5, 1, 0); - zephir_array_update_string(&_2$$5, SL("model"), model, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &message, "setmetadata", NULL, 0, &_2$$5); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_3, 0, &message); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &messages, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1$$3, &messages, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&message, &messages, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&message) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_4$$7); - zephir_create_array(&_4$$7, 1, 0); - zephir_array_update_string(&_4$$7, SL("model"), model, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &message, "setmetadata", NULL, 0, &_4$$7); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_3, 0, &message); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &messages, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&key); + zephir_get_class(&key, model, 1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); + if (0 == zephir_array_isset(&_0, &key)) { + ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "initializecolumnmap", NULL, 32, model, &key); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$3)) { + RETURN_MM_NULL(); } - ZEPHIR_INIT_NVAR(&message); } - ZEPHIR_MM_RESTORE(); + RETURN_CTOR(&key); } -zend_object *zephir_init_properties_Phalcon_Mvc_Model(zend_class_entry *class_type) +zend_object *zephir_init_properties_Phalcon_Mvc_Model_MetaData(zend_class_entry *class_type) { - zval _0, _2, _4, _6, _8, _10, _12, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8, _13$$9; + zval _0, _2, _1$$3, _3$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_12); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_13$$9); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); @@ -45736,47 +46317,17 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Model(zend_class_entry *class_ty { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("uniqueTypes"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("uniqueTypes"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("metaData"), &_1$$3); } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("uniqueParams"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_2) == IS_NULL) { ZEPHIR_INIT_VAR(&_3$$4); array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("uniqueParams"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("snapshot"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("snapshot"), &_5$$5); - } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("oldSnapshot"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("oldSnapshot"), &_7$$6); - } - zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("related"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_8) == IS_NULL) { - ZEPHIR_INIT_VAR(&_9$$7); - array_init(&_9$$7); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("related"), &_9$$7); - } - zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("errorMessages"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_10) == IS_NULL) { - ZEPHIR_INIT_VAR(&_11$$8); - array_init(&_11$$8); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("errorMessages"), &_11$$8); - } - zephir_read_property_ex(&_12, this_ptr, ZEND_STRL("dirtyRelated"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_12) == IS_NULL) { - ZEPHIR_INIT_VAR(&_13$$9); - array_init(&_13$$9); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("dirtyRelated"), &_13$$9); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("columnMap"), &_3$$4); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -45793,52 +46344,43 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Model(zend_class_entry *class_ty -ZEPHIR_INIT_CLASS(Phalcon_Mvc_ModelInterface) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaDataInterface) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ModelInterface, phalcon, mvc_modelinterface, phalcon_mvc_modelinterface_method_entry); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, MetaDataInterface, phalcon, mvc_model_metadatainterface, phalcon_mvc_model_metadatainterface_method_entry); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, appendMessage); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, assign); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, average); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, cloneResult); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, cloneResultMap); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, cloneResultMapHydrate); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, count); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, create); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, delete); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, find); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, findFirst); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, fireEvent); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, fireEventCancel); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getDirtyState); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getMessages); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getModelsMetaData); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getOperationMade); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getReadConnection); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getReadConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getRelated); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getSchema); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getSource); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getWriteConnection); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, getWriteConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, maximum); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, minimum); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, query); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, refresh); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, save); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setDirtyState); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setReadConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setSnapshotData); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setTransaction); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, setWriteConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, skipOperation); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, sum); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, validationHasFailed); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, update); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getAttributes); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getAutomaticCreateAttributes); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getAutomaticUpdateAttributes); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getBindTypes); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getColumnMap); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getDefaultValues); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getDataTypes); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getDataTypesNumeric); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getEmptyStringAttributes); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getIdentityField); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getNonPrimaryKeyAttributes); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getNotNullAttributes); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getPrimaryKeyAttributes); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getReverseColumnMap); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getStrategy); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, hasAttribute); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, isEmpty); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, read); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, readColumnMap); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, readColumnMapIndex); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, readMetaData); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, readMetaDataIndex); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, reset); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, setAutomaticCreateAttributes); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, setAutomaticUpdateAttributes); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, setEmptyStringAttributes); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, writeMetaDataIndex); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, setStrategy); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, write); + @@ -45846,18 +46388,71 @@ ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModelInterface, update); #endif +#if PHP_VERSION_ID < 70000 +#else +#endif +static void phalcon_orm_destroy_cache() { + zend_phalcon_globals *phalcon_globals_ptr = ZEPHIR_VGLOBAL; -ZEPHIR_INIT_CLASS(Phalcon_Mvc_ModuleDefinitionInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ModuleDefinitionInterface, phalcon, mvc_moduledefinitioninterface, phalcon_mvc_moduledefinitioninterface_method_entry); + if (phalcon_globals_ptr->orm.parser_cache != NULL) { + zend_hash_destroy(phalcon_globals_ptr->orm.parser_cache); + FREE_HASHTABLE(phalcon_globals_ptr->orm.parser_cache); + phalcon_globals_ptr->orm.parser_cache = NULL; + } - return SUCCESS; + if (phalcon_globals_ptr->orm.ast_cache != NULL) { + zend_hash_destroy(phalcon_globals_ptr->orm.ast_cache); + FREE_HASHTABLE(phalcon_globals_ptr->orm.ast_cache); + phalcon_globals_ptr->orm.ast_cache = NULL; + } } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModuleDefinitionInterface, registerAutoloaders); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModuleDefinitionInterface, registerServices); +static void phalcon_orm_singlequotes(zval *return_value, zval *str) { + + int i; + smart_str escaped_str = {0}; + char *marker; + + if (Z_TYPE_P(str) != IS_STRING) { + RETURN_ZVAL(str, 1, 0); + } + + marker = Z_STRVAL_P(str); + + for (i = 0; i < Z_STRLEN_P(str); i++) { + if ((*marker) == '\0') { + break; + } + if ((*marker) == '\'') { + if (i > 0) { + if (*(marker - 1) != '\\') { + smart_str_appendc(&escaped_str, '\''); + } + } else { + smart_str_appendc(&escaped_str, '\''); + } + } + smart_str_appendc(&escaped_str, (*marker)); + marker++; + } + + smart_str_0(&escaped_str); + +#if PHP_VERSION_ID < 70000 + if (escaped_str.len) { + RETURN_STRINGL(escaped_str.c, escaped_str.len, 0); + } +#else + if (escaped_str.s) { + RETURN_STR(escaped_str.s); + } +#endif + + smart_str_free(&escaped_str); + RETURN_EMPTY_STRING(); +} @@ -45868,6451 +46463,7811 @@ ZEPHIR_DOC_METHOD(Phalcon_Mvc_ModuleDefinitionInterface, registerServices); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Router, phalcon, mvc_router, phalcon_di_abstractinjectionaware_ce, phalcon_mvc_router_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Query, phalcon, mvc_model_query, phalcon_mvc_model_query_method_entry, 0); - zend_declare_property_string(phalcon_mvc_router_ce, SL("action"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_ce, SL("controller"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_ce, SL("defaultAction"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_ce, SL("defaultController"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_ce, SL("defaultModule"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_ce, SL("defaultNamespace"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_ce, SL("defaultParams"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_ce, SL("keyRouteNames"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_ce, SL("keyRouteIds"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_ce, SL("matchedRoute"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_ce, SL("matches"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_ce, SL("module"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_ce, SL("namespaceName"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_ce, SL("notFoundPaths"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_ce, SL("params"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_router_ce, SL("removeExtraSlashes"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_ce, SL("routes"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_router_ce, SL("wasMatched"), 0, ZEND_ACC_PROTECTED); - phalcon_mvc_router_ce->create_object = zephir_init_properties_Phalcon_Mvc_Router; - zephir_declare_class_constant_long(phalcon_mvc_router_ce, SL("POSITION_FIRST"), 0); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("ast"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("bindParams"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("bindTypes"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("cache"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("cacheOptions"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("container"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("enableImplicitJoins"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("intermediate"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("manager"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("metaData"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("models"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("modelsInstances"), ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_mvc_model_query_ce, SL("nestingLevel"), -1, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("phql"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_mvc_model_query_ce, SL("sharedLock"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("sqlAliases"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("sqlAliasesModels"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("sqlAliasesModelsInstances"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("sqlColumnAliases"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("sqlModelsAliases"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("type"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_mvc_model_query_ce, SL("uniqueRow"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("transaction"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_ce, SL("internalPhqlCache"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC); + phalcon_mvc_model_query_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Query; + zephir_declare_class_constant_long(phalcon_mvc_model_query_ce, SL("TYPE_DELETE"), 303); - zephir_declare_class_constant_long(phalcon_mvc_router_ce, SL("POSITION_LAST"), 1); + zephir_declare_class_constant_long(phalcon_mvc_model_query_ce, SL("TYPE_INSERT"), 306); - zend_class_implements(phalcon_mvc_router_ce, 1, phalcon_mvc_routerinterface_ce); - zend_class_implements(phalcon_mvc_router_ce, 1, phalcon_events_eventsawareinterface_ce); + zephir_declare_class_constant_long(phalcon_mvc_model_query_ce, SL("TYPE_SELECT"), 309); + + zephir_declare_class_constant_long(phalcon_mvc_model_query_ce, SL("TYPE_UPDATE"), 300); + + zend_class_implements(phalcon_mvc_model_query_ce, 1, phalcon_mvc_model_queryinterface_ce); + zend_class_implements(phalcon_mvc_model_query_ce, 1, phalcon_di_injectionawareinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router, __construct) +static PHP_METHOD(Phalcon_Mvc_Model_Query, __construct) { - zval routes, _1$$3, _3$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *defaultRoutes_param = NULL, _0$$3, _2$$3, _4$$3; - zend_bool defaultRoutes; + zval options; + zval *phql_param = NULL, *container = NULL, container_sub, *options_param = NULL, __$true, __$false, __$null, enableImplicitJoins, _0, _1; + zval phql; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&routes); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$3); - ZEND_PARSE_PARAMETERS_START(0, 1) + ZVAL_UNDEF(&phql); + ZVAL_UNDEF(&container_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&enableImplicitJoins); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&options); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 3) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(defaultRoutes) + Z_PARAM_STR_OR_NULL(phql) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(container, phalcon_di_diinterface_ce) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &defaultRoutes_param); - if (!defaultRoutes_param) { - defaultRoutes = 1; + zephir_fetch_params(1, 0, 3, &phql_param, &container, &options_param); + if (!phql_param) { + ZEPHIR_INIT_VAR(&phql); } else { - if (UNEXPECTED(Z_TYPE_P(defaultRoutes_param) != IS_TRUE && Z_TYPE_P(defaultRoutes_param) != IS_FALSE)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'defaultRoutes' must be of the type bool")); - RETURN_MM_NULL(); + zephir_get_strval(&phql, phql_param); } - defaultRoutes = (Z_TYPE_P(defaultRoutes_param) == IS_TRUE); + if (!container) { + container = &container_sub; + container = &__$null; } - ZEPHIR_INIT_VAR(&routes); - array_init(&routes); - if (defaultRoutes) { - ZEPHIR_INIT_VAR(&_0$$3); - object_init_ex(&_0$$3, phalcon_mvc_router_route_ce); - ZEPHIR_INIT_VAR(&_1$$3); - zephir_create_array(&_1$$3, 1, 0); - add_assoc_long_ex(&_1$$3, SL("controller"), 1); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "#^/([\\w0-9\\_\\-]+)[/]{0,1}$#u"); - ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 101, &_2$$3, &_1$$3); - zephir_check_call_status(); - zephir_array_append(&routes, &_0$$3, PH_SEPARATE, "phalcon/Mvc/Router.zep", 170); - ZEPHIR_INIT_NVAR(&_2$$3); - object_init_ex(&_2$$3, phalcon_mvc_router_route_ce); - ZEPHIR_INIT_VAR(&_3$$3); - zephir_create_array(&_3$$3, 3, 0); - add_assoc_long_ex(&_3$$3, SL("controller"), 1); - add_assoc_long_ex(&_3$$3, SL("action"), 2); - add_assoc_long_ex(&_3$$3, SL("params"), 3); - ZEPHIR_INIT_VAR(&_4$$3); - ZVAL_STRING(&_4$$3, "#^/([\\w0-9\\_\\-]+)/([\\w0-9\\.\\_]+)(/.*)*$#u"); - ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 101, &_4$$3, &_3$$3); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("phql"), &phql); + if (Z_TYPE_P(container) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdi", NULL, 0, container); zephir_check_call_status(); - zephir_array_append(&routes, &_2$$3, PH_SEPARATE, "phalcon/Mvc/Router.zep", 179); } - zephir_update_property_zval(this_ptr, ZEND_STRL("routes"), &routes); + zephir_memory_observe(&enableImplicitJoins); + if (zephir_array_isset_string_fetch(&enableImplicitJoins, &options, SL("enable_implicit_joins"), 0)) { + if (ZEPHIR_IS_TRUE(&enableImplicitJoins)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("enableImplicitJoins"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("enableImplicitJoins"), &__$false); + } + } else { + if (ZEPHIR_GLOBAL(orm).enable_implicit_joins) { + zephir_update_property_zval(this_ptr, ZEND_STRL("enableImplicitJoins"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("enableImplicitJoins"), &__$false); + } + } + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &_0); + ZEPHIR_INIT_VAR(&_1); + array_init(&_1); + zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &_1); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Router, add) +static PHP_METHOD(Phalcon_Mvc_Model_Query, cache) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *httpMethods = NULL, httpMethods_sub, *position_param = NULL, __$null, route, _0; - zval pattern; + zval *cacheOptions_param = NULL; + zval cacheOptions; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_UNDEF(&httpMethods_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_ZVAL_OR_NULL(httpMethods) - Z_PARAM_LONG(position) + ZVAL_UNDEF(&cacheOptions); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(cacheOptions) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 3, &pattern_param, &paths, &httpMethods, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!httpMethods) { - httpMethods = &httpMethods_sub; - httpMethods = &__$null; - } - if (!position_param) { - position = 1; - } else { - } - ZEPHIR_INIT_VAR(&route); - object_init_ex(&route, phalcon_mvc_router_route_ce); - ZEPHIR_CALL_METHOD(NULL, &route, "__construct", NULL, 101, &pattern, paths, httpMethods); - zephir_check_call_status(); - ZVAL_LONG(&_0, position); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "attach", NULL, 0, &route, &_0); - zephir_check_call_status(); - RETURN_CCTOR(&route); + zephir_fetch_params(1, 1, 0, &cacheOptions_param); + zephir_get_arrval(&cacheOptions, cacheOptions_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("cacheOptions"), &cacheOptions); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Router, addConnect) +static PHP_METHOD(Phalcon_Mvc_Model_Query, clean) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!position_param) { - position = 1; - } else { - } + ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "CONNECT"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); + array_init(&_0); + zephir_update_static_property_ce(phalcon_mvc_model_query_ce, ZEND_STRL("internalPhqlCache"), &_0); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Router, addDelete) +static PHP_METHOD(Phalcon_Mvc_Model_Query, execute) { + zval _5$$8; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *bindParams_param = NULL, *bindTypes_param = NULL, uniqueRow, cacheOptions, key, cacheService, cache, result, preparedResult, defaultBindParams, mergedParams, defaultBindTypes, mergedTypes, type, lifetime, intermediate, _0, _1$$3, _2$$3, _3$$3, _4$$8, _6$$9, _7$$19, _8$$19; + zval bindParams, bindTypes; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&uniqueRow); + ZVAL_UNDEF(&cacheOptions); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&cacheService); + ZVAL_UNDEF(&cache); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&preparedResult); + ZVAL_UNDEF(&defaultBindParams); + ZVAL_UNDEF(&mergedParams); + ZVAL_UNDEF(&defaultBindTypes); + ZVAL_UNDEF(&mergedTypes); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&lifetime); + ZVAL_UNDEF(&intermediate); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$8); + ZVAL_UNDEF(&_6$$9); + ZVAL_UNDEF(&_7$$19); + ZVAL_UNDEF(&_8$$19); + ZVAL_UNDEF(&_5$$8); + ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 0, 2, &bindParams_param, &bindTypes_param); + if (!bindParams_param) { + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); + } else { + zephir_get_arrval(&bindParams, bindParams_param); } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + if (!bindTypes_param) { + ZEPHIR_INIT_VAR(&bindTypes); + array_init(&bindTypes); } else { - ZEPHIR_INIT_VAR(&pattern); + zephir_get_arrval(&bindTypes, bindTypes_param); } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + zephir_read_property(&_0, this_ptr, ZEND_STRL("uniqueRow"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&uniqueRow, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("cacheOptions"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&cacheOptions, &_0); + if (Z_TYPE_P(&cacheOptions) != IS_NULL) { + if (UNEXPECTED(Z_TYPE_P(&cacheOptions) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid caching options", "phalcon/Mvc/Model/Query.zep", 274); + return; + } + zephir_memory_observe(&key); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&key, &cacheOptions, SL("key"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A cache key must be provided to identify the cached resultset in the cache backend", "phalcon/Mvc/Model/Query.zep", 283); + return; + } + zephir_memory_observe(&lifetime); + if (!(zephir_array_isset_string_fetch(&lifetime, &cacheOptions, SL("lifetime"), 0))) { + ZEPHIR_INIT_NVAR(&lifetime); + ZVAL_LONG(&lifetime, 3600); + } + zephir_memory_observe(&cacheService); + if (!(zephir_array_isset_string_fetch(&cacheService, &cacheOptions, SL("service"), 0))) { + ZEPHIR_INIT_NVAR(&cacheService); + ZVAL_STRING(&cacheService, "modelsCache"); + } + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&cache, &_1$$3, "getshared", NULL, 0, &cacheService); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "Phalcon\\Cache\\CacheInterface"); + ZEPHIR_CALL_FUNCTION(&_3$$3, "is_a", NULL, 87, &cache, &_2$$3); + zephir_check_call_status(); + if (UNEXPECTED(!ZEPHIR_IS_TRUE_IDENTICAL(&_3$$3))) { + ZEPHIR_INIT_VAR(&_4$$8); + object_init_ex(&_4$$8, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_5$$8); + ZEPHIR_CONCAT_SS(&_5$$8, "Cache service must be an object implementing ", "Phalcon\\Cache\\CacheInterface"); + ZEPHIR_CALL_METHOD(NULL, &_4$$8, "__construct", NULL, 33, &_5$$8); + zephir_check_call_status(); + zephir_throw_exception_debug(&_4$$8, "phalcon/Mvc/Model/Query.zep", 303); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&result, &cache, "get", NULL, 0, &key); + zephir_check_call_status(); + if (!(ZEPHIR_IS_EMPTY(&result))) { + if (UNEXPECTED(Z_TYPE_P(&result) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Cache didn't return a valid resultset", "phalcon/Mvc/Model/Query.zep", 312); + return; + } + ZVAL_BOOL(&_6$$9, 0); + ZEPHIR_CALL_METHOD(NULL, &result, "setisfresh", NULL, 0, &_6$$9); + zephir_check_call_status(); + if (zephir_is_true(&uniqueRow)) { + ZEPHIR_CALL_METHOD(&preparedResult, &result, "getfirst", NULL, 0); + zephir_check_call_status(); + } else { + ZEPHIR_CPY_WRT(&preparedResult, &result); + } + RETURN_CCTOR(&preparedResult); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), &cache); } - if (!position_param) { - position = 1; + ZEPHIR_CALL_METHOD(&intermediate, this_ptr, "parse", NULL, 0); + zephir_check_call_status(); + zephir_memory_observe(&defaultBindParams); + zephir_read_property(&defaultBindParams, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(&mergedParams); + zephir_add_function(&mergedParams, &defaultBindParams, &bindParams); + zephir_memory_observe(&defaultBindTypes); + zephir_read_property(&defaultBindTypes, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC); + if (Z_TYPE_P(&defaultBindTypes) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&mergedTypes); + zephir_add_function(&mergedTypes, &defaultBindTypes, &bindTypes); } else { + ZEPHIR_CPY_WRT(&mergedTypes, &bindTypes); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("type"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&type, &_0); + do { + if (ZEPHIR_IS_LONG(&type, 309)) { + ZEPHIR_CALL_METHOD(&result, this_ptr, "executeselect", NULL, 446, &intermediate, &mergedParams, &mergedTypes); + zephir_check_call_status(); + break; } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "DELETE"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Router, addGet) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; - zval *this_ptr = getThis(); + if (ZEPHIR_IS_LONG(&type, 306)) { + ZEPHIR_CALL_METHOD(&result, this_ptr, "executeinsert", NULL, 447, &intermediate, &mergedParams, &mergedTypes); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_LONG(&type, 300)) { + ZEPHIR_CALL_METHOD(&result, this_ptr, "executeupdate", NULL, 448, &intermediate, &mergedParams, &mergedTypes); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_LONG(&type, 303)) { + ZEPHIR_CALL_METHOD(&result, this_ptr, "executedelete", NULL, 449, &intermediate, &mergedParams, &mergedTypes); + zephir_check_call_status(); + break; + } + ZEPHIR_INIT_VAR(&_7$$19); + object_init_ex(&_7$$19, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_8$$19); + ZEPHIR_CONCAT_SV(&_8$$19, "Unknown statement ", &type); + ZEPHIR_CALL_METHOD(NULL, &_7$$19, "__construct", NULL, 33, &_8$$19); + zephir_check_call_status(); + zephir_throw_exception_debug(&_7$$19, "phalcon/Mvc/Model/Query.zep", 395); + ZEPHIR_MM_RESTORE(); + return; + } while(0); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); + if (Z_TYPE_P(&cacheOptions) != IS_NULL) { + if (!ZEPHIR_IS_LONG(&type, 309)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Only PHQL statements that return resultsets can be cached", "phalcon/Mvc/Model/Query.zep", 408); + return; + } + ZEPHIR_CALL_METHOD(NULL, &cache, "set", NULL, 0, &key, &result, &lifetime); + zephir_check_call_status(); } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + if (zephir_is_true(&uniqueRow)) { + ZEPHIR_CALL_METHOD(&preparedResult, &result, "getfirst", NULL, 0); + zephir_check_call_status(); } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + ZEPHIR_CPY_WRT(&preparedResult, &result); } - if (!position_param) { - position = 1; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "GET"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); + RETURN_CCTOR(&preparedResult); } -static PHP_METHOD(Phalcon_Mvc_Router, addHead) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getCache) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!position_param) { - position = 1; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "HEAD"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MEMBER(getThis(), "cache"); } -static PHP_METHOD(Phalcon_Mvc_Router, addOptions) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getCacheOptions) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!position_param) { - position = 1; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "OPTIONS"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MEMBER(getThis(), "cacheOptions"); } -static PHP_METHOD(Phalcon_Mvc_Router, addPatch) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getBindParams) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!position_param) { - position = 1; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "PATCH"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MEMBER(getThis(), "bindParams"); } -static PHP_METHOD(Phalcon_Mvc_Router, addPost) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getBindTypes) +{ + + RETURN_MEMBER(getThis(), "bindTypes"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Query, getDI) +{ + + RETURN_MEMBER(getThis(), "container"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Query, getIntermediate) +{ + + RETURN_MEMBER(getThis(), "intermediate"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Query, getSingleResult) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *bindParams_param = NULL, *bindTypes_param = NULL, _0, _1; + zval bindParams, bindTypes; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) + ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 0, 2, &bindParams_param, &bindTypes_param); + if (!bindParams_param) { + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); + } else { + zephir_get_arrval(&bindParams, bindParams_param); } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + if (!bindTypes_param) { + ZEPHIR_INIT_VAR(&bindTypes); + array_init(&bindTypes); } else { - ZEPHIR_INIT_VAR(&pattern); + zephir_get_arrval(&bindTypes, bindTypes_param); } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + zephir_read_property(&_0, this_ptr, ZEND_STRL("uniqueRow"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_0)) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &bindParams, &bindTypes); + zephir_check_call_status(); + RETURN_MM(); } - if (!position_param) { - position = 1; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "POST"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "execute", NULL, 0, &bindParams, &bindTypes); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(&_1, "getfirst", NULL, 0); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router, addPurge) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getSql) { + zval intermediate, _0, _1$$3, _2$$3, _3$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&intermediate); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!position_param) { - position = 1; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "PURGE"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); + + ZEPHIR_CALL_METHOD(&intermediate, this_ptr, "parse", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("type"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_LONG(&_0, 309)) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); + ZVAL_BOOL(&_3$$3, 1); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "executeselect", NULL, 446, &intermediate, &_1$$3, &_2$$3, &_3$$3); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "This type of statement generates multiple SQL statements", "phalcon/Mvc/Model/Query.zep", 514); + return; } -static PHP_METHOD(Phalcon_Mvc_Router, addPut) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getType) +{ + + RETURN_MEMBER(getThis(), "type"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Query, getUniqueRow) +{ + + RETURN_MEMBER(getThis(), "uniqueRow"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Query, getTransaction) +{ + + RETURN_MEMBER(getThis(), "transaction"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Query, parse) { + zval intermediate, phql, ast, irPhql, uniqueId, type, _0, _1$$5, _2$$7, _3$$13, _4$$13; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&intermediate); + ZVAL_UNDEF(&phql); + ZVAL_UNDEF(&ast); + ZVAL_UNDEF(&irPhql); + ZVAL_UNDEF(&uniqueId); + ZVAL_UNDEF(&type); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1$$5); + ZVAL_UNDEF(&_2$$7); + ZVAL_UNDEF(&_3$$13); + ZVAL_UNDEF(&_4$$13); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("intermediate"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&intermediate, &_0); + if (Z_TYPE_P(&intermediate) == IS_ARRAY) { + RETURN_CCTOR(&intermediate); } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); + zephir_read_property(&_0, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&phql, &_0); + ZEPHIR_CALL_CE_STATIC(&ast, phalcon_mvc_model_query_lang_ce, "parsephql", NULL, 0, &phql); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&irPhql); + ZVAL_NULL(&irPhql); + ZEPHIR_INIT_VAR(&uniqueId); + ZVAL_NULL(&uniqueId); + if (Z_TYPE_P(&ast) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&uniqueId); + if (zephir_array_isset_string_fetch(&uniqueId, &ast, SL("id"), 0)) { + ZEPHIR_OBS_NVAR(&irPhql); + zephir_read_static_property_ce(&_1$$5, phalcon_mvc_model_query_ce, SL("internalPhqlCache"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&irPhql, &_1$$5, &uniqueId, 0)) { + if (Z_TYPE_P(&irPhql) == IS_ARRAY) { + zephir_array_fetch_string(&_2$$7, &ast, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 579); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_2$$7); + RETURN_CCTOR(&irPhql); + } + } + } + zephir_memory_observe(&type); + if (zephir_array_isset_string_fetch(&type, &ast, SL("type"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("ast"), &ast); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &type); + do { + if (ZEPHIR_IS_LONG(&type, 309)) { + ZEPHIR_CALL_METHOD(&irPhql, this_ptr, "_prepareselect", NULL, 450); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_LONG(&type, 306)) { + ZEPHIR_CALL_METHOD(&irPhql, this_ptr, "_prepareinsert", NULL, 451); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_LONG(&type, 300)) { + ZEPHIR_CALL_METHOD(&irPhql, this_ptr, "_prepareupdate", NULL, 452); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_LONG(&type, 303)) { + ZEPHIR_CALL_METHOD(&irPhql, this_ptr, "_preparedelete", NULL, 453); + zephir_check_call_status(); + break; + } + ZEPHIR_INIT_VAR(&_3$$13); + object_init_ex(&_3$$13, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_4$$13); + ZEPHIR_CONCAT_SVSV(&_4$$13, "Unknown statement ", &type, ", when preparing: ", &phql); + ZEPHIR_CALL_METHOD(NULL, &_3$$13, "__construct", NULL, 33, &_4$$13); + zephir_check_call_status(); + zephir_throw_exception_debug(&_3$$13, "phalcon/Mvc/Model/Query.zep", 613); + ZEPHIR_MM_RESTORE(); + return; + } while(0); + + } } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + if (UNEXPECTED(Z_TYPE_P(&irPhql) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted AST", "phalcon/Mvc/Model/Query.zep", 619); + return; } - if (!position_param) { - position = 1; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "PUT"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); + if (Z_TYPE_P(&uniqueId) == IS_LONG) { + zephir_update_static_property_array_multi_ce(phalcon_mvc_model_query_ce, SL("internalPhqlCache"), &irPhql, SL("z"), 1, &uniqueId); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("intermediate"), &irPhql); + RETURN_CCTOR(&irPhql); } -static PHP_METHOD(Phalcon_Mvc_Router, addTrace) +static PHP_METHOD(Phalcon_Mvc_Model_Query, setBindParams) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position, ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *position_param = NULL, __$null, _0, _1; - zval pattern; + zend_bool merge; + zval *bindParams_param = NULL, *merge_param = NULL, currentBindParams, _0$$3; + zval bindParams; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(¤tBindParams); + ZVAL_UNDEF(&_0$$3); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(bindParams) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_LONG(position) + Z_PARAM_BOOL(merge) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &position_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!position_param) { - position = 1; + zephir_fetch_params(1, 1, 1, &bindParams_param, &merge_param); + ZEPHIR_OBS_COPY_OR_DUP(&bindParams, bindParams_param); + if (!merge_param) { + merge = 0; } else { } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "TRACE"); - ZVAL_LONG(&_1, position); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &pattern, paths, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); + if (merge) { + zephir_memory_observe(¤tBindParams); + zephir_read_property(¤tBindParams, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(&_0$$3); + zephir_add_function(&_0$$3, ¤tBindParams, &bindParams); + zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &_0$$3); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &bindParams); + } + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Router, attach) +static PHP_METHOD(Phalcon_Mvc_Model_Query, setBindTypes) { - zval _1$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long position; - zval *route, route_sub, *position_param = NULL, _0$$4, _2$$4; + zend_bool merge; + zval *bindTypes_param = NULL, *merge_param = NULL, currentBindTypes, _0$$4; + zval bindTypes; zval *this_ptr = getThis(); - ZVAL_UNDEF(&route_sub); + ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(¤tBindTypes); ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_1$$4); ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(route, phalcon_mvc_router_routeinterface_ce) + Z_PARAM_ARRAY(bindTypes) Z_PARAM_OPTIONAL - Z_PARAM_LONG(position) + Z_PARAM_BOOL(merge) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &route, &position_param); - if (!position_param) { - position = 1; + zephir_fetch_params(1, 1, 1, &bindTypes_param, &merge_param); + ZEPHIR_OBS_COPY_OR_DUP(&bindTypes, bindTypes_param); + if (!merge_param) { + merge = 0; } else { } - do { - if (position == 1) { - zephir_update_property_array_append(this_ptr, SL("routes"), route); - break; - } - if (position == 0) { + if (UNEXPECTED(merge)) { + zephir_memory_observe(¤tBindTypes); + zephir_read_property(¤tBindTypes, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC); + if (Z_TYPE_P(¤tBindTypes) == IS_ARRAY) { ZEPHIR_INIT_VAR(&_0$$4); - ZEPHIR_INIT_VAR(&_1$$4); - zephir_create_array(&_1$$4, 1, 0); - zephir_array_fast_append(&_1$$4, route); - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - zephir_fast_array_merge(&_0$$4, &_1$$4, &_2$$4); - zephir_update_property_zval(this_ptr, ZEND_STRL("routes"), &_0$$4); - break; + zephir_add_function(&_0$$4, ¤tBindTypes, &bindTypes); + zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &_0$$4); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "Invalid route position", "phalcon/Mvc/Router.zep", 494); - return; - } while(0); - + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); + } RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Router, clear) +static PHP_METHOD(Phalcon_Mvc_Model_Query, setDI) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *container, container_sub, manager, metaData, _0; zval *this_ptr = getThis(); + ZVAL_UNDEF(&container_sub); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&metaData); ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - + zephir_fetch_params(1, 1, 0, &container); ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("routes"), &_0); + ZVAL_STRING(&_0, "modelsManager"); + ZEPHIR_CALL_METHOD(&manager, container, "getshared", NULL, 0, &_0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&manager) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Injected service 'modelsManager' is invalid", "phalcon/Mvc/Model/Query.zep", 683); + return; + } + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "modelsMetadata"); + ZEPHIR_CALL_METHOD(&metaData, container, "getshared", NULL, 0, &_0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&metaData) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Injected service 'modelsMetaData' is invalid", "phalcon/Mvc/Model/Query.zep", 689); + return; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("manager"), &manager); + zephir_update_property_zval(this_ptr, ZEND_STRL("metaData"), &metaData); + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Router, getEventsManager) -{ - - RETURN_MEMBER(getThis(), "eventsManager"); -} - -static PHP_METHOD(Phalcon_Mvc_Router, getActionName) -{ - - RETURN_MEMBER(getThis(), "action"); -} - -static PHP_METHOD(Phalcon_Mvc_Router, getControllerName) -{ - - RETURN_MEMBER(getThis(), "controller"); -} - -static PHP_METHOD(Phalcon_Mvc_Router, getDefaults) +static PHP_METHOD(Phalcon_Mvc_Model_Query, setIntermediate) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *intermediate_param = NULL; + zval intermediate; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&intermediate); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(intermediate) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_create_array(return_value, 5, 0); - zephir_memory_observe(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultNamespace"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("namespace"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultModule"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("module"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultController"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("controller"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultAction"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("action"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultParams"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("params"), &_0, PH_COPY | PH_SEPARATE); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Router, getKeyRouteNames) -{ - - RETURN_MEMBER(getThis(), "keyRouteNames"); -} - -static PHP_METHOD(Phalcon_Mvc_Router, getKeyRouteIds) -{ - - RETURN_MEMBER(getThis(), "keyRouteIds"); + zephir_fetch_params(1, 1, 0, &intermediate_param); + ZEPHIR_OBS_COPY_OR_DUP(&intermediate, intermediate_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("intermediate"), &intermediate); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Router, getMatchedRoute) +static PHP_METHOD(Phalcon_Mvc_Model_Query, setSharedLock) { + zval *sharedLock_param = NULL, __$true, __$false; + zend_bool sharedLock; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "matchedRoute"); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(sharedLock) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(0, 1, &sharedLock_param); + if (!sharedLock_param) { + sharedLock = 0; + } else { + } + if (sharedLock) { + zephir_update_property_zval(this_ptr, ZEND_STRL("sharedLock"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("sharedLock"), &__$false); + } + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_Router, getMatches) +static PHP_METHOD(Phalcon_Mvc_Model_Query, setTransaction) { + zval *transaction, transaction_sub; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "matches"); + ZVAL_UNDEF(&transaction_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(transaction, phalcon_mvc_model_transactioninterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &transaction); + zephir_update_property_zval(this_ptr, ZEND_STRL("transaction"), transaction); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_Router, getModuleName) +static PHP_METHOD(Phalcon_Mvc_Model_Query, setType) { + zval *type_param = NULL, _0; + zend_long type; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "module"); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(type) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &type_param); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, type); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_0); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_Router, getNamespaceName) +static PHP_METHOD(Phalcon_Mvc_Model_Query, setUniqueRow) { + zval *uniqueRow_param = NULL, __$true, __$false; + zend_bool uniqueRow; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "namespaceName"); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(uniqueRow) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &uniqueRow_param); + if (uniqueRow) { + zephir_update_property_zval(this_ptr, ZEND_STRL("uniqueRow"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("uniqueRow"), &__$false); + } + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_Router, getParams) +static PHP_METHOD(Phalcon_Mvc_Model_Query, executeDelete) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL, *_8 = NULL, *_10 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, models, modelName, model, records, connection, record, exception, _0, _3, _11, _1$$4, _2$$5, _5$$7, _7$$8, _9$$6; + zval intermediate, bindParams, bindTypes; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "params"); -} - -static PHP_METHOD(Phalcon_Mvc_Router, getRouteById) -{ - zend_string *_7; - zend_ulong _6; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *id, id_sub, route, routeId, key, _0, _3, *_4, _5, _1$$3, _2$$3; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&id_sub); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&routeId); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&intermediate); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&models); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&records); + ZVAL_UNDEF(&connection); + ZVAL_UNDEF(&record); + ZVAL_UNDEF(&exception); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(id) + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_7$$8); + ZVAL_UNDEF(&_9$$6); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ARRAY(intermediate) + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &id); - zephir_memory_observe(&key); - zephir_read_property(&_0, this_ptr, ZEND_STRL("keyRouteIds"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&key, &_0, id, 0)) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_2$$3, &_1$$3, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Router.zep", 614); - RETURN_CTOR(&_2$$3); + zephir_fetch_params(1, 3, 0, &intermediate_param, &bindParams_param, &bindTypes_param); + zephir_get_arrval(&intermediate, intermediate_param); + zephir_get_arrval(&bindParams, bindParams_param); + zephir_get_arrval(&bindTypes, bindTypes_param); + zephir_memory_observe(&models); + zephir_array_fetch_string(&models, &intermediate, SL("models"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 757); + if (UNEXPECTED(zephir_array_isset_long(&models, 1))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Delete from several models at the same time is still not supported", "phalcon/Mvc/Model/Query.zep", 762); + return; } - zephir_read_property(&_3, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_3, 0, "phalcon/Mvc/Router.zep", 626); - if (Z_TYPE_P(&_3) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_3), _6, _7, _4) - { - ZEPHIR_INIT_NVAR(&key); - if (_7 != NULL) { - ZVAL_STR_COPY(&key, _7); - } else { - ZVAL_LONG(&key, _6); - } - ZEPHIR_INIT_NVAR(&route); - ZVAL_COPY(&route, _4); - ZEPHIR_CALL_METHOD(&routeId, &route, "getrouteid", NULL, 0); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("keyRouteIds"), &routeId, &key); - if (ZEPHIR_IS_EQUAL(&routeId, id)) { - RETURN_CCTOR(&route); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_3, "rewind", NULL, 0); + zephir_memory_observe(&modelName); + zephir_array_fetch_long(&modelName, &models, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 765); + zephir_memory_observe(&model); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&model, &_0, &modelName, 0))) { + zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&model, &_1$$4, "load", NULL, 0, &modelName); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5, &_3, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5)) { - break; + } + ZEPHIR_CALL_METHOD(&records, this_ptr, "getrelatedrecords", NULL, 454, &model, &intermediate, &bindParams, &bindTypes); + zephir_check_call_status(); + if (!(zephir_fast_count_int(&records))) { + object_init_ex(return_value, phalcon_mvc_model_query_status_ce); + ZVAL_BOOL(&_2$$5, 1); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 455, &_2$$5); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_CALL_METHOD(&connection, this_ptr, "getwriteconnection", NULL, 0, &model, &intermediate, &bindParams, &bindTypes); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &connection, "begin", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &records, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &records, "valid", NULL, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&_3))) { + break; + } + + /* try_start_1: */ + + ZEPHIR_CALL_METHOD(&record, &records, "current", &_4, 0); + zephir_check_call_status_or_jump(try_end_1); + ZEPHIR_CALL_METHOD(&_5$$7, &record, "delete", NULL, 0); + zephir_check_call_status_or_jump(try_end_1); + if (!(zephir_is_true(&_5$$7))) { + ZEPHIR_CALL_METHOD(NULL, &connection, "rollback", &_6, 0); + zephir_check_call_status_or_jump(try_end_1); + object_init_ex(return_value, phalcon_mvc_model_query_status_ce); + ZVAL_BOOL(&_7$$8, 0); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 455, &_7$$8, &record); + zephir_check_call_status_or_jump(try_end_1); + RETURN_MM(); } - ZEPHIR_CALL_METHOD(&key, &_3, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&route, &_3, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&routeId, &route, "getrouteid", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &records, "next", &_8, 0); + zephir_check_call_status_or_jump(try_end_1); + + try_end_1: + + if (EG(exception)) { + ZEPHIR_INIT_NVAR(&_9$$6); + ZVAL_OBJ(&_9$$6, EG(exception)); + Z_ADDREF_P(&_9$$6); + if (zephir_is_instance_of(&_9$$6, SL("PDOException"))) { + zend_clear_exception(); + ZEPHIR_CPY_WRT(&exception, &_9$$6); + ZEPHIR_CALL_METHOD(NULL, &connection, "rollback", &_10, 0); zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("keyRouteIds"), &routeId, &key); - if (ZEPHIR_IS_EQUAL(&routeId, id)) { - RETURN_CCTOR(&route); - } - ZEPHIR_CALL_METHOD(NULL, &_3, "next", NULL, 0); - zephir_check_call_status(); + zephir_throw_exception_debug(&exception, "phalcon/Mvc/Model/Query.zep", 824); + ZEPHIR_MM_RESTORE(); + return; + } } } - ZEPHIR_INIT_NVAR(&route); - ZEPHIR_INIT_NVAR(&key); - RETURN_MM_BOOL(0); + ZEPHIR_CALL_METHOD(NULL, &connection, "commit", NULL, 0); + zephir_check_call_status(); + object_init_ex(return_value, phalcon_mvc_model_query_status_ce); + ZVAL_BOOL(&_11, 1); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 455, &_11); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router, getRouteByName) +static PHP_METHOD(Phalcon_Mvc_Model_Query, executeInsert) { - zend_string *_7; - zend_ulong _6; + zend_string *_5; + zend_ulong _4; + zend_bool automaticFields = 0, _18$$8, _31$$17; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_7 = NULL, *_9 = NULL, *_14 = NULL, *_16 = NULL, *_17 = NULL, *_22 = NULL, *_24 = NULL, *_30 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, route, routeName, key, _0, _3, *_4, _5, _1$$3, _2$$3; - zval name; + zval *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, modelName, manager, connection, metaData, attributes, fields, columnMap, dialect, insertValues, number, value, model, values, exprValue, insertValue, wildcard, fieldName, attributeName, insertModel, _0, _1, *_2, _3, _34, _6$$8, _8$$11, _10$$11, _11$$11, _12$$12, _13$$12, _15$$13, _19$$15, _20$$15, _21$$17, _23$$20, _25$$20, _26$$20, _27$$21, _28$$21, _29$$22, _32$$24, _33$$24; + zval intermediate, bindParams, bindTypes; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&routeName); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&intermediate); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&connection); + ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&fields); + ZVAL_UNDEF(&columnMap); + ZVAL_UNDEF(&dialect); + ZVAL_UNDEF(&insertValues); + ZVAL_UNDEF(&number); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&exprValue); + ZVAL_UNDEF(&insertValue); + ZVAL_UNDEF(&wildcard); + ZVAL_UNDEF(&fieldName); + ZVAL_UNDEF(&attributeName); + ZVAL_UNDEF(&insertModel); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + ZVAL_UNDEF(&_34); + ZVAL_UNDEF(&_6$$8); + ZVAL_UNDEF(&_8$$11); + ZVAL_UNDEF(&_10$$11); + ZVAL_UNDEF(&_11$$11); + ZVAL_UNDEF(&_12$$12); + ZVAL_UNDEF(&_13$$12); + ZVAL_UNDEF(&_15$$13); + ZVAL_UNDEF(&_19$$15); + ZVAL_UNDEF(&_20$$15); + ZVAL_UNDEF(&_21$$17); + ZVAL_UNDEF(&_23$$20); + ZVAL_UNDEF(&_25$$20); + ZVAL_UNDEF(&_26$$20); + ZVAL_UNDEF(&_27$$21); + ZVAL_UNDEF(&_28$$21); + ZVAL_UNDEF(&_29$$22); + ZVAL_UNDEF(&_32$$24); + ZVAL_UNDEF(&_33$$24); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ARRAY(intermediate) + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 3, 0, &intermediate_param, &bindParams_param, &bindTypes_param); + zephir_get_arrval(&intermediate, intermediate_param); + zephir_get_arrval(&bindParams, bindParams_param); + zephir_get_arrval(&bindTypes, bindTypes_param); + zephir_memory_observe(&modelName); + zephir_array_fetch_string(&modelName, &intermediate, SL("model"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 852); + zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&manager, &_0); + zephir_memory_observe(&model); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&model, &_0, &modelName, 0))) { + ZEPHIR_CALL_METHOD(&model, &manager, "load", NULL, 0, &modelName); + zephir_check_call_status(); } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); + ZEPHIR_CALL_METHOD(&connection, this_ptr, "getwriteconnection", NULL, 0, &model, &intermediate, &bindParams, &bindTypes); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&metaData, &_1); + ZEPHIR_CALL_METHOD(&attributes, &metaData, "getattributes", NULL, 0, &model); + zephir_check_call_status(); + automaticFields = 0; + zephir_memory_observe(&fields); + if (!(zephir_array_isset_string_fetch(&fields, &intermediate, SL("fields"), 0))) { + automaticFields = 1; + ZEPHIR_CPY_WRT(&fields, &attributes); + if (ZEPHIR_GLOBAL(orm).column_renaming) { + ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", NULL, 0, &model); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&columnMap); + ZVAL_NULL(&columnMap); + } } - zephir_memory_observe(&key); - zephir_read_property(&_0, this_ptr, ZEND_STRL("keyRouteNames"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&key, &_0, &name, 0)) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_2$$3, &_1$$3, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Router.zep", 641); - RETURN_CTOR(&_2$$3); + zephir_memory_observe(&values); + zephir_array_fetch_string(&values, &intermediate, SL("values"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 887); + if (UNEXPECTED(zephir_fast_count_int(&fields) != zephir_fast_count_int(&values))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The column count does not match the values count", "phalcon/Mvc/Model/Query.zep", 896); + return; } - zephir_read_property(&_3, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_3, 0, "phalcon/Mvc/Router.zep", 656); - if (Z_TYPE_P(&_3) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_3), _6, _7, _4) + ZEPHIR_CALL_METHOD(&dialect, &connection, "getdialect", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&insertValues); + array_init(&insertValues); + zephir_is_iterable(&values, 0, "phalcon/Mvc/Model/Query.zep", 967); + if (Z_TYPE_P(&values) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&values), _4, _5, _2) { - ZEPHIR_INIT_NVAR(&key); - if (_7 != NULL) { - ZVAL_STR_COPY(&key, _7); + ZEPHIR_INIT_NVAR(&number); + if (_5 != NULL) { + ZVAL_STR_COPY(&number, _5); } else { - ZVAL_LONG(&key, _6); + ZVAL_LONG(&number, _4); } - ZEPHIR_INIT_NVAR(&route); - ZVAL_COPY(&route, _4); - ZEPHIR_CALL_METHOD(&routeName, &route, "getname", NULL, 0); - zephir_check_call_status(); - if (!(ZEPHIR_IS_EMPTY(&routeName))) { - zephir_update_property_array(this_ptr, SL("keyRouteNames"), &routeName, &key); - if (ZEPHIR_IS_EQUAL(&routeName, &name)) { - RETURN_CCTOR(&route); + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _2); + ZEPHIR_OBS_NVAR(&exprValue); + zephir_array_fetch_string(&exprValue, &value, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 906); + zephir_array_fetch_string(&_6$$8, &value, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 908); + do { + if (ZEPHIR_IS_LONG(&_6$$8, 260) || ZEPHIR_IS_LONG(&_6$$8, 258) || ZEPHIR_IS_LONG(&_6$$8, 259)) { + ZEPHIR_CALL_METHOD(&insertValue, &dialect, "getsqlexpression", &_7, 0, &exprValue); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_LONG(&_6$$8, 322)) { + ZEPHIR_INIT_NVAR(&insertValue); + ZVAL_NULL(&insertValue); + break; + } + if (ZEPHIR_IS_LONG(&_6$$8, 273) || ZEPHIR_IS_LONG(&_6$$8, 274) || ZEPHIR_IS_LONG(&_6$$8, 277)) { + ZEPHIR_CALL_METHOD(&_8$$11, &dialect, "getsqlexpression", &_9, 0, &exprValue); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_10$$11); + ZVAL_STRING(&_10$$11, ":"); + ZEPHIR_INIT_NVAR(&_11$$11); + ZVAL_STRING(&_11$$11, ""); + ZEPHIR_INIT_NVAR(&wildcard); + zephir_fast_str_replace(&wildcard, &_10$$11, &_11$$11, &_8$$11); + ZEPHIR_OBS_NVAR(&insertValue); + if (UNEXPECTED(!(zephir_array_isset_fetch(&insertValue, &bindParams, &wildcard, 0)))) { + ZEPHIR_INIT_NVAR(&_12$$12); + object_init_ex(&_12$$12, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_13$$12); + ZEPHIR_CONCAT_SVS(&_13$$12, "Bound parameter '", &wildcard, "' cannot be replaced because it isn't in the placeholders list"); + ZEPHIR_CALL_METHOD(NULL, &_12$$12, "__construct", &_14, 33, &_13$$12); + zephir_check_call_status(); + zephir_throw_exception_debug(&_12$$12, "phalcon/Mvc/Model/Query.zep", 932); + ZEPHIR_MM_RESTORE(); + return; + } + break; + } + ZEPHIR_INIT_NVAR(&insertValue); + object_init_ex(&insertValue, phalcon_db_rawvalue_ce); + ZEPHIR_CALL_METHOD(&_15$$13, &dialect, "getsqlexpression", &_16, 0, &exprValue); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &insertValue, "__construct", &_17, 36, &_15$$13); + zephir_check_call_status(); + break; + } while(0); + + ZEPHIR_OBS_NVAR(&fieldName); + zephir_array_fetch(&fieldName, &fields, &number, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 945); + _18$$8 = automaticFields; + if (_18$$8) { + _18$$8 = Z_TYPE_P(&columnMap) == IS_ARRAY; + } + if (_18$$8) { + ZEPHIR_OBS_NVAR(&attributeName); + if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeName, &columnMap, &fieldName, 0)))) { + ZEPHIR_INIT_NVAR(&_19$$15); + object_init_ex(&_19$$15, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_20$$15); + ZEPHIR_CONCAT_SVS(&_20$$15, "Column '", &fieldName, "' isn't part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_19$$15, "__construct", &_14, 33, &_20$$15); + zephir_check_call_status(); + zephir_throw_exception_debug(&_19$$15, "phalcon/Mvc/Model/Query.zep", 955); + ZEPHIR_MM_RESTORE(); + return; } + } else { + ZEPHIR_CPY_WRT(&attributeName, &fieldName); } + zephir_array_update_zval(&insertValues, &attributeName, &insertValue, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &_3, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_5, &_3, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_3, &values, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_5)) { + if (!zend_is_true(&_3)) { break; } - ZEPHIR_CALL_METHOD(&key, &_3, "key", NULL, 0); + ZEPHIR_CALL_METHOD(&number, &values, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&route, &_3, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&routeName, &route, "getname", NULL, 0); - zephir_check_call_status(); - if (!(ZEPHIR_IS_EMPTY(&routeName))) { - zephir_update_property_array(this_ptr, SL("keyRouteNames"), &routeName, &key); - if (ZEPHIR_IS_EQUAL(&routeName, &name)) { - RETURN_CCTOR(&route); + ZEPHIR_OBS_NVAR(&exprValue); + zephir_array_fetch_string(&exprValue, &value, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 906); + zephir_array_fetch_string(&_21$$17, &value, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 908); + do { + if (ZEPHIR_IS_LONG(&_21$$17, 260) || ZEPHIR_IS_LONG(&_21$$17, 258) || ZEPHIR_IS_LONG(&_21$$17, 259)) { + ZEPHIR_CALL_METHOD(&insertValue, &dialect, "getsqlexpression", &_22, 0, &exprValue); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_LONG(&_21$$17, 322)) { + ZEPHIR_INIT_NVAR(&insertValue); + ZVAL_NULL(&insertValue); + break; + } + if (ZEPHIR_IS_LONG(&_21$$17, 273) || ZEPHIR_IS_LONG(&_21$$17, 274) || ZEPHIR_IS_LONG(&_21$$17, 277)) { + ZEPHIR_CALL_METHOD(&_23$$20, &dialect, "getsqlexpression", &_24, 0, &exprValue); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_25$$20); + ZVAL_STRING(&_25$$20, ":"); + ZEPHIR_INIT_NVAR(&_26$$20); + ZVAL_STRING(&_26$$20, ""); + ZEPHIR_INIT_NVAR(&wildcard); + zephir_fast_str_replace(&wildcard, &_25$$20, &_26$$20, &_23$$20); + ZEPHIR_OBS_NVAR(&insertValue); + if (UNEXPECTED(!(zephir_array_isset_fetch(&insertValue, &bindParams, &wildcard, 0)))) { + ZEPHIR_INIT_NVAR(&_27$$21); + object_init_ex(&_27$$21, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_28$$21); + ZEPHIR_CONCAT_SVS(&_28$$21, "Bound parameter '", &wildcard, "' cannot be replaced because it isn't in the placeholders list"); + ZEPHIR_CALL_METHOD(NULL, &_27$$21, "__construct", &_14, 33, &_28$$21); + zephir_check_call_status(); + zephir_throw_exception_debug(&_27$$21, "phalcon/Mvc/Model/Query.zep", 932); + ZEPHIR_MM_RESTORE(); + return; + } + break; } + ZEPHIR_INIT_NVAR(&insertValue); + object_init_ex(&insertValue, phalcon_db_rawvalue_ce); + ZEPHIR_CALL_METHOD(&_29$$22, &dialect, "getsqlexpression", &_30, 0, &exprValue); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &insertValue, "__construct", &_17, 36, &_29$$22); + zephir_check_call_status(); + break; + } while(0); + + ZEPHIR_OBS_NVAR(&fieldName); + zephir_array_fetch(&fieldName, &fields, &number, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 945); + _31$$17 = automaticFields; + if (_31$$17) { + _31$$17 = Z_TYPE_P(&columnMap) == IS_ARRAY; } - ZEPHIR_CALL_METHOD(NULL, &_3, "next", NULL, 0); + if (_31$$17) { + ZEPHIR_OBS_NVAR(&attributeName); + if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeName, &columnMap, &fieldName, 0)))) { + ZEPHIR_INIT_NVAR(&_32$$24); + object_init_ex(&_32$$24, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_33$$24); + ZEPHIR_CONCAT_SVS(&_33$$24, "Column '", &fieldName, "' isn't part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_32$$24, "__construct", &_14, 33, &_33$$24); + zephir_check_call_status(); + zephir_throw_exception_debug(&_32$$24, "phalcon/Mvc/Model/Query.zep", 955); + ZEPHIR_MM_RESTORE(); + return; + } + } else { + ZEPHIR_CPY_WRT(&attributeName, &fieldName); + } + zephir_array_update_zval(&insertValues, &attributeName, &insertValue, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&route); - ZEPHIR_INIT_NVAR(&key); - RETURN_MM_BOOL(0); -} - -static PHP_METHOD(Phalcon_Mvc_Router, getRoutes) -{ - - RETURN_MEMBER(getThis(), "routes"); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&number); + ZEPHIR_CALL_METHOD(&insertModel, &manager, "load", NULL, 0, &modelName); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &insertModel, "assign", NULL, 0, &insertValues); + zephir_check_call_status(); + object_init_ex(return_value, phalcon_mvc_model_query_status_ce); + ZEPHIR_CALL_METHOD(&_34, &insertModel, "create", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 455, &_34, &insertModel); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router, handle) +static PHP_METHOD(Phalcon_Mvc_Model_Query, executeSelect) { - zend_string *_25$$30, *_56$$75; - zend_ulong _24$$30, _55$$75; - zval _19$$25, _31$$36, _33$$39, _38$$47, _40$$50, _50$$70, _61$$81, _63$$84, _68$$92, _70$$95; - zend_bool _2, _29$$31, _36$$42, _59$$76, _66$$87; + zend_string *_17, *_63, *_69, *_84$$93; + zend_ulong _16, _62, _68, _83$$93; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_12 = NULL, *_13 = NULL, *_16 = NULL, *_18 = NULL, *_21 = NULL, *_28 = NULL, *_43 = NULL, *_44 = NULL, *_47 = NULL, *_49 = NULL, *_52 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *uri_param = NULL, __$true, __$false, __$null, request, currentHostName, routeFound, parts, params, matches, notFoundPaths, vnamespace, module, controller, action, paramsStr, strParams, route, methods, container, hostname, regexHostName, matched, pattern, handledUri, beforeMatch, paths, converters, part, position, matchPosition, converter, eventsManager, _0, _1, _4, _6, _7, *_8, _9, _72, _73, _74, _75, _76, _3$$3, _5$$6, _10$$9, _11$$9, _14$$14, _15$$20, _17$$24, _20$$28, *_22$$30, _23$$30, _26$$32, _27$$32, _30$$36, _32$$39, _34$$43, _35$$43, _37$$47, _39$$50, _41$$54, _42$$54, _45$$59, _46$$65, _48$$69, _51$$73, *_53$$75, _54$$75, _57$$77, _58$$77, _60$$81, _62$$84, _64$$88, _65$$88, _67$$92, _69$$95, _71$$100, _77$$108, _78$$110, _79$$112; - zval uri; + zephir_fcall_cache_entry *_4 = NULL, *_5 = NULL, *_8 = NULL, *_20 = NULL, *_21 = NULL, *_22 = NULL, *_30 = NULL, *_41 = NULL, *_42 = NULL, *_43 = NULL, *_51 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, numberObjects = 0; + zend_bool simulate, haveObjects = 0, haveScalars = 0, isComplex = 0, isSimpleStd = 0, isKeepingSnapshots = 0, _38$$28, _59$$46, _90$$83; + zval *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, *simulate_param = NULL, __$true, __$null, manager, modelName, models, model, connection, connectionTypes, columns, column, selectColumns, simpleColumnMap, metaData, aliasCopy, sqlColumn, attributes, instance, columnMap, attribute, columnAlias, sqlAlias, dialect, sqlSelect, bindCounts, processed, wildcard, value, processedTypes, typeWildcard, result, resultData, cache, resultObject, columns1, typesColumnMap, wildcardValue, resultsetClassName, _0, *_1, _2, *_10, _11, *_14, _15, *_60, _61, *_66, _67, _73, _3$$3, _6$$5, _7$$7, _9$$9, _12$$11, _13$$16, _18$$28, _19$$29, *_23$$31, _24$$31, _29$$31, _26$$34, _28$$35, _31$$36, *_32$$37, _33$$37, _36$$41, _37$$42, _39$$46, _40$$47, *_44$$49, _45$$49, _50$$49, _47$$52, _49$$53, _52$$54, *_53$$55, _54$$55, _57$$59, _58$$60, _64$$67, _65$$71, _70$$73, _71$$76, _72$$79, _74$$90, *_75$$90, _76$$90, _78$$91, _80$$92, *_81$$93, _82$$93, _86$$94, _88$$95, _89$$85, _98$$83, _91$$98, _92$$98, _93$$97, _94$$97, _95$$99, _96$$99; + zval intermediate, bindParams, bindTypes, _25$$34, _27$$35, _34$$38, _35$$39, _46$$52, _48$$53, _55$$56, _56$$57, _77$$91, _79$$92, _85$$94, _87$$95, _97$$97; zval *this_ptr = getThis(); - ZVAL_UNDEF(&uri); + ZVAL_UNDEF(&intermediate); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&_25$$34); + ZVAL_UNDEF(&_27$$35); + ZVAL_UNDEF(&_34$$38); + ZVAL_UNDEF(&_35$$39); + ZVAL_UNDEF(&_46$$52); + ZVAL_UNDEF(&_48$$53); + ZVAL_UNDEF(&_55$$56); + ZVAL_UNDEF(&_56$$57); + ZVAL_UNDEF(&_77$$91); + ZVAL_UNDEF(&_79$$92); + ZVAL_UNDEF(&_85$$94); + ZVAL_UNDEF(&_87$$95); + ZVAL_UNDEF(&_97$$97); ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&request); - ZVAL_UNDEF(¤tHostName); - ZVAL_UNDEF(&routeFound); - ZVAL_UNDEF(&parts); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&matches); - ZVAL_UNDEF(¬FoundPaths); - ZVAL_UNDEF(&vnamespace); - ZVAL_UNDEF(&module); - ZVAL_UNDEF(&controller); - ZVAL_UNDEF(&action); - ZVAL_UNDEF(¶msStr); - ZVAL_UNDEF(&strParams); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&methods); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&hostname); - ZVAL_UNDEF(®exHostName); - ZVAL_UNDEF(&matched); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&handledUri); - ZVAL_UNDEF(&beforeMatch); - ZVAL_UNDEF(&paths); - ZVAL_UNDEF(&converters); - ZVAL_UNDEF(&part); - ZVAL_UNDEF(&position); - ZVAL_UNDEF(&matchPosition); - ZVAL_UNDEF(&converter); - ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&models); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&connection); + ZVAL_UNDEF(&connectionTypes); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&column); + ZVAL_UNDEF(&selectColumns); + ZVAL_UNDEF(&simpleColumnMap); + ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&aliasCopy); + ZVAL_UNDEF(&sqlColumn); + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&instance); + ZVAL_UNDEF(&columnMap); + ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&columnAlias); + ZVAL_UNDEF(&sqlAlias); + ZVAL_UNDEF(&dialect); + ZVAL_UNDEF(&sqlSelect); + ZVAL_UNDEF(&bindCounts); + ZVAL_UNDEF(&processed); + ZVAL_UNDEF(&wildcard); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&processedTypes); + ZVAL_UNDEF(&typeWildcard); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&resultData); + ZVAL_UNDEF(&cache); + ZVAL_UNDEF(&resultObject); + ZVAL_UNDEF(&columns1); + ZVAL_UNDEF(&typesColumnMap); + ZVAL_UNDEF(&wildcardValue); + ZVAL_UNDEF(&resultsetClassName); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_72); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_15); + ZVAL_UNDEF(&_61); + ZVAL_UNDEF(&_67); ZVAL_UNDEF(&_73); - ZVAL_UNDEF(&_74); - ZVAL_UNDEF(&_75); - ZVAL_UNDEF(&_76); ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_10$$9); - ZVAL_UNDEF(&_11$$9); - ZVAL_UNDEF(&_14$$14); - ZVAL_UNDEF(&_15$$20); - ZVAL_UNDEF(&_17$$24); - ZVAL_UNDEF(&_20$$28); - ZVAL_UNDEF(&_23$$30); - ZVAL_UNDEF(&_26$$32); - ZVAL_UNDEF(&_27$$32); - ZVAL_UNDEF(&_30$$36); - ZVAL_UNDEF(&_32$$39); - ZVAL_UNDEF(&_34$$43); - ZVAL_UNDEF(&_35$$43); - ZVAL_UNDEF(&_37$$47); - ZVAL_UNDEF(&_39$$50); - ZVAL_UNDEF(&_41$$54); - ZVAL_UNDEF(&_42$$54); - ZVAL_UNDEF(&_45$$59); - ZVAL_UNDEF(&_46$$65); - ZVAL_UNDEF(&_48$$69); - ZVAL_UNDEF(&_51$$73); - ZVAL_UNDEF(&_54$$75); - ZVAL_UNDEF(&_57$$77); - ZVAL_UNDEF(&_58$$77); - ZVAL_UNDEF(&_60$$81); - ZVAL_UNDEF(&_62$$84); - ZVAL_UNDEF(&_64$$88); - ZVAL_UNDEF(&_65$$88); - ZVAL_UNDEF(&_67$$92); - ZVAL_UNDEF(&_69$$95); - ZVAL_UNDEF(&_71$$100); - ZVAL_UNDEF(&_77$$108); - ZVAL_UNDEF(&_78$$110); - ZVAL_UNDEF(&_79$$112); - ZVAL_UNDEF(&_19$$25); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_7$$7); + ZVAL_UNDEF(&_9$$9); + ZVAL_UNDEF(&_12$$11); + ZVAL_UNDEF(&_13$$16); + ZVAL_UNDEF(&_18$$28); + ZVAL_UNDEF(&_19$$29); + ZVAL_UNDEF(&_24$$31); + ZVAL_UNDEF(&_29$$31); + ZVAL_UNDEF(&_26$$34); + ZVAL_UNDEF(&_28$$35); ZVAL_UNDEF(&_31$$36); - ZVAL_UNDEF(&_33$$39); - ZVAL_UNDEF(&_38$$47); - ZVAL_UNDEF(&_40$$50); - ZVAL_UNDEF(&_50$$70); - ZVAL_UNDEF(&_61$$81); - ZVAL_UNDEF(&_63$$84); - ZVAL_UNDEF(&_68$$92); - ZVAL_UNDEF(&_70$$95); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(uri) + ZVAL_UNDEF(&_33$$37); + ZVAL_UNDEF(&_36$$41); + ZVAL_UNDEF(&_37$$42); + ZVAL_UNDEF(&_39$$46); + ZVAL_UNDEF(&_40$$47); + ZVAL_UNDEF(&_45$$49); + ZVAL_UNDEF(&_50$$49); + ZVAL_UNDEF(&_47$$52); + ZVAL_UNDEF(&_49$$53); + ZVAL_UNDEF(&_52$$54); + ZVAL_UNDEF(&_54$$55); + ZVAL_UNDEF(&_57$$59); + ZVAL_UNDEF(&_58$$60); + ZVAL_UNDEF(&_64$$67); + ZVAL_UNDEF(&_65$$71); + ZVAL_UNDEF(&_70$$73); + ZVAL_UNDEF(&_71$$76); + ZVAL_UNDEF(&_72$$79); + ZVAL_UNDEF(&_74$$90); + ZVAL_UNDEF(&_76$$90); + ZVAL_UNDEF(&_78$$91); + ZVAL_UNDEF(&_80$$92); + ZVAL_UNDEF(&_82$$93); + ZVAL_UNDEF(&_86$$94); + ZVAL_UNDEF(&_88$$95); + ZVAL_UNDEF(&_89$$85); + ZVAL_UNDEF(&_98$$83); + ZVAL_UNDEF(&_91$$98); + ZVAL_UNDEF(&_92$$98); + ZVAL_UNDEF(&_93$$97); + ZVAL_UNDEF(&_94$$97); + ZVAL_UNDEF(&_95$$99); + ZVAL_UNDEF(&_96$$99); + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_ARRAY(intermediate) + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(simulate) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &uri_param); - if (UNEXPECTED(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 of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(uri_param) == IS_STRING)) { - zephir_get_strval(&uri, uri_param); - } else { - ZEPHIR_INIT_VAR(&uri); - } - ZVAL_LONG(&_0, 5); - ZEPHIR_CALL_FUNCTION(&_1, "parse_url", NULL, 102, &uri, &_0); - zephir_check_call_status(); - zephir_get_strval(&uri, &_1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("removeExtraSlashes"), PH_NOISY_CC | PH_READONLY); - _2 = zephir_is_true(&_0); - if (_2) { - _2 = !ZEPHIR_IS_STRING_IDENTICAL(&uri, "/"); - } - if (_2) { - ZEPHIR_INIT_VAR(&_3$$3); - ZVAL_STRING(&_3$$3, "/"); - ZEPHIR_INIT_VAR(&handledUri); - zephir_fast_trim(&handledUri, &uri, &_3$$3, ZEPHIR_TRIM_RIGHT); - } else { - ZEPHIR_CPY_WRT(&handledUri, &uri); - } - if (ZEPHIR_IS_EMPTY(&handledUri)) { - ZEPHIR_INIT_NVAR(&handledUri); - ZVAL_STRING(&handledUri, "/"); - } - ZEPHIR_INIT_VAR(¤tHostName); - ZVAL_NULL(¤tHostName); - ZEPHIR_INIT_VAR(&routeFound); - ZVAL_BOOL(&routeFound, 0); - ZEPHIR_INIT_VAR(&parts); - array_init(&parts); - ZEPHIR_INIT_VAR(¶ms); - array_init(¶ms); - ZEPHIR_INIT_VAR(&matches); - ZVAL_NULL(&matches); - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$true); + zephir_fetch_params(1, 3, 1, &intermediate_param, &bindParams_param, &bindTypes_param, &simulate_param); + zephir_get_arrval(&intermediate, intermediate_param); + zephir_get_arrval(&bindParams, bindParams_param); + zephir_get_arrval(&bindTypes, bindTypes_param); + if (!simulate_param) { + simulate = 0; } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$false); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("matchedRoute"), &__$null); - zephir_read_property(&_4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_4); - if (Z_TYPE_P(&eventsManager) != IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$6); - ZVAL_STRING(&_5$$6, "router:beforeCheckRoutes"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_5$$6, this_ptr); - zephir_check_call_status(); - } - zephir_read_property(&_4, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_4); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'request' service", "phalcon/Mvc/Router.zep", 724); - return; - } - ZEPHIR_INIT_VAR(&_7); - ZVAL_STRING(&_7, "request"); - ZEPHIR_CALL_METHOD(&_6, &container, "get", NULL, 0, &_7); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&request, &_6); - zephir_read_property(&_4, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_4, 0, "phalcon/Mvc/Router.zep", 930); - if (Z_TYPE_P(&_4) == IS_ARRAY) { - ZEND_HASH_REVERSE_FOREACH_VAL(Z_ARRVAL_P(&_4), _8) + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&manager, &_0); + ZEPHIR_INIT_VAR(&connectionTypes); + array_init(&connectionTypes); + zephir_memory_observe(&models); + zephir_array_fetch_string(&models, &intermediate, SL("models"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1004); + zephir_is_iterable(&models, 0, "phalcon/Mvc/Model/Query.zep", 1032); + if (Z_TYPE_P(&models) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&models), _1) { - ZEPHIR_INIT_NVAR(&route); - ZVAL_COPY(&route, _8); - ZEPHIR_INIT_NVAR(¶ms); - array_init(¶ms); - ZEPHIR_INIT_NVAR(&matches); - ZVAL_NULL(&matches); - ZEPHIR_CALL_METHOD(&methods, &route, "gethttpmethods", NULL, 0); + ZEPHIR_INIT_NVAR(&modelName); + ZVAL_COPY(&modelName, _1); + ZEPHIR_OBS_NVAR(&model); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&model, &_3$$3, &modelName, 0))) { + ZEPHIR_CALL_METHOD(&model, &manager, "load", &_4, 0, &modelName); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("modelsInstances"), &modelName, &model); + } + ZEPHIR_CALL_METHOD(&connection, this_ptr, "getreadconnection", &_5, 0, &model, &intermediate, &bindParams, &bindTypes); zephir_check_call_status(); - if (Z_TYPE_P(&methods) != IS_NULL) { - ZVAL_BOOL(&_11$$9, 1); - ZEPHIR_CALL_METHOD(&_10$$9, &request, "ismethod", &_12, 0, &methods, &_11$$9); + if (Z_TYPE_P(&connection) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(&_6$$5, &connection, "gettype", NULL, 0); zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_10$$9)) { - continue; + zephir_array_update_zval(&connectionTypes, &_6$$5, &__$true, PH_COPY | PH_SEPARATE); + if (UNEXPECTED(zephir_fast_count_int(&connectionTypes) == 2)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Cannot use models of different database systems in the same query", "phalcon/Mvc/Model/Query.zep", 1027); + return; } } - ZEPHIR_CALL_METHOD(&hostname, &route, "gethostname", NULL, 0); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &models, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &models, "valid", NULL, 0); zephir_check_call_status(); - if (Z_TYPE_P(&hostname) != IS_NULL) { - if (Z_TYPE_P(¤tHostName) == IS_NULL) { - ZEPHIR_CALL_METHOD(¤tHostName, &request, "gethttphost", &_13, 0); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&modelName, &models, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&model); + zephir_read_property(&_7$$7, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&model, &_7$$7, &modelName, 0))) { + ZEPHIR_CALL_METHOD(&model, &manager, "load", &_8, 0, &modelName); zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("modelsInstances"), &modelName, &model); } - if (!(zephir_is_true(¤tHostName))) { - continue; - } - if (zephir_memnstr_str(&hostname, SL("("), "phalcon/Mvc/Router.zep", 772)) { - if (!(zephir_memnstr_str(&hostname, SL("#"), "phalcon/Mvc/Router.zep", 773))) { - ZEPHIR_INIT_NVAR(®exHostName); - ZEPHIR_CONCAT_SV(®exHostName, "#^", &hostname); - if (!(zephir_memnstr_str(&hostname, SL(":"), "phalcon/Mvc/Router.zep", 776))) { - zephir_concat_self_str(®exHostName, SL("(:[[:digit:]]+)?")); - } - zephir_concat_self_str(®exHostName, SL("$#i")); - } else { - ZEPHIR_CPY_WRT(®exHostName, &hostname); + ZEPHIR_CALL_METHOD(&connection, this_ptr, "getreadconnection", &_5, 0, &model, &intermediate, &bindParams, &bindTypes); + zephir_check_call_status(); + if (Z_TYPE_P(&connection) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(&_9$$9, &connection, "gettype", NULL, 0); + zephir_check_call_status(); + zephir_array_update_zval(&connectionTypes, &_9$$9, &__$true, PH_COPY | PH_SEPARATE); + if (UNEXPECTED(zephir_fast_count_int(&connectionTypes) == 2)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Cannot use models of different database systems in the same query", "phalcon/Mvc/Model/Query.zep", 1027); + return; } - ZEPHIR_INIT_NVAR(&_14$$14); - ZEPHIR_INIT_NVAR(&matched); - zephir_preg_match(&matched, ®exHostName, ¤tHostName, &_14$$14, 0, 0 , 0 ); - } else { - ZEPHIR_INIT_NVAR(&matched); - ZVAL_BOOL(&matched, ZEPHIR_IS_EQUAL(¤tHostName, &hostname)); - } - if (!(zephir_is_true(&matched))) { - continue; } + ZEPHIR_CALL_METHOD(NULL, &models, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&modelName); + zephir_memory_observe(&columns); + zephir_array_fetch_string(&columns, &intermediate, SL("columns"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1032); + haveObjects = 0; + haveScalars = 0; + isComplex = 0; + numberObjects = 0; + ZEPHIR_CPY_WRT(&columns1, &columns); + zephir_is_iterable(&columns, 0, "phalcon/Mvc/Model/Query.zep", 1060); + if (Z_TYPE_P(&columns) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&columns), _10) + { + ZEPHIR_INIT_NVAR(&column); + ZVAL_COPY(&column, _10); + if (UNEXPECTED(Z_TYPE_P(&column) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid column definition", "phalcon/Mvc/Model/Query.zep", 1044); + return; } - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_15$$20); - ZVAL_STRING(&_15$$20, "router:beforeCheckRoute"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_16, 0, &_15$$20, this_ptr, &route); - zephir_check_call_status(); + zephir_array_fetch_string(&_12$$11, &column, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1047); + if (ZEPHIR_IS_STRING(&_12$$11, "scalar")) { + if (!(zephir_array_isset_string(&column, SL("balias")))) { + isComplex = 1; + } + haveScalars = 1; + } else { + haveObjects = 1; + numberObjects++; } - ZEPHIR_CALL_METHOD(&pattern, &route, "getcompiledpattern", NULL, 0); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_11, &columns, "valid", NULL, 0); zephir_check_call_status(); - if (zephir_memnstr_str(&pattern, SL("^"), "phalcon/Mvc/Router.zep", 804)) { - ZEPHIR_INIT_NVAR(&routeFound); - zephir_preg_match(&routeFound, &pattern, &handledUri, &matches, 0, 0 , 0 ); - } else { - ZEPHIR_INIT_NVAR(&routeFound); - ZVAL_BOOL(&routeFound, ZEPHIR_IS_EQUAL(&pattern, &handledUri)); + if (!zend_is_true(&_11)) { + break; } - if (zephir_is_true(&routeFound)) { - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_17$$24); - ZVAL_STRING(&_17$$24, "router:matchedRoute"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_18, 0, &_17$$24, this_ptr, &route); - zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&column, &columns, "current", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&column) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid column definition", "phalcon/Mvc/Model/Query.zep", 1044); + return; } - ZEPHIR_CALL_METHOD(&beforeMatch, &route, "getbeforematch", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&beforeMatch) != IS_NULL) { - if (UNEXPECTED(!(zephir_is_callable(&beforeMatch)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "Before-Match callback is not callable in matched route", "phalcon/Mvc/Router.zep", 826); - return; + zephir_array_fetch_string(&_13$$16, &column, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1047); + if (ZEPHIR_IS_STRING(&_13$$16, "scalar")) { + if (!(zephir_array_isset_string(&column, SL("balias")))) { + isComplex = 1; } - ZEPHIR_INIT_NVAR(&_19$$25); - zephir_create_array(&_19$$25, 3, 0); - zephir_array_fast_append(&_19$$25, &handledUri); - zephir_array_fast_append(&_19$$25, &route); - zephir_array_fast_append(&_19$$25, this_ptr); - ZEPHIR_INIT_NVAR(&routeFound); - ZEPHIR_CALL_USER_FUNC_ARRAY(&routeFound, &beforeMatch, &_19$$25); - zephir_check_call_status(); + haveScalars = 1; + } else { + haveObjects = 1; + numberObjects++; } + ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&column); + if (!(isComplex)) { + if (haveObjects) { + if (haveScalars) { + isComplex = 1; } else { - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_20$$28); - ZVAL_STRING(&_20$$28, "router:notMatchedRoute"); - ZEPHIR_CALL_METHOD(&routeFound, &eventsManager, "fire", &_21, 0, &_20$$28, this_ptr, &route); - zephir_check_call_status(); + if (numberObjects == 1) { + isSimpleStd = 0; + } else { + isComplex = 1; } } - if (zephir_is_true(&routeFound)) { - ZEPHIR_CALL_METHOD(&paths, &route, "getpaths", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&parts, &paths); - if (Z_TYPE_P(&matches) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(&converters, &route, "getconverters", NULL, 0); + } else { + isSimpleStd = 1; + } + } + ZEPHIR_INIT_VAR(&instance); + ZVAL_NULL(&instance); + ZEPHIR_INIT_VAR(&selectColumns); + array_init(&selectColumns); + ZEPHIR_INIT_VAR(&simpleColumnMap); + array_init(&simpleColumnMap); + zephir_read_property(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&metaData, &_0); + zephir_is_iterable(&columns, 0, "phalcon/Mvc/Model/Query.zep", 1166); + if (Z_TYPE_P(&columns) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&columns), _16, _17, _14) + { + ZEPHIR_INIT_NVAR(&aliasCopy); + if (_17 != NULL) { + ZVAL_STR_COPY(&aliasCopy, _17); + } else { + ZVAL_LONG(&aliasCopy, _16); + } + ZEPHIR_INIT_NVAR(&column); + ZVAL_COPY(&column, _14); + ZEPHIR_OBS_NVAR(&sqlColumn); + zephir_array_fetch_string(&sqlColumn, &column, SL("column"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1083); + zephir_array_fetch_string(&_18$$28, &column, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1086); + if (ZEPHIR_IS_STRING(&_18$$28, "object")) { + ZEPHIR_OBS_NVAR(&modelName); + zephir_array_fetch_string(&modelName, &column, SL("model"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1087); + ZEPHIR_OBS_NVAR(&instance); + zephir_read_property(&_19$$29, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&instance, &_19$$29, &modelName, 0))) { + ZEPHIR_CALL_METHOD(&instance, &manager, "load", &_20, 0, &modelName); zephir_check_call_status(); - zephir_is_iterable(&paths, 0, "phalcon/Mvc/Router.zep", 918); - if (Z_TYPE_P(&paths) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&paths), _24$$30, _25$$30, _22$$30) + zephir_update_property_array(this_ptr, SL("modelsInstances"), &modelName, &instance); + } + ZEPHIR_CALL_METHOD(&attributes, &metaData, "getattributes", &_21, 0, &instance); + zephir_check_call_status(); + if (isComplex) { + if (ZEPHIR_GLOBAL(orm).column_renaming) { + ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", &_22, 0, &instance); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&columnMap); + ZVAL_NULL(&columnMap); + } + zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model/Query.zep", 1123); + if (Z_TYPE_P(&attributes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _23$$31) { - ZEPHIR_INIT_NVAR(&part); - if (_25$$30 != NULL) { - ZVAL_STR_COPY(&part, _25$$30); - } else { - ZVAL_LONG(&part, _24$$30); - } - ZEPHIR_INIT_NVAR(&position); - ZVAL_COPY(&position, _22$$30); - if (UNEXPECTED(Z_TYPE_P(&part) != IS_STRING)) { - ZEPHIR_INIT_NVAR(&_26$$32); - object_init_ex(&_26$$32, phalcon_mvc_router_exception_ce); - ZEPHIR_INIT_NVAR(&_27$$32); - ZEPHIR_CONCAT_SV(&_27$$32, "Wrong key in paths: ", &part); - ZEPHIR_CALL_METHOD(NULL, &_26$$32, "__construct", &_28, 33, &_27$$32); - zephir_check_call_status(); - zephir_throw_exception_debug(&_26$$32, "phalcon/Mvc/Router.zep", 866); - ZEPHIR_MM_RESTORE(); - return; - } - _29$$31 = Z_TYPE_P(&position) != IS_STRING; - if (_29$$31) { - _29$$31 = Z_TYPE_P(&position) != IS_LONG; - } - if (_29$$31) { - continue; - } - ZEPHIR_OBS_NVAR(&matchPosition); - if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { - if (Z_TYPE_P(&converters) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_30$$36); - ZEPHIR_INIT_NVAR(&_31$$36); - zephir_create_array(&_31$$36, 1, 0); - zephir_array_fast_append(&_31$$36, &matchPosition); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_30$$36, &converter, &_31$$36); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_30$$36, PH_COPY | PH_SEPARATE); - continue; - } - } - zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); - } else { - if (Z_TYPE_P(&converters) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_32$$39); - ZEPHIR_INIT_NVAR(&_33$$39); - zephir_create_array(&_33$$39, 1, 0); - zephir_array_fast_append(&_33$$39, &position); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_32$$39, &converter, &_33$$39); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_32$$39, PH_COPY | PH_SEPARATE); - } - } else { - if (Z_TYPE_P(&position) == IS_LONG) { - zephir_array_unset(&parts, &part, PH_SEPARATE); - } - } + ZEPHIR_INIT_NVAR(&attribute); + ZVAL_COPY(&attribute, _23$$31); + ZEPHIR_INIT_NVAR(&_25$$34); + zephir_create_array(&_25$$34, 3, 0); + zephir_array_fast_append(&_25$$34, &attribute); + zephir_array_fast_append(&_25$$34, &sqlColumn); + ZEPHIR_INIT_NVAR(&_26$$34); + ZEPHIR_CONCAT_SVSV(&_26$$34, "_", &sqlColumn, "_", &attribute); + zephir_array_fast_append(&_25$$34, &_26$$34); + zephir_array_append(&selectColumns, &_25$$34, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1116); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_24$$31, &attributes, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_24$$31)) { + break; } + ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_27$$35); + zephir_create_array(&_27$$35, 3, 0); + zephir_array_fast_append(&_27$$35, &attribute); + zephir_array_fast_append(&_27$$35, &sqlColumn); + ZEPHIR_INIT_NVAR(&_28$$35); + ZEPHIR_CONCAT_SVSV(&_28$$35, "_", &sqlColumn, "_", &attribute); + zephir_array_fast_append(&_27$$35, &_28$$35); + zephir_array_append(&selectColumns, &_27$$35, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1116); + ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&attribute); + zephir_array_update_multi(&columns1, &instance, SL("zs"), 3, &aliasCopy, SL("instance")); + zephir_array_update_multi(&columns1, &attributes, SL("zs"), 3, &aliasCopy, SL("attributes")); + zephir_array_update_multi(&columns1, &columnMap, SL("zs"), 3, &aliasCopy, SL("columnMap")); + ZEPHIR_CALL_METHOD(&_29$$31, &manager, "iskeepingsnapshots", &_30, 0, &instance); + zephir_check_call_status(); + isKeepingSnapshots = zephir_get_boolval(&_29$$31); + if (isKeepingSnapshots) { + ZEPHIR_INIT_NVAR(&_31$$36); + ZVAL_BOOL(&_31$$36, isKeepingSnapshots); + zephir_array_update_multi(&columns1, &_31$$36, SL("zs"), 3, &aliasCopy, SL("keepSnapshots")); + } + } else { + zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model/Query.zep", 1140); + if (Z_TYPE_P(&attributes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _32$$37) + { + ZEPHIR_INIT_NVAR(&attribute); + ZVAL_COPY(&attribute, _32$$37); + ZEPHIR_INIT_NVAR(&_34$$38); + zephir_create_array(&_34$$38, 2, 0); + zephir_array_fast_append(&_34$$38, &attribute); + zephir_array_fast_append(&_34$$38, &sqlColumn); + zephir_array_append(&selectColumns, &_34$$38, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1138); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &paths, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_23$$30, &paths, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_33$$37, &attributes, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_23$$30)) { + if (!zend_is_true(&_33$$37)) { break; } - ZEPHIR_CALL_METHOD(&part, &paths, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&position, &paths, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&part) != IS_STRING)) { - ZEPHIR_INIT_NVAR(&_34$$43); - object_init_ex(&_34$$43, phalcon_mvc_router_exception_ce); - ZEPHIR_INIT_NVAR(&_35$$43); - ZEPHIR_CONCAT_SV(&_35$$43, "Wrong key in paths: ", &part); - ZEPHIR_CALL_METHOD(NULL, &_34$$43, "__construct", &_28, 33, &_35$$43); - zephir_check_call_status(); - zephir_throw_exception_debug(&_34$$43, "phalcon/Mvc/Router.zep", 866); - ZEPHIR_MM_RESTORE(); - return; - } - _36$$42 = Z_TYPE_P(&position) != IS_STRING; - if (_36$$42) { - _36$$42 = Z_TYPE_P(&position) != IS_LONG; - } - if (_36$$42) { - continue; - } - ZEPHIR_OBS_NVAR(&matchPosition); - if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { - if (Z_TYPE_P(&converters) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_37$$47); - ZEPHIR_INIT_NVAR(&_38$$47); - zephir_create_array(&_38$$47, 1, 0); - zephir_array_fast_append(&_38$$47, &matchPosition); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_37$$47, &converter, &_38$$47); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_37$$47, PH_COPY | PH_SEPARATE); - continue; - } - } - zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); - } else { - if (Z_TYPE_P(&converters) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_39$$50); - ZEPHIR_INIT_NVAR(&_40$$50); - zephir_create_array(&_40$$50, 1, 0); - zephir_array_fast_append(&_40$$50, &position); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_39$$50, &converter, &_40$$50); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_39$$50, PH_COPY | PH_SEPARATE); - } - } else { - if (Z_TYPE_P(&position) == IS_LONG) { - zephir_array_unset(&parts, &part, PH_SEPARATE); - } - } - } - ZEPHIR_CALL_METHOD(NULL, &paths, "next", NULL, 0); + ZEPHIR_INIT_NVAR(&_35$$39); + zephir_create_array(&_35$$39, 2, 0); + zephir_array_fast_append(&_35$$39, &attribute); + zephir_array_fast_append(&_35$$39, &sqlColumn); + zephir_array_append(&selectColumns, &_35$$39, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1138); + ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&position); - ZEPHIR_INIT_NVAR(&part); - zephir_update_property_zval(this_ptr, ZEND_STRL("matches"), &matches); + ZEPHIR_INIT_NVAR(&attribute); + } + } else { + ZEPHIR_INIT_NVAR(&columnAlias); + if (Z_TYPE_P(&aliasCopy) == IS_LONG) { + ZEPHIR_INIT_NVAR(&_36$$41); + zephir_create_array(&_36$$41, 2, 0); + zephir_array_fast_append(&_36$$41, &sqlColumn); + zephir_array_fast_append(&_36$$41, &__$null); + ZEPHIR_CPY_WRT(&columnAlias, &_36$$41); + } else { + ZEPHIR_INIT_NVAR(&_37$$42); + zephir_create_array(&_37$$42, 3, 0); + zephir_array_fast_append(&_37$$42, &sqlColumn); + zephir_array_fast_append(&_37$$42, &__$null); + zephir_array_fast_append(&_37$$42, &aliasCopy); + ZEPHIR_CPY_WRT(&columnAlias, &_37$$42); + } + zephir_array_append(&selectColumns, &columnAlias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1151); + } + _38$$28 = !isComplex; + if (_38$$28) { + _38$$28 = isSimpleStd; + } + if (_38$$28) { + ZEPHIR_OBS_NVAR(&sqlAlias); + if (zephir_array_isset_string_fetch(&sqlAlias, &column, SL("sqlAlias"), 0)) { + zephir_array_update_zval(&simpleColumnMap, &sqlAlias, &aliasCopy, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&simpleColumnMap, &aliasCopy, &aliasCopy, PH_COPY | PH_SEPARATE); } - zephir_update_property_zval(this_ptr, ZEND_STRL("matchedRoute"), &route); - break; } } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &_4, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_9, &_4, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_15, &columns, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_9)) { + if (!zend_is_true(&_15)) { break; } - ZEPHIR_CALL_METHOD(&route, &_4, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&aliasCopy, &columns, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(¶ms); - array_init(¶ms); - ZEPHIR_INIT_NVAR(&matches); - ZVAL_NULL(&matches); - ZEPHIR_CALL_METHOD(&methods, &route, "gethttpmethods", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&methods) != IS_NULL) { - ZVAL_BOOL(&_42$$54, 1); - ZEPHIR_CALL_METHOD(&_41$$54, &request, "ismethod", &_43, 0, &methods, &_42$$54); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_41$$54)) { - continue; - } - } - ZEPHIR_CALL_METHOD(&hostname, &route, "gethostname", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&hostname) != IS_NULL) { - if (Z_TYPE_P(¤tHostName) == IS_NULL) { - ZEPHIR_CALL_METHOD(¤tHostName, &request, "gethttphost", &_44, 0); + ZEPHIR_CALL_METHOD(&column, &columns, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&sqlColumn); + zephir_array_fetch_string(&sqlColumn, &column, SL("column"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1083); + zephir_array_fetch_string(&_39$$46, &column, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1086); + if (ZEPHIR_IS_STRING(&_39$$46, "object")) { + ZEPHIR_OBS_NVAR(&modelName); + zephir_array_fetch_string(&modelName, &column, SL("model"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1087); + ZEPHIR_OBS_NVAR(&instance); + zephir_read_property(&_40$$47, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&instance, &_40$$47, &modelName, 0))) { + ZEPHIR_CALL_METHOD(&instance, &manager, "load", &_41, 0, &modelName); zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("modelsInstances"), &modelName, &instance); } - if (!(zephir_is_true(¤tHostName))) { - continue; - } - if (zephir_memnstr_str(&hostname, SL("("), "phalcon/Mvc/Router.zep", 772)) { - if (!(zephir_memnstr_str(&hostname, SL("#"), "phalcon/Mvc/Router.zep", 773))) { - ZEPHIR_INIT_NVAR(®exHostName); - ZEPHIR_CONCAT_SV(®exHostName, "#^", &hostname); - if (!(zephir_memnstr_str(&hostname, SL(":"), "phalcon/Mvc/Router.zep", 776))) { - zephir_concat_self_str(®exHostName, SL("(:[[:digit:]]+)?")); - } - zephir_concat_self_str(®exHostName, SL("$#i")); + ZEPHIR_CALL_METHOD(&attributes, &metaData, "getattributes", &_42, 0, &instance); + zephir_check_call_status(); + if (isComplex) { + if (ZEPHIR_GLOBAL(orm).column_renaming) { + ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", &_43, 0, &instance); + zephir_check_call_status(); } else { - ZEPHIR_CPY_WRT(®exHostName, &hostname); + ZEPHIR_INIT_NVAR(&columnMap); + ZVAL_NULL(&columnMap); } - ZEPHIR_INIT_NVAR(&_45$$59); - ZEPHIR_INIT_NVAR(&matched); - zephir_preg_match(&matched, ®exHostName, ¤tHostName, &_45$$59, 0, 0 , 0 ); - } else { - ZEPHIR_INIT_NVAR(&matched); - ZVAL_BOOL(&matched, ZEPHIR_IS_EQUAL(¤tHostName, &hostname)); - } - if (!(zephir_is_true(&matched))) { - continue; - } - } - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_46$$65); - ZVAL_STRING(&_46$$65, "router:beforeCheckRoute"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_47, 0, &_46$$65, this_ptr, &route); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&pattern, &route, "getcompiledpattern", NULL, 0); - zephir_check_call_status(); - if (zephir_memnstr_str(&pattern, SL("^"), "phalcon/Mvc/Router.zep", 804)) { - ZEPHIR_INIT_NVAR(&routeFound); - zephir_preg_match(&routeFound, &pattern, &handledUri, &matches, 0, 0 , 0 ); - } else { - ZEPHIR_INIT_NVAR(&routeFound); - ZVAL_BOOL(&routeFound, ZEPHIR_IS_EQUAL(&pattern, &handledUri)); - } - if (zephir_is_true(&routeFound)) { - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_48$$69); - ZVAL_STRING(&_48$$69, "router:matchedRoute"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_49, 0, &_48$$69, this_ptr, &route); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&beforeMatch, &route, "getbeforematch", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&beforeMatch) != IS_NULL) { - if (UNEXPECTED(!(zephir_is_callable(&beforeMatch)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "Before-Match callback is not callable in matched route", "phalcon/Mvc/Router.zep", 826); - return; + zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model/Query.zep", 1123); + if (Z_TYPE_P(&attributes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _44$$49) + { + ZEPHIR_INIT_NVAR(&attribute); + ZVAL_COPY(&attribute, _44$$49); + ZEPHIR_INIT_NVAR(&_46$$52); + zephir_create_array(&_46$$52, 3, 0); + zephir_array_fast_append(&_46$$52, &attribute); + zephir_array_fast_append(&_46$$52, &sqlColumn); + ZEPHIR_INIT_NVAR(&_47$$52); + ZEPHIR_CONCAT_SVSV(&_47$$52, "_", &sqlColumn, "_", &attribute); + zephir_array_fast_append(&_46$$52, &_47$$52); + zephir_array_append(&selectColumns, &_46$$52, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1116); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_45$$49, &attributes, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_45$$49)) { + break; + } + ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_48$$53); + zephir_create_array(&_48$$53, 3, 0); + zephir_array_fast_append(&_48$$53, &attribute); + zephir_array_fast_append(&_48$$53, &sqlColumn); + ZEPHIR_INIT_NVAR(&_49$$53); + ZEPHIR_CONCAT_SVSV(&_49$$53, "_", &sqlColumn, "_", &attribute); + zephir_array_fast_append(&_48$$53, &_49$$53); + zephir_array_append(&selectColumns, &_48$$53, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1116); + ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); + zephir_check_call_status(); + } } - ZEPHIR_INIT_NVAR(&_50$$70); - zephir_create_array(&_50$$70, 3, 0); - zephir_array_fast_append(&_50$$70, &handledUri); - zephir_array_fast_append(&_50$$70, &route); - zephir_array_fast_append(&_50$$70, this_ptr); - ZEPHIR_INIT_NVAR(&routeFound); - ZEPHIR_CALL_USER_FUNC_ARRAY(&routeFound, &beforeMatch, &_50$$70); - zephir_check_call_status(); - } - } else { - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_51$$73); - ZVAL_STRING(&_51$$73, "router:notMatchedRoute"); - ZEPHIR_CALL_METHOD(&routeFound, &eventsManager, "fire", &_52, 0, &_51$$73, this_ptr, &route); - zephir_check_call_status(); - } - } - if (zephir_is_true(&routeFound)) { - ZEPHIR_CALL_METHOD(&paths, &route, "getpaths", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&parts, &paths); - if (Z_TYPE_P(&matches) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(&converters, &route, "getconverters", NULL, 0); + ZEPHIR_INIT_NVAR(&attribute); + zephir_array_update_multi(&columns1, &instance, SL("zs"), 3, &aliasCopy, SL("instance")); + zephir_array_update_multi(&columns1, &attributes, SL("zs"), 3, &aliasCopy, SL("attributes")); + zephir_array_update_multi(&columns1, &columnMap, SL("zs"), 3, &aliasCopy, SL("columnMap")); + ZEPHIR_CALL_METHOD(&_50$$49, &manager, "iskeepingsnapshots", &_51, 0, &instance); zephir_check_call_status(); - zephir_is_iterable(&paths, 0, "phalcon/Mvc/Router.zep", 918); - if (Z_TYPE_P(&paths) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&paths), _55$$75, _56$$75, _53$$75) + isKeepingSnapshots = zephir_get_boolval(&_50$$49); + if (isKeepingSnapshots) { + ZEPHIR_INIT_NVAR(&_52$$54); + ZVAL_BOOL(&_52$$54, isKeepingSnapshots); + zephir_array_update_multi(&columns1, &_52$$54, SL("zs"), 3, &aliasCopy, SL("keepSnapshots")); + } + } else { + zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model/Query.zep", 1140); + if (Z_TYPE_P(&attributes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _53$$55) { - ZEPHIR_INIT_NVAR(&part); - if (_56$$75 != NULL) { - ZVAL_STR_COPY(&part, _56$$75); - } else { - ZVAL_LONG(&part, _55$$75); - } - ZEPHIR_INIT_NVAR(&position); - ZVAL_COPY(&position, _53$$75); - if (UNEXPECTED(Z_TYPE_P(&part) != IS_STRING)) { - ZEPHIR_INIT_NVAR(&_57$$77); - object_init_ex(&_57$$77, phalcon_mvc_router_exception_ce); - ZEPHIR_INIT_NVAR(&_58$$77); - ZEPHIR_CONCAT_SV(&_58$$77, "Wrong key in paths: ", &part); - ZEPHIR_CALL_METHOD(NULL, &_57$$77, "__construct", &_28, 33, &_58$$77); - zephir_check_call_status(); - zephir_throw_exception_debug(&_57$$77, "phalcon/Mvc/Router.zep", 866); - ZEPHIR_MM_RESTORE(); - return; - } - _59$$76 = Z_TYPE_P(&position) != IS_STRING; - if (_59$$76) { - _59$$76 = Z_TYPE_P(&position) != IS_LONG; - } - if (_59$$76) { - continue; - } - ZEPHIR_OBS_NVAR(&matchPosition); - if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { - if (Z_TYPE_P(&converters) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_60$$81); - ZEPHIR_INIT_NVAR(&_61$$81); - zephir_create_array(&_61$$81, 1, 0); - zephir_array_fast_append(&_61$$81, &matchPosition); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_60$$81, &converter, &_61$$81); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_60$$81, PH_COPY | PH_SEPARATE); - continue; - } - } - zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); - } else { - if (Z_TYPE_P(&converters) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_62$$84); - ZEPHIR_INIT_NVAR(&_63$$84); - zephir_create_array(&_63$$84, 1, 0); - zephir_array_fast_append(&_63$$84, &position); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_62$$84, &converter, &_63$$84); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_62$$84, PH_COPY | PH_SEPARATE); - } - } else { - if (Z_TYPE_P(&position) == IS_LONG) { - zephir_array_unset(&parts, &part, PH_SEPARATE); - } - } - } + ZEPHIR_INIT_NVAR(&attribute); + ZVAL_COPY(&attribute, _53$$55); + ZEPHIR_INIT_NVAR(&_55$$56); + zephir_create_array(&_55$$56, 2, 0); + zephir_array_fast_append(&_55$$56, &attribute); + zephir_array_fast_append(&_55$$56, &sqlColumn); + zephir_array_append(&selectColumns, &_55$$56, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1138); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &paths, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_54$$75, &paths, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_54$$55, &attributes, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_54$$75)) { + if (!zend_is_true(&_54$$55)) { break; } - ZEPHIR_CALL_METHOD(&part, &paths, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&position, &paths, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&part) != IS_STRING)) { - ZEPHIR_INIT_NVAR(&_64$$88); - object_init_ex(&_64$$88, phalcon_mvc_router_exception_ce); - ZEPHIR_INIT_NVAR(&_65$$88); - ZEPHIR_CONCAT_SV(&_65$$88, "Wrong key in paths: ", &part); - ZEPHIR_CALL_METHOD(NULL, &_64$$88, "__construct", &_28, 33, &_65$$88); - zephir_check_call_status(); - zephir_throw_exception_debug(&_64$$88, "phalcon/Mvc/Router.zep", 866); - ZEPHIR_MM_RESTORE(); - return; - } - _66$$87 = Z_TYPE_P(&position) != IS_STRING; - if (_66$$87) { - _66$$87 = Z_TYPE_P(&position) != IS_LONG; - } - if (_66$$87) { - continue; - } - ZEPHIR_OBS_NVAR(&matchPosition); - if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { - if (Z_TYPE_P(&converters) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_67$$92); - ZEPHIR_INIT_NVAR(&_68$$92); - zephir_create_array(&_68$$92, 1, 0); - zephir_array_fast_append(&_68$$92, &matchPosition); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_67$$92, &converter, &_68$$92); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_67$$92, PH_COPY | PH_SEPARATE); - continue; - } - } - zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); - } else { - if (Z_TYPE_P(&converters) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_69$$95); - ZEPHIR_INIT_NVAR(&_70$$95); - zephir_create_array(&_70$$95, 1, 0); - zephir_array_fast_append(&_70$$95, &position); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_69$$95, &converter, &_70$$95); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_69$$95, PH_COPY | PH_SEPARATE); - } - } else { - if (Z_TYPE_P(&position) == IS_LONG) { - zephir_array_unset(&parts, &part, PH_SEPARATE); - } - } - } - ZEPHIR_CALL_METHOD(NULL, &paths, "next", NULL, 0); + ZEPHIR_INIT_NVAR(&_56$$57); + zephir_create_array(&_56$$57, 2, 0); + zephir_array_fast_append(&_56$$57, &attribute); + zephir_array_fast_append(&_56$$57, &sqlColumn); + zephir_array_append(&selectColumns, &_56$$57, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1138); + ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&position); - ZEPHIR_INIT_NVAR(&part); - zephir_update_property_zval(this_ptr, ZEND_STRL("matches"), &matches); + ZEPHIR_INIT_NVAR(&attribute); } - zephir_update_property_zval(this_ptr, ZEND_STRL("matchedRoute"), &route); - break; + } else { + if (Z_TYPE_P(&aliasCopy) == IS_LONG) { + ZEPHIR_INIT_NVAR(&_57$$59); + zephir_create_array(&_57$$59, 2, 0); + zephir_array_fast_append(&_57$$59, &sqlColumn); + zephir_array_fast_append(&_57$$59, &__$null); + ZEPHIR_CPY_WRT(&columnAlias, &_57$$59); + } else { + ZEPHIR_INIT_NVAR(&_58$$60); + zephir_create_array(&_58$$60, 3, 0); + zephir_array_fast_append(&_58$$60, &sqlColumn); + zephir_array_fast_append(&_58$$60, &__$null); + zephir_array_fast_append(&_58$$60, &aliasCopy); + ZEPHIR_CPY_WRT(&columnAlias, &_58$$60); + } + zephir_array_append(&selectColumns, &columnAlias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1151); } - ZEPHIR_CALL_METHOD(NULL, &_4, "next", NULL, 0); + _59$$46 = !isComplex; + if (_59$$46) { + _59$$46 = isSimpleStd; + } + if (_59$$46) { + ZEPHIR_OBS_NVAR(&sqlAlias); + if (zephir_array_isset_string_fetch(&sqlAlias, &column, SL("sqlAlias"), 0)) { + zephir_array_update_zval(&simpleColumnMap, &sqlAlias, &aliasCopy, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&simpleColumnMap, &aliasCopy, &aliasCopy, PH_COPY | PH_SEPARATE); + } + } + ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&route); - if (zephir_is_true(&routeFound)) { - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$false); - } + ZEPHIR_INIT_NVAR(&column); + ZEPHIR_INIT_NVAR(&aliasCopy); + ZEPHIR_INIT_VAR(&processed); + array_init(&processed); + ZEPHIR_INIT_VAR(&bindCounts); + array_init(&bindCounts); + zephir_array_update_string(&intermediate, SL("columns"), &selectColumns, PH_COPY | PH_SEPARATE); + zephir_is_iterable(&bindParams, 0, "phalcon/Mvc/Model/Query.zep", 1187); + if (Z_TYPE_P(&bindParams) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&bindParams), _62, _63, _60) + { + ZEPHIR_INIT_NVAR(&wildcard); + if (_63 != NULL) { + ZVAL_STR_COPY(&wildcard, _63); + } else { + ZVAL_LONG(&wildcard, _62); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _60); + if (Z_TYPE_P(&wildcard) == IS_LONG) { + ZEPHIR_INIT_NVAR(&wildcardValue); + ZEPHIR_CONCAT_SV(&wildcardValue, ":", &wildcard); + } else { + ZEPHIR_CPY_WRT(&wildcardValue, &wildcard); + } + zephir_array_update_zval(&processed, &wildcardValue, &value, PH_COPY | PH_SEPARATE); + if (Z_TYPE_P(&value) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&_64$$67); + ZVAL_LONG(&_64$$67, zephir_fast_count_int(&value)); + zephir_array_update_zval(&bindCounts, &wildcardValue, &_64$$67, PH_COPY | PH_SEPARATE); + } + } ZEND_HASH_FOREACH_END(); } else { - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$false); - } - } - if (!(zephir_is_true(&routeFound))) { - zephir_read_property(&_71$$100, this_ptr, ZEND_STRL("notFoundPaths"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(¬FoundPaths, &_71$$100); - if (Z_TYPE_P(¬FoundPaths) != IS_NULL) { - ZEPHIR_CALL_CE_STATIC(&parts, phalcon_mvc_router_route_ce, "getroutepaths", NULL, 0, ¬FoundPaths); + ZEPHIR_CALL_METHOD(NULL, &bindParams, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_61, &bindParams, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_61)) { + break; + } + ZEPHIR_CALL_METHOD(&wildcard, &bindParams, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &bindParams, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&wildcard) == IS_LONG) { + ZEPHIR_INIT_NVAR(&wildcardValue); + ZEPHIR_CONCAT_SV(&wildcardValue, ":", &wildcard); + } else { + ZEPHIR_CPY_WRT(&wildcardValue, &wildcard); + } + zephir_array_update_zval(&processed, &wildcardValue, &value, PH_COPY | PH_SEPARATE); + if (Z_TYPE_P(&value) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&_65$$71); + ZVAL_LONG(&_65$$71, zephir_fast_count_int(&value)); + zephir_array_update_zval(&bindCounts, &wildcardValue, &_65$$71, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, &bindParams, "next", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&routeFound); - ZVAL_BOOL(&routeFound, 1); } } - zephir_read_property(&_72, this_ptr, ZEND_STRL("defaultNamespace"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("namespaceName"), &_72); - zephir_read_property(&_73, this_ptr, ZEND_STRL("defaultModule"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("module"), &_73); - zephir_read_property(&_74, this_ptr, ZEND_STRL("defaultController"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("controller"), &_74); - zephir_read_property(&_75, this_ptr, ZEND_STRL("defaultAction"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("action"), &_75); - zephir_read_property(&_76, this_ptr, ZEND_STRL("defaultParams"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("params"), &_76); - if (zephir_is_true(&routeFound)) { - zephir_memory_observe(&vnamespace); - if (zephir_array_isset_string_fetch(&vnamespace, &parts, SL("namespace"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("namespaceName"), &vnamespace); - zephir_array_unset_string(&parts, SL("namespace"), PH_SEPARATE); - } - zephir_memory_observe(&module); - if (zephir_array_isset_string_fetch(&module, &parts, SL("module"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("module"), &module); - zephir_array_unset_string(&parts, SL("module"), PH_SEPARATE); - } - zephir_memory_observe(&controller); - if (zephir_array_isset_string_fetch(&controller, &parts, SL("controller"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("controller"), &controller); - zephir_array_unset_string(&parts, SL("controller"), PH_SEPARATE); - } - zephir_memory_observe(&action); - if (zephir_array_isset_string_fetch(&action, &parts, SL("action"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("action"), &action); - zephir_array_unset_string(&parts, SL("action"), PH_SEPARATE); - } - zephir_memory_observe(¶msStr); - if (zephir_array_isset_string_fetch(¶msStr, &parts, SL("params"), 0)) { - if (Z_TYPE_P(¶msStr) == IS_STRING) { - ZEPHIR_INIT_VAR(&_77$$108); - ZVAL_STRING(&_77$$108, "/"); - ZEPHIR_INIT_VAR(&strParams); - zephir_fast_trim(&strParams, ¶msStr, &_77$$108, ZEPHIR_TRIM_BOTH); - if (!ZEPHIR_IS_STRING_IDENTICAL(&strParams, "")) { - ZEPHIR_INIT_NVAR(¶ms); - zephir_fast_explode_str(¶ms, SL("/"), &strParams, LONG_MAX); - } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&wildcard); + ZEPHIR_INIT_VAR(&processedTypes); + array_init(&processedTypes); + zephir_is_iterable(&bindTypes, 0, "phalcon/Mvc/Model/Query.zep", 1200); + if (Z_TYPE_P(&bindTypes) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&bindTypes), _68, _69, _66) + { + ZEPHIR_INIT_NVAR(&typeWildcard); + if (_69 != NULL) { + ZVAL_STR_COPY(&typeWildcard, _69); + } else { + ZVAL_LONG(&typeWildcard, _68); } - zephir_array_unset_string(&parts, SL("params"), PH_SEPARATE); - } - if (zephir_fast_count_int(¶ms)) { - ZEPHIR_INIT_VAR(&_78$$110); - zephir_fast_array_merge(&_78$$110, ¶ms, &parts); - zephir_update_property_zval(this_ptr, ZEND_STRL("params"), &_78$$110); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("params"), &parts); + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _66); + if (Z_TYPE_P(&typeWildcard) == IS_LONG) { + ZEPHIR_INIT_NVAR(&_70$$73); + ZEPHIR_CONCAT_SV(&_70$$73, ":", &typeWildcard); + zephir_array_update_zval(&processedTypes, &_70$$73, &value, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&processedTypes, &typeWildcard, &value, PH_COPY | PH_SEPARATE); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &bindTypes, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_67, &bindTypes, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_67)) { + break; + } + ZEPHIR_CALL_METHOD(&typeWildcard, &bindTypes, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &bindTypes, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&typeWildcard) == IS_LONG) { + ZEPHIR_INIT_NVAR(&_71$$76); + ZEPHIR_CONCAT_SV(&_71$$76, ":", &typeWildcard); + zephir_array_update_zval(&processedTypes, &_71$$76, &value, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&processedTypes, &typeWildcard, &value, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, &bindTypes, "next", NULL, 0); + zephir_check_call_status(); } } - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_79$$112); - ZVAL_STRING(&_79$$112, "router:afterCheckRoutes"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_79$$112, this_ptr); - zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&typeWildcard); + if (zephir_fast_count_int(&bindCounts)) { + zephir_array_update_string(&intermediate, SL("bindCounts"), &bindCounts, PH_COPY | PH_SEPARATE); } - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Router, isExactControllerName) -{ - - RETURN_BOOL(1); -} - -static PHP_METHOD(Phalcon_Mvc_Router, mount) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *group, group_sub, groupRoutes, beforeMatch, hostname, routes, route, eventsManager, _0, _6, _1$$3, *_2$$5, _3$$5, *_4$$8, _5$$8; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&group_sub); - ZVAL_UNDEF(&groupRoutes); - ZVAL_UNDEF(&beforeMatch); - ZVAL_UNDEF(&hostname); - ZVAL_UNDEF(&routes); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_5$$8); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(group, phalcon_mvc_router_groupinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &group); - zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_1$$3); - ZVAL_STRING(&_1$$3, "router:beforeMount"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_1$$3, this_ptr, group); + ZEPHIR_CALL_METHOD(&dialect, &connection, "getdialect", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&sqlSelect, &dialect, "select", NULL, 0, &intermediate); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("sharedLock"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_0)) { + ZEPHIR_CALL_METHOD(&_72$$79, &dialect, "sharedlock", NULL, 0, &sqlSelect); zephir_check_call_status(); + ZEPHIR_CPY_WRT(&sqlSelect, &_72$$79); } - ZEPHIR_CALL_METHOD(&groupRoutes, group, "getroutes", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(!(zephir_fast_count_int(&groupRoutes)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "The group of routes does not contain any routes", "phalcon/Mvc/Router.zep", 1051); - return; + if (simulate) { + zephir_create_array(return_value, 3, 0); + zephir_array_update_string(return_value, SL("sql"), &sqlSelect, PH_COPY | PH_SEPARATE); + zephir_array_update_string(return_value, SL("bind"), &processed, PH_COPY | PH_SEPARATE); + zephir_array_update_string(return_value, SL("bindTypes"), &processedTypes, PH_COPY | PH_SEPARATE); + RETURN_MM(); } - ZEPHIR_CALL_METHOD(&beforeMatch, group, "getbeforematch", NULL, 0); + ZEPHIR_CALL_METHOD(&result, &connection, "query", NULL, 0, &sqlSelect, &processed, &processedTypes); zephir_check_call_status(); - if (Z_TYPE_P(&beforeMatch) != IS_NULL) { - zephir_is_iterable(&groupRoutes, 0, "phalcon/Mvc/Router.zep", 1063); - if (Z_TYPE_P(&groupRoutes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&groupRoutes), _2$$5) - { - ZEPHIR_INIT_NVAR(&route); - ZVAL_COPY(&route, _2$$5); - ZEPHIR_CALL_METHOD(NULL, &route, "beforematch", NULL, 0, &beforeMatch); + if (zephir_instance_of_ev(&result, phalcon_db_resultinterface_ce)) { + ZEPHIR_CPY_WRT(&resultData, &result); + } else { + ZEPHIR_INIT_NVAR(&resultData); + ZVAL_NULL(&resultData); + } + zephir_read_property(&_73, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&cache, &_73); + if (!(isComplex)) { + if (isSimpleStd) { + ZEPHIR_INIT_VAR(&resultObject); + object_init_ex(&resultObject, phalcon_mvc_model_row_ce); + if (zephir_has_constructor(&resultObject)) { + ZEPHIR_CALL_METHOD(NULL, &resultObject, "__construct", NULL, 0); zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); + } + + isKeepingSnapshots = 0; } else { - ZEPHIR_CALL_METHOD(NULL, &groupRoutes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$5, &groupRoutes, "valid", NULL, 0); + if (Z_TYPE_P(&instance) == IS_OBJECT) { + ZEPHIR_CPY_WRT(&resultObject, &instance); + } else { + ZEPHIR_CPY_WRT(&resultObject, &model); + } + if (!(ZEPHIR_GLOBAL(orm).cast_on_hydrate)) { + ZEPHIR_CALL_METHOD(&simpleColumnMap, &metaData, "getcolumnmap", NULL, 0, &resultObject); zephir_check_call_status(); - if (!zend_is_true(&_3$$5)) { - break; - } - ZEPHIR_CALL_METHOD(&route, &groupRoutes, "current", NULL, 0); + } else { + ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", NULL, 0, &resultObject); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &route, "beforematch", NULL, 0, &beforeMatch); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &groupRoutes, "next", NULL, 0); + ZEPHIR_CALL_METHOD(&typesColumnMap, &metaData, "getdatatypes", NULL, 0, &resultObject); zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&simpleColumnMap); + if (Z_TYPE_P(&columnMap) == IS_NULL) { + array_init(&simpleColumnMap); + ZEPHIR_CALL_METHOD(&_74$$90, &metaData, "getattributes", NULL, 0, &resultObject); + zephir_check_call_status(); + zephir_is_iterable(&_74$$90, 0, "phalcon/Mvc/Model/Query.zep", 1288); + if (Z_TYPE_P(&_74$$90) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_74$$90), _75$$90) + { + ZEPHIR_INIT_NVAR(&attribute); + ZVAL_COPY(&attribute, _75$$90); + ZEPHIR_INIT_NVAR(&_77$$91); + zephir_create_array(&_77$$91, 2, 0); + zephir_array_fast_append(&_77$$91, &attribute); + ZEPHIR_OBS_NVAR(&_78$$91); + zephir_array_fetch(&_78$$91, &typesColumnMap, &attribute, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1286); + zephir_array_fast_append(&_77$$91, &_78$$91); + zephir_array_update_zval(&simpleColumnMap, &attribute, &_77$$91, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_74$$90, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_76$$90, &_74$$90, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_76$$90)) { + break; + } + ZEPHIR_CALL_METHOD(&attribute, &_74$$90, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_79$$92); + zephir_create_array(&_79$$92, 2, 0); + zephir_array_fast_append(&_79$$92, &attribute); + ZEPHIR_OBS_NVAR(&_80$$92); + zephir_array_fetch(&_80$$92, &typesColumnMap, &attribute, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1286); + zephir_array_fast_append(&_79$$92, &_80$$92); + zephir_array_update_zval(&simpleColumnMap, &attribute, &_79$$92, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &_74$$90, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&attribute); + } else { + array_init(&simpleColumnMap); + zephir_is_iterable(&columnMap, 0, "phalcon/Mvc/Model/Query.zep", 1297); + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&columnMap), _83$$93, _84$$93, _81$$93) + { + ZEPHIR_INIT_NVAR(&column); + if (_84$$93 != NULL) { + ZVAL_STR_COPY(&column, _84$$93); + } else { + ZVAL_LONG(&column, _83$$93); + } + ZEPHIR_INIT_NVAR(&attribute); + ZVAL_COPY(&attribute, _81$$93); + ZEPHIR_INIT_NVAR(&_85$$94); + zephir_create_array(&_85$$94, 2, 0); + zephir_array_fast_append(&_85$$94, &attribute); + ZEPHIR_OBS_NVAR(&_86$$94); + zephir_array_fetch(&_86$$94, &typesColumnMap, &column, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1295); + zephir_array_fast_append(&_85$$94, &_86$$94); + zephir_array_update_zval(&simpleColumnMap, &column, &_85$$94, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &columnMap, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_82$$93, &columnMap, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_82$$93)) { + break; + } + ZEPHIR_CALL_METHOD(&column, &columnMap, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&attribute, &columnMap, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_87$$95); + zephir_create_array(&_87$$95, 2, 0); + zephir_array_fast_append(&_87$$95, &attribute); + ZEPHIR_OBS_NVAR(&_88$$95); + zephir_array_fetch(&_88$$95, &typesColumnMap, &column, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1295); + zephir_array_fast_append(&_87$$95, &_88$$95); + zephir_array_update_zval(&simpleColumnMap, &column, &_87$$95, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &columnMap, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&attribute); + ZEPHIR_INIT_NVAR(&column); + } } + ZEPHIR_CALL_METHOD(&_89$$85, &manager, "iskeepingsnapshots", NULL, 0, &resultObject); + zephir_check_call_status(); + isKeepingSnapshots = zephir_get_boolval(&_89$$85); } - ZEPHIR_INIT_NVAR(&route); - } - ZEPHIR_CALL_METHOD(&hostname, group, "gethostname", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&hostname) != IS_NULL) { - zephir_is_iterable(&groupRoutes, 0, "phalcon/Mvc/Router.zep", 1072); - if (Z_TYPE_P(&groupRoutes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&groupRoutes), _4$$8) - { - ZEPHIR_INIT_NVAR(&route); - ZVAL_COPY(&route, _4$$8); - ZEPHIR_CALL_METHOD(NULL, &route, "sethostname", NULL, 0, &hostname); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &groupRoutes, "rewind", NULL, 0); + _90$$83 = zephir_instance_of_ev(&resultObject, phalcon_mvc_modelinterface_ce); + if (_90$$83) { + _90$$83 = (zephir_method_exists_ex(&resultObject, ZEND_STRL("getresultsetclass")) == SUCCESS); + } + if (_90$$83) { + ZEPHIR_CALL_METHOD(&resultsetClassName, &resultObject, "getresultsetclass", NULL, 0); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5$$8, &groupRoutes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5$$8)) { - break; + if (zephir_is_true(&resultsetClassName)) { + if (UNEXPECTED(!(zephir_class_exists(&resultsetClassName, 1)))) { + ZEPHIR_INIT_VAR(&_91$$98); + object_init_ex(&_91$$98, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_92$$98); + ZEPHIR_CONCAT_SVS(&_92$$98, "Resultset class \"", &resultsetClassName, "\" not found"); + ZEPHIR_CALL_METHOD(NULL, &_91$$98, "__construct", NULL, 33, &_92$$98); + zephir_check_call_status(); + zephir_throw_exception_debug(&_91$$98, "phalcon/Mvc/Model/Query.zep", 1313); + ZEPHIR_MM_RESTORE(); + return; } - ZEPHIR_CALL_METHOD(&route, &groupRoutes, "current", NULL, 0); + ZEPHIR_INIT_VAR(&_93$$97); + ZVAL_STRING(&_93$$97, "Phalcon\\Mvc\\Model\\ResultsetInterface"); + ZEPHIR_CALL_FUNCTION(&_94$$97, "is_subclass_of", NULL, 438, &resultsetClassName, &_93$$97); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &route, "sethostname", NULL, 0, &hostname); + if (UNEXPECTED(!zephir_is_true(&_94$$97))) { + ZEPHIR_INIT_VAR(&_95$$99); + object_init_ex(&_95$$99, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_96$$99); + ZEPHIR_CONCAT_SVS(&_96$$99, "Resultset class \"", &resultsetClassName, "\" must be an implementation of Phalcon\\Mvc\\Model\\ResultsetInterface"); + ZEPHIR_CALL_METHOD(NULL, &_95$$99, "__construct", NULL, 33, &_96$$99); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &groupRoutes, "next", NULL, 0); + zephir_throw_exception_debug(&_95$$99, "phalcon/Mvc/Model/Query.zep", 1319); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_VAR(&_97$$97); + zephir_create_array(&_97$$97, 5, 0); + zephir_array_fast_append(&_97$$97, &simpleColumnMap); + zephir_array_fast_append(&_97$$97, &resultObject); + zephir_array_fast_append(&_97$$97, &resultData); + zephir_array_fast_append(&_97$$97, &cache); + ZEPHIR_INIT_NVAR(&_93$$97); + ZVAL_BOOL(&_93$$97, isKeepingSnapshots); + zephir_array_fast_append(&_97$$97, &_93$$97); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(return_value, &resultsetClassName, &_97$$97); zephir_check_call_status(); + RETURN_MM(); } } - ZEPHIR_INIT_NVAR(&route); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&routes, &_0); - ZEPHIR_INIT_VAR(&_6); - zephir_fast_array_merge(&_6, &routes, &groupRoutes); - zephir_update_property_zval(this_ptr, ZEND_STRL("routes"), &_6); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Router, notFound) -{ - zend_bool _0; - zval *paths, paths_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&paths_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(paths) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &paths); - _0 = Z_TYPE_P(paths) != IS_ARRAY; - if (_0) { - _0 = Z_TYPE_P(paths) != IS_STRING; - } - if (UNEXPECTED(_0)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_router_exception_ce, "The not-found paths must be an array or string", "phalcon/Mvc/Router.zep", 1094); - return; - } - zephir_update_property_zval(this_ptr, ZEND_STRL("notFoundPaths"), paths); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_Router, removeExtraSlashes) -{ - zval *remove_param = NULL, __$true, __$false; - zend_bool remove; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(remove) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &remove_param); - if (UNEXPECTED(Z_TYPE_P(remove_param) != IS_TRUE && Z_TYPE_P(remove_param) != IS_FALSE)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'remove' must be of the type bool")); - RETURN_NULL(); - } - remove = (Z_TYPE_P(remove_param) == IS_TRUE); - if (remove) { - zephir_update_property_zval(this_ptr, ZEND_STRL("removeExtraSlashes"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("removeExtraSlashes"), &__$false); + object_init_ex(return_value, phalcon_mvc_model_resultset_simple_ce); + if (isKeepingSnapshots) { + ZVAL_BOOL(&_98$$83, 1); + } else { + ZVAL_BOOL(&_98$$83, 0); + } + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 456, &simpleColumnMap, &resultObject, &resultData, &cache, &_98$$83); + zephir_check_call_status(); + RETURN_MM(); } - RETURN_THISW(); + object_init_ex(return_value, phalcon_mvc_model_resultset_complex_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 457, &columns1, &resultData, &cache); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router, setDefaultAction) +static PHP_METHOD(Phalcon_Mvc_Model_Query, executeUpdate) { + zend_string *_5; + zend_ulong _4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *actionName_param = NULL; - zval actionName; + zephir_fcall_cache_entry *_7 = NULL, *_9 = NULL, *_14 = NULL, *_16 = NULL, *_17 = NULL, *_19 = NULL, *_21 = NULL, *_27 = NULL, *_30 = NULL, *_32 = NULL, *_34 = NULL, *_36 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, models, modelName, model, connection, dialect, fields, values, updateValues, fieldName, value, selectBindParams, selectBindTypes, number, field, records, exprValue, updateValue, wildcard, record, exception, _0, *_2, _3, _29, _37, _1$$4, _6$$5, _8$$10, _10$$10, _11$$10, _12$$11, _13$$11, _15$$13, _18$$14, _20$$19, _22$$19, _23$$19, _24$$20, _25$$20, _26$$22, _28$$23, _31$$25, _33$$26, _35$$24; + zval intermediate, bindParams, bindTypes; zval *this_ptr = getThis(); - ZVAL_UNDEF(&actionName); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(actionName) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &actionName_param); - if (UNEXPECTED(Z_TYPE_P(actionName_param) != IS_STRING && Z_TYPE_P(actionName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(actionName_param) == IS_STRING)) { - zephir_get_strval(&actionName, actionName_param); - } else { - ZEPHIR_INIT_VAR(&actionName); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultAction"), &actionName); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Router, setDefaultController) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *controllerName_param = NULL; - zval controllerName; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&controllerName); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(controllerName) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &controllerName_param); - if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { - zephir_get_strval(&controllerName, controllerName_param); - } else { - ZEPHIR_INIT_VAR(&controllerName); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultController"), &controllerName); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Router, setDefaultModule) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *moduleName_param = NULL; - zval moduleName; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&moduleName); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(moduleName) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &moduleName_param); - if (UNEXPECTED(Z_TYPE_P(moduleName_param) != IS_STRING && Z_TYPE_P(moduleName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'moduleName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(moduleName_param) == IS_STRING)) { - zephir_get_strval(&moduleName, moduleName_param); - } else { - ZEPHIR_INIT_VAR(&moduleName); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultModule"), &moduleName); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Router, setDefaultNamespace) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *namespaceName_param = NULL; - zval namespaceName; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&namespaceName); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(namespaceName) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &namespaceName_param); - if (UNEXPECTED(Z_TYPE_P(namespaceName_param) != IS_STRING && Z_TYPE_P(namespaceName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'namespaceName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(namespaceName_param) == IS_STRING)) { - zephir_get_strval(&namespaceName, namespaceName_param); - } else { - ZEPHIR_INIT_VAR(&namespaceName); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultNamespace"), &namespaceName); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Router, setDefaults) -{ - zval _0$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *defaults_param = NULL, namespaceName, module, controller, action, params; - zval defaults; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&defaults); - ZVAL_UNDEF(&namespaceName); - ZVAL_UNDEF(&module); - ZVAL_UNDEF(&controller); - ZVAL_UNDEF(&action); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&_0$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(defaults) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &defaults_param); - ZEPHIR_OBS_COPY_OR_DUP(&defaults, defaults_param); - zephir_memory_observe(&namespaceName); - if (zephir_array_isset_string_fetch(&namespaceName, &defaults, SL("namespace"), 0)) { - zephir_cast_to_string(&_0$$3, &namespaceName); - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultNamespace"), &_0$$3); - } - zephir_memory_observe(&module); - if (zephir_array_isset_string_fetch(&module, &defaults, SL("module"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultModule"), &module); - } - zephir_memory_observe(&controller); - if (zephir_array_isset_string_fetch(&controller, &defaults, SL("controller"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultController"), &controller); - } - zephir_memory_observe(&action); - if (zephir_array_isset_string_fetch(&action, &defaults, SL("action"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultAction"), &action); - } - zephir_memory_observe(¶ms); - if (zephir_array_isset_string_fetch(¶ms, &defaults, SL("params"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultParams"), ¶ms); - } - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Router, setEventsManager) -{ - zval *eventsManager, eventsManager_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&eventsManager_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); - zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); -} - -static PHP_METHOD(Phalcon_Mvc_Router, setKeyRouteNames) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *routeNames_param = NULL; - zval routeNames; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&routeNames); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(routeNames) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &routeNames_param); - zephir_get_arrval(&routeNames, routeNames_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("keyRouteNames"), &routeNames); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Router, setKeyRouteIds) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *routeIds_param = NULL; - zval routeIds; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&routeIds); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(routeIds) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &routeIds_param); - zephir_get_arrval(&routeIds, routeIds_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("keyRouteIds"), &routeIds); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Router, wasMatched) -{ - - RETURN_MEMBER(getThis(), "wasMatched"); -} - -zend_object *zephir_init_properties_Phalcon_Mvc_Router(zend_class_entry *class_type) -{ - zval _0, _2, _4, _6, _8, _10, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_11$$8); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("routes"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("matches"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("matches"), &_5$$5); - } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("keyRouteIds"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("keyRouteIds"), &_7$$6); - } - zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("keyRouteNames"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_8) == IS_NULL) { - ZEPHIR_INIT_VAR(&_9$$7); - array_init(&_9$$7); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("keyRouteNames"), &_9$$7); - } - zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("defaultParams"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_10) == IS_NULL) { - ZEPHIR_INIT_VAR(&_11$$8); - array_init(&_11$$8); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("defaultParams"), &_11$$8); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_RouterInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, RouterInterface, phalcon, mvc_routerinterface, phalcon_mvc_routerinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, add); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addConnect); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addDelete); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addHead); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addGet); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addOptions); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addPatch); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addPost); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addPurge); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addPut); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, addTrace); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, attach); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, clear); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getActionName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getControllerName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getMatchedRoute); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getMatches); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getModuleName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getNamespaceName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getParams); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getRoutes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getRouteById); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, getRouteByName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, handle); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, mount); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, setDefaultAction); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, setDefaultController); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, setDefaultModule); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, setDefaults); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_RouterInterface, wasMatched); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Url) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc, Url, phalcon, mvc_url, phalcon_di_abstractinjectionaware_ce, phalcon_mvc_url_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_url_ce, SL("baseUri"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_url_ce, SL("basePath"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_url_ce, SL("router"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_url_ce, SL("staticBaseUri"), ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_mvc_url_ce, 1, phalcon_mvc_url_urlinterface_ce); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Url, __construct) -{ - zval *router = NULL, router_sub, __$null; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&router_sub); - ZVAL_NULL(&__$null); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(router, phalcon_mvc_routerinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(0, 1, &router); - if (!router) { - router = &router_sub; - router = &__$null; - } - zephir_update_property_zval(this_ptr, ZEND_STRL("router"), router); -} - -static PHP_METHOD(Phalcon_Mvc_Url, get) -{ - zval strUri, _16$$15; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool local, _0$$3, _1$$3, _20$$16; - zval *uri = NULL, uri_sub, *args = NULL, args_sub, *local_param = NULL, *baseUri = NULL, baseUri_sub, __$null, router, container, routeName, route, queryString, _2$$4, _3$$4, _4$$4, _5$$4, _6$$9, _11$$9, _14$$9, _15$$9, _7$$11, _8$$11, _9$$11, _10$$11, _12$$14, _13$$14, _17$$15, _18$$15, _19$$15, _21$$17, _22$$17, _23$$18, _24$$19; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&uri_sub); - ZVAL_UNDEF(&args_sub); - ZVAL_UNDEF(&baseUri_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&router); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&routeName); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&queryString); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$9); - ZVAL_UNDEF(&_11$$9); - ZVAL_UNDEF(&_14$$9); - ZVAL_UNDEF(&_15$$9); - ZVAL_UNDEF(&_7$$11); - ZVAL_UNDEF(&_8$$11); - ZVAL_UNDEF(&_9$$11); - ZVAL_UNDEF(&_10$$11); - ZVAL_UNDEF(&_12$$14); - ZVAL_UNDEF(&_13$$14); - ZVAL_UNDEF(&_17$$15); - ZVAL_UNDEF(&_18$$15); - ZVAL_UNDEF(&_19$$15); - ZVAL_UNDEF(&_21$$17); - ZVAL_UNDEF(&_22$$17); - ZVAL_UNDEF(&_23$$18); - ZVAL_UNDEF(&_24$$19); - ZVAL_UNDEF(&strUri); - ZVAL_UNDEF(&_16$$15); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 4) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(uri) - Z_PARAM_ZVAL_OR_NULL(args) - Z_PARAM_BOOL_OR_NULL(local, is_null_true) - Z_PARAM_ZVAL_OR_NULL(baseUri) + ZVAL_UNDEF(&intermediate); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&models); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&connection); + ZVAL_UNDEF(&dialect); + ZVAL_UNDEF(&fields); + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&updateValues); + ZVAL_UNDEF(&fieldName); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&selectBindParams); + ZVAL_UNDEF(&selectBindTypes); + ZVAL_UNDEF(&number); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&records); + ZVAL_UNDEF(&exprValue); + ZVAL_UNDEF(&updateValue); + ZVAL_UNDEF(&wildcard); + ZVAL_UNDEF(&record); + ZVAL_UNDEF(&exception); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_29); + ZVAL_UNDEF(&_37); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_8$$10); + ZVAL_UNDEF(&_10$$10); + ZVAL_UNDEF(&_11$$10); + ZVAL_UNDEF(&_12$$11); + ZVAL_UNDEF(&_13$$11); + ZVAL_UNDEF(&_15$$13); + ZVAL_UNDEF(&_18$$14); + ZVAL_UNDEF(&_20$$19); + ZVAL_UNDEF(&_22$$19); + ZVAL_UNDEF(&_23$$19); + ZVAL_UNDEF(&_24$$20); + ZVAL_UNDEF(&_25$$20); + ZVAL_UNDEF(&_26$$22); + ZVAL_UNDEF(&_28$$23); + ZVAL_UNDEF(&_31$$25); + ZVAL_UNDEF(&_33$$26); + ZVAL_UNDEF(&_35$$24); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ARRAY(intermediate) + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 4, &uri, &args, &local_param, &baseUri); - if (!uri) { - uri = &uri_sub; - ZEPHIR_CPY_WRT(uri, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(uri); - } - if (!args) { - args = &args_sub; - args = &__$null; + zephir_fetch_params(1, 3, 0, &intermediate_param, &bindParams_param, &bindTypes_param); + zephir_get_arrval(&intermediate, intermediate_param); + zephir_get_arrval(&bindParams, bindParams_param); + zephir_get_arrval(&bindTypes, bindTypes_param); + zephir_memory_observe(&models); + zephir_array_fetch_string(&models, &intermediate, SL("models"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1368); + if (UNEXPECTED(zephir_array_isset_long(&models, 1))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Updating several models at the same time is still not supported", "phalcon/Mvc/Model/Query.zep", 1373); + return; } - if (!local_param) { - local = 0; - } else { - } - if (!baseUri) { - baseUri = &baseUri_sub; - ZEPHIR_CPY_WRT(baseUri, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(baseUri); + zephir_memory_observe(&modelName); + zephir_array_fetch_long(&modelName, &models, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1376); + zephir_memory_observe(&model); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&model, &_0, &modelName, 0))) { + zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&model, &_1$$4, "load", NULL, 0, &modelName); + zephir_check_call_status(); } - if (local == 0) { - _0$$3 = Z_TYPE_P(uri) == IS_STRING; - if (_0$$3) { - _1$$3 = zephir_memnstr_str(uri, SL("//"), "phalcon/Mvc/Url.zep", 107); - if (!(_1$$3)) { - _1$$3 = zephir_memnstr_str(uri, SL(":"), "phalcon/Mvc/Url.zep", 107); + ZEPHIR_CALL_METHOD(&connection, this_ptr, "getwriteconnection", NULL, 0, &model, &intermediate, &bindParams, &bindTypes); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&dialect, &connection, "getdialect", NULL, 0); + zephir_check_call_status(); + zephir_memory_observe(&fields); + zephir_array_fetch_string(&fields, &intermediate, SL("fields"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1395); + zephir_memory_observe(&values); + zephir_array_fetch_string(&values, &intermediate, SL("values"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1396); + ZEPHIR_INIT_VAR(&updateValues); + array_init(&updateValues); + ZEPHIR_CPY_WRT(&selectBindParams, &bindParams); + ZEPHIR_CPY_WRT(&selectBindTypes, &bindTypes); + zephir_is_iterable(&fields, 0, "phalcon/Mvc/Model/Query.zep", 1468); + if (Z_TYPE_P(&fields) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&fields), _4, _5, _2) + { + ZEPHIR_INIT_NVAR(&number); + if (_5 != NULL) { + ZVAL_STR_COPY(&number, _5); + } else { + ZVAL_LONG(&number, _4); } - _0$$3 = _1$$3; - } - if (_0$$3) { - ZEPHIR_INIT_VAR(&_2$$4); - ZEPHIR_INIT_VAR(&_3$$4); - ZVAL_STRING(&_3$$4, "#^((//)|([a-z0-9]+://)|([a-z0-9]+:))#i"); - ZEPHIR_INIT_VAR(&_4$$4); - ZEPHIR_INIT_VAR(&_5$$4); - ZVAL_STRING(&_5$$4, "#^((//)|([a-z0-9]+://)|([a-z0-9]+:))#i"); - zephir_preg_match(&_4$$4, &_5$$4, uri, &_2$$4, 0, 0 , 0 ); - if (zephir_is_true(&_4$$4)) { - local = 0; + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _2); + ZEPHIR_OBS_NVAR(&value); + zephir_array_fetch(&value, &values, &number, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1411); + ZEPHIR_OBS_NVAR(&exprValue); + zephir_array_fetch_string(&exprValue, &value, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1412); + if (zephir_array_isset_string(&field, SL("balias"))) { + ZEPHIR_OBS_NVAR(&fieldName); + zephir_array_fetch_string(&fieldName, &field, SL("balias"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1415); } else { - local = 1; + ZEPHIR_OBS_NVAR(&fieldName); + zephir_array_fetch_string(&fieldName, &field, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1417); } - } else { - local = 1; - } - } - if (Z_TYPE_P(baseUri) != IS_STRING) { - ZEPHIR_CALL_METHOD(baseUri, this_ptr, "getbaseuri", NULL, 0); + zephir_array_fetch_string(&_6$$5, &value, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1420); + do { + if (ZEPHIR_IS_LONG(&_6$$5, 260) || ZEPHIR_IS_LONG(&_6$$5, 258) || ZEPHIR_IS_LONG(&_6$$5, 259)) { + ZEPHIR_CALL_METHOD(&updateValue, &dialect, "getsqlexpression", &_7, 0, &exprValue); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_LONG(&_6$$5, 322)) { + ZEPHIR_INIT_NVAR(&updateValue); + ZVAL_NULL(&updateValue); + break; + } + if (ZEPHIR_IS_LONG(&_6$$5, 273) || ZEPHIR_IS_LONG(&_6$$5, 274) || ZEPHIR_IS_LONG(&_6$$5, 277)) { + ZEPHIR_CALL_METHOD(&_8$$10, &dialect, "getsqlexpression", &_9, 0, &exprValue); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_10$$10); + ZVAL_STRING(&_10$$10, ":"); + ZEPHIR_INIT_NVAR(&_11$$10); + ZVAL_STRING(&_11$$10, ""); + ZEPHIR_INIT_NVAR(&wildcard); + zephir_fast_str_replace(&wildcard, &_10$$10, &_11$$10, &_8$$10); + ZEPHIR_OBS_NVAR(&updateValue); + if (UNEXPECTED(!(zephir_array_isset_fetch(&updateValue, &bindParams, &wildcard, 0)))) { + ZEPHIR_INIT_NVAR(&_12$$11); + object_init_ex(&_12$$11, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_13$$11); + ZEPHIR_CONCAT_SVS(&_13$$11, "Bound parameter '", &wildcard, "' cannot be replaced because it's not in the placeholders list"); + ZEPHIR_CALL_METHOD(NULL, &_12$$11, "__construct", &_14, 33, &_13$$11); + zephir_check_call_status(); + zephir_throw_exception_debug(&_12$$11, "phalcon/Mvc/Model/Query.zep", 1443); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_array_unset(&selectBindParams, &wildcard, PH_SEPARATE); + zephir_array_unset(&selectBindTypes, &wildcard, PH_SEPARATE); + break; + } + if (ZEPHIR_IS_LONG(&_6$$5, 277)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Not supported", "phalcon/Mvc/Model/Query.zep", 1452); + return; + } + ZEPHIR_INIT_NVAR(&updateValue); + object_init_ex(&updateValue, phalcon_db_rawvalue_ce); + ZEPHIR_CALL_METHOD(&_15$$13, &dialect, "getsqlexpression", &_16, 0, &exprValue); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &updateValue, "__construct", &_17, 36, &_15$$13); + zephir_check_call_status(); + break; + } while(0); + + zephir_array_update_zval(&updateValues, &fieldName, &updateValue, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); zephir_check_call_status(); - } - if (Z_TYPE_P(uri) == IS_ARRAY) { - zephir_memory_observe(&routeName); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&routeName, uri, SL("for"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "It's necessary to define the route name with the parameter 'for'", "phalcon/Mvc/Url.zep", 126); - return; - } - zephir_read_property(&_6$$9, this_ptr, ZEND_STRL("router"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&router, &_6$$9); - if (UNEXPECTED(!zephir_is_true(&router))) { - zephir_read_property(&_7$$11, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_7$$11); - if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "A dependency injection container is required to access the 'router' service", "phalcon/Mvc/Url.zep", 140); - return; - } - ZEPHIR_INIT_VAR(&_9$$11); - ZVAL_STRING(&_9$$11, "router"); - ZEPHIR_CALL_METHOD(&_8$$11, &container, "has", NULL, 0, &_9$$11); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &fields, "valid", NULL, 0); zephir_check_call_status(); - if (UNEXPECTED(!zephir_is_true(&_8$$11))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_url_exception_ce, "A dependency injection container is required to access the 'router' service", "phalcon/Mvc/Url.zep", 146); - return; + if (!zend_is_true(&_3)) { + break; } - ZEPHIR_INIT_NVAR(&_9$$11); - ZVAL_STRING(&_9$$11, "router"); - ZEPHIR_CALL_METHOD(&_10$$11, &container, "getshared", NULL, 0, &_9$$11); + ZEPHIR_CALL_METHOD(&number, &fields, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CPY_WRT(&router, &_10$$11); - zephir_update_property_zval(this_ptr, ZEND_STRL("router"), &router); - } - ZEPHIR_CALL_METHOD(&_11$$9, &router, "getroutebyname", NULL, 0, &routeName); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&route, &_11$$9); - if (UNEXPECTED(Z_TYPE_P(&route) != IS_OBJECT)) { - ZEPHIR_INIT_VAR(&_12$$14); - object_init_ex(&_12$$14, phalcon_mvc_url_exception_ce); - ZEPHIR_INIT_VAR(&_13$$14); - ZEPHIR_CONCAT_SVS(&_13$$14, "Cannot obtain a route using the name '", &routeName, "'"); - ZEPHIR_CALL_METHOD(NULL, &_12$$14, "__construct", NULL, 33, &_13$$14); + ZEPHIR_CALL_METHOD(&field, &fields, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&value); + zephir_array_fetch(&value, &values, &number, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1411); + ZEPHIR_OBS_NVAR(&exprValue); + zephir_array_fetch_string(&exprValue, &value, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1412); + if (zephir_array_isset_string(&field, SL("balias"))) { + ZEPHIR_OBS_NVAR(&fieldName); + zephir_array_fetch_string(&fieldName, &field, SL("balias"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1415); + } else { + ZEPHIR_OBS_NVAR(&fieldName); + zephir_array_fetch_string(&fieldName, &field, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1417); + } + zephir_array_fetch_string(&_18$$14, &value, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1420); + do { + if (ZEPHIR_IS_LONG(&_18$$14, 260) || ZEPHIR_IS_LONG(&_18$$14, 258) || ZEPHIR_IS_LONG(&_18$$14, 259)) { + ZEPHIR_CALL_METHOD(&updateValue, &dialect, "getsqlexpression", &_19, 0, &exprValue); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_LONG(&_18$$14, 322)) { + ZEPHIR_INIT_NVAR(&updateValue); + ZVAL_NULL(&updateValue); + break; + } + if (ZEPHIR_IS_LONG(&_18$$14, 273) || ZEPHIR_IS_LONG(&_18$$14, 274) || ZEPHIR_IS_LONG(&_18$$14, 277)) { + ZEPHIR_CALL_METHOD(&_20$$19, &dialect, "getsqlexpression", &_21, 0, &exprValue); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_22$$19); + ZVAL_STRING(&_22$$19, ":"); + ZEPHIR_INIT_NVAR(&_23$$19); + ZVAL_STRING(&_23$$19, ""); + ZEPHIR_INIT_NVAR(&wildcard); + zephir_fast_str_replace(&wildcard, &_22$$19, &_23$$19, &_20$$19); + ZEPHIR_OBS_NVAR(&updateValue); + if (UNEXPECTED(!(zephir_array_isset_fetch(&updateValue, &bindParams, &wildcard, 0)))) { + ZEPHIR_INIT_NVAR(&_24$$20); + object_init_ex(&_24$$20, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_25$$20); + ZEPHIR_CONCAT_SVS(&_25$$20, "Bound parameter '", &wildcard, "' cannot be replaced because it's not in the placeholders list"); + ZEPHIR_CALL_METHOD(NULL, &_24$$20, "__construct", &_14, 33, &_25$$20); + zephir_check_call_status(); + zephir_throw_exception_debug(&_24$$20, "phalcon/Mvc/Model/Query.zep", 1443); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_array_unset(&selectBindParams, &wildcard, PH_SEPARATE); + zephir_array_unset(&selectBindTypes, &wildcard, PH_SEPARATE); + break; + } + if (ZEPHIR_IS_LONG(&_18$$14, 277)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Not supported", "phalcon/Mvc/Model/Query.zep", 1452); + return; + } + ZEPHIR_INIT_NVAR(&updateValue); + object_init_ex(&updateValue, phalcon_db_rawvalue_ce); + ZEPHIR_CALL_METHOD(&_26$$22, &dialect, "getsqlexpression", &_27, 0, &exprValue); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &updateValue, "__construct", &_17, 36, &_26$$22); + zephir_check_call_status(); + break; + } while(0); + + zephir_array_update_zval(&updateValues, &fieldName, &updateValue, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); zephir_check_call_status(); - zephir_throw_exception_debug(&_12$$14, "phalcon/Mvc/Url.zep", 161); - ZEPHIR_MM_RESTORE(); - return; } - ZEPHIR_INIT_VAR(&_14$$9); - ZEPHIR_CALL_METHOD(&_11$$9, &route, "getpattern", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_15$$9, &route, "getreversedpaths", NULL, 0); - zephir_check_call_status(); - phalcon_replace_paths(&_14$$9, &_11$$9, &_15$$9, uri); - ZEPHIR_CPY_WRT(uri, &_14$$9); } - if (local) { - zephir_cast_to_string(&_16$$15, uri); - ZEPHIR_CPY_WRT(&strUri, &_16$$15); - ZEPHIR_INIT_VAR(&_17$$15); - ZEPHIR_CONCAT_VV(&_17$$15, baseUri, &strUri); - ZEPHIR_INIT_VAR(&_18$$15); - ZVAL_STRING(&_18$$15, "#(?create_object = zephir_init_properties_Phalcon_Mvc_View; - zephir_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_ACTION_VIEW"), 1); - - zephir_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_BEFORE_TEMPLATE"), 2); - - zephir_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_LAYOUT"), 3); - - zephir_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_MAIN_LAYOUT"), 5); - - zephir_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_NO_RENDER"), 0); + } + ZEPHIR_INIT_VAR(&left); + ZVAL_NULL(&left); + ZEPHIR_INIT_VAR(&right); + ZVAL_NULL(&right); + zephir_memory_observe(&exprType); + if (zephir_array_isset_string_fetch(&exprType, &expr, SL("type"), 0)) { + tempNotQuoting = 1; + if (!ZEPHIR_IS_LONG(&exprType, 409)) { + zephir_memory_observe(&exprLeft); + if (zephir_array_isset_string_fetch(&exprLeft, &expr, SL("left"), 0)) { + if (tempNotQuoting) { + ZVAL_BOOL(&_0$$5, 1); + } else { + ZVAL_BOOL(&_0$$5, 0); + } + ZEPHIR_CALL_METHOD(&left, this_ptr, "getexpression", NULL, 458, &exprLeft, &_0$$5); + zephir_check_call_status(); + } + zephir_memory_observe(&exprRight); + if (zephir_array_isset_string_fetch(&exprRight, &expr, SL("right"), 0)) { + if (tempNotQuoting) { + ZVAL_BOOL(&_1$$6, 1); + } else { + ZVAL_BOOL(&_1$$6, 0); + } + ZEPHIR_CALL_METHOD(&right, this_ptr, "getexpression", NULL, 458, &exprRight, &_1$$6); + zephir_check_call_status(); + } + } + do { + if (ZEPHIR_IS_LONG(&exprType, '<')) { + ZEPHIR_INIT_VAR(&exprReturn); + zephir_create_array(&exprReturn, 4, 0); + add_assoc_stringl_ex(&exprReturn, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&exprReturn, SL("op"), SL("<")); + zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); + break; + } + if (ZEPHIR_IS_LONG(&exprType, '=')) { + ZEPHIR_INIT_VAR(&_2$$8); + zephir_create_array(&_2$$8, 4, 0); + add_assoc_stringl_ex(&_2$$8, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_2$$8, SL("op"), SL("=")); + zephir_array_update_string(&_2$$8, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_2$$8, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_2$$8); + break; + } + if (ZEPHIR_IS_LONG(&exprType, '>')) { + ZEPHIR_INIT_VAR(&_3$$9); + zephir_create_array(&_3$$9, 4, 0); + add_assoc_stringl_ex(&_3$$9, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_3$$9, SL("op"), SL(">")); + zephir_array_update_string(&_3$$9, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_3$$9, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_3$$9); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 270)) { + ZEPHIR_INIT_VAR(&_4$$10); + zephir_create_array(&_4$$10, 4, 0); + add_assoc_stringl_ex(&_4$$10, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_4$$10, SL("op"), SL("<>")); + zephir_array_update_string(&_4$$10, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_4$$10, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_4$$10); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 271)) { + ZEPHIR_INIT_VAR(&_5$$11); + zephir_create_array(&_5$$11, 4, 0); + add_assoc_stringl_ex(&_5$$11, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_5$$11, SL("op"), SL("<=")); + zephir_array_update_string(&_5$$11, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_5$$11, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_5$$11); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 272)) { + ZEPHIR_INIT_VAR(&_6$$12); + zephir_create_array(&_6$$12, 4, 0); + add_assoc_stringl_ex(&_6$$12, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_6$$12, SL("op"), SL(">=")); + zephir_array_update_string(&_6$$12, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_6$$12, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_6$$12); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 266)) { + ZEPHIR_INIT_VAR(&_7$$13); + zephir_create_array(&_7$$13, 4, 0); + add_assoc_stringl_ex(&_7$$13, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_7$$13, SL("op"), SL("AND")); + zephir_array_update_string(&_7$$13, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_7$$13, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_7$$13); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 267)) { + ZEPHIR_INIT_VAR(&_8$$14); + zephir_create_array(&_8$$14, 4, 0); + add_assoc_stringl_ex(&_8$$14, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_8$$14, SL("op"), SL("OR")); + zephir_array_update_string(&_8$$14, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_8$$14, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_8$$14); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 355)) { + ZEPHIR_CALL_METHOD(&exprReturn, this_ptr, "getqualified", NULL, 459, &expr); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_LONG(&exprType, '+')) { + ZEPHIR_INIT_VAR(&_9$$16); + zephir_create_array(&_9$$16, 4, 0); + add_assoc_stringl_ex(&_9$$16, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_9$$16, SL("op"), SL("+")); + zephir_array_update_string(&_9$$16, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_9$$16, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_9$$16); + break; + } + if (ZEPHIR_IS_LONG(&exprType, '-')) { + ZEPHIR_INIT_VAR(&_10$$17); + zephir_create_array(&_10$$17, 4, 0); + add_assoc_stringl_ex(&_10$$17, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_10$$17, SL("op"), SL("-")); + zephir_array_update_string(&_10$$17, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_10$$17, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_10$$17); + break; + } + if (ZEPHIR_IS_LONG(&exprType, '*')) { + ZEPHIR_INIT_VAR(&_11$$18); + zephir_create_array(&_11$$18, 4, 0); + add_assoc_stringl_ex(&_11$$18, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_11$$18, SL("op"), SL("*")); + zephir_array_update_string(&_11$$18, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_11$$18, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_11$$18); + break; + } + if (ZEPHIR_IS_LONG(&exprType, '/')) { + ZEPHIR_INIT_VAR(&_12$$19); + zephir_create_array(&_12$$19, 4, 0); + add_assoc_stringl_ex(&_12$$19, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_12$$19, SL("op"), SL("/")); + zephir_array_update_string(&_12$$19, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_12$$19, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_12$$19); + break; + } + if (ZEPHIR_IS_LONG(&exprType, '%')) { + ZEPHIR_INIT_VAR(&_13$$20); + zephir_create_array(&_13$$20, 4, 0); + add_assoc_stringl_ex(&_13$$20, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_13$$20, SL("op"), SL("%")); + zephir_array_update_string(&_13$$20, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_13$$20, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_13$$20); + break; + } + if (ZEPHIR_IS_LONG(&exprType, '&')) { + ZEPHIR_INIT_VAR(&_14$$21); + zephir_create_array(&_14$$21, 4, 0); + add_assoc_stringl_ex(&_14$$21, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_14$$21, SL("op"), SL("&")); + zephir_array_update_string(&_14$$21, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_14$$21, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_14$$21); + break; + } + if (ZEPHIR_IS_LONG(&exprType, '|')) { + ZEPHIR_INIT_VAR(&_15$$22); + zephir_create_array(&_15$$22, 4, 0); + add_assoc_stringl_ex(&_15$$22, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_15$$22, SL("op"), SL("|")); + zephir_array_update_string(&_15$$22, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_15$$22, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_15$$22); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 356) || ZEPHIR_IS_LONG(&exprType, 407)) { + ZEPHIR_INIT_VAR(&_16$$23); + zephir_create_array(&_16$$23, 2, 0); + add_assoc_stringl_ex(&_16$$23, SL("type"), SL("parentheses")); + zephir_array_update_string(&_16$$23, SL("left"), &left, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_16$$23); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 367)) { + ZEPHIR_INIT_VAR(&_17$$24); + zephir_create_array(&_17$$24, 3, 0); + add_assoc_stringl_ex(&_17$$24, SL("type"), SL("unary-op")); + add_assoc_stringl_ex(&_17$$24, SL("op"), SL("-")); + zephir_array_update_string(&_17$$24, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_17$$24); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 258) || ZEPHIR_IS_LONG(&exprType, 259) || ZEPHIR_IS_LONG(&exprType, 414)) { + ZEPHIR_INIT_VAR(&_18$$25); + zephir_create_array(&_18$$25, 2, 0); + add_assoc_stringl_ex(&_18$$25, SL("type"), SL("literal")); + zephir_memory_observe(&_19$$25); + zephir_array_fetch_string(&_19$$25, &expr, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1786); + zephir_array_update_string(&_18$$25, SL("value"), &_19$$25, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_18$$25); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 334)) { + ZEPHIR_INIT_VAR(&_20$$26); + zephir_create_array(&_20$$26, 2, 0); + add_assoc_stringl_ex(&_20$$26, SL("type"), SL("literal")); + add_assoc_stringl_ex(&_20$$26, SL("value"), SL("TRUE")); + ZEPHIR_CPY_WRT(&exprReturn, &_20$$26); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 335)) { + ZEPHIR_INIT_VAR(&_21$$27); + zephir_create_array(&_21$$27, 2, 0); + add_assoc_stringl_ex(&_21$$27, SL("type"), SL("literal")); + add_assoc_stringl_ex(&_21$$27, SL("value"), SL("FALSE")); + ZEPHIR_CPY_WRT(&exprReturn, &_21$$27); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 260)) { + zephir_memory_observe(&value); + zephir_array_fetch_string(&value, &expr, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1807); + if (quoting) { + if (zephir_memnstr_str(&value, SL("'"), "phalcon/Mvc/Model/Query.zep", 1814)) { + ZEPHIR_INIT_VAR(&escapedValue); + phalcon_orm_singlequotes(&escapedValue, &value); + } else { + ZEPHIR_CPY_WRT(&escapedValue, &value); + } + ZEPHIR_INIT_VAR(&exprValue); + ZEPHIR_CONCAT_SVS(&exprValue, "'", &escapedValue, "'"); + } else { + ZEPHIR_CPY_WRT(&exprValue, &value); + } + ZEPHIR_INIT_VAR(&_22$$28); + zephir_create_array(&_22$$28, 2, 0); + add_assoc_stringl_ex(&_22$$28, SL("type"), SL("literal")); + zephir_array_update_string(&_22$$28, SL("value"), &exprValue, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_22$$28); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 273)) { + ZEPHIR_INIT_VAR(&_23$$33); + zephir_create_array(&_23$$33, 2, 0); + add_assoc_stringl_ex(&_23$$33, SL("type"), SL("placeholder")); + ZEPHIR_INIT_VAR(&_24$$33); + zephir_array_fetch_string(&_25$$33, &expr, SL("value"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1835); + ZEPHIR_INIT_VAR(&_26$$33); + ZVAL_STRING(&_26$$33, "?"); + ZEPHIR_INIT_VAR(&_27$$33); + ZVAL_STRING(&_27$$33, ":"); + zephir_fast_str_replace(&_24$$33, &_26$$33, &_27$$33, &_25$$33); + zephir_array_update_string(&_23$$33, SL("value"), &_24$$33, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_23$$33); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 274)) { + ZEPHIR_INIT_VAR(&_28$$34); + zephir_create_array(&_28$$34, 2, 0); + add_assoc_stringl_ex(&_28$$34, SL("type"), SL("placeholder")); + zephir_array_fetch_string(&_29$$34, &expr, SL("value"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1844); + ZEPHIR_INIT_VAR(&_30$$34); + ZEPHIR_CONCAT_SV(&_30$$34, ":", &_29$$34); + zephir_array_update_string(&_28$$34, SL("value"), &_30$$34, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_28$$34); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 277)) { + ZEPHIR_OBS_NVAR(&value); + zephir_array_fetch_string(&value, &expr, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1849); + if (zephir_memnstr_str(&value, SL(":"), "phalcon/Mvc/Model/Query.zep", 1851)) { + ZEPHIR_INIT_VAR(&valueParts); + zephir_fast_explode_str(&valueParts, SL(":"), &value, LONG_MAX); + zephir_memory_observe(&name); + zephir_array_fetch_long(&name, &valueParts, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1853); + zephir_memory_observe(&bindType); + zephir_array_fetch_long(&bindType, &valueParts, 1, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1854); + do { + if (ZEPHIR_IS_STRING(&bindType, "str")) { + ZEPHIR_INIT_VAR(&_31$$37); + ZVAL_LONG(&_31$$37, 2); + zephir_update_property_array(this_ptr, SL("bindTypes"), &name, &_31$$37); + ZEPHIR_INIT_VAR(&_32$$37); + zephir_create_array(&_32$$37, 2, 0); + add_assoc_stringl_ex(&_32$$37, SL("type"), SL("placeholder")); + ZEPHIR_INIT_VAR(&_33$$37); + ZEPHIR_CONCAT_SV(&_33$$37, ":", &name); + zephir_array_update_string(&_32$$37, SL("value"), &_33$$37, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_32$$37); + break; + } + if (ZEPHIR_IS_STRING(&bindType, "int")) { + ZEPHIR_INIT_VAR(&_34$$38); + ZVAL_LONG(&_34$$38, 1); + zephir_update_property_array(this_ptr, SL("bindTypes"), &name, &_34$$38); + ZEPHIR_INIT_VAR(&_35$$38); + zephir_create_array(&_35$$38, 2, 0); + add_assoc_stringl_ex(&_35$$38, SL("type"), SL("placeholder")); + ZEPHIR_INIT_VAR(&_36$$38); + ZEPHIR_CONCAT_SV(&_36$$38, ":", &name); + zephir_array_update_string(&_35$$38, SL("value"), &_36$$38, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_35$$38); + break; + } + if (ZEPHIR_IS_STRING(&bindType, "double")) { + ZEPHIR_INIT_VAR(&_37$$39); + ZVAL_LONG(&_37$$39, 32); + zephir_update_property_array(this_ptr, SL("bindTypes"), &name, &_37$$39); + ZEPHIR_INIT_VAR(&_38$$39); + zephir_create_array(&_38$$39, 2, 0); + add_assoc_stringl_ex(&_38$$39, SL("type"), SL("placeholder")); + ZEPHIR_INIT_VAR(&_39$$39); + ZEPHIR_CONCAT_SV(&_39$$39, ":", &name); + zephir_array_update_string(&_38$$39, SL("value"), &_39$$39, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_38$$39); + break; + } + if (ZEPHIR_IS_STRING(&bindType, "bool")) { + ZEPHIR_INIT_VAR(&_40$$40); + ZVAL_LONG(&_40$$40, 5); + zephir_update_property_array(this_ptr, SL("bindTypes"), &name, &_40$$40); + ZEPHIR_INIT_VAR(&_41$$40); + zephir_create_array(&_41$$40, 2, 0); + add_assoc_stringl_ex(&_41$$40, SL("type"), SL("placeholder")); + ZEPHIR_INIT_VAR(&_42$$40); + ZEPHIR_CONCAT_SV(&_42$$40, ":", &name); + zephir_array_update_string(&_41$$40, SL("value"), &_42$$40, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_41$$40); + break; + } + if (ZEPHIR_IS_STRING(&bindType, "blob")) { + ZEPHIR_INIT_VAR(&_43$$41); + ZVAL_LONG(&_43$$41, 3); + zephir_update_property_array(this_ptr, SL("bindTypes"), &name, &_43$$41); + ZEPHIR_INIT_VAR(&_44$$41); + zephir_create_array(&_44$$41, 2, 0); + add_assoc_stringl_ex(&_44$$41, SL("type"), SL("placeholder")); + ZEPHIR_INIT_VAR(&_45$$41); + ZEPHIR_CONCAT_SV(&_45$$41, ":", &name); + zephir_array_update_string(&_44$$41, SL("value"), &_45$$41, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_44$$41); + break; + } + if (ZEPHIR_IS_STRING(&bindType, "null")) { + ZEPHIR_INIT_VAR(&_46$$42); + ZVAL_LONG(&_46$$42, 0); + zephir_update_property_array(this_ptr, SL("bindTypes"), &name, &_46$$42); + ZEPHIR_INIT_VAR(&_47$$42); + zephir_create_array(&_47$$42, 2, 0); + add_assoc_stringl_ex(&_47$$42, SL("type"), SL("placeholder")); + ZEPHIR_INIT_VAR(&_48$$42); + ZEPHIR_CONCAT_SV(&_48$$42, ":", &name); + zephir_array_update_string(&_47$$42, SL("value"), &_48$$42, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_47$$42); + break; + } + if (ZEPHIR_IS_STRING(&bindType, "array") || ZEPHIR_IS_STRING(&bindType, "array-str") || ZEPHIR_IS_STRING(&bindType, "array-int")) { + zephir_memory_observe(&bind); + zephir_read_property(&_49$$43, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(!(zephir_array_isset_fetch(&bind, &_49$$43, &name, 0)))) { + ZEPHIR_INIT_VAR(&_50$$44); + object_init_ex(&_50$$44, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_51$$44); + ZEPHIR_CONCAT_SV(&_51$$44, "Bind value is required for array type placeholder: ", &name); + ZEPHIR_CALL_METHOD(NULL, &_50$$44, "__construct", NULL, 33, &_51$$44); + zephir_check_call_status(); + zephir_throw_exception_debug(&_50$$44, "phalcon/Mvc/Model/Query.zep", 1924); + ZEPHIR_MM_RESTORE(); + return; + } + if (UNEXPECTED(Z_TYPE_P(&bind) != IS_ARRAY)) { + ZEPHIR_INIT_VAR(&_52$$45); + object_init_ex(&_52$$45, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_53$$45); + ZEPHIR_CONCAT_SV(&_53$$45, "Bind type requires an array in placeholder: ", &name); + ZEPHIR_CALL_METHOD(NULL, &_52$$45, "__construct", NULL, 33, &_53$$45); + zephir_check_call_status(); + zephir_throw_exception_debug(&_52$$45, "phalcon/Mvc/Model/Query.zep", 1930); + ZEPHIR_MM_RESTORE(); + return; + } + if (UNEXPECTED(zephir_fast_count_int(&bind) < 1)) { + ZEPHIR_INIT_VAR(&_54$$46); + object_init_ex(&_54$$46, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_55$$46); + ZEPHIR_CONCAT_SV(&_55$$46, "At least one value must be bound in placeholder: ", &name); + ZEPHIR_CALL_METHOD(NULL, &_54$$46, "__construct", NULL, 33, &_55$$46); + zephir_check_call_status(); + zephir_throw_exception_debug(&_54$$46, "phalcon/Mvc/Model/Query.zep", 1936); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_VAR(&_56$$43); + zephir_create_array(&_56$$43, 4, 0); + add_assoc_stringl_ex(&_56$$43, SL("type"), SL("placeholder")); + ZEPHIR_INIT_VAR(&_57$$43); + ZEPHIR_CONCAT_SV(&_57$$43, ":", &name); + zephir_array_update_string(&_56$$43, SL("value"), &_57$$43, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_56$$43, SL("rawValue"), &name, PH_COPY | PH_SEPARATE); + add_assoc_long_ex(&_56$$43, SL("times"), zephir_fast_count_int(&bind)); + ZEPHIR_CPY_WRT(&exprReturn, &_56$$43); + break; + } + ZEPHIR_INIT_VAR(&_58$$47); + object_init_ex(&_58$$47, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_59$$47); + ZEPHIR_CONCAT_SV(&_59$$47, "Unknown bind type: ", &bindType); + ZEPHIR_CALL_METHOD(NULL, &_58$$47, "__construct", NULL, 33, &_59$$47); + zephir_check_call_status(); + zephir_throw_exception_debug(&_58$$47, "phalcon/Mvc/Model/Query.zep", 1951); + ZEPHIR_MM_RESTORE(); + return; + } while(0); - zephir_declare_class_constant_long(phalcon_mvc_view_ce, SL("LEVEL_AFTER_TEMPLATE"), 4); + } else { + ZEPHIR_INIT_VAR(&_60$$48); + zephir_create_array(&_60$$48, 2, 0); + add_assoc_stringl_ex(&_60$$48, SL("type"), SL("placeholder")); + ZEPHIR_INIT_VAR(&_61$$48); + ZEPHIR_CONCAT_SV(&_61$$48, ":", &value); + zephir_array_update_string(&_60$$48, SL("value"), &_61$$48, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_60$$48); + } + break; + } + if (ZEPHIR_IS_LONG(&exprType, 322)) { + ZEPHIR_INIT_VAR(&_62$$49); + zephir_create_array(&_62$$49, 2, 0); + add_assoc_stringl_ex(&_62$$49, SL("type"), SL("literal")); + add_assoc_stringl_ex(&_62$$49, SL("value"), SL("NULL")); + ZEPHIR_CPY_WRT(&exprReturn, &_62$$49); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 268)) { + ZEPHIR_INIT_VAR(&_63$$50); + zephir_create_array(&_63$$50, 4, 0); + add_assoc_stringl_ex(&_63$$50, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_63$$50, SL("op"), SL("LIKE")); + zephir_array_update_string(&_63$$50, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_63$$50, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_63$$50); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 351)) { + ZEPHIR_INIT_VAR(&_64$$51); + zephir_create_array(&_64$$51, 4, 0); + add_assoc_stringl_ex(&_64$$51, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_64$$51, SL("op"), SL("NOT LIKE")); + zephir_array_update_string(&_64$$51, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_64$$51, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_64$$51); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 275)) { + ZEPHIR_INIT_VAR(&_65$$52); + zephir_create_array(&_65$$52, 4, 0); + add_assoc_stringl_ex(&_65$$52, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_65$$52, SL("op"), SL("ILIKE")); + zephir_array_update_string(&_65$$52, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_65$$52, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_65$$52); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 357)) { + ZEPHIR_INIT_VAR(&_66$$53); + zephir_create_array(&_66$$53, 4, 0); + add_assoc_stringl_ex(&_66$$53, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_66$$53, SL("op"), SL("NOT ILIKE")); + zephir_array_update_string(&_66$$53, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_66$$53, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_66$$53); + break; + } + if (ZEPHIR_IS_LONG(&exprType, '!')) { + ZEPHIR_INIT_VAR(&_67$$54); + zephir_create_array(&_67$$54, 3, 0); + add_assoc_stringl_ex(&_67$$54, SL("type"), SL("unary-op")); + add_assoc_stringl_ex(&_67$$54, SL("op"), SL("NOT ")); + zephir_array_update_string(&_67$$54, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_67$$54); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 365)) { + ZEPHIR_INIT_VAR(&_68$$55); + zephir_create_array(&_68$$55, 3, 0); + add_assoc_stringl_ex(&_68$$55, SL("type"), SL("unary-op")); + add_assoc_stringl_ex(&_68$$55, SL("op"), SL(" IS NULL")); + zephir_array_update_string(&_68$$55, SL("left"), &left, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_68$$55); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 366)) { + ZEPHIR_INIT_VAR(&_69$$56); + zephir_create_array(&_69$$56, 3, 0); + add_assoc_stringl_ex(&_69$$56, SL("type"), SL("unary-op")); + add_assoc_stringl_ex(&_69$$56, SL("op"), SL(" IS NOT NULL")); + zephir_array_update_string(&_69$$56, SL("left"), &left, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_69$$56); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 315)) { + ZEPHIR_INIT_VAR(&_70$$57); + zephir_create_array(&_70$$57, 4, 0); + add_assoc_stringl_ex(&_70$$57, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_70$$57, SL("op"), SL("IN")); + zephir_array_update_string(&_70$$57, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_70$$57, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_70$$57); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 323)) { + ZEPHIR_INIT_VAR(&_71$$58); + zephir_create_array(&_71$$58, 4, 0); + add_assoc_stringl_ex(&_71$$58, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_71$$58, SL("op"), SL("NOT IN")); + zephir_array_update_string(&_71$$58, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_71$$58, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_71$$58); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 408)) { + ZEPHIR_INIT_VAR(&_72$$59); + zephir_create_array(&_72$$59, 3, 0); + add_assoc_stringl_ex(&_72$$59, SL("type"), SL("unary-op")); + add_assoc_stringl_ex(&_72$$59, SL("op"), SL("EXISTS")); + zephir_array_update_string(&_72$$59, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_72$$59); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 330)) { + ZEPHIR_INIT_VAR(&_73$$60); + zephir_create_array(&_73$$60, 3, 0); + add_assoc_stringl_ex(&_73$$60, SL("type"), SL("unary-op")); + add_assoc_stringl_ex(&_73$$60, SL("op"), SL("DISTINCT ")); + zephir_array_update_string(&_73$$60, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_73$$60); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 332)) { + ZEPHIR_INIT_VAR(&_74$$61); + zephir_create_array(&_74$$61, 4, 0); + add_assoc_stringl_ex(&_74$$61, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_74$$61, SL("op"), SL("BETWEEN NOT")); + zephir_array_update_string(&_74$$61, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_74$$61, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_74$$61); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 331)) { + ZEPHIR_INIT_VAR(&_75$$62); + zephir_create_array(&_75$$62, 4, 0); + add_assoc_stringl_ex(&_75$$62, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_75$$62, SL("op"), SL("BETWEEN")); + zephir_array_update_string(&_75$$62, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_75$$62, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_75$$62); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 276)) { + ZEPHIR_INIT_VAR(&_76$$63); + zephir_create_array(&_76$$63, 4, 0); + add_assoc_stringl_ex(&_76$$63, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_76$$63, SL("op"), SL("AGAINST")); + zephir_array_update_string(&_76$$63, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_76$$63, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_76$$63); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 333)) { + ZEPHIR_INIT_VAR(&_77$$64); + zephir_create_array(&_77$$64, 3, 0); + add_assoc_stringl_ex(&_77$$64, SL("type"), SL("cast")); + zephir_array_update_string(&_77$$64, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_77$$64, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_77$$64); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 336)) { + ZEPHIR_INIT_VAR(&_78$$65); + zephir_create_array(&_78$$65, 3, 0); + add_assoc_stringl_ex(&_78$$65, SL("type"), SL("convert")); + zephir_array_update_string(&_78$$65, SL("left"), &left, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_78$$65, SL("right"), &right, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_78$$65); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 358)) { + ZEPHIR_INIT_VAR(&_79$$66); + zephir_create_array(&_79$$66, 2, 0); + add_assoc_stringl_ex(&_79$$66, SL("type"), SL("literal")); + zephir_memory_observe(&_80$$66); + zephir_array_fetch_string(&_80$$66, &expr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2127); + zephir_array_update_string(&_79$$66, SL("value"), &_80$$66, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_79$$66); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 350)) { + ZEPHIR_CALL_METHOD(&exprReturn, this_ptr, "getfunctioncall", NULL, 460, &expr); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 409)) { + ZEPHIR_CALL_METHOD(&exprReturn, this_ptr, "getcaseexpression", NULL, 461, &expr); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_LONG(&exprType, 309)) { + ZEPHIR_INIT_VAR(&_81$$69); + zephir_create_array(&_81$$69, 2, 0); + add_assoc_stringl_ex(&_81$$69, SL("type"), SL("select")); + ZVAL_BOOL(&_83$$69, 1); + ZEPHIR_CALL_METHOD(&_82$$69, this_ptr, "_prepareselect", NULL, 450, &expr, &_83$$69); + zephir_check_call_status(); + zephir_array_update_string(&_81$$69, SL("value"), &_82$$69, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&exprReturn, &_81$$69); + break; + } + ZEPHIR_INIT_VAR(&_84$$70); + object_init_ex(&_84$$70, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_85$$70); + ZEPHIR_CONCAT_SV(&_85$$70, "Unknown expression type ", &exprType); + ZEPHIR_CALL_METHOD(NULL, &_84$$70, "__construct", NULL, 33, &_85$$70); + zephir_check_call_status(); + zephir_throw_exception_debug(&_84$$70, "phalcon/Mvc/Model/Query.zep", 2150); + ZEPHIR_MM_RESTORE(); + return; + } while(0); - zend_class_implements(phalcon_mvc_view_ce, 1, phalcon_mvc_viewinterface_ce); - zend_class_implements(phalcon_mvc_view_ce, 1, phalcon_events_eventsawareinterface_ce); - return SUCCESS; + RETURN_CCTOR(&exprReturn); + } + if (zephir_array_isset_string(&expr, SL("domain"))) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getqualified", NULL, 459, &expr); + zephir_check_call_status(); + RETURN_MM(); + } + if (zephir_array_isset_long(&expr, 0)) { + ZEPHIR_INIT_VAR(&listItems); + array_init(&listItems); + zephir_is_iterable(&expr, 0, "phalcon/Mvc/Model/Query.zep", 2173); + if (Z_TYPE_P(&expr) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&expr), _86$$72) + { + ZEPHIR_INIT_NVAR(&exprListItem); + ZVAL_COPY(&exprListItem, _86$$72); + ZEPHIR_CALL_METHOD(&_88$$73, this_ptr, "getexpression", NULL, 458, &exprListItem); + zephir_check_call_status(); + zephir_array_append(&listItems, &_88$$73, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2170); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &expr, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_87$$72, &expr, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_87$$72)) { + break; + } + ZEPHIR_CALL_METHOD(&exprListItem, &expr, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_89$$74, this_ptr, "getexpression", NULL, 458, &exprListItem); + zephir_check_call_status(); + zephir_array_append(&listItems, &_89$$74, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2170); + ZEPHIR_CALL_METHOD(NULL, &expr, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&exprListItem); + zephir_create_array(return_value, 2, 0); + add_assoc_stringl_ex(return_value, SL("type"), SL("list")); + zephir_array_fast_append(return_value, &listItems); + RETURN_MM(); + } + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Unknown expression", "phalcon/Mvc/Model/Query.zep", 2179); + return; } -static PHP_METHOD(Phalcon_Mvc_View, __construct) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getFunctionCall) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *options_param = NULL; - zval options; + zephir_fcall_cache_entry *_3 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, distinct = 0; + zval *expr_param = NULL, arguments, argument, _10, *_0$$6, _1$$6, _2$$7, _4$$8, _5$$9, _6$$9, _7$$10, _8$$10, _9$$11; + zval expr, functionArgs; zval *this_ptr = getThis(); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&functionArgs); + ZVAL_UNDEF(&arguments); + ZVAL_UNDEF(&argument); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_1$$6); + ZVAL_UNDEF(&_2$$7); + ZVAL_UNDEF(&_4$$8); + ZVAL_UNDEF(&_5$$9); + ZVAL_UNDEF(&_6$$9); + ZVAL_UNDEF(&_7$$10); + ZVAL_UNDEF(&_8$$10); + ZVAL_UNDEF(&_9$$11); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(expr) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &options_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); + zephir_fetch_params(1, 1, 0, &expr_param); + ZEPHIR_OBS_COPY_OR_DUP(&expr, expr_param); + zephir_memory_observe(&arguments); + if (zephir_array_isset_string_fetch(&arguments, &expr, SL("arguments"), 0)) { + if (zephir_array_isset_string(&expr, SL("distinct"))) { + distinct = 1; + } else { + distinct = 0; + } + if (zephir_array_isset_long(&arguments, 0)) { + ZEPHIR_INIT_VAR(&functionArgs); + array_init(&functionArgs); + zephir_is_iterable(&arguments, 0, "phalcon/Mvc/Model/Query.zep", 2205); + if (Z_TYPE_P(&arguments) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&arguments), _0$$6) + { + ZEPHIR_INIT_NVAR(&argument); + ZVAL_COPY(&argument, _0$$6); + ZEPHIR_CALL_METHOD(&_2$$7, this_ptr, "getcallargument", &_3, 462, &argument); + zephir_check_call_status(); + zephir_array_append(&functionArgs, &_2$$7, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2203); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &arguments, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1$$6, &arguments, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1$$6)) { + break; + } + ZEPHIR_CALL_METHOD(&argument, &arguments, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4$$8, this_ptr, "getcallargument", &_3, 462, &argument); + zephir_check_call_status(); + zephir_array_append(&functionArgs, &_4$$8, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2203); + ZEPHIR_CALL_METHOD(NULL, &arguments, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&argument); + } else { + ZEPHIR_INIT_VAR(&_5$$9); + zephir_create_array(&_5$$9, 1, 0); + ZEPHIR_CALL_METHOD(&_6$$9, this_ptr, "getcallargument", &_3, 462, &arguments); + zephir_check_call_status(); + zephir_array_fast_append(&_5$$9, &_6$$9); + ZEPHIR_CPY_WRT(&functionArgs, &_5$$9); + } + if (distinct) { + zephir_create_array(return_value, 4, 0); + add_assoc_stringl_ex(return_value, SL("type"), SL("functionCall")); + zephir_memory_observe(&_7$$10); + zephir_array_fetch_string(&_7$$10, &expr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2215); + zephir_array_update_string(return_value, SL("name"), &_7$$10, PH_COPY | PH_SEPARATE); + zephir_array_update_string(return_value, SL("arguments"), &functionArgs, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_8$$10); + ZVAL_LONG(&_8$$10, distinct); + zephir_array_update_string(return_value, SL("distinct"), &_8$$10, PH_COPY | PH_SEPARATE); + RETURN_MM(); + } else { + zephir_create_array(return_value, 3, 0); + add_assoc_stringl_ex(return_value, SL("type"), SL("functionCall")); + zephir_memory_observe(&_9$$11); + zephir_array_fetch_string(&_9$$11, &expr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2222); + zephir_array_update_string(return_value, SL("name"), &_9$$11, PH_COPY | PH_SEPARATE); + zephir_array_update_string(return_value, SL("arguments"), &functionArgs, PH_COPY | PH_SEPARATE); + RETURN_MM(); + } } - zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); - ZEPHIR_MM_RESTORE(); + zephir_create_array(return_value, 2, 0); + add_assoc_stringl_ex(return_value, SL("type"), SL("functionCall")); + zephir_memory_observe(&_10); + zephir_array_fetch_string(&_10, &expr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2231); + zephir_array_update_string(return_value, SL("name"), &_10, PH_COPY | PH_SEPARATE); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_View, __get) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getGroupClause) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_3 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL; - zval key; + zval *group_param = NULL, groupItem, *_0$$3, _1$$3, _2$$4, _4$$5, _5$$6, _6$$6; + zval group, groupParts; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&group); + ZVAL_UNDEF(&groupParts); + ZVAL_UNDEF(&groupItem); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_6$$6); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + Z_PARAM_ARRAY(group) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + zephir_fetch_params(1, 1, 0, &group_param); + ZEPHIR_OBS_COPY_OR_DUP(&group, group_param); + if (zephir_array_isset_long(&group, 0)) { + ZEPHIR_INIT_VAR(&groupParts); + array_init(&groupParts); + zephir_is_iterable(&group, 0, "phalcon/Mvc/Model/Query.zep", 2251); + if (Z_TYPE_P(&group) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&group), _0$$3) + { + ZEPHIR_INIT_NVAR(&groupItem); + ZVAL_COPY(&groupItem, _0$$3); + ZEPHIR_CALL_METHOD(&_2$$4, this_ptr, "getexpression", &_3, 458, &groupItem); + zephir_check_call_status(); + zephir_array_append(&groupParts, &_2$$4, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2249); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &group, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1$$3, &group, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&groupItem, &group, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4$$5, this_ptr, "getexpression", &_3, 458, &groupItem); + zephir_check_call_status(); + zephir_array_append(&groupParts, &_4$$5, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2249); + ZEPHIR_CALL_METHOD(NULL, &group, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&groupItem); } else { - ZEPHIR_INIT_VAR(&key); + ZEPHIR_INIT_VAR(&_5$$6); + zephir_create_array(&_5$$6, 1, 0); + ZEPHIR_CALL_METHOD(&_6$$6, this_ptr, "getexpression", &_3, 458, &group); + zephir_check_call_status(); + zephir_array_fast_append(&_5$$6, &_6$$6); + ZEPHIR_CPY_WRT(&groupParts, &_5$$6); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getvar", NULL, 0, &key); - zephir_check_call_status(); - RETURN_MM(); + RETURN_CTOR(&groupParts); } -static PHP_METHOD(Phalcon_Mvc_View, __isset) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getLimitClause) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *key_param = NULL, _0; - zval key; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *limitClause_param = NULL, number, offset, _0$$3, _1$$4; + zval limitClause, limit; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&limitClause); + ZVAL_UNDEF(&limit); + ZVAL_UNDEF(&number); + ZVAL_UNDEF(&offset); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$4); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + Z_PARAM_ARRAY(limitClause) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 0, &limitClause_param); + ZEPHIR_OBS_COPY_OR_DUP(&limitClause, limitClause_param); + ZEPHIR_INIT_VAR(&limit); + array_init(&limit); + zephir_memory_observe(&number); + if (zephir_array_isset_string_fetch(&number, &limitClause, SL("number"), 0)) { + ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "getexpression", NULL, 458, &number); + zephir_check_call_status(); + zephir_array_update_string(&limit, SL("number"), &_0$$3, PH_COPY | PH_SEPARATE); } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); + zephir_memory_observe(&offset); + if (zephir_array_isset_string_fetch(&offset, &limitClause, SL("offset"), 0)) { + ZEPHIR_CALL_METHOD(&_1$$4, this_ptr, "getexpression", NULL, 458, &offset); + zephir_check_call_status(); + zephir_array_update_string(&limit, SL("offset"), &_1$$4, PH_COPY | PH_SEPARATE); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("viewParams"), PH_NOISY_CC | PH_READONLY); - RETURN_MM_BOOL(zephir_array_isset(&_0, &key)); + RETURN_CTOR(&limit); } -static PHP_METHOD(Phalcon_Mvc_View, __set) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getJoin) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub; - zval key; - zval *this_ptr = getThis(); + zval join; + zval *manager, manager_sub, *join_param = NULL, qualified, modelName, source, model, schema, _0$$3; - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&manager_sub); + ZVAL_UNDEF(&qualified); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&join); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) + Z_PARAM_OBJECT_OF_CLASS(manager, phalcon_mvc_model_managerinterface_ce) + Z_PARAM_ARRAY(join) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &key_param, &value); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setvar", NULL, 0, &key, value); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_View, cleanTemplateAfter) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("templatesAfter"), &_0); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, cleanTemplateBefore) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("templatesBefore"), &_0); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, disableLevel) -{ - zval *level, level_sub, __$true; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&level_sub); - ZVAL_BOOL(&__$true, 1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(level) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &level); - if (Z_TYPE_P(level) == IS_ARRAY) { - zephir_update_property_zval(this_ptr, ZEND_STRL("disabledLevels"), level); - } else { - zephir_update_property_array(this_ptr, SL("disabledLevels"), level, &__$true); - } - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_View, disable) -{ - zval __$true, __$false; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("disabled"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("disabled"), &__$false); - } - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_View, enable) -{ - zval __$true, __$false; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("disabled"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("disabled"), &__$false); + zephir_fetch_params(1, 2, 0, &manager, &join_param); + zephir_get_arrval(&join, join_param); + zephir_memory_observe(&qualified); + if (zephir_array_isset_string_fetch(&qualified, &join, SL("qualified"), 0)) { + zephir_array_fetch_string(&_0$$3, &qualified, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2287); + if (ZEPHIR_IS_LONG(&_0$$3, 355)) { + zephir_memory_observe(&modelName); + zephir_array_fetch_string(&modelName, &qualified, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2288); + ZEPHIR_CALL_METHOD(&model, manager, "load", NULL, 0, &modelName); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); + zephir_check_call_status(); + zephir_create_array(return_value, 4, 0); + zephir_array_update_string(return_value, SL("schema"), &schema, PH_COPY | PH_SEPARATE); + zephir_array_update_string(return_value, SL("source"), &source, PH_COPY | PH_SEPARATE); + zephir_array_update_string(return_value, SL("modelName"), &modelName, PH_COPY | PH_SEPARATE); + zephir_array_update_string(return_value, SL("model"), &model, PH_COPY | PH_SEPARATE); + RETURN_MM(); + } } - RETURN_THISW(); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 2303); + return; } -static PHP_METHOD(Phalcon_Mvc_View, exists) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getJoinType) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *view_param = NULL; - zval view; + zval *join_param = NULL, type, _0, _1, _2; + zval join; zval *this_ptr = getThis(); - ZVAL_UNDEF(&view); + ZVAL_UNDEF(&join); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(view) + Z_PARAM_ARRAY(join) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &view_param); - if (UNEXPECTED(Z_TYPE_P(view_param) != IS_STRING && Z_TYPE_P(view_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'view' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(view_param) == IS_STRING)) { - zephir_get_strval(&view, view_param); - } else { - ZEPHIR_INIT_VAR(&view); + zephir_fetch_params(1, 1, 0, &join_param); + zephir_get_arrval(&join, join_param); + zephir_memory_observe(&type); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&type, &join, SL("type"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 2314); + return; } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, &view); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_View, finish) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_FUNCTION(NULL, "ob_end_clean", NULL, 489); - zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, getActionName) -{ - - RETURN_MEMBER(getThis(), "actionName"); -} - -static PHP_METHOD(Phalcon_Mvc_View, getActiveRenderPath) -{ - zend_bool _1$$3; - zval activeRenderPath, _0, _2$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, viewsDirsCount = 0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&activeRenderPath); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2$$4); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getviewsdirs", NULL, 0); - zephir_check_call_status(); - viewsDirsCount = zephir_fast_count_int(&_0); - zephir_memory_observe(&activeRenderPath); - zephir_read_property(&activeRenderPath, this_ptr, ZEND_STRL("activeRenderPaths"), PH_NOISY_CC); - if (viewsDirsCount == 1) { - _1$$3 = Z_TYPE_P(&activeRenderPath) == IS_ARRAY; - if (_1$$3) { - _1$$3 = ((zephir_fast_count_int(&activeRenderPath)) ? 1 : 0); + do { + if (ZEPHIR_IS_LONG(&type, 360)) { + RETURN_MM_STRING("INNER"); } - if (_1$$3) { - zephir_array_fetch_long(&_2$$4, &activeRenderPath, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/View.zep", 339); - ZEPHIR_CPY_WRT(&activeRenderPath, &_2$$4); + if (ZEPHIR_IS_LONG(&type, 361)) { + RETURN_MM_STRING("LEFT"); } - } - if (Z_TYPE_P(&activeRenderPath) == IS_NULL) { - ZEPHIR_INIT_NVAR(&activeRenderPath); - ZVAL_STRING(&activeRenderPath, ""); - } - RETURN_CCTOR(&activeRenderPath); -} - -static PHP_METHOD(Phalcon_Mvc_View, getBasePath) -{ - - RETURN_MEMBER(getThis(), "basePath"); -} - -static PHP_METHOD(Phalcon_Mvc_View, getContent) -{ - - RETURN_MEMBER(getThis(), "content"); -} - -static PHP_METHOD(Phalcon_Mvc_View, getControllerName) -{ - - RETURN_MEMBER(getThis(), "controllerName"); -} - -static PHP_METHOD(Phalcon_Mvc_View, getCurrentRenderLevel) -{ - - RETURN_MEMBER(getThis(), "currentRenderLevel"); -} - -static PHP_METHOD(Phalcon_Mvc_View, getRegisteredEngines) -{ - - RETURN_MEMBER(getThis(), "registeredEngines"); -} - -static PHP_METHOD(Phalcon_Mvc_View, getRenderLevel) -{ - - RETURN_MEMBER(getThis(), "renderLevel"); -} - -static PHP_METHOD(Phalcon_Mvc_View, getEventsManager) -{ - - RETURN_MEMBER(getThis(), "eventsManager"); -} - -static PHP_METHOD(Phalcon_Mvc_View, getLayout) -{ - - RETURN_MEMBER(getThis(), "layout"); -} - -static PHP_METHOD(Phalcon_Mvc_View, getLayoutsDir) -{ - - RETURN_MEMBER(getThis(), "layoutsDir"); -} - -static PHP_METHOD(Phalcon_Mvc_View, getMainView) -{ - - RETURN_MEMBER(getThis(), "mainView"); -} - -static PHP_METHOD(Phalcon_Mvc_View, getParamsToView) -{ - - RETURN_MEMBER(getThis(), "viewParams"); -} - -static PHP_METHOD(Phalcon_Mvc_View, getPartial) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *partialPath_param = NULL, *params = NULL, params_sub, __$null; - zval partialPath; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&partialPath); - ZVAL_UNDEF(¶ms_sub); - ZVAL_NULL(&__$null); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(partialPath) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(params) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &partialPath_param, ¶ms); - if (UNEXPECTED(Z_TYPE_P(partialPath_param) != IS_STRING && Z_TYPE_P(partialPath_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'partialPath' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(partialPath_param) == IS_STRING)) { - zephir_get_strval(&partialPath, partialPath_param); - } else { - ZEPHIR_INIT_VAR(&partialPath); - } - if (!params) { - params = ¶ms_sub; - params = &__$null; - } - ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 387); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "partial", NULL, 0, &partialPath, params); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", NULL, 394); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_View, getPartialsDir) -{ - - RETURN_MEMBER(getThis(), "partialsDir"); -} - -static PHP_METHOD(Phalcon_Mvc_View, getRender) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval params, _1$$3; - zval *controllerName_param = NULL, *actionName_param = NULL, *params_param = NULL, *configCallback = NULL, configCallback_sub, __$null, view, _0$$3; - zval controllerName, actionName; - zval *this_ptr = getThis(); + if (ZEPHIR_IS_LONG(&type, 362)) { + RETURN_MM_STRING("RIGHT"); + } + if (ZEPHIR_IS_LONG(&type, 363)) { + RETURN_MM_STRING("CROSS"); + } + if (ZEPHIR_IS_LONG(&type, 364)) { + RETURN_MM_STRING("FULL OUTER"); + } + } while(0); - ZVAL_UNDEF(&controllerName); - ZVAL_UNDEF(&actionName); - ZVAL_UNDEF(&configCallback_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&view); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&_1$$3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 4) - Z_PARAM_STR(controllerName) - Z_PARAM_STR(actionName) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(params) - Z_PARAM_ZVAL_OR_NULL(configCallback) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 2, &controllerName_param, &actionName_param, ¶ms_param, &configCallback); - if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { - zephir_get_strval(&controllerName, controllerName_param); - } else { - ZEPHIR_INIT_VAR(&controllerName); - } - if (UNEXPECTED(Z_TYPE_P(actionName_param) != IS_STRING && Z_TYPE_P(actionName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(actionName_param) == IS_STRING)) { - zephir_get_strval(&actionName, actionName_param); - } else { - ZEPHIR_INIT_VAR(&actionName); - } - if (!params_param) { - ZEPHIR_INIT_VAR(¶ms); - array_init(¶ms); - } else { - zephir_get_arrval(¶ms, params_param); - } - if (!configCallback) { - configCallback = &configCallback_sub; - configCallback = &__$null; - } - ZEPHIR_INIT_VAR(&view); - if (zephir_clone(&view, this_ptr) == FAILURE) { - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(NULL, &view, "reset", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &view, "setvars", NULL, 0, ¶ms); - zephir_check_call_status(); - if (Z_TYPE_P(configCallback) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_0$$3); - ZEPHIR_INIT_VAR(&_1$$3); - zephir_create_array(&_1$$3, 1, 0); - zephir_array_fast_append(&_1$$3, &view); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_0$$3, configCallback, &_1$$3); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(NULL, &view, "start", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &view, "render", NULL, 0, &controllerName, &actionName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &view, "finish", NULL, 0); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&view, "getcontent", NULL, 0); + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, phalcon_mvc_model_exception_ce); + zephir_read_property(&_1, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_CONCAT_SVSV(&_2, "Unknown join type ", &type, ", when preparing: ", &_1); + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 33, &_2); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_View, getVar) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *key_param = NULL, value, _0; - zval key; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - zephir_memory_observe(&value); - zephir_read_property(&_0, this_ptr, ZEND_STRL("viewParams"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&value, &_0, &key, 0))) { - RETURN_MM_NULL(); - } - RETURN_CCTOR(&value); -} - -static PHP_METHOD(Phalcon_Mvc_View, getViewsDir) -{ - - RETURN_MEMBER(getThis(), "viewsDirs"); -} - -static PHP_METHOD(Phalcon_Mvc_View, getViewsDirs) -{ - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_memory_observe(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("viewsDirs"), PH_NOISY_CC); - if (Z_TYPE_P(&_0) == IS_STRING) { - zephir_create_array(return_value, 1, 0); - zephir_memory_observe(&_1$$3); - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("viewsDirs"), PH_NOISY_CC); - zephir_array_fast_append(return_value, &_1$$3); - RETURN_MM(); - } - RETURN_MM_MEMBER(getThis(), "viewsDirs"); + zephir_throw_exception_debug(&_0, "phalcon/Mvc/Model/Query.zep", 2336); + ZEPHIR_MM_RESTORE(); + return; } -static PHP_METHOD(Phalcon_Mvc_View, has) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getJoins) { - zend_string *_9$$4, *_16$$9; - zend_ulong _8$$4, _15$$9; + zend_string *_22, *_45, *_30$$21, *_49$$26, *_79$$55; + zend_ulong _21, _44, _29$$21, _48$$26, _78$$55; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL, *_8 = NULL, *_24 = NULL, *_50 = NULL, *_51 = NULL, *_56 = NULL, *_57 = NULL, *_64 = NULL, *_65 = NULL, *_80 = NULL, *_81 = NULL, *_92 = NULL, *_93 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *view_param = NULL, basePath, viewsDir, engines, extension, _0, _2, *_3, _4, _1$$3, _5$$4, *_6$$4, _7$$4, _10$$5, _11$$7, _12$$9, *_13$$9, _14$$9, _17$$10, _18$$12; - zval view; + zval *select_param = NULL, __$true, models, sqlAliases, sqlAliasesModels, sqlModelsAliases, sqlAliasesModelsInstances, modelsInstances, fromModels, manager, selectJoins, joinItem, joins, joinData, schema, source, model, realModelName, completeSource, joinType, aliasExpr, alias, joinAliasName, joinExpr, fromModelName, joinAlias, joinModel, joinSource, preCondition, modelNameAlias, relation, relations, modelAlias, sqlJoin, sqlJoinItem, selectTables, tables, tableItem, _0, *_1, _2, *_19, _20, *_35, _36, _41, *_42, _43, _5$$9, _6$$9, _7$$9, _9$$11, _10$$11, _11$$11, _12$$12, _13$$14, _14$$14, _15$$14, _16$$16, _17$$16, _18$$16, _23$$18, _25$$20, _26$$21, *_27$$21, _28$$21, _37$$24, _38$$24, _39$$25, _40$$25, *_46$$26, _47$$26, _52$$31, _53$$31, _54$$31, _55$$32, *_58$$35, _59$$35, _61$$39, _66$$45, _67$$45, _68$$45, _69$$46, *_70$$49, _71$$49, _73$$53, *_76$$55, _77$$55, _82$$60, _83$$60, _84$$60, _85$$61, *_86$$64, _87$$64, _89$$68, _94$$74, _95$$74, _96$$74, _97$$75, *_98$$78, _99$$78, _101$$82; + zval select, sqlJoins, joinModels, joinSources, joinTypes, joinPreCondition, joinPrepared, _31$$22, _32$$22, _33$$23, _34$$23, _60$$39, _62$$40, _63$$40, _72$$53, _74$$54, _75$$54, _88$$68, _90$$69, _91$$69, _100$$82, _102$$83, _103$$83; zval *this_ptr = getThis(); - ZVAL_UNDEF(&view); - ZVAL_UNDEF(&basePath); - ZVAL_UNDEF(&viewsDir); - ZVAL_UNDEF(&engines); - ZVAL_UNDEF(&extension); + ZVAL_UNDEF(&select); + ZVAL_UNDEF(&sqlJoins); + ZVAL_UNDEF(&joinModels); + ZVAL_UNDEF(&joinSources); + ZVAL_UNDEF(&joinTypes); + ZVAL_UNDEF(&joinPreCondition); + ZVAL_UNDEF(&joinPrepared); + ZVAL_UNDEF(&_31$$22); + ZVAL_UNDEF(&_32$$22); + ZVAL_UNDEF(&_33$$23); + ZVAL_UNDEF(&_34$$23); + ZVAL_UNDEF(&_60$$39); + ZVAL_UNDEF(&_62$$40); + ZVAL_UNDEF(&_63$$40); + ZVAL_UNDEF(&_72$$53); + ZVAL_UNDEF(&_74$$54); + ZVAL_UNDEF(&_75$$54); + ZVAL_UNDEF(&_88$$68); + ZVAL_UNDEF(&_90$$69); + ZVAL_UNDEF(&_91$$69); + ZVAL_UNDEF(&_100$$82); + ZVAL_UNDEF(&_102$$83); + ZVAL_UNDEF(&_103$$83); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&models); + ZVAL_UNDEF(&sqlAliases); + ZVAL_UNDEF(&sqlAliasesModels); + ZVAL_UNDEF(&sqlModelsAliases); + ZVAL_UNDEF(&sqlAliasesModelsInstances); + ZVAL_UNDEF(&modelsInstances); + ZVAL_UNDEF(&fromModels); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&selectJoins); + ZVAL_UNDEF(&joinItem); + ZVAL_UNDEF(&joins); + ZVAL_UNDEF(&joinData); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&realModelName); + ZVAL_UNDEF(&completeSource); + ZVAL_UNDEF(&joinType); + ZVAL_UNDEF(&aliasExpr); + ZVAL_UNDEF(&alias); + ZVAL_UNDEF(&joinAliasName); + ZVAL_UNDEF(&joinExpr); + ZVAL_UNDEF(&fromModelName); + ZVAL_UNDEF(&joinAlias); + ZVAL_UNDEF(&joinModel); + ZVAL_UNDEF(&joinSource); + ZVAL_UNDEF(&preCondition); + ZVAL_UNDEF(&modelNameAlias); + ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&relations); + ZVAL_UNDEF(&modelAlias); + ZVAL_UNDEF(&sqlJoin); + ZVAL_UNDEF(&sqlJoinItem); + ZVAL_UNDEF(&selectTables); + ZVAL_UNDEF(&tables); + ZVAL_UNDEF(&tableItem); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_10$$5); - ZVAL_UNDEF(&_11$$7); - ZVAL_UNDEF(&_12$$9); - ZVAL_UNDEF(&_14$$9); - ZVAL_UNDEF(&_17$$10); - ZVAL_UNDEF(&_18$$12); + ZVAL_UNDEF(&_20); + ZVAL_UNDEF(&_36); + ZVAL_UNDEF(&_41); + ZVAL_UNDEF(&_43); + ZVAL_UNDEF(&_5$$9); + ZVAL_UNDEF(&_6$$9); + ZVAL_UNDEF(&_7$$9); + ZVAL_UNDEF(&_9$$11); + ZVAL_UNDEF(&_10$$11); + ZVAL_UNDEF(&_11$$11); + ZVAL_UNDEF(&_12$$12); + ZVAL_UNDEF(&_13$$14); + ZVAL_UNDEF(&_14$$14); + ZVAL_UNDEF(&_15$$14); + ZVAL_UNDEF(&_16$$16); + ZVAL_UNDEF(&_17$$16); + ZVAL_UNDEF(&_18$$16); + ZVAL_UNDEF(&_23$$18); + ZVAL_UNDEF(&_25$$20); + ZVAL_UNDEF(&_26$$21); + ZVAL_UNDEF(&_28$$21); + ZVAL_UNDEF(&_37$$24); + ZVAL_UNDEF(&_38$$24); + ZVAL_UNDEF(&_39$$25); + ZVAL_UNDEF(&_40$$25); + ZVAL_UNDEF(&_47$$26); + ZVAL_UNDEF(&_52$$31); + ZVAL_UNDEF(&_53$$31); + ZVAL_UNDEF(&_54$$31); + ZVAL_UNDEF(&_55$$32); + ZVAL_UNDEF(&_59$$35); + ZVAL_UNDEF(&_61$$39); + ZVAL_UNDEF(&_66$$45); + ZVAL_UNDEF(&_67$$45); + ZVAL_UNDEF(&_68$$45); + ZVAL_UNDEF(&_69$$46); + ZVAL_UNDEF(&_71$$49); + ZVAL_UNDEF(&_73$$53); + ZVAL_UNDEF(&_77$$55); + ZVAL_UNDEF(&_82$$60); + ZVAL_UNDEF(&_83$$60); + ZVAL_UNDEF(&_84$$60); + ZVAL_UNDEF(&_85$$61); + ZVAL_UNDEF(&_87$$64); + ZVAL_UNDEF(&_89$$68); + ZVAL_UNDEF(&_94$$74); + ZVAL_UNDEF(&_95$$74); + ZVAL_UNDEF(&_96$$74); + ZVAL_UNDEF(&_97$$75); + ZVAL_UNDEF(&_99$$78); + ZVAL_UNDEF(&_101$$82); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(view) + Z_PARAM_ARRAY(select) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &view_param); - if (UNEXPECTED(Z_TYPE_P(view_param) != IS_STRING && Z_TYPE_P(view_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'view' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(view_param) == IS_STRING)) { - zephir_get_strval(&view, view_param); + zephir_fetch_params(1, 1, 0, &select_param); + zephir_get_arrval(&select, select_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&models, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("sqlAliases"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&sqlAliases, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("sqlAliasesModels"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&sqlAliasesModels, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("sqlModelsAliases"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&sqlModelsAliases, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&sqlAliasesModelsInstances, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&modelsInstances, &_0); + ZEPHIR_CPY_WRT(&fromModels, &models); + ZEPHIR_INIT_VAR(&sqlJoins); + array_init(&sqlJoins); + ZEPHIR_INIT_VAR(&joinModels); + array_init(&joinModels); + ZEPHIR_INIT_VAR(&joinSources); + array_init(&joinSources); + ZEPHIR_INIT_VAR(&joinTypes); + array_init(&joinTypes); + ZEPHIR_INIT_VAR(&joinPreCondition); + array_init(&joinPreCondition); + ZEPHIR_INIT_VAR(&joinPrepared); + array_init(&joinPrepared); + zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&manager, &_0); + zephir_memory_observe(&tables); + zephir_array_fetch_string(&tables, &select, SL("tables"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2372); + if (!(zephir_array_isset_long(&tables, 0))) { + ZEPHIR_INIT_VAR(&selectTables); + zephir_create_array(&selectTables, 1, 0); + zephir_array_fast_append(&selectTables, &tables); } else { - ZEPHIR_INIT_VAR(&view); + ZEPHIR_CPY_WRT(&selectTables, &tables); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("basePath"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&basePath, &_0); - zephir_memory_observe(&engines); - zephir_read_property(&engines, this_ptr, ZEND_STRL("registeredEngines"), PH_NOISY_CC); - if (ZEPHIR_IS_EMPTY(&engines)) { - ZEPHIR_INIT_VAR(&_1$$3); - zephir_create_array(&_1$$3, 1, 0); - add_assoc_stringl_ex(&_1$$3, SL(".phtml"), SL("Phalcon\\Mvc\\View\\Engine\\Php")); - ZEPHIR_CPY_WRT(&engines, &_1$$3); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "registerengines", NULL, 0, &engines); - zephir_check_call_status(); + zephir_memory_observe(&joins); + zephir_array_fetch_string(&joins, &select, SL("joins"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2380); + if (!(zephir_array_isset_long(&joins, 0))) { + ZEPHIR_INIT_VAR(&selectJoins); + zephir_create_array(&selectJoins, 1, 0); + zephir_array_fast_append(&selectJoins, &joins); + } else { + ZEPHIR_CPY_WRT(&selectJoins, &joins); } - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getviewsdirs", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&_2, 0, "phalcon/Mvc/View.zep", 599); - if (Z_TYPE_P(&_2) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_2), _3) + zephir_is_iterable(&selectJoins, 0, "phalcon/Mvc/Model/Query.zep", 2531); + if (Z_TYPE_P(&selectJoins) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&selectJoins), _1) { - ZEPHIR_INIT_NVAR(&viewsDir); - ZVAL_COPY(&viewsDir, _3); - ZEPHIR_INIT_NVAR(&_5$$4); - zephir_is_iterable(&engines, 0, "phalcon/Mvc/View.zep", 597); - if (Z_TYPE_P(&engines) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&engines), _8$$4, _9$$4, _6$$4) - { - ZEPHIR_INIT_NVAR(&extension); - if (_9$$4 != NULL) { - ZVAL_STR_COPY(&extension, _9$$4); - } else { - ZVAL_LONG(&extension, _8$$4); - } - ZEPHIR_INIT_NVAR(&_5$$4); - ZVAL_COPY(&_5$$4, _6$$4); - ZEPHIR_INIT_NVAR(&_10$$5); - ZEPHIR_CONCAT_VVVV(&_10$$5, &basePath, &viewsDir, &view, &extension); - if ((zephir_file_exists(&_10$$5) == SUCCESS)) { - RETURN_MM_BOOL(1); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &engines, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_7$$4, &engines, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_7$$4)) { - break; - } - ZEPHIR_CALL_METHOD(&extension, &engines, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_5$$4, &engines, "current", NULL, 0); + ZEPHIR_INIT_NVAR(&joinItem); + ZVAL_COPY(&joinItem, _1); + ZEPHIR_CALL_METHOD(&joinData, this_ptr, "getjoin", &_3, 463, &manager, &joinItem); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&source); + zephir_array_fetch_string(&source, &joinData, SL("source"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2394); + ZEPHIR_OBS_NVAR(&schema); + zephir_array_fetch_string(&schema, &joinData, SL("schema"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2395); + ZEPHIR_OBS_NVAR(&model); + zephir_array_fetch_string(&model, &joinData, SL("model"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2396); + ZEPHIR_OBS_NVAR(&realModelName); + zephir_array_fetch_string(&realModelName, &joinData, SL("modelName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2397); + ZEPHIR_INIT_NVAR(&completeSource); + zephir_create_array(&completeSource, 2, 0); + zephir_array_fast_append(&completeSource, &source); + zephir_array_fast_append(&completeSource, &schema); + ZEPHIR_CALL_METHOD(&joinType, this_ptr, "getjointype", &_4, 464, &joinItem); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&aliasExpr); + if (zephir_array_isset_string_fetch(&aliasExpr, &joinItem, SL("alias"), 0)) { + ZEPHIR_OBS_NVAR(&alias); + zephir_array_fetch_string(&alias, &aliasExpr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2409); + if (UNEXPECTED(zephir_array_isset(&joinModels, &alias))) { + ZEPHIR_INIT_NVAR(&_5$$9); + object_init_ex(&_5$$9, phalcon_mvc_model_exception_ce); + zephir_read_property(&_6$$9, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_7$$9); + ZEPHIR_CONCAT_SVSV(&_7$$9, "Cannot use '", &alias, "' as join alias because it was already used, when preparing: ", &_6$$9); + ZEPHIR_CALL_METHOD(NULL, &_5$$9, "__construct", &_8, 33, &_7$$9); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_11$$7); - ZEPHIR_CONCAT_VVVV(&_11$$7, &basePath, &viewsDir, &view, &extension); - if ((zephir_file_exists(&_11$$7) == SUCCESS)) { - RETURN_MM_BOOL(1); - } - ZEPHIR_CALL_METHOD(NULL, &engines, "next", NULL, 0); + zephir_throw_exception_debug(&_5$$9, "phalcon/Mvc/Model/Query.zep", 2417); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2423); + zephir_array_update_zval(&joinTypes, &alias, &joinType, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&joinModels, &alias, &realModelName, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlModelsAliases, &realModelName, &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModels, &alias, &realModelName, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&models, &realModelName, &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&joinSources, &alias, &completeSource, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&joinPrepared, &alias, &joinItem, PH_COPY | PH_SEPARATE); + } else { + if (UNEXPECTED(zephir_array_isset(&joinModels, &realModelName))) { + ZEPHIR_INIT_NVAR(&_9$$11); + object_init_ex(&_9$$11, phalcon_mvc_model_exception_ce); + zephir_read_property(&_10$$11, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_11$$11); + ZEPHIR_CONCAT_SVSV(&_11$$11, "Cannot use '", &realModelName, "' as join alias because it was already used, when preparing: ", &_10$$11); + ZEPHIR_CALL_METHOD(NULL, &_9$$11, "__construct", &_8, 33, &_11$$11); zephir_check_call_status(); + zephir_throw_exception_debug(&_9$$11, "phalcon/Mvc/Model/Query.zep", 2476); + ZEPHIR_MM_RESTORE(); + return; } + zephir_array_update_zval(&joinTypes, &realModelName, &joinType, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliases, &realModelName, &source, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&joinModels, &realModelName, &source, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlModelsAliases, &realModelName, &realModelName, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModels, &realModelName, &realModelName, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModelsInstances, &realModelName, &model, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&models, &realModelName, &source, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&joinSources, &realModelName, &completeSource, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&joinPrepared, &realModelName, &joinItem, PH_COPY | PH_SEPARATE); } - ZEPHIR_INIT_NVAR(&_5$$4); - ZEPHIR_INIT_NVAR(&extension); + zephir_array_update_zval(&modelsInstances, &realModelName, &model, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &_2, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &selectJoins, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_4, &_2, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_2, &selectJoins, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_4)) { + if (!zend_is_true(&_2)) { break; } - ZEPHIR_CALL_METHOD(&viewsDir, &_2, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&joinItem, &selectJoins, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_12$$9); - zephir_is_iterable(&engines, 0, "phalcon/Mvc/View.zep", 597); - if (Z_TYPE_P(&engines) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&engines), _15$$9, _16$$9, _13$$9) - { - ZEPHIR_INIT_NVAR(&extension); - if (_16$$9 != NULL) { - ZVAL_STR_COPY(&extension, _16$$9); - } else { - ZVAL_LONG(&extension, _15$$9); - } - ZEPHIR_INIT_NVAR(&_12$$9); - ZVAL_COPY(&_12$$9, _13$$9); - ZEPHIR_INIT_NVAR(&_17$$10); - ZEPHIR_CONCAT_VVVV(&_17$$10, &basePath, &viewsDir, &view, &extension); - if ((zephir_file_exists(&_17$$10) == SUCCESS)) { - RETURN_MM_BOOL(1); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &engines, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_14$$9, &engines, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_14$$9)) { - break; - } - ZEPHIR_CALL_METHOD(&extension, &engines, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_12$$9, &engines, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&joinData, this_ptr, "getjoin", &_3, 463, &manager, &joinItem); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&source); + zephir_array_fetch_string(&source, &joinData, SL("source"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2394); + ZEPHIR_OBS_NVAR(&schema); + zephir_array_fetch_string(&schema, &joinData, SL("schema"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2395); + ZEPHIR_OBS_NVAR(&model); + zephir_array_fetch_string(&model, &joinData, SL("model"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2396); + ZEPHIR_OBS_NVAR(&realModelName); + zephir_array_fetch_string(&realModelName, &joinData, SL("modelName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2397); + ZEPHIR_INIT_NVAR(&_12$$12); + zephir_create_array(&_12$$12, 2, 0); + zephir_array_fast_append(&_12$$12, &source); + zephir_array_fast_append(&_12$$12, &schema); + ZEPHIR_CPY_WRT(&completeSource, &_12$$12); + ZEPHIR_CALL_METHOD(&joinType, this_ptr, "getjointype", &_4, 464, &joinItem); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&aliasExpr); + if (zephir_array_isset_string_fetch(&aliasExpr, &joinItem, SL("alias"), 0)) { + ZEPHIR_OBS_NVAR(&alias); + zephir_array_fetch_string(&alias, &aliasExpr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2409); + if (UNEXPECTED(zephir_array_isset(&joinModels, &alias))) { + ZEPHIR_INIT_NVAR(&_13$$14); + object_init_ex(&_13$$14, phalcon_mvc_model_exception_ce); + zephir_read_property(&_14$$14, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_15$$14); + ZEPHIR_CONCAT_SVSV(&_15$$14, "Cannot use '", &alias, "' as join alias because it was already used, when preparing: ", &_14$$14); + ZEPHIR_CALL_METHOD(NULL, &_13$$14, "__construct", &_8, 33, &_15$$14); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_18$$12); - ZEPHIR_CONCAT_VVVV(&_18$$12, &basePath, &viewsDir, &view, &extension); - if ((zephir_file_exists(&_18$$12) == SUCCESS)) { - RETURN_MM_BOOL(1); - } - ZEPHIR_CALL_METHOD(NULL, &engines, "next", NULL, 0); + zephir_throw_exception_debug(&_13$$14, "phalcon/Mvc/Model/Query.zep", 2417); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2423); + zephir_array_update_zval(&joinTypes, &alias, &joinType, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&joinModels, &alias, &realModelName, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlModelsAliases, &realModelName, &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModels, &alias, &realModelName, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&models, &realModelName, &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&joinSources, &alias, &completeSource, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&joinPrepared, &alias, &joinItem, PH_COPY | PH_SEPARATE); + } else { + if (UNEXPECTED(zephir_array_isset(&joinModels, &realModelName))) { + ZEPHIR_INIT_NVAR(&_16$$16); + object_init_ex(&_16$$16, phalcon_mvc_model_exception_ce); + zephir_read_property(&_17$$16, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_18$$16); + ZEPHIR_CONCAT_SVSV(&_18$$16, "Cannot use '", &realModelName, "' as join alias because it was already used, when preparing: ", &_17$$16); + ZEPHIR_CALL_METHOD(NULL, &_16$$16, "__construct", &_8, 33, &_18$$16); zephir_check_call_status(); + zephir_throw_exception_debug(&_16$$16, "phalcon/Mvc/Model/Query.zep", 2476); + ZEPHIR_MM_RESTORE(); + return; } + zephir_array_update_zval(&joinTypes, &realModelName, &joinType, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliases, &realModelName, &source, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&joinModels, &realModelName, &source, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlModelsAliases, &realModelName, &realModelName, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModels, &realModelName, &realModelName, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModelsInstances, &realModelName, &model, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&models, &realModelName, &source, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&joinSources, &realModelName, &completeSource, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&joinPrepared, &realModelName, &joinItem, PH_COPY | PH_SEPARATE); } - ZEPHIR_INIT_NVAR(&_12$$9); - ZEPHIR_INIT_NVAR(&extension); - ZEPHIR_CALL_METHOD(NULL, &_2, "next", NULL, 0); + zephir_array_update_zval(&modelsInstances, &realModelName, &model, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &selectJoins, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&viewsDir); - RETURN_MM_BOOL(0); -} - -static PHP_METHOD(Phalcon_Mvc_View, isDisabled) -{ - - RETURN_MEMBER(getThis(), "disabled"); -} - -static PHP_METHOD(Phalcon_Mvc_View, partial) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *partialPath_param = NULL, *params = NULL, params_sub, __$null, viewParams, _3, _4, _5, _6, _7, _0$$3, _1$$3, _2$$3; - zval partialPath; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&partialPath); - ZVAL_UNDEF(¶ms_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&viewParams); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(partialPath) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(params) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &partialPath_param, ¶ms); - if (UNEXPECTED(Z_TYPE_P(partialPath_param) != IS_STRING && Z_TYPE_P(partialPath_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'partialPath' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(partialPath_param) == IS_STRING)) { - zephir_get_strval(&partialPath, partialPath_param); + ZEPHIR_INIT_NVAR(&joinItem); + zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &models); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliases"), &sqlAliases); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModels"), &sqlAliasesModels); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlModelsAliases"), &sqlModelsAliases); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &sqlAliasesModelsInstances); + zephir_update_property_zval(this_ptr, ZEND_STRL("modelsInstances"), &modelsInstances); + zephir_is_iterable(&joinPrepared, 0, "phalcon/Mvc/Model/Query.zep", 2551); + if (Z_TYPE_P(&joinPrepared) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&joinPrepared), _21, _22, _19) + { + ZEPHIR_INIT_NVAR(&joinAliasName); + if (_22 != NULL) { + ZVAL_STR_COPY(&joinAliasName, _22); + } else { + ZVAL_LONG(&joinAliasName, _21); + } + ZEPHIR_INIT_NVAR(&joinItem); + ZVAL_COPY(&joinItem, _19); + ZEPHIR_OBS_NVAR(&joinExpr); + if (zephir_array_isset_string_fetch(&joinExpr, &joinItem, SL("conditions"), 0)) { + ZEPHIR_CALL_METHOD(&_23$$18, this_ptr, "getexpression", &_24, 458, &joinExpr); + zephir_check_call_status(); + zephir_array_update_zval(&joinPreCondition, &joinAliasName, &_23$$18, PH_COPY | PH_SEPARATE); + } + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_INIT_VAR(&partialPath); + ZEPHIR_CALL_METHOD(NULL, &joinPrepared, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_20, &joinPrepared, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_20)) { + break; + } + ZEPHIR_CALL_METHOD(&joinAliasName, &joinPrepared, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&joinItem, &joinPrepared, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&joinExpr); + if (zephir_array_isset_string_fetch(&joinExpr, &joinItem, SL("conditions"), 0)) { + ZEPHIR_CALL_METHOD(&_25$$20, this_ptr, "getexpression", &_24, 458, &joinExpr); + zephir_check_call_status(); + zephir_array_update_zval(&joinPreCondition, &joinAliasName, &_25$$20, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, &joinPrepared, "next", NULL, 0); + zephir_check_call_status(); + } } - if (!params) { - params = ¶ms_sub; - params = &__$null; - } - if (Z_TYPE_P(params) == IS_ARRAY) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("viewParams"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&viewParams, &_0$$3); - ZEPHIR_INIT_VAR(&_1$$3); - zephir_fast_array_merge(&_1$$3, &viewParams, params); - zephir_update_property_zval(this_ptr, ZEND_STRL("viewParams"), &_1$$3); - ZEPHIR_INIT_VAR(&_2$$3); - ZEPHIR_CREATE_SYMBOL_TABLE(); - - } - ZEPHIR_CALL_METHOD(&_3, this_ptr, "loadtemplateengines", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_4, this_ptr, ZEND_STRL("partialsDir"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_5); - ZEPHIR_CONCAT_VV(&_5, &_4, &partialPath); - ZVAL_BOOL(&_6, 0); - ZVAL_BOOL(&_7, 0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &_3, &_5, &_6, &_7); - zephir_check_call_status(); - if (Z_TYPE_P(params) == IS_ARRAY) { - zephir_update_property_zval(this_ptr, ZEND_STRL("viewParams"), &viewParams); - } - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_View, pick) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *renderView, renderView_sub, pickView, layout, parts, _0$$4; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&renderView_sub); - ZVAL_UNDEF(&pickView); - ZVAL_UNDEF(&layout); - ZVAL_UNDEF(&parts); - ZVAL_UNDEF(&_0$$4); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(renderView) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &renderView); - if (Z_TYPE_P(renderView) == IS_ARRAY) { - ZEPHIR_CPY_WRT(&pickView, renderView); - } else { - ZEPHIR_INIT_VAR(&layout); - ZVAL_NULL(&layout); - if (zephir_memnstr_str(renderView, SL("/"), "phalcon/Mvc/View.zep", 701)) { - ZEPHIR_INIT_VAR(&parts); - zephir_fast_explode_str(&parts, SL("/"), renderView, LONG_MAX); - ZEPHIR_OBS_NVAR(&layout); - zephir_array_fetch_long(&layout, &parts, 0, PH_NOISY, "phalcon/Mvc/View.zep", 703); - } - ZEPHIR_INIT_VAR(&_0$$4); - zephir_create_array(&_0$$4, 1, 0); - zephir_array_fast_append(&_0$$4, renderView); - ZEPHIR_CPY_WRT(&pickView, &_0$$4); - if (Z_TYPE_P(&layout) != IS_NULL) { - zephir_array_append(&pickView, &layout, PH_SEPARATE, "phalcon/Mvc/View.zep", 709); - } - } - zephir_update_property_zval(this_ptr, ZEND_STRL("pickView"), &pickView); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, registerEngines) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *engines_param = NULL; - zval engines; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&engines); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(engines) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &engines_param); - ZEPHIR_OBS_COPY_OR_DUP(&engines, engines_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("registeredEngines"), &engines); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, render) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval params; - zval *controllerName_param = NULL, *actionName_param = NULL, *params_param = NULL, result; - zval controllerName, actionName; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&controllerName); - ZVAL_UNDEF(&actionName); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(¶ms); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(controllerName) - Z_PARAM_STR(actionName) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(params) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &controllerName_param, &actionName_param, ¶ms_param); - if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { - zephir_get_strval(&controllerName, controllerName_param); - } else { - ZEPHIR_INIT_VAR(&controllerName); - } - if (UNEXPECTED(Z_TYPE_P(actionName_param) != IS_STRING && Z_TYPE_P(actionName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(actionName_param) == IS_STRING)) { - zephir_get_strval(&actionName, actionName_param); - } else { - ZEPHIR_INIT_VAR(&actionName); - } - if (!params_param) { - ZEPHIR_INIT_VAR(¶ms); - array_init(¶ms); - } else { - zephir_get_arrval(¶ms, params_param); - } - ZEPHIR_CALL_METHOD(&result, this_ptr, "processrender", NULL, 0, &controllerName, &actionName, ¶ms); - zephir_check_call_status(); - if (!(zephir_is_true(&result))) { - RETURN_MM_BOOL(0); - } - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, reset) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$true, __$false, _0, _1, _2; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("disabled"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("disabled"), &__$false); - } - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("engines"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("engines"), &__$false); - } - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, 5); - zephir_update_property_zval(this_ptr, ZEND_STRL("renderLevel"), &_0); - ZEPHIR_INIT_VAR(&_1); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, ""); - zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &_1); - ZEPHIR_INIT_NVAR(&_1); - array_init(&_1); - zephir_update_property_zval(this_ptr, ZEND_STRL("templatesBefore"), &_1); - ZEPHIR_INIT_VAR(&_2); - array_init(&_2); - zephir_update_property_zval(this_ptr, ZEND_STRL("templatesAfter"), &_2); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, setBasePath) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *basePath_param = NULL; - zval basePath; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&basePath); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(basePath) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &basePath_param); - zephir_get_strval(&basePath, basePath_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("basePath"), &basePath); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, setContent) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *content_param = NULL; - zval content; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&content); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(content) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &content_param); - zephir_get_strval(&content, content_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &content); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, setEventsManager) -{ - zval *eventsManager, eventsManager_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&eventsManager_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); - zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); -} - -static PHP_METHOD(Phalcon_Mvc_View, setLayout) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *layout_param = NULL; - zval layout; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&layout); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(layout) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &layout_param); - zephir_get_strval(&layout, layout_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("layout"), &layout); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, setLayoutsDir) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *layoutsDir_param = NULL; - zval layoutsDir; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&layoutsDir); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(layoutsDir) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &layoutsDir_param); - zephir_get_strval(&layoutsDir, layoutsDir_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("layoutsDir"), &layoutsDir); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, setMainView) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *viewPath_param = NULL; - zval viewPath; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&viewPath); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(viewPath) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &viewPath_param); - zephir_get_strval(&viewPath, viewPath_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("mainView"), &viewPath); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, setPartialsDir) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *partialsDir_param = NULL; - zval partialsDir; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&partialsDir); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(partialsDir) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &partialsDir_param); - zephir_get_strval(&partialsDir, partialsDir_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("partialsDir"), &partialsDir); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, setParamToView) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *key_param = NULL, *value, value_sub; - zval key; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &key_param, &value); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - zephir_update_property_array(this_ptr, SL("viewParams"), &key, value); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, setRenderLevel) -{ - zval *level_param = NULL, _0; - zend_long level; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(level) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &level_param); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, level); - zephir_update_property_zval(this_ptr, ZEND_STRL("renderLevel"), &_0); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_View, setTemplateAfter) -{ - zval _0$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *templateAfter, templateAfter_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&templateAfter_sub); - ZVAL_UNDEF(&_0$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(templateAfter) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &templateAfter); - if (Z_TYPE_P(templateAfter) != IS_ARRAY) { - ZEPHIR_INIT_VAR(&_0$$3); - zephir_create_array(&_0$$3, 1, 0); - zephir_array_fast_append(&_0$$3, templateAfter); - zephir_update_property_zval(this_ptr, ZEND_STRL("templatesAfter"), &_0$$3); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("templatesAfter"), templateAfter); - } - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, setTemplateBefore) -{ - zval _0$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *templateBefore, templateBefore_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&templateBefore_sub); - ZVAL_UNDEF(&_0$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(templateBefore) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &templateBefore); - if (Z_TYPE_P(templateBefore) != IS_ARRAY) { - ZEPHIR_INIT_VAR(&_0$$3); - zephir_create_array(&_0$$3, 1, 0); - zephir_array_fast_append(&_0$$3, templateBefore); - zephir_update_property_zval(this_ptr, ZEND_STRL("templatesBefore"), &_0$$3); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("templatesBefore"), templateBefore); - } - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, setVar) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *key_param = NULL, *value, value_sub; - zval key; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &key_param, &value); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - zephir_update_property_array(this_ptr, SL("viewParams"), &key, value); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, setVars) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool merge; - zval *params_param = NULL, *merge_param = NULL, _0$$3, _1$$3; - zval params; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(params) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(merge) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, ¶ms_param, &merge_param); - ZEPHIR_OBS_COPY_OR_DUP(¶ms, params_param); - if (!merge_param) { - merge = 1; - } else { - } - if (merge) { - ZEPHIR_INIT_VAR(&_0$$3); - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("viewParams"), PH_NOISY_CC | PH_READONLY); - zephir_fast_array_merge(&_0$$3, &_1$$3, ¶ms); - zephir_update_property_zval(this_ptr, ZEND_STRL("viewParams"), &_0$$3); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("viewParams"), ¶ms); - } - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, setViewsDir) -{ - zend_string *_5$$5; - zend_ulong _4$$5; - zend_bool _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *viewsDir, viewsDir_sub, position, directory, newViewsDir, _1$$4, *_2$$5, _3$$5, _6$$6, _7$$8; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&viewsDir_sub); - ZVAL_UNDEF(&position); - ZVAL_UNDEF(&directory); - ZVAL_UNDEF(&newViewsDir); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_6$$6); - ZVAL_UNDEF(&_7$$8); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(viewsDir) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &viewsDir); - _0 = Z_TYPE_P(viewsDir) != IS_STRING; - if (_0) { - _0 = Z_TYPE_P(viewsDir) != IS_ARRAY; - } - if (_0) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "Views directory must be a string or an array", "phalcon/Mvc/View.zep", 982); - return; - } - if (Z_TYPE_P(viewsDir) == IS_STRING) { - ZEPHIR_CALL_METHOD(&_1$$4, this_ptr, "getdirseparator", NULL, 490, viewsDir); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("viewsDirs"), &_1$$4); - } else { - ZEPHIR_INIT_VAR(&newViewsDir); - array_init(&newViewsDir); - zephir_is_iterable(viewsDir, 0, "phalcon/Mvc/View.zep", 1000); - if (Z_TYPE_P(viewsDir) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(viewsDir), _4$$5, _5$$5, _2$$5) + ZEPHIR_INIT_NVAR(&joinItem); + ZEPHIR_INIT_NVAR(&joinAliasName); + zephir_read_property(&_0, this_ptr, ZEND_STRL("enableImplicitJoins"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_is_true(&_0))) { + ZEPHIR_INIT_VAR(&_26$$21); + zephir_is_iterable(&joinPrepared, 0, "phalcon/Mvc/Model/Query.zep", 2563); + if (Z_TYPE_P(&joinPrepared) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&joinPrepared), _29$$21, _30$$21, _27$$21) { - ZEPHIR_INIT_NVAR(&position); - if (_5$$5 != NULL) { - ZVAL_STR_COPY(&position, _5$$5); + ZEPHIR_INIT_NVAR(&joinAliasName); + if (_30$$21 != NULL) { + ZVAL_STR_COPY(&joinAliasName, _30$$21); } else { - ZVAL_LONG(&position, _4$$5); - } - ZEPHIR_INIT_NVAR(&directory); - ZVAL_COPY(&directory, _2$$5); - if (Z_TYPE_P(&directory) != IS_STRING) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "Views directory item must be a string", "phalcon/Mvc/View.zep", 994); - return; + ZVAL_LONG(&joinAliasName, _29$$21); } - ZEPHIR_CALL_METHOD(&_6$$6, this_ptr, "getdirseparator", NULL, 490, &directory); - zephir_check_call_status(); - zephir_array_update_zval(&newViewsDir, &position, &_6$$6, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_26$$21); + ZVAL_COPY(&_26$$21, _27$$21); + ZEPHIR_OBS_NVAR(&joinType); + zephir_array_fetch(&joinType, &joinTypes, &joinAliasName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2553); + ZEPHIR_OBS_NVAR(&joinSource); + zephir_array_fetch(&joinSource, &joinSources, &joinAliasName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2554); + ZEPHIR_OBS_NVAR(&preCondition); + zephir_array_fetch(&preCondition, &joinPreCondition, &joinAliasName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2555); + ZEPHIR_INIT_NVAR(&_31$$22); + zephir_create_array(&_31$$22, 3, 0); + zephir_array_update_string(&_31$$22, SL("type"), &joinType, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_31$$22, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_32$$22); + zephir_create_array(&_32$$22, 1, 0); + zephir_array_fast_append(&_32$$22, &preCondition); + zephir_array_update_string(&_31$$22, SL("conditions"), &_32$$22, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlJoins, &_31$$22, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2560); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, viewsDir, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &joinPrepared, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_3$$5, viewsDir, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_28$$21, &joinPrepared, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_3$$5)) { + if (!zend_is_true(&_28$$21)) { break; } - ZEPHIR_CALL_METHOD(&position, viewsDir, "key", NULL, 0); + ZEPHIR_CALL_METHOD(&joinAliasName, &joinPrepared, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&directory, viewsDir, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&_26$$21, &joinPrepared, "current", NULL, 0); zephir_check_call_status(); - if (Z_TYPE_P(&directory) != IS_STRING) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "Views directory item must be a string", "phalcon/Mvc/View.zep", 994); - return; - } - ZEPHIR_CALL_METHOD(&_7$$8, this_ptr, "getdirseparator", NULL, 490, &directory); - zephir_check_call_status(); - zephir_array_update_zval(&newViewsDir, &position, &_7$$8, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, viewsDir, "next", NULL, 0); + ZEPHIR_OBS_NVAR(&joinType); + zephir_array_fetch(&joinType, &joinTypes, &joinAliasName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2553); + ZEPHIR_OBS_NVAR(&joinSource); + zephir_array_fetch(&joinSource, &joinSources, &joinAliasName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2554); + ZEPHIR_OBS_NVAR(&preCondition); + zephir_array_fetch(&preCondition, &joinPreCondition, &joinAliasName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2555); + ZEPHIR_INIT_NVAR(&_33$$23); + zephir_create_array(&_33$$23, 3, 0); + zephir_array_update_string(&_33$$23, SL("type"), &joinType, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_33$$23, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_34$$23); + zephir_create_array(&_34$$23, 1, 0); + zephir_array_fast_append(&_34$$23, &preCondition); + zephir_array_update_string(&_33$$23, SL("conditions"), &_34$$23, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlJoins, &_33$$23, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2560); + ZEPHIR_CALL_METHOD(NULL, &joinPrepared, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&directory); - ZEPHIR_INIT_NVAR(&position); - zephir_update_property_zval(this_ptr, ZEND_STRL("viewsDirs"), &newViewsDir); - } - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, start) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$null; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_NULL(&__$null); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 387); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &__$null); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_View, toString) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval params; - zval *controllerName_param = NULL, *actionName_param = NULL, *params_param = NULL, result, _0; - zval controllerName, actionName; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&controllerName); - ZVAL_UNDEF(&actionName); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(¶ms); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(controllerName) - Z_PARAM_STR(actionName) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(params) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &controllerName_param, &actionName_param, ¶ms_param); - if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { - zephir_get_strval(&controllerName, controllerName_param); - } else { - ZEPHIR_INIT_VAR(&controllerName); - } - if (UNEXPECTED(Z_TYPE_P(actionName_param) != IS_STRING && Z_TYPE_P(actionName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(actionName_param) == IS_STRING)) { - zephir_get_strval(&actionName, actionName_param); - } else { - ZEPHIR_INIT_VAR(&actionName); - } - if (!params_param) { - ZEPHIR_INIT_VAR(¶ms); - array_init(¶ms); - } else { - zephir_get_arrval(¶ms, params_param); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "start", NULL, 0); - zephir_check_call_status(); - ZVAL_BOOL(&_0, 0); - ZEPHIR_CALL_METHOD(&result, this_ptr, "processrender", NULL, 0, &controllerName, &actionName, ¶ms, &_0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "finish", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&result))) { - RETURN_MM_STRING(""); + ZEPHIR_INIT_NVAR(&_26$$21); + ZEPHIR_INIT_NVAR(&joinAliasName); + RETURN_CTOR(&sqlJoins); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getcontent", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_View, engineRender) -{ - zend_string *_9$$3, *_28$$16; - zend_ulong _8$$3, _27$$16; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL, *_13 = NULL, *_16 = NULL, *_20 = NULL, *_23 = NULL, *_32 = NULL, *_35 = NULL, *_39 = NULL, *_42 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool silence, mustClean; - zval viewPath, _45$$30; - zval *engines_param = NULL, *viewPath_param = NULL, *silence_param = NULL, *mustClean_param = NULL, basePath, engine, eventsManager, extension, viewsDir, viewsDirPath, viewEnginePath, viewEnginePaths, viewParams, _0, _1, *_2, _3, _4$$3, *_6$$3, _7$$3, _11$$8, _12$$8, _14$$7, _15$$10, _18$$13, _19$$13, _21$$12, _22$$15, _24$$16, *_25$$16, _26$$16, _30$$21, _31$$21, _33$$20, _34$$23, _37$$26, _38$$26, _40$$25, _41$$28, _43$$29, _44$$30; - zval engines, _10$$8, _17$$13, _29$$21, _36$$26; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&engines); - ZVAL_UNDEF(&_10$$8); - ZVAL_UNDEF(&_17$$13); - ZVAL_UNDEF(&_29$$21); - ZVAL_UNDEF(&_36$$26); - ZVAL_UNDEF(&basePath); - ZVAL_UNDEF(&engine); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&extension); - ZVAL_UNDEF(&viewsDir); - ZVAL_UNDEF(&viewsDirPath); - ZVAL_UNDEF(&viewEnginePath); - ZVAL_UNDEF(&viewEnginePaths); - ZVAL_UNDEF(&viewParams); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_12$$8); - ZVAL_UNDEF(&_14$$7); - ZVAL_UNDEF(&_15$$10); - ZVAL_UNDEF(&_18$$13); - ZVAL_UNDEF(&_19$$13); - ZVAL_UNDEF(&_21$$12); - ZVAL_UNDEF(&_22$$15); - ZVAL_UNDEF(&_24$$16); - ZVAL_UNDEF(&_26$$16); - ZVAL_UNDEF(&_30$$21); - ZVAL_UNDEF(&_31$$21); - ZVAL_UNDEF(&_33$$20); - ZVAL_UNDEF(&_34$$23); - ZVAL_UNDEF(&_37$$26); - ZVAL_UNDEF(&_38$$26); - ZVAL_UNDEF(&_40$$25); - ZVAL_UNDEF(&_41$$28); - ZVAL_UNDEF(&_43$$29); - ZVAL_UNDEF(&_44$$30); - ZVAL_UNDEF(&viewPath); - ZVAL_UNDEF(&_45$$30); - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_ARRAY(engines) - Z_PARAM_STR(viewPath) - Z_PARAM_BOOL(silence) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(mustClean) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 1, &engines_param, &viewPath_param, &silence_param, &mustClean_param); - zephir_get_arrval(&engines, engines_param); - zephir_get_strval(&viewPath, viewPath_param); - if (!mustClean_param) { - mustClean = 1; + ZEPHIR_INIT_NVAR(&fromModels); + array_init(&fromModels); + zephir_is_iterable(&selectTables, 0, "phalcon/Mvc/Model/Query.zep", 2578); + if (Z_TYPE_P(&selectTables) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&selectTables), _35) + { + ZEPHIR_INIT_NVAR(&tableItem); + ZVAL_COPY(&tableItem, _35); + zephir_array_fetch_string(&_37$$24, &tableItem, SL("qualifiedName"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2572); + ZEPHIR_OBS_NVAR(&_38$$24); + zephir_array_fetch_string(&_38$$24, &_37$$24, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2572); + zephir_array_update_zval(&fromModels, &_38$$24, &__$true, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); } else { + ZEPHIR_CALL_METHOD(NULL, &selectTables, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_36, &selectTables, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_36)) { + break; + } + ZEPHIR_CALL_METHOD(&tableItem, &selectTables, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_fetch_string(&_39$$25, &tableItem, SL("qualifiedName"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2572); + ZEPHIR_OBS_NVAR(&_40$$25); + zephir_array_fetch_string(&_40$$25, &_39$$25, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2572); + zephir_array_update_zval(&fromModels, &_40$$25, &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &selectTables, "next", NULL, 0); + zephir_check_call_status(); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("basePath"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&basePath, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("viewParams"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&viewParams, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - ZEPHIR_INIT_VAR(&viewEnginePaths); - array_init(&viewEnginePaths); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getviewsdirs", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&_1, 0, "phalcon/Mvc/View.zep", 1106); - if (Z_TYPE_P(&_1) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_1), _2) + } + ZEPHIR_INIT_NVAR(&tableItem); + ZEPHIR_INIT_VAR(&_41); + zephir_is_iterable(&fromModels, 0, "phalcon/Mvc/Model/Query.zep", 2698); + if (Z_TYPE_P(&fromModels) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&fromModels), _44, _45, _42) { - ZEPHIR_INIT_NVAR(&viewsDir); - ZVAL_COPY(&viewsDir, _2); - ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "isabsolutepath", &_5, 491, &viewPath); - zephir_check_call_status(); - if (!(zephir_is_true(&_4$$3))) { - ZEPHIR_INIT_NVAR(&viewsDirPath); - ZEPHIR_CONCAT_VVV(&viewsDirPath, &basePath, &viewsDir, &viewPath); + ZEPHIR_INIT_NVAR(&fromModelName); + if (_45 != NULL) { + ZVAL_STR_COPY(&fromModelName, _45); } else { - ZEPHIR_CPY_WRT(&viewsDirPath, &viewPath); + ZVAL_LONG(&fromModelName, _44); } - zephir_is_iterable(&engines, 0, "phalcon/Mvc/View.zep", 1101); - if (Z_TYPE_P(&engines) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&engines), _8$$3, _9$$3, _6$$3) + ZEPHIR_INIT_NVAR(&_41); + ZVAL_COPY(&_41, _42); + zephir_is_iterable(&joinModels, 0, "phalcon/Mvc/Model/Query.zep", 2696); + if (Z_TYPE_P(&joinModels) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&joinModels), _48$$26, _49$$26, _46$$26) { - ZEPHIR_INIT_NVAR(&extension); - if (_9$$3 != NULL) { - ZVAL_STR_COPY(&extension, _9$$3); + ZEPHIR_INIT_NVAR(&joinAlias); + if (_49$$26 != NULL) { + ZVAL_STR_COPY(&joinAlias, _49$$26); } else { - ZVAL_LONG(&extension, _8$$3); + ZVAL_LONG(&joinAlias, _48$$26); } - ZEPHIR_INIT_NVAR(&engine); - ZVAL_COPY(&engine, _6$$3); - ZEPHIR_INIT_NVAR(&viewEnginePath); - ZEPHIR_CONCAT_VV(&viewEnginePath, &viewsDirPath, &extension); - if ((zephir_file_exists(&viewEnginePath) == SUCCESS)) { - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_10$$8); - zephir_create_array(&_10$$8, 1, 0); - zephir_array_fast_append(&_10$$8, &viewEnginePath); - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRenderPaths"), &_10$$8); - ZEPHIR_INIT_NVAR(&_12$$8); - ZVAL_STRING(&_12$$8, "view:beforeRenderView"); - ZEPHIR_CALL_METHOD(&_11$$8, &eventsManager, "fire", &_13, 0, &_12$$8, this_ptr, &viewEnginePath); + ZEPHIR_INIT_NVAR(&joinModel); + ZVAL_COPY(&joinModel, _46$$26); + ZEPHIR_OBS_NVAR(&joinSource); + zephir_array_fetch(&joinSource, &joinSources, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2583); + ZEPHIR_OBS_NVAR(&joinType); + zephir_array_fetch(&joinType, &joinTypes, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2588); + ZEPHIR_OBS_NVAR(&preCondition); + if (!(zephir_array_isset_fetch(&preCondition, &joinPreCondition, &joinAlias, 0))) { + ZEPHIR_OBS_NVAR(&modelNameAlias); + zephir_array_fetch(&modelNameAlias, &sqlAliasesModels, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2597); + ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_50, 0, &fromModelName, &modelNameAlias); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&relation)) { + ZEPHIR_CALL_METHOD(&relations, &manager, "getrelationsbetween", &_51, 0, &fromModelName, &modelNameAlias); zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_11$$8)) { - continue; + if (Z_TYPE_P(&relations) == IS_ARRAY) { + if (UNEXPECTED(zephir_fast_count_int(&relations) != 1)) { + ZEPHIR_INIT_NVAR(&_52$$31); + object_init_ex(&_52$$31, phalcon_mvc_model_exception_ce); + zephir_read_property(&_53$$31, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_54$$31); + ZEPHIR_CONCAT_SVSVSV(&_54$$31, "There is more than one relation between models '", &fromModelName, "' and '", &joinModel, "', the join must be done using an alias, when preparing: ", &_53$$31); + ZEPHIR_CALL_METHOD(NULL, &_52$$31, "__construct", &_8, 33, &_54$$31); + zephir_check_call_status(); + zephir_throw_exception_debug(&_52$$31, "phalcon/Mvc/Model/Query.zep", 2623); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_OBS_NVAR(&relation); + zephir_array_fetch_long(&relation, &relations, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2629); } } - if (mustClean) { - ZVAL_BOOL(&_14$$7, 1); - } else { - ZVAL_BOOL(&_14$$7, 0); - } - ZEPHIR_CALL_METHOD(NULL, &engine, "render", NULL, 0, &viewEnginePath, &viewParams, &_14$$7); - zephir_check_call_status(); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_15$$10); - ZVAL_STRING(&_15$$10, "view:afterRenderView"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_16, 0, &_15$$10, this_ptr); + if (Z_TYPE_P(&relation) == IS_OBJECT) { + ZEPHIR_OBS_NVAR(&modelAlias); + zephir_array_fetch(&modelAlias, &sqlModelsAliases, &fromModelName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2640); + ZEPHIR_CALL_METHOD(&_55$$32, &relation, "isthrough", NULL, 0); zephir_check_call_status(); + if (!(zephir_is_true(&_55$$32))) { + ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getsinglejoin", &_56, 465, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); + zephir_check_call_status(); + } else { + ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getmultijoin", &_57, 466, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); + zephir_check_call_status(); + } + if (zephir_array_isset_long(&sqlJoin, 0)) { + zephir_is_iterable(&sqlJoin, 0, "phalcon/Mvc/Model/Query.zep", 2670); + if (Z_TYPE_P(&sqlJoin) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&sqlJoin), _58$$35) + { + ZEPHIR_INIT_NVAR(&sqlJoinItem); + ZVAL_COPY(&sqlJoinItem, _58$$35); + zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2668); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_59$$35, &sqlJoin, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_59$$35)) { + break; + } + ZEPHIR_CALL_METHOD(&sqlJoinItem, &sqlJoin, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2668); + ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&sqlJoinItem); + } else { + zephir_array_append(&sqlJoins, &sqlJoin, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2671); + } + } else { + ZEPHIR_INIT_NVAR(&_60$$39); + zephir_create_array(&_60$$39, 3, 0); + zephir_array_update_string(&_60$$39, SL("type"), &joinType, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_60$$39, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_61$$39); + array_init(&_61$$39); + zephir_array_update_string(&_60$$39, SL("conditions"), &_61$$39, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlJoins, &_60$$39, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2682); } - RETURN_MM_NULL(); + } else { + ZEPHIR_INIT_NVAR(&_62$$40); + zephir_create_array(&_62$$40, 3, 0); + zephir_array_update_string(&_62$$40, SL("type"), &joinType, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_62$$40, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_63$$40); + zephir_create_array(&_63$$40, 1, 0); + zephir_array_fast_append(&_63$$40, &preCondition); + zephir_array_update_string(&_62$$40, SL("conditions"), &_63$$40, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlJoins, &_62$$40, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2693); } - zephir_array_append(&viewEnginePaths, &viewEnginePath, PH_SEPARATE, "phalcon/Mvc/View.zep", 1099); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &engines, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &joinModels, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_7$$3, &engines, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_47$$26, &joinModels, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_7$$3)) { + if (!zend_is_true(&_47$$26)) { break; } - ZEPHIR_CALL_METHOD(&extension, &engines, "key", NULL, 0); + ZEPHIR_CALL_METHOD(&joinAlias, &joinModels, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&engine, &engines, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&joinModel, &joinModels, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&viewEnginePath); - ZEPHIR_CONCAT_VV(&viewEnginePath, &viewsDirPath, &extension); - if ((zephir_file_exists(&viewEnginePath) == SUCCESS)) { - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_17$$13); - zephir_create_array(&_17$$13, 1, 0); - zephir_array_fast_append(&_17$$13, &viewEnginePath); - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRenderPaths"), &_17$$13); - ZEPHIR_INIT_NVAR(&_19$$13); - ZVAL_STRING(&_19$$13, "view:beforeRenderView"); - ZEPHIR_CALL_METHOD(&_18$$13, &eventsManager, "fire", &_20, 0, &_19$$13, this_ptr, &viewEnginePath); + ZEPHIR_OBS_NVAR(&joinSource); + zephir_array_fetch(&joinSource, &joinSources, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2583); + ZEPHIR_OBS_NVAR(&joinType); + zephir_array_fetch(&joinType, &joinTypes, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2588); + ZEPHIR_OBS_NVAR(&preCondition); + if (!(zephir_array_isset_fetch(&preCondition, &joinPreCondition, &joinAlias, 0))) { + ZEPHIR_OBS_NVAR(&modelNameAlias); + zephir_array_fetch(&modelNameAlias, &sqlAliasesModels, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2597); + ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_64, 0, &fromModelName, &modelNameAlias); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&relation)) { + ZEPHIR_CALL_METHOD(&relations, &manager, "getrelationsbetween", &_65, 0, &fromModelName, &modelNameAlias); zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_18$$13)) { - continue; + if (Z_TYPE_P(&relations) == IS_ARRAY) { + if (UNEXPECTED(zephir_fast_count_int(&relations) != 1)) { + ZEPHIR_INIT_NVAR(&_66$$45); + object_init_ex(&_66$$45, phalcon_mvc_model_exception_ce); + zephir_read_property(&_67$$45, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_68$$45); + ZEPHIR_CONCAT_SVSVSV(&_68$$45, "There is more than one relation between models '", &fromModelName, "' and '", &joinModel, "', the join must be done using an alias, when preparing: ", &_67$$45); + ZEPHIR_CALL_METHOD(NULL, &_66$$45, "__construct", &_8, 33, &_68$$45); + zephir_check_call_status(); + zephir_throw_exception_debug(&_66$$45, "phalcon/Mvc/Model/Query.zep", 2623); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_OBS_NVAR(&relation); + zephir_array_fetch_long(&relation, &relations, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2629); } } - if (mustClean) { - ZVAL_BOOL(&_21$$12, 1); - } else { - ZVAL_BOOL(&_21$$12, 0); - } - ZEPHIR_CALL_METHOD(NULL, &engine, "render", NULL, 0, &viewEnginePath, &viewParams, &_21$$12); - zephir_check_call_status(); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_22$$15); - ZVAL_STRING(&_22$$15, "view:afterRenderView"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_23, 0, &_22$$15, this_ptr); + if (Z_TYPE_P(&relation) == IS_OBJECT) { + ZEPHIR_OBS_NVAR(&modelAlias); + zephir_array_fetch(&modelAlias, &sqlModelsAliases, &fromModelName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2640); + ZEPHIR_CALL_METHOD(&_69$$46, &relation, "isthrough", NULL, 0); zephir_check_call_status(); + if (!(zephir_is_true(&_69$$46))) { + ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getsinglejoin", &_56, 465, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); + zephir_check_call_status(); + } else { + ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getmultijoin", &_57, 466, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); + zephir_check_call_status(); + } + if (zephir_array_isset_long(&sqlJoin, 0)) { + zephir_is_iterable(&sqlJoin, 0, "phalcon/Mvc/Model/Query.zep", 2670); + if (Z_TYPE_P(&sqlJoin) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&sqlJoin), _70$$49) + { + ZEPHIR_INIT_NVAR(&sqlJoinItem); + ZVAL_COPY(&sqlJoinItem, _70$$49); + zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2668); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_71$$49, &sqlJoin, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_71$$49)) { + break; + } + ZEPHIR_CALL_METHOD(&sqlJoinItem, &sqlJoin, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2668); + ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&sqlJoinItem); + } else { + zephir_array_append(&sqlJoins, &sqlJoin, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2671); + } + } else { + ZEPHIR_INIT_NVAR(&_72$$53); + zephir_create_array(&_72$$53, 3, 0); + zephir_array_update_string(&_72$$53, SL("type"), &joinType, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_72$$53, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_73$$53); + array_init(&_73$$53); + zephir_array_update_string(&_72$$53, SL("conditions"), &_73$$53, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlJoins, &_72$$53, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2682); } - RETURN_MM_NULL(); + } else { + ZEPHIR_INIT_NVAR(&_74$$54); + zephir_create_array(&_74$$54, 3, 0); + zephir_array_update_string(&_74$$54, SL("type"), &joinType, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_74$$54, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_75$$54); + zephir_create_array(&_75$$54, 1, 0); + zephir_array_fast_append(&_75$$54, &preCondition); + zephir_array_update_string(&_74$$54, SL("conditions"), &_75$$54, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlJoins, &_74$$54, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2693); } - zephir_array_append(&viewEnginePaths, &viewEnginePath, PH_SEPARATE, "phalcon/Mvc/View.zep", 1099); - ZEPHIR_CALL_METHOD(NULL, &engines, "next", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &joinModels, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&engine); - ZEPHIR_INIT_NVAR(&extension); - } ZEND_HASH_FOREACH_END(); + ZEPHIR_INIT_NVAR(&joinModel); + ZEPHIR_INIT_NVAR(&joinAlias); + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &_1, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &fromModels, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_3, &_1, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_43, &fromModels, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_3)) { + if (!zend_is_true(&_43)) { break; } - ZEPHIR_CALL_METHOD(&viewsDir, &_1, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&fromModelName, &fromModels, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_24$$16, this_ptr, "isabsolutepath", &_5, 491, &viewPath); - zephir_check_call_status(); - if (!(zephir_is_true(&_24$$16))) { - ZEPHIR_INIT_NVAR(&viewsDirPath); - ZEPHIR_CONCAT_VVV(&viewsDirPath, &basePath, &viewsDir, &viewPath); - } else { - ZEPHIR_CPY_WRT(&viewsDirPath, &viewPath); - } - zephir_is_iterable(&engines, 0, "phalcon/Mvc/View.zep", 1101); - if (Z_TYPE_P(&engines) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&engines), _27$$16, _28$$16, _25$$16) + ZEPHIR_CALL_METHOD(&_41, &fromModels, "current", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&joinModels, 0, "phalcon/Mvc/Model/Query.zep", 2696); + if (Z_TYPE_P(&joinModels) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&joinModels), _78$$55, _79$$55, _76$$55) { - ZEPHIR_INIT_NVAR(&extension); - if (_28$$16 != NULL) { - ZVAL_STR_COPY(&extension, _28$$16); + ZEPHIR_INIT_NVAR(&joinAlias); + if (_79$$55 != NULL) { + ZVAL_STR_COPY(&joinAlias, _79$$55); } else { - ZVAL_LONG(&extension, _27$$16); + ZVAL_LONG(&joinAlias, _78$$55); } - ZEPHIR_INIT_NVAR(&engine); - ZVAL_COPY(&engine, _25$$16); - ZEPHIR_INIT_NVAR(&viewEnginePath); - ZEPHIR_CONCAT_VV(&viewEnginePath, &viewsDirPath, &extension); - if ((zephir_file_exists(&viewEnginePath) == SUCCESS)) { - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_29$$21); - zephir_create_array(&_29$$21, 1, 0); - zephir_array_fast_append(&_29$$21, &viewEnginePath); - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRenderPaths"), &_29$$21); - ZEPHIR_INIT_NVAR(&_31$$21); - ZVAL_STRING(&_31$$21, "view:beforeRenderView"); - ZEPHIR_CALL_METHOD(&_30$$21, &eventsManager, "fire", &_32, 0, &_31$$21, this_ptr, &viewEnginePath); + ZEPHIR_INIT_NVAR(&joinModel); + ZVAL_COPY(&joinModel, _76$$55); + ZEPHIR_OBS_NVAR(&joinSource); + zephir_array_fetch(&joinSource, &joinSources, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2583); + ZEPHIR_OBS_NVAR(&joinType); + zephir_array_fetch(&joinType, &joinTypes, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2588); + ZEPHIR_OBS_NVAR(&preCondition); + if (!(zephir_array_isset_fetch(&preCondition, &joinPreCondition, &joinAlias, 0))) { + ZEPHIR_OBS_NVAR(&modelNameAlias); + zephir_array_fetch(&modelNameAlias, &sqlAliasesModels, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2597); + ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_80, 0, &fromModelName, &modelNameAlias); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&relation)) { + ZEPHIR_CALL_METHOD(&relations, &manager, "getrelationsbetween", &_81, 0, &fromModelName, &modelNameAlias); zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_30$$21)) { - continue; + if (Z_TYPE_P(&relations) == IS_ARRAY) { + if (UNEXPECTED(zephir_fast_count_int(&relations) != 1)) { + ZEPHIR_INIT_NVAR(&_82$$60); + object_init_ex(&_82$$60, phalcon_mvc_model_exception_ce); + zephir_read_property(&_83$$60, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_84$$60); + ZEPHIR_CONCAT_SVSVSV(&_84$$60, "There is more than one relation between models '", &fromModelName, "' and '", &joinModel, "', the join must be done using an alias, when preparing: ", &_83$$60); + ZEPHIR_CALL_METHOD(NULL, &_82$$60, "__construct", &_8, 33, &_84$$60); + zephir_check_call_status(); + zephir_throw_exception_debug(&_82$$60, "phalcon/Mvc/Model/Query.zep", 2623); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_OBS_NVAR(&relation); + zephir_array_fetch_long(&relation, &relations, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2629); } } - if (mustClean) { - ZVAL_BOOL(&_33$$20, 1); - } else { - ZVAL_BOOL(&_33$$20, 0); - } - ZEPHIR_CALL_METHOD(NULL, &engine, "render", NULL, 0, &viewEnginePath, &viewParams, &_33$$20); - zephir_check_call_status(); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_34$$23); - ZVAL_STRING(&_34$$23, "view:afterRenderView"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_35, 0, &_34$$23, this_ptr); + if (Z_TYPE_P(&relation) == IS_OBJECT) { + ZEPHIR_OBS_NVAR(&modelAlias); + zephir_array_fetch(&modelAlias, &sqlModelsAliases, &fromModelName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2640); + ZEPHIR_CALL_METHOD(&_85$$61, &relation, "isthrough", NULL, 0); zephir_check_call_status(); + if (!(zephir_is_true(&_85$$61))) { + ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getsinglejoin", &_56, 465, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); + zephir_check_call_status(); + } else { + ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getmultijoin", &_57, 466, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); + zephir_check_call_status(); + } + if (zephir_array_isset_long(&sqlJoin, 0)) { + zephir_is_iterable(&sqlJoin, 0, "phalcon/Mvc/Model/Query.zep", 2670); + if (Z_TYPE_P(&sqlJoin) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&sqlJoin), _86$$64) + { + ZEPHIR_INIT_NVAR(&sqlJoinItem); + ZVAL_COPY(&sqlJoinItem, _86$$64); + zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2668); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_87$$64, &sqlJoin, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_87$$64)) { + break; + } + ZEPHIR_CALL_METHOD(&sqlJoinItem, &sqlJoin, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2668); + ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&sqlJoinItem); + } else { + zephir_array_append(&sqlJoins, &sqlJoin, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2671); + } + } else { + ZEPHIR_INIT_NVAR(&_88$$68); + zephir_create_array(&_88$$68, 3, 0); + zephir_array_update_string(&_88$$68, SL("type"), &joinType, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_88$$68, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_89$$68); + array_init(&_89$$68); + zephir_array_update_string(&_88$$68, SL("conditions"), &_89$$68, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlJoins, &_88$$68, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2682); } - RETURN_MM_NULL(); + } else { + ZEPHIR_INIT_NVAR(&_90$$69); + zephir_create_array(&_90$$69, 3, 0); + zephir_array_update_string(&_90$$69, SL("type"), &joinType, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_90$$69, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_91$$69); + zephir_create_array(&_91$$69, 1, 0); + zephir_array_fast_append(&_91$$69, &preCondition); + zephir_array_update_string(&_90$$69, SL("conditions"), &_91$$69, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlJoins, &_90$$69, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2693); } - zephir_array_append(&viewEnginePaths, &viewEnginePath, PH_SEPARATE, "phalcon/Mvc/View.zep", 1099); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &engines, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &joinModels, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_26$$16, &engines, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_77$$55, &joinModels, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_26$$16)) { + if (!zend_is_true(&_77$$55)) { break; } - ZEPHIR_CALL_METHOD(&extension, &engines, "key", NULL, 0); + ZEPHIR_CALL_METHOD(&joinAlias, &joinModels, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&engine, &engines, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&joinModel, &joinModels, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&viewEnginePath); - ZEPHIR_CONCAT_VV(&viewEnginePath, &viewsDirPath, &extension); - if ((zephir_file_exists(&viewEnginePath) == SUCCESS)) { - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_36$$26); - zephir_create_array(&_36$$26, 1, 0); - zephir_array_fast_append(&_36$$26, &viewEnginePath); - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRenderPaths"), &_36$$26); - ZEPHIR_INIT_NVAR(&_38$$26); - ZVAL_STRING(&_38$$26, "view:beforeRenderView"); - ZEPHIR_CALL_METHOD(&_37$$26, &eventsManager, "fire", &_39, 0, &_38$$26, this_ptr, &viewEnginePath); + ZEPHIR_OBS_NVAR(&joinSource); + zephir_array_fetch(&joinSource, &joinSources, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2583); + ZEPHIR_OBS_NVAR(&joinType); + zephir_array_fetch(&joinType, &joinTypes, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2588); + ZEPHIR_OBS_NVAR(&preCondition); + if (!(zephir_array_isset_fetch(&preCondition, &joinPreCondition, &joinAlias, 0))) { + ZEPHIR_OBS_NVAR(&modelNameAlias); + zephir_array_fetch(&modelNameAlias, &sqlAliasesModels, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2597); + ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_92, 0, &fromModelName, &modelNameAlias); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&relation)) { + ZEPHIR_CALL_METHOD(&relations, &manager, "getrelationsbetween", &_93, 0, &fromModelName, &modelNameAlias); zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_37$$26)) { - continue; + if (Z_TYPE_P(&relations) == IS_ARRAY) { + if (UNEXPECTED(zephir_fast_count_int(&relations) != 1)) { + ZEPHIR_INIT_NVAR(&_94$$74); + object_init_ex(&_94$$74, phalcon_mvc_model_exception_ce); + zephir_read_property(&_95$$74, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_96$$74); + ZEPHIR_CONCAT_SVSVSV(&_96$$74, "There is more than one relation between models '", &fromModelName, "' and '", &joinModel, "', the join must be done using an alias, when preparing: ", &_95$$74); + ZEPHIR_CALL_METHOD(NULL, &_94$$74, "__construct", &_8, 33, &_96$$74); + zephir_check_call_status(); + zephir_throw_exception_debug(&_94$$74, "phalcon/Mvc/Model/Query.zep", 2623); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_OBS_NVAR(&relation); + zephir_array_fetch_long(&relation, &relations, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2629); } } - if (mustClean) { - ZVAL_BOOL(&_40$$25, 1); - } else { - ZVAL_BOOL(&_40$$25, 0); - } - ZEPHIR_CALL_METHOD(NULL, &engine, "render", NULL, 0, &viewEnginePath, &viewParams, &_40$$25); - zephir_check_call_status(); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_41$$28); - ZVAL_STRING(&_41$$28, "view:afterRenderView"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_42, 0, &_41$$28, this_ptr); + if (Z_TYPE_P(&relation) == IS_OBJECT) { + ZEPHIR_OBS_NVAR(&modelAlias); + zephir_array_fetch(&modelAlias, &sqlModelsAliases, &fromModelName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2640); + ZEPHIR_CALL_METHOD(&_97$$75, &relation, "isthrough", NULL, 0); zephir_check_call_status(); + if (!(zephir_is_true(&_97$$75))) { + ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getsinglejoin", &_56, 465, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); + zephir_check_call_status(); + } else { + ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getmultijoin", &_57, 466, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); + zephir_check_call_status(); + } + if (zephir_array_isset_long(&sqlJoin, 0)) { + zephir_is_iterable(&sqlJoin, 0, "phalcon/Mvc/Model/Query.zep", 2670); + if (Z_TYPE_P(&sqlJoin) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&sqlJoin), _98$$78) + { + ZEPHIR_INIT_NVAR(&sqlJoinItem); + ZVAL_COPY(&sqlJoinItem, _98$$78); + zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2668); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_99$$78, &sqlJoin, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_99$$78)) { + break; + } + ZEPHIR_CALL_METHOD(&sqlJoinItem, &sqlJoin, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2668); + ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&sqlJoinItem); + } else { + zephir_array_append(&sqlJoins, &sqlJoin, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2671); + } + } else { + ZEPHIR_INIT_NVAR(&_100$$82); + zephir_create_array(&_100$$82, 3, 0); + zephir_array_update_string(&_100$$82, SL("type"), &joinType, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_100$$82, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_101$$82); + array_init(&_101$$82); + zephir_array_update_string(&_100$$82, SL("conditions"), &_101$$82, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlJoins, &_100$$82, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2682); } - RETURN_MM_NULL(); + } else { + ZEPHIR_INIT_NVAR(&_102$$83); + zephir_create_array(&_102$$83, 3, 0); + zephir_array_update_string(&_102$$83, SL("type"), &joinType, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_102$$83, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_103$$83); + zephir_create_array(&_103$$83, 1, 0); + zephir_array_fast_append(&_103$$83, &preCondition); + zephir_array_update_string(&_102$$83, SL("conditions"), &_103$$83, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlJoins, &_102$$83, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2693); } - zephir_array_append(&viewEnginePaths, &viewEnginePath, PH_SEPARATE, "phalcon/Mvc/View.zep", 1099); - ZEPHIR_CALL_METHOD(NULL, &engines, "next", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &joinModels, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&engine); - ZEPHIR_INIT_NVAR(&extension); - ZEPHIR_CALL_METHOD(NULL, &_1, "next", NULL, 0); + ZEPHIR_INIT_NVAR(&joinModel); + ZEPHIR_INIT_NVAR(&joinAlias); + ZEPHIR_CALL_METHOD(NULL, &fromModels, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&viewsDir); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRenderPaths"), &viewEnginePaths); - ZEPHIR_INIT_VAR(&_43$$29); - ZVAL_STRING(&_43$$29, "view:notFoundView"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_43$$29, this_ptr, &viewEnginePath); - zephir_check_call_status(); - } - if (!(silence)) { - ZEPHIR_INIT_VAR(&_44$$30); - object_init_ex(&_44$$30, phalcon_mvc_view_exception_ce); - ZEPHIR_INIT_VAR(&_45$$30); - ZEPHIR_CONCAT_SVS(&_45$$30, "View '", &viewPath, "' was not found in any of the views directory"); - ZEPHIR_CALL_METHOD(NULL, &_44$$30, "__construct", NULL, 33, &_45$$30); - zephir_check_call_status(); - zephir_throw_exception_debug(&_44$$30, "phalcon/Mvc/View.zep", 1115); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_MM_RESTORE(); + ZEPHIR_INIT_NVAR(&_41); + ZEPHIR_INIT_NVAR(&fromModelName); + RETURN_CTOR(&sqlJoins); } -static PHP_METHOD(Phalcon_Mvc_View, isAbsolutePath) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getMultiJoin) { - unsigned char _6, _2$$3, _4$$3; - zend_bool _5, _1$$3, _3$$3; + zend_string *_4$$3; + zend_ulong _3$$3; + zval sqlJoins, _10$$4, _12$$4, _18$$6, _19$$6, _21$$8, _22$$8, _23$$8, _25$$8, _26$$8, _27$$8, _28$$8; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *path_param = NULL, _0; - zval path; + zephir_fcall_cache_entry *_8 = NULL, *_11 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *joinType_param = NULL, *joinSource, joinSource_sub, *modelAlias_param = NULL, *joinAlias_param = NULL, *relation, relation_sub, fields, referencedFields, intermediateModelName, intermediateModel, intermediateSource, intermediateSchema, intermediateFields, intermediateReferencedFields, referencedModelName, manager, field, position, intermediateField, sqlEqualsJoinCondition, _0, *_1$$3, _2$$3, _5$$5, _6$$5, _7$$5, _9$$4, _13$$7, _14$$7, _15$$7, _16$$6, _17$$6, _20$$8, _24$$8; + zval joinType, modelAlias, joinAlias; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&path); + ZVAL_UNDEF(&joinType); + ZVAL_UNDEF(&modelAlias); + ZVAL_UNDEF(&joinAlias); + ZVAL_UNDEF(&joinSource_sub); + ZVAL_UNDEF(&relation_sub); + ZVAL_UNDEF(&fields); + ZVAL_UNDEF(&referencedFields); + ZVAL_UNDEF(&intermediateModelName); + ZVAL_UNDEF(&intermediateModel); + ZVAL_UNDEF(&intermediateSource); + ZVAL_UNDEF(&intermediateSchema); + ZVAL_UNDEF(&intermediateFields); + ZVAL_UNDEF(&intermediateReferencedFields); + ZVAL_UNDEF(&referencedModelName); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&position); + ZVAL_UNDEF(&intermediateField); + ZVAL_UNDEF(&sqlEqualsJoinCondition); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(path) + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&_13$$7); + ZVAL_UNDEF(&_14$$7); + ZVAL_UNDEF(&_15$$7); + ZVAL_UNDEF(&_16$$6); + ZVAL_UNDEF(&_17$$6); + ZVAL_UNDEF(&_20$$8); + ZVAL_UNDEF(&_24$$8); + ZVAL_UNDEF(&sqlJoins); + ZVAL_UNDEF(&_10$$4); + ZVAL_UNDEF(&_12$$4); + ZVAL_UNDEF(&_18$$6); + ZVAL_UNDEF(&_19$$6); + ZVAL_UNDEF(&_21$$8); + ZVAL_UNDEF(&_22$$8); + ZVAL_UNDEF(&_23$$8); + ZVAL_UNDEF(&_25$$8); + ZVAL_UNDEF(&_26$$8); + ZVAL_UNDEF(&_27$$8); + ZVAL_UNDEF(&_28$$8); + ZEND_PARSE_PARAMETERS_START(5, 5) + Z_PARAM_STR(joinType) + Z_PARAM_ZVAL(joinSource) + Z_PARAM_STR(modelAlias) + Z_PARAM_STR(joinAlias) + Z_PARAM_OBJECT_OF_CLASS(relation, phalcon_mvc_model_relationinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &path_param); - zephir_get_strval(&path, path_param); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_GET_CONSTANT(&_0, "PHP_OS"); - if (ZEPHIR_IS_STRING_IDENTICAL(&_0, "WINNT")) { - _1$$3 = zephir_fast_strlen_ev(&path) >= 3; - if (_1$$3) { - _2$$3 = ZEPHIR_STRING_OFFSET(&path, 1); - _1$$3 = _2$$3 == ':'; - } - _3$$3 = _1$$3; - if (_3$$3) { - _4$$3 = ZEPHIR_STRING_OFFSET(&path, 2); - _3$$3 = _4$$3 == '\\'; - } - RETURN_MM_BOOL(_3$$3); + zephir_fetch_params(1, 5, 0, &joinType_param, &joinSource, &modelAlias_param, &joinAlias_param, &relation); + if (UNEXPECTED(Z_TYPE_P(joinType_param) != IS_STRING && Z_TYPE_P(joinType_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'joinType' must be of the type string")); + RETURN_MM_NULL(); } - _5 = zephir_fast_strlen_ev(&path) >= 1; - if (_5) { - _6 = ZEPHIR_STRING_OFFSET(&path, 0); - _5 = _6 == '/'; + if (EXPECTED(Z_TYPE_P(joinType_param) == IS_STRING)) { + zephir_get_strval(&joinType, joinType_param); + } else { + ZEPHIR_INIT_VAR(&joinType); } - RETURN_MM_BOOL(_5); + zephir_get_strval(&modelAlias, modelAlias_param); + zephir_get_strval(&joinAlias, joinAlias_param); + ZEPHIR_INIT_VAR(&sqlJoins); + array_init(&sqlJoins); + ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&referencedFields, relation, "getreferencedfields", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&intermediateModelName, relation, "getintermediatemodel", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&manager, &_0); + ZEPHIR_CALL_METHOD(&intermediateModel, &manager, "load", NULL, 0, &intermediateModelName); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&intermediateSource, &intermediateModel, "getsource", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&intermediateSchema, &intermediateModel, "getschema", NULL, 0); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("sqlAliases"), &intermediateModelName, &intermediateSource); + zephir_update_property_array(this_ptr, SL("sqlAliasesModelsInstances"), &intermediateModelName, &intermediateModel); + ZEPHIR_CALL_METHOD(&intermediateFields, relation, "getintermediatefields", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&intermediateReferencedFields, relation, "getintermediatereferencedfields", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&referencedModelName, relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&fields) == IS_ARRAY) { + zephir_is_iterable(&fields, 0, "phalcon/Mvc/Model/Query.zep", 2815); + if (Z_TYPE_P(&fields) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&fields), _3$$3, _4$$3, _1$$3) + { + ZEPHIR_INIT_NVAR(&field); + if (_4$$3 != NULL) { + ZVAL_STR_COPY(&field, _4$$3); + } else { + ZVAL_LONG(&field, _3$$3); + } + ZEPHIR_INIT_NVAR(&position); + ZVAL_COPY(&position, _1$$3); + if (UNEXPECTED(!(zephir_array_isset(&referencedFields, &position)))) { + ZEPHIR_INIT_NVAR(&_5$$5); + object_init_ex(&_5$$5, phalcon_mvc_model_exception_ce); + zephir_read_property(&_6$$5, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_7$$5); + ZEPHIR_CONCAT_SVSVSV(&_7$$5, "The number of fields must be equal to the number of referenced fields in join ", &modelAlias, "-", &joinAlias, ", when preparing: ", &_6$$5); + ZEPHIR_CALL_METHOD(NULL, &_5$$5, "__construct", &_8, 33, &_7$$5); + zephir_check_call_status(); + zephir_throw_exception_debug(&_5$$5, "phalcon/Mvc/Model/Query.zep", 2782); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_OBS_NVAR(&intermediateField); + zephir_array_fetch(&intermediateField, &intermediateFields, &position, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2788); + ZEPHIR_INIT_NVAR(&sqlEqualsJoinCondition); + zephir_create_array(&sqlEqualsJoinCondition, 4, 0); + add_assoc_stringl_ex(&sqlEqualsJoinCondition, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&sqlEqualsJoinCondition, SL("op"), SL("=")); + ZEPHIR_INIT_NVAR(&_10$$4); + zephir_create_array(&_10$$4, 3, 0); + add_assoc_long_ex(&_10$$4, SL("type"), 355); + zephir_array_update_string(&_10$$4, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_10$$4, SL("name"), &field, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_9$$4, this_ptr, "getqualified", &_11, 459, &_10$$4); + zephir_check_call_status(); + zephir_array_update_string(&sqlEqualsJoinCondition, SL("left"), &_9$$4, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_12$$4); + zephir_create_array(&_12$$4, 3, 0); + add_assoc_stringl_ex(&_12$$4, SL("type"), SL("qualified")); + zephir_array_update_string(&_12$$4, SL("domain"), &joinAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_12$$4, SL("name"), &referencedFields, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_9$$4, this_ptr, "getqualified", &_11, 459, &_12$$4); + zephir_check_call_status(); + zephir_array_update_string(&sqlEqualsJoinCondition, SL("right"), &_9$$4, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2$$3, &fields, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&field, &fields, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&position, &fields, "current", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(!(zephir_array_isset(&referencedFields, &position)))) { + ZEPHIR_INIT_NVAR(&_13$$7); + object_init_ex(&_13$$7, phalcon_mvc_model_exception_ce); + zephir_read_property(&_14$$7, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_15$$7); + ZEPHIR_CONCAT_SVSVSV(&_15$$7, "The number of fields must be equal to the number of referenced fields in join ", &modelAlias, "-", &joinAlias, ", when preparing: ", &_14$$7); + ZEPHIR_CALL_METHOD(NULL, &_13$$7, "__construct", &_8, 33, &_15$$7); + zephir_check_call_status(); + zephir_throw_exception_debug(&_13$$7, "phalcon/Mvc/Model/Query.zep", 2782); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_OBS_NVAR(&intermediateField); + zephir_array_fetch(&intermediateField, &intermediateFields, &position, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2788); + ZEPHIR_INIT_NVAR(&_16$$6); + zephir_create_array(&_16$$6, 4, 0); + add_assoc_stringl_ex(&_16$$6, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_16$$6, SL("op"), SL("=")); + ZEPHIR_INIT_NVAR(&_18$$6); + zephir_create_array(&_18$$6, 3, 0); + add_assoc_long_ex(&_18$$6, SL("type"), 355); + zephir_array_update_string(&_18$$6, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_18$$6, SL("name"), &field, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_17$$6, this_ptr, "getqualified", &_11, 459, &_18$$6); + zephir_check_call_status(); + zephir_array_update_string(&_16$$6, SL("left"), &_17$$6, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_19$$6); + zephir_create_array(&_19$$6, 3, 0); + add_assoc_stringl_ex(&_19$$6, SL("type"), SL("qualified")); + zephir_array_update_string(&_19$$6, SL("domain"), &joinAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_19$$6, SL("name"), &referencedFields, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_17$$6, this_ptr, "getqualified", &_11, 459, &_19$$6); + zephir_check_call_status(); + zephir_array_update_string(&_16$$6, SL("right"), &_17$$6, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&sqlEqualsJoinCondition, &_16$$6); + ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&position); + ZEPHIR_INIT_NVAR(&field); + } else { + ZEPHIR_INIT_VAR(&_20$$8); + zephir_create_array(&_20$$8, 2, 0); + ZEPHIR_INIT_VAR(&_21$$8); + zephir_create_array(&_21$$8, 3, 0); + zephir_array_update_string(&_21$$8, SL("type"), &joinType, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_22$$8); + zephir_create_array(&_22$$8, 2, 0); + zephir_array_fast_append(&_22$$8, &intermediateSource); + zephir_array_fast_append(&_22$$8, &intermediateSchema); + zephir_array_update_string(&_21$$8, SL("source"), &_22$$8, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_22$$8); + zephir_create_array(&_22$$8, 1, 0); + ZEPHIR_INIT_VAR(&_23$$8); + zephir_create_array(&_23$$8, 4, 0); + add_assoc_stringl_ex(&_23$$8, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_23$$8, SL("op"), SL("=")); + ZEPHIR_INIT_VAR(&_25$$8); + zephir_create_array(&_25$$8, 3, 0); + add_assoc_long_ex(&_25$$8, SL("type"), 355); + zephir_array_update_string(&_25$$8, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_25$$8, SL("name"), &fields, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_24$$8, this_ptr, "getqualified", &_11, 459, &_25$$8); + zephir_check_call_status(); + zephir_array_update_string(&_23$$8, SL("left"), &_24$$8, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_26$$8); + zephir_create_array(&_26$$8, 3, 0); + add_assoc_stringl_ex(&_26$$8, SL("type"), SL("qualified")); + zephir_array_update_string(&_26$$8, SL("domain"), &intermediateModelName, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_26$$8, SL("name"), &intermediateFields, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_24$$8, this_ptr, "getqualified", &_11, 459, &_26$$8); + zephir_check_call_status(); + zephir_array_update_string(&_23$$8, SL("right"), &_24$$8, PH_COPY | PH_SEPARATE); + zephir_array_fast_append(&_22$$8, &_23$$8); + zephir_array_update_string(&_21$$8, SL("conditions"), &_22$$8, PH_COPY | PH_SEPARATE); + zephir_array_fast_append(&_20$$8, &_21$$8); + ZEPHIR_INIT_NVAR(&_21$$8); + zephir_create_array(&_21$$8, 3, 0); + zephir_array_update_string(&_21$$8, SL("type"), &joinType, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_21$$8, SL("source"), joinSource, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_22$$8); + zephir_create_array(&_22$$8, 1, 0); + ZEPHIR_INIT_NVAR(&_23$$8); + zephir_create_array(&_23$$8, 4, 0); + add_assoc_stringl_ex(&_23$$8, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_23$$8, SL("op"), SL("=")); + ZEPHIR_INIT_VAR(&_27$$8); + zephir_create_array(&_27$$8, 3, 0); + add_assoc_long_ex(&_27$$8, SL("type"), 355); + zephir_array_update_string(&_27$$8, SL("domain"), &intermediateModelName, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_27$$8, SL("name"), &intermediateReferencedFields, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_24$$8, this_ptr, "getqualified", &_11, 459, &_27$$8); + zephir_check_call_status(); + zephir_array_update_string(&_23$$8, SL("left"), &_24$$8, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_28$$8); + zephir_create_array(&_28$$8, 3, 0); + add_assoc_stringl_ex(&_28$$8, SL("type"), SL("qualified")); + zephir_array_update_string(&_28$$8, SL("domain"), &referencedModelName, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_28$$8, SL("name"), &referencedFields, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_24$$8, this_ptr, "getqualified", &_11, 459, &_28$$8); + zephir_check_call_status(); + zephir_array_update_string(&_23$$8, SL("right"), &_24$$8, PH_COPY | PH_SEPARATE); + zephir_array_fast_append(&_22$$8, &_23$$8); + zephir_array_update_string(&_21$$8, SL("conditions"), &_22$$8, PH_COPY | PH_SEPARATE); + zephir_array_fast_append(&_20$$8, &_21$$8); + ZEPHIR_CPY_WRT(&sqlJoins, &_20$$8); + } + RETURN_CTOR(&sqlJoins); } -static PHP_METHOD(Phalcon_Mvc_View, loadTemplateEngines) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getOrderClause) { - zval _15$$11, _21$$17; - zend_class_entry *_8$$9, *_17$$15; - zend_string *_6$$5; - zend_ulong _5$$5; - zval engines, di, registeredEngines, engineService, extension, _0, _1$$3, _2$$4, *_3$$5, _4$$5, _7$$9, _11$$12, _12$$12, _14$$11, _16$$15, _18$$18, _19$$18, _20$$17; + zval orderParts, orderPartSort; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_9 = NULL, *_10 = NULL, *_13 = NULL; + zephir_fcall_cache_entry *_3 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *order, order_sub, orderColumns, orderItem, orderPartExpr, orderSort, *_0, _1, _2$$5, _4$$7, _5$$8, _6$$8, _7$$9, _8$$10, _9$$12, _10$$12, _11$$13, _12$$13, _13$$14; zval *this_ptr = getThis(); - ZVAL_UNDEF(&engines); - ZVAL_UNDEF(&di); - ZVAL_UNDEF(®isteredEngines); - ZVAL_UNDEF(&engineService); - ZVAL_UNDEF(&extension); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&order_sub); + ZVAL_UNDEF(&orderColumns); + ZVAL_UNDEF(&orderItem); + ZVAL_UNDEF(&orderPartExpr); + ZVAL_UNDEF(&orderSort); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_4$$7); + ZVAL_UNDEF(&_5$$8); + ZVAL_UNDEF(&_6$$8); ZVAL_UNDEF(&_7$$9); - ZVAL_UNDEF(&_11$$12); - ZVAL_UNDEF(&_12$$12); - ZVAL_UNDEF(&_14$$11); - ZVAL_UNDEF(&_16$$15); - ZVAL_UNDEF(&_18$$18); - ZVAL_UNDEF(&_19$$18); - ZVAL_UNDEF(&_20$$17); - ZVAL_UNDEF(&_15$$11); - ZVAL_UNDEF(&_21$$17); + ZVAL_UNDEF(&_8$$10); + ZVAL_UNDEF(&_9$$12); + ZVAL_UNDEF(&_10$$12); + ZVAL_UNDEF(&_11$$13); + ZVAL_UNDEF(&_12$$13); + ZVAL_UNDEF(&_13$$14); + ZVAL_UNDEF(&orderParts); + ZVAL_UNDEF(&orderPartSort); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(order) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("engines"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&engines, &_0); - if (ZEPHIR_IS_FALSE_IDENTICAL(&engines)) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&di, &_1$$3); - ZEPHIR_INIT_NVAR(&engines); - array_init(&engines); - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("registeredEngines"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(®isteredEngines, &_1$$3); - if (ZEPHIR_IS_EMPTY(®isteredEngines)) { - ZEPHIR_INIT_VAR(&_2$$4); - object_init_ex(&_2$$4, phalcon_mvc_view_engine_php_ce); - ZEPHIR_CALL_METHOD(NULL, &_2$$4, "__construct", NULL, 492, this_ptr, &di); + zephir_fetch_params(1, 1, 0, &order); + if (!(zephir_array_isset_long(order, 0))) { + ZEPHIR_INIT_VAR(&orderColumns); + zephir_create_array(&orderColumns, 1, 0); + zephir_array_fast_append(&orderColumns, order); + } else { + ZEPHIR_CPY_WRT(&orderColumns, order); + } + ZEPHIR_INIT_VAR(&orderParts); + array_init(&orderParts); + zephir_is_iterable(&orderColumns, 0, "phalcon/Mvc/Model/Query.zep", 2924); + if (Z_TYPE_P(&orderColumns) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&orderColumns), _0) + { + ZEPHIR_INIT_NVAR(&orderItem); + ZVAL_COPY(&orderItem, _0); + zephir_array_fetch_string(&_2$$5, &orderItem, SL("column"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2906); + ZEPHIR_CALL_METHOD(&orderPartExpr, this_ptr, "getexpression", &_3, 458, &_2$$5); zephir_check_call_status(); - zephir_array_update_string(&engines, SL(".phtml"), &_2$$4, PH_COPY | PH_SEPARATE); - } else { - if (Z_TYPE_P(&di) != IS_OBJECT) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "A dependency injection container is required to access application services", "phalcon/Mvc/View.zep", 1159); - return; - } - zephir_is_iterable(®isteredEngines, 0, "phalcon/Mvc/View.zep", 1196); - if (Z_TYPE_P(®isteredEngines) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(®isteredEngines), _5$$5, _6$$5, _3$$5) - { - ZEPHIR_INIT_NVAR(&extension); - if (_6$$5 != NULL) { - ZVAL_STR_COPY(&extension, _6$$5); - } else { - ZVAL_LONG(&extension, _5$$5); - } - ZEPHIR_INIT_NVAR(&engineService); - ZVAL_COPY(&engineService, _3$$5); - if (Z_TYPE_P(&engineService) == IS_OBJECT) { - if (zephir_is_instance_of(&engineService, SL("Closure"))) { - _8$$9 = zephir_fetch_class_str_ex(SL("Closure"), ZEND_FETCH_CLASS_AUTO); - ZEPHIR_CALL_CE_STATIC(&_7$$9, _8$$9, "bind", &_9, 0, &engineService, &di); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&engineService, &_7$$9); - ZEPHIR_CALL_FUNCTION(&_7$$9, "call_user_func", &_10, 188, &engineService, this_ptr); - zephir_check_call_status(); - zephir_array_update_zval(&engines, &extension, &_7$$9, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&engines, &extension, &engineService, PH_COPY | PH_SEPARATE); - } - } else { - if (Z_TYPE_P(&engineService) != IS_STRING) { - ZEPHIR_INIT_NVAR(&_11$$12); - object_init_ex(&_11$$12, phalcon_mvc_view_exception_ce); - ZEPHIR_INIT_NVAR(&_12$$12); - ZEPHIR_CONCAT_SV(&_12$$12, "Invalid template engine registration for extension: ", &extension); - ZEPHIR_CALL_METHOD(NULL, &_11$$12, "__construct", &_13, 33, &_12$$12); - zephir_check_call_status(); - zephir_throw_exception_debug(&_11$$12, "phalcon/Mvc/View.zep", 1187); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_NVAR(&_15$$11); - zephir_create_array(&_15$$11, 1, 0); - zephir_array_fast_append(&_15$$11, this_ptr); - ZEPHIR_CALL_METHOD(&_14$$11, &di, "get", NULL, 0, &engineService, &_15$$11); - zephir_check_call_status(); - zephir_array_update_zval(&engines, &extension, &_14$$11, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); + if (zephir_array_isset_string_fetch(&orderSort, &orderItem, SL("sort"), 1)) { + if (ZEPHIR_IS_LONG(&orderSort, 327)) { + ZEPHIR_INIT_NVAR(&orderPartSort); + zephir_create_array(&orderPartSort, 2, 0); + zephir_array_fast_append(&orderPartSort, &orderPartExpr); + ZEPHIR_INIT_NVAR(&_4$$7); + ZVAL_STRING(&_4$$7, "ASC"); + zephir_array_fast_append(&orderPartSort, &_4$$7); + } else { + ZEPHIR_INIT_NVAR(&_5$$8); + zephir_create_array(&_5$$8, 2, 0); + zephir_array_fast_append(&_5$$8, &orderPartExpr); + ZEPHIR_INIT_NVAR(&_6$$8); + ZVAL_STRING(&_6$$8, "DESC"); + zephir_array_fast_append(&_5$$8, &_6$$8); + ZEPHIR_CPY_WRT(&orderPartSort, &_5$$8); + } } else { - ZEPHIR_CALL_METHOD(NULL, ®isteredEngines, "rewind", NULL, 0); + ZEPHIR_INIT_NVAR(&_7$$9); + zephir_create_array(&_7$$9, 1, 0); + zephir_array_fast_append(&_7$$9, &orderPartExpr); + ZEPHIR_CPY_WRT(&orderPartSort, &_7$$9); + } + zephir_array_append(&orderParts, &orderPartSort, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2921); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &orderColumns, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &orderColumns, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&orderItem, &orderColumns, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_fetch_string(&_8$$10, &orderItem, SL("column"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2906); + ZEPHIR_CALL_METHOD(&orderPartExpr, this_ptr, "getexpression", &_3, 458, &_8$$10); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_4$$5, ®isteredEngines, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_4$$5)) { - break; + ZEPHIR_OBS_NVAR(&orderSort); + if (zephir_array_isset_string_fetch(&orderSort, &orderItem, SL("sort"), 0)) { + if (ZEPHIR_IS_LONG(&orderSort, 327)) { + ZEPHIR_INIT_NVAR(&_9$$12); + zephir_create_array(&_9$$12, 2, 0); + zephir_array_fast_append(&_9$$12, &orderPartExpr); + ZEPHIR_INIT_NVAR(&_10$$12); + ZVAL_STRING(&_10$$12, "ASC"); + zephir_array_fast_append(&_9$$12, &_10$$12); + ZEPHIR_CPY_WRT(&orderPartSort, &_9$$12); + } else { + ZEPHIR_INIT_NVAR(&_11$$13); + zephir_create_array(&_11$$13, 2, 0); + zephir_array_fast_append(&_11$$13, &orderPartExpr); + ZEPHIR_INIT_NVAR(&_12$$13); + ZVAL_STRING(&_12$$13, "DESC"); + zephir_array_fast_append(&_11$$13, &_12$$13); + ZEPHIR_CPY_WRT(&orderPartSort, &_11$$13); } - ZEPHIR_CALL_METHOD(&extension, ®isteredEngines, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&engineService, ®isteredEngines, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&engineService) == IS_OBJECT) { - if (zephir_is_instance_of(&engineService, SL("Closure"))) { - _17$$15 = zephir_fetch_class_str_ex(SL("Closure"), ZEND_FETCH_CLASS_AUTO); - ZEPHIR_CALL_CE_STATIC(&_16$$15, _17$$15, "bind", &_9, 0, &engineService, &di); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&engineService, &_16$$15); - ZEPHIR_CALL_FUNCTION(&_16$$15, "call_user_func", &_10, 188, &engineService, this_ptr); - zephir_check_call_status(); - zephir_array_update_zval(&engines, &extension, &_16$$15, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&engines, &extension, &engineService, PH_COPY | PH_SEPARATE); - } - } else { - if (Z_TYPE_P(&engineService) != IS_STRING) { - ZEPHIR_INIT_NVAR(&_18$$18); - object_init_ex(&_18$$18, phalcon_mvc_view_exception_ce); - ZEPHIR_INIT_NVAR(&_19$$18); - ZEPHIR_CONCAT_SV(&_19$$18, "Invalid template engine registration for extension: ", &extension); - ZEPHIR_CALL_METHOD(NULL, &_18$$18, "__construct", &_13, 33, &_19$$18); - zephir_check_call_status(); - zephir_throw_exception_debug(&_18$$18, "phalcon/Mvc/View.zep", 1187); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_NVAR(&_21$$17); - zephir_create_array(&_21$$17, 1, 0); - zephir_array_fast_append(&_21$$17, this_ptr); - ZEPHIR_CALL_METHOD(&_20$$17, &di, "get", NULL, 0, &engineService, &_21$$17); - zephir_check_call_status(); - zephir_array_update_zval(&engines, &extension, &_20$$17, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, ®isteredEngines, "next", NULL, 0); - zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&_13$$14); + zephir_create_array(&_13$$14, 1, 0); + zephir_array_fast_append(&_13$$14, &orderPartExpr); + ZEPHIR_CPY_WRT(&orderPartSort, &_13$$14); } - } - ZEPHIR_INIT_NVAR(&engineService); - ZEPHIR_INIT_NVAR(&extension); + zephir_array_append(&orderParts, &orderPartSort, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2921); + ZEPHIR_CALL_METHOD(NULL, &orderColumns, "next", NULL, 0); + zephir_check_call_status(); } - zephir_update_property_zval(this_ptr, ZEND_STRL("engines"), &engines); } - RETURN_CCTOR(&engines); + ZEPHIR_INIT_NVAR(&orderItem); + RETURN_CTOR(&orderParts); } -static PHP_METHOD(Phalcon_Mvc_View, processRender) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getQualified) { + zend_bool _3, _4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, renderLevel = 0; - zend_bool fireEvents, silence = 0, _5, _30; - zval params; - zval *controllerName_param = NULL, *actionName_param = NULL, *params_param = NULL, *fireEvents_param = NULL, layoutsDir, layout, pickView, layoutName, engines, renderView, pickViewAction, eventsManager, disabledLevels, templatesBefore, templatesAfter, templateBefore, templateAfter, _0, _2, _4, _8, _9, _1$$3, _6$$11, _7$$11, _10$$15, _11$$17, *_12$$17, _13$$17, _14$$18, _15$$18, _16$$19, _17$$19, _18$$21, _19$$21, _20$$23, *_21$$23, _22$$23, _23$$24, _24$$24, _25$$25, _26$$25, _27$$27, _28$$27, _29$$13, _31$$28; - zval controllerName, actionName, _3$$7; + zephir_fcall_cache_entry *_22 = NULL, *_27 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, number = 0; + zval *expr_param = NULL, columnName, nestingLevel, sqlColumnAliases, metaData, sqlAliases, source, sqlAliasesModelsInstances, realColumnName, columnDomain, model, models, columnMap, hasModel, className, _0, _5, _6, _1$$3, _2$$3, _7$$6, _8$$7, _9$$7, _10$$7, _11$$8, _12$$9, _13$$9, _14$$9, _15$$12, _16$$12, _17$$12, _18$$14, *_19$$14, _20$$14, _34$$14, _21$$15, _23$$17, _24$$17, _25$$17, _26$$18, _28$$20, _29$$20, _30$$20, _31$$21, _32$$21, _33$$21, _35$$23, _36$$23, _37$$23, _38$$27, _39$$27, _40$$27; + zval expr; zval *this_ptr = getThis(); - ZVAL_UNDEF(&controllerName); - ZVAL_UNDEF(&actionName); - ZVAL_UNDEF(&_3$$7); - ZVAL_UNDEF(&layoutsDir); - ZVAL_UNDEF(&layout); - ZVAL_UNDEF(&pickView); - ZVAL_UNDEF(&layoutName); - ZVAL_UNDEF(&engines); - ZVAL_UNDEF(&renderView); - ZVAL_UNDEF(&pickViewAction); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&disabledLevels); - ZVAL_UNDEF(&templatesBefore); - ZVAL_UNDEF(&templatesAfter); - ZVAL_UNDEF(&templateBefore); - ZVAL_UNDEF(&templateAfter); + ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&columnName); + ZVAL_UNDEF(&nestingLevel); + ZVAL_UNDEF(&sqlColumnAliases); + ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&sqlAliases); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&sqlAliasesModelsInstances); + ZVAL_UNDEF(&realColumnName); + ZVAL_UNDEF(&columnDomain); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&models); + ZVAL_UNDEF(&columnMap); + ZVAL_UNDEF(&hasModel); + ZVAL_UNDEF(&className); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_6$$11); - ZVAL_UNDEF(&_7$$11); - ZVAL_UNDEF(&_10$$15); - ZVAL_UNDEF(&_11$$17); - ZVAL_UNDEF(&_13$$17); - ZVAL_UNDEF(&_14$$18); - ZVAL_UNDEF(&_15$$18); - ZVAL_UNDEF(&_16$$19); - ZVAL_UNDEF(&_17$$19); - ZVAL_UNDEF(&_18$$21); - ZVAL_UNDEF(&_19$$21); - ZVAL_UNDEF(&_20$$23); - ZVAL_UNDEF(&_22$$23); - ZVAL_UNDEF(&_23$$24); - ZVAL_UNDEF(&_24$$24); - ZVAL_UNDEF(&_25$$25); - ZVAL_UNDEF(&_26$$25); - ZVAL_UNDEF(&_27$$27); - ZVAL_UNDEF(&_28$$27); - ZVAL_UNDEF(&_29$$13); - ZVAL_UNDEF(&_31$$28); - ZVAL_UNDEF(¶ms); - ZEND_PARSE_PARAMETERS_START(2, 4) - Z_PARAM_STR(controllerName) - Z_PARAM_STR(actionName) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(params) - Z_PARAM_BOOL(fireEvents) + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_8$$7); + ZVAL_UNDEF(&_9$$7); + ZVAL_UNDEF(&_10$$7); + ZVAL_UNDEF(&_11$$8); + ZVAL_UNDEF(&_12$$9); + ZVAL_UNDEF(&_13$$9); + ZVAL_UNDEF(&_14$$9); + ZVAL_UNDEF(&_15$$12); + ZVAL_UNDEF(&_16$$12); + ZVAL_UNDEF(&_17$$12); + ZVAL_UNDEF(&_18$$14); + ZVAL_UNDEF(&_20$$14); + ZVAL_UNDEF(&_34$$14); + ZVAL_UNDEF(&_21$$15); + ZVAL_UNDEF(&_23$$17); + ZVAL_UNDEF(&_24$$17); + ZVAL_UNDEF(&_25$$17); + ZVAL_UNDEF(&_26$$18); + ZVAL_UNDEF(&_28$$20); + ZVAL_UNDEF(&_29$$20); + ZVAL_UNDEF(&_30$$20); + ZVAL_UNDEF(&_31$$21); + ZVAL_UNDEF(&_32$$21); + ZVAL_UNDEF(&_33$$21); + ZVAL_UNDEF(&_35$$23); + ZVAL_UNDEF(&_36$$23); + ZVAL_UNDEF(&_37$$23); + ZVAL_UNDEF(&_38$$27); + ZVAL_UNDEF(&_39$$27); + ZVAL_UNDEF(&_40$$27); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(expr) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 2, &controllerName_param, &actionName_param, ¶ms_param, &fireEvents_param); - if (UNEXPECTED(Z_TYPE_P(controllerName_param) != IS_STRING && Z_TYPE_P(controllerName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(controllerName_param) == IS_STRING)) { - zephir_get_strval(&controllerName, controllerName_param); - } else { - ZEPHIR_INIT_VAR(&controllerName); - } - if (UNEXPECTED(Z_TYPE_P(actionName_param) != IS_STRING && Z_TYPE_P(actionName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(actionName_param) == IS_STRING)) { - zephir_get_strval(&actionName, actionName_param); - } else { - ZEPHIR_INIT_VAR(&actionName); - } - if (!params_param) { - ZEPHIR_INIT_VAR(¶ms); - array_init(¶ms); + zephir_fetch_params(1, 1, 0, &expr_param); + ZEPHIR_OBS_COPY_OR_DUP(&expr, expr_param); + zephir_memory_observe(&columnName); + zephir_array_fetch_string(&columnName, &expr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2938); + zephir_read_property(&_0, this_ptr, ZEND_STRL("nestingLevel"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&nestingLevel, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("sqlColumnAliases"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset(&_0, &nestingLevel)) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("sqlColumnAliases"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_2$$3, &_1$$3, &nestingLevel, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2946); + ZEPHIR_CPY_WRT(&sqlColumnAliases, &_2$$3); } else { - zephir_get_arrval(¶ms, params_param); + ZEPHIR_INIT_NVAR(&sqlColumnAliases); + array_init(&sqlColumnAliases); } - if (!fireEvents_param) { - fireEvents = 1; - } else { + _3 = zephir_array_isset(&sqlColumnAliases, &columnName); + if (_3) { + _4 = !(zephir_array_isset_string(&expr, SL("domain"))); + if (!(_4)) { + zephir_array_fetch_string(&_5, &expr, SL("domain"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2951); + _4 = ZEPHIR_IS_EMPTY(&_5); } - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, 0); - zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("disabled"), PH_NOISY_CC | PH_READONLY); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_0)) { - ZEPHIR_CALL_FUNCTION(&_1$$3, "ob_get_contents", NULL, 493); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &_1$$3); - RETURN_MM_BOOL(0); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("controllerName"), &controllerName); - zephir_update_property_zval(this_ptr, ZEND_STRL("actionName"), &actionName); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setvars", NULL, 0, ¶ms); - zephir_check_call_status(); - zephir_read_property(&_2, this_ptr, ZEND_STRL("layoutsDir"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&layoutsDir, &_2); - if (!(zephir_is_true(&layoutsDir))) { - ZEPHIR_INIT_NVAR(&layoutsDir); - ZVAL_STRING(&layoutsDir, "layouts/"); + _3 = _4; } - zephir_read_property(&_2, this_ptr, ZEND_STRL("layout"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&layout, &_2); - if (zephir_is_true(&layout)) { - ZEPHIR_CPY_WRT(&layoutName, &layout); - } else { - ZEPHIR_CPY_WRT(&layoutName, &controllerName); + if (_3) { + zephir_create_array(return_value, 2, 0); + add_assoc_stringl_ex(return_value, SL("type"), SL("qualified")); + zephir_array_update_string(return_value, SL("name"), &columnName, PH_COPY | PH_SEPARATE); + RETURN_MM(); } - ZEPHIR_CALL_METHOD(&engines, this_ptr, "loadtemplateengines", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_2, this_ptr, ZEND_STRL("pickView"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&pickView, &_2); - if (Z_TYPE_P(&pickView) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$7); - ZEPHIR_CONCAT_VSV(&_3$$7, &controllerName, "/", &actionName); - ZEPHIR_CPY_WRT(&renderView, &_3$$7); - } else { - ZEPHIR_OBS_NVAR(&renderView); - zephir_array_fetch_long(&renderView, &pickView, 0, PH_NOISY, "phalcon/Mvc/View.zep", 1274); - if (Z_TYPE_P(&layoutName) == IS_NULL) { - zephir_memory_observe(&pickViewAction); - if (zephir_array_isset_long_fetch(&pickViewAction, &pickView, 1, 0)) { - ZEPHIR_CPY_WRT(&layoutName, &pickViewAction); - } + zephir_read_property(&_6, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&metaData, &_6); + zephir_memory_observe(&columnDomain); + if (zephir_array_isset_string_fetch(&columnDomain, &expr, SL("domain"), 0)) { + zephir_read_property(&_7$$6, this_ptr, ZEND_STRL("sqlAliases"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&sqlAliases, &_7$$6); + zephir_memory_observe(&source); + if (UNEXPECTED(!(zephir_array_isset_fetch(&source, &sqlAliases, &columnDomain, 0)))) { + ZEPHIR_INIT_VAR(&_8$$7); + object_init_ex(&_8$$7, phalcon_mvc_model_exception_ce); + zephir_read_property(&_9$$7, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_10$$7); + ZEPHIR_CONCAT_SVSV(&_10$$7, "Unknown model or alias '", &columnDomain, "' (11), when preparing: ", &_9$$7); + ZEPHIR_CALL_METHOD(NULL, &_8$$7, "__construct", NULL, 33, &_10$$7); + zephir_check_call_status(); + zephir_throw_exception_debug(&_8$$7, "phalcon/Mvc/Model/Query.zep", 2972); + ZEPHIR_MM_RESTORE(); + return; } - } - zephir_read_property(&_2, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_2); - ZEPHIR_INIT_VAR(&_4); - ZEPHIR_CREATE_SYMBOL_TABLE(); - - _5 = fireEvents; - if (_5) { - _5 = Z_TYPE_P(&eventsManager) == IS_OBJECT; - } - if (_5) { - ZEPHIR_INIT_VAR(&_7$$11); - ZVAL_STRING(&_7$$11, "view:beforeRender"); - ZEPHIR_CALL_METHOD(&_6$$11, &eventsManager, "fire", NULL, 0, &_7$$11, this_ptr); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_6$$11)) { - RETURN_MM_BOOL(0); + if (ZEPHIR_GLOBAL(orm).column_renaming) { + zephir_read_property(&_11$$8, this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&sqlAliasesModelsInstances, &_11$$8); + zephir_memory_observe(&model); + if (UNEXPECTED(!(zephir_array_isset_fetch(&model, &sqlAliasesModelsInstances, &columnDomain, 0)))) { + ZEPHIR_INIT_VAR(&_12$$9); + object_init_ex(&_12$$9, phalcon_mvc_model_exception_ce); + zephir_read_property(&_13$$9, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_14$$9); + ZEPHIR_CONCAT_SVSV(&_14$$9, "There is no model related to model or alias '", &columnDomain, "', when executing: ", &_13$$9); + ZEPHIR_CALL_METHOD(NULL, &_12$$9, "__construct", NULL, 33, &_14$$9); + zephir_check_call_status(); + zephir_throw_exception_debug(&_12$$9, "phalcon/Mvc/Model/Query.zep", 2991); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getreversecolumnmap", NULL, 0, &model); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&columnMap); + ZVAL_NULL(&columnMap); } - } - ZEPHIR_CALL_FUNCTION(&_8, "ob_get_contents", NULL, 493); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &_8); - silence = 1; - zephir_read_property(&_2, this_ptr, ZEND_STRL("disabledLevels"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&disabledLevels, &_2); - zephir_memory_observe(&_9); - zephir_read_property(&_9, this_ptr, ZEND_STRL("renderLevel"), PH_NOISY_CC); - renderLevel = zephir_get_intval(&_9); - if (renderLevel) { - if (renderLevel >= 1) { - if (!(zephir_array_isset_long(&disabledLevels, 1))) { - ZVAL_UNDEF(&_10$$15); - ZVAL_LONG(&_10$$15, 1); - zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_10$$15); - if (silence) { - ZVAL_BOOL(&_10$$15, 1); - } else { - ZVAL_BOOL(&_10$$15, 0); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &renderView, &_10$$15); + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + zephir_memory_observe(&realColumnName); + if (UNEXPECTED(!(zephir_array_isset_fetch(&realColumnName, &columnMap, &columnName, 0)))) { + ZEPHIR_INIT_VAR(&_15$$12); + object_init_ex(&_15$$12, phalcon_mvc_model_exception_ce); + zephir_read_property(&_16$$12, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_17$$12); + ZEPHIR_CONCAT_SVSVSV(&_17$$12, "Column '", &columnName, "' doesn't belong to the model or alias '", &columnDomain, "', when executing: ", &_16$$12); + ZEPHIR_CALL_METHOD(NULL, &_15$$12, "__construct", NULL, 33, &_17$$12); zephir_check_call_status(); + zephir_throw_exception_debug(&_15$$12, "phalcon/Mvc/Model/Query.zep", 3003); + ZEPHIR_MM_RESTORE(); + return; } + } else { + ZEPHIR_CPY_WRT(&realColumnName, &columnName); } - if (renderLevel >= 2) { - if (!(zephir_array_isset_long(&disabledLevels, 2))) { - ZVAL_UNDEF(&_11$$17); - ZVAL_LONG(&_11$$17, 2); - zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_11$$17); - zephir_read_property(&_11$$17, this_ptr, ZEND_STRL("templatesBefore"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&templatesBefore, &_11$$17); - silence = 0; - zephir_is_iterable(&templatesBefore, 0, "phalcon/Mvc/View.zep", 1350); - if (Z_TYPE_P(&templatesBefore) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&templatesBefore), _12$$17) - { - ZEPHIR_INIT_NVAR(&templateBefore); - ZVAL_COPY(&templateBefore, _12$$17); - ZEPHIR_INIT_NVAR(&_14$$18); - ZEPHIR_CONCAT_VV(&_14$$18, &layoutsDir, &templateBefore); - if (silence) { - ZVAL_BOOL(&_15$$18, 1); - } else { - ZVAL_BOOL(&_15$$18, 0); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &_14$$18, &_15$$18); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &templatesBefore, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_13$$17, &templatesBefore, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_13$$17)) { - break; - } - ZEPHIR_CALL_METHOD(&templateBefore, &templatesBefore, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_16$$19); - ZEPHIR_CONCAT_VV(&_16$$19, &layoutsDir, &templateBefore); - if (silence) { - ZVAL_BOOL(&_17$$19, 1); - } else { - ZVAL_BOOL(&_17$$19, 0); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &_16$$19, &_17$$19); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &templatesBefore, "next", NULL, 0); + } else { + number = 0; + ZEPHIR_INIT_VAR(&hasModel); + ZVAL_BOOL(&hasModel, 0); + zephir_read_property(&_18$$14, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_18$$14, 0, "phalcon/Mvc/Model/Query.zep", 3037); + if (Z_TYPE_P(&_18$$14) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_18$$14), _19$$14) + { + ZEPHIR_INIT_NVAR(&model); + ZVAL_COPY(&model, _19$$14); + ZEPHIR_CALL_METHOD(&_21$$15, &metaData, "hasattribute", &_22, 0, &model, &columnName); + zephir_check_call_status(); + if (zephir_is_true(&_21$$15)) { + number++; + if (UNEXPECTED(number > 1)) { + ZEPHIR_INIT_NVAR(&_23$$17); + object_init_ex(&_23$$17, phalcon_mvc_model_exception_ce); + zephir_read_property(&_24$$17, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_25$$17); + ZEPHIR_CONCAT_SVSV(&_25$$17, "The column '", &columnName, "' is ambiguous, when preparing: ", &_24$$17); + ZEPHIR_CALL_METHOD(NULL, &_23$$17, "__construct", NULL, 33, &_25$$17); zephir_check_call_status(); + zephir_throw_exception_debug(&_23$$17, "phalcon/Mvc/Model/Query.zep", 3026); + ZEPHIR_MM_RESTORE(); + return; } + ZEPHIR_CPY_WRT(&hasModel, &model); } - ZEPHIR_INIT_NVAR(&templateBefore); - silence = 1; - } - } - if (renderLevel >= 3) { - if (!(zephir_array_isset_long(&disabledLevels, 3))) { - ZVAL_UNDEF(&_18$$21); - ZVAL_LONG(&_18$$21, 3); - zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_18$$21); - ZEPHIR_INIT_VAR(&_19$$21); - ZEPHIR_CONCAT_VV(&_19$$21, &layoutsDir, &layoutName); - if (silence) { - ZVAL_BOOL(&_18$$21, 1); - } else { - ZVAL_BOOL(&_18$$21, 0); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_18$$14, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_20$$14, &_18$$14, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_20$$14)) { + break; } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &_19$$21, &_18$$21); + ZEPHIR_CALL_METHOD(&model, &_18$$14, "current", NULL, 0); zephir_check_call_status(); - } - } - if (renderLevel >= 4) { - if (!(zephir_array_isset_long(&disabledLevels, 4))) { - ZVAL_UNDEF(&_20$$23); - ZVAL_LONG(&_20$$23, 4); - zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_20$$23); - zephir_read_property(&_20$$23, this_ptr, ZEND_STRL("templatesAfter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&templatesAfter, &_20$$23); - silence = 0; - zephir_is_iterable(&templatesAfter, 0, "phalcon/Mvc/View.zep", 1386); - if (Z_TYPE_P(&templatesAfter) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&templatesAfter), _21$$23) - { - ZEPHIR_INIT_NVAR(&templateAfter); - ZVAL_COPY(&templateAfter, _21$$23); - ZEPHIR_INIT_NVAR(&_23$$24); - ZEPHIR_CONCAT_VV(&_23$$24, &layoutsDir, &templateAfter); - if (silence) { - ZVAL_BOOL(&_24$$24, 1); - } else { - ZVAL_BOOL(&_24$$24, 0); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &_23$$24, &_24$$24); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &templatesAfter, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(&_26$$18, &metaData, "hasattribute", &_27, 0, &model, &columnName); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_22$$23, &templatesAfter, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_22$$23)) { - break; - } - ZEPHIR_CALL_METHOD(&templateAfter, &templatesAfter, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_25$$25); - ZEPHIR_CONCAT_VV(&_25$$25, &layoutsDir, &templateAfter); - if (silence) { - ZVAL_BOOL(&_26$$25, 1); - } else { - ZVAL_BOOL(&_26$$25, 0); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &_25$$25, &_26$$25); + if (zephir_is_true(&_26$$18)) { + number++; + if (UNEXPECTED(number > 1)) { + ZEPHIR_INIT_NVAR(&_28$$20); + object_init_ex(&_28$$20, phalcon_mvc_model_exception_ce); + zephir_read_property(&_29$$20, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_30$$20); + ZEPHIR_CONCAT_SVSV(&_30$$20, "The column '", &columnName, "' is ambiguous, when preparing: ", &_29$$20); + ZEPHIR_CALL_METHOD(NULL, &_28$$20, "__construct", NULL, 33, &_30$$20); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &templatesAfter, "next", NULL, 0); - zephir_check_call_status(); + zephir_throw_exception_debug(&_28$$20, "phalcon/Mvc/Model/Query.zep", 3026); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CPY_WRT(&hasModel, &model); } - } - ZEPHIR_INIT_NVAR(&templateAfter); - silence = 1; - } - } - if (renderLevel >= 5) { - if (!(zephir_array_isset_long(&disabledLevels, 5))) { - ZVAL_UNDEF(&_27$$27); - ZVAL_LONG(&_27$$27, 5); - zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_27$$27); - zephir_read_property(&_27$$27, this_ptr, ZEND_STRL("mainView"), PH_NOISY_CC | PH_READONLY); - if (silence) { - ZVAL_BOOL(&_28$$27, 1); - } else { - ZVAL_BOOL(&_28$$27, 0); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "enginerender", NULL, 0, &engines, &_27$$27, &_28$$27); + ZEPHIR_CALL_METHOD(NULL, &_18$$14, "next", NULL, 0); zephir_check_call_status(); } } - ZVAL_UNDEF(&_29$$13); - ZVAL_LONG(&_29$$13, 0); - zephir_update_property_zval(this_ptr, ZEND_STRL("currentRenderLevel"), &_29$$13); - } - _30 = fireEvents; - if (_30) { - _30 = Z_TYPE_P(&eventsManager) == IS_OBJECT; - } - if (_30) { - ZEPHIR_INIT_VAR(&_31$$28); - ZVAL_STRING(&_31$$28, "view:afterRender"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_31$$28, this_ptr); - zephir_check_call_status(); - } - RETURN_MM_BOOL(1); -} - -static PHP_METHOD(Phalcon_Mvc_View, getDirSeparator) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *directory_param = NULL, _0, _1; - zval directory; - - ZVAL_UNDEF(&directory); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(directory) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &directory_param); - if (UNEXPECTED(Z_TYPE_P(directory_param) != IS_STRING && Z_TYPE_P(directory_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'directory' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(directory_param) == IS_STRING)) { - zephir_get_strval(&directory, directory_param); - } else { - ZEPHIR_INIT_VAR(&directory); - } - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "/"); - zephir_fast_trim(&_0, &directory, &_1, ZEPHIR_TRIM_RIGHT); - ZEPHIR_CONCAT_VS(return_value, &_0, "/"); - RETURN_MM(); -} - -zend_object *zephir_init_properties_Phalcon_Mvc_View(zend_class_entry *class_type) -{ - zval _0, _2, _4, _6, _8, _10, _12, _14, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8, _13$$9, _15$$10; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_13$$9); - ZVAL_UNDEF(&_15$$10); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("viewParams"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("viewParams"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("viewsDirs"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("viewsDirs"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("templatesBefore"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("templatesBefore"), &_5$$5); - } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("templatesAfter"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("templatesAfter"), &_7$$6); + ZEPHIR_INIT_NVAR(&model); + if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&hasModel))) { + ZEPHIR_INIT_VAR(&_31$$21); + object_init_ex(&_31$$21, phalcon_mvc_model_exception_ce); + zephir_read_property(&_32$$21, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_33$$21); + ZEPHIR_CONCAT_SVSV(&_33$$21, "Column '", &columnName, "' doesn't belong to any of the selected models (1), when preparing: ", &_32$$21); + ZEPHIR_CALL_METHOD(NULL, &_31$$21, "__construct", NULL, 33, &_33$$21); + zephir_check_call_status(); + zephir_throw_exception_debug(&_31$$21, "phalcon/Mvc/Model/Query.zep", 3040); + ZEPHIR_MM_RESTORE(); + return; } - zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("registeredEngines"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_8) == IS_NULL) { - ZEPHIR_INIT_VAR(&_9$$7); - array_init(&_9$$7); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("registeredEngines"), &_9$$7); + zephir_read_property(&_34$$14, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&models, &_34$$14); + if (UNEXPECTED(Z_TYPE_P(&models) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The models list was not loaded correctly", "phalcon/Mvc/Model/Query.zep", 3051); + return; } - zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_10) == IS_NULL) { - ZEPHIR_INIT_VAR(&_11$$8); - array_init(&_11$$8); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_11$$8); + ZEPHIR_INIT_VAR(&className); + zephir_get_class(&className, &hasModel, 0); + ZEPHIR_OBS_NVAR(&source); + if (UNEXPECTED(!(zephir_array_isset_fetch(&source, &models, &className, 0)))) { + ZEPHIR_INIT_VAR(&_35$$23); + object_init_ex(&_35$$23, phalcon_mvc_model_exception_ce); + zephir_read_property(&_36$$23, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_37$$23); + ZEPHIR_CONCAT_SVSV(&_37$$23, "Can't obtain model's source from models list: '", &className, "', when preparing: ", &_36$$23); + ZEPHIR_CALL_METHOD(NULL, &_35$$23, "__construct", NULL, 33, &_37$$23); + zephir_check_call_status(); + zephir_throw_exception_debug(&_35$$23, "phalcon/Mvc/Model/Query.zep", 3062); + ZEPHIR_MM_RESTORE(); + return; } - zephir_read_property_ex(&_12, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_12) == IS_NULL) { - ZEPHIR_INIT_VAR(&_13$$9); - array_init(&_13$$9); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_13$$9); + if (ZEPHIR_GLOBAL(orm).column_renaming) { + ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getreversecolumnmap", NULL, 0, &hasModel); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&columnMap); + ZVAL_NULL(&columnMap); } - zephir_read_property_ex(&_14, this_ptr, ZEND_STRL("disabledLevels"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_14) == IS_NULL) { - ZEPHIR_INIT_VAR(&_15$$10); - array_init(&_15$$10); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("disabledLevels"), &_15$$10); + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&realColumnName); + if (UNEXPECTED(!(zephir_array_isset_fetch(&realColumnName, &columnMap, &columnName, 0)))) { + ZEPHIR_INIT_VAR(&_38$$27); + object_init_ex(&_38$$27, phalcon_mvc_model_exception_ce); + zephir_read_property(&_39$$27, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_40$$27); + ZEPHIR_CONCAT_SVSV(&_40$$27, "Column '", &columnName, "' doesn't belong to any of the selected models (3), when preparing: ", &_39$$27); + ZEPHIR_CALL_METHOD(NULL, &_38$$27, "__construct", NULL, 33, &_40$$27); + zephir_check_call_status(); + zephir_throw_exception_debug(&_38$$27, "phalcon/Mvc/Model/Query.zep", 3081); + ZEPHIR_MM_RESTORE(); + return; + } + } else { + ZEPHIR_CPY_WRT(&realColumnName, &columnName); } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); } + zephir_create_array(return_value, 4, 0); + add_assoc_stringl_ex(return_value, SL("type"), SL("qualified")); + zephir_array_update_string(return_value, SL("domain"), &source, PH_COPY | PH_SEPARATE); + zephir_array_update_string(return_value, SL("name"), &realColumnName, PH_COPY | PH_SEPARATE); + zephir_array_update_string(return_value, SL("balias"), &columnName, PH_COPY | PH_SEPARATE); + RETURN_MM(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_ViewBaseInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ViewBaseInterface, phalcon, mvc_viewbaseinterface, phalcon_mvc_viewbaseinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, getContent); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, getParamsToView); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, getViewsDir); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, partial); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, setContent); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, setParamToView); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, setVar); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewBaseInterface, setViewsDir); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_ViewInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc, ViewInterface, phalcon, mvc_viewinterface, phalcon_mvc_viewinterface_method_entry); - - zend_class_implements(phalcon_mvc_viewinterface_ce, 1, phalcon_mvc_viewbaseinterface_ce); - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, cleanTemplateAfter); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, cleanTemplateBefore); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, disable); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, enable); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, finish); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getActionName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getActiveRenderPath); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getBasePath); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getControllerName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getLayout); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getLayoutsDir); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getMainView); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, getPartialsDir); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, isDisabled); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, pick); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, registerEngines); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, render); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, reset); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setBasePath); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setLayout); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setLayoutsDir); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setMainView); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setPartialsDir); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setRenderLevel); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setTemplateAfter); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, setTemplateBefore); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_ViewInterface, start); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_Collection) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Micro, Collection, phalcon, mvc_micro_collection, phalcon_mvc_micro_collection_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_micro_collection_ce, SL("handler"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_micro_collection_ce, SL("handlers"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_micro_collection_ce, SL("lazy"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_micro_collection_ce, SL("prefix"), "", ZEND_ACC_PROTECTED); - phalcon_mvc_micro_collection_ce->create_object = zephir_init_properties_Phalcon_Mvc_Micro_Collection; - - zend_class_implements(phalcon_mvc_micro_collection_ce, 1, phalcon_mvc_micro_collectioninterface_ce); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, delete) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getReadConnection) { + zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; - zval routePattern, name; + zval intermediate, bindParams, bindTypes; + zval *model, model_sub, *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, connection, transaction, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&connection); + ZVAL_UNDEF(&transaction); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&intermediate); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + Z_PARAM_ARRAY_OR_NULL(intermediate) + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 3, &model, &intermediate_param, &bindParams_param, &bindTypes_param); + if (!intermediate_param) { + ZEPHIR_INIT_VAR(&intermediate); + } else { + zephir_get_arrval(&intermediate, intermediate_param); } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); + if (!bindParams_param) { + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); } else { - ZEPHIR_INIT_VAR(&routePattern); + zephir_get_arrval(&bindParams, bindParams_param); } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); + if (!bindTypes_param) { + ZEPHIR_INIT_VAR(&bindTypes); + array_init(&bindTypes); } else { - zephir_get_strval(&name, name_param); + zephir_get_arrval(&bindTypes, bindTypes_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "DELETE"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); - zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, get) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; - zval routePattern, name; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); + ZEPHIR_INIT_VAR(&connection); + ZVAL_NULL(&connection); + zephir_read_property(&_0, this_ptr, ZEND_STRL("transaction"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&transaction, &_0); + _1 = Z_TYPE_P(&transaction) == IS_OBJECT; + if (_1) { + _1 = zephir_instance_of_ev(&transaction, phalcon_mvc_model_transactioninterface_ce); } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); - } else { - ZEPHIR_INIT_VAR(&routePattern); + if (_1) { + ZEPHIR_RETURN_CALL_METHOD(&transaction, "getconnection", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); - } else { - zephir_get_strval(&name, name_param); + if ((zephir_method_exists_ex(model, ZEND_STRL("selectreadconnection")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(&connection, model, "selectreadconnection", NULL, 0, &intermediate, &bindParams, &bindTypes); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&connection) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "selectReadConnection did not return a connection", "phalcon/Mvc/Model/Query.zep", 3125); + return; + } + RETURN_CCTOR(&connection); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "GET"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); + ZEPHIR_RETURN_CALL_METHOD(model, "getreadconnection", NULL, 0); zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, getHandler) -{ - - RETURN_MEMBER(getThis(), "handler"); -} - -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, getHandlers) -{ - - RETURN_MEMBER(getThis(), "handlers"); -} - -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, getPrefix) -{ - - RETURN_MEMBER(getThis(), "prefix"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, head) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getRelatedRecords) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; - zval routePattern, name; + zval intermediate, bindParams, bindTypes, _0, _1; + zval *model, model_sub, *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, selectIr, whereConditions, limitConditions, query, _2, _3, _4, _5, _6; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&selectIr); + ZVAL_UNDEF(&whereConditions); + ZVAL_UNDEF(&limitConditions); + ZVAL_UNDEF(&query); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&intermediate); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ARRAY(intermediate) + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); - } else { - ZEPHIR_INIT_VAR(&routePattern); + zephir_fetch_params(1, 4, 0, &model, &intermediate_param, &bindParams_param, &bindTypes_param); + zephir_get_arrval(&intermediate, intermediate_param); + zephir_get_arrval(&bindParams, bindParams_param); + zephir_get_arrval(&bindTypes, bindTypes_param); + ZEPHIR_INIT_VAR(&selectIr); + zephir_create_array(&selectIr, 3, 0); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 1, 0); + ZEPHIR_INIT_VAR(&_1); + zephir_create_array(&_1, 3, 0); + add_assoc_stringl_ex(&_1, SL("type"), SL("object")); + ZEPHIR_INIT_VAR(&_2); + zephir_get_class(&_2, model, 0); + zephir_array_update_string(&_1, SL("model"), &_2, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_3, model, "getsource", NULL, 0); + zephir_check_call_status(); + zephir_array_update_string(&_1, SL("column"), &_3, PH_COPY | PH_SEPARATE); + zephir_array_fast_append(&_0, &_1); + zephir_array_update_string(&selectIr, SL("columns"), &_0, PH_COPY | PH_SEPARATE); + zephir_memory_observe(&_4); + zephir_array_fetch_string(&_4, &intermediate, SL("models"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3155); + zephir_array_update_string(&selectIr, SL("models"), &_4, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_4); + zephir_array_fetch_string(&_4, &intermediate, SL("tables"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3157); + zephir_array_update_string(&selectIr, SL("tables"), &_4, PH_COPY | PH_SEPARATE); + zephir_memory_observe(&whereConditions); + if (zephir_array_isset_string_fetch(&whereConditions, &intermediate, SL("where"), 0)) { + zephir_array_update_string(&selectIr, SL("where"), &whereConditions, PH_COPY | PH_SEPARATE); } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); - } else { - zephir_get_strval(&name, name_param); + zephir_memory_observe(&limitConditions); + if (zephir_array_isset_string_fetch(&limitConditions, &intermediate, SL("limit"), 0)) { + zephir_array_update_string(&selectIr, SL("limit"), &limitConditions, PH_COPY | PH_SEPARATE); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "HEAD"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); + ZEPHIR_INIT_VAR(&query); + object_init_ex(&query, phalcon_mvc_model_query_ce); + ZEPHIR_CALL_METHOD(NULL, &query, "__construct", NULL, 467); zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, isLazy) -{ - - RETURN_MEMBER(getThis(), "lazy"); + zephir_read_property(&_5, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &query, "setdi", NULL, 468, &_5); + zephir_check_call_status(); + ZVAL_LONG(&_6, 309); + ZEPHIR_CALL_METHOD(NULL, &query, "settype", NULL, 469, &_6); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &query, "setintermediate", NULL, 470, &selectIr); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(&query, "execute", NULL, 471, &bindParams, &bindTypes); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, map) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getSelectColumn) { + zend_string *_4$$4; + zend_ulong _3$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_6 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; - zval routePattern, name; + zval *column_param = NULL, columnType, sqlAliases, modelName, source, columnDomain, sqlColumnAlias, preparedAlias, sqlExprColumn, sqlAliasesModels, columnData, balias, eager, _19, _20, _0$$4, *_1$$4, _2$$4, _5$$5, _7$$6, _8$$7, _9$$7, _10$$8, _11$$10, _15$$10, _12$$11, _13$$11, _14$$11, _16$$15, _17$$16, _18$$18; + zval column, sqlColumns, sqlColumn; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + ZVAL_UNDEF(&column); + ZVAL_UNDEF(&sqlColumns); + ZVAL_UNDEF(&sqlColumn); + ZVAL_UNDEF(&columnType); + ZVAL_UNDEF(&sqlAliases); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&columnDomain); + ZVAL_UNDEF(&sqlColumnAlias); + ZVAL_UNDEF(&preparedAlias); + ZVAL_UNDEF(&sqlExprColumn); + ZVAL_UNDEF(&sqlAliasesModels); + ZVAL_UNDEF(&columnData); + ZVAL_UNDEF(&balias); + ZVAL_UNDEF(&eager); + ZVAL_UNDEF(&_19); + ZVAL_UNDEF(&_20); + ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_8$$7); + ZVAL_UNDEF(&_9$$7); + ZVAL_UNDEF(&_10$$8); + ZVAL_UNDEF(&_11$$10); + ZVAL_UNDEF(&_15$$10); + ZVAL_UNDEF(&_12$$11); + ZVAL_UNDEF(&_13$$11); + ZVAL_UNDEF(&_14$$11); + ZVAL_UNDEF(&_16$$15); + ZVAL_UNDEF(&_17$$16); + ZVAL_UNDEF(&_18$$18); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(column) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 0, &column_param); + ZEPHIR_OBS_COPY_OR_DUP(&column, column_param); + zephir_memory_observe(&columnType); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&columnType, &column, SL("type"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 3197); + return; } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); - } else { - ZEPHIR_INIT_VAR(&routePattern); + ZEPHIR_INIT_VAR(&sqlColumns); + array_init(&sqlColumns); + zephir_memory_observe(&eager); + zephir_array_isset_string_fetch(&eager, &column, SL("eager"), 0); + if (ZEPHIR_IS_LONG(&columnType, 352)) { + zephir_read_property(&_0$$4, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_0$$4, 0, "phalcon/Mvc/Model/Query.zep", 3227); + if (Z_TYPE_P(&_0$$4) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_0$$4), _3$$4, _4$$4, _1$$4) + { + ZEPHIR_INIT_NVAR(&modelName); + if (_4$$4 != NULL) { + ZVAL_STR_COPY(&modelName, _4$$4); + } else { + ZVAL_LONG(&modelName, _3$$4); + } + ZEPHIR_INIT_NVAR(&source); + ZVAL_COPY(&source, _1$$4); + ZEPHIR_INIT_NVAR(&sqlColumn); + zephir_create_array(&sqlColumn, 4, 0); + add_assoc_stringl_ex(&sqlColumn, SL("type"), SL("object")); + zephir_array_update_string(&sqlColumn, SL("model"), &modelName, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&sqlColumn, SL("column"), &source, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_FUNCTION(&_5$$5, "lcfirst", &_6, 76, &modelName); + zephir_check_call_status(); + zephir_array_update_string(&sqlColumn, SL("balias"), &_5$$5, PH_COPY | PH_SEPARATE); + if (Z_TYPE_P(&eager) != IS_NULL) { + zephir_array_update_string(&sqlColumn, SL("eager"), &eager, PH_COPY | PH_SEPARATE); + zephir_array_fetch_string(&_7$$6, &column, SL("eagerType"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3221); + zephir_array_update_string(&sqlColumn, SL("eagerType"), &_7$$6, PH_COPY | PH_SEPARATE); + } + zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3224); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_0$$4, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2$$4, &_0$$4, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2$$4)) { + break; + } + ZEPHIR_CALL_METHOD(&modelName, &_0$$4, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&source, &_0$$4, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_8$$7); + zephir_create_array(&_8$$7, 4, 0); + add_assoc_stringl_ex(&_8$$7, SL("type"), SL("object")); + zephir_array_update_string(&_8$$7, SL("model"), &modelName, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_8$$7, SL("column"), &source, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_FUNCTION(&_9$$7, "lcfirst", &_6, 76, &modelName); + zephir_check_call_status(); + zephir_array_update_string(&_8$$7, SL("balias"), &_9$$7, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&sqlColumn, &_8$$7); + if (Z_TYPE_P(&eager) != IS_NULL) { + zephir_array_update_string(&sqlColumn, SL("eager"), &eager, PH_COPY | PH_SEPARATE); + zephir_array_fetch_string(&_10$$8, &column, SL("eagerType"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3221); + zephir_array_update_string(&sqlColumn, SL("eagerType"), &_10$$8, PH_COPY | PH_SEPARATE); + } + zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3224); + ZEPHIR_CALL_METHOD(NULL, &_0$$4, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&source); + ZEPHIR_INIT_NVAR(&modelName); + RETURN_CTOR(&sqlColumns); } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); - } else { - zephir_get_strval(&name, name_param); + if (UNEXPECTED(!(zephir_array_isset_string(&column, SL("column"))))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 3231); + return; } - ZVAL_NULL(&_0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); + if (ZEPHIR_IS_LONG(&columnType, 353)) { + zephir_read_property(&_11$$10, this_ptr, ZEND_STRL("sqlAliases"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&sqlAliases, &_11$$10); + zephir_memory_observe(&columnDomain); + zephir_array_fetch_string(&columnDomain, &column, SL("column"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3243); + ZEPHIR_OBS_NVAR(&source); + if (UNEXPECTED(!(zephir_array_isset_fetch(&source, &sqlAliases, &columnDomain, 0)))) { + ZEPHIR_INIT_VAR(&_12$$11); + object_init_ex(&_12$$11, phalcon_mvc_model_exception_ce); + zephir_read_property(&_13$$11, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_14$$11); + ZEPHIR_CONCAT_SVSV(&_14$$11, "Unknown model or alias '", &columnDomain, "' (2), when preparing: ", &_13$$11); + ZEPHIR_CALL_METHOD(NULL, &_12$$11, "__construct", NULL, 33, &_14$$11); + zephir_check_call_status(); + zephir_throw_exception_debug(&_12$$11, "phalcon/Mvc/Model/Query.zep", 3248); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CPY_WRT(&sqlColumnAlias, &source); + zephir_memory_observe(&preparedAlias); + zephir_array_isset_string_fetch(&preparedAlias, &column, SL("balias"), 0); + zephir_read_property(&_11$$10, this_ptr, ZEND_STRL("sqlAliasesModels"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&sqlAliasesModels, &_11$$10); + ZEPHIR_OBS_NVAR(&modelName); + zephir_array_fetch(&modelName, &sqlAliasesModels, &columnDomain, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3262); + if (Z_TYPE_P(&preparedAlias) != IS_STRING) { + if (ZEPHIR_IS_EQUAL(&columnDomain, &modelName)) { + ZEPHIR_CALL_FUNCTION(&preparedAlias, "lcfirst", &_6, 76, &modelName); + zephir_check_call_status(); + } else { + ZEPHIR_CPY_WRT(&preparedAlias, &columnDomain); + } + } + ZEPHIR_INIT_VAR(&_15$$10); + zephir_create_array(&_15$$10, 4, 0); + add_assoc_stringl_ex(&_15$$10, SL("type"), SL("object")); + zephir_array_update_string(&_15$$10, SL("model"), &modelName, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_15$$10, SL("column"), &sqlColumnAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_15$$10, SL("balias"), &preparedAlias, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&sqlColumn, &_15$$10); + if (Z_TYPE_P(&eager) != IS_NULL) { + zephir_array_update_string(&sqlColumn, SL("eager"), &eager, PH_COPY | PH_SEPARATE); + zephir_array_fetch_string(&_16$$15, &column, SL("eagerType"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3289); + zephir_array_update_string(&sqlColumn, SL("eagerType"), &_16$$15, PH_COPY | PH_SEPARATE); + } + zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3292); + RETURN_CTOR(&sqlColumns); + } + if (ZEPHIR_IS_LONG(&columnType, 354)) { + ZEPHIR_INIT_VAR(&_17$$16); + zephir_create_array(&_17$$16, 1, 0); + add_assoc_stringl_ex(&_17$$16, SL("type"), SL("scalar")); + ZEPHIR_CPY_WRT(&sqlColumn, &_17$$16); + zephir_memory_observe(&columnData); + zephir_array_fetch_string(&columnData, &column, SL("column"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3306); + ZEPHIR_CALL_METHOD(&sqlExprColumn, this_ptr, "getexpression", NULL, 458, &columnData); + zephir_check_call_status(); + zephir_memory_observe(&balias); + if (zephir_array_isset_string_fetch(&balias, &sqlExprColumn, SL("balias"), 0)) { + zephir_array_update_string(&sqlColumn, SL("balias"), &balias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&sqlColumn, SL("sqlAlias"), &balias, PH_COPY | PH_SEPARATE); + } + if (Z_TYPE_P(&eager) != IS_NULL) { + zephir_array_update_string(&sqlColumn, SL("eager"), &eager, PH_COPY | PH_SEPARATE); + zephir_array_fetch_string(&_18$$18, &column, SL("eagerType"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3319); + zephir_array_update_string(&sqlColumn, SL("eagerType"), &_18$$18, PH_COPY | PH_SEPARATE); + } + zephir_array_update_string(&sqlColumn, SL("column"), &sqlExprColumn, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3323); + RETURN_CTOR(&sqlColumns); + } + ZEPHIR_INIT_VAR(&_19); + object_init_ex(&_19, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_20); + ZEPHIR_CONCAT_SV(&_20, "Unknown type of column ", &columnType); + ZEPHIR_CALL_METHOD(NULL, &_19, "__construct", NULL, 33, &_20); zephir_check_call_status(); - RETURN_THIS(); + zephir_throw_exception_debug(&_19, "phalcon/Mvc/Model/Query.zep", 3328); + ZEPHIR_MM_RESTORE(); + return; } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, mapVia) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getSingleJoin) { + zend_string *_8$$4; + zend_ulong _7$$4; + zval _1$$3, _3$$3, _4$$3, _13$$5, _15$$5, _16$$5, _20$$7, _22$$7, _23$$7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_12 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, *method, method_sub, *name_param = NULL; - zval routePattern, name; + zval *joinType_param = NULL, *joinSource, joinSource_sub, *modelAlias_param = NULL, *joinAlias_param = NULL, *relation, relation_sub, fields, referencedFields, sqlJoinConditions, sqlJoinPartialConditions, position, field, referencedField, _0$$3, _2$$3, *_5$$4, _6$$4, _9$$6, _10$$6, _11$$6, _14$$5, _17$$8, _18$$8, _19$$8, _21$$7; + zval joinType, modelAlias, joinAlias; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&method_sub); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) - Z_PARAM_ZVAL(method) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + ZVAL_UNDEF(&joinType); + ZVAL_UNDEF(&modelAlias); + ZVAL_UNDEF(&joinAlias); + ZVAL_UNDEF(&joinSource_sub); + ZVAL_UNDEF(&relation_sub); + ZVAL_UNDEF(&fields); + ZVAL_UNDEF(&referencedFields); + ZVAL_UNDEF(&sqlJoinConditions); + ZVAL_UNDEF(&sqlJoinPartialConditions); + ZVAL_UNDEF(&position); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&referencedField); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_9$$6); + ZVAL_UNDEF(&_10$$6); + ZVAL_UNDEF(&_11$$6); + ZVAL_UNDEF(&_14$$5); + ZVAL_UNDEF(&_17$$8); + ZVAL_UNDEF(&_18$$8); + ZVAL_UNDEF(&_19$$8); + ZVAL_UNDEF(&_21$$7); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_13$$5); + ZVAL_UNDEF(&_15$$5); + ZVAL_UNDEF(&_16$$5); + ZVAL_UNDEF(&_20$$7); + ZVAL_UNDEF(&_22$$7); + ZVAL_UNDEF(&_23$$7); + ZEND_PARSE_PARAMETERS_START(5, 5) + Z_PARAM_STR(joinType) + Z_PARAM_ZVAL(joinSource) + Z_PARAM_STR(modelAlias) + Z_PARAM_STR(joinAlias) + Z_PARAM_OBJECT_OF_CLASS(relation, phalcon_mvc_model_relationinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 1, &routePattern_param, &handler, &method, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + zephir_fetch_params(1, 5, 0, &joinType_param, &joinSource, &modelAlias_param, &joinAlias_param, &relation); + if (UNEXPECTED(Z_TYPE_P(joinType_param) != IS_STRING && Z_TYPE_P(joinType_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'joinType' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); + if (EXPECTED(Z_TYPE_P(joinType_param) == IS_STRING)) { + zephir_get_strval(&joinType, joinType_param); } else { - ZEPHIR_INIT_VAR(&routePattern); + ZEPHIR_INIT_VAR(&joinType); } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); + zephir_get_strval(&modelAlias, modelAlias_param); + zephir_get_strval(&joinAlias, joinAlias_param); + ZEPHIR_INIT_VAR(&sqlJoinConditions); + ZVAL_NULL(&sqlJoinConditions); + ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&referencedFields, relation, "getreferencedfields", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&fields) != IS_ARRAY) { + ZEPHIR_INIT_VAR(&_0$$3); + zephir_create_array(&_0$$3, 1, 0); + ZEPHIR_INIT_VAR(&_1$$3); + zephir_create_array(&_1$$3, 4, 0); + add_assoc_stringl_ex(&_1$$3, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_1$$3, SL("op"), SL("=")); + ZEPHIR_INIT_VAR(&_3$$3); + zephir_create_array(&_3$$3, 3, 0); + add_assoc_long_ex(&_3$$3, SL("type"), 355); + zephir_array_update_string(&_3$$3, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_3$$3, SL("name"), &fields, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "getqualified", NULL, 459, &_3$$3); + zephir_check_call_status(); + zephir_array_update_string(&_1$$3, SL("left"), &_2$$3, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_4$$3); + zephir_create_array(&_4$$3, 3, 0); + add_assoc_stringl_ex(&_4$$3, SL("type"), SL("qualified")); + zephir_array_update_string(&_4$$3, SL("domain"), &joinAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_4$$3, SL("name"), &referencedFields, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "getqualified", NULL, 459, &_4$$3); + zephir_check_call_status(); + zephir_array_update_string(&_1$$3, SL("right"), &_2$$3, PH_COPY | PH_SEPARATE); + zephir_array_fast_append(&_0$$3, &_1$$3); + ZEPHIR_CPY_WRT(&sqlJoinConditions, &_0$$3); } else { - zephir_get_strval(&name, name_param); + ZEPHIR_INIT_VAR(&sqlJoinPartialConditions); + array_init(&sqlJoinPartialConditions); + zephir_is_iterable(&fields, 0, "phalcon/Mvc/Model/Query.zep", 3418); + if (Z_TYPE_P(&fields) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&fields), _7$$4, _8$$4, _5$$4) + { + ZEPHIR_INIT_NVAR(&position); + if (_8$$4 != NULL) { + ZVAL_STR_COPY(&position, _8$$4); + } else { + ZVAL_LONG(&position, _7$$4); + } + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _5$$4); + ZEPHIR_OBS_NVAR(&referencedField); + if (UNEXPECTED(!(zephir_array_isset_fetch(&referencedField, &referencedFields, &position, 0)))) { + ZEPHIR_INIT_NVAR(&_9$$6); + object_init_ex(&_9$$6, phalcon_mvc_model_exception_ce); + zephir_read_property(&_10$$6, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_11$$6); + ZEPHIR_CONCAT_SVSVSV(&_11$$6, "The number of fields must be equal to the number of referenced fields in join ", &modelAlias, "-", &joinAlias, ", when preparing: ", &_10$$6); + ZEPHIR_CALL_METHOD(NULL, &_9$$6, "__construct", &_12, 33, &_11$$6); + zephir_check_call_status(); + zephir_throw_exception_debug(&_9$$6, "phalcon/Mvc/Model/Query.zep", 3390); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_NVAR(&_13$$5); + zephir_create_array(&_13$$5, 4, 0); + add_assoc_stringl_ex(&_13$$5, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_13$$5, SL("op"), SL("=")); + ZEPHIR_INIT_NVAR(&_15$$5); + zephir_create_array(&_15$$5, 3, 0); + add_assoc_long_ex(&_15$$5, SL("type"), 355); + zephir_array_update_string(&_15$$5, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_15$$5, SL("name"), &field, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_14$$5, this_ptr, "getqualified", NULL, 459, &_15$$5); + zephir_check_call_status(); + zephir_array_update_string(&_13$$5, SL("left"), &_14$$5, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_16$$5); + zephir_create_array(&_16$$5, 3, 0); + add_assoc_stringl_ex(&_16$$5, SL("type"), SL("qualified")); + zephir_array_update_string(&_16$$5, SL("domain"), &joinAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_16$$5, SL("name"), &referencedField, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_14$$5, this_ptr, "getqualified", NULL, 459, &_16$$5); + zephir_check_call_status(); + zephir_array_update_string(&_13$$5, SL("right"), &_14$$5, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlJoinPartialConditions, &_13$$5, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3415); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_6$$4, &fields, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_6$$4)) { + break; + } + ZEPHIR_CALL_METHOD(&position, &fields, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&field, &fields, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&referencedField); + if (UNEXPECTED(!(zephir_array_isset_fetch(&referencedField, &referencedFields, &position, 0)))) { + ZEPHIR_INIT_NVAR(&_17$$8); + object_init_ex(&_17$$8, phalcon_mvc_model_exception_ce); + zephir_read_property(&_18$$8, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_19$$8); + ZEPHIR_CONCAT_SVSVSV(&_19$$8, "The number of fields must be equal to the number of referenced fields in join ", &modelAlias, "-", &joinAlias, ", when preparing: ", &_18$$8); + ZEPHIR_CALL_METHOD(NULL, &_17$$8, "__construct", &_12, 33, &_19$$8); + zephir_check_call_status(); + zephir_throw_exception_debug(&_17$$8, "phalcon/Mvc/Model/Query.zep", 3390); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_NVAR(&_20$$7); + zephir_create_array(&_20$$7, 4, 0); + add_assoc_stringl_ex(&_20$$7, SL("type"), SL("binary-op")); + add_assoc_stringl_ex(&_20$$7, SL("op"), SL("=")); + ZEPHIR_INIT_NVAR(&_22$$7); + zephir_create_array(&_22$$7, 3, 0); + add_assoc_long_ex(&_22$$7, SL("type"), 355); + zephir_array_update_string(&_22$$7, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_22$$7, SL("name"), &field, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_21$$7, this_ptr, "getqualified", NULL, 459, &_22$$7); + zephir_check_call_status(); + zephir_array_update_string(&_20$$7, SL("left"), &_21$$7, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_23$$7); + zephir_create_array(&_23$$7, 3, 0); + add_assoc_stringl_ex(&_23$$7, SL("type"), SL("qualified")); + zephir_array_update_string(&_23$$7, SL("domain"), &joinAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_23$$7, SL("name"), &referencedField, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_21$$7, this_ptr, "getqualified", NULL, 459, &_23$$7); + zephir_check_call_status(); + zephir_array_update_string(&_20$$7, SL("right"), &_21$$7, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlJoinPartialConditions, &_20$$7, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3415); + ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&field); + ZEPHIR_INIT_NVAR(&position); } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, method, &routePattern, handler, &name); - zephir_check_call_status(); - RETURN_THIS(); + zephir_create_array(return_value, 3, 0); + zephir_array_update_string(return_value, SL("type"), &joinType, PH_COPY | PH_SEPARATE); + zephir_array_update_string(return_value, SL("source"), joinSource, PH_COPY | PH_SEPARATE); + zephir_array_update_string(return_value, SL("conditions"), &sqlJoinConditions, PH_COPY | PH_SEPARATE); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, options) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getTable) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; - zval routePattern, name; - zval *this_ptr = getThis(); + zval qualifiedName; + zval *manager, manager_sub, *qualifiedName_param = NULL, modelName, model, source, schema; - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + ZVAL_UNDEF(&manager_sub); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&qualifiedName); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(manager, phalcon_mvc_model_managerinterface_ce) + Z_PARAM_ARRAY(qualifiedName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); - } else { - ZEPHIR_INIT_VAR(&routePattern); - } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); - } else { - zephir_get_strval(&name, name_param); + zephir_fetch_params(1, 2, 0, &manager, &qualifiedName_param); + zephir_get_arrval(&qualifiedName, qualifiedName_param); + zephir_memory_observe(&modelName); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&modelName, &qualifiedName, SL("name"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 3440); + return; } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "OPTIONS"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); + ZEPHIR_CALL_METHOD(&model, manager, "load", NULL, 0, &modelName); zephir_check_call_status(); - RETURN_THIS(); + ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&schema)) { + zephir_create_array(return_value, 2, 0); + zephir_array_fast_append(return_value, &schema); + zephir_array_fast_append(return_value, &source); + RETURN_MM(); + } + RETURN_CCTOR(&source); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, patch) +static PHP_METHOD(Phalcon_Mvc_Model_Query, getWriteConnection) { + zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; - zval routePattern, name; + zval intermediate, bindParams, bindTypes; + zval *model, model_sub, *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, connection, transaction, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&connection); + ZVAL_UNDEF(&transaction); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&intermediate); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + Z_PARAM_ARRAY_OR_NULL(intermediate) + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 3, &model, &intermediate_param, &bindParams_param, &bindTypes_param); + if (!intermediate_param) { + ZEPHIR_INIT_VAR(&intermediate); + } else { + zephir_get_arrval(&intermediate, intermediate_param); } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); + if (!bindParams_param) { + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); } else { - ZEPHIR_INIT_VAR(&routePattern); + zephir_get_arrval(&bindParams, bindParams_param); } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); + if (!bindTypes_param) { + ZEPHIR_INIT_VAR(&bindTypes); + array_init(&bindTypes); } else { - zephir_get_strval(&name, name_param); + zephir_get_arrval(&bindTypes, bindTypes_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "PATCH"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); + ZEPHIR_INIT_VAR(&connection); + ZVAL_NULL(&connection); + zephir_read_property(&_0, this_ptr, ZEND_STRL("transaction"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&transaction, &_0); + _1 = Z_TYPE_P(&transaction) == IS_OBJECT; + if (_1) { + _1 = zephir_instance_of_ev(&transaction, phalcon_mvc_model_transactioninterface_ce); + } + if (_1) { + ZEPHIR_RETURN_CALL_METHOD(&transaction, "getconnection", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); + } + if ((zephir_method_exists_ex(model, ZEND_STRL("selectwriteconnection")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(&connection, model, "selectwriteconnection", NULL, 0, &intermediate, &bindParams, &bindTypes); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&connection) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "selectWriteConnection did not return a connection", "phalcon/Mvc/Model/Query.zep", 3478); + return; + } + RETURN_CCTOR(&connection); + } + ZEPHIR_RETURN_CALL_METHOD(model, "getwriteconnection", NULL, 0); zephir_check_call_status(); - RETURN_THIS(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, post) +static PHP_METHOD(Phalcon_Mvc_Model_Query, _prepareDelete) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval __$null, ast, delete, tables, models, modelsInstances, sqlTables, sqlModels, sqlAliases, sqlAliasesModelsInstances, deleteTables, manager, table, qualifiedName, modelName, model, source, schema, completeSource, alias, sqlDelete, where, limit, _0, *_1, _2, _4$$8, _5$$9, _7$$13, _8$$14, _9$$17, _10$$17, _11$$18; + zephir_fcall_cache_entry *_3 = NULL, *_6 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; - zval routePattern, name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&handler_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&ast); + ZVAL_UNDEF(&delete); + ZVAL_UNDEF(&tables); + ZVAL_UNDEF(&models); + ZVAL_UNDEF(&modelsInstances); + ZVAL_UNDEF(&sqlTables); + ZVAL_UNDEF(&sqlModels); + ZVAL_UNDEF(&sqlAliases); + ZVAL_UNDEF(&sqlAliasesModelsInstances); + ZVAL_UNDEF(&deleteTables); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&qualifiedName); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&completeSource); + ZVAL_UNDEF(&alias); + ZVAL_UNDEF(&sqlDelete); + ZVAL_UNDEF(&where); + ZVAL_UNDEF(&limit); ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4$$8); + ZVAL_UNDEF(&_5$$9); + ZVAL_UNDEF(&_7$$13); + ZVAL_UNDEF(&_8$$14); + ZVAL_UNDEF(&_9$$17); + ZVAL_UNDEF(&_10$$17); + ZVAL_UNDEF(&_11$$18); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("ast"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&ast, &_0); + zephir_memory_observe(&delete); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&delete, &ast, SL("delete"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted DELETE AST", "phalcon/Mvc/Model/Query.zep", 3500); + return; } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); + zephir_memory_observe(&tables); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&tables, &delete, SL("tables"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted DELETE AST", "phalcon/Mvc/Model/Query.zep", 3504); + return; + } + ZEPHIR_INIT_VAR(&models); + array_init(&models); + ZEPHIR_INIT_VAR(&modelsInstances); + array_init(&modelsInstances); + ZEPHIR_INIT_VAR(&sqlTables); + array_init(&sqlTables); + ZEPHIR_INIT_VAR(&sqlModels); + array_init(&sqlModels); + ZEPHIR_INIT_VAR(&sqlAliases); + array_init(&sqlAliases); + ZEPHIR_INIT_VAR(&sqlAliasesModelsInstances); + array_init(&sqlAliasesModelsInstances); + if (!(zephir_array_isset_long(&tables, 0))) { + ZEPHIR_INIT_VAR(&deleteTables); + zephir_create_array(&deleteTables, 1, 0); + zephir_array_fast_append(&deleteTables, &tables); } else { - ZEPHIR_INIT_VAR(&routePattern); + ZEPHIR_CPY_WRT(&deleteTables, &tables); } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); + zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&manager, &_0); + zephir_is_iterable(&deleteTables, 0, "phalcon/Mvc/Model/Query.zep", 3564); + if (Z_TYPE_P(&deleteTables) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&deleteTables), _1) + { + ZEPHIR_INIT_NVAR(&table); + ZVAL_COPY(&table, _1); + ZEPHIR_OBS_NVAR(&qualifiedName); + zephir_array_fetch_string(&qualifiedName, &table, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3528); + ZEPHIR_OBS_NVAR(&modelName); + zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3529); + ZEPHIR_CALL_METHOD(&model, &manager, "load", &_3, 0, &modelName); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&completeSource); + if (zephir_is_true(&schema)) { + ZEPHIR_INIT_NVAR(&_4$$8); + zephir_create_array(&_4$$8, 2, 0); + zephir_array_fast_append(&_4$$8, &source); + zephir_array_fast_append(&_4$$8, &schema); + ZEPHIR_CPY_WRT(&completeSource, &_4$$8); + } else { + ZEPHIR_INIT_NVAR(&_5$$9); + zephir_create_array(&_5$$9, 2, 0); + zephir_array_fast_append(&_5$$9, &source); + zephir_array_fast_append(&_5$$9, &__$null); + ZEPHIR_CPY_WRT(&completeSource, &_5$$9); + } + ZEPHIR_OBS_NVAR(&alias); + if (zephir_array_isset_string_fetch(&alias, &table, SL("alias"), 0)) { + zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); + zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3546); + zephir_array_append(&sqlTables, &completeSource, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3547); + zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&models, &alias, &modelName, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&sqlAliases, &modelName, &source, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlTables, &source, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3553); + zephir_array_update_zval(&models, &modelName, &source, PH_COPY | PH_SEPARATE); + } + zephir_array_append(&sqlModels, &modelName, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3557); + zephir_array_update_zval(&modelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); } else { - zephir_get_strval(&name, name_param); + ZEPHIR_CALL_METHOD(NULL, &deleteTables, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &deleteTables, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&table, &deleteTables, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&qualifiedName); + zephir_array_fetch_string(&qualifiedName, &table, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3528); + ZEPHIR_OBS_NVAR(&modelName); + zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3529); + ZEPHIR_CALL_METHOD(&model, &manager, "load", &_6, 0, &modelName); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&schema)) { + ZEPHIR_INIT_NVAR(&_7$$13); + zephir_create_array(&_7$$13, 2, 0); + zephir_array_fast_append(&_7$$13, &source); + zephir_array_fast_append(&_7$$13, &schema); + ZEPHIR_CPY_WRT(&completeSource, &_7$$13); + } else { + ZEPHIR_INIT_NVAR(&_8$$14); + zephir_create_array(&_8$$14, 2, 0); + zephir_array_fast_append(&_8$$14, &source); + zephir_array_fast_append(&_8$$14, &__$null); + ZEPHIR_CPY_WRT(&completeSource, &_8$$14); + } + ZEPHIR_OBS_NVAR(&alias); + if (zephir_array_isset_string_fetch(&alias, &table, SL("alias"), 0)) { + zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); + zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3546); + zephir_array_append(&sqlTables, &completeSource, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3547); + zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&models, &alias, &modelName, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&sqlAliases, &modelName, &source, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlTables, &source, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3553); + zephir_array_update_zval(&models, &modelName, &source, PH_COPY | PH_SEPARATE); + } + zephir_array_append(&sqlModels, &modelName, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3557); + zephir_array_update_zval(&modelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &deleteTables, "next", NULL, 0); + zephir_check_call_status(); + } } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "POST"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); - zephir_check_call_status(); - RETURN_THIS(); + ZEPHIR_INIT_NVAR(&table); + zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &models); + zephir_update_property_zval(this_ptr, ZEND_STRL("modelsInstances"), &modelsInstances); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliases"), &sqlAliases); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &sqlAliasesModelsInstances); + ZEPHIR_INIT_VAR(&sqlDelete); + array_init(&sqlDelete); + zephir_array_update_string(&sqlDelete, SL("tables"), &sqlTables, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&sqlDelete, SL("models"), &sqlModels, PH_COPY | PH_SEPARATE); + zephir_memory_observe(&where); + if (zephir_array_isset_string_fetch(&where, &ast, SL("where"), 0)) { + ZVAL_BOOL(&_10$$17, 1); + ZEPHIR_CALL_METHOD(&_9$$17, this_ptr, "getexpression", NULL, 458, &where, &_10$$17); + zephir_check_call_status(); + zephir_array_update_string(&sqlDelete, SL("where"), &_9$$17, PH_COPY | PH_SEPARATE); + } + zephir_memory_observe(&limit); + if (zephir_array_isset_string_fetch(&limit, &ast, SL("limit"), 0)) { + ZEPHIR_CALL_METHOD(&_11$$18, this_ptr, "getlimitclause", NULL, 472, &limit); + zephir_check_call_status(); + zephir_array_update_string(&sqlDelete, SL("limit"), &_11$$18, PH_COPY | PH_SEPARATE); + } + RETURN_CCTOR(&sqlDelete); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, put) +static PHP_METHOD(Phalcon_Mvc_Model_Query, _prepareInsert) { + zval _5$$7, _10$$8; + zend_bool notQuoting = 0; + zval ast, qualifiedName, manager, modelName, model, source, schema, exprValues, exprValue, sqlInsert, metaData, fields, sqlFields, field, name, _0, _2, *_3, _4, _1$$6, _6$$7, _7$$7, _8$$7, _11$$8, _12$$8, _13$$8, *_14$$9, _15$$9, _16$$10, _18$$11, _19$$11, _20$$11, _22$$12, _24$$13, _25$$13, _26$$13; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_9 = NULL, *_17 = NULL, *_21 = NULL, *_23 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; - zval routePattern, name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&ast); + ZVAL_UNDEF(&qualifiedName); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&exprValues); + ZVAL_UNDEF(&exprValue); + ZVAL_UNDEF(&sqlInsert); + ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&fields); + ZVAL_UNDEF(&sqlFields); + ZVAL_UNDEF(&field); ZVAL_UNDEF(&name); - ZVAL_UNDEF(&handler_sub); ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_1$$6); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_7$$7); + ZVAL_UNDEF(&_8$$7); + ZVAL_UNDEF(&_11$$8); + ZVAL_UNDEF(&_12$$8); + ZVAL_UNDEF(&_13$$8); + ZVAL_UNDEF(&_15$$9); + ZVAL_UNDEF(&_16$$10); + ZVAL_UNDEF(&_18$$11); + ZVAL_UNDEF(&_19$$11); + ZVAL_UNDEF(&_20$$11); + ZVAL_UNDEF(&_22$$12); + ZVAL_UNDEF(&_24$$13); + ZVAL_UNDEF(&_25$$13); + ZVAL_UNDEF(&_26$$13); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_10$$8); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("ast"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&ast, &_0); + if (UNEXPECTED(!(zephir_array_isset_string(&ast, SL("qualifiedName"))))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted INSERT AST", "phalcon/Mvc/Model/Query.zep", 3598); + return; } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); - } else { - ZEPHIR_INIT_VAR(&routePattern); + if (UNEXPECTED(!(zephir_array_isset_string(&ast, SL("values"))))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted INSERT AST", "phalcon/Mvc/Model/Query.zep", 3602); + return; } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); - } else { - zephir_get_strval(&name, name_param); + zephir_memory_observe(&qualifiedName); + zephir_array_fetch_string(&qualifiedName, &ast, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3605); + if (UNEXPECTED(!(zephir_array_isset_string(&qualifiedName, SL("name"))))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted INSERT AST", "phalcon/Mvc/Model/Query.zep", 3609); + return; } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "PUT"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); + zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&manager, &_0); + zephir_memory_observe(&modelName); + zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3613); + ZEPHIR_CALL_METHOD(&model, &manager, "load", NULL, 0, &modelName); zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, setHandler) -{ - zend_bool lazy; - zval *handler, handler_sub, *lazy_param = NULL, __$true, __$false; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&handler_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(handler) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(lazy) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 1, &handler, &lazy_param); - if (!lazy_param) { - lazy = 0; + ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&schema)) { + ZEPHIR_INIT_VAR(&_1$$6); + zephir_create_array(&_1$$6, 2, 0); + zephir_array_fast_append(&_1$$6, &schema); + zephir_array_fast_append(&_1$$6, &source); + ZEPHIR_CPY_WRT(&source, &_1$$6); + } + notQuoting = 0; + ZEPHIR_INIT_VAR(&exprValues); + array_init(&exprValues); + zephir_array_fetch_string(&_2, &ast, SL("values"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3626); + zephir_is_iterable(&_2, 0, "phalcon/Mvc/Model/Query.zep", 3634); + if (Z_TYPE_P(&_2) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_2), _3) + { + ZEPHIR_INIT_NVAR(&exprValue); + ZVAL_COPY(&exprValue, _3); + ZEPHIR_INIT_NVAR(&_5$$7); + zephir_create_array(&_5$$7, 2, 0); + ZEPHIR_OBS_NVAR(&_6$$7); + zephir_array_fetch_string(&_6$$7, &exprValue, SL("type"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3629); + zephir_array_update_string(&_5$$7, SL("type"), &_6$$7, PH_COPY | PH_SEPARATE); + if (notQuoting) { + ZVAL_BOOL(&_8$$7, 1); + } else { + ZVAL_BOOL(&_8$$7, 0); + } + ZEPHIR_CALL_METHOD(&_7$$7, this_ptr, "getexpression", &_9, 458, &exprValue, &_8$$7); + zephir_check_call_status(); + zephir_array_update_string(&_5$$7, SL("value"), &_7$$7, PH_COPY | PH_SEPARATE); + zephir_array_append(&exprValues, &_5$$7, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3631); + } ZEND_HASH_FOREACH_END(); } else { + ZEPHIR_CALL_METHOD(NULL, &_2, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_4, &_2, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_4)) { + break; + } + ZEPHIR_CALL_METHOD(&exprValue, &_2, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_10$$8); + zephir_create_array(&_10$$8, 2, 0); + ZEPHIR_OBS_NVAR(&_11$$8); + zephir_array_fetch_string(&_11$$8, &exprValue, SL("type"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3629); + zephir_array_update_string(&_10$$8, SL("type"), &_11$$8, PH_COPY | PH_SEPARATE); + if (notQuoting) { + ZVAL_BOOL(&_13$$8, 1); + } else { + ZVAL_BOOL(&_13$$8, 0); + } + ZEPHIR_CALL_METHOD(&_12$$8, this_ptr, "getexpression", &_9, 458, &exprValue, &_13$$8); + zephir_check_call_status(); + zephir_array_update_string(&_10$$8, SL("value"), &_12$$8, PH_COPY | PH_SEPARATE); + zephir_array_append(&exprValues, &_10$$8, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3631); + ZEPHIR_CALL_METHOD(NULL, &_2, "next", NULL, 0); + zephir_check_call_status(); } - zephir_update_property_zval(this_ptr, ZEND_STRL("handler"), handler); - if (lazy) { - zephir_update_property_zval(this_ptr, ZEND_STRL("lazy"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("lazy"), &__$false); - } - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, setLazy) -{ - zval *lazy_param = NULL, __$true, __$false; - zend_bool lazy; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(lazy) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &lazy_param); - if (UNEXPECTED(Z_TYPE_P(lazy_param) != IS_TRUE && Z_TYPE_P(lazy_param) != IS_FALSE)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'lazy' must be of the type bool")); - RETURN_NULL(); } - lazy = (Z_TYPE_P(lazy_param) == IS_TRUE); - if (lazy) { - zephir_update_property_zval(this_ptr, ZEND_STRL("lazy"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("lazy"), &__$false); + ZEPHIR_INIT_NVAR(&exprValue); + ZEPHIR_INIT_VAR(&sqlInsert); + zephir_create_array(&sqlInsert, 2, 0); + zephir_array_update_string(&sqlInsert, SL("model"), &modelName, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&sqlInsert, SL("table"), &source, PH_COPY | PH_SEPARATE); + zephir_read_property(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&metaData, &_0); + zephir_memory_observe(&fields); + if (zephir_array_isset_string_fetch(&fields, &ast, SL("fields"), 0)) { + ZEPHIR_INIT_VAR(&sqlFields); + array_init(&sqlFields); + zephir_is_iterable(&fields, 0, "phalcon/Mvc/Model/Query.zep", 3658); + if (Z_TYPE_P(&fields) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&fields), _14$$9) + { + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _14$$9); + ZEPHIR_OBS_NVAR(&name); + zephir_array_fetch_string(&name, &field, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3645); + ZEPHIR_CALL_METHOD(&_16$$10, &metaData, "hasattribute", &_17, 0, &model, &name); + zephir_check_call_status(); + if (UNEXPECTED(!zephir_is_true(&_16$$10))) { + ZEPHIR_INIT_NVAR(&_18$$11); + object_init_ex(&_18$$11, phalcon_mvc_model_exception_ce); + zephir_read_property(&_19$$11, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_20$$11); + ZEPHIR_CONCAT_SVSVSV(&_20$$11, "The model '", &modelName, "' doesn't have the attribute '", &name, "', when preparing: ", &_19$$11); + ZEPHIR_CALL_METHOD(NULL, &_18$$11, "__construct", &_21, 33, &_20$$11); + zephir_check_call_status(); + zephir_throw_exception_debug(&_18$$11, "phalcon/Mvc/Model/Query.zep", 3651); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_array_append(&sqlFields, &name, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3655); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_15$$9, &fields, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_15$$9)) { + break; + } + ZEPHIR_CALL_METHOD(&field, &fields, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&name); + zephir_array_fetch_string(&name, &field, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3645); + ZEPHIR_CALL_METHOD(&_22$$12, &metaData, "hasattribute", &_23, 0, &model, &name); + zephir_check_call_status(); + if (UNEXPECTED(!zephir_is_true(&_22$$12))) { + ZEPHIR_INIT_NVAR(&_24$$13); + object_init_ex(&_24$$13, phalcon_mvc_model_exception_ce); + zephir_read_property(&_25$$13, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_26$$13); + ZEPHIR_CONCAT_SVSVSV(&_26$$13, "The model '", &modelName, "' doesn't have the attribute '", &name, "', when preparing: ", &_25$$13); + ZEPHIR_CALL_METHOD(NULL, &_24$$13, "__construct", &_21, 33, &_26$$13); + zephir_check_call_status(); + zephir_throw_exception_debug(&_24$$13, "phalcon/Mvc/Model/Query.zep", 3651); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_array_append(&sqlFields, &name, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3655); + ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&field); + zephir_array_update_string(&sqlInsert, SL("fields"), &sqlFields, PH_COPY | PH_SEPARATE); } - RETURN_THISW(); + zephir_array_update_string(&sqlInsert, SL("values"), &exprValues, PH_COPY | PH_SEPARATE); + RETURN_CCTOR(&sqlInsert); } -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, setPrefix) +static PHP_METHOD(Phalcon_Mvc_Model_Query, _prepareSelect) { + zval _13$$24, _25$$28, _46$$43, _58$$47, _90$$66, _93$$73, _99$$81, _102$$88; + zval sqlModels, sqlTables, sqlAliases, sqlColumns, sqlAliasesModels, sqlModelsAliases, sqlAliasesModelsInstances, models, modelsInstances, _21$$24, _22$$24, _23$$24, _33$$28, _34$$28, _35$$28, _54$$43, _55$$43, _56$$43, _66$$47, _67$$47, _68$$47; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *prefix_param = NULL; - zval prefix; + zephir_fcall_cache_entry *_4 = NULL, *_8 = NULL, *_14 = NULL, *_16 = NULL, *_26 = NULL, *_28 = NULL, *_36 = NULL, *_47 = NULL, *_49 = NULL, *_59 = NULL, *_61 = NULL, *_85 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, position = 0, number = 0; + zend_bool merge; + zval *ast = NULL, ast_sub, *merge_param = NULL, __$null, __$true, select, tables, columns, selectedModels, manager, metaData, selectedModel, qualifiedName, modelName, model, schema, source, completeSource, alias, joins, sqlJoins, selectColumns, sqlColumnAliases, column, sqlColumn, sqlSelect, distinct, having, where, groupBy, order, limit, tempModels, tempModelsInstances, tempSqlAliases, tempSqlModelsAliases, tempSqlAliasesModelsInstances, tempSqlAliasesModels, with, withs, withItem, automaticJoins, relation, joinAlias, relationModel, bestAlias, eagerType, _1, *_2, _3, *_82, _83, _103, _0$$3, _5$$17, _6$$17, _7$$17, _9$$19, *_10$$21, _11$$21, _12$$24, _15$$25, _17$$27, _18$$27, _19$$27, _20$$26, _24$$28, _27$$29, _29$$31, _30$$31, _31$$31, _32$$30, _37$$33, _38$$36, _39$$36, _40$$36, _41$$38, _42$$41, *_43$$40, _44$$40, _45$$43, _48$$44, _50$$46, _51$$46, _52$$46, _53$$45, _57$$47, _60$$48, _62$$50, _63$$50, _64$$50, _65$$49, _69$$52, _70$$52, _71$$52, _72$$52, _73$$52, _74$$52, _75$$52, _76$$52, _77$$52, _78$$52, _79$$52, _80$$52, _81$$55, _84$$60, *_86$$60, _87$$60, _88$$65, _89$$66, _91$$72, _92$$73, _94$$75, *_95$$75, _96$$75, _97$$80, _98$$81, _100$$87, _101$$88, _104$$92, _105$$93, _106$$94, _107$$95, _108$$96; zval *this_ptr = getThis(); - ZVAL_UNDEF(&prefix); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(prefix) + ZVAL_UNDEF(&ast_sub); + ZVAL_NULL(&__$null); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&select); + ZVAL_UNDEF(&tables); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&selectedModels); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&selectedModel); + ZVAL_UNDEF(&qualifiedName); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&completeSource); + ZVAL_UNDEF(&alias); + ZVAL_UNDEF(&joins); + ZVAL_UNDEF(&sqlJoins); + ZVAL_UNDEF(&selectColumns); + ZVAL_UNDEF(&sqlColumnAliases); + ZVAL_UNDEF(&column); + ZVAL_UNDEF(&sqlColumn); + ZVAL_UNDEF(&sqlSelect); + ZVAL_UNDEF(&distinct); + ZVAL_UNDEF(&having); + ZVAL_UNDEF(&where); + ZVAL_UNDEF(&groupBy); + ZVAL_UNDEF(&order); + ZVAL_UNDEF(&limit); + ZVAL_UNDEF(&tempModels); + ZVAL_UNDEF(&tempModelsInstances); + ZVAL_UNDEF(&tempSqlAliases); + ZVAL_UNDEF(&tempSqlModelsAliases); + ZVAL_UNDEF(&tempSqlAliasesModelsInstances); + ZVAL_UNDEF(&tempSqlAliasesModels); + ZVAL_UNDEF(&with); + ZVAL_UNDEF(&withs); + ZVAL_UNDEF(&withItem); + ZVAL_UNDEF(&automaticJoins); + ZVAL_UNDEF(&relation); + ZVAL_UNDEF(&joinAlias); + ZVAL_UNDEF(&relationModel); + ZVAL_UNDEF(&bestAlias); + ZVAL_UNDEF(&eagerType); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_83); + ZVAL_UNDEF(&_103); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_5$$17); + ZVAL_UNDEF(&_6$$17); + ZVAL_UNDEF(&_7$$17); + ZVAL_UNDEF(&_9$$19); + ZVAL_UNDEF(&_11$$21); + ZVAL_UNDEF(&_12$$24); + ZVAL_UNDEF(&_15$$25); + ZVAL_UNDEF(&_17$$27); + ZVAL_UNDEF(&_18$$27); + ZVAL_UNDEF(&_19$$27); + ZVAL_UNDEF(&_20$$26); + ZVAL_UNDEF(&_24$$28); + ZVAL_UNDEF(&_27$$29); + ZVAL_UNDEF(&_29$$31); + ZVAL_UNDEF(&_30$$31); + ZVAL_UNDEF(&_31$$31); + ZVAL_UNDEF(&_32$$30); + ZVAL_UNDEF(&_37$$33); + ZVAL_UNDEF(&_38$$36); + ZVAL_UNDEF(&_39$$36); + ZVAL_UNDEF(&_40$$36); + ZVAL_UNDEF(&_41$$38); + ZVAL_UNDEF(&_42$$41); + ZVAL_UNDEF(&_44$$40); + ZVAL_UNDEF(&_45$$43); + ZVAL_UNDEF(&_48$$44); + ZVAL_UNDEF(&_50$$46); + ZVAL_UNDEF(&_51$$46); + ZVAL_UNDEF(&_52$$46); + ZVAL_UNDEF(&_53$$45); + ZVAL_UNDEF(&_57$$47); + ZVAL_UNDEF(&_60$$48); + ZVAL_UNDEF(&_62$$50); + ZVAL_UNDEF(&_63$$50); + ZVAL_UNDEF(&_64$$50); + ZVAL_UNDEF(&_65$$49); + ZVAL_UNDEF(&_69$$52); + ZVAL_UNDEF(&_70$$52); + ZVAL_UNDEF(&_71$$52); + ZVAL_UNDEF(&_72$$52); + ZVAL_UNDEF(&_73$$52); + ZVAL_UNDEF(&_74$$52); + ZVAL_UNDEF(&_75$$52); + ZVAL_UNDEF(&_76$$52); + ZVAL_UNDEF(&_77$$52); + ZVAL_UNDEF(&_78$$52); + ZVAL_UNDEF(&_79$$52); + ZVAL_UNDEF(&_80$$52); + ZVAL_UNDEF(&_81$$55); + ZVAL_UNDEF(&_84$$60); + ZVAL_UNDEF(&_87$$60); + ZVAL_UNDEF(&_88$$65); + ZVAL_UNDEF(&_89$$66); + ZVAL_UNDEF(&_91$$72); + ZVAL_UNDEF(&_92$$73); + ZVAL_UNDEF(&_94$$75); + ZVAL_UNDEF(&_96$$75); + ZVAL_UNDEF(&_97$$80); + ZVAL_UNDEF(&_98$$81); + ZVAL_UNDEF(&_100$$87); + ZVAL_UNDEF(&_101$$88); + ZVAL_UNDEF(&_104$$92); + ZVAL_UNDEF(&_105$$93); + ZVAL_UNDEF(&_106$$94); + ZVAL_UNDEF(&_107$$95); + ZVAL_UNDEF(&_108$$96); + ZVAL_UNDEF(&sqlModels); + ZVAL_UNDEF(&sqlTables); + ZVAL_UNDEF(&sqlAliases); + ZVAL_UNDEF(&sqlColumns); + ZVAL_UNDEF(&sqlAliasesModels); + ZVAL_UNDEF(&sqlModelsAliases); + ZVAL_UNDEF(&sqlAliasesModelsInstances); + ZVAL_UNDEF(&models); + ZVAL_UNDEF(&modelsInstances); + ZVAL_UNDEF(&_21$$24); + ZVAL_UNDEF(&_22$$24); + ZVAL_UNDEF(&_23$$24); + ZVAL_UNDEF(&_33$$28); + ZVAL_UNDEF(&_34$$28); + ZVAL_UNDEF(&_35$$28); + ZVAL_UNDEF(&_54$$43); + ZVAL_UNDEF(&_55$$43); + ZVAL_UNDEF(&_56$$43); + ZVAL_UNDEF(&_66$$47); + ZVAL_UNDEF(&_67$$47); + ZVAL_UNDEF(&_68$$47); + ZVAL_UNDEF(&_13$$24); + ZVAL_UNDEF(&_25$$28); + ZVAL_UNDEF(&_46$$43); + ZVAL_UNDEF(&_58$$47); + ZVAL_UNDEF(&_90$$66); + ZVAL_UNDEF(&_93$$73); + ZVAL_UNDEF(&_99$$81); + ZVAL_UNDEF(&_102$$88); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(ast) + Z_PARAM_BOOL(merge) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &prefix_param); - if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 0, 2, &ast, &merge_param); + if (!ast) { + ast = &ast_sub; + ZEPHIR_CPY_WRT(ast, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(ast); } - if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) { - zephir_get_strval(&prefix, prefix_param); + if (!merge_param) { + merge = 0; } else { - ZEPHIR_INIT_VAR(&prefix); + } + if (ZEPHIR_IS_EMPTY(ast)) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("ast"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(ast, &_0$$3); } - zephir_update_property_zval(this_ptr, ZEND_STRL("prefix"), &prefix); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Micro_Collection, addMap) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval routePattern, name; - zval *method, method_sub, *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&method_sub); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&routePattern); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_ZVAL(method) - Z_PARAM_STR(routePattern) - Z_PARAM_ZVAL(handler) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 1, &method, &routePattern_param, &handler, &name_param); - if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); - RETURN_MM_NULL(); + zephir_memory_observe(&select); + if (!(zephir_array_isset_string_fetch(&select, ast, SL("select"), 0))) { + ZEPHIR_CPY_WRT(&select, ast); } - if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { - zephir_get_strval(&routePattern, routePattern_param); + zephir_memory_observe(&tables); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&tables, &select, SL("tables"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 3694); + return; + } + zephir_memory_observe(&columns); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&columns, &select, SL("columns"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 3698); + return; + } + RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("nestingLevel"))); + ZEPHIR_INIT_VAR(&sqlModels); + array_init(&sqlModels); + ZEPHIR_INIT_VAR(&sqlTables); + array_init(&sqlTables); + ZEPHIR_INIT_VAR(&sqlColumns); + array_init(&sqlColumns); + ZEPHIR_INIT_VAR(&sqlAliases); + array_init(&sqlAliases); + ZEPHIR_INIT_VAR(&sqlAliasesModels); + array_init(&sqlAliasesModels); + ZEPHIR_INIT_VAR(&sqlModelsAliases); + array_init(&sqlModelsAliases); + ZEPHIR_INIT_VAR(&sqlAliasesModelsInstances); + array_init(&sqlAliasesModelsInstances); + ZEPHIR_INIT_VAR(&models); + array_init(&models); + ZEPHIR_INIT_VAR(&modelsInstances); + array_init(&modelsInstances); + if (!(zephir_array_isset_long(&tables, 0))) { + ZEPHIR_INIT_VAR(&selectedModels); + zephir_create_array(&selectedModels, 1, 0); + zephir_array_fast_append(&selectedModels, &tables); } else { - ZEPHIR_INIT_VAR(&routePattern); + ZEPHIR_CPY_WRT(&selectedModels, &tables); } - if (!name_param) { - ZEPHIR_INIT_VAR(&name); + if (!(zephir_array_isset_long(&columns, 0))) { + ZEPHIR_INIT_VAR(&selectColumns); + zephir_create_array(&selectColumns, 1, 0); + zephir_array_fast_append(&selectColumns, &columns); } else { - zephir_get_strval(&name, name_param); + ZEPHIR_CPY_WRT(&selectColumns, &columns); } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 4, 0); - zephir_array_fast_append(&_0, method); - zephir_array_fast_append(&_0, &routePattern); - zephir_array_fast_append(&_0, handler); - zephir_array_fast_append(&_0, &name); - zephir_update_property_array_append(this_ptr, SL("handlers"), &_0); - ZEPHIR_MM_RESTORE(); -} - -zend_object *zephir_init_properties_Phalcon_Mvc_Micro_Collection(zend_class_entry *class_type) -{ - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("handlers"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("handlers"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + zephir_read_property(&_1, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&manager, &_1); + zephir_read_property(&_1, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&metaData, &_1); + if (UNEXPECTED(Z_TYPE_P(&manager) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A models-manager is required to execute the query", "phalcon/Mvc/Model/Query.zep", 3765); + return; } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_CollectionInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Micro, CollectionInterface, phalcon, mvc_micro_collectioninterface, phalcon_mvc_micro_collectioninterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, delete); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, get); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, getHandler); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, getHandlers); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, getPrefix); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, head); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, isLazy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, map); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, options); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, patch); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, post); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, put); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, setHandler); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, setLazy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, setPrefix); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_Exception) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Micro, Exception, phalcon, mvc_micro_exception, zend_ce_exception, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_LazyLoader) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Micro, LazyLoader, phalcon, mvc_micro_lazyloader, phalcon_mvc_micro_lazyloader_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_micro_lazyloader_ce, SL("definition"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_micro_lazyloader_ce, SL("handler"), ZEND_ACC_PROTECTED); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *definition_param = NULL; - zval definition; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&definition); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(definition) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &definition_param); - if (UNEXPECTED(Z_TYPE_P(definition_param) != IS_STRING && Z_TYPE_P(definition_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'definition' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(definition_param) == IS_STRING)) { - zephir_get_strval(&definition, definition_param); - } else { - ZEPHIR_INIT_VAR(&definition); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("definition"), &definition); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, callMethod) -{ - zval _4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *method_param = NULL, *arguments = NULL, arguments_sub, *modelBinder = NULL, modelBinder_sub, __$null, handler, definition, bindCacheKey, _0, _1$$4, _2$$4, _3$$5; - zval method; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&arguments_sub); - ZVAL_UNDEF(&modelBinder_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&handler); - ZVAL_UNDEF(&definition); - ZVAL_UNDEF(&bindCacheKey); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(method) - Z_PARAM_ZVAL(arguments) - Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(modelBinder, phalcon_mvc_model_binderinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &method_param, &arguments, &modelBinder); - if (UNEXPECTED(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 of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(method_param) == IS_STRING)) { - zephir_get_strval(&method, method_param); - } else { - ZEPHIR_INIT_VAR(&method); - } - ZEPHIR_SEPARATE_PARAM(arguments); - if (!modelBinder) { - modelBinder = &modelBinder_sub; - modelBinder = &__$null; + if (UNEXPECTED(Z_TYPE_P(&metaData) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A meta-data is required to execute the query", "phalcon/Mvc/Model/Query.zep", 3771); + return; } - zephir_read_property(&_0, this_ptr, ZEND_STRL("handler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&handler, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("definition"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&definition, &_0); - if (Z_TYPE_P(&handler) != IS_OBJECT) { - if (!(zephir_class_exists(&definition, 1))) { - ZEPHIR_INIT_VAR(&_1$$4); - object_init_ex(&_1$$4, phalcon_mvc_micro_exception_ce); - ZEPHIR_INIT_VAR(&_2$$4); - ZEPHIR_CONCAT_SVS(&_2$$4, "Handler '", &definition, "' doesn't exist"); - ZEPHIR_CALL_METHOD(NULL, &_1$$4, "__construct", NULL, 33, &_2$$4); + number = 0; + ZEPHIR_INIT_VAR(&automaticJoins); + array_init(&automaticJoins); + zephir_is_iterable(&selectedModels, 0, "phalcon/Mvc/Model/Query.zep", 3901); + if (Z_TYPE_P(&selectedModels) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&selectedModels), _2) + { + ZEPHIR_INIT_NVAR(&selectedModel); + ZVAL_COPY(&selectedModel, _2); + ZEPHIR_OBS_NVAR(&qualifiedName); + zephir_array_fetch_string(&qualifiedName, &selectedModel, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3779); + ZEPHIR_OBS_NVAR(&modelName); + zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3780); + ZEPHIR_CALL_METHOD(&model, &manager, "load", &_4, 0, &modelName); zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$4, "phalcon/Mvc/Micro/LazyLoader.zep", 55); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_NVAR(&handler); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&handler, &definition); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("handler"), &handler); - } - if (Z_TYPE_P(modelBinder) != IS_NULL) { - ZEPHIR_INIT_VAR(&bindCacheKey); - ZEPHIR_CONCAT_SVSV(&bindCacheKey, "_PHMB_", &definition, "_", &method); - ZEPHIR_CALL_METHOD(&_3$$5, modelBinder, "bindtohandler", NULL, 0, &handler, arguments, &bindCacheKey, &method); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(arguments, &_3$$5); - } - ZEPHIR_INIT_VAR(&_4); - zephir_create_array(&_4, 2, 0); - zephir_array_fast_append(&_4, &handler); - zephir_array_fast_append(&_4, &method); - ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_4, arguments); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, getDefinition) -{ - - RETURN_MEMBER(getThis(), "definition"); -} - -static PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, getHandler) -{ - - RETURN_MEMBER(getThis(), "handler"); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_MiddlewareInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Micro, MiddlewareInterface, phalcon, mvc_micro_middlewareinterface, phalcon_mvc_micro_middlewareinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_MiddlewareInterface, call); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Dispatcher_Exception) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Dispatcher, Exception, phalcon, mvc_dispatcher_exception, phalcon_dispatcher_exception_ce, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Url_Exception) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Url, Exception, phalcon, mvc_url_exception, zend_ce_exception, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Url_UrlInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Url, UrlInterface, phalcon, mvc_url_urlinterface, phalcon_mvc_url_urlinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Url_UrlInterface, get); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Url_UrlInterface, getBasePath); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Url_UrlInterface, getBaseUri); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Url_UrlInterface, setBasePath); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Url_UrlInterface, setBaseUri); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Url_UrlInterface, path); - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -static void phalcon_get_uri(zval *return_value, zval *path) -{ - int i, found = 0, mark = 0; - char *cursor, *str, ch; - - if (Z_TYPE_P(path) != IS_STRING) { - RETURN_EMPTY_STRING(); - } - - if (Z_STRLEN_P(path) > 0) { - cursor = Z_STRVAL_P(path) + Z_STRLEN_P(path) - 1; - for (i = Z_STRLEN_P(path); i > 0; i--) { - ch = *cursor; - if (ch == '/' || ch == '\\') { - found++; - if (found == 1) { - mark = i - 1; - } else { - str = emalloc(mark - i + 1); - memcpy(str, Z_STRVAL_P(path) + i, mark - i); - str[mark - i] = '\0'; - ZVAL_STRINGL(return_value, str, mark - i); + ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&schema)) { + ZEPHIR_INIT_NVAR(&completeSource); + zephir_create_array(&completeSource, 2, 0); + zephir_array_fast_append(&completeSource, &source); + zephir_array_fast_append(&completeSource, &schema); + } else { + ZEPHIR_CPY_WRT(&completeSource, &source); + } + ZEPHIR_OBS_NVAR(&alias); + if (zephir_array_isset_string_fetch(&alias, &selectedModel, SL("alias"), 0)) { + if (UNEXPECTED(zephir_array_isset(&sqlAliases, &alias))) { + ZEPHIR_INIT_NVAR(&_5$$17); + object_init_ex(&_5$$17, phalcon_mvc_model_exception_ce); + zephir_read_property(&_6$$17, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_7$$17); + ZEPHIR_CONCAT_SVSV(&_7$$17, "Alias '", &alias, "' is used more than once, when preparing: ", &_6$$17); + ZEPHIR_CALL_METHOD(NULL, &_5$$17, "__construct", &_8, 33, &_7$$17); + zephir_check_call_status(); + zephir_throw_exception_debug(&_5$$17, "phalcon/Mvc/Model/Query.zep", 3805); + ZEPHIR_MM_RESTORE(); return; } - } - cursor--; - } - } - - RETURN_EMPTY_STRING(); -} - -zval *phalcon_replace_marker(int named, zval *paths, zval *replacements, unsigned long *position, char *cursor, char *marker) -{ - unsigned int length = 0, variable_length, ch, j; - char *item = NULL, *cursor_var, *variable = NULL; - int not_valid = 0; - zval *zv, *tmp; - - if (named) { - length = cursor - marker - 1; - item = estrndup(marker + 1, length); - cursor_var = item; - marker = item; - for (j = 0; j < length; j++) { - ch = *cursor_var; - if (ch == '\0') { - not_valid = 1; - break; - } - if (j == 0 && !((ch >= 'a' && ch <='z') || (ch >= 'A' && ch <= 'Z'))){ - not_valid = 1; - break; - } - if ((ch >= 'a' && ch <='z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || ch == '-' || ch == '_' || ch == ':') { - if (ch == ':') { - variable_length = cursor_var - marker; - variable = estrndup(marker, variable_length); - break; + zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModels, &alias, &modelName, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlModelsAliases, &modelName, &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); + if (Z_TYPE_P(&completeSource) == IS_ARRAY) { + zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3817); + } else { + ZEPHIR_INIT_NVAR(&_9$$19); + zephir_create_array(&_9$$19, 3, 0); + zephir_array_fast_append(&_9$$19, &source); + zephir_array_fast_append(&_9$$19, &__$null); + zephir_array_fast_append(&_9$$19, &alias); + ZEPHIR_CPY_WRT(&completeSource, &_9$$19); } + zephir_array_update_zval(&models, &modelName, &alias, PH_COPY | PH_SEPARATE); } else { - not_valid = 1; - break; + ZEPHIR_CPY_WRT(&alias, &source); + zephir_array_update_zval(&sqlAliases, &modelName, &source, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModels, &modelName, &modelName, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlModelsAliases, &modelName, &modelName, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&models, &modelName, &source, PH_COPY | PH_SEPARATE); } - cursor_var++; - } - } - - if (!not_valid) { - - if (zend_hash_index_exists(Z_ARRVAL_P(paths), *position)) { - if (named) { - if (variable) { - efree(item); - item = variable; - length = variable_length; - } - if (zend_hash_str_exists(Z_ARRVAL_P(replacements), item, length)) { - if ((zv = zend_hash_str_find(Z_ARRVAL_P(replacements), item, length)) != NULL) { - efree(item); - (*position)++; - return zv; - } + ZEPHIR_OBS_NVAR(&with); + if (zephir_array_isset_string_fetch(&with, &selectedModel, SL("with"), 0)) { + if (!(zephir_array_isset_long(&with, 0))) { + ZEPHIR_INIT_NVAR(&withs); + zephir_create_array(&withs, 1, 0); + zephir_array_fast_append(&withs, &with); + } else { + ZEPHIR_CPY_WRT(&withs, &with); } - } else { - if ((zv = zend_hash_index_find(Z_ARRVAL_P(paths), *position)) != NULL) { - if (Z_TYPE_P(zv) == IS_STRING) { - if (zend_hash_str_exists(Z_ARRVAL_P(replacements), Z_STRVAL_P(zv), Z_STRLEN_P(zv))) { - if ((tmp = zend_hash_str_find(Z_ARRVAL_P(replacements), Z_STRVAL_P(zv), Z_STRLEN_P(zv))) != NULL) { - (*position)++; - return tmp; + zephir_is_iterable(&withs, 0, "phalcon/Mvc/Model/Query.zep", 3893); + if (Z_TYPE_P(&withs) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&withs), _10$$21) + { + ZEPHIR_INIT_NVAR(&withItem); + ZVAL_COPY(&withItem, _10$$21); + ZEPHIR_INIT_NVAR(&_12$$24); + ZVAL_LONG(&_12$$24, number); + ZEPHIR_INIT_NVAR(&_13$$24); + ZEPHIR_CONCAT_SV(&_13$$24, "AA", &_12$$24); + ZEPHIR_CPY_WRT(&joinAlias, &_13$$24); + ZEPHIR_OBS_NVAR(&relationModel); + zephir_array_fetch_string(&relationModel, &withItem, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3843); + ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_14, 0, &modelName, &relationModel); + zephir_check_call_status(); + if (Z_TYPE_P(&relation) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_15$$25); + ZVAL_STRING(&_15$$25, "alias"); + ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_15$$25); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); + zephir_check_call_status(); + } else { + ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationsbetween", &_16, 0, &modelName, &relationModel); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&relation) != IS_OBJECT)) { + ZEPHIR_INIT_NVAR(&_17$$27); + object_init_ex(&_17$$27, phalcon_mvc_model_exception_ce); + zephir_read_property(&_18$$27, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_19$$27); + ZEPHIR_CONCAT_SVSVSV(&_19$$27, "Can't find a relationship between '", &modelName, "' and '", &relationModel, "' when preparing: ", &_18$$27); + ZEPHIR_CALL_METHOD(NULL, &_17$$27, "__construct", &_8, 33, &_19$$27); + zephir_check_call_status(); + zephir_throw_exception_debug(&_17$$27, "phalcon/Mvc/Model/Query.zep", 3863); + ZEPHIR_MM_RESTORE(); + return; } + ZEPHIR_INIT_NVAR(&_20$$26); + ZVAL_STRING(&_20$$26, "alias"); + ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_20$$26); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); + zephir_check_call_status(); } - } - } - } - } - - (*position)++; - } - - if (item) { - efree(item); - } - - return NULL; -} - -static void phalcon_replace_paths(zval *return_value, zval *pattern, zval *paths, zval *replacements) -{ - - char *cursor, *marker = NULL; - unsigned int bracket_count = 0, parentheses_count = 0, intermediate = 0; - unsigned char ch; - smart_str route_str = {0}; - zend_ulong position = 1; - int i; - zval *replace, replace_copy; - int use_copy, looking_placeholder = 0; - - if (Z_TYPE_P(pattern) != IS_STRING || Z_TYPE_P(replacements) != IS_ARRAY || Z_TYPE_P(paths) != IS_ARRAY) { - ZVAL_NULL(return_value); - php_error_docref(NULL, E_WARNING, "Invalid arguments supplied for phalcon_replace_paths()"); - return; - } - - if (Z_STRLEN_P(pattern) <= 0) { - ZVAL_FALSE(return_value); - return; - } - - cursor = Z_STRVAL_P(pattern); - if (*cursor == '/') { - ++cursor; - i = 1; - } - else { - i = 0; - } - - if (!zend_hash_num_elements(Z_ARRVAL_P(paths))) { - ZVAL_STRINGL(return_value, Z_STRVAL_P(pattern) + i, Z_STRLEN_P(pattern) - i); - return; - } - - for (; i < Z_STRLEN_P(pattern); ++i) { - - ch = *cursor; - if (ch == '\0') { - break; - } - - if (parentheses_count == 0 && !looking_placeholder) { - if (ch == '{') { - if (bracket_count == 0) { - marker = cursor; - intermediate = 0; - } - bracket_count++; - } else { - if (ch == '}') { - bracket_count--; - if (intermediate > 0) { - if (bracket_count == 0) { - replace = phalcon_replace_marker(1, paths, replacements, &position, cursor, marker); - if (replace) { - use_copy = 0; - if (Z_TYPE_P(replace) != IS_STRING) { - use_copy = zend_make_printable_zval(replace, &replace_copy); - if (use_copy) { - replace = &replace_copy; - } - } - smart_str_appendl(&route_str, Z_STRVAL_P(replace), Z_STRLEN_P(replace)); - if (use_copy) { - zval_dtor(&replace_copy); + ZEPHIR_INIT_NVAR(&_21$$24); + zephir_create_array(&_21$$24, 5, 0); + add_assoc_long_ex(&_21$$24, SL("type"), 353); + zephir_array_update_string(&_21$$24, SL("column"), &joinAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_21$$24, SL("eager"), &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_21$$24, SL("eagerType"), &eagerType, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_21$$24, SL("balias"), &bestAlias, PH_COPY | PH_SEPARATE); + zephir_array_append(&selectColumns, &_21$$24, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3877); + ZEPHIR_INIT_NVAR(&_22$$24); + zephir_create_array(&_22$$24, 3, 0); + add_assoc_long_ex(&_22$$24, SL("type"), 360); + ZEPHIR_INIT_NVAR(&_23$$24); + zephir_create_array(&_23$$24, 2, 0); + add_assoc_long_ex(&_23$$24, SL("type"), 355); + zephir_array_update_string(&_23$$24, SL("name"), &relationModel, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_22$$24, SL("qualified"), &_23$$24, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_23$$24); + zephir_create_array(&_23$$24, 2, 0); + add_assoc_long_ex(&_23$$24, SL("type"), 355); + zephir_array_update_string(&_23$$24, SL("name"), &joinAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_22$$24, SL("alias"), &_23$$24, PH_COPY | PH_SEPARATE); + zephir_array_append(&automaticJoins, &_22$$24, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3889); + number++; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &withs, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_11$$21, &withs, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_11$$21)) { + break; + } + ZEPHIR_CALL_METHOD(&withItem, &withs, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_24$$28); + ZVAL_LONG(&_24$$28, number); + ZEPHIR_INIT_NVAR(&_25$$28); + ZEPHIR_CONCAT_SV(&_25$$28, "AA", &_24$$28); + ZEPHIR_CPY_WRT(&joinAlias, &_25$$28); + ZEPHIR_OBS_NVAR(&relationModel); + zephir_array_fetch_string(&relationModel, &withItem, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3843); + ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_26, 0, &modelName, &relationModel); + zephir_check_call_status(); + if (Z_TYPE_P(&relation) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_27$$29); + ZVAL_STRING(&_27$$29, "alias"); + ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_27$$29); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); + zephir_check_call_status(); + } else { + ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationsbetween", &_28, 0, &modelName, &relationModel); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&relation) != IS_OBJECT)) { + ZEPHIR_INIT_NVAR(&_29$$31); + object_init_ex(&_29$$31, phalcon_mvc_model_exception_ce); + zephir_read_property(&_30$$31, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_31$$31); + ZEPHIR_CONCAT_SVSVSV(&_31$$31, "Can't find a relationship between '", &modelName, "' and '", &relationModel, "' when preparing: ", &_30$$31); + ZEPHIR_CALL_METHOD(NULL, &_29$$31, "__construct", &_8, 33, &_31$$31); + zephir_check_call_status(); + zephir_throw_exception_debug(&_29$$31, "phalcon/Mvc/Model/Query.zep", 3863); + ZEPHIR_MM_RESTORE(); + return; } + ZEPHIR_INIT_NVAR(&_32$$30); + ZVAL_STRING(&_32$$30, "alias"); + ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_32$$30); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); + zephir_check_call_status(); } - cursor++; - continue; - } + ZEPHIR_INIT_NVAR(&_33$$28); + zephir_create_array(&_33$$28, 5, 0); + add_assoc_long_ex(&_33$$28, SL("type"), 353); + zephir_array_update_string(&_33$$28, SL("column"), &joinAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_33$$28, SL("eager"), &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_33$$28, SL("eagerType"), &eagerType, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_33$$28, SL("balias"), &bestAlias, PH_COPY | PH_SEPARATE); + zephir_array_append(&selectColumns, &_33$$28, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3877); + ZEPHIR_INIT_NVAR(&_34$$28); + zephir_create_array(&_34$$28, 3, 0); + add_assoc_long_ex(&_34$$28, SL("type"), 360); + ZEPHIR_INIT_NVAR(&_35$$28); + zephir_create_array(&_35$$28, 2, 0); + add_assoc_long_ex(&_35$$28, SL("type"), 355); + zephir_array_update_string(&_35$$28, SL("name"), &relationModel, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_34$$28, SL("qualified"), &_35$$28, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_35$$28); + zephir_create_array(&_35$$28, 2, 0); + add_assoc_long_ex(&_35$$28, SL("type"), 355); + zephir_array_update_string(&_35$$28, SL("name"), &joinAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_34$$28, SL("alias"), &_35$$28, PH_COPY | PH_SEPARATE); + zephir_array_append(&automaticJoins, &_34$$28, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3889); + number++; + ZEPHIR_CALL_METHOD(NULL, &withs, "next", NULL, 0); + zephir_check_call_status(); } } + ZEPHIR_INIT_NVAR(&withItem); } - } - - if (bracket_count == 0 && !looking_placeholder) { - if (ch == '(') { - if (parentheses_count == 0) { - marker = cursor; - intermediate = 0; + zephir_array_append(&sqlModels, &modelName, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3895); + zephir_array_append(&sqlTables, &completeSource, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3896); + zephir_array_update_zval(&modelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &selectedModels, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &selectedModels, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&selectedModel, &selectedModels, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&qualifiedName); + zephir_array_fetch_string(&qualifiedName, &selectedModel, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3779); + ZEPHIR_OBS_NVAR(&modelName); + zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3780); + ZEPHIR_CALL_METHOD(&model, &manager, "load", &_36, 0, &modelName); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&schema)) { + ZEPHIR_INIT_NVAR(&_37$$33); + zephir_create_array(&_37$$33, 2, 0); + zephir_array_fast_append(&_37$$33, &source); + zephir_array_fast_append(&_37$$33, &schema); + ZEPHIR_CPY_WRT(&completeSource, &_37$$33); + } else { + ZEPHIR_CPY_WRT(&completeSource, &source); } - parentheses_count++; - } else { - if (ch == ')') { - parentheses_count--; - if (intermediate > 0) { - if (parentheses_count == 0) { - replace = phalcon_replace_marker(0, paths, replacements, &position, cursor, marker); - if (replace) { - use_copy = 0; - if (Z_TYPE_P(replace) != IS_STRING) { - use_copy = zend_make_printable_zval(replace, &replace_copy); - if (use_copy) { - replace = &replace_copy; - } - } - smart_str_appendl(&route_str, Z_STRVAL_P(replace), Z_STRLEN_P(replace)); - if (use_copy) { - zval_dtor(&replace_copy); - } - } - cursor++; - continue; - } + ZEPHIR_OBS_NVAR(&alias); + if (zephir_array_isset_string_fetch(&alias, &selectedModel, SL("alias"), 0)) { + if (UNEXPECTED(zephir_array_isset(&sqlAliases, &alias))) { + ZEPHIR_INIT_NVAR(&_38$$36); + object_init_ex(&_38$$36, phalcon_mvc_model_exception_ce); + zephir_read_property(&_39$$36, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_40$$36); + ZEPHIR_CONCAT_SVSV(&_40$$36, "Alias '", &alias, "' is used more than once, when preparing: ", &_39$$36); + ZEPHIR_CALL_METHOD(NULL, &_38$$36, "__construct", &_8, 33, &_40$$36); + zephir_check_call_status(); + zephir_throw_exception_debug(&_38$$36, "phalcon/Mvc/Model/Query.zep", 3805); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModels, &alias, &modelName, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlModelsAliases, &modelName, &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); + if (Z_TYPE_P(&completeSource) == IS_ARRAY) { + zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3817); + } else { + ZEPHIR_INIT_NVAR(&_41$$38); + zephir_create_array(&_41$$38, 3, 0); + zephir_array_fast_append(&_41$$38, &source); + zephir_array_fast_append(&_41$$38, &__$null); + zephir_array_fast_append(&_41$$38, &alias); + ZEPHIR_CPY_WRT(&completeSource, &_41$$38); } + zephir_array_update_zval(&models, &modelName, &alias, PH_COPY | PH_SEPARATE); + } else { + ZEPHIR_CPY_WRT(&alias, &source); + zephir_array_update_zval(&sqlAliases, &modelName, &source, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModels, &modelName, &modelName, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlModelsAliases, &modelName, &modelName, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&models, &modelName, &source, PH_COPY | PH_SEPARATE); } - } - } - - if (bracket_count == 0 && parentheses_count == 0) { - if (looking_placeholder) { - if (intermediate > 0) { - if (ch < 'a' || ch > 'z' || i == (Z_STRLEN_P(pattern) - 1)) { - replace = phalcon_replace_marker(0, paths, replacements, &position, cursor, marker); - if (replace) { - use_copy = 0; - if (Z_TYPE_P(replace) != IS_STRING) { - use_copy = zend_make_printable_zval(replace, &replace_copy); - if (use_copy) { - replace = &replace_copy; + ZEPHIR_OBS_NVAR(&with); + if (zephir_array_isset_string_fetch(&with, &selectedModel, SL("with"), 0)) { + if (!(zephir_array_isset_long(&with, 0))) { + ZEPHIR_INIT_NVAR(&_42$$41); + zephir_create_array(&_42$$41, 1, 0); + zephir_array_fast_append(&_42$$41, &with); + ZEPHIR_CPY_WRT(&withs, &_42$$41); + } else { + ZEPHIR_CPY_WRT(&withs, &with); + } + zephir_is_iterable(&withs, 0, "phalcon/Mvc/Model/Query.zep", 3893); + if (Z_TYPE_P(&withs) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&withs), _43$$40) + { + ZEPHIR_INIT_NVAR(&withItem); + ZVAL_COPY(&withItem, _43$$40); + ZEPHIR_INIT_NVAR(&_45$$43); + ZVAL_LONG(&_45$$43, number); + ZEPHIR_INIT_NVAR(&_46$$43); + ZEPHIR_CONCAT_SV(&_46$$43, "AA", &_45$$43); + ZEPHIR_CPY_WRT(&joinAlias, &_46$$43); + ZEPHIR_OBS_NVAR(&relationModel); + zephir_array_fetch_string(&relationModel, &withItem, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3843); + ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_47, 0, &modelName, &relationModel); + zephir_check_call_status(); + if (Z_TYPE_P(&relation) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_48$$44); + ZVAL_STRING(&_48$$44, "alias"); + ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_48$$44); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); + zephir_check_call_status(); + } else { + ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationsbetween", &_49, 0, &modelName, &relationModel); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&relation) != IS_OBJECT)) { + ZEPHIR_INIT_NVAR(&_50$$46); + object_init_ex(&_50$$46, phalcon_mvc_model_exception_ce); + zephir_read_property(&_51$$46, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_52$$46); + ZEPHIR_CONCAT_SVSVSV(&_52$$46, "Can't find a relationship between '", &modelName, "' and '", &relationModel, "' when preparing: ", &_51$$46); + ZEPHIR_CALL_METHOD(NULL, &_50$$46, "__construct", &_8, 33, &_52$$46); + zephir_check_call_status(); + zephir_throw_exception_debug(&_50$$46, "phalcon/Mvc/Model/Query.zep", 3863); + ZEPHIR_MM_RESTORE(); + return; } + ZEPHIR_INIT_NVAR(&_53$$45); + ZVAL_STRING(&_53$$45, "alias"); + ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_53$$45); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); + zephir_check_call_status(); } - smart_str_appendl(&route_str, Z_STRVAL_P(replace), Z_STRLEN_P(replace)); - if (use_copy) { - zval_dtor(&replace_copy); + ZEPHIR_INIT_NVAR(&_54$$43); + zephir_create_array(&_54$$43, 5, 0); + add_assoc_long_ex(&_54$$43, SL("type"), 353); + zephir_array_update_string(&_54$$43, SL("column"), &joinAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_54$$43, SL("eager"), &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_54$$43, SL("eagerType"), &eagerType, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_54$$43, SL("balias"), &bestAlias, PH_COPY | PH_SEPARATE); + zephir_array_append(&selectColumns, &_54$$43, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3877); + ZEPHIR_INIT_NVAR(&_55$$43); + zephir_create_array(&_55$$43, 3, 0); + add_assoc_long_ex(&_55$$43, SL("type"), 360); + ZEPHIR_INIT_NVAR(&_56$$43); + zephir_create_array(&_56$$43, 2, 0); + add_assoc_long_ex(&_56$$43, SL("type"), 355); + zephir_array_update_string(&_56$$43, SL("name"), &relationModel, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_55$$43, SL("qualified"), &_56$$43, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_56$$43); + zephir_create_array(&_56$$43, 2, 0); + add_assoc_long_ex(&_56$$43, SL("type"), 355); + zephir_array_update_string(&_56$$43, SL("name"), &joinAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_55$$43, SL("alias"), &_56$$43, PH_COPY | PH_SEPARATE); + zephir_array_append(&automaticJoins, &_55$$43, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3889); + number++; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &withs, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_44$$40, &withs, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_44$$40)) { + break; } + ZEPHIR_CALL_METHOD(&withItem, &withs, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_57$$47); + ZVAL_LONG(&_57$$47, number); + ZEPHIR_INIT_NVAR(&_58$$47); + ZEPHIR_CONCAT_SV(&_58$$47, "AA", &_57$$47); + ZEPHIR_CPY_WRT(&joinAlias, &_58$$47); + ZEPHIR_OBS_NVAR(&relationModel); + zephir_array_fetch_string(&relationModel, &withItem, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3843); + ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_59, 0, &modelName, &relationModel); + zephir_check_call_status(); + if (Z_TYPE_P(&relation) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_60$$48); + ZVAL_STRING(&_60$$48, "alias"); + ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_60$$48); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); + zephir_check_call_status(); + } else { + ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationsbetween", &_61, 0, &modelName, &relationModel); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&relation) != IS_OBJECT)) { + ZEPHIR_INIT_NVAR(&_62$$50); + object_init_ex(&_62$$50, phalcon_mvc_model_exception_ce); + zephir_read_property(&_63$$50, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_64$$50); + ZEPHIR_CONCAT_SVSVSV(&_64$$50, "Can't find a relationship between '", &modelName, "' and '", &relationModel, "' when preparing: ", &_63$$50); + ZEPHIR_CALL_METHOD(NULL, &_62$$50, "__construct", &_8, 33, &_64$$50); + zephir_check_call_status(); + zephir_throw_exception_debug(&_62$$50, "phalcon/Mvc/Model/Query.zep", 3863); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_NVAR(&_65$$49); + ZVAL_STRING(&_65$$49, "alias"); + ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_65$$49); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); + zephir_check_call_status(); + } + ZEPHIR_INIT_NVAR(&_66$$47); + zephir_create_array(&_66$$47, 5, 0); + add_assoc_long_ex(&_66$$47, SL("type"), 353); + zephir_array_update_string(&_66$$47, SL("column"), &joinAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_66$$47, SL("eager"), &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_66$$47, SL("eagerType"), &eagerType, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_66$$47, SL("balias"), &bestAlias, PH_COPY | PH_SEPARATE); + zephir_array_append(&selectColumns, &_66$$47, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3877); + ZEPHIR_INIT_NVAR(&_67$$47); + zephir_create_array(&_67$$47, 3, 0); + add_assoc_long_ex(&_67$$47, SL("type"), 360); + ZEPHIR_INIT_NVAR(&_68$$47); + zephir_create_array(&_68$$47, 2, 0); + add_assoc_long_ex(&_68$$47, SL("type"), 355); + zephir_array_update_string(&_68$$47, SL("name"), &relationModel, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_67$$47, SL("qualified"), &_68$$47, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_68$$47); + zephir_create_array(&_68$$47, 2, 0); + add_assoc_long_ex(&_68$$47, SL("type"), 355); + zephir_array_update_string(&_68$$47, SL("name"), &joinAlias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_67$$47, SL("alias"), &_68$$47, PH_COPY | PH_SEPARATE); + zephir_array_append(&automaticJoins, &_67$$47, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3889); + number++; + ZEPHIR_CALL_METHOD(NULL, &withs, "next", NULL, 0); + zephir_check_call_status(); } - looking_placeholder = 0; - continue; } + ZEPHIR_INIT_NVAR(&withItem); } + zephir_array_append(&sqlModels, &modelName, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3895); + zephir_array_append(&sqlTables, &completeSource, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3896); + zephir_array_update_zval(&modelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &selectedModels, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&selectedModel); + if (!(merge)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &models); + zephir_update_property_zval(this_ptr, ZEND_STRL("modelsInstances"), &modelsInstances); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliases"), &sqlAliases); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModels"), &sqlAliasesModels); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlModelsAliases"), &sqlModelsAliases); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &sqlAliasesModelsInstances); + } else { + zephir_memory_observe(&tempModels); + zephir_read_property(&tempModels, this_ptr, ZEND_STRL("models"), PH_NOISY_CC); + zephir_memory_observe(&tempModelsInstances); + zephir_read_property(&tempModelsInstances, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC); + zephir_memory_observe(&tempSqlAliases); + zephir_read_property(&tempSqlAliases, this_ptr, ZEND_STRL("sqlAliases"), PH_NOISY_CC); + zephir_memory_observe(&tempSqlAliasesModels); + zephir_read_property(&tempSqlAliasesModels, this_ptr, ZEND_STRL("sqlAliasesModels"), PH_NOISY_CC); + zephir_memory_observe(&tempSqlModelsAliases); + zephir_read_property(&tempSqlModelsAliases, this_ptr, ZEND_STRL("sqlModelsAliases"), PH_NOISY_CC); + zephir_memory_observe(&tempSqlAliasesModelsInstances); + zephir_read_property(&tempSqlAliasesModelsInstances, this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(&_69$$52); + zephir_read_property(&_70$$52, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); + zephir_fast_array_merge(&_69$$52, &_70$$52, &models); + zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &_69$$52); + ZEPHIR_INIT_VAR(&_71$$52); + zephir_read_property(&_72$$52, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); + zephir_fast_array_merge(&_71$$52, &_72$$52, &modelsInstances); + zephir_update_property_zval(this_ptr, ZEND_STRL("modelsInstances"), &_71$$52); + ZEPHIR_INIT_VAR(&_73$$52); + zephir_read_property(&_74$$52, this_ptr, ZEND_STRL("sqlAliases"), PH_NOISY_CC | PH_READONLY); + zephir_fast_array_merge(&_73$$52, &_74$$52, &sqlAliases); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliases"), &_73$$52); + ZEPHIR_INIT_VAR(&_75$$52); + zephir_read_property(&_76$$52, this_ptr, ZEND_STRL("sqlAliasesModels"), PH_NOISY_CC | PH_READONLY); + zephir_fast_array_merge(&_75$$52, &_76$$52, &sqlAliasesModels); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModels"), &_75$$52); + ZEPHIR_INIT_VAR(&_77$$52); + zephir_read_property(&_78$$52, this_ptr, ZEND_STRL("sqlModelsAliases"), PH_NOISY_CC | PH_READONLY); + zephir_fast_array_merge(&_77$$52, &_78$$52, &sqlModelsAliases); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlModelsAliases"), &_77$$52); + ZEPHIR_INIT_VAR(&_79$$52); + zephir_read_property(&_80$$52, this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), PH_NOISY_CC | PH_READONLY); + zephir_fast_array_merge(&_79$$52, &_80$$52, &sqlAliasesModelsInstances); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &_79$$52); + } + zephir_memory_observe(&joins); + zephir_array_isset_string_fetch(&joins, &select, SL("joins"), 0); + if (zephir_fast_count_int(&joins)) { + if (zephir_fast_count_int(&automaticJoins)) { + if (zephir_array_isset_long(&joins, 0)) { + ZEPHIR_INIT_VAR(&_81$$55); + zephir_fast_array_merge(&_81$$55, &joins, &automaticJoins); + zephir_array_update_string(&select, SL("joins"), &_81$$55, PH_COPY | PH_SEPARATE); } else { - if (ch == ':') { - looking_placeholder = 1; - marker = cursor; - intermediate = 0; - } + zephir_array_append(&automaticJoins, &joins, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3932); + zephir_array_update_string(&select, SL("joins"), &automaticJoins, PH_COPY | PH_SEPARATE); } } - - if (bracket_count > 0 || parentheses_count > 0 || looking_placeholder) { - intermediate++; + ZEPHIR_CALL_METHOD(&sqlJoins, this_ptr, "getjoins", NULL, 473, &select); + zephir_check_call_status(); + } else { + if (zephir_fast_count_int(&automaticJoins)) { + zephir_array_update_string(&select, SL("joins"), &automaticJoins, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&sqlJoins, this_ptr, "getjoins", NULL, 473, &select); + zephir_check_call_status(); } else { - smart_str_appendc(&route_str, ch); + ZEPHIR_INIT_NVAR(&sqlJoins); + array_init(&sqlJoins); } - - cursor++; - } - smart_str_0(&route_str); - - if (route_str.s) { - RETURN_STR(route_str.s); - } else { - smart_str_free(&route_str); - RETURN_EMPTY_STRING(); } -} - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Controller_BindModelInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Controller, BindModelInterface, phalcon, mvc_controller_bindmodelinterface, phalcon_mvc_controller_bindmodelinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Controller_BindModelInterface, getModelName); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Behavior) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Behavior, phalcon, mvc_model_behavior, phalcon_mvc_model_behavior_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_mvc_model_behavior_ce, SL("options"), ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_mvc_model_behavior_ce, 1, phalcon_mvc_model_behaviorinterface_ce); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Behavior, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *options_param = NULL; - zval options; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &options_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); + position = 0; + ZEPHIR_INIT_VAR(&sqlColumnAliases); + array_init(&sqlColumnAliases); + zephir_is_iterable(&selectColumns, 0, "phalcon/Mvc/Model/Query.zep", 3983); + if (Z_TYPE_P(&selectColumns) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&selectColumns), _82) + { + ZEPHIR_INIT_NVAR(&column); + ZVAL_COPY(&column, _82); + ZEPHIR_CALL_METHOD(&_84$$60, this_ptr, "getselectcolumn", &_85, 474, &column); + zephir_check_call_status(); + zephir_is_iterable(&_84$$60, 0, "phalcon/Mvc/Model/Query.zep", 3981); + if (Z_TYPE_P(&_84$$60) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_84$$60), _86$$60) + { + ZEPHIR_INIT_NVAR(&sqlColumn); + ZVAL_COPY(&sqlColumn, _86$$60); + ZEPHIR_OBS_NVAR(&alias); + if (zephir_array_isset_string_fetch(&alias, &column, SL("alias"), 0)) { + zephir_array_update_string(&sqlColumn, SL("balias"), &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&sqlColumn, SL("sqlAlias"), &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlColumnAliases, &alias, &__$true, PH_COPY | PH_SEPARATE); + } else { + ZEPHIR_OBS_NVAR(&alias); + if (zephir_array_isset_string_fetch(&alias, &sqlColumn, SL("balias"), 0)) { + zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); + } else { + zephir_array_fetch_string(&_88$$65, &sqlColumn, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3971); + if (ZEPHIR_IS_STRING(&_88$$65, "scalar")) { + ZEPHIR_INIT_NVAR(&_89$$66); + ZVAL_LONG(&_89$$66, position); + ZEPHIR_INIT_NVAR(&_90$$66); + ZEPHIR_CONCAT_SV(&_90$$66, "_", &_89$$66); + zephir_array_update_zval(&sqlColumns, &_90$$66, &sqlColumn, PH_COPY | PH_SEPARATE); + } else { + zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3974); + } + } + } + position++; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_84$$60, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_87$$60, &_84$$60, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_87$$60)) { + break; + } + ZEPHIR_CALL_METHOD(&sqlColumn, &_84$$60, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&alias); + if (zephir_array_isset_string_fetch(&alias, &column, SL("alias"), 0)) { + zephir_array_update_string(&sqlColumn, SL("balias"), &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&sqlColumn, SL("sqlAlias"), &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlColumnAliases, &alias, &__$true, PH_COPY | PH_SEPARATE); + } else { + ZEPHIR_OBS_NVAR(&alias); + if (zephir_array_isset_string_fetch(&alias, &sqlColumn, SL("balias"), 0)) { + zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); + } else { + zephir_array_fetch_string(&_91$$72, &sqlColumn, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3971); + if (ZEPHIR_IS_STRING(&_91$$72, "scalar")) { + ZEPHIR_INIT_NVAR(&_92$$73); + ZVAL_LONG(&_92$$73, position); + ZEPHIR_INIT_NVAR(&_93$$73); + ZEPHIR_CONCAT_SV(&_93$$73, "_", &_92$$73); + zephir_array_update_zval(&sqlColumns, &_93$$73, &sqlColumn, PH_COPY | PH_SEPARATE); + } else { + zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3974); + } + } + } + position++; + ZEPHIR_CALL_METHOD(NULL, &_84$$60, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&sqlColumn); + } ZEND_HASH_FOREACH_END(); } else { - zephir_get_arrval(&options, options_param); + ZEPHIR_CALL_METHOD(NULL, &selectColumns, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_83, &selectColumns, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_83)) { + break; + } + ZEPHIR_CALL_METHOD(&column, &selectColumns, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_94$$75, this_ptr, "getselectcolumn", &_85, 474, &column); + zephir_check_call_status(); + zephir_is_iterable(&_94$$75, 0, "phalcon/Mvc/Model/Query.zep", 3981); + if (Z_TYPE_P(&_94$$75) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_94$$75), _95$$75) + { + ZEPHIR_INIT_NVAR(&sqlColumn); + ZVAL_COPY(&sqlColumn, _95$$75); + ZEPHIR_OBS_NVAR(&alias); + if (zephir_array_isset_string_fetch(&alias, &column, SL("alias"), 0)) { + zephir_array_update_string(&sqlColumn, SL("balias"), &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&sqlColumn, SL("sqlAlias"), &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlColumnAliases, &alias, &__$true, PH_COPY | PH_SEPARATE); + } else { + ZEPHIR_OBS_NVAR(&alias); + if (zephir_array_isset_string_fetch(&alias, &sqlColumn, SL("balias"), 0)) { + zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); + } else { + zephir_array_fetch_string(&_97$$80, &sqlColumn, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3971); + if (ZEPHIR_IS_STRING(&_97$$80, "scalar")) { + ZEPHIR_INIT_NVAR(&_98$$81); + ZVAL_LONG(&_98$$81, position); + ZEPHIR_INIT_NVAR(&_99$$81); + ZEPHIR_CONCAT_SV(&_99$$81, "_", &_98$$81); + zephir_array_update_zval(&sqlColumns, &_99$$81, &sqlColumn, PH_COPY | PH_SEPARATE); + } else { + zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3974); + } + } + } + position++; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_94$$75, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_96$$75, &_94$$75, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_96$$75)) { + break; + } + ZEPHIR_CALL_METHOD(&sqlColumn, &_94$$75, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&alias); + if (zephir_array_isset_string_fetch(&alias, &column, SL("alias"), 0)) { + zephir_array_update_string(&sqlColumn, SL("balias"), &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&sqlColumn, SL("sqlAlias"), &alias, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlColumnAliases, &alias, &__$true, PH_COPY | PH_SEPARATE); + } else { + ZEPHIR_OBS_NVAR(&alias); + if (zephir_array_isset_string_fetch(&alias, &sqlColumn, SL("balias"), 0)) { + zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); + } else { + zephir_array_fetch_string(&_100$$87, &sqlColumn, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3971); + if (ZEPHIR_IS_STRING(&_100$$87, "scalar")) { + ZEPHIR_INIT_NVAR(&_101$$88); + ZVAL_LONG(&_101$$88, position); + ZEPHIR_INIT_NVAR(&_102$$88); + ZEPHIR_CONCAT_SV(&_102$$88, "_", &_101$$88); + zephir_array_update_zval(&sqlColumns, &_102$$88, &sqlColumn, PH_COPY | PH_SEPARATE); + } else { + zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3974); + } + } + } + position++; + ZEPHIR_CALL_METHOD(NULL, &_94$$75, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&sqlColumn); + ZEPHIR_CALL_METHOD(NULL, &selectColumns, "next", NULL, 0); + zephir_check_call_status(); + } } - zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); - ZEPHIR_MM_RESTORE(); + ZEPHIR_INIT_NVAR(&column); + zephir_memory_observe(&_103); + zephir_read_property(&_103, this_ptr, ZEND_STRL("nestingLevel"), PH_NOISY_CC); + zephir_update_property_array(this_ptr, SL("sqlColumnAliases"), &_103, &sqlColumnAliases); + ZEPHIR_INIT_VAR(&sqlSelect); + zephir_create_array(&sqlSelect, 3, 0); + zephir_array_update_string(&sqlSelect, SL("models"), &sqlModels, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&sqlSelect, SL("tables"), &sqlTables, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&sqlSelect, SL("columns"), &sqlColumns, PH_COPY | PH_SEPARATE); + zephir_memory_observe(&distinct); + if (zephir_array_isset_string_fetch(&distinct, &select, SL("distinct"), 0)) { + zephir_array_update_string(&sqlSelect, SL("distinct"), &distinct, PH_COPY | PH_SEPARATE); + } + if (zephir_fast_count_int(&sqlJoins)) { + zephir_array_update_string(&sqlSelect, SL("joins"), &sqlJoins, PH_COPY | PH_SEPARATE); + } + zephir_memory_observe(&where); + if (zephir_array_isset_string_fetch(&where, ast, SL("where"), 0)) { + ZEPHIR_CALL_METHOD(&_104$$92, this_ptr, "getexpression", NULL, 458, &where); + zephir_check_call_status(); + zephir_array_update_string(&sqlSelect, SL("where"), &_104$$92, PH_COPY | PH_SEPARATE); + } + zephir_memory_observe(&groupBy); + if (zephir_array_isset_string_fetch(&groupBy, ast, SL("groupBy"), 0)) { + ZEPHIR_CALL_METHOD(&_105$$93, this_ptr, "getgroupclause", NULL, 475, &groupBy); + zephir_check_call_status(); + zephir_array_update_string(&sqlSelect, SL("group"), &_105$$93, PH_COPY | PH_SEPARATE); + } + zephir_memory_observe(&having); + if (zephir_array_isset_string_fetch(&having, ast, SL("having"), 0)) { + ZEPHIR_CALL_METHOD(&_106$$94, this_ptr, "getexpression", NULL, 458, &having); + zephir_check_call_status(); + zephir_array_update_string(&sqlSelect, SL("having"), &_106$$94, PH_COPY | PH_SEPARATE); + } + zephir_memory_observe(&order); + if (zephir_array_isset_string_fetch(&order, ast, SL("orderBy"), 0)) { + ZEPHIR_CALL_METHOD(&_107$$95, this_ptr, "getorderclause", NULL, 476, &order); + zephir_check_call_status(); + zephir_array_update_string(&sqlSelect, SL("order"), &_107$$95, PH_COPY | PH_SEPARATE); + } + zephir_memory_observe(&limit); + if (zephir_array_isset_string_fetch(&limit, ast, SL("limit"), 0)) { + ZEPHIR_CALL_METHOD(&_108$$96, this_ptr, "getlimitclause", NULL, 472, &limit); + zephir_check_call_status(); + zephir_array_update_string(&sqlSelect, SL("limit"), &_108$$96, PH_COPY | PH_SEPARATE); + } + if (zephir_array_isset_string(ast, SL("forUpdate"))) { + zephir_array_update_string(&sqlSelect, SL("forUpdate"), &__$true, PH_COPY | PH_SEPARATE); + } + if (merge) { + zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &tempModels); + zephir_update_property_zval(this_ptr, ZEND_STRL("modelsInstances"), &tempModelsInstances); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliases"), &tempSqlAliases); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModels"), &tempSqlAliasesModels); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlModelsAliases"), &tempSqlModelsAliases); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &tempSqlAliasesModelsInstances); + } + RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("nestingLevel"))); + RETURN_CCTOR(&sqlSelect); } -static PHP_METHOD(Phalcon_Mvc_Model_Behavior, getOptions) +static PHP_METHOD(Phalcon_Mvc_Model_Query, _prepareUpdate) { + zval _15$$20, _22$$21; + zend_bool notQuoting = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *eventName_param = NULL, options, eventOptions, _0; - zval eventName; + zval __$null, ast, update, tables, values, modelsInstances, models, sqlTables, sqlAliases, sqlAliasesModelsInstances, updateTables, completeSource, sqlModels, manager, table, qualifiedName, modelName, model, source, schema, alias, sqlFields, sqlValues, updateValues, updateValue, exprColumn, sqlUpdate, where, limit, _0, *_1, _2, *_9, _10, _4$$9, _5$$10, _7$$14, _8$$15, _11$$20, _12$$20, _13$$20, _16$$20, _17$$20, _18$$20, _19$$21, _20$$21, _21$$21, _23$$21, _24$$21, _25$$21, _26$$22, _27$$22, _28$$23; + zephir_fcall_cache_entry *_3 = NULL, *_6 = NULL, *_14 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&eventOptions); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&ast); + ZVAL_UNDEF(&update); + ZVAL_UNDEF(&tables); + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&modelsInstances); + ZVAL_UNDEF(&models); + ZVAL_UNDEF(&sqlTables); + ZVAL_UNDEF(&sqlAliases); + ZVAL_UNDEF(&sqlAliasesModelsInstances); + ZVAL_UNDEF(&updateTables); + ZVAL_UNDEF(&completeSource); + ZVAL_UNDEF(&sqlModels); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&qualifiedName); + ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&alias); + ZVAL_UNDEF(&sqlFields); + ZVAL_UNDEF(&sqlValues); + ZVAL_UNDEF(&updateValues); + ZVAL_UNDEF(&updateValue); + ZVAL_UNDEF(&exprColumn); + ZVAL_UNDEF(&sqlUpdate); + ZVAL_UNDEF(&where); + ZVAL_UNDEF(&limit); ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(eventName) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_4$$9); + ZVAL_UNDEF(&_5$$10); + ZVAL_UNDEF(&_7$$14); + ZVAL_UNDEF(&_8$$15); + ZVAL_UNDEF(&_11$$20); + ZVAL_UNDEF(&_12$$20); + ZVAL_UNDEF(&_13$$20); + ZVAL_UNDEF(&_16$$20); + ZVAL_UNDEF(&_17$$20); + ZVAL_UNDEF(&_18$$20); + ZVAL_UNDEF(&_19$$21); + ZVAL_UNDEF(&_20$$21); + ZVAL_UNDEF(&_21$$21); + ZVAL_UNDEF(&_23$$21); + ZVAL_UNDEF(&_24$$21); + ZVAL_UNDEF(&_25$$21); + ZVAL_UNDEF(&_26$$22); + ZVAL_UNDEF(&_27$$22); + ZVAL_UNDEF(&_28$$23); + ZVAL_UNDEF(&_15$$20); + ZVAL_UNDEF(&_22$$21); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &eventName_param); - if (!eventName_param) { - ZEPHIR_INIT_VAR(&eventName); - } else { - if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string")); - RETURN_MM_NULL(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("ast"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&ast, &_0); + zephir_memory_observe(&update); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&update, &ast, SL("update"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted UPDATE AST", "phalcon/Mvc/Model/Query.zep", 4060); + return; } - if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { - zephir_get_strval(&eventName, eventName_param); - } else { - ZEPHIR_INIT_VAR(&eventName); + zephir_memory_observe(&tables); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&tables, &update, SL("tables"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted UPDATE AST", "phalcon/Mvc/Model/Query.zep", 4064); + return; } + zephir_memory_observe(&values); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&values, &update, SL("values"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted UPDATE AST", "phalcon/Mvc/Model/Query.zep", 4068); + return; } - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&options, &_0); - if (!ZEPHIR_IS_NULL(&eventName)) { - zephir_memory_observe(&eventOptions); - if (!(zephir_array_isset_fetch(&eventOptions, &options, &eventName, 0))) { - RETURN_MM_NULL(); - } - RETURN_CCTOR(&eventOptions); + ZEPHIR_INIT_VAR(&models); + array_init(&models); + ZEPHIR_INIT_VAR(&modelsInstances); + array_init(&modelsInstances); + ZEPHIR_INIT_VAR(&sqlTables); + array_init(&sqlTables); + ZEPHIR_INIT_VAR(&sqlModels); + array_init(&sqlModels); + ZEPHIR_INIT_VAR(&sqlAliases); + array_init(&sqlAliases); + ZEPHIR_INIT_VAR(&sqlAliasesModelsInstances); + array_init(&sqlAliasesModelsInstances); + if (!(zephir_array_isset_long(&tables, 0))) { + ZEPHIR_INIT_VAR(&updateTables); + zephir_create_array(&updateTables, 1, 0); + zephir_array_fast_append(&updateTables, &tables); + } else { + ZEPHIR_CPY_WRT(&updateTables, &tables); } - RETURN_CCTOR(&options); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Behavior, missingMethod) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval arguments; - zval method; - zval *model, model_sub, *method_param = NULL, *arguments_param = NULL; - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&arguments); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_STR(method) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(arguments) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &model, &method_param, &arguments_param); - zephir_get_strval(&method, method_param); - if (!arguments_param) { - ZEPHIR_INIT_VAR(&arguments); - array_init(&arguments); + zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&manager, &_0); + zephir_is_iterable(&updateTables, 0, "phalcon/Mvc/Model/Query.zep", 4134); + if (Z_TYPE_P(&updateTables) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&updateTables), _1) + { + ZEPHIR_INIT_NVAR(&table); + ZVAL_COPY(&table, _1); + ZEPHIR_OBS_NVAR(&qualifiedName); + zephir_array_fetch_string(&qualifiedName, &table, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4092); + ZEPHIR_OBS_NVAR(&modelName); + zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4093); + ZEPHIR_CALL_METHOD(&model, &manager, "load", &_3, 0, &modelName); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&completeSource); + if (zephir_is_true(&schema)) { + ZEPHIR_INIT_NVAR(&_4$$9); + zephir_create_array(&_4$$9, 2, 0); + zephir_array_fast_append(&_4$$9, &source); + zephir_array_fast_append(&_4$$9, &schema); + ZEPHIR_CPY_WRT(&completeSource, &_4$$9); + } else { + ZEPHIR_INIT_NVAR(&_5$$10); + zephir_create_array(&_5$$10, 2, 0); + zephir_array_fast_append(&_5$$10, &source); + zephir_array_fast_append(&_5$$10, &__$null); + ZEPHIR_CPY_WRT(&completeSource, &_5$$10); + } + ZEPHIR_OBS_NVAR(&alias); + if (zephir_array_isset_string_fetch(&alias, &table, SL("alias"), 0)) { + zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); + zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4116); + zephir_array_append(&sqlTables, &completeSource, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4117); + zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&models, &alias, &modelName, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&sqlAliases, &modelName, &source, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlTables, &source, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4123); + zephir_array_update_zval(&models, &modelName, &source, PH_COPY | PH_SEPARATE); + } + zephir_array_append(&sqlModels, &modelName, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4127); + zephir_array_update_zval(&modelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); } else { - zephir_get_arrval(&arguments, arguments_param); + ZEPHIR_CALL_METHOD(NULL, &updateTables, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &updateTables, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&table, &updateTables, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&qualifiedName); + zephir_array_fetch_string(&qualifiedName, &table, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4092); + ZEPHIR_OBS_NVAR(&modelName); + zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4093); + ZEPHIR_CALL_METHOD(&model, &manager, "load", &_6, 0, &modelName); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&schema)) { + ZEPHIR_INIT_NVAR(&_7$$14); + zephir_create_array(&_7$$14, 2, 0); + zephir_array_fast_append(&_7$$14, &source); + zephir_array_fast_append(&_7$$14, &schema); + ZEPHIR_CPY_WRT(&completeSource, &_7$$14); + } else { + ZEPHIR_INIT_NVAR(&_8$$15); + zephir_create_array(&_8$$15, 2, 0); + zephir_array_fast_append(&_8$$15, &source); + zephir_array_fast_append(&_8$$15, &__$null); + ZEPHIR_CPY_WRT(&completeSource, &_8$$15); + } + ZEPHIR_OBS_NVAR(&alias); + if (zephir_array_isset_string_fetch(&alias, &table, SL("alias"), 0)) { + zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); + zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4116); + zephir_array_append(&sqlTables, &completeSource, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4117); + zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&models, &alias, &modelName, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&sqlAliases, &modelName, &source, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&sqlAliasesModelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlTables, &source, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4123); + zephir_array_update_zval(&models, &modelName, &source, PH_COPY | PH_SEPARATE); + } + zephir_array_append(&sqlModels, &modelName, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4127); + zephir_array_update_zval(&modelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &updateTables, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_MM_NULL(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Behavior, mustTakeAction) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *eventName_param = NULL, _0; - zval eventName; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(eventName) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &eventName_param); - if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string")); - RETURN_MM_NULL(); + ZEPHIR_INIT_NVAR(&table); + zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &models); + zephir_update_property_zval(this_ptr, ZEND_STRL("modelsInstances"), &modelsInstances); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliases"), &sqlAliases); + zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &sqlAliasesModelsInstances); + ZEPHIR_INIT_VAR(&sqlFields); + array_init(&sqlFields); + ZEPHIR_INIT_VAR(&sqlValues); + array_init(&sqlValues); + if (!(zephir_array_isset_long(&values, 0))) { + ZEPHIR_INIT_VAR(&updateValues); + zephir_create_array(&updateValues, 1, 0); + zephir_array_fast_append(&updateValues, &values); + } else { + ZEPHIR_CPY_WRT(&updateValues, &values); } - if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { - zephir_get_strval(&eventName, eventName_param); + notQuoting = 0; + zephir_is_iterable(&updateValues, 0, "phalcon/Mvc/Model/Query.zep", 4158); + if (Z_TYPE_P(&updateValues) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&updateValues), _9) + { + ZEPHIR_INIT_NVAR(&updateValue); + ZVAL_COPY(&updateValue, _9); + zephir_array_fetch_string(&_12$$20, &updateValue, SL("column"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 4150); + if (notQuoting) { + ZVAL_BOOL(&_13$$20, 1); + } else { + ZVAL_BOOL(&_13$$20, 0); + } + ZEPHIR_CALL_METHOD(&_11$$20, this_ptr, "getexpression", &_14, 458, &_12$$20, &_13$$20); + zephir_check_call_status(); + zephir_array_append(&sqlFields, &_11$$20, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4150); + ZEPHIR_OBS_NVAR(&exprColumn); + zephir_array_fetch_string(&exprColumn, &updateValue, SL("expr"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4151); + ZEPHIR_INIT_NVAR(&_15$$20); + zephir_create_array(&_15$$20, 2, 0); + ZEPHIR_OBS_NVAR(&_16$$20); + zephir_array_fetch_string(&_16$$20, &exprColumn, SL("type"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4153); + zephir_array_update_string(&_15$$20, SL("type"), &_16$$20, PH_COPY | PH_SEPARATE); + if (notQuoting) { + ZVAL_BOOL(&_18$$20, 1); + } else { + ZVAL_BOOL(&_18$$20, 0); + } + ZEPHIR_CALL_METHOD(&_17$$20, this_ptr, "getexpression", &_14, 458, &exprColumn, &_18$$20); + zephir_check_call_status(); + zephir_array_update_string(&_15$$20, SL("value"), &_17$$20, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlValues, &_15$$20, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4155); + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_INIT_VAR(&eventName); + ZEPHIR_CALL_METHOD(NULL, &updateValues, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_10, &updateValues, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_10)) { + break; + } + ZEPHIR_CALL_METHOD(&updateValue, &updateValues, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_fetch_string(&_20$$21, &updateValue, SL("column"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 4150); + if (notQuoting) { + ZVAL_BOOL(&_21$$21, 1); + } else { + ZVAL_BOOL(&_21$$21, 0); + } + ZEPHIR_CALL_METHOD(&_19$$21, this_ptr, "getexpression", &_14, 458, &_20$$21, &_21$$21); + zephir_check_call_status(); + zephir_array_append(&sqlFields, &_19$$21, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4150); + ZEPHIR_OBS_NVAR(&exprColumn); + zephir_array_fetch_string(&exprColumn, &updateValue, SL("expr"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4151); + ZEPHIR_INIT_NVAR(&_22$$21); + zephir_create_array(&_22$$21, 2, 0); + ZEPHIR_OBS_NVAR(&_23$$21); + zephir_array_fetch_string(&_23$$21, &exprColumn, SL("type"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4153); + zephir_array_update_string(&_22$$21, SL("type"), &_23$$21, PH_COPY | PH_SEPARATE); + if (notQuoting) { + ZVAL_BOOL(&_25$$21, 1); + } else { + ZVAL_BOOL(&_25$$21, 0); + } + ZEPHIR_CALL_METHOD(&_24$$21, this_ptr, "getexpression", &_14, 458, &exprColumn, &_25$$21); + zephir_check_call_status(); + zephir_array_update_string(&_22$$21, SL("value"), &_24$$21, PH_COPY | PH_SEPARATE); + zephir_array_append(&sqlValues, &_22$$21, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4155); + ZEPHIR_CALL_METHOD(NULL, &updateValues, "next", NULL, 0); + zephir_check_call_status(); + } } - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - RETURN_MM_BOOL(zephir_array_isset(&_0, &eventName)); + ZEPHIR_INIT_NVAR(&updateValue); + ZEPHIR_INIT_VAR(&sqlUpdate); + zephir_create_array(&sqlUpdate, 4, 0); + zephir_array_update_string(&sqlUpdate, SL("tables"), &sqlTables, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&sqlUpdate, SL("models"), &sqlModels, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&sqlUpdate, SL("fields"), &sqlFields, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&sqlUpdate, SL("values"), &sqlValues, PH_COPY | PH_SEPARATE); + zephir_memory_observe(&where); + if (zephir_array_isset_string_fetch(&where, &ast, SL("where"), 0)) { + ZVAL_BOOL(&_27$$22, 1); + ZEPHIR_CALL_METHOD(&_26$$22, this_ptr, "getexpression", &_14, 458, &where, &_27$$22); + zephir_check_call_status(); + zephir_array_update_string(&sqlUpdate, SL("where"), &_26$$22, PH_COPY | PH_SEPARATE); + } + zephir_memory_observe(&limit); + if (zephir_array_isset_string_fetch(&limit, &ast, SL("limit"), 0)) { + ZEPHIR_CALL_METHOD(&_28$$23, this_ptr, "getlimitclause", NULL, 472, &limit); + zephir_check_call_status(); + zephir_array_update_string(&sqlUpdate, SL("limit"), &_28$$23, PH_COPY | PH_SEPARATE); + } + RETURN_CCTOR(&sqlUpdate); } -static PHP_METHOD(Phalcon_Mvc_Model_Behavior, notify) +zend_object *zephir_init_properties_Phalcon_Mvc_Model_Query(zend_class_entry *class_type) { + zval _0, _2, _4, _6, _8, _10, _12, _14, _16, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8, _13$$9, _15$$10, _17$$11; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *type_param = NULL, *model, model_sub; - zval type; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_16); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_9$$7); + ZVAL_UNDEF(&_11$$8); + ZVAL_UNDEF(&_13$$9); + ZVAL_UNDEF(&_15$$10); + ZVAL_UNDEF(&_17$$11); + - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&model_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(type) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &type_param, &model); - zephir_get_strval(&type, type_param); - RETURN_MM_NULL(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("sqlModelsAliases"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sqlModelsAliases"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("sqlColumnAliases"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sqlColumnAliases"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &_5$$5); + } + zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("sqlAliasesModels"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_6) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$6); + array_init(&_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sqlAliasesModels"), &_7$$6); + } + zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("sqlAliases"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_8) == IS_NULL) { + ZEPHIR_INIT_VAR(&_9$$7); + array_init(&_9$$7); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sqlAliases"), &_9$$7); + } + zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_10) == IS_NULL) { + ZEPHIR_INIT_VAR(&_11$$8); + array_init(&_11$$8); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("modelsInstances"), &_11$$8); + } + zephir_read_property_ex(&_12, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_12) == IS_NULL) { + ZEPHIR_INIT_VAR(&_13$$9); + array_init(&_13$$9); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("models"), &_13$$9); + } + zephir_read_property_ex(&_14, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_14) == IS_NULL) { + ZEPHIR_INIT_VAR(&_15$$10); + array_init(&_15$$10); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("bindTypes"), &_15$$10); + } + zephir_read_property_ex(&_16, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_16) == IS_NULL) { + ZEPHIR_INIT_VAR(&_17$$11); + array_init(&_17$$11); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("bindParams"), &_17$$11); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } } @@ -52325,15 +54280,26 @@ static PHP_METHOD(Phalcon_Mvc_Model_Behavior, notify) -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_BehaviorInterface) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_QueryInterface) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, BehaviorInterface, phalcon, mvc_model_behaviorinterface, phalcon_mvc_model_behaviorinterface_method_entry); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, QueryInterface, phalcon, mvc_model_queryinterface, phalcon_mvc_model_queryinterface_method_entry); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BehaviorInterface, missingMethod); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BehaviorInterface, notify); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, cache); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, execute); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getBindParams); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getCacheOptions); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getBindTypes); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getSql); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getSingleResult); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getUniqueRow); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, parse); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, setBindParams); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, setBindTypes); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, setSharedLock); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, setUniqueRow); @@ -52344,529 +54310,322 @@ ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BehaviorInterface, notify); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Binder) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Relation) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Binder, phalcon, mvc_model_binder, phalcon_mvc_model_binder_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Relation, phalcon, mvc_model_relation, phalcon_mvc_model_relation_method_entry, 0); - zend_declare_property_null(phalcon_mvc_model_binder_ce, SL("boundModels"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_binder_ce, SL("cache"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_binder_ce, SL("internalCache"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_binder_ce, SL("originalValues"), ZEND_ACC_PROTECTED); - phalcon_mvc_model_binder_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Binder; + zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("fields"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("intermediateFields"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("intermediateModel"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("intermediateReferencedFields"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("options"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("referencedFields"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("referencedModel"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("type"), ZEND_ACC_PROTECTED); + phalcon_mvc_model_relation_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Relation; + zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("ACTION_CASCADE"), 2); - zend_class_implements(phalcon_mvc_model_binder_ce, 1, phalcon_mvc_model_binderinterface_ce); - return SUCCESS; -} + zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("ACTION_RESTRICT"), 1); -static PHP_METHOD(Phalcon_Mvc_Model_Binder, __construct) -{ - zval *cache = NULL, cache_sub, __$null; - zval *this_ptr = getThis(); + zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("BELONGS_TO"), 0); - ZVAL_UNDEF(&cache_sub); - ZVAL_NULL(&__$null); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(cache, phalcon_cache_adapter_adapterinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(0, 1, &cache); - if (!cache) { - cache = &cache_sub; - cache = &__$null; - } - zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), cache); + zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("HAS_MANY"), 2); + + zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("HAS_MANY_THROUGH"), 4); + + zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("HAS_ONE"), 1); + + zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("HAS_ONE_THROUGH"), 3); + + zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("NO_ACTION"), 0); + + zend_class_implements(phalcon_mvc_model_relation_ce, 1, phalcon_mvc_model_relationinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Binder, bindToHandler) +static PHP_METHOD(Phalcon_Mvc_Model_Relation, __construct) { - zend_string *_6$$4; - zend_ulong _5$$4; - zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval cacheKey, methodName; - zval params; - zval *handler, handler_sub, *params_param = NULL, *cacheKey_param = NULL, *methodName_param = NULL, paramKey, className, boundModel, paramsCache, paramValue, _0, _2, *_3$$4, _4$$4; + zval options; + zval referencedModel; + zval *type_param = NULL, *referencedModel_param = NULL, *fields, fields_sub, *referencedFields, referencedFields_sub, *options_param = NULL, _0; + zend_long type; zval *this_ptr = getThis(); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(¶mKey); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&boundModel); - ZVAL_UNDEF(¶msCache); - ZVAL_UNDEF(¶mValue); + ZVAL_UNDEF(&fields_sub); + ZVAL_UNDEF(&referencedFields_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&cacheKey); - ZVAL_UNDEF(&methodName); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_OBJECT(handler) - Z_PARAM_ARRAY(params) - Z_PARAM_STR(cacheKey) + ZVAL_UNDEF(&referencedModel); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(4, 5) + Z_PARAM_LONG(type) + Z_PARAM_STR(referencedModel) + Z_PARAM_ZVAL(fields) + Z_PARAM_ZVAL(referencedFields) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(methodName) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 1, &handler, ¶ms_param, &cacheKey_param, &methodName_param); - zephir_get_arrval(¶ms, params_param); - zephir_get_strval(&cacheKey, cacheKey_param); - if (!methodName_param) { - ZEPHIR_INIT_VAR(&methodName); - } else { - if (UNEXPECTED(Z_TYPE_P(methodName_param) != IS_STRING && Z_TYPE_P(methodName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'methodName' must be of the type string")); + zephir_fetch_params(1, 4, 1, &type_param, &referencedModel_param, &fields, &referencedFields, &options_param); + if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(methodName_param) == IS_STRING)) { - zephir_get_strval(&methodName, methodName_param); + if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) { + zephir_get_strval(&referencedModel, referencedModel_param); } else { - ZEPHIR_INIT_VAR(&methodName); - } - } - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("originalValues"), &_0); - _1 = !((zephir_is_instance_of(handler, SL("Closure")))); - if (_1) { - _1 = ZEPHIR_IS_NULL(&methodName); - } - if (UNEXPECTED(_1)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "You must specify methodName for handler or pass Closure as handler", "phalcon/Mvc/Model/Binder.zep", 75); - return; + ZEPHIR_INIT_VAR(&referencedModel); } - ZEPHIR_INIT_VAR(&_2); - array_init(&_2); - zephir_update_property_zval(this_ptr, ZEND_STRL("boundModels"), &_2); - ZEPHIR_CALL_METHOD(¶msCache, this_ptr, "getparamsfromcache", NULL, 0, &cacheKey); - zephir_check_call_status(); - if (Z_TYPE_P(¶msCache) == IS_ARRAY) { - zephir_is_iterable(¶msCache, 0, "phalcon/Mvc/Model/Binder.zep", 90); - if (Z_TYPE_P(¶msCache) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(¶msCache), _5$$4, _6$$4, _3$$4) - { - ZEPHIR_INIT_NVAR(¶mKey); - if (_6$$4 != NULL) { - ZVAL_STR_COPY(¶mKey, _6$$4); - } else { - ZVAL_LONG(¶mKey, _5$$4); - } - ZEPHIR_INIT_NVAR(&className); - ZVAL_COPY(&className, _3$$4); - ZEPHIR_OBS_NVAR(¶mValue); - zephir_array_fetch(¶mValue, ¶ms, ¶mKey, PH_NOISY, "phalcon/Mvc/Model/Binder.zep", 83); - ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_7, 0, ¶mValue, &className); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("originalValues"), ¶mKey, ¶mValue); - zephir_array_update_zval(¶ms, ¶mKey, &boundModel, PH_COPY | PH_SEPARATE); - zephir_update_property_array(this_ptr, SL("boundModels"), ¶mKey, &boundModel); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, ¶msCache, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_4$$4, ¶msCache, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_4$$4)) { - break; - } - ZEPHIR_CALL_METHOD(¶mKey, ¶msCache, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&className, ¶msCache, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(¶mValue); - zephir_array_fetch(¶mValue, ¶ms, ¶mKey, PH_NOISY, "phalcon/Mvc/Model/Binder.zep", 83); - ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_7, 0, ¶mValue, &className); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("originalValues"), ¶mKey, ¶mValue); - zephir_array_update_zval(¶ms, ¶mKey, &boundModel, PH_COPY | PH_SEPARATE); - zephir_update_property_array(this_ptr, SL("boundModels"), ¶mKey, &boundModel); - ZEPHIR_CALL_METHOD(NULL, ¶msCache, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&className); - ZEPHIR_INIT_NVAR(¶mKey); - RETURN_CTOR(¶ms); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getparamsfromreflection", NULL, 0, handler, ¶ms, &cacheKey, &methodName); - zephir_check_call_status(); - RETURN_MM(); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, type); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("referencedModel"), &referencedModel); + zephir_update_property_zval(this_ptr, ZEND_STRL("fields"), fields); + zephir_update_property_zval(this_ptr, ZEND_STRL("referencedFields"), referencedFields); + zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Binder, findBoundModel) +static PHP_METHOD(Phalcon_Mvc_Model_Relation, getFields) { - zend_class_entry *_0; + + RETURN_MEMBER(getThis(), "fields"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Relation, getForeignKey) +{ + zval options, foreignKey, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval className; - zval *paramValue, paramValue_sub, *className_param = NULL; + zval *this_ptr = getThis(); - ZVAL_UNDEF(¶mValue_sub); - ZVAL_UNDEF(&className); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(paramValue) - Z_PARAM_STR(className) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&foreignKey); + ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, ¶mValue, &className_param); - zephir_get_strval(&className, className_param); - _0 = zephir_fetch_class(&className); - ZEPHIR_RETURN_CALL_CE_STATIC(_0, "findfirst", NULL, 0, paramValue); - zephir_check_call_status(); - RETURN_MM(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&options, &_0); + zephir_memory_observe(&foreignKey); + if (zephir_array_isset_string_fetch(&foreignKey, &options, SL("foreignKey"), 0)) { + if (zephir_is_true(&foreignKey)) { + RETURN_CCTOR(&foreignKey); + } + } + RETURN_MM_BOOL(0); } -static PHP_METHOD(Phalcon_Mvc_Model_Binder, getBoundModels) +static PHP_METHOD(Phalcon_Mvc_Model_Relation, getIntermediateFields) { - RETURN_MEMBER(getThis(), "boundModels"); + RETURN_MEMBER(getThis(), "intermediateFields"); } -static PHP_METHOD(Phalcon_Mvc_Model_Binder, getOriginalValues) +static PHP_METHOD(Phalcon_Mvc_Model_Relation, getIntermediateModel) { - RETURN_MEMBER(getThis(), "originalValues"); + RETURN_MEMBER(getThis(), "intermediateModel"); } -static PHP_METHOD(Phalcon_Mvc_Model_Binder, getCache) +static PHP_METHOD(Phalcon_Mvc_Model_Relation, getIntermediateReferencedFields) { - RETURN_MEMBER(getThis(), "cache"); + RETURN_MEMBER(getThis(), "intermediateReferencedFields"); } -static PHP_METHOD(Phalcon_Mvc_Model_Binder, getParamsFromCache) +static PHP_METHOD(Phalcon_Mvc_Model_Relation, getOption) { - zend_bool _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *cacheKey_param = NULL, cache, internalParams, _0, _1, _3; - zval cacheKey; + zval *name_param = NULL, option, _0; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&cacheKey); - ZVAL_UNDEF(&cache); - ZVAL_UNDEF(&internalParams); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&option); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(cacheKey) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &cacheKey_param); - zephir_get_strval(&cacheKey, cacheKey_param); - zephir_memory_observe(&internalParams); - zephir_read_property(&_0, this_ptr, ZEND_STRL("internalCache"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&internalParams, &_0, &cacheKey, 0)) { - RETURN_CCTOR(&internalParams); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); } - zephir_read_property(&_1, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&cache, &_1); - _2 = Z_TYPE_P(&cache) == IS_NULL; - if (!(_2)) { - ZEPHIR_CALL_METHOD(&_3, &cache, "has", NULL, 0, &cacheKey); - zephir_check_call_status(); - _2 = !zephir_is_true(&_3); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); } - if (_2) { + zephir_memory_observe(&option); + zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&option, &_0, &name, 0))) { RETURN_MM_NULL(); } - ZEPHIR_CALL_METHOD(&internalParams, &cache, "get", NULL, 0, &cacheKey); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("internalCache"), &cacheKey, &internalParams); - RETURN_CCTOR(&internalParams); + RETURN_CCTOR(&option); } -static PHP_METHOD(Phalcon_Mvc_Model_Binder, getParamsFromReflection) +static PHP_METHOD(Phalcon_Mvc_Model_Relation, getOptions) { - zend_class_entry *_9$$10, *_17$$24; - zend_string *_4; - zend_ulong _3; + + RETURN_MEMBER(getThis(), "options"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Relation, getParams) +{ + zval options, params, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_8 = NULL, *_12 = NULL, *_13 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval cacheKey, methodName; - zval params, paramsCache; - zval *handler, handler_sub, *params_param = NULL, *cacheKey_param = NULL, *methodName_param = NULL, methodParams, reflection, paramKey, methodParam, className, realClasses, boundModel, cache, handlerClass, reflectionClass, paramsKeys, paramValue, _0, *_1, _2, _5$$7, _6$$5, _7$$5, _10$$14, _11$$14, _14$$21, _15$$19, _16$$19, _18$$28, _19$$28; zval *this_ptr = getThis(); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&methodParams); - ZVAL_UNDEF(&reflection); - ZVAL_UNDEF(¶mKey); - ZVAL_UNDEF(&methodParam); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&realClasses); - ZVAL_UNDEF(&boundModel); - ZVAL_UNDEF(&cache); - ZVAL_UNDEF(&handlerClass); - ZVAL_UNDEF(&reflectionClass); - ZVAL_UNDEF(¶msKeys); - ZVAL_UNDEF(¶mValue); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_5$$7); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_7$$5); - ZVAL_UNDEF(&_10$$14); - ZVAL_UNDEF(&_11$$14); - ZVAL_UNDEF(&_14$$21); - ZVAL_UNDEF(&_15$$19); - ZVAL_UNDEF(&_16$$19); - ZVAL_UNDEF(&_18$$28); - ZVAL_UNDEF(&_19$$28); + ZVAL_UNDEF(&options); ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(¶msCache); - ZVAL_UNDEF(&cacheKey); - ZVAL_UNDEF(&methodName); - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_OBJECT(handler) - Z_PARAM_ARRAY(params) - Z_PARAM_STR(cacheKey) - Z_PARAM_STR(methodName) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 0, &handler, ¶ms_param, &cacheKey_param, &methodName_param); - zephir_get_arrval(¶ms, params_param); - zephir_get_strval(&cacheKey, cacheKey_param); - if (UNEXPECTED(Z_TYPE_P(methodName_param) != IS_STRING && Z_TYPE_P(methodName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'methodName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(methodName_param) == IS_STRING)) { - zephir_get_strval(&methodName, methodName_param); - } else { - ZEPHIR_INIT_VAR(&methodName); - } - ZEPHIR_INIT_VAR(&realClasses); - ZVAL_NULL(&realClasses); - ZEPHIR_INIT_VAR(¶msCache); - array_init(¶msCache); - ZEPHIR_INIT_VAR(&reflection); - if (!ZEPHIR_IS_NULL(&methodName)) { - object_init_ex(&reflection, zephir_get_internal_ce(SL("reflectionmethod"))); - ZEPHIR_CALL_METHOD(NULL, &reflection, "__construct", NULL, 437, handler, &methodName); - zephir_check_call_status(); - } else { - object_init_ex(&reflection, zephir_get_internal_ce(SL("reflectionfunction"))); - ZEPHIR_CALL_METHOD(NULL, &reflection, "__construct", NULL, 151, handler); - zephir_check_call_status(); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&cache, &_0); - ZEPHIR_CALL_METHOD(&methodParams, &reflection, "getparameters", NULL, 152); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(¶msKeys); - zephir_array_keys(¶msKeys, ¶ms); - zephir_is_iterable(&methodParams, 0, "phalcon/Mvc/Model/Binder.zep", 243); - if (Z_TYPE_P(&methodParams) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&methodParams), _3, _4, _1) - { - ZEPHIR_INIT_NVAR(¶mKey); - if (_4 != NULL) { - ZVAL_STR_COPY(¶mKey, _4); - } else { - ZVAL_LONG(¶mKey, _3); - } - ZEPHIR_INIT_NVAR(&methodParam); - ZVAL_COPY(&methodParam, _1); - ZEPHIR_CALL_METHOD(&reflectionClass, &methodParam, "getclass", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&reflectionClass))) { - continue; - } - ZEPHIR_CALL_METHOD(&className, &reflectionClass, "getname", NULL, 0); - zephir_check_call_status(); - if (!(zephir_array_isset(¶ms, ¶mKey))) { - zephir_array_fetch(&_5$$7, ¶msKeys, ¶mKey, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Binder.zep", 195); - ZEPHIR_CPY_WRT(¶mKey, &_5$$7); - } - ZEPHIR_INIT_NVAR(&boundModel); - ZVAL_NULL(&boundModel); - ZEPHIR_OBS_NVAR(¶mValue); - zephir_array_fetch(¶mValue, ¶ms, ¶mKey, PH_NOISY, "phalcon/Mvc/Model/Binder.zep", 199); - ZEPHIR_INIT_NVAR(&_6$$5); - ZVAL_STRING(&_6$$5, "Phalcon\\Mvc\\Model"); - ZEPHIR_CALL_FUNCTION(&_7$$5, "is_subclass_of", &_8, 438, &className, &_6$$5); - zephir_check_call_status(); - if (ZEPHIR_IS_STRING(&className, "Phalcon\\Mvc\\Model")) { - if (Z_TYPE_P(&realClasses) == IS_NULL) { - if (zephir_instance_of_ev(handler, phalcon_mvc_controller_bindmodelinterface_ce)) { - ZEPHIR_INIT_NVAR(&handlerClass); - zephir_get_class(&handlerClass, handler, 0); - _9$$10 = zephir_fetch_class(&handlerClass); - ZEPHIR_CALL_CE_STATIC(&realClasses, _9$$10, "getmodelname", NULL, 0); - zephir_check_call_status(); - } else if (zephir_instance_of_ev(handler, phalcon_mvc_model_binder_bindableinterface_ce)) { - ZEPHIR_CALL_METHOD(&realClasses, handler, "getmodelname", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Handler must implement Phalcon\\Mvc\\Model\\Binder\\BindableInterface in order to use Phalcon\\Mvc\\Model as parameter", "phalcon/Mvc/Model/Binder.zep", 211); - return; - } - } - if (Z_TYPE_P(&realClasses) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&className); - if (UNEXPECTED(!(zephir_array_isset_fetch(&className, &realClasses, ¶mKey, 0)))) { - ZEPHIR_INIT_NVAR(&_10$$14); - object_init_ex(&_10$$14, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_11$$14); - ZEPHIR_CONCAT_SVS(&_11$$14, "You should provide model class name for ", ¶mKey, " parameter"); - ZEPHIR_CALL_METHOD(NULL, &_10$$14, "__construct", &_12, 33, &_11$$14); - zephir_check_call_status(); - zephir_throw_exception_debug(&_10$$14, "phalcon/Mvc/Model/Binder.zep", 219); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_13, 0, ¶mValue, &className); - zephir_check_call_status(); - } else if (Z_TYPE_P(&realClasses) == IS_STRING) { - ZEPHIR_CPY_WRT(&className, &realClasses); - ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_13, 0, ¶mValue, &className); - zephir_check_call_status(); - } else { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "getModelName should return array or string", "phalcon/Mvc/Model/Binder.zep", 229); - return; - } - } else if (zephir_is_true(&_7$$5)) { - ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_13, 0, ¶mValue, &className); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&options, &_0); + zephir_memory_observe(¶ms); + if (zephir_array_isset_string_fetch(¶ms, &options, SL("params"), 0)) { + if (zephir_is_true(¶ms)) { + if (zephir_is_callable(¶ms)) { + ZEPHIR_CALL_USER_FUNC(return_value, ¶ms); zephir_check_call_status(); + RETURN_MM(); } - if (Z_TYPE_P(&boundModel) != IS_NULL) { - zephir_update_property_array(this_ptr, SL("originalValues"), ¶mKey, ¶mValue); - zephir_array_update_zval(¶ms, ¶mKey, &boundModel, PH_COPY | PH_SEPARATE); - zephir_update_property_array(this_ptr, SL("boundModels"), ¶mKey, &boundModel); - zephir_array_update_zval(¶msCache, ¶mKey, &className, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &methodParams, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &methodParams, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(¶mKey, &methodParams, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&methodParam, &methodParams, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&reflectionClass, &methodParam, "getclass", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&reflectionClass))) { - continue; - } - ZEPHIR_CALL_METHOD(&className, &reflectionClass, "getname", NULL, 0); - zephir_check_call_status(); - if (!(zephir_array_isset(¶ms, ¶mKey))) { - zephir_array_fetch(&_14$$21, ¶msKeys, ¶mKey, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Binder.zep", 195); - ZEPHIR_CPY_WRT(¶mKey, &_14$$21); - } - ZEPHIR_INIT_NVAR(&boundModel); - ZVAL_NULL(&boundModel); - ZEPHIR_OBS_NVAR(¶mValue); - zephir_array_fetch(¶mValue, ¶ms, ¶mKey, PH_NOISY, "phalcon/Mvc/Model/Binder.zep", 199); - ZEPHIR_INIT_NVAR(&_15$$19); - ZVAL_STRING(&_15$$19, "Phalcon\\Mvc\\Model"); - ZEPHIR_CALL_FUNCTION(&_16$$19, "is_subclass_of", &_8, 438, &className, &_15$$19); - zephir_check_call_status(); - if (ZEPHIR_IS_STRING(&className, "Phalcon\\Mvc\\Model")) { - if (Z_TYPE_P(&realClasses) == IS_NULL) { - if (zephir_instance_of_ev(handler, phalcon_mvc_controller_bindmodelinterface_ce)) { - ZEPHIR_INIT_NVAR(&handlerClass); - zephir_get_class(&handlerClass, handler, 0); - _17$$24 = zephir_fetch_class(&handlerClass); - ZEPHIR_CALL_CE_STATIC(&realClasses, _17$$24, "getmodelname", NULL, 0); - zephir_check_call_status(); - } else if (zephir_instance_of_ev(handler, phalcon_mvc_model_binder_bindableinterface_ce)) { - ZEPHIR_CALL_METHOD(&realClasses, handler, "getmodelname", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Handler must implement Phalcon\\Mvc\\Model\\Binder\\BindableInterface in order to use Phalcon\\Mvc\\Model as parameter", "phalcon/Mvc/Model/Binder.zep", 211); - return; - } - } - if (Z_TYPE_P(&realClasses) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&className); - if (UNEXPECTED(!(zephir_array_isset_fetch(&className, &realClasses, ¶mKey, 0)))) { - ZEPHIR_INIT_NVAR(&_18$$28); - object_init_ex(&_18$$28, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_19$$28); - ZEPHIR_CONCAT_SVS(&_19$$28, "You should provide model class name for ", ¶mKey, " parameter"); - ZEPHIR_CALL_METHOD(NULL, &_18$$28, "__construct", &_12, 33, &_19$$28); - zephir_check_call_status(); - zephir_throw_exception_debug(&_18$$28, "phalcon/Mvc/Model/Binder.zep", 219); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_13, 0, ¶mValue, &className); - zephir_check_call_status(); - } else if (Z_TYPE_P(&realClasses) == IS_STRING) { - ZEPHIR_CPY_WRT(&className, &realClasses); - ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_13, 0, ¶mValue, &className); - zephir_check_call_status(); - } else { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "getModelName should return array or string", "phalcon/Mvc/Model/Binder.zep", 229); - return; - } - } else if (zephir_is_true(&_16$$19)) { - ZEPHIR_CALL_METHOD(&boundModel, this_ptr, "findboundmodel", &_13, 0, ¶mValue, &className); - zephir_check_call_status(); - } - if (Z_TYPE_P(&boundModel) != IS_NULL) { - zephir_update_property_array(this_ptr, SL("originalValues"), ¶mKey, ¶mValue); - zephir_array_update_zval(¶ms, ¶mKey, &boundModel, PH_COPY | PH_SEPARATE); - zephir_update_property_array(this_ptr, SL("boundModels"), ¶mKey, &boundModel); - zephir_array_update_zval(¶msCache, ¶mKey, &className, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &methodParams, "next", NULL, 0); - zephir_check_call_status(); + RETURN_CCTOR(¶ms); } } - ZEPHIR_INIT_NVAR(&methodParam); - ZEPHIR_INIT_NVAR(¶mKey); - if (Z_TYPE_P(&cache) != IS_NULL) { - ZEPHIR_CALL_METHOD(NULL, &cache, "set", NULL, 0, &cacheKey, ¶msCache); - zephir_check_call_status(); + RETURN_MM_BOOL(0); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Relation, getType) +{ + + RETURN_MEMBER(getThis(), "type"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Relation, getReferencedFields) +{ + + RETURN_MEMBER(getThis(), "referencedFields"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Relation, getReferencedModel) +{ + + RETURN_MEMBER(getThis(), "referencedModel"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Relation, isForeignKey) +{ + zval foreignKey, _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&foreignKey); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_memory_observe(&foreignKey); + zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_string_fetch(&foreignKey, &_0, SL("foreignKey"), 0))) { + RETURN_MM_BOOL(0); } - zephir_update_property_array(this_ptr, SL("internalCache"), &cacheKey, ¶msCache); - RETURN_CTOR(¶ms); + RETURN_MM_BOOL(zephir_get_boolval(&foreignKey)); } -static PHP_METHOD(Phalcon_Mvc_Model_Binder, setCache) +static PHP_METHOD(Phalcon_Mvc_Model_Relation, isThrough) { - zval *cache, cache_sub; + zend_bool _1; + zval type, _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zval *this_ptr = getThis(); - ZVAL_UNDEF(&cache_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(cache, phalcon_cache_adapter_adapterinterface_ce) + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("type"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&type, &_0); + _1 = ZEPHIR_IS_LONG(&type, 3); + if (!(_1)) { + _1 = ZEPHIR_IS_LONG(&type, 4); + } + RETURN_MM_BOOL(_1); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Relation, isReusable) +{ + zval options, reusable, _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&reusable); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&options, &_0); + zephir_memory_observe(&reusable); + if (!(zephir_array_isset_string_fetch(&reusable, &options, SL("reusable"), 0))) { + RETURN_MM_BOOL(0); + } + RETURN_CCTOR(&reusable); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Relation, setIntermediateRelation) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval intermediateModel; + zval *intermediateFields, intermediateFields_sub, *intermediateModel_param = NULL, *intermediateReferencedFields, intermediateReferencedFields_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&intermediateFields_sub); + ZVAL_UNDEF(&intermediateReferencedFields_sub); + ZVAL_UNDEF(&intermediateModel); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ZVAL(intermediateFields) + Z_PARAM_STR(intermediateModel) + Z_PARAM_ZVAL(intermediateReferencedFields) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &cache); - zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), cache); - RETURN_THISW(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 0, &intermediateFields, &intermediateModel_param, &intermediateReferencedFields); + if (UNEXPECTED(Z_TYPE_P(intermediateModel_param) != IS_STRING && Z_TYPE_P(intermediateModel_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'intermediateModel' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(intermediateModel_param) == IS_STRING)) { + zephir_get_strval(&intermediateModel, intermediateModel_param); + } else { + ZEPHIR_INIT_VAR(&intermediateModel); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("intermediateFields"), intermediateFields); + zephir_update_property_zval(this_ptr, ZEND_STRL("intermediateModel"), &intermediateModel); + zephir_update_property_zval(this_ptr, ZEND_STRL("intermediateReferencedFields"), intermediateReferencedFields); + ZEPHIR_MM_RESTORE(); } -zend_object *zephir_init_properties_Phalcon_Mvc_Model_Binder(zend_class_entry *class_type) +zend_object *zephir_init_properties_Phalcon_Mvc_Model_Relation(zend_class_entry *class_type) { - zval _0, _2, _4, _1$$3, _3$$4, _5$$5; + zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); @@ -52875,23 +54634,11 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Model_Binder(zend_class_entry *c { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("originalValues"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("originalValues"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("internalCache"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("internalCache"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("boundModels"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("boundModels"), &_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_1$$3); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -52908,17 +54655,28 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Model_Binder(zend_class_entry *c -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_BinderInterface) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_RelationInterface) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, BinderInterface, phalcon, mvc_model_binderinterface, phalcon_mvc_model_binderinterface_method_entry); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, RelationInterface, phalcon, mvc_model_relationinterface, phalcon_mvc_model_relationinterface_method_entry); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BinderInterface, bindToHandler); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BinderInterface, getBoundModels); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BinderInterface, getCache); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BinderInterface, setCache); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getFields); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getForeignKey); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getIntermediateFields); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getIntermediateModel); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getIntermediateReferencedFields); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getOption); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getOptions); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getParams); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getReferencedFields); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getReferencedModel); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getType); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, isForeignKey); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, isReusable); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, isThrough); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, setIntermediateRelation); @@ -52929,1608 +54687,1397 @@ ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_BinderInterface, setCache); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Criteria) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_ResultInterface) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Criteria, phalcon, mvc_model_criteria, phalcon_mvc_model_criteria_method_entry, 0); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, ResultInterface, phalcon, mvc_model_resultinterface, phalcon_mvc_model_resultinterface_method_entry); - zend_declare_property_null(phalcon_mvc_model_criteria_ce, SL("bindParams"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_criteria_ce, SL("bindTypes"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_model_criteria_ce, SL("hiddenParamNumber"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_criteria_ce, SL("model"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_criteria_ce, SL("params"), ZEND_ACC_PROTECTED); - phalcon_mvc_model_criteria_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Criteria; + return SUCCESS; +} - zend_class_implements(phalcon_mvc_model_criteria_ce, 1, phalcon_mvc_model_criteriainterface_ce); - zend_class_implements(phalcon_mvc_model_criteria_ce, 1, phalcon_di_injectionawareinterface_ce); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultInterface, setDirtyState); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Resultset) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Resultset, phalcon, mvc_model_resultset, phalcon_mvc_model_resultset_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("activeRow"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("cache"), ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_mvc_model_resultset_ce, SL("count"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("errorMessages"), ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_mvc_model_resultset_ce, SL("hydrateMode"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_mvc_model_resultset_ce, SL("isFresh"), 1, ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_mvc_model_resultset_ce, SL("pointer"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("row"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("rows"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("result"), ZEND_ACC_PROTECTED); + phalcon_mvc_model_resultset_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Resultset; + zephir_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("HYDRATE_ARRAYS"), 1); + + zephir_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("HYDRATE_OBJECTS"), 2); + + zephir_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("HYDRATE_RECORDS"), 0); + + zephir_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("TYPE_RESULT_FULL"), 0); + + zephir_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("TYPE_RESULT_PARTIAL"), 1); + + zend_class_implements(phalcon_mvc_model_resultset_ce, 1, phalcon_mvc_model_resultsetinterface_ce); + zend_class_implements(phalcon_mvc_model_resultset_ce, 1, zend_ce_iterator); + zend_class_implements(phalcon_mvc_model_resultset_ce, 1, spl_ce_SeekableIterator); + zend_class_implements(phalcon_mvc_model_resultset_ce, 1, zend_ce_countable); + zend_class_implements(phalcon_mvc_model_resultset_ce, 1, zend_ce_arrayaccess); + zend_class_implements(phalcon_mvc_model_resultset_ce, 1, zend_ce_serializable); + zend_class_implements(phalcon_mvc_model_resultset_ce, 1, php_json_serializable_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, andWhere) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, __construct) { + zend_bool _11, _4$$4; + zval _10, _7$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *conditions_param = NULL, *bindParams = NULL, bindParams_sub, *bindTypes = NULL, bindTypes_sub, __$null, currentConditions, _0, _1$$3; - zval conditions; + zend_long ZEPHIR_LAST_CALL_STATUS, prefetchRecords = 0; + zval *result, result_sub, *cache = NULL, cache_sub, __$null, rowCount, rows, _8, _0$$3, _1$$3, _2$$4, _3$$4, _5$$4, _6$$5, _9$$6, _12$$9; zval *this_ptr = getThis(); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&bindParams_sub); - ZVAL_UNDEF(&bindTypes_sub); + ZVAL_UNDEF(&result_sub); + ZVAL_UNDEF(&cache_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(¤tConditions); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&rowCount); + ZVAL_UNDEF(&rows); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_9$$6); + ZVAL_UNDEF(&_12$$9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_7$$5); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(conditions) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(result) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(bindParams) - Z_PARAM_ZVAL_OR_NULL(bindTypes) + Z_PARAM_ZVAL_OR_NULL(cache) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams, &bindTypes); - if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); + zephir_fetch_params(1, 1, 1, &result, &cache); + if (!cache) { + cache = &cache_sub; + cache = &__$null; + } + if (Z_TYPE_P(result) != IS_OBJECT) { + ZVAL_UNDEF(&_0$$3); + ZVAL_LONG(&_0$$3, 0); + zephir_update_property_zval(this_ptr, ZEND_STRL("count"), &_0$$3); + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_1$$3); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { - zephir_get_strval(&conditions, conditions_param); - } else { - ZEPHIR_INIT_VAR(&conditions); + zephir_update_property_zval(this_ptr, ZEND_STRL("result"), result); + if (Z_TYPE_P(cache) != IS_NULL) { + ZEPHIR_INIT_VAR(&_2$$4); + ZVAL_STRING(&_2$$4, "Phalcon\\Cache\\CacheInterface"); + ZEPHIR_CALL_FUNCTION(&_3$$4, "is_a", NULL, 87, cache, &_2$$4); + zephir_check_call_status(); + _4$$4 = !ZEPHIR_IS_TRUE_IDENTICAL(&_3$$4); + if (_4$$4) { + ZEPHIR_INIT_NVAR(&_2$$4); + ZVAL_STRING(&_2$$4, "Psr\\SimpleCache\\CacheInterface"); + ZEPHIR_CALL_FUNCTION(&_5$$4, "is_a", NULL, 87, cache, &_2$$4); + zephir_check_call_status(); + _4$$4 = !ZEPHIR_IS_TRUE_IDENTICAL(&_5$$4); + } + if (UNEXPECTED(_4$$4)) { + ZEPHIR_INIT_VAR(&_6$$5); + object_init_ex(&_6$$5, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_7$$5); + ZEPHIR_CONCAT_SS(&_7$$5, "Cache service must be an object implementing ", "Phalcon\\Cache\\CacheInterface or Psr\\SimpleCache\\CacheInterface"); + ZEPHIR_CALL_METHOD(NULL, &_6$$5, "__construct", NULL, 33, &_7$$5); + zephir_check_call_status(); + zephir_throw_exception_debug(&_6$$5, "phalcon/Mvc/Model/Resultset.zep", 168); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), cache); } - if (!bindParams) { - bindParams = &bindParams_sub; - bindParams = &__$null; + ZVAL_LONG(&_8, 2); + ZEPHIR_CALL_METHOD(NULL, result, "setfetchmode", NULL, 0, &_8); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&rowCount, result, "numrows", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("count"), &rowCount); + if (ZEPHIR_IS_LONG(&rowCount, 0)) { + ZEPHIR_INIT_VAR(&_9$$6); + array_init(&_9$$6); + zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_9$$6); + RETURN_MM_NULL(); } - if (!bindTypes) { - bindTypes = &bindTypes_sub; - bindTypes = &__$null; + ZEPHIR_INIT_VAR(&_10); + ZEPHIR_INIT_NVAR(&_10); + ZVAL_STRING(&_10, "ZEPHIR_GLOBAL(orm).resultset_prefetch_records"); + prefetchRecords = zephir_get_intval_ex(&_10); + _11 = prefetchRecords > 0; + if (_11) { + _11 = ZEPHIR_LE_LONG(&rowCount, prefetchRecords); } - zephir_memory_observe(¤tConditions); - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_string_fetch(¤tConditions, &_0, SL("conditions"), 0)) { - ZEPHIR_INIT_VAR(&_1$$3); - ZEPHIR_CONCAT_SVSVS(&_1$$3, "(", ¤tConditions, ") AND (", &conditions, ")"); - zephir_get_strval(&conditions, &_1$$3); + if (_11) { + ZEPHIR_CALL_METHOD(&rows, result, "fetchall", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&rows) == IS_ARRAY) { + zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &rows); + } else { + ZEPHIR_INIT_VAR(&_12$$9); + array_init(&_12$$9); + zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_12$$9); + } } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "where", NULL, 0, &conditions, bindParams, bindTypes); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, betweenWhere) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, count) { - zval _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, hiddenParam, minimumKey, nextHiddenParam, maximumKey, _0; - zval expr; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&minimum_sub); - ZVAL_UNDEF(&maximum_sub); - ZVAL_UNDEF(&hiddenParam); - ZVAL_UNDEF(&minimumKey); - ZVAL_UNDEF(&nextHiddenParam); - ZVAL_UNDEF(&maximumKey); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_STR(expr) - Z_PARAM_ZVAL(minimum) - Z_PARAM_ZVAL(maximum) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &expr_param, &minimum, &maximum); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - zephir_memory_observe(&hiddenParam); - zephir_read_property(&hiddenParam, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&nextHiddenParam); - ZVAL_LONG(&nextHiddenParam, (zephir_get_numberval(&hiddenParam) + 1)); - ZEPHIR_INIT_VAR(&minimumKey); - ZEPHIR_CONCAT_SV(&minimumKey, "ACP", &hiddenParam); - ZEPHIR_INIT_VAR(&maximumKey); - ZEPHIR_CONCAT_SV(&maximumKey, "ACP", &nextHiddenParam); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_CONCAT_VSVSVS(&_0, &expr, " BETWEEN :", &minimumKey, ": AND :", &maximumKey, ":"); - ZEPHIR_INIT_VAR(&_1); - zephir_create_array(&_1, 2, 0); - zephir_array_update_zval(&_1, &minimumKey, minimum, PH_COPY); - zephir_array_update_zval(&_1, &maximumKey, maximum, PH_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, &_0, &_1); - zephir_check_call_status(); - SEPARATE_ZVAL(&nextHiddenParam); - zephir_increment(&nextHiddenParam); - zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &nextHiddenParam); - RETURN_THIS(); + RETURN_MEMBER(getThis(), "count"); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, bind) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, delete) { + zval _4$$6; + zend_bool result = 0, transaction = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool merge, _5; - zval *bindParams_param = NULL, *merge_param = NULL, _0, _3, _4, _1$$3, _2$$3, _6$$4, _7$$4, _8$$4, _9$$4, _10$$5; - zval bindParams; + zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_5 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *conditionCallback = NULL, conditionCallback_sub, __$null, record, connection, _0, _3$$6, _6$$3, _7$$8; zval *this_ptr = getThis(); - ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&conditionCallback_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&record); + ZVAL_UNDEF(&connection); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_10$$5); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(bindParams) + ZVAL_UNDEF(&_3$$6); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$8); + ZVAL_UNDEF(&_4$$6); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(merge) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(conditionCallback, zend_ce_closure) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &bindParams_param, &merge_param); - ZEPHIR_OBS_COPY_OR_DUP(&bindParams, bindParams_param); - if (!merge_param) { - merge = 0; - } else { - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_string(&_0, SL("bind")))) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "bind"); - zephir_update_property_array(this_ptr, SL("params"), &_2$$3, &_1$$3); + zephir_fetch_params(1, 0, 1, &conditionCallback); + if (!conditionCallback) { + conditionCallback = &conditionCallback_sub; + conditionCallback = &__$null; } - zephir_read_property(&_3, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&_4); - zephir_array_fetch_string(&_4, &_3, SL("bind"), PH_NOISY, "phalcon/Mvc/Model/Criteria.zep", 129); - _5 = Z_TYPE_P(&_4) == IS_ARRAY; - if (_5) { - _5 = merge; + ZEPHIR_INIT_VAR(&connection); + ZVAL_NULL(&connection); + result = 1; + transaction = 0; + ZEPHIR_CALL_METHOD(NULL, this_ptr, "rewind", NULL, 92); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", &_1, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&_0))) { + break; + } + ZEPHIR_CALL_METHOD(&record, this_ptr, "current", &_2, 0); + zephir_check_call_status(); + if (transaction == 0) { + if (UNEXPECTED(!((zephir_method_exists_ex(&record, ZEND_STRL("getwriteconnection")) == SUCCESS)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The returned record is not valid", "phalcon/Mvc/Model/Resultset.zep", 242); + return; + } + ZEPHIR_CALL_METHOD(&connection, &record, "getwriteconnection", NULL, 0); + zephir_check_call_status(); + transaction = 1; + ZEPHIR_CALL_METHOD(NULL, &connection, "begin", NULL, 0); + zephir_check_call_status(); + } + if (Z_TYPE_P(conditionCallback) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_3$$6); + ZEPHIR_INIT_NVAR(&_4$$6); + zephir_create_array(&_4$$6, 1, 0); + zephir_array_fast_append(&_4$$6, &record); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_3$$6, conditionCallback, &_4$$6); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_3$$6)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); + zephir_check_call_status(); + continue; + } + } + ZEPHIR_CALL_METHOD(&_6$$3, &record, "delete", NULL, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&_6$$3))) { + ZEPHIR_CALL_METHOD(&_7$$8, &record, "getmessages", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("errorMessages"), &_7$$8); + ZEPHIR_CALL_METHOD(NULL, &connection, "rollback", NULL, 0); + zephir_check_call_status(); + result = 0; + transaction = 0; + break; + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); + zephir_check_call_status(); } - if (_5) { - zephir_read_property(&_6$$4, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_7$$4, &_6$$4, SL("bind"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Criteria.zep", 130); - ZEPHIR_INIT_VAR(&_8$$4); - zephir_add_function(&_8$$4, &_7$$4, &bindParams); - ZEPHIR_INIT_VAR(&_9$$4); - ZVAL_STRING(&_9$$4, "bind"); - zephir_update_property_array(this_ptr, SL("params"), &_9$$4, &_8$$4); - } else { - ZEPHIR_INIT_VAR(&_10$$5); - ZVAL_STRING(&_10$$5, "bind"); - zephir_update_property_array(this_ptr, SL("params"), &_10$$5, &bindParams); + if (transaction == 1) { + ZEPHIR_CALL_METHOD(NULL, &connection, "commit", NULL, 0); + zephir_check_call_status(); } - RETURN_THIS(); + RETURN_MM_BOOL(result); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, bindTypes) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, filter) { + zend_bool _4$$3; + zval records, _3$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *bindTypes_param = NULL, _0; - zval bindTypes; + zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_5 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *filter, filter_sub, record, processedRecord, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&filter_sub); + ZVAL_UNDEF(&record); + ZVAL_UNDEF(&processedRecord); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&records); + ZVAL_UNDEF(&_3$$3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(bindTypes) + Z_PARAM_ZVAL(filter) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &bindTypes_param); - ZEPHIR_OBS_COPY_OR_DUP(&bindTypes, bindTypes_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "bindTypes"); - zephir_update_property_array(this_ptr, SL("params"), &_0, &bindTypes); - RETURN_THIS(); + zephir_fetch_params(1, 1, 0, &filter); + ZEPHIR_INIT_VAR(&records); + array_init(&records); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "rewind", NULL, 92); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", &_1, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&_0))) { + break; + } + ZEPHIR_CALL_METHOD(&record, this_ptr, "current", &_2, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_3$$3); + zephir_create_array(&_3$$3, 1, 0); + zephir_array_fast_append(&_3$$3, &record); + ZEPHIR_INIT_NVAR(&processedRecord); + ZEPHIR_CALL_USER_FUNC_ARRAY(&processedRecord, filter, &_3$$3); + zephir_check_call_status(); + _4$$3 = Z_TYPE_P(&processedRecord) != IS_OBJECT; + if (_4$$3) { + _4$$3 = Z_TYPE_P(&processedRecord) != IS_ARRAY; + } + if (_4$$3) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); + zephir_check_call_status(); + continue; + } + zephir_array_append(&records, &processedRecord, PH_SEPARATE, "phalcon/Mvc/Model/Resultset.zep", 336); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); + zephir_check_call_status(); + } + RETURN_CTOR(&records); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, cache) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getCache) { + + RETURN_MEMBER(getThis(), "cache"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getFirst) +{ + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *cache_param = NULL, _0; - zval cache; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&cache); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(cache) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &cache_param); - ZEPHIR_OBS_COPY_OR_DUP(&cache, cache_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "cache"); - zephir_update_property_array(this_ptr, SL("params"), &_0, &cache); - RETURN_THIS(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("count"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_LONG(&_0, 0)) { + RETURN_MM_NULL(); + } + ZVAL_LONG(&_1, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 93, &_1); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "current", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, columns) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getHydrateMode) +{ + + RETURN_MEMBER(getThis(), "hydrateMode"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getLast) { + zval count, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *columns, columns_sub, _0; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&columns_sub); + ZVAL_UNDEF(&count); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(columns) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &columns); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "columns"); - zephir_update_property_array(this_ptr, SL("params"), &_0, columns); - RETURN_THIS(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("count"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&count, &_0); + if (ZEPHIR_IS_LONG(&count, 0)) { + RETURN_MM_NULL(); + } + ZVAL_LONG(&_0, (zephir_get_numberval(&count) - 1)); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 93, &_0); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "current", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, conditions) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getMessages) +{ + + RETURN_MEMBER(getThis(), "errorMessages"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getType) { + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *conditions_param = NULL, _0; - zval conditions; zval *this_ptr = getThis(); - ZVAL_UNDEF(&conditions); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(conditions) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &conditions_param); - if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { - zephir_get_strval(&conditions, conditions_param); + + ZEPHIR_INIT_VAR(&_0); + zephir_memory_observe(&_1); + zephir_read_property(&_1, this_ptr, ZEND_STRL("rows"), PH_NOISY_CC); + if (Z_TYPE_P(&_1) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&_0); + ZVAL_LONG(&_0, 0); } else { - ZEPHIR_INIT_VAR(&conditions); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_LONG(&_0, 1); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "conditions"); - zephir_update_property_array(this_ptr, SL("params"), &_0, &conditions); - RETURN_THIS(); + RETURN_CCTOR(&_0); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, createBuilder) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, isFresh) { - zval container, manager, builder, _0, _1, _2, _3; + + RETURN_MEMBER(getThis(), "isFresh"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, jsonSerialize) +{ + zend_bool _3$$3; + zval records; + zval current, _0, _4$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_5 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&builder); + ZVAL_UNDEF(¤t); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&records); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_CALL_METHOD(&container, this_ptr, "getdi", NULL, 0); + ZEPHIR_INIT_VAR(&records); + array_init(&records); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "rewind", NULL, 92); zephir_check_call_status(); - if (Z_TYPE_P(&container) != IS_OBJECT) { - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); + while (1) { + ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", &_1, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdi", NULL, 0, &container); + if (!(zephir_is_true(&_0))) { + break; + } + ZEPHIR_CALL_METHOD(¤t, this_ptr, "current", &_2, 0); + zephir_check_call_status(); + _3$$3 = Z_TYPE_P(¤t) == IS_OBJECT; + if (_3$$3) { + _3$$3 = (zephir_method_exists_ex(¤t, ZEND_STRL("jsonserialize")) == SUCCESS); + } + if (_3$$3) { + ZEPHIR_CALL_METHOD(&_4$$4, ¤t, "jsonserialize", NULL, 0); + zephir_check_call_status(); + zephir_array_append(&records, &_4$$4, PH_SEPARATE, "phalcon/Mvc/Model/Resultset.zep", 461); + } else { + zephir_array_append(&records, ¤t, PH_SEPARATE, "phalcon/Mvc/Model/Resultset.zep", 463); + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); zephir_check_call_status(); } - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "modelsManager"); - ZEPHIR_CALL_METHOD(&_0, &container, "getshared", NULL, 0, &_1); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&manager, &_0); - zephir_read_property(&_2, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&builder, &manager, "createbuilder", NULL, 0, &_2); - zephir_check_call_status(); - zephir_read_property(&_3, this_ptr, ZEND_STRL("model"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &builder, "from", NULL, 0, &_3); - zephir_check_call_status(); - RETURN_CCTOR(&builder); + RETURN_CTOR(&records); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, distinct) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, key) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *distinct, distinct_sub, _0; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&distinct_sub); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(distinct) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &distinct); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "distinct"); - zephir_update_property_array(this_ptr, SL("params"), &_0, distinct); - RETURN_THIS(); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", NULL, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&_0))) { + RETURN_MM_NULL(); + } + RETURN_MM_MEMBER(getThis(), "pointer"); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, execute) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, next) { - zend_class_entry *_1; - zval model, _0; + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_CALL_METHOD(&model, this_ptr, "getmodelname", NULL, 0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("pointer"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1, (zephir_get_numberval(&_0) + 1)); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 93, &_1); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&model) != IS_STRING)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Model name must be string", "phalcon/Mvc/Model/Criteria.zep", 279); - return; - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getparams", NULL, 0); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetGet) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval index_sub, _0; + zval *index; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(index) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &index); + zephir_read_property(&_0, this_ptr, ZEND_STRL("count"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(ZEPHIR_GE(index, &_0))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The index does not exist in the cursor", "phalcon/Mvc/Model/Resultset.zep", 503); + return; + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 93, index); zephir_check_call_status(); - _1 = zephir_fetch_class(&model); - ZEPHIR_RETURN_CALL_CE_STATIC(_1, "find", NULL, 0, &_0); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "current", NULL, 0); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, forUpdate) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetExists) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *forUpdate_param = NULL, _0, _1; - zend_bool forUpdate; + zval *index, index_sub, _0; zval *this_ptr = getThis(); + ZVAL_UNDEF(&index_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(forUpdate) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(index) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &index); + zephir_read_property(&_0, this_ptr, ZEND_STRL("count"), PH_NOISY_CC | PH_READONLY); + RETURN_BOOL(ZEPHIR_LT(index, &_0)); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetSet) +{ + zval *offset, offset_sub, *value, value_sub; + + ZVAL_UNDEF(&offset_sub); + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(offset) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(2, 0, &offset, &value); + ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_model_exception_ce, "Cursor is an immutable ArrayAccess object", "phalcon/Mvc/Model/Resultset.zep", 530); + return; +} + +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetUnset) +{ + zval *offset, offset_sub; + + ZVAL_UNDEF(&offset_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(offset) ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &offset); + ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_model_exception_ce, "Cursor is an immutable ArrayAccess object", "phalcon/Mvc/Model/Resultset.zep", 538); + return; +} + +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, rewind) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &forUpdate_param); - if (!forUpdate_param) { - forUpdate = 1; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "for_update"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_BOOL(&_1, forUpdate); - zephir_update_property_array(this_ptr, SL("params"), &_0, &_1); - RETURN_THIS(); + + ZVAL_LONG(&_0, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 93, &_0); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, fromInput) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, seek) { - zend_bool _6$$4, _7$$7, _11$$10, _12$$13; - zend_string *_5$$3; - zend_ulong _4$$3; + zend_bool _1, _6$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_13 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval data, conditions, bind, _1$$3; - zval modelName, operator, _17$$16; - zval *container, container_sub, *modelName_param = NULL, *data_param = NULL, *operator_param = NULL, __$null, attribute, field, value, type, metaData, model, dataTypes, criteria, columnMap, _0$$3, *_2$$3, _3$$3, _8$$9, _9$$9, _10$$8, _13$$15, _14$$15, _15$$14, _16$$16; + zval *position, position_sub, __$null, result, row, _0, _2, _3$$3, _5$$3, _7$$3, _9$$3, _11$$3, _4$$4, _8$$6, _10$$7, _12$$8; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&container_sub); + ZVAL_UNDEF(&position_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&dataTypes); - ZVAL_UNDEF(&criteria); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&row); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_8$$9); - ZVAL_UNDEF(&_9$$9); - ZVAL_UNDEF(&_10$$8); - ZVAL_UNDEF(&_13$$15); - ZVAL_UNDEF(&_14$$15); - ZVAL_UNDEF(&_15$$14); - ZVAL_UNDEF(&_16$$16); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&_17$$16); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&bind); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) - Z_PARAM_STR(modelName) - Z_PARAM_ARRAY(data) - Z_PARAM_OPTIONAL - Z_PARAM_STR(operator) + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_9$$3); + ZVAL_UNDEF(&_11$$3); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&_10$$7); + ZVAL_UNDEF(&_12$$8); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(position) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 1, &container, &modelName_param, &data_param, &operator_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); - } else { - ZEPHIR_INIT_VAR(&modelName); + zephir_fetch_params(1, 1, 0, &position); + zephir_read_property(&_0, this_ptr, ZEND_STRL("pointer"), PH_NOISY_CC | PH_READONLY); + _1 = !ZEPHIR_IS_EQUAL(&_0, position); + if (!(_1)) { + zephir_read_property(&_2, this_ptr, ZEND_STRL("row"), PH_NOISY_CC | PH_READONLY); + _1 = Z_TYPE_P(&_2) == IS_NULL; } - ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); - if (!operator_param) { - ZEPHIR_INIT_VAR(&operator); - ZVAL_STRING(&operator, "AND"); - } else { - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); + if (_1) { + zephir_memory_observe(&_3$$3); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("rows"), PH_NOISY_CC); + if (Z_TYPE_P(&_3$$3) == IS_ARRAY) { + zephir_memory_observe(&row); + zephir_read_property(&_4$$4, this_ptr, ZEND_STRL("rows"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&row, &_4$$4, position, 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("row"), &row); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("pointer"), position); + zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &__$null); + RETURN_MM_NULL(); + } + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("result"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&result, &_5$$3); + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("row"), PH_NOISY_CC | PH_READONLY); + _6$$3 = Z_TYPE_P(&_5$$3) == IS_NULL; + if (_6$$3) { + zephir_read_property(&_7$$3, this_ptr, ZEND_STRL("pointer"), PH_NOISY_CC | PH_READONLY); + _6$$3 = ZEPHIR_IS_LONG_IDENTICAL(&_7$$3, 0); + } + if (_6$$3) { + ZEPHIR_CALL_METHOD(&_8$$6, &result, "fetch", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("row"), &_8$$6); + } + zephir_read_property(&_9$$3, this_ptr, ZEND_STRL("pointer"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_GT(&_9$$3, position)) { + ZEPHIR_CALL_METHOD(NULL, &result, "dataseek", NULL, 0, position); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_10$$7, &result, "fetch", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("row"), &_10$$7); + zephir_update_property_zval(this_ptr, ZEND_STRL("pointer"), position); + } + while (1) { + zephir_read_property(&_11$$3, this_ptr, ZEND_STRL("pointer"), PH_NOISY_CC | PH_READONLY); + if (!(ZEPHIR_LT(&_11$$3, position))) { + break; + } + ZEPHIR_CALL_METHOD(&_12$$8, &result, "fetch", &_13, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("row"), &_12$$8); + RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("pointer"))); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("pointer"), position); + zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &__$null); } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, setHydrateMode) +{ + zval *hydrateMode_param = NULL, _0; + zend_long hydrateMode; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(hydrateMode) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &hydrateMode_param); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, hydrateMode); + zephir_update_property_zval(this_ptr, ZEND_STRL("hydrateMode"), &_0); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, setIsFresh) +{ + zval *isFresh_param = NULL, __$true, __$false; + zend_bool isFresh; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(isFresh) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &isFresh_param); + if (isFresh) { + zephir_update_property_zval(this_ptr, ZEND_STRL("isFresh"), &__$true); } else { - ZEPHIR_INIT_VAR(&operator); + zephir_update_property_zval(this_ptr, ZEND_STRL("isFresh"), &__$false); } + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, update) +{ + zval _4$$6; + zend_bool transaction = 0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_5 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *data, data_sub, *conditionCallback = NULL, conditionCallback_sub, __$null, record, connection, _0, _3$$6, _6$$3, _7$$8; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&data_sub); + ZVAL_UNDEF(&conditionCallback_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&record); + ZVAL_UNDEF(&connection); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_3$$6); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$8); + ZVAL_UNDEF(&_4$$6); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(data) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(conditionCallback, zend_ce_closure) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &data, &conditionCallback); + if (!conditionCallback) { + conditionCallback = &conditionCallback_sub; + conditionCallback = &__$null; } - ZEPHIR_INIT_VAR(&conditions); - array_init(&conditions); - if (zephir_fast_count_int(&data)) { - ZEPHIR_INIT_VAR(&_0$$3); - ZVAL_STRING(&_0$$3, "modelsMetadata"); - ZEPHIR_CALL_METHOD(&metaData, container, "getshared", NULL, 0, &_0$$3); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_1$$3); - zephir_create_array(&_1$$3, 2, 0); - zephir_array_fast_append(&_1$$3, &__$null); - zephir_array_fast_append(&_1$$3, container); - ZEPHIR_INIT_VAR(&model); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&model, &modelName, &_1$$3); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&dataTypes, &metaData, "getdatatypes", NULL, 0, &model); + ZEPHIR_INIT_VAR(&connection); + ZVAL_NULL(&connection); + transaction = 0; + ZEPHIR_CALL_METHOD(NULL, this_ptr, "rewind", NULL, 92); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", &_1, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getreversecolumnmap", NULL, 0, &model); + if (!(zephir_is_true(&_0))) { + break; + } + ZEPHIR_CALL_METHOD(&record, this_ptr, "current", &_2, 0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&bind); - array_init(&bind); - zephir_is_iterable(&data, 0, "phalcon/Mvc/Model/Criteria.zep", 356); - if (Z_TYPE_P(&data) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _4$$3, _5$$3, _2$$3) - { - ZEPHIR_INIT_NVAR(&field); - if (_5$$3 != NULL) { - ZVAL_STR_COPY(&field, _5$$3); - } else { - ZVAL_LONG(&field, _4$$3); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _2$$3); - _6$$4 = Z_TYPE_P(&columnMap) == IS_ARRAY; - if (_6$$4) { - _6$$4 = ((zephir_fast_count_int(&columnMap)) ? 1 : 0); - } - if (_6$$4) { - ZEPHIR_OBS_NVAR(&attribute); - zephir_array_fetch(&attribute, &columnMap, &field, PH_NOISY, "phalcon/Mvc/Model/Criteria.zep", 331); - } else { - ZEPHIR_CPY_WRT(&attribute, &field); - } - ZEPHIR_OBS_NVAR(&type); - if (zephir_array_isset_fetch(&type, &dataTypes, &attribute, 0)) { - _7$$7 = Z_TYPE_P(&value) != IS_NULL; - if (_7$$7) { - _7$$7 = !ZEPHIR_IS_STRING_IDENTICAL(&value, ""); - } - if (_7$$7) { - if (ZEPHIR_IS_LONG(&type, 2)) { - ZEPHIR_INIT_NVAR(&_8$$9); - ZEPHIR_CONCAT_SVSVS(&_8$$9, "[", &field, "] LIKE :", &field, ":"); - zephir_array_append(&conditions, &_8$$9, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 342); - ZEPHIR_INIT_NVAR(&_9$$9); - ZEPHIR_CONCAT_SVS(&_9$$9, "%", &value, "%"); - zephir_array_update_zval(&bind, &field, &_9$$9, PH_COPY | PH_SEPARATE); - continue; - } - ZEPHIR_INIT_NVAR(&_10$$8); - ZEPHIR_CONCAT_SVSVS(&_10$$8, "[", &field, "] = :", &field, ":"); - zephir_array_append(&conditions, &_10$$8, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 351); - zephir_array_update_zval(&bind, &field, &value, PH_COPY | PH_SEPARATE); - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); + if (transaction == 0) { + if (UNEXPECTED(!((zephir_method_exists_ex(&record, ZEND_STRL("getwriteconnection")) == SUCCESS)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The returned record is not valid", "phalcon/Mvc/Model/Resultset.zep", 655); + return; + } + ZEPHIR_CALL_METHOD(&connection, &record, "getwriteconnection", NULL, 0); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$3, &data, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&field, &data, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); - zephir_check_call_status(); - _11$$10 = Z_TYPE_P(&columnMap) == IS_ARRAY; - if (_11$$10) { - _11$$10 = ((zephir_fast_count_int(&columnMap)) ? 1 : 0); - } - if (_11$$10) { - ZEPHIR_OBS_NVAR(&attribute); - zephir_array_fetch(&attribute, &columnMap, &field, PH_NOISY, "phalcon/Mvc/Model/Criteria.zep", 331); - } else { - ZEPHIR_CPY_WRT(&attribute, &field); - } - ZEPHIR_OBS_NVAR(&type); - if (zephir_array_isset_fetch(&type, &dataTypes, &attribute, 0)) { - _12$$13 = Z_TYPE_P(&value) != IS_NULL; - if (_12$$13) { - _12$$13 = !ZEPHIR_IS_STRING_IDENTICAL(&value, ""); - } - if (_12$$13) { - if (ZEPHIR_IS_LONG(&type, 2)) { - ZEPHIR_INIT_NVAR(&_13$$15); - ZEPHIR_CONCAT_SVSVS(&_13$$15, "[", &field, "] LIKE :", &field, ":"); - zephir_array_append(&conditions, &_13$$15, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 342); - ZEPHIR_INIT_NVAR(&_14$$15); - ZEPHIR_CONCAT_SVS(&_14$$15, "%", &value, "%"); - zephir_array_update_zval(&bind, &field, &_14$$15, PH_COPY | PH_SEPARATE); - continue; - } - ZEPHIR_INIT_NVAR(&_15$$14); - ZEPHIR_CONCAT_SVSVS(&_15$$14, "[", &field, "] = :", &field, ":"); - zephir_array_append(&conditions, &_15$$14, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 351); - zephir_array_update_zval(&bind, &field, &value, PH_COPY | PH_SEPARATE); - } - } - ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); + transaction = 1; + ZEPHIR_CALL_METHOD(NULL, &connection, "begin", NULL, 0); + zephir_check_call_status(); + } + if (Z_TYPE_P(conditionCallback) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_3$$6); + ZEPHIR_INIT_NVAR(&_4$$6); + zephir_create_array(&_4$$6, 1, 0); + zephir_array_fast_append(&_4$$6, &record); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_3$$6, conditionCallback, &_4$$6); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_3$$6)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); zephir_check_call_status(); + continue; } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&field); - } - ZEPHIR_INIT_VAR(&criteria); - object_init_ex(&criteria, phalcon_mvc_model_criteria_ce); - if (zephir_has_constructor(&criteria)) { - ZEPHIR_CALL_METHOD(NULL, &criteria, "__construct", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &record, "assign", NULL, 0, data); zephir_check_call_status(); - } - - ZEPHIR_CALL_METHOD(NULL, &criteria, "setdi", NULL, 429, container); - zephir_check_call_status(); - if (zephir_fast_count_int(&conditions)) { - ZEPHIR_INIT_VAR(&_16$$16); - ZEPHIR_INIT_VAR(&_17$$16); - ZEPHIR_CONCAT_SVS(&_17$$16, " ", &operator, " "); - zephir_fast_join(&_16$$16, &_17$$16, &conditions); - ZEPHIR_CALL_METHOD(NULL, &criteria, "where", NULL, 439, &_16$$16); + ZEPHIR_CALL_METHOD(&_6$$3, &record, "save", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &criteria, "bind", NULL, 440, &bind); + if (!(zephir_is_true(&_6$$3))) { + ZEPHIR_CALL_METHOD(&_7$$8, &record, "getmessages", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("errorMessages"), &_7$$8); + ZEPHIR_CALL_METHOD(NULL, &connection, "rollback", NULL, 0); + zephir_check_call_status(); + transaction = 0; + break; + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); zephir_check_call_status(); } - ZEPHIR_CALL_METHOD(NULL, &criteria, "setmodelname", NULL, 430, &modelName); - zephir_check_call_status(); - RETURN_CCTOR(&criteria); + if (transaction == 1) { + ZEPHIR_CALL_METHOD(NULL, &connection, "commit", NULL, 0); + zephir_check_call_status(); + } + RETURN_MM_BOOL(transaction); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getColumns) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset, valid) { - zval columns, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&columns); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("pointer"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_1, this_ptr, ZEND_STRL("count"), PH_NOISY_CC | PH_READONLY); + RETURN_BOOL(ZEPHIR_LT(&_0, &_1)); +} + +zend_object *zephir_init_properties_Phalcon_Mvc_Model_Resultset(zend_class_entry *class_type) +{ + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("errorMessages"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("errorMessages"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_ResultsetInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, ResultsetInterface, phalcon, mvc_model_resultsetinterface, phalcon_mvc_model_resultsetinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, delete); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, filter); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getCache); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getFirst); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getHydrateMode); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getLast); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getMessages); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getType); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, isFresh); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, setHydrateMode); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, setIsFresh); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, toArray); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, update); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Row) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model, Row, phalcon, mvc_model_row, zend_standard_class_def, phalcon_mvc_model_row_method_entry, 0); + + zend_class_implements(phalcon_mvc_model_row_ce, 1, phalcon_mvc_entityinterface_ce); + zend_class_implements(phalcon_mvc_model_row_ce, 1, phalcon_mvc_model_resultinterface_ce); + zend_class_implements(phalcon_mvc_model_row_ce, 1, zend_ce_arrayaccess); + zend_class_implements(phalcon_mvc_model_row_ce, 1, php_json_serializable_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Mvc_Model_Row, jsonSerialize) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_memory_observe(&columns); - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_string_fetch(&columns, &_0, SL("columns"), 0))) { - RETURN_MM_NULL(); - } - RETURN_CCTOR(&columns); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "toarray", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getConditions) +static PHP_METHOD(Phalcon_Mvc_Model_Row, offsetGet) { - zval conditions, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval index_sub, _0, _1; + zval *index; zval *this_ptr = getThis(); - ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(&index_sub); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(index) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_memory_observe(&conditions); - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_string_fetch(&conditions, &_0, SL("conditions"), 0))) { - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 0, &index); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "offsetexists", NULL, 0, index); + zephir_check_call_status(); + if (!(zephir_is_true(&_0))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The index does not exist in the row", "phalcon/Mvc/Model/Row.zep", 42); + return; } - RETURN_CCTOR(&conditions); + zephir_memory_observe(&_1); + zephir_read_property_zval(&_1, this_ptr, index, PH_NOISY_CC); + RETURN_CCTOR(&_1); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getDI) +static PHP_METHOD(Phalcon_Mvc_Model_Row, offsetExists) { - zval _0, _1; + zval index_sub; + zval *index; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_1, &_0, SL("di"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Criteria.zep", 413); - RETURN_CTORW(&_1); + ZVAL_UNDEF(&index_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(index) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &index); + RETURN_BOOL(zephir_isset_property_zval(this_ptr, index)); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getGroupBy) +static PHP_METHOD(Phalcon_Mvc_Model_Row, offsetSet) +{ + zval offset_sub, value_sub; + zval *offset, *value; + + ZVAL_UNDEF(&offset_sub); + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(offset) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(2, 0, &offset, &value); + ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_model_exception_ce, "Row is an immutable ArrayAccess object", "phalcon/Mvc/Model/Row.zep", 66); + return; +} + +static PHP_METHOD(Phalcon_Mvc_Model_Row, offsetUnset) +{ + zval offset_sub; + zval *offset; + + ZVAL_UNDEF(&offset_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(offset) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &offset); + ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_model_exception_ce, "Row is an immutable ArrayAccess object", "phalcon/Mvc/Model/Row.zep", 76); + return; +} + +static PHP_METHOD(Phalcon_Mvc_Model_Row, readAttribute) { - zval group, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *attribute_param = NULL, value; + zval attribute; zval *this_ptr = getThis(); - ZVAL_UNDEF(&group); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&value); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(attribute) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_memory_observe(&group); - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_string_fetch(&group, &_0, SL("group"), 0))) { + zephir_fetch_params(1, 1, 0, &attribute_param); + if (UNEXPECTED(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be of the type string")); RETURN_MM_NULL(); } - RETURN_CCTOR(&group); + if (EXPECTED(Z_TYPE_P(attribute_param) == IS_STRING)) { + zephir_get_strval(&attribute, attribute_param); + } else { + ZEPHIR_INIT_VAR(&attribute); + } + zephir_memory_observe(&value); + if (!(zephir_fetch_property_zval(&value, this_ptr, &attribute, PH_SILENT_CC))) { + RETURN_MM_NULL(); + } + RETURN_CCTOR(&value); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getHaving) +static PHP_METHOD(Phalcon_Mvc_Model_Row, setDirtyState) +{ + zval *dirtyState_param = NULL; + zend_long dirtyState; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(dirtyState) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &dirtyState_param); + RETURN_BOOL(0); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Row, toArray) { - zval having, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - - ZVAL_UNDEF(&having); - ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_memory_observe(&having); - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_string_fetch(&having, &_0, SL("having"), 0))) { - RETURN_MM_NULL(); - } - RETURN_CCTOR(&having); + ZEPHIR_RETURN_CALL_FUNCTION("get_object_vars", NULL, 426, this_ptr); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getLimit) +static PHP_METHOD(Phalcon_Mvc_Model_Row, writeAttribute) { - zval limit, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *attribute_param = NULL, *value, value_sub; + zval attribute; zval *this_ptr = getThis(); - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(attribute) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_memory_observe(&limit); - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_string_fetch(&limit, &_0, SL("limit"), 0))) { + zephir_fetch_params(1, 2, 0, &attribute_param, &value); + if (UNEXPECTED(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be of the type string")); RETURN_MM_NULL(); } - RETURN_CCTOR(&limit); + if (EXPECTED(Z_TYPE_P(attribute_param) == IS_STRING)) { + zephir_get_strval(&attribute, attribute_param); + } else { + ZEPHIR_INIT_VAR(&attribute); + } + zephir_update_property_zval_zval(this_ptr, &attribute, value); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getModelName) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Transaction) { + ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Transaction, phalcon, mvc_model_transaction, phalcon_mvc_model_transaction_method_entry, 0); - RETURN_MEMBER(getThis(), "model"); + zend_declare_property_bool(phalcon_mvc_model_transaction_ce, SL("activeTransaction"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_transaction_ce, SL("connection"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_mvc_model_transaction_ce, SL("isNewTransaction"), 1, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_transaction_ce, SL("manager"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_transaction_ce, SL("messages"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_transaction_ce, SL("rollbackRecord"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_mvc_model_transaction_ce, SL("rollbackOnAbort"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_mvc_model_transaction_ce, SL("rollbackThrowException"), 0, ZEND_ACC_PROTECTED); + phalcon_mvc_model_transaction_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Transaction; + + zend_class_implements(phalcon_mvc_model_transaction_ce, 1, phalcon_mvc_model_transactioninterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getOrderBy) +static PHP_METHOD(Phalcon_Mvc_Model_Transaction, __construct) { - zval order, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval service; + zend_bool autoBegin; + zval *container, container_sub, *autoBegin_param = NULL, *service_param = NULL, connection, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&order); + ZVAL_UNDEF(&container_sub); + ZVAL_UNDEF(&connection); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&service); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(autoBegin) + Z_PARAM_STR(service) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_memory_observe(&order); - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_string_fetch(&order, &_0, SL("order"), 0))) { - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 2, &container, &autoBegin_param, &service_param); + if (!autoBegin_param) { + autoBegin = 0; + } else { + } + if (!service_param) { + ZEPHIR_INIT_VAR(&service); + ZVAL_STRING(&service, "db"); + } else { + zephir_get_strval(&service, service_param); } - RETURN_CCTOR(&order); + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), &_0); + ZEPHIR_CALL_METHOD(&connection, container, "get", NULL, 0, &service); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("connection"), &connection); + if (autoBegin) { + ZEPHIR_CALL_METHOD(NULL, &connection, "begin", NULL, 0); + zephir_check_call_status(); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getParams) +static PHP_METHOD(Phalcon_Mvc_Model_Transaction, begin) { + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "params"); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "begin", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, getWhere) +static PHP_METHOD(Phalcon_Mvc_Model_Transaction, commit) { - zval conditions, _0; + zval manager, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(&manager); ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_memory_observe(&conditions); - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_string_fetch(&conditions, &_0, SL("conditions"), 0))) { - RETURN_MM_NULL(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&manager, &_0); + if (Z_TYPE_P(&manager) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(NULL, &manager, "notifycommit", NULL, 0, this_ptr); + zephir_check_call_status(); } - RETURN_CCTOR(&conditions); + zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "commit", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, groupBy) +static PHP_METHOD(Phalcon_Mvc_Model_Transaction, getConnection) { + zval _0, _1$$3, _2$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *group, group_sub, _0; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&group_sub); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(group) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &group); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "group"); - zephir_update_property_array(this_ptr, SL("params"), &_0, group); - RETURN_THIS(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("rollbackOnAbort"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_0)) { + ZEPHIR_CALL_FUNCTION(&_1$$3, "connection_aborted", NULL, 481); + zephir_check_call_status(); + if (zephir_is_true(&_1$$3)) { + ZEPHIR_INIT_VAR(&_2$$4); + ZVAL_STRING(&_2$$4, "The request was aborted"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "rollback", NULL, 0, &_2$$4); + zephir_check_call_status(); + } + } + RETURN_MM_MEMBER(getThis(), "connection"); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, having) +static PHP_METHOD(Phalcon_Mvc_Model_Transaction, getMessages) +{ + + RETURN_MEMBER(getThis(), "messages"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction, isManaged) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *having, having_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&having_sub); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(having) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &having); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "having"); - zephir_update_property_array(this_ptr, SL("params"), &_0, having); - RETURN_THIS(); + + zephir_memory_observe(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC); + RETURN_MM_BOOL(Z_TYPE_P(&_0) == IS_OBJECT); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, innerJoin) +static PHP_METHOD(Phalcon_Mvc_Model_Transaction, isValid) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model_param = NULL, *conditions = NULL, conditions_sub, *alias = NULL, alias_sub, __$null, _0; - zval model; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&conditions_sub); - ZVAL_UNDEF(&alias_sub); - ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(model) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(conditions) - Z_PARAM_ZVAL_OR_NULL(alias) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &model_param, &conditions, &alias); - if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { - zephir_get_strval(&model, model_param); - } else { - ZEPHIR_INIT_VAR(&model); - } - if (!conditions) { - conditions = &conditions_sub; - conditions = &__$null; - } - if (!alias) { - alias = &alias_sub; - alias = &__$null; - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "INNER"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "join", NULL, 0, &model, conditions, alias, &_0); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "isundertransaction", NULL, 0); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, inWhere) +static PHP_METHOD(Phalcon_Mvc_Model_Transaction, rollback) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval values, bindParams, bindKeys; - zval *expr_param = NULL, *values_param = NULL, hiddenParam, value, *_1, _2, _5, _6, _3$$4, _4$$5; - zval expr, key, queryKey, _0$$3; + zval *rollbackMessage_param = NULL, *rollbackRecord = NULL, rollbackRecord_sub, __$null, manager, connection, _0, _1, _2$$4, _3$$7, _4$$7; + zval rollbackMessage; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&queryKey); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&hiddenParam); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindKeys); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(expr) - Z_PARAM_ARRAY(values) + ZVAL_UNDEF(&rollbackMessage); + ZVAL_UNDEF(&rollbackRecord_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&manager); + ZVAL_UNDEF(&connection); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$7); + ZVAL_UNDEF(&_4$$7); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(rollbackMessage) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(rollbackRecord, phalcon_mvc_modelinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &expr_param, &values_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); + zephir_fetch_params(1, 0, 2, &rollbackMessage_param, &rollbackRecord); + if (!rollbackMessage_param) { + ZEPHIR_INIT_VAR(&rollbackMessage); } else { - ZEPHIR_INIT_VAR(&expr); + zephir_get_strval(&rollbackMessage, rollbackMessage_param); } - ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); - if (!(zephir_fast_count_int(&values))) { - ZEPHIR_INIT_VAR(&_0$$3); - ZEPHIR_CONCAT_VSV(&_0$$3, &expr, " != ", &expr); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, &_0$$3); + if (!rollbackRecord) { + rollbackRecord = &rollbackRecord_sub; + rollbackRecord = &__$null; + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&manager, &_0); + if (Z_TYPE_P(&manager) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(NULL, &manager, "notifyrollback", NULL, 0, this_ptr); zephir_check_call_status(); - RETURN_THIS(); } - zephir_memory_observe(&hiddenParam); - zephir_read_property(&hiddenParam, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - ZEPHIR_INIT_VAR(&bindKeys); - array_init(&bindKeys); - zephir_is_iterable(&values, 0, "phalcon/Mvc/Model/Criteria.zep", 595); - if (Z_TYPE_P(&values) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&values), _1) - { - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _1); - ZEPHIR_INIT_NVAR(&_3$$4); - ZEPHIR_CONCAT_SV(&_3$$4, "ACP", &hiddenParam); - zephir_get_strval(&key, &_3$$4); - ZEPHIR_INIT_NVAR(&queryKey); - ZEPHIR_CONCAT_SVS(&queryKey, ":", &key, ":"); - zephir_array_append(&bindKeys, &queryKey, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 585); - zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); - SEPARATE_ZVAL(&hiddenParam); - zephir_increment(&hiddenParam); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &values, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_4$$5); - ZEPHIR_CONCAT_SV(&_4$$5, "ACP", &hiddenParam); - zephir_get_strval(&key, &_4$$5); - ZEPHIR_INIT_NVAR(&queryKey); - ZEPHIR_CONCAT_SVS(&queryKey, ":", &key, ":"); - zephir_array_append(&bindKeys, &queryKey, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 585); - zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); - SEPARATE_ZVAL(&hiddenParam); - zephir_increment(&hiddenParam); - ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_VAR(&_5); - zephir_fast_join_str(&_5, SL(", "), &bindKeys); - ZEPHIR_INIT_VAR(&_6); - ZEPHIR_CONCAT_VSVS(&_6, &expr, " IN (", &_5, ")"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, &_6, &bindParams); + zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&connection, &_0); + ZEPHIR_CALL_METHOD(&_1, &connection, "rollback", NULL, 0); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &hiddenParam); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, join) -{ - zval join, _1$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model_param = NULL, *conditions = NULL, conditions_sub, *alias = NULL, alias_sub, *type = NULL, type_sub, __$null, mergedJoins, currentJoins, _0, _4, _2$$5, _3$$6; - zval model; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&conditions_sub); - ZVAL_UNDEF(&alias_sub); - ZVAL_UNDEF(&type_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&mergedJoins); - ZVAL_UNDEF(¤tJoins); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_3$$6); - ZVAL_UNDEF(&join); - ZVAL_UNDEF(&_1$$4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_STR(model) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(conditions) - Z_PARAM_ZVAL_OR_NULL(alias) - Z_PARAM_ZVAL_OR_NULL(type) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 3, &model_param, &conditions, &alias, &type); - if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { - zephir_get_strval(&model, model_param); - } else { - ZEPHIR_INIT_VAR(&model); - } - if (!conditions) { - conditions = &conditions_sub; - conditions = &__$null; - } - if (!alias) { - alias = &alias_sub; - alias = &__$null; - } - if (!type) { - type = &type_sub; - type = &__$null; - } - ZEPHIR_INIT_VAR(&join); - zephir_create_array(&join, 4, 0); - zephir_array_fast_append(&join, &model); - zephir_array_fast_append(&join, conditions); - zephir_array_fast_append(&join, alias); - zephir_array_fast_append(&join, type); - zephir_memory_observe(¤tJoins); - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_string_fetch(¤tJoins, &_0, SL("joins"), 0)) { - if (Z_TYPE_P(¤tJoins) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_1$$4); - zephir_create_array(&_1$$4, 1, 0); - zephir_array_fast_append(&_1$$4, &join); - ZEPHIR_INIT_VAR(&mergedJoins); - zephir_fast_array_merge(&mergedJoins, ¤tJoins, &_1$$4); - } else { - ZEPHIR_INIT_VAR(&_2$$5); - zephir_create_array(&_2$$5, 1, 0); - zephir_array_fast_append(&_2$$5, &join); - ZEPHIR_CPY_WRT(&mergedJoins, &_2$$5); + if (UNEXPECTED(zephir_is_true(&_1))) { + if (!(!(ZEPHIR_IS_EMPTY(&rollbackMessage)))) { + ZEPHIR_INIT_NVAR(&rollbackMessage); + ZVAL_STRING(&rollbackMessage, "Transaction aborted"); } - } else { - ZEPHIR_INIT_VAR(&_3$$6); - zephir_create_array(&_3$$6, 1, 0); - zephir_array_fast_append(&_3$$6, &join); - ZEPHIR_CPY_WRT(&mergedJoins, &_3$$6); - } - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, "joins"); - zephir_update_property_array(this_ptr, SL("params"), &_4, &mergedJoins); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, leftJoin) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model_param = NULL, *conditions = NULL, conditions_sub, *alias = NULL, alias_sub, __$null, _0; - zval model; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&conditions_sub); - ZVAL_UNDEF(&alias_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(model) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(conditions) - Z_PARAM_ZVAL_OR_NULL(alias) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &model_param, &conditions, &alias); - if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { - zephir_get_strval(&model, model_param); - } else { - ZEPHIR_INIT_VAR(&model); - } - if (!conditions) { - conditions = &conditions_sub; - conditions = &__$null; - } - if (!alias) { - alias = &alias_sub; - alias = &__$null; - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "LEFT"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "join", NULL, 0, &model, conditions, alias, &_0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, limit) -{ - zval _5$$5; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *limit_param = NULL, *offset_param = NULL, _0, _1, _2, _3$$4, _4$$4, _6$$5; - zend_long limit, offset, ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_5$$5); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_LONG(limit) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(offset) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &limit_param, &offset_param); - if (!offset_param) { - offset = 0; - } else { + if (Z_TYPE_P(rollbackRecord) == IS_OBJECT) { + zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackRecord"), rollbackRecord); } - ZVAL_LONG(&_0, limit); - ZEPHIR_CALL_FUNCTION(&_1, "abs", NULL, 284, &_0); - zephir_check_call_status(); - limit = zephir_get_numberval(&_1); - ZVAL_LONG(&_0, offset); - ZEPHIR_CALL_FUNCTION(&_2, "abs", NULL, 284, &_0); - zephir_check_call_status(); - offset = zephir_get_numberval(&_2); - if (UNEXPECTED(limit == 0)) { - RETURN_THIS(); - } - if (offset == 0) { - ZEPHIR_INIT_VAR(&_3$$4); - ZVAL_STRING(&_3$$4, "limit"); - ZEPHIR_INIT_VAR(&_4$$4); - ZVAL_LONG(&_4$$4, limit); - zephir_update_property_array(this_ptr, SL("params"), &_3$$4, &_4$$4); - } else { - ZEPHIR_INIT_VAR(&_5$$5); - zephir_create_array(&_5$$5, 2, 0); - ZEPHIR_INIT_VAR(&_6$$5); - ZVAL_LONG(&_6$$5, limit); - zephir_array_update_string(&_5$$5, SL("number"), &_6$$5, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_6$$5); - ZVAL_LONG(&_6$$5, offset); - zephir_array_update_string(&_5$$5, SL("offset"), &_6$$5, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_6$$5); - ZVAL_STRING(&_6$$5, "limit"); - zephir_update_property_array(this_ptr, SL("params"), &_6$$5, &_5$$5); - } - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, notBetweenWhere) -{ - zval _3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, hiddenParam, nextHiddenParam, _0, _1; - zval expr, minimumKey, maximumKey, _2; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&minimumKey); - ZVAL_UNDEF(&maximumKey); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&minimum_sub); - ZVAL_UNDEF(&maximum_sub); - ZVAL_UNDEF(&hiddenParam); - ZVAL_UNDEF(&nextHiddenParam); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_STR(expr) - Z_PARAM_ZVAL(minimum) - Z_PARAM_ZVAL(maximum) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &expr_param, &minimum, &maximum); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - zephir_memory_observe(&hiddenParam); - zephir_read_property(&hiddenParam, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&nextHiddenParam); - ZVAL_LONG(&nextHiddenParam, (zephir_get_numberval(&hiddenParam) + 1)); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_CONCAT_SV(&_0, "ACP", &hiddenParam); - zephir_get_strval(&minimumKey, &_0); - ZEPHIR_INIT_VAR(&_1); - ZEPHIR_CONCAT_SV(&_1, "ACP", &nextHiddenParam); - zephir_get_strval(&maximumKey, &_1); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VSVSVS(&_2, &expr, " NOT BETWEEN :", &minimumKey, ": AND :", &maximumKey, ":"); - ZEPHIR_INIT_VAR(&_3); - zephir_create_array(&_3, 2, 0); - zephir_array_update_zval(&_3, &minimumKey, minimum, PH_COPY); - zephir_array_update_zval(&_3, &maximumKey, maximum, PH_COPY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, &_2, &_3); - zephir_check_call_status(); - SEPARATE_ZVAL(&nextHiddenParam); - zephir_increment(&nextHiddenParam); - zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &nextHiddenParam); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, notInWhere) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval values, bindParams, bindKeys; - zval *expr_param = NULL, *values_param = NULL, hiddenParam, value, *_0, _1, _6, _7, _2$$3, _4$$4; - zval expr, key, _3$$3, _5$$4; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&hiddenParam); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindKeys); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(expr) - Z_PARAM_ARRAY(values) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &expr_param, &values_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); - zephir_memory_observe(&hiddenParam); - zephir_read_property(&hiddenParam, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - ZEPHIR_INIT_VAR(&bindKeys); - array_init(&bindKeys); - zephir_is_iterable(&values, 0, "phalcon/Mvc/Model/Criteria.zep", 782); - if (Z_TYPE_P(&values) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&values), _0) - { - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0); - ZEPHIR_INIT_NVAR(&_2$$3); - ZEPHIR_CONCAT_SV(&_2$$3, "ACP", &hiddenParam); - zephir_get_strval(&key, &_2$$3); - ZEPHIR_INIT_NVAR(&_3$$3); - ZEPHIR_CONCAT_SVS(&_3$$3, ":", &key, ":"); - zephir_array_append(&bindKeys, &_3$$3, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 772); - zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); - SEPARATE_ZVAL(&hiddenParam); - zephir_increment(&hiddenParam); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &values, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_4$$4); - ZEPHIR_CONCAT_SV(&_4$$4, "ACP", &hiddenParam); - zephir_get_strval(&key, &_4$$4); - ZEPHIR_INIT_NVAR(&_5$$4); - ZEPHIR_CONCAT_SVS(&_5$$4, ":", &key, ":"); - zephir_array_append(&bindKeys, &_5$$4, PH_SEPARATE, "phalcon/Mvc/Model/Criteria.zep", 772); - zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); - SEPARATE_ZVAL(&hiddenParam); - zephir_increment(&hiddenParam); - ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("rollbackThrowException"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_2$$4)) { + ZEPHIR_INIT_VAR(&_3$$7); + object_init_ex(&_3$$7, phalcon_mvc_model_transaction_failed_ce); + zephir_read_property(&_4$$7, this_ptr, ZEND_STRL("rollbackRecord"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_3$$7, "__construct", NULL, 482, &rollbackMessage, &_4$$7); zephir_check_call_status(); + zephir_throw_exception_debug(&_3$$7, "phalcon/Mvc/Model/Transaction.zep", 215); + ZEPHIR_MM_RESTORE(); + return; } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_VAR(&_6); - zephir_fast_join_str(&_6, SL(", "), &bindKeys); - ZEPHIR_INIT_VAR(&_7); - ZEPHIR_CONCAT_VSVS(&_7, &expr, " NOT IN (", &_6, ")"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "andwhere", NULL, 0, &_7, &bindParams); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &hiddenParam); - RETURN_THIS(); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, orderBy) +static PHP_METHOD(Phalcon_Mvc_Model_Transaction, setIsNewTransaction) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *orderColumns_param = NULL, _0; - zval orderColumns; + zval *isNew_param = NULL, __$true, __$false; + zend_bool isNew; zval *this_ptr = getThis(); - ZVAL_UNDEF(&orderColumns); - ZVAL_UNDEF(&_0); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(orderColumns) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &orderColumns_param); - if (UNEXPECTED(Z_TYPE_P(orderColumns_param) != IS_STRING && Z_TYPE_P(orderColumns_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'orderColumns' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(orderColumns_param) == IS_STRING)) { - zephir_get_strval(&orderColumns, orderColumns_param); - } else { - ZEPHIR_INIT_VAR(&orderColumns); - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "order"); - zephir_update_property_array(this_ptr, SL("params"), &_0, &orderColumns); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, orWhere) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *conditions_param = NULL, *bindParams = NULL, bindParams_sub, *bindTypes = NULL, bindTypes_sub, __$null, currentConditions, _0, _1$$3; - zval conditions; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&bindParams_sub); - ZVAL_UNDEF(&bindTypes_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(¤tConditions); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(conditions) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(bindParams) - Z_PARAM_ZVAL_OR_NULL(bindTypes) + Z_PARAM_BOOL(isNew) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams, &bindTypes); - if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { - zephir_get_strval(&conditions, conditions_param); + zephir_fetch_params_without_memory_grow(1, 0, &isNew_param); + if (isNew) { + zephir_update_property_zval(this_ptr, ZEND_STRL("isNewTransaction"), &__$true); } else { - ZEPHIR_INIT_VAR(&conditions); - } - if (!bindParams) { - bindParams = &bindParams_sub; - bindParams = &__$null; - } - if (!bindTypes) { - bindTypes = &bindTypes_sub; - bindTypes = &__$null; - } - zephir_memory_observe(¤tConditions); - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_string_fetch(¤tConditions, &_0, SL("conditions"), 0)) { - ZEPHIR_INIT_VAR(&_1$$3); - ZEPHIR_CONCAT_SVSVS(&_1$$3, "(", ¤tConditions, ") OR (", &conditions, ")"); - zephir_get_strval(&conditions, &_1$$3); + zephir_update_property_zval(this_ptr, ZEND_STRL("isNewTransaction"), &__$false); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "where", NULL, 0, &conditions, bindParams, bindTypes); - zephir_check_call_status(); - RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, rightJoin) +static PHP_METHOD(Phalcon_Mvc_Model_Transaction, setRollbackOnAbort) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model_param = NULL, *conditions = NULL, conditions_sub, *alias = NULL, alias_sub, __$null, _0; - zval model; + zval *rollbackOnAbort_param = NULL, __$true, __$false; + zend_bool rollbackOnAbort; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&conditions_sub); - ZVAL_UNDEF(&alias_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(model) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(conditions) - Z_PARAM_ZVAL_OR_NULL(alias) + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(rollbackOnAbort) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &model_param, &conditions, &alias); - if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { - zephir_get_strval(&model, model_param); + zephir_fetch_params_without_memory_grow(1, 0, &rollbackOnAbort_param); + if (rollbackOnAbort) { + zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackOnAbort"), &__$true); } else { - ZEPHIR_INIT_VAR(&model); - } - if (!conditions) { - conditions = &conditions_sub; - conditions = &__$null; - } - if (!alias) { - alias = &alias_sub; - alias = &__$null; + zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackOnAbort"), &__$false); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "RIGHT"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "join", NULL, 0, &model, conditions, alias, &_0); - zephir_check_call_status(); - RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, setDI) +static PHP_METHOD(Phalcon_Mvc_Model_Transaction, setRollbackedRecord) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *container, container_sub, _0; + zval *record, record_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container_sub); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&record_sub); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + Z_PARAM_OBJECT_OF_CLASS(record, phalcon_mvc_modelinterface_ce) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &container); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "di"); - zephir_update_property_array(this_ptr, SL("params"), &_0, container); - ZEPHIR_MM_RESTORE(); + zephir_fetch_params_without_memory_grow(1, 0, &record); + zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackRecord"), record); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, setModelName) +static PHP_METHOD(Phalcon_Mvc_Model_Transaction, setTransactionManager) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *modelName_param = NULL; - zval modelName; + zval *manager, manager_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); + ZVAL_UNDEF(&manager_sub); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(modelName) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &modelName_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); - } else { - ZEPHIR_INIT_VAR(&modelName); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("model"), &modelName); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, sharedLock) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *sharedLock_param = NULL, _0, _1; - zend_bool sharedLock; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(sharedLock) + Z_PARAM_OBJECT_OF_CLASS(manager, phalcon_mvc_model_transaction_managerinterface_ce) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &sharedLock_param); - if (!sharedLock_param) { - sharedLock = 1; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "shared_lock"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_BOOL(&_1, sharedLock); - zephir_update_property_array(this_ptr, SL("params"), &_0, &_1); - RETURN_THIS(); + zephir_fetch_params_without_memory_grow(1, 0, &manager); + zephir_update_property_zval(this_ptr, ZEND_STRL("manager"), manager); } -static PHP_METHOD(Phalcon_Mvc_Model_Criteria, where) +static PHP_METHOD(Phalcon_Mvc_Model_Transaction, throwRollbackException) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *conditions_param = NULL, *bindParams = NULL, bindParams_sub, *bindTypes = NULL, bindTypes_sub, __$null, currentBindParams, currentBindTypes, _0, _1$$3, _2$$4, _3$$4, _4$$5, _5$$6, _6$$7, _7$$7, _8$$8; - zval conditions; + zval *status_param = NULL, __$true, __$false; + zend_bool status; zval *this_ptr = getThis(); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&bindParams_sub); - ZVAL_UNDEF(&bindTypes_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(¤tBindParams); - ZVAL_UNDEF(¤tBindTypes); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_7$$7); - ZVAL_UNDEF(&_8$$8); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(conditions) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(bindParams) - Z_PARAM_ZVAL_OR_NULL(bindTypes) + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(status) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams, &bindTypes); - if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { - zephir_get_strval(&conditions, conditions_param); + zephir_fetch_params_without_memory_grow(1, 0, &status_param); + if (status) { + zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackThrowException"), &__$true); } else { - ZEPHIR_INIT_VAR(&conditions); - } - if (!bindParams) { - bindParams = &bindParams_sub; - bindParams = &__$null; - } - if (!bindTypes) { - bindTypes = &bindTypes_sub; - bindTypes = &__$null; - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "conditions"); - zephir_update_property_array(this_ptr, SL("params"), &_0, &conditions); - if (Z_TYPE_P(bindParams) == IS_ARRAY) { - zephir_memory_observe(¤tBindParams); - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_string_fetch(¤tBindParams, &_1$$3, SL("bind"), 0)) { - ZEPHIR_INIT_VAR(&_2$$4); - zephir_fast_array_merge(&_2$$4, ¤tBindParams, bindParams); - ZEPHIR_INIT_VAR(&_3$$4); - ZVAL_STRING(&_3$$4, "bind"); - zephir_update_property_array(this_ptr, SL("params"), &_3$$4, &_2$$4); - } else { - ZEPHIR_INIT_VAR(&_4$$5); - ZVAL_STRING(&_4$$5, "bind"); - zephir_update_property_array(this_ptr, SL("params"), &_4$$5, bindParams); - } - } - if (Z_TYPE_P(bindTypes) == IS_ARRAY) { - zephir_memory_observe(¤tBindTypes); - zephir_read_property(&_5$$6, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_string_fetch(¤tBindTypes, &_5$$6, SL("bindTypes"), 0)) { - ZEPHIR_INIT_VAR(&_6$$7); - zephir_fast_array_merge(&_6$$7, ¤tBindTypes, bindTypes); - ZEPHIR_INIT_VAR(&_7$$7); - ZVAL_STRING(&_7$$7, "bindTypes"); - zephir_update_property_array(this_ptr, SL("params"), &_7$$7, &_6$$7); - } else { - ZEPHIR_INIT_VAR(&_8$$8); - ZVAL_STRING(&_8$$8, "bindTypes"); - zephir_update_property_array(this_ptr, SL("params"), &_8$$8, bindTypes); - } + zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackThrowException"), &__$false); } - RETURN_THIS(); + RETURN_THISW(); } -zend_object *zephir_init_properties_Phalcon_Mvc_Model_Criteria(zend_class_entry *class_type) +zend_object *zephir_init_properties_Phalcon_Mvc_Model_Transaction(zend_class_entry *class_type) { zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; @@ -54544,11 +56091,11 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Model_Criteria(zend_class_entry { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("messages"), &_1$$3); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -54565,45 +56112,25 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Model_Criteria(zend_class_entry -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_CriteriaInterface) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_TransactionInterface) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, CriteriaInterface, phalcon, mvc_model_criteriainterface, phalcon_mvc_model_criteriainterface_method_entry); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, TransactionInterface, phalcon, mvc_model_transactioninterface, phalcon_mvc_model_transactioninterface_method_entry); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, andWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, betweenWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, bind); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, bindTypes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, cache); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, conditions); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, distinct); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, execute); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, forUpdate); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getColumns); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getConditions); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getGroupBy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getHaving); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getLimit); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getModelName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getOrderBy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getParams); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, getWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, groupBy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, having); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, innerJoin); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, inWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, leftJoin); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, limit); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, notBetweenWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, notInWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, orderBy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, orWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, rightJoin); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, setModelName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, sharedLock); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, where); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, begin); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, commit); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, getConnection); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, getMessages); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, isManaged); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, isValid); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, rollback); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, setIsNewTransaction); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, setRollbackOnAbort); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, setRollbackedRecord); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, setTransactionManager); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, throwRollbackException); @@ -54614,13 +56141,90 @@ ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_CriteriaInterface, where); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Exception) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_ValidationFailed) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model, Exception, phalcon, mvc_model_exception, zend_ce_exception, NULL, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model, ValidationFailed, phalcon, mvc_model_validationfailed, phalcon_mvc_model_exception_ce, phalcon_mvc_model_validationfailed_method_entry, 0); + + zend_declare_property_null(phalcon_mvc_model_validationfailed_ce, SL("messages"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_validationfailed_ce, SL("model"), ZEND_ACC_PROTECTED); + phalcon_mvc_model_validationfailed_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_ValidationFailed; return SUCCESS; } +static PHP_METHOD(Phalcon_Mvc_Model_ValidationFailed, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval validationMessages; + zval *model, model_sub, *validationMessages_param = NULL, messageStr, message; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&messageStr); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&validationMessages); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ARRAY(validationMessages) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &model, &validationMessages_param); + ZEPHIR_OBS_COPY_OR_DUP(&validationMessages, validationMessages_param); + if (zephir_fast_count_int(&validationMessages) > 0) { + zephir_memory_observe(&message); + zephir_array_fetch_long(&message, &validationMessages, 0, PH_NOISY, "phalcon/Mvc/Model/ValidationFailed.zep", 48); + ZEPHIR_CALL_METHOD(&messageStr, &message, "getmessage", NULL, 0); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&messageStr); + ZVAL_STRING(&messageStr, "Validation failed"); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("model"), model); + zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), &validationMessages); + ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_validationfailed_ce, getThis(), "__construct", NULL, 0, &messageStr); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_ValidationFailed, getMessages) +{ + + RETURN_MEMBER(getThis(), "messages"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_ValidationFailed, getModel) +{ + + RETURN_MEMBER(getThis(), "model"); +} + +zend_object *zephir_init_properties_Phalcon_Mvc_Model_ValidationFailed(zend_class_entry *class_type) +{ + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("messages"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } +} + @@ -54631,4703 +56235,5846 @@ ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Exception) -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Manager) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Resultset_Complex) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Manager, phalcon, mvc_model_manager, phalcon_mvc_model_manager_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("aliases"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("behaviors"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("belongsTo"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("belongsToSingle"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("builder"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("container"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("customEventsManager"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("dynamicUpdate"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasMany"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasManySingle"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasManyToMany"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasManyToManySingle"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasOne"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasOneSingle"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasOneThrough"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("hasOneThroughSingle"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("initialized"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("keepSnapshots"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("lastInitialized"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("lastQuery"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("modelVisibility"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_model_manager_ce, SL("prefix"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("readConnectionServices"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("sources"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("schemas"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("writeConnectionServices"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_manager_ce, SL("reusable"), ZEND_ACC_PROTECTED); - phalcon_mvc_model_manager_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Manager; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Resultset, Complex, phalcon, mvc_model_resultset_complex, phalcon_mvc_model_resultset_ce, phalcon_mvc_model_resultset_complex_method_entry, 0); - zend_class_implements(phalcon_mvc_model_manager_ce, 1, phalcon_mvc_model_managerinterface_ce); - zend_class_implements(phalcon_mvc_model_manager_ce, 1, phalcon_di_injectionawareinterface_ce); - zend_class_implements(phalcon_mvc_model_manager_ce, 1, phalcon_events_eventsawareinterface_ce); + zend_declare_property_null(phalcon_mvc_model_resultset_complex_ce, SL("columnTypes"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_mvc_model_resultset_complex_ce, SL("disableHydration"), 0, ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, __destruct) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - phalcon_orm_destroy_cache(); - ZEPHIR_CALL_CE_STATIC(NULL, phalcon_mvc_model_query_ce, "clean", NULL, 0); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Manager, addBehavior) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, *behavior, behavior_sub, entityName, _0, _1$$3; + zval *columnTypes, columnTypes_sub, *result = NULL, result_sub, *cache = NULL, cache_sub, __$null; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&behavior_sub); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_OBJECT_OF_CLASS(behavior, phalcon_mvc_model_behaviorinterface_ce) + ZVAL_UNDEF(&columnTypes_sub); + ZVAL_UNDEF(&result_sub); + ZVAL_UNDEF(&cache_sub); + ZVAL_NULL(&__$null); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ZVAL(columnTypes) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(result, phalcon_db_resultinterface_ce) + Z_PARAM_ZVAL_OR_NULL(cache) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &behavior); - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("behaviors"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset(&_0, &entityName))) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_array(this_ptr, SL("behaviors"), &entityName, &_1$$3); + zephir_fetch_params(1, 1, 2, &columnTypes, &result, &cache); + if (!result) { + result = &result_sub; + result = &__$null; } - zephir_update_property_array_multi(this_ptr, SL("behaviors"), behavior, SL("za"), 2, &entityName); + if (!cache) { + cache = &cache_sub; + cache = &__$null; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("columnTypes"), columnTypes); + ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_resultset_complex_ce, getThis(), "__construct", NULL, 0, result, cache); + zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, addBelongsTo) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, current) { + zend_class_entry *_14$$16, *_29$$36; + zend_string *_5; + zend_ulong _4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval referencedModel, keyRelation; - zval *model, model_sub, *fields, fields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, entityName, referencedEntity, relation, relations, alias, lowerAlias, singleRelations, _0, _1, _2, _3; + zephir_fcall_cache_entry *_15 = NULL, *_18 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, dirtyState = 0; + zval __$true, __$false, row, hydrateMode, eager, alias, activeRow, type, column, columnValue, value, attribute, source, attributes, columnMap, rowModel, keepSnapshots, sqlAlias, modelName, _0, _1, *_2, _3, *_6$$11, _7$$11, _8$$12, _9$$13, _10$$16, _12$$16, _13$$16, _11$$17, _16$$19, _17$$19, _19$$25, _20$$25, *_21$$31, _22$$31, _23$$32, _24$$33, _25$$36, _27$$36, _28$$36, _26$$37, _30$$39, _31$$39, _32$$45, _33$$45; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&fields_sub); - ZVAL_UNDEF(&referencedFields_sub); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&referencedEntity); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&relations); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&row); + ZVAL_UNDEF(&hydrateMode); + ZVAL_UNDEF(&eager); ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&lowerAlias); - ZVAL_UNDEF(&singleRelations); + ZVAL_UNDEF(&activeRow); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&column); + ZVAL_UNDEF(&columnValue); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&columnMap); + ZVAL_UNDEF(&rowModel); + ZVAL_UNDEF(&keepSnapshots); + ZVAL_UNDEF(&sqlAlias); + ZVAL_UNDEF(&modelName); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&referencedModel); - ZVAL_UNDEF(&keyRelation); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(4, 5) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ZVAL(fields) - Z_PARAM_STR(referencedModel) - Z_PARAM_ZVAL(referencedFields) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_7$$11); + ZVAL_UNDEF(&_8$$12); + ZVAL_UNDEF(&_9$$13); + ZVAL_UNDEF(&_10$$16); + ZVAL_UNDEF(&_12$$16); + ZVAL_UNDEF(&_13$$16); + ZVAL_UNDEF(&_11$$17); + ZVAL_UNDEF(&_16$$19); + ZVAL_UNDEF(&_17$$19); + ZVAL_UNDEF(&_19$$25); + ZVAL_UNDEF(&_20$$25); + ZVAL_UNDEF(&_22$$31); + ZVAL_UNDEF(&_23$$32); + ZVAL_UNDEF(&_24$$33); + ZVAL_UNDEF(&_25$$36); + ZVAL_UNDEF(&_27$$36); + ZVAL_UNDEF(&_28$$36); + ZVAL_UNDEF(&_26$$37); + ZVAL_UNDEF(&_30$$39); + ZVAL_UNDEF(&_31$$39); + ZVAL_UNDEF(&_32$$45); + ZVAL_UNDEF(&_33$$45); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 1, &model, &fields, &referencedModel_param, &referencedFields, &options_param); - if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) { - zephir_get_strval(&referencedModel, referencedModel_param); - } else { - ZEPHIR_INIT_VAR(&referencedModel); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("activeRow"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&activeRow, &_0); + if (Z_TYPE_P(&activeRow) != IS_NULL) { + RETURN_CCTOR(&activeRow); } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("row"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&row, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("disableHydration"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &row); + RETURN_CCTOR(&row); } - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 1); - ZEPHIR_INIT_VAR(&referencedEntity); - zephir_fast_strtolower(&referencedEntity, &referencedModel); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity); - zephir_get_strval(&keyRelation, &_0); - zephir_memory_observe(&relations); - zephir_read_property(&_1, this_ptr, ZEND_STRL("belongsTo"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&relations, &_1, &keyRelation, 0))) { - ZEPHIR_INIT_NVAR(&relations); - array_init(&relations); - } - if (Z_TYPE_P(referencedFields) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(referencedFields))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 296); - return; + if (Z_TYPE_P(&row) != IS_ARRAY) { + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &__$false); } + RETURN_MM_BOOL(0); } - ZEPHIR_INIT_VAR(&relation); - object_init_ex(&relation, phalcon_mvc_model_relation_ce); - ZVAL_LONG(&_2, 0); - ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 441, &_2, &referencedModel, fields, referencedFields, &options); - zephir_check_call_status(); - zephir_memory_observe(&alias); - if (zephir_array_isset_string_fetch(&alias, &options, SL("alias"), 0)) { - if (UNEXPECTED(Z_TYPE_P(&alias) != IS_STRING)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 316); - return; + zephir_read_property(&_1, this_ptr, ZEND_STRL("hydrateMode"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&hydrateMode, &_1); + do { + if (ZEPHIR_IS_LONG(&hydrateMode, 0)) { + ZEPHIR_INIT_NVAR(&activeRow); + object_init_ex(&activeRow, phalcon_mvc_model_row_ce); + if (zephir_has_constructor(&activeRow)) { + ZEPHIR_CALL_METHOD(NULL, &activeRow, "__construct", NULL, 0); + zephir_check_call_status(); + } + + break; } - ZEPHIR_INIT_VAR(&lowerAlias); - zephir_fast_strtolower(&lowerAlias, &alias); + if (ZEPHIR_IS_LONG(&hydrateMode, 1)) { + ZEPHIR_INIT_NVAR(&activeRow); + array_init(&activeRow); + break; + } + ZEPHIR_INIT_NVAR(&activeRow); + object_init(&activeRow); + break; + } while(0); + + dirtyState = 0; + zephir_read_property(&_1, this_ptr, ZEND_STRL("columnTypes"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_1, 0, "phalcon/Mvc/Model/Resultset/Complex.zep", 262); + if (Z_TYPE_P(&_1) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_1), _4, _5, _2) + { + ZEPHIR_INIT_NVAR(&alias); + if (_5 != NULL) { + ZVAL_STR_COPY(&alias, _5); + } else { + ZVAL_LONG(&alias, _4); + } + ZEPHIR_INIT_NVAR(&column); + ZVAL_COPY(&column, _2); + if (UNEXPECTED(Z_TYPE_P(&column) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Column type is corrupt", "phalcon/Mvc/Model/Resultset/Complex.zep", 141); + return; + } + ZEPHIR_OBS_NVAR(&type); + zephir_array_fetch_string(&type, &column, SL("type"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 144); + if (ZEPHIR_IS_STRING(&type, "object")) { + ZEPHIR_OBS_NVAR(&source); + zephir_array_fetch_string(&source, &column, SL("column"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 150); + ZEPHIR_OBS_NVAR(&attributes); + zephir_array_fetch_string(&attributes, &column, SL("attributes"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 151); + ZEPHIR_OBS_NVAR(&columnMap); + zephir_array_fetch_string(&columnMap, &column, SL("columnMap"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 152); + ZEPHIR_INIT_NVAR(&rowModel); + array_init(&rowModel); + zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model/Resultset/Complex.zep", 170); + if (Z_TYPE_P(&attributes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _6$$11) + { + ZEPHIR_INIT_NVAR(&attribute); + ZVAL_COPY(&attribute, _6$$11); + ZEPHIR_OBS_NVAR(&columnValue); + ZEPHIR_INIT_NVAR(&_8$$12); + ZEPHIR_CONCAT_SVSV(&_8$$12, "_", &source, "_", &attribute); + zephir_array_fetch(&columnValue, &row, &_8$$12, PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 163); + zephir_array_update_zval(&rowModel, &attribute, &columnValue, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_7$$11, &attributes, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_7$$11)) { + break; + } + ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&columnValue); + ZEPHIR_INIT_NVAR(&_9$$13); + ZEPHIR_CONCAT_SVSV(&_9$$13, "_", &source, "_", &attribute); + zephir_array_fetch(&columnValue, &row, &_9$$13, PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 163); + zephir_array_update_zval(&rowModel, &attribute, &columnValue, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&attribute); + do { + if (ZEPHIR_IS_LONG(&hydrateMode, 0)) { + ZEPHIR_OBS_NVAR(&keepSnapshots); + if (!(zephir_array_isset_string_fetch(&keepSnapshots, &column, SL("keepSnapshots"), 0))) { + ZEPHIR_INIT_NVAR(&keepSnapshots); + ZVAL_BOOL(&keepSnapshots, 0); + } + if (ZEPHIR_GLOBAL(orm).late_state_binding) { + ZEPHIR_OBS_NVAR(&_10$$16); + zephir_array_fetch_string(&_10$$16, &column, SL("instance"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 178); + if (zephir_instance_of_ev(&_10$$16, phalcon_mvc_model_ce)) { + zephir_array_fetch_string(&_11$$17, &column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 179); + ZEPHIR_INIT_NVAR(&modelName); + zephir_get_class(&modelName, &_11$$17, 0); + } else { + ZEPHIR_INIT_NVAR(&modelName); + ZVAL_STRING(&modelName, "Phalcon\\Mvc\\Model"); + } + zephir_array_fetch_string(&_12$$16, &column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 185); + ZVAL_LONG(&_13$$16, dirtyState); + _14$$16 = zephir_fetch_class(&modelName); + ZEPHIR_CALL_CE_STATIC(&value, _14$$16, "cloneresultmap", NULL, 0, &_12$$16, &rowModel, &columnMap, &_13$$16, &keepSnapshots); + zephir_check_call_status(); + } else { + zephir_array_fetch_string(&_16$$19, &column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 197); + ZVAL_LONG(&_17$$19, dirtyState); + ZEPHIR_CALL_CE_STATIC(&value, phalcon_mvc_model_ce, "cloneresultmap", &_15, 0, &_16$$19, &rowModel, &columnMap, &_17$$19, &keepSnapshots); + zephir_check_call_status(); + } + break; + } + ZEPHIR_CALL_CE_STATIC(&value, phalcon_mvc_model_ce, "cloneresultmaphydrate", &_18, 0, &rowModel, &columnMap, &hydrateMode); + zephir_check_call_status(); + break; + } while(0); + + ZEPHIR_OBS_NVAR(&attribute); + zephir_array_fetch_string(&attribute, &column, SL("balias"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 221); + } else { + ZEPHIR_OBS_NVAR(&sqlAlias); + if (zephir_array_isset_string_fetch(&sqlAlias, &column, SL("sqlAlias"), 0)) { + ZEPHIR_OBS_NVAR(&value); + zephir_array_fetch(&value, &row, &sqlAlias, PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 227); + } else { + ZEPHIR_OBS_NVAR(&value); + zephir_array_isset_fetch(&value, &row, &alias, 0); + } + if (zephir_array_isset_string(&column, SL("balias"))) { + ZEPHIR_CPY_WRT(&attribute, &alias); + } else { + ZEPHIR_INIT_NVAR(&_19$$25); + ZVAL_STRING(&_19$$25, "_"); + ZEPHIR_INIT_NVAR(&_20$$25); + ZVAL_STRING(&_20$$25, ""); + ZEPHIR_INIT_NVAR(&attribute); + zephir_fast_str_replace(&attribute, &_19$$25, &_20$$25, &alias); + } + } + if (!(zephir_array_isset_string_fetch(&eager, &column, SL("eager"), 1))) { + do { + if (ZEPHIR_IS_LONG(&hydrateMode, 1)) { + zephir_array_update_zval(&activeRow, &attribute, &value, PH_COPY | PH_SEPARATE); + break; + } + zephir_update_property_zval_zval(&activeRow, &attribute, &value); + break; + } while(0); + + } + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity); - } - zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 329); - ZEPHIR_INIT_VAR(&_3); - ZEPHIR_CONCAT_VSV(&_3, &entityName, "$", &lowerAlias); - zephir_update_property_array(this_ptr, SL("aliases"), &_3, &relation); - zephir_update_property_array(this_ptr, SL("belongsTo"), &keyRelation, &relations); - zephir_memory_observe(&singleRelations); - zephir_read_property(&_2, this_ptr, ZEND_STRL("belongsToSingle"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&singleRelations, &_2, &entityName, 0))) { - ZEPHIR_INIT_NVAR(&singleRelations); - array_init(&singleRelations); + ZEPHIR_CALL_METHOD(NULL, &_1, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &_1, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&alias, &_1, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&column, &_1, "current", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&column) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Column type is corrupt", "phalcon/Mvc/Model/Resultset/Complex.zep", 141); + return; + } + ZEPHIR_OBS_NVAR(&type); + zephir_array_fetch_string(&type, &column, SL("type"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 144); + if (ZEPHIR_IS_STRING(&type, "object")) { + ZEPHIR_OBS_NVAR(&source); + zephir_array_fetch_string(&source, &column, SL("column"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 150); + ZEPHIR_OBS_NVAR(&attributes); + zephir_array_fetch_string(&attributes, &column, SL("attributes"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 151); + ZEPHIR_OBS_NVAR(&columnMap); + zephir_array_fetch_string(&columnMap, &column, SL("columnMap"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 152); + ZEPHIR_INIT_NVAR(&rowModel); + array_init(&rowModel); + zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model/Resultset/Complex.zep", 170); + if (Z_TYPE_P(&attributes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _21$$31) + { + ZEPHIR_INIT_NVAR(&attribute); + ZVAL_COPY(&attribute, _21$$31); + ZEPHIR_OBS_NVAR(&columnValue); + ZEPHIR_INIT_NVAR(&_23$$32); + ZEPHIR_CONCAT_SVSV(&_23$$32, "_", &source, "_", &attribute); + zephir_array_fetch(&columnValue, &row, &_23$$32, PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 163); + zephir_array_update_zval(&rowModel, &attribute, &columnValue, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_22$$31, &attributes, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_22$$31)) { + break; + } + ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&columnValue); + ZEPHIR_INIT_NVAR(&_24$$33); + ZEPHIR_CONCAT_SVSV(&_24$$33, "_", &source, "_", &attribute); + zephir_array_fetch(&columnValue, &row, &_24$$33, PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 163); + zephir_array_update_zval(&rowModel, &attribute, &columnValue, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&attribute); + do { + if (ZEPHIR_IS_LONG(&hydrateMode, 0)) { + ZEPHIR_OBS_NVAR(&keepSnapshots); + if (!(zephir_array_isset_string_fetch(&keepSnapshots, &column, SL("keepSnapshots"), 0))) { + ZEPHIR_INIT_NVAR(&keepSnapshots); + ZVAL_BOOL(&keepSnapshots, 0); + } + if (ZEPHIR_GLOBAL(orm).late_state_binding) { + ZEPHIR_OBS_NVAR(&_25$$36); + zephir_array_fetch_string(&_25$$36, &column, SL("instance"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 178); + if (zephir_instance_of_ev(&_25$$36, phalcon_mvc_model_ce)) { + zephir_array_fetch_string(&_26$$37, &column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 179); + ZEPHIR_INIT_NVAR(&modelName); + zephir_get_class(&modelName, &_26$$37, 0); + } else { + ZEPHIR_INIT_NVAR(&modelName); + ZVAL_STRING(&modelName, "Phalcon\\Mvc\\Model"); + } + zephir_array_fetch_string(&_27$$36, &column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 185); + ZVAL_LONG(&_28$$36, dirtyState); + _29$$36 = zephir_fetch_class(&modelName); + ZEPHIR_CALL_CE_STATIC(&value, _29$$36, "cloneresultmap", NULL, 0, &_27$$36, &rowModel, &columnMap, &_28$$36, &keepSnapshots); + zephir_check_call_status(); + } else { + zephir_array_fetch_string(&_30$$39, &column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 197); + ZVAL_LONG(&_31$$39, dirtyState); + ZEPHIR_CALL_CE_STATIC(&value, phalcon_mvc_model_ce, "cloneresultmap", &_15, 0, &_30$$39, &rowModel, &columnMap, &_31$$39, &keepSnapshots); + zephir_check_call_status(); + } + break; + } + ZEPHIR_CALL_CE_STATIC(&value, phalcon_mvc_model_ce, "cloneresultmaphydrate", &_18, 0, &rowModel, &columnMap, &hydrateMode); + zephir_check_call_status(); + break; + } while(0); + + ZEPHIR_OBS_NVAR(&attribute); + zephir_array_fetch_string(&attribute, &column, SL("balias"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 221); + } else { + ZEPHIR_OBS_NVAR(&sqlAlias); + if (zephir_array_isset_string_fetch(&sqlAlias, &column, SL("sqlAlias"), 0)) { + ZEPHIR_OBS_NVAR(&value); + zephir_array_fetch(&value, &row, &sqlAlias, PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 227); + } else { + ZEPHIR_OBS_NVAR(&value); + zephir_array_isset_fetch(&value, &row, &alias, 0); + } + if (zephir_array_isset_string(&column, SL("balias"))) { + ZEPHIR_CPY_WRT(&attribute, &alias); + } else { + ZEPHIR_INIT_NVAR(&_32$$45); + ZVAL_STRING(&_32$$45, "_"); + ZEPHIR_INIT_NVAR(&_33$$45); + ZVAL_STRING(&_33$$45, ""); + ZEPHIR_INIT_NVAR(&attribute); + zephir_fast_str_replace(&attribute, &_32$$45, &_33$$45, &alias); + } + } + ZEPHIR_OBS_NVAR(&eager); + if (!(zephir_array_isset_string_fetch(&eager, &column, SL("eager"), 0))) { + do { + if (ZEPHIR_IS_LONG(&hydrateMode, 1)) { + zephir_array_update_zval(&activeRow, &attribute, &value, PH_COPY | PH_SEPARATE); + break; + } + zephir_update_property_zval_zval(&activeRow, &attribute, &value); + break; + } while(0); + + } + ZEPHIR_CALL_METHOD(NULL, &_1, "next", NULL, 0); + zephir_check_call_status(); + } } - zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 343); - zephir_update_property_array(this_ptr, SL("belongsToSingle"), &entityName, &singleRelations); - RETURN_CCTOR(&relation); + ZEPHIR_INIT_NVAR(&column); + ZEPHIR_INIT_NVAR(&alias); + zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &activeRow); + RETURN_CCTOR(&activeRow); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasMany) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, toArray) { + zval records; + zval current, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_3 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval referencedModel, keyRelation; - zval *model, model_sub, *fields, fields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, entityName, referencedEntity, hasMany, relation, relations, alias, lowerAlias, singleRelations, _0, _1, _2; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&fields_sub); - ZVAL_UNDEF(&referencedFields_sub); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&referencedEntity); - ZVAL_UNDEF(&hasMany); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&lowerAlias); - ZVAL_UNDEF(&singleRelations); + ZVAL_UNDEF(¤t); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&referencedModel); - ZVAL_UNDEF(&keyRelation); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(4, 5) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ZVAL(fields) - Z_PARAM_STR(referencedModel) - Z_PARAM_ZVAL(referencedFields) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&records); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 1, &model, &fields, &referencedModel_param, &referencedFields, &options_param); - if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) { - zephir_get_strval(&referencedModel, referencedModel_param); - } else { - ZEPHIR_INIT_VAR(&referencedModel); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 1); - ZEPHIR_INIT_VAR(&referencedEntity); - zephir_fast_strtolower(&referencedEntity, &referencedModel); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity); - zephir_get_strval(&keyRelation, &_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&hasMany, &_1); - zephir_memory_observe(&relations); - if (!(zephir_array_isset_fetch(&relations, &hasMany, &keyRelation, 0))) { - ZEPHIR_INIT_NVAR(&relations); - array_init(&relations); - } - if (Z_TYPE_P(referencedFields) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(referencedFields))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 392); - return; - } - } - ZEPHIR_INIT_VAR(&relation); - object_init_ex(&relation, phalcon_mvc_model_relation_ce); - ZVAL_LONG(&_1, 2); - ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 441, &_1, &referencedModel, fields, referencedFields, &options); + + ZEPHIR_INIT_VAR(&records); + array_init(&records); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "rewind", NULL, 92); zephir_check_call_status(); - zephir_memory_observe(&alias); - if (zephir_array_isset_string_fetch(&alias, &options, SL("alias"), 0)) { - if (UNEXPECTED(Z_TYPE_P(&alias) != IS_STRING)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 412); - return; + while (1) { + ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", &_1, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&_0))) { + break; } - ZEPHIR_INIT_VAR(&lowerAlias); - zephir_fast_strtolower(&lowerAlias, &alias); - } else { - ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity); - } - zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 425); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VSV(&_2, &entityName, "$", &lowerAlias); - zephir_update_property_array(this_ptr, SL("aliases"), &_2, &relation); - zephir_update_property_array(this_ptr, SL("hasMany"), &keyRelation, &relations); - zephir_memory_observe(&singleRelations); - zephir_read_property(&_1, this_ptr, ZEND_STRL("hasManySingle"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&singleRelations, &_1, &entityName, 0))) { - ZEPHIR_INIT_NVAR(&singleRelations); - array_init(&singleRelations); + ZEPHIR_CALL_METHOD(¤t, this_ptr, "current", &_2, 480); + zephir_check_call_status(); + zephir_array_append(&records, ¤t, PH_SEPARATE, "phalcon/Mvc/Model/Resultset/Complex.zep", 282); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_3, 0); + zephir_check_call_status(); } - zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 439); - zephir_update_property_array(this_ptr, SL("hasManySingle"), &entityName, &singleRelations); - RETURN_CCTOR(&relation); + RETURN_CTOR(&records); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasManyToMany) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, serialize) { + zval data; + zval container, serializer, _0, _1, _2, _3$$4, _4$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval intermediateModel, referencedModel, keyRelation; - zval *model, model_sub, *fields, fields_sub, *intermediateModel_param = NULL, *intermediateFields, intermediateFields_sub, *intermediateReferencedFields, intermediateReferencedFields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, entityName, referencedEntity, hasManyToMany, relation, relations, alias, lowerAlias, singleRelations, intermediateEntity, _0, _1, _2; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&fields_sub); - ZVAL_UNDEF(&intermediateFields_sub); - ZVAL_UNDEF(&intermediateReferencedFields_sub); - ZVAL_UNDEF(&referencedFields_sub); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&referencedEntity); - ZVAL_UNDEF(&hasManyToMany); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&lowerAlias); - ZVAL_UNDEF(&singleRelations); - ZVAL_UNDEF(&intermediateEntity); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&serializer); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&intermediateModel); - ZVAL_UNDEF(&referencedModel); - ZVAL_UNDEF(&keyRelation); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(7, 8) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ZVAL(fields) - Z_PARAM_STR(intermediateModel) - Z_PARAM_ZVAL(intermediateFields) - Z_PARAM_ZVAL(intermediateReferencedFields) - Z_PARAM_STR(referencedModel) - Z_PARAM_ZVAL(referencedFields) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&data); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 7, 1, &model, &fields, &intermediateModel_param, &intermediateFields, &intermediateReferencedFields, &referencedModel_param, &referencedFields, &options_param); - if (UNEXPECTED(Z_TYPE_P(intermediateModel_param) != IS_STRING && Z_TYPE_P(intermediateModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'intermediateModel' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(intermediateModel_param) == IS_STRING)) { - zephir_get_strval(&intermediateModel, intermediateModel_param); - } else { - ZEPHIR_INIT_VAR(&intermediateModel); - } - if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) { - zephir_get_strval(&referencedModel, referencedModel_param); - } else { - ZEPHIR_INIT_VAR(&referencedModel); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 1); - ZEPHIR_INIT_VAR(&intermediateEntity); - zephir_fast_strtolower(&intermediateEntity, &intermediateModel); - ZEPHIR_INIT_VAR(&referencedEntity); - zephir_fast_strtolower(&referencedEntity, &referencedModel); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity); - zephir_get_strval(&keyRelation, &_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("hasManyToMany"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&hasManyToMany, &_1); - zephir_memory_observe(&relations); - if (!(zephir_array_isset_fetch(&relations, &hasManyToMany, &keyRelation, 0))) { - ZEPHIR_INIT_NVAR(&relations); - array_init(&relations); - } - if (Z_TYPE_P(intermediateFields) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(intermediateFields))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 496); - return; - } - } - if (Z_TYPE_P(intermediateReferencedFields) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(intermediateFields))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 508); - return; - } - } - ZEPHIR_INIT_VAR(&relation); - object_init_ex(&relation, phalcon_mvc_model_relation_ce); - ZVAL_LONG(&_1, 4); - ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 441, &_1, &referencedModel, fields, referencedFields, &options); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &relation, "setintermediaterelation", NULL, 442, intermediateFields, &intermediateModel, intermediateReferencedFields); + + ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); zephir_check_call_status(); - zephir_memory_observe(&alias); - if (zephir_array_isset_string_fetch(&alias, &options, SL("alias"), 0)) { - if (Z_TYPE_P(&alias) != IS_STRING) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 537); - return; - } - ZEPHIR_INIT_VAR(&lowerAlias); - zephir_fast_strtolower(&lowerAlias, &alias); - } else { - ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The dependency injector container is not valid", "phalcon/Mvc/Model/Resultset/Complex.zep", 303); + return; } - zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 548); + ZEPHIR_INIT_VAR(&data); + zephir_create_array(&data, 4, 0); + zephir_memory_observe(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC); + zephir_array_update_string(&data, SL("cache"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "toarray", NULL, 0); + zephir_check_call_status(); + zephir_array_update_string(&data, SL("rows"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("columnTypes"), PH_NOISY_CC); + zephir_array_update_string(&data, SL("columnTypes"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("hydrateMode"), PH_NOISY_CC); + zephir_array_update_string(&data, SL("hydrateMode"), &_0, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VSV(&_2, &entityName, "$", &lowerAlias); - zephir_update_property_array(this_ptr, SL("aliases"), &_2, &relation); - zephir_update_property_array(this_ptr, SL("hasManyToMany"), &keyRelation, &relations); - zephir_memory_observe(&singleRelations); - zephir_read_property(&_1, this_ptr, ZEND_STRL("hasManyToManySingle"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&singleRelations, &_1, &entityName, 0))) { - ZEPHIR_INIT_NVAR(&singleRelations); - array_init(&singleRelations); + ZVAL_STRING(&_2, "serializer"); + ZEPHIR_CALL_METHOD(&_1, &container, "has", NULL, 0, &_2); + zephir_check_call_status(); + if (zephir_is_true(&_1)) { + ZEPHIR_INIT_VAR(&_4$$4); + ZVAL_STRING(&_4$$4, "serializer"); + ZEPHIR_CALL_METHOD(&_3$$4, &container, "getshared", NULL, 0, &_4$$4); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&serializer, &_3$$4); + ZEPHIR_CALL_METHOD(NULL, &serializer, "setdata", NULL, 0, &data); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(&serializer, "serialize", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } - zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 570); - zephir_update_property_array(this_ptr, SL("hasManyToManySingle"), &entityName, &singleRelations); - RETURN_CCTOR(&relation); + ZEPHIR_RETURN_CALL_FUNCTION("serialize", NULL, 15, &data); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasOne) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, unserialize) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval referencedModel, keyRelation; - zval *model, model_sub, *fields, fields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, entityName, referencedEntity, relation, relations, alias, lowerAlias, singleRelations, _0, _1, _2, _3; + zval *data, data_sub, __$true, __$false, resultset, container, serializer, _0, _1, _4, _5, _6, _7, _8, _9, _2$$4, _3$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&fields_sub); - ZVAL_UNDEF(&referencedFields_sub); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&referencedEntity); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&lowerAlias); - ZVAL_UNDEF(&singleRelations); + ZVAL_UNDEF(&data_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&resultset); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&serializer); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&referencedModel); - ZVAL_UNDEF(&keyRelation); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(4, 5) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ZVAL(fields) - Z_PARAM_STR(referencedModel) - Z_PARAM_ZVAL(referencedFields) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(data) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 1, &model, &fields, &referencedModel_param, &referencedFields, &options_param); - if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) { - zephir_get_strval(&referencedModel, referencedModel_param); - } else { - ZEPHIR_INIT_VAR(&referencedModel); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); + zephir_fetch_params(1, 1, 0, &data); + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("disableHydration"), &__$true); } else { - zephir_get_arrval(&options, options_param); - } - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 1); - ZEPHIR_INIT_VAR(&referencedEntity); - zephir_fast_strtolower(&referencedEntity, &referencedModel); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity); - zephir_get_strval(&keyRelation, &_0); - zephir_memory_observe(&relations); - zephir_read_property(&_1, this_ptr, ZEND_STRL("hasOne"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&relations, &_1, &keyRelation, 0))) { - ZEPHIR_INIT_NVAR(&relations); - array_init(&relations); + zephir_update_property_zval(this_ptr, ZEND_STRL("disableHydration"), &__$false); } - if (Z_TYPE_P(referencedFields) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(referencedFields))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 618); - return; - } + ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The dependency injector container is not valid", "phalcon/Mvc/Model/Resultset/Complex.zep", 339); + return; } - ZEPHIR_INIT_VAR(&relation); - object_init_ex(&relation, phalcon_mvc_model_relation_ce); - ZVAL_LONG(&_2, 1); - ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 441, &_2, &referencedModel, fields, referencedFields, &options); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "serializer"); + ZEPHIR_CALL_METHOD(&_0, &container, "has", NULL, 0, &_1); zephir_check_call_status(); - zephir_memory_observe(&alias); - if (zephir_array_isset_string_fetch(&alias, &options, SL("alias"), 0)) { - if (UNEXPECTED(Z_TYPE_P(&alias) != IS_STRING)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 638); - return; - } - ZEPHIR_INIT_VAR(&lowerAlias); - zephir_fast_strtolower(&lowerAlias, &alias); + if (zephir_is_true(&_0)) { + ZEPHIR_INIT_VAR(&_3$$4); + ZVAL_STRING(&_3$$4, "serializer"); + ZEPHIR_CALL_METHOD(&_2$$4, &container, "getshared", NULL, 0, &_3$$4); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&serializer, &_2$$4); + ZEPHIR_CALL_METHOD(NULL, &serializer, "unserialize", NULL, 0, data); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&resultset, &serializer, "getdata", NULL, 0); + zephir_check_call_status(); } else { - ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity); + ZEPHIR_CALL_FUNCTION(&resultset, "unserialize", NULL, 16, data); + zephir_check_call_status(); } - zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 651); - ZEPHIR_INIT_VAR(&_3); - ZEPHIR_CONCAT_VSV(&_3, &entityName, "$", &lowerAlias); - zephir_update_property_array(this_ptr, SL("aliases"), &_3, &relation); - zephir_update_property_array(this_ptr, SL("hasOne"), &keyRelation, &relations); - zephir_memory_observe(&singleRelations); - zephir_read_property(&_2, this_ptr, ZEND_STRL("hasOneSingle"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&singleRelations, &_2, &entityName, 0))) { - ZEPHIR_INIT_NVAR(&singleRelations); - array_init(&singleRelations); + if (UNEXPECTED(Z_TYPE_P(&resultset) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid serialization data", "phalcon/Mvc/Model/Resultset/Complex.zep", 352); + return; } - zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 665); - zephir_update_property_array(this_ptr, SL("hasOneSingle"), &entityName, &singleRelations); - RETURN_CCTOR(&relation); + zephir_array_fetch_string(&_4, &resultset, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 355); + zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_4); + zephir_array_fetch_string(&_5, &resultset, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 356); + ZVAL_UNDEF(&_6); + ZVAL_LONG(&_6, zephir_fast_count_int(&_5)); + zephir_update_property_zval(this_ptr, ZEND_STRL("count"), &_6); + zephir_array_fetch_string(&_7, &resultset, SL("cache"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 357); + zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), &_7); + zephir_array_fetch_string(&_8, &resultset, SL("columnTypes"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 358); + zephir_update_property_zval(this_ptr, ZEND_STRL("columnTypes"), &_8); + zephir_array_fetch_string(&_9, &resultset, SL("hydrateMode"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 359); + zephir_update_property_zval(this_ptr, ZEND_STRL("hydrateMode"), &_9); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, addHasOneThrough) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, __serialize) { + zval records, cache, columnTypes, hydrateMode, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval intermediateModel, referencedModel, keyRelation; - zval *model, model_sub, *fields, fields_sub, *intermediateModel_param = NULL, *intermediateFields, intermediateFields_sub, *intermediateReferencedFields, intermediateReferencedFields_sub, *referencedModel_param = NULL, *referencedFields, referencedFields_sub, *options_param = NULL, entityName, referencedEntity, hasOneThrough, relation, relations, alias, lowerAlias, singleRelations, intermediateEntity, _0, _1, _2; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&fields_sub); - ZVAL_UNDEF(&intermediateFields_sub); - ZVAL_UNDEF(&intermediateReferencedFields_sub); - ZVAL_UNDEF(&referencedFields_sub); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&referencedEntity); - ZVAL_UNDEF(&hasOneThrough); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&lowerAlias); - ZVAL_UNDEF(&singleRelations); - ZVAL_UNDEF(&intermediateEntity); + ZVAL_UNDEF(&records); + ZVAL_UNDEF(&cache); + ZVAL_UNDEF(&columnTypes); + ZVAL_UNDEF(&hydrateMode); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&intermediateModel); - ZVAL_UNDEF(&referencedModel); - ZVAL_UNDEF(&keyRelation); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(7, 8) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ZVAL(fields) - Z_PARAM_STR(intermediateModel) - Z_PARAM_ZVAL(intermediateFields) - Z_PARAM_ZVAL(intermediateReferencedFields) - Z_PARAM_STR(referencedModel) - Z_PARAM_ZVAL(referencedFields) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 7, 1, &model, &fields, &intermediateModel_param, &intermediateFields, &intermediateReferencedFields, &referencedModel_param, &referencedFields, &options_param); - if (UNEXPECTED(Z_TYPE_P(intermediateModel_param) != IS_STRING && Z_TYPE_P(intermediateModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'intermediateModel' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(intermediateModel_param) == IS_STRING)) { - zephir_get_strval(&intermediateModel, intermediateModel_param); - } else { - ZEPHIR_INIT_VAR(&intermediateModel); - } - if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) { - zephir_get_strval(&referencedModel, referencedModel_param); - } else { - ZEPHIR_INIT_VAR(&referencedModel); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 1); - ZEPHIR_INIT_VAR(&intermediateEntity); - zephir_fast_strtolower(&intermediateEntity, &intermediateModel); - ZEPHIR_INIT_VAR(&referencedEntity); - zephir_fast_strtolower(&referencedEntity, &referencedModel); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_CONCAT_VSV(&_0, &entityName, "$", &referencedEntity); - zephir_get_strval(&keyRelation, &_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("hasOneThrough"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&hasOneThrough, &_1); - zephir_memory_observe(&relations); - if (!(zephir_array_isset_fetch(&relations, &hasOneThrough, &keyRelation, 0))) { - ZEPHIR_INIT_NVAR(&relations); - array_init(&relations); - } - if (Z_TYPE_P(intermediateFields) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(intermediateFields))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 722); - return; - } - } - if (Z_TYPE_P(intermediateReferencedFields) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(fields) != zephir_fast_count_int(intermediateFields))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Number of referenced fields are not the same", "phalcon/Mvc/Model/Manager.zep", 734); - return; - } - } - ZEPHIR_INIT_VAR(&relation); - object_init_ex(&relation, phalcon_mvc_model_relation_ce); - ZVAL_LONG(&_1, 3); - ZEPHIR_CALL_METHOD(NULL, &relation, "__construct", NULL, 441, &_1, &referencedModel, fields, referencedFields, &options); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &relation, "setintermediaterelation", NULL, 442, intermediateFields, &intermediateModel, intermediateReferencedFields); + + ZEPHIR_CALL_METHOD(&records, this_ptr, "toarray", NULL, 0); zephir_check_call_status(); - zephir_memory_observe(&alias); - if (zephir_array_isset_string_fetch(&alias, &options, SL("alias"), 0)) { - if (Z_TYPE_P(&alias) != IS_STRING) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Relation alias must be a string", "phalcon/Mvc/Model/Manager.zep", 763); - return; - } - ZEPHIR_INIT_VAR(&lowerAlias); - zephir_fast_strtolower(&lowerAlias, &alias); - } else { - ZEPHIR_CPY_WRT(&lowerAlias, &referencedEntity); - } - zephir_array_append(&relations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 774); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VSV(&_2, &entityName, "$", &lowerAlias); - zephir_update_property_array(this_ptr, SL("aliases"), &_2, &relation); - zephir_update_property_array(this_ptr, SL("hasOneThrough"), &keyRelation, &relations); - zephir_memory_observe(&singleRelations); - zephir_read_property(&_1, this_ptr, ZEND_STRL("hasOneThroughSingle"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&singleRelations, &_1, &entityName, 0))) { - ZEPHIR_INIT_NVAR(&singleRelations); - array_init(&singleRelations); - } - zephir_array_append(&singleRelations, &relation, PH_SEPARATE, "phalcon/Mvc/Model/Manager.zep", 796); - zephir_update_property_array(this_ptr, SL("hasOneThroughSingle"), &entityName, &singleRelations); - RETURN_CCTOR(&relation); + zephir_read_property(&_0, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&cache, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("columnTypes"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&columnTypes, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("hydrateMode"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&hydrateMode, &_0); + zephir_create_array(return_value, 4, 0); + zephir_array_update_string(return_value, SL("cache"), &cache, PH_COPY | PH_SEPARATE); + zephir_array_update_string(return_value, SL("rows"), &records, PH_COPY | PH_SEPARATE); + zephir_array_update_string(return_value, SL("columnTypes"), &columnTypes, PH_COPY | PH_SEPARATE); + zephir_array_update_string(return_value, SL("hydrateMode"), &hydrateMode, PH_COPY | PH_SEPARATE); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, clearReusableObjects) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, __unserialize) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *data_param = NULL, __$true, __$false, _0, _1, _2, _3, _4, _5; + zval data; zval *this_ptr = getThis(); + ZVAL_UNDEF(&data); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(data) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("reusable"), &_0); + zephir_fetch_params(1, 1, 0, &data_param); + zephir_get_arrval(&data, data_param); + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("disableHydration"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("disableHydration"), &__$false); + } + zephir_array_fetch_string(&_0, &data, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 390); + zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_0); + zephir_array_fetch_string(&_1, &data, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 391); + ZVAL_UNDEF(&_2); + ZVAL_LONG(&_2, zephir_fast_count_int(&_1)); + zephir_update_property_zval(this_ptr, ZEND_STRL("count"), &_2); + zephir_array_fetch_string(&_3, &data, SL("cache"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 392); + zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), &_3); + zephir_array_fetch_string(&_4, &data, SL("columnTypes"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 393); + zephir_update_property_zval(this_ptr, ZEND_STRL("columnTypes"), &_4); + zephir_array_fetch_string(&_5, &data, SL("hydrateMode"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 394); + zephir_update_property_zval(this_ptr, ZEND_STRL("hydrateMode"), &_5); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, createBuilder) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Resultset_Simple) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Resultset, Simple, phalcon, mvc_model_resultset_simple, phalcon_mvc_model_resultset_ce, phalcon_mvc_model_resultset_simple_method_entry, 0); + + zend_declare_property_null(phalcon_mvc_model_resultset_simple_ce, SL("columnMap"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_resultset_simple_ce, SL("model"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_mvc_model_resultset_simple_ce, SL("keepSnapshots"), 0, ZEND_ACC_PROTECTED); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, __construct) { - zval _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *params = NULL, params_sub, __$null, container, _0, _1, _3; + zend_bool keepSnapshots; + zval *columnMap, columnMap_sub, *model, model_sub, *result, result_sub, *cache = NULL, cache_sub, *keepSnapshots_param = NULL, __$true, __$false, __$null; zval *this_ptr = getThis(); - ZVAL_UNDEF(¶ms_sub); + ZVAL_UNDEF(&columnMap_sub); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&result_sub); + ZVAL_UNDEF(&cache_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_2); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) + ZEND_PARSE_PARAMETERS_START(3, 5) + Z_PARAM_ZVAL(columnMap) + Z_PARAM_ZVAL(model) + Z_PARAM_ZVAL(result) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(params) + Z_PARAM_ZVAL_OR_NULL(cache) + Z_PARAM_BOOL(keepSnapshots) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, ¶ms); - if (!params) { - params = ¶ms_sub; - params = &__$null; + zephir_fetch_params(1, 3, 2, &columnMap, &model, &result, &cache, &keepSnapshots_param); + if (!cache) { + cache = &cache_sub; + cache = &__$null; } - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injection container is required to access the services related to the ORM", "phalcon/Mvc/Model/Manager.zep", 828); - return; + if (!keepSnapshots_param) { + keepSnapshots = 0; + } else { + } + zephir_update_property_zval(this_ptr, ZEND_STRL("model"), model); + zephir_update_property_zval(this_ptr, ZEND_STRL("columnMap"), columnMap); + if (keepSnapshots) { + zephir_update_property_zval(this_ptr, ZEND_STRL("keepSnapshots"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("keepSnapshots"), &__$false); } - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 2, 0); - zephir_array_fast_append(&_2, params); - zephir_array_fast_append(&_2, &container); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "Phalcon\\Mvc\\Model\\Query\\Builder"); - ZEPHIR_CALL_METHOD(&_1, &container, "get", NULL, 0, &_3, &_2); + ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_resultset_simple_ce, getThis(), "__construct", NULL, 0, result, cache); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("builder"), &_1); - RETURN_MM_MEMBER(getThis(), "builder"); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, createQuery) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, current) { - zval _2; + zend_class_entry *_6$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *phql_param = NULL, container, query, _0, _1, _3; - zval phql; + zval __$true, __$false, row, hydrateMode, columnMap, activeRow, modelName, _0, _1$$6, _3$$6, _4$$6, _5$$6, _2$$7, _7$$9, _8$$9, _9$$9; zval *this_ptr = getThis(); - ZVAL_UNDEF(&phql); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&query); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&row); + ZVAL_UNDEF(&hydrateMode); + ZVAL_UNDEF(&columnMap); + ZVAL_UNDEF(&activeRow); + ZVAL_UNDEF(&modelName); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(phql) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1$$6); + ZVAL_UNDEF(&_3$$6); + ZVAL_UNDEF(&_4$$6); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_2$$7); + ZVAL_UNDEF(&_7$$9); + ZVAL_UNDEF(&_8$$9); + ZVAL_UNDEF(&_9$$9); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &phql_param); - if (UNEXPECTED(Z_TYPE_P(phql_param) != IS_STRING && Z_TYPE_P(phql_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'phql' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(phql_param) == IS_STRING)) { - zephir_get_strval(&phql, phql_param); - } else { - ZEPHIR_INIT_VAR(&phql); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("activeRow"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&activeRow, &_0); + if (Z_TYPE_P(&activeRow) != IS_NULL) { + RETURN_CCTOR(&activeRow); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injection container is required to access the services related to the ORM", "phalcon/Mvc/Model/Manager.zep", 861); - return; + zephir_read_property(&_0, this_ptr, ZEND_STRL("row"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&row, &_0); + if (Z_TYPE_P(&row) != IS_ARRAY) { + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &__$false); + } + RETURN_MM_NULL(); } - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 2, 0); - zephir_array_fast_append(&_2, &phql); - zephir_array_fast_append(&_2, &container); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "Phalcon\\Mvc\\Model\\Query"); - ZEPHIR_CALL_METHOD(&_1, &container, "get", NULL, 0, &_3, &_2); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&query, &_1); - zephir_update_property_zval(this_ptr, ZEND_STRL("lastQuery"), &query); - RETURN_CCTOR(&query); + zephir_read_property(&_0, this_ptr, ZEND_STRL("hydrateMode"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&hydrateMode, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&columnMap, &_0); + do { + if (ZEPHIR_IS_LONG(&hydrateMode, 0)) { + if (ZEPHIR_GLOBAL(orm).late_state_binding) { + zephir_memory_observe(&_1$$6); + zephir_read_property(&_1$$6, this_ptr, ZEND_STRL("model"), PH_NOISY_CC); + if (zephir_instance_of_ev(&_1$$6, phalcon_mvc_model_ce)) { + zephir_read_property(&_2$$7, this_ptr, ZEND_STRL("model"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&modelName); + zephir_get_class(&modelName, &_2$$7, 0); + } else { + ZEPHIR_INIT_NVAR(&modelName); + ZVAL_STRING(&modelName, "Phalcon\\Mvc\\Model"); + } + zephir_read_property(&_3$$6, this_ptr, ZEND_STRL("model"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_4$$6, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_5$$6, 0); + _6$$6 = zephir_fetch_class(&modelName); + ZEPHIR_CALL_CE_STATIC(&activeRow, _6$$6, "cloneresultmap", NULL, 0, &_3$$6, &row, &columnMap, &_5$$6, &_4$$6); + zephir_check_call_status(); + } else { + zephir_read_property(&_7$$9, this_ptr, ZEND_STRL("model"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_8$$9, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_9$$9, 0); + ZEPHIR_CALL_CE_STATIC(&activeRow, phalcon_mvc_model_ce, "cloneresultmap", NULL, 0, &_7$$9, &row, &columnMap, &_9$$9, &_8$$9); + zephir_check_call_status(); + } + break; + } + ZEPHIR_CALL_CE_STATIC(&activeRow, phalcon_mvc_model_ce, "cloneresultmaphydrate", NULL, 0, &row, &columnMap, &hydrateMode); + zephir_check_call_status(); + break; + } while(0); + + zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &activeRow); + RETURN_CCTOR(&activeRow); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, executeQuery) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, toArray) { + zend_string *_9$$8, *_22$$19; + zend_ulong _8$$8, _21$$19; + zval renamedRecords, renamed; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_12 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *phql_param = NULL, *placeholders = NULL, placeholders_sub, *types = NULL, types_sub, __$null, query; - zval phql; + zval *renameColumns_param = NULL, __$null, result, records, record, renamedKey, key, value, columnMap, _2, _0$$3, _3$$5, *_4$$7, _5$$7, *_6$$8, _7$$8, _10$$11, _11$$11, _13$$13, _14$$13, _15$$16, _16$$16, _17$$18, _18$$18, *_19$$19, _20$$19, _23$$22, _24$$22, _25$$24, _26$$24, _27$$27, _28$$27, _29$$29, _30$$29; + zend_bool renameColumns, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&phql); - ZVAL_UNDEF(&placeholders_sub); - ZVAL_UNDEF(&types_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&query); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(phql) + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&records); + ZVAL_UNDEF(&record); + ZVAL_UNDEF(&renamedKey); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&columnMap); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_7$$8); + ZVAL_UNDEF(&_10$$11); + ZVAL_UNDEF(&_11$$11); + ZVAL_UNDEF(&_13$$13); + ZVAL_UNDEF(&_14$$13); + ZVAL_UNDEF(&_15$$16); + ZVAL_UNDEF(&_16$$16); + ZVAL_UNDEF(&_17$$18); + ZVAL_UNDEF(&_18$$18); + ZVAL_UNDEF(&_20$$19); + ZVAL_UNDEF(&_23$$22); + ZVAL_UNDEF(&_24$$22); + ZVAL_UNDEF(&_25$$24); + ZVAL_UNDEF(&_26$$24); + ZVAL_UNDEF(&_27$$27); + ZVAL_UNDEF(&_28$$27); + ZVAL_UNDEF(&_29$$29); + ZVAL_UNDEF(&_30$$29); + ZVAL_UNDEF(&renamedRecords); + ZVAL_UNDEF(&renamed); + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(placeholders) - Z_PARAM_ZVAL_OR_NULL(types) + Z_PARAM_BOOL(renameColumns) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &phql_param, &placeholders, &types); - if (UNEXPECTED(Z_TYPE_P(phql_param) != IS_STRING && Z_TYPE_P(phql_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'phql' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(phql_param) == IS_STRING)) { - zephir_get_strval(&phql, phql_param); + zephir_fetch_params(1, 0, 1, &renameColumns_param); + if (!renameColumns_param) { + renameColumns = 1; } else { - ZEPHIR_INIT_VAR(&phql); - } - if (!placeholders) { - placeholders = &placeholders_sub; - placeholders = &__$null; - } - if (!types) { - types = &types_sub; - types = &__$null; - } - ZEPHIR_CALL_METHOD(&query, this_ptr, "createquery", NULL, 0, &phql); - zephir_check_call_status(); - if (Z_TYPE_P(placeholders) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(NULL, &query, "setbindparams", NULL, 0, placeholders); + } + zephir_memory_observe(&records); + zephir_read_property(&records, this_ptr, ZEND_STRL("rows"), PH_NOISY_CC); + if (Z_TYPE_P(&records) != IS_ARRAY) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("result"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&result, &_0$$3); + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("row"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0$$3) != IS_NULL) { + ZEPHIR_CALL_METHOD(NULL, &result, "execute", NULL, 0); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(&records, &result, "fetchall", NULL, 0); zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("row"), &__$null); + zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &records); } - if (Z_TYPE_P(types) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(NULL, &query, "setbindtypes", NULL, 0, types); - zephir_check_call_status(); + _1 = renameColumns; + if (_1) { + zephir_memory_observe(&_2); + zephir_read_property(&_2, this_ptr, ZEND_STRL("model"), PH_NOISY_CC); + _1 = !(zephir_instance_of_ev(&_2, phalcon_mvc_model_row_ce)); } - ZEPHIR_RETURN_CALL_METHOD(&query, "execute", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + if (_1) { + zephir_read_property(&_3$$5, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&columnMap, &_3$$5); + if (Z_TYPE_P(&columnMap) != IS_ARRAY) { + RETURN_CCTOR(&records); + } + ZEPHIR_INIT_VAR(&renamedRecords); + array_init(&renamedRecords); + if (Z_TYPE_P(&records) == IS_ARRAY) { + zephir_is_iterable(&records, 0, "phalcon/Mvc/Model/Resultset/Simple.zep", 246); + if (Z_TYPE_P(&records) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&records), _4$$7) + { + ZEPHIR_INIT_NVAR(&record); + ZVAL_COPY(&record, _4$$7); + ZEPHIR_INIT_NVAR(&renamed); + array_init(&renamed); + zephir_is_iterable(&record, 0, "phalcon/Mvc/Model/Resultset/Simple.zep", 244); + if (Z_TYPE_P(&record) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&record), _8$$8, _9$$8, _6$$8) + { + ZEPHIR_INIT_NVAR(&key); + if (_9$$8 != NULL) { + ZVAL_STR_COPY(&key, _9$$8); + } else { + ZVAL_LONG(&key, _8$$8); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _6$$8); + if (Z_TYPE_P(&key) == IS_STRING) { + ZEPHIR_OBS_NVAR(&renamedKey); + if (UNEXPECTED(!(zephir_array_isset_fetch(&renamedKey, &columnMap, &key, 0)))) { + ZEPHIR_INIT_NVAR(&_10$$11); + object_init_ex(&_10$$11, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_11$$11); + ZEPHIR_CONCAT_SVS(&_11$$11, "Column '", &key, "' is not part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_10$$11, "__construct", &_12, 33, &_11$$11); + zephir_check_call_status(); + zephir_throw_exception_debug(&_10$$11, "phalcon/Mvc/Model/Resultset/Simple.zep", 226); + ZEPHIR_MM_RESTORE(); + return; + } + if (Z_TYPE_P(&renamedKey) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&renamedKey); + if (UNEXPECTED(!(zephir_array_isset_long_fetch(&renamedKey, &renamedKey, 0, 0)))) { + ZEPHIR_INIT_NVAR(&_13$$13); + object_init_ex(&_13$$13, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_14$$13); + ZEPHIR_CONCAT_SVS(&_14$$13, "Column '", &key, "' is not part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_13$$13, "__construct", &_12, 33, &_14$$13); + zephir_check_call_status(); + zephir_throw_exception_debug(&_13$$13, "phalcon/Mvc/Model/Resultset/Simple.zep", 233); + ZEPHIR_MM_RESTORE(); + return; + } + } + zephir_array_update_zval(&renamed, &renamedKey, &value, PH_COPY | PH_SEPARATE); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &record, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_7$$8, &record, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_7$$8)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &record, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &record, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&key) == IS_STRING) { + ZEPHIR_OBS_NVAR(&renamedKey); + if (UNEXPECTED(!(zephir_array_isset_fetch(&renamedKey, &columnMap, &key, 0)))) { + ZEPHIR_INIT_NVAR(&_15$$16); + object_init_ex(&_15$$16, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_16$$16); + ZEPHIR_CONCAT_SVS(&_16$$16, "Column '", &key, "' is not part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_15$$16, "__construct", &_12, 33, &_16$$16); + zephir_check_call_status(); + zephir_throw_exception_debug(&_15$$16, "phalcon/Mvc/Model/Resultset/Simple.zep", 226); + ZEPHIR_MM_RESTORE(); + return; + } + if (Z_TYPE_P(&renamedKey) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&renamedKey); + if (UNEXPECTED(!(zephir_array_isset_long_fetch(&renamedKey, &renamedKey, 0, 0)))) { + ZEPHIR_INIT_NVAR(&_17$$18); + object_init_ex(&_17$$18, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_18$$18); + ZEPHIR_CONCAT_SVS(&_18$$18, "Column '", &key, "' is not part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_17$$18, "__construct", &_12, 33, &_18$$18); + zephir_check_call_status(); + zephir_throw_exception_debug(&_17$$18, "phalcon/Mvc/Model/Resultset/Simple.zep", 233); + ZEPHIR_MM_RESTORE(); + return; + } + } + zephir_array_update_zval(&renamed, &renamedKey, &value, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, &record, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + zephir_array_append(&renamedRecords, &renamed, PH_SEPARATE, "phalcon/Mvc/Model/Resultset/Simple.zep", 244); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &records, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5$$7, &records, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5$$7)) { + break; + } + ZEPHIR_CALL_METHOD(&record, &records, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&renamed); + array_init(&renamed); + zephir_is_iterable(&record, 0, "phalcon/Mvc/Model/Resultset/Simple.zep", 244); + if (Z_TYPE_P(&record) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&record), _21$$19, _22$$19, _19$$19) + { + ZEPHIR_INIT_NVAR(&key); + if (_22$$19 != NULL) { + ZVAL_STR_COPY(&key, _22$$19); + } else { + ZVAL_LONG(&key, _21$$19); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _19$$19); + if (Z_TYPE_P(&key) == IS_STRING) { + ZEPHIR_OBS_NVAR(&renamedKey); + if (UNEXPECTED(!(zephir_array_isset_fetch(&renamedKey, &columnMap, &key, 0)))) { + ZEPHIR_INIT_NVAR(&_23$$22); + object_init_ex(&_23$$22, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_24$$22); + ZEPHIR_CONCAT_SVS(&_24$$22, "Column '", &key, "' is not part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_23$$22, "__construct", &_12, 33, &_24$$22); + zephir_check_call_status(); + zephir_throw_exception_debug(&_23$$22, "phalcon/Mvc/Model/Resultset/Simple.zep", 226); + ZEPHIR_MM_RESTORE(); + return; + } + if (Z_TYPE_P(&renamedKey) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&renamedKey); + if (UNEXPECTED(!(zephir_array_isset_long_fetch(&renamedKey, &renamedKey, 0, 0)))) { + ZEPHIR_INIT_NVAR(&_25$$24); + object_init_ex(&_25$$24, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_26$$24); + ZEPHIR_CONCAT_SVS(&_26$$24, "Column '", &key, "' is not part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_25$$24, "__construct", &_12, 33, &_26$$24); + zephir_check_call_status(); + zephir_throw_exception_debug(&_25$$24, "phalcon/Mvc/Model/Resultset/Simple.zep", 233); + ZEPHIR_MM_RESTORE(); + return; + } + } + zephir_array_update_zval(&renamed, &renamedKey, &value, PH_COPY | PH_SEPARATE); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &record, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_20$$19, &record, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_20$$19)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &record, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &record, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&key) == IS_STRING) { + ZEPHIR_OBS_NVAR(&renamedKey); + if (UNEXPECTED(!(zephir_array_isset_fetch(&renamedKey, &columnMap, &key, 0)))) { + ZEPHIR_INIT_NVAR(&_27$$27); + object_init_ex(&_27$$27, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_28$$27); + ZEPHIR_CONCAT_SVS(&_28$$27, "Column '", &key, "' is not part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_27$$27, "__construct", &_12, 33, &_28$$27); + zephir_check_call_status(); + zephir_throw_exception_debug(&_27$$27, "phalcon/Mvc/Model/Resultset/Simple.zep", 226); + ZEPHIR_MM_RESTORE(); + return; + } + if (Z_TYPE_P(&renamedKey) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&renamedKey); + if (UNEXPECTED(!(zephir_array_isset_long_fetch(&renamedKey, &renamedKey, 0, 0)))) { + ZEPHIR_INIT_NVAR(&_29$$29); + object_init_ex(&_29$$29, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_NVAR(&_30$$29); + ZEPHIR_CONCAT_SVS(&_30$$29, "Column '", &key, "' is not part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_29$$29, "__construct", &_12, 33, &_30$$29); + zephir_check_call_status(); + zephir_throw_exception_debug(&_29$$29, "phalcon/Mvc/Model/Resultset/Simple.zep", 233); + ZEPHIR_MM_RESTORE(); + return; + } + } + zephir_array_update_zval(&renamed, &renamedKey, &value, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, &record, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + zephir_array_append(&renamedRecords, &renamed, PH_SEPARATE, "phalcon/Mvc/Model/Resultset/Simple.zep", 244); + ZEPHIR_CALL_METHOD(NULL, &records, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&record); + } + RETURN_CTOR(&renamedRecords); + } + RETURN_CCTOR(&records); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsBelongsTo) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, serialize) { + zval data; + zval container, serializer, _0, _1, _2, _3, _4$$4, _5$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL; - zval modelName, modelRelation; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&serializer); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&data); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); - } else { - ZEPHIR_INIT_VAR(&modelName); - } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); - RETURN_MM_NULL(); + + ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The dependency injector container is not valid", "phalcon/Mvc/Model/Resultset/Simple.zep", 266); + return; } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); - } else { - ZEPHIR_INIT_VAR(&modelRelation); + ZEPHIR_INIT_VAR(&data); + zephir_create_array(&data, 6, 0); + zephir_memory_observe(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("model"), PH_NOISY_CC); + zephir_array_update_string(&data, SL("model"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC); + zephir_array_update_string(&data, SL("cache"), &_0, PH_COPY | PH_SEPARATE); + ZVAL_BOOL(&_2, 0); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "toarray", NULL, 0, &_2); + zephir_check_call_status(); + zephir_array_update_string(&data, SL("rows"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC); + zephir_array_update_string(&data, SL("columnMap"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("hydrateMode"), PH_NOISY_CC); + zephir_array_update_string(&data, SL("hydrateMode"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC); + zephir_array_update_string(&data, SL("keepSnapshots"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "serializer"); + ZEPHIR_CALL_METHOD(&_1, &container, "has", NULL, 0, &_3); + zephir_check_call_status(); + if (zephir_is_true(&_1)) { + ZEPHIR_INIT_VAR(&_5$$4); + ZVAL_STRING(&_5$$4, "serializer"); + ZEPHIR_CALL_METHOD(&_4$$4, &container, "getshared", NULL, 0, &_5$$4); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&serializer, &_4$$4); + ZEPHIR_CALL_METHOD(NULL, &serializer, "setdata", NULL, 0, &data); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(&serializer, "serialize", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hasbelongsto", NULL, 0, &modelName, &modelRelation); + ZEPHIR_RETURN_CALL_FUNCTION("serialize", NULL, 15, &data); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasMany) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, unserialize) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL; - zval modelName, modelRelation; + zval *data, data_sub, resultset, keepSnapshots, container, serializer, _0, _1, _4, _5, _6, _7, _8, _9, _10, _2$$4, _3$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) + ZVAL_UNDEF(&data_sub); + ZVAL_UNDEF(&resultset); + ZVAL_UNDEF(&keepSnapshots); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&serializer); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(data) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 0, &data); + ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The dependency injector container is not valid", "phalcon/Mvc/Model/Resultset/Simple.zep", 303); + return; } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "serializer"); + ZEPHIR_CALL_METHOD(&_0, &container, "has", NULL, 0, &_1); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + ZEPHIR_INIT_VAR(&_3$$4); + ZVAL_STRING(&_3$$4, "serializer"); + ZEPHIR_CALL_METHOD(&_2$$4, &container, "getshared", NULL, 0, &_3$$4); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&serializer, &_2$$4); + ZEPHIR_CALL_METHOD(NULL, &serializer, "unserialize", NULL, 0, data); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&resultset, &serializer, "getdata", NULL, 0); + zephir_check_call_status(); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_CALL_FUNCTION(&resultset, "unserialize", NULL, 16, data); + zephir_check_call_status(); } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); - RETURN_MM_NULL(); + if (UNEXPECTED(Z_TYPE_P(&resultset) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid serialization data", "phalcon/Mvc/Model/Resultset/Simple.zep", 316); + return; } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); - } else { - ZEPHIR_INIT_VAR(&modelRelation); + zephir_array_fetch_string(&_4, &resultset, SL("model"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 319); + zephir_update_property_zval(this_ptr, ZEND_STRL("model"), &_4); + zephir_array_fetch_string(&_5, &resultset, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 320); + zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_5); + zephir_array_fetch_string(&_6, &resultset, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 321); + ZVAL_UNDEF(&_7); + ZVAL_LONG(&_7, zephir_fast_count_int(&_6)); + zephir_update_property_zval(this_ptr, ZEND_STRL("count"), &_7); + zephir_array_fetch_string(&_8, &resultset, SL("cache"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 322); + zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), &_8); + zephir_array_fetch_string(&_9, &resultset, SL("columnMap"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 323); + zephir_update_property_zval(this_ptr, ZEND_STRL("columnMap"), &_9); + zephir_array_fetch_string(&_10, &resultset, SL("hydrateMode"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 324); + zephir_update_property_zval(this_ptr, ZEND_STRL("hydrateMode"), &_10); + if (zephir_array_isset_string_fetch(&keepSnapshots, &resultset, SL("keepSnapshots"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("keepSnapshots"), &keepSnapshots); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hashasmany", NULL, 0, &modelName, &modelRelation); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasManyToMany) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, __serialize) { + zval _0, _1, _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL; - zval modelName, modelRelation; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); - } else { - ZEPHIR_INIT_VAR(&modelName); - } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); - } else { - ZEPHIR_INIT_VAR(&modelRelation); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hashasmanytomany", NULL, 0, &modelName, &modelRelation); + + zephir_create_array(return_value, 6, 0); + zephir_memory_observe(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("model"), PH_NOISY_CC); + zephir_array_update_string(return_value, SL("model"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC); + zephir_array_update_string(return_value, SL("cache"), &_0, PH_COPY | PH_SEPARATE); + ZVAL_BOOL(&_2, 0); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "toarray", NULL, 0, &_2); zephir_check_call_status(); + zephir_array_update_string(return_value, SL("rows"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC); + zephir_array_update_string(return_value, SL("columnMap"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("hydrateMode"), PH_NOISY_CC); + zephir_array_update_string(return_value, SL("hydrateMode"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC); + zephir_array_update_string(return_value, SL("keepSnapshots"), &_0, PH_COPY | PH_SEPARATE); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasOne) +static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, __unserialize) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL; - zval modelName, modelRelation; + zval *data_param = NULL, keepSnapshots, _0, _1, _2, _3, _4, _5, _6; + zval data; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&keepSnapshots); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(data) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); - } else { - ZEPHIR_INIT_VAR(&modelName); - } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); - } else { - ZEPHIR_INIT_VAR(&modelRelation); + zephir_fetch_params(1, 1, 0, &data_param); + zephir_get_arrval(&data, data_param); + zephir_array_fetch_string(&_0, &data, SL("model"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 347); + zephir_update_property_zval(this_ptr, ZEND_STRL("model"), &_0); + zephir_array_fetch_string(&_1, &data, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 348); + zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_1); + zephir_array_fetch_string(&_2, &data, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 349); + ZVAL_UNDEF(&_3); + ZVAL_LONG(&_3, zephir_fast_count_int(&_2)); + zephir_update_property_zval(this_ptr, ZEND_STRL("count"), &_3); + zephir_array_fetch_string(&_4, &data, SL("cache"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 350); + zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), &_4); + zephir_array_fetch_string(&_5, &data, SL("columnMap"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 351); + zephir_update_property_zval(this_ptr, ZEND_STRL("columnMap"), &_5); + zephir_array_fetch_string(&_6, &data, SL("hydrateMode"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 352); + zephir_update_property_zval(this_ptr, ZEND_STRL("hydrateMode"), &_6); + if (zephir_array_isset_string_fetch(&keepSnapshots, &data, SL("keepSnapshots"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("keepSnapshots"), &keepSnapshots); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hashasone", NULL, 0, &modelName, &modelRelation); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, existsHasOneThrough) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL; - zval modelName, modelRelation; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); - } else { - ZEPHIR_INIT_VAR(&modelName); - } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); - } else { - ZEPHIR_INIT_VAR(&modelRelation); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hashasonethrough", NULL, 0, &modelName, &modelRelation); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getBelongsTo) + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Apcu) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, relations, _0, _1; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\MetaData, Apcu, phalcon, mvc_model_metadata_apcu, phalcon_mvc_model_metadata_ce, phalcon_mvc_model_metadata_apcu_method_entry, 0); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - zephir_memory_observe(&relations); - zephir_read_property(&_0, this_ptr, ZEND_STRL("belongsToSingle"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 0))) { - array_init(return_value); - RETURN_MM(); - } - RETURN_CCTOR(&relations); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getBelongsToRecords) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Apcu, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL, *record, record_sub, *parameters = NULL, parameters_sub, *method_param = NULL, __$null, relations, _0, _1, _2, _3, _4; - zval modelName, modelRelation, method, keyRelation; + zval options; + zval *factory, factory_sub, *options_param = NULL, _0, _1, _2, _3, _4, _5; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&keyRelation); - ZVAL_UNDEF(&record_sub); - ZVAL_UNDEF(¶meters_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&relations); + ZVAL_UNDEF(&factory_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&options); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 5) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) - Z_PARAM_OBJECT_OF_CLASS(record, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_cache_adapterfactory_ce) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(parameters) - Z_PARAM_STR_OR_NULL(method) + Z_PARAM_ARRAY_OR_NULL(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 2, &modelName_param, &modelRelation_param, &record, ¶meters, &method_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); - } else { - ZEPHIR_INIT_VAR(&modelName); - } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); - } else { - ZEPHIR_INIT_VAR(&modelRelation); - } - if (!parameters) { - parameters = ¶meters_sub; - parameters = &__$null; - } - if (!method_param) { - ZEPHIR_INIT_VAR(&method); + zephir_fetch_params(1, 1, 1, &factory, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); } else { - zephir_get_strval(&method, method_param); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - ZEPHIR_INIT_VAR(&_0); - zephir_fast_strtolower(&_0, &modelName); ZEPHIR_INIT_VAR(&_1); - zephir_fast_strtolower(&_1, &modelRelation); + ZVAL_STRING(&_1, "prefix"); ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VSV(&_2, &_0, "$", &_1); - zephir_get_strval(&keyRelation, &_2); - zephir_memory_observe(&relations); - zephir_read_property(&_3, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&relations, &_3, &keyRelation, 0))) { - RETURN_MM_BOOL(0); - } - zephir_array_fetch_long(&_4, &relations, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1030); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelationrecords", NULL, 0, &_4, record, parameters, &method); + ZVAL_STRING(&_2, "ph-mm-apcu-"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getarrval", NULL, 0, &options, &_1, &_2); zephir_check_call_status(); - RETURN_MM(); + zephir_array_update_string(&options, SL("prefix"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "lifetime"); + ZVAL_LONG(&_4, 172800); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "getarrval", NULL, 0, &options, &_1, &_4); + zephir_check_call_status(); + zephir_array_update_string(&options, SL("lifetime"), &_3, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "apcu"); + ZEPHIR_CALL_METHOD(&_5, factory, "newinstance", NULL, 0, &_1, &options); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("adapter"), &_5); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getBuilder) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Libmemcached) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\MetaData, Libmemcached, phalcon, mvc_model_metadata_libmemcached, phalcon_mvc_model_metadata_ce, phalcon_mvc_model_metadata_libmemcached_method_entry, 0); - RETURN_MEMBER(getThis(), "builder"); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getConnectionService) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Libmemcached, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval connectionServices; - zval *model, model_sub, *connectionServices_param = NULL, connection, _0; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval options; + zval *factory, factory_sub, *options_param = NULL, _0, _1, _2, _3, _4, _5, _6; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&connection); + ZVAL_UNDEF(&factory_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&connectionServices); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ARRAY(connectionServices) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_cache_adapterfactory_ce) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &connectionServices_param); - zephir_get_arrval(&connectionServices, connectionServices_param); - zephir_memory_observe(&connection); - ZEPHIR_INIT_VAR(&_0); - zephir_get_class(&_0, model, 1); - if (!(zephir_array_isset_fetch(&connection, &connectionServices, &_0, 0))) { - RETURN_MM_STRING("db"); + zephir_fetch_params(1, 1, 1, &factory, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - RETURN_CCTOR(&connection); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "persistentId"); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "ph-mm-mcid-"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getarrval", NULL, 0, &options, &_1, &_2); + zephir_check_call_status(); + zephir_array_update_string(&options, SL("persistentId"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "prefix"); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "ph-mm-memc-"); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "getarrval", NULL, 0, &options, &_1, &_2); + zephir_check_call_status(); + zephir_array_update_string(&options, SL("prefix"), &_3, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "lifetime"); + ZVAL_LONG(&_5, 172800); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "getarrval", NULL, 0, &options, &_1, &_5); + zephir_check_call_status(); + zephir_array_update_string(&options, SL("lifetime"), &_4, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "libmemcached"); + ZEPHIR_CALL_METHOD(&_6, factory, "newinstance", NULL, 0, &_1, &options); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("adapter"), &_6); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getCustomEventsManager) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Libmemcached, reset) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, eventsManager, _0, _1; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&eventsManager); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - zephir_memory_observe(&eventsManager); - zephir_read_property(&_0, this_ptr, ZEND_STRL("customEventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (zephir_array_isset_fetch(&eventsManager, &_0, &_1, 0)) { - RETURN_CCTOR(&eventsManager); - } - RETURN_MM_NULL(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "clear", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_metadata_libmemcached_ce, getThis(), "reset", NULL, 0); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getDI) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Memory) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\MetaData, Memory, phalcon, mvc_model_metadata_memory, phalcon_mvc_model_metadata_ce, phalcon_mvc_model_metadata_memory_method_entry, 0); - RETURN_MEMBER(getThis(), "container"); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getEventsManager) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Memory, __construct) { + zval *options = NULL, options_sub, __$null; - RETURN_MEMBER(getThis(), "eventsManager"); + ZVAL_UNDEF(&options_sub); + ZVAL_NULL(&__$null); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(options) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(0, 1, &options); + if (!options) { + options = &options_sub; + options = &__$null; + } } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasMany) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Memory, read) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, relations, _0, _1; - zval *this_ptr = getThis(); + zval *key_param = NULL; + zval key; - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&key); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - zephir_memory_observe(&relations); - zephir_read_property(&_0, this_ptr, ZEND_STRL("hasManySingle"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 0))) { - array_init(return_value); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &key_param); + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + RETURN_MM_NULL(); } - RETURN_CCTOR(&relations); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasManyRecords) + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); + } else { + ZEPHIR_INIT_VAR(&key); + } + RETURN_MM_NULL(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Memory, write) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL, *record, record_sub, *parameters = NULL, parameters_sub, *method_param = NULL, __$null, relations, _0, _1, _2, _3, _4; - zval modelName, modelRelation, method, keyRelation; - zval *this_ptr = getThis(); + zval data; + zval *key_param = NULL, *data_param = NULL; + zval key; - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&keyRelation); - ZVAL_UNDEF(&record_sub); - ZVAL_UNDEF(¶meters_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 5) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) - Z_PARAM_OBJECT_OF_CLASS(record, phalcon_mvc_modelinterface_ce) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(parameters) - Z_PARAM_STR_OR_NULL(method) + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&data); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(key) + Z_PARAM_ARRAY(data) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 2, &modelName_param, &modelRelation_param, &record, ¶meters, &method_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); - } else { - ZEPHIR_INIT_VAR(&modelName); - } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + zephir_fetch_params(1, 2, 0, &key_param, &data_param); + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); - } else { - ZEPHIR_INIT_VAR(&modelRelation); - } - if (!parameters) { - parameters = ¶meters_sub; - parameters = &__$null; - } - if (!method_param) { - ZEPHIR_INIT_VAR(&method); + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); } else { - zephir_get_strval(&method, method_param); - } - ZEPHIR_INIT_VAR(&_0); - zephir_fast_strtolower(&_0, &modelName); - ZEPHIR_INIT_VAR(&_1); - zephir_fast_strtolower(&_1, &modelRelation); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VSV(&_2, &_0, "$", &_1); - zephir_get_strval(&keyRelation, &_2); - zephir_memory_observe(&relations); - zephir_read_property(&_3, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&relations, &_3, &keyRelation, 0))) { - RETURN_MM_BOOL(0); + ZEPHIR_INIT_VAR(&key); } - zephir_array_fetch_long(&_4, &relations, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1141); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelationrecords", NULL, 0, &_4, record, parameters, &method); - zephir_check_call_status(); - RETURN_MM(); + zephir_get_arrval(&data, data_param); + RETURN_MM_NULL(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasManyToMany) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, relations, _0, _1; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - zephir_memory_observe(&relations); - zephir_read_property(&_0, this_ptr, ZEND_STRL("hasManyToManySingle"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 0))) { - array_init(return_value); - RETURN_MM(); - } - RETURN_CCTOR(&relations); -} -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOne) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, relations, _0, _1; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - zephir_memory_observe(&relations); - zephir_read_property(&_0, this_ptr, ZEND_STRL("hasOneSingle"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 0))) { - array_init(return_value); - RETURN_MM(); - } - RETURN_CCTOR(&relations); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOneAndHasMany) + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Redis) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, _0, _1; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\MetaData, Redis, phalcon, mvc_model_metadata_redis, phalcon_mvc_model_metadata_ce, phalcon_mvc_model_metadata_redis_method_entry, 0); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "gethasone", NULL, 0, model); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "gethasmany", NULL, 0, model); - zephir_check_call_status(); - zephir_fast_array_merge(return_value, &_0, &_1); - RETURN_MM(); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOneRecords) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Redis, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL, *record, record_sub, *parameters = NULL, parameters_sub, *method_param = NULL, __$null, relations, _0, _1, _2, _3, _4; - zval modelName, modelRelation, method, keyRelation; + zval options; + zval *factory, factory_sub, *options_param = NULL, _0, _1, _2, _3, _4, _5; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&keyRelation); - ZVAL_UNDEF(&record_sub); - ZVAL_UNDEF(¶meters_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&relations); + ZVAL_UNDEF(&factory_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 5) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) - Z_PARAM_OBJECT_OF_CLASS(record, phalcon_mvc_modelinterface_ce) + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_cache_adapterfactory_ce) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(parameters) - Z_PARAM_STR_OR_NULL(method) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 2, &modelName_param, &modelRelation_param, &record, ¶meters, &method_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); - } else { - ZEPHIR_INIT_VAR(&modelName); - } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); - } else { - ZEPHIR_INIT_VAR(&modelRelation); - } - if (!parameters) { - parameters = ¶meters_sub; - parameters = &__$null; - } - if (!method_param) { - ZEPHIR_INIT_VAR(&method); + zephir_fetch_params(1, 1, 1, &factory, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - zephir_get_strval(&method, method_param); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - ZEPHIR_INIT_VAR(&_0); - zephir_fast_strtolower(&_0, &modelName); ZEPHIR_INIT_VAR(&_1); - zephir_fast_strtolower(&_1, &modelRelation); + ZVAL_STRING(&_1, "prefix"); ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VSV(&_2, &_0, "$", &_1); - zephir_get_strval(&keyRelation, &_2); - zephir_memory_observe(&relations); - zephir_read_property(&_3, this_ptr, ZEND_STRL("hasOne"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&relations, &_3, &keyRelation, 0))) { - RETURN_MM_BOOL(0); - } - zephir_array_fetch_long(&_4, &relations, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 1210); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrelationrecords", NULL, 0, &_4, record, parameters, &method); + ZVAL_STRING(&_2, "ph-mm-reds-"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getarrval", NULL, 0, &options, &_1, &_2); zephir_check_call_status(); - RETURN_MM(); + zephir_array_update_string(&options, SL("prefix"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "lifetime"); + ZVAL_LONG(&_4, 172800); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "getarrval", NULL, 0, &options, &_1, &_4); + zephir_check_call_status(); + zephir_array_update_string(&options, SL("lifetime"), &_3, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "redis"); + ZEPHIR_CALL_METHOD(&_5, factory, "newinstance", NULL, 0, &_1, &options); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("adapter"), &_5); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getHasOneThrough) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Redis, reset) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, relations, _0, _1; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&relations); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - zephir_memory_observe(&relations); - zephir_read_property(&_0, this_ptr, ZEND_STRL("hasOneThroughSingle"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (!(zephir_array_isset_fetch(&relations, &_0, &_1, 0))) { - array_init(return_value); - RETURN_MM(); - } - RETURN_CCTOR(&relations); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "clear", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_metadata_redis_ce, getThis(), "reset", NULL, 0); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getLastInitialized) -{ - RETURN_MEMBER(getThis(), "lastInitialized"); -} -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getLastQuery) + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Stream) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\MetaData, Stream, phalcon, mvc_model_metadata_stream, phalcon_mvc_model_metadata_ce, phalcon_mvc_model_metadata_stream_method_entry, 0); - RETURN_MEMBER(getThis(), "lastQuery"); + zend_declare_property_string(phalcon_mvc_model_metadata_stream_ce, SL("metaDataDir"), "./", ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getModelPrefix) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Stream, __construct) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *options_param = NULL, metaDataDir; + zval options; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "prefix"); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&metaDataDir); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + zephir_memory_observe(&metaDataDir); + if (zephir_array_isset_string_fetch(&metaDataDir, &options, SL("metaDataDir"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("metaDataDir"), &metaDataDir); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getModelSchema) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Stream, read) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, schema, _0, _1; + zval *key_param = NULL, path, _0, _1, _2, _3; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&schema); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&path); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - zephir_memory_observe(&schema); - zephir_read_property(&_0, this_ptr, ZEND_STRL("schemas"), PH_NOISY_CC | PH_READONLY); + zephir_fetch_params(1, 1, 0, &key_param); + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); + } else { + ZEPHIR_INIT_VAR(&key); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("metaDataDir"), PH_NOISY_CC | PH_READONLY); ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (!(zephir_array_isset_fetch(&schema, &_0, &_1, 0))) { + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "_"); + zephir_prepare_virtual_path(&_1, &key, &_2); + ZEPHIR_INIT_VAR(&path); + ZEPHIR_CONCAT_VVS(&path, &_0, &_1, ".php"); + if (!((zephir_file_exists(&path) == SUCCESS))) { RETURN_MM_NULL(); } - RETURN_CCTOR(&schema); + ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(&_3); + if (zephir_require_zval_ret(&_3, &path) == FAILURE) { + RETURN_MM_NULL(); + } + RETURN_CCTOR(&_3); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getModelSource) +static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Stream, write) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, entityName, _0, _3, _4, _5, _1$$3, _2$$3; + zval data; + zval *key_param = NULL, *data_param = NULL, option, path, _6, _7, _0$$3, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&option); + ZVAL_UNDEF(&path); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_2$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&data); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(key) + Z_PARAM_ARRAY(data) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("sources"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset(&_0, &entityName))) { + zephir_fetch_params(1, 2, 0, &key_param, &data_param); + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); + } else { + ZEPHIR_INIT_VAR(&key); + } + zephir_get_arrval(&data, data_param); + /* try_start_1: */ + + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("metaDataDir"), PH_NOISY_CC | PH_READONLY); ZEPHIR_INIT_VAR(&_1$$3); ZEPHIR_INIT_VAR(&_2$$3); - zephir_get_class_ns(&_2$$3, model, 0); - zephir_uncamelize(&_1$$3, &_2$$3, NULL ); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setmodelsource", NULL, 0, model, &_1$$3); - zephir_check_call_status(); + ZVAL_STRING(&_2$$3, "_"); + zephir_prepare_virtual_path(&_1$$3, &key, &_2$$3); + ZEPHIR_INIT_VAR(&path); + ZEPHIR_CONCAT_VVS(&path, &_0$$3, &_1$$3, ".php"); + ZEPHIR_INIT_VAR(&option); + ZVAL_BOOL(&option, ZEPHIR_GLOBAL(orm).exception_on_failed_metadata_save); + ZEPHIR_INIT_VAR(&_3$$3); + ZEPHIR_INIT_VAR(&_4$$3); + ZEPHIR_INIT_NVAR(&_4$$3); + zephir_var_export_ex(&_4$$3, &data); + ZEPHIR_INIT_VAR(&_5$$3); + ZEPHIR_CONCAT_SVS(&_5$$3, "create_object = zephir_init_properties_Phalcon_Mvc_Model_Query_Builder; + + zend_class_implements(phalcon_mvc_model_query_builder_ce, 1, phalcon_mvc_model_query_builderinterface_ce); + zend_class_implements(phalcon_mvc_model_query_builder_ce, 1, phalcon_di_injectionawareinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, __construct) { + zend_bool _7$$38; + zval mergedConditions, mergedParams, mergedTypes; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, _0; + zval *params = NULL, params_sub, *container = NULL, container_sub, __$null, conditions, columns, groupClause, havingClause, limitClause, forUpdate, sharedLock, orderClause, offsetClause, joinsClause, singleConditionArray, limit, offset, fromClause, singleCondition, singleParams, singleTypes, distinct, bind, bindTypes, *_0$$7, _1$$7, _6$$7, _2$$11, _3$$12, _4$$16, _5$$17; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZVAL_UNDEF(¶ms_sub); + ZVAL_UNDEF(&container_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&groupClause); + ZVAL_UNDEF(&havingClause); + ZVAL_UNDEF(&limitClause); + ZVAL_UNDEF(&forUpdate); + ZVAL_UNDEF(&sharedLock); + ZVAL_UNDEF(&orderClause); + ZVAL_UNDEF(&offsetClause); + ZVAL_UNDEF(&joinsClause); + ZVAL_UNDEF(&singleConditionArray); + ZVAL_UNDEF(&limit); + ZVAL_UNDEF(&offset); + ZVAL_UNDEF(&fromClause); + ZVAL_UNDEF(&singleCondition); + ZVAL_UNDEF(&singleParams); + ZVAL_UNDEF(&singleTypes); + ZVAL_UNDEF(&distinct); + ZVAL_UNDEF(&bind); + ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&_1$$7); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_2$$11); + ZVAL_UNDEF(&_3$$12); + ZVAL_UNDEF(&_4$$16); + ZVAL_UNDEF(&_5$$17); + ZVAL_UNDEF(&mergedConditions); + ZVAL_UNDEF(&mergedParams); + ZVAL_UNDEF(&mergedTypes); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(params) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(container, phalcon_di_diinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - zephir_read_property(&_0, this_ptr, ZEND_STRL("writeConnectionServices"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getconnectionservice", NULL, 0, model, &_0); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 0, 2, ¶ms, &container); + if (!params) { + params = ¶ms_sub; + params = &__$null; + } + if (!container) { + container = &container_sub; + container = &__$null; + } + if (Z_TYPE_P(params) == IS_ARRAY) { + zephir_memory_observe(&conditions); + if (zephir_array_isset_long_fetch(&conditions, params, 0, 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("conditions"), &conditions); + } else { + ZEPHIR_OBS_NVAR(&conditions); + if (zephir_array_isset_string_fetch(&conditions, params, SL("conditions"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("conditions"), &conditions); + } + } + if (Z_TYPE_P(&conditions) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&mergedConditions); + array_init(&mergedConditions); + ZEPHIR_INIT_VAR(&mergedParams); + array_init(&mergedParams); + ZEPHIR_INIT_VAR(&mergedTypes); + array_init(&mergedTypes); + zephir_is_iterable(&conditions, 0, "phalcon/Mvc/Model/Query/Builder.zep", 189); + if (Z_TYPE_P(&conditions) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&conditions), _0$$7) + { + ZEPHIR_INIT_NVAR(&singleConditionArray); + ZVAL_COPY(&singleConditionArray, _0$$7); + if (Z_TYPE_P(&singleConditionArray) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&singleCondition); + zephir_array_isset_long_fetch(&singleCondition, &singleConditionArray, 0, 0); + ZEPHIR_OBS_NVAR(&singleParams); + zephir_array_isset_long_fetch(&singleParams, &singleConditionArray, 1, 0); + ZEPHIR_OBS_NVAR(&singleTypes); + zephir_array_isset_long_fetch(&singleTypes, &singleConditionArray, 2, 0); + if (Z_TYPE_P(&singleCondition) == IS_STRING) { + zephir_array_append(&mergedConditions, &singleCondition, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 176); + } + if (Z_TYPE_P(&singleParams) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&_2$$11); + zephir_add_function(&_2$$11, &mergedParams, &singleParams); + ZEPHIR_CPY_WRT(&mergedParams, &_2$$11); + } + if (Z_TYPE_P(&singleTypes) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&_3$$12); + zephir_add_function(&_3$$12, &mergedTypes, &singleTypes); + ZEPHIR_CPY_WRT(&mergedTypes, &_3$$12); + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &conditions, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1$$7, &conditions, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1$$7)) { + break; + } + ZEPHIR_CALL_METHOD(&singleConditionArray, &conditions, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&singleConditionArray) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&singleCondition); + zephir_array_isset_long_fetch(&singleCondition, &singleConditionArray, 0, 0); + ZEPHIR_OBS_NVAR(&singleParams); + zephir_array_isset_long_fetch(&singleParams, &singleConditionArray, 1, 0); + ZEPHIR_OBS_NVAR(&singleTypes); + zephir_array_isset_long_fetch(&singleTypes, &singleConditionArray, 2, 0); + if (Z_TYPE_P(&singleCondition) == IS_STRING) { + zephir_array_append(&mergedConditions, &singleCondition, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 176); + } + if (Z_TYPE_P(&singleParams) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&_4$$16); + zephir_add_function(&_4$$16, &mergedParams, &singleParams); + ZEPHIR_CPY_WRT(&mergedParams, &_4$$16); + } + if (Z_TYPE_P(&singleTypes) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&_5$$17); + zephir_add_function(&_5$$17, &mergedTypes, &singleTypes); + ZEPHIR_CPY_WRT(&mergedTypes, &_5$$17); + } + } + ZEPHIR_CALL_METHOD(NULL, &conditions, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&singleConditionArray); + ZEPHIR_INIT_VAR(&_6$$7); + zephir_fast_join_str(&_6$$7, SL(" AND "), &mergedConditions); + zephir_update_property_zval(this_ptr, ZEND_STRL("conditions"), &_6$$7); + zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &mergedParams); + zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &mergedTypes); + } + zephir_memory_observe(&bind); + if (zephir_array_isset_string_fetch(&bind, params, SL("bind"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &bind); + } + zephir_memory_observe(&bindTypes); + if (zephir_array_isset_string_fetch(&bindTypes, params, SL("bindTypes"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); + } + zephir_memory_observe(&distinct); + if (zephir_array_isset_string_fetch(&distinct, params, SL("distinct"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("distinct"), &distinct); + } + zephir_memory_observe(&fromClause); + if (zephir_array_isset_string_fetch(&fromClause, params, SL("models"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &fromClause); + } + zephir_memory_observe(&columns); + if (zephir_array_isset_string_fetch(&columns, params, SL("columns"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("columns"), &columns); + } + zephir_memory_observe(&joinsClause); + if (zephir_array_isset_string_fetch(&joinsClause, params, SL("joins"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("joins"), &joinsClause); + } + zephir_memory_observe(&groupClause); + if (zephir_array_isset_string_fetch(&groupClause, params, SL("group"), 0)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "groupby", NULL, 0, &groupClause); + zephir_check_call_status(); + } + zephir_memory_observe(&havingClause); + if (zephir_array_isset_string_fetch(&havingClause, params, SL("having"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("having"), &havingClause); + } + zephir_memory_observe(&orderClause); + if (zephir_array_isset_string_fetch(&orderClause, params, SL("order"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("order"), &orderClause); + } + zephir_memory_observe(&limitClause); + if (zephir_array_isset_string_fetch(&limitClause, params, SL("limit"), 0)) { + if (Z_TYPE_P(&limitClause) == IS_ARRAY) { + zephir_memory_observe(&limit); + if (zephir_array_isset_long_fetch(&limit, &limitClause, 0, 0)) { + if (Z_TYPE_P(&limit) == IS_LONG) { + zephir_update_property_zval(this_ptr, ZEND_STRL("limit"), &limit); + } + zephir_memory_observe(&offset); + if (zephir_array_isset_long_fetch(&offset, &limitClause, 1, 0)) { + if (Z_TYPE_P(&offset) == IS_LONG) { + zephir_update_property_zval(this_ptr, ZEND_STRL("offset"), &offset); + } + } + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("limit"), &limitClause); + } + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("limit"), &limitClause); + } + } + if (zephir_array_isset_string_fetch(&offsetClause, params, SL("offset"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("offset"), &offsetClause); + } + if (zephir_array_isset_string_fetch(&forUpdate, params, SL("for_update"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("forUpdate"), &forUpdate); + } + if (zephir_array_isset_string_fetch(&sharedLock, params, SL("shared_lock"), 1)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("sharedLock"), &sharedLock); + } + } else { + _7$$38 = Z_TYPE_P(params) == IS_STRING; + if (_7$$38) { + _7$$38 = !ZEPHIR_IS_STRING_IDENTICAL(params, ""); + } + if (_7$$38) { + zephir_update_property_zval(this_ptr, ZEND_STRL("conditions"), params); + } + } + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, hasBelongsTo) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, addFrom) { + zend_bool _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL, _0; - zval modelName, modelRelation; + zval *model_param = NULL, *alias_param = NULL, models, currentModel, _0, _1$$4; + zval model, alias; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&alias); + ZVAL_UNDEF(&models); + ZVAL_UNDEF(¤tModel); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) + ZVAL_UNDEF(&_1$$4); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(model) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(alias) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + zephir_fetch_params(1, 1, 1, &model_param, &alias_param); + zephir_get_strval(&model, model_param); + if (!alias_param) { + ZEPHIR_INIT_VAR(&alias); } else { - ZEPHIR_INIT_VAR(&modelName); + zephir_get_strval(&alias, alias_param); } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); - RETURN_MM_NULL(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&models, &_0); + if (Z_TYPE_P(&models) != IS_ARRAY) { + if (Z_TYPE_P(&models) != IS_NULL) { + ZEPHIR_CPY_WRT(¤tModel, &models); + ZEPHIR_INIT_VAR(&_1$$4); + zephir_create_array(&_1$$4, 1, 0); + zephir_array_fast_append(&_1$$4, ¤tModel); + ZEPHIR_CPY_WRT(&models, &_1$$4); + } else { + ZEPHIR_INIT_NVAR(&models); + array_init(&models); + } } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); + _2 = 1 == 1; + if (_2) { + _2 = !ZEPHIR_IS_NULL(&alias); + } + if (_2) { + zephir_array_update_zval(&models, &alias, &model, PH_COPY | PH_SEPARATE); } else { - ZEPHIR_INIT_VAR(&modelRelation); + zephir_array_append(&models, &model, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 344); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "belongsTo"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checkhasrelationship", NULL, 444, &_0, &modelName, &modelRelation); - zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &models); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, hasHasMany) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, andHaving) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL, _0; - zval modelName, modelRelation; + zval bindParams, bindTypes; + zval *conditions_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, currentConditions, _0$$3; + zval conditions; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(¤tConditions); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(conditions) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams_param, &bindTypes_param); + if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { + zephir_get_strval(&conditions, conditions_param); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_INIT_VAR(&conditions); } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); - RETURN_MM_NULL(); + if (!bindParams_param) { + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); + } else { + zephir_get_arrval(&bindParams, bindParams_param); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); + if (!bindTypes_param) { + ZEPHIR_INIT_VAR(&bindTypes); + array_init(&bindTypes); } else { - ZEPHIR_INIT_VAR(&modelRelation); + zephir_get_arrval(&bindTypes, bindTypes_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "hasMany"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checkhasrelationship", NULL, 444, &_0, &modelName, &modelRelation); + zephir_memory_observe(¤tConditions); + zephir_read_property(¤tConditions, this_ptr, ZEND_STRL("having"), PH_NOISY_CC); + if (zephir_is_true(¤tConditions)) { + ZEPHIR_INIT_VAR(&_0$$3); + ZEPHIR_CONCAT_SVSVS(&_0$$3, "(", ¤tConditions, ") AND (", &conditions, ")"); + zephir_get_strval(&conditions, &_0$$3); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "having", NULL, 0, &conditions, &bindParams, &bindTypes); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, hasHasManyToMany) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, andWhere) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL, _0; - zval modelName, modelRelation; + zval bindParams, bindTypes; + zval *conditions_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, currentConditions, _0$$3; + zval conditions; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(¤tConditions); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(conditions) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams_param, &bindTypes_param); + if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { + zephir_get_strval(&conditions, conditions_param); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_INIT_VAR(&conditions); } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); - RETURN_MM_NULL(); + if (!bindParams_param) { + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); + } else { + zephir_get_arrval(&bindParams, bindParams_param); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); + if (!bindTypes_param) { + ZEPHIR_INIT_VAR(&bindTypes); + array_init(&bindTypes); } else { - ZEPHIR_INIT_VAR(&modelRelation); + zephir_get_arrval(&bindTypes, bindTypes_param); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "hasManyToMany"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checkhasrelationship", NULL, 444, &_0, &modelName, &modelRelation); + zephir_memory_observe(¤tConditions); + zephir_read_property(¤tConditions, this_ptr, ZEND_STRL("conditions"), PH_NOISY_CC); + if (zephir_is_true(¤tConditions)) { + ZEPHIR_INIT_VAR(&_0$$3); + ZEPHIR_CONCAT_SVSVS(&_0$$3, "(", ¤tConditions, ") AND (", &conditions, ")"); + zephir_get_strval(&conditions, &_0$$3); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "where", NULL, 0, &conditions, &bindParams, &bindTypes); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, hasHasOne) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, autoescape) { + zend_bool _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL, _0; - zval modelName, modelRelation; - zval *this_ptr = getThis(); + zval *identifier_param = NULL; + zval identifier; - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) + ZVAL_UNDEF(&identifier); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(identifier) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); - } else { - ZEPHIR_INIT_VAR(&modelName); + zephir_fetch_params(1, 1, 0, &identifier_param); + zephir_get_strval(&identifier, identifier_param); + _0 = zephir_memnstr_str(&identifier, SL("["), "phalcon/Mvc/Model/Query/Builder.zep", 418); + if (!(_0)) { + _0 = zephir_memnstr_str(&identifier, SL("."), "phalcon/Mvc/Model/Query/Builder.zep", 418); } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); - RETURN_MM_NULL(); + _1 = _0; + if (!(_1)) { + _1 = zephir_is_numeric(&identifier); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); - } else { - ZEPHIR_INIT_VAR(&modelRelation); + if (_1) { + RETURN_CTOR(&identifier); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "hasOne"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checkhasrelationship", NULL, 444, &_0, &modelName, &modelRelation); - zephir_check_call_status(); + ZEPHIR_CONCAT_SVS(return_value, "[", &identifier, "]"); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, hasHasOneThrough) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, betweenHaving) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, *modelRelation_param = NULL, _0; - zval modelName, modelRelation; + zval *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, *operator_param = NULL, _0; + zval expr, operator; zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); + ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&operator); + ZVAL_UNDEF(&minimum_sub); + ZVAL_UNDEF(&maximum_sub); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &modelName_param, &modelRelation_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_STR(expr) + Z_PARAM_ZVAL(minimum) + Z_PARAM_ZVAL(maximum) + Z_PARAM_OPTIONAL + Z_PARAM_STR(operator) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 1, &expr_param, &minimum, &maximum, &operator_param); + if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); + if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { + zephir_get_strval(&expr, expr_param); } else { - ZEPHIR_INIT_VAR(&modelName); + ZEPHIR_INIT_VAR(&expr); } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); + if (!operator_param) { + ZEPHIR_INIT_VAR(&operator); + ZVAL_STRING(&operator, "and"); + } else { + if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); + if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { + zephir_get_strval(&operator, operator_param); } else { - ZEPHIR_INIT_VAR(&modelRelation); + ZEPHIR_INIT_VAR(&operator); + } } ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "hasOneThrough"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checkhasrelationship", NULL, 444, &_0, &modelName, &modelRelation); + ZVAL_STRING(&_0, "Having"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionbetween", NULL, 0, &_0, &operator, &expr, minimum, maximum); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, initialize) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, betweenWhere) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, __$true, className, eventsManager, _0, _1, _2$$5; + zval *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, *operator_param = NULL, _0; + zval expr, operator; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&operator); + ZVAL_UNDEF(&minimum_sub); + ZVAL_UNDEF(&maximum_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$5); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_STR(expr) + Z_PARAM_ZVAL(minimum) + Z_PARAM_ZVAL(maximum) + Z_PARAM_OPTIONAL + Z_PARAM_STR(operator) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZEPHIR_INIT_VAR(&className); - zephir_get_class(&className, model, 1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset(&_0, &className)) { - RETURN_MM_BOOL(0); - } - zephir_update_property_array(this_ptr, SL("initialized"), &className, &__$true); - if ((zephir_method_exists_ex(model, ZEND_STRL("initialize")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(NULL, model, "initialize", NULL, 0); - zephir_check_call_status(); + zephir_fetch_params(1, 3, 1, &expr_param, &minimum, &maximum, &operator_param); + if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + RETURN_MM_NULL(); } - zephir_update_property_zval(this_ptr, ZEND_STRL("lastInitialized"), model); - zephir_read_property(&_1, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_1); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_2$$5); - ZVAL_STRING(&_2$$5, "modelsManager:afterInitialize"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_2$$5, this_ptr, model); - zephir_check_call_status(); + if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { + zephir_get_strval(&expr, expr_param); + } else { + ZEPHIR_INIT_VAR(&expr); } - RETURN_MM_BOOL(1); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Manager, isInitialized) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *className_param = NULL, _0, _1; - zval className; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(className) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &className_param); - if (UNEXPECTED(Z_TYPE_P(className_param) != IS_STRING && Z_TYPE_P(className_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'className' must be of the type string")); + if (!operator_param) { + ZEPHIR_INIT_VAR(&operator); + ZVAL_STRING(&operator, "and"); + } else { + if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(className_param) == IS_STRING)) { - zephir_get_strval(&className, className_param); + if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { + zephir_get_strval(&operator, operator_param); } else { - ZEPHIR_INIT_VAR(&className); + ZEPHIR_INIT_VAR(&operator); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_fast_strtolower(&_1, &className); - RETURN_MM_BOOL(zephir_array_isset(&_0, &_1)); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "Where"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionbetween", NULL, 0, &_0, &operator, &expr, minimum, maximum); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, isKeepingSnapshots) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, columns) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, isKeeping, _0, _1; + zval *columns, columns_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&isKeeping); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&columns_sub); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ZVAL(columns) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - if (ZEPHIR_GLOBAL(orm).dynamic_update) { - RETURN_MM_BOOL(1); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (!(zephir_array_isset_fetch(&isKeeping, &_0, &_1, 1))) { - RETURN_MM_BOOL(0); - } - RETURN_CTOR(&isKeeping); + zephir_fetch_params_without_memory_grow(1, 0, &columns); + zephir_update_property_zval(this_ptr, ZEND_STRL("columns"), columns); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, isUsingDynamicUpdate) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, distinct) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, isUsing, _0, _1; + zval *distinct, distinct_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&isUsing); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&distinct_sub); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ZVAL(distinct) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - if (ZEPHIR_GLOBAL(orm).dynamic_update) { - RETURN_MM_BOOL(1); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("dynamicUpdate"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (!(zephir_array_isset_fetch(&isUsing, &_0, &_1, 1))) { - RETURN_MM_BOOL(0); - } - RETURN_CTOR(&isUsing); + zephir_fetch_params_without_memory_grow(1, 0, &distinct); + zephir_update_property_zval(this_ptr, ZEND_STRL("distinct"), distinct); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, isVisibleModelProperty) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, forUpdate) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval property; - zval *model, model_sub, *property_param = NULL, __$true, properties, className, publicProperties, classReflection, reflectionProperties, reflectionProperty, _0, _6, _1$$3, *_2$$3, _3$$3, _4$$4, _5$$5; + zval *forUpdate_param = NULL, __$true, __$false; + zend_bool forUpdate; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&properties); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&publicProperties); - ZVAL_UNDEF(&classReflection); - ZVAL_UNDEF(&reflectionProperties); - ZVAL_UNDEF(&reflectionProperty); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&property); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_STR(property) + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(forUpdate) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &property_param); - zephir_get_strval(&property, property_param); - ZEPHIR_INIT_VAR(&className); - zephir_get_class(&className, model, 0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelVisibility"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset(&_0, &className))) { - ZEPHIR_INIT_VAR(&publicProperties); - array_init(&publicProperties); - ZEPHIR_INIT_VAR(&classReflection); - object_init_ex(&classReflection, zephir_get_internal_ce(SL("reflectionclass"))); - ZEPHIR_CALL_METHOD(NULL, &classReflection, "__construct", NULL, 154, &className); - zephir_check_call_status(); - ZVAL_LONG(&_1$$3, 1); - ZEPHIR_CALL_METHOD(&reflectionProperties, &classReflection, "getproperties", NULL, 165, &_1$$3); - zephir_check_call_status(); - zephir_is_iterable(&reflectionProperties, 0, "phalcon/Mvc/Model/Manager.zep", 1915); - if (Z_TYPE_P(&reflectionProperties) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&reflectionProperties), _2$$3) - { - ZEPHIR_INIT_NVAR(&reflectionProperty); - ZVAL_COPY(&reflectionProperty, _2$$3); - ZEPHIR_OBS_NVAR(&_4$$4); - zephir_read_property(&_4$$4, &reflectionProperty, ZEND_STRL("name"), PH_NOISY_CC); - zephir_array_update_zval(&publicProperties, &_4$$4, &__$true, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &reflectionProperties, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$3, &reflectionProperties, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&reflectionProperty, &reflectionProperties, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&_5$$5); - zephir_read_property(&_5$$5, &reflectionProperty, ZEND_STRL("name"), PH_NOISY_CC); - zephir_array_update_zval(&publicProperties, &_5$$5, &__$true, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &reflectionProperties, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&reflectionProperty); - zephir_update_property_array(this_ptr, SL("modelVisibility"), &className, &publicProperties); + zephir_fetch_params_without_memory_grow(1, 0, &forUpdate_param); + if (forUpdate) { + zephir_update_property_zval(this_ptr, ZEND_STRL("forUpdate"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("forUpdate"), &__$false); } - zephir_read_property(&_6, this_ptr, ZEND_STRL("modelVisibility"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&properties); - zephir_array_fetch(&properties, &_6, &className, PH_NOISY, "phalcon/Mvc/Model/Manager.zep", 1918); - RETURN_MM_BOOL(zephir_array_key_exists(&properties, &property)); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, keepSnapshots) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, from) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool keepSnapshots; - zval *model, model_sub, *keepSnapshots_param = NULL, _0, _1; + zval *models, models_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_BOOL(keepSnapshots) + ZVAL_UNDEF(&models_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(models) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &keepSnapshots_param); - ZEPHIR_INIT_VAR(&_0); - zephir_get_class(&_0, model, 1); - ZEPHIR_INIT_VAR(&_1); - ZVAL_BOOL(&_1, keepSnapshots); - zephir_update_property_array(this_ptr, SL("keepSnapshots"), &_0, &_1); - ZEPHIR_MM_RESTORE(); + zephir_fetch_params_without_memory_grow(1, 0, &models); + zephir_update_property_zval(this_ptr, ZEND_STRL("models"), models); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, load) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getBindParams) { - zval _2; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelName_param = NULL, __$null, model, _3, _0$$3; - zval modelName, _1$$3; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&_1$$3); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(modelName) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &modelName_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); - } else { - ZEPHIR_INIT_VAR(&modelName); - } - if (UNEXPECTED(!(zephir_class_exists(&modelName, 1)))) { - ZEPHIR_INIT_VAR(&_0$$3); - object_init_ex(&_0$$3, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_1$$3); - ZEPHIR_CONCAT_SVS(&_1$$3, "Model '", &modelName, "' could not be loaded"); - ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 33, &_1$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_0$$3, "phalcon/Mvc/Model/Manager.zep", 1953); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 3, 0); - zephir_array_fast_append(&_2, &__$null); - zephir_memory_observe(&_3); - zephir_read_property(&_3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC); - zephir_array_fast_append(&_2, &_3); - zephir_array_fast_append(&_2, this_ptr); - ZEPHIR_INIT_VAR(&model); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&model, &modelName, &_2); - zephir_check_call_status(); - RETURN_CCTOR(&model); + RETURN_MEMBER(getThis(), "bindParams"); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, notifyEvent) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getBindTypes) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *eventName_param = NULL, *model, model_sub, status, behavior, modelsBehaviors, eventsManager, customEventsManager, _0, _1, _4, _6, *_2$$3, _3$$3; - zval eventName, _5$$8, _7$$10; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&_5$$8); - ZVAL_UNDEF(&_7$$10); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&status); - ZVAL_UNDEF(&behavior); - ZVAL_UNDEF(&modelsBehaviors); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&customEventsManager); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_3$$3); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(eventName) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &eventName_param, &model); - if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { - zephir_get_strval(&eventName, eventName_param); - } else { - ZEPHIR_INIT_VAR(&eventName); - } - ZEPHIR_INIT_VAR(&status); - ZVAL_BOOL(&status, 1); - zephir_memory_observe(&modelsBehaviors); - zephir_read_property(&_0, this_ptr, ZEND_STRL("behaviors"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (zephir_array_isset_fetch(&modelsBehaviors, &_0, &_1, 0)) { - zephir_is_iterable(&modelsBehaviors, 0, "phalcon/Mvc/Model/Manager.zep", 2000); - if (Z_TYPE_P(&modelsBehaviors) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&modelsBehaviors), _2$$3) - { - ZEPHIR_INIT_NVAR(&behavior); - ZVAL_COPY(&behavior, _2$$3); - ZEPHIR_CALL_METHOD(&status, &behavior, "notify", NULL, 0, &eventName, model); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) { - RETURN_MM_BOOL(0); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$3, &modelsBehaviors, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&behavior, &modelsBehaviors, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&status, &behavior, "notify", NULL, 0, &eventName, model); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) { - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&behavior); - } - zephir_read_property(&_4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_4); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_5$$8); - ZEPHIR_CONCAT_SV(&_5$$8, "model:", &eventName); - ZEPHIR_CALL_METHOD(&status, &eventsManager, "fire", NULL, 0, &_5$$8, model); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) { - RETURN_CCTOR(&status); - } - } - zephir_memory_observe(&customEventsManager); - zephir_read_property(&_4, this_ptr, ZEND_STRL("customEventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_6); - zephir_get_class(&_6, model, 1); - if (zephir_array_isset_fetch(&customEventsManager, &_4, &_6, 0)) { - ZEPHIR_INIT_VAR(&_7$$10); - ZEPHIR_CONCAT_SV(&_7$$10, "model:", &eventName); - ZEPHIR_CALL_METHOD(&status, &customEventsManager, "fire", NULL, 0, &_7$$10, model); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) { - RETURN_MM_BOOL(0); - } - } - RETURN_CCTOR(&status); + RETURN_MEMBER(getThis(), "bindTypes"); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, missingMethod) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getColumns) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval eventName, _5$$8; - zval *model, model_sub, *eventName_param = NULL, *data, data_sub, modelsBehaviors, result, eventsManager, behavior, _0, _1, _4, *_2$$3, _3$$3; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data_sub); - ZVAL_UNDEF(&modelsBehaviors); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&behavior); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&eventName); - ZVAL_UNDEF(&_5$$8); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_STR(eventName) - Z_PARAM_ZVAL(data) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &model, &eventName_param, &data); - if (UNEXPECTED(Z_TYPE_P(eventName_param) != IS_STRING && Z_TYPE_P(eventName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(eventName_param) == IS_STRING)) { - zephir_get_strval(&eventName, eventName_param); - } else { - ZEPHIR_INIT_VAR(&eventName); - } - zephir_memory_observe(&modelsBehaviors); - zephir_read_property(&_0, this_ptr, ZEND_STRL("behaviors"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_get_class(&_1, model, 1); - if (zephir_array_isset_fetch(&modelsBehaviors, &_0, &_1, 0)) { - zephir_is_iterable(&modelsBehaviors, 0, "phalcon/Mvc/Model/Manager.zep", 2062); - if (Z_TYPE_P(&modelsBehaviors) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&modelsBehaviors), _2$$3) - { - ZEPHIR_INIT_NVAR(&behavior); - ZVAL_COPY(&behavior, _2$$3); - ZEPHIR_CALL_METHOD(&result, &behavior, "missingmethod", NULL, 0, model, &eventName, data); - zephir_check_call_status(); - if (Z_TYPE_P(&result) != IS_NULL) { - RETURN_CCTOR(&result); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$3, &modelsBehaviors, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&behavior, &modelsBehaviors, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&result, &behavior, "missingmethod", NULL, 0, model, &eventName, data); - zephir_check_call_status(); - if (Z_TYPE_P(&result) != IS_NULL) { - RETURN_CCTOR(&result); - } - ZEPHIR_CALL_METHOD(NULL, &modelsBehaviors, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&behavior); - } - zephir_read_property(&_4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_4); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_5$$8); - ZEPHIR_CONCAT_SV(&_5$$8, "model:", &eventName); - ZEPHIR_RETURN_CALL_METHOD(&eventsManager, "fire", NULL, 0, &_5$$8, model, data); - zephir_check_call_status(); - RETURN_MM(); - } - RETURN_MM_NULL(); + RETURN_MEMBER(getThis(), "columns"); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setConnectionService) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getDI) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval connectionService; - zval *model, model_sub, *connectionService_param = NULL; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&connectionService); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_STR(connectionService) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &connectionService_param); - if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) { - zephir_get_strval(&connectionService, connectionService_param); - } else { - ZEPHIR_INIT_VAR(&connectionService); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setreadconnectionservice", NULL, 0, model, &connectionService); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setwriteconnectionservice", NULL, 0, model, &connectionService); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MEMBER(getThis(), "container"); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setCustomEventsManager) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getDistinct) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model, model_sub, *eventsManager, eventsManager_sub, _0; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&eventsManager_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &eventsManager); - ZEPHIR_INIT_VAR(&_0); - zephir_get_class(&_0, model, 1); - zephir_update_property_array(this_ptr, SL("customEventsManager"), &_0, eventsManager); - ZEPHIR_MM_RESTORE(); + RETURN_MEMBER(getThis(), "distinct"); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setDI) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getFrom) { - zval *container, container_sub; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&container_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &container); - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); + RETURN_MEMBER(getThis(), "models"); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setEventsManager) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getGroupBy) { - zval *eventsManager, eventsManager_sub; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&eventsManager_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); - zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); + RETURN_MEMBER(getThis(), "group"); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setModelPrefix) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getHaving) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *prefix_param = NULL; - zval prefix; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&prefix); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(prefix) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &prefix_param); - if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) { - zephir_get_strval(&prefix, prefix_param); - } else { - ZEPHIR_INIT_VAR(&prefix); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("prefix"), &prefix); - ZEPHIR_MM_RESTORE(); + RETURN_MEMBER(getThis(), "having"); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setModelSchema) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getJoins) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval schema; - zval *model, model_sub, *schema_param = NULL, _0; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&schema); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_STR(schema) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &schema_param); - if (UNEXPECTED(Z_TYPE_P(schema_param) != IS_STRING && Z_TYPE_P(schema_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'schema' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(schema_param) == IS_STRING)) { - zephir_get_strval(&schema, schema_param); - } else { - ZEPHIR_INIT_VAR(&schema); - } - ZEPHIR_INIT_VAR(&_0); - zephir_get_class(&_0, model, 1); - zephir_update_property_array(this_ptr, SL("schemas"), &_0, &schema); - ZEPHIR_MM_RESTORE(); + RETURN_MEMBER(getThis(), "joins"); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setModelSource) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getLimit) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval source; - zval *model, model_sub, *source_param = NULL, _0; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&source); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_STR(source) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &source_param); - if (UNEXPECTED(Z_TYPE_P(source_param) != IS_STRING && Z_TYPE_P(source_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'source' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(source_param) == IS_STRING)) { - zephir_get_strval(&source, source_param); - } else { - ZEPHIR_INIT_VAR(&source); - } - ZEPHIR_INIT_VAR(&_0); - zephir_get_class(&_0, model, 1); - zephir_update_property_array(this_ptr, SL("sources"), &_0, &source); - ZEPHIR_MM_RESTORE(); + RETURN_MEMBER(getThis(), "limit"); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setReadConnectionService) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getModels) { + zend_bool _1; + zval models, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval connectionService; - zval *model, model_sub, *connectionService_param = NULL, _0; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&models); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&connectionService); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_STR(connectionService) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &connectionService_param); - if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) { - zephir_get_strval(&connectionService, connectionService_param); - } else { - ZEPHIR_INIT_VAR(&connectionService); - } - ZEPHIR_INIT_VAR(&_0); - zephir_get_class(&_0, model, 1); - zephir_update_property_array(this_ptr, SL("readConnectionServices"), &_0, &connectionService); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setReusableRecords) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *modelName_param = NULL, *key_param = NULL, *records, records_sub; - zval modelName, key; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&records_sub); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_STR(modelName) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(records) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &modelName_param, &key_param, &records); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); - } else { - ZEPHIR_INIT_VAR(&modelName); - } - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&models, &_0); + _1 = Z_TYPE_P(&models) == IS_ARRAY; + if (_1) { + _1 = zephir_fast_count_int(&models) == 1; } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); + if (_1) { + ZEPHIR_MAKE_REF(&models); + ZEPHIR_RETURN_CALL_FUNCTION("reset", NULL, 477, &models); + ZEPHIR_UNREF(&models); + zephir_check_call_status(); + RETURN_MM(); } - zephir_update_property_array(this_ptr, SL("reusable"), &key, records); - ZEPHIR_MM_RESTORE(); + RETURN_CCTOR(&models); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, setWriteConnectionService) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getOffset) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval connectionService; - zval *model, model_sub, *connectionService_param = NULL, _0; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&connectionService); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_STR(connectionService) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &connectionService_param); - if (UNEXPECTED(Z_TYPE_P(connectionService_param) != IS_STRING && Z_TYPE_P(connectionService_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'connectionService' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(connectionService_param) == IS_STRING)) { - zephir_get_strval(&connectionService, connectionService_param); - } else { - ZEPHIR_INIT_VAR(&connectionService); - } - ZEPHIR_INIT_VAR(&_0); - zephir_get_class(&_0, model, 1); - zephir_update_property_array(this_ptr, SL("writeConnectionServices"), &_0, &connectionService); - ZEPHIR_MM_RESTORE(); + RETURN_MEMBER(getThis(), "offset"); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, useDynamicUpdate) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getOrderBy) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool dynamicUpdate; - zval *model, model_sub, *dynamicUpdate_param = NULL, entityName, _0, _1; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&entityName); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_BOOL(dynamicUpdate) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &dynamicUpdate_param); - ZEPHIR_INIT_VAR(&entityName); - zephir_get_class(&entityName, model, 1); - ZEPHIR_INIT_VAR(&_0); - ZVAL_BOOL(&_0, dynamicUpdate); - zephir_update_property_array(this_ptr, SL("dynamicUpdate"), &entityName, &_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_BOOL(&_1, dynamicUpdate); - zephir_update_property_array(this_ptr, SL("keepSnapshots"), &entityName, &_1); - ZEPHIR_MM_RESTORE(); + RETURN_MEMBER(getThis(), "order"); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, getConnection) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getPhql) { + zend_string *_12$$26, *_21$$35, *_32$$43; + zend_ulong _11$$26, _20$$35, _31$$43; + zval _2$$8; + zend_bool noPrimary = 0, _86$$86; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval __$null, container, models, conditions, model, metaData, modelInstance, primaryKeys, firstPrimaryKey, columnMap, modelAlias, attributeField, phql, column, columns, selectedColumns, selectedColumn, selectedModel, selectedModels, columnAlias, modelColumnAlias, joins, join, joinModel, joinConditions, joinAlias, joinType, group, groupItems, groupItem, having, order, orderItems, orderItem, limit, number, offset, forUpdate, distinct, _0, _1$$8, _3$$17, _4$$17, _5$$19, _6$$13, _7$$13, _8$$13, *_9$$26, _10$$26, _17$$26, _13$$29, _14$$29, _15$$32, _16$$32, *_18$$35, _19$$35, _26$$35, _22$$37, _23$$38, _24$$40, _25$$41, _27$$42, _28$$42, *_29$$43, _30$$43, _37$$43, _38$$43, _33$$45, _34$$45, _35$$48, _36$$48, _39$$50, _40$$50, *_41$$51, _42$$51, _43$$53, _44$$53, _45$$54, _46$$54, _47$$55, _48$$55, _49$$56, _50$$58, _51$$58, _52$$59, _53$$59, _54$$60, _55$$60, _56$$61, _57$$63, *_58$$64, _59$$64, _62$$64, _63$$64, _60$$65, _61$$66, _64$$68, *_65$$70, _66$$70, _77$$70, _78$$70, itemExplode$$73, _67$$73, _68$$73, _69$$73, _70$$73, _71$$71, itemExplode$$76, _72$$76, _73$$76, _74$$76, _75$$76, _76$$74, _79$$77, _80$$83, _81$$86, _82$$86, _83$$86, _84$$86, _85$$86, _87$$87, _88$$87, _89$$87, _90$$87, _91$$87; zend_long ZEPHIR_LAST_CALL_STATUS; - zval connectionServices; - zval *model, model_sub, *connectionServices_param = NULL, container, service, connection, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&container); - ZVAL_UNDEF(&service); - ZVAL_UNDEF(&connection); + ZVAL_UNDEF(&models); + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&modelInstance); + ZVAL_UNDEF(&primaryKeys); + ZVAL_UNDEF(&firstPrimaryKey); + ZVAL_UNDEF(&columnMap); + ZVAL_UNDEF(&modelAlias); + ZVAL_UNDEF(&attributeField); + ZVAL_UNDEF(&phql); + ZVAL_UNDEF(&column); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&selectedColumns); + ZVAL_UNDEF(&selectedColumn); + ZVAL_UNDEF(&selectedModel); + ZVAL_UNDEF(&selectedModels); + ZVAL_UNDEF(&columnAlias); + ZVAL_UNDEF(&modelColumnAlias); + ZVAL_UNDEF(&joins); + ZVAL_UNDEF(&join); + ZVAL_UNDEF(&joinModel); + ZVAL_UNDEF(&joinConditions); + ZVAL_UNDEF(&joinAlias); + ZVAL_UNDEF(&joinType); + ZVAL_UNDEF(&group); + ZVAL_UNDEF(&groupItems); + ZVAL_UNDEF(&groupItem); + ZVAL_UNDEF(&having); + ZVAL_UNDEF(&order); + ZVAL_UNDEF(&orderItems); + ZVAL_UNDEF(&orderItem); + ZVAL_UNDEF(&limit); + ZVAL_UNDEF(&number); + ZVAL_UNDEF(&offset); + ZVAL_UNDEF(&forUpdate); + ZVAL_UNDEF(&distinct); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&connectionServices); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ARRAY(connectionServices) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1$$8); + ZVAL_UNDEF(&_3$$17); + ZVAL_UNDEF(&_4$$17); + ZVAL_UNDEF(&_5$$19); + ZVAL_UNDEF(&_6$$13); + ZVAL_UNDEF(&_7$$13); + ZVAL_UNDEF(&_8$$13); + ZVAL_UNDEF(&_10$$26); + ZVAL_UNDEF(&_17$$26); + ZVAL_UNDEF(&_13$$29); + ZVAL_UNDEF(&_14$$29); + ZVAL_UNDEF(&_15$$32); + ZVAL_UNDEF(&_16$$32); + ZVAL_UNDEF(&_19$$35); + ZVAL_UNDEF(&_26$$35); + ZVAL_UNDEF(&_22$$37); + ZVAL_UNDEF(&_23$$38); + ZVAL_UNDEF(&_24$$40); + ZVAL_UNDEF(&_25$$41); + ZVAL_UNDEF(&_27$$42); + ZVAL_UNDEF(&_28$$42); + ZVAL_UNDEF(&_30$$43); + ZVAL_UNDEF(&_37$$43); + ZVAL_UNDEF(&_38$$43); + ZVAL_UNDEF(&_33$$45); + ZVAL_UNDEF(&_34$$45); + ZVAL_UNDEF(&_35$$48); + ZVAL_UNDEF(&_36$$48); + ZVAL_UNDEF(&_39$$50); + ZVAL_UNDEF(&_40$$50); + ZVAL_UNDEF(&_42$$51); + ZVAL_UNDEF(&_43$$53); + ZVAL_UNDEF(&_44$$53); + ZVAL_UNDEF(&_45$$54); + ZVAL_UNDEF(&_46$$54); + ZVAL_UNDEF(&_47$$55); + ZVAL_UNDEF(&_48$$55); + ZVAL_UNDEF(&_49$$56); + ZVAL_UNDEF(&_50$$58); + ZVAL_UNDEF(&_51$$58); + ZVAL_UNDEF(&_52$$59); + ZVAL_UNDEF(&_53$$59); + ZVAL_UNDEF(&_54$$60); + ZVAL_UNDEF(&_55$$60); + ZVAL_UNDEF(&_56$$61); + ZVAL_UNDEF(&_57$$63); + ZVAL_UNDEF(&_59$$64); + ZVAL_UNDEF(&_62$$64); + ZVAL_UNDEF(&_63$$64); + ZVAL_UNDEF(&_60$$65); + ZVAL_UNDEF(&_61$$66); + ZVAL_UNDEF(&_64$$68); + ZVAL_UNDEF(&_66$$70); + ZVAL_UNDEF(&_77$$70); + ZVAL_UNDEF(&_78$$70); + ZVAL_UNDEF(&itemExplode$$73); + ZVAL_UNDEF(&_67$$73); + ZVAL_UNDEF(&_68$$73); + ZVAL_UNDEF(&_69$$73); + ZVAL_UNDEF(&_70$$73); + ZVAL_UNDEF(&_71$$71); + ZVAL_UNDEF(&itemExplode$$76); + ZVAL_UNDEF(&_72$$76); + ZVAL_UNDEF(&_73$$76); + ZVAL_UNDEF(&_74$$76); + ZVAL_UNDEF(&_75$$76); + ZVAL_UNDEF(&_76$$74); + ZVAL_UNDEF(&_79$$77); + ZVAL_UNDEF(&_80$$83); + ZVAL_UNDEF(&_81$$86); + ZVAL_UNDEF(&_82$$86); + ZVAL_UNDEF(&_83$$86); + ZVAL_UNDEF(&_84$$86); + ZVAL_UNDEF(&_85$$86); + ZVAL_UNDEF(&_87$$87); + ZVAL_UNDEF(&_88$$87); + ZVAL_UNDEF(&_89$$87); + ZVAL_UNDEF(&_90$$87); + ZVAL_UNDEF(&_91$$87); + ZVAL_UNDEF(&_2$$8); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &connectionServices_param); - zephir_get_arrval(&connectionServices, connectionServices_param); - ZEPHIR_CALL_METHOD(&service, this_ptr, "getconnectionservice", NULL, 0, model, &connectionServices); - zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CPY_WRT(&container, &_0); - if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injection container is required to access the services related to the ORM", "phalcon/Mvc/Model/Manager.zep", 2267); - return; + if (Z_TYPE_P(&container) != IS_OBJECT) { + ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &container); } - ZEPHIR_CALL_METHOD(&_1, &container, "getshared", NULL, 0, &service); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&connection, &_1); - if (UNEXPECTED(Z_TYPE_P(&connection) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid injected connection service", "phalcon/Mvc/Model/Manager.zep", 2276); - return; + zephir_read_property(&_0, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&models, &_0); + if (Z_TYPE_P(&models) == IS_ARRAY) { + if (UNEXPECTED(!(zephir_fast_count_int(&models)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "At least one model is required to build the query", "phalcon/Mvc/Model/Query/Builder.zep", 705); + return; + } + } else { + if (UNEXPECTED(!zephir_is_true(&models))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "At least one model is required to build the query", "phalcon/Mvc/Model/Query/Builder.zep", 711); + return; + } } - RETURN_CCTOR(&connection); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Manager, mergeFindParameters) -{ - zend_bool _6$$6, _9$$11, _16$$17, _17$$17, _22$$26, _23$$26; - zend_string *_5$$5, *_15$$16; - zend_ulong _4$$5, _14$$16; - zval findParams; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *findParamsOne = NULL, findParamsOne_sub, *findParamsTwo = NULL, findParamsTwo_sub, key, value, _0$$3, _1$$4, *_2$$5, _3$$5, _7$$9, _8$$9, _10$$14, _11$$14, *_12$$16, _13$$16, _18$$20, _19$$20, _20$$24, _21$$24, _24$$29, _25$$29, _26$$33, _27$$33; - - ZVAL_UNDEF(&findParamsOne_sub); - ZVAL_UNDEF(&findParamsTwo_sub); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_7$$9); - ZVAL_UNDEF(&_8$$9); - ZVAL_UNDEF(&_10$$14); - ZVAL_UNDEF(&_11$$14); - ZVAL_UNDEF(&_13$$16); - ZVAL_UNDEF(&_18$$20); - ZVAL_UNDEF(&_19$$20); - ZVAL_UNDEF(&_20$$24); - ZVAL_UNDEF(&_21$$24); - ZVAL_UNDEF(&_24$$29); - ZVAL_UNDEF(&_25$$29); - ZVAL_UNDEF(&_26$$33); - ZVAL_UNDEF(&_27$$33); - ZVAL_UNDEF(&findParams); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(findParamsOne) - Z_PARAM_ZVAL(findParamsTwo) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &findParamsOne, &findParamsTwo); - ZEPHIR_SEPARATE_PARAM(findParamsOne); - ZEPHIR_SEPARATE_PARAM(findParamsTwo); - ZEPHIR_INIT_VAR(&findParams); - array_init(&findParams); - if (Z_TYPE_P(findParamsOne) == IS_STRING) { - ZEPHIR_INIT_VAR(&_0$$3); - zephir_create_array(&_0$$3, 1, 0); - zephir_array_update_string(&_0$$3, SL("conditions"), findParamsOne, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(findParamsOne, &_0$$3); - } - if (Z_TYPE_P(findParamsTwo) == IS_STRING) { - ZEPHIR_INIT_VAR(&_1$$4); - zephir_create_array(&_1$$4, 1, 0); - zephir_array_update_string(&_1$$4, SL("conditions"), findParamsTwo, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(findParamsTwo, &_1$$4); - } - if (Z_TYPE_P(findParamsOne) == IS_ARRAY) { - zephir_is_iterable(findParamsOne, 0, "phalcon/Mvc/Model/Manager.zep", 2321); - if (Z_TYPE_P(findParamsOne) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(findParamsOne), _4$$5, _5$$5, _2$$5) - { - ZEPHIR_INIT_NVAR(&key); - if (_5$$5 != NULL) { - ZVAL_STR_COPY(&key, _5$$5); + zephir_read_property(&_0, this_ptr, ZEND_STRL("conditions"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&conditions, &_0); + if (zephir_is_numeric(&conditions)) { + if (Z_TYPE_P(&models) == IS_ARRAY) { + if (UNEXPECTED(zephir_fast_count_int(&models) > 1)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Cannot build the query. Invalid condition", "phalcon/Mvc/Model/Query/Builder.zep", 726); + return; + } + zephir_memory_observe(&model); + zephir_array_fetch_long(&model, &models, 0, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 729); + } else { + ZEPHIR_CPY_WRT(&model, &models); + } + ZEPHIR_INIT_VAR(&_1$$8); + ZVAL_STRING(&_1$$8, "modelsMetadata"); + ZEPHIR_CALL_METHOD(&metaData, &container, "getshared", NULL, 0, &_1$$8); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2$$8); + zephir_create_array(&_2$$8, 2, 0); + zephir_array_fast_append(&_2$$8, &__$null); + zephir_array_fast_append(&_2$$8, &container); + ZEPHIR_INIT_VAR(&modelInstance); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&modelInstance, &model, &_2$$8); + zephir_check_call_status(); + noPrimary = 1; + ZEPHIR_CALL_METHOD(&primaryKeys, &metaData, "getprimarykeyattributes", NULL, 0, &modelInstance); + zephir_check_call_status(); + if (zephir_fast_count_int(&primaryKeys)) { + zephir_memory_observe(&firstPrimaryKey); + if (zephir_array_isset_long_fetch(&firstPrimaryKey, &primaryKeys, 0, 0)) { + if (ZEPHIR_GLOBAL(orm).column_renaming) { + ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", NULL, 0, &modelInstance); + zephir_check_call_status(); } else { - ZVAL_LONG(&key, _4$$5); + ZEPHIR_INIT_NVAR(&columnMap); + ZVAL_NULL(&columnMap); } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _2$$5); - _6$$6 = ZEPHIR_IS_LONG_IDENTICAL(&key, 0); - if (!(_6$$6)) { - _6$$6 = ZEPHIR_IS_STRING_IDENTICAL(&key, "conditions"); + if (Z_TYPE_P(&columnMap) == IS_ARRAY) { + zephir_memory_observe(&attributeField); + if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &firstPrimaryKey, 0)))) { + ZEPHIR_INIT_VAR(&_3$$17); + object_init_ex(&_3$$17, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_4$$17); + ZEPHIR_CONCAT_SVS(&_4$$17, "Column '", &firstPrimaryKey, "' isn't part of the column map"); + ZEPHIR_CALL_METHOD(NULL, &_3$$17, "__construct", NULL, 33, &_4$$17); + zephir_check_call_status(); + zephir_throw_exception_debug(&_3$$17, "phalcon/Mvc/Model/Query/Builder.zep", 765); + ZEPHIR_MM_RESTORE(); + return; + } + } else { + ZEPHIR_CPY_WRT(&attributeField, &firstPrimaryKey); } - if (_6$$6) { - if (!(zephir_array_isset_long(&findParams, 0))) { - zephir_array_update_long(&findParams, 0, &value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + if (Z_TYPE_P(&conditions) == IS_STRING) { + ZEPHIR_INIT_VAR(&_5$$19); + ZEPHIR_CONCAT_SVS(&_5$$19, "'", &conditions, "'"); + ZEPHIR_CPY_WRT(&conditions, &_5$$19); + } + ZEPHIR_CALL_METHOD(&_6$$13, this_ptr, "autoescape", NULL, 478, &model); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_7$$13, this_ptr, "autoescape", NULL, 478, &attributeField); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_8$$13); + ZEPHIR_CONCAT_VSVSV(&_8$$13, &_6$$13, ".", &_7$$13, " = ", &conditions); + ZEPHIR_CPY_WRT(&conditions, &_8$$13); + noPrimary = 0; + } + } + if (UNEXPECTED(noPrimary)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Source related to this model does not have a primary key defined", "phalcon/Mvc/Model/Query/Builder.zep", 792); + return; + } + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("distinct"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&distinct, &_0); + if (((Z_TYPE_P(&distinct) == IS_TRUE || Z_TYPE_P(&distinct) == IS_FALSE) == 1)) { + ZEPHIR_INIT_VAR(&phql); + if (zephir_is_true(&distinct)) { + ZVAL_STRING(&phql, "SELECT DISTINCT "); + } else { + ZVAL_STRING(&phql, "SELECT ALL "); + } + } else { + ZEPHIR_INIT_NVAR(&phql); + ZVAL_STRING(&phql, "SELECT "); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("columns"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&columns, &_0); + if (Z_TYPE_P(&columns) != IS_NULL) { + if (Z_TYPE_P(&columns) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&selectedColumns); + array_init(&selectedColumns); + zephir_is_iterable(&columns, 0, "phalcon/Mvc/Model/Query/Builder.zep", 825); + if (Z_TYPE_P(&columns) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&columns), _11$$26, _12$$26, _9$$26) + { + ZEPHIR_INIT_NVAR(&columnAlias); + if (_12$$26 != NULL) { + ZVAL_STR_COPY(&columnAlias, _12$$26); } else { - zephir_array_fetch_long(&_7$$9, &findParams, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 2315); - ZEPHIR_INIT_NVAR(&_8$$9); - ZEPHIR_CONCAT_SVSVS(&_8$$9, "(", &_7$$9, ") AND (", &value, ")"); - zephir_array_update_long(&findParams, 0, &_8$$9, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + ZVAL_LONG(&columnAlias, _11$$26); + } + ZEPHIR_INIT_NVAR(&column); + ZVAL_COPY(&column, _9$$26); + if (Z_TYPE_P(&columnAlias) == IS_LONG) { + zephir_array_append(&selectedColumns, &column, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 819); + } else { + ZEPHIR_CALL_METHOD(&_13$$29, this_ptr, "autoescape", NULL, 478, &columnAlias); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_14$$29); + ZEPHIR_CONCAT_VSV(&_14$$29, &column, " AS ", &_13$$29); + zephir_array_append(&selectedColumns, &_14$$29, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 821); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_10$$26, &columns, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_10$$26)) { + break; + } + ZEPHIR_CALL_METHOD(&columnAlias, &columns, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&column, &columns, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&columnAlias) == IS_LONG) { + zephir_array_append(&selectedColumns, &column, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 819); + } else { + ZEPHIR_CALL_METHOD(&_15$$32, this_ptr, "autoescape", NULL, 478, &columnAlias); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_16$$32); + ZEPHIR_CONCAT_VSV(&_16$$32, &column, " AS ", &_15$$32); + zephir_array_append(&selectedColumns, &_16$$32, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 821); + } + ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&column); + ZEPHIR_INIT_NVAR(&columnAlias); + ZEPHIR_INIT_VAR(&_17$$26); + zephir_fast_join_str(&_17$$26, SL(", "), &selectedColumns); + zephir_concat_self(&phql, &_17$$26); + } else { + zephir_concat_self(&phql, &columns); + } + } else { + if (Z_TYPE_P(&models) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&selectedColumns); + array_init(&selectedColumns); + zephir_is_iterable(&models, 0, "phalcon/Mvc/Model/Query/Builder.zep", 846); + if (Z_TYPE_P(&models) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&models), _20$$35, _21$$35, _18$$35) + { + ZEPHIR_INIT_NVAR(&modelColumnAlias); + if (_21$$35 != NULL) { + ZVAL_STR_COPY(&modelColumnAlias, _21$$35); + } else { + ZVAL_LONG(&modelColumnAlias, _20$$35); + } + ZEPHIR_INIT_NVAR(&model); + ZVAL_COPY(&model, _18$$35); + ZEPHIR_INIT_NVAR(&selectedColumn); + if (Z_TYPE_P(&modelColumnAlias) == IS_LONG) { + ZEPHIR_CALL_METHOD(&_22$$37, this_ptr, "autoescape", NULL, 478, &model); + zephir_check_call_status(); + ZEPHIR_CONCAT_VS(&selectedColumn, &_22$$37, ".*"); + } else { + ZEPHIR_CALL_METHOD(&_23$$38, this_ptr, "autoescape", NULL, 478, &modelColumnAlias); + zephir_check_call_status(); + ZEPHIR_CONCAT_VS(&selectedColumn, &_23$$38, ".*"); } + zephir_array_append(&selectedColumns, &selectedColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 843); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &models, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_19$$35, &models, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_19$$35)) { + break; + } + ZEPHIR_CALL_METHOD(&modelColumnAlias, &models, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&model, &models, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&selectedColumn); + if (Z_TYPE_P(&modelColumnAlias) == IS_LONG) { + ZEPHIR_CALL_METHOD(&_24$$40, this_ptr, "autoescape", NULL, 478, &model); + zephir_check_call_status(); + ZEPHIR_CONCAT_VS(&selectedColumn, &_24$$40, ".*"); + } else { + ZEPHIR_CALL_METHOD(&_25$$41, this_ptr, "autoescape", NULL, 478, &modelColumnAlias); + zephir_check_call_status(); + ZEPHIR_CONCAT_VS(&selectedColumn, &_25$$41, ".*"); + } + zephir_array_append(&selectedColumns, &selectedColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 843); + ZEPHIR_CALL_METHOD(NULL, &models, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&model); + ZEPHIR_INIT_NVAR(&modelColumnAlias); + ZEPHIR_INIT_VAR(&_26$$35); + zephir_fast_join_str(&_26$$35, SL(", "), &selectedColumns); + zephir_concat_self(&phql, &_26$$35); + } else { + ZEPHIR_CALL_METHOD(&_27$$42, this_ptr, "autoescape", NULL, 478, &models); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_28$$42); + ZEPHIR_CONCAT_VS(&_28$$42, &_27$$42, ".*"); + zephir_concat_self(&phql, &_28$$42); + } + } + if (Z_TYPE_P(&models) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&selectedModels); + array_init(&selectedModels); + zephir_is_iterable(&models, 0, "phalcon/Mvc/Model/Query/Builder.zep", 868); + if (Z_TYPE_P(&models) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&models), _31$$43, _32$$43, _29$$43) + { + ZEPHIR_INIT_NVAR(&modelAlias); + if (_32$$43 != NULL) { + ZVAL_STR_COPY(&modelAlias, _32$$43); } else { - zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE); + ZVAL_LONG(&modelAlias, _31$$43); + } + ZEPHIR_INIT_NVAR(&model); + ZVAL_COPY(&model, _29$$43); + if (Z_TYPE_P(&modelAlias) == IS_STRING) { + ZEPHIR_CALL_METHOD(&_33$$45, this_ptr, "autoescape", NULL, 478, &model); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_34$$45, this_ptr, "autoescape", NULL, 478, &modelAlias); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&selectedModel); + ZEPHIR_CONCAT_VSV(&selectedModel, &_33$$45, " AS ", &_34$$45); + } else { + ZEPHIR_CALL_METHOD(&selectedModel, this_ptr, "autoescape", NULL, 478, &model); + zephir_check_call_status(); } + zephir_array_append(&selectedModels, &selectedModel, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 865); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, findParamsOne, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &models, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_3$$5, findParamsOne, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_30$$43, &models, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_3$$5)) { + if (!zend_is_true(&_30$$43)) { break; } - ZEPHIR_CALL_METHOD(&key, findParamsOne, "key", NULL, 0); + ZEPHIR_CALL_METHOD(&modelAlias, &models, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, findParamsOne, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&model, &models, "current", NULL, 0); zephir_check_call_status(); - _9$$11 = ZEPHIR_IS_LONG_IDENTICAL(&key, 0); - if (!(_9$$11)) { - _9$$11 = ZEPHIR_IS_STRING_IDENTICAL(&key, "conditions"); - } - if (_9$$11) { - if (!(zephir_array_isset_long(&findParams, 0))) { - zephir_array_update_long(&findParams, 0, &value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); - } else { - zephir_array_fetch_long(&_10$$14, &findParams, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 2315); - ZEPHIR_INIT_NVAR(&_11$$14); - ZEPHIR_CONCAT_SVSVS(&_11$$14, "(", &_10$$14, ") AND (", &value, ")"); - zephir_array_update_long(&findParams, 0, &_11$$14, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); - } + if (Z_TYPE_P(&modelAlias) == IS_STRING) { + ZEPHIR_CALL_METHOD(&_35$$48, this_ptr, "autoescape", NULL, 478, &model); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_36$$48, this_ptr, "autoescape", NULL, 478, &modelAlias); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&selectedModel); + ZEPHIR_CONCAT_VSV(&selectedModel, &_35$$48, " AS ", &_36$$48); } else { - zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&selectedModel, this_ptr, "autoescape", NULL, 478, &model); + zephir_check_call_status(); } - ZEPHIR_CALL_METHOD(NULL, findParamsOne, "next", NULL, 0); + zephir_array_append(&selectedModels, &selectedModel, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 865); + ZEPHIR_CALL_METHOD(NULL, &models, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); + ZEPHIR_INIT_NVAR(&model); + ZEPHIR_INIT_NVAR(&modelAlias); + ZEPHIR_INIT_VAR(&_37$$43); + zephir_fast_join_str(&_37$$43, SL(", "), &selectedModels); + ZEPHIR_INIT_VAR(&_38$$43); + ZEPHIR_CONCAT_SV(&_38$$43, " FROM ", &_37$$43); + zephir_concat_self(&phql, &_38$$43); + } else { + ZEPHIR_CALL_METHOD(&_39$$50, this_ptr, "autoescape", NULL, 478, &models); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_40$$50); + ZEPHIR_CONCAT_SV(&_40$$50, " FROM ", &_39$$50); + zephir_concat_self(&phql, &_40$$50); } - if (Z_TYPE_P(findParamsTwo) == IS_ARRAY) { - zephir_is_iterable(findParamsTwo, 0, "phalcon/Mvc/Model/Manager.zep", 2346); - if (Z_TYPE_P(findParamsTwo) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(findParamsTwo), _14$$16, _15$$16, _12$$16) + zephir_read_property(&_0, this_ptr, ZEND_STRL("joins"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&joins, &_0); + if (Z_TYPE_P(&joins) == IS_ARRAY) { + zephir_is_iterable(&joins, 0, "phalcon/Mvc/Model/Query/Builder.zep", 923); + if (Z_TYPE_P(&joins) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&joins), _41$$51) { - ZEPHIR_INIT_NVAR(&key); - if (_15$$16 != NULL) { - ZVAL_STR_COPY(&key, _15$$16); + ZEPHIR_INIT_NVAR(&join); + ZVAL_COPY(&join, _41$$51); + ZEPHIR_OBS_NVAR(&joinModel); + zephir_array_fetch_long(&joinModel, &join, 0, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 883); + ZEPHIR_OBS_NVAR(&joinConditions); + zephir_array_fetch_long(&joinConditions, &join, 1, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 888); + ZEPHIR_OBS_NVAR(&joinAlias); + zephir_array_fetch_long(&joinAlias, &join, 2, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 893); + ZEPHIR_OBS_NVAR(&joinType); + zephir_array_fetch_long(&joinType, &join, 3, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 898); + if (zephir_is_true(&joinType)) { + ZEPHIR_CALL_METHOD(&_43$$53, this_ptr, "autoescape", NULL, 478, &joinModel); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_44$$53); + ZEPHIR_CONCAT_SVSV(&_44$$53, " ", &joinType, " JOIN ", &_43$$53); + zephir_concat_self(&phql, &_44$$53); } else { - ZVAL_LONG(&key, _14$$16); + ZEPHIR_CALL_METHOD(&_45$$54, this_ptr, "autoescape", NULL, 478, &joinModel); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_46$$54); + ZEPHIR_CONCAT_SV(&_46$$54, " JOIN ", &_45$$54); + zephir_concat_self(&phql, &_46$$54); } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _12$$16); - _16$$17 = ZEPHIR_IS_LONG_IDENTICAL(&key, 0); - if (!(_16$$17)) { - _16$$17 = ZEPHIR_IS_STRING_IDENTICAL(&key, "conditions"); + if (zephir_is_true(&joinAlias)) { + ZEPHIR_CALL_METHOD(&_47$$55, this_ptr, "autoescape", NULL, 478, &joinAlias); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_48$$55); + ZEPHIR_CONCAT_SV(&_48$$55, " AS ", &_47$$55); + zephir_concat_self(&phql, &_48$$55); } - _17$$17 = ZEPHIR_IS_STRING_IDENTICAL(&key, "bind"); - if (!(_17$$17)) { - _17$$17 = ZEPHIR_IS_STRING_IDENTICAL(&key, "bindTypes"); + if (zephir_is_true(&joinConditions)) { + ZEPHIR_INIT_NVAR(&_49$$56); + ZEPHIR_CONCAT_SV(&_49$$56, " ON ", &joinConditions); + zephir_concat_self(&phql, &_49$$56); } - if (_16$$17) { - if (!(zephir_array_isset_long(&findParams, 0))) { - zephir_array_update_long(&findParams, 0, &value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &joins, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_42$$51, &joins, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_42$$51)) { + break; + } + ZEPHIR_CALL_METHOD(&join, &joins, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&joinModel); + zephir_array_fetch_long(&joinModel, &join, 0, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 883); + ZEPHIR_OBS_NVAR(&joinConditions); + zephir_array_fetch_long(&joinConditions, &join, 1, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 888); + ZEPHIR_OBS_NVAR(&joinAlias); + zephir_array_fetch_long(&joinAlias, &join, 2, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 893); + ZEPHIR_OBS_NVAR(&joinType); + zephir_array_fetch_long(&joinType, &join, 3, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 898); + if (zephir_is_true(&joinType)) { + ZEPHIR_CALL_METHOD(&_50$$58, this_ptr, "autoescape", NULL, 478, &joinModel); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_51$$58); + ZEPHIR_CONCAT_SVSV(&_51$$58, " ", &joinType, " JOIN ", &_50$$58); + zephir_concat_self(&phql, &_51$$58); } else { - zephir_array_fetch_long(&_18$$20, &findParams, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 2329); - ZEPHIR_INIT_NVAR(&_19$$20); - ZEPHIR_CONCAT_SVSVS(&_19$$20, "(", &_18$$20, ") AND (", &value, ")"); - zephir_array_update_long(&findParams, 0, &_19$$20, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + ZEPHIR_CALL_METHOD(&_52$$59, this_ptr, "autoescape", NULL, 478, &joinModel); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_53$$59); + ZEPHIR_CONCAT_SV(&_53$$59, " JOIN ", &_52$$59); + zephir_concat_self(&phql, &_53$$59); } - } else if (_17$$17) { - if (Z_TYPE_P(&value) == IS_ARRAY) { - if (!(zephir_array_isset(&findParams, &key))) { - zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_INIT_NVAR(&_20$$24); - zephir_array_fetch(&_21$$24, &findParams, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 2337); - zephir_fast_array_merge(&_20$$24, &_21$$24, &value); - zephir_array_update_zval(&findParams, &key, &_20$$24, PH_COPY | PH_SEPARATE); - } + if (zephir_is_true(&joinAlias)) { + ZEPHIR_CALL_METHOD(&_54$$60, this_ptr, "autoescape", NULL, 478, &joinAlias); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_55$$60); + ZEPHIR_CONCAT_SV(&_55$$60, " AS ", &_54$$60); + zephir_concat_self(&phql, &_55$$60); } - } else { - zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE); - } + if (zephir_is_true(&joinConditions)) { + ZEPHIR_INIT_NVAR(&_56$$61); + ZEPHIR_CONCAT_SV(&_56$$61, " ON ", &joinConditions); + zephir_concat_self(&phql, &_56$$61); + } + ZEPHIR_CALL_METHOD(NULL, &joins, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&join); + } + if (Z_TYPE_P(&conditions) == IS_STRING) { + if (!(ZEPHIR_IS_EMPTY(&conditions))) { + ZEPHIR_INIT_VAR(&_57$$63); + ZEPHIR_CONCAT_SV(&_57$$63, " WHERE ", &conditions); + zephir_concat_self(&phql, &_57$$63); + } + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("group"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&group, &_0); + if (!(ZEPHIR_IS_EMPTY(&group))) { + ZEPHIR_INIT_VAR(&groupItems); + array_init(&groupItems); + zephir_is_iterable(&group, 0, "phalcon/Mvc/Model/Query/Builder.zep", 943); + if (Z_TYPE_P(&group) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&group), _58$$64) + { + ZEPHIR_INIT_NVAR(&groupItem); + ZVAL_COPY(&groupItem, _58$$64); + ZEPHIR_CALL_METHOD(&_60$$65, this_ptr, "autoescape", NULL, 478, &groupItem); + zephir_check_call_status(); + zephir_array_append(&groupItems, &_60$$65, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 940); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, findParamsTwo, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &group, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_13$$16, findParamsTwo, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_59$$64, &group, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_13$$16)) { + if (!zend_is_true(&_59$$64)) { break; } - ZEPHIR_CALL_METHOD(&key, findParamsTwo, "key", NULL, 0); + ZEPHIR_CALL_METHOD(&groupItem, &group, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, findParamsTwo, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&_61$$66, this_ptr, "autoescape", NULL, 478, &groupItem); + zephir_check_call_status(); + zephir_array_append(&groupItems, &_61$$66, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 940); + ZEPHIR_CALL_METHOD(NULL, &group, "next", NULL, 0); zephir_check_call_status(); - _22$$26 = ZEPHIR_IS_LONG_IDENTICAL(&key, 0); - if (!(_22$$26)) { - _22$$26 = ZEPHIR_IS_STRING_IDENTICAL(&key, "conditions"); + } + } + ZEPHIR_INIT_NVAR(&groupItem); + ZEPHIR_INIT_VAR(&_62$$64); + zephir_fast_join_str(&_62$$64, SL(", "), &groupItems); + ZEPHIR_INIT_VAR(&_63$$64); + ZEPHIR_CONCAT_SV(&_63$$64, " GROUP BY ", &_62$$64); + zephir_concat_self(&phql, &_63$$64); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("having"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&having, &_0); + if (Z_TYPE_P(&having) != IS_NULL) { + if (!(ZEPHIR_IS_EMPTY(&having))) { + ZEPHIR_INIT_VAR(&_64$$68); + ZEPHIR_CONCAT_SV(&_64$$68, " HAVING ", &having); + zephir_concat_self(&phql, &_64$$68); + } + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("order"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&order, &_0); + if (Z_TYPE_P(&order) != IS_NULL) { + if (Z_TYPE_P(&order) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&orderItems); + array_init(&orderItems); + zephir_is_iterable(&order, 0, "phalcon/Mvc/Model/Query/Builder.zep", 987); + if (Z_TYPE_P(&order) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&order), _65$$70) + { + ZEPHIR_INIT_NVAR(&orderItem); + ZVAL_COPY(&orderItem, _65$$70); + if (Z_TYPE_P(&orderItem) == IS_LONG) { + zephir_array_append(&orderItems, &orderItem, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 970); + continue; } - _23$$26 = ZEPHIR_IS_STRING_IDENTICAL(&key, "bind"); - if (!(_23$$26)) { - _23$$26 = ZEPHIR_IS_STRING_IDENTICAL(&key, "bindTypes"); + if (zephir_memnstr_str(&orderItem, SL(" "), "phalcon/Mvc/Model/Query/Builder.zep", 975) != 0) { + ZEPHIR_INIT_NVAR(&itemExplode$$73); + zephir_fast_explode_str(&itemExplode$$73, SL(" "), &orderItem, LONG_MAX); + zephir_array_fetch_long(&_68$$73, &itemExplode$$73, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query/Builder.zep", 979); + ZEPHIR_CALL_METHOD(&_67$$73, this_ptr, "autoescape", NULL, 478, &_68$$73); + zephir_check_call_status(); + zephir_array_fetch_long(&_69$$73, &itemExplode$$73, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query/Builder.zep", 979); + ZEPHIR_INIT_NVAR(&_70$$73); + ZEPHIR_CONCAT_VSV(&_70$$73, &_67$$73, " ", &_69$$73); + zephir_array_append(&orderItems, &_70$$73, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 979); + continue; } - if (_22$$26) { - if (!(zephir_array_isset_long(&findParams, 0))) { - zephir_array_update_long(&findParams, 0, &value, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); - } else { - zephir_array_fetch_long(&_24$$29, &findParams, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 2329); - ZEPHIR_INIT_NVAR(&_25$$29); - ZEPHIR_CONCAT_SVSVS(&_25$$29, "(", &_24$$29, ") AND (", &value, ")"); - zephir_array_update_long(&findParams, 0, &_25$$29, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + ZEPHIR_CALL_METHOD(&_71$$71, this_ptr, "autoescape", NULL, 478, &orderItem); + zephir_check_call_status(); + zephir_array_append(&orderItems, &_71$$71, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 984); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &order, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_66$$70, &order, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_66$$70)) { + break; + } + ZEPHIR_CALL_METHOD(&orderItem, &order, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&orderItem) == IS_LONG) { + zephir_array_append(&orderItems, &orderItem, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 970); + continue; } - } else if (_23$$26) { - if (Z_TYPE_P(&value) == IS_ARRAY) { - if (!(zephir_array_isset(&findParams, &key))) { - zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_INIT_NVAR(&_26$$33); - zephir_array_fetch(&_27$$33, &findParams, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Manager.zep", 2337); - zephir_fast_array_merge(&_26$$33, &_27$$33, &value); - zephir_array_update_zval(&findParams, &key, &_26$$33, PH_COPY | PH_SEPARATE); - } + if (zephir_memnstr_str(&orderItem, SL(" "), "phalcon/Mvc/Model/Query/Builder.zep", 975) != 0) { + ZEPHIR_INIT_NVAR(&itemExplode$$76); + zephir_fast_explode_str(&itemExplode$$76, SL(" "), &orderItem, LONG_MAX); + zephir_array_fetch_long(&_73$$76, &itemExplode$$76, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query/Builder.zep", 979); + ZEPHIR_CALL_METHOD(&_72$$76, this_ptr, "autoescape", NULL, 478, &_73$$76); + zephir_check_call_status(); + zephir_array_fetch_long(&_74$$76, &itemExplode$$76, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query/Builder.zep", 979); + ZEPHIR_INIT_NVAR(&_75$$76); + ZEPHIR_CONCAT_VSV(&_75$$76, &_72$$76, " ", &_74$$76); + zephir_array_append(&orderItems, &_75$$76, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 979); + continue; } - } else { - zephir_array_update_zval(&findParams, &key, &value, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_76$$74, this_ptr, "autoescape", NULL, 478, &orderItem); + zephir_check_call_status(); + zephir_array_append(&orderItems, &_76$$74, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 984); + ZEPHIR_CALL_METHOD(NULL, &order, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&orderItem); + ZEPHIR_INIT_VAR(&_77$$70); + zephir_fast_join_str(&_77$$70, SL(", "), &orderItems); + ZEPHIR_INIT_VAR(&_78$$70); + ZEPHIR_CONCAT_SV(&_78$$70, " ORDER BY ", &_77$$70); + zephir_concat_self(&phql, &_78$$70); + } else { + ZEPHIR_INIT_VAR(&_79$$77); + ZEPHIR_CONCAT_SV(&_79$$77, " ORDER BY ", &order); + zephir_concat_self(&phql, &_79$$77); + } + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("limit"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&limit, &_0); + if (Z_TYPE_P(&limit) != IS_NULL) { + ZEPHIR_INIT_VAR(&number); + ZVAL_NULL(&number); + if (Z_TYPE_P(&limit) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&number); + zephir_array_fetch_string(&number, &limit, SL("number"), PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 1001); + zephir_memory_observe(&offset); + if (zephir_array_isset_string_fetch(&offset, &limit, SL("offset"), 0)) { + if (!(zephir_is_numeric(&offset))) { + ZEPHIR_INIT_NVAR(&offset); + ZVAL_LONG(&offset, 0); + } + } + } else { + if (zephir_is_numeric(&limit)) { + ZEPHIR_CPY_WRT(&number, &limit); + zephir_read_property(&_80$$83, this_ptr, ZEND_STRL("offset"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&offset, &_80$$83); + if (Z_TYPE_P(&offset) != IS_NULL) { + if (!(zephir_is_numeric(&offset))) { + ZEPHIR_INIT_NVAR(&offset); + ZVAL_LONG(&offset, 0); } - ZEPHIR_CALL_METHOD(NULL, findParamsTwo, "next", NULL, 0); + } + } + } + if (zephir_is_numeric(&number)) { + zephir_concat_self_str(&phql, SL(" LIMIT :APL0:")); + ZVAL_LONG(&_81$$86, 10); + ZEPHIR_CALL_FUNCTION(&_82$$86, "intval", NULL, 42, &number, &_81$$86); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_83$$86); + ZVAL_STRING(&_83$$86, "APL0"); + zephir_update_property_array(this_ptr, SL("bindParams"), &_83$$86, &_82$$86); + ZEPHIR_INIT_VAR(&_84$$86); + ZVAL_STRING(&_84$$86, "APL0"); + ZEPHIR_INIT_VAR(&_85$$86); + ZVAL_LONG(&_85$$86, 1); + zephir_update_property_array(this_ptr, SL("bindTypes"), &_84$$86, &_85$$86); + _86$$86 = zephir_is_numeric(&offset); + if (_86$$86) { + _86$$86 = !ZEPHIR_IS_LONG_IDENTICAL(&offset, 0); + } + if (_86$$86) { + zephir_concat_self_str(&phql, SL(" OFFSET :APL1:")); + ZVAL_LONG(&_87$$87, 10); + ZEPHIR_CALL_FUNCTION(&_88$$87, "intval", NULL, 42, &offset, &_87$$87); zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_89$$87); + ZVAL_STRING(&_89$$87, "APL1"); + zephir_update_property_array(this_ptr, SL("bindParams"), &_89$$87, &_88$$87); + ZEPHIR_INIT_VAR(&_90$$87); + ZVAL_STRING(&_90$$87, "APL1"); + ZEPHIR_INIT_VAR(&_91$$87); + ZVAL_LONG(&_91$$87, 1); + zephir_update_property_array(this_ptr, SL("bindTypes"), &_90$$87, &_91$$87); } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); } - RETURN_CTOR(&findParams); + zephir_read_property(&_0, this_ptr, ZEND_STRL("forUpdate"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&forUpdate, &_0); + if (((Z_TYPE_P(&forUpdate) == IS_TRUE || Z_TYPE_P(&forUpdate) == IS_FALSE) == 1)) { + if (zephir_is_true(&forUpdate)) { + zephir_concat_self_str(&phql, SL(" FOR UPDATE")); + } + } + RETURN_CCTOR(&phql); } -static PHP_METHOD(Phalcon_Mvc_Model_Manager, checkHasRelationship) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getQuery) { + zval _2; + zval query, bindParams, bindTypes, phql, container, _0, _1, _3, _4, _5$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, *modelName_param = NULL, *modelRelation_param = NULL, entityName, _0, _1, _2, _3; - zval collection, modelName, modelRelation, keyRelation; zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&modelRelation); - ZVAL_UNDEF(&keyRelation); - ZVAL_UNDEF(&entityName); + ZVAL_UNDEF(&query); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(&phql); + ZVAL_UNDEF(&container); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_STR(collection) - Z_PARAM_STR(modelName) - Z_PARAM_STR(modelRelation) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_2); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &collection_param, &modelName_param, &modelRelation_param); - zephir_get_strval(&collection, collection_param); - if (UNEXPECTED(Z_TYPE_P(modelName_param) != IS_STRING && Z_TYPE_P(modelName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(modelName_param) == IS_STRING)) { - zephir_get_strval(&modelName, modelName_param); - } else { - ZEPHIR_INIT_VAR(&modelName); + + ZEPHIR_CALL_METHOD(&phql, this_ptr, "getphql", NULL, 479); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_0); + if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injection container is required to access the services related to the ORM", "phalcon/Mvc/Model/Query/Builder.zep", 1058); + return; } - if (UNEXPECTED(Z_TYPE_P(modelRelation_param) != IS_STRING && Z_TYPE_P(modelRelation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'modelRelation' must be of the type string")); - RETURN_MM_NULL(); + ZEPHIR_INIT_VAR(&_2); + zephir_create_array(&_2, 2, 0); + zephir_array_fast_append(&_2, &phql); + zephir_array_fast_append(&_2, &container); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "Phalcon\\Mvc\\Model\\Query"); + ZEPHIR_CALL_METHOD(&_1, &container, "get", NULL, 0, &_3, &_2); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&query, &_1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&bindParams, &_0); + if (Z_TYPE_P(&bindParams) == IS_ARRAY) { + ZEPHIR_CALL_METHOD(NULL, &query, "setbindparams", NULL, 0, &bindParams); + zephir_check_call_status(); } - if (EXPECTED(Z_TYPE_P(modelRelation_param) == IS_STRING)) { - zephir_get_strval(&modelRelation, modelRelation_param); - } else { - ZEPHIR_INIT_VAR(&modelRelation); + zephir_read_property(&_0, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&bindTypes, &_0); + if (Z_TYPE_P(&bindTypes) == IS_ARRAY) { + ZEPHIR_CALL_METHOD(NULL, &query, "setbindtypes", NULL, 0, &bindTypes); + zephir_check_call_status(); } - ZEPHIR_INIT_VAR(&entityName); - zephir_fast_strtolower(&entityName, &modelName); - ZEPHIR_INIT_VAR(&_0); - zephir_fast_strtolower(&_0, &modelRelation); - ZEPHIR_INIT_VAR(&_1); - ZEPHIR_CONCAT_VSV(&_1, &entityName, "$", &_0); - zephir_get_strval(&keyRelation, &_1); - zephir_read_property(&_2, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset(&_2, &entityName))) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "load", NULL, 0, &modelName); + zephir_memory_observe(&_4); + zephir_read_property(&_4, this_ptr, ZEND_STRL("sharedLock"), PH_NOISY_CC); + if (((Z_TYPE_P(&_4) == IS_TRUE || Z_TYPE_P(&_4) == IS_FALSE) == 1)) { + zephir_read_property(&_5$$6, this_ptr, ZEND_STRL("sharedLock"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &query, "setsharedlock", NULL, 0, &_5$$6); zephir_check_call_status(); } - zephir_memory_observe(&_3); - zephir_read_property_zval(&_3, this_ptr, &collection, PH_NOISY_CC); - RETURN_MM_BOOL(zephir_array_isset(&_3, &keyRelation)); + RETURN_CCTOR(&query); } -zend_object *zephir_init_properties_Phalcon_Mvc_Model_Manager(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getWhere) +{ + + RETURN_MEMBER(getThis(), "conditions"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, groupBy) { - zval _0, _2, _4, _6, _8, _10, _12, _14, _16, _18, _20, _22, _24, _26, _28, _30, _32, _34, _36, _38, _40, _42, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8, _13$$9, _15$$10, _17$$11, _19$$12, _21$$13, _23$$14, _25$$15, _27$$16, _29$$17, _31$$18, _33$$19, _35$$20, _37$$21, _39$$22, _41$$23, _43$$24; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_16); - ZVAL_UNDEF(&_18); - ZVAL_UNDEF(&_20); - ZVAL_UNDEF(&_22); - ZVAL_UNDEF(&_24); - ZVAL_UNDEF(&_26); - ZVAL_UNDEF(&_28); - ZVAL_UNDEF(&_30); - ZVAL_UNDEF(&_32); - ZVAL_UNDEF(&_34); - ZVAL_UNDEF(&_36); - ZVAL_UNDEF(&_38); - ZVAL_UNDEF(&_40); - ZVAL_UNDEF(&_42); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_13$$9); - ZVAL_UNDEF(&_15$$10); - ZVAL_UNDEF(&_17$$11); - ZVAL_UNDEF(&_19$$12); - ZVAL_UNDEF(&_21$$13); - ZVAL_UNDEF(&_23$$14); - ZVAL_UNDEF(&_25$$15); - ZVAL_UNDEF(&_27$$16); - ZVAL_UNDEF(&_29$$17); - ZVAL_UNDEF(&_31$$18); - ZVAL_UNDEF(&_33$$19); - ZVAL_UNDEF(&_35$$20); - ZVAL_UNDEF(&_37$$21); - ZVAL_UNDEF(&_39$$22); - ZVAL_UNDEF(&_41$$23); - ZVAL_UNDEF(&_43$$24); - + zval *group = NULL, group_sub, _0$$4, _1$$4, _2$$4, _3$$3; + zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("reusable"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("reusable"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("writeConnectionServices"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("writeConnectionServices"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("schemas"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("schemas"), &_5$$5); - } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("sources"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sources"), &_7$$6); - } - zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("readConnectionServices"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_8) == IS_NULL) { - ZEPHIR_INIT_VAR(&_9$$7); - array_init(&_9$$7); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("readConnectionServices"), &_9$$7); - } - zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("modelVisibility"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_10) == IS_NULL) { - ZEPHIR_INIT_VAR(&_11$$8); - array_init(&_11$$8); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("modelVisibility"), &_11$$8); - } - zephir_read_property_ex(&_12, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_12) == IS_NULL) { - ZEPHIR_INIT_VAR(&_13$$9); - array_init(&_13$$9); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("keepSnapshots"), &_13$$9); - } - zephir_read_property_ex(&_14, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_14) == IS_NULL) { - ZEPHIR_INIT_VAR(&_15$$10); - array_init(&_15$$10); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("initialized"), &_15$$10); - } - zephir_read_property_ex(&_16, this_ptr, ZEND_STRL("hasOneThroughSingle"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_16) == IS_NULL) { - ZEPHIR_INIT_VAR(&_17$$11); - array_init(&_17$$11); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasOneThroughSingle"), &_17$$11); - } - zephir_read_property_ex(&_18, this_ptr, ZEND_STRL("hasOneThrough"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_18) == IS_NULL) { - ZEPHIR_INIT_VAR(&_19$$12); - array_init(&_19$$12); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasOneThrough"), &_19$$12); - } - zephir_read_property_ex(&_20, this_ptr, ZEND_STRL("hasOneSingle"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_20) == IS_NULL) { - ZEPHIR_INIT_VAR(&_21$$13); - array_init(&_21$$13); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasOneSingle"), &_21$$13); - } - zephir_read_property_ex(&_22, this_ptr, ZEND_STRL("hasOne"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_22) == IS_NULL) { - ZEPHIR_INIT_VAR(&_23$$14); - array_init(&_23$$14); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasOne"), &_23$$14); - } - zephir_read_property_ex(&_24, this_ptr, ZEND_STRL("hasManyToManySingle"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_24) == IS_NULL) { - ZEPHIR_INIT_VAR(&_25$$15); - array_init(&_25$$15); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasManyToManySingle"), &_25$$15); - } - zephir_read_property_ex(&_26, this_ptr, ZEND_STRL("hasManyToMany"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_26) == IS_NULL) { - ZEPHIR_INIT_VAR(&_27$$16); - array_init(&_27$$16); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasManyToMany"), &_27$$16); - } - zephir_read_property_ex(&_28, this_ptr, ZEND_STRL("hasManySingle"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_28) == IS_NULL) { - ZEPHIR_INIT_VAR(&_29$$17); - array_init(&_29$$17); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasManySingle"), &_29$$17); - } - zephir_read_property_ex(&_30, this_ptr, ZEND_STRL("hasMany"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_30) == IS_NULL) { - ZEPHIR_INIT_VAR(&_31$$18); - array_init(&_31$$18); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("hasMany"), &_31$$18); - } - zephir_read_property_ex(&_32, this_ptr, ZEND_STRL("dynamicUpdate"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_32) == IS_NULL) { - ZEPHIR_INIT_VAR(&_33$$19); - array_init(&_33$$19); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("dynamicUpdate"), &_33$$19); - } - zephir_read_property_ex(&_34, this_ptr, ZEND_STRL("customEventsManager"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_34) == IS_NULL) { - ZEPHIR_INIT_VAR(&_35$$20); - array_init(&_35$$20); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("customEventsManager"), &_35$$20); - } - zephir_read_property_ex(&_36, this_ptr, ZEND_STRL("belongsToSingle"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_36) == IS_NULL) { - ZEPHIR_INIT_VAR(&_37$$21); - array_init(&_37$$21); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("belongsToSingle"), &_37$$21); - } - zephir_read_property_ex(&_38, this_ptr, ZEND_STRL("belongsTo"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_38) == IS_NULL) { - ZEPHIR_INIT_VAR(&_39$$22); - array_init(&_39$$22); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("belongsTo"), &_39$$22); - } - zephir_read_property_ex(&_40, this_ptr, ZEND_STRL("behaviors"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_40) == IS_NULL) { - ZEPHIR_INIT_VAR(&_41$$23); - array_init(&_41$$23); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("behaviors"), &_41$$23); - } - zephir_read_property_ex(&_42, this_ptr, ZEND_STRL("aliases"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_42) == IS_NULL) { - ZEPHIR_INIT_VAR(&_43$$24); - array_init(&_43$$24); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("aliases"), &_43$$24); + ZVAL_UNDEF(&group_sub); + ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(group) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &group); + ZEPHIR_SEPARATE_PARAM(group); + if (Z_TYPE_P(group) == IS_STRING) { + if (zephir_memnstr_str(group, SL(","), "phalcon/Mvc/Model/Query/Builder.zep", 1114)) { + ZEPHIR_INIT_VAR(&_0$$4); + ZEPHIR_INIT_VAR(&_1$$4); + ZVAL_STRING(&_1$$4, " "); + ZEPHIR_INIT_VAR(&_2$$4); + ZVAL_STRING(&_2$$4, ""); + zephir_fast_str_replace(&_0$$4, &_1$$4, &_2$$4, group); + ZEPHIR_CPY_WRT(group, &_0$$4); } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + ZEPHIR_INIT_VAR(&_3$$3); + zephir_fast_explode_str(&_3$$3, SL(","), group, LONG_MAX); + ZEPHIR_CPY_WRT(group, &_3$$3); } + zephir_update_property_zval(this_ptr, ZEND_STRL("group"), group); + RETURN_THIS(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_ManagerInterface) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, having) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, ManagerInterface, phalcon, mvc_model_managerinterface, phalcon_mvc_model_managerinterface_method_entry); - - return SUCCESS; -} + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval bindParams, bindTypes; + zval *conditions_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, currentBindParams, currentBindTypes, _0$$3, _1$$5; + zval conditions; + zval *this_ptr = getThis(); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addBehavior); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addBelongsTo); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addHasMany); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addHasOne); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addHasOneThrough); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, addHasManyToMany); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, createBuilder); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, createQuery); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, executeQuery); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getBelongsTo); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getBelongsToRecords); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getBuilder); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasMany); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasManyRecords); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasManyToMany); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasOne); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasOneThrough); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasOneAndHasMany); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getHasOneRecords); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getLastInitialized); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getLastQuery); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getModelSchema); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getModelSource); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getReadConnection); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getReadConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getRelationByAlias); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getRelationRecords); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getRelations); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getRelationsBetween); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getWriteConnection); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, getWriteConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, hasBelongsTo); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, hasHasMany); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, hasHasOne); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, hasHasOneThrough); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, hasHasManyToMany); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, load); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, initialize); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, isInitialized); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, isKeepingSnapshots); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, isUsingDynamicUpdate); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, isVisibleModelProperty); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, keepSnapshots); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, missingMethod); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, notifyEvent); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setReadConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setModelSchema); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setModelSource); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, setWriteConnectionService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ManagerInterface, useDynamicUpdate); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, MetaData, phalcon, mvc_model_metadata, phalcon_mvc_model_metadata_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("adapter"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("columnMap"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("container"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("metaData"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_metadata_ce, SL("strategy"), ZEND_ACC_PROTECTED); - phalcon_mvc_model_metadata_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_MetaData; - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_ATTRIBUTES"), 0); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_AUTOMATIC_DEFAULT_INSERT"), 10); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_AUTOMATIC_DEFAULT_UPDATE"), 11); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_COLUMN_MAP"), 0); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATE_AT"), 6); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATE_IN"), 7); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATA_TYPES"), 4); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATA_TYPES_BIND"), 9); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DATA_TYPES_NUMERIC"), 5); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_DEFAULT_VALUES"), 12); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_EMPTY_STRING_VALUES"), 13); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_IDENTITY_COLUMN"), 8); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_NON_PRIMARY_KEY"), 2); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_NOT_NULL"), 3); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_PRIMARY_KEY"), 1); - - zephir_declare_class_constant_long(phalcon_mvc_model_metadata_ce, SL("MODELS_REVERSE_COLUMN_MAP"), 1); - - zend_class_implements(phalcon_mvc_model_metadata_ce, 1, phalcon_di_injectionawareinterface_ce); - zend_class_implements(phalcon_mvc_model_metadata_ce, 1, phalcon_mvc_model_metadatainterface_ce); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getAdapter) -{ - - RETURN_MEMBER(getThis(), "adapter"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getAttributes) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(¤tBindParams); + ZVAL_UNDEF(¤tBindTypes); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$5); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(conditions) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZVAL_LONG(&_0, 0); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 110); - return; + zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams_param, &bindTypes_param); + zephir_get_strval(&conditions, conditions_param); + if (!bindParams_param) { + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); + } else { + zephir_get_arrval(&bindParams, bindParams_param); } - RETURN_CCTOR(&data); + if (!bindTypes_param) { + ZEPHIR_INIT_VAR(&bindTypes); + array_init(&bindTypes); + } else { + zephir_get_arrval(&bindTypes, bindTypes_param); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("having"), &conditions); + zephir_memory_observe(¤tBindParams); + zephir_read_property(¤tBindParams, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC); + if (Z_TYPE_P(¤tBindParams) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&_0$$3); + zephir_add_function(&_0$$3, ¤tBindParams, &bindParams); + zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &_0$$3); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &bindParams); + } + zephir_memory_observe(¤tBindTypes); + zephir_read_property(¤tBindTypes, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC); + if (Z_TYPE_P(¤tBindTypes) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&_1$$5); + zephir_add_function(&_1$$5, ¤tBindTypes, &bindTypes); + zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &_1$$5); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); + } + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getAutomaticCreateAttributes) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, inHaving) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval values; + zval *expr_param = NULL, *values_param = NULL, *operator_param = NULL, _0; + zval expr, operator; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&operator); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZVAL_UNDEF(&values); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(expr) + Z_PARAM_ARRAY(values) + Z_PARAM_OPTIONAL + Z_PARAM_STR(operator) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZVAL_LONG(&_0, 10); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 137); - return; + zephir_fetch_params(1, 2, 1, &expr_param, &values_param, &operator_param); + if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + RETURN_MM_NULL(); } - RETURN_CCTOR(&data); + if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { + zephir_get_strval(&expr, expr_param); + } else { + ZEPHIR_INIT_VAR(&expr); + } + ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); + if (!operator_param) { + ZEPHIR_INIT_VAR(&operator); + ZVAL_STRING(&operator, "and"); + } else { + if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { + zephir_get_strval(&operator, operator_param); + } else { + ZEPHIR_INIT_VAR(&operator); + } + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "Having"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionin", NULL, 0, &_0, &operator, &expr, &values); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getAutomaticUpdateAttributes) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, innerJoin) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval *model_param = NULL, *conditions_param = NULL, *alias_param = NULL, _1; + zval model, conditions, alias; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(&alias); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(model) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(conditions) + Z_PARAM_STR_OR_NULL(alias) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZVAL_LONG(&_0, 11); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 164); - return; + zephir_fetch_params(1, 1, 2, &model_param, &conditions_param, &alias_param); + if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); + RETURN_MM_NULL(); } - RETURN_CCTOR(&data); + if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { + zephir_get_strval(&model, model_param); + } else { + ZEPHIR_INIT_VAR(&model); + } + if (!conditions_param) { + ZEPHIR_INIT_VAR(&conditions); + } else { + zephir_get_strval(&conditions, conditions_param); + } + if (!alias_param) { + ZEPHIR_INIT_VAR(&alias); + } else { + zephir_get_strval(&alias, alias_param); + } + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 4, 0); + zephir_array_fast_append(&_0, &model); + zephir_array_fast_append(&_0, &conditions); + zephir_array_fast_append(&_0, &alias); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "INNER"); + zephir_array_fast_append(&_0, &_1); + zephir_update_property_array_append(this_ptr, SL("joins"), &_0); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getBindTypes) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, inWhere) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval values; + zval *expr_param = NULL, *values_param = NULL, *operator_param = NULL, _0; + zval expr, operator; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&operator); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZVAL_UNDEF(&values); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(expr) + Z_PARAM_ARRAY(values) + Z_PARAM_OPTIONAL + Z_PARAM_STR(operator) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZVAL_LONG(&_0, 9); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 191); - return; + zephir_fetch_params(1, 2, 1, &expr_param, &values_param, &operator_param); + if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + RETURN_MM_NULL(); } - RETURN_CCTOR(&data); + if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { + zephir_get_strval(&expr, expr_param); + } else { + ZEPHIR_INIT_VAR(&expr); + } + ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); + if (!operator_param) { + ZEPHIR_INIT_VAR(&operator); + ZVAL_STRING(&operator, "and"); + } else { + if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { + zephir_get_strval(&operator, operator_param); + } else { + ZEPHIR_INIT_VAR(&operator); + } + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "Where"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionin", NULL, 0, &_0, &operator, &expr, &values); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getColumnMap) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, join) { - zend_bool _1; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval *model_param = NULL, *conditions_param = NULL, *alias_param = NULL, *type_param = NULL; + zval model, conditions, alias, type; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(&alias); + ZVAL_UNDEF(&type); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_STR(model) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(conditions) + Z_PARAM_STR_OR_NULL(alias) + Z_PARAM_STR_OR_NULL(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZVAL_LONG(&_0, 0); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readcolumnmapindex", NULL, 25, model, &_0); - zephir_check_call_status(); - _1 = Z_TYPE_P(&data) != IS_NULL; - if (_1) { - _1 = Z_TYPE_P(&data) != IS_ARRAY; + zephir_fetch_params(1, 1, 3, &model_param, &conditions_param, &alias_param, &type_param); + if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); + RETURN_MM_NULL(); } - if (UNEXPECTED(_1)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 215); - return; + if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { + zephir_get_strval(&model, model_param); + } else { + ZEPHIR_INIT_VAR(&model); } - RETURN_CCTOR(&data); + if (!conditions_param) { + ZEPHIR_INIT_VAR(&conditions); + } else { + zephir_get_strval(&conditions, conditions_param); + } + if (!alias_param) { + ZEPHIR_INIT_VAR(&alias); + } else { + zephir_get_strval(&alias, alias_param); + } + if (!type_param) { + ZEPHIR_INIT_VAR(&type); + } else { + zephir_get_strval(&type, type_param); + } + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 4, 0); + zephir_array_fast_append(&_0, &model); + zephir_array_fast_append(&_0, &conditions); + zephir_array_fast_append(&_0, &alias); + zephir_array_fast_append(&_0, &type); + zephir_update_property_array_append(this_ptr, SL("joins"), &_0); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getDefaultValues) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, leftJoin) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval *model_param = NULL, *conditions_param = NULL, *alias_param = NULL, _1; + zval model, conditions, alias; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(&alias); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(model) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(conditions) + Z_PARAM_STR_OR_NULL(alias) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZVAL_LONG(&_0, 12); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 239); - return; + zephir_fetch_params(1, 1, 2, &model_param, &conditions_param, &alias_param); + if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); + RETURN_MM_NULL(); } - RETURN_CCTOR(&data); + if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { + zephir_get_strval(&model, model_param); + } else { + ZEPHIR_INIT_VAR(&model); + } + if (!conditions_param) { + ZEPHIR_INIT_VAR(&conditions); + } else { + zephir_get_strval(&conditions, conditions_param); + } + if (!alias_param) { + ZEPHIR_INIT_VAR(&alias); + } else { + zephir_get_strval(&alias, alias_param); + } + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 4, 0); + zephir_array_fast_append(&_0, &model); + zephir_array_fast_append(&_0, &conditions); + zephir_array_fast_append(&_0, &alias); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "LEFT"); + zephir_array_fast_append(&_0, &_1); + zephir_update_property_array_append(this_ptr, SL("joins"), &_0); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getDataTypes) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, limit) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval *limit_param = NULL, *offset = NULL, offset_sub, __$null, _0, _1, _2$$4, _3$$4; + zend_long limit, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&offset_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_LONG(limit) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(offset) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZVAL_LONG(&_0, 4); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); + zephir_fetch_params(1, 1, 1, &limit_param, &offset); + if (!offset) { + offset = &offset_sub; + offset = &__$null; + } + ZVAL_LONG(&_0, limit); + ZEPHIR_CALL_FUNCTION(&_1, "abs", NULL, 284, &_0); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 263); - return; + limit = zephir_get_numberval(&_1); + if (UNEXPECTED(limit == 0)) { + RETURN_THIS(); } - RETURN_CCTOR(&data); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, limit); + zephir_update_property_zval(this_ptr, ZEND_STRL("limit"), &_0); + if (zephir_is_numeric(offset)) { + ZVAL_LONG(&_2$$4, zephir_get_intval(offset)); + ZEPHIR_CALL_FUNCTION(&_3$$4, "abs", NULL, 284, &_2$$4); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("offset"), &_3$$4); + } + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getDataTypesNumeric) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, notBetweenHaving) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, *operator_param = NULL, _0; + zval expr, operator; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&operator); + ZVAL_UNDEF(&minimum_sub); + ZVAL_UNDEF(&maximum_sub); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_STR(expr) + Z_PARAM_ZVAL(minimum) + Z_PARAM_ZVAL(maximum) + Z_PARAM_OPTIONAL + Z_PARAM_STR(operator) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZVAL_LONG(&_0, 5); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 290); - return; + zephir_fetch_params(1, 3, 1, &expr_param, &minimum, &maximum, &operator_param); + if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + RETURN_MM_NULL(); } - RETURN_CCTOR(&data); -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getDI) -{ - zval container, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (Z_TYPE_P(&container) != IS_OBJECT) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injection container is required to access internal services", "phalcon/Mvc/Model/MetaData.zep", 308); - return; + if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { + zephir_get_strval(&expr, expr_param); + } else { + ZEPHIR_INIT_VAR(&expr); } - RETURN_CCTOR(&container); + if (!operator_param) { + ZEPHIR_INIT_VAR(&operator); + ZVAL_STRING(&operator, "and"); + } else { + if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { + zephir_get_strval(&operator, operator_param); + } else { + ZEPHIR_INIT_VAR(&operator); + } + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "Having"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionnotbetween", NULL, 0, &_0, &operator, &expr, minimum, maximum); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getEmptyStringAttributes) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, notBetweenWhere) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, *operator_param = NULL, _0; + zval expr, operator; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&operator); + ZVAL_UNDEF(&minimum_sub); + ZVAL_UNDEF(&maximum_sub); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_STR(expr) + Z_PARAM_ZVAL(minimum) + Z_PARAM_ZVAL(maximum) + Z_PARAM_OPTIONAL + Z_PARAM_STR(operator) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZVAL_LONG(&_0, 13); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 335); - return; + zephir_fetch_params(1, 3, 1, &expr_param, &minimum, &maximum, &operator_param); + if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + RETURN_MM_NULL(); } - RETURN_CCTOR(&data); + if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { + zephir_get_strval(&expr, expr_param); + } else { + ZEPHIR_INIT_VAR(&expr); + } + if (!operator_param) { + ZEPHIR_INIT_VAR(&operator); + ZVAL_STRING(&operator, "and"); + } else { + if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { + zephir_get_strval(&operator, operator_param); + } else { + ZEPHIR_INIT_VAR(&operator); + } + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "Where"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionnotbetween", NULL, 0, &_0, &operator, &expr, minimum, maximum); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getIdentityField) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, notInHaving) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, _0; + zval values; + zval *expr_param = NULL, *values_param = NULL, *operator_param = NULL, _0; + zval expr, operator; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&operator); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZVAL_UNDEF(&values); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(expr) + Z_PARAM_ARRAY(values) + Z_PARAM_OPTIONAL + Z_PARAM_STR(operator) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZVAL_LONG(&_0, 8); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "readmetadataindex", NULL, 24, model, &_0); + zephir_fetch_params(1, 2, 1, &expr_param, &values_param, &operator_param); + if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { + zephir_get_strval(&expr, expr_param); + } else { + ZEPHIR_INIT_VAR(&expr); + } + ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); + if (!operator_param) { + ZEPHIR_INIT_VAR(&operator); + ZVAL_STRING(&operator, "and"); + } else { + if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { + zephir_get_strval(&operator, operator_param); + } else { + ZEPHIR_INIT_VAR(&operator); + } + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "Having"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionnotin", NULL, 0, &_0, &operator, &expr, &values); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getNonPrimaryKeyAttributes) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, notInWhere) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval values; + zval *expr_param = NULL, *values_param = NULL, *operator_param = NULL, _0; + zval expr, operator; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&operator); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZVAL_UNDEF(&values); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(expr) + Z_PARAM_ARRAY(values) + Z_PARAM_OPTIONAL + Z_PARAM_STR(operator) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZVAL_LONG(&_0, 2); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 375); - return; + zephir_fetch_params(1, 2, 1, &expr_param, &values_param, &operator_param); + if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + RETURN_MM_NULL(); } - RETURN_CCTOR(&data); + if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { + zephir_get_strval(&expr, expr_param); + } else { + ZEPHIR_INIT_VAR(&expr); + } + ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); + if (!operator_param) { + ZEPHIR_INIT_VAR(&operator); + ZVAL_STRING(&operator, "and"); + } else { + if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { + zephir_get_strval(&operator, operator_param); + } else { + ZEPHIR_INIT_VAR(&operator); + } + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "Where"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionnotin", NULL, 0, &_0, &operator, &expr, &values); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getNotNullAttributes) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, offset) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval *offset_param = NULL, _0; + zend_long offset; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_LONG(offset) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZVAL_LONG(&_0, 3); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 399); - return; - } - RETURN_CCTOR(&data); + zephir_fetch_params_without_memory_grow(1, 0, &offset_param); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, offset); + zephir_update_property_zval(this_ptr, ZEND_STRL("offset"), &_0); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getPrimaryKeyAttributes) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, orderBy) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval *orderBy, orderBy_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&orderBy_sub); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ZVAL(orderBy) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZVAL_LONG(&_0, 1); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readmetadataindex", NULL, 24, model, &_0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 423); - return; - } - RETURN_CCTOR(&data); + zephir_fetch_params_without_memory_grow(1, 0, &orderBy); + zephir_update_property_zval(this_ptr, ZEND_STRL("order"), orderBy); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getReverseColumnMap) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, orHaving) { - zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, data, _0; + zval bindParams, bindTypes; + zval *conditions_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, currentConditions, _0$$3; + zval conditions; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(¤tConditions); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(conditions) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZVAL_LONG(&_0, 1); - ZEPHIR_CALL_METHOD(&data, this_ptr, "readcolumnmapindex", NULL, 25, model, &_0); - zephir_check_call_status(); - _1 = Z_TYPE_P(&data) != IS_NULL; - if (_1) { - _1 = Z_TYPE_P(&data) != IS_ARRAY; + zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams_param, &bindTypes_param); + if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); + RETURN_MM_NULL(); } - if (UNEXPECTED(_1)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The meta-data is invalid or is corrupt", "phalcon/Mvc/Model/MetaData.zep", 450); - return; + if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { + zephir_get_strval(&conditions, conditions_param); + } else { + ZEPHIR_INIT_VAR(&conditions); } - RETURN_CCTOR(&data); -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getStrategy) -{ - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("strategy"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_mvc_model_metadata_strategy_introspection_ce); - if (zephir_has_constructor(&_1$$3)) { - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 0); - zephir_check_call_status(); - } - - zephir_update_property_zval(this_ptr, ZEND_STRL("strategy"), &_1$$3); + if (!bindParams_param) { + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); + } else { + zephir_get_arrval(&bindParams, bindParams_param); } - RETURN_MM_MEMBER(getThis(), "strategy"); + if (!bindTypes_param) { + ZEPHIR_INIT_VAR(&bindTypes); + array_init(&bindTypes); + } else { + zephir_get_arrval(&bindTypes, bindTypes_param); + } + zephir_memory_observe(¤tConditions); + zephir_read_property(¤tConditions, this_ptr, ZEND_STRL("having"), PH_NOISY_CC); + if (zephir_is_true(¤tConditions)) { + ZEPHIR_INIT_VAR(&_0$$3); + ZEPHIR_CONCAT_SVSVS(&_0$$3, "(", ¤tConditions, ") OR (", &conditions, ")"); + zephir_get_strval(&conditions, &_0$$3); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "having", NULL, 0, &conditions, &bindParams, &bindTypes); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, hasAttribute) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, orWhere) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval attribute; - zval *model, model_sub, *attribute_param = NULL, columnMap, _0, _1; + zval bindParams, bindTypes; + zval *conditions_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, currentConditions, _0$$3; + zval conditions; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&attribute); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_STR(attribute) + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(¤tConditions); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(conditions) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &attribute_param); - zephir_get_strval(&attribute, attribute_param); - ZEPHIR_CALL_METHOD(&columnMap, this_ptr, "getreversecolumnmap", NULL, 0, model); - zephir_check_call_status(); - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - RETURN_MM_BOOL(zephir_array_isset(&columnMap, &attribute)); + zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams_param, &bindTypes_param); + if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "readmetadata", NULL, 26, model); + if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { + zephir_get_strval(&conditions, conditions_param); + } else { + ZEPHIR_INIT_VAR(&conditions); + } + if (!bindParams_param) { + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); + } else { + zephir_get_arrval(&bindParams, bindParams_param); + } + if (!bindTypes_param) { + ZEPHIR_INIT_VAR(&bindTypes); + array_init(&bindTypes); + } else { + zephir_get_arrval(&bindTypes, bindTypes_param); + } + zephir_memory_observe(¤tConditions); + zephir_read_property(¤tConditions, this_ptr, ZEND_STRL("conditions"), PH_NOISY_CC); + if (zephir_is_true(¤tConditions)) { + ZEPHIR_INIT_VAR(&_0$$3); + ZEPHIR_CONCAT_SVSVS(&_0$$3, "(", ¤tConditions, ") OR (", &conditions, ")"); + zephir_get_strval(&conditions, &_0$$3); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "where", NULL, 0, &conditions, &bindParams, &bindTypes); zephir_check_call_status(); - zephir_array_fetch_long(&_1, &_0, 4, PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 490); - RETURN_MM_BOOL(zephir_array_isset(&_1, &attribute)); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, isEmpty) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, rightJoin) { zval _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - RETURN_BOOL(zephir_fast_count_int(&_0) == 0); -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, read) -{ zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, _0; - zval key; + zval *model_param = NULL, *conditions_param = NULL, *alias_param = NULL, _1; + zval model, conditions, alias; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(&alias); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(model) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(conditions) + Z_PARAM_STR_OR_NULL(alias) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + zephir_fetch_params(1, 1, 2, &model_param, &conditions_param, &alias_param); + if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { + zephir_get_strval(&model, model_param); } else { - ZEPHIR_INIT_VAR(&key); + ZEPHIR_INIT_VAR(&model); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &key); - zephir_check_call_status(); - RETURN_MM(); + if (!conditions_param) { + ZEPHIR_INIT_VAR(&conditions); + } else { + zephir_get_strval(&conditions, conditions_param); + } + if (!alias_param) { + ZEPHIR_INIT_VAR(&alias); + } else { + zephir_get_strval(&alias, alias_param); + } + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 4, 0); + zephir_array_fast_append(&_0, &model); + zephir_array_fast_append(&_0, &conditions); + zephir_array_fast_append(&_0, &alias); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "RIGHT"); + zephir_array_fast_append(&_0, &_1); + zephir_update_property_array_append(this_ptr, SL("joins"), &_0); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, readColumnMap) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, setBindParams) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, keyName, _0$$4, _1$$4; + zend_bool merge; + zval *bindParams_param = NULL, *merge_param = NULL, currentBindParams, _0$$4; + zval bindParams; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&keyName); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(¤tBindParams); ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$4); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - if (!(ZEPHIR_GLOBAL(orm).column_renaming)) { - RETURN_MM_NULL(); - } - ZEPHIR_CALL_METHOD(&keyName, this_ptr, "getcolumnmapuniquekey", NULL, 27, model); - zephir_check_call_status(); - if (EXPECTED(Z_TYPE_P(&keyName) != IS_NULL)) { - zephir_read_property(&_0$$4, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_1$$4, &_0$$4, &keyName, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 535); - RETURN_CTOR(&_1$$4); - } - RETURN_MM_NULL(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, readColumnMapIndex) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long index, ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, *index_param = NULL, keyName, _0$$4, _1$$4, _2$$4; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&keyName); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_LONG(index) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &index_param); - if (!(ZEPHIR_GLOBAL(orm).column_renaming)) { - RETURN_MM_NULL(); - } - ZEPHIR_CALL_METHOD(&keyName, this_ptr, "getcolumnmapuniquekey", NULL, 27, model); - zephir_check_call_status(); - if (EXPECTED(Z_TYPE_P(&keyName) != IS_NULL)) { - zephir_read_property(&_0$$4, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_1$$4, &_0$$4, &keyName, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 561); - zephir_array_fetch_long(&_2$$4, &_1$$4, index, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 561); - RETURN_CTOR(&_2$$4); - } - RETURN_MM_NULL(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, readMetaData) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, key, _0$$3, _1$$3; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(bindParams) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(merge) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZEPHIR_CALL_METHOD(&key, this_ptr, "getmetadatauniquekey", NULL, 28, model); - zephir_check_call_status(); - if (EXPECTED(Z_TYPE_P(&key) != IS_NULL)) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_1$$3, &_0$$3, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 582); - RETURN_CTOR(&_1$$3); + zephir_fetch_params(1, 1, 1, &bindParams_param, &merge_param); + ZEPHIR_OBS_COPY_OR_DUP(&bindParams, bindParams_param); + if (!merge_param) { + merge = 0; + } else { + } + if (merge) { + zephir_memory_observe(¤tBindParams); + zephir_read_property(¤tBindParams, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC); + if (Z_TYPE_P(¤tBindParams) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&_0$$4); + zephir_add_function(&_0$$4, ¤tBindParams, &bindParams); + zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &_0$$4); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &bindParams); + } + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &bindParams); } - RETURN_MM_NULL(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, readMetaDataIndex) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, setBindTypes) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long index, ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, *index_param = NULL, key, _0$$3, _1$$3, _2$$3; + zend_bool merge; + zval *bindTypes_param = NULL, *merge_param = NULL, currentBindTypes, _0$$4; + zval bindTypes; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_LONG(index) + ZVAL_UNDEF(&bindTypes); + ZVAL_UNDEF(¤tBindTypes); + ZVAL_UNDEF(&_0$$4); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(bindTypes) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(merge) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &index_param); - ZEPHIR_CALL_METHOD(&key, this_ptr, "getmetadatauniquekey", NULL, 28, model); - zephir_check_call_status(); - if (EXPECTED(Z_TYPE_P(&key) != IS_NULL)) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_1$$3, &_0$$3, &key, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 604); - zephir_array_fetch_long(&_2$$3, &_1$$3, index, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/MetaData.zep", 604); - RETURN_CTOR(&_2$$3); + zephir_fetch_params(1, 1, 1, &bindTypes_param, &merge_param); + ZEPHIR_OBS_COPY_OR_DUP(&bindTypes, bindTypes_param); + if (!merge_param) { + merge = 0; + } else { + } + if (UNEXPECTED(merge)) { + zephir_memory_observe(¤tBindTypes); + zephir_read_property(¤tBindTypes, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC); + if (Z_TYPE_P(¤tBindTypes) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&_0$$4); + zephir_add_function(&_0$$4, ¤tBindTypes, &bindTypes); + zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &_0$$4); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); + } + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); } - RETURN_MM_NULL(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, reset) -{ - zval _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("metaData"), &_0); - ZEPHIR_INIT_VAR(&_1); - array_init(&_1); - zephir_update_property_zval(this_ptr, ZEND_STRL("columnMap"), &_1); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setAutomaticCreateAttributes) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes; - zval *model, model_sub, *attributes_param = NULL, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ARRAY(attributes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &attributes_param); - zephir_get_arrval(&attributes, attributes_param); - ZVAL_LONG(&_0, 10); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "writemetadataindex", NULL, 29, model, &_0, &attributes); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setAutomaticUpdateAttributes) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes; - zval *model, model_sub, *attributes_param = NULL, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ARRAY(attributes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &attributes_param); - zephir_get_arrval(&attributes, attributes_param); - ZVAL_LONG(&_0, 11); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "writemetadataindex", NULL, 29, model, &_0, &attributes); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setEmptyStringAttributes) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes; - zval *model, model_sub, *attributes_param = NULL, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ARRAY(attributes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &attributes_param); - zephir_get_arrval(&attributes, attributes_param); - ZVAL_LONG(&_0, 13); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "writemetadataindex", NULL, 29, model, &_0, &attributes); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setDI) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, setDI) { zval *container, container_sub; zval *this_ptr = getThis(); @@ -59340,403 +62087,611 @@ static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setDI) zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, setStrategy) -{ - zval *strategy, strategy_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&strategy_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(strategy, phalcon_mvc_model_metadata_strategy_strategyinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &strategy); - zephir_update_property_zval(this_ptr, ZEND_STRL("strategy"), strategy); -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, write) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, where) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval data; - zval *key_param = NULL, *data_param = NULL, result, option, _1, _2, _0$$3; - zval key; + zval bindParams, bindTypes; + zval *conditions_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, currentBindParams, currentBindTypes, _0$$4, _1$$7; + zval conditions; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&option); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&data); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(key) - Z_PARAM_ARRAY(data) + ZVAL_UNDEF(&conditions); + ZVAL_UNDEF(¤tBindParams); + ZVAL_UNDEF(¤tBindTypes); + ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&_1$$7); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&bindTypes); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(conditions) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(bindParams) + Z_PARAM_ARRAY(bindTypes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &key_param, &data_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams_param, &bindTypes_param); + zephir_get_strval(&conditions, conditions_param); + if (!bindParams_param) { + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); + } else { + zephir_get_arrval(&bindParams, bindParams_param); } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + if (!bindTypes_param) { + ZEPHIR_INIT_VAR(&bindTypes); + array_init(&bindTypes); } else { - ZEPHIR_INIT_VAR(&key); + zephir_get_arrval(&bindTypes, bindTypes_param); } - zephir_get_arrval(&data, data_param); - /* try_start_1: */ - - ZEPHIR_INIT_VAR(&option); - ZVAL_BOOL(&option, ZEPHIR_GLOBAL(orm).exception_on_failed_metadata_save); - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&result, &_0$$3, "set", NULL, 0, &key, &data); - zephir_check_call_status_or_jump(try_end_1); - if (ZEPHIR_IS_FALSE_IDENTICAL(&result)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwwriteexception", NULL, 30, &option); - zephir_check_call_status_or_jump(try_end_1); - } - - try_end_1: - - if (EG(exception)) { - ZEPHIR_INIT_VAR(&_1); - ZVAL_OBJ(&_1, EG(exception)); - Z_ADDREF_P(&_1); - ZEPHIR_INIT_VAR(&_2); - if (zephir_is_instance_of(&_1, SL("Exception"))) { - zend_clear_exception(); - ZEPHIR_CPY_WRT(&_2, &_1); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwwriteexception", NULL, 30, &option); - zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("conditions"), &conditions); + if (zephir_fast_count_int(&bindParams) > 0) { + zephir_memory_observe(¤tBindParams); + zephir_read_property(¤tBindParams, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC); + if (Z_TYPE_P(¤tBindParams) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&_0$$4); + zephir_add_function(&_0$$4, ¤tBindParams, &bindParams); + zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &_0$$4); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &bindParams); } } - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, writeMetaDataIndex) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long index, ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, *index_param = NULL, *data, data_sub, key; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&data_sub); - ZVAL_UNDEF(&key); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_LONG(index) - Z_PARAM_ZVAL(data) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &model, &index_param, &data); - ZEPHIR_CALL_METHOD(&key, this_ptr, "getmetadatauniquekey", NULL, 28, model); - zephir_check_call_status(); - if (EXPECTED(Z_TYPE_P(&key) != IS_NULL)) { - zephir_update_property_array_multi(this_ptr, SL("metaData"), data, SL("zl"), 2, &key, index); + if (zephir_fast_count_int(&bindTypes) > 0) { + zephir_read_property(¤tBindTypes, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(¤tBindTypes) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&_1$$7); + zephir_add_function(&_1$$7, ¤tBindTypes, &bindTypes); + zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &_1$$7); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); + } } - ZEPHIR_MM_RESTORE(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, initialize) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, conditionBetween) { + zval _6; + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, *key, key_sub, *table, table_sub, *schema, schema_sub; + zval *clause_param = NULL, *operator_param = NULL, *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, hiddenParam, nextHiddenParam, minimumKey, maximumKey, operatorMethod, _5, _1$$3, _2$$3, _3$$3; + zval clause, operator, expr, _4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&key_sub); - ZVAL_UNDEF(&table_sub); - ZVAL_UNDEF(&schema_sub); - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ZVAL(key) - Z_PARAM_ZVAL(table) - Z_PARAM_ZVAL(schema) + ZVAL_UNDEF(&clause); + ZVAL_UNDEF(&operator); + ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&minimum_sub); + ZVAL_UNDEF(&maximum_sub); + ZVAL_UNDEF(&hiddenParam); + ZVAL_UNDEF(&nextHiddenParam); + ZVAL_UNDEF(&minimumKey); + ZVAL_UNDEF(&maximumKey); + ZVAL_UNDEF(&operatorMethod); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_6); + ZEND_PARSE_PARAMETERS_START(5, 5) + Z_PARAM_STR(clause) + Z_PARAM_STR(operator) + Z_PARAM_STR(expr) + Z_PARAM_ZVAL(minimum) + Z_PARAM_ZVAL(maximum) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 0, &model, &key, &table, &schema); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "initializemetadata", NULL, 31, model, key); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "initializecolumnmap", NULL, 32, model, key); + zephir_fetch_params(1, 5, 0, &clause_param, &operator_param, &expr_param, &minimum, &maximum); + if (UNEXPECTED(Z_TYPE_P(clause_param) != IS_STRING && Z_TYPE_P(clause_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'clause' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(clause_param) == IS_STRING)) { + zephir_get_strval(&clause, clause_param); + } else { + ZEPHIR_INIT_VAR(&clause); + } + if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { + zephir_get_strval(&operator, operator_param); + } else { + ZEPHIR_INIT_VAR(&operator); + } + if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { + zephir_get_strval(&expr, expr_param); + } else { + ZEPHIR_INIT_VAR(&expr); + } + _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "and"); + if (_0) { + _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "or"); + } + if (UNEXPECTED(_0)) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "Operator % is not available."); + ZEPHIR_CALL_FUNCTION(&_3$$3, "sprintf", NULL, 117, &_2$$3, &operator); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_3$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model/Query/Builder.zep", 1597); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_VAR(&_4); + ZEPHIR_CONCAT_VV(&_4, &operator, &clause); + ZEPHIR_CPY_WRT(&operatorMethod, &_4); + zephir_memory_observe(&hiddenParam); + zephir_read_property(&hiddenParam, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(&nextHiddenParam); + ZVAL_LONG(&nextHiddenParam, (zephir_get_numberval(&hiddenParam) + 1)); + ZEPHIR_INIT_VAR(&minimumKey); + ZEPHIR_CONCAT_SV(&minimumKey, "AP", &hiddenParam); + ZEPHIR_INIT_VAR(&maximumKey); + ZEPHIR_CONCAT_SV(&maximumKey, "AP", &nextHiddenParam); + ZEPHIR_INIT_VAR(&_5); + ZEPHIR_CONCAT_VSVSVS(&_5, &expr, " BETWEEN :", &minimumKey, ": AND :", &maximumKey, ":"); + ZEPHIR_INIT_VAR(&_6); + zephir_create_array(&_6, 2, 0); + zephir_array_update_zval(&_6, &minimumKey, minimum, PH_COPY); + zephir_array_update_zval(&_6, &maximumKey, maximum, PH_COPY); + ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &operatorMethod, NULL, 0, &_5, &_6); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + SEPARATE_ZVAL(&nextHiddenParam); + zephir_increment(&nextHiddenParam); + zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &nextHiddenParam); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, initializeMetaData) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, conditionIn) { - zval prefixKey; + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, *key, key_sub, strategy, metaData, data, modelMetadata, container, _0$$3, _1$$4, _2$$8, _3$$8, _4$$8; + zend_long ZEPHIR_LAST_CALL_STATUS, hiddenParam = 0; + zval values; + zval *clause_param = NULL, *operator_param = NULL, *expr_param = NULL, *values_param = NULL, key, queryKey, value, bindKeys, bindParams, operatorMethod, _6, *_7, _8, _13, _14, _15, _1$$3, _2$$3, _3$$3, _9$$5, _11$$6; + zval clause, operator, expr, _4, _5$$4, _10$$5, _12$$6; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&key_sub); - ZVAL_UNDEF(&strategy); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&modelMetadata); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$8); - ZVAL_UNDEF(&_3$$8); - ZVAL_UNDEF(&_4$$8); - ZVAL_UNDEF(&prefixKey); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ZVAL(key) + ZVAL_UNDEF(&clause); + ZVAL_UNDEF(&operator); + ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_10$$5); + ZVAL_UNDEF(&_12$$6); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&queryKey); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&bindKeys); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&operatorMethod); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_13); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_15); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_11$$6); + ZVAL_UNDEF(&values); + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_STR(clause) + Z_PARAM_STR(operator) + Z_PARAM_STR(expr) + Z_PARAM_ARRAY(values) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &key); - ZEPHIR_INIT_VAR(&strategy); - ZVAL_NULL(&strategy); - if (EXPECTED(Z_TYPE_P(key) != IS_NULL)) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&metaData, &_0$$3); - if (0 == zephir_array_isset(&metaData, key)) { - ZEPHIR_INIT_VAR(&_1$$4); - ZEPHIR_CONCAT_SV(&_1$$4, "meta-", key); - zephir_get_strval(&prefixKey, &_1$$4); - ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, &prefixKey); + zephir_fetch_params(1, 4, 0, &clause_param, &operator_param, &expr_param, &values_param); + if (UNEXPECTED(Z_TYPE_P(clause_param) != IS_STRING && Z_TYPE_P(clause_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'clause' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(clause_param) == IS_STRING)) { + zephir_get_strval(&clause, clause_param); + } else { + ZEPHIR_INIT_VAR(&clause); + } + if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { + zephir_get_strval(&operator, operator_param); + } else { + ZEPHIR_INIT_VAR(&operator); + } + if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { + zephir_get_strval(&expr, expr_param); + } else { + ZEPHIR_INIT_VAR(&expr); + } + ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); + _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "and"); + if (_0) { + _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "or"); + } + if (UNEXPECTED(_0)) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "Operator % is not available."); + ZEPHIR_CALL_FUNCTION(&_3$$3, "sprintf", NULL, 117, &_2$$3, &operator); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_3$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model/Query/Builder.zep", 1645); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_VAR(&_4); + ZEPHIR_CONCAT_VV(&_4, &operator, &clause); + ZEPHIR_CPY_WRT(&operatorMethod, &_4); + if (!(zephir_fast_count_int(&values))) { + ZEPHIR_INIT_VAR(&_5$$4); + ZEPHIR_CONCAT_VSV(&_5$$4, &expr, " != ", &expr); + ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &operatorMethod, NULL, 0, &_5$$4); + zephir_check_call_status(); + RETURN_THIS(); + } + zephir_memory_observe(&_6); + zephir_read_property(&_6, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); + hiddenParam = zephir_get_intval(&_6); + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); + ZEPHIR_INIT_VAR(&bindKeys); + array_init(&bindKeys); + zephir_is_iterable(&values, 0, "phalcon/Mvc/Model/Query/Builder.zep", 1676); + if (Z_TYPE_P(&values) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&values), _7) + { + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _7); + ZEPHIR_INIT_NVAR(&_9$$5); + ZVAL_LONG(&_9$$5, hiddenParam); + ZEPHIR_INIT_NVAR(&_10$$5); + ZEPHIR_CONCAT_SV(&_10$$5, "AP", &_9$$5); + ZEPHIR_CPY_WRT(&key, &_10$$5); + ZEPHIR_INIT_NVAR(&queryKey); + ZEPHIR_CONCAT_SVS(&queryKey, ":", &key, ":"); + zephir_array_append(&bindKeys, &queryKey, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 1667); + zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); + hiddenParam++; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_8, &values, "valid", NULL, 0); zephir_check_call_status(); - if (Z_TYPE_P(&data) != IS_NULL) { - zephir_update_property_array(this_ptr, SL("metaData"), key, &data); - } else { - if ((zephir_method_exists_ex(model, ZEND_STRL("metadata")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(&modelMetadata, model, "metadata", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&modelMetadata) != IS_ARRAY)) { - ZEPHIR_INIT_VAR(&_2$$8); - object_init_ex(&_2$$8, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_3$$8); - zephir_get_class(&_3$$8, model, 0); - ZEPHIR_INIT_VAR(&_4$$8); - ZEPHIR_CONCAT_SV(&_4$$8, "Invalid meta-data for model ", &_3$$8); - ZEPHIR_CALL_METHOD(NULL, &_2$$8, "__construct", NULL, 33, &_4$$8); - zephir_check_call_status(); - zephir_throw_exception_debug(&_2$$8, "phalcon/Mvc/Model/MetaData.zep", 785); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CALL_METHOD(&container, this_ptr, "getdi", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&modelMetadata, &strategy, "getmetadata", NULL, 0, model, &container); - zephir_check_call_status(); - } - zephir_update_property_array(this_ptr, SL("metaData"), key, &modelMetadata); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, &prefixKey, &modelMetadata); - zephir_check_call_status(); + if (!zend_is_true(&_8)) { + break; } + ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_11$$6); + ZVAL_LONG(&_11$$6, hiddenParam); + ZEPHIR_INIT_NVAR(&_12$$6); + ZEPHIR_CONCAT_SV(&_12$$6, "AP", &_11$$6); + ZEPHIR_CPY_WRT(&key, &_12$$6); + ZEPHIR_INIT_NVAR(&queryKey); + ZEPHIR_CONCAT_SVS(&queryKey, ":", &key, ":"); + zephir_array_append(&bindKeys, &queryKey, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 1667); + zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); + hiddenParam++; + ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); + zephir_check_call_status(); } - RETURN_MM_BOOL(1); } - RETURN_MM_BOOL(0); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_VAR(&_13); + zephir_fast_join_str(&_13, SL(", "), &bindKeys); + ZEPHIR_INIT_VAR(&_14); + ZEPHIR_CONCAT_VSVS(&_14, &expr, " IN (", &_13, ")"); + ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &operatorMethod, NULL, 0, &_14, &bindParams); + zephir_check_call_status(); + ZVAL_UNDEF(&_15); + ZVAL_LONG(&_15, hiddenParam); + zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &_15); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, initializeColumnMap) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, conditionNotBetween) { - zval prefixKey; + zval _6; + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, *key, key_sub, strategy, data, modelColumnMap, container, _0, _1; + zval *clause_param = NULL, *operator_param = NULL, *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, hiddenParam, nextHiddenParam, minimumKey, maximumKey, operatorMethod, _5, _1$$3, _2$$3, _3$$3; + zval clause, operator, expr, _4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&key_sub); - ZVAL_UNDEF(&strategy); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&modelColumnMap); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&prefixKey); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ZVAL(key) + ZVAL_UNDEF(&clause); + ZVAL_UNDEF(&operator); + ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&minimum_sub); + ZVAL_UNDEF(&maximum_sub); + ZVAL_UNDEF(&hiddenParam); + ZVAL_UNDEF(&nextHiddenParam); + ZVAL_UNDEF(&minimumKey); + ZVAL_UNDEF(&maximumKey); + ZVAL_UNDEF(&operatorMethod); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_6); + ZEND_PARSE_PARAMETERS_START(5, 5) + Z_PARAM_STR(clause) + Z_PARAM_STR(operator) + Z_PARAM_STR(expr) + Z_PARAM_ZVAL(minimum) + Z_PARAM_ZVAL(maximum) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &key); - if (UNEXPECTED(Z_TYPE_P(key) == IS_NULL)) { - RETURN_MM_BOOL(0); + zephir_fetch_params(1, 5, 0, &clause_param, &operator_param, &expr_param, &minimum, &maximum); + if (UNEXPECTED(Z_TYPE_P(clause_param) != IS_STRING && Z_TYPE_P(clause_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'clause' must be of the type string")); + RETURN_MM_NULL(); } - if (!(ZEPHIR_GLOBAL(orm).column_renaming)) { - RETURN_MM_BOOL(0); + if (EXPECTED(Z_TYPE_P(clause_param) == IS_STRING)) { + zephir_get_strval(&clause, clause_param); + } else { + ZEPHIR_INIT_VAR(&clause); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); - if (1 == zephir_array_isset(&_0, key)) { - RETURN_MM_BOOL(1); + if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_INIT_VAR(&_1); - ZEPHIR_CONCAT_SV(&_1, "map-", key); - zephir_get_strval(&prefixKey, &_1); - ZEPHIR_CALL_METHOD(&data, this_ptr, "read", NULL, 0, &prefixKey); - zephir_check_call_status(); - if (Z_TYPE_P(&data) != IS_NULL) { - zephir_update_property_array(this_ptr, SL("columnMap"), key, &data); - RETURN_MM_BOOL(1); + if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { + zephir_get_strval(&operator, operator_param); + } else { + ZEPHIR_INIT_VAR(&operator); } - ZEPHIR_CALL_METHOD(&container, this_ptr, "getdi", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&strategy, this_ptr, "getstrategy", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&modelColumnMap, &strategy, "getcolumnmaps", NULL, 0, model, &container); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("columnMap"), key, &modelColumnMap); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, &prefixKey, &modelColumnMap); + if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { + zephir_get_strval(&expr, expr_param); + } else { + ZEPHIR_INIT_VAR(&expr); + } + _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "and"); + if (_0) { + _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "or"); + } + if (UNEXPECTED(_0)) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "Operator % is not available."); + ZEPHIR_CALL_FUNCTION(&_3$$3, "sprintf", NULL, 117, &_2$$3, &operator); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_3$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model/Query/Builder.zep", 1699); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_VAR(&_4); + ZEPHIR_CONCAT_VV(&_4, &operator, &clause); + ZEPHIR_CPY_WRT(&operatorMethod, &_4); + zephir_memory_observe(&hiddenParam); + zephir_read_property(&hiddenParam, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(&nextHiddenParam); + ZVAL_LONG(&nextHiddenParam, (zephir_get_numberval(&hiddenParam) + 1)); + ZEPHIR_INIT_VAR(&minimumKey); + ZEPHIR_CONCAT_SV(&minimumKey, "AP", &hiddenParam); + ZEPHIR_INIT_VAR(&maximumKey); + ZEPHIR_CONCAT_SV(&maximumKey, "AP", &nextHiddenParam); + ZEPHIR_INIT_VAR(&_5); + ZEPHIR_CONCAT_VSVSVS(&_5, &expr, " NOT BETWEEN :", &minimumKey, ": AND :", &maximumKey, ":"); + ZEPHIR_INIT_VAR(&_6); + zephir_create_array(&_6, 2, 0); + zephir_array_update_zval(&_6, &minimumKey, minimum, PH_COPY); + zephir_array_update_zval(&_6, &maximumKey, maximum, PH_COPY); + ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &operatorMethod, NULL, 0, &_5, &_6); zephir_check_call_status(); - RETURN_MM_BOOL(1); + SEPARATE_ZVAL(&nextHiddenParam); + zephir_increment(&nextHiddenParam); + zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &nextHiddenParam); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, throwWriteException) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, conditionNotIn) { - zval message; + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *option, option_sub, _0$$3; + zend_long ZEPHIR_LAST_CALL_STATUS, hiddenParam = 0; + zval values; + zval *clause_param = NULL, *operator_param = NULL, *expr_param = NULL, *values_param = NULL, key, queryKey, value, bindKeys, bindParams, operatorMethod, _6, *_7, _8, _13, _14, _15, _1$$3, _2$$3, _3$$3, _9$$5, _11$$6; + zval clause, operator, expr, _4, _5$$4, _10$$5, _12$$6; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&option_sub); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&message); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(option) + ZVAL_UNDEF(&clause); + ZVAL_UNDEF(&operator); + ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_10$$5); + ZVAL_UNDEF(&_12$$6); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&queryKey); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&bindKeys); + ZVAL_UNDEF(&bindParams); + ZVAL_UNDEF(&operatorMethod); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_13); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_15); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_11$$6); + ZVAL_UNDEF(&values); + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_STR(clause) + Z_PARAM_STR(operator) + Z_PARAM_STR(expr) + Z_PARAM_ARRAY(values) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &option); - ZEPHIR_INIT_VAR(&message); - ZVAL_STRING(&message, "Failed to store metaData to the cache adapter"); - if (zephir_is_true(option)) { - ZEPHIR_INIT_VAR(&_0$$3); - object_init_ex(&_0$$3, phalcon_mvc_model_exception_ce); - ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 33, &message); + zephir_fetch_params(1, 4, 0, &clause_param, &operator_param, &expr_param, &values_param); + if (UNEXPECTED(Z_TYPE_P(clause_param) != IS_STRING && Z_TYPE_P(clause_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'clause' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(clause_param) == IS_STRING)) { + zephir_get_strval(&clause, clause_param); + } else { + ZEPHIR_INIT_VAR(&clause); + } + if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { + zephir_get_strval(&operator, operator_param); + } else { + ZEPHIR_INIT_VAR(&operator); + } + if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { + zephir_get_strval(&expr, expr_param); + } else { + ZEPHIR_INIT_VAR(&expr); + } + ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); + _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "and"); + if (_0) { + _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "or"); + } + if (UNEXPECTED(_0)) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "Operator % is not available."); + ZEPHIR_CALL_FUNCTION(&_3$$3, "sprintf", NULL, 117, &_2$$3, &operator); zephir_check_call_status(); - zephir_throw_exception_debug(&_0$$3, "phalcon/Mvc/Model/MetaData.zep", 882); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_3$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model/Query/Builder.zep", 1746); ZEPHIR_MM_RESTORE(); return; + } + ZEPHIR_INIT_VAR(&_4); + ZEPHIR_CONCAT_VV(&_4, &operator, &clause); + ZEPHIR_CPY_WRT(&operatorMethod, &_4); + if (!(zephir_fast_count_int(&values))) { + ZEPHIR_INIT_VAR(&_5$$4); + ZEPHIR_CONCAT_VSV(&_5$$4, &expr, " != ", &expr); + ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &operatorMethod, NULL, 0, &_5$$4); + zephir_check_call_status(); + RETURN_THIS(); + } + zephir_memory_observe(&_6); + zephir_read_property(&_6, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); + hiddenParam = zephir_get_intval(&_6); + ZEPHIR_INIT_VAR(&bindParams); + array_init(&bindParams); + ZEPHIR_INIT_VAR(&bindKeys); + array_init(&bindKeys); + zephir_is_iterable(&values, 0, "phalcon/Mvc/Model/Query/Builder.zep", 1777); + if (Z_TYPE_P(&values) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&values), _7) + { + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _7); + ZEPHIR_INIT_NVAR(&_9$$5); + ZVAL_LONG(&_9$$5, hiddenParam); + ZEPHIR_INIT_NVAR(&_10$$5); + ZEPHIR_CONCAT_SV(&_10$$5, "AP", &_9$$5); + ZEPHIR_CPY_WRT(&key, &_10$$5); + ZEPHIR_INIT_NVAR(&queryKey); + ZEPHIR_CONCAT_SVS(&queryKey, ":", &key, ":"); + zephir_array_append(&bindKeys, &queryKey, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 1768); + zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); + hiddenParam++; + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_FUNCTION(NULL, "trigger_error", NULL, 7, &message); + ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_8, &values, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_8)) { + break; + } + ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_11$$6); + ZVAL_LONG(&_11$$6, hiddenParam); + ZEPHIR_INIT_NVAR(&_12$$6); + ZEPHIR_CONCAT_SV(&_12$$6, "AP", &_11$$6); + ZEPHIR_CPY_WRT(&key, &_12$$6); + ZEPHIR_INIT_NVAR(&queryKey); + ZEPHIR_CONCAT_SVS(&queryKey, ":", &key, ":"); + zephir_array_append(&bindKeys, &queryKey, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 1768); + zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); + hiddenParam++; + ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); + zephir_check_call_status(); + } } - ZEPHIR_MM_RESTORE(); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_VAR(&_13); + zephir_fast_join_str(&_13, SL(", "), &bindKeys); + ZEPHIR_INIT_VAR(&_14); + ZEPHIR_CONCAT_VSVS(&_14, &expr, " NOT IN (", &_13, ")"); + ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &operatorMethod, NULL, 0, &_14, &bindParams); + zephir_check_call_status(); + ZVAL_UNDEF(&_15); + ZVAL_LONG(&_15, hiddenParam); + zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &_15); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getArrVal) +zend_object *zephir_init_properties_Phalcon_Mvc_Model_Query_Builder(zend_class_entry *class_type) { + zval _0, _2, _4, _6, _1$$3, _3$$4, _5$$5, _7$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *collection_param = NULL, *index, index_sub, *defaultValue = NULL, defaultValue_sub, __$null, value; - zval collection; - - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&index_sub); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&value); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_ARRAY(collection) - Z_PARAM_ZVAL(index) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &collection_param, &index, &defaultValue); - ZEPHIR_OBS_COPY_OR_DUP(&collection, collection_param); - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; - } - zephir_memory_observe(&value); - if (UNEXPECTED(!(zephir_array_isset_fetch(&value, &collection, index, 0)))) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); - } - RETURN_CCTOR(&value); -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getMetaDataUniqueKey) -{ - zval key; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, _0, _1$$3; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&key); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZEPHIR_INIT_VAR(&key); - zephir_get_class(&key, model, 1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - if (0 == zephir_array_isset(&_0, &key)) { - ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "initializemetadata", NULL, 31, model, &key); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$3)) { - RETURN_MM_NULL(); - } - } - RETURN_CTOR(&key); -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData, getColumnMapUniqueKey) -{ - zval key; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, _0, _1$$3; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&key); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &model); - ZEPHIR_INIT_VAR(&key); - zephir_get_class(&key, model, 1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); - if (0 == zephir_array_isset(&_0, &key)) { - ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "initializecolumnmap", NULL, 32, model, &key); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$3)) { - RETURN_MM_NULL(); - } - } - RETURN_CTOR(&key); -} - -zend_object *zephir_init_properties_Phalcon_Mvc_Model_MetaData(zend_class_entry *class_type) -{ - zval _0, _2, _1$$3, _3$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); @@ -59744,17 +62699,29 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Model_MetaData(zend_class_entry { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("joins"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("metaData"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("joins"), &_1$$3); } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("group"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_2) == IS_NULL) { ZEPHIR_INIT_VAR(&_3$$4); array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("columnMap"), &_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("group"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("bindTypes"), &_5$$5); + } + zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_6) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$6); + array_init(&_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("bindParams"), &_7$$6); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -59771,115 +62738,55 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Model_MetaData(zend_class_entry -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaDataInterface) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query_BuilderInterface) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, MetaDataInterface, phalcon, mvc_model_metadatainterface, phalcon_mvc_model_metadatainterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getAutomaticCreateAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getAutomaticUpdateAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getBindTypes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getColumnMap); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getDefaultValues); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getDataTypes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getDataTypesNumeric); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getEmptyStringAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getIdentityField); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getNonPrimaryKeyAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getNotNullAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getPrimaryKeyAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getReverseColumnMap); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, getStrategy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, hasAttribute); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, isEmpty); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, read); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, readColumnMap); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, readColumnMapIndex); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, readMetaData); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, readMetaDataIndex); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, reset); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, setAutomaticCreateAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, setAutomaticUpdateAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, setEmptyStringAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, writeMetaDataIndex); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, setStrategy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaDataInterface, write); - - - - -#ifdef HAVE_CONFIG_H -#endif - - -#if PHP_VERSION_ID < 70000 -#else -#endif - -static void phalcon_orm_destroy_cache() { + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model\\Query, BuilderInterface, phalcon, mvc_model_query_builderinterface, phalcon_mvc_model_query_builderinterface_method_entry); - zend_phalcon_globals *phalcon_globals_ptr = ZEPHIR_VGLOBAL; + zephir_declare_class_constant_string(phalcon_mvc_model_query_builderinterface_ce, SL("OPERATOR_AND"), "and"); - if (phalcon_globals_ptr->orm.parser_cache != NULL) { - zend_hash_destroy(phalcon_globals_ptr->orm.parser_cache); - FREE_HASHTABLE(phalcon_globals_ptr->orm.parser_cache); - phalcon_globals_ptr->orm.parser_cache = NULL; - } + zephir_declare_class_constant_string(phalcon_mvc_model_query_builderinterface_ce, SL("OPERATOR_OR"), "or"); - if (phalcon_globals_ptr->orm.ast_cache != NULL) { - zend_hash_destroy(phalcon_globals_ptr->orm.ast_cache); - FREE_HASHTABLE(phalcon_globals_ptr->orm.ast_cache); - phalcon_globals_ptr->orm.ast_cache = NULL; - } + return SUCCESS; } -static void phalcon_orm_singlequotes(zval *return_value, zval *str) { - - int i; - smart_str escaped_str = {0}; - char *marker; - - if (Z_TYPE_P(str) != IS_STRING) { - RETURN_ZVAL(str, 1, 0); - } - - marker = Z_STRVAL_P(str); - - for (i = 0; i < Z_STRLEN_P(str); i++) { - if ((*marker) == '\0') { - break; - } - if ((*marker) == '\'') { - if (i > 0) { - if (*(marker - 1) != '\\') { - smart_str_appendc(&escaped_str, '\''); - } - } else { - smart_str_appendc(&escaped_str, '\''); - } - } - smart_str_appendc(&escaped_str, (*marker)); - marker++; - } - - smart_str_0(&escaped_str); - -#if PHP_VERSION_ID < 70000 - if (escaped_str.len) { - RETURN_STRINGL(escaped_str.c, escaped_str.len, 0); - } -#else - if (escaped_str.s) { - RETURN_STR(escaped_str.s); - } -#endif - - smart_str_free(&escaped_str); - RETURN_EMPTY_STRING(); -} +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, addFrom); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, andWhere); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, betweenWhere); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, columns); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, distinct); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, forUpdate); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, from); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getBindParams); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getBindTypes); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getColumns); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getDistinct); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getFrom); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getGroupBy); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getHaving); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getJoins); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getLimit); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getOffset); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getOrderBy); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getPhql); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getQuery); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getWhere); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, groupBy); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, having); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, innerJoin); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, inWhere); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, join); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, leftJoin); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, limit); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getModels); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, notBetweenWhere); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, notInWhere); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, offset); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, orderBy); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, orWhere); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, rightJoin); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, setBindParams); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, setBindTypes); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, where); @@ -59890,21338 +62797,8090 @@ static void phalcon_orm_singlequotes(zval *return_value, zval *str) { -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query_Lang) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Query, phalcon, mvc_model_query, phalcon_mvc_model_query_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("ast"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("bindParams"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("bindTypes"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("cache"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("cacheOptions"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("container"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("enableImplicitJoins"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("intermediate"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("manager"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("metaData"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("models"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("modelsInstances"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_model_query_ce, SL("nestingLevel"), -1, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("phql"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_query_ce, SL("sharedLock"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("sqlAliases"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("sqlAliasesModels"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("sqlAliasesModelsInstances"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("sqlColumnAliases"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("sqlModelsAliases"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("type"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_query_ce, SL("uniqueRow"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("transaction"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_ce, SL("internalPhqlCache"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC); - phalcon_mvc_model_query_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Query; - zephir_declare_class_constant_long(phalcon_mvc_model_query_ce, SL("TYPE_DELETE"), 303); - - zephir_declare_class_constant_long(phalcon_mvc_model_query_ce, SL("TYPE_INSERT"), 306); - - zephir_declare_class_constant_long(phalcon_mvc_model_query_ce, SL("TYPE_SELECT"), 309); - - zephir_declare_class_constant_long(phalcon_mvc_model_query_ce, SL("TYPE_UPDATE"), 300); + ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model\\Query, Lang, phalcon, mvc_model_query_lang, phalcon_mvc_model_query_lang_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zend_class_implements(phalcon_mvc_model_query_ce, 1, phalcon_mvc_model_queryinterface_ce); - zend_class_implements(phalcon_mvc_model_query_ce, 1, phalcon_di_injectionawareinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Query, __construct) +static PHP_METHOD(Phalcon_Mvc_Model_Query_Lang, parsePHQL) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval *phql_param = NULL, *container = NULL, container_sub, *options_param = NULL, __$true, __$false, __$null, enableImplicitJoins, _0, _1; + zval *phql_param = NULL; zval phql; - zval *this_ptr = getThis(); ZVAL_UNDEF(&phql); - ZVAL_UNDEF(&container_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&enableImplicitJoins); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&options); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 3) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(phql) - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(container, phalcon_di_diinterface_ce) - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 3, &phql_param, &container, &options_param); - if (!phql_param) { - ZEPHIR_INIT_VAR(&phql); - } else { - zephir_get_strval(&phql, phql_param); - } - if (!container) { - container = &container_sub; - container = &__$null; - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("phql"), &phql); - if (Z_TYPE_P(container) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdi", NULL, 0, container); - zephir_check_call_status(); - } - zephir_memory_observe(&enableImplicitJoins); - if (zephir_array_isset_string_fetch(&enableImplicitJoins, &options, SL("enable_implicit_joins"), 0)) { - if (ZEPHIR_IS_TRUE(&enableImplicitJoins)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("enableImplicitJoins"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("enableImplicitJoins"), &__$false); - } - } else { - if (ZEPHIR_GLOBAL(orm).enable_implicit_joins) { - zephir_update_property_zval(this_ptr, ZEND_STRL("enableImplicitJoins"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("enableImplicitJoins"), &__$false); - } - } - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &_0); - ZEPHIR_INIT_VAR(&_1); - array_init(&_1); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &_1); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, cache) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *cacheOptions_param = NULL; - zval cacheOptions; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&cacheOptions); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(cacheOptions) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &cacheOptions_param); - zephir_get_arrval(&cacheOptions, cacheOptions_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("cacheOptions"), &cacheOptions); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, clean) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_static_property_ce(phalcon_mvc_model_query_ce, ZEND_STRL("internalPhqlCache"), &_0); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, execute) -{ - zval _5$$8; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *bindParams_param = NULL, *bindTypes_param = NULL, uniqueRow, cacheOptions, key, cacheService, cache, result, preparedResult, defaultBindParams, mergedParams, defaultBindTypes, mergedTypes, type, lifetime, intermediate, _0, _1$$3, _2$$3, _3$$3, _4$$8, _6$$9, _7$$19, _8$$19; - zval bindParams, bindTypes; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&uniqueRow); - ZVAL_UNDEF(&cacheOptions); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&cacheService); - ZVAL_UNDEF(&cache); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&preparedResult); - ZVAL_UNDEF(&defaultBindParams); - ZVAL_UNDEF(&mergedParams); - ZVAL_UNDEF(&defaultBindTypes); - ZVAL_UNDEF(&mergedTypes); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&lifetime); - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$8); - ZVAL_UNDEF(&_6$$9); - ZVAL_UNDEF(&_7$$19); - ZVAL_UNDEF(&_8$$19); - ZVAL_UNDEF(&_5$$8); - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) + Z_PARAM_STR(phql) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &bindParams_param, &bindTypes_param); - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - } else { - zephir_get_arrval(&bindParams, bindParams_param); + zephir_fetch_params(1, 1, 0, &phql_param); + if (UNEXPECTED(Z_TYPE_P(phql_param) != IS_STRING && Z_TYPE_P(phql_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'phql' must be of the type string")); + RETURN_MM_NULL(); } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); + if (EXPECTED(Z_TYPE_P(phql_param) == IS_STRING)) { + zephir_get_strval(&phql, phql_param); } else { - zephir_get_arrval(&bindTypes, bindTypes_param); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("uniqueRow"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&uniqueRow, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("cacheOptions"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&cacheOptions, &_0); - if (Z_TYPE_P(&cacheOptions) != IS_NULL) { - if (UNEXPECTED(Z_TYPE_P(&cacheOptions) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid caching options", "phalcon/Mvc/Model/Query.zep", 274); - return; - } - zephir_memory_observe(&key); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&key, &cacheOptions, SL("key"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A cache key must be provided to identify the cached resultset in the cache backend", "phalcon/Mvc/Model/Query.zep", 283); - return; - } - zephir_memory_observe(&lifetime); - if (!(zephir_array_isset_string_fetch(&lifetime, &cacheOptions, SL("lifetime"), 0))) { - ZEPHIR_INIT_NVAR(&lifetime); - ZVAL_LONG(&lifetime, 3600); - } - zephir_memory_observe(&cacheService); - if (!(zephir_array_isset_string_fetch(&cacheService, &cacheOptions, SL("service"), 0))) { - ZEPHIR_INIT_NVAR(&cacheService); - ZVAL_STRING(&cacheService, "modelsCache"); - } - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&cache, &_1$$3, "getshared", NULL, 0, &cacheService); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "Phalcon\\Cache\\CacheInterface"); - ZEPHIR_CALL_FUNCTION(&_3$$3, "is_a", NULL, 87, &cache, &_2$$3); - zephir_check_call_status(); - if (UNEXPECTED(!ZEPHIR_IS_TRUE_IDENTICAL(&_3$$3))) { - ZEPHIR_INIT_VAR(&_4$$8); - object_init_ex(&_4$$8, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_5$$8); - ZEPHIR_CONCAT_SS(&_5$$8, "Cache service must be an object implementing ", "Phalcon\\Cache\\CacheInterface"); - ZEPHIR_CALL_METHOD(NULL, &_4$$8, "__construct", NULL, 33, &_5$$8); - zephir_check_call_status(); - zephir_throw_exception_debug(&_4$$8, "phalcon/Mvc/Model/Query.zep", 303); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CALL_METHOD(&result, &cache, "get", NULL, 0, &key); - zephir_check_call_status(); - if (!(ZEPHIR_IS_EMPTY(&result))) { - if (UNEXPECTED(Z_TYPE_P(&result) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Cache didn't return a valid resultset", "phalcon/Mvc/Model/Query.zep", 312); - return; - } - ZVAL_BOOL(&_6$$9, 0); - ZEPHIR_CALL_METHOD(NULL, &result, "setisfresh", NULL, 0, &_6$$9); - zephir_check_call_status(); - if (zephir_is_true(&uniqueRow)) { - ZEPHIR_CALL_METHOD(&preparedResult, &result, "getfirst", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&preparedResult, &result); - } - RETURN_CCTOR(&preparedResult); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), &cache); + ZEPHIR_INIT_VAR(&phql); } - ZEPHIR_CALL_METHOD(&intermediate, this_ptr, "parse", NULL, 0); + ZEPHIR_LAST_CALL_STATUS = phql_parse_phql(return_value, &phql); zephir_check_call_status(); - zephir_memory_observe(&defaultBindParams); - zephir_read_property(&defaultBindParams, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&mergedParams); - zephir_add_function(&mergedParams, &defaultBindParams, &bindParams); - zephir_memory_observe(&defaultBindTypes); - zephir_read_property(&defaultBindTypes, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC); - if (Z_TYPE_P(&defaultBindTypes) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&mergedTypes); - zephir_add_function(&mergedTypes, &defaultBindTypes, &bindTypes); - } else { - ZEPHIR_CPY_WRT(&mergedTypes, &bindTypes); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("type"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&type, &_0); - do { - if (ZEPHIR_IS_LONG(&type, 309)) { - ZEPHIR_CALL_METHOD(&result, this_ptr, "executeselect", NULL, 446, &intermediate, &mergedParams, &mergedTypes); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&type, 306)) { - ZEPHIR_CALL_METHOD(&result, this_ptr, "executeinsert", NULL, 447, &intermediate, &mergedParams, &mergedTypes); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&type, 300)) { - ZEPHIR_CALL_METHOD(&result, this_ptr, "executeupdate", NULL, 448, &intermediate, &mergedParams, &mergedTypes); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&type, 303)) { - ZEPHIR_CALL_METHOD(&result, this_ptr, "executedelete", NULL, 449, &intermediate, &mergedParams, &mergedTypes); - zephir_check_call_status(); - break; - } - ZEPHIR_INIT_VAR(&_7$$19); - object_init_ex(&_7$$19, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_8$$19); - ZEPHIR_CONCAT_SV(&_8$$19, "Unknown statement ", &type); - ZEPHIR_CALL_METHOD(NULL, &_7$$19, "__construct", NULL, 33, &_8$$19); - zephir_check_call_status(); - zephir_throw_exception_debug(&_7$$19, "phalcon/Mvc/Model/Query.zep", 395); - ZEPHIR_MM_RESTORE(); - return; - } while(0); - - if (Z_TYPE_P(&cacheOptions) != IS_NULL) { - if (!ZEPHIR_IS_LONG(&type, 309)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Only PHQL statements that return resultsets can be cached", "phalcon/Mvc/Model/Query.zep", 408); - return; - } - ZEPHIR_CALL_METHOD(NULL, &cache, "set", NULL, 0, &key, &result, &lifetime); - zephir_check_call_status(); - } - if (zephir_is_true(&uniqueRow)) { - ZEPHIR_CALL_METHOD(&preparedResult, &result, "getfirst", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&preparedResult, &result); - } - RETURN_CCTOR(&preparedResult); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getCache) -{ - - RETURN_MEMBER(getThis(), "cache"); -} -static PHP_METHOD(Phalcon_Mvc_Model_Query, getCacheOptions) -{ - RETURN_MEMBER(getThis(), "cacheOptions"); -} +/* Driver template for the LEMON parser generator. +** The author disclaims copyright to this source code. +*/ +/* First off, code is include which follows the "include" declaration +** in the input file. */ +// 30 "parser.php.lemon" -static PHP_METHOD(Phalcon_Mvc_Model_Query, getBindParams) -{ - RETURN_MEMBER(getThis(), "bindParams"); -} +// 12 "parser.php.c" +/* Next is all token values, in a form suitable for use by makeheaders. +** This section will be null unless lemon is run with the -m switch. +*/ +/* Make sure the INTERFACE macro is defined. +*/ +#ifndef INTERFACE +# define INTERFACE 1 +#endif +/* The next thing included is series of defines which control +** various aspects of the generated parser. +** PPCODETYPE is the data type used for storing terminal +** and nonterminal numbers. "unsigned char" is +** used if there are fewer than 250 terminals +** and nonterminals. "int" is used otherwise. +** PPNOCODE is a number of type PPCODETYPE which corresponds +** to no legal terminal or nonterminal number. This +** number is used to fill in empty slots of the hash +** table. +** PPFALLBACK If defined, this indicates that one or more tokens +** have fall-back values which should be used if the +** original value of the token will not parse. +** PPACTIONTYPE is the data type used for storing terminal +** and nonterminal numbers. "unsigned char" is +** used if there are fewer than 250 rules and +** states combined. "int" is used otherwise. +** phql_TOKENTYPE is the data type used for minor tokens given +** directly to the parser from the tokenizer. +** PPMINORTYPE is the data type used for all minor tokens. +** This is typically a union of many types, one of +** which is phql_TOKENTYPE. The entry in the union +** for base tokens is called "pp0". +** PPSTACKDEPTH is the maximum depth of the parser's stack. +** phql_ARG_SDECL A static variable declaration for the %extra_argument +** phql_ARG_PDECL A parameter declaration for the %extra_argument +** phql_ARG_STORE Code to store %extra_argument into pppParser +** phql_ARG_FETCH Code to extract %extra_argument from pppParser +** PPNSTATE the combined number of states. +** PPNRULE the number of rules in the grammar +** PPERRORSYMBOL is the code number of the error symbol. If not +** defined, then do no error processing. +*/ +#define PPCODETYPE unsigned char +#define PPNOCODE 135 +#define PPACTIONTYPE unsigned short int +#define phql_TOKENTYPE phql_parser_token* +typedef union { + phql_TOKENTYPE pp0; + zval pp202; + int pp269; +} PPMINORTYPE; +#define PPSTACKDEPTH 100 +#define phql_ARG_SDECL phql_parser_status *status; +#define phql_ARG_PDECL ,phql_parser_status *status +#define phql_ARG_FETCH phql_parser_status *status = pppParser->status +#define phql_ARG_STORE pppParser->status = status +#define PPNSTATE 295 +#define PPNRULE 162 +#define PPERRORSYMBOL 80 +#define PPERRSYMDT pp269 +#define PP_NO_ACTION (PPNSTATE+PPNRULE+2) +#define PP_ACCEPT_ACTION (PPNSTATE+PPNRULE+1) +#define PP_ERROR_ACTION (PPNSTATE+PPNRULE) -static PHP_METHOD(Phalcon_Mvc_Model_Query, getBindTypes) -{ +/* Next are that tables used to determine what action to take based on the +** current state and lookahead token. These tables are used to implement +** functions that take a state number and lookahead value and return an +** action integer. +** +** Suppose the action integer is N. Then the action is determined as +** follows +** +** 0 <= N < PPNSTATE Shift N. That is, push the lookahead +** token onto the stack and goto state N. +** +** PPNSTATE <= N < PPNSTATE+PPNRULE Reduce by rule N-PPNSTATE. +** +** N == PPNSTATE+PPNRULE A syntax error has occurred. +** +** N == PPNSTATE+PPNRULE+1 The parser accepts its input. +** +** N == PPNSTATE+PPNRULE+2 No such action. Denotes unused +** slots in the pp_action[] table. +** +** The action table is constructed as a single large table named pp_action[]. +** Given state S and lookahead X, the action is computed as +** +** pp_action[ pp_shift_ofst[S] + X ] +** +** If the index value pp_shift_ofst[S]+X is out of range or if the value +** pp_lookahead[pp_shift_ofst[S]+X] is not equal to X or if pp_shift_ofst[S] +** is equal to PP_SHIFT_USE_DFLT, it means that the action is not in the table +** and that pp_default[S] should be used instead. +** +** The formula above is for computing the action when the lookahead is +** a terminal symbol. If the lookahead is a non-terminal (as occurs after +** a reduce action) then the pp_reduce_ofst[] array is used in place of +** the pp_shift_ofst[] array and PP_REDUCE_USE_DFLT is used in place of +** PP_SHIFT_USE_DFLT. +** +** The following are the tables generated in this section: +** +** pp_action[] A single table containing all actions. +** pp_lookahead[] A table containing the lookahead for each entry in +** pp_action. Used to detect hash collisions. +** pp_shift_ofst[] For each state, the offset into pp_action for +** shifting terminals. +** pp_reduce_ofst[] For each state, the offset into pp_action for +** shifting non-terminals after a reduce. +** pp_default[] Default action for each state. +*/ +static PPACTIONTYPE pp_action[] = { + /* 0 */ 120, 126, 128, 55, 57, 59, 61, 63, 65, 45, + /* 10 */ 47, 67, 72, 49, 51, 53, 41, 39, 43, 37, + /* 20 */ 34, 122, 74, 69, 120, 126, 128, 55, 57, 59, + /* 30 */ 61, 63, 65, 45, 47, 67, 72, 49, 51, 53, + /* 40 */ 41, 39, 43, 37, 34, 122, 74, 69, 19, 20, + /* 50 */ 21, 22, 23, 32, 33, 120, 126, 128, 55, 57, + /* 60 */ 59, 61, 63, 65, 45, 47, 67, 72, 49, 51, + /* 70 */ 53, 41, 39, 43, 37, 34, 122, 74, 69, 37, + /* 80 */ 34, 122, 74, 69, 94, 222, 81, 220, 95, 90, + /* 90 */ 111, 211, 113, 114, 213, 156, 79, 188, 89, 120, + /* 100 */ 126, 128, 55, 57, 59, 61, 63, 65, 45, 47, + /* 110 */ 67, 72, 49, 51, 53, 41, 39, 43, 37, 34, + /* 120 */ 122, 74, 69, 55, 57, 59, 61, 63, 65, 45, + /* 130 */ 47, 67, 72, 49, 51, 53, 41, 39, 43, 37, + /* 140 */ 34, 122, 74, 69, 132, 249, 120, 126, 128, 55, + /* 150 */ 57, 59, 61, 63, 65, 45, 47, 67, 72, 49, + /* 160 */ 51, 53, 41, 39, 43, 37, 34, 122, 74, 69, + /* 170 */ 41, 39, 43, 37, 34, 122, 74, 69, 142, 7, + /* 180 */ 120, 126, 128, 55, 57, 59, 61, 63, 65, 45, + /* 190 */ 47, 67, 72, 49, 51, 53, 41, 39, 43, 37, + /* 200 */ 34, 122, 74, 69, 120, 126, 128, 55, 57, 59, + /* 210 */ 61, 63, 65, 45, 47, 67, 72, 49, 51, 53, + /* 220 */ 41, 39, 43, 37, 34, 122, 74, 69, 45, 47, + /* 230 */ 67, 72, 49, 51, 53, 41, 39, 43, 37, 34, + /* 240 */ 122, 74, 69, 122, 74, 69, 154, 156, 148, 188, + /* 250 */ 120, 126, 128, 55, 57, 59, 61, 63, 65, 45, + /* 260 */ 47, 67, 72, 49, 51, 53, 41, 39, 43, 37, + /* 270 */ 34, 122, 74, 69, 170, 242, 158, 35, 95, 99, + /* 280 */ 171, 173, 8, 76, 112, 113, 114, 161, 49, 51, + /* 290 */ 53, 41, 39, 43, 37, 34, 122, 74, 69, 83, + /* 300 */ 170, 130, 295, 35, 84, 92, 171, 173, 296, 194, + /* 310 */ 210, 196, 198, 161, 202, 206, 107, 176, 177, 183, + /* 320 */ 184, 185, 135, 139, 145, 100, 151, 130, 432, 124, + /* 330 */ 17, 180, 178, 179, 181, 182, 297, 228, 236, 224, + /* 340 */ 225, 6, 6, 176, 177, 183, 184, 185, 135, 139, + /* 350 */ 145, 115, 151, 164, 164, 298, 94, 180, 178, 179, + /* 360 */ 181, 182, 215, 107, 24, 35, 70, 230, 171, 173, + /* 370 */ 98, 175, 175, 95, 104, 216, 92, 232, 76, 299, + /* 380 */ 123, 226, 234, 92, 160, 160, 119, 186, 186, 130, + /* 390 */ 193, 35, 191, 251, 171, 173, 91, 76, 278, 94, + /* 400 */ 292, 161, 240, 105, 175, 176, 177, 183, 184, 185, + /* 410 */ 135, 139, 145, 103, 151, 130, 82, 160, 9, 180, + /* 420 */ 178, 179, 181, 182, 194, 210, 196, 198, 26, 202, + /* 430 */ 206, 176, 177, 183, 184, 185, 135, 139, 145, 10, + /* 440 */ 151, 164, 31, 153, 190, 180, 178, 179, 181, 182, + /* 450 */ 170, 218, 96, 35, 85, 109, 171, 173, 137, 175, + /* 460 */ 175, 168, 6, 161, 110, 28, 239, 15, 162, 167, + /* 470 */ 168, 102, 160, 160, 165, 186, 11, 130, 217, 35, + /* 480 */ 13, 431, 171, 173, 12, 201, 121, 247, 199, 161, + /* 490 */ 227, 162, 14, 176, 177, 183, 184, 185, 135, 139, + /* 500 */ 145, 27, 151, 130, 175, 175, 16, 180, 178, 179, + /* 510 */ 181, 182, 244, 248, 281, 288, 284, 160, 160, 176, + /* 520 */ 177, 183, 184, 185, 135, 139, 145, 18, 151, 205, + /* 530 */ 254, 262, 203, 180, 178, 179, 181, 182, 67, 72, + /* 540 */ 49, 51, 53, 41, 39, 43, 37, 34, 122, 74, + /* 550 */ 69, 209, 78, 25, 207, 223, 219, 253, 258, 458, + /* 560 */ 1, 2, 3, 4, 5, 6, 133, 29, 168, 107, + /* 570 */ 6, 77, 260, 263, 175, 31, 272, 69, 257, 283, + /* 580 */ 284, 256, 131, 260, 261, 75, 127, 160, 235, 108, + /* 590 */ 175, 273, 267, 175, 86, 261, 109, 289, 94, 30, + /* 600 */ 175, 175, 164, 160, 175, 279, 160, 80, 214, 219, + /* 610 */ 84, 212, 247, 160, 160, 87, 84, 160, 88, 260, + /* 620 */ 175, 238, 107, 287, 93, 97, 36, 175, 107, 101, + /* 630 */ 175, 259, 106, 160, 110, 38, 169, 175, 246, 175, + /* 640 */ 160, 175, 286, 160, 175, 40, 42, 44, 269, 46, + /* 650 */ 160, 386, 160, 175, 160, 48, 50, 160, 116, 125, + /* 660 */ 118, 52, 117, 175, 175, 175, 160, 175, 264, 258, + /* 670 */ 54, 134, 56, 175, 175, 58, 160, 160, 160, 175, + /* 680 */ 160, 60, 62, 136, 64, 76, 160, 160, 175, 268, + /* 690 */ 175, 66, 160, 175, 138, 140, 143, 149, 144, 175, + /* 700 */ 175, 160, 175, 160, 146, 187, 160, 68, 71, 175, + /* 710 */ 276, 73, 160, 160, 129, 160, 141, 147, 150, 152, + /* 720 */ 155, 163, 160, 157, 166, 175, 175, 192, 159, 175, + /* 730 */ 195, 172, 175, 174, 175, 175, 323, 175, 160, 160, + /* 740 */ 189, 175, 160, 231, 197, 160, 175, 160, 160, 175, + /* 750 */ 160, 175, 241, 324, 160, 250, 200, 325, 175, 160, + /* 760 */ 326, 175, 160, 204, 160, 327, 328, 294, 208, 329, + /* 770 */ 175, 160, 84, 175, 160, 330, 331, 221, 229, 245, + /* 780 */ 243, 233, 255, 160, 107, 237, 160, 334, 271, 335, + /* 790 */ 252, 270, 265, 342, 266, 274, 275, 277, 385, 280, + /* 800 */ 282, 285, 290, 291, 348, 293, +}; +static PPCODETYPE pp_lookahead[] = { + /* 0 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + /* 10 */ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + /* 20 */ 21, 22, 23, 24, 1, 2, 3, 4, 5, 6, + /* 30 */ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + /* 40 */ 17, 18, 19, 20, 21, 22, 23, 24, 61, 62, + /* 50 */ 63, 64, 65, 54, 55, 1, 2, 3, 4, 5, + /* 60 */ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + /* 70 */ 16, 17, 18, 19, 20, 21, 22, 23, 24, 20, + /* 80 */ 21, 22, 23, 24, 31, 31, 97, 33, 120, 121, + /* 90 */ 101, 102, 103, 104, 26, 72, 28, 74, 45, 1, + /* 100 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, + /* 110 */ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + /* 120 */ 22, 23, 24, 4, 5, 6, 7, 8, 9, 10, + /* 130 */ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + /* 140 */ 21, 22, 23, 24, 46, 51, 1, 2, 3, 4, + /* 150 */ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + /* 160 */ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + /* 170 */ 17, 18, 19, 20, 21, 22, 23, 24, 33, 88, + /* 180 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + /* 190 */ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + /* 200 */ 21, 22, 23, 24, 1, 2, 3, 4, 5, 6, + /* 210 */ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + /* 220 */ 17, 18, 19, 20, 21, 22, 23, 24, 10, 11, + /* 230 */ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, + /* 240 */ 22, 23, 24, 22, 23, 24, 71, 72, 69, 74, + /* 250 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + /* 260 */ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + /* 270 */ 21, 22, 23, 24, 18, 56, 73, 21, 120, 121, + /* 280 */ 24, 25, 89, 27, 102, 103, 104, 31, 14, 15, + /* 290 */ 16, 17, 18, 19, 20, 21, 22, 23, 24, 100, + /* 300 */ 18, 45, 0, 21, 105, 26, 24, 25, 0, 34, + /* 310 */ 35, 36, 37, 31, 39, 40, 117, 61, 62, 63, + /* 320 */ 64, 65, 66, 67, 68, 46, 70, 45, 46, 24, + /* 330 */ 26, 75, 76, 77, 78, 79, 0, 83, 83, 29, + /* 340 */ 30, 87, 87, 61, 62, 63, 64, 65, 66, 67, + /* 350 */ 68, 105, 70, 99, 99, 0, 31, 75, 76, 77, + /* 360 */ 78, 79, 18, 117, 60, 21, 12, 13, 24, 25, + /* 370 */ 45, 117, 117, 120, 121, 31, 26, 23, 27, 0, + /* 380 */ 75, 127, 127, 26, 130, 130, 99, 133, 133, 45, + /* 390 */ 31, 21, 33, 42, 24, 25, 46, 27, 47, 31, + /* 400 */ 49, 31, 57, 46, 117, 61, 62, 63, 64, 65, + /* 410 */ 66, 67, 68, 45, 70, 45, 26, 130, 90, 75, + /* 420 */ 76, 77, 78, 79, 34, 35, 36, 37, 52, 39, + /* 430 */ 40, 61, 62, 63, 64, 65, 66, 67, 68, 91, + /* 440 */ 70, 99, 99, 128, 129, 75, 76, 77, 78, 79, + /* 450 */ 18, 18, 31, 21, 33, 32, 24, 25, 83, 117, + /* 460 */ 117, 26, 87, 31, 31, 122, 123, 59, 45, 127, + /* 470 */ 26, 50, 130, 130, 132, 133, 92, 45, 32, 21, + /* 480 */ 58, 46, 24, 25, 93, 35, 99, 99, 38, 31, + /* 490 */ 46, 45, 47, 61, 62, 63, 64, 65, 66, 67, + /* 500 */ 68, 53, 70, 45, 117, 117, 126, 75, 76, 77, + /* 510 */ 78, 79, 124, 125, 115, 116, 117, 130, 130, 61, + /* 520 */ 62, 63, 64, 65, 66, 67, 68, 126, 70, 35, + /* 530 */ 44, 45, 38, 75, 76, 77, 78, 79, 12, 13, + /* 540 */ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, + /* 550 */ 24, 35, 95, 126, 38, 98, 99, 105, 26, 81, + /* 560 */ 82, 83, 84, 85, 86, 87, 83, 26, 26, 117, + /* 570 */ 87, 94, 99, 109, 117, 99, 112, 24, 46, 116, + /* 580 */ 117, 108, 99, 99, 111, 45, 99, 130, 46, 31, + /* 590 */ 117, 113, 108, 117, 31, 111, 32, 119, 31, 123, + /* 600 */ 117, 117, 99, 130, 117, 100, 130, 96, 98, 99, + /* 610 */ 105, 100, 99, 130, 130, 50, 105, 130, 120, 99, + /* 620 */ 117, 99, 117, 99, 120, 50, 99, 117, 117, 120, + /* 630 */ 117, 111, 120, 130, 31, 99, 133, 117, 125, 117, + /* 640 */ 130, 117, 118, 130, 117, 99, 99, 99, 26, 99, + /* 650 */ 130, 0, 130, 117, 130, 99, 99, 130, 106, 75, + /* 660 */ 41, 99, 107, 117, 117, 117, 130, 117, 46, 26, + /* 670 */ 99, 46, 99, 117, 117, 99, 130, 130, 130, 117, + /* 680 */ 130, 99, 99, 45, 99, 27, 130, 130, 117, 46, + /* 690 */ 117, 99, 130, 117, 46, 45, 31, 31, 46, 117, + /* 700 */ 117, 130, 117, 130, 45, 29, 130, 99, 99, 117, + /* 710 */ 59, 99, 130, 130, 99, 130, 99, 99, 46, 99, + /* 720 */ 129, 131, 130, 99, 46, 117, 117, 31, 99, 117, + /* 730 */ 35, 99, 117, 99, 117, 117, 31, 117, 130, 130, + /* 740 */ 99, 117, 130, 99, 35, 130, 117, 130, 130, 117, + /* 750 */ 130, 117, 99, 31, 130, 99, 35, 31, 117, 130, + /* 760 */ 31, 117, 130, 35, 130, 31, 31, 100, 35, 31, + /* 770 */ 117, 130, 105, 117, 130, 31, 31, 31, 46, 26, + /* 780 */ 53, 45, 45, 130, 117, 46, 130, 0, 31, 0, + /* 790 */ 43, 112, 44, 0, 45, 88, 114, 126, 0, 48, + /* 800 */ 26, 4, 88, 114, 0, 28, +}; +#define PP_SHIFT_USE_DFLT (-14) +static short pp_shift_ofst[] = { + /* 0 */ 351, 302, 308, 336, 355, 379, 94, 219, 345, 376, + /* 10 */ 408, 422, -14, 445, -14, -13, 304, -13, -14, -14, + /* 20 */ -14, -14, -14, -14, -13, -14, 448, 458, 541, 458, + /* 30 */ -14, -1, -14, -14, 458, 458, 221, 458, 221, 458, + /* 40 */ 59, 458, 59, 458, 59, 458, 526, 458, 526, 458, + /* 50 */ 153, 458, 153, 458, 153, 458, 218, 458, 218, 458, + /* 60 */ 218, 458, 218, 458, 218, 458, 218, 458, 274, 354, + /* 70 */ 458, 553, 458, 274, 540, 256, 310, 344, 68, 558, + /* 80 */ 390, -14, 558, -14, 421, 563, 565, 53, -14, 567, + /* 90 */ 350, -14, 567, -14, -14, -14, 575, 325, 567, 279, + /* 100 */ -14, -14, 368, 567, 357, -14, -14, -14, 564, 603, + /* 110 */ -14, 275, -14, -14, 558, 359, 619, -14, 458, 249, + /* 120 */ 458, 249, 305, -14, 584, -14, 458, 119, 458, 119, + /* 130 */ 370, 98, -14, 625, -14, 638, 658, 648, -14, 650, + /* 140 */ 458, 145, 665, 652, -14, 659, 458, 179, 666, 672, + /* 150 */ -14, 458, 23, 175, -14, -14, 458, 203, 458, 249, + /* 160 */ -14, 423, 676, 282, 249, 678, -14, 435, 432, -14, + /* 170 */ -14, 458, 553, 458, 553, -14, -14, -14, -14, -14, + /* 180 */ -14, -14, -14, -14, -14, -14, -14, -14, 458, 249, + /* 190 */ -14, 696, -14, -14, 695, 705, 709, 722, 450, 721, + /* 200 */ 726, 729, 494, 728, 734, 735, 516, 733, 738, 744, + /* 210 */ 745, -14, -14, 344, -14, -14, 446, 433, -14, 54, + /* 220 */ 746, -14, -14, -14, -14, -14, 444, -14, 732, -14, + /* 230 */ 458, 553, 736, 256, 542, -14, 739, -14, 221, -14, + /* 240 */ 458, 249, 727, 458, 753, 458, -14, 249, -14, 458, + /* 250 */ 249, 747, 558, 486, 737, 458, 532, 787, 458, -14, + /* 260 */ 249, -14, 757, 622, 748, 749, 458, 643, 789, 757, + /* 270 */ -14, -14, -14, 94, 651, 793, -13, 798, 558, 751, + /* 280 */ 558, 774, 558, -14, 797, 458, -14, 249, -14, 94, + /* 290 */ 651, 804, 777, 558, -14, +}; +#define PP_REDUCE_USE_DFLT (-33) +static short pp_reduce_ofst[] = { + /* 0 */ 478, -33, -33, -33, -33, -33, 91, 193, 328, 348, + /* 10 */ 384, 391, -33, -33, -33, 380, -33, 401, -33, -33, + /* 20 */ -33, -33, -33, -33, 427, -33, -33, 343, -33, 476, + /* 30 */ -33, -33, -33, -33, 522, 527, -33, 536, -33, 546, + /* 40 */ -33, 547, -33, 548, -33, 550, -33, 556, -33, 557, + /* 50 */ -33, 562, -33, 571, -33, 573, -33, 576, -33, 582, + /* 60 */ -33, 583, -33, 585, -33, 592, -33, 608, -33, -33, + /* 70 */ 609, -33, 612, -33, -33, 254, 477, 457, -33, 511, + /* 80 */ -11, -33, 199, -33, -33, -33, -33, 498, -33, -32, + /* 90 */ -33, -33, 504, -33, -33, -33, -33, 509, 158, -33, + /* 100 */ -33, -33, 512, 253, -33, -33, -33, -33, -33, -33, + /* 110 */ -33, 182, -33, -33, 246, 552, 555, -33, 287, -33, + /* 120 */ 387, -33, -33, -33, -33, -33, 487, -33, 615, -33, + /* 130 */ 483, -33, -33, -33, -33, -33, 375, -33, -33, -33, + /* 140 */ 617, -33, -33, -33, -33, -33, 618, -33, -33, -33, + /* 150 */ -33, 620, 315, 591, -33, -33, 624, -33, 629, -33, + /* 160 */ -33, -33, 590, 342, -33, -33, -33, -33, 503, -33, + /* 170 */ -33, 632, -33, 634, -33, -33, -33, -33, -33, -33, + /* 180 */ -33, -33, -33, -33, -33, -33, -33, -33, 641, -33, + /* 190 */ -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + /* 200 */ -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + /* 210 */ -33, -33, -33, 510, -33, -33, -33, -33, -33, -33, + /* 220 */ -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, + /* 230 */ 644, -33, -33, 255, -33, -33, -33, -33, -33, -33, + /* 240 */ 653, -33, -33, 388, -33, 513, -33, -33, -33, 656, + /* 250 */ -33, -33, 452, -33, -33, 473, -33, -33, 520, -33, + /* 260 */ -33, -33, 464, -33, -33, -33, 484, -33, -33, 679, + /* 270 */ -33, -33, -33, 707, 682, -33, 671, -33, 505, -33, + /* 280 */ 399, -33, 463, -33, -33, 524, -33, -33, -33, 714, + /* 290 */ 689, -33, -33, 667, -33, +}; +static PPACTIONTYPE pp_default[] = { + /* 0 */ 457, 457, 457, 457, 457, 457, 364, 373, 378, 366, + /* 10 */ 384, 380, 300, 457, 379, 457, 381, 457, 382, 387, + /* 20 */ 388, 389, 390, 391, 457, 383, 457, 457, 365, 457, + /* 30 */ 367, 369, 370, 371, 457, 457, 392, 457, 394, 457, + /* 40 */ 395, 457, 396, 457, 397, 457, 398, 457, 399, 457, + /* 50 */ 400, 457, 401, 457, 402, 457, 403, 457, 404, 457, + /* 60 */ 405, 457, 406, 457, 407, 457, 408, 457, 409, 457, + /* 70 */ 457, 410, 457, 411, 457, 457, 304, 457, 457, 457, + /* 80 */ 315, 301, 457, 312, 352, 457, 350, 457, 353, 457, + /* 90 */ 457, 354, 457, 359, 361, 360, 351, 457, 457, 457, + /* 100 */ 355, 356, 457, 457, 457, 357, 358, 362, 456, 457, + /* 110 */ 455, 314, 316, 318, 457, 322, 333, 319, 457, 332, + /* 120 */ 457, 419, 457, 437, 457, 438, 457, 439, 457, 440, + /* 130 */ 457, 457, 443, 457, 415, 457, 457, 457, 418, 457, + /* 140 */ 457, 457, 457, 457, 420, 457, 457, 457, 457, 457, + /* 150 */ 421, 457, 457, 457, 422, 423, 457, 457, 457, 425, + /* 160 */ 427, 456, 430, 457, 436, 457, 428, 457, 457, 433, + /* 170 */ 435, 457, 441, 457, 442, 444, 445, 446, 447, 448, + /* 180 */ 449, 450, 451, 452, 453, 454, 434, 429, 457, 426, + /* 190 */ 424, 457, 320, 321, 457, 457, 457, 457, 457, 457, + /* 200 */ 457, 457, 457, 457, 457, 457, 457, 457, 457, 457, + /* 210 */ 457, 317, 313, 457, 305, 307, 456, 457, 308, 311, + /* 220 */ 457, 309, 310, 306, 302, 303, 457, 413, 457, 416, + /* 230 */ 457, 412, 457, 457, 457, 414, 457, 417, 393, 368, + /* 240 */ 457, 377, 457, 457, 372, 457, 374, 376, 375, 457, + /* 250 */ 363, 457, 457, 457, 457, 457, 457, 457, 457, 336, + /* 260 */ 338, 337, 457, 457, 457, 457, 457, 457, 457, 457, + /* 270 */ 339, 341, 340, 364, 457, 457, 457, 457, 457, 457, + /* 280 */ 457, 343, 457, 344, 457, 457, 346, 347, 345, 364, + /* 290 */ 457, 457, 457, 457, 349, +}; +#define PP_SZ_ACTTAB (sizeof(pp_action)/sizeof(pp_action[0])) - RETURN_MEMBER(getThis(), "bindTypes"); -} +/* The next table maps tokens into fallback tokens. If a construct +** like the following: +** +** %fallback ID X Y Z. +** +** appears in the grammer, then ID becomes a fallback token for X, Y, +** and Z. Whenever one of the tokens X, Y, or Z is input to the parser +** but it does not parse, the type of the token is changed to ID and +** the parse is retried before an error is thrown. +*/ +#ifdef PPFALLBACK +static const PPCODETYPE ppFallback[] = { +}; +#endif /* PPFALLBACK */ -static PHP_METHOD(Phalcon_Mvc_Model_Query, getDI) -{ +/* The following structure represents a single element of the +** parser's stack. Information stored includes: +** +** + The state number for the parser at this level of the stack. +** +** + The value of the token stored at this level of the stack. +** (In other words, the "major" token.) +** +** + The semantic value stored at this level of the stack. This is +** the information used by the action routines in the grammar. +** It is sometimes called the "minor" token. +*/ +struct ppStackEntry { + int stateno; /* The state-number */ + int major; /* The major token value. This is the code + ** number for the token at this stack level */ + PPMINORTYPE minor; /* The user-supplied minor token value. This + ** is the value of the token */ +}; +typedef struct ppStackEntry ppStackEntry; - RETURN_MEMBER(getThis(), "container"); -} +/* The state of the parser is completely contained in an instance of +** the following structure */ +struct ppParser { + int ppidx; /* Index of top element in stack */ + int pperrcnt; /* Shifts left before out of the error */ + phql_ARG_SDECL /* A place to hold %extra_argument */ + ppStackEntry ppstack[PPSTACKDEPTH]; /* The parser's stack */ +}; +typedef struct ppParser ppParser; -static PHP_METHOD(Phalcon_Mvc_Model_Query, getIntermediate) -{ +#ifndef NDEBUG +static FILE *ppTraceFILE = 0; +static char *ppTracePrompt = 0; +#endif /* NDEBUG */ - RETURN_MEMBER(getThis(), "intermediate"); +#ifndef NDEBUG +static void phql_Trace(FILE *TraceFILE, char *zTracePrompt){ + ppTraceFILE = TraceFILE; + ppTracePrompt = zTracePrompt; + if( ppTraceFILE==0 ) ppTracePrompt = 0; + else if( ppTracePrompt==0 ) ppTraceFILE = 0; } +#endif /* NDEBUG */ -static PHP_METHOD(Phalcon_Mvc_Model_Query, getSingleResult) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *bindParams_param = NULL, *bindTypes_param = NULL, _0, _1; - zval bindParams, bindTypes; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &bindParams_param, &bindTypes_param); - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - } else { - zephir_get_arrval(&bindParams, bindParams_param); - } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - } else { - zephir_get_arrval(&bindTypes, bindTypes_param); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("uniqueRow"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_0)) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "execute", NULL, 0, &bindParams, &bindTypes); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(&_1, this_ptr, "execute", NULL, 0, &bindParams, &bindTypes); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&_1, "getfirst", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getSql) -{ - zval intermediate, _0, _1$$3, _2$$3, _3$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&intermediate, this_ptr, "parse", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("type"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_LONG(&_0, 309)) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); - ZVAL_BOOL(&_3$$3, 1); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "executeselect", NULL, 446, &intermediate, &_1$$3, &_2$$3, &_3$$3); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "This type of statement generates multiple SQL statements", "phalcon/Mvc/Model/Query.zep", 514); - return; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getType) -{ - - RETURN_MEMBER(getThis(), "type"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getUniqueRow) -{ - - RETURN_MEMBER(getThis(), "uniqueRow"); -} +#ifndef NDEBUG +/* For tracing shifts, the names of all terminals and nonterminals +** are required. The following table supplies these names */ +static const char *ppTokenName[] = { + "$", "AGAINST", "BETWEEN", "BETWEEN_NOT", + "EQUALS", "NOTEQUALS", "LESS", "GREATER", + "GREATEREQUAL", "LESSEQUAL", "AND", "OR", + "LIKE", "ILIKE", "BITWISE_AND", "BITWISE_OR", + "BITWISE_XOR", "DIVIDE", "TIMES", "MOD", + "PLUS", "MINUS", "IS", "IN", + "NOT", "BITWISE_NOT", "COMMA", "SELECT", + "FROM", "DISTINCT", "ALL", "IDENTIFIER", + "DOT", "AS", "INNER", "JOIN", + "CROSS", "LEFT", "OUTER", "RIGHT", + "FULL", "ON", "INSERT", "INTO", + "VALUES", "PARENTHESES_OPEN", "PARENTHESES_CLOSE", "UPDATE", + "SET", "DELETE", "WITH", "WHERE", + "ORDER", "BY", "ASC", "DESC", + "GROUP", "HAVING", "FOR", "LIMIT", + "OFFSET", "INTEGER", "HINTEGER", "NPLACEHOLDER", + "SPLACEHOLDER", "BPLACEHOLDER", "EXISTS", "CAST", + "CONVERT", "USING", "CASE", "END", + "WHEN", "THEN", "ELSE", "NULL", + "STRING", "DOUBLE", "TRUE", "FALSE", + "error", "program", "query_language", "select_statement", + "insert_statement", "update_statement", "delete_statement", "select_clause", + "where_clause", "group_clause", "having_clause", "order_clause", + "select_limit_clause", "for_update_clause", "distinct_all", "column_list", + "associated_name_list", "join_list_or_null", "column_item", "expr", + "associated_name", "join_list", "join_item", "join_clause", + "join_type", "aliased_or_qualified_name", "join_associated_name", "join_conditions", + "values_list", "field_list", "value_list", "value_item", + "field_item", "update_clause", "limit_clause", "update_item_list", + "update_item", "qualified_name", "new_value", "delete_clause", + "with_item", "with_list", "order_list", "order_item", + "group_list", "group_item", "integer_or_placeholder", "argument_list", + "when_clauses", "when_clause", "function_call", "distinct_or_null", + "argument_list_or_null", "argument_item", +}; +#endif /* NDEBUG */ -static PHP_METHOD(Phalcon_Mvc_Model_Query, getTransaction) -{ +#ifndef NDEBUG +/* For tracing reduce actions, the names of all rules are required. +*/ +static const char *ppRuleName[] = { + /* 0 */ "program ::= query_language", + /* 1 */ "query_language ::= select_statement", + /* 2 */ "query_language ::= insert_statement", + /* 3 */ "query_language ::= update_statement", + /* 4 */ "query_language ::= delete_statement", + /* 5 */ "select_statement ::= select_clause where_clause group_clause having_clause order_clause select_limit_clause for_update_clause", + /* 6 */ "select_clause ::= SELECT distinct_all column_list FROM associated_name_list join_list_or_null", + /* 7 */ "distinct_all ::= DISTINCT", + /* 8 */ "distinct_all ::= ALL", + /* 9 */ "distinct_all ::=", + /* 10 */ "column_list ::= column_list COMMA column_item", + /* 11 */ "column_list ::= column_item", + /* 12 */ "column_item ::= TIMES", + /* 13 */ "column_item ::= IDENTIFIER DOT TIMES", + /* 14 */ "column_item ::= expr AS IDENTIFIER", + /* 15 */ "column_item ::= expr IDENTIFIER", + /* 16 */ "column_item ::= expr", + /* 17 */ "associated_name_list ::= associated_name_list COMMA associated_name", + /* 18 */ "associated_name_list ::= associated_name", + /* 19 */ "join_list_or_null ::= join_list", + /* 20 */ "join_list_or_null ::=", + /* 21 */ "join_list ::= join_list join_item", + /* 22 */ "join_list ::= join_item", + /* 23 */ "join_item ::= join_clause", + /* 24 */ "join_clause ::= join_type aliased_or_qualified_name join_associated_name join_conditions", + /* 25 */ "join_associated_name ::= AS IDENTIFIER", + /* 26 */ "join_associated_name ::= IDENTIFIER", + /* 27 */ "join_associated_name ::=", + /* 28 */ "join_type ::= INNER JOIN", + /* 29 */ "join_type ::= CROSS JOIN", + /* 30 */ "join_type ::= LEFT OUTER JOIN", + /* 31 */ "join_type ::= LEFT JOIN", + /* 32 */ "join_type ::= RIGHT OUTER JOIN", + /* 33 */ "join_type ::= RIGHT JOIN", + /* 34 */ "join_type ::= FULL OUTER JOIN", + /* 35 */ "join_type ::= FULL JOIN", + /* 36 */ "join_type ::= JOIN", + /* 37 */ "join_conditions ::= ON expr", + /* 38 */ "join_conditions ::=", + /* 39 */ "insert_statement ::= INSERT INTO aliased_or_qualified_name VALUES PARENTHESES_OPEN values_list PARENTHESES_CLOSE", + /* 40 */ "insert_statement ::= INSERT INTO aliased_or_qualified_name PARENTHESES_OPEN field_list PARENTHESES_CLOSE VALUES PARENTHESES_OPEN values_list PARENTHESES_CLOSE", + /* 41 */ "values_list ::= values_list COMMA value_item", + /* 42 */ "values_list ::= value_item", + /* 43 */ "value_item ::= expr", + /* 44 */ "field_list ::= field_list COMMA field_item", + /* 45 */ "field_list ::= field_item", + /* 46 */ "field_item ::= IDENTIFIER", + /* 47 */ "update_statement ::= update_clause where_clause limit_clause", + /* 48 */ "update_clause ::= UPDATE associated_name SET update_item_list", + /* 49 */ "update_item_list ::= update_item_list COMMA update_item", + /* 50 */ "update_item_list ::= update_item", + /* 51 */ "update_item ::= qualified_name EQUALS new_value", + /* 52 */ "new_value ::= expr", + /* 53 */ "delete_statement ::= delete_clause where_clause limit_clause", + /* 54 */ "delete_clause ::= DELETE FROM associated_name", + /* 55 */ "associated_name ::= aliased_or_qualified_name AS IDENTIFIER", + /* 56 */ "associated_name ::= aliased_or_qualified_name IDENTIFIER", + /* 57 */ "associated_name ::= aliased_or_qualified_name", + /* 58 */ "associated_name ::= aliased_or_qualified_name AS IDENTIFIER WITH with_item", + /* 59 */ "associated_name ::= aliased_or_qualified_name AS IDENTIFIER WITH PARENTHESES_OPEN with_list PARENTHESES_CLOSE", + /* 60 */ "associated_name ::= aliased_or_qualified_name IDENTIFIER WITH PARENTHESES_OPEN with_list PARENTHESES_CLOSE", + /* 61 */ "associated_name ::= aliased_or_qualified_name IDENTIFIER WITH with_item", + /* 62 */ "associated_name ::= aliased_or_qualified_name WITH PARENTHESES_OPEN with_list PARENTHESES_CLOSE", + /* 63 */ "associated_name ::= aliased_or_qualified_name WITH with_item", + /* 64 */ "with_list ::= with_list COMMA with_item", + /* 65 */ "with_list ::= with_item", + /* 66 */ "with_item ::= IDENTIFIER", + /* 67 */ "aliased_or_qualified_name ::= qualified_name", + /* 68 */ "where_clause ::= WHERE expr", + /* 69 */ "where_clause ::=", + /* 70 */ "order_clause ::= ORDER BY order_list", + /* 71 */ "order_clause ::=", + /* 72 */ "order_list ::= order_list COMMA order_item", + /* 73 */ "order_list ::= order_item", + /* 74 */ "order_item ::= expr", + /* 75 */ "order_item ::= expr ASC", + /* 76 */ "order_item ::= expr DESC", + /* 77 */ "group_clause ::= GROUP BY group_list", + /* 78 */ "group_clause ::=", + /* 79 */ "group_list ::= group_list COMMA group_item", + /* 80 */ "group_list ::= group_item", + /* 81 */ "group_item ::= expr", + /* 82 */ "having_clause ::= HAVING expr", + /* 83 */ "having_clause ::=", + /* 84 */ "for_update_clause ::= FOR UPDATE", + /* 85 */ "for_update_clause ::=", + /* 86 */ "select_limit_clause ::= LIMIT integer_or_placeholder", + /* 87 */ "select_limit_clause ::= LIMIT integer_or_placeholder COMMA integer_or_placeholder", + /* 88 */ "select_limit_clause ::= LIMIT integer_or_placeholder OFFSET integer_or_placeholder", + /* 89 */ "select_limit_clause ::=", + /* 90 */ "limit_clause ::= LIMIT integer_or_placeholder", + /* 91 */ "limit_clause ::=", + /* 92 */ "integer_or_placeholder ::= INTEGER", + /* 93 */ "integer_or_placeholder ::= HINTEGER", + /* 94 */ "integer_or_placeholder ::= NPLACEHOLDER", + /* 95 */ "integer_or_placeholder ::= SPLACEHOLDER", + /* 96 */ "integer_or_placeholder ::= BPLACEHOLDER", + /* 97 */ "expr ::= MINUS expr", + /* 98 */ "expr ::= expr MINUS expr", + /* 99 */ "expr ::= expr PLUS expr", + /* 100 */ "expr ::= expr TIMES expr", + /* 101 */ "expr ::= expr DIVIDE expr", + /* 102 */ "expr ::= expr MOD expr", + /* 103 */ "expr ::= expr AND expr", + /* 104 */ "expr ::= expr OR expr", + /* 105 */ "expr ::= expr BITWISE_AND expr", + /* 106 */ "expr ::= expr BITWISE_OR expr", + /* 107 */ "expr ::= expr BITWISE_XOR expr", + /* 108 */ "expr ::= expr EQUALS expr", + /* 109 */ "expr ::= expr NOTEQUALS expr", + /* 110 */ "expr ::= expr LESS expr", + /* 111 */ "expr ::= expr GREATER expr", + /* 112 */ "expr ::= expr GREATEREQUAL expr", + /* 113 */ "expr ::= expr LESSEQUAL expr", + /* 114 */ "expr ::= expr LIKE expr", + /* 115 */ "expr ::= expr NOT LIKE expr", + /* 116 */ "expr ::= expr ILIKE expr", + /* 117 */ "expr ::= expr NOT ILIKE expr", + /* 118 */ "expr ::= expr IN PARENTHESES_OPEN argument_list PARENTHESES_CLOSE", + /* 119 */ "expr ::= expr NOT IN PARENTHESES_OPEN argument_list PARENTHESES_CLOSE", + /* 120 */ "expr ::= PARENTHESES_OPEN select_statement PARENTHESES_CLOSE", + /* 121 */ "expr ::= expr IN PARENTHESES_OPEN select_statement PARENTHESES_CLOSE", + /* 122 */ "expr ::= expr NOT IN PARENTHESES_OPEN select_statement PARENTHESES_CLOSE", + /* 123 */ "expr ::= EXISTS PARENTHESES_OPEN select_statement PARENTHESES_CLOSE", + /* 124 */ "expr ::= expr AGAINST expr", + /* 125 */ "expr ::= CAST PARENTHESES_OPEN expr AS IDENTIFIER PARENTHESES_CLOSE", + /* 126 */ "expr ::= CONVERT PARENTHESES_OPEN expr USING IDENTIFIER PARENTHESES_CLOSE", + /* 127 */ "expr ::= CASE expr when_clauses END", + /* 128 */ "when_clauses ::= when_clauses when_clause", + /* 129 */ "when_clauses ::= when_clause", + /* 130 */ "when_clause ::= WHEN expr THEN expr", + /* 131 */ "when_clause ::= ELSE expr", + /* 132 */ "expr ::= function_call", + /* 133 */ "function_call ::= IDENTIFIER PARENTHESES_OPEN distinct_or_null argument_list_or_null PARENTHESES_CLOSE", + /* 134 */ "distinct_or_null ::= DISTINCT", + /* 135 */ "distinct_or_null ::=", + /* 136 */ "argument_list_or_null ::= argument_list", + /* 137 */ "argument_list_or_null ::=", + /* 138 */ "argument_list ::= argument_list COMMA argument_item", + /* 139 */ "argument_list ::= argument_item", + /* 140 */ "argument_item ::= TIMES", + /* 141 */ "argument_item ::= expr", + /* 142 */ "expr ::= expr IS NULL", + /* 143 */ "expr ::= expr IS NOT NULL", + /* 144 */ "expr ::= expr BETWEEN expr", + /* 145 */ "expr ::= expr BETWEEN_NOT expr", + /* 146 */ "expr ::= NOT expr", + /* 147 */ "expr ::= BITWISE_NOT expr", + /* 148 */ "expr ::= PARENTHESES_OPEN expr PARENTHESES_CLOSE", + /* 149 */ "expr ::= qualified_name", + /* 150 */ "expr ::= INTEGER", + /* 151 */ "expr ::= HINTEGER", + /* 152 */ "expr ::= STRING", + /* 153 */ "expr ::= DOUBLE", + /* 154 */ "expr ::= NULL", + /* 155 */ "expr ::= TRUE", + /* 156 */ "expr ::= FALSE", + /* 157 */ "expr ::= NPLACEHOLDER", + /* 158 */ "expr ::= SPLACEHOLDER", + /* 159 */ "expr ::= BPLACEHOLDER", + /* 160 */ "qualified_name ::= IDENTIFIER DOT IDENTIFIER", + /* 161 */ "qualified_name ::= IDENTIFIER", +}; +#endif /* NDEBUG */ - RETURN_MEMBER(getThis(), "transaction"); +const char *phql_TokenName(int tokenType){ +#ifndef NDEBUG + if( tokenType>0 && tokenType<(sizeof(ppTokenName)/sizeof(ppTokenName[0])) ){ + return ppTokenName[tokenType]; + }else{ + return "Unknown"; + } +#else + return ""; +#endif } -static PHP_METHOD(Phalcon_Mvc_Model_Query, parse) -{ - zval intermediate, phql, ast, irPhql, uniqueId, type, _0, _1$$5, _2$$7, _3$$13, _4$$13; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&phql); - ZVAL_UNDEF(&ast); - ZVAL_UNDEF(&irPhql); - ZVAL_UNDEF(&uniqueId); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$5); - ZVAL_UNDEF(&_2$$7); - ZVAL_UNDEF(&_3$$13); - ZVAL_UNDEF(&_4$$13); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("intermediate"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&intermediate, &_0); - if (Z_TYPE_P(&intermediate) == IS_ARRAY) { - RETURN_CCTOR(&intermediate); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&phql, &_0); - ZEPHIR_CALL_CE_STATIC(&ast, phalcon_mvc_model_query_lang_ce, "parsephql", NULL, 0, &phql); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&irPhql); - ZVAL_NULL(&irPhql); - ZEPHIR_INIT_VAR(&uniqueId); - ZVAL_NULL(&uniqueId); - if (Z_TYPE_P(&ast) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&uniqueId); - if (zephir_array_isset_string_fetch(&uniqueId, &ast, SL("id"), 0)) { - ZEPHIR_OBS_NVAR(&irPhql); - zephir_read_static_property_ce(&_1$$5, phalcon_mvc_model_query_ce, SL("internalPhqlCache"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&irPhql, &_1$$5, &uniqueId, 0)) { - if (Z_TYPE_P(&irPhql) == IS_ARRAY) { - zephir_array_fetch_string(&_2$$7, &ast, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 579); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_2$$7); - RETURN_CCTOR(&irPhql); - } - } - } - zephir_memory_observe(&type); - if (zephir_array_isset_string_fetch(&type, &ast, SL("type"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("ast"), &ast); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &type); - do { - if (ZEPHIR_IS_LONG(&type, 309)) { - ZEPHIR_CALL_METHOD(&irPhql, this_ptr, "_prepareselect", NULL, 450); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&type, 306)) { - ZEPHIR_CALL_METHOD(&irPhql, this_ptr, "_prepareinsert", NULL, 451); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&type, 300)) { - ZEPHIR_CALL_METHOD(&irPhql, this_ptr, "_prepareupdate", NULL, 452); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&type, 303)) { - ZEPHIR_CALL_METHOD(&irPhql, this_ptr, "_preparedelete", NULL, 453); - zephir_check_call_status(); - break; - } - ZEPHIR_INIT_VAR(&_3$$13); - object_init_ex(&_3$$13, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_4$$13); - ZEPHIR_CONCAT_SVSV(&_4$$13, "Unknown statement ", &type, ", when preparing: ", &phql); - ZEPHIR_CALL_METHOD(NULL, &_3$$13, "__construct", NULL, 33, &_4$$13); - zephir_check_call_status(); - zephir_throw_exception_debug(&_3$$13, "phalcon/Mvc/Model/Query.zep", 613); - ZEPHIR_MM_RESTORE(); - return; - } while(0); - - } - } - if (UNEXPECTED(Z_TYPE_P(&irPhql) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted AST", "phalcon/Mvc/Model/Query.zep", 619); - return; - } - if (Z_TYPE_P(&uniqueId) == IS_LONG) { - zephir_update_static_property_array_multi_ce(phalcon_mvc_model_query_ce, SL("internalPhqlCache"), &irPhql, SL("z"), 1, &uniqueId); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("intermediate"), &irPhql); - RETURN_CCTOR(&irPhql); +void *phql_Alloc(void *(*mallocProc)(size_t)){ + ppParser *pParser; + pParser = (ppParser*)(*mallocProc)( (size_t)sizeof(ppParser) ); + if( pParser ){ + pParser->ppidx = -1; + } + return pParser; } -static PHP_METHOD(Phalcon_Mvc_Model_Query, setBindParams) +/* The following function deletes the value associated with a +** symbol. The symbol can be either a terminal or nonterminal. +** "ppmajor" is the symbol code, and "pppminor" is a pointer to +** the value. +*/ +static void pp_destructor(PPCODETYPE ppmajor, PPMINORTYPE *pppminor){ + switch( ppmajor ){ + /* Here is inserted the actions which take place when a + ** terminal or non-terminal is destroyed. This can happen + ** when the symbol is popped from the stack during a + ** reduce or during error processing or when a parser is + ** being destroyed before it is finished parsing. + ** + ** Note: during a reduce, the only symbols destroyed are those + ** which appear on the RHS of the rule, but which are not used + ** inside the C code. + */ + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + case 18: + case 19: + case 20: + case 21: + case 22: + case 23: + case 24: + case 25: + case 26: + case 27: + case 28: + case 29: + case 30: + case 31: + case 32: + case 33: + case 34: + case 35: + case 36: + case 37: + case 38: + case 39: + case 40: + case 41: + case 42: + case 43: + case 44: + case 45: + case 46: + case 47: + case 48: + case 49: + case 50: + case 51: + case 52: + case 53: + case 54: + case 55: + case 56: + case 57: + case 58: + case 59: + case 60: + case 61: + case 62: + case 63: + case 64: + case 65: + case 66: + case 67: + case 68: + case 69: + case 70: + case 71: + case 72: + case 73: + case 74: + case 75: + case 76: + case 77: + case 78: + case 79: +// 101 "parser.php.lemon" { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool merge; - zval *bindParams_param = NULL, *merge_param = NULL, currentBindParams, _0$$3; - zval bindParams; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(¤tBindParams); - ZVAL_UNDEF(&_0$$3); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(merge) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &bindParams_param, &merge_param); - ZEPHIR_OBS_COPY_OR_DUP(&bindParams, bindParams_param); - if (!merge_param) { - merge = 0; - } else { + if ((pppminor->pp0)) { + if ((pppminor->pp0)->free_flag) { + efree((pppminor->pp0)->token); } - if (merge) { - zephir_memory_observe(¤tBindParams); - zephir_read_property(¤tBindParams, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&_0$$3); - zephir_add_function(&_0$$3, ¤tBindParams, &bindParams); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &_0$$3); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &bindParams); + efree((pppminor->pp0)); } - RETURN_THIS(); } - -static PHP_METHOD(Phalcon_Mvc_Model_Query, setBindTypes) +// 826 "parser.php.c" + break; + case 82: + case 83: + case 84: + case 85: + case 86: + case 87: + case 89: + case 95: + case 96: + case 98: + case 99: + case 100: + case 101: + case 102: + case 103: + case 104: + case 105: + case 109: + case 110: + case 112: + case 113: + case 115: + case 116: + case 117: + case 119: + case 120: + case 121: + case 122: + case 123: + case 124: + case 125: + case 127: + case 130: + case 133: +// 114 "parser.php.lemon" { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool merge; - zval *bindTypes_param = NULL, *merge_param = NULL, currentBindTypes, _0$$4; - zval bindTypes; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(¤tBindTypes); - ZVAL_UNDEF(&_0$$4); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(bindTypes) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(merge) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &bindTypes_param, &merge_param); - ZEPHIR_OBS_COPY_OR_DUP(&bindTypes, bindTypes_param); - if (!merge_param) { - merge = 0; - } else { - } - if (UNEXPECTED(merge)) { - zephir_memory_observe(¤tBindTypes); - zephir_read_property(¤tBindTypes, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC); - if (Z_TYPE_P(¤tBindTypes) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_0$$4); - zephir_add_function(&_0$$4, ¤tBindTypes, &bindTypes); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &_0$$4); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); - } - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); - } - RETURN_THIS(); + zval_ptr_dtor(&(pppminor->pp202)); } - -static PHP_METHOD(Phalcon_Mvc_Model_Query, setDI) +// 866 "parser.php.c" + break; + case 88: + case 90: + case 91: + case 92: + case 93: + case 94: + case 106: + case 107: + case 114: + case 131: + case 132: +// 496 "parser.php.lemon" { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *container, container_sub, manager, metaData, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container_sub); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &container); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "modelsManager"); - ZEPHIR_CALL_METHOD(&manager, container, "getshared", NULL, 0, &_0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&manager) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Injected service 'modelsManager' is invalid", "phalcon/Mvc/Model/Query.zep", 683); - return; - } - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, "modelsMetadata"); - ZEPHIR_CALL_METHOD(&metaData, container, "getshared", NULL, 0, &_0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&metaData) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Injected service 'modelsMetaData' is invalid", "phalcon/Mvc/Model/Query.zep", 689); - return; - } - zephir_update_property_zval(this_ptr, ZEND_STRL("manager"), &manager); - zephir_update_property_zval(this_ptr, ZEND_STRL("metaData"), &metaData); - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); - ZEPHIR_MM_RESTORE(); + zephir_safe_zval_ptr_dtor((pppminor->pp202)); } - -static PHP_METHOD(Phalcon_Mvc_Model_Query, setIntermediate) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *intermediate_param = NULL; - zval intermediate; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&intermediate); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(intermediate) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &intermediate_param); - ZEPHIR_OBS_COPY_OR_DUP(&intermediate, intermediate_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("intermediate"), &intermediate); - RETURN_THIS(); +// 883 "parser.php.c" + break; + default: break; /* If no destructor action specified: do nothing */ + } } -static PHP_METHOD(Phalcon_Mvc_Model_Query, setSharedLock) -{ - zval *sharedLock_param = NULL, __$true, __$false; - zend_bool sharedLock; - zval *this_ptr = getThis(); +static int pp_pop_parser_stack(ppParser *pParser){ + PPCODETYPE ppmajor; + ppStackEntry *pptos = &pParser->ppstack[pParser->ppidx]; - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(sharedLock) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(0, 1, &sharedLock_param); - if (!sharedLock_param) { - sharedLock = 0; - } else { - } - if (sharedLock) { - zephir_update_property_zval(this_ptr, ZEND_STRL("sharedLock"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("sharedLock"), &__$false); - } - RETURN_THISW(); + if( pParser->ppidx<0 ) return 0; +#ifndef NDEBUG + if( ppTraceFILE && pParser->ppidx>=0 ){ + fprintf(ppTraceFILE,"%sPopping %s\n", + ppTracePrompt, + ppTokenName[pptos->major]); + } +#endif + ppmajor = pptos->major; + pp_destructor( ppmajor, &pptos->minor); + pParser->ppidx--; + return ppmajor; } -static PHP_METHOD(Phalcon_Mvc_Model_Query, setTransaction) -{ - zval *transaction, transaction_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&transaction_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(transaction, phalcon_mvc_model_transactioninterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &transaction); - zephir_update_property_zval(this_ptr, ZEND_STRL("transaction"), transaction); - RETURN_THISW(); +static void phql_Free( + void *p, /* The parser to be deleted */ + void (*freeProc)(void*) /* Function used to reclaim memory */ +){ + ppParser *pParser = (ppParser*)p; + if( pParser==0 ) return; + while( pParser->ppidx>=0 ) pp_pop_parser_stack(pParser); + (*freeProc)((void*)pParser); } -static PHP_METHOD(Phalcon_Mvc_Model_Query, setType) -{ - zval *type_param = NULL, _0; - zend_long type; - zval *this_ptr = getThis(); +static int pp_find_shift_action( + ppParser *pParser, /* The parser */ + int iLookAhead /* The look-ahead token */ +){ + int i; + int stateno = pParser->ppstack[pParser->ppidx].stateno; - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(type) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &type_param); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, type); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_0); - RETURN_THISW(); + /* if( pParser->ppidx<0 ) return PP_NO_ACTION; */ + i = pp_shift_ofst[stateno]; + if( i==PP_SHIFT_USE_DFLT ){ + return pp_default[stateno]; + } + if( iLookAhead==PPNOCODE ){ + return PP_NO_ACTION; + } + i += iLookAhead; + if( i<0 || i>=PP_SZ_ACTTAB || pp_lookahead[i]!=iLookAhead ){ +#ifdef PPFALLBACK + int iFallback; /* Fallback token */ + if( iLookAhead %s\n", + ppTracePrompt, ppTokenName[iLookAhead], ppTokenName[iFallback]); + } +#endif + return pp_find_shift_action(pParser, iFallback); + } +#endif + return pp_default[stateno]; + }else{ + return pp_action[i]; + } } -static PHP_METHOD(Phalcon_Mvc_Model_Query, setUniqueRow) -{ - zval *uniqueRow_param = NULL, __$true, __$false; - zend_bool uniqueRow; - zval *this_ptr = getThis(); +static int pp_find_reduce_action( + ppParser *pParser, /* The parser */ + int iLookAhead /* The look-ahead token */ +){ + int i; + int stateno = pParser->ppstack[pParser->ppidx].stateno; - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(uniqueRow) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &uniqueRow_param); - if (uniqueRow) { - zephir_update_property_zval(this_ptr, ZEND_STRL("uniqueRow"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("uniqueRow"), &__$false); - } - RETURN_THISW(); + i = pp_reduce_ofst[stateno]; + if( i==PP_REDUCE_USE_DFLT ){ + return pp_default[stateno]; + } + if( iLookAhead==PPNOCODE ){ + return PP_NO_ACTION; + } + i += iLookAhead; + if( i<0 || i>=PP_SZ_ACTTAB || pp_lookahead[i]!=iLookAhead ){ + return pp_default[stateno]; + }else{ + return pp_action[i]; + } } -static PHP_METHOD(Phalcon_Mvc_Model_Query, executeDelete) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL, *_8 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, models, modelName, model, records, connection, record, _0, _3, _9, _1$$4, _2$$5, _5$$6, _7$$7; - zval intermediate, bindParams, bindTypes; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&records); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&record); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_7$$7); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ARRAY(intermediate) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &intermediate_param, &bindParams_param, &bindTypes_param); - zephir_get_arrval(&intermediate, intermediate_param); - zephir_get_arrval(&bindParams, bindParams_param); - zephir_get_arrval(&bindTypes, bindTypes_param); - zephir_memory_observe(&models); - zephir_array_fetch_string(&models, &intermediate, SL("models"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 757); - if (UNEXPECTED(zephir_array_isset_long(&models, 1))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Delete from several models at the same time is still not supported", "phalcon/Mvc/Model/Query.zep", 762); - return; - } - zephir_memory_observe(&modelName); - zephir_array_fetch_long(&modelName, &models, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 765); - zephir_memory_observe(&model); - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&model, &_0, &modelName, 0))) { - zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&model, &_1$$4, "load", NULL, 0, &modelName); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&records, this_ptr, "getrelatedrecords", NULL, 454, &model, &intermediate, &bindParams, &bindTypes); - zephir_check_call_status(); - if (!(zephir_fast_count_int(&records))) { - object_init_ex(return_value, phalcon_mvc_model_query_status_ce); - ZVAL_BOOL(&_2$$5, 1); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 455, &_2$$5); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(&connection, this_ptr, "getwriteconnection", NULL, 0, &model, &intermediate, &bindParams, &bindTypes); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &connection, "begin", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &records, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &records, "valid", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_3))) { - break; - } - ZEPHIR_CALL_METHOD(&record, &records, "current", &_4, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_5$$6, &record, "delete", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_5$$6))) { - ZEPHIR_CALL_METHOD(NULL, &connection, "rollback", &_6, 0); - zephir_check_call_status(); - object_init_ex(return_value, phalcon_mvc_model_query_status_ce); - ZVAL_BOOL(&_7$$7, 0); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 455, &_7$$7, &record); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(NULL, &records, "next", &_8, 0); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(NULL, &connection, "commit", NULL, 0); - zephir_check_call_status(); - object_init_ex(return_value, phalcon_mvc_model_query_status_ce); - ZVAL_BOOL(&_9, 1); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 455, &_9); - zephir_check_call_status(); - RETURN_MM(); +static void pp_shift( + ppParser *pppParser, /* The parser to be shifted */ + int ppNewState, /* The new state to shift in */ + int ppMajor, /* The major token to shift in */ + PPMINORTYPE *pppMinor /* Pointer ot the minor token to shift in */ +){ + ppStackEntry *pptos; + pppParser->ppidx++; + if( pppParser->ppidx>=PPSTACKDEPTH ){ + phql_ARG_FETCH; + pppParser->ppidx--; +#ifndef NDEBUG + if( ppTraceFILE ){ + fprintf(ppTraceFILE,"%sStack Overflow!\n",ppTracePrompt); + } +#endif + while( pppParser->ppidx>=0 ) pp_pop_parser_stack(pppParser); + /* Here code is inserted which will execute if the parser + ** stack every overflows */ + phql_ARG_STORE; /* Suppress warning about unused %extra_argument var */ + return; + } + pptos = &pppParser->ppstack[pppParser->ppidx]; + pptos->stateno = ppNewState; + pptos->major = ppMajor; + pptos->minor = *pppMinor; +#ifndef NDEBUG + if( ppTraceFILE && pppParser->ppidx>0 ){ + int i; + fprintf(ppTraceFILE,"%sShift %d\n",ppTracePrompt,ppNewState); + fprintf(ppTraceFILE,"%sStack:",ppTracePrompt); + for(i=1; i<=pppParser->ppidx; i++) + fprintf(ppTraceFILE," %s",ppTokenName[pppParser->ppstack[i].major]); + fprintf(ppTraceFILE,"\n"); + } +#endif } -static PHP_METHOD(Phalcon_Mvc_Model_Query, executeInsert) -{ - zend_string *_5; - zend_ulong _4; - zend_bool automaticFields = 0, _18$$8, _31$$17; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL, *_9 = NULL, *_14 = NULL, *_16 = NULL, *_17 = NULL, *_22 = NULL, *_24 = NULL, *_30 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, modelName, manager, connection, metaData, attributes, fields, columnMap, dialect, insertValues, number, value, model, values, exprValue, insertValue, wildcard, fieldName, attributeName, insertModel, _0, _1, *_2, _3, _34, _6$$8, _8$$11, _10$$11, _11$$11, _12$$12, _13$$12, _15$$13, _19$$15, _20$$15, _21$$17, _23$$20, _25$$20, _26$$20, _27$$21, _28$$21, _29$$22, _32$$24, _33$$24; - zval intermediate, bindParams, bindTypes; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&dialect); - ZVAL_UNDEF(&insertValues); - ZVAL_UNDEF(&number); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&exprValue); - ZVAL_UNDEF(&insertValue); - ZVAL_UNDEF(&wildcard); - ZVAL_UNDEF(&fieldName); - ZVAL_UNDEF(&attributeName); - ZVAL_UNDEF(&insertModel); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_34); - ZVAL_UNDEF(&_6$$8); - ZVAL_UNDEF(&_8$$11); - ZVAL_UNDEF(&_10$$11); - ZVAL_UNDEF(&_11$$11); - ZVAL_UNDEF(&_12$$12); - ZVAL_UNDEF(&_13$$12); - ZVAL_UNDEF(&_15$$13); - ZVAL_UNDEF(&_19$$15); - ZVAL_UNDEF(&_20$$15); - ZVAL_UNDEF(&_21$$17); - ZVAL_UNDEF(&_23$$20); - ZVAL_UNDEF(&_25$$20); - ZVAL_UNDEF(&_26$$20); - ZVAL_UNDEF(&_27$$21); - ZVAL_UNDEF(&_28$$21); - ZVAL_UNDEF(&_29$$22); - ZVAL_UNDEF(&_32$$24); - ZVAL_UNDEF(&_33$$24); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ARRAY(intermediate) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &intermediate_param, &bindParams_param, &bindTypes_param); - zephir_get_arrval(&intermediate, intermediate_param); - zephir_get_arrval(&bindParams, bindParams_param); - zephir_get_arrval(&bindTypes, bindTypes_param); - zephir_memory_observe(&modelName); - zephir_array_fetch_string(&modelName, &intermediate, SL("model"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 846); - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - zephir_memory_observe(&model); - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&model, &_0, &modelName, 0))) { - ZEPHIR_CALL_METHOD(&model, &manager, "load", NULL, 0, &modelName); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&connection, this_ptr, "getwriteconnection", NULL, 0, &model, &intermediate, &bindParams, &bindTypes); - zephir_check_call_status(); - zephir_read_property(&_1, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&metaData, &_1); - ZEPHIR_CALL_METHOD(&attributes, &metaData, "getattributes", NULL, 0, &model); - zephir_check_call_status(); - automaticFields = 0; - zephir_memory_observe(&fields); - if (!(zephir_array_isset_string_fetch(&fields, &intermediate, SL("fields"), 0))) { - automaticFields = 1; - ZEPHIR_CPY_WRT(&fields, &attributes); - if (ZEPHIR_GLOBAL(orm).column_renaming) { - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", NULL, 0, &model); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&columnMap); - ZVAL_NULL(&columnMap); - } - } - zephir_memory_observe(&values); - zephir_array_fetch_string(&values, &intermediate, SL("values"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 881); - if (UNEXPECTED(zephir_fast_count_int(&fields) != zephir_fast_count_int(&values))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The column count does not match the values count", "phalcon/Mvc/Model/Query.zep", 890); - return; - } - ZEPHIR_CALL_METHOD(&dialect, &connection, "getdialect", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&insertValues); - array_init(&insertValues); - zephir_is_iterable(&values, 0, "phalcon/Mvc/Model/Query.zep", 961); - if (Z_TYPE_P(&values) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&values), _4, _5, _2) - { - ZEPHIR_INIT_NVAR(&number); - if (_5 != NULL) { - ZVAL_STR_COPY(&number, _5); - } else { - ZVAL_LONG(&number, _4); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _2); - ZEPHIR_OBS_NVAR(&exprValue); - zephir_array_fetch_string(&exprValue, &value, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 900); - zephir_array_fetch_string(&_6$$8, &value, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 902); - do { - if (ZEPHIR_IS_LONG(&_6$$8, 260) || ZEPHIR_IS_LONG(&_6$$8, 258) || ZEPHIR_IS_LONG(&_6$$8, 259)) { - ZEPHIR_CALL_METHOD(&insertValue, &dialect, "getsqlexpression", &_7, 0, &exprValue); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&_6$$8, 322)) { - ZEPHIR_INIT_NVAR(&insertValue); - ZVAL_NULL(&insertValue); - break; - } - if (ZEPHIR_IS_LONG(&_6$$8, 273) || ZEPHIR_IS_LONG(&_6$$8, 274) || ZEPHIR_IS_LONG(&_6$$8, 277)) { - ZEPHIR_CALL_METHOD(&_8$$11, &dialect, "getsqlexpression", &_9, 0, &exprValue); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_10$$11); - ZVAL_STRING(&_10$$11, ":"); - ZEPHIR_INIT_NVAR(&_11$$11); - ZVAL_STRING(&_11$$11, ""); - ZEPHIR_INIT_NVAR(&wildcard); - zephir_fast_str_replace(&wildcard, &_10$$11, &_11$$11, &_8$$11); - ZEPHIR_OBS_NVAR(&insertValue); - if (UNEXPECTED(!(zephir_array_isset_fetch(&insertValue, &bindParams, &wildcard, 0)))) { - ZEPHIR_INIT_NVAR(&_12$$12); - object_init_ex(&_12$$12, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_13$$12); - ZEPHIR_CONCAT_SVS(&_13$$12, "Bound parameter '", &wildcard, "' cannot be replaced because it isn't in the placeholders list"); - ZEPHIR_CALL_METHOD(NULL, &_12$$12, "__construct", &_14, 33, &_13$$12); - zephir_check_call_status(); - zephir_throw_exception_debug(&_12$$12, "phalcon/Mvc/Model/Query.zep", 926); - ZEPHIR_MM_RESTORE(); - return; - } - break; - } - ZEPHIR_INIT_NVAR(&insertValue); - object_init_ex(&insertValue, phalcon_db_rawvalue_ce); - ZEPHIR_CALL_METHOD(&_15$$13, &dialect, "getsqlexpression", &_16, 0, &exprValue); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &insertValue, "__construct", &_17, 36, &_15$$13); - zephir_check_call_status(); - break; - } while(0); +/* The following table contains information about every rule that +** is used during the reduce. +*/ +static struct { + PPCODETYPE lhs; /* Symbol on the left-hand side of the rule */ + unsigned char nrhs; /* Number of right-hand side symbols in the rule */ +} ppRuleInfo[] = { + { 81, 1 }, + { 82, 1 }, + { 82, 1 }, + { 82, 1 }, + { 82, 1 }, + { 83, 7 }, + { 87, 6 }, + { 94, 1 }, + { 94, 1 }, + { 94, 0 }, + { 95, 3 }, + { 95, 1 }, + { 98, 1 }, + { 98, 3 }, + { 98, 3 }, + { 98, 2 }, + { 98, 1 }, + { 96, 3 }, + { 96, 1 }, + { 97, 1 }, + { 97, 0 }, + { 101, 2 }, + { 101, 1 }, + { 102, 1 }, + { 103, 4 }, + { 106, 2 }, + { 106, 1 }, + { 106, 0 }, + { 104, 2 }, + { 104, 2 }, + { 104, 3 }, + { 104, 2 }, + { 104, 3 }, + { 104, 2 }, + { 104, 3 }, + { 104, 2 }, + { 104, 1 }, + { 107, 2 }, + { 107, 0 }, + { 84, 7 }, + { 84, 10 }, + { 108, 3 }, + { 108, 1 }, + { 111, 1 }, + { 109, 3 }, + { 109, 1 }, + { 112, 1 }, + { 85, 3 }, + { 113, 4 }, + { 115, 3 }, + { 115, 1 }, + { 116, 3 }, + { 118, 1 }, + { 86, 3 }, + { 119, 3 }, + { 100, 3 }, + { 100, 2 }, + { 100, 1 }, + { 100, 5 }, + { 100, 7 }, + { 100, 6 }, + { 100, 4 }, + { 100, 5 }, + { 100, 3 }, + { 121, 3 }, + { 121, 1 }, + { 120, 1 }, + { 105, 1 }, + { 88, 2 }, + { 88, 0 }, + { 91, 3 }, + { 91, 0 }, + { 122, 3 }, + { 122, 1 }, + { 123, 1 }, + { 123, 2 }, + { 123, 2 }, + { 89, 3 }, + { 89, 0 }, + { 124, 3 }, + { 124, 1 }, + { 125, 1 }, + { 90, 2 }, + { 90, 0 }, + { 93, 2 }, + { 93, 0 }, + { 92, 2 }, + { 92, 4 }, + { 92, 4 }, + { 92, 0 }, + { 114, 2 }, + { 114, 0 }, + { 126, 1 }, + { 126, 1 }, + { 126, 1 }, + { 126, 1 }, + { 126, 1 }, + { 99, 2 }, + { 99, 3 }, + { 99, 3 }, + { 99, 3 }, + { 99, 3 }, + { 99, 3 }, + { 99, 3 }, + { 99, 3 }, + { 99, 3 }, + { 99, 3 }, + { 99, 3 }, + { 99, 3 }, + { 99, 3 }, + { 99, 3 }, + { 99, 3 }, + { 99, 3 }, + { 99, 3 }, + { 99, 3 }, + { 99, 4 }, + { 99, 3 }, + { 99, 4 }, + { 99, 5 }, + { 99, 6 }, + { 99, 3 }, + { 99, 5 }, + { 99, 6 }, + { 99, 4 }, + { 99, 3 }, + { 99, 6 }, + { 99, 6 }, + { 99, 4 }, + { 128, 2 }, + { 128, 1 }, + { 129, 4 }, + { 129, 2 }, + { 99, 1 }, + { 130, 5 }, + { 131, 1 }, + { 131, 0 }, + { 132, 1 }, + { 132, 0 }, + { 127, 3 }, + { 127, 1 }, + { 133, 1 }, + { 133, 1 }, + { 99, 3 }, + { 99, 4 }, + { 99, 3 }, + { 99, 3 }, + { 99, 2 }, + { 99, 2 }, + { 99, 3 }, + { 99, 1 }, + { 99, 1 }, + { 99, 1 }, + { 99, 1 }, + { 99, 1 }, + { 99, 1 }, + { 99, 1 }, + { 99, 1 }, + { 99, 1 }, + { 99, 1 }, + { 99, 1 }, + { 117, 3 }, + { 117, 1 }, +}; - ZEPHIR_OBS_NVAR(&fieldName); - zephir_array_fetch(&fieldName, &fields, &number, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 939); - _18$$8 = automaticFields; - if (_18$$8) { - _18$$8 = Z_TYPE_P(&columnMap) == IS_ARRAY; - } - if (_18$$8) { - ZEPHIR_OBS_NVAR(&attributeName); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeName, &columnMap, &fieldName, 0)))) { - ZEPHIR_INIT_NVAR(&_19$$15); - object_init_ex(&_19$$15, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_20$$15); - ZEPHIR_CONCAT_SVS(&_20$$15, "Column '", &fieldName, "' isn't part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_19$$15, "__construct", &_14, 33, &_20$$15); - zephir_check_call_status(); - zephir_throw_exception_debug(&_19$$15, "phalcon/Mvc/Model/Query.zep", 949); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&attributeName, &fieldName); - } - zephir_array_update_zval(&insertValues, &attributeName, &insertValue, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &values, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3)) { - break; - } - ZEPHIR_CALL_METHOD(&number, &values, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&exprValue); - zephir_array_fetch_string(&exprValue, &value, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 900); - zephir_array_fetch_string(&_21$$17, &value, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 902); - do { - if (ZEPHIR_IS_LONG(&_21$$17, 260) || ZEPHIR_IS_LONG(&_21$$17, 258) || ZEPHIR_IS_LONG(&_21$$17, 259)) { - ZEPHIR_CALL_METHOD(&insertValue, &dialect, "getsqlexpression", &_22, 0, &exprValue); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&_21$$17, 322)) { - ZEPHIR_INIT_NVAR(&insertValue); - ZVAL_NULL(&insertValue); - break; - } - if (ZEPHIR_IS_LONG(&_21$$17, 273) || ZEPHIR_IS_LONG(&_21$$17, 274) || ZEPHIR_IS_LONG(&_21$$17, 277)) { - ZEPHIR_CALL_METHOD(&_23$$20, &dialect, "getsqlexpression", &_24, 0, &exprValue); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_25$$20); - ZVAL_STRING(&_25$$20, ":"); - ZEPHIR_INIT_NVAR(&_26$$20); - ZVAL_STRING(&_26$$20, ""); - ZEPHIR_INIT_NVAR(&wildcard); - zephir_fast_str_replace(&wildcard, &_25$$20, &_26$$20, &_23$$20); - ZEPHIR_OBS_NVAR(&insertValue); - if (UNEXPECTED(!(zephir_array_isset_fetch(&insertValue, &bindParams, &wildcard, 0)))) { - ZEPHIR_INIT_NVAR(&_27$$21); - object_init_ex(&_27$$21, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_28$$21); - ZEPHIR_CONCAT_SVS(&_28$$21, "Bound parameter '", &wildcard, "' cannot be replaced because it isn't in the placeholders list"); - ZEPHIR_CALL_METHOD(NULL, &_27$$21, "__construct", &_14, 33, &_28$$21); - zephir_check_call_status(); - zephir_throw_exception_debug(&_27$$21, "phalcon/Mvc/Model/Query.zep", 926); - ZEPHIR_MM_RESTORE(); - return; - } - break; - } - ZEPHIR_INIT_NVAR(&insertValue); - object_init_ex(&insertValue, phalcon_db_rawvalue_ce); - ZEPHIR_CALL_METHOD(&_29$$22, &dialect, "getsqlexpression", &_30, 0, &exprValue); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &insertValue, "__construct", &_17, 36, &_29$$22); - zephir_check_call_status(); - break; - } while(0); +static void pp_accept(ppParser*); /* Forward Declaration */ - ZEPHIR_OBS_NVAR(&fieldName); - zephir_array_fetch(&fieldName, &fields, &number, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 939); - _31$$17 = automaticFields; - if (_31$$17) { - _31$$17 = Z_TYPE_P(&columnMap) == IS_ARRAY; - } - if (_31$$17) { - ZEPHIR_OBS_NVAR(&attributeName); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeName, &columnMap, &fieldName, 0)))) { - ZEPHIR_INIT_NVAR(&_32$$24); - object_init_ex(&_32$$24, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_33$$24); - ZEPHIR_CONCAT_SVS(&_33$$24, "Column '", &fieldName, "' isn't part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_32$$24, "__construct", &_14, 33, &_33$$24); - zephir_check_call_status(); - zephir_throw_exception_debug(&_32$$24, "phalcon/Mvc/Model/Query.zep", 949); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&attributeName, &fieldName); - } - zephir_array_update_zval(&insertValues, &attributeName, &insertValue, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&number); - ZEPHIR_CALL_METHOD(&insertModel, &manager, "load", NULL, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &insertModel, "assign", NULL, 0, &insertValues); - zephir_check_call_status(); - object_init_ex(return_value, phalcon_mvc_model_query_status_ce); - ZEPHIR_CALL_METHOD(&_34, &insertModel, "create", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 455, &_34, &insertModel); - zephir_check_call_status(); - RETURN_MM(); -} +static void pp_reduce( + ppParser *pppParser, /* The parser */ + int ppruleno /* Number of the rule by which to reduce */ +){ + int ppgoto; /* The next state */ + int ppact; /* The next action */ + PPMINORTYPE ppgotominor; /* The LHS of the rule reduced */ + ppStackEntry *ppmsp; /* The top of the parser's stack */ + int ppsize; /* Amount to pop the stack */ + phql_ARG_FETCH; + ppmsp = &pppParser->ppstack[pppParser->ppidx]; +#ifndef NDEBUG + if( ppTraceFILE && ppruleno>=0 + && ppruleno + ** { ... } // User supplied code + ** // + ** break; + */ + case 0: +// 110 "parser.php.lemon" { - zend_string *_17, *_63, *_69, *_84$$93; - zend_ulong _16, _62, _68, _83$$93; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL, *_5 = NULL, *_8 = NULL, *_20 = NULL, *_21 = NULL, *_22 = NULL, *_30 = NULL, *_41 = NULL, *_42 = NULL, *_43 = NULL, *_51 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, numberObjects = 0; - zend_bool simulate, haveObjects = 0, haveScalars = 0, isComplex = 0, isSimpleStd = 0, isKeepingSnapshots = 0, _38$$28, _59$$46, _90$$83; - zval *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, *simulate_param = NULL, __$true, __$null, manager, modelName, models, model, connection, connectionTypes, columns, column, selectColumns, simpleColumnMap, metaData, aliasCopy, sqlColumn, attributes, instance, columnMap, attribute, columnAlias, sqlAlias, dialect, sqlSelect, bindCounts, processed, wildcard, value, processedTypes, typeWildcard, result, resultData, cache, resultObject, columns1, typesColumnMap, wildcardValue, resultsetClassName, _0, *_1, _2, *_10, _11, *_14, _15, *_60, _61, *_66, _67, _73, _3$$3, _6$$5, _7$$7, _9$$9, _12$$11, _13$$16, _18$$28, _19$$29, *_23$$31, _24$$31, _29$$31, _26$$34, _28$$35, _31$$36, *_32$$37, _33$$37, _36$$41, _37$$42, _39$$46, _40$$47, *_44$$49, _45$$49, _50$$49, _47$$52, _49$$53, _52$$54, *_53$$55, _54$$55, _57$$59, _58$$60, _64$$67, _65$$71, _70$$73, _71$$76, _72$$79, _74$$90, *_75$$90, _76$$90, _78$$91, _80$$92, *_81$$93, _82$$93, _86$$94, _88$$95, _89$$85, _98$$83, _91$$98, _92$$98, _93$$97, _94$$97, _95$$99, _96$$99; - zval intermediate, bindParams, bindTypes, _25$$34, _27$$35, _34$$38, _35$$39, _46$$52, _48$$53, _55$$56, _56$$57, _77$$91, _79$$92, _85$$94, _87$$95, _97$$97; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&_25$$34); - ZVAL_UNDEF(&_27$$35); - ZVAL_UNDEF(&_34$$38); - ZVAL_UNDEF(&_35$$39); - ZVAL_UNDEF(&_46$$52); - ZVAL_UNDEF(&_48$$53); - ZVAL_UNDEF(&_55$$56); - ZVAL_UNDEF(&_56$$57); - ZVAL_UNDEF(&_77$$91); - ZVAL_UNDEF(&_79$$92); - ZVAL_UNDEF(&_85$$94); - ZVAL_UNDEF(&_87$$95); - ZVAL_UNDEF(&_97$$97); - ZVAL_BOOL(&__$true, 1); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&connectionTypes); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&selectColumns); - ZVAL_UNDEF(&simpleColumnMap); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&aliasCopy); - ZVAL_UNDEF(&sqlColumn); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&instance); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&columnAlias); - ZVAL_UNDEF(&sqlAlias); - ZVAL_UNDEF(&dialect); - ZVAL_UNDEF(&sqlSelect); - ZVAL_UNDEF(&bindCounts); - ZVAL_UNDEF(&processed); - ZVAL_UNDEF(&wildcard); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&processedTypes); - ZVAL_UNDEF(&typeWildcard); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&resultData); - ZVAL_UNDEF(&cache); - ZVAL_UNDEF(&resultObject); - ZVAL_UNDEF(&columns1); - ZVAL_UNDEF(&typesColumnMap); - ZVAL_UNDEF(&wildcardValue); - ZVAL_UNDEF(&resultsetClassName); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_15); - ZVAL_UNDEF(&_61); - ZVAL_UNDEF(&_67); - ZVAL_UNDEF(&_73); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_7$$7); - ZVAL_UNDEF(&_9$$9); - ZVAL_UNDEF(&_12$$11); - ZVAL_UNDEF(&_13$$16); - ZVAL_UNDEF(&_18$$28); - ZVAL_UNDEF(&_19$$29); - ZVAL_UNDEF(&_24$$31); - ZVAL_UNDEF(&_29$$31); - ZVAL_UNDEF(&_26$$34); - ZVAL_UNDEF(&_28$$35); - ZVAL_UNDEF(&_31$$36); - ZVAL_UNDEF(&_33$$37); - ZVAL_UNDEF(&_36$$41); - ZVAL_UNDEF(&_37$$42); - ZVAL_UNDEF(&_39$$46); - ZVAL_UNDEF(&_40$$47); - ZVAL_UNDEF(&_45$$49); - ZVAL_UNDEF(&_50$$49); - ZVAL_UNDEF(&_47$$52); - ZVAL_UNDEF(&_49$$53); - ZVAL_UNDEF(&_52$$54); - ZVAL_UNDEF(&_54$$55); - ZVAL_UNDEF(&_57$$59); - ZVAL_UNDEF(&_58$$60); - ZVAL_UNDEF(&_64$$67); - ZVAL_UNDEF(&_65$$71); - ZVAL_UNDEF(&_70$$73); - ZVAL_UNDEF(&_71$$76); - ZVAL_UNDEF(&_72$$79); - ZVAL_UNDEF(&_74$$90); - ZVAL_UNDEF(&_76$$90); - ZVAL_UNDEF(&_78$$91); - ZVAL_UNDEF(&_80$$92); - ZVAL_UNDEF(&_82$$93); - ZVAL_UNDEF(&_86$$94); - ZVAL_UNDEF(&_88$$95); - ZVAL_UNDEF(&_89$$85); - ZVAL_UNDEF(&_98$$83); - ZVAL_UNDEF(&_91$$98); - ZVAL_UNDEF(&_92$$98); - ZVAL_UNDEF(&_93$$97); - ZVAL_UNDEF(&_94$$97); - ZVAL_UNDEF(&_95$$99); - ZVAL_UNDEF(&_96$$99); - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_ARRAY(intermediate) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(simulate) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 1, &intermediate_param, &bindParams_param, &bindTypes_param, &simulate_param); - zephir_get_arrval(&intermediate, intermediate_param); - zephir_get_arrval(&bindParams, bindParams_param); - zephir_get_arrval(&bindTypes, bindTypes_param); - if (!simulate_param) { - simulate = 0; - } else { - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - ZEPHIR_INIT_VAR(&connectionTypes); - array_init(&connectionTypes); - zephir_memory_observe(&models); - zephir_array_fetch_string(&models, &intermediate, SL("models"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 998); - zephir_is_iterable(&models, 0, "phalcon/Mvc/Model/Query.zep", 1026); - if (Z_TYPE_P(&models) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&models), _1) - { - ZEPHIR_INIT_NVAR(&modelName); - ZVAL_COPY(&modelName, _1); - ZEPHIR_OBS_NVAR(&model); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&model, &_3$$3, &modelName, 0))) { - ZEPHIR_CALL_METHOD(&model, &manager, "load", &_4, 0, &modelName); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("modelsInstances"), &modelName, &model); - } - ZEPHIR_CALL_METHOD(&connection, this_ptr, "getreadconnection", &_5, 0, &model, &intermediate, &bindParams, &bindTypes); - zephir_check_call_status(); - if (Z_TYPE_P(&connection) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(&_6$$5, &connection, "gettype", NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&connectionTypes, &_6$$5, &__$true, PH_COPY | PH_SEPARATE); - if (UNEXPECTED(zephir_fast_count_int(&connectionTypes) == 2)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Cannot use models of different database systems in the same query", "phalcon/Mvc/Model/Query.zep", 1021); - return; - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &models, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &models, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&modelName, &models, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&model); - zephir_read_property(&_7$$7, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&model, &_7$$7, &modelName, 0))) { - ZEPHIR_CALL_METHOD(&model, &manager, "load", &_8, 0, &modelName); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("modelsInstances"), &modelName, &model); - } - ZEPHIR_CALL_METHOD(&connection, this_ptr, "getreadconnection", &_5, 0, &model, &intermediate, &bindParams, &bindTypes); - zephir_check_call_status(); - if (Z_TYPE_P(&connection) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(&_9$$9, &connection, "gettype", NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&connectionTypes, &_9$$9, &__$true, PH_COPY | PH_SEPARATE); - if (UNEXPECTED(zephir_fast_count_int(&connectionTypes) == 2)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Cannot use models of different database systems in the same query", "phalcon/Mvc/Model/Query.zep", 1021); - return; - } - } - ZEPHIR_CALL_METHOD(NULL, &models, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&modelName); - zephir_memory_observe(&columns); - zephir_array_fetch_string(&columns, &intermediate, SL("columns"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1026); - haveObjects = 0; - haveScalars = 0; - isComplex = 0; - numberObjects = 0; - ZEPHIR_CPY_WRT(&columns1, &columns); - zephir_is_iterable(&columns, 0, "phalcon/Mvc/Model/Query.zep", 1054); - if (Z_TYPE_P(&columns) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&columns), _10) - { - ZEPHIR_INIT_NVAR(&column); - ZVAL_COPY(&column, _10); - if (UNEXPECTED(Z_TYPE_P(&column) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid column definition", "phalcon/Mvc/Model/Query.zep", 1038); - return; - } - zephir_array_fetch_string(&_12$$11, &column, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1041); - if (ZEPHIR_IS_STRING(&_12$$11, "scalar")) { - if (!(zephir_array_isset_string(&column, SL("balias")))) { - isComplex = 1; - } - haveScalars = 1; - } else { - haveObjects = 1; - numberObjects++; - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_11, &columns, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_11)) { - break; - } - ZEPHIR_CALL_METHOD(&column, &columns, "current", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&column) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid column definition", "phalcon/Mvc/Model/Query.zep", 1038); - return; - } - zephir_array_fetch_string(&_13$$16, &column, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1041); - if (ZEPHIR_IS_STRING(&_13$$16, "scalar")) { - if (!(zephir_array_isset_string(&column, SL("balias")))) { - isComplex = 1; - } - haveScalars = 1; - } else { - haveObjects = 1; - numberObjects++; - } - ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&column); - if (!(isComplex)) { - if (haveObjects) { - if (haveScalars) { - isComplex = 1; - } else { - if (numberObjects == 1) { - isSimpleStd = 0; - } else { - isComplex = 1; - } - } - } else { - isSimpleStd = 1; - } - } - ZEPHIR_INIT_VAR(&instance); - ZVAL_NULL(&instance); - ZEPHIR_INIT_VAR(&selectColumns); - array_init(&selectColumns); - ZEPHIR_INIT_VAR(&simpleColumnMap); - array_init(&simpleColumnMap); - zephir_read_property(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&metaData, &_0); - zephir_is_iterable(&columns, 0, "phalcon/Mvc/Model/Query.zep", 1160); - if (Z_TYPE_P(&columns) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&columns), _16, _17, _14) - { - ZEPHIR_INIT_NVAR(&aliasCopy); - if (_17 != NULL) { - ZVAL_STR_COPY(&aliasCopy, _17); - } else { - ZVAL_LONG(&aliasCopy, _16); - } - ZEPHIR_INIT_NVAR(&column); - ZVAL_COPY(&column, _14); - ZEPHIR_OBS_NVAR(&sqlColumn); - zephir_array_fetch_string(&sqlColumn, &column, SL("column"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1077); - zephir_array_fetch_string(&_18$$28, &column, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1080); - if (ZEPHIR_IS_STRING(&_18$$28, "object")) { - ZEPHIR_OBS_NVAR(&modelName); - zephir_array_fetch_string(&modelName, &column, SL("model"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1081); - ZEPHIR_OBS_NVAR(&instance); - zephir_read_property(&_19$$29, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&instance, &_19$$29, &modelName, 0))) { - ZEPHIR_CALL_METHOD(&instance, &manager, "load", &_20, 0, &modelName); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("modelsInstances"), &modelName, &instance); - } - ZEPHIR_CALL_METHOD(&attributes, &metaData, "getattributes", &_21, 0, &instance); - zephir_check_call_status(); - if (isComplex) { - if (ZEPHIR_GLOBAL(orm).column_renaming) { - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", &_22, 0, &instance); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&columnMap); - ZVAL_NULL(&columnMap); - } - zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model/Query.zep", 1117); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _23$$31) - { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _23$$31); - ZEPHIR_INIT_NVAR(&_25$$34); - zephir_create_array(&_25$$34, 3, 0); - zephir_array_fast_append(&_25$$34, &attribute); - zephir_array_fast_append(&_25$$34, &sqlColumn); - ZEPHIR_INIT_NVAR(&_26$$34); - ZEPHIR_CONCAT_SVSV(&_26$$34, "_", &sqlColumn, "_", &attribute); - zephir_array_fast_append(&_25$$34, &_26$$34); - zephir_array_append(&selectColumns, &_25$$34, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1110); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_24$$31, &attributes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_24$$31)) { - break; - } - ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_27$$35); - zephir_create_array(&_27$$35, 3, 0); - zephir_array_fast_append(&_27$$35, &attribute); - zephir_array_fast_append(&_27$$35, &sqlColumn); - ZEPHIR_INIT_NVAR(&_28$$35); - ZEPHIR_CONCAT_SVSV(&_28$$35, "_", &sqlColumn, "_", &attribute); - zephir_array_fast_append(&_27$$35, &_28$$35); - zephir_array_append(&selectColumns, &_27$$35, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1110); - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&attribute); - zephir_array_update_multi(&columns1, &instance, SL("zs"), 3, &aliasCopy, SL("instance")); - zephir_array_update_multi(&columns1, &attributes, SL("zs"), 3, &aliasCopy, SL("attributes")); - zephir_array_update_multi(&columns1, &columnMap, SL("zs"), 3, &aliasCopy, SL("columnMap")); - ZEPHIR_CALL_METHOD(&_29$$31, &manager, "iskeepingsnapshots", &_30, 0, &instance); - zephir_check_call_status(); - isKeepingSnapshots = zephir_get_boolval(&_29$$31); - if (isKeepingSnapshots) { - ZEPHIR_INIT_NVAR(&_31$$36); - ZVAL_BOOL(&_31$$36, isKeepingSnapshots); - zephir_array_update_multi(&columns1, &_31$$36, SL("zs"), 3, &aliasCopy, SL("keepSnapshots")); - } - } else { - zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model/Query.zep", 1134); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _32$$37) - { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _32$$37); - ZEPHIR_INIT_NVAR(&_34$$38); - zephir_create_array(&_34$$38, 2, 0); - zephir_array_fast_append(&_34$$38, &attribute); - zephir_array_fast_append(&_34$$38, &sqlColumn); - zephir_array_append(&selectColumns, &_34$$38, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1132); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_33$$37, &attributes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_33$$37)) { - break; - } - ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_35$$39); - zephir_create_array(&_35$$39, 2, 0); - zephir_array_fast_append(&_35$$39, &attribute); - zephir_array_fast_append(&_35$$39, &sqlColumn); - zephir_array_append(&selectColumns, &_35$$39, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1132); - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&attribute); - } - } else { - ZEPHIR_INIT_NVAR(&columnAlias); - if (Z_TYPE_P(&aliasCopy) == IS_LONG) { - ZEPHIR_INIT_NVAR(&_36$$41); - zephir_create_array(&_36$$41, 2, 0); - zephir_array_fast_append(&_36$$41, &sqlColumn); - zephir_array_fast_append(&_36$$41, &__$null); - ZEPHIR_CPY_WRT(&columnAlias, &_36$$41); - } else { - ZEPHIR_INIT_NVAR(&_37$$42); - zephir_create_array(&_37$$42, 3, 0); - zephir_array_fast_append(&_37$$42, &sqlColumn); - zephir_array_fast_append(&_37$$42, &__$null); - zephir_array_fast_append(&_37$$42, &aliasCopy); - ZEPHIR_CPY_WRT(&columnAlias, &_37$$42); - } - zephir_array_append(&selectColumns, &columnAlias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1145); - } - _38$$28 = !isComplex; - if (_38$$28) { - _38$$28 = isSimpleStd; - } - if (_38$$28) { - ZEPHIR_OBS_NVAR(&sqlAlias); - if (zephir_array_isset_string_fetch(&sqlAlias, &column, SL("sqlAlias"), 0)) { - zephir_array_update_zval(&simpleColumnMap, &sqlAlias, &aliasCopy, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&simpleColumnMap, &aliasCopy, &aliasCopy, PH_COPY | PH_SEPARATE); - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_15, &columns, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_15)) { - break; - } - ZEPHIR_CALL_METHOD(&aliasCopy, &columns, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&column, &columns, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&sqlColumn); - zephir_array_fetch_string(&sqlColumn, &column, SL("column"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1077); - zephir_array_fetch_string(&_39$$46, &column, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1080); - if (ZEPHIR_IS_STRING(&_39$$46, "object")) { - ZEPHIR_OBS_NVAR(&modelName); - zephir_array_fetch_string(&modelName, &column, SL("model"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1081); - ZEPHIR_OBS_NVAR(&instance); - zephir_read_property(&_40$$47, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&instance, &_40$$47, &modelName, 0))) { - ZEPHIR_CALL_METHOD(&instance, &manager, "load", &_41, 0, &modelName); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("modelsInstances"), &modelName, &instance); - } - ZEPHIR_CALL_METHOD(&attributes, &metaData, "getattributes", &_42, 0, &instance); - zephir_check_call_status(); - if (isComplex) { - if (ZEPHIR_GLOBAL(orm).column_renaming) { - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", &_43, 0, &instance); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&columnMap); - ZVAL_NULL(&columnMap); - } - zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model/Query.zep", 1117); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _44$$49) - { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _44$$49); - ZEPHIR_INIT_NVAR(&_46$$52); - zephir_create_array(&_46$$52, 3, 0); - zephir_array_fast_append(&_46$$52, &attribute); - zephir_array_fast_append(&_46$$52, &sqlColumn); - ZEPHIR_INIT_NVAR(&_47$$52); - ZEPHIR_CONCAT_SVSV(&_47$$52, "_", &sqlColumn, "_", &attribute); - zephir_array_fast_append(&_46$$52, &_47$$52); - zephir_array_append(&selectColumns, &_46$$52, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1110); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_45$$49, &attributes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_45$$49)) { - break; - } - ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_48$$53); - zephir_create_array(&_48$$53, 3, 0); - zephir_array_fast_append(&_48$$53, &attribute); - zephir_array_fast_append(&_48$$53, &sqlColumn); - ZEPHIR_INIT_NVAR(&_49$$53); - ZEPHIR_CONCAT_SVSV(&_49$$53, "_", &sqlColumn, "_", &attribute); - zephir_array_fast_append(&_48$$53, &_49$$53); - zephir_array_append(&selectColumns, &_48$$53, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1110); - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&attribute); - zephir_array_update_multi(&columns1, &instance, SL("zs"), 3, &aliasCopy, SL("instance")); - zephir_array_update_multi(&columns1, &attributes, SL("zs"), 3, &aliasCopy, SL("attributes")); - zephir_array_update_multi(&columns1, &columnMap, SL("zs"), 3, &aliasCopy, SL("columnMap")); - ZEPHIR_CALL_METHOD(&_50$$49, &manager, "iskeepingsnapshots", &_51, 0, &instance); - zephir_check_call_status(); - isKeepingSnapshots = zephir_get_boolval(&_50$$49); - if (isKeepingSnapshots) { - ZEPHIR_INIT_NVAR(&_52$$54); - ZVAL_BOOL(&_52$$54, isKeepingSnapshots); - zephir_array_update_multi(&columns1, &_52$$54, SL("zs"), 3, &aliasCopy, SL("keepSnapshots")); - } - } else { - zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model/Query.zep", 1134); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _53$$55) - { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _53$$55); - ZEPHIR_INIT_NVAR(&_55$$56); - zephir_create_array(&_55$$56, 2, 0); - zephir_array_fast_append(&_55$$56, &attribute); - zephir_array_fast_append(&_55$$56, &sqlColumn); - zephir_array_append(&selectColumns, &_55$$56, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1132); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_54$$55, &attributes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_54$$55)) { - break; - } - ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_56$$57); - zephir_create_array(&_56$$57, 2, 0); - zephir_array_fast_append(&_56$$57, &attribute); - zephir_array_fast_append(&_56$$57, &sqlColumn); - zephir_array_append(&selectColumns, &_56$$57, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1132); - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&attribute); - } - } else { - if (Z_TYPE_P(&aliasCopy) == IS_LONG) { - ZEPHIR_INIT_NVAR(&_57$$59); - zephir_create_array(&_57$$59, 2, 0); - zephir_array_fast_append(&_57$$59, &sqlColumn); - zephir_array_fast_append(&_57$$59, &__$null); - ZEPHIR_CPY_WRT(&columnAlias, &_57$$59); - } else { - ZEPHIR_INIT_NVAR(&_58$$60); - zephir_create_array(&_58$$60, 3, 0); - zephir_array_fast_append(&_58$$60, &sqlColumn); - zephir_array_fast_append(&_58$$60, &__$null); - zephir_array_fast_append(&_58$$60, &aliasCopy); - ZEPHIR_CPY_WRT(&columnAlias, &_58$$60); - } - zephir_array_append(&selectColumns, &columnAlias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1145); - } - _59$$46 = !isComplex; - if (_59$$46) { - _59$$46 = isSimpleStd; - } - if (_59$$46) { - ZEPHIR_OBS_NVAR(&sqlAlias); - if (zephir_array_isset_string_fetch(&sqlAlias, &column, SL("sqlAlias"), 0)) { - zephir_array_update_zval(&simpleColumnMap, &sqlAlias, &aliasCopy, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&simpleColumnMap, &aliasCopy, &aliasCopy, PH_COPY | PH_SEPARATE); - } - } - ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&column); - ZEPHIR_INIT_NVAR(&aliasCopy); - ZEPHIR_INIT_VAR(&processed); - array_init(&processed); - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); - zephir_array_update_string(&intermediate, SL("columns"), &selectColumns, PH_COPY | PH_SEPARATE); - zephir_is_iterable(&bindParams, 0, "phalcon/Mvc/Model/Query.zep", 1181); - if (Z_TYPE_P(&bindParams) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&bindParams), _62, _63, _60) - { - ZEPHIR_INIT_NVAR(&wildcard); - if (_63 != NULL) { - ZVAL_STR_COPY(&wildcard, _63); - } else { - ZVAL_LONG(&wildcard, _62); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _60); - if (Z_TYPE_P(&wildcard) == IS_LONG) { - ZEPHIR_INIT_NVAR(&wildcardValue); - ZEPHIR_CONCAT_SV(&wildcardValue, ":", &wildcard); - } else { - ZEPHIR_CPY_WRT(&wildcardValue, &wildcard); - } - zephir_array_update_zval(&processed, &wildcardValue, &value, PH_COPY | PH_SEPARATE); - if (Z_TYPE_P(&value) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_64$$67); - ZVAL_LONG(&_64$$67, zephir_fast_count_int(&value)); - zephir_array_update_zval(&bindCounts, &wildcardValue, &_64$$67, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &bindParams, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_61, &bindParams, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_61)) { - break; - } - ZEPHIR_CALL_METHOD(&wildcard, &bindParams, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &bindParams, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&wildcard) == IS_LONG) { - ZEPHIR_INIT_NVAR(&wildcardValue); - ZEPHIR_CONCAT_SV(&wildcardValue, ":", &wildcard); - } else { - ZEPHIR_CPY_WRT(&wildcardValue, &wildcard); - } - zephir_array_update_zval(&processed, &wildcardValue, &value, PH_COPY | PH_SEPARATE); - if (Z_TYPE_P(&value) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_65$$71); - ZVAL_LONG(&_65$$71, zephir_fast_count_int(&value)); - zephir_array_update_zval(&bindCounts, &wildcardValue, &_65$$71, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &bindParams, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&wildcard); - ZEPHIR_INIT_VAR(&processedTypes); - array_init(&processedTypes); - zephir_is_iterable(&bindTypes, 0, "phalcon/Mvc/Model/Query.zep", 1194); - if (Z_TYPE_P(&bindTypes) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&bindTypes), _68, _69, _66) - { - ZEPHIR_INIT_NVAR(&typeWildcard); - if (_69 != NULL) { - ZVAL_STR_COPY(&typeWildcard, _69); - } else { - ZVAL_LONG(&typeWildcard, _68); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _66); - if (Z_TYPE_P(&typeWildcard) == IS_LONG) { - ZEPHIR_INIT_NVAR(&_70$$73); - ZEPHIR_CONCAT_SV(&_70$$73, ":", &typeWildcard); - zephir_array_update_zval(&processedTypes, &_70$$73, &value, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&processedTypes, &typeWildcard, &value, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &bindTypes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_67, &bindTypes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_67)) { - break; - } - ZEPHIR_CALL_METHOD(&typeWildcard, &bindTypes, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &bindTypes, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&typeWildcard) == IS_LONG) { - ZEPHIR_INIT_NVAR(&_71$$76); - ZEPHIR_CONCAT_SV(&_71$$76, ":", &typeWildcard); - zephir_array_update_zval(&processedTypes, &_71$$76, &value, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&processedTypes, &typeWildcard, &value, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &bindTypes, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&typeWildcard); - if (zephir_fast_count_int(&bindCounts)) { - zephir_array_update_string(&intermediate, SL("bindCounts"), &bindCounts, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(&dialect, &connection, "getdialect", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&sqlSelect, &dialect, "select", NULL, 0, &intermediate); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("sharedLock"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_0)) { - ZEPHIR_CALL_METHOD(&_72$$79, &dialect, "sharedlock", NULL, 0, &sqlSelect); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&sqlSelect, &_72$$79); - } - if (simulate) { - zephir_create_array(return_value, 3, 0); - zephir_array_update_string(return_value, SL("sql"), &sqlSelect, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("bind"), &processed, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("bindTypes"), &processedTypes, PH_COPY | PH_SEPARATE); - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(&result, &connection, "query", NULL, 0, &sqlSelect, &processed, &processedTypes); - zephir_check_call_status(); - if (zephir_instance_of_ev(&result, phalcon_db_resultinterface_ce)) { - ZEPHIR_CPY_WRT(&resultData, &result); - } else { - ZEPHIR_INIT_NVAR(&resultData); - ZVAL_NULL(&resultData); - } - zephir_read_property(&_73, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&cache, &_73); - if (!(isComplex)) { - if (isSimpleStd) { - ZEPHIR_INIT_VAR(&resultObject); - object_init_ex(&resultObject, phalcon_mvc_model_row_ce); - if (zephir_has_constructor(&resultObject)) { - ZEPHIR_CALL_METHOD(NULL, &resultObject, "__construct", NULL, 0); - zephir_check_call_status(); - } - - isKeepingSnapshots = 0; - } else { - if (Z_TYPE_P(&instance) == IS_OBJECT) { - ZEPHIR_CPY_WRT(&resultObject, &instance); - } else { - ZEPHIR_CPY_WRT(&resultObject, &model); - } - if (!(ZEPHIR_GLOBAL(orm).cast_on_hydrate)) { - ZEPHIR_CALL_METHOD(&simpleColumnMap, &metaData, "getcolumnmap", NULL, 0, &resultObject); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", NULL, 0, &resultObject); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&typesColumnMap, &metaData, "getdatatypes", NULL, 0, &resultObject); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&simpleColumnMap); - if (Z_TYPE_P(&columnMap) == IS_NULL) { - array_init(&simpleColumnMap); - ZEPHIR_CALL_METHOD(&_74$$90, &metaData, "getattributes", NULL, 0, &resultObject); - zephir_check_call_status(); - zephir_is_iterable(&_74$$90, 0, "phalcon/Mvc/Model/Query.zep", 1282); - if (Z_TYPE_P(&_74$$90) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_74$$90), _75$$90) - { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _75$$90); - ZEPHIR_INIT_NVAR(&_77$$91); - zephir_create_array(&_77$$91, 2, 0); - zephir_array_fast_append(&_77$$91, &attribute); - ZEPHIR_OBS_NVAR(&_78$$91); - zephir_array_fetch(&_78$$91, &typesColumnMap, &attribute, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1280); - zephir_array_fast_append(&_77$$91, &_78$$91); - zephir_array_update_zval(&simpleColumnMap, &attribute, &_77$$91, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_74$$90, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_76$$90, &_74$$90, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_76$$90)) { - break; - } - ZEPHIR_CALL_METHOD(&attribute, &_74$$90, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_79$$92); - zephir_create_array(&_79$$92, 2, 0); - zephir_array_fast_append(&_79$$92, &attribute); - ZEPHIR_OBS_NVAR(&_80$$92); - zephir_array_fetch(&_80$$92, &typesColumnMap, &attribute, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1280); - zephir_array_fast_append(&_79$$92, &_80$$92); - zephir_array_update_zval(&simpleColumnMap, &attribute, &_79$$92, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &_74$$90, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&attribute); - } else { - array_init(&simpleColumnMap); - zephir_is_iterable(&columnMap, 0, "phalcon/Mvc/Model/Query.zep", 1291); - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&columnMap), _83$$93, _84$$93, _81$$93) - { - ZEPHIR_INIT_NVAR(&column); - if (_84$$93 != NULL) { - ZVAL_STR_COPY(&column, _84$$93); - } else { - ZVAL_LONG(&column, _83$$93); - } - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _81$$93); - ZEPHIR_INIT_NVAR(&_85$$94); - zephir_create_array(&_85$$94, 2, 0); - zephir_array_fast_append(&_85$$94, &attribute); - ZEPHIR_OBS_NVAR(&_86$$94); - zephir_array_fetch(&_86$$94, &typesColumnMap, &column, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1289); - zephir_array_fast_append(&_85$$94, &_86$$94); - zephir_array_update_zval(&simpleColumnMap, &column, &_85$$94, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &columnMap, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_82$$93, &columnMap, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_82$$93)) { - break; - } - ZEPHIR_CALL_METHOD(&column, &columnMap, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&attribute, &columnMap, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_87$$95); - zephir_create_array(&_87$$95, 2, 0); - zephir_array_fast_append(&_87$$95, &attribute); - ZEPHIR_OBS_NVAR(&_88$$95); - zephir_array_fetch(&_88$$95, &typesColumnMap, &column, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1289); - zephir_array_fast_append(&_87$$95, &_88$$95); - zephir_array_update_zval(&simpleColumnMap, &column, &_87$$95, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &columnMap, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&attribute); - ZEPHIR_INIT_NVAR(&column); - } - } - ZEPHIR_CALL_METHOD(&_89$$85, &manager, "iskeepingsnapshots", NULL, 0, &resultObject); - zephir_check_call_status(); - isKeepingSnapshots = zephir_get_boolval(&_89$$85); - } - _90$$83 = zephir_instance_of_ev(&resultObject, phalcon_mvc_modelinterface_ce); - if (_90$$83) { - _90$$83 = (zephir_method_exists_ex(&resultObject, ZEND_STRL("getresultsetclass")) == SUCCESS); - } - if (_90$$83) { - ZEPHIR_CALL_METHOD(&resultsetClassName, &resultObject, "getresultsetclass", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&resultsetClassName)) { - if (UNEXPECTED(!(zephir_class_exists(&resultsetClassName, 1)))) { - ZEPHIR_INIT_VAR(&_91$$98); - object_init_ex(&_91$$98, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_92$$98); - ZEPHIR_CONCAT_SVS(&_92$$98, "Resultset class \"", &resultsetClassName, "\" not found"); - ZEPHIR_CALL_METHOD(NULL, &_91$$98, "__construct", NULL, 33, &_92$$98); - zephir_check_call_status(); - zephir_throw_exception_debug(&_91$$98, "phalcon/Mvc/Model/Query.zep", 1307); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_VAR(&_93$$97); - ZVAL_STRING(&_93$$97, "Phalcon\\Mvc\\Model\\ResultsetInterface"); - ZEPHIR_CALL_FUNCTION(&_94$$97, "is_subclass_of", NULL, 438, &resultsetClassName, &_93$$97); - zephir_check_call_status(); - if (UNEXPECTED(!zephir_is_true(&_94$$97))) { - ZEPHIR_INIT_VAR(&_95$$99); - object_init_ex(&_95$$99, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_96$$99); - ZEPHIR_CONCAT_SVS(&_96$$99, "Resultset class \"", &resultsetClassName, "\" must be an implementation of Phalcon\\Mvc\\Model\\ResultsetInterface"); - ZEPHIR_CALL_METHOD(NULL, &_95$$99, "__construct", NULL, 33, &_96$$99); - zephir_check_call_status(); - zephir_throw_exception_debug(&_95$$99, "phalcon/Mvc/Model/Query.zep", 1313); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_VAR(&_97$$97); - zephir_create_array(&_97$$97, 5, 0); - zephir_array_fast_append(&_97$$97, &simpleColumnMap); - zephir_array_fast_append(&_97$$97, &resultObject); - zephir_array_fast_append(&_97$$97, &resultData); - zephir_array_fast_append(&_97$$97, &cache); - ZEPHIR_INIT_NVAR(&_93$$97); - ZVAL_BOOL(&_93$$97, isKeepingSnapshots); - zephir_array_fast_append(&_97$$97, &_93$$97); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(return_value, &resultsetClassName, &_97$$97); - zephir_check_call_status(); - RETURN_MM(); - } - } - object_init_ex(return_value, phalcon_mvc_model_resultset_simple_ce); - if (isKeepingSnapshots) { - ZVAL_BOOL(&_98$$83, 1); - } else { - ZVAL_BOOL(&_98$$83, 0); - } - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 456, &simpleColumnMap, &resultObject, &resultData, &cache, &_98$$83); - zephir_check_call_status(); - RETURN_MM(); - } - object_init_ex(return_value, phalcon_mvc_model_resultset_complex_ce); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 457, &columns1, &resultData, &cache); - zephir_check_call_status(); - RETURN_MM(); + ZVAL_ZVAL(&status->ret, &ppmsp[0].minor.pp202, 1, 1); } - -static PHP_METHOD(Phalcon_Mvc_Model_Query, executeUpdate) +// 1262 "parser.php.c" + break; + case 1: + case 2: + case 3: + case 4: + case 18: + case 19: + case 22: + case 23: + case 43: + case 50: + case 52: + case 65: + case 67: + case 73: + case 80: + case 81: + case 132: + case 136: + case 141: + case 149: +// 118 "parser.php.lemon" { - zend_string *_5; - zend_ulong _4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL, *_9 = NULL, *_14 = NULL, *_16 = NULL, *_17 = NULL, *_19 = NULL, *_21 = NULL, *_27 = NULL, *_30 = NULL, *_32 = NULL, *_34 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, models, modelName, model, connection, dialect, fields, values, updateValues, fieldName, value, selectBindParams, selectBindTypes, number, field, records, exprValue, updateValue, wildcard, record, _0, *_2, _3, _29, _35, _1$$4, _6$$5, _8$$10, _10$$10, _11$$10, _12$$11, _13$$11, _15$$13, _18$$14, _20$$19, _22$$19, _23$$19, _24$$20, _25$$20, _26$$22, _28$$23, _31$$24, _33$$25; - zval intermediate, bindParams, bindTypes; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&dialect); - ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&updateValues); - ZVAL_UNDEF(&fieldName); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&selectBindParams); - ZVAL_UNDEF(&selectBindTypes); - ZVAL_UNDEF(&number); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&records); - ZVAL_UNDEF(&exprValue); - ZVAL_UNDEF(&updateValue); - ZVAL_UNDEF(&wildcard); - ZVAL_UNDEF(&record); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_29); - ZVAL_UNDEF(&_35); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_8$$10); - ZVAL_UNDEF(&_10$$10); - ZVAL_UNDEF(&_11$$10); - ZVAL_UNDEF(&_12$$11); - ZVAL_UNDEF(&_13$$11); - ZVAL_UNDEF(&_15$$13); - ZVAL_UNDEF(&_18$$14); - ZVAL_UNDEF(&_20$$19); - ZVAL_UNDEF(&_22$$19); - ZVAL_UNDEF(&_23$$19); - ZVAL_UNDEF(&_24$$20); - ZVAL_UNDEF(&_25$$20); - ZVAL_UNDEF(&_26$$22); - ZVAL_UNDEF(&_28$$23); - ZVAL_UNDEF(&_31$$24); - ZVAL_UNDEF(&_33$$25); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ARRAY(intermediate) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &intermediate_param, &bindParams_param, &bindTypes_param); - zephir_get_arrval(&intermediate, intermediate_param); - zephir_get_arrval(&bindParams, bindParams_param); - zephir_get_arrval(&bindTypes, bindTypes_param); - zephir_memory_observe(&models); - zephir_array_fetch_string(&models, &intermediate, SL("models"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1361); - if (UNEXPECTED(zephir_array_isset_long(&models, 1))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Updating several models at the same time is still not supported", "phalcon/Mvc/Model/Query.zep", 1366); - return; - } - zephir_memory_observe(&modelName); - zephir_array_fetch_long(&modelName, &models, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1369); - zephir_memory_observe(&model); - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&model, &_0, &modelName, 0))) { - zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&model, &_1$$4, "load", NULL, 0, &modelName); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&connection, this_ptr, "getwriteconnection", NULL, 0, &model, &intermediate, &bindParams, &bindTypes); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&dialect, &connection, "getdialect", NULL, 0); - zephir_check_call_status(); - zephir_memory_observe(&fields); - zephir_array_fetch_string(&fields, &intermediate, SL("fields"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1388); - zephir_memory_observe(&values); - zephir_array_fetch_string(&values, &intermediate, SL("values"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1389); - ZEPHIR_INIT_VAR(&updateValues); - array_init(&updateValues); - ZEPHIR_CPY_WRT(&selectBindParams, &bindParams); - ZEPHIR_CPY_WRT(&selectBindTypes, &bindTypes); - zephir_is_iterable(&fields, 0, "phalcon/Mvc/Model/Query.zep", 1461); - if (Z_TYPE_P(&fields) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&fields), _4, _5, _2) - { - ZEPHIR_INIT_NVAR(&number); - if (_5 != NULL) { - ZVAL_STR_COPY(&number, _5); - } else { - ZVAL_LONG(&number, _4); - } - ZEPHIR_INIT_NVAR(&field); - ZVAL_COPY(&field, _2); - ZEPHIR_OBS_NVAR(&value); - zephir_array_fetch(&value, &values, &number, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1404); - ZEPHIR_OBS_NVAR(&exprValue); - zephir_array_fetch_string(&exprValue, &value, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1405); - if (zephir_array_isset_string(&field, SL("balias"))) { - ZEPHIR_OBS_NVAR(&fieldName); - zephir_array_fetch_string(&fieldName, &field, SL("balias"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1408); - } else { - ZEPHIR_OBS_NVAR(&fieldName); - zephir_array_fetch_string(&fieldName, &field, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1410); - } - zephir_array_fetch_string(&_6$$5, &value, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1413); - do { - if (ZEPHIR_IS_LONG(&_6$$5, 260) || ZEPHIR_IS_LONG(&_6$$5, 258) || ZEPHIR_IS_LONG(&_6$$5, 259)) { - ZEPHIR_CALL_METHOD(&updateValue, &dialect, "getsqlexpression", &_7, 0, &exprValue); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&_6$$5, 322)) { - ZEPHIR_INIT_NVAR(&updateValue); - ZVAL_NULL(&updateValue); - break; - } - if (ZEPHIR_IS_LONG(&_6$$5, 273) || ZEPHIR_IS_LONG(&_6$$5, 274) || ZEPHIR_IS_LONG(&_6$$5, 277)) { - ZEPHIR_CALL_METHOD(&_8$$10, &dialect, "getsqlexpression", &_9, 0, &exprValue); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_10$$10); - ZVAL_STRING(&_10$$10, ":"); - ZEPHIR_INIT_NVAR(&_11$$10); - ZVAL_STRING(&_11$$10, ""); - ZEPHIR_INIT_NVAR(&wildcard); - zephir_fast_str_replace(&wildcard, &_10$$10, &_11$$10, &_8$$10); - ZEPHIR_OBS_NVAR(&updateValue); - if (UNEXPECTED(!(zephir_array_isset_fetch(&updateValue, &bindParams, &wildcard, 0)))) { - ZEPHIR_INIT_NVAR(&_12$$11); - object_init_ex(&_12$$11, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_13$$11); - ZEPHIR_CONCAT_SVS(&_13$$11, "Bound parameter '", &wildcard, "' cannot be replaced because it's not in the placeholders list"); - ZEPHIR_CALL_METHOD(NULL, &_12$$11, "__construct", &_14, 33, &_13$$11); - zephir_check_call_status(); - zephir_throw_exception_debug(&_12$$11, "phalcon/Mvc/Model/Query.zep", 1436); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_unset(&selectBindParams, &wildcard, PH_SEPARATE); - zephir_array_unset(&selectBindTypes, &wildcard, PH_SEPARATE); - break; - } - if (ZEPHIR_IS_LONG(&_6$$5, 277)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Not supported", "phalcon/Mvc/Model/Query.zep", 1445); - return; - } - ZEPHIR_INIT_NVAR(&updateValue); - object_init_ex(&updateValue, phalcon_db_rawvalue_ce); - ZEPHIR_CALL_METHOD(&_15$$13, &dialect, "getsqlexpression", &_16, 0, &exprValue); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &updateValue, "__construct", &_17, 36, &_15$$13); - zephir_check_call_status(); - break; - } while(0); - - zephir_array_update_zval(&updateValues, &fieldName, &updateValue, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &fields, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3)) { - break; - } - ZEPHIR_CALL_METHOD(&number, &fields, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&field, &fields, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&value); - zephir_array_fetch(&value, &values, &number, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1404); - ZEPHIR_OBS_NVAR(&exprValue); - zephir_array_fetch_string(&exprValue, &value, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1405); - if (zephir_array_isset_string(&field, SL("balias"))) { - ZEPHIR_OBS_NVAR(&fieldName); - zephir_array_fetch_string(&fieldName, &field, SL("balias"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1408); - } else { - ZEPHIR_OBS_NVAR(&fieldName); - zephir_array_fetch_string(&fieldName, &field, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1410); - } - zephir_array_fetch_string(&_18$$14, &value, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1413); - do { - if (ZEPHIR_IS_LONG(&_18$$14, 260) || ZEPHIR_IS_LONG(&_18$$14, 258) || ZEPHIR_IS_LONG(&_18$$14, 259)) { - ZEPHIR_CALL_METHOD(&updateValue, &dialect, "getsqlexpression", &_19, 0, &exprValue); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&_18$$14, 322)) { - ZEPHIR_INIT_NVAR(&updateValue); - ZVAL_NULL(&updateValue); - break; - } - if (ZEPHIR_IS_LONG(&_18$$14, 273) || ZEPHIR_IS_LONG(&_18$$14, 274) || ZEPHIR_IS_LONG(&_18$$14, 277)) { - ZEPHIR_CALL_METHOD(&_20$$19, &dialect, "getsqlexpression", &_21, 0, &exprValue); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_22$$19); - ZVAL_STRING(&_22$$19, ":"); - ZEPHIR_INIT_NVAR(&_23$$19); - ZVAL_STRING(&_23$$19, ""); - ZEPHIR_INIT_NVAR(&wildcard); - zephir_fast_str_replace(&wildcard, &_22$$19, &_23$$19, &_20$$19); - ZEPHIR_OBS_NVAR(&updateValue); - if (UNEXPECTED(!(zephir_array_isset_fetch(&updateValue, &bindParams, &wildcard, 0)))) { - ZEPHIR_INIT_NVAR(&_24$$20); - object_init_ex(&_24$$20, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_25$$20); - ZEPHIR_CONCAT_SVS(&_25$$20, "Bound parameter '", &wildcard, "' cannot be replaced because it's not in the placeholders list"); - ZEPHIR_CALL_METHOD(NULL, &_24$$20, "__construct", &_14, 33, &_25$$20); - zephir_check_call_status(); - zephir_throw_exception_debug(&_24$$20, "phalcon/Mvc/Model/Query.zep", 1436); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_unset(&selectBindParams, &wildcard, PH_SEPARATE); - zephir_array_unset(&selectBindTypes, &wildcard, PH_SEPARATE); - break; - } - if (ZEPHIR_IS_LONG(&_18$$14, 277)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Not supported", "phalcon/Mvc/Model/Query.zep", 1445); - return; - } - ZEPHIR_INIT_NVAR(&updateValue); - object_init_ex(&updateValue, phalcon_db_rawvalue_ce); - ZEPHIR_CALL_METHOD(&_26$$22, &dialect, "getsqlexpression", &_27, 0, &exprValue); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &updateValue, "__construct", &_17, 36, &_26$$22); - zephir_check_call_status(); - break; - } while(0); - - zephir_array_update_zval(&updateValues, &fieldName, &updateValue, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&field); - ZEPHIR_INIT_NVAR(&number); - ZEPHIR_CALL_METHOD(&records, this_ptr, "getrelatedrecords", NULL, 454, &model, &intermediate, &selectBindParams, &selectBindTypes); - zephir_check_call_status(); - if (!(zephir_fast_count_int(&records))) { - object_init_ex(return_value, phalcon_mvc_model_query_status_ce); - ZVAL_BOOL(&_28$$23, 1); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 455, &_28$$23); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(&connection, this_ptr, "getwriteconnection", NULL, 0, &model, &intermediate, &bindParams, &bindTypes); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &connection, "begin", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &records, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_29, &records, "valid", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_29))) { - break; - } - ZEPHIR_CALL_METHOD(&record, &records, "current", &_30, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &record, "assign", NULL, 0, &updateValues); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_31$$24, &record, "update", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_31$$24))) { - ZEPHIR_CALL_METHOD(NULL, &connection, "rollback", &_32, 0); - zephir_check_call_status(); - object_init_ex(return_value, phalcon_mvc_model_query_status_ce); - ZVAL_BOOL(&_33$$25, 0); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 455, &_33$$25, &record); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(NULL, &records, "next", &_34, 0); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(NULL, &connection, "commit", NULL, 0); - zephir_check_call_status(); - object_init_ex(return_value, phalcon_mvc_model_query_status_ce); - ZVAL_BOOL(&_35, 1); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 455, &_35); - zephir_check_call_status(); - RETURN_MM(); + ppgotominor.pp202 = ppmsp[0].minor.pp202; } - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getCallArgument) +// 1288 "parser.php.c" + break; + case 5: +// 138 "parser.php.lemon" { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *argument_param = NULL, _0; - zval argument; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&argument); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(argument) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &argument_param); - ZEPHIR_OBS_COPY_OR_DUP(&argument, argument_param); - zephir_array_fetch_string(&_0, &argument, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1523); - if (ZEPHIR_IS_LONG(&_0, 352)) { - zephir_create_array(return_value, 1, 0); - add_assoc_stringl_ex(return_value, SL("type"), SL("all")); - RETURN_MM(); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getexpression", NULL, 458, &argument); - zephir_check_call_status(); - RETURN_MM(); + phql_ret_select_statement(&ppgotominor.pp202, &ppmsp[-6].minor.pp202, &ppmsp[-5].minor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[-4].minor.pp202, &ppmsp[-3].minor.pp202, &ppmsp[-1].minor.pp202, &ppmsp[0].minor.pp202); } - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getCaseExpression) +// 1295 "parser.php.c" + break; + case 6: +// 146 "parser.php.lemon" { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_6 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *expr_param = NULL, whenClauses, whenExpr, _0, *_1, _2, _18, _19, _4$$4, _5$$4, _7$$4, _9$$5, _10$$5, _12$$7, _13$$7, _14$$7, _16$$8, _17$$8; - zval expr, _3$$4, _8$$5, _11$$7, _15$$8; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_8$$5); - ZVAL_UNDEF(&_11$$7); - ZVAL_UNDEF(&_15$$8); - ZVAL_UNDEF(&whenClauses); - ZVAL_UNDEF(&whenExpr); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_18); - ZVAL_UNDEF(&_19); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_9$$5); - ZVAL_UNDEF(&_10$$5); - ZVAL_UNDEF(&_12$$7); - ZVAL_UNDEF(&_13$$7); - ZVAL_UNDEF(&_14$$7); - ZVAL_UNDEF(&_16$$8); - ZVAL_UNDEF(&_17$$8); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(expr) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &expr_param); - ZEPHIR_OBS_COPY_OR_DUP(&expr, expr_param); - ZEPHIR_INIT_VAR(&whenClauses); - array_init(&whenClauses); - zephir_array_fetch_string(&_0, &expr, SL("right"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1541); - zephir_is_iterable(&_0, 0, "phalcon/Mvc/Model/Query.zep", 1556); - if (Z_TYPE_P(&_0) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) - { - ZEPHIR_INIT_NVAR(&whenExpr); - ZVAL_COPY(&whenExpr, _1); - if (zephir_array_isset_string(&whenExpr, SL("right"))) { - ZEPHIR_INIT_NVAR(&_3$$4); - zephir_create_array(&_3$$4, 3, 0); - add_assoc_stringl_ex(&_3$$4, SL("type"), SL("when")); - zephir_array_fetch_string(&_5$$4, &whenExpr, SL("left"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1545); - ZEPHIR_CALL_METHOD(&_4$$4, this_ptr, "getexpression", &_6, 458, &_5$$4); - zephir_check_call_status(); - zephir_array_update_string(&_3$$4, SL("expr"), &_4$$4, PH_COPY | PH_SEPARATE); - zephir_array_fetch_string(&_7$$4, &whenExpr, SL("right"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1546); - ZEPHIR_CALL_METHOD(&_4$$4, this_ptr, "getexpression", &_6, 458, &_7$$4); - zephir_check_call_status(); - zephir_array_update_string(&_3$$4, SL("then"), &_4$$4, PH_COPY | PH_SEPARATE); - zephir_array_append(&whenClauses, &_3$$4, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1547); - } else { - ZEPHIR_INIT_NVAR(&_8$$5); - zephir_create_array(&_8$$5, 2, 0); - add_assoc_stringl_ex(&_8$$5, SL("type"), SL("else")); - zephir_array_fetch_string(&_10$$5, &whenExpr, SL("left"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1551); - ZEPHIR_CALL_METHOD(&_9$$5, this_ptr, "getexpression", &_6, 458, &_10$$5); - zephir_check_call_status(); - zephir_array_update_string(&_8$$5, SL("expr"), &_9$$5, PH_COPY | PH_SEPARATE); - zephir_array_append(&whenClauses, &_8$$5, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1552); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&whenExpr, &_0, "current", NULL, 0); - zephir_check_call_status(); - if (zephir_array_isset_string(&whenExpr, SL("right"))) { - ZEPHIR_INIT_NVAR(&_11$$7); - zephir_create_array(&_11$$7, 3, 0); - add_assoc_stringl_ex(&_11$$7, SL("type"), SL("when")); - zephir_array_fetch_string(&_13$$7, &whenExpr, SL("left"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1545); - ZEPHIR_CALL_METHOD(&_12$$7, this_ptr, "getexpression", &_6, 458, &_13$$7); - zephir_check_call_status(); - zephir_array_update_string(&_11$$7, SL("expr"), &_12$$7, PH_COPY | PH_SEPARATE); - zephir_array_fetch_string(&_14$$7, &whenExpr, SL("right"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1546); - ZEPHIR_CALL_METHOD(&_12$$7, this_ptr, "getexpression", &_6, 458, &_14$$7); - zephir_check_call_status(); - zephir_array_update_string(&_11$$7, SL("then"), &_12$$7, PH_COPY | PH_SEPARATE); - zephir_array_append(&whenClauses, &_11$$7, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1547); - } else { - ZEPHIR_INIT_NVAR(&_15$$8); - zephir_create_array(&_15$$8, 2, 0); - add_assoc_stringl_ex(&_15$$8, SL("type"), SL("else")); - zephir_array_fetch_string(&_17$$8, &whenExpr, SL("left"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1551); - ZEPHIR_CALL_METHOD(&_16$$8, this_ptr, "getexpression", &_6, 458, &_17$$8); - zephir_check_call_status(); - zephir_array_update_string(&_15$$8, SL("expr"), &_16$$8, PH_COPY | PH_SEPARATE); - zephir_array_append(&whenClauses, &_15$$8, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 1552); - } - ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&whenExpr); - zephir_create_array(return_value, 3, 0); - add_assoc_stringl_ex(return_value, SL("type"), SL("case")); - zephir_array_fetch_string(&_19, &expr, SL("left"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1558); - ZEPHIR_CALL_METHOD(&_18, this_ptr, "getexpression", &_6, 458, &_19); - zephir_check_call_status(); - zephir_array_update_string(return_value, SL("expr"), &_18, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("when-clauses"), &whenClauses, PH_COPY | PH_SEPARATE); - RETURN_MM(); + phql_ret_select_clause(&ppgotominor.pp202, &ppmsp[-4].minor.pp202, &ppmsp[-3].minor.pp202, &ppmsp[-1].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(27,&ppmsp[-5].minor); + pp_destructor(28,&ppmsp[-2].minor); } - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getExpression) +// 1304 "parser.php.c" + break; + case 7: +// 154 "parser.php.lemon" { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool quoting, tempNotQuoting = 0; - zval *expr_param = NULL, *quoting_param = NULL, exprType, exprLeft, exprRight, left, right, listItems, exprListItem, exprReturn, value, escapedValue, exprValue, valueParts, name, bindType, bind, _0$$5, _1$$6, _2$$8, _3$$9, _4$$10, _5$$11, _6$$12, _7$$13, _8$$14, _9$$16, _10$$17, _11$$18, _12$$19, _13$$20, _14$$21, _15$$22, _16$$23, _17$$24, _18$$25, _19$$25, _20$$26, _21$$27, _22$$28, _23$$33, _24$$33, _25$$33, _26$$33, _27$$33, _28$$34, _29$$34, _30$$34, _31$$37, _32$$37, _33$$37, _34$$38, _35$$38, _36$$38, _37$$39, _38$$39, _39$$39, _40$$40, _41$$40, _42$$40, _43$$41, _44$$41, _45$$41, _46$$42, _47$$42, _48$$42, _49$$43, _56$$43, _57$$43, _50$$44, _51$$44, _52$$45, _53$$45, _54$$46, _55$$46, _58$$47, _59$$47, _60$$48, _61$$48, _62$$49, _63$$50, _64$$51, _65$$52, _66$$53, _67$$54, _68$$55, _69$$56, _70$$57, _71$$58, _72$$59, _73$$60, _74$$61, _75$$62, _76$$63, _77$$64, _78$$65, _79$$66, _80$$66, _81$$69, _82$$69, _83$$69, _84$$70, _85$$70, *_86$$72, _87$$72, _88$$73, _89$$74; - zval expr; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&exprType); - ZVAL_UNDEF(&exprLeft); - ZVAL_UNDEF(&exprRight); - ZVAL_UNDEF(&left); - ZVAL_UNDEF(&right); - ZVAL_UNDEF(&listItems); - ZVAL_UNDEF(&exprListItem); - ZVAL_UNDEF(&exprReturn); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&escapedValue); - ZVAL_UNDEF(&exprValue); - ZVAL_UNDEF(&valueParts); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&bindType); - ZVAL_UNDEF(&bind); - ZVAL_UNDEF(&_0$$5); - ZVAL_UNDEF(&_1$$6); - ZVAL_UNDEF(&_2$$8); - ZVAL_UNDEF(&_3$$9); - ZVAL_UNDEF(&_4$$10); - ZVAL_UNDEF(&_5$$11); - ZVAL_UNDEF(&_6$$12); - ZVAL_UNDEF(&_7$$13); - ZVAL_UNDEF(&_8$$14); - ZVAL_UNDEF(&_9$$16); - ZVAL_UNDEF(&_10$$17); - ZVAL_UNDEF(&_11$$18); - ZVAL_UNDEF(&_12$$19); - ZVAL_UNDEF(&_13$$20); - ZVAL_UNDEF(&_14$$21); - ZVAL_UNDEF(&_15$$22); - ZVAL_UNDEF(&_16$$23); - ZVAL_UNDEF(&_17$$24); - ZVAL_UNDEF(&_18$$25); - ZVAL_UNDEF(&_19$$25); - ZVAL_UNDEF(&_20$$26); - ZVAL_UNDEF(&_21$$27); - ZVAL_UNDEF(&_22$$28); - ZVAL_UNDEF(&_23$$33); - ZVAL_UNDEF(&_24$$33); - ZVAL_UNDEF(&_25$$33); - ZVAL_UNDEF(&_26$$33); - ZVAL_UNDEF(&_27$$33); - ZVAL_UNDEF(&_28$$34); - ZVAL_UNDEF(&_29$$34); - ZVAL_UNDEF(&_30$$34); - ZVAL_UNDEF(&_31$$37); - ZVAL_UNDEF(&_32$$37); - ZVAL_UNDEF(&_33$$37); - ZVAL_UNDEF(&_34$$38); - ZVAL_UNDEF(&_35$$38); - ZVAL_UNDEF(&_36$$38); - ZVAL_UNDEF(&_37$$39); - ZVAL_UNDEF(&_38$$39); - ZVAL_UNDEF(&_39$$39); - ZVAL_UNDEF(&_40$$40); - ZVAL_UNDEF(&_41$$40); - ZVAL_UNDEF(&_42$$40); - ZVAL_UNDEF(&_43$$41); - ZVAL_UNDEF(&_44$$41); - ZVAL_UNDEF(&_45$$41); - ZVAL_UNDEF(&_46$$42); - ZVAL_UNDEF(&_47$$42); - ZVAL_UNDEF(&_48$$42); - ZVAL_UNDEF(&_49$$43); - ZVAL_UNDEF(&_56$$43); - ZVAL_UNDEF(&_57$$43); - ZVAL_UNDEF(&_50$$44); - ZVAL_UNDEF(&_51$$44); - ZVAL_UNDEF(&_52$$45); - ZVAL_UNDEF(&_53$$45); - ZVAL_UNDEF(&_54$$46); - ZVAL_UNDEF(&_55$$46); - ZVAL_UNDEF(&_58$$47); - ZVAL_UNDEF(&_59$$47); - ZVAL_UNDEF(&_60$$48); - ZVAL_UNDEF(&_61$$48); - ZVAL_UNDEF(&_62$$49); - ZVAL_UNDEF(&_63$$50); - ZVAL_UNDEF(&_64$$51); - ZVAL_UNDEF(&_65$$52); - ZVAL_UNDEF(&_66$$53); - ZVAL_UNDEF(&_67$$54); - ZVAL_UNDEF(&_68$$55); - ZVAL_UNDEF(&_69$$56); - ZVAL_UNDEF(&_70$$57); - ZVAL_UNDEF(&_71$$58); - ZVAL_UNDEF(&_72$$59); - ZVAL_UNDEF(&_73$$60); - ZVAL_UNDEF(&_74$$61); - ZVAL_UNDEF(&_75$$62); - ZVAL_UNDEF(&_76$$63); - ZVAL_UNDEF(&_77$$64); - ZVAL_UNDEF(&_78$$65); - ZVAL_UNDEF(&_79$$66); - ZVAL_UNDEF(&_80$$66); - ZVAL_UNDEF(&_81$$69); - ZVAL_UNDEF(&_82$$69); - ZVAL_UNDEF(&_83$$69); - ZVAL_UNDEF(&_84$$70); - ZVAL_UNDEF(&_85$$70); - ZVAL_UNDEF(&_87$$72); - ZVAL_UNDEF(&_88$$73); - ZVAL_UNDEF(&_89$$74); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(expr) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(quoting) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &expr_param, "ing_param); - zephir_get_arrval(&expr, expr_param); - if (!quoting_param) { - quoting = 1; - } else { - } - ZEPHIR_INIT_VAR(&left); - ZVAL_NULL(&left); - ZEPHIR_INIT_VAR(&right); - ZVAL_NULL(&right); - zephir_memory_observe(&exprType); - if (zephir_array_isset_string_fetch(&exprType, &expr, SL("type"), 0)) { - tempNotQuoting = 1; - if (!ZEPHIR_IS_LONG(&exprType, 409)) { - zephir_memory_observe(&exprLeft); - if (zephir_array_isset_string_fetch(&exprLeft, &expr, SL("left"), 0)) { - if (tempNotQuoting) { - ZVAL_BOOL(&_0$$5, 1); - } else { - ZVAL_BOOL(&_0$$5, 0); - } - ZEPHIR_CALL_METHOD(&left, this_ptr, "getexpression", NULL, 458, &exprLeft, &_0$$5); - zephir_check_call_status(); - } - zephir_memory_observe(&exprRight); - if (zephir_array_isset_string_fetch(&exprRight, &expr, SL("right"), 0)) { - if (tempNotQuoting) { - ZVAL_BOOL(&_1$$6, 1); - } else { - ZVAL_BOOL(&_1$$6, 0); - } - ZEPHIR_CALL_METHOD(&right, this_ptr, "getexpression", NULL, 458, &exprRight, &_1$$6); - zephir_check_call_status(); - } - } - do { - if (ZEPHIR_IS_LONG(&exprType, '<')) { - ZEPHIR_INIT_VAR(&exprReturn); - zephir_create_array(&exprReturn, 4, 0); - add_assoc_stringl_ex(&exprReturn, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&exprReturn, SL("op"), SL("<")); - zephir_array_update_string(&exprReturn, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&exprReturn, SL("right"), &right, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '=')) { - ZEPHIR_INIT_VAR(&_2$$8); - zephir_create_array(&_2$$8, 4, 0); - add_assoc_stringl_ex(&_2$$8, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_2$$8, SL("op"), SL("=")); - zephir_array_update_string(&_2$$8, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_2$$8, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_2$$8); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '>')) { - ZEPHIR_INIT_VAR(&_3$$9); - zephir_create_array(&_3$$9, 4, 0); - add_assoc_stringl_ex(&_3$$9, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_3$$9, SL("op"), SL(">")); - zephir_array_update_string(&_3$$9, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_3$$9, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_3$$9); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 270)) { - ZEPHIR_INIT_VAR(&_4$$10); - zephir_create_array(&_4$$10, 4, 0); - add_assoc_stringl_ex(&_4$$10, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_4$$10, SL("op"), SL("<>")); - zephir_array_update_string(&_4$$10, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_4$$10, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_4$$10); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 271)) { - ZEPHIR_INIT_VAR(&_5$$11); - zephir_create_array(&_5$$11, 4, 0); - add_assoc_stringl_ex(&_5$$11, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_5$$11, SL("op"), SL("<=")); - zephir_array_update_string(&_5$$11, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_5$$11, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_5$$11); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 272)) { - ZEPHIR_INIT_VAR(&_6$$12); - zephir_create_array(&_6$$12, 4, 0); - add_assoc_stringl_ex(&_6$$12, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_6$$12, SL("op"), SL(">=")); - zephir_array_update_string(&_6$$12, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_6$$12, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_6$$12); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 266)) { - ZEPHIR_INIT_VAR(&_7$$13); - zephir_create_array(&_7$$13, 4, 0); - add_assoc_stringl_ex(&_7$$13, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_7$$13, SL("op"), SL("AND")); - zephir_array_update_string(&_7$$13, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_7$$13, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_7$$13); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 267)) { - ZEPHIR_INIT_VAR(&_8$$14); - zephir_create_array(&_8$$14, 4, 0); - add_assoc_stringl_ex(&_8$$14, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_8$$14, SL("op"), SL("OR")); - zephir_array_update_string(&_8$$14, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_8$$14, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_8$$14); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 355)) { - ZEPHIR_CALL_METHOD(&exprReturn, this_ptr, "getqualified", NULL, 459, &expr); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '+')) { - ZEPHIR_INIT_VAR(&_9$$16); - zephir_create_array(&_9$$16, 4, 0); - add_assoc_stringl_ex(&_9$$16, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_9$$16, SL("op"), SL("+")); - zephir_array_update_string(&_9$$16, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_9$$16, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_9$$16); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '-')) { - ZEPHIR_INIT_VAR(&_10$$17); - zephir_create_array(&_10$$17, 4, 0); - add_assoc_stringl_ex(&_10$$17, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_10$$17, SL("op"), SL("-")); - zephir_array_update_string(&_10$$17, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_10$$17, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_10$$17); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '*')) { - ZEPHIR_INIT_VAR(&_11$$18); - zephir_create_array(&_11$$18, 4, 0); - add_assoc_stringl_ex(&_11$$18, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_11$$18, SL("op"), SL("*")); - zephir_array_update_string(&_11$$18, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_11$$18, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_11$$18); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '/')) { - ZEPHIR_INIT_VAR(&_12$$19); - zephir_create_array(&_12$$19, 4, 0); - add_assoc_stringl_ex(&_12$$19, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_12$$19, SL("op"), SL("/")); - zephir_array_update_string(&_12$$19, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_12$$19, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_12$$19); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '%')) { - ZEPHIR_INIT_VAR(&_13$$20); - zephir_create_array(&_13$$20, 4, 0); - add_assoc_stringl_ex(&_13$$20, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_13$$20, SL("op"), SL("%")); - zephir_array_update_string(&_13$$20, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_13$$20, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_13$$20); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '&')) { - ZEPHIR_INIT_VAR(&_14$$21); - zephir_create_array(&_14$$21, 4, 0); - add_assoc_stringl_ex(&_14$$21, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_14$$21, SL("op"), SL("&")); - zephir_array_update_string(&_14$$21, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_14$$21, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_14$$21); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '|')) { - ZEPHIR_INIT_VAR(&_15$$22); - zephir_create_array(&_15$$22, 4, 0); - add_assoc_stringl_ex(&_15$$22, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_15$$22, SL("op"), SL("|")); - zephir_array_update_string(&_15$$22, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_15$$22, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_15$$22); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 356) || ZEPHIR_IS_LONG(&exprType, 407)) { - ZEPHIR_INIT_VAR(&_16$$23); - zephir_create_array(&_16$$23, 2, 0); - add_assoc_stringl_ex(&_16$$23, SL("type"), SL("parentheses")); - zephir_array_update_string(&_16$$23, SL("left"), &left, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_16$$23); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 367)) { - ZEPHIR_INIT_VAR(&_17$$24); - zephir_create_array(&_17$$24, 3, 0); - add_assoc_stringl_ex(&_17$$24, SL("type"), SL("unary-op")); - add_assoc_stringl_ex(&_17$$24, SL("op"), SL("-")); - zephir_array_update_string(&_17$$24, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_17$$24); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 258) || ZEPHIR_IS_LONG(&exprType, 259) || ZEPHIR_IS_LONG(&exprType, 414)) { - ZEPHIR_INIT_VAR(&_18$$25); - zephir_create_array(&_18$$25, 2, 0); - add_assoc_stringl_ex(&_18$$25, SL("type"), SL("literal")); - zephir_memory_observe(&_19$$25); - zephir_array_fetch_string(&_19$$25, &expr, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1774); - zephir_array_update_string(&_18$$25, SL("value"), &_19$$25, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_18$$25); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 334)) { - ZEPHIR_INIT_VAR(&_20$$26); - zephir_create_array(&_20$$26, 2, 0); - add_assoc_stringl_ex(&_20$$26, SL("type"), SL("literal")); - add_assoc_stringl_ex(&_20$$26, SL("value"), SL("TRUE")); - ZEPHIR_CPY_WRT(&exprReturn, &_20$$26); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 335)) { - ZEPHIR_INIT_VAR(&_21$$27); - zephir_create_array(&_21$$27, 2, 0); - add_assoc_stringl_ex(&_21$$27, SL("type"), SL("literal")); - add_assoc_stringl_ex(&_21$$27, SL("value"), SL("FALSE")); - ZEPHIR_CPY_WRT(&exprReturn, &_21$$27); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 260)) { - zephir_memory_observe(&value); - zephir_array_fetch_string(&value, &expr, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1795); - if (quoting) { - if (zephir_memnstr_str(&value, SL("'"), "phalcon/Mvc/Model/Query.zep", 1802)) { - ZEPHIR_INIT_VAR(&escapedValue); - phalcon_orm_singlequotes(&escapedValue, &value); - } else { - ZEPHIR_CPY_WRT(&escapedValue, &value); - } - ZEPHIR_INIT_VAR(&exprValue); - ZEPHIR_CONCAT_SVS(&exprValue, "'", &escapedValue, "'"); - } else { - ZEPHIR_CPY_WRT(&exprValue, &value); - } - ZEPHIR_INIT_VAR(&_22$$28); - zephir_create_array(&_22$$28, 2, 0); - add_assoc_stringl_ex(&_22$$28, SL("type"), SL("literal")); - zephir_array_update_string(&_22$$28, SL("value"), &exprValue, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_22$$28); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 273)) { - ZEPHIR_INIT_VAR(&_23$$33); - zephir_create_array(&_23$$33, 2, 0); - add_assoc_stringl_ex(&_23$$33, SL("type"), SL("placeholder")); - ZEPHIR_INIT_VAR(&_24$$33); - zephir_array_fetch_string(&_25$$33, &expr, SL("value"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1823); - ZEPHIR_INIT_VAR(&_26$$33); - ZVAL_STRING(&_26$$33, "?"); - ZEPHIR_INIT_VAR(&_27$$33); - ZVAL_STRING(&_27$$33, ":"); - zephir_fast_str_replace(&_24$$33, &_26$$33, &_27$$33, &_25$$33); - zephir_array_update_string(&_23$$33, SL("value"), &_24$$33, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_23$$33); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 274)) { - ZEPHIR_INIT_VAR(&_28$$34); - zephir_create_array(&_28$$34, 2, 0); - add_assoc_stringl_ex(&_28$$34, SL("type"), SL("placeholder")); - zephir_array_fetch_string(&_29$$34, &expr, SL("value"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 1832); - ZEPHIR_INIT_VAR(&_30$$34); - ZEPHIR_CONCAT_SV(&_30$$34, ":", &_29$$34); - zephir_array_update_string(&_28$$34, SL("value"), &_30$$34, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_28$$34); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 277)) { - ZEPHIR_OBS_NVAR(&value); - zephir_array_fetch_string(&value, &expr, SL("value"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1837); - if (zephir_memnstr_str(&value, SL(":"), "phalcon/Mvc/Model/Query.zep", 1839)) { - ZEPHIR_INIT_VAR(&valueParts); - zephir_fast_explode_str(&valueParts, SL(":"), &value, LONG_MAX); - zephir_memory_observe(&name); - zephir_array_fetch_long(&name, &valueParts, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1841); - zephir_memory_observe(&bindType); - zephir_array_fetch_long(&bindType, &valueParts, 1, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 1842); - do { - if (ZEPHIR_IS_STRING(&bindType, "str")) { - ZEPHIR_INIT_VAR(&_31$$37); - ZVAL_LONG(&_31$$37, 2); - zephir_update_property_array(this_ptr, SL("bindTypes"), &name, &_31$$37); - ZEPHIR_INIT_VAR(&_32$$37); - zephir_create_array(&_32$$37, 2, 0); - add_assoc_stringl_ex(&_32$$37, SL("type"), SL("placeholder")); - ZEPHIR_INIT_VAR(&_33$$37); - ZEPHIR_CONCAT_SV(&_33$$37, ":", &name); - zephir_array_update_string(&_32$$37, SL("value"), &_33$$37, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_32$$37); - break; - } - if (ZEPHIR_IS_STRING(&bindType, "int")) { - ZEPHIR_INIT_VAR(&_34$$38); - ZVAL_LONG(&_34$$38, 1); - zephir_update_property_array(this_ptr, SL("bindTypes"), &name, &_34$$38); - ZEPHIR_INIT_VAR(&_35$$38); - zephir_create_array(&_35$$38, 2, 0); - add_assoc_stringl_ex(&_35$$38, SL("type"), SL("placeholder")); - ZEPHIR_INIT_VAR(&_36$$38); - ZEPHIR_CONCAT_SV(&_36$$38, ":", &name); - zephir_array_update_string(&_35$$38, SL("value"), &_36$$38, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_35$$38); - break; - } - if (ZEPHIR_IS_STRING(&bindType, "double")) { - ZEPHIR_INIT_VAR(&_37$$39); - ZVAL_LONG(&_37$$39, 32); - zephir_update_property_array(this_ptr, SL("bindTypes"), &name, &_37$$39); - ZEPHIR_INIT_VAR(&_38$$39); - zephir_create_array(&_38$$39, 2, 0); - add_assoc_stringl_ex(&_38$$39, SL("type"), SL("placeholder")); - ZEPHIR_INIT_VAR(&_39$$39); - ZEPHIR_CONCAT_SV(&_39$$39, ":", &name); - zephir_array_update_string(&_38$$39, SL("value"), &_39$$39, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_38$$39); - break; - } - if (ZEPHIR_IS_STRING(&bindType, "bool")) { - ZEPHIR_INIT_VAR(&_40$$40); - ZVAL_LONG(&_40$$40, 5); - zephir_update_property_array(this_ptr, SL("bindTypes"), &name, &_40$$40); - ZEPHIR_INIT_VAR(&_41$$40); - zephir_create_array(&_41$$40, 2, 0); - add_assoc_stringl_ex(&_41$$40, SL("type"), SL("placeholder")); - ZEPHIR_INIT_VAR(&_42$$40); - ZEPHIR_CONCAT_SV(&_42$$40, ":", &name); - zephir_array_update_string(&_41$$40, SL("value"), &_42$$40, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_41$$40); - break; - } - if (ZEPHIR_IS_STRING(&bindType, "blob")) { - ZEPHIR_INIT_VAR(&_43$$41); - ZVAL_LONG(&_43$$41, 3); - zephir_update_property_array(this_ptr, SL("bindTypes"), &name, &_43$$41); - ZEPHIR_INIT_VAR(&_44$$41); - zephir_create_array(&_44$$41, 2, 0); - add_assoc_stringl_ex(&_44$$41, SL("type"), SL("placeholder")); - ZEPHIR_INIT_VAR(&_45$$41); - ZEPHIR_CONCAT_SV(&_45$$41, ":", &name); - zephir_array_update_string(&_44$$41, SL("value"), &_45$$41, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_44$$41); - break; - } - if (ZEPHIR_IS_STRING(&bindType, "null")) { - ZEPHIR_INIT_VAR(&_46$$42); - ZVAL_LONG(&_46$$42, 0); - zephir_update_property_array(this_ptr, SL("bindTypes"), &name, &_46$$42); - ZEPHIR_INIT_VAR(&_47$$42); - zephir_create_array(&_47$$42, 2, 0); - add_assoc_stringl_ex(&_47$$42, SL("type"), SL("placeholder")); - ZEPHIR_INIT_VAR(&_48$$42); - ZEPHIR_CONCAT_SV(&_48$$42, ":", &name); - zephir_array_update_string(&_47$$42, SL("value"), &_48$$42, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_47$$42); - break; - } - if (ZEPHIR_IS_STRING(&bindType, "array") || ZEPHIR_IS_STRING(&bindType, "array-str") || ZEPHIR_IS_STRING(&bindType, "array-int")) { - zephir_memory_observe(&bind); - zephir_read_property(&_49$$43, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(!(zephir_array_isset_fetch(&bind, &_49$$43, &name, 0)))) { - ZEPHIR_INIT_VAR(&_50$$44); - object_init_ex(&_50$$44, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_51$$44); - ZEPHIR_CONCAT_SV(&_51$$44, "Bind value is required for array type placeholder: ", &name); - ZEPHIR_CALL_METHOD(NULL, &_50$$44, "__construct", NULL, 33, &_51$$44); - zephir_check_call_status(); - zephir_throw_exception_debug(&_50$$44, "phalcon/Mvc/Model/Query.zep", 1912); - ZEPHIR_MM_RESTORE(); - return; - } - if (UNEXPECTED(Z_TYPE_P(&bind) != IS_ARRAY)) { - ZEPHIR_INIT_VAR(&_52$$45); - object_init_ex(&_52$$45, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_53$$45); - ZEPHIR_CONCAT_SV(&_53$$45, "Bind type requires an array in placeholder: ", &name); - ZEPHIR_CALL_METHOD(NULL, &_52$$45, "__construct", NULL, 33, &_53$$45); - zephir_check_call_status(); - zephir_throw_exception_debug(&_52$$45, "phalcon/Mvc/Model/Query.zep", 1918); - ZEPHIR_MM_RESTORE(); - return; - } - if (UNEXPECTED(zephir_fast_count_int(&bind) < 1)) { - ZEPHIR_INIT_VAR(&_54$$46); - object_init_ex(&_54$$46, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_55$$46); - ZEPHIR_CONCAT_SV(&_55$$46, "At least one value must be bound in placeholder: ", &name); - ZEPHIR_CALL_METHOD(NULL, &_54$$46, "__construct", NULL, 33, &_55$$46); - zephir_check_call_status(); - zephir_throw_exception_debug(&_54$$46, "phalcon/Mvc/Model/Query.zep", 1924); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_VAR(&_56$$43); - zephir_create_array(&_56$$43, 4, 0); - add_assoc_stringl_ex(&_56$$43, SL("type"), SL("placeholder")); - ZEPHIR_INIT_VAR(&_57$$43); - ZEPHIR_CONCAT_SV(&_57$$43, ":", &name); - zephir_array_update_string(&_56$$43, SL("value"), &_57$$43, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_56$$43, SL("rawValue"), &name, PH_COPY | PH_SEPARATE); - add_assoc_long_ex(&_56$$43, SL("times"), zephir_fast_count_int(&bind)); - ZEPHIR_CPY_WRT(&exprReturn, &_56$$43); - break; - } - ZEPHIR_INIT_VAR(&_58$$47); - object_init_ex(&_58$$47, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_59$$47); - ZEPHIR_CONCAT_SV(&_59$$47, "Unknown bind type: ", &bindType); - ZEPHIR_CALL_METHOD(NULL, &_58$$47, "__construct", NULL, 33, &_59$$47); - zephir_check_call_status(); - zephir_throw_exception_debug(&_58$$47, "phalcon/Mvc/Model/Query.zep", 1939); - ZEPHIR_MM_RESTORE(); - return; - } while(0); - - } else { - ZEPHIR_INIT_VAR(&_60$$48); - zephir_create_array(&_60$$48, 2, 0); - add_assoc_stringl_ex(&_60$$48, SL("type"), SL("placeholder")); - ZEPHIR_INIT_VAR(&_61$$48); - ZEPHIR_CONCAT_SV(&_61$$48, ":", &value); - zephir_array_update_string(&_60$$48, SL("value"), &_61$$48, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_60$$48); - } - break; - } - if (ZEPHIR_IS_LONG(&exprType, 322)) { - ZEPHIR_INIT_VAR(&_62$$49); - zephir_create_array(&_62$$49, 2, 0); - add_assoc_stringl_ex(&_62$$49, SL("type"), SL("literal")); - add_assoc_stringl_ex(&_62$$49, SL("value"), SL("NULL")); - ZEPHIR_CPY_WRT(&exprReturn, &_62$$49); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 268)) { - ZEPHIR_INIT_VAR(&_63$$50); - zephir_create_array(&_63$$50, 4, 0); - add_assoc_stringl_ex(&_63$$50, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_63$$50, SL("op"), SL("LIKE")); - zephir_array_update_string(&_63$$50, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_63$$50, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_63$$50); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 351)) { - ZEPHIR_INIT_VAR(&_64$$51); - zephir_create_array(&_64$$51, 4, 0); - add_assoc_stringl_ex(&_64$$51, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_64$$51, SL("op"), SL("NOT LIKE")); - zephir_array_update_string(&_64$$51, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_64$$51, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_64$$51); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 275)) { - ZEPHIR_INIT_VAR(&_65$$52); - zephir_create_array(&_65$$52, 4, 0); - add_assoc_stringl_ex(&_65$$52, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_65$$52, SL("op"), SL("ILIKE")); - zephir_array_update_string(&_65$$52, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_65$$52, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_65$$52); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 357)) { - ZEPHIR_INIT_VAR(&_66$$53); - zephir_create_array(&_66$$53, 4, 0); - add_assoc_stringl_ex(&_66$$53, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_66$$53, SL("op"), SL("NOT ILIKE")); - zephir_array_update_string(&_66$$53, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_66$$53, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_66$$53); - break; - } - if (ZEPHIR_IS_LONG(&exprType, '!')) { - ZEPHIR_INIT_VAR(&_67$$54); - zephir_create_array(&_67$$54, 3, 0); - add_assoc_stringl_ex(&_67$$54, SL("type"), SL("unary-op")); - add_assoc_stringl_ex(&_67$$54, SL("op"), SL("NOT ")); - zephir_array_update_string(&_67$$54, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_67$$54); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 365)) { - ZEPHIR_INIT_VAR(&_68$$55); - zephir_create_array(&_68$$55, 3, 0); - add_assoc_stringl_ex(&_68$$55, SL("type"), SL("unary-op")); - add_assoc_stringl_ex(&_68$$55, SL("op"), SL(" IS NULL")); - zephir_array_update_string(&_68$$55, SL("left"), &left, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_68$$55); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 366)) { - ZEPHIR_INIT_VAR(&_69$$56); - zephir_create_array(&_69$$56, 3, 0); - add_assoc_stringl_ex(&_69$$56, SL("type"), SL("unary-op")); - add_assoc_stringl_ex(&_69$$56, SL("op"), SL(" IS NOT NULL")); - zephir_array_update_string(&_69$$56, SL("left"), &left, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_69$$56); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 315)) { - ZEPHIR_INIT_VAR(&_70$$57); - zephir_create_array(&_70$$57, 4, 0); - add_assoc_stringl_ex(&_70$$57, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_70$$57, SL("op"), SL("IN")); - zephir_array_update_string(&_70$$57, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_70$$57, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_70$$57); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 323)) { - ZEPHIR_INIT_VAR(&_71$$58); - zephir_create_array(&_71$$58, 4, 0); - add_assoc_stringl_ex(&_71$$58, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_71$$58, SL("op"), SL("NOT IN")); - zephir_array_update_string(&_71$$58, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_71$$58, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_71$$58); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 408)) { - ZEPHIR_INIT_VAR(&_72$$59); - zephir_create_array(&_72$$59, 3, 0); - add_assoc_stringl_ex(&_72$$59, SL("type"), SL("unary-op")); - add_assoc_stringl_ex(&_72$$59, SL("op"), SL("EXISTS")); - zephir_array_update_string(&_72$$59, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_72$$59); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 330)) { - ZEPHIR_INIT_VAR(&_73$$60); - zephir_create_array(&_73$$60, 3, 0); - add_assoc_stringl_ex(&_73$$60, SL("type"), SL("unary-op")); - add_assoc_stringl_ex(&_73$$60, SL("op"), SL("DISTINCT ")); - zephir_array_update_string(&_73$$60, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_73$$60); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 332)) { - ZEPHIR_INIT_VAR(&_74$$61); - zephir_create_array(&_74$$61, 4, 0); - add_assoc_stringl_ex(&_74$$61, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_74$$61, SL("op"), SL("BETWEEN NOT")); - zephir_array_update_string(&_74$$61, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_74$$61, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_74$$61); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 331)) { - ZEPHIR_INIT_VAR(&_75$$62); - zephir_create_array(&_75$$62, 4, 0); - add_assoc_stringl_ex(&_75$$62, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_75$$62, SL("op"), SL("BETWEEN")); - zephir_array_update_string(&_75$$62, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_75$$62, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_75$$62); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 276)) { - ZEPHIR_INIT_VAR(&_76$$63); - zephir_create_array(&_76$$63, 4, 0); - add_assoc_stringl_ex(&_76$$63, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_76$$63, SL("op"), SL("AGAINST")); - zephir_array_update_string(&_76$$63, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_76$$63, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_76$$63); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 333)) { - ZEPHIR_INIT_VAR(&_77$$64); - zephir_create_array(&_77$$64, 3, 0); - add_assoc_stringl_ex(&_77$$64, SL("type"), SL("cast")); - zephir_array_update_string(&_77$$64, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_77$$64, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_77$$64); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 336)) { - ZEPHIR_INIT_VAR(&_78$$65); - zephir_create_array(&_78$$65, 3, 0); - add_assoc_stringl_ex(&_78$$65, SL("type"), SL("convert")); - zephir_array_update_string(&_78$$65, SL("left"), &left, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_78$$65, SL("right"), &right, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_78$$65); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 358)) { - ZEPHIR_INIT_VAR(&_79$$66); - zephir_create_array(&_79$$66, 2, 0); - add_assoc_stringl_ex(&_79$$66, SL("type"), SL("literal")); - zephir_memory_observe(&_80$$66); - zephir_array_fetch_string(&_80$$66, &expr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2115); - zephir_array_update_string(&_79$$66, SL("value"), &_80$$66, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_79$$66); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 350)) { - ZEPHIR_CALL_METHOD(&exprReturn, this_ptr, "getfunctioncall", NULL, 460, &expr); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 409)) { - ZEPHIR_CALL_METHOD(&exprReturn, this_ptr, "getcaseexpression", NULL, 461, &expr); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_LONG(&exprType, 309)) { - ZEPHIR_INIT_VAR(&_81$$69); - zephir_create_array(&_81$$69, 2, 0); - add_assoc_stringl_ex(&_81$$69, SL("type"), SL("select")); - ZVAL_BOOL(&_83$$69, 1); - ZEPHIR_CALL_METHOD(&_82$$69, this_ptr, "_prepareselect", NULL, 450, &expr, &_83$$69); - zephir_check_call_status(); - zephir_array_update_string(&_81$$69, SL("value"), &_82$$69, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&exprReturn, &_81$$69); - break; - } - ZEPHIR_INIT_VAR(&_84$$70); - object_init_ex(&_84$$70, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_85$$70); - ZEPHIR_CONCAT_SV(&_85$$70, "Unknown expression type ", &exprType); - ZEPHIR_CALL_METHOD(NULL, &_84$$70, "__construct", NULL, 33, &_85$$70); - zephir_check_call_status(); - zephir_throw_exception_debug(&_84$$70, "phalcon/Mvc/Model/Query.zep", 2138); - ZEPHIR_MM_RESTORE(); - return; - } while(0); - - RETURN_CCTOR(&exprReturn); - } - if (zephir_array_isset_string(&expr, SL("domain"))) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getqualified", NULL, 459, &expr); - zephir_check_call_status(); - RETURN_MM(); - } - if (zephir_array_isset_long(&expr, 0)) { - ZEPHIR_INIT_VAR(&listItems); - array_init(&listItems); - zephir_is_iterable(&expr, 0, "phalcon/Mvc/Model/Query.zep", 2161); - if (Z_TYPE_P(&expr) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&expr), _86$$72) - { - ZEPHIR_INIT_NVAR(&exprListItem); - ZVAL_COPY(&exprListItem, _86$$72); - ZEPHIR_CALL_METHOD(&_88$$73, this_ptr, "getexpression", NULL, 458, &exprListItem); - zephir_check_call_status(); - zephir_array_append(&listItems, &_88$$73, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2158); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &expr, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_87$$72, &expr, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_87$$72)) { - break; - } - ZEPHIR_CALL_METHOD(&exprListItem, &expr, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_89$$74, this_ptr, "getexpression", NULL, 458, &exprListItem); - zephir_check_call_status(); - zephir_array_append(&listItems, &_89$$74, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2158); - ZEPHIR_CALL_METHOD(NULL, &expr, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&exprListItem); - zephir_create_array(return_value, 2, 0); - add_assoc_stringl_ex(return_value, SL("type"), SL("list")); - zephir_array_fast_append(return_value, &listItems); - RETURN_MM(); - } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Unknown expression", "phalcon/Mvc/Model/Query.zep", 2167); - return; + phql_ret_distinct_all(&ppgotominor.pp202, 1); + pp_destructor(29,&ppmsp[0].minor); } - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getFunctionCall) +// 1312 "parser.php.c" + break; + case 8: +// 158 "parser.php.lemon" { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, distinct = 0; - zval *expr_param = NULL, arguments, argument, _10, *_0$$6, _1$$6, _2$$7, _4$$8, _5$$9, _6$$9, _7$$10, _8$$10, _9$$11; - zval expr, functionArgs; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&functionArgs); - ZVAL_UNDEF(&arguments); - ZVAL_UNDEF(&argument); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_1$$6); - ZVAL_UNDEF(&_2$$7); - ZVAL_UNDEF(&_4$$8); - ZVAL_UNDEF(&_5$$9); - ZVAL_UNDEF(&_6$$9); - ZVAL_UNDEF(&_7$$10); - ZVAL_UNDEF(&_8$$10); - ZVAL_UNDEF(&_9$$11); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(expr) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &expr_param); - ZEPHIR_OBS_COPY_OR_DUP(&expr, expr_param); - zephir_memory_observe(&arguments); - if (zephir_array_isset_string_fetch(&arguments, &expr, SL("arguments"), 0)) { - if (zephir_array_isset_string(&expr, SL("distinct"))) { - distinct = 1; - } else { - distinct = 0; - } - if (zephir_array_isset_long(&arguments, 0)) { - ZEPHIR_INIT_VAR(&functionArgs); - array_init(&functionArgs); - zephir_is_iterable(&arguments, 0, "phalcon/Mvc/Model/Query.zep", 2193); - if (Z_TYPE_P(&arguments) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&arguments), _0$$6) - { - ZEPHIR_INIT_NVAR(&argument); - ZVAL_COPY(&argument, _0$$6); - ZEPHIR_CALL_METHOD(&_2$$7, this_ptr, "getcallargument", &_3, 462, &argument); - zephir_check_call_status(); - zephir_array_append(&functionArgs, &_2$$7, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2191); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &arguments, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1$$6, &arguments, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1$$6)) { - break; - } - ZEPHIR_CALL_METHOD(&argument, &arguments, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$8, this_ptr, "getcallargument", &_3, 462, &argument); - zephir_check_call_status(); - zephir_array_append(&functionArgs, &_4$$8, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2191); - ZEPHIR_CALL_METHOD(NULL, &arguments, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&argument); - } else { - ZEPHIR_INIT_VAR(&_5$$9); - zephir_create_array(&_5$$9, 1, 0); - ZEPHIR_CALL_METHOD(&_6$$9, this_ptr, "getcallargument", &_3, 462, &arguments); - zephir_check_call_status(); - zephir_array_fast_append(&_5$$9, &_6$$9); - ZEPHIR_CPY_WRT(&functionArgs, &_5$$9); - } - if (distinct) { - zephir_create_array(return_value, 4, 0); - add_assoc_stringl_ex(return_value, SL("type"), SL("functionCall")); - zephir_memory_observe(&_7$$10); - zephir_array_fetch_string(&_7$$10, &expr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2203); - zephir_array_update_string(return_value, SL("name"), &_7$$10, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("arguments"), &functionArgs, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_8$$10); - ZVAL_LONG(&_8$$10, distinct); - zephir_array_update_string(return_value, SL("distinct"), &_8$$10, PH_COPY | PH_SEPARATE); - RETURN_MM(); - } else { - zephir_create_array(return_value, 3, 0); - add_assoc_stringl_ex(return_value, SL("type"), SL("functionCall")); - zephir_memory_observe(&_9$$11); - zephir_array_fetch_string(&_9$$11, &expr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2210); - zephir_array_update_string(return_value, SL("name"), &_9$$11, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("arguments"), &functionArgs, PH_COPY | PH_SEPARATE); - RETURN_MM(); - } - } - zephir_create_array(return_value, 2, 0); - add_assoc_stringl_ex(return_value, SL("type"), SL("functionCall")); - zephir_memory_observe(&_10); - zephir_array_fetch_string(&_10, &expr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2219); - zephir_array_update_string(return_value, SL("name"), &_10, PH_COPY | PH_SEPARATE); - RETURN_MM(); + phql_ret_distinct_all(&ppgotominor.pp202, 0); + pp_destructor(30,&ppmsp[0].minor); } - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getGroupClause) +// 1320 "parser.php.c" + break; + case 9: + case 20: + case 27: + case 38: + case 69: + case 71: + case 78: + case 83: + case 85: + case 89: + case 91: + case 135: + case 137: +// 162 "parser.php.lemon" { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *group_param = NULL, groupItem, *_0$$3, _1$$3, _2$$4, _4$$5, _5$$6, _6$$6; - zval group, groupParts; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&group); - ZVAL_UNDEF(&groupParts); - ZVAL_UNDEF(&groupItem); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_6$$6); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(group) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &group_param); - ZEPHIR_OBS_COPY_OR_DUP(&group, group_param); - if (zephir_array_isset_long(&group, 0)) { - ZEPHIR_INIT_VAR(&groupParts); - array_init(&groupParts); - zephir_is_iterable(&group, 0, "phalcon/Mvc/Model/Query.zep", 2239); - if (Z_TYPE_P(&group) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&group), _0$$3) - { - ZEPHIR_INIT_NVAR(&groupItem); - ZVAL_COPY(&groupItem, _0$$3); - ZEPHIR_CALL_METHOD(&_2$$4, this_ptr, "getexpression", &_3, 458, &groupItem); - zephir_check_call_status(); - zephir_array_append(&groupParts, &_2$$4, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2237); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &group, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1$$3, &group, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&groupItem, &group, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$5, this_ptr, "getexpression", &_3, 458, &groupItem); - zephir_check_call_status(); - zephir_array_append(&groupParts, &_4$$5, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2237); - ZEPHIR_CALL_METHOD(NULL, &group, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&groupItem); - } else { - ZEPHIR_INIT_VAR(&_5$$6); - zephir_create_array(&_5$$6, 1, 0); - ZEPHIR_CALL_METHOD(&_6$$6, this_ptr, "getexpression", &_3, 458, &group); - zephir_check_call_status(); - zephir_array_fast_append(&_5$$6, &_6$$6); - ZEPHIR_CPY_WRT(&groupParts, &_5$$6); - } - RETURN_CTOR(&groupParts); + ZVAL_UNDEF(&ppgotominor.pp202); } - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getLimitClause) +// 1339 "parser.php.c" + break; + case 10: + case 17: + case 41: + case 44: + case 49: + case 64: + case 72: + case 79: + case 138: +// 170 "parser.php.lemon" { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *limitClause_param = NULL, number, offset, _0$$3, _1$$4; - zval limitClause, limit; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&limitClause); - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&number); - ZVAL_UNDEF(&offset); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$4); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(limitClause) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &limitClause_param); - ZEPHIR_OBS_COPY_OR_DUP(&limitClause, limitClause_param); - ZEPHIR_INIT_VAR(&limit); - array_init(&limit); - zephir_memory_observe(&number); - if (zephir_array_isset_string_fetch(&number, &limitClause, SL("number"), 0)) { - ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "getexpression", NULL, 458, &number); - zephir_check_call_status(); - zephir_array_update_string(&limit, SL("number"), &_0$$3, PH_COPY | PH_SEPARATE); - } - zephir_memory_observe(&offset); - if (zephir_array_isset_string_fetch(&offset, &limitClause, SL("offset"), 0)) { - ZEPHIR_CALL_METHOD(&_1$$4, this_ptr, "getexpression", NULL, 458, &offset); - zephir_check_call_status(); - zephir_array_update_string(&limit, SL("offset"), &_1$$4, PH_COPY | PH_SEPARATE); - } - RETURN_CTOR(&limit); + phql_ret_zval_list(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(26,&ppmsp[-1].minor); } - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getJoin) +// 1355 "parser.php.c" + break; + case 11: + case 42: + case 45: + case 129: + case 139: +// 174 "parser.php.lemon" { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval join; - zval *manager, manager_sub, *join_param = NULL, qualified, modelName, source, model, schema, _0$$3; - - ZVAL_UNDEF(&manager_sub); - ZVAL_UNDEF(&qualified); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&join); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(manager, phalcon_mvc_model_managerinterface_ce) - Z_PARAM_ARRAY(join) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &manager, &join_param); - zephir_get_arrval(&join, join_param); - zephir_memory_observe(&qualified); - if (zephir_array_isset_string_fetch(&qualified, &join, SL("qualified"), 0)) { - zephir_array_fetch_string(&_0$$3, &qualified, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2275); - if (ZEPHIR_IS_LONG(&_0$$3, 355)) { - zephir_memory_observe(&modelName); - zephir_array_fetch_string(&modelName, &qualified, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2276); - ZEPHIR_CALL_METHOD(&model, manager, "load", NULL, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); - zephir_check_call_status(); - zephir_create_array(return_value, 4, 0); - zephir_array_update_string(return_value, SL("schema"), &schema, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("source"), &source, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("modelName"), &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("model"), &model, PH_COPY | PH_SEPARATE); - RETURN_MM(); - } - } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 2291); - return; + phql_ret_zval_list(&ppgotominor.pp202, &ppmsp[0].minor.pp202, NULL); } - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getJoinType) +// 1366 "parser.php.c" + break; + case 12: + case 140: +// 182 "parser.php.lemon" { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *join_param = NULL, type, _0, _1, _2; - zval join; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&join); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(join) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &join_param); - zephir_get_arrval(&join, join_param); - zephir_memory_observe(&type); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&type, &join, SL("type"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 2302); - return; - } - do { - if (ZEPHIR_IS_LONG(&type, 360)) { - RETURN_MM_STRING("INNER"); - } - if (ZEPHIR_IS_LONG(&type, 361)) { - RETURN_MM_STRING("LEFT"); - } - if (ZEPHIR_IS_LONG(&type, 362)) { - RETURN_MM_STRING("RIGHT"); - } - if (ZEPHIR_IS_LONG(&type, 363)) { - RETURN_MM_STRING("CROSS"); - } - if (ZEPHIR_IS_LONG(&type, 364)) { - RETURN_MM_STRING("FULL OUTER"); - } - } while(0); - - ZEPHIR_INIT_VAR(&_0); - object_init_ex(&_0, phalcon_mvc_model_exception_ce); - zephir_read_property(&_1, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_SVSV(&_2, "Unknown join type ", &type, ", when preparing: ", &_1); - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 33, &_2); - zephir_check_call_status(); - zephir_throw_exception_debug(&_0, "phalcon/Mvc/Model/Query.zep", 2324); - ZEPHIR_MM_RESTORE(); - return; + phql_ret_column_item(&ppgotominor.pp202, PHQL_T_STARALL, NULL, NULL, NULL); + pp_destructor(18,&ppmsp[0].minor); } - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getJoins) +// 1375 "parser.php.c" + break; + case 13: +// 186 "parser.php.lemon" { - zend_string *_22, *_45, *_30$$21, *_49$$26, *_79$$55; - zend_ulong _21, _44, _29$$21, _48$$26, _78$$55; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL, *_8 = NULL, *_24 = NULL, *_50 = NULL, *_51 = NULL, *_56 = NULL, *_57 = NULL, *_64 = NULL, *_65 = NULL, *_80 = NULL, *_81 = NULL, *_92 = NULL, *_93 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *select_param = NULL, __$true, models, sqlAliases, sqlAliasesModels, sqlModelsAliases, sqlAliasesModelsInstances, modelsInstances, fromModels, manager, selectJoins, joinItem, joins, joinData, schema, source, model, realModelName, completeSource, joinType, aliasExpr, alias, joinAliasName, joinExpr, fromModelName, joinAlias, joinModel, joinSource, preCondition, modelNameAlias, relation, relations, modelAlias, sqlJoin, sqlJoinItem, selectTables, tables, tableItem, _0, *_1, _2, *_19, _20, *_35, _36, _41, *_42, _43, _5$$9, _6$$9, _7$$9, _9$$11, _10$$11, _11$$11, _12$$12, _13$$14, _14$$14, _15$$14, _16$$16, _17$$16, _18$$16, _23$$18, _25$$20, _26$$21, *_27$$21, _28$$21, _37$$24, _38$$24, _39$$25, _40$$25, *_46$$26, _47$$26, _52$$31, _53$$31, _54$$31, _55$$32, *_58$$35, _59$$35, _61$$39, _66$$45, _67$$45, _68$$45, _69$$46, *_70$$49, _71$$49, _73$$53, *_76$$55, _77$$55, _82$$60, _83$$60, _84$$60, _85$$61, *_86$$64, _87$$64, _89$$68, _94$$74, _95$$74, _96$$74, _97$$75, *_98$$78, _99$$78, _101$$82; - zval select, sqlJoins, joinModels, joinSources, joinTypes, joinPreCondition, joinPrepared, _31$$22, _32$$22, _33$$23, _34$$23, _60$$39, _62$$40, _63$$40, _72$$53, _74$$54, _75$$54, _88$$68, _90$$69, _91$$69, _100$$82, _102$$83, _103$$83; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&select); - ZVAL_UNDEF(&sqlJoins); - ZVAL_UNDEF(&joinModels); - ZVAL_UNDEF(&joinSources); - ZVAL_UNDEF(&joinTypes); - ZVAL_UNDEF(&joinPreCondition); - ZVAL_UNDEF(&joinPrepared); - ZVAL_UNDEF(&_31$$22); - ZVAL_UNDEF(&_32$$22); - ZVAL_UNDEF(&_33$$23); - ZVAL_UNDEF(&_34$$23); - ZVAL_UNDEF(&_60$$39); - ZVAL_UNDEF(&_62$$40); - ZVAL_UNDEF(&_63$$40); - ZVAL_UNDEF(&_72$$53); - ZVAL_UNDEF(&_74$$54); - ZVAL_UNDEF(&_75$$54); - ZVAL_UNDEF(&_88$$68); - ZVAL_UNDEF(&_90$$69); - ZVAL_UNDEF(&_91$$69); - ZVAL_UNDEF(&_100$$82); - ZVAL_UNDEF(&_102$$83); - ZVAL_UNDEF(&_103$$83); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&sqlAliases); - ZVAL_UNDEF(&sqlAliasesModels); - ZVAL_UNDEF(&sqlModelsAliases); - ZVAL_UNDEF(&sqlAliasesModelsInstances); - ZVAL_UNDEF(&modelsInstances); - ZVAL_UNDEF(&fromModels); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&selectJoins); - ZVAL_UNDEF(&joinItem); - ZVAL_UNDEF(&joins); - ZVAL_UNDEF(&joinData); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&realModelName); - ZVAL_UNDEF(&completeSource); - ZVAL_UNDEF(&joinType); - ZVAL_UNDEF(&aliasExpr); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&joinAliasName); - ZVAL_UNDEF(&joinExpr); - ZVAL_UNDEF(&fromModelName); - ZVAL_UNDEF(&joinAlias); - ZVAL_UNDEF(&joinModel); - ZVAL_UNDEF(&joinSource); - ZVAL_UNDEF(&preCondition); - ZVAL_UNDEF(&modelNameAlias); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&relations); - ZVAL_UNDEF(&modelAlias); - ZVAL_UNDEF(&sqlJoin); - ZVAL_UNDEF(&sqlJoinItem); - ZVAL_UNDEF(&selectTables); - ZVAL_UNDEF(&tables); - ZVAL_UNDEF(&tableItem); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_20); - ZVAL_UNDEF(&_36); - ZVAL_UNDEF(&_41); - ZVAL_UNDEF(&_43); - ZVAL_UNDEF(&_5$$9); - ZVAL_UNDEF(&_6$$9); - ZVAL_UNDEF(&_7$$9); - ZVAL_UNDEF(&_9$$11); - ZVAL_UNDEF(&_10$$11); - ZVAL_UNDEF(&_11$$11); - ZVAL_UNDEF(&_12$$12); - ZVAL_UNDEF(&_13$$14); - ZVAL_UNDEF(&_14$$14); - ZVAL_UNDEF(&_15$$14); - ZVAL_UNDEF(&_16$$16); - ZVAL_UNDEF(&_17$$16); - ZVAL_UNDEF(&_18$$16); - ZVAL_UNDEF(&_23$$18); - ZVAL_UNDEF(&_25$$20); - ZVAL_UNDEF(&_26$$21); - ZVAL_UNDEF(&_28$$21); - ZVAL_UNDEF(&_37$$24); - ZVAL_UNDEF(&_38$$24); - ZVAL_UNDEF(&_39$$25); - ZVAL_UNDEF(&_40$$25); - ZVAL_UNDEF(&_47$$26); - ZVAL_UNDEF(&_52$$31); - ZVAL_UNDEF(&_53$$31); - ZVAL_UNDEF(&_54$$31); - ZVAL_UNDEF(&_55$$32); - ZVAL_UNDEF(&_59$$35); - ZVAL_UNDEF(&_61$$39); - ZVAL_UNDEF(&_66$$45); - ZVAL_UNDEF(&_67$$45); - ZVAL_UNDEF(&_68$$45); - ZVAL_UNDEF(&_69$$46); - ZVAL_UNDEF(&_71$$49); - ZVAL_UNDEF(&_73$$53); - ZVAL_UNDEF(&_77$$55); - ZVAL_UNDEF(&_82$$60); - ZVAL_UNDEF(&_83$$60); - ZVAL_UNDEF(&_84$$60); - ZVAL_UNDEF(&_85$$61); - ZVAL_UNDEF(&_87$$64); - ZVAL_UNDEF(&_89$$68); - ZVAL_UNDEF(&_94$$74); - ZVAL_UNDEF(&_95$$74); - ZVAL_UNDEF(&_96$$74); - ZVAL_UNDEF(&_97$$75); - ZVAL_UNDEF(&_99$$78); - ZVAL_UNDEF(&_101$$82); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(select) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &select_param); - zephir_get_arrval(&select, select_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&models, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("sqlAliases"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&sqlAliases, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("sqlAliasesModels"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&sqlAliasesModels, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("sqlModelsAliases"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&sqlModelsAliases, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&sqlAliasesModelsInstances, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&modelsInstances, &_0); - ZEPHIR_CPY_WRT(&fromModels, &models); - ZEPHIR_INIT_VAR(&sqlJoins); - array_init(&sqlJoins); - ZEPHIR_INIT_VAR(&joinModels); - array_init(&joinModels); - ZEPHIR_INIT_VAR(&joinSources); - array_init(&joinSources); - ZEPHIR_INIT_VAR(&joinTypes); - array_init(&joinTypes); - ZEPHIR_INIT_VAR(&joinPreCondition); - array_init(&joinPreCondition); - ZEPHIR_INIT_VAR(&joinPrepared); - array_init(&joinPrepared); - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - zephir_memory_observe(&tables); - zephir_array_fetch_string(&tables, &select, SL("tables"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2360); - if (!(zephir_array_isset_long(&tables, 0))) { - ZEPHIR_INIT_VAR(&selectTables); - zephir_create_array(&selectTables, 1, 0); - zephir_array_fast_append(&selectTables, &tables); - } else { - ZEPHIR_CPY_WRT(&selectTables, &tables); - } - zephir_memory_observe(&joins); - zephir_array_fetch_string(&joins, &select, SL("joins"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2368); - if (!(zephir_array_isset_long(&joins, 0))) { - ZEPHIR_INIT_VAR(&selectJoins); - zephir_create_array(&selectJoins, 1, 0); - zephir_array_fast_append(&selectJoins, &joins); - } else { - ZEPHIR_CPY_WRT(&selectJoins, &joins); - } - zephir_is_iterable(&selectJoins, 0, "phalcon/Mvc/Model/Query.zep", 2519); - if (Z_TYPE_P(&selectJoins) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&selectJoins), _1) - { - ZEPHIR_INIT_NVAR(&joinItem); - ZVAL_COPY(&joinItem, _1); - ZEPHIR_CALL_METHOD(&joinData, this_ptr, "getjoin", &_3, 463, &manager, &joinItem); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&source); - zephir_array_fetch_string(&source, &joinData, SL("source"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2382); - ZEPHIR_OBS_NVAR(&schema); - zephir_array_fetch_string(&schema, &joinData, SL("schema"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2383); - ZEPHIR_OBS_NVAR(&model); - zephir_array_fetch_string(&model, &joinData, SL("model"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2384); - ZEPHIR_OBS_NVAR(&realModelName); - zephir_array_fetch_string(&realModelName, &joinData, SL("modelName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2385); - ZEPHIR_INIT_NVAR(&completeSource); - zephir_create_array(&completeSource, 2, 0); - zephir_array_fast_append(&completeSource, &source); - zephir_array_fast_append(&completeSource, &schema); - ZEPHIR_CALL_METHOD(&joinType, this_ptr, "getjointype", &_4, 464, &joinItem); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&aliasExpr); - if (zephir_array_isset_string_fetch(&aliasExpr, &joinItem, SL("alias"), 0)) { - ZEPHIR_OBS_NVAR(&alias); - zephir_array_fetch_string(&alias, &aliasExpr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2397); - if (UNEXPECTED(zephir_array_isset(&joinModels, &alias))) { - ZEPHIR_INIT_NVAR(&_5$$9); - object_init_ex(&_5$$9, phalcon_mvc_model_exception_ce); - zephir_read_property(&_6$$9, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_7$$9); - ZEPHIR_CONCAT_SVSV(&_7$$9, "Cannot use '", &alias, "' as join alias because it was already used, when preparing: ", &_6$$9); - ZEPHIR_CALL_METHOD(NULL, &_5$$9, "__construct", &_8, 33, &_7$$9); - zephir_check_call_status(); - zephir_throw_exception_debug(&_5$$9, "phalcon/Mvc/Model/Query.zep", 2405); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2411); - zephir_array_update_zval(&joinTypes, &alias, &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinModels, &alias, &realModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlModelsAliases, &realModelName, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModels, &alias, &realModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &realModelName, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinSources, &alias, &completeSource, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinPrepared, &alias, &joinItem, PH_COPY | PH_SEPARATE); - } else { - if (UNEXPECTED(zephir_array_isset(&joinModels, &realModelName))) { - ZEPHIR_INIT_NVAR(&_9$$11); - object_init_ex(&_9$$11, phalcon_mvc_model_exception_ce); - zephir_read_property(&_10$$11, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_11$$11); - ZEPHIR_CONCAT_SVSV(&_11$$11, "Cannot use '", &realModelName, "' as join alias because it was already used, when preparing: ", &_10$$11); - ZEPHIR_CALL_METHOD(NULL, &_9$$11, "__construct", &_8, 33, &_11$$11); - zephir_check_call_status(); - zephir_throw_exception_debug(&_9$$11, "phalcon/Mvc/Model/Query.zep", 2464); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_update_zval(&joinTypes, &realModelName, &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliases, &realModelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinModels, &realModelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlModelsAliases, &realModelName, &realModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModels, &realModelName, &realModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &realModelName, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &realModelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinSources, &realModelName, &completeSource, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinPrepared, &realModelName, &joinItem, PH_COPY | PH_SEPARATE); - } - zephir_array_update_zval(&modelsInstances, &realModelName, &model, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &selectJoins, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &selectJoins, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&joinItem, &selectJoins, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&joinData, this_ptr, "getjoin", &_3, 463, &manager, &joinItem); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&source); - zephir_array_fetch_string(&source, &joinData, SL("source"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2382); - ZEPHIR_OBS_NVAR(&schema); - zephir_array_fetch_string(&schema, &joinData, SL("schema"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2383); - ZEPHIR_OBS_NVAR(&model); - zephir_array_fetch_string(&model, &joinData, SL("model"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2384); - ZEPHIR_OBS_NVAR(&realModelName); - zephir_array_fetch_string(&realModelName, &joinData, SL("modelName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2385); - ZEPHIR_INIT_NVAR(&_12$$12); - zephir_create_array(&_12$$12, 2, 0); - zephir_array_fast_append(&_12$$12, &source); - zephir_array_fast_append(&_12$$12, &schema); - ZEPHIR_CPY_WRT(&completeSource, &_12$$12); - ZEPHIR_CALL_METHOD(&joinType, this_ptr, "getjointype", &_4, 464, &joinItem); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&aliasExpr); - if (zephir_array_isset_string_fetch(&aliasExpr, &joinItem, SL("alias"), 0)) { - ZEPHIR_OBS_NVAR(&alias); - zephir_array_fetch_string(&alias, &aliasExpr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2397); - if (UNEXPECTED(zephir_array_isset(&joinModels, &alias))) { - ZEPHIR_INIT_NVAR(&_13$$14); - object_init_ex(&_13$$14, phalcon_mvc_model_exception_ce); - zephir_read_property(&_14$$14, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_15$$14); - ZEPHIR_CONCAT_SVSV(&_15$$14, "Cannot use '", &alias, "' as join alias because it was already used, when preparing: ", &_14$$14); - ZEPHIR_CALL_METHOD(NULL, &_13$$14, "__construct", &_8, 33, &_15$$14); - zephir_check_call_status(); - zephir_throw_exception_debug(&_13$$14, "phalcon/Mvc/Model/Query.zep", 2405); - ZEPHIR_MM_RESTORE(); - return; + phql_ret_column_item(&ppgotominor.pp202, PHQL_T_DOMAINALL, NULL, ppmsp[-2].minor.pp0, NULL); + pp_destructor(32,&ppmsp[-1].minor); + pp_destructor(18,&ppmsp[0].minor); +} +// 1384 "parser.php.c" + break; + case 14: +// 190 "parser.php.lemon" +{ + phql_ret_column_item(&ppgotominor.pp202, PHQL_T_EXPR, &ppmsp[-2].minor.pp202, NULL, ppmsp[0].minor.pp0); + pp_destructor(33,&ppmsp[-1].minor); +} +// 1392 "parser.php.c" + break; + case 15: +// 194 "parser.php.lemon" +{ + phql_ret_column_item(&ppgotominor.pp202, PHQL_T_EXPR, &ppmsp[-1].minor.pp202, NULL, ppmsp[0].minor.pp0); +} +// 1399 "parser.php.c" + break; + case 16: +// 198 "parser.php.lemon" +{ + phql_ret_column_item(&ppgotominor.pp202, PHQL_T_EXPR, &ppmsp[0].minor.pp202, NULL, NULL); +} +// 1406 "parser.php.c" + break; + case 21: + case 128: +// 226 "parser.php.lemon" +{ + phql_ret_zval_list(&ppgotominor.pp202, &ppmsp[-1].minor.pp202, &ppmsp[0].minor.pp202); +} +// 1414 "parser.php.c" + break; + case 24: +// 247 "parser.php.lemon" +{ + phql_ret_join_item(&ppgotominor.pp202, &ppmsp[-3].minor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[-1].minor.pp202, &ppmsp[0].minor.pp202); +} +// 1421 "parser.php.c" + break; + case 25: +// 255 "parser.php.lemon" +{ + phql_ret_qualified_name(&ppgotominor.pp202, NULL, NULL, ppmsp[0].minor.pp0); + pp_destructor(33,&ppmsp[-1].minor); +} +// 1429 "parser.php.c" + break; + case 26: + case 46: + case 66: + case 161: +// 259 "parser.php.lemon" +{ + phql_ret_qualified_name(&ppgotominor.pp202, NULL, NULL, ppmsp[0].minor.pp0); +} +// 1439 "parser.php.c" + break; + case 28: +// 271 "parser.php.lemon" +{ + phql_ret_join_type(&ppgotominor.pp202, PHQL_T_INNERJOIN); + pp_destructor(34,&ppmsp[-1].minor); + pp_destructor(35,&ppmsp[0].minor); +} +// 1448 "parser.php.c" + break; + case 29: +// 275 "parser.php.lemon" +{ + phql_ret_join_type(&ppgotominor.pp202, PHQL_T_CROSSJOIN); + pp_destructor(36,&ppmsp[-1].minor); + pp_destructor(35,&ppmsp[0].minor); +} +// 1457 "parser.php.c" + break; + case 30: +// 279 "parser.php.lemon" +{ + phql_ret_join_type(&ppgotominor.pp202, PHQL_T_LEFTJOIN); + pp_destructor(37,&ppmsp[-2].minor); + pp_destructor(38,&ppmsp[-1].minor); + pp_destructor(35,&ppmsp[0].minor); +} +// 1467 "parser.php.c" + break; + case 31: +// 283 "parser.php.lemon" +{ + phql_ret_join_type(&ppgotominor.pp202, PHQL_T_LEFTJOIN); + pp_destructor(37,&ppmsp[-1].minor); + pp_destructor(35,&ppmsp[0].minor); +} +// 1476 "parser.php.c" + break; + case 32: +// 287 "parser.php.lemon" +{ + phql_ret_join_type(&ppgotominor.pp202, PHQL_T_RIGHTJOIN); + pp_destructor(39,&ppmsp[-2].minor); + pp_destructor(38,&ppmsp[-1].minor); + pp_destructor(35,&ppmsp[0].minor); +} +// 1486 "parser.php.c" + break; + case 33: +// 291 "parser.php.lemon" +{ + phql_ret_join_type(&ppgotominor.pp202, PHQL_T_RIGHTJOIN); + pp_destructor(39,&ppmsp[-1].minor); + pp_destructor(35,&ppmsp[0].minor); +} +// 1495 "parser.php.c" + break; + case 34: +// 295 "parser.php.lemon" +{ + phql_ret_join_type(&ppgotominor.pp202, PHQL_T_FULLJOIN); + pp_destructor(40,&ppmsp[-2].minor); + pp_destructor(38,&ppmsp[-1].minor); + pp_destructor(35,&ppmsp[0].minor); +} +// 1505 "parser.php.c" + break; + case 35: +// 299 "parser.php.lemon" +{ + phql_ret_join_type(&ppgotominor.pp202, PHQL_T_FULLJOIN); + pp_destructor(40,&ppmsp[-1].minor); + pp_destructor(35,&ppmsp[0].minor); +} +// 1514 "parser.php.c" + break; + case 36: +// 303 "parser.php.lemon" +{ + phql_ret_join_type(&ppgotominor.pp202, PHQL_T_INNERJOIN); + pp_destructor(35,&ppmsp[0].minor); +} +// 1522 "parser.php.c" + break; + case 37: +// 311 "parser.php.lemon" +{ + ppgotominor.pp202 = ppmsp[0].minor.pp202; + pp_destructor(41,&ppmsp[-1].minor); +} +// 1530 "parser.php.c" + break; + case 39: +// 324 "parser.php.lemon" +{ + phql_ret_insert_statement(&ppgotominor.pp202, &ppmsp[-4].minor.pp202, NULL, &ppmsp[-1].minor.pp202); + pp_destructor(42,&ppmsp[-6].minor); + pp_destructor(43,&ppmsp[-5].minor); + pp_destructor(44,&ppmsp[-3].minor); + pp_destructor(45,&ppmsp[-2].minor); + pp_destructor(46,&ppmsp[0].minor); +} +// 1542 "parser.php.c" + break; + case 40: +// 328 "parser.php.lemon" +{ + phql_ret_insert_statement(&ppgotominor.pp202, &ppmsp[-7].minor.pp202, &ppmsp[-5].minor.pp202, &ppmsp[-1].minor.pp202); + pp_destructor(42,&ppmsp[-9].minor); + pp_destructor(43,&ppmsp[-8].minor); + pp_destructor(45,&ppmsp[-6].minor); + pp_destructor(46,&ppmsp[-4].minor); + pp_destructor(44,&ppmsp[-3].minor); + pp_destructor(45,&ppmsp[-2].minor); + pp_destructor(46,&ppmsp[0].minor); +} +// 1556 "parser.php.c" + break; + case 47: +// 374 "parser.php.lemon" +{ + phql_ret_update_statement(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[-1].minor.pp202, &ppmsp[0].minor.pp202); +} +// 1563 "parser.php.c" + break; + case 48: +// 382 "parser.php.lemon" +{ + phql_ret_update_clause(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(47,&ppmsp[-3].minor); + pp_destructor(48,&ppmsp[-1].minor); +} +// 1572 "parser.php.c" + break; + case 51: +// 402 "parser.php.lemon" +{ + phql_ret_update_item(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(4,&ppmsp[-1].minor); +} +// 1580 "parser.php.c" + break; + case 53: +// 416 "parser.php.lemon" +{ + phql_ret_delete_statement(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[-1].minor.pp202, &ppmsp[0].minor.pp202); +} +// 1587 "parser.php.c" + break; + case 54: +// 424 "parser.php.lemon" +{ + phql_ret_delete_clause(&ppgotominor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(49,&ppmsp[-2].minor); + pp_destructor(28,&ppmsp[-1].minor); +} +// 1596 "parser.php.c" + break; + case 55: +// 432 "parser.php.lemon" +{ + phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, ppmsp[0].minor.pp0, NULL); + pp_destructor(33,&ppmsp[-1].minor); +} +// 1604 "parser.php.c" + break; + case 56: +// 436 "parser.php.lemon" +{ + phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-1].minor.pp202, ppmsp[0].minor.pp0, NULL); +} +// 1611 "parser.php.c" + break; + case 57: +// 440 "parser.php.lemon" +{ + phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[0].minor.pp202, NULL, NULL); +} +// 1618 "parser.php.c" + break; + case 58: +// 444 "parser.php.lemon" +{ + phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-4].minor.pp202, ppmsp[-2].minor.pp0, &ppmsp[0].minor.pp202); + pp_destructor(33,&ppmsp[-3].minor); + pp_destructor(50,&ppmsp[-1].minor); +} +// 1627 "parser.php.c" + break; + case 59: +// 448 "parser.php.lemon" +{ + phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-6].minor.pp202, ppmsp[-4].minor.pp0, &ppmsp[-1].minor.pp202); + pp_destructor(33,&ppmsp[-5].minor); + pp_destructor(50,&ppmsp[-3].minor); + pp_destructor(45,&ppmsp[-2].minor); + pp_destructor(46,&ppmsp[0].minor); +} +// 1638 "parser.php.c" + break; + case 60: +// 452 "parser.php.lemon" +{ + phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-5].minor.pp202, ppmsp[-4].minor.pp0, &ppmsp[-1].minor.pp202); + pp_destructor(50,&ppmsp[-3].minor); + pp_destructor(45,&ppmsp[-2].minor); + pp_destructor(46,&ppmsp[0].minor); +} +// 1648 "parser.php.c" + break; + case 61: +// 456 "parser.php.lemon" +{ + phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-3].minor.pp202, ppmsp[-2].minor.pp0, &ppmsp[0].minor.pp202); + pp_destructor(50,&ppmsp[-1].minor); +} +// 1656 "parser.php.c" + break; + case 62: +// 460 "parser.php.lemon" +{ + phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-4].minor.pp202, NULL, &ppmsp[-1].minor.pp202); + pp_destructor(50,&ppmsp[-3].minor); + pp_destructor(45,&ppmsp[-2].minor); + pp_destructor(46,&ppmsp[0].minor); +} +// 1666 "parser.php.c" + break; + case 63: +// 464 "parser.php.lemon" +{ + phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, NULL, &ppmsp[0].minor.pp202); + pp_destructor(50,&ppmsp[-1].minor); +} +// 1674 "parser.php.c" + break; + case 68: +// 500 "parser.php.lemon" +{ + ppgotominor.pp202 = ppmsp[0].minor.pp202; + pp_destructor(51,&ppmsp[-1].minor); +} +// 1682 "parser.php.c" + break; + case 70: +// 512 "parser.php.lemon" +{ + ppgotominor.pp202 = ppmsp[0].minor.pp202; + pp_destructor(52,&ppmsp[-2].minor); + pp_destructor(53,&ppmsp[-1].minor); +} +// 1691 "parser.php.c" + break; + case 74: +// 536 "parser.php.lemon" +{ + phql_ret_order_item(&ppgotominor.pp202, &ppmsp[0].minor.pp202, 0); +} +// 1698 "parser.php.c" + break; + case 75: +// 540 "parser.php.lemon" +{ + phql_ret_order_item(&ppgotominor.pp202, &ppmsp[-1].minor.pp202, PHQL_T_ASC); + pp_destructor(54,&ppmsp[0].minor); +} +// 1706 "parser.php.c" + break; + case 76: +// 544 "parser.php.lemon" +{ + phql_ret_order_item(&ppgotominor.pp202, &ppmsp[-1].minor.pp202, PHQL_T_DESC); + pp_destructor(55,&ppmsp[0].minor); +} +// 1714 "parser.php.c" + break; + case 77: +// 552 "parser.php.lemon" +{ + ppgotominor.pp202 = ppmsp[0].minor.pp202; + pp_destructor(56,&ppmsp[-2].minor); + pp_destructor(53,&ppmsp[-1].minor); +} +// 1723 "parser.php.c" + break; + case 82: +// 584 "parser.php.lemon" +{ + ppgotominor.pp202 = ppmsp[0].minor.pp202; + pp_destructor(57,&ppmsp[-1].minor); +} +// 1731 "parser.php.c" + break; + case 84: +// 596 "parser.php.lemon" +{ + phql_ret_for_update_clause(&ppgotominor.pp202); + pp_destructor(58,&ppmsp[-1].minor); + pp_destructor(47,&ppmsp[0].minor); +} +// 1740 "parser.php.c" + break; + case 86: + case 90: +// 608 "parser.php.lemon" +{ + phql_ret_limit_clause(&ppgotominor.pp202, &ppmsp[0].minor.pp202, NULL); + pp_destructor(59,&ppmsp[-1].minor); +} +// 1749 "parser.php.c" + break; + case 87: +// 612 "parser.php.lemon" +{ + phql_ret_limit_clause(&ppgotominor.pp202, &ppmsp[0].minor.pp202, &ppmsp[-2].minor.pp202); + pp_destructor(59,&ppmsp[-3].minor); + pp_destructor(26,&ppmsp[-1].minor); +} +// 1758 "parser.php.c" + break; + case 88: +// 616 "parser.php.lemon" +{ + phql_ret_limit_clause(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(59,&ppmsp[-3].minor); + pp_destructor(60,&ppmsp[-1].minor); +} +// 1767 "parser.php.c" + break; + case 92: + case 150: +// 636 "parser.php.lemon" +{ + phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_INTEGER, ppmsp[0].minor.pp0); +} +// 1775 "parser.php.c" + break; + case 93: + case 151: +// 640 "parser.php.lemon" +{ + phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_HINTEGER, ppmsp[0].minor.pp0); +} +// 1783 "parser.php.c" + break; + case 94: + case 157: +// 644 "parser.php.lemon" +{ + phql_ret_placeholder_zval(&ppgotominor.pp202, PHQL_T_NPLACEHOLDER, ppmsp[0].minor.pp0); +} +// 1791 "parser.php.c" + break; + case 95: + case 158: +// 648 "parser.php.lemon" +{ + phql_ret_placeholder_zval(&ppgotominor.pp202, PHQL_T_SPLACEHOLDER, ppmsp[0].minor.pp0); +} +// 1799 "parser.php.c" + break; + case 96: + case 159: +// 652 "parser.php.lemon" +{ + phql_ret_placeholder_zval(&ppgotominor.pp202, PHQL_T_BPLACEHOLDER, ppmsp[0].minor.pp0); +} +// 1807 "parser.php.c" + break; + case 97: +// 660 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_MINUS, NULL, &ppmsp[0].minor.pp202); + pp_destructor(21,&ppmsp[-1].minor); +} +// 1815 "parser.php.c" + break; + case 98: +// 664 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_SUB, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(21,&ppmsp[-1].minor); +} +// 1823 "parser.php.c" + break; + case 99: +// 668 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_ADD, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(20,&ppmsp[-1].minor); +} +// 1831 "parser.php.c" + break; + case 100: +// 672 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_MUL, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(18,&ppmsp[-1].minor); +} +// 1839 "parser.php.c" + break; + case 101: +// 676 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_DIV, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(17,&ppmsp[-1].minor); +} +// 1847 "parser.php.c" + break; + case 102: +// 680 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_MOD, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(19,&ppmsp[-1].minor); +} +// 1855 "parser.php.c" + break; + case 103: +// 684 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_AND, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(10,&ppmsp[-1].minor); +} +// 1863 "parser.php.c" + break; + case 104: +// 688 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_OR, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(11,&ppmsp[-1].minor); +} +// 1871 "parser.php.c" + break; + case 105: +// 692 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_BITWISE_AND, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(14,&ppmsp[-1].minor); +} +// 1879 "parser.php.c" + break; + case 106: +// 696 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_BITWISE_OR, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(15,&ppmsp[-1].minor); +} +// 1887 "parser.php.c" + break; + case 107: +// 700 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_BITWISE_XOR, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(16,&ppmsp[-1].minor); +} +// 1895 "parser.php.c" + break; + case 108: +// 704 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_EQUALS, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(4,&ppmsp[-1].minor); +} +// 1903 "parser.php.c" + break; + case 109: +// 708 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_NOTEQUALS, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(5,&ppmsp[-1].minor); +} +// 1911 "parser.php.c" + break; + case 110: +// 712 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_LESS, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(6,&ppmsp[-1].minor); +} +// 1919 "parser.php.c" + break; + case 111: +// 716 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_GREATER, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(7,&ppmsp[-1].minor); +} +// 1927 "parser.php.c" + break; + case 112: +// 720 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_GREATEREQUAL, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(8,&ppmsp[-1].minor); +} +// 1935 "parser.php.c" + break; + case 113: +// 724 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_LESSEQUAL, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(9,&ppmsp[-1].minor); +} +// 1943 "parser.php.c" + break; + case 114: +// 728 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_LIKE, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(12,&ppmsp[-1].minor); +} +// 1951 "parser.php.c" + break; + case 115: +// 732 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_NLIKE, &ppmsp[-3].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(24,&ppmsp[-2].minor); + pp_destructor(12,&ppmsp[-1].minor); +} +// 1960 "parser.php.c" + break; + case 116: +// 736 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_ILIKE, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(13,&ppmsp[-1].minor); +} +// 1968 "parser.php.c" + break; + case 117: +// 740 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_NILIKE, &ppmsp[-3].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(24,&ppmsp[-2].minor); + pp_destructor(13,&ppmsp[-1].minor); +} +// 1977 "parser.php.c" + break; + case 118: + case 121: +// 744 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_IN, &ppmsp[-4].minor.pp202, &ppmsp[-1].minor.pp202); + pp_destructor(23,&ppmsp[-3].minor); + pp_destructor(45,&ppmsp[-2].minor); + pp_destructor(46,&ppmsp[0].minor); +} +// 1988 "parser.php.c" + break; + case 119: + case 122: +// 748 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_NOTIN, &ppmsp[-5].minor.pp202, &ppmsp[-1].minor.pp202); + pp_destructor(24,&ppmsp[-4].minor); + pp_destructor(23,&ppmsp[-3].minor); + pp_destructor(45,&ppmsp[-2].minor); + pp_destructor(46,&ppmsp[0].minor); +} +// 2000 "parser.php.c" + break; + case 120: +// 752 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_SUBQUERY, &ppmsp[-1].minor.pp202, NULL); + pp_destructor(45,&ppmsp[-2].minor); + pp_destructor(46,&ppmsp[0].minor); +} +// 2009 "parser.php.c" + break; + case 123: +// 764 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_EXISTS, NULL, &ppmsp[-1].minor.pp202); + pp_destructor(66,&ppmsp[-3].minor); + pp_destructor(45,&ppmsp[-2].minor); + pp_destructor(46,&ppmsp[0].minor); +} +// 2019 "parser.php.c" + break; + case 124: +// 768 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_AGAINST, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(1,&ppmsp[-1].minor); +} +// 2027 "parser.php.c" + break; + case 125: +// 772 "parser.php.lemon" +{ + { + zval qualified; + phql_ret_raw_qualified_name(&qualified, ppmsp[-1].minor.pp0, NULL); + phql_ret_expr(&ppgotominor.pp202, PHQL_T_CAST, &ppmsp[-3].minor.pp202, &qualified); + } + pp_destructor(67,&ppmsp[-5].minor); + pp_destructor(45,&ppmsp[-4].minor); + pp_destructor(33,&ppmsp[-2].minor); + pp_destructor(46,&ppmsp[0].minor); +} +// 2042 "parser.php.c" + break; + case 126: +// 780 "parser.php.lemon" +{ + { + zval qualified; + phql_ret_raw_qualified_name(&qualified, ppmsp[-1].minor.pp0, NULL); + phql_ret_expr(&ppgotominor.pp202, PHQL_T_CONVERT, &ppmsp[-3].minor.pp202, &qualified); + } + pp_destructor(68,&ppmsp[-5].minor); + pp_destructor(45,&ppmsp[-4].minor); + pp_destructor(69,&ppmsp[-2].minor); + pp_destructor(46,&ppmsp[0].minor); +} +// 2057 "parser.php.c" + break; + case 127: +// 788 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_CASE, &ppmsp[-2].minor.pp202, &ppmsp[-1].minor.pp202); + pp_destructor(70,&ppmsp[-3].minor); + pp_destructor(71,&ppmsp[0].minor); +} +// 2066 "parser.php.c" + break; + case 130: +// 800 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_WHEN, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(72,&ppmsp[-3].minor); + pp_destructor(73,&ppmsp[-1].minor); +} +// 2075 "parser.php.c" + break; + case 131: +// 804 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_ELSE, &ppmsp[0].minor.pp202, NULL); + pp_destructor(74,&ppmsp[-1].minor); +} +// 2083 "parser.php.c" + break; + case 133: +// 816 "parser.php.lemon" +{ + phql_ret_func_call(&ppgotominor.pp202, ppmsp[-4].minor.pp0, &ppmsp[-1].minor.pp202, &ppmsp[-2].minor.pp202); + pp_destructor(45,&ppmsp[-3].minor); + pp_destructor(46,&ppmsp[0].minor); +} +// 2092 "parser.php.c" + break; + case 134: +// 824 "parser.php.lemon" +{ + phql_ret_distinct(&ppgotominor.pp202); + pp_destructor(29,&ppmsp[0].minor); +} +// 2100 "parser.php.c" + break; + case 142: +// 868 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_ISNULL, &ppmsp[-2].minor.pp202, NULL); + pp_destructor(22,&ppmsp[-1].minor); + pp_destructor(75,&ppmsp[0].minor); +} +// 2109 "parser.php.c" + break; + case 143: +// 872 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_ISNOTNULL, &ppmsp[-3].minor.pp202, NULL); + pp_destructor(22,&ppmsp[-2].minor); + pp_destructor(24,&ppmsp[-1].minor); + pp_destructor(75,&ppmsp[0].minor); +} +// 2119 "parser.php.c" + break; + case 144: +// 876 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_BETWEEN, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(2,&ppmsp[-1].minor); +} +// 2127 "parser.php.c" + break; + case 145: +// 880 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_BETWEEN_NOT, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); + pp_destructor(3,&ppmsp[-1].minor); +} +// 2135 "parser.php.c" + break; + case 146: +// 884 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_NOT, NULL, &ppmsp[0].minor.pp202); + pp_destructor(24,&ppmsp[-1].minor); +} +// 2143 "parser.php.c" + break; + case 147: +// 888 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_BITWISE_NOT, NULL, &ppmsp[0].minor.pp202); + pp_destructor(25,&ppmsp[-1].minor); +} +// 2151 "parser.php.c" + break; + case 148: +// 892 "parser.php.lemon" +{ + phql_ret_expr(&ppgotominor.pp202, PHQL_T_ENCLOSED, &ppmsp[-1].minor.pp202, NULL); + pp_destructor(45,&ppmsp[-2].minor); + pp_destructor(46,&ppmsp[0].minor); +} +// 2160 "parser.php.c" + break; + case 152: +// 908 "parser.php.lemon" +{ + phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_STRING, ppmsp[0].minor.pp0); +} +// 2167 "parser.php.c" + break; + case 153: +// 912 "parser.php.lemon" +{ + phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_DOUBLE, ppmsp[0].minor.pp0); +} +// 2174 "parser.php.c" + break; + case 154: +// 916 "parser.php.lemon" +{ + phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_NULL, NULL); + pp_destructor(75,&ppmsp[0].minor); +} +// 2182 "parser.php.c" + break; + case 155: +// 920 "parser.php.lemon" +{ + phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_TRUE, NULL); + pp_destructor(78,&ppmsp[0].minor); +} +// 2190 "parser.php.c" + break; + case 156: +// 924 "parser.php.lemon" +{ + phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_FALSE, NULL); + pp_destructor(79,&ppmsp[0].minor); +} +// 2198 "parser.php.c" + break; + case 160: +// 947 "parser.php.lemon" +{ + phql_ret_qualified_name(&ppgotominor.pp202, NULL, ppmsp[-2].minor.pp0, ppmsp[0].minor.pp0); + pp_destructor(32,&ppmsp[-1].minor); +} +// 2206 "parser.php.c" + break; + }; + ppgoto = ppRuleInfo[ppruleno].lhs; + ppsize = ppRuleInfo[ppruleno].nrhs; + pppParser->ppidx -= ppsize; + ppact = pp_find_reduce_action(pppParser,ppgoto); + if( ppact < PPNSTATE ){ + pp_shift(pppParser,ppact,ppgoto,&ppgotominor); + }else if( ppact == PPNSTATE + PPNRULE + 1 ){ + pp_accept(pppParser); + } +} + +static void pp_parse_failed( + ppParser *pppParser /* The parser */ +){ + phql_ARG_FETCH; +#ifndef NDEBUG + if( ppTraceFILE ){ + fprintf(ppTraceFILE,"%sFail!\n",ppTracePrompt); + } +#endif + while( pppParser->ppidx>=0 ) pp_pop_parser_stack(pppParser); + /* Here code is inserted which will be executed whenever the + ** parser fails */ + phql_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ +} + +static void pp_syntax_error( + ppParser *pppParser, /* The parser */ + int ppmajor, /* The major type of the error token */ + PPMINORTYPE ppminor /* The minor type of the error token */ +){ + phql_ARG_FETCH; +#define PPTOKEN (ppminor.pp0) +// 34 "parser.php.lemon" + + if (status->scanner_state->start_length) { + { + + char *token_name = NULL; + int token_found = 0; + unsigned int token_length; + const phql_token_names *tokens = phql_tokens; + int active_token = status->scanner_state->active_token; + int near_length = status->scanner_state->start_length; + + if (active_token) { + + do { + if (tokens->code == active_token) { + token_name = tokens->name; + token_length = tokens->length; + token_found = 1; + break; } - zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2411); - zephir_array_update_zval(&joinTypes, &alias, &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinModels, &alias, &realModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlModelsAliases, &realModelName, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModels, &alias, &realModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &realModelName, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinSources, &alias, &completeSource, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinPrepared, &alias, &joinItem, PH_COPY | PH_SEPARATE); + ++tokens; + } while (tokens[0].code != 0); + + } + + if (!token_name) { + token_length = strlen("UNKNOWN"); + token_name = estrndup("UNKNOWN", token_length); + token_found = 0; + } + + status->syntax_error_len = 96 + status->token->len + token_length + near_length + status->phql_length;; + status->syntax_error = emalloc(sizeof(char) * status->syntax_error_len); + + if (near_length > 0) { + if (status->token->value) { + snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected token %s(%s), near to '%s', when parsing: %s (%d)", token_name, status->token->value, status->scanner_state->start, status->phql, status->phql_length); } else { - if (UNEXPECTED(zephir_array_isset(&joinModels, &realModelName))) { - ZEPHIR_INIT_NVAR(&_16$$16); - object_init_ex(&_16$$16, phalcon_mvc_model_exception_ce); - zephir_read_property(&_17$$16, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_18$$16); - ZEPHIR_CONCAT_SVSV(&_18$$16, "Cannot use '", &realModelName, "' as join alias because it was already used, when preparing: ", &_17$$16); - ZEPHIR_CALL_METHOD(NULL, &_16$$16, "__construct", &_8, 33, &_18$$16); - zephir_check_call_status(); - zephir_throw_exception_debug(&_16$$16, "phalcon/Mvc/Model/Query.zep", 2464); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_update_zval(&joinTypes, &realModelName, &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliases, &realModelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinModels, &realModelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlModelsAliases, &realModelName, &realModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModels, &realModelName, &realModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &realModelName, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &realModelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinSources, &realModelName, &completeSource, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&joinPrepared, &realModelName, &joinItem, PH_COPY | PH_SEPARATE); + snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected token %s, near to '%s', when parsing: %s (%d)", token_name, status->scanner_state->start, status->phql, status->phql_length); } - zephir_array_update_zval(&modelsInstances, &realModelName, &model, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &selectJoins, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&joinItem); - zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &models); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliases"), &sqlAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModels"), &sqlAliasesModels); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlModelsAliases"), &sqlModelsAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &sqlAliasesModelsInstances); - zephir_update_property_zval(this_ptr, ZEND_STRL("modelsInstances"), &modelsInstances); - zephir_is_iterable(&joinPrepared, 0, "phalcon/Mvc/Model/Query.zep", 2539); - if (Z_TYPE_P(&joinPrepared) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&joinPrepared), _21, _22, _19) - { - ZEPHIR_INIT_NVAR(&joinAliasName); - if (_22 != NULL) { - ZVAL_STR_COPY(&joinAliasName, _22); } else { - ZVAL_LONG(&joinAliasName, _21); + if (active_token != PHQL_T_IGNORE) { + if (status->token->value) { + snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected token %s(%s), at the end of query, when parsing: %s (%d)", token_name, status->token->value, status->phql, status->phql_length); + } else { + snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected token %s, at the end of query, when parsing: %s (%d)", token_name, status->phql, status->phql_length); + } + } else { + snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected EOF, at the end of query"); + } + status->syntax_error[status->syntax_error_len - 1] = '\0'; } - ZEPHIR_INIT_NVAR(&joinItem); - ZVAL_COPY(&joinItem, _19); - ZEPHIR_OBS_NVAR(&joinExpr); - if (zephir_array_isset_string_fetch(&joinExpr, &joinItem, SL("conditions"), 0)) { - ZEPHIR_CALL_METHOD(&_23$$18, this_ptr, "getexpression", &_24, 458, &joinExpr); - zephir_check_call_status(); - zephir_array_update_zval(&joinPreCondition, &joinAliasName, &_23$$18, PH_COPY | PH_SEPARATE); + + if (!token_found) { + if (token_name) { + efree(token_name); + } } - } ZEND_HASH_FOREACH_END(); + } } else { - ZEPHIR_CALL_METHOD(NULL, &joinPrepared, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_20, &joinPrepared, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_20)) { - break; - } - ZEPHIR_CALL_METHOD(&joinAliasName, &joinPrepared, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&joinItem, &joinPrepared, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&joinExpr); - if (zephir_array_isset_string_fetch(&joinExpr, &joinItem, SL("conditions"), 0)) { - ZEPHIR_CALL_METHOD(&_25$$20, this_ptr, "getexpression", &_24, 458, &joinExpr); - zephir_check_call_status(); - zephir_array_update_zval(&joinPreCondition, &joinAliasName, &_25$$20, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &joinPrepared, "next", NULL, 0); - zephir_check_call_status(); + status->syntax_error_len = strlen("Syntax error, unexpected EOF"); + status->syntax_error = estrndup("Syntax error, unexpected EOF", status->syntax_error_len); + } + + status->status = PHQL_PARSING_FAILED; + +// 2315 "parser.php.c" + phql_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ +} + +static void pp_accept( + ppParser *pppParser /* The parser */ +){ + phql_ARG_FETCH; +#ifndef NDEBUG + if( ppTraceFILE ){ + fprintf(ppTraceFILE,"%sAccept!\n",ppTracePrompt); + } +#endif + while( pppParser->ppidx>=0 ) pp_pop_parser_stack(pppParser); + /* Here code is inserted which will be executed whenever the + ** parser accepts */ + phql_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ +} + +/* The main parser program. +** The first argument is a pointer to a structure obtained from +** "phql_Alloc" which describes the current state of the parser. +** The second argument is the major token number. The third is +** the minor token. The fourth optional argument is whatever the +** user wants (and specified in the grammar) and is available for +** use by the action routines. +** +** Inputs: +**
    +**
  • A pointer to the parser (an opaque structure.) +**
  • The major token number. +**
  • The minor token number. +**
  • An option argument of a grammar-specified type. +**
+** +** Outputs: +** None. +*/ +static void phql_( + void *ppp, /* The parser */ + int ppmajor, /* The major token code number */ + phql_TOKENTYPE ppminor /* The value for the token */ + phql_ARG_PDECL /* Optional %extra_argument parameter */ +){ + PPMINORTYPE ppminorunion; + int ppact; /* The parser action. */ + int ppendofinput; /* True if we are at the end of input */ + int pperrorhit = 0; /* True if ppmajor has invoked an error */ + ppParser *pppParser; /* The parser */ + + /* (re)initialize the parser, if necessary */ + pppParser = (ppParser*)ppp; + if( pppParser->ppidx<0 ){ + if( ppmajor==0 ) return; + pppParser->ppidx = 0; + pppParser->pperrcnt = -1; + pppParser->ppstack[0].stateno = 0; + pppParser->ppstack[0].major = 0; + } + ppminorunion.pp0 = ppminor; + ppendofinput = (ppmajor==0); + phql_ARG_STORE; + +#ifndef NDEBUG + if( ppTraceFILE ){ + fprintf(ppTraceFILE,"%sInput %s\n",ppTracePrompt,ppTokenName[ppmajor]); + } +#endif + + do{ + ppact = pp_find_shift_action(pppParser,ppmajor); + if( ppactpperrcnt--; + if( ppendofinput && pppParser->ppidx>=0 ){ + ppmajor = 0; + }else{ + ppmajor = PPNOCODE; + } + }else if( ppact < PPNSTATE + PPNRULE ){ + pp_reduce(pppParser,ppact-PPNSTATE); + }else if( ppact == PP_ERROR_ACTION ){ + int ppmx; +#ifndef NDEBUG + if( ppTraceFILE ){ + fprintf(ppTraceFILE,"%sSyntax Error!\n",ppTracePrompt); + } +#endif +#ifdef PPERRORSYMBOL + /* A syntax error has occurred. + ** The response to an error depends upon whether or not the + ** grammar defines an error token "ERROR". + ** + ** This is what we do if the grammar does define ERROR: + ** + ** * Call the %syntax_error function. + ** + ** * Begin popping the stack until we enter a state where + ** it is legal to shift the error symbol, then shift + ** the error symbol. + ** + ** * Set the error count to three. + ** + ** * Begin accepting and shifting new tokens. No new error + ** processing will occur until three tokens have been + ** shifted successfully. + ** + */ + if( pppParser->pperrcnt<0 ){ + pp_syntax_error(pppParser,ppmajor,ppminorunion); + } + ppmx = pppParser->ppstack[pppParser->ppidx].major; + if( ppmx==PPERRORSYMBOL || pperrorhit ){ +#ifndef NDEBUG + if( ppTraceFILE ){ + fprintf(ppTraceFILE,"%sDiscard input token %s\n", + ppTracePrompt,ppTokenName[ppmajor]); + } +#endif + pp_destructor(ppmajor,&ppminorunion); + ppmajor = PPNOCODE; + }else{ + while( + pppParser->ppidx >= 0 && + ppmx != PPERRORSYMBOL && + (ppact = pp_find_shift_action(pppParser,PPERRORSYMBOL)) >= PPNSTATE + ){ + pp_pop_parser_stack(pppParser); + } + if( pppParser->ppidx < 0 || ppmajor==0 ){ + pp_destructor(ppmajor,&ppminorunion); + pp_parse_failed(pppParser); + ppmajor = PPNOCODE; + }else if( ppmx!=PPERRORSYMBOL ){ + PPMINORTYPE u2; + u2.PPERRSYMDT = 0; + pp_shift(pppParser,ppact,PPERRORSYMBOL,&u2); + } + } + pppParser->pperrcnt = 3; + pperrorhit = 1; +#else /* PPERRORSYMBOL is not defined */ + /* This is what we do if the grammar does not define ERROR: + ** + ** * Report an error message, and throw away the input token. + ** + ** * If the input token is $, then fail the parse. + ** + ** As before, subsequent error messages are suppressed until + ** three input tokens have been successfully shifted. + */ + if( pppParser->pperrcnt<=0 ){ + pp_syntax_error(pppParser,ppmajor,ppminorunion); + } + pppParser->pperrcnt = 3; + pp_destructor(ppmajor,&ppminorunion); + if( ppendofinput ){ + pp_parse_failed(pppParser); + } + ppmajor = PPNOCODE; +#endif + }else{ + pp_accept(pppParser); + ppmajor = PPNOCODE; + } + }while( ppmajor!=PPNOCODE && pppParser->ppidx>=0 ); + return; +} +/* base.c + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the + * LICENSE.txt file that was distributed with this source code. + */ + +const phql_token_names phql_tokens[] = +{ + { SL("INTEGER"), PHQL_T_INTEGER }, + { SL("DOUBLE"), PHQL_T_DOUBLE }, + { SL("STRING"), PHQL_T_STRING }, + { SL("IDENTIFIER"), PHQL_T_IDENTIFIER }, + { SL("HEXAINTEGER"), PHQL_T_HINTEGER }, + { SL("MINUS"), PHQL_T_MINUS }, + { SL("+"), PHQL_T_ADD }, + { SL("-"), PHQL_T_SUB }, + { SL("*"), PHQL_T_MUL }, + { SL("/"), PHQL_T_DIV }, + { SL("&"), PHQL_T_BITWISE_AND }, + { SL("|"), PHQL_T_BITWISE_OR }, + { SL("%%"), PHQL_T_MOD }, + { SL("AND"), PHQL_T_AND }, + { SL("OR"), PHQL_T_OR }, + { SL("LIKE"), PHQL_T_LIKE }, + { SL("ILIKE"), PHQL_T_ILIKE }, + { SL("DOT"), PHQL_T_DOT }, + { SL("COLON"), PHQL_T_COLON }, + { SL("COMMA"), PHQL_T_COMMA }, + { SL("EQUALS"), PHQL_T_EQUALS }, + { SL("NOT EQUALS"), PHQL_T_NOTEQUALS }, + { SL("NOT"), PHQL_T_NOT }, + { SL("<"), PHQL_T_LESS }, + { SL("<="), PHQL_T_LESSEQUAL }, + { SL(">"), PHQL_T_GREATER }, + { SL(">="), PHQL_T_GREATEREQUAL }, + { SL("("), PHQL_T_PARENTHESES_OPEN }, + { SL(")"), PHQL_T_PARENTHESES_CLOSE }, + { SL("NUMERIC PLACEHOLDER"), PHQL_T_NPLACEHOLDER }, + { SL("STRING PLACEHOLDER"), PHQL_T_SPLACEHOLDER }, + { SL("UPDATE"), PHQL_T_UPDATE }, + { SL("SET"), PHQL_T_SET }, + { SL("WHERE"), PHQL_T_WHERE }, + { SL("DELETE"), PHQL_T_DELETE }, + { SL("FROM"), PHQL_T_FROM }, + { SL("AS"), PHQL_T_AS }, + { SL("INSERT"), PHQL_T_INSERT }, + { SL("INTO"), PHQL_T_INTO }, + { SL("VALUES"), PHQL_T_VALUES }, + { SL("SELECT"), PHQL_T_SELECT }, + { SL("ORDER"), PHQL_T_ORDER }, + { SL("BY"), PHQL_T_BY }, + { SL("LIMIT"), PHQL_T_LIMIT }, + { SL("OFFSET"), PHQL_T_OFFSET }, + { SL("GROUP"), PHQL_T_GROUP }, + { SL("HAVING"), PHQL_T_HAVING }, + { SL("IN"), PHQL_T_IN }, + { SL("ON"), PHQL_T_ON }, + { SL("INNER"), PHQL_T_INNER }, + { SL("JOIN"), PHQL_T_JOIN }, + { SL("LEFT"), PHQL_T_LEFT }, + { SL("RIGHT"), PHQL_T_RIGHT }, + { SL("IS"), PHQL_T_IS }, + { SL("NULL"), PHQL_T_NULL }, + { SL("NOT IN"), PHQL_T_NOTIN }, + { SL("CROSS"), PHQL_T_CROSS }, + { SL("OUTER"), PHQL_T_OUTER }, + { SL("FULL"), PHQL_T_FULL }, + { SL("ASC"), PHQL_T_ASC }, + { SL("DESC"), PHQL_T_DESC }, + { SL("BETWEEN"), PHQL_T_BETWEEN }, + { SL("DISTINCT"), PHQL_T_DISTINCT }, + { SL("AGAINST"), PHQL_T_AGAINST }, + { SL("CAST"), PHQL_T_CAST }, + { SL("CONVERT"), PHQL_T_CONVERT }, + { SL("USING"), PHQL_T_USING }, + { SL("ALL"), PHQL_T_ALL }, + { SL("EXISTS"), PHQL_T_EXISTS }, + { SL("CASE"), PHQL_T_CASE }, + { SL("WHEN"), PHQL_T_WHEN }, + { SL("THEN"), PHQL_T_THEN }, + { SL("ELSE"), PHQL_T_ELSE }, + { SL("END"), PHQL_T_END }, + { SL("FOR"), PHQL_T_FOR }, + { SL("WITH"), PHQL_T_WITH }, + { NULL, 0, 0 } +}; + +static void *phql_wrapper_alloc(size_t bytes) +{ + return emalloc(bytes); +} + +static void phql_wrapper_free(void *pointer) +{ + efree(pointer); +} + +static void phql_parse_with_token(void* phql_parser, int opcode, int parsercode, phql_scanner_token *token, phql_parser_status *parser_status) +{ + + phql_parser_token *pToken; + + pToken = emalloc(sizeof(phql_parser_token)); + pToken->opcode = opcode; + pToken->token = token->value; + pToken->token_len = token->len; + pToken->free_flag = 1; + phql_(phql_parser, parsercode, pToken, parser_status); + + token->value = NULL; + token->len = 0; +} + +static void phql_scanner_error_msg(phql_parser_status *parser_status, zval **error_msg) +{ + + char *error = NULL, *error_part; + unsigned int length; + phql_scanner_state *state = parser_status->scanner_state; + + ZVAL_UNDEF(*error_msg); + + if (state->start) { + length = 64 + state->start_length + parser_status->phql_length; + error = emalloc(sizeof(char) * length); + if (state->start_length > 16) { + error_part = estrndup(state->start, 16); + snprintf(error, length, "Scanning error before '%s...' when parsing: %s (%d)", error_part, parser_status->phql, parser_status->phql_length); + efree(error_part); + } else { + snprintf(error, length, "Scanning error before '%s' when parsing: %s (%d)", state->start, parser_status->phql, parser_status->phql_length); } + error[length - 1] = '\0'; + ZVAL_STRING(*error_msg, error); + } else { + ZVAL_STRING(*error_msg, "Scanning error near to EOF"); } - ZEPHIR_INIT_NVAR(&joinItem); - ZEPHIR_INIT_NVAR(&joinAliasName); - zephir_read_property(&_0, this_ptr, ZEND_STRL("enableImplicitJoins"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_is_true(&_0))) { - ZEPHIR_INIT_VAR(&_26$$21); - zephir_is_iterable(&joinPrepared, 0, "phalcon/Mvc/Model/Query.zep", 2551); - if (Z_TYPE_P(&joinPrepared) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&joinPrepared), _29$$21, _30$$21, _27$$21) - { - ZEPHIR_INIT_NVAR(&joinAliasName); - if (_30$$21 != NULL) { - ZVAL_STR_COPY(&joinAliasName, _30$$21); + + if (error) { + efree(error); + } +} + +static int phql_parse_phql(zval *result, zval *phql) +{ + zval err_msg, *error_msg = &err_msg; + ZVAL_UNDEF(error_msg); + ZVAL_NULL(result); + + if (phql_internal_parse_phql(&result, Z_STRVAL_P(phql), Z_STRLEN_P(phql), &error_msg) == FAILURE) { + ZEPHIR_THROW_EXCEPTION_STRW(phalcon_mvc_model_exception_ce, Z_STRVAL_P(error_msg)); + return FAILURE; + } + + return SUCCESS; +} + +static int phql_internal_parse_phql(zval **result, char *phql, unsigned int phql_length, zval **error_msg) +{ + zend_phalcon_globals *phalcon_globals_ptr = ZEPHIR_VGLOBAL; + phql_parser_status *parser_status = NULL; + int scanner_status, status = SUCCESS, error_length, cache_level; + phql_scanner_state *state; + phql_scanner_token token; + void* phql_parser; + char *error; + unsigned long phql_key = 0; + zval *temp_ast; + + if (!phql) { + ZVAL_STRING(*error_msg, "PHQL statement cannot be NULL"); + return FAILURE; + } + + cache_level = phalcon_globals_ptr->orm.cache_level; + if (cache_level >= 0) { + phql_key = zend_inline_hash_func(phql, phql_length + 1); + if (phalcon_globals_ptr->orm.parser_cache != NULL) { + if ((temp_ast = zend_hash_index_find(phalcon_globals_ptr->orm.parser_cache, phql_key)) != NULL) { + ZVAL_ZVAL(*result, temp_ast, 1, 0); + Z_TRY_ADDREF_P(*result); + return SUCCESS; + } + } + } + + phql_parser = phql_Alloc(phql_wrapper_alloc); + + parser_status = emalloc(sizeof(phql_parser_status)); + state = emalloc(sizeof(phql_scanner_state)); + + parser_status->status = PHQL_PARSING_OK; + parser_status->scanner_state = state; + ZVAL_UNDEF(&parser_status->ret); + + parser_status->syntax_error = NULL; + parser_status->token = &token; + parser_status->enable_literals = phalcon_globals_ptr->orm.enable_literals; + parser_status->phql = phql; + parser_status->phql_length = phql_length; + + state->active_token = 0; + state->start = phql; + state->start_length = 0; + state->end = state->start; + + token.value = NULL; + token.len = 0; + + while (0 <= (scanner_status = phql_get_token(state, &token))) { + + /* Calculate the 'start' length */ + state->start_length = (phql + phql_length - state->start); + + state->active_token = token.opcode; + + /* Parse the token found */ + switch (token.opcode) { + + case PHQL_T_IGNORE: + break; + + case PHQL_T_ADD: + phql_(phql_parser, PHQL_PLUS, NULL, parser_status); + break; + case PHQL_T_SUB: + phql_(phql_parser, PHQL_MINUS, NULL, parser_status); + break; + case PHQL_T_MUL: + phql_(phql_parser, PHQL_TIMES, NULL, parser_status); + break; + case PHQL_T_DIV: + phql_(phql_parser, PHQL_DIVIDE, NULL, parser_status); + break; + case PHQL_T_MOD: + phql_(phql_parser, PHQL_MOD, NULL, parser_status); + break; + case PHQL_T_AND: + phql_(phql_parser, PHQL_AND, NULL, parser_status); + break; + case PHQL_T_OR: + phql_(phql_parser, PHQL_OR, NULL, parser_status); + break; + case PHQL_T_EQUALS: + phql_(phql_parser, PHQL_EQUALS, NULL, parser_status); + break; + case PHQL_T_NOTEQUALS: + phql_(phql_parser, PHQL_NOTEQUALS, NULL, parser_status); + break; + case PHQL_T_LESS: + phql_(phql_parser, PHQL_LESS, NULL, parser_status); + break; + case PHQL_T_GREATER: + phql_(phql_parser, PHQL_GREATER, NULL, parser_status); + break; + case PHQL_T_GREATEREQUAL: + phql_(phql_parser, PHQL_GREATEREQUAL, NULL, parser_status); + break; + case PHQL_T_LESSEQUAL: + phql_(phql_parser, PHQL_LESSEQUAL, NULL, parser_status); + break; + + case PHQL_T_IDENTIFIER: + phql_parse_with_token(phql_parser, PHQL_T_IDENTIFIER, PHQL_IDENTIFIER, &token, parser_status); + break; + + case PHQL_T_DOT: + phql_(phql_parser, PHQL_DOT, NULL, parser_status); + break; + case PHQL_T_COMMA: + phql_(phql_parser, PHQL_COMMA, NULL, parser_status); + break; + + case PHQL_T_PARENTHESES_OPEN: + phql_(phql_parser, PHQL_PARENTHESES_OPEN, NULL, parser_status); + break; + case PHQL_T_PARENTHESES_CLOSE: + phql_(phql_parser, PHQL_PARENTHESES_CLOSE, NULL, parser_status); + break; + + case PHQL_T_LIKE: + phql_(phql_parser, PHQL_LIKE, NULL, parser_status); + break; + case PHQL_T_ILIKE: + phql_(phql_parser, PHQL_ILIKE, NULL, parser_status); + break; + case PHQL_T_NOT: + phql_(phql_parser, PHQL_NOT, NULL, parser_status); + break; + case PHQL_T_BITWISE_AND: + phql_(phql_parser, PHQL_BITWISE_AND, NULL, parser_status); + break; + case PHQL_T_BITWISE_OR: + phql_(phql_parser, PHQL_BITWISE_OR, NULL, parser_status); + break; + case PHQL_T_BITWISE_NOT: + phql_(phql_parser, PHQL_BITWISE_NOT, NULL, parser_status); + break; + case PHQL_T_BITWISE_XOR: + phql_(phql_parser, PHQL_BITWISE_XOR, NULL, parser_status); + break; + case PHQL_T_AGAINST: + phql_(phql_parser, PHQL_AGAINST, NULL, parser_status); + break; + case PHQL_T_CASE: + phql_(phql_parser, PHQL_CASE, NULL, parser_status); + break; + case PHQL_T_WHEN: + phql_(phql_parser, PHQL_WHEN, NULL, parser_status); + break; + case PHQL_T_THEN: + phql_(phql_parser, PHQL_THEN, NULL, parser_status); + break; + case PHQL_T_END: + phql_(phql_parser, PHQL_END, NULL, parser_status); + break; + case PHQL_T_ELSE: + phql_(phql_parser, PHQL_ELSE, NULL, parser_status); + break; + case PHQL_T_FOR: + phql_(phql_parser, PHQL_FOR, NULL, parser_status); + break; + case PHQL_T_WITH: + phql_(phql_parser, PHQL_WITH, NULL, parser_status); + break; + + case PHQL_T_INTEGER: + if (parser_status->enable_literals) { + phql_parse_with_token(phql_parser, PHQL_T_INTEGER, PHQL_INTEGER, &token, parser_status); } else { - ZVAL_LONG(&joinAliasName, _29$$21); + ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements"); + parser_status->status = PHQL_PARSING_FAILED; } - ZEPHIR_INIT_NVAR(&_26$$21); - ZVAL_COPY(&_26$$21, _27$$21); - ZEPHIR_OBS_NVAR(&joinType); - zephir_array_fetch(&joinType, &joinTypes, &joinAliasName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2541); - ZEPHIR_OBS_NVAR(&joinSource); - zephir_array_fetch(&joinSource, &joinSources, &joinAliasName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2542); - ZEPHIR_OBS_NVAR(&preCondition); - zephir_array_fetch(&preCondition, &joinPreCondition, &joinAliasName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2543); - ZEPHIR_INIT_NVAR(&_31$$22); - zephir_create_array(&_31$$22, 3, 0); - zephir_array_update_string(&_31$$22, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_31$$22, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_32$$22); - zephir_create_array(&_32$$22, 1, 0); - zephir_array_fast_append(&_32$$22, &preCondition); - zephir_array_update_string(&_31$$22, SL("conditions"), &_32$$22, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_31$$22, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2548); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &joinPrepared, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_28$$21, &joinPrepared, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_28$$21)) { - break; + break; + case PHQL_T_DOUBLE: + if (parser_status->enable_literals) { + phql_parse_with_token(phql_parser, PHQL_T_DOUBLE, PHQL_DOUBLE, &token, parser_status); + } else { + ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements"); + parser_status->status = PHQL_PARSING_FAILED; } - ZEPHIR_CALL_METHOD(&joinAliasName, &joinPrepared, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_26$$21, &joinPrepared, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&joinType); - zephir_array_fetch(&joinType, &joinTypes, &joinAliasName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2541); - ZEPHIR_OBS_NVAR(&joinSource); - zephir_array_fetch(&joinSource, &joinSources, &joinAliasName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2542); - ZEPHIR_OBS_NVAR(&preCondition); - zephir_array_fetch(&preCondition, &joinPreCondition, &joinAliasName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2543); - ZEPHIR_INIT_NVAR(&_33$$23); - zephir_create_array(&_33$$23, 3, 0); - zephir_array_update_string(&_33$$23, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_33$$23, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_34$$23); - zephir_create_array(&_34$$23, 1, 0); - zephir_array_fast_append(&_34$$23, &preCondition); - zephir_array_update_string(&_33$$23, SL("conditions"), &_34$$23, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_33$$23, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2548); - ZEPHIR_CALL_METHOD(NULL, &joinPrepared, "next", NULL, 0); - zephir_check_call_status(); - } + break; + case PHQL_T_STRING: + if (parser_status->enable_literals) { + phql_parse_with_token(phql_parser, PHQL_T_STRING, PHQL_STRING, &token, parser_status); + } else { + ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements"); + parser_status->status = PHQL_PARSING_FAILED; + } + break; + case PHQL_T_TRUE: + if (parser_status->enable_literals) { + phql_(phql_parser, PHQL_TRUE, NULL, parser_status); + } else { + ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements"); + parser_status->status = PHQL_PARSING_FAILED; + } + break; + case PHQL_T_FALSE: + if (parser_status->enable_literals) { + phql_(phql_parser, PHQL_FALSE, NULL, parser_status); + } else { + ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements"); + parser_status->status = PHQL_PARSING_FAILED; + } + break; + case PHQL_T_HINTEGER: + if (parser_status->enable_literals) { + phql_parse_with_token(phql_parser, PHQL_T_HINTEGER, PHQL_HINTEGER, &token, parser_status); + } else { + ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements"); + parser_status->status = PHQL_PARSING_FAILED; + } + break; + + case PHQL_T_NPLACEHOLDER: + phql_parse_with_token(phql_parser, PHQL_T_NPLACEHOLDER, PHQL_NPLACEHOLDER, &token, parser_status); + break; + case PHQL_T_SPLACEHOLDER: + phql_parse_with_token(phql_parser, PHQL_T_SPLACEHOLDER, PHQL_SPLACEHOLDER, &token, parser_status); + break; + case PHQL_T_BPLACEHOLDER: + phql_parse_with_token(phql_parser, PHQL_T_BPLACEHOLDER, PHQL_BPLACEHOLDER, &token, parser_status); + break; + + case PHQL_T_FROM: + phql_(phql_parser, PHQL_FROM, NULL, parser_status); + break; + case PHQL_T_UPDATE: + phql_(phql_parser, PHQL_UPDATE, NULL, parser_status); + break; + case PHQL_T_SET: + phql_(phql_parser, PHQL_SET, NULL, parser_status); + break; + case PHQL_T_WHERE: + phql_(phql_parser, PHQL_WHERE, NULL, parser_status); + break; + case PHQL_T_DELETE: + phql_(phql_parser, PHQL_DELETE, NULL, parser_status); + break; + case PHQL_T_INSERT: + phql_(phql_parser, PHQL_INSERT, NULL, parser_status); + break; + case PHQL_T_INTO: + phql_(phql_parser, PHQL_INTO, NULL, parser_status); + break; + case PHQL_T_VALUES: + phql_(phql_parser, PHQL_VALUES, NULL, parser_status); + break; + case PHQL_T_SELECT: + phql_(phql_parser, PHQL_SELECT, NULL, parser_status); + break; + case PHQL_T_AS: + phql_(phql_parser, PHQL_AS, NULL, parser_status); + break; + case PHQL_T_ORDER: + phql_(phql_parser, PHQL_ORDER, NULL, parser_status); + break; + case PHQL_T_BY: + phql_(phql_parser, PHQL_BY, NULL, parser_status); + break; + case PHQL_T_LIMIT: + phql_(phql_parser, PHQL_LIMIT, NULL, parser_status); + break; + case PHQL_T_OFFSET: + phql_(phql_parser, PHQL_OFFSET, NULL, parser_status); + break; + case PHQL_T_GROUP: + phql_(phql_parser, PHQL_GROUP, NULL, parser_status); + break; + case PHQL_T_HAVING: + phql_(phql_parser, PHQL_HAVING, NULL, parser_status); + break; + case PHQL_T_ASC: + phql_(phql_parser, PHQL_ASC, NULL, parser_status); + break; + case PHQL_T_DESC: + phql_(phql_parser, PHQL_DESC, NULL, parser_status); + break; + case PHQL_T_IN: + phql_(phql_parser, PHQL_IN, NULL, parser_status); + break; + case PHQL_T_ON: + phql_(phql_parser, PHQL_ON, NULL, parser_status); + break; + case PHQL_T_INNER: + phql_(phql_parser, PHQL_INNER, NULL, parser_status); + break; + case PHQL_T_JOIN: + phql_(phql_parser, PHQL_JOIN, NULL, parser_status); + break; + case PHQL_T_LEFT: + phql_(phql_parser, PHQL_LEFT, NULL, parser_status); + break; + case PHQL_T_RIGHT: + phql_(phql_parser, PHQL_RIGHT, NULL, parser_status); + break; + case PHQL_T_CROSS: + phql_(phql_parser, PHQL_CROSS, NULL, parser_status); + break; + case PHQL_T_FULL: + phql_(phql_parser, PHQL_FULL, NULL, parser_status); + break; + case PHQL_T_OUTER: + phql_(phql_parser, PHQL_OUTER, NULL, parser_status); + break; + case PHQL_T_IS: + phql_(phql_parser, PHQL_IS, NULL, parser_status); + break; + case PHQL_T_NULL: + phql_(phql_parser, PHQL_NULL, NULL, parser_status); + break; + case PHQL_T_BETWEEN: + phql_(phql_parser, PHQL_BETWEEN, NULL, parser_status); + break; + case PHQL_T_BETWEEN_NOT: + phql_(phql_parser, PHQL_BETWEEN_NOT, NULL, parser_status); + break; + case PHQL_T_DISTINCT: + phql_(phql_parser, PHQL_DISTINCT, NULL, parser_status); + break; + case PHQL_T_ALL: + phql_(phql_parser, PHQL_ALL, NULL, parser_status); + break; + case PHQL_T_CAST: + phql_(phql_parser, PHQL_CAST, NULL, parser_status); + break; + case PHQL_T_CONVERT: + phql_(phql_parser, PHQL_CONVERT, NULL, parser_status); + break; + case PHQL_T_USING: + phql_(phql_parser, PHQL_USING, NULL, parser_status); + break; + case PHQL_T_EXISTS: + phql_(phql_parser, PHQL_EXISTS, NULL, parser_status); + break; + + default: + parser_status->status = PHQL_PARSING_FAILED; + error_length = sizeof(char) * 32; + error = emalloc(error_length); + snprintf(error, error_length, "Scanner: Unknown opcode %d", token.opcode); + error[error_length - 1] = '\0'; + ZVAL_STRING(*error_msg, error); + efree(error); + break; } - ZEPHIR_INIT_NVAR(&_26$$21); - ZEPHIR_INIT_NVAR(&joinAliasName); - RETURN_CTOR(&sqlJoins); + + if (parser_status->status != PHQL_PARSING_OK) { + status = FAILURE; + break; + } + + state->end = state->start; } - ZEPHIR_INIT_NVAR(&fromModels); - array_init(&fromModels); - zephir_is_iterable(&selectTables, 0, "phalcon/Mvc/Model/Query.zep", 2566); - if (Z_TYPE_P(&selectTables) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&selectTables), _35) - { - ZEPHIR_INIT_NVAR(&tableItem); - ZVAL_COPY(&tableItem, _35); - zephir_array_fetch_string(&_37$$24, &tableItem, SL("qualifiedName"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2560); - ZEPHIR_OBS_NVAR(&_38$$24); - zephir_array_fetch_string(&_38$$24, &_37$$24, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2560); - zephir_array_update_zval(&fromModels, &_38$$24, &__$true, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &selectTables, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_36, &selectTables, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_36)) { + + if (status != FAILURE) { + switch (scanner_status) { + + case PHQL_SCANNER_RETCODE_ERR: + case PHQL_SCANNER_RETCODE_IMPOSSIBLE: + if (Z_TYPE_P(*error_msg) == IS_UNDEF) { + phql_scanner_error_msg(parser_status, error_msg); + } + + status = FAILURE; break; - } - ZEPHIR_CALL_METHOD(&tableItem, &selectTables, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_fetch_string(&_39$$25, &tableItem, SL("qualifiedName"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2560); - ZEPHIR_OBS_NVAR(&_40$$25); - zephir_array_fetch_string(&_40$$25, &_39$$25, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2560); - zephir_array_update_zval(&fromModels, &_40$$25, &__$true, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &selectTables, "next", NULL, 0); - zephir_check_call_status(); + + default: + phql_(phql_parser, 0, NULL, parser_status); } } - ZEPHIR_INIT_NVAR(&tableItem); - ZEPHIR_INIT_VAR(&_41); - zephir_is_iterable(&fromModels, 0, "phalcon/Mvc/Model/Query.zep", 2686); - if (Z_TYPE_P(&fromModels) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&fromModels), _44, _45, _42) - { - ZEPHIR_INIT_NVAR(&fromModelName); - if (_45 != NULL) { - ZVAL_STR_COPY(&fromModelName, _45); - } else { - ZVAL_LONG(&fromModelName, _44); + + state->active_token = 0; + state->start = NULL; + + if (parser_status->status != PHQL_PARSING_OK) { + status = FAILURE; + if (parser_status->syntax_error) { + if (Z_TYPE_P(*error_msg) == IS_UNDEF) { + ZVAL_STRING(*error_msg, parser_status->syntax_error); } - ZEPHIR_INIT_NVAR(&_41); - ZVAL_COPY(&_41, _42); - zephir_is_iterable(&joinModels, 0, "phalcon/Mvc/Model/Query.zep", 2684); - if (Z_TYPE_P(&joinModels) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&joinModels), _48$$26, _49$$26, _46$$26) - { - ZEPHIR_INIT_NVAR(&joinAlias); - if (_49$$26 != NULL) { - ZVAL_STR_COPY(&joinAlias, _49$$26); - } else { - ZVAL_LONG(&joinAlias, _48$$26); - } - ZEPHIR_INIT_NVAR(&joinModel); - ZVAL_COPY(&joinModel, _46$$26); - ZEPHIR_OBS_NVAR(&joinSource); - zephir_array_fetch(&joinSource, &joinSources, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2571); - ZEPHIR_OBS_NVAR(&joinType); - zephir_array_fetch(&joinType, &joinTypes, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2576); - ZEPHIR_OBS_NVAR(&preCondition); - if (!(zephir_array_isset_fetch(&preCondition, &joinPreCondition, &joinAlias, 0))) { - ZEPHIR_OBS_NVAR(&modelNameAlias); - zephir_array_fetch(&modelNameAlias, &sqlAliasesModels, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2585); - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_50, 0, &fromModelName, &modelNameAlias); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&relation)) { - ZEPHIR_CALL_METHOD(&relations, &manager, "getrelationsbetween", &_51, 0, &fromModelName, &modelNameAlias); - zephir_check_call_status(); - if (Z_TYPE_P(&relations) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(&relations) != 1)) { - ZEPHIR_INIT_NVAR(&_52$$31); - object_init_ex(&_52$$31, phalcon_mvc_model_exception_ce); - zephir_read_property(&_53$$31, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_54$$31); - ZEPHIR_CONCAT_SVSVSV(&_54$$31, "There is more than one relation between models '", &fromModelName, "' and '", &joinModel, "', the join must be done using an alias, when preparing: ", &_53$$31); - ZEPHIR_CALL_METHOD(NULL, &_52$$31, "__construct", &_8, 33, &_54$$31); - zephir_check_call_status(); - zephir_throw_exception_debug(&_52$$31, "phalcon/Mvc/Model/Query.zep", 2611); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_OBS_NVAR(&relation); - zephir_array_fetch_long(&relation, &relations, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2617); - } - } - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_OBS_NVAR(&modelAlias); - zephir_array_fetch(&modelAlias, &sqlModelsAliases, &fromModelName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2628); - ZEPHIR_CALL_METHOD(&_55$$32, &relation, "isthrough", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_55$$32))) { - ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getsinglejoin", &_56, 465, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getmultijoin", &_57, 466, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); - zephir_check_call_status(); - } - if (zephir_array_isset_long(&sqlJoin, 0)) { - zephir_is_iterable(&sqlJoin, 0, "phalcon/Mvc/Model/Query.zep", 2658); - if (Z_TYPE_P(&sqlJoin) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&sqlJoin), _58$$35) - { - ZEPHIR_INIT_NVAR(&sqlJoinItem); - ZVAL_COPY(&sqlJoinItem, _58$$35); - zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2656); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_59$$35, &sqlJoin, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_59$$35)) { - break; - } - ZEPHIR_CALL_METHOD(&sqlJoinItem, &sqlJoin, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2656); - ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&sqlJoinItem); - } else { - zephir_array_append(&sqlJoins, &sqlJoin, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2659); - } - } else { - ZEPHIR_INIT_NVAR(&_60$$39); - zephir_create_array(&_60$$39, 3, 0); - zephir_array_update_string(&_60$$39, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_60$$39, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_61$$39); - array_init(&_61$$39); - zephir_array_update_string(&_60$$39, SL("conditions"), &_61$$39, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_60$$39, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2670); - } - } else { - ZEPHIR_INIT_NVAR(&_62$$40); - zephir_create_array(&_62$$40, 3, 0); - zephir_array_update_string(&_62$$40, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_62$$40, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_63$$40); - zephir_create_array(&_63$$40, 1, 0); - zephir_array_fast_append(&_63$$40, &preCondition); - zephir_array_update_string(&_62$$40, SL("conditions"), &_63$$40, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_62$$40, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2681); + + efree(parser_status->syntax_error); + } + } + + phql_Free(phql_parser, phql_wrapper_free); + + if (status != FAILURE) { + if (parser_status->status == PHQL_PARSING_OK) { + if (Z_TYPE_P(&parser_status->ret) == IS_ARRAY) { + + if (phalcon_globals_ptr->orm.cache_level >= 1) { + if (Z_TYPE_P(&parser_status->ret) == IS_ARRAY) { + add_assoc_long(&parser_status->ret, "id", phalcon_globals_ptr->orm.unique_cache_id++); } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &joinModels, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_47$$26, &joinModels, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_47$$26)) { - break; + } + + ZVAL_ZVAL(*result, &parser_status->ret, 1, 1); + + if (cache_level >= 0) { + + if (!phalcon_globals_ptr->orm.parser_cache) { + ALLOC_HASHTABLE(phalcon_globals_ptr->orm.parser_cache); + zend_hash_init(phalcon_globals_ptr->orm.parser_cache, 0, NULL, ZVAL_PTR_DTOR, 0); } - ZEPHIR_CALL_METHOD(&joinAlias, &joinModels, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&joinModel, &joinModels, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&joinSource); - zephir_array_fetch(&joinSource, &joinSources, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2571); - ZEPHIR_OBS_NVAR(&joinType); - zephir_array_fetch(&joinType, &joinTypes, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2576); - ZEPHIR_OBS_NVAR(&preCondition); - if (!(zephir_array_isset_fetch(&preCondition, &joinPreCondition, &joinAlias, 0))) { - ZEPHIR_OBS_NVAR(&modelNameAlias); - zephir_array_fetch(&modelNameAlias, &sqlAliasesModels, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2585); - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_64, 0, &fromModelName, &modelNameAlias); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&relation)) { - ZEPHIR_CALL_METHOD(&relations, &manager, "getrelationsbetween", &_65, 0, &fromModelName, &modelNameAlias); - zephir_check_call_status(); - if (Z_TYPE_P(&relations) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(&relations) != 1)) { - ZEPHIR_INIT_NVAR(&_66$$45); - object_init_ex(&_66$$45, phalcon_mvc_model_exception_ce); - zephir_read_property(&_67$$45, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_68$$45); - ZEPHIR_CONCAT_SVSVSV(&_68$$45, "There is more than one relation between models '", &fromModelName, "' and '", &joinModel, "', the join must be done using an alias, when preparing: ", &_67$$45); - ZEPHIR_CALL_METHOD(NULL, &_66$$45, "__construct", &_8, 33, &_68$$45); - zephir_check_call_status(); - zephir_throw_exception_debug(&_66$$45, "phalcon/Mvc/Model/Query.zep", 2611); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_OBS_NVAR(&relation); - zephir_array_fetch_long(&relation, &relations, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2617); - } - } - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_OBS_NVAR(&modelAlias); - zephir_array_fetch(&modelAlias, &sqlModelsAliases, &fromModelName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2628); - ZEPHIR_CALL_METHOD(&_69$$46, &relation, "isthrough", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_69$$46))) { - ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getsinglejoin", &_56, 465, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getmultijoin", &_57, 466, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); - zephir_check_call_status(); - } - if (zephir_array_isset_long(&sqlJoin, 0)) { - zephir_is_iterable(&sqlJoin, 0, "phalcon/Mvc/Model/Query.zep", 2658); - if (Z_TYPE_P(&sqlJoin) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&sqlJoin), _70$$49) - { - ZEPHIR_INIT_NVAR(&sqlJoinItem); - ZVAL_COPY(&sqlJoinItem, _70$$49); - zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2656); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_71$$49, &sqlJoin, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_71$$49)) { - break; - } - ZEPHIR_CALL_METHOD(&sqlJoinItem, &sqlJoin, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2656); - ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&sqlJoinItem); - } else { - zephir_array_append(&sqlJoins, &sqlJoin, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2659); - } - } else { - ZEPHIR_INIT_NVAR(&_72$$53); - zephir_create_array(&_72$$53, 3, 0); - zephir_array_update_string(&_72$$53, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_72$$53, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_73$$53); - array_init(&_73$$53); - zephir_array_update_string(&_72$$53, SL("conditions"), &_73$$53, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_72$$53, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2670); - } - } else { - ZEPHIR_INIT_NVAR(&_74$$54); - zephir_create_array(&_74$$54, 3, 0); - zephir_array_update_string(&_74$$54, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_74$$54, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_75$$54); - zephir_create_array(&_75$$54, 1, 0); - zephir_array_fast_append(&_75$$54, &preCondition); - zephir_array_update_string(&_74$$54, SL("conditions"), &_75$$54, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_74$$54, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2681); - } - ZEPHIR_CALL_METHOD(NULL, &joinModels, "next", NULL, 0); - zephir_check_call_status(); + + Z_TRY_ADDREF_P(*result); + + zend_hash_index_update( + phalcon_globals_ptr->orm.parser_cache, + phql_key, + *result + ); } + } - ZEPHIR_INIT_NVAR(&joinModel); - ZEPHIR_INIT_NVAR(&joinAlias); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &fromModels, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_43, &fromModels, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_43)) { - break; - } - ZEPHIR_CALL_METHOD(&fromModelName, &fromModels, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_41, &fromModels, "current", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&joinModels, 0, "phalcon/Mvc/Model/Query.zep", 2684); - if (Z_TYPE_P(&joinModels) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&joinModels), _78$$55, _79$$55, _76$$55) - { - ZEPHIR_INIT_NVAR(&joinAlias); - if (_79$$55 != NULL) { - ZVAL_STR_COPY(&joinAlias, _79$$55); - } else { - ZVAL_LONG(&joinAlias, _78$$55); - } - ZEPHIR_INIT_NVAR(&joinModel); - ZVAL_COPY(&joinModel, _76$$55); - ZEPHIR_OBS_NVAR(&joinSource); - zephir_array_fetch(&joinSource, &joinSources, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2571); - ZEPHIR_OBS_NVAR(&joinType); - zephir_array_fetch(&joinType, &joinTypes, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2576); - ZEPHIR_OBS_NVAR(&preCondition); - if (!(zephir_array_isset_fetch(&preCondition, &joinPreCondition, &joinAlias, 0))) { - ZEPHIR_OBS_NVAR(&modelNameAlias); - zephir_array_fetch(&modelNameAlias, &sqlAliasesModels, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2585); - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_80, 0, &fromModelName, &modelNameAlias); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&relation)) { - ZEPHIR_CALL_METHOD(&relations, &manager, "getrelationsbetween", &_81, 0, &fromModelName, &modelNameAlias); - zephir_check_call_status(); - if (Z_TYPE_P(&relations) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(&relations) != 1)) { - ZEPHIR_INIT_NVAR(&_82$$60); - object_init_ex(&_82$$60, phalcon_mvc_model_exception_ce); - zephir_read_property(&_83$$60, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_84$$60); - ZEPHIR_CONCAT_SVSVSV(&_84$$60, "There is more than one relation between models '", &fromModelName, "' and '", &joinModel, "', the join must be done using an alias, when preparing: ", &_83$$60); - ZEPHIR_CALL_METHOD(NULL, &_82$$60, "__construct", &_8, 33, &_84$$60); - zephir_check_call_status(); - zephir_throw_exception_debug(&_82$$60, "phalcon/Mvc/Model/Query.zep", 2611); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_OBS_NVAR(&relation); - zephir_array_fetch_long(&relation, &relations, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2617); - } - } - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_OBS_NVAR(&modelAlias); - zephir_array_fetch(&modelAlias, &sqlModelsAliases, &fromModelName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2628); - ZEPHIR_CALL_METHOD(&_85$$61, &relation, "isthrough", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_85$$61))) { - ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getsinglejoin", &_56, 465, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getmultijoin", &_57, 466, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); - zephir_check_call_status(); - } - if (zephir_array_isset_long(&sqlJoin, 0)) { - zephir_is_iterable(&sqlJoin, 0, "phalcon/Mvc/Model/Query.zep", 2658); - if (Z_TYPE_P(&sqlJoin) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&sqlJoin), _86$$64) - { - ZEPHIR_INIT_NVAR(&sqlJoinItem); - ZVAL_COPY(&sqlJoinItem, _86$$64); - zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2656); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_87$$64, &sqlJoin, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_87$$64)) { - break; - } - ZEPHIR_CALL_METHOD(&sqlJoinItem, &sqlJoin, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2656); - ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&sqlJoinItem); - } else { - zephir_array_append(&sqlJoins, &sqlJoin, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2659); - } - } else { - ZEPHIR_INIT_NVAR(&_88$$68); - zephir_create_array(&_88$$68, 3, 0); - zephir_array_update_string(&_88$$68, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_88$$68, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_89$$68); - array_init(&_89$$68); - zephir_array_update_string(&_88$$68, SL("conditions"), &_89$$68, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_88$$68, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2670); - } - } else { - ZEPHIR_INIT_NVAR(&_90$$69); - zephir_create_array(&_90$$69, 3, 0); - zephir_array_update_string(&_90$$69, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_90$$69, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_91$$69); - zephir_create_array(&_91$$69, 1, 0); - zephir_array_fast_append(&_91$$69, &preCondition); - zephir_array_update_string(&_90$$69, SL("conditions"), &_91$$69, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_90$$69, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2681); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &joinModels, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_77$$55, &joinModels, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_77$$55)) { - break; - } - ZEPHIR_CALL_METHOD(&joinAlias, &joinModels, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&joinModel, &joinModels, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&joinSource); - zephir_array_fetch(&joinSource, &joinSources, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2571); - ZEPHIR_OBS_NVAR(&joinType); - zephir_array_fetch(&joinType, &joinTypes, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2576); - ZEPHIR_OBS_NVAR(&preCondition); - if (!(zephir_array_isset_fetch(&preCondition, &joinPreCondition, &joinAlias, 0))) { - ZEPHIR_OBS_NVAR(&modelNameAlias); - zephir_array_fetch(&modelNameAlias, &sqlAliasesModels, &joinAlias, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2585); - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_92, 0, &fromModelName, &modelNameAlias); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&relation)) { - ZEPHIR_CALL_METHOD(&relations, &manager, "getrelationsbetween", &_93, 0, &fromModelName, &modelNameAlias); - zephir_check_call_status(); - if (Z_TYPE_P(&relations) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(&relations) != 1)) { - ZEPHIR_INIT_NVAR(&_94$$74); - object_init_ex(&_94$$74, phalcon_mvc_model_exception_ce); - zephir_read_property(&_95$$74, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_96$$74); - ZEPHIR_CONCAT_SVSVSV(&_96$$74, "There is more than one relation between models '", &fromModelName, "' and '", &joinModel, "', the join must be done using an alias, when preparing: ", &_95$$74); - ZEPHIR_CALL_METHOD(NULL, &_94$$74, "__construct", &_8, 33, &_96$$74); - zephir_check_call_status(); - zephir_throw_exception_debug(&_94$$74, "phalcon/Mvc/Model/Query.zep", 2611); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_OBS_NVAR(&relation); - zephir_array_fetch_long(&relation, &relations, 0, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2617); - } - } - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_OBS_NVAR(&modelAlias); - zephir_array_fetch(&modelAlias, &sqlModelsAliases, &fromModelName, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2628); - ZEPHIR_CALL_METHOD(&_97$$75, &relation, "isthrough", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_97$$75))) { - ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getsinglejoin", &_56, 465, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&sqlJoin, this_ptr, "getmultijoin", &_57, 466, &joinType, &joinSource, &modelAlias, &joinAlias, &relation); - zephir_check_call_status(); - } - if (zephir_array_isset_long(&sqlJoin, 0)) { - zephir_is_iterable(&sqlJoin, 0, "phalcon/Mvc/Model/Query.zep", 2658); - if (Z_TYPE_P(&sqlJoin) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&sqlJoin), _98$$78) - { - ZEPHIR_INIT_NVAR(&sqlJoinItem); - ZVAL_COPY(&sqlJoinItem, _98$$78); - zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2656); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_99$$78, &sqlJoin, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_99$$78)) { - break; - } - ZEPHIR_CALL_METHOD(&sqlJoinItem, &sqlJoin, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_append(&sqlJoins, &sqlJoinItem, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2656); - ZEPHIR_CALL_METHOD(NULL, &sqlJoin, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&sqlJoinItem); - } else { - zephir_array_append(&sqlJoins, &sqlJoin, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2659); - } - } else { - ZEPHIR_INIT_NVAR(&_100$$82); - zephir_create_array(&_100$$82, 3, 0); - zephir_array_update_string(&_100$$82, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_100$$82, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_101$$82); - array_init(&_101$$82); - zephir_array_update_string(&_100$$82, SL("conditions"), &_101$$82, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_100$$82, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2670); - } - } else { - ZEPHIR_INIT_NVAR(&_102$$83); - zephir_create_array(&_102$$83, 3, 0); - zephir_array_update_string(&_102$$83, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_102$$83, SL("source"), &joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_103$$83); - zephir_create_array(&_103$$83, 1, 0); - zephir_array_fast_append(&_103$$83, &preCondition); - zephir_array_update_string(&_102$$83, SL("conditions"), &_103$$83, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoins, &_102$$83, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2681); - } - ZEPHIR_CALL_METHOD(NULL, &joinModels, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&joinModel); - ZEPHIR_INIT_NVAR(&joinAlias); - ZEPHIR_CALL_METHOD(NULL, &fromModels, "next", NULL, 0); - zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&_41); - ZEPHIR_INIT_NVAR(&fromModelName); - RETURN_CTOR(&sqlJoins); -} -static PHP_METHOD(Phalcon_Mvc_Model_Query, getMultiJoin) -{ - zend_string *_4$$3; - zend_ulong _3$$3; - zval sqlJoins, _10$$4, _12$$4, _18$$6, _19$$6, _21$$8, _22$$8, _23$$8, _25$$8, _26$$8, _27$$8, _28$$8; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_8 = NULL, *_11 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *joinType_param = NULL, *joinSource, joinSource_sub, *modelAlias_param = NULL, *joinAlias_param = NULL, *relation, relation_sub, fields, referencedFields, intermediateModelName, intermediateModel, intermediateSource, intermediateSchema, intermediateFields, intermediateReferencedFields, referencedModelName, manager, field, position, intermediateField, sqlEqualsJoinCondition, _0, *_1$$3, _2$$3, _5$$5, _6$$5, _7$$5, _9$$4, _13$$7, _14$$7, _15$$7, _16$$6, _17$$6, _20$$8, _24$$8; - zval joinType, modelAlias, joinAlias; - zval *this_ptr = getThis(); + efree(parser_status); + efree(state); - ZVAL_UNDEF(&joinType); - ZVAL_UNDEF(&modelAlias); - ZVAL_UNDEF(&joinAlias); - ZVAL_UNDEF(&joinSource_sub); - ZVAL_UNDEF(&relation_sub); - ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&referencedFields); - ZVAL_UNDEF(&intermediateModelName); - ZVAL_UNDEF(&intermediateModel); - ZVAL_UNDEF(&intermediateSource); - ZVAL_UNDEF(&intermediateSchema); - ZVAL_UNDEF(&intermediateFields); - ZVAL_UNDEF(&intermediateReferencedFields); - ZVAL_UNDEF(&referencedModelName); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&position); - ZVAL_UNDEF(&intermediateField); - ZVAL_UNDEF(&sqlEqualsJoinCondition); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_7$$5); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_13$$7); - ZVAL_UNDEF(&_14$$7); - ZVAL_UNDEF(&_15$$7); - ZVAL_UNDEF(&_16$$6); - ZVAL_UNDEF(&_17$$6); - ZVAL_UNDEF(&_20$$8); - ZVAL_UNDEF(&_24$$8); - ZVAL_UNDEF(&sqlJoins); - ZVAL_UNDEF(&_10$$4); - ZVAL_UNDEF(&_12$$4); - ZVAL_UNDEF(&_18$$6); - ZVAL_UNDEF(&_19$$6); - ZVAL_UNDEF(&_21$$8); - ZVAL_UNDEF(&_22$$8); - ZVAL_UNDEF(&_23$$8); - ZVAL_UNDEF(&_25$$8); - ZVAL_UNDEF(&_26$$8); - ZVAL_UNDEF(&_27$$8); - ZVAL_UNDEF(&_28$$8); - ZEND_PARSE_PARAMETERS_START(5, 5) - Z_PARAM_STR(joinType) - Z_PARAM_ZVAL(joinSource) - Z_PARAM_STR(modelAlias) - Z_PARAM_STR(joinAlias) - Z_PARAM_OBJECT_OF_CLASS(relation, phalcon_mvc_model_relationinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 5, 0, &joinType_param, &joinSource, &modelAlias_param, &joinAlias_param, &relation); - if (UNEXPECTED(Z_TYPE_P(joinType_param) != IS_STRING && Z_TYPE_P(joinType_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'joinType' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(joinType_param) == IS_STRING)) { - zephir_get_strval(&joinType, joinType_param); - } else { - ZEPHIR_INIT_VAR(&joinType); - } - zephir_get_strval(&modelAlias, modelAlias_param); - zephir_get_strval(&joinAlias, joinAlias_param); - ZEPHIR_INIT_VAR(&sqlJoins); - array_init(&sqlJoins); - ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedFields, relation, "getreferencedfields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&intermediateModelName, relation, "getintermediatemodel", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - ZEPHIR_CALL_METHOD(&intermediateModel, &manager, "load", NULL, 0, &intermediateModelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&intermediateSource, &intermediateModel, "getsource", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&intermediateSchema, &intermediateModel, "getschema", NULL, 0); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("sqlAliases"), &intermediateModelName, &intermediateSource); - zephir_update_property_array(this_ptr, SL("sqlAliasesModelsInstances"), &intermediateModelName, &intermediateModel); - ZEPHIR_CALL_METHOD(&intermediateFields, relation, "getintermediatefields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&intermediateReferencedFields, relation, "getintermediatereferencedfields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedModelName, relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&fields) == IS_ARRAY) { - zephir_is_iterable(&fields, 0, "phalcon/Mvc/Model/Query.zep", 2803); - if (Z_TYPE_P(&fields) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&fields), _3$$3, _4$$3, _1$$3) - { - ZEPHIR_INIT_NVAR(&field); - if (_4$$3 != NULL) { - ZVAL_STR_COPY(&field, _4$$3); - } else { - ZVAL_LONG(&field, _3$$3); - } - ZEPHIR_INIT_NVAR(&position); - ZVAL_COPY(&position, _1$$3); - if (UNEXPECTED(!(zephir_array_isset(&referencedFields, &position)))) { - ZEPHIR_INIT_NVAR(&_5$$5); - object_init_ex(&_5$$5, phalcon_mvc_model_exception_ce); - zephir_read_property(&_6$$5, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_7$$5); - ZEPHIR_CONCAT_SVSVSV(&_7$$5, "The number of fields must be equal to the number of referenced fields in join ", &modelAlias, "-", &joinAlias, ", when preparing: ", &_6$$5); - ZEPHIR_CALL_METHOD(NULL, &_5$$5, "__construct", &_8, 33, &_7$$5); - zephir_check_call_status(); - zephir_throw_exception_debug(&_5$$5, "phalcon/Mvc/Model/Query.zep", 2770); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_OBS_NVAR(&intermediateField); - zephir_array_fetch(&intermediateField, &intermediateFields, &position, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2776); - ZEPHIR_INIT_NVAR(&sqlEqualsJoinCondition); - zephir_create_array(&sqlEqualsJoinCondition, 4, 0); - add_assoc_stringl_ex(&sqlEqualsJoinCondition, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&sqlEqualsJoinCondition, SL("op"), SL("=")); - ZEPHIR_INIT_NVAR(&_10$$4); - zephir_create_array(&_10$$4, 3, 0); - add_assoc_long_ex(&_10$$4, SL("type"), 355); - zephir_array_update_string(&_10$$4, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_10$$4, SL("name"), &field, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_9$$4, this_ptr, "getqualified", &_11, 459, &_10$$4); - zephir_check_call_status(); - zephir_array_update_string(&sqlEqualsJoinCondition, SL("left"), &_9$$4, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_12$$4); - zephir_create_array(&_12$$4, 3, 0); - add_assoc_stringl_ex(&_12$$4, SL("type"), SL("qualified")); - zephir_array_update_string(&_12$$4, SL("domain"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_12$$4, SL("name"), &referencedFields, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_9$$4, this_ptr, "getqualified", &_11, 459, &_12$$4); - zephir_check_call_status(); - zephir_array_update_string(&sqlEqualsJoinCondition, SL("right"), &_9$$4, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2$$3, &fields, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&field, &fields, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&position, &fields, "current", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(!(zephir_array_isset(&referencedFields, &position)))) { - ZEPHIR_INIT_NVAR(&_13$$7); - object_init_ex(&_13$$7, phalcon_mvc_model_exception_ce); - zephir_read_property(&_14$$7, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_15$$7); - ZEPHIR_CONCAT_SVSVSV(&_15$$7, "The number of fields must be equal to the number of referenced fields in join ", &modelAlias, "-", &joinAlias, ", when preparing: ", &_14$$7); - ZEPHIR_CALL_METHOD(NULL, &_13$$7, "__construct", &_8, 33, &_15$$7); - zephir_check_call_status(); - zephir_throw_exception_debug(&_13$$7, "phalcon/Mvc/Model/Query.zep", 2770); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_OBS_NVAR(&intermediateField); - zephir_array_fetch(&intermediateField, &intermediateFields, &position, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2776); - ZEPHIR_INIT_NVAR(&_16$$6); - zephir_create_array(&_16$$6, 4, 0); - add_assoc_stringl_ex(&_16$$6, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_16$$6, SL("op"), SL("=")); - ZEPHIR_INIT_NVAR(&_18$$6); - zephir_create_array(&_18$$6, 3, 0); - add_assoc_long_ex(&_18$$6, SL("type"), 355); - zephir_array_update_string(&_18$$6, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_18$$6, SL("name"), &field, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_17$$6, this_ptr, "getqualified", &_11, 459, &_18$$6); - zephir_check_call_status(); - zephir_array_update_string(&_16$$6, SL("left"), &_17$$6, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_19$$6); - zephir_create_array(&_19$$6, 3, 0); - add_assoc_stringl_ex(&_19$$6, SL("type"), SL("qualified")); - zephir_array_update_string(&_19$$6, SL("domain"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_19$$6, SL("name"), &referencedFields, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_17$$6, this_ptr, "getqualified", &_11, 459, &_19$$6); - zephir_check_call_status(); - zephir_array_update_string(&_16$$6, SL("right"), &_17$$6, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&sqlEqualsJoinCondition, &_16$$6); - ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&position); - ZEPHIR_INIT_NVAR(&field); - } else { - ZEPHIR_INIT_VAR(&_20$$8); - zephir_create_array(&_20$$8, 2, 0); - ZEPHIR_INIT_VAR(&_21$$8); - zephir_create_array(&_21$$8, 3, 0); - zephir_array_update_string(&_21$$8, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_22$$8); - zephir_create_array(&_22$$8, 2, 0); - zephir_array_fast_append(&_22$$8, &intermediateSource); - zephir_array_fast_append(&_22$$8, &intermediateSchema); - zephir_array_update_string(&_21$$8, SL("source"), &_22$$8, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_22$$8); - zephir_create_array(&_22$$8, 1, 0); - ZEPHIR_INIT_VAR(&_23$$8); - zephir_create_array(&_23$$8, 4, 0); - add_assoc_stringl_ex(&_23$$8, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_23$$8, SL("op"), SL("=")); - ZEPHIR_INIT_VAR(&_25$$8); - zephir_create_array(&_25$$8, 3, 0); - add_assoc_long_ex(&_25$$8, SL("type"), 355); - zephir_array_update_string(&_25$$8, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_25$$8, SL("name"), &fields, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_24$$8, this_ptr, "getqualified", &_11, 459, &_25$$8); - zephir_check_call_status(); - zephir_array_update_string(&_23$$8, SL("left"), &_24$$8, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_26$$8); - zephir_create_array(&_26$$8, 3, 0); - add_assoc_stringl_ex(&_26$$8, SL("type"), SL("qualified")); - zephir_array_update_string(&_26$$8, SL("domain"), &intermediateModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_26$$8, SL("name"), &intermediateFields, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_24$$8, this_ptr, "getqualified", &_11, 459, &_26$$8); - zephir_check_call_status(); - zephir_array_update_string(&_23$$8, SL("right"), &_24$$8, PH_COPY | PH_SEPARATE); - zephir_array_fast_append(&_22$$8, &_23$$8); - zephir_array_update_string(&_21$$8, SL("conditions"), &_22$$8, PH_COPY | PH_SEPARATE); - zephir_array_fast_append(&_20$$8, &_21$$8); - ZEPHIR_INIT_NVAR(&_21$$8); - zephir_create_array(&_21$$8, 3, 0); - zephir_array_update_string(&_21$$8, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_21$$8, SL("source"), joinSource, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_22$$8); - zephir_create_array(&_22$$8, 1, 0); - ZEPHIR_INIT_NVAR(&_23$$8); - zephir_create_array(&_23$$8, 4, 0); - add_assoc_stringl_ex(&_23$$8, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_23$$8, SL("op"), SL("=")); - ZEPHIR_INIT_VAR(&_27$$8); - zephir_create_array(&_27$$8, 3, 0); - add_assoc_long_ex(&_27$$8, SL("type"), 355); - zephir_array_update_string(&_27$$8, SL("domain"), &intermediateModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_27$$8, SL("name"), &intermediateReferencedFields, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_24$$8, this_ptr, "getqualified", &_11, 459, &_27$$8); - zephir_check_call_status(); - zephir_array_update_string(&_23$$8, SL("left"), &_24$$8, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_28$$8); - zephir_create_array(&_28$$8, 3, 0); - add_assoc_stringl_ex(&_28$$8, SL("type"), SL("qualified")); - zephir_array_update_string(&_28$$8, SL("domain"), &referencedModelName, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_28$$8, SL("name"), &referencedFields, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_24$$8, this_ptr, "getqualified", &_11, 459, &_28$$8); - zephir_check_call_status(); - zephir_array_update_string(&_23$$8, SL("right"), &_24$$8, PH_COPY | PH_SEPARATE); - zephir_array_fast_append(&_22$$8, &_23$$8); - zephir_array_update_string(&_21$$8, SL("conditions"), &_22$$8, PH_COPY | PH_SEPARATE); - zephir_array_fast_append(&_20$$8, &_21$$8); - ZEPHIR_CPY_WRT(&sqlJoins, &_20$$8); - } - RETURN_CTOR(&sqlJoins); + return status; } -static PHP_METHOD(Phalcon_Mvc_Model_Query, getOrderClause) -{ - zval orderParts, orderPartSort; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *order, order_sub, orderColumns, orderItem, orderPartExpr, orderSort, *_0, _1, _2$$5, _4$$7, _5$$8, _6$$8, _7$$9, _8$$10, _9$$12, _10$$12, _11$$13, _12$$13, _13$$14; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&order_sub); - ZVAL_UNDEF(&orderColumns); - ZVAL_UNDEF(&orderItem); - ZVAL_UNDEF(&orderPartExpr); - ZVAL_UNDEF(&orderSort); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_4$$7); - ZVAL_UNDEF(&_5$$8); - ZVAL_UNDEF(&_6$$8); - ZVAL_UNDEF(&_7$$9); - ZVAL_UNDEF(&_8$$10); - ZVAL_UNDEF(&_9$$12); - ZVAL_UNDEF(&_10$$12); - ZVAL_UNDEF(&_11$$13); - ZVAL_UNDEF(&_12$$13); - ZVAL_UNDEF(&_13$$14); - ZVAL_UNDEF(&orderParts); - ZVAL_UNDEF(&orderPartSort); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(order) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &order); - if (!(zephir_array_isset_long(order, 0))) { - ZEPHIR_INIT_VAR(&orderColumns); - zephir_create_array(&orderColumns, 1, 0); - zephir_array_fast_append(&orderColumns, order); - } else { - ZEPHIR_CPY_WRT(&orderColumns, order); - } - ZEPHIR_INIT_VAR(&orderParts); - array_init(&orderParts); - zephir_is_iterable(&orderColumns, 0, "phalcon/Mvc/Model/Query.zep", 2912); - if (Z_TYPE_P(&orderColumns) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&orderColumns), _0) - { - ZEPHIR_INIT_NVAR(&orderItem); - ZVAL_COPY(&orderItem, _0); - zephir_array_fetch_string(&_2$$5, &orderItem, SL("column"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2894); - ZEPHIR_CALL_METHOD(&orderPartExpr, this_ptr, "getexpression", &_3, 458, &_2$$5); - zephir_check_call_status(); - if (zephir_array_isset_string_fetch(&orderSort, &orderItem, SL("sort"), 1)) { - if (ZEPHIR_IS_LONG(&orderSort, 327)) { - ZEPHIR_INIT_NVAR(&orderPartSort); - zephir_create_array(&orderPartSort, 2, 0); - zephir_array_fast_append(&orderPartSort, &orderPartExpr); - ZEPHIR_INIT_NVAR(&_4$$7); - ZVAL_STRING(&_4$$7, "ASC"); - zephir_array_fast_append(&orderPartSort, &_4$$7); - } else { - ZEPHIR_INIT_NVAR(&_5$$8); - zephir_create_array(&_5$$8, 2, 0); - zephir_array_fast_append(&_5$$8, &orderPartExpr); - ZEPHIR_INIT_NVAR(&_6$$8); - ZVAL_STRING(&_6$$8, "DESC"); - zephir_array_fast_append(&_5$$8, &_6$$8); - ZEPHIR_CPY_WRT(&orderPartSort, &_5$$8); - } - } else { - ZEPHIR_INIT_NVAR(&_7$$9); - zephir_create_array(&_7$$9, 1, 0); - zephir_array_fast_append(&_7$$9, &orderPartExpr); - ZEPHIR_CPY_WRT(&orderPartSort, &_7$$9); - } - zephir_array_append(&orderParts, &orderPartSort, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2909); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &orderColumns, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &orderColumns, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&orderItem, &orderColumns, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_fetch_string(&_8$$10, &orderItem, SL("column"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2894); - ZEPHIR_CALL_METHOD(&orderPartExpr, this_ptr, "getexpression", &_3, 458, &_8$$10); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&orderSort); - if (zephir_array_isset_string_fetch(&orderSort, &orderItem, SL("sort"), 0)) { - if (ZEPHIR_IS_LONG(&orderSort, 327)) { - ZEPHIR_INIT_NVAR(&_9$$12); - zephir_create_array(&_9$$12, 2, 0); - zephir_array_fast_append(&_9$$12, &orderPartExpr); - ZEPHIR_INIT_NVAR(&_10$$12); - ZVAL_STRING(&_10$$12, "ASC"); - zephir_array_fast_append(&_9$$12, &_10$$12); - ZEPHIR_CPY_WRT(&orderPartSort, &_9$$12); - } else { - ZEPHIR_INIT_NVAR(&_11$$13); - zephir_create_array(&_11$$13, 2, 0); - zephir_array_fast_append(&_11$$13, &orderPartExpr); - ZEPHIR_INIT_NVAR(&_12$$13); - ZVAL_STRING(&_12$$13, "DESC"); - zephir_array_fast_append(&_11$$13, &_12$$13); - ZEPHIR_CPY_WRT(&orderPartSort, &_11$$13); - } - } else { - ZEPHIR_INIT_NVAR(&_13$$14); - zephir_create_array(&_13$$14, 1, 0); - zephir_array_fast_append(&_13$$14, &orderPartExpr); - ZEPHIR_CPY_WRT(&orderPartSort, &_13$$14); - } - zephir_array_append(&orderParts, &orderPartSort, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 2909); - ZEPHIR_CALL_METHOD(NULL, &orderColumns, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&orderItem); - RETURN_CTOR(&orderParts); -} +/* Generated by re2c 1.1.1 */ +/* scanner.re + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the + * LICENSE.txt file that was distributed with this source code. + */ -static PHP_METHOD(Phalcon_Mvc_Model_Query, getQualified) -{ - zend_bool _3, _4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_22 = NULL, *_27 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, number = 0; - zval *expr_param = NULL, columnName, nestingLevel, sqlColumnAliases, metaData, sqlAliases, source, sqlAliasesModelsInstances, realColumnName, columnDomain, model, models, columnMap, hasModel, className, _0, _5, _6, _1$$3, _2$$3, _7$$6, _8$$7, _9$$7, _10$$7, _11$$8, _12$$9, _13$$9, _14$$9, _15$$12, _16$$12, _17$$12, _18$$14, *_19$$14, _20$$14, _34$$14, _21$$15, _23$$17, _24$$17, _25$$17, _26$$18, _28$$20, _29$$20, _30$$20, _31$$21, _32$$21, _33$$21, _35$$23, _36$$23, _37$$23, _38$$27, _39$$27, _40$$27; - zval expr; - zval *this_ptr = getThis(); +#ifdef HAVE_CONFIG_H +#endif - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&columnName); - ZVAL_UNDEF(&nestingLevel); - ZVAL_UNDEF(&sqlColumnAliases); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&sqlAliases); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&sqlAliasesModelsInstances); - ZVAL_UNDEF(&realColumnName); - ZVAL_UNDEF(&columnDomain); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&hasModel); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_8$$7); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_10$$7); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_12$$9); - ZVAL_UNDEF(&_13$$9); - ZVAL_UNDEF(&_14$$9); - ZVAL_UNDEF(&_15$$12); - ZVAL_UNDEF(&_16$$12); - ZVAL_UNDEF(&_17$$12); - ZVAL_UNDEF(&_18$$14); - ZVAL_UNDEF(&_20$$14); - ZVAL_UNDEF(&_34$$14); - ZVAL_UNDEF(&_21$$15); - ZVAL_UNDEF(&_23$$17); - ZVAL_UNDEF(&_24$$17); - ZVAL_UNDEF(&_25$$17); - ZVAL_UNDEF(&_26$$18); - ZVAL_UNDEF(&_28$$20); - ZVAL_UNDEF(&_29$$20); - ZVAL_UNDEF(&_30$$20); - ZVAL_UNDEF(&_31$$21); - ZVAL_UNDEF(&_32$$21); - ZVAL_UNDEF(&_33$$21); - ZVAL_UNDEF(&_35$$23); - ZVAL_UNDEF(&_36$$23); - ZVAL_UNDEF(&_37$$23); - ZVAL_UNDEF(&_38$$27); - ZVAL_UNDEF(&_39$$27); - ZVAL_UNDEF(&_40$$27); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(expr) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &expr_param); - ZEPHIR_OBS_COPY_OR_DUP(&expr, expr_param); - zephir_memory_observe(&columnName); - zephir_array_fetch_string(&columnName, &expr, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 2926); - zephir_read_property(&_0, this_ptr, ZEND_STRL("nestingLevel"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&nestingLevel, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("sqlColumnAliases"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset(&_0, &nestingLevel)) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("sqlColumnAliases"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_2$$3, &_1$$3, &nestingLevel, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2934); - ZEPHIR_CPY_WRT(&sqlColumnAliases, &_2$$3); - } else { - ZEPHIR_INIT_NVAR(&sqlColumnAliases); - array_init(&sqlColumnAliases); - } - _3 = zephir_array_isset(&sqlColumnAliases, &columnName); - if (_3) { - _4 = !(zephir_array_isset_string(&expr, SL("domain"))); - if (!(_4)) { - zephir_array_fetch_string(&_5, &expr, SL("domain"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 2939); - _4 = ZEPHIR_IS_EMPTY(&_5); + + +#define PPCTYPE unsigned char +#define PPCURSOR (s->start) +#define PPLIMIT (s->end) +#define PPMARKER q + +static int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) { + + char *q = PPCURSOR; + int status = PHQL_SCANNER_RETCODE_IMPOSSIBLE; + + + while (PHQL_SCANNER_RETCODE_IMPOSSIBLE == status) { + + + { + PPCTYPE ppch; + unsigned int ppaccept = 0; + ppch = *PPCURSOR; + switch (ppch) { + case 0x00: goto pp2; + case '\t': + case '\n': + case '\r': + case ' ': goto pp6; + case '!': goto pp9; + case '"': goto pp11; + case '%': goto pp12; + case '&': goto pp14; + case '\'': goto pp16; + case '(': goto pp17; + case ')': goto pp19; + case '*': goto pp21; + case '+': goto pp23; + case ',': goto pp25; + case '-': goto pp27; + case '.': goto pp29; + case '/': goto pp31; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto pp33; + case ':': goto pp36; + case '<': goto pp38; + case '=': goto pp40; + case '>': goto pp42; + case '?': goto pp44; + case '@': goto pp45; + case 'A': + case 'a': goto pp46; + case 'B': + case 'b': goto pp48; + case 'C': + case 'c': goto pp49; + case 'D': + case 'd': goto pp50; + case 'E': + case 'e': goto pp51; + case 'F': + case 'f': goto pp52; + case 'G': + case 'g': goto pp53; + case 'H': + case 'h': goto pp55; + case 'I': + case 'i': goto pp56; + case 'J': + case 'j': goto pp57; + case 'K': + case 'M': + case 'P': + case 'Q': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'k': + case 'm': + case 'p': + case 'q': + case 'y': + case 'z': goto pp58; + case 'L': + case 'l': goto pp60; + case 'N': + case 'n': goto pp61; + case 'O': + case 'o': goto pp62; + case 'R': + case 'r': goto pp63; + case 'S': + case 's': goto pp64; + case 'T': + case 't': goto pp65; + case 'U': + case 'u': goto pp66; + case 'V': + case 'v': goto pp67; + case 'W': + case 'w': goto pp68; + case '[': goto pp69; + case '\\': goto pp70; + case '^': goto pp71; + case 'x': goto pp73; + case '{': goto pp75; + case '|': goto pp76; + case '~': goto pp78; + default: goto pp4; + } +pp2: + ++PPCURSOR; + { + status = PHQL_SCANNER_RETCODE_EOF; + break; } - _3 = _4; - } - if (_3) { - zephir_create_array(return_value, 2, 0); - add_assoc_stringl_ex(return_value, SL("type"), SL("qualified")); - zephir_array_update_string(return_value, SL("name"), &columnName, PH_COPY | PH_SEPARATE); - RETURN_MM(); - } - zephir_read_property(&_6, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&metaData, &_6); - zephir_memory_observe(&columnDomain); - if (zephir_array_isset_string_fetch(&columnDomain, &expr, SL("domain"), 0)) { - zephir_read_property(&_7$$6, this_ptr, ZEND_STRL("sqlAliases"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&sqlAliases, &_7$$6); - zephir_memory_observe(&source); - if (UNEXPECTED(!(zephir_array_isset_fetch(&source, &sqlAliases, &columnDomain, 0)))) { - ZEPHIR_INIT_VAR(&_8$$7); - object_init_ex(&_8$$7, phalcon_mvc_model_exception_ce); - zephir_read_property(&_9$$7, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_10$$7); - ZEPHIR_CONCAT_SVSV(&_10$$7, "Unknown model or alias '", &columnDomain, "' (11), when preparing: ", &_9$$7); - ZEPHIR_CALL_METHOD(NULL, &_8$$7, "__construct", NULL, 33, &_10$$7); - zephir_check_call_status(); - zephir_throw_exception_debug(&_8$$7, "phalcon/Mvc/Model/Query.zep", 2960); - ZEPHIR_MM_RESTORE(); - return; +pp4: + ++PPCURSOR; +pp5: + { + status = PHQL_SCANNER_RETCODE_ERR; + break; } - if (ZEPHIR_GLOBAL(orm).column_renaming) { - zephir_read_property(&_11$$8, this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&sqlAliasesModelsInstances, &_11$$8); - zephir_memory_observe(&model); - if (UNEXPECTED(!(zephir_array_isset_fetch(&model, &sqlAliasesModelsInstances, &columnDomain, 0)))) { - ZEPHIR_INIT_VAR(&_12$$9); - object_init_ex(&_12$$9, phalcon_mvc_model_exception_ce); - zephir_read_property(&_13$$9, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_14$$9); - ZEPHIR_CONCAT_SVSV(&_14$$9, "There is no model related to model or alias '", &columnDomain, "', when executing: ", &_13$$9); - ZEPHIR_CALL_METHOD(NULL, &_12$$9, "__construct", NULL, 33, &_14$$9); - zephir_check_call_status(); - zephir_throw_exception_debug(&_12$$9, "phalcon/Mvc/Model/Query.zep", 2979); - ZEPHIR_MM_RESTORE(); - return; +pp6: + ppch = *++PPCURSOR; + switch (ppch) { + case '\t': + case '\n': + case '\r': + case ' ': goto pp6; + default: goto pp8; } - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getreversecolumnmap", NULL, 0, &model); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&columnMap); - ZVAL_NULL(&columnMap); +pp8: + { + token->opcode = PHQL_T_IGNORE; + return 0; } - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - zephir_memory_observe(&realColumnName); - if (UNEXPECTED(!(zephir_array_isset_fetch(&realColumnName, &columnMap, &columnName, 0)))) { - ZEPHIR_INIT_VAR(&_15$$12); - object_init_ex(&_15$$12, phalcon_mvc_model_exception_ce); - zephir_read_property(&_16$$12, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_17$$12); - ZEPHIR_CONCAT_SVSVSV(&_17$$12, "Column '", &columnName, "' doesn't belong to the model or alias '", &columnDomain, "', when executing: ", &_16$$12); - ZEPHIR_CALL_METHOD(NULL, &_15$$12, "__construct", NULL, 33, &_17$$12); - zephir_check_call_status(); - zephir_throw_exception_debug(&_15$$12, "phalcon/Mvc/Model/Query.zep", 2991); - ZEPHIR_MM_RESTORE(); - return; +pp9: + ppch = *++PPCURSOR; + switch (ppch) { + case '!': goto pp80; + case '=': goto pp82; + default: goto pp10; } - } else { - ZEPHIR_CPY_WRT(&realColumnName, &columnName); +pp10: + { + token->opcode = PHQL_T_NOT; + return 0; } - } else { - number = 0; - ZEPHIR_INIT_VAR(&hasModel); - ZVAL_BOOL(&hasModel, 0); - zephir_read_property(&_18$$14, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_18$$14, 0, "phalcon/Mvc/Model/Query.zep", 3025); - if (Z_TYPE_P(&_18$$14) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_18$$14), _19$$14) +pp11: + ppaccept = 0; + ppch = *(PPMARKER = ++PPCURSOR); + if (ppch <= 0x00) goto pp5; + goto pp85; +pp12: + ++PPCURSOR; { - ZEPHIR_INIT_NVAR(&model); - ZVAL_COPY(&model, _19$$14); - ZEPHIR_CALL_METHOD(&_21$$15, &metaData, "hasattribute", &_22, 0, &model, &columnName); - zephir_check_call_status(); - if (zephir_is_true(&_21$$15)) { - number++; - if (UNEXPECTED(number > 1)) { - ZEPHIR_INIT_NVAR(&_23$$17); - object_init_ex(&_23$$17, phalcon_mvc_model_exception_ce); - zephir_read_property(&_24$$17, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_25$$17); - ZEPHIR_CONCAT_SVSV(&_25$$17, "The column '", &columnName, "' is ambiguous, when preparing: ", &_24$$17); - ZEPHIR_CALL_METHOD(NULL, &_23$$17, "__construct", NULL, 33, &_25$$17); - zephir_check_call_status(); - zephir_throw_exception_debug(&_23$$17, "phalcon/Mvc/Model/Query.zep", 3014); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CPY_WRT(&hasModel, &model); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_18$$14, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_20$$14, &_18$$14, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_20$$14)) { - break; - } - ZEPHIR_CALL_METHOD(&model, &_18$$14, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_26$$18, &metaData, "hasattribute", &_27, 0, &model, &columnName); - zephir_check_call_status(); - if (zephir_is_true(&_26$$18)) { - number++; - if (UNEXPECTED(number > 1)) { - ZEPHIR_INIT_NVAR(&_28$$20); - object_init_ex(&_28$$20, phalcon_mvc_model_exception_ce); - zephir_read_property(&_29$$20, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_30$$20); - ZEPHIR_CONCAT_SVSV(&_30$$20, "The column '", &columnName, "' is ambiguous, when preparing: ", &_29$$20); - ZEPHIR_CALL_METHOD(NULL, &_28$$20, "__construct", NULL, 33, &_30$$20); - zephir_check_call_status(); - zephir_throw_exception_debug(&_28$$20, "phalcon/Mvc/Model/Query.zep", 3014); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CPY_WRT(&hasModel, &model); - } - ZEPHIR_CALL_METHOD(NULL, &_18$$14, "next", NULL, 0); - zephir_check_call_status(); + token->opcode = PHQL_T_MOD; + return 0; + } +pp14: + ppch = *++PPCURSOR; + switch (ppch) { + case '&': goto pp90; + default: goto pp15; } +pp15: + { + token->opcode = PHQL_T_BITWISE_AND; + return 0; } - ZEPHIR_INIT_NVAR(&model); - if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&hasModel))) { - ZEPHIR_INIT_VAR(&_31$$21); - object_init_ex(&_31$$21, phalcon_mvc_model_exception_ce); - zephir_read_property(&_32$$21, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_33$$21); - ZEPHIR_CONCAT_SVSV(&_33$$21, "Column '", &columnName, "' doesn't belong to any of the selected models (1), when preparing: ", &_32$$21); - ZEPHIR_CALL_METHOD(NULL, &_31$$21, "__construct", NULL, 33, &_33$$21); - zephir_check_call_status(); - zephir_throw_exception_debug(&_31$$21, "phalcon/Mvc/Model/Query.zep", 3028); - ZEPHIR_MM_RESTORE(); - return; +pp16: + ppaccept = 0; + ppch = *(PPMARKER = ++PPCURSOR); + if (ppch <= 0x00) goto pp5; + goto pp93; +pp17: + ++PPCURSOR; + { + token->opcode = PHQL_T_PARENTHESES_OPEN; + return 0; } - zephir_read_property(&_34$$14, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&models, &_34$$14); - if (UNEXPECTED(Z_TYPE_P(&models) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The models list was not loaded correctly", "phalcon/Mvc/Model/Query.zep", 3039); - return; +pp19: + ++PPCURSOR; + { + token->opcode = PHQL_T_PARENTHESES_CLOSE; + return 0; } - ZEPHIR_INIT_VAR(&className); - zephir_get_class(&className, &hasModel, 0); - ZEPHIR_OBS_NVAR(&source); - if (UNEXPECTED(!(zephir_array_isset_fetch(&source, &models, &className, 0)))) { - ZEPHIR_INIT_VAR(&_35$$23); - object_init_ex(&_35$$23, phalcon_mvc_model_exception_ce); - zephir_read_property(&_36$$23, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_37$$23); - ZEPHIR_CONCAT_SVSV(&_37$$23, "Can't obtain model's source from models list: '", &className, "', when preparing: ", &_36$$23); - ZEPHIR_CALL_METHOD(NULL, &_35$$23, "__construct", NULL, 33, &_37$$23); - zephir_check_call_status(); - zephir_throw_exception_debug(&_35$$23, "phalcon/Mvc/Model/Query.zep", 3050); - ZEPHIR_MM_RESTORE(); - return; +pp21: + ++PPCURSOR; + { + token->opcode = PHQL_T_MUL; + return 0; } - if (ZEPHIR_GLOBAL(orm).column_renaming) { - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getreversecolumnmap", NULL, 0, &hasModel); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&columnMap); - ZVAL_NULL(&columnMap); - } - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&realColumnName); - if (UNEXPECTED(!(zephir_array_isset_fetch(&realColumnName, &columnMap, &columnName, 0)))) { - ZEPHIR_INIT_VAR(&_38$$27); - object_init_ex(&_38$$27, phalcon_mvc_model_exception_ce); - zephir_read_property(&_39$$27, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_40$$27); - ZEPHIR_CONCAT_SVSV(&_40$$27, "Column '", &columnName, "' doesn't belong to any of the selected models (3), when preparing: ", &_39$$27); - ZEPHIR_CALL_METHOD(NULL, &_38$$27, "__construct", NULL, 33, &_40$$27); - zephir_check_call_status(); - zephir_throw_exception_debug(&_38$$27, "phalcon/Mvc/Model/Query.zep", 3069); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&realColumnName, &columnName); +pp23: + ++PPCURSOR; + { + token->opcode = PHQL_T_ADD; + return 0; } - } - zephir_create_array(return_value, 4, 0); - add_assoc_stringl_ex(return_value, SL("type"), SL("qualified")); - zephir_array_update_string(return_value, SL("domain"), &source, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("name"), &realColumnName, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("balias"), &columnName, PH_COPY | PH_SEPARATE); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getReadConnection) -{ - zend_bool _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval intermediate, bindParams, bindTypes; - zval *model, model_sub, *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, connection, transaction, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&transaction); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY_OR_NULL(intermediate) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 3, &model, &intermediate_param, &bindParams_param, &bindTypes_param); - if (!intermediate_param) { - ZEPHIR_INIT_VAR(&intermediate); - } else { - zephir_get_arrval(&intermediate, intermediate_param); - } - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - } else { - zephir_get_arrval(&bindParams, bindParams_param); - } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - } else { - zephir_get_arrval(&bindTypes, bindTypes_param); - } - ZEPHIR_INIT_VAR(&connection); - ZVAL_NULL(&connection); - zephir_read_property(&_0, this_ptr, ZEND_STRL("transaction"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&transaction, &_0); - _1 = Z_TYPE_P(&transaction) == IS_OBJECT; - if (_1) { - _1 = zephir_instance_of_ev(&transaction, phalcon_mvc_model_transactioninterface_ce); - } - if (_1) { - ZEPHIR_RETURN_CALL_METHOD(&transaction, "getconnection", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); - } - if ((zephir_method_exists_ex(model, ZEND_STRL("selectreadconnection")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(&connection, model, "selectreadconnection", NULL, 0, &intermediate, &bindParams, &bindTypes); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&connection) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "selectReadConnection did not return a connection", "phalcon/Mvc/Model/Query.zep", 3113); - return; +pp25: + ++PPCURSOR; + { + token->opcode = PHQL_T_COMMA; + return 0; } - RETURN_CCTOR(&connection); - } - ZEPHIR_RETURN_CALL_METHOD(model, "getreadconnection", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getRelatedRecords) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval intermediate, bindParams, bindTypes, _0, _1; - zval *model, model_sub, *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, selectIr, whereConditions, limitConditions, query, _2, _3, _4, _5, _6; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&selectIr); - ZVAL_UNDEF(&whereConditions); - ZVAL_UNDEF(&limitConditions); - ZVAL_UNDEF(&query); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ARRAY(intermediate) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 0, &model, &intermediate_param, &bindParams_param, &bindTypes_param); - zephir_get_arrval(&intermediate, intermediate_param); - zephir_get_arrval(&bindParams, bindParams_param); - zephir_get_arrval(&bindTypes, bindTypes_param); - ZEPHIR_INIT_VAR(&selectIr); - zephir_create_array(&selectIr, 3, 0); - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 1, 0); - ZEPHIR_INIT_VAR(&_1); - zephir_create_array(&_1, 3, 0); - add_assoc_stringl_ex(&_1, SL("type"), SL("object")); - ZEPHIR_INIT_VAR(&_2); - zephir_get_class(&_2, model, 0); - zephir_array_update_string(&_1, SL("model"), &_2, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_3, model, "getsource", NULL, 0); - zephir_check_call_status(); - zephir_array_update_string(&_1, SL("column"), &_3, PH_COPY | PH_SEPARATE); - zephir_array_fast_append(&_0, &_1); - zephir_array_update_string(&selectIr, SL("columns"), &_0, PH_COPY | PH_SEPARATE); - zephir_memory_observe(&_4); - zephir_array_fetch_string(&_4, &intermediate, SL("models"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3143); - zephir_array_update_string(&selectIr, SL("models"), &_4, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_4); - zephir_array_fetch_string(&_4, &intermediate, SL("tables"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3145); - zephir_array_update_string(&selectIr, SL("tables"), &_4, PH_COPY | PH_SEPARATE); - zephir_memory_observe(&whereConditions); - if (zephir_array_isset_string_fetch(&whereConditions, &intermediate, SL("where"), 0)) { - zephir_array_update_string(&selectIr, SL("where"), &whereConditions, PH_COPY | PH_SEPARATE); - } - zephir_memory_observe(&limitConditions); - if (zephir_array_isset_string_fetch(&limitConditions, &intermediate, SL("limit"), 0)) { - zephir_array_update_string(&selectIr, SL("limit"), &limitConditions, PH_COPY | PH_SEPARATE); - } - ZEPHIR_INIT_VAR(&query); - object_init_ex(&query, phalcon_mvc_model_query_ce); - ZEPHIR_CALL_METHOD(NULL, &query, "__construct", NULL, 467); - zephir_check_call_status(); - zephir_read_property(&_5, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &query, "setdi", NULL, 468, &_5); - zephir_check_call_status(); - ZVAL_LONG(&_6, 309); - ZEPHIR_CALL_METHOD(NULL, &query, "settype", NULL, 469, &_6); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &query, "setintermediate", NULL, 470, &selectIr); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&query, "execute", NULL, 471, &bindParams, &bindTypes); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getSelectColumn) -{ - zend_string *_4$$4; - zend_ulong _3$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_6 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *column_param = NULL, columnType, sqlAliases, modelName, source, columnDomain, sqlColumnAlias, preparedAlias, sqlExprColumn, sqlAliasesModels, columnData, balias, eager, _19, _20, _0$$4, *_1$$4, _2$$4, _5$$5, _7$$6, _8$$7, _9$$7, _10$$8, _11$$10, _15$$10, _12$$11, _13$$11, _14$$11, _16$$15, _17$$16, _18$$18; - zval column, sqlColumns, sqlColumn; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&sqlColumns); - ZVAL_UNDEF(&sqlColumn); - ZVAL_UNDEF(&columnType); - ZVAL_UNDEF(&sqlAliases); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&columnDomain); - ZVAL_UNDEF(&sqlColumnAlias); - ZVAL_UNDEF(&preparedAlias); - ZVAL_UNDEF(&sqlExprColumn); - ZVAL_UNDEF(&sqlAliasesModels); - ZVAL_UNDEF(&columnData); - ZVAL_UNDEF(&balias); - ZVAL_UNDEF(&eager); - ZVAL_UNDEF(&_19); - ZVAL_UNDEF(&_20); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_8$$7); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_10$$8); - ZVAL_UNDEF(&_11$$10); - ZVAL_UNDEF(&_15$$10); - ZVAL_UNDEF(&_12$$11); - ZVAL_UNDEF(&_13$$11); - ZVAL_UNDEF(&_14$$11); - ZVAL_UNDEF(&_16$$15); - ZVAL_UNDEF(&_17$$16); - ZVAL_UNDEF(&_18$$18); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(column) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &column_param); - ZEPHIR_OBS_COPY_OR_DUP(&column, column_param); - zephir_memory_observe(&columnType); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&columnType, &column, SL("type"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 3185); - return; - } - ZEPHIR_INIT_VAR(&sqlColumns); - array_init(&sqlColumns); - zephir_memory_observe(&eager); - zephir_array_isset_string_fetch(&eager, &column, SL("eager"), 0); - if (ZEPHIR_IS_LONG(&columnType, 352)) { - zephir_read_property(&_0$$4, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_0$$4, 0, "phalcon/Mvc/Model/Query.zep", 3215); - if (Z_TYPE_P(&_0$$4) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_0$$4), _3$$4, _4$$4, _1$$4) +pp27: + ++PPCURSOR; { - ZEPHIR_INIT_NVAR(&modelName); - if (_4$$4 != NULL) { - ZVAL_STR_COPY(&modelName, _4$$4); - } else { - ZVAL_LONG(&modelName, _3$$4); - } - ZEPHIR_INIT_NVAR(&source); - ZVAL_COPY(&source, _1$$4); - ZEPHIR_INIT_NVAR(&sqlColumn); - zephir_create_array(&sqlColumn, 4, 0); - add_assoc_stringl_ex(&sqlColumn, SL("type"), SL("object")); - zephir_array_update_string(&sqlColumn, SL("model"), &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlColumn, SL("column"), &source, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_FUNCTION(&_5$$5, "lcfirst", &_6, 76, &modelName); - zephir_check_call_status(); - zephir_array_update_string(&sqlColumn, SL("balias"), &_5$$5, PH_COPY | PH_SEPARATE); - if (Z_TYPE_P(&eager) != IS_NULL) { - zephir_array_update_string(&sqlColumn, SL("eager"), &eager, PH_COPY | PH_SEPARATE); - zephir_array_fetch_string(&_7$$6, &column, SL("eagerType"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3209); - zephir_array_update_string(&sqlColumn, SL("eagerType"), &_7$$6, PH_COPY | PH_SEPARATE); - } - zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3212); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_0$$4, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2$$4, &_0$$4, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2$$4)) { - break; - } - ZEPHIR_CALL_METHOD(&modelName, &_0$$4, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &_0$$4, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_8$$7); - zephir_create_array(&_8$$7, 4, 0); - add_assoc_stringl_ex(&_8$$7, SL("type"), SL("object")); - zephir_array_update_string(&_8$$7, SL("model"), &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_8$$7, SL("column"), &source, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_FUNCTION(&_9$$7, "lcfirst", &_6, 76, &modelName); - zephir_check_call_status(); - zephir_array_update_string(&_8$$7, SL("balias"), &_9$$7, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&sqlColumn, &_8$$7); - if (Z_TYPE_P(&eager) != IS_NULL) { - zephir_array_update_string(&sqlColumn, SL("eager"), &eager, PH_COPY | PH_SEPARATE); - zephir_array_fetch_string(&_10$$8, &column, SL("eagerType"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3209); - zephir_array_update_string(&sqlColumn, SL("eagerType"), &_10$$8, PH_COPY | PH_SEPARATE); - } - zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3212); - ZEPHIR_CALL_METHOD(NULL, &_0$$4, "next", NULL, 0); - zephir_check_call_status(); + token->opcode = PHQL_T_SUB; + return 0; + } +pp29: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto pp95; + default: goto pp30; } +pp30: + { + token->opcode = PHQL_T_DOT; + return 0; } - ZEPHIR_INIT_NVAR(&source); - ZEPHIR_INIT_NVAR(&modelName); - RETURN_CTOR(&sqlColumns); - } - if (UNEXPECTED(!(zephir_array_isset_string(&column, SL("column"))))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 3219); - return; - } - if (ZEPHIR_IS_LONG(&columnType, 353)) { - zephir_read_property(&_11$$10, this_ptr, ZEND_STRL("sqlAliases"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&sqlAliases, &_11$$10); - zephir_memory_observe(&columnDomain); - zephir_array_fetch_string(&columnDomain, &column, SL("column"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3231); - ZEPHIR_OBS_NVAR(&source); - if (UNEXPECTED(!(zephir_array_isset_fetch(&source, &sqlAliases, &columnDomain, 0)))) { - ZEPHIR_INIT_VAR(&_12$$11); - object_init_ex(&_12$$11, phalcon_mvc_model_exception_ce); - zephir_read_property(&_13$$11, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_14$$11); - ZEPHIR_CONCAT_SVSV(&_14$$11, "Unknown model or alias '", &columnDomain, "' (2), when preparing: ", &_13$$11); - ZEPHIR_CALL_METHOD(NULL, &_12$$11, "__construct", NULL, 33, &_14$$11); - zephir_check_call_status(); - zephir_throw_exception_debug(&_12$$11, "phalcon/Mvc/Model/Query.zep", 3236); - ZEPHIR_MM_RESTORE(); - return; +pp31: + ++PPCURSOR; + { + token->opcode = PHQL_T_DIV; + return 0; } - ZEPHIR_CPY_WRT(&sqlColumnAlias, &source); - zephir_memory_observe(&preparedAlias); - zephir_array_isset_string_fetch(&preparedAlias, &column, SL("balias"), 0); - zephir_read_property(&_11$$10, this_ptr, ZEND_STRL("sqlAliasesModels"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&sqlAliasesModels, &_11$$10); - ZEPHIR_OBS_NVAR(&modelName); - zephir_array_fetch(&modelName, &sqlAliasesModels, &columnDomain, PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3250); - if (Z_TYPE_P(&preparedAlias) != IS_STRING) { - if (ZEPHIR_IS_EQUAL(&columnDomain, &modelName)) { - ZEPHIR_CALL_FUNCTION(&preparedAlias, "lcfirst", &_6, 76, &modelName); - zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&preparedAlias, &columnDomain); +pp33: + ppch = *++PPCURSOR; + switch (ppch) { + case '.': goto pp95; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto pp33; + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'x': goto pp98; + default: goto pp35; } +pp35: + { + token->opcode = PHQL_T_INTEGER; + token->value = estrndup(q, PPCURSOR - q); + token->len = PPCURSOR - q; + q = PPCURSOR; + return 0; } - ZEPHIR_INIT_VAR(&_15$$10); - zephir_create_array(&_15$$10, 4, 0); - add_assoc_stringl_ex(&_15$$10, SL("type"), SL("object")); - zephir_array_update_string(&_15$$10, SL("model"), &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_15$$10, SL("column"), &sqlColumnAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_15$$10, SL("balias"), &preparedAlias, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&sqlColumn, &_15$$10); - if (Z_TYPE_P(&eager) != IS_NULL) { - zephir_array_update_string(&sqlColumn, SL("eager"), &eager, PH_COPY | PH_SEPARATE); - zephir_array_fetch_string(&_16$$15, &column, SL("eagerType"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3277); - zephir_array_update_string(&sqlColumn, SL("eagerType"), &_16$$15, PH_COPY | PH_SEPARATE); +pp36: + ppaccept = 1; + ppch = *(PPMARKER = ++PPCURSOR); + switch (ppch) { + case '-': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp100; + default: goto pp37; + } +pp37: + { + token->opcode = PHQL_T_COLON; + return 0; } - zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3280); - RETURN_CTOR(&sqlColumns); - } - if (ZEPHIR_IS_LONG(&columnType, 354)) { - ZEPHIR_INIT_VAR(&_17$$16); - zephir_create_array(&_17$$16, 1, 0); - add_assoc_stringl_ex(&_17$$16, SL("type"), SL("scalar")); - ZEPHIR_CPY_WRT(&sqlColumn, &_17$$16); - zephir_memory_observe(&columnData); - zephir_array_fetch_string(&columnData, &column, SL("column"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3294); - ZEPHIR_CALL_METHOD(&sqlExprColumn, this_ptr, "getexpression", NULL, 458, &columnData); - zephir_check_call_status(); - zephir_memory_observe(&balias); - if (zephir_array_isset_string_fetch(&balias, &sqlExprColumn, SL("balias"), 0)) { - zephir_array_update_string(&sqlColumn, SL("balias"), &balias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlColumn, SL("sqlAlias"), &balias, PH_COPY | PH_SEPARATE); +pp38: + ppch = *++PPCURSOR; + switch (ppch) { + case '=': goto pp102; + case '>': goto pp104; + default: goto pp39; + } +pp39: + { + token->opcode = PHQL_T_LESS; + return 0; } - if (Z_TYPE_P(&eager) != IS_NULL) { - zephir_array_update_string(&sqlColumn, SL("eager"), &eager, PH_COPY | PH_SEPARATE); - zephir_array_fetch_string(&_18$$18, &column, SL("eagerType"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3307); - zephir_array_update_string(&sqlColumn, SL("eagerType"), &_18$$18, PH_COPY | PH_SEPARATE); +pp40: + ++PPCURSOR; + { + token->opcode = PHQL_T_EQUALS; + return 0; } - zephir_array_update_string(&sqlColumn, SL("column"), &sqlExprColumn, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3311); - RETURN_CTOR(&sqlColumns); - } - ZEPHIR_INIT_VAR(&_19); - object_init_ex(&_19, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_20); - ZEPHIR_CONCAT_SV(&_20, "Unknown type of column ", &columnType); - ZEPHIR_CALL_METHOD(NULL, &_19, "__construct", NULL, 33, &_20); - zephir_check_call_status(); - zephir_throw_exception_debug(&_19, "phalcon/Mvc/Model/Query.zep", 3316); - ZEPHIR_MM_RESTORE(); - return; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getSingleJoin) -{ - zend_string *_8$$4; - zend_ulong _7$$4; - zval _1$$3, _3$$3, _4$$3, _13$$5, _15$$5, _16$$5, _20$$7, _22$$7, _23$$7; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_12 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *joinType_param = NULL, *joinSource, joinSource_sub, *modelAlias_param = NULL, *joinAlias_param = NULL, *relation, relation_sub, fields, referencedFields, sqlJoinConditions, sqlJoinPartialConditions, position, field, referencedField, _0$$3, _2$$3, *_5$$4, _6$$4, _9$$6, _10$$6, _11$$6, _14$$5, _17$$8, _18$$8, _19$$8, _21$$7; - zval joinType, modelAlias, joinAlias; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&joinType); - ZVAL_UNDEF(&modelAlias); - ZVAL_UNDEF(&joinAlias); - ZVAL_UNDEF(&joinSource_sub); - ZVAL_UNDEF(&relation_sub); - ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&referencedFields); - ZVAL_UNDEF(&sqlJoinConditions); - ZVAL_UNDEF(&sqlJoinPartialConditions); - ZVAL_UNDEF(&position); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&referencedField); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_9$$6); - ZVAL_UNDEF(&_10$$6); - ZVAL_UNDEF(&_11$$6); - ZVAL_UNDEF(&_14$$5); - ZVAL_UNDEF(&_17$$8); - ZVAL_UNDEF(&_18$$8); - ZVAL_UNDEF(&_19$$8); - ZVAL_UNDEF(&_21$$7); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_13$$5); - ZVAL_UNDEF(&_15$$5); - ZVAL_UNDEF(&_16$$5); - ZVAL_UNDEF(&_20$$7); - ZVAL_UNDEF(&_22$$7); - ZVAL_UNDEF(&_23$$7); - ZEND_PARSE_PARAMETERS_START(5, 5) - Z_PARAM_STR(joinType) - Z_PARAM_ZVAL(joinSource) - Z_PARAM_STR(modelAlias) - Z_PARAM_STR(joinAlias) - Z_PARAM_OBJECT_OF_CLASS(relation, phalcon_mvc_model_relationinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 5, 0, &joinType_param, &joinSource, &modelAlias_param, &joinAlias_param, &relation); - if (UNEXPECTED(Z_TYPE_P(joinType_param) != IS_STRING && Z_TYPE_P(joinType_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'joinType' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(joinType_param) == IS_STRING)) { - zephir_get_strval(&joinType, joinType_param); - } else { - ZEPHIR_INIT_VAR(&joinType); - } - zephir_get_strval(&modelAlias, modelAlias_param); - zephir_get_strval(&joinAlias, joinAlias_param); - ZEPHIR_INIT_VAR(&sqlJoinConditions); - ZVAL_NULL(&sqlJoinConditions); - ZEPHIR_CALL_METHOD(&fields, relation, "getfields", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&referencedFields, relation, "getreferencedfields", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&fields) != IS_ARRAY) { - ZEPHIR_INIT_VAR(&_0$$3); - zephir_create_array(&_0$$3, 1, 0); - ZEPHIR_INIT_VAR(&_1$$3); - zephir_create_array(&_1$$3, 4, 0); - add_assoc_stringl_ex(&_1$$3, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_1$$3, SL("op"), SL("=")); - ZEPHIR_INIT_VAR(&_3$$3); - zephir_create_array(&_3$$3, 3, 0); - add_assoc_long_ex(&_3$$3, SL("type"), 355); - zephir_array_update_string(&_3$$3, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_3$$3, SL("name"), &fields, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "getqualified", NULL, 459, &_3$$3); - zephir_check_call_status(); - zephir_array_update_string(&_1$$3, SL("left"), &_2$$3, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_4$$3); - zephir_create_array(&_4$$3, 3, 0); - add_assoc_stringl_ex(&_4$$3, SL("type"), SL("qualified")); - zephir_array_update_string(&_4$$3, SL("domain"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_4$$3, SL("name"), &referencedFields, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "getqualified", NULL, 459, &_4$$3); - zephir_check_call_status(); - zephir_array_update_string(&_1$$3, SL("right"), &_2$$3, PH_COPY | PH_SEPARATE); - zephir_array_fast_append(&_0$$3, &_1$$3); - ZEPHIR_CPY_WRT(&sqlJoinConditions, &_0$$3); - } else { - ZEPHIR_INIT_VAR(&sqlJoinPartialConditions); - array_init(&sqlJoinPartialConditions); - zephir_is_iterable(&fields, 0, "phalcon/Mvc/Model/Query.zep", 3406); - if (Z_TYPE_P(&fields) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&fields), _7$$4, _8$$4, _5$$4) +pp42: + ppch = *++PPCURSOR; + switch (ppch) { + case '=': goto pp106; + default: goto pp43; + } +pp43: { - ZEPHIR_INIT_NVAR(&position); - if (_8$$4 != NULL) { - ZVAL_STR_COPY(&position, _8$$4); - } else { - ZVAL_LONG(&position, _7$$4); - } - ZEPHIR_INIT_NVAR(&field); - ZVAL_COPY(&field, _5$$4); - ZEPHIR_OBS_NVAR(&referencedField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&referencedField, &referencedFields, &position, 0)))) { - ZEPHIR_INIT_NVAR(&_9$$6); - object_init_ex(&_9$$6, phalcon_mvc_model_exception_ce); - zephir_read_property(&_10$$6, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_11$$6); - ZEPHIR_CONCAT_SVSVSV(&_11$$6, "The number of fields must be equal to the number of referenced fields in join ", &modelAlias, "-", &joinAlias, ", when preparing: ", &_10$$6); - ZEPHIR_CALL_METHOD(NULL, &_9$$6, "__construct", &_12, 33, &_11$$6); - zephir_check_call_status(); - zephir_throw_exception_debug(&_9$$6, "phalcon/Mvc/Model/Query.zep", 3378); - ZEPHIR_MM_RESTORE(); - return; + token->opcode = PHQL_T_GREATER; + return 0; + } +pp44: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto pp108; + default: goto pp5; + } +pp45: + ppch = *++PPCURSOR; + switch (ppch) { + case '>': goto pp111; + case '@': goto pp113; + default: goto pp5; + } +pp46: + ppch = *++PPCURSOR; + switch (ppch) { + case 'G': + case 'g': goto pp115; + case 'L': + case 'l': goto pp116; + case 'N': + case 'n': goto pp117; + case 'S': + case 's': goto pp118; + default: goto pp74; + } +pp47: + { + token->value = estrndup(q, PPCURSOR - q); + token->len = PPCURSOR - q; + if (token->len > 2 && !memcmp(token->value, "0x", 2)) { + token->opcode = PHQL_T_HINTEGER; + } else { + int i, alpha = 0; + for (i = 0; i < token->len; i++) { + unsigned char ch = token->value[i]; + if (!((ch >= '0') && (ch <= '9'))) { + alpha = 1; + break; + } } - ZEPHIR_INIT_NVAR(&_13$$5); - zephir_create_array(&_13$$5, 4, 0); - add_assoc_stringl_ex(&_13$$5, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_13$$5, SL("op"), SL("=")); - ZEPHIR_INIT_NVAR(&_15$$5); - zephir_create_array(&_15$$5, 3, 0); - add_assoc_long_ex(&_15$$5, SL("type"), 355); - zephir_array_update_string(&_15$$5, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_15$$5, SL("name"), &field, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_14$$5, this_ptr, "getqualified", NULL, 459, &_15$$5); - zephir_check_call_status(); - zephir_array_update_string(&_13$$5, SL("left"), &_14$$5, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_16$$5); - zephir_create_array(&_16$$5, 3, 0); - add_assoc_stringl_ex(&_16$$5, SL("type"), SL("qualified")); - zephir_array_update_string(&_16$$5, SL("domain"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_16$$5, SL("name"), &referencedField, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_14$$5, this_ptr, "getqualified", NULL, 459, &_16$$5); - zephir_check_call_status(); - zephir_array_update_string(&_13$$5, SL("right"), &_14$$5, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoinPartialConditions, &_13$$5, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3403); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_6$$4, &fields, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_6$$4)) { - break; + if (alpha) { + token->opcode = PHQL_T_IDENTIFIER; + } else { + token->opcode = PHQL_T_INTEGER; } - ZEPHIR_CALL_METHOD(&position, &fields, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&field, &fields, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&referencedField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&referencedField, &referencedFields, &position, 0)))) { - ZEPHIR_INIT_NVAR(&_17$$8); - object_init_ex(&_17$$8, phalcon_mvc_model_exception_ce); - zephir_read_property(&_18$$8, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_19$$8); - ZEPHIR_CONCAT_SVSVSV(&_19$$8, "The number of fields must be equal to the number of referenced fields in join ", &modelAlias, "-", &joinAlias, ", when preparing: ", &_18$$8); - ZEPHIR_CALL_METHOD(NULL, &_17$$8, "__construct", &_12, 33, &_19$$8); - zephir_check_call_status(); - zephir_throw_exception_debug(&_17$$8, "phalcon/Mvc/Model/Query.zep", 3378); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_NVAR(&_20$$7); - zephir_create_array(&_20$$7, 4, 0); - add_assoc_stringl_ex(&_20$$7, SL("type"), SL("binary-op")); - add_assoc_stringl_ex(&_20$$7, SL("op"), SL("=")); - ZEPHIR_INIT_NVAR(&_22$$7); - zephir_create_array(&_22$$7, 3, 0); - add_assoc_long_ex(&_22$$7, SL("type"), 355); - zephir_array_update_string(&_22$$7, SL("domain"), &modelAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_22$$7, SL("name"), &field, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_21$$7, this_ptr, "getqualified", NULL, 459, &_22$$7); - zephir_check_call_status(); - zephir_array_update_string(&_20$$7, SL("left"), &_21$$7, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_23$$7); - zephir_create_array(&_23$$7, 3, 0); - add_assoc_stringl_ex(&_23$$7, SL("type"), SL("qualified")); - zephir_array_update_string(&_23$$7, SL("domain"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_23$$7, SL("name"), &referencedField, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_21$$7, this_ptr, "getqualified", NULL, 459, &_23$$7); - zephir_check_call_status(); - zephir_array_update_string(&_20$$7, SL("right"), &_21$$7, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlJoinPartialConditions, &_20$$7, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3403); - ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); - zephir_check_call_status(); } + q = PPCURSOR; + return 0; } - ZEPHIR_INIT_NVAR(&field); - ZEPHIR_INIT_NVAR(&position); - } - zephir_create_array(return_value, 3, 0); - zephir_array_update_string(return_value, SL("type"), &joinType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("source"), joinSource, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("conditions"), &sqlJoinConditions, PH_COPY | PH_SEPARATE); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getTable) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval qualifiedName; - zval *manager, manager_sub, *qualifiedName_param = NULL, modelName, model, source, schema; - - ZVAL_UNDEF(&manager_sub); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&qualifiedName); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(manager, phalcon_mvc_model_managerinterface_ce) - Z_PARAM_ARRAY(qualifiedName) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &manager, &qualifiedName_param); - zephir_get_arrval(&qualifiedName, qualifiedName_param); - zephir_memory_observe(&modelName); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&modelName, &qualifiedName, SL("name"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 3428); - return; - } - ZEPHIR_CALL_METHOD(&model, manager, "load", NULL, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&schema)) { - zephir_create_array(return_value, 2, 0); - zephir_array_fast_append(return_value, &schema); - zephir_array_fast_append(return_value, &source); - RETURN_MM(); - } - RETURN_CCTOR(&source); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, getWriteConnection) -{ - zend_bool _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval intermediate, bindParams, bindTypes; - zval *model, model_sub, *intermediate_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, connection, transaction, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&transaction); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&intermediate); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY_OR_NULL(intermediate) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 3, &model, &intermediate_param, &bindParams_param, &bindTypes_param); - if (!intermediate_param) { - ZEPHIR_INIT_VAR(&intermediate); - } else { - zephir_get_arrval(&intermediate, intermediate_param); - } - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - } else { - zephir_get_arrval(&bindParams, bindParams_param); - } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - } else { - zephir_get_arrval(&bindTypes, bindTypes_param); - } - ZEPHIR_INIT_VAR(&connection); - ZVAL_NULL(&connection); - zephir_read_property(&_0, this_ptr, ZEND_STRL("transaction"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&transaction, &_0); - _1 = Z_TYPE_P(&transaction) == IS_OBJECT; - if (_1) { - _1 = zephir_instance_of_ev(&transaction, phalcon_mvc_model_transactioninterface_ce); - } - if (_1) { - ZEPHIR_RETURN_CALL_METHOD(&transaction, "getconnection", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); - } - if ((zephir_method_exists_ex(model, ZEND_STRL("selectwriteconnection")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(&connection, model, "selectwriteconnection", NULL, 0, &intermediate, &bindParams, &bindTypes); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&connection) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "selectWriteConnection did not return a connection", "phalcon/Mvc/Model/Query.zep", 3466); - return; - } - RETURN_CCTOR(&connection); - } - ZEPHIR_RETURN_CALL_METHOD(model, "getwriteconnection", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, _prepareDelete) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$null, ast, delete, tables, models, modelsInstances, sqlTables, sqlModels, sqlAliases, sqlAliasesModelsInstances, deleteTables, manager, table, qualifiedName, modelName, model, source, schema, completeSource, alias, sqlDelete, where, limit, _0, *_1, _2, _4$$8, _5$$9, _7$$13, _8$$14, _9$$17, _10$$17, _11$$18; - zephir_fcall_cache_entry *_3 = NULL, *_6 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&ast); - ZVAL_UNDEF(&delete); - ZVAL_UNDEF(&tables); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&modelsInstances); - ZVAL_UNDEF(&sqlTables); - ZVAL_UNDEF(&sqlModels); - ZVAL_UNDEF(&sqlAliases); - ZVAL_UNDEF(&sqlAliasesModelsInstances); - ZVAL_UNDEF(&deleteTables); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&table); - ZVAL_UNDEF(&qualifiedName); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&completeSource); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&sqlDelete); - ZVAL_UNDEF(&where); - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4$$8); - ZVAL_UNDEF(&_5$$9); - ZVAL_UNDEF(&_7$$13); - ZVAL_UNDEF(&_8$$14); - ZVAL_UNDEF(&_9$$17); - ZVAL_UNDEF(&_10$$17); - ZVAL_UNDEF(&_11$$18); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("ast"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&ast, &_0); - zephir_memory_observe(&delete); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&delete, &ast, SL("delete"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted DELETE AST", "phalcon/Mvc/Model/Query.zep", 3488); - return; - } - zephir_memory_observe(&tables); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&tables, &delete, SL("tables"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted DELETE AST", "phalcon/Mvc/Model/Query.zep", 3492); - return; - } - ZEPHIR_INIT_VAR(&models); - array_init(&models); - ZEPHIR_INIT_VAR(&modelsInstances); - array_init(&modelsInstances); - ZEPHIR_INIT_VAR(&sqlTables); - array_init(&sqlTables); - ZEPHIR_INIT_VAR(&sqlModels); - array_init(&sqlModels); - ZEPHIR_INIT_VAR(&sqlAliases); - array_init(&sqlAliases); - ZEPHIR_INIT_VAR(&sqlAliasesModelsInstances); - array_init(&sqlAliasesModelsInstances); - if (!(zephir_array_isset_long(&tables, 0))) { - ZEPHIR_INIT_VAR(&deleteTables); - zephir_create_array(&deleteTables, 1, 0); - zephir_array_fast_append(&deleteTables, &tables); - } else { - ZEPHIR_CPY_WRT(&deleteTables, &tables); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - zephir_is_iterable(&deleteTables, 0, "phalcon/Mvc/Model/Query.zep", 3552); - if (Z_TYPE_P(&deleteTables) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&deleteTables), _1) - { - ZEPHIR_INIT_NVAR(&table); - ZVAL_COPY(&table, _1); - ZEPHIR_OBS_NVAR(&qualifiedName); - zephir_array_fetch_string(&qualifiedName, &table, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3516); - ZEPHIR_OBS_NVAR(&modelName); - zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3517); - ZEPHIR_CALL_METHOD(&model, &manager, "load", &_3, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&completeSource); - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_NVAR(&_4$$8); - zephir_create_array(&_4$$8, 2, 0); - zephir_array_fast_append(&_4$$8, &source); - zephir_array_fast_append(&_4$$8, &schema); - ZEPHIR_CPY_WRT(&completeSource, &_4$$8); - } else { - ZEPHIR_INIT_NVAR(&_5$$9); - zephir_create_array(&_5$$9, 2, 0); - zephir_array_fast_append(&_5$$9, &source); - zephir_array_fast_append(&_5$$9, &__$null); - ZEPHIR_CPY_WRT(&completeSource, &_5$$9); +pp48: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp120; + case 'Y': + case 'y': goto pp121; + default: goto pp74; } - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &table, SL("alias"), 0)) { - zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); - zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3534); - zephir_array_append(&sqlTables, &completeSource, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3535); - zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &alias, &modelName, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&sqlAliases, &modelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlTables, &source, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3541); - zephir_array_update_zval(&models, &modelName, &source, PH_COPY | PH_SEPARATE); +pp49: + ppch = *++PPCURSOR; + switch (ppch) { + case 'A': + case 'a': goto pp123; + case 'O': + case 'o': goto pp124; + case 'R': + case 'r': goto pp125; + default: goto pp74; } - zephir_array_append(&sqlModels, &modelName, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3545); - zephir_array_update_zval(&modelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &deleteTables, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &deleteTables, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; +pp50: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp126; + case 'I': + case 'i': goto pp127; + default: goto pp74; } - ZEPHIR_CALL_METHOD(&table, &deleteTables, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&qualifiedName); - zephir_array_fetch_string(&qualifiedName, &table, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3516); - ZEPHIR_OBS_NVAR(&modelName); - zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3517); - ZEPHIR_CALL_METHOD(&model, &manager, "load", &_6, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_NVAR(&_7$$13); - zephir_create_array(&_7$$13, 2, 0); - zephir_array_fast_append(&_7$$13, &source); - zephir_array_fast_append(&_7$$13, &schema); - ZEPHIR_CPY_WRT(&completeSource, &_7$$13); - } else { - ZEPHIR_INIT_NVAR(&_8$$14); - zephir_create_array(&_8$$14, 2, 0); - zephir_array_fast_append(&_8$$14, &source); - zephir_array_fast_append(&_8$$14, &__$null); - ZEPHIR_CPY_WRT(&completeSource, &_8$$14); - } - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &table, SL("alias"), 0)) { - zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); - zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3534); - zephir_array_append(&sqlTables, &completeSource, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3535); - zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &alias, &modelName, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&sqlAliases, &modelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlTables, &source, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3541); - zephir_array_update_zval(&models, &modelName, &source, PH_COPY | PH_SEPARATE); - } - zephir_array_append(&sqlModels, &modelName, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3545); - zephir_array_update_zval(&modelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &deleteTables, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&table); - zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &models); - zephir_update_property_zval(this_ptr, ZEND_STRL("modelsInstances"), &modelsInstances); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliases"), &sqlAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &sqlAliasesModelsInstances); - ZEPHIR_INIT_VAR(&sqlDelete); - array_init(&sqlDelete); - zephir_array_update_string(&sqlDelete, SL("tables"), &sqlTables, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlDelete, SL("models"), &sqlModels, PH_COPY | PH_SEPARATE); - zephir_memory_observe(&where); - if (zephir_array_isset_string_fetch(&where, &ast, SL("where"), 0)) { - ZVAL_BOOL(&_10$$17, 1); - ZEPHIR_CALL_METHOD(&_9$$17, this_ptr, "getexpression", NULL, 458, &where, &_10$$17); - zephir_check_call_status(); - zephir_array_update_string(&sqlDelete, SL("where"), &_9$$17, PH_COPY | PH_SEPARATE); - } - zephir_memory_observe(&limit); - if (zephir_array_isset_string_fetch(&limit, &ast, SL("limit"), 0)) { - ZEPHIR_CALL_METHOD(&_11$$18, this_ptr, "getlimitclause", NULL, 472, &limit); - zephir_check_call_status(); - zephir_array_update_string(&sqlDelete, SL("limit"), &_11$$18, PH_COPY | PH_SEPARATE); - } - RETURN_CCTOR(&sqlDelete); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, _prepareInsert) -{ - zval _5$$7, _10$$8; - zend_bool notQuoting = 0; - zval ast, qualifiedName, manager, modelName, model, source, schema, exprValues, exprValue, sqlInsert, metaData, fields, sqlFields, field, name, _0, _2, *_3, _4, _1$$6, _6$$7, _7$$7, _8$$7, _11$$8, _12$$8, _13$$8, *_14$$9, _15$$9, _16$$10, _18$$11, _19$$11, _20$$11, _22$$12, _24$$13, _25$$13, _26$$13; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_9 = NULL, *_17 = NULL, *_21 = NULL, *_23 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&ast); - ZVAL_UNDEF(&qualifiedName); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&exprValues); - ZVAL_UNDEF(&exprValue); - ZVAL_UNDEF(&sqlInsert); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&sqlFields); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1$$6); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_7$$7); - ZVAL_UNDEF(&_8$$7); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_12$$8); - ZVAL_UNDEF(&_13$$8); - ZVAL_UNDEF(&_15$$9); - ZVAL_UNDEF(&_16$$10); - ZVAL_UNDEF(&_18$$11); - ZVAL_UNDEF(&_19$$11); - ZVAL_UNDEF(&_20$$11); - ZVAL_UNDEF(&_22$$12); - ZVAL_UNDEF(&_24$$13); - ZVAL_UNDEF(&_25$$13); - ZVAL_UNDEF(&_26$$13); - ZVAL_UNDEF(&_5$$7); - ZVAL_UNDEF(&_10$$8); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("ast"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&ast, &_0); - if (UNEXPECTED(!(zephir_array_isset_string(&ast, SL("qualifiedName"))))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted INSERT AST", "phalcon/Mvc/Model/Query.zep", 3586); - return; - } - if (UNEXPECTED(!(zephir_array_isset_string(&ast, SL("values"))))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted INSERT AST", "phalcon/Mvc/Model/Query.zep", 3590); - return; - } - zephir_memory_observe(&qualifiedName); - zephir_array_fetch_string(&qualifiedName, &ast, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3593); - if (UNEXPECTED(!(zephir_array_isset_string(&qualifiedName, SL("name"))))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted INSERT AST", "phalcon/Mvc/Model/Query.zep", 3597); - return; - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - zephir_memory_observe(&modelName); - zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3601); - ZEPHIR_CALL_METHOD(&model, &manager, "load", NULL, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_VAR(&_1$$6); - zephir_create_array(&_1$$6, 2, 0); - zephir_array_fast_append(&_1$$6, &schema); - zephir_array_fast_append(&_1$$6, &source); - ZEPHIR_CPY_WRT(&source, &_1$$6); - } - notQuoting = 0; - ZEPHIR_INIT_VAR(&exprValues); - array_init(&exprValues); - zephir_array_fetch_string(&_2, &ast, SL("values"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3614); - zephir_is_iterable(&_2, 0, "phalcon/Mvc/Model/Query.zep", 3622); - if (Z_TYPE_P(&_2) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_2), _3) - { - ZEPHIR_INIT_NVAR(&exprValue); - ZVAL_COPY(&exprValue, _3); - ZEPHIR_INIT_NVAR(&_5$$7); - zephir_create_array(&_5$$7, 2, 0); - ZEPHIR_OBS_NVAR(&_6$$7); - zephir_array_fetch_string(&_6$$7, &exprValue, SL("type"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3617); - zephir_array_update_string(&_5$$7, SL("type"), &_6$$7, PH_COPY | PH_SEPARATE); - if (notQuoting) { - ZVAL_BOOL(&_8$$7, 1); - } else { - ZVAL_BOOL(&_8$$7, 0); +pp51: + ppch = *++PPCURSOR; + switch (ppch) { + case 'L': + case 'l': goto pp128; + case 'N': + case 'n': goto pp129; + case 'X': goto pp130; + case 'x': goto pp131; + default: goto pp74; } - ZEPHIR_CALL_METHOD(&_7$$7, this_ptr, "getexpression", &_9, 458, &exprValue, &_8$$7); - zephir_check_call_status(); - zephir_array_update_string(&_5$$7, SL("value"), &_7$$7, PH_COPY | PH_SEPARATE); - zephir_array_append(&exprValues, &_5$$7, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3619); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_2, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_4, &_2, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_4)) { - break; +pp52: + ppch = *++PPCURSOR; + switch (ppch) { + case 'A': + case 'a': goto pp132; + case 'O': + case 'o': goto pp133; + case 'R': + case 'r': goto pp134; + case 'U': + case 'u': goto pp135; + default: goto pp74; } - ZEPHIR_CALL_METHOD(&exprValue, &_2, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_10$$8); - zephir_create_array(&_10$$8, 2, 0); - ZEPHIR_OBS_NVAR(&_11$$8); - zephir_array_fetch_string(&_11$$8, &exprValue, SL("type"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3617); - zephir_array_update_string(&_10$$8, SL("type"), &_11$$8, PH_COPY | PH_SEPARATE); - if (notQuoting) { - ZVAL_BOOL(&_13$$8, 1); - } else { - ZVAL_BOOL(&_13$$8, 0); - } - ZEPHIR_CALL_METHOD(&_12$$8, this_ptr, "getexpression", &_9, 458, &exprValue, &_13$$8); - zephir_check_call_status(); - zephir_array_update_string(&_10$$8, SL("value"), &_12$$8, PH_COPY | PH_SEPARATE); - zephir_array_append(&exprValues, &_10$$8, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3619); - ZEPHIR_CALL_METHOD(NULL, &_2, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&exprValue); - ZEPHIR_INIT_VAR(&sqlInsert); - zephir_create_array(&sqlInsert, 2, 0); - zephir_array_update_string(&sqlInsert, SL("model"), &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlInsert, SL("table"), &source, PH_COPY | PH_SEPARATE); - zephir_read_property(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&metaData, &_0); - zephir_memory_observe(&fields); - if (zephir_array_isset_string_fetch(&fields, &ast, SL("fields"), 0)) { - ZEPHIR_INIT_VAR(&sqlFields); - array_init(&sqlFields); - zephir_is_iterable(&fields, 0, "phalcon/Mvc/Model/Query.zep", 3646); - if (Z_TYPE_P(&fields) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&fields), _14$$9) +pp53: + ppch = *++PPCURSOR; + switch (ppch) { + case 'R': + case 'r': goto pp136; + default: goto pp59; + } +pp54: { - ZEPHIR_INIT_NVAR(&field); - ZVAL_COPY(&field, _14$$9); - ZEPHIR_OBS_NVAR(&name); - zephir_array_fetch_string(&name, &field, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3633); - ZEPHIR_CALL_METHOD(&_16$$10, &metaData, "hasattribute", &_17, 0, &model, &name); - zephir_check_call_status(); - if (UNEXPECTED(!zephir_is_true(&_16$$10))) { - ZEPHIR_INIT_NVAR(&_18$$11); - object_init_ex(&_18$$11, phalcon_mvc_model_exception_ce); - zephir_read_property(&_19$$11, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_20$$11); - ZEPHIR_CONCAT_SVSVSV(&_20$$11, "The model '", &modelName, "' doesn't have the attribute '", &name, "', when preparing: ", &_19$$11); - ZEPHIR_CALL_METHOD(NULL, &_18$$11, "__construct", &_21, 33, &_20$$11); - zephir_check_call_status(); - zephir_throw_exception_debug(&_18$$11, "phalcon/Mvc/Model/Query.zep", 3639); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_append(&sqlFields, &name, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3643); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &fields, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_15$$9, &fields, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_15$$9)) { - break; + token->opcode = PHQL_T_IDENTIFIER; + if ((PPCURSOR - q) > 1) { + if (q[0] == '\\') { + token->value = estrndup(q + 1, PPCURSOR - q - 1); + token->len = PPCURSOR - q - 1; + } else { + token->value = estrndup(q, PPCURSOR - q); + token->len = PPCURSOR - q; } - ZEPHIR_CALL_METHOD(&field, &fields, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&name); - zephir_array_fetch_string(&name, &field, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3633); - ZEPHIR_CALL_METHOD(&_22$$12, &metaData, "hasattribute", &_23, 0, &model, &name); - zephir_check_call_status(); - if (UNEXPECTED(!zephir_is_true(&_22$$12))) { - ZEPHIR_INIT_NVAR(&_24$$13); - object_init_ex(&_24$$13, phalcon_mvc_model_exception_ce); - zephir_read_property(&_25$$13, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_26$$13); - ZEPHIR_CONCAT_SVSVSV(&_26$$13, "The model '", &modelName, "' doesn't have the attribute '", &name, "', when preparing: ", &_25$$13); - ZEPHIR_CALL_METHOD(NULL, &_24$$13, "__construct", &_21, 33, &_26$$13); - zephir_check_call_status(); - zephir_throw_exception_debug(&_24$$13, "phalcon/Mvc/Model/Query.zep", 3639); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_append(&sqlFields, &name, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3643); - ZEPHIR_CALL_METHOD(NULL, &fields, "next", NULL, 0); - zephir_check_call_status(); + } else { + token->value = estrndup(q, PPCURSOR - q); + token->len = PPCURSOR - q; } + q = PPCURSOR; + return 0; } - ZEPHIR_INIT_NVAR(&field); - zephir_array_update_string(&sqlInsert, SL("fields"), &sqlFields, PH_COPY | PH_SEPARATE); - } - zephir_array_update_string(&sqlInsert, SL("values"), &exprValues, PH_COPY | PH_SEPARATE); - RETURN_CCTOR(&sqlInsert); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, _prepareSelect) -{ - zval _13$$24, _25$$28, _46$$43, _58$$47, _90$$66, _93$$73, _99$$81, _102$$88; - zval sqlModels, sqlTables, sqlAliases, sqlColumns, sqlAliasesModels, sqlModelsAliases, sqlAliasesModelsInstances, models, modelsInstances, _21$$24, _22$$24, _23$$24, _33$$28, _34$$28, _35$$28, _54$$43, _55$$43, _56$$43, _66$$47, _67$$47, _68$$47; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL, *_8 = NULL, *_14 = NULL, *_16 = NULL, *_26 = NULL, *_28 = NULL, *_36 = NULL, *_47 = NULL, *_49 = NULL, *_59 = NULL, *_61 = NULL, *_85 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, position = 0, number = 0; - zend_bool merge; - zval *ast = NULL, ast_sub, *merge_param = NULL, __$null, __$true, select, tables, columns, selectedModels, manager, metaData, selectedModel, qualifiedName, modelName, model, schema, source, completeSource, alias, joins, sqlJoins, selectColumns, sqlColumnAliases, column, sqlColumn, sqlSelect, distinct, having, where, groupBy, order, limit, tempModels, tempModelsInstances, tempSqlAliases, tempSqlModelsAliases, tempSqlAliasesModelsInstances, tempSqlAliasesModels, with, withs, withItem, automaticJoins, relation, joinAlias, relationModel, bestAlias, eagerType, _1, *_2, _3, *_82, _83, _103, _0$$3, _5$$17, _6$$17, _7$$17, _9$$19, *_10$$21, _11$$21, _12$$24, _15$$25, _17$$27, _18$$27, _19$$27, _20$$26, _24$$28, _27$$29, _29$$31, _30$$31, _31$$31, _32$$30, _37$$33, _38$$36, _39$$36, _40$$36, _41$$38, _42$$41, *_43$$40, _44$$40, _45$$43, _48$$44, _50$$46, _51$$46, _52$$46, _53$$45, _57$$47, _60$$48, _62$$50, _63$$50, _64$$50, _65$$49, _69$$52, _70$$52, _71$$52, _72$$52, _73$$52, _74$$52, _75$$52, _76$$52, _77$$52, _78$$52, _79$$52, _80$$52, _81$$55, _84$$60, *_86$$60, _87$$60, _88$$65, _89$$66, _91$$72, _92$$73, _94$$75, *_95$$75, _96$$75, _97$$80, _98$$81, _100$$87, _101$$88, _104$$92, _105$$93, _106$$94, _107$$95, _108$$96; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&ast_sub); - ZVAL_NULL(&__$null); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&select); - ZVAL_UNDEF(&tables); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&selectedModels); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&selectedModel); - ZVAL_UNDEF(&qualifiedName); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&completeSource); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&joins); - ZVAL_UNDEF(&sqlJoins); - ZVAL_UNDEF(&selectColumns); - ZVAL_UNDEF(&sqlColumnAliases); - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&sqlColumn); - ZVAL_UNDEF(&sqlSelect); - ZVAL_UNDEF(&distinct); - ZVAL_UNDEF(&having); - ZVAL_UNDEF(&where); - ZVAL_UNDEF(&groupBy); - ZVAL_UNDEF(&order); - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&tempModels); - ZVAL_UNDEF(&tempModelsInstances); - ZVAL_UNDEF(&tempSqlAliases); - ZVAL_UNDEF(&tempSqlModelsAliases); - ZVAL_UNDEF(&tempSqlAliasesModelsInstances); - ZVAL_UNDEF(&tempSqlAliasesModels); - ZVAL_UNDEF(&with); - ZVAL_UNDEF(&withs); - ZVAL_UNDEF(&withItem); - ZVAL_UNDEF(&automaticJoins); - ZVAL_UNDEF(&relation); - ZVAL_UNDEF(&joinAlias); - ZVAL_UNDEF(&relationModel); - ZVAL_UNDEF(&bestAlias); - ZVAL_UNDEF(&eagerType); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_83); - ZVAL_UNDEF(&_103); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_5$$17); - ZVAL_UNDEF(&_6$$17); - ZVAL_UNDEF(&_7$$17); - ZVAL_UNDEF(&_9$$19); - ZVAL_UNDEF(&_11$$21); - ZVAL_UNDEF(&_12$$24); - ZVAL_UNDEF(&_15$$25); - ZVAL_UNDEF(&_17$$27); - ZVAL_UNDEF(&_18$$27); - ZVAL_UNDEF(&_19$$27); - ZVAL_UNDEF(&_20$$26); - ZVAL_UNDEF(&_24$$28); - ZVAL_UNDEF(&_27$$29); - ZVAL_UNDEF(&_29$$31); - ZVAL_UNDEF(&_30$$31); - ZVAL_UNDEF(&_31$$31); - ZVAL_UNDEF(&_32$$30); - ZVAL_UNDEF(&_37$$33); - ZVAL_UNDEF(&_38$$36); - ZVAL_UNDEF(&_39$$36); - ZVAL_UNDEF(&_40$$36); - ZVAL_UNDEF(&_41$$38); - ZVAL_UNDEF(&_42$$41); - ZVAL_UNDEF(&_44$$40); - ZVAL_UNDEF(&_45$$43); - ZVAL_UNDEF(&_48$$44); - ZVAL_UNDEF(&_50$$46); - ZVAL_UNDEF(&_51$$46); - ZVAL_UNDEF(&_52$$46); - ZVAL_UNDEF(&_53$$45); - ZVAL_UNDEF(&_57$$47); - ZVAL_UNDEF(&_60$$48); - ZVAL_UNDEF(&_62$$50); - ZVAL_UNDEF(&_63$$50); - ZVAL_UNDEF(&_64$$50); - ZVAL_UNDEF(&_65$$49); - ZVAL_UNDEF(&_69$$52); - ZVAL_UNDEF(&_70$$52); - ZVAL_UNDEF(&_71$$52); - ZVAL_UNDEF(&_72$$52); - ZVAL_UNDEF(&_73$$52); - ZVAL_UNDEF(&_74$$52); - ZVAL_UNDEF(&_75$$52); - ZVAL_UNDEF(&_76$$52); - ZVAL_UNDEF(&_77$$52); - ZVAL_UNDEF(&_78$$52); - ZVAL_UNDEF(&_79$$52); - ZVAL_UNDEF(&_80$$52); - ZVAL_UNDEF(&_81$$55); - ZVAL_UNDEF(&_84$$60); - ZVAL_UNDEF(&_87$$60); - ZVAL_UNDEF(&_88$$65); - ZVAL_UNDEF(&_89$$66); - ZVAL_UNDEF(&_91$$72); - ZVAL_UNDEF(&_92$$73); - ZVAL_UNDEF(&_94$$75); - ZVAL_UNDEF(&_96$$75); - ZVAL_UNDEF(&_97$$80); - ZVAL_UNDEF(&_98$$81); - ZVAL_UNDEF(&_100$$87); - ZVAL_UNDEF(&_101$$88); - ZVAL_UNDEF(&_104$$92); - ZVAL_UNDEF(&_105$$93); - ZVAL_UNDEF(&_106$$94); - ZVAL_UNDEF(&_107$$95); - ZVAL_UNDEF(&_108$$96); - ZVAL_UNDEF(&sqlModels); - ZVAL_UNDEF(&sqlTables); - ZVAL_UNDEF(&sqlAliases); - ZVAL_UNDEF(&sqlColumns); - ZVAL_UNDEF(&sqlAliasesModels); - ZVAL_UNDEF(&sqlModelsAliases); - ZVAL_UNDEF(&sqlAliasesModelsInstances); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&modelsInstances); - ZVAL_UNDEF(&_21$$24); - ZVAL_UNDEF(&_22$$24); - ZVAL_UNDEF(&_23$$24); - ZVAL_UNDEF(&_33$$28); - ZVAL_UNDEF(&_34$$28); - ZVAL_UNDEF(&_35$$28); - ZVAL_UNDEF(&_54$$43); - ZVAL_UNDEF(&_55$$43); - ZVAL_UNDEF(&_56$$43); - ZVAL_UNDEF(&_66$$47); - ZVAL_UNDEF(&_67$$47); - ZVAL_UNDEF(&_68$$47); - ZVAL_UNDEF(&_13$$24); - ZVAL_UNDEF(&_25$$28); - ZVAL_UNDEF(&_46$$43); - ZVAL_UNDEF(&_58$$47); - ZVAL_UNDEF(&_90$$66); - ZVAL_UNDEF(&_93$$73); - ZVAL_UNDEF(&_99$$81); - ZVAL_UNDEF(&_102$$88); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(ast) - Z_PARAM_BOOL(merge) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &ast, &merge_param); - if (!ast) { - ast = &ast_sub; - ZEPHIR_CPY_WRT(ast, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(ast); - } - if (!merge_param) { - merge = 0; - } else { - } - if (ZEPHIR_IS_EMPTY(ast)) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("ast"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(ast, &_0$$3); - } - zephir_memory_observe(&select); - if (!(zephir_array_isset_string_fetch(&select, ast, SL("select"), 0))) { - ZEPHIR_CPY_WRT(&select, ast); - } - zephir_memory_observe(&tables); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&tables, &select, SL("tables"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 3682); - return; - } - zephir_memory_observe(&columns); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&columns, &select, SL("columns"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted SELECT AST", "phalcon/Mvc/Model/Query.zep", 3686); - return; - } - RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("nestingLevel"))); - ZEPHIR_INIT_VAR(&sqlModels); - array_init(&sqlModels); - ZEPHIR_INIT_VAR(&sqlTables); - array_init(&sqlTables); - ZEPHIR_INIT_VAR(&sqlColumns); - array_init(&sqlColumns); - ZEPHIR_INIT_VAR(&sqlAliases); - array_init(&sqlAliases); - ZEPHIR_INIT_VAR(&sqlAliasesModels); - array_init(&sqlAliasesModels); - ZEPHIR_INIT_VAR(&sqlModelsAliases); - array_init(&sqlModelsAliases); - ZEPHIR_INIT_VAR(&sqlAliasesModelsInstances); - array_init(&sqlAliasesModelsInstances); - ZEPHIR_INIT_VAR(&models); - array_init(&models); - ZEPHIR_INIT_VAR(&modelsInstances); - array_init(&modelsInstances); - if (!(zephir_array_isset_long(&tables, 0))) { - ZEPHIR_INIT_VAR(&selectedModels); - zephir_create_array(&selectedModels, 1, 0); - zephir_array_fast_append(&selectedModels, &tables); - } else { - ZEPHIR_CPY_WRT(&selectedModels, &tables); - } - if (!(zephir_array_isset_long(&columns, 0))) { - ZEPHIR_INIT_VAR(&selectColumns); - zephir_create_array(&selectColumns, 1, 0); - zephir_array_fast_append(&selectColumns, &columns); - } else { - ZEPHIR_CPY_WRT(&selectColumns, &columns); - } - zephir_read_property(&_1, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_1); - zephir_read_property(&_1, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&metaData, &_1); - if (UNEXPECTED(Z_TYPE_P(&manager) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A models-manager is required to execute the query", "phalcon/Mvc/Model/Query.zep", 3753); - return; - } - if (UNEXPECTED(Z_TYPE_P(&metaData) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A meta-data is required to execute the query", "phalcon/Mvc/Model/Query.zep", 3759); - return; - } - number = 0; - ZEPHIR_INIT_VAR(&automaticJoins); - array_init(&automaticJoins); - zephir_is_iterable(&selectedModels, 0, "phalcon/Mvc/Model/Query.zep", 3889); - if (Z_TYPE_P(&selectedModels) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&selectedModels), _2) - { - ZEPHIR_INIT_NVAR(&selectedModel); - ZVAL_COPY(&selectedModel, _2); - ZEPHIR_OBS_NVAR(&qualifiedName); - zephir_array_fetch_string(&qualifiedName, &selectedModel, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3767); - ZEPHIR_OBS_NVAR(&modelName); - zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3768); - ZEPHIR_CALL_METHOD(&model, &manager, "load", &_4, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_NVAR(&completeSource); - zephir_create_array(&completeSource, 2, 0); - zephir_array_fast_append(&completeSource, &source); - zephir_array_fast_append(&completeSource, &schema); - } else { - ZEPHIR_CPY_WRT(&completeSource, &source); +pp55: + ppch = *++PPCURSOR; + switch (ppch) { + case 'A': + case 'a': goto pp137; + default: goto pp59; } - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &selectedModel, SL("alias"), 0)) { - if (UNEXPECTED(zephir_array_isset(&sqlAliases, &alias))) { - ZEPHIR_INIT_NVAR(&_5$$17); - object_init_ex(&_5$$17, phalcon_mvc_model_exception_ce); - zephir_read_property(&_6$$17, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_7$$17); - ZEPHIR_CONCAT_SVSV(&_7$$17, "Alias '", &alias, "' is used more than once, when preparing: ", &_6$$17); - ZEPHIR_CALL_METHOD(NULL, &_5$$17, "__construct", &_8, 33, &_7$$17); - zephir_check_call_status(); - zephir_throw_exception_debug(&_5$$17, "phalcon/Mvc/Model/Query.zep", 3793); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModels, &alias, &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlModelsAliases, &modelName, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); - if (Z_TYPE_P(&completeSource) == IS_ARRAY) { - zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3805); - } else { - ZEPHIR_INIT_NVAR(&_9$$19); - zephir_create_array(&_9$$19, 3, 0); - zephir_array_fast_append(&_9$$19, &source); - zephir_array_fast_append(&_9$$19, &__$null); - zephir_array_fast_append(&_9$$19, &alias); - ZEPHIR_CPY_WRT(&completeSource, &_9$$19); - } - zephir_array_update_zval(&models, &modelName, &alias, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_CPY_WRT(&alias, &source); - zephir_array_update_zval(&sqlAliases, &modelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModels, &modelName, &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlModelsAliases, &modelName, &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &modelName, &source, PH_COPY | PH_SEPARATE); +pp56: + ppch = *++PPCURSOR; + switch (ppch) { + case 'L': + case 'l': goto pp138; + case 'N': + case 'n': goto pp139; + case 'S': + case 's': goto pp141; + default: goto pp59; } - ZEPHIR_OBS_NVAR(&with); - if (zephir_array_isset_string_fetch(&with, &selectedModel, SL("with"), 0)) { - if (!(zephir_array_isset_long(&with, 0))) { - ZEPHIR_INIT_NVAR(&withs); - zephir_create_array(&withs, 1, 0); - zephir_array_fast_append(&withs, &with); - } else { - ZEPHIR_CPY_WRT(&withs, &with); - } - zephir_is_iterable(&withs, 0, "phalcon/Mvc/Model/Query.zep", 3881); - if (Z_TYPE_P(&withs) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&withs), _10$$21) - { - ZEPHIR_INIT_NVAR(&withItem); - ZVAL_COPY(&withItem, _10$$21); - ZEPHIR_INIT_NVAR(&_12$$24); - ZVAL_LONG(&_12$$24, number); - ZEPHIR_INIT_NVAR(&_13$$24); - ZEPHIR_CONCAT_SV(&_13$$24, "AA", &_12$$24); - ZEPHIR_CPY_WRT(&joinAlias, &_13$$24); - ZEPHIR_OBS_NVAR(&relationModel); - zephir_array_fetch_string(&relationModel, &withItem, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3831); - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_14, 0, &modelName, &relationModel); - zephir_check_call_status(); - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_15$$25); - ZVAL_STRING(&_15$$25, "alias"); - ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_15$$25); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationsbetween", &_16, 0, &modelName, &relationModel); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&relation) != IS_OBJECT)) { - ZEPHIR_INIT_NVAR(&_17$$27); - object_init_ex(&_17$$27, phalcon_mvc_model_exception_ce); - zephir_read_property(&_18$$27, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_19$$27); - ZEPHIR_CONCAT_SVSVSV(&_19$$27, "Can't find a relationship between '", &modelName, "' and '", &relationModel, "' when preparing: ", &_18$$27); - ZEPHIR_CALL_METHOD(NULL, &_17$$27, "__construct", &_8, 33, &_19$$27); - zephir_check_call_status(); - zephir_throw_exception_debug(&_17$$27, "phalcon/Mvc/Model/Query.zep", 3851); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_NVAR(&_20$$26); - ZVAL_STRING(&_20$$26, "alias"); - ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_20$$26); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_INIT_NVAR(&_21$$24); - zephir_create_array(&_21$$24, 5, 0); - add_assoc_long_ex(&_21$$24, SL("type"), 353); - zephir_array_update_string(&_21$$24, SL("column"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_21$$24, SL("eager"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_21$$24, SL("eagerType"), &eagerType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_21$$24, SL("balias"), &bestAlias, PH_COPY | PH_SEPARATE); - zephir_array_append(&selectColumns, &_21$$24, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3865); - ZEPHIR_INIT_NVAR(&_22$$24); - zephir_create_array(&_22$$24, 3, 0); - add_assoc_long_ex(&_22$$24, SL("type"), 360); - ZEPHIR_INIT_NVAR(&_23$$24); - zephir_create_array(&_23$$24, 2, 0); - add_assoc_long_ex(&_23$$24, SL("type"), 355); - zephir_array_update_string(&_23$$24, SL("name"), &relationModel, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_22$$24, SL("qualified"), &_23$$24, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_23$$24); - zephir_create_array(&_23$$24, 2, 0); - add_assoc_long_ex(&_23$$24, SL("type"), 355); - zephir_array_update_string(&_23$$24, SL("name"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_22$$24, SL("alias"), &_23$$24, PH_COPY | PH_SEPARATE); - zephir_array_append(&automaticJoins, &_22$$24, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3877); - number++; - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &withs, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_11$$21, &withs, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_11$$21)) { - break; - } - ZEPHIR_CALL_METHOD(&withItem, &withs, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_24$$28); - ZVAL_LONG(&_24$$28, number); - ZEPHIR_INIT_NVAR(&_25$$28); - ZEPHIR_CONCAT_SV(&_25$$28, "AA", &_24$$28); - ZEPHIR_CPY_WRT(&joinAlias, &_25$$28); - ZEPHIR_OBS_NVAR(&relationModel); - zephir_array_fetch_string(&relationModel, &withItem, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3831); - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_26, 0, &modelName, &relationModel); - zephir_check_call_status(); - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_27$$29); - ZVAL_STRING(&_27$$29, "alias"); - ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_27$$29); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationsbetween", &_28, 0, &modelName, &relationModel); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&relation) != IS_OBJECT)) { - ZEPHIR_INIT_NVAR(&_29$$31); - object_init_ex(&_29$$31, phalcon_mvc_model_exception_ce); - zephir_read_property(&_30$$31, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_31$$31); - ZEPHIR_CONCAT_SVSVSV(&_31$$31, "Can't find a relationship between '", &modelName, "' and '", &relationModel, "' when preparing: ", &_30$$31); - ZEPHIR_CALL_METHOD(NULL, &_29$$31, "__construct", &_8, 33, &_31$$31); - zephir_check_call_status(); - zephir_throw_exception_debug(&_29$$31, "phalcon/Mvc/Model/Query.zep", 3851); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_NVAR(&_32$$30); - ZVAL_STRING(&_32$$30, "alias"); - ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_32$$30); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_INIT_NVAR(&_33$$28); - zephir_create_array(&_33$$28, 5, 0); - add_assoc_long_ex(&_33$$28, SL("type"), 353); - zephir_array_update_string(&_33$$28, SL("column"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_33$$28, SL("eager"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_33$$28, SL("eagerType"), &eagerType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_33$$28, SL("balias"), &bestAlias, PH_COPY | PH_SEPARATE); - zephir_array_append(&selectColumns, &_33$$28, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3865); - ZEPHIR_INIT_NVAR(&_34$$28); - zephir_create_array(&_34$$28, 3, 0); - add_assoc_long_ex(&_34$$28, SL("type"), 360); - ZEPHIR_INIT_NVAR(&_35$$28); - zephir_create_array(&_35$$28, 2, 0); - add_assoc_long_ex(&_35$$28, SL("type"), 355); - zephir_array_update_string(&_35$$28, SL("name"), &relationModel, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_34$$28, SL("qualified"), &_35$$28, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_35$$28); - zephir_create_array(&_35$$28, 2, 0); - add_assoc_long_ex(&_35$$28, SL("type"), 355); - zephir_array_update_string(&_35$$28, SL("name"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_34$$28, SL("alias"), &_35$$28, PH_COPY | PH_SEPARATE); - zephir_array_append(&automaticJoins, &_34$$28, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3877); - number++; - ZEPHIR_CALL_METHOD(NULL, &withs, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&withItem); +pp57: + ppch = *++PPCURSOR; + switch (ppch) { + case 'O': + case 'o': goto pp143; + default: goto pp59; } - zephir_array_append(&sqlModels, &modelName, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3883); - zephir_array_append(&sqlTables, &completeSource, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3884); - zephir_array_update_zval(&modelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &selectedModels, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &selectedModels, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3)) { - break; +pp58: + ppch = *++PPCURSOR; +pp59: + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp54; } - ZEPHIR_CALL_METHOD(&selectedModel, &selectedModels, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&qualifiedName); - zephir_array_fetch_string(&qualifiedName, &selectedModel, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3767); - ZEPHIR_OBS_NVAR(&modelName); - zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3768); - ZEPHIR_CALL_METHOD(&model, &manager, "load", &_36, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_NVAR(&_37$$33); - zephir_create_array(&_37$$33, 2, 0); - zephir_array_fast_append(&_37$$33, &source); - zephir_array_fast_append(&_37$$33, &schema); - ZEPHIR_CPY_WRT(&completeSource, &_37$$33); - } else { - ZEPHIR_CPY_WRT(&completeSource, &source); - } - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &selectedModel, SL("alias"), 0)) { - if (UNEXPECTED(zephir_array_isset(&sqlAliases, &alias))) { - ZEPHIR_INIT_NVAR(&_38$$36); - object_init_ex(&_38$$36, phalcon_mvc_model_exception_ce); - zephir_read_property(&_39$$36, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_40$$36); - ZEPHIR_CONCAT_SVSV(&_40$$36, "Alias '", &alias, "' is used more than once, when preparing: ", &_39$$36); - ZEPHIR_CALL_METHOD(NULL, &_38$$36, "__construct", &_8, 33, &_40$$36); - zephir_check_call_status(); - zephir_throw_exception_debug(&_38$$36, "phalcon/Mvc/Model/Query.zep", 3793); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModels, &alias, &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlModelsAliases, &modelName, &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); - if (Z_TYPE_P(&completeSource) == IS_ARRAY) { - zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3805); - } else { - ZEPHIR_INIT_NVAR(&_41$$38); - zephir_create_array(&_41$$38, 3, 0); - zephir_array_fast_append(&_41$$38, &source); - zephir_array_fast_append(&_41$$38, &__$null); - zephir_array_fast_append(&_41$$38, &alias); - ZEPHIR_CPY_WRT(&completeSource, &_41$$38); - } - zephir_array_update_zval(&models, &modelName, &alias, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_CPY_WRT(&alias, &source); - zephir_array_update_zval(&sqlAliases, &modelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModels, &modelName, &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlModelsAliases, &modelName, &modelName, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &modelName, &source, PH_COPY | PH_SEPARATE); - } - ZEPHIR_OBS_NVAR(&with); - if (zephir_array_isset_string_fetch(&with, &selectedModel, SL("with"), 0)) { - if (!(zephir_array_isset_long(&with, 0))) { - ZEPHIR_INIT_NVAR(&_42$$41); - zephir_create_array(&_42$$41, 1, 0); - zephir_array_fast_append(&_42$$41, &with); - ZEPHIR_CPY_WRT(&withs, &_42$$41); - } else { - ZEPHIR_CPY_WRT(&withs, &with); - } - zephir_is_iterable(&withs, 0, "phalcon/Mvc/Model/Query.zep", 3881); - if (Z_TYPE_P(&withs) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&withs), _43$$40) - { - ZEPHIR_INIT_NVAR(&withItem); - ZVAL_COPY(&withItem, _43$$40); - ZEPHIR_INIT_NVAR(&_45$$43); - ZVAL_LONG(&_45$$43, number); - ZEPHIR_INIT_NVAR(&_46$$43); - ZEPHIR_CONCAT_SV(&_46$$43, "AA", &_45$$43); - ZEPHIR_CPY_WRT(&joinAlias, &_46$$43); - ZEPHIR_OBS_NVAR(&relationModel); - zephir_array_fetch_string(&relationModel, &withItem, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3831); - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_47, 0, &modelName, &relationModel); - zephir_check_call_status(); - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_48$$44); - ZVAL_STRING(&_48$$44, "alias"); - ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_48$$44); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationsbetween", &_49, 0, &modelName, &relationModel); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&relation) != IS_OBJECT)) { - ZEPHIR_INIT_NVAR(&_50$$46); - object_init_ex(&_50$$46, phalcon_mvc_model_exception_ce); - zephir_read_property(&_51$$46, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_52$$46); - ZEPHIR_CONCAT_SVSVSV(&_52$$46, "Can't find a relationship between '", &modelName, "' and '", &relationModel, "' when preparing: ", &_51$$46); - ZEPHIR_CALL_METHOD(NULL, &_50$$46, "__construct", &_8, 33, &_52$$46); - zephir_check_call_status(); - zephir_throw_exception_debug(&_50$$46, "phalcon/Mvc/Model/Query.zep", 3851); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_NVAR(&_53$$45); - ZVAL_STRING(&_53$$45, "alias"); - ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_53$$45); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_INIT_NVAR(&_54$$43); - zephir_create_array(&_54$$43, 5, 0); - add_assoc_long_ex(&_54$$43, SL("type"), 353); - zephir_array_update_string(&_54$$43, SL("column"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_54$$43, SL("eager"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_54$$43, SL("eagerType"), &eagerType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_54$$43, SL("balias"), &bestAlias, PH_COPY | PH_SEPARATE); - zephir_array_append(&selectColumns, &_54$$43, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3865); - ZEPHIR_INIT_NVAR(&_55$$43); - zephir_create_array(&_55$$43, 3, 0); - add_assoc_long_ex(&_55$$43, SL("type"), 360); - ZEPHIR_INIT_NVAR(&_56$$43); - zephir_create_array(&_56$$43, 2, 0); - add_assoc_long_ex(&_56$$43, SL("type"), 355); - zephir_array_update_string(&_56$$43, SL("name"), &relationModel, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_55$$43, SL("qualified"), &_56$$43, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_56$$43); - zephir_create_array(&_56$$43, 2, 0); - add_assoc_long_ex(&_56$$43, SL("type"), 355); - zephir_array_update_string(&_56$$43, SL("name"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_55$$43, SL("alias"), &_56$$43, PH_COPY | PH_SEPARATE); - zephir_array_append(&automaticJoins, &_55$$43, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3877); - number++; - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &withs, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_44$$40, &withs, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_44$$40)) { - break; - } - ZEPHIR_CALL_METHOD(&withItem, &withs, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_57$$47); - ZVAL_LONG(&_57$$47, number); - ZEPHIR_INIT_NVAR(&_58$$47); - ZEPHIR_CONCAT_SV(&_58$$47, "AA", &_57$$47); - ZEPHIR_CPY_WRT(&joinAlias, &_58$$47); - ZEPHIR_OBS_NVAR(&relationModel); - zephir_array_fetch_string(&relationModel, &withItem, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 3831); - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationbyalias", &_59, 0, &modelName, &relationModel); - zephir_check_call_status(); - if (Z_TYPE_P(&relation) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_60$$48); - ZVAL_STRING(&_60$$48, "alias"); - ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_60$$48); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(&relation, &manager, "getrelationsbetween", &_61, 0, &modelName, &relationModel); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&relation) != IS_OBJECT)) { - ZEPHIR_INIT_NVAR(&_62$$50); - object_init_ex(&_62$$50, phalcon_mvc_model_exception_ce); - zephir_read_property(&_63$$50, this_ptr, ZEND_STRL("phql"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_64$$50); - ZEPHIR_CONCAT_SVSVSV(&_64$$50, "Can't find a relationship between '", &modelName, "' and '", &relationModel, "' when preparing: ", &_63$$50); - ZEPHIR_CALL_METHOD(NULL, &_62$$50, "__construct", &_8, 33, &_64$$50); - zephir_check_call_status(); - zephir_throw_exception_debug(&_62$$50, "phalcon/Mvc/Model/Query.zep", 3851); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_NVAR(&_65$$49); - ZVAL_STRING(&_65$$49, "alias"); - ZEPHIR_CALL_METHOD(&bestAlias, &relation, "getoption", NULL, 0, &_65$$49); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&relationModel, &relation, "getreferencedmodel", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&eagerType, &relation, "gettype", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_INIT_NVAR(&_66$$47); - zephir_create_array(&_66$$47, 5, 0); - add_assoc_long_ex(&_66$$47, SL("type"), 353); - zephir_array_update_string(&_66$$47, SL("column"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_66$$47, SL("eager"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_66$$47, SL("eagerType"), &eagerType, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_66$$47, SL("balias"), &bestAlias, PH_COPY | PH_SEPARATE); - zephir_array_append(&selectColumns, &_66$$47, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3865); - ZEPHIR_INIT_NVAR(&_67$$47); - zephir_create_array(&_67$$47, 3, 0); - add_assoc_long_ex(&_67$$47, SL("type"), 360); - ZEPHIR_INIT_NVAR(&_68$$47); - zephir_create_array(&_68$$47, 2, 0); - add_assoc_long_ex(&_68$$47, SL("type"), 355); - zephir_array_update_string(&_68$$47, SL("name"), &relationModel, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_67$$47, SL("qualified"), &_68$$47, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_68$$47); - zephir_create_array(&_68$$47, 2, 0); - add_assoc_long_ex(&_68$$47, SL("type"), 355); - zephir_array_update_string(&_68$$47, SL("name"), &joinAlias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_67$$47, SL("alias"), &_68$$47, PH_COPY | PH_SEPARATE); - zephir_array_append(&automaticJoins, &_67$$47, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3877); - number++; - ZEPHIR_CALL_METHOD(NULL, &withs, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&withItem); - } - zephir_array_append(&sqlModels, &modelName, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3883); - zephir_array_append(&sqlTables, &completeSource, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3884); - zephir_array_update_zval(&modelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &selectedModels, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&selectedModel); - if (!(merge)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &models); - zephir_update_property_zval(this_ptr, ZEND_STRL("modelsInstances"), &modelsInstances); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliases"), &sqlAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModels"), &sqlAliasesModels); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlModelsAliases"), &sqlModelsAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &sqlAliasesModelsInstances); - } else { - zephir_memory_observe(&tempModels); - zephir_read_property(&tempModels, this_ptr, ZEND_STRL("models"), PH_NOISY_CC); - zephir_memory_observe(&tempModelsInstances); - zephir_read_property(&tempModelsInstances, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC); - zephir_memory_observe(&tempSqlAliases); - zephir_read_property(&tempSqlAliases, this_ptr, ZEND_STRL("sqlAliases"), PH_NOISY_CC); - zephir_memory_observe(&tempSqlAliasesModels); - zephir_read_property(&tempSqlAliasesModels, this_ptr, ZEND_STRL("sqlAliasesModels"), PH_NOISY_CC); - zephir_memory_observe(&tempSqlModelsAliases); - zephir_read_property(&tempSqlModelsAliases, this_ptr, ZEND_STRL("sqlModelsAliases"), PH_NOISY_CC); - zephir_memory_observe(&tempSqlAliasesModelsInstances); - zephir_read_property(&tempSqlAliasesModelsInstances, this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&_69$$52); - zephir_read_property(&_70$$52, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); - zephir_fast_array_merge(&_69$$52, &_70$$52, &models); - zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &_69$$52); - ZEPHIR_INIT_VAR(&_71$$52); - zephir_read_property(&_72$$52, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - zephir_fast_array_merge(&_71$$52, &_72$$52, &modelsInstances); - zephir_update_property_zval(this_ptr, ZEND_STRL("modelsInstances"), &_71$$52); - ZEPHIR_INIT_VAR(&_73$$52); - zephir_read_property(&_74$$52, this_ptr, ZEND_STRL("sqlAliases"), PH_NOISY_CC | PH_READONLY); - zephir_fast_array_merge(&_73$$52, &_74$$52, &sqlAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliases"), &_73$$52); - ZEPHIR_INIT_VAR(&_75$$52); - zephir_read_property(&_76$$52, this_ptr, ZEND_STRL("sqlAliasesModels"), PH_NOISY_CC | PH_READONLY); - zephir_fast_array_merge(&_75$$52, &_76$$52, &sqlAliasesModels); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModels"), &_75$$52); - ZEPHIR_INIT_VAR(&_77$$52); - zephir_read_property(&_78$$52, this_ptr, ZEND_STRL("sqlModelsAliases"), PH_NOISY_CC | PH_READONLY); - zephir_fast_array_merge(&_77$$52, &_78$$52, &sqlModelsAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlModelsAliases"), &_77$$52); - ZEPHIR_INIT_VAR(&_79$$52); - zephir_read_property(&_80$$52, this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), PH_NOISY_CC | PH_READONLY); - zephir_fast_array_merge(&_79$$52, &_80$$52, &sqlAliasesModelsInstances); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &_79$$52); - } - zephir_memory_observe(&joins); - zephir_array_isset_string_fetch(&joins, &select, SL("joins"), 0); - if (zephir_fast_count_int(&joins)) { - if (zephir_fast_count_int(&automaticJoins)) { - if (zephir_array_isset_long(&joins, 0)) { - ZEPHIR_INIT_VAR(&_81$$55); - zephir_fast_array_merge(&_81$$55, &joins, &automaticJoins); - zephir_array_update_string(&select, SL("joins"), &_81$$55, PH_COPY | PH_SEPARATE); - } else { - zephir_array_append(&automaticJoins, &joins, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3920); - zephir_array_update_string(&select, SL("joins"), &automaticJoins, PH_COPY | PH_SEPARATE); +pp60: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp144; + case 'I': + case 'i': goto pp145; + default: goto pp59; } - } - ZEPHIR_CALL_METHOD(&sqlJoins, this_ptr, "getjoins", NULL, 473, &select); - zephir_check_call_status(); - } else { - if (zephir_fast_count_int(&automaticJoins)) { - zephir_array_update_string(&select, SL("joins"), &automaticJoins, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&sqlJoins, this_ptr, "getjoins", NULL, 473, &select); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&sqlJoins); - array_init(&sqlJoins); - } - } - position = 0; - ZEPHIR_INIT_VAR(&sqlColumnAliases); - array_init(&sqlColumnAliases); - zephir_is_iterable(&selectColumns, 0, "phalcon/Mvc/Model/Query.zep", 3971); - if (Z_TYPE_P(&selectColumns) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&selectColumns), _82) - { - ZEPHIR_INIT_NVAR(&column); - ZVAL_COPY(&column, _82); - ZEPHIR_CALL_METHOD(&_84$$60, this_ptr, "getselectcolumn", &_85, 474, &column); - zephir_check_call_status(); - zephir_is_iterable(&_84$$60, 0, "phalcon/Mvc/Model/Query.zep", 3969); - if (Z_TYPE_P(&_84$$60) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_84$$60), _86$$60) - { - ZEPHIR_INIT_NVAR(&sqlColumn); - ZVAL_COPY(&sqlColumn, _86$$60); - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &column, SL("alias"), 0)) { - zephir_array_update_string(&sqlColumn, SL("balias"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlColumn, SL("sqlAlias"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlColumnAliases, &alias, &__$true, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &sqlColumn, SL("balias"), 0)) { - zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); - } else { - zephir_array_fetch_string(&_88$$65, &sqlColumn, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3959); - if (ZEPHIR_IS_STRING(&_88$$65, "scalar")) { - ZEPHIR_INIT_NVAR(&_89$$66); - ZVAL_LONG(&_89$$66, position); - ZEPHIR_INIT_NVAR(&_90$$66); - ZEPHIR_CONCAT_SV(&_90$$66, "_", &_89$$66); - zephir_array_update_zval(&sqlColumns, &_90$$66, &sqlColumn, PH_COPY | PH_SEPARATE); - } else { - zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3962); - } - } - } - position++; - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_84$$60, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_87$$60, &_84$$60, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_87$$60)) { - break; - } - ZEPHIR_CALL_METHOD(&sqlColumn, &_84$$60, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &column, SL("alias"), 0)) { - zephir_array_update_string(&sqlColumn, SL("balias"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlColumn, SL("sqlAlias"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlColumnAliases, &alias, &__$true, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &sqlColumn, SL("balias"), 0)) { - zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); - } else { - zephir_array_fetch_string(&_91$$72, &sqlColumn, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3959); - if (ZEPHIR_IS_STRING(&_91$$72, "scalar")) { - ZEPHIR_INIT_NVAR(&_92$$73); - ZVAL_LONG(&_92$$73, position); - ZEPHIR_INIT_NVAR(&_93$$73); - ZEPHIR_CONCAT_SV(&_93$$73, "_", &_92$$73); - zephir_array_update_zval(&sqlColumns, &_93$$73, &sqlColumn, PH_COPY | PH_SEPARATE); - } else { - zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3962); - } - } - } - position++; - ZEPHIR_CALL_METHOD(NULL, &_84$$60, "next", NULL, 0); - zephir_check_call_status(); - } +pp61: + ppch = *++PPCURSOR; + switch (ppch) { + case 'O': + case 'o': goto pp146; + case 'U': + case 'u': goto pp147; + default: goto pp59; } - ZEPHIR_INIT_NVAR(&sqlColumn); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &selectColumns, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_83, &selectColumns, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_83)) { - break; +pp62: + ppch = *++PPCURSOR; + switch (ppch) { + case 'F': + case 'f': goto pp148; + case 'N': + case 'n': goto pp149; + case 'R': + case 'r': goto pp151; + case 'U': + case 'u': goto pp153; + default: goto pp59; } - ZEPHIR_CALL_METHOD(&column, &selectColumns, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_94$$75, this_ptr, "getselectcolumn", &_85, 474, &column); - zephir_check_call_status(); - zephir_is_iterable(&_94$$75, 0, "phalcon/Mvc/Model/Query.zep", 3969); - if (Z_TYPE_P(&_94$$75) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_94$$75), _95$$75) - { - ZEPHIR_INIT_NVAR(&sqlColumn); - ZVAL_COPY(&sqlColumn, _95$$75); - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &column, SL("alias"), 0)) { - zephir_array_update_string(&sqlColumn, SL("balias"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlColumn, SL("sqlAlias"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlColumnAliases, &alias, &__$true, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &sqlColumn, SL("balias"), 0)) { - zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); - } else { - zephir_array_fetch_string(&_97$$80, &sqlColumn, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3959); - if (ZEPHIR_IS_STRING(&_97$$80, "scalar")) { - ZEPHIR_INIT_NVAR(&_98$$81); - ZVAL_LONG(&_98$$81, position); - ZEPHIR_INIT_NVAR(&_99$$81); - ZEPHIR_CONCAT_SV(&_99$$81, "_", &_98$$81); - zephir_array_update_zval(&sqlColumns, &_99$$81, &sqlColumn, PH_COPY | PH_SEPARATE); - } else { - zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3962); - } - } - } - position++; - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_94$$75, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_96$$75, &_94$$75, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_96$$75)) { - break; - } - ZEPHIR_CALL_METHOD(&sqlColumn, &_94$$75, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &column, SL("alias"), 0)) { - zephir_array_update_string(&sqlColumn, SL("balias"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlColumn, SL("sqlAlias"), &alias, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlColumnAliases, &alias, &__$true, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &sqlColumn, SL("balias"), 0)) { - zephir_array_update_zval(&sqlColumns, &alias, &sqlColumn, PH_COPY | PH_SEPARATE); - } else { - zephir_array_fetch_string(&_100$$87, &sqlColumn, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 3959); - if (ZEPHIR_IS_STRING(&_100$$87, "scalar")) { - ZEPHIR_INIT_NVAR(&_101$$88); - ZVAL_LONG(&_101$$88, position); - ZEPHIR_INIT_NVAR(&_102$$88); - ZEPHIR_CONCAT_SV(&_102$$88, "_", &_101$$88); - zephir_array_update_zval(&sqlColumns, &_102$$88, &sqlColumn, PH_COPY | PH_SEPARATE); - } else { - zephir_array_append(&sqlColumns, &sqlColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 3962); - } - } - } - position++; - ZEPHIR_CALL_METHOD(NULL, &_94$$75, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&sqlColumn); - ZEPHIR_CALL_METHOD(NULL, &selectColumns, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&column); - zephir_memory_observe(&_103); - zephir_read_property(&_103, this_ptr, ZEND_STRL("nestingLevel"), PH_NOISY_CC); - zephir_update_property_array(this_ptr, SL("sqlColumnAliases"), &_103, &sqlColumnAliases); - ZEPHIR_INIT_VAR(&sqlSelect); - zephir_create_array(&sqlSelect, 3, 0); - zephir_array_update_string(&sqlSelect, SL("models"), &sqlModels, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlSelect, SL("tables"), &sqlTables, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlSelect, SL("columns"), &sqlColumns, PH_COPY | PH_SEPARATE); - zephir_memory_observe(&distinct); - if (zephir_array_isset_string_fetch(&distinct, &select, SL("distinct"), 0)) { - zephir_array_update_string(&sqlSelect, SL("distinct"), &distinct, PH_COPY | PH_SEPARATE); - } - if (zephir_fast_count_int(&sqlJoins)) { - zephir_array_update_string(&sqlSelect, SL("joins"), &sqlJoins, PH_COPY | PH_SEPARATE); - } - zephir_memory_observe(&where); - if (zephir_array_isset_string_fetch(&where, ast, SL("where"), 0)) { - ZEPHIR_CALL_METHOD(&_104$$92, this_ptr, "getexpression", NULL, 458, &where); - zephir_check_call_status(); - zephir_array_update_string(&sqlSelect, SL("where"), &_104$$92, PH_COPY | PH_SEPARATE); - } - zephir_memory_observe(&groupBy); - if (zephir_array_isset_string_fetch(&groupBy, ast, SL("groupBy"), 0)) { - ZEPHIR_CALL_METHOD(&_105$$93, this_ptr, "getgroupclause", NULL, 475, &groupBy); - zephir_check_call_status(); - zephir_array_update_string(&sqlSelect, SL("group"), &_105$$93, PH_COPY | PH_SEPARATE); - } - zephir_memory_observe(&having); - if (zephir_array_isset_string_fetch(&having, ast, SL("having"), 0)) { - ZEPHIR_CALL_METHOD(&_106$$94, this_ptr, "getexpression", NULL, 458, &having); - zephir_check_call_status(); - zephir_array_update_string(&sqlSelect, SL("having"), &_106$$94, PH_COPY | PH_SEPARATE); - } - zephir_memory_observe(&order); - if (zephir_array_isset_string_fetch(&order, ast, SL("orderBy"), 0)) { - ZEPHIR_CALL_METHOD(&_107$$95, this_ptr, "getorderclause", NULL, 476, &order); - zephir_check_call_status(); - zephir_array_update_string(&sqlSelect, SL("order"), &_107$$95, PH_COPY | PH_SEPARATE); - } - zephir_memory_observe(&limit); - if (zephir_array_isset_string_fetch(&limit, ast, SL("limit"), 0)) { - ZEPHIR_CALL_METHOD(&_108$$96, this_ptr, "getlimitclause", NULL, 472, &limit); - zephir_check_call_status(); - zephir_array_update_string(&sqlSelect, SL("limit"), &_108$$96, PH_COPY | PH_SEPARATE); - } - if (zephir_array_isset_string(ast, SL("forUpdate"))) { - zephir_array_update_string(&sqlSelect, SL("forUpdate"), &__$true, PH_COPY | PH_SEPARATE); - } - if (merge) { - zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &tempModels); - zephir_update_property_zval(this_ptr, ZEND_STRL("modelsInstances"), &tempModelsInstances); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliases"), &tempSqlAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModels"), &tempSqlAliasesModels); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlModelsAliases"), &tempSqlModelsAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &tempSqlAliasesModelsInstances); - } - RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("nestingLevel"))); - RETURN_CCTOR(&sqlSelect); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query, _prepareUpdate) -{ - zval _15$$20, _22$$21; - zend_bool notQuoting = 0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$null, ast, update, tables, values, modelsInstances, models, sqlTables, sqlAliases, sqlAliasesModelsInstances, updateTables, completeSource, sqlModels, manager, table, qualifiedName, modelName, model, source, schema, alias, sqlFields, sqlValues, updateValues, updateValue, exprColumn, sqlUpdate, where, limit, _0, *_1, _2, *_9, _10, _4$$9, _5$$10, _7$$14, _8$$15, _11$$20, _12$$20, _13$$20, _16$$20, _17$$20, _18$$20, _19$$21, _20$$21, _21$$21, _23$$21, _24$$21, _25$$21, _26$$22, _27$$22, _28$$23; - zephir_fcall_cache_entry *_3 = NULL, *_6 = NULL, *_14 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&ast); - ZVAL_UNDEF(&update); - ZVAL_UNDEF(&tables); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&modelsInstances); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&sqlTables); - ZVAL_UNDEF(&sqlAliases); - ZVAL_UNDEF(&sqlAliasesModelsInstances); - ZVAL_UNDEF(&updateTables); - ZVAL_UNDEF(&completeSource); - ZVAL_UNDEF(&sqlModels); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&table); - ZVAL_UNDEF(&qualifiedName); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&sqlFields); - ZVAL_UNDEF(&sqlValues); - ZVAL_UNDEF(&updateValues); - ZVAL_UNDEF(&updateValue); - ZVAL_UNDEF(&exprColumn); - ZVAL_UNDEF(&sqlUpdate); - ZVAL_UNDEF(&where); - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_4$$9); - ZVAL_UNDEF(&_5$$10); - ZVAL_UNDEF(&_7$$14); - ZVAL_UNDEF(&_8$$15); - ZVAL_UNDEF(&_11$$20); - ZVAL_UNDEF(&_12$$20); - ZVAL_UNDEF(&_13$$20); - ZVAL_UNDEF(&_16$$20); - ZVAL_UNDEF(&_17$$20); - ZVAL_UNDEF(&_18$$20); - ZVAL_UNDEF(&_19$$21); - ZVAL_UNDEF(&_20$$21); - ZVAL_UNDEF(&_21$$21); - ZVAL_UNDEF(&_23$$21); - ZVAL_UNDEF(&_24$$21); - ZVAL_UNDEF(&_25$$21); - ZVAL_UNDEF(&_26$$22); - ZVAL_UNDEF(&_27$$22); - ZVAL_UNDEF(&_28$$23); - ZVAL_UNDEF(&_15$$20); - ZVAL_UNDEF(&_22$$21); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("ast"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&ast, &_0); - zephir_memory_observe(&update); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&update, &ast, SL("update"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted UPDATE AST", "phalcon/Mvc/Model/Query.zep", 4048); - return; - } - zephir_memory_observe(&tables); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&tables, &update, SL("tables"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted UPDATE AST", "phalcon/Mvc/Model/Query.zep", 4052); - return; - } - zephir_memory_observe(&values); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&values, &update, SL("values"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Corrupted UPDATE AST", "phalcon/Mvc/Model/Query.zep", 4056); - return; - } - ZEPHIR_INIT_VAR(&models); - array_init(&models); - ZEPHIR_INIT_VAR(&modelsInstances); - array_init(&modelsInstances); - ZEPHIR_INIT_VAR(&sqlTables); - array_init(&sqlTables); - ZEPHIR_INIT_VAR(&sqlModels); - array_init(&sqlModels); - ZEPHIR_INIT_VAR(&sqlAliases); - array_init(&sqlAliases); - ZEPHIR_INIT_VAR(&sqlAliasesModelsInstances); - array_init(&sqlAliasesModelsInstances); - if (!(zephir_array_isset_long(&tables, 0))) { - ZEPHIR_INIT_VAR(&updateTables); - zephir_create_array(&updateTables, 1, 0); - zephir_array_fast_append(&updateTables, &tables); - } else { - ZEPHIR_CPY_WRT(&updateTables, &tables); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - zephir_is_iterable(&updateTables, 0, "phalcon/Mvc/Model/Query.zep", 4122); - if (Z_TYPE_P(&updateTables) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&updateTables), _1) - { - ZEPHIR_INIT_NVAR(&table); - ZVAL_COPY(&table, _1); - ZEPHIR_OBS_NVAR(&qualifiedName); - zephir_array_fetch_string(&qualifiedName, &table, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4080); - ZEPHIR_OBS_NVAR(&modelName); - zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4081); - ZEPHIR_CALL_METHOD(&model, &manager, "load", &_3, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&completeSource); - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_NVAR(&_4$$9); - zephir_create_array(&_4$$9, 2, 0); - zephir_array_fast_append(&_4$$9, &source); - zephir_array_fast_append(&_4$$9, &schema); - ZEPHIR_CPY_WRT(&completeSource, &_4$$9); - } else { - ZEPHIR_INIT_NVAR(&_5$$10); - zephir_create_array(&_5$$10, 2, 0); - zephir_array_fast_append(&_5$$10, &source); - zephir_array_fast_append(&_5$$10, &__$null); - ZEPHIR_CPY_WRT(&completeSource, &_5$$10); +pp63: + ppch = *++PPCURSOR; + switch (ppch) { + case 'I': + case 'i': goto pp154; + default: goto pp59; } - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &table, SL("alias"), 0)) { - zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); - zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4104); - zephir_array_append(&sqlTables, &completeSource, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4105); - zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &alias, &modelName, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&sqlAliases, &modelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlTables, &source, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4111); - zephir_array_update_zval(&models, &modelName, &source, PH_COPY | PH_SEPARATE); +pp64: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp155; + default: goto pp59; } - zephir_array_append(&sqlModels, &modelName, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4115); - zephir_array_update_zval(&modelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &updateTables, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &updateTables, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; +pp65: + ppch = *++PPCURSOR; + switch (ppch) { + case 'H': + case 'h': goto pp156; + case 'R': + case 'r': goto pp157; + default: goto pp59; } - ZEPHIR_CALL_METHOD(&table, &updateTables, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&qualifiedName); - zephir_array_fetch_string(&qualifiedName, &table, SL("qualifiedName"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4080); - ZEPHIR_OBS_NVAR(&modelName); - zephir_array_fetch_string(&modelName, &qualifiedName, SL("name"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4081); - ZEPHIR_CALL_METHOD(&model, &manager, "load", &_6, 0, &modelName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&source, &model, "getsource", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&schema, &model, "getschema", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_NVAR(&_7$$14); - zephir_create_array(&_7$$14, 2, 0); - zephir_array_fast_append(&_7$$14, &source); - zephir_array_fast_append(&_7$$14, &schema); - ZEPHIR_CPY_WRT(&completeSource, &_7$$14); - } else { - ZEPHIR_INIT_NVAR(&_8$$15); - zephir_create_array(&_8$$15, 2, 0); - zephir_array_fast_append(&_8$$15, &source); - zephir_array_fast_append(&_8$$15, &__$null); - ZEPHIR_CPY_WRT(&completeSource, &_8$$15); - } - ZEPHIR_OBS_NVAR(&alias); - if (zephir_array_isset_string_fetch(&alias, &table, SL("alias"), 0)) { - zephir_array_update_zval(&sqlAliases, &alias, &alias, PH_COPY | PH_SEPARATE); - zephir_array_append(&completeSource, &alias, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4104); - zephir_array_append(&sqlTables, &completeSource, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4105); - zephir_array_update_zval(&sqlAliasesModelsInstances, &alias, &model, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&models, &alias, &modelName, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&sqlAliases, &modelName, &source, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&sqlAliasesModelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlTables, &source, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4111); - zephir_array_update_zval(&models, &modelName, &source, PH_COPY | PH_SEPARATE); - } - zephir_array_append(&sqlModels, &modelName, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4115); - zephir_array_update_zval(&modelsInstances, &modelName, &model, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &updateTables, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&table); - zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &models); - zephir_update_property_zval(this_ptr, ZEND_STRL("modelsInstances"), &modelsInstances); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliases"), &sqlAliases); - zephir_update_property_zval(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &sqlAliasesModelsInstances); - ZEPHIR_INIT_VAR(&sqlFields); - array_init(&sqlFields); - ZEPHIR_INIT_VAR(&sqlValues); - array_init(&sqlValues); - if (!(zephir_array_isset_long(&values, 0))) { - ZEPHIR_INIT_VAR(&updateValues); - zephir_create_array(&updateValues, 1, 0); - zephir_array_fast_append(&updateValues, &values); - } else { - ZEPHIR_CPY_WRT(&updateValues, &values); - } - notQuoting = 0; - zephir_is_iterable(&updateValues, 0, "phalcon/Mvc/Model/Query.zep", 4146); - if (Z_TYPE_P(&updateValues) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&updateValues), _9) - { - ZEPHIR_INIT_NVAR(&updateValue); - ZVAL_COPY(&updateValue, _9); - zephir_array_fetch_string(&_12$$20, &updateValue, SL("column"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 4138); - if (notQuoting) { - ZVAL_BOOL(&_13$$20, 1); - } else { - ZVAL_BOOL(&_13$$20, 0); +pp66: + ppch = *++PPCURSOR; + switch (ppch) { + case 'P': + case 'p': goto pp158; + case 'S': + case 's': goto pp159; + default: goto pp59; } - ZEPHIR_CALL_METHOD(&_11$$20, this_ptr, "getexpression", &_14, 458, &_12$$20, &_13$$20); - zephir_check_call_status(); - zephir_array_append(&sqlFields, &_11$$20, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4138); - ZEPHIR_OBS_NVAR(&exprColumn); - zephir_array_fetch_string(&exprColumn, &updateValue, SL("expr"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4139); - ZEPHIR_INIT_NVAR(&_15$$20); - zephir_create_array(&_15$$20, 2, 0); - ZEPHIR_OBS_NVAR(&_16$$20); - zephir_array_fetch_string(&_16$$20, &exprColumn, SL("type"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4141); - zephir_array_update_string(&_15$$20, SL("type"), &_16$$20, PH_COPY | PH_SEPARATE); - if (notQuoting) { - ZVAL_BOOL(&_18$$20, 1); - } else { - ZVAL_BOOL(&_18$$20, 0); +pp67: + ppch = *++PPCURSOR; + switch (ppch) { + case 'A': + case 'a': goto pp160; + default: goto pp59; } - ZEPHIR_CALL_METHOD(&_17$$20, this_ptr, "getexpression", &_14, 458, &exprColumn, &_18$$20); - zephir_check_call_status(); - zephir_array_update_string(&_15$$20, SL("value"), &_17$$20, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlValues, &_15$$20, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4143); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &updateValues, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_10, &updateValues, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_10)) { - break; +pp68: + ppch = *++PPCURSOR; + switch (ppch) { + case 'H': + case 'h': goto pp161; + case 'I': + case 'i': goto pp162; + default: goto pp59; } - ZEPHIR_CALL_METHOD(&updateValue, &updateValues, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_fetch_string(&_20$$21, &updateValue, SL("column"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query.zep", 4138); - if (notQuoting) { - ZVAL_BOOL(&_21$$21, 1); - } else { - ZVAL_BOOL(&_21$$21, 0); - } - ZEPHIR_CALL_METHOD(&_19$$21, this_ptr, "getexpression", &_14, 458, &_20$$21, &_21$$21); - zephir_check_call_status(); - zephir_array_append(&sqlFields, &_19$$21, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4138); - ZEPHIR_OBS_NVAR(&exprColumn); - zephir_array_fetch_string(&exprColumn, &updateValue, SL("expr"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4139); - ZEPHIR_INIT_NVAR(&_22$$21); - zephir_create_array(&_22$$21, 2, 0); - ZEPHIR_OBS_NVAR(&_23$$21); - zephir_array_fetch_string(&_23$$21, &exprColumn, SL("type"), PH_NOISY, "phalcon/Mvc/Model/Query.zep", 4141); - zephir_array_update_string(&_22$$21, SL("type"), &_23$$21, PH_COPY | PH_SEPARATE); - if (notQuoting) { - ZVAL_BOOL(&_25$$21, 1); - } else { - ZVAL_BOOL(&_25$$21, 0); - } - ZEPHIR_CALL_METHOD(&_24$$21, this_ptr, "getexpression", &_14, 458, &exprColumn, &_25$$21); - zephir_check_call_status(); - zephir_array_update_string(&_22$$21, SL("value"), &_24$$21, PH_COPY | PH_SEPARATE); - zephir_array_append(&sqlValues, &_22$$21, PH_SEPARATE, "phalcon/Mvc/Model/Query.zep", 4143); - ZEPHIR_CALL_METHOD(NULL, &updateValues, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&updateValue); - ZEPHIR_INIT_VAR(&sqlUpdate); - zephir_create_array(&sqlUpdate, 4, 0); - zephir_array_update_string(&sqlUpdate, SL("tables"), &sqlTables, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlUpdate, SL("models"), &sqlModels, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlUpdate, SL("fields"), &sqlFields, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&sqlUpdate, SL("values"), &sqlValues, PH_COPY | PH_SEPARATE); - zephir_memory_observe(&where); - if (zephir_array_isset_string_fetch(&where, &ast, SL("where"), 0)) { - ZVAL_BOOL(&_27$$22, 1); - ZEPHIR_CALL_METHOD(&_26$$22, this_ptr, "getexpression", &_14, 458, &where, &_27$$22); - zephir_check_call_status(); - zephir_array_update_string(&sqlUpdate, SL("where"), &_26$$22, PH_COPY | PH_SEPARATE); - } - zephir_memory_observe(&limit); - if (zephir_array_isset_string_fetch(&limit, &ast, SL("limit"), 0)) { - ZEPHIR_CALL_METHOD(&_28$$23, this_ptr, "getlimitclause", NULL, 472, &limit); - zephir_check_call_status(); - zephir_array_update_string(&sqlUpdate, SL("limit"), &_28$$23, PH_COPY | PH_SEPARATE); - } - RETURN_CCTOR(&sqlUpdate); -} - -zend_object *zephir_init_properties_Phalcon_Mvc_Model_Query(zend_class_entry *class_type) -{ - zval _0, _2, _4, _6, _8, _10, _12, _14, _16, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8, _13$$9, _15$$10, _17$$11; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_16); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_13$$9); - ZVAL_UNDEF(&_15$$10); - ZVAL_UNDEF(&_17$$11); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("sqlModelsAliases"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sqlModelsAliases"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("sqlColumnAliases"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sqlColumnAliases"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sqlAliasesModelsInstances"), &_5$$5); +pp69: + ppaccept = 0; + ppch = *(PPMARKER = ++PPCURSOR); + switch (ppch) { + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + case 0x08: + case '\t': + case '\n': + case '\v': + case '\f': + case '\r': + case 0x0E: + case 0x0F: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + case 0x18: + case 0x19: + case 0x1A: + case 0x1B: + case 0x1C: + case 0x1D: + case 0x1E: + case 0x1F: + case '[': + case 0x7F: goto pp5; + default: goto pp164; + } +pp70: + ppch = *++PPCURSOR; + switch (ppch) { + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp5; + } +pp71: + ++PPCURSOR; + { + token->opcode = PHQL_T_BITWISE_XOR; + return 0; } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("sqlAliasesModels"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sqlAliasesModels"), &_7$$6); +pp73: + ppch = *++PPCURSOR; +pp74: + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'x': goto pp73; + case ':': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'y': + case 'z': goto pp58; + default: goto pp47; + } +pp75: + ppaccept = 0; + ppch = *(PPMARKER = ++PPCURSOR); + switch (ppch) { + case '-': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp169; + default: goto pp5; + } +pp76: + ppch = *++PPCURSOR; + switch (ppch) { + case '|': goto pp171; + default: goto pp77; + } +pp77: + { + token->opcode = PHQL_T_BITWISE_OR; + return 0; } - zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("sqlAliases"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_8) == IS_NULL) { - ZEPHIR_INIT_VAR(&_9$$7); - array_init(&_9$$7); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("sqlAliases"), &_9$$7); +pp78: + ++PPCURSOR; + { + token->opcode = PHQL_T_BITWISE_NOT; + return 0; } - zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("modelsInstances"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_10) == IS_NULL) { - ZEPHIR_INIT_VAR(&_11$$8); - array_init(&_11$$8); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("modelsInstances"), &_11$$8); +pp80: + ++PPCURSOR; + { + token->opcode = PHQL_T_TS_NEGATE; + return 0; } - zephir_read_property_ex(&_12, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_12) == IS_NULL) { - ZEPHIR_INIT_VAR(&_13$$9); - array_init(&_13$$9); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("models"), &_13$$9); +pp82: + ++PPCURSOR; + { + token->opcode = PHQL_T_NOTEQUALS; + return 0; } - zephir_read_property_ex(&_14, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_14) == IS_NULL) { - ZEPHIR_INIT_VAR(&_15$$10); - array_init(&_15$$10); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("bindTypes"), &_15$$10); +pp84: + ppch = *++PPCURSOR; +pp85: + switch (ppch) { + case 0x00: goto pp86; + case '"': goto pp87; + case '\\': goto pp89; + default: goto pp84; + } +pp86: + PPCURSOR = PPMARKER; + switch (ppaccept) { + case 0: goto pp5; + case 1: goto pp37; + case 2: goto pp209; + default: goto pp168; + } +pp87: + ++PPCURSOR; + { + token->opcode = PHQL_T_STRING; + token->value = estrndup(q, PPCURSOR - q - 1); + token->len = PPCURSOR - q - 1; + q = PPCURSOR; + return 0; } - zephir_read_property_ex(&_16, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_16) == IS_NULL) { - ZEPHIR_INIT_VAR(&_17$$11); - array_init(&_17$$11); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("bindParams"), &_17$$11); +pp89: + ppch = *++PPCURSOR; + switch (ppch) { + case '\n': goto pp86; + default: goto pp84; + } +pp90: + ++PPCURSOR; + { + token->opcode = PHQL_T_TS_AND; + return 0; } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_QueryInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, QueryInterface, phalcon, mvc_model_queryinterface, phalcon_mvc_model_queryinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, cache); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, execute); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getBindParams); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getCacheOptions); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getBindTypes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getSql); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getSingleResult); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, getUniqueRow); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, parse); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, setBindParams); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, setBindTypes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, setSharedLock); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_QueryInterface, setUniqueRow); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Relation) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Relation, phalcon, mvc_model_relation, phalcon_mvc_model_relation_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("fields"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("intermediateFields"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("intermediateModel"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("intermediateReferencedFields"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("options"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("referencedFields"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("referencedModel"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_relation_ce, SL("type"), ZEND_ACC_PROTECTED); - phalcon_mvc_model_relation_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Relation; - zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("ACTION_CASCADE"), 2); - - zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("ACTION_RESTRICT"), 1); - - zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("BELONGS_TO"), 0); - - zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("HAS_MANY"), 2); - - zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("HAS_MANY_THROUGH"), 4); - - zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("HAS_ONE"), 1); - - zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("HAS_ONE_THROUGH"), 3); - - zephir_declare_class_constant_long(phalcon_mvc_model_relation_ce, SL("NO_ACTION"), 0); - - zend_class_implements(phalcon_mvc_model_relation_ce, 1, phalcon_mvc_model_relationinterface_ce); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval options; - zval referencedModel; - zval *type_param = NULL, *referencedModel_param = NULL, *fields, fields_sub, *referencedFields, referencedFields_sub, *options_param = NULL, _0; - zend_long type; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&fields_sub); - ZVAL_UNDEF(&referencedFields_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&referencedModel); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(4, 5) - Z_PARAM_LONG(type) - Z_PARAM_STR(referencedModel) - Z_PARAM_ZVAL(fields) - Z_PARAM_ZVAL(referencedFields) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 1, &type_param, &referencedModel_param, &fields, &referencedFields, &options_param); - if (UNEXPECTED(Z_TYPE_P(referencedModel_param) != IS_STRING && Z_TYPE_P(referencedModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'referencedModel' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(referencedModel_param) == IS_STRING)) { - zephir_get_strval(&referencedModel, referencedModel_param); - } else { - ZEPHIR_INIT_VAR(&referencedModel); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, type); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("referencedModel"), &referencedModel); - zephir_update_property_zval(this_ptr, ZEND_STRL("fields"), fields); - zephir_update_property_zval(this_ptr, ZEND_STRL("referencedFields"), referencedFields); - zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getFields) -{ - - RETURN_MEMBER(getThis(), "fields"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getForeignKey) -{ - zval options, foreignKey, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&foreignKey); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&options, &_0); - zephir_memory_observe(&foreignKey); - if (zephir_array_isset_string_fetch(&foreignKey, &options, SL("foreignKey"), 0)) { - if (zephir_is_true(&foreignKey)) { - RETURN_CCTOR(&foreignKey); +pp92: + ppch = *++PPCURSOR; +pp93: + switch (ppch) { + case 0x00: goto pp86; + case '\'': goto pp87; + case '\\': goto pp94; + default: goto pp92; + } +pp94: + ppch = *++PPCURSOR; + switch (ppch) { + case '\n': goto pp86; + default: goto pp92; + } +pp95: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto pp95; + default: goto pp97; + } +pp97: + { + token->opcode = PHQL_T_DOUBLE; + token->value = estrndup(q, PPCURSOR - q); + token->len = PPCURSOR - q; + q = PPCURSOR; + return 0; } - } - RETURN_MM_BOOL(0); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getIntermediateFields) -{ - - RETURN_MEMBER(getThis(), "intermediateFields"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getIntermediateModel) -{ - - RETURN_MEMBER(getThis(), "intermediateModel"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getIntermediateReferencedFields) -{ - - RETURN_MEMBER(getThis(), "intermediateReferencedFields"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getOption) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, option, _0; - zval name; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&option); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - zephir_memory_observe(&option); - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&option, &_0, &name, 0))) { - RETURN_MM_NULL(); - } - RETURN_CCTOR(&option); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getOptions) -{ - - RETURN_MEMBER(getThis(), "options"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getParams) -{ - zval options, params, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&options); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&options, &_0); - zephir_memory_observe(¶ms); - if (zephir_array_isset_string_fetch(¶ms, &options, SL("params"), 0)) { - if (zephir_is_true(¶ms)) { - if (zephir_is_callable(¶ms)) { - ZEPHIR_CALL_USER_FUNC(return_value, ¶ms); - zephir_check_call_status(); - RETURN_MM(); +pp98: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'x': goto pp98; + default: goto pp47; } - RETURN_CCTOR(¶ms); +pp100: + ppch = *++PPCURSOR; + switch (ppch) { + case '-': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp100; + case ':': goto pp173; + default: goto pp86; + } +pp102: + ++PPCURSOR; + { + token->opcode = PHQL_T_LESSEQUAL; + return 0; } - } - RETURN_MM_BOOL(0); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getType) -{ - - RETURN_MEMBER(getThis(), "type"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getReferencedFields) -{ - - RETURN_MEMBER(getThis(), "referencedFields"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, getReferencedModel) -{ - - RETURN_MEMBER(getThis(), "referencedModel"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, isForeignKey) -{ - zval foreignKey, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&foreignKey); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_memory_observe(&foreignKey); - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_string_fetch(&foreignKey, &_0, SL("foreignKey"), 0))) { - RETURN_MM_BOOL(0); - } - RETURN_MM_BOOL(zephir_get_boolval(&foreignKey)); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, isThrough) -{ - zend_bool _1; - zval type, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("type"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&type, &_0); - _1 = ZEPHIR_IS_LONG(&type, 3); - if (!(_1)) { - _1 = ZEPHIR_IS_LONG(&type, 4); - } - RETURN_MM_BOOL(_1); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, isReusable) -{ - zval options, reusable, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&reusable); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&options, &_0); - zephir_memory_observe(&reusable); - if (!(zephir_array_isset_string_fetch(&reusable, &options, SL("reusable"), 0))) { - RETURN_MM_BOOL(0); - } - RETURN_CCTOR(&reusable); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Relation, setIntermediateRelation) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval intermediateModel; - zval *intermediateFields, intermediateFields_sub, *intermediateModel_param = NULL, *intermediateReferencedFields, intermediateReferencedFields_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&intermediateFields_sub); - ZVAL_UNDEF(&intermediateReferencedFields_sub); - ZVAL_UNDEF(&intermediateModel); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ZVAL(intermediateFields) - Z_PARAM_STR(intermediateModel) - Z_PARAM_ZVAL(intermediateReferencedFields) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &intermediateFields, &intermediateModel_param, &intermediateReferencedFields); - if (UNEXPECTED(Z_TYPE_P(intermediateModel_param) != IS_STRING && Z_TYPE_P(intermediateModel_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'intermediateModel' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(intermediateModel_param) == IS_STRING)) { - zephir_get_strval(&intermediateModel, intermediateModel_param); - } else { - ZEPHIR_INIT_VAR(&intermediateModel); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("intermediateFields"), intermediateFields); - zephir_update_property_zval(this_ptr, ZEND_STRL("intermediateModel"), &intermediateModel); - zephir_update_property_zval(this_ptr, ZEND_STRL("intermediateReferencedFields"), intermediateReferencedFields); - ZEPHIR_MM_RESTORE(); -} - -zend_object *zephir_init_properties_Phalcon_Mvc_Model_Relation(zend_class_entry *class_type) -{ - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_1$$3); +pp104: + ++PPCURSOR; + { + token->opcode = PHQL_T_NOTEQUALS; + return 0; } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_RelationInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, RelationInterface, phalcon, mvc_model_relationinterface, phalcon_mvc_model_relationinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getFields); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getForeignKey); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getIntermediateFields); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getIntermediateModel); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getIntermediateReferencedFields); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getOption); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getOptions); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getParams); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getReferencedFields); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getReferencedModel); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, getType); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, isForeignKey); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, isReusable); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, isThrough); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_RelationInterface, setIntermediateRelation); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_ResultInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, ResultInterface, phalcon, mvc_model_resultinterface, phalcon_mvc_model_resultinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultInterface, setDirtyState); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Resultset) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Resultset, phalcon, mvc_model_resultset, phalcon_mvc_model_resultset_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("activeRow"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("cache"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_model_resultset_ce, SL("count"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("errorMessages"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_model_resultset_ce, SL("hydrateMode"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_resultset_ce, SL("isFresh"), 1, ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_model_resultset_ce, SL("pointer"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("row"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("rows"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_resultset_ce, SL("result"), ZEND_ACC_PROTECTED); - phalcon_mvc_model_resultset_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Resultset; - zephir_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("HYDRATE_ARRAYS"), 1); - - zephir_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("HYDRATE_OBJECTS"), 2); - - zephir_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("HYDRATE_RECORDS"), 0); - - zephir_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("TYPE_RESULT_FULL"), 0); - - zephir_declare_class_constant_long(phalcon_mvc_model_resultset_ce, SL("TYPE_RESULT_PARTIAL"), 1); - - zend_class_implements(phalcon_mvc_model_resultset_ce, 1, phalcon_mvc_model_resultsetinterface_ce); - zend_class_implements(phalcon_mvc_model_resultset_ce, 1, zend_ce_iterator); - zend_class_implements(phalcon_mvc_model_resultset_ce, 1, spl_ce_SeekableIterator); - zend_class_implements(phalcon_mvc_model_resultset_ce, 1, zend_ce_countable); - zend_class_implements(phalcon_mvc_model_resultset_ce, 1, zend_ce_arrayaccess); - zend_class_implements(phalcon_mvc_model_resultset_ce, 1, zend_ce_serializable); - zend_class_implements(phalcon_mvc_model_resultset_ce, 1, php_json_serializable_ce); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, __construct) -{ - zend_bool _11, _4$$4; - zval _10, _7$$5; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, prefetchRecords = 0; - zval *result, result_sub, *cache = NULL, cache_sub, __$null, rowCount, rows, _8, _0$$3, _1$$3, _2$$4, _3$$4, _5$$4, _6$$5, _9$$6, _12$$9; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&result_sub); - ZVAL_UNDEF(&cache_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&rowCount); - ZVAL_UNDEF(&rows); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_9$$6); - ZVAL_UNDEF(&_12$$9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_7$$5); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(result) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(cache) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &result, &cache); - if (!cache) { - cache = &cache_sub; - cache = &__$null; - } - if (Z_TYPE_P(result) != IS_OBJECT) { - ZVAL_UNDEF(&_0$$3); - ZVAL_LONG(&_0$$3, 0); - zephir_update_property_zval(this_ptr, ZEND_STRL("count"), &_0$$3); - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_1$$3); - RETURN_MM_NULL(); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("result"), result); - if (Z_TYPE_P(cache) != IS_NULL) { - ZEPHIR_INIT_VAR(&_2$$4); - ZVAL_STRING(&_2$$4, "Phalcon\\Cache\\CacheInterface"); - ZEPHIR_CALL_FUNCTION(&_3$$4, "is_a", NULL, 87, cache, &_2$$4); - zephir_check_call_status(); - _4$$4 = !ZEPHIR_IS_TRUE_IDENTICAL(&_3$$4); - if (_4$$4) { - ZEPHIR_INIT_NVAR(&_2$$4); - ZVAL_STRING(&_2$$4, "Psr\\SimpleCache\\CacheInterface"); - ZEPHIR_CALL_FUNCTION(&_5$$4, "is_a", NULL, 87, cache, &_2$$4); - zephir_check_call_status(); - _4$$4 = !ZEPHIR_IS_TRUE_IDENTICAL(&_5$$4); +pp106: + ++PPCURSOR; + { + token->opcode = PHQL_T_GREATEREQUAL; + return 0; } - if (UNEXPECTED(_4$$4)) { - ZEPHIR_INIT_VAR(&_6$$5); - object_init_ex(&_6$$5, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_7$$5); - ZEPHIR_CONCAT_SS(&_7$$5, "Cache service must be an object implementing ", "Phalcon\\Cache\\CacheInterface or Psr\\SimpleCache\\CacheInterface"); - ZEPHIR_CALL_METHOD(NULL, &_6$$5, "__construct", NULL, 33, &_7$$5); - zephir_check_call_status(); - zephir_throw_exception_debug(&_6$$5, "phalcon/Mvc/Model/Resultset.zep", 168); - ZEPHIR_MM_RESTORE(); - return; +pp108: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto pp108; + default: goto pp110; + } +pp110: + { + token->opcode = PHQL_T_NPLACEHOLDER; + token->value = estrndup(q, PPCURSOR - q); + token->len = PPCURSOR - q; + q = PPCURSOR; + return 0; } - zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), cache); - } - ZVAL_LONG(&_8, 2); - ZEPHIR_CALL_METHOD(NULL, result, "setfetchmode", NULL, 0, &_8); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&rowCount, result, "numrows", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("count"), &rowCount); - if (ZEPHIR_IS_LONG(&rowCount, 0)) { - ZEPHIR_INIT_VAR(&_9$$6); - array_init(&_9$$6); - zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_9$$6); - RETURN_MM_NULL(); - } - ZEPHIR_INIT_VAR(&_10); - ZEPHIR_INIT_NVAR(&_10); - ZVAL_STRING(&_10, "ZEPHIR_GLOBAL(orm).resultset_prefetch_records"); - prefetchRecords = zephir_get_intval_ex(&_10); - _11 = prefetchRecords > 0; - if (_11) { - _11 = ZEPHIR_LE_LONG(&rowCount, prefetchRecords); - } - if (_11) { - ZEPHIR_CALL_METHOD(&rows, result, "fetchall", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&rows) == IS_ARRAY) { - zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &rows); - } else { - ZEPHIR_INIT_VAR(&_12$$9); - array_init(&_12$$9); - zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_12$$9); +pp111: + ++PPCURSOR; + { + token->opcode = PHQL_T_TS_CONTAINS_ANOTHER; + return 0; } - } - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, count) -{ - - RETURN_MEMBER(getThis(), "count"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, delete) -{ - zval _4$$6; - zend_bool result = 0, transaction = 0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_5 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *conditionCallback = NULL, conditionCallback_sub, __$null, record, connection, _0, _3$$6, _6$$3, _7$$8; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&conditionCallback_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&record); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3$$6); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$8); - ZVAL_UNDEF(&_4$$6); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(conditionCallback, zend_ce_closure) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &conditionCallback); - if (!conditionCallback) { - conditionCallback = &conditionCallback_sub; - conditionCallback = &__$null; - } - ZEPHIR_INIT_VAR(&connection); - ZVAL_NULL(&connection); - result = 1; - transaction = 0; - ZEPHIR_CALL_METHOD(NULL, this_ptr, "rewind", NULL, 92); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", &_1, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_0))) { - break; +pp113: + ++PPCURSOR; + { + token->opcode = PHQL_T_TS_MATCHES; + return 0; } - ZEPHIR_CALL_METHOD(&record, this_ptr, "current", &_2, 0); - zephir_check_call_status(); - if (transaction == 0) { - if (UNEXPECTED(!((zephir_method_exists_ex(&record, ZEND_STRL("getwriteconnection")) == SUCCESS)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The returned record is not valid", "phalcon/Mvc/Model/Resultset.zep", 242); - return; +pp115: + ppch = *++PPCURSOR; + switch (ppch) { + case 'A': + case 'a': goto pp175; + default: goto pp59; } - ZEPHIR_CALL_METHOD(&connection, &record, "getwriteconnection", NULL, 0); - zephir_check_call_status(); - transaction = 1; - ZEPHIR_CALL_METHOD(NULL, &connection, "begin", NULL, 0); - zephir_check_call_status(); - } - if (Z_TYPE_P(conditionCallback) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_3$$6); - ZEPHIR_INIT_NVAR(&_4$$6); - zephir_create_array(&_4$$6, 1, 0); - zephir_array_fast_append(&_4$$6, &record); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_3$$6, conditionCallback, &_4$$6); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_3$$6)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); - zephir_check_call_status(); - continue; +pp116: + ppch = *++PPCURSOR; + switch (ppch) { + case 'L': + case 'l': goto pp176; + default: goto pp59; } +pp117: + ppch = *++PPCURSOR; + switch (ppch) { + case 'D': + case 'd': goto pp178; + default: goto pp59; + } +pp118: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + case 'C': + case 'c': goto pp180; + default: goto pp119; + } +pp119: + { + token->opcode = PHQL_T_AS; + return 0; } - ZEPHIR_CALL_METHOD(&_6$$3, &record, "delete", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_6$$3))) { - ZEPHIR_CALL_METHOD(&_7$$8, &record, "getmessages", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("errorMessages"), &_7$$8); - ZEPHIR_CALL_METHOD(NULL, &connection, "rollback", NULL, 0); - zephir_check_call_status(); - result = 0; - transaction = 0; - break; - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); - zephir_check_call_status(); - } - if (transaction == 1) { - ZEPHIR_CALL_METHOD(NULL, &connection, "commit", NULL, 0); - zephir_check_call_status(); - } - RETURN_MM_BOOL(result); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, filter) -{ - zend_bool _4$$3; - zval records, _3$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_5 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *filter, filter_sub, record, processedRecord, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&filter_sub); - ZVAL_UNDEF(&record); - ZVAL_UNDEF(&processedRecord); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&records); - ZVAL_UNDEF(&_3$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(filter) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &filter); - ZEPHIR_INIT_VAR(&records); - array_init(&records); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "rewind", NULL, 92); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", &_1, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_0))) { - break; - } - ZEPHIR_CALL_METHOD(&record, this_ptr, "current", &_2, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_3$$3); - zephir_create_array(&_3$$3, 1, 0); - zephir_array_fast_append(&_3$$3, &record); - ZEPHIR_INIT_NVAR(&processedRecord); - ZEPHIR_CALL_USER_FUNC_ARRAY(&processedRecord, filter, &_3$$3); - zephir_check_call_status(); - _4$$3 = Z_TYPE_P(&processedRecord) != IS_OBJECT; - if (_4$$3) { - _4$$3 = Z_TYPE_P(&processedRecord) != IS_ARRAY; - } - if (_4$$3) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); - zephir_check_call_status(); - continue; - } - zephir_array_append(&records, &processedRecord, PH_SEPARATE, "phalcon/Mvc/Model/Resultset.zep", 336); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); - zephir_check_call_status(); - } - RETURN_CTOR(&records); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getCache) -{ - - RETURN_MEMBER(getThis(), "cache"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getFirst) -{ - zval _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("count"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_LONG(&_0, 0)) { - RETURN_MM_NULL(); - } - ZVAL_LONG(&_1, 0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 93, &_1); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "current", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getHydrateMode) -{ - - RETURN_MEMBER(getThis(), "hydrateMode"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getLast) -{ - zval count, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&count); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("count"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&count, &_0); - if (ZEPHIR_IS_LONG(&count, 0)) { - RETURN_MM_NULL(); - } - ZVAL_LONG(&_0, (zephir_get_numberval(&count) - 1)); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 93, &_0); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "current", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getMessages) -{ - - RETURN_MEMBER(getThis(), "errorMessages"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, getType) -{ - zval _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - zephir_memory_observe(&_1); - zephir_read_property(&_1, this_ptr, ZEND_STRL("rows"), PH_NOISY_CC); - if (Z_TYPE_P(&_1) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_0); - ZVAL_LONG(&_0, 0); - } else { - ZEPHIR_INIT_NVAR(&_0); - ZVAL_LONG(&_0, 1); - } - RETURN_CCTOR(&_0); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, isFresh) -{ - - RETURN_MEMBER(getThis(), "isFresh"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, jsonSerialize) -{ - zend_bool _3$$3; - zval records; - zval current, _0, _4$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_5 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(¤t); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&records); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&records); - array_init(&records); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "rewind", NULL, 92); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", &_1, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_0))) { - break; - } - ZEPHIR_CALL_METHOD(¤t, this_ptr, "current", &_2, 0); - zephir_check_call_status(); - _3$$3 = Z_TYPE_P(¤t) == IS_OBJECT; - if (_3$$3) { - _3$$3 = (zephir_method_exists_ex(¤t, ZEND_STRL("jsonserialize")) == SUCCESS); - } - if (_3$$3) { - ZEPHIR_CALL_METHOD(&_4$$4, ¤t, "jsonserialize", NULL, 0); - zephir_check_call_status(); - zephir_array_append(&records, &_4$$4, PH_SEPARATE, "phalcon/Mvc/Model/Resultset.zep", 461); - } else { - zephir_array_append(&records, ¤t, PH_SEPARATE, "phalcon/Mvc/Model/Resultset.zep", 463); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); - zephir_check_call_status(); - } - RETURN_CTOR(&records); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, key) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_0))) { - RETURN_MM_NULL(); - } - RETURN_MM_MEMBER(getThis(), "pointer"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, next) -{ - zval _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("pointer"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_1, (zephir_get_numberval(&_0) + 1)); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 93, &_1); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetGet) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval index_sub, _0; - zval *index; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&index_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(index) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &index); - zephir_read_property(&_0, this_ptr, ZEND_STRL("count"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(ZEPHIR_GE(index, &_0))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The index does not exist in the cursor", "phalcon/Mvc/Model/Resultset.zep", 503); - return; - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 93, index); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "current", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetExists) -{ - zval *index, index_sub, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&index_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(index) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &index); - zephir_read_property(&_0, this_ptr, ZEND_STRL("count"), PH_NOISY_CC | PH_READONLY); - RETURN_BOOL(ZEPHIR_LT(index, &_0)); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetSet) -{ - zval *offset, offset_sub, *value, value_sub; - - ZVAL_UNDEF(&offset_sub); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(offset) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(2, 0, &offset, &value); - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_model_exception_ce, "Cursor is an immutable ArrayAccess object", "phalcon/Mvc/Model/Resultset.zep", 530); - return; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, offsetUnset) -{ - zval *offset, offset_sub; - - ZVAL_UNDEF(&offset_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(offset) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &offset); - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_model_exception_ce, "Cursor is an immutable ArrayAccess object", "phalcon/Mvc/Model/Resultset.zep", 538); - return; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, rewind) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZVAL_LONG(&_0, 0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "seek", NULL, 93, &_0); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, seek) -{ - zend_bool _1, _6$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_13 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *position, position_sub, __$null, result, row, _0, _2, _3$$3, _5$$3, _7$$3, _9$$3, _11$$3, _4$$4, _8$$6, _10$$7, _12$$8; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&position_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&row); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_9$$3); - ZVAL_UNDEF(&_11$$3); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_8$$6); - ZVAL_UNDEF(&_10$$7); - ZVAL_UNDEF(&_12$$8); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(position) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &position); - zephir_read_property(&_0, this_ptr, ZEND_STRL("pointer"), PH_NOISY_CC | PH_READONLY); - _1 = !ZEPHIR_IS_EQUAL(&_0, position); - if (!(_1)) { - zephir_read_property(&_2, this_ptr, ZEND_STRL("row"), PH_NOISY_CC | PH_READONLY); - _1 = Z_TYPE_P(&_2) == IS_NULL; - } - if (_1) { - zephir_memory_observe(&_3$$3); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("rows"), PH_NOISY_CC); - if (Z_TYPE_P(&_3$$3) == IS_ARRAY) { - zephir_memory_observe(&row); - zephir_read_property(&_4$$4, this_ptr, ZEND_STRL("rows"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&row, &_4$$4, position, 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("row"), &row); +pp120: + ppch = *++PPCURSOR; + switch (ppch) { + case 'T': + case 't': goto pp182; + default: goto pp74; } - zephir_update_property_zval(this_ptr, ZEND_STRL("pointer"), position); - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &__$null); - RETURN_MM_NULL(); - } - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("result"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&result, &_5$$3); - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("row"), PH_NOISY_CC | PH_READONLY); - _6$$3 = Z_TYPE_P(&_5$$3) == IS_NULL; - if (_6$$3) { - zephir_read_property(&_7$$3, this_ptr, ZEND_STRL("pointer"), PH_NOISY_CC | PH_READONLY); - _6$$3 = ZEPHIR_IS_LONG_IDENTICAL(&_7$$3, 0); - } - if (_6$$3) { - ZEPHIR_CALL_METHOD(&_8$$6, &result, "fetch", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("row"), &_8$$6); - } - zephir_read_property(&_9$$3, this_ptr, ZEND_STRL("pointer"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_GT(&_9$$3, position)) { - ZEPHIR_CALL_METHOD(NULL, &result, "dataseek", NULL, 0, position); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_10$$7, &result, "fetch", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("row"), &_10$$7); - zephir_update_property_zval(this_ptr, ZEND_STRL("pointer"), position); - } - while (1) { - zephir_read_property(&_11$$3, this_ptr, ZEND_STRL("pointer"), PH_NOISY_CC | PH_READONLY); - if (!(ZEPHIR_LT(&_11$$3, position))) { - break; +pp121: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp122; } - ZEPHIR_CALL_METHOD(&_12$$8, &result, "fetch", &_13, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("row"), &_12$$8); - RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("pointer"))); +pp122: + { + token->opcode = PHQL_T_BY; + return 0; } - zephir_update_property_zval(this_ptr, ZEND_STRL("pointer"), position); - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &__$null); - } - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, setHydrateMode) -{ - zval *hydrateMode_param = NULL, _0; - zend_long hydrateMode; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(hydrateMode) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &hydrateMode_param); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, hydrateMode); - zephir_update_property_zval(this_ptr, ZEND_STRL("hydrateMode"), &_0); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, setIsFresh) -{ - zval *isFresh_param = NULL, __$true, __$false; - zend_bool isFresh; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(isFresh) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &isFresh_param); - if (isFresh) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isFresh"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("isFresh"), &__$false); - } - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, update) -{ - zval _4$$6; - zend_bool transaction = 0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_5 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *data, data_sub, *conditionCallback = NULL, conditionCallback_sub, __$null, record, connection, _0, _3$$6, _6$$3, _7$$8; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&data_sub); - ZVAL_UNDEF(&conditionCallback_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&record); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3$$6); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$8); - ZVAL_UNDEF(&_4$$6); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(data) - Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(conditionCallback, zend_ce_closure) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &data, &conditionCallback); - if (!conditionCallback) { - conditionCallback = &conditionCallback_sub; - conditionCallback = &__$null; - } - ZEPHIR_INIT_VAR(&connection); - ZVAL_NULL(&connection); - transaction = 0; - ZEPHIR_CALL_METHOD(NULL, this_ptr, "rewind", NULL, 92); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", &_1, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_0))) { - break; +pp123: + ppch = *++PPCURSOR; + switch (ppch) { + case 'S': + case 's': goto pp183; + default: goto pp74; + } +pp124: + ppch = *++PPCURSOR; + switch (ppch) { + case 'N': + case 'n': goto pp184; + default: goto pp59; + } +pp125: + ppch = *++PPCURSOR; + switch (ppch) { + case 'O': + case 'o': goto pp185; + default: goto pp59; + } +pp126: + ppch = *++PPCURSOR; + switch (ppch) { + case 'L': + case 'l': goto pp186; + case 'S': + case 's': goto pp187; + default: goto pp74; + } +pp127: + ppch = *++PPCURSOR; + switch (ppch) { + case 'S': + case 's': goto pp188; + default: goto pp59; + } +pp128: + ppch = *++PPCURSOR; + switch (ppch) { + case 'S': + case 's': goto pp189; + default: goto pp59; + } +pp129: + ppch = *++PPCURSOR; + switch (ppch) { + case 'D': + case 'd': goto pp190; + default: goto pp59; + } +pp130: + ppch = *++PPCURSOR; + switch (ppch) { + case 'I': + case 'i': goto pp192; + default: goto pp59; + } +pp131: + ppch = *++PPCURSOR; + switch (ppch) { + case 'I': + case 'i': goto pp192; + default: goto pp74; + } +pp132: + ppch = *++PPCURSOR; + switch (ppch) { + case 'L': + case 'l': goto pp193; + default: goto pp74; + } +pp133: + ppch = *++PPCURSOR; + switch (ppch) { + case 'R': + case 'r': goto pp194; + default: goto pp59; + } +pp134: + ppch = *++PPCURSOR; + switch (ppch) { + case 'O': + case 'o': goto pp196; + default: goto pp59; + } +pp135: + ppch = *++PPCURSOR; + switch (ppch) { + case 'L': + case 'l': goto pp197; + default: goto pp59; + } +pp136: + ppch = *++PPCURSOR; + switch (ppch) { + case 'O': + case 'o': goto pp198; + default: goto pp59; + } +pp137: + ppch = *++PPCURSOR; + switch (ppch) { + case 'V': + case 'v': goto pp199; + default: goto pp59; + } +pp138: + ppch = *++PPCURSOR; + switch (ppch) { + case 'I': + case 'i': goto pp200; + default: goto pp59; + } +pp139: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'o': + case 'p': + case 'q': + case 'r': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + case 'N': + case 'n': goto pp201; + case 'S': + case 's': goto pp202; + case 'T': + case 't': goto pp203; + default: goto pp140; + } +pp140: + { + token->opcode = PHQL_T_IN; + return 0; } - ZEPHIR_CALL_METHOD(&record, this_ptr, "current", &_2, 0); - zephir_check_call_status(); - if (transaction == 0) { - if (UNEXPECTED(!((zephir_method_exists_ex(&record, ZEND_STRL("getwriteconnection")) == SUCCESS)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The returned record is not valid", "phalcon/Mvc/Model/Resultset.zep", 655); - return; +pp141: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp142; } - ZEPHIR_CALL_METHOD(&connection, &record, "getwriteconnection", NULL, 0); - zephir_check_call_status(); - transaction = 1; - ZEPHIR_CALL_METHOD(NULL, &connection, "begin", NULL, 0); - zephir_check_call_status(); +pp142: + { + token->opcode = PHQL_T_IS; + return 0; } - if (Z_TYPE_P(conditionCallback) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_3$$6); - ZEPHIR_INIT_NVAR(&_4$$6); - zephir_create_array(&_4$$6, 1, 0); - zephir_array_fast_append(&_4$$6, &record); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_3$$6, conditionCallback, &_4$$6); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_3$$6)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); - zephir_check_call_status(); - continue; +pp143: + ppch = *++PPCURSOR; + switch (ppch) { + case 'I': + case 'i': goto pp204; + default: goto pp59; + } +pp144: + ppch = *++PPCURSOR; + switch (ppch) { + case 'F': + case 'f': goto pp205; + default: goto pp59; + } +pp145: + ppch = *++PPCURSOR; + switch (ppch) { + case 'K': + case 'k': goto pp206; + case 'M': + case 'm': goto pp207; + default: goto pp59; + } +pp146: + ppch = *++PPCURSOR; + switch (ppch) { + case 'T': + case 't': goto pp208; + default: goto pp59; + } +pp147: + ppch = *++PPCURSOR; + switch (ppch) { + case 'L': + case 'l': goto pp210; + default: goto pp59; + } +pp148: + ppch = *++PPCURSOR; + switch (ppch) { + case 'F': + case 'f': goto pp211; + default: goto pp59; + } +pp149: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp150; } +pp150: + { + token->opcode = PHQL_T_ON; + return 0; } - ZEPHIR_CALL_METHOD(NULL, &record, "assign", NULL, 0, data); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_6$$3, &record, "save", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_6$$3))) { - ZEPHIR_CALL_METHOD(&_7$$8, &record, "getmessages", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("errorMessages"), &_7$$8); - ZEPHIR_CALL_METHOD(NULL, &connection, "rollback", NULL, 0); - zephir_check_call_status(); - transaction = 0; - break; +pp151: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + case 'D': + case 'd': goto pp212; + default: goto pp152; + } +pp152: + { + token->opcode = PHQL_T_OR; + return 0; } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_5, 0); - zephir_check_call_status(); - } - if (transaction == 1) { - ZEPHIR_CALL_METHOD(NULL, &connection, "commit", NULL, 0); - zephir_check_call_status(); - } - RETURN_MM_BOOL(transaction); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset, valid) -{ - zval _0, _1; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("pointer"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_1, this_ptr, ZEND_STRL("count"), PH_NOISY_CC | PH_READONLY); - RETURN_BOOL(ZEPHIR_LT(&_0, &_1)); -} - -zend_object *zephir_init_properties_Phalcon_Mvc_Model_Resultset(zend_class_entry *class_type) -{ - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("errorMessages"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("errorMessages"), &_1$$3); +pp153: + ppch = *++PPCURSOR; + switch (ppch) { + case 'T': + case 't': goto pp213; + default: goto pp59; + } +pp154: + ppch = *++PPCURSOR; + switch (ppch) { + case 'G': + case 'g': goto pp214; + default: goto pp59; + } +pp155: + ppch = *++PPCURSOR; + switch (ppch) { + case 'L': + case 'l': goto pp215; + case 'T': + case 't': goto pp216; + default: goto pp59; + } +pp156: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp218; + default: goto pp59; + } +pp157: + ppch = *++PPCURSOR; + switch (ppch) { + case 'U': + case 'u': goto pp219; + default: goto pp59; + } +pp158: + ppch = *++PPCURSOR; + switch (ppch) { + case 'D': + case 'd': goto pp220; + default: goto pp59; + } +pp159: + ppch = *++PPCURSOR; + switch (ppch) { + case 'I': + case 'i': goto pp221; + default: goto pp59; + } +pp160: + ppch = *++PPCURSOR; + switch (ppch) { + case 'L': + case 'l': goto pp222; + default: goto pp59; + } +pp161: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp223; + default: goto pp59; + } +pp162: + ppch = *++PPCURSOR; + switch (ppch) { + case 'T': + case 't': goto pp224; + default: goto pp59; + } +pp163: + ppch = *++PPCURSOR; +pp164: + switch (ppch) { + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + case 0x08: + case '\t': + case '\n': + case '\v': + case '\f': + case '\r': + case 0x0E: + case 0x0F: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + case 0x18: + case 0x19: + case 0x1A: + case 0x1B: + case 0x1C: + case 0x1D: + case 0x1E: + case 0x1F: + case '[': + case 0x7F: goto pp86; + case '\\': goto pp165; + case ']': goto pp167; + default: goto pp163; + } +pp165: + ppch = *++PPCURSOR; + switch (ppch) { + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + case 0x08: + case '\t': + case '\n': + case '\v': + case '\f': + case '\r': + case 0x0E: + case 0x0F: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + case 0x18: + case 0x19: + case 0x1A: + case 0x1B: + case 0x1C: + case 0x1D: + case 0x1E: + case 0x1F: + case 0x7F: goto pp86; + case '\\': goto pp165; + case ']': goto pp225; + default: goto pp163; + } +pp167: + ++PPCURSOR; +pp168: + { + token->opcode = PHQL_T_IDENTIFIER; + token->value = estrndup(q, PPCURSOR - q - 1); + token->len = PPCURSOR - q - 1; + q = PPCURSOR; + return 0; } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_ResultsetInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, ResultsetInterface, phalcon, mvc_model_resultsetinterface, phalcon_mvc_model_resultsetinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, delete); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, filter); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getCache); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getFirst); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getHydrateMode); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getLast); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getMessages); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, getType); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, isFresh); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, setHydrateMode); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, setIsFresh); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, toArray); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_ResultsetInterface, update); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Row) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model, Row, phalcon, mvc_model_row, zend_standard_class_def, phalcon_mvc_model_row_method_entry, 0); - - zend_class_implements(phalcon_mvc_model_row_ce, 1, phalcon_mvc_entityinterface_ce); - zend_class_implements(phalcon_mvc_model_row_ce, 1, phalcon_mvc_model_resultinterface_ce); - zend_class_implements(phalcon_mvc_model_row_ce, 1, zend_ce_arrayaccess); - zend_class_implements(phalcon_mvc_model_row_ce, 1, php_json_serializable_ce); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Row, jsonSerialize) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "toarray", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Row, offsetGet) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval index_sub, _0, _1; - zval *index; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&index_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(index) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &index); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "offsetexists", NULL, 0, index); - zephir_check_call_status(); - if (!(zephir_is_true(&_0))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The index does not exist in the row", "phalcon/Mvc/Model/Row.zep", 42); - return; - } - zephir_memory_observe(&_1); - zephir_read_property_zval(&_1, this_ptr, index, PH_NOISY_CC); - RETURN_CCTOR(&_1); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Row, offsetExists) -{ - zval index_sub; - zval *index; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&index_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(index) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &index); - RETURN_BOOL(zephir_isset_property_zval(this_ptr, index)); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Row, offsetSet) -{ - zval offset_sub, value_sub; - zval *offset, *value; - - ZVAL_UNDEF(&offset_sub); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(offset) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(2, 0, &offset, &value); - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_model_exception_ce, "Row is an immutable ArrayAccess object", "phalcon/Mvc/Model/Row.zep", 66); - return; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Row, offsetUnset) -{ - zval offset_sub; - zval *offset; - - ZVAL_UNDEF(&offset_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(offset) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &offset); - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_mvc_model_exception_ce, "Row is an immutable ArrayAccess object", "phalcon/Mvc/Model/Row.zep", 76); - return; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Row, readAttribute) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *attribute_param = NULL, value; - zval attribute; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&value); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(attribute) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &attribute_param); - if (UNEXPECTED(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(attribute_param) == IS_STRING)) { - zephir_get_strval(&attribute, attribute_param); - } else { - ZEPHIR_INIT_VAR(&attribute); - } - zephir_memory_observe(&value); - if (!(zephir_fetch_property_zval(&value, this_ptr, &attribute, PH_SILENT_CC))) { - RETURN_MM_NULL(); - } - RETURN_CCTOR(&value); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Row, setDirtyState) -{ - zval *dirtyState_param = NULL; - zend_long dirtyState; - - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(dirtyState) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &dirtyState_param); - RETURN_BOOL(0); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Row, toArray) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_RETURN_CALL_FUNCTION("get_object_vars", NULL, 426, this_ptr); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Row, writeAttribute) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *attribute_param = NULL, *value, value_sub; - zval attribute; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(attribute) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &attribute_param, &value); - if (UNEXPECTED(Z_TYPE_P(attribute_param) != IS_STRING && Z_TYPE_P(attribute_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'attribute' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(attribute_param) == IS_STRING)) { - zephir_get_strval(&attribute, attribute_param); - } else { - ZEPHIR_INIT_VAR(&attribute); - } - zephir_update_property_zval_zval(this_ptr, &attribute, value); - ZEPHIR_MM_RESTORE(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Transaction) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model, Transaction, phalcon, mvc_model_transaction, phalcon_mvc_model_transaction_method_entry, 0); - - zend_declare_property_bool(phalcon_mvc_model_transaction_ce, SL("activeTransaction"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_transaction_ce, SL("connection"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_transaction_ce, SL("isNewTransaction"), 1, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_transaction_ce, SL("manager"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_transaction_ce, SL("messages"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_transaction_ce, SL("rollbackRecord"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_transaction_ce, SL("rollbackOnAbort"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_transaction_ce, SL("rollbackThrowException"), 0, ZEND_ACC_PROTECTED); - phalcon_mvc_model_transaction_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Transaction; - - zend_class_implements(phalcon_mvc_model_transaction_ce, 1, phalcon_mvc_model_transactioninterface_ce); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval service; - zend_bool autoBegin; - zval *container, container_sub, *autoBegin_param = NULL, *service_param = NULL, connection, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container_sub); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&service); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(autoBegin) - Z_PARAM_STR(service) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &container, &autoBegin_param, &service_param); - if (!autoBegin_param) { - autoBegin = 0; - } else { +pp169: + ppch = *++PPCURSOR; + switch (ppch) { + case '-': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp169; + case '}': goto pp226; + default: goto pp86; + } +pp171: + ++PPCURSOR; + { + token->opcode = PHQL_T_TS_OR; + return 0; } - if (!service_param) { - ZEPHIR_INIT_VAR(&service); - ZVAL_STRING(&service, "db"); - } else { - zephir_get_strval(&service, service_param); - } - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), &_0); - ZEPHIR_CALL_METHOD(&connection, container, "get", NULL, 0, &service); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("connection"), &connection); - if (autoBegin) { - ZEPHIR_CALL_METHOD(NULL, &connection, "begin", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, begin) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "begin", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, commit) -{ - zval manager, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - if (Z_TYPE_P(&manager) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(NULL, &manager, "notifycommit", NULL, 0, this_ptr); - zephir_check_call_status(); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "commit", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, getConnection) -{ - zval _0, _1$$3, _2$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("rollbackOnAbort"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_0)) { - ZEPHIR_CALL_FUNCTION(&_1$$3, "connection_aborted", NULL, 481); - zephir_check_call_status(); - if (zephir_is_true(&_1$$3)) { - ZEPHIR_INIT_VAR(&_2$$4); - ZVAL_STRING(&_2$$4, "The request was aborted"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "rollback", NULL, 0, &_2$$4); - zephir_check_call_status(); +pp173: + ++PPCURSOR; + { + token->opcode = PHQL_T_SPLACEHOLDER; + token->value = estrndup(q, PPCURSOR - q - 1); + token->len = PPCURSOR - q - 1; + q = PPCURSOR; + return 0; } - } - RETURN_MM_MEMBER(getThis(), "connection"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, getMessages) -{ - - RETURN_MEMBER(getThis(), "messages"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, isManaged) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_memory_observe(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC); - RETURN_MM_BOOL(Z_TYPE_P(&_0) == IS_OBJECT); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, isValid) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "isundertransaction", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, rollback) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *rollbackMessage_param = NULL, *rollbackRecord = NULL, rollbackRecord_sub, __$null, manager, connection, _0, _1, _2$$4, _3$$7, _4$$7; - zval rollbackMessage; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&rollbackMessage); - ZVAL_UNDEF(&rollbackRecord_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&manager); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$7); - ZVAL_UNDEF(&_4$$7); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(rollbackMessage) - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(rollbackRecord, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &rollbackMessage_param, &rollbackRecord); - if (!rollbackMessage_param) { - ZEPHIR_INIT_VAR(&rollbackMessage); - } else { - zephir_get_strval(&rollbackMessage, rollbackMessage_param); - } - if (!rollbackRecord) { - rollbackRecord = &rollbackRecord_sub; - rollbackRecord = &__$null; - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("manager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&manager, &_0); - if (Z_TYPE_P(&manager) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(NULL, &manager, "notifyrollback", NULL, 0, this_ptr); - zephir_check_call_status(); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&connection, &_0); - ZEPHIR_CALL_METHOD(&_1, &connection, "rollback", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(zephir_is_true(&_1))) { - if (!(!(ZEPHIR_IS_EMPTY(&rollbackMessage)))) { - ZEPHIR_INIT_NVAR(&rollbackMessage); - ZVAL_STRING(&rollbackMessage, "Transaction aborted"); +pp175: + ppch = *++PPCURSOR; + switch (ppch) { + case 'I': + case 'i': goto pp228; + default: goto pp59; + } +pp176: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp177; + } +pp177: + { + token->opcode = PHQL_T_ALL; + return 0; } - if (Z_TYPE_P(rollbackRecord) == IS_OBJECT) { - zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackRecord"), rollbackRecord); +pp178: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp179; + } +pp179: + { + token->opcode = PHQL_T_AND; + return 0; } - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("rollbackThrowException"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_2$$4)) { - ZEPHIR_INIT_VAR(&_3$$7); - object_init_ex(&_3$$7, phalcon_mvc_model_transaction_failed_ce); - zephir_read_property(&_4$$7, this_ptr, ZEND_STRL("rollbackRecord"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_3$$7, "__construct", NULL, 482, &rollbackMessage, &_4$$7); - zephir_check_call_status(); - zephir_throw_exception_debug(&_3$$7, "phalcon/Mvc/Model/Transaction.zep", 215); - ZEPHIR_MM_RESTORE(); - return; +pp180: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp181; + } +pp181: + { + token->opcode = PHQL_T_ASC; + return 0; } - } - RETURN_MM_BOOL(1); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, setIsNewTransaction) -{ - zval *isNew_param = NULL, __$true, __$false; - zend_bool isNew; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(isNew) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &isNew_param); - if (isNew) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isNewTransaction"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("isNewTransaction"), &__$false); - } -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, setRollbackOnAbort) -{ - zval *rollbackOnAbort_param = NULL, __$true, __$false; - zend_bool rollbackOnAbort; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(rollbackOnAbort) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &rollbackOnAbort_param); - if (rollbackOnAbort) { - zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackOnAbort"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackOnAbort"), &__$false); - } -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, setRollbackedRecord) -{ - zval *record, record_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&record_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(record, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &record); - zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackRecord"), record); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, setTransactionManager) -{ - zval *manager, manager_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&manager_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(manager, phalcon_mvc_model_transaction_managerinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &manager); - zephir_update_property_zval(this_ptr, ZEND_STRL("manager"), manager); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction, throwRollbackException) -{ - zval *status_param = NULL, __$true, __$false; - zend_bool status; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(status) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &status_param); - if (status) { - zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackThrowException"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackThrowException"), &__$false); - } - RETURN_THISW(); -} - -zend_object *zephir_init_properties_Phalcon_Mvc_Model_Transaction(zend_class_entry *class_type) -{ - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("messages"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_TransactionInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model, TransactionInterface, phalcon, mvc_model_transactioninterface, phalcon_mvc_model_transactioninterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, begin); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, commit); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, getConnection); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, getMessages); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, isManaged); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, isValid); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, rollback); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, setIsNewTransaction); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, setRollbackOnAbort); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, setRollbackedRecord); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, setTransactionManager); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_TransactionInterface, throwRollbackException); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_ValidationFailed) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model, ValidationFailed, phalcon, mvc_model_validationfailed, phalcon_mvc_model_exception_ce, phalcon_mvc_model_validationfailed_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_model_validationfailed_ce, SL("messages"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_validationfailed_ce, SL("model"), ZEND_ACC_PROTECTED); - phalcon_mvc_model_validationfailed_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_ValidationFailed; - - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Model_ValidationFailed, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval validationMessages; - zval *model, model_sub, *validationMessages_param = NULL, messageStr, message; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&messageStr); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&validationMessages); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_ARRAY(validationMessages) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &validationMessages_param); - ZEPHIR_OBS_COPY_OR_DUP(&validationMessages, validationMessages_param); - if (zephir_fast_count_int(&validationMessages) > 0) { - zephir_memory_observe(&message); - zephir_array_fetch_long(&message, &validationMessages, 0, PH_NOISY, "phalcon/Mvc/Model/ValidationFailed.zep", 48); - ZEPHIR_CALL_METHOD(&messageStr, &message, "getmessage", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&messageStr); - ZVAL_STRING(&messageStr, "Validation failed"); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("model"), model); - zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), &validationMessages); - ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_validationfailed_ce, getThis(), "__construct", NULL, 0, &messageStr); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_ValidationFailed, getMessages) -{ - - RETURN_MEMBER(getThis(), "messages"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_ValidationFailed, getModel) -{ - - RETURN_MEMBER(getThis(), "model"); -} - -zend_object *zephir_init_properties_Phalcon_Mvc_Model_ValidationFailed(zend_class_entry *class_type) -{ - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("messages"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Behavior_SoftDelete) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Behavior, SoftDelete, phalcon, mvc_model_behavior_softdelete, phalcon_mvc_model_behavior_ce, phalcon_mvc_model_behavior_softdelete_method_entry, 0); - - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Behavior_SoftDelete, notify) -{ - zend_bool _9; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_6 = NULL, *_7 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *type_param = NULL, *model, model_sub, options, value, field, updateModel, message, modelsManager, metaData, _0, _1, _2, _8, _3$$7, *_4$$7, _5$$7, _10$$10, _11$$10; - zval type; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&updateModel); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&modelsManager); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_3$$7); - ZVAL_UNDEF(&_5$$7); - ZVAL_UNDEF(&_10$$10); - ZVAL_UNDEF(&_11$$10); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(type) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &type_param, &model); - if (UNEXPECTED(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(type_param) == IS_STRING)) { - zephir_get_strval(&type, type_param); - } else { - ZEPHIR_INIT_VAR(&type); - } - if (!ZEPHIR_IS_STRING_IDENTICAL(&type, "beforeDelete")) { - RETURN_MM_NULL(); - } - ZEPHIR_CALL_METHOD(&options, this_ptr, "getoptions", NULL, 0); - zephir_check_call_status(); - zephir_memory_observe(&value); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&value, &options, SL("value"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The option 'value' is required", "phalcon/Mvc/Model/Behavior/SoftDelete.zep", 42); - return; - } - zephir_memory_observe(&field); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&field, &options, SL("field"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The option 'field' is required", "phalcon/Mvc/Model/Behavior/SoftDelete.zep", 49); - return; - } - ZVAL_BOOL(&_0, 1); - ZEPHIR_CALL_METHOD(NULL, model, "skipoperation", NULL, 0, &_0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, model, "readattribute", NULL, 0, &field); - zephir_check_call_status(); - if (ZEPHIR_IS_IDENTICAL(&_1, &value)) { - RETURN_MM_NULL(); - } - ZEPHIR_CALL_METHOD(&modelsManager, model, "getmodelsmanager", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&updateModel); - if (zephir_clone(&updateModel, model) == FAILURE) { - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(NULL, &updateModel, "writeattribute", NULL, 0, &field, &value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_2, &updateModel, "save", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_2))) { - ZEPHIR_CALL_METHOD(&_3$$7, &updateModel, "getmessages", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&_3$$7, 0, "phalcon/Mvc/Model/Behavior/SoftDelete.zep", 84); - if (Z_TYPE_P(&_3$$7) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_3$$7), _4$$7) - { - ZEPHIR_INIT_NVAR(&message); - ZVAL_COPY(&message, _4$$7); - ZEPHIR_CALL_METHOD(NULL, model, "appendmessage", &_6, 0, &message); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_3$$7, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5$$7, &_3$$7, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5$$7)) { - break; - } - ZEPHIR_CALL_METHOD(&message, &_3$$7, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, model, "appendmessage", &_7, 0, &message); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_3$$7, "next", NULL, 0); - zephir_check_call_status(); +pp182: + ppch = *++PPCURSOR; + switch (ppch) { + case 'W': + case 'w': goto pp229; + default: goto pp59; } - } - ZEPHIR_INIT_NVAR(&message); - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", NULL, 0, &field, &value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_8, &modelsManager, "iskeepingsnapshots", NULL, 0, model); - zephir_check_call_status(); - _9 = zephir_is_true(&_8); - if (_9) { - _9 = ZEPHIR_GLOBAL(orm).update_snapshot_on_save; - } - if (_9) { - ZEPHIR_CALL_METHOD(&metaData, model, "getmodelsmetadata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_10$$10, &updateModel, "getsnapshotdata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, model, "setsnapshotdata", NULL, 0, &_10$$10); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_11$$10, &updateModel, "getoldsnapshotdata", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, model, "setoldsnapshotdata", NULL, 0, &_11$$10); - zephir_check_call_status(); - } - ZEPHIR_MM_RESTORE(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Behavior_Timestampable) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Behavior, Timestampable, phalcon, mvc_model_behavior_timestampable, phalcon_mvc_model_behavior_ce, phalcon_mvc_model_behavior_timestampable_method_entry, 0); - - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Behavior_Timestampable, notify) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *type_param = NULL, *model, model_sub, options, timestamp, singleField, field, _0, *_1$$6, _2$$6; - zval type; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(×tamp); - ZVAL_UNDEF(&singleField); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2$$6); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(type) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &type_param, &model); - if (UNEXPECTED(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(type_param) == IS_STRING)) { - zephir_get_strval(&type, type_param); - } else { - ZEPHIR_INIT_VAR(&type); - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "musttakeaction", NULL, 0, &type); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - RETURN_MM_NULL(); - } - ZEPHIR_CALL_METHOD(&options, this_ptr, "getoptions", NULL, 0, &type); - zephir_check_call_status(); - if (Z_TYPE_P(&options) != IS_ARRAY) { - RETURN_MM_NULL(); - } - zephir_memory_observe(&field); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&field, &options, SL("field"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The option 'field' is required", "phalcon/Mvc/Model/Behavior/Timestampable.zep", 50); - return; - } - ZEPHIR_CALL_METHOD(×tamp, this_ptr, "gettimestamp", NULL, 435, &options); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&field) == IS_ARRAY)) { - zephir_is_iterable(&field, 0, "phalcon/Mvc/Model/Behavior/Timestampable.zep", 63); - if (Z_TYPE_P(&field) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&field), _1$$6) - { - ZEPHIR_INIT_NVAR(&singleField); - ZVAL_COPY(&singleField, _1$$6); - ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", &_3, 0, &singleField, ×tamp); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &field, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2$$6, &field, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2$$6)) { - break; - } - ZEPHIR_CALL_METHOD(&singleField, &field, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", &_4, 0, &singleField, ×tamp); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &field, "next", NULL, 0); - zephir_check_call_status(); +pp183: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp230; + case 'T': + case 't': goto pp232; + default: goto pp59; } - } - ZEPHIR_INIT_NVAR(&singleField); - } else { - ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", NULL, 0, &field, ×tamp); - zephir_check_call_status(); - } - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Behavior_Timestampable, getTimestamp) -{ - zend_bool _0$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *options_param = NULL, format, generator; - zval options; - - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&format); - ZVAL_UNDEF(&generator); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &options_param); - zephir_get_arrval(&options, options_param); - zephir_memory_observe(&format); - if (zephir_array_isset_string_fetch(&format, &options, SL("format"), 0)) { - ZEPHIR_RETURN_CALL_FUNCTION("date", NULL, 436, &format); - zephir_check_call_status(); - RETURN_MM(); - } - zephir_memory_observe(&generator); - if (zephir_array_isset_string_fetch(&generator, &options, SL("generator"), 0)) { - _0$$4 = Z_TYPE_P(&generator) == IS_OBJECT; - if (_0$$4) { - _0$$4 = zephir_is_instance_of(&generator, SL("Closure")); - } - if (_0$$4) { - ZEPHIR_CALL_USER_FUNC(return_value, &generator); - zephir_check_call_status(); - RETURN_MM(); - } - } - zephir_time(return_value); - RETURN_MM(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Transaction_Exception) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Transaction, Exception, phalcon, mvc_model_transaction_exception, phalcon_mvc_model_exception_ce, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Transaction_Failed) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Transaction, Failed, phalcon, mvc_model_transaction_failed, phalcon_mvc_model_transaction_exception_ce, phalcon_mvc_model_transaction_failed_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_model_transaction_failed_ce, SL("record"), ZEND_ACC_PROTECTED); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Failed, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *message_param = NULL, *record = NULL, record_sub, __$null; - zval message; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&record_sub); - ZVAL_NULL(&__$null); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) - Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(record, phalcon_mvc_modelinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &record); - if (UNEXPECTED(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(message_param) == IS_STRING)) { - zephir_get_strval(&message, message_param); - } else { - ZEPHIR_INIT_VAR(&message); - } - if (!record) { - record = &record_sub; - record = &__$null; - } - zephir_update_property_zval(this_ptr, ZEND_STRL("record"), record); - ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_transaction_failed_ce, getThis(), "__construct", NULL, 0, &message); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Failed, getRecord) -{ - - RETURN_MEMBER(getThis(), "record"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Failed, getRecordMessages) -{ - zval record, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&record); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("record"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&record, &_0); - if (Z_TYPE_P(&record) != IS_NULL) { - ZEPHIR_RETURN_CALL_METHOD(&record, "getmessages", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getmessage", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Transaction_Manager) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model\\Transaction, Manager, phalcon, mvc_model_transaction_manager, phalcon_mvc_model_transaction_manager_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_model_transaction_manager_ce, SL("container"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_transaction_manager_ce, SL("initialized"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_model_transaction_manager_ce, SL("number"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_transaction_manager_ce, SL("rollbackPendent"), 1, ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_model_transaction_manager_ce, SL("service"), "db", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_transaction_manager_ce, SL("transactions"), ZEND_ACC_PROTECTED); - phalcon_mvc_model_transaction_manager_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Transaction_Manager; - - zend_class_implements(phalcon_mvc_model_transaction_manager_ce, 1, phalcon_mvc_model_transaction_managerinterface_ce); - zend_class_implements(phalcon_mvc_model_transaction_manager_ce, 1, phalcon_di_injectionawareinterface_ce); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *container = NULL, container_sub, __$null; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container_sub); - ZVAL_NULL(&__$null); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(container, phalcon_di_diinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &container); - if (!container) { - container = &container_sub; - ZEPHIR_CPY_WRT(container, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(container); - } - if (!(zephir_is_true(container))) { - ZEPHIR_CALL_CE_STATIC(container, phalcon_di_di_ce, "getdefault", NULL, 0); - zephir_check_call_status(); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); - if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_transaction_exception_ce, "A dependency injection container is required to access the services related to the ORM", "phalcon/Mvc/Model/Transaction/Manager.zep", 114); - return; - } - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, collectTransactions) -{ - zval transactions, _0, _1, *_2, _3, _4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&transactions); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("transactions"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&transactions, &_0); - ZEPHIR_INIT_VAR(&_1); - zephir_is_iterable(&transactions, 0, "phalcon/Mvc/Model/Transaction/Manager.zep", 131); - if (Z_TYPE_P(&transactions) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&transactions), _2) - { - ZEPHIR_INIT_NVAR(&_1); - ZVAL_COPY(&_1, _2); - RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("number"))); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &transactions, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &transactions, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3)) { - break; +pp184: + ppch = *++PPCURSOR; + switch (ppch) { + case 'V': + case 'v': goto pp234; + default: goto pp59; } - ZEPHIR_CALL_METHOD(&_1, &transactions, "current", NULL, 0); - zephir_check_call_status(); - RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("number"))); - ZEPHIR_CALL_METHOD(NULL, &transactions, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&_1); - ZEPHIR_INIT_VAR(&_4); - array_init(&_4); - zephir_update_property_zval(this_ptr, ZEND_STRL("transactions"), &_4); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, commit) -{ - zval transactions, transaction, connection, _0, *_1, _2, _3$$3, _4$$5; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&transactions); - ZVAL_UNDEF(&transaction); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$5); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("transactions"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&transactions, &_0); - zephir_is_iterable(&transactions, 0, "phalcon/Mvc/Model/Transaction/Manager.zep", 150); - if (Z_TYPE_P(&transactions) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&transactions), _1) - { - ZEPHIR_INIT_NVAR(&transaction); - ZVAL_COPY(&transaction, _1); - ZEPHIR_CALL_METHOD(&connection, &transaction, "getconnection", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_3$$3, &connection, "isundertransaction", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&_3$$3)) { - ZEPHIR_CALL_METHOD(NULL, &connection, "commit", NULL, 0); - zephir_check_call_status(); +pp185: + ppch = *++PPCURSOR; + switch (ppch) { + case 'S': + case 's': goto pp235; + default: goto pp59; } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &transactions, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &transactions, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; +pp186: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp236; + default: goto pp59; } - ZEPHIR_CALL_METHOD(&transaction, &transactions, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&connection, &transaction, "getconnection", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$5, &connection, "isundertransaction", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&_4$$5)) { - ZEPHIR_CALL_METHOD(NULL, &connection, "commit", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(NULL, &transactions, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&transaction); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, get) -{ - zval _2$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *autoBegin_param = NULL, __$true, __$false, _0, _4, _1$$3, _3$$4; - zend_bool autoBegin; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_2$$4); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(autoBegin) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &autoBegin_param); - if (!autoBegin_param) { - autoBegin = 1; - } else { - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_is_true(&_0))) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("rollbackPendent"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_1$$3)) { - ZEPHIR_INIT_VAR(&_2$$4); - zephir_create_array(&_2$$4, 2, 0); - zephir_array_fast_append(&_2$$4, this_ptr); - ZEPHIR_INIT_VAR(&_3$$4); - ZVAL_STRING(&_3$$4, "rollbackPendent"); - zephir_array_fast_append(&_2$$4, &_3$$4); - ZEPHIR_CALL_FUNCTION(NULL, "register_shutdown_function", NULL, 483, &_2$$4); - zephir_check_call_status(); - } - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("initialized"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("initialized"), &__$false); - } - } - if (autoBegin) { - ZVAL_BOOL(&_4, 1); - } else { - ZVAL_BOOL(&_4, 0); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getorcreatetransaction", NULL, 0, &_4); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, getDbService) -{ - - RETURN_MEMBER(getThis(), "service"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, getDI) -{ - - RETURN_MEMBER(getThis(), "container"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, getOrCreateTransaction) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *autoBegin_param = NULL, container, transaction, transactions, _0, _6, _7, _1$$4, *_2$$4, _3$$4, _4$$6, _5$$8; - zend_bool autoBegin; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&transaction); - ZVAL_UNDEF(&transactions); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$6); - ZVAL_UNDEF(&_5$$8); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(autoBegin) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &autoBegin_param); - if (!autoBegin_param) { - autoBegin = 1; - } else { - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_transaction_exception_ce, "A dependency injection container is required to access the services related to the ORM", "phalcon/Mvc/Model/Transaction/Manager.zep", 210); - return; - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("number"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_0)) { - zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("transactions"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&transactions, &_1$$4); - zephir_is_iterable(&transactions, 0, "phalcon/Mvc/Model/Transaction/Manager.zep", 223); - if (Z_TYPE_P(&transactions) == IS_ARRAY) { - ZEND_HASH_REVERSE_FOREACH_VAL(Z_ARRVAL_P(&transactions), _2$$4) - { - ZEPHIR_INIT_NVAR(&transaction); - ZVAL_COPY(&transaction, _2$$4); - if (Z_TYPE_P(&transaction) == IS_OBJECT) { - ZVAL_BOOL(&_4$$6, 0); - ZEPHIR_CALL_METHOD(NULL, &transaction, "setisnewtransaction", NULL, 0, &_4$$6); - zephir_check_call_status(); - RETURN_CCTOR(&transaction); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &transactions, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$4, &transactions, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$4)) { - break; - } - ZEPHIR_CALL_METHOD(&transaction, &transactions, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&transaction) == IS_OBJECT) { - ZVAL_BOOL(&_5$$8, 0); - ZEPHIR_CALL_METHOD(NULL, &transaction, "setisnewtransaction", NULL, 0, &_5$$8); - zephir_check_call_status(); - RETURN_CCTOR(&transaction); - } - ZEPHIR_CALL_METHOD(NULL, &transactions, "next", NULL, 0); - zephir_check_call_status(); +pp187: + ppch = *++PPCURSOR; + switch (ppch) { + case 'C': + case 'c': goto pp237; + default: goto pp59; + } +pp188: + ppch = *++PPCURSOR; + switch (ppch) { + case 'T': + case 't': goto pp239; + default: goto pp59; + } +pp189: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp240; + default: goto pp59; + } +pp190: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp191; } +pp191: + { + token->opcode = PHQL_T_END; + return 0; } - ZEPHIR_INIT_NVAR(&transaction); - } - ZEPHIR_INIT_NVAR(&transaction); - object_init_ex(&transaction, phalcon_mvc_model_transaction_ce); - zephir_read_property(&_6, this_ptr, ZEND_STRL("service"), PH_NOISY_CC | PH_READONLY); - if (autoBegin) { - ZVAL_BOOL(&_7, 1); - } else { - ZVAL_BOOL(&_7, 0); - } - ZEPHIR_CALL_METHOD(NULL, &transaction, "__construct", NULL, 484, &container, &_7, &_6); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &transaction, "settransactionmanager", NULL, 485, this_ptr); - zephir_check_call_status(); - zephir_update_property_array_append(this_ptr, SL("transactions"), &transaction); - RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("number"))); - RETURN_CCTOR(&transaction); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, getRollbackPendent) -{ - - RETURN_MEMBER(getThis(), "rollbackPendent"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, has) -{ - zval _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("number"), PH_NOISY_CC | PH_READONLY); - RETURN_BOOL(ZEPHIR_GT_LONG(&_0, 0)); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, notifyCommit) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *transaction, transaction_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&transaction_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(transaction, phalcon_mvc_model_transactioninterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &transaction); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "collecttransaction", NULL, 0, transaction); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, notifyRollback) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *transaction, transaction_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&transaction_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(transaction, phalcon_mvc_model_transactioninterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &transaction); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "collecttransaction", NULL, 0, transaction); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, rollback) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collect_param = NULL, transactions, transaction, connection, _0, *_1, _2, _3$$3, _5$$6; - zend_bool collect; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&transactions); - ZVAL_UNDEF(&transaction); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_5$$6); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(collect) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &collect_param); - if (!collect_param) { - collect = 1; - } else { - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("transactions"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&transactions, &_0); - zephir_is_iterable(&transactions, 0, "phalcon/Mvc/Model/Transaction/Manager.zep", 294); - if (Z_TYPE_P(&transactions) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&transactions), _1) - { - ZEPHIR_INIT_NVAR(&transaction); - ZVAL_COPY(&transaction, _1); - ZEPHIR_CALL_METHOD(&connection, &transaction, "getconnection", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_3$$3, &connection, "isundertransaction", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&_3$$3)) { - ZEPHIR_CALL_METHOD(NULL, &connection, "rollback", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &connection, "close", NULL, 0); - zephir_check_call_status(); +pp192: + ppch = *++PPCURSOR; + switch (ppch) { + case 'S': + case 's': goto pp242; + default: goto pp59; } - if (collect) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "collecttransaction", &_4, 0, &transaction); - zephir_check_call_status(); +pp193: + ppch = *++PPCURSOR; + switch (ppch) { + case 'S': + case 's': goto pp243; + default: goto pp59; } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &transactions, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &transactions, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; +pp194: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp195; } - ZEPHIR_CALL_METHOD(&transaction, &transactions, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&connection, &transaction, "getconnection", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_5$$6, &connection, "isundertransaction", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&_5$$6)) { - ZEPHIR_CALL_METHOD(NULL, &connection, "rollback", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &connection, "close", NULL, 0); - zephir_check_call_status(); - } - if (collect) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "collecttransaction", &_4, 0, &transaction); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(NULL, &transactions, "next", NULL, 0); - zephir_check_call_status(); +pp195: + { + token->opcode = PHQL_T_FOR; + return 0; } - } - ZEPHIR_INIT_NVAR(&transaction); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, rollbackPendent) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(NULL, this_ptr, "rollback", NULL, 0); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, setDbService) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *service_param = NULL; - zval service; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&service); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(service) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &service_param); - if (UNEXPECTED(Z_TYPE_P(service_param) != IS_STRING && Z_TYPE_P(service_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'service' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(service_param) == IS_STRING)) { - zephir_get_strval(&service, service_param); - } else { - ZEPHIR_INIT_VAR(&service); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("service"), &service); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, setDI) -{ - zval *container, container_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &container); - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, setRollbackPendent) -{ - zval *rollbackPendent_param = NULL, __$true, __$false; - zend_bool rollbackPendent; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(rollbackPendent) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &rollbackPendent_param); - if (rollbackPendent) { - zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackPendent"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackPendent"), &__$false); - } - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, collectTransaction) -{ - zval newTransactions; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *transaction, transaction_sub, managedTransaction, _0, *_1, _2; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&transaction_sub); - ZVAL_UNDEF(&managedTransaction); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&newTransactions); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(transaction, phalcon_mvc_model_transactioninterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &transaction); - ZEPHIR_INIT_VAR(&newTransactions); - array_init(&newTransactions); - zephir_read_property(&_0, this_ptr, ZEND_STRL("transactions"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_0, 0, "phalcon/Mvc/Model/Transaction/Manager.zep", 359); - if (Z_TYPE_P(&_0) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) - { - ZEPHIR_INIT_NVAR(&managedTransaction); - ZVAL_COPY(&managedTransaction, _1); - if (!ZEPHIR_IS_EQUAL(&managedTransaction, transaction)) { - zephir_array_append(&newTransactions, transaction, PH_SEPARATE, "phalcon/Mvc/Model/Transaction/Manager.zep", 353); - } else { - RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("number"))); +pp196: + ppch = *++PPCURSOR; + switch (ppch) { + case 'M': + case 'm': goto pp244; + default: goto pp59; } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; +pp197: + ppch = *++PPCURSOR; + switch (ppch) { + case 'L': + case 'l': goto pp246; + default: goto pp59; } - ZEPHIR_CALL_METHOD(&managedTransaction, &_0, "current", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_EQUAL(&managedTransaction, transaction)) { - zephir_array_append(&newTransactions, transaction, PH_SEPARATE, "phalcon/Mvc/Model/Transaction/Manager.zep", 353); - } else { - RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("number"))); - } - ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&managedTransaction); - zephir_update_property_zval(this_ptr, ZEND_STRL("transactions"), &newTransactions); - ZEPHIR_MM_RESTORE(); -} - -zend_object *zephir_init_properties_Phalcon_Mvc_Model_Transaction_Manager(zend_class_entry *class_type) -{ - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("transactions"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("transactions"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Transaction_ManagerInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model\\Transaction, ManagerInterface, phalcon, mvc_model_transaction_managerinterface, phalcon_mvc_model_transaction_managerinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, collectTransactions); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, commit); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, get); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, getDbService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, getRollbackPendent); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, has); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, notifyCommit); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, notifyRollback); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, rollback); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, rollbackPendent); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, setDbService); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, setRollbackPendent); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Resultset_Complex) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Resultset, Complex, phalcon, mvc_model_resultset_complex, phalcon_mvc_model_resultset_ce, phalcon_mvc_model_resultset_complex_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_model_resultset_complex_ce, SL("columnTypes"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_resultset_complex_ce, SL("disableHydration"), 0, ZEND_ACC_PROTECTED); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *columnTypes, columnTypes_sub, *result = NULL, result_sub, *cache = NULL, cache_sub, __$null; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&columnTypes_sub); - ZVAL_UNDEF(&result_sub); - ZVAL_UNDEF(&cache_sub); - ZVAL_NULL(&__$null); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ZVAL(columnTypes) - Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(result, phalcon_db_resultinterface_ce) - Z_PARAM_ZVAL_OR_NULL(cache) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &columnTypes, &result, &cache); - if (!result) { - result = &result_sub; - result = &__$null; - } - if (!cache) { - cache = &cache_sub; - cache = &__$null; - } - zephir_update_property_zval(this_ptr, ZEND_STRL("columnTypes"), columnTypes); - ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_resultset_complex_ce, getThis(), "__construct", NULL, 0, result, cache); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, current) -{ - zend_class_entry *_14$$16, *_29$$36; - zend_string *_5; - zend_ulong _4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_15 = NULL, *_18 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, dirtyState = 0; - zval __$true, __$false, row, hydrateMode, eager, alias, activeRow, type, column, columnValue, value, attribute, source, attributes, columnMap, rowModel, keepSnapshots, sqlAlias, modelName, _0, _1, *_2, _3, *_6$$11, _7$$11, _8$$12, _9$$13, _10$$16, _12$$16, _13$$16, _11$$17, _16$$19, _17$$19, _19$$25, _20$$25, *_21$$31, _22$$31, _23$$32, _24$$33, _25$$36, _27$$36, _28$$36, _26$$37, _30$$39, _31$$39, _32$$45, _33$$45; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&row); - ZVAL_UNDEF(&hydrateMode); - ZVAL_UNDEF(&eager); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&activeRow); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&columnValue); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&attribute); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&rowModel); - ZVAL_UNDEF(&keepSnapshots); - ZVAL_UNDEF(&sqlAlias); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_7$$11); - ZVAL_UNDEF(&_8$$12); - ZVAL_UNDEF(&_9$$13); - ZVAL_UNDEF(&_10$$16); - ZVAL_UNDEF(&_12$$16); - ZVAL_UNDEF(&_13$$16); - ZVAL_UNDEF(&_11$$17); - ZVAL_UNDEF(&_16$$19); - ZVAL_UNDEF(&_17$$19); - ZVAL_UNDEF(&_19$$25); - ZVAL_UNDEF(&_20$$25); - ZVAL_UNDEF(&_22$$31); - ZVAL_UNDEF(&_23$$32); - ZVAL_UNDEF(&_24$$33); - ZVAL_UNDEF(&_25$$36); - ZVAL_UNDEF(&_27$$36); - ZVAL_UNDEF(&_28$$36); - ZVAL_UNDEF(&_26$$37); - ZVAL_UNDEF(&_30$$39); - ZVAL_UNDEF(&_31$$39); - ZVAL_UNDEF(&_32$$45); - ZVAL_UNDEF(&_33$$45); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("activeRow"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&activeRow, &_0); - if (Z_TYPE_P(&activeRow) != IS_NULL) { - RETURN_CCTOR(&activeRow); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("row"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&row, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("disableHydration"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &row); - RETURN_CCTOR(&row); - } - if (Z_TYPE_P(&row) != IS_ARRAY) { - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &__$false); - } - RETURN_MM_BOOL(0); - } - zephir_read_property(&_1, this_ptr, ZEND_STRL("hydrateMode"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&hydrateMode, &_1); - do { - if (ZEPHIR_IS_LONG(&hydrateMode, 0)) { - ZEPHIR_INIT_NVAR(&activeRow); - object_init_ex(&activeRow, phalcon_mvc_model_row_ce); - if (zephir_has_constructor(&activeRow)) { - ZEPHIR_CALL_METHOD(NULL, &activeRow, "__construct", NULL, 0); - zephir_check_call_status(); +pp198: + ppch = *++PPCURSOR; + switch (ppch) { + case 'U': + case 'u': goto pp248; + default: goto pp59; } - - break; +pp199: + ppch = *++PPCURSOR; + switch (ppch) { + case 'I': + case 'i': goto pp249; + default: goto pp59; + } +pp200: + ppch = *++PPCURSOR; + switch (ppch) { + case 'K': + case 'k': goto pp250; + default: goto pp59; + } +pp201: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp251; + default: goto pp59; + } +pp202: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp252; + default: goto pp59; + } +pp203: + ppch = *++PPCURSOR; + switch (ppch) { + case 'O': + case 'o': goto pp253; + default: goto pp59; + } +pp204: + ppch = *++PPCURSOR; + switch (ppch) { + case 'N': + case 'n': goto pp255; + default: goto pp59; + } +pp205: + ppch = *++PPCURSOR; + switch (ppch) { + case 'T': + case 't': goto pp257; + default: goto pp59; + } +pp206: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp259; + default: goto pp59; + } +pp207: + ppch = *++PPCURSOR; + switch (ppch) { + case 'I': + case 'i': goto pp261; + default: goto pp59; + } +pp208: + ppaccept = 2; + ppch = *(PPMARKER = ++PPCURSOR); + switch (ppch) { + case ' ': goto pp262; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp209; + } +pp209: + { + token->opcode = PHQL_T_NOT; + return 0; } - if (ZEPHIR_IS_LONG(&hydrateMode, 1)) { - ZEPHIR_INIT_NVAR(&activeRow); - array_init(&activeRow); - break; +pp210: + ppch = *++PPCURSOR; + switch (ppch) { + case 'L': + case 'l': goto pp263; + default: goto pp59; + } +pp211: + ppch = *++PPCURSOR; + switch (ppch) { + case 'S': + case 's': goto pp265; + default: goto pp59; + } +pp212: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp266; + default: goto pp59; + } +pp213: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp267; + default: goto pp59; + } +pp214: + ppch = *++PPCURSOR; + switch (ppch) { + case 'H': + case 'h': goto pp268; + default: goto pp59; + } +pp215: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp269; + default: goto pp59; + } +pp216: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp217; + } +pp217: + { + token->opcode = PHQL_T_SET; + return 0; } - ZEPHIR_INIT_NVAR(&activeRow); - object_init(&activeRow); - break; - } while(0); - - dirtyState = 0; - zephir_read_property(&_1, this_ptr, ZEND_STRL("columnTypes"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_1, 0, "phalcon/Mvc/Model/Resultset/Complex.zep", 262); - if (Z_TYPE_P(&_1) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_1), _4, _5, _2) - { - ZEPHIR_INIT_NVAR(&alias); - if (_5 != NULL) { - ZVAL_STR_COPY(&alias, _5); - } else { - ZVAL_LONG(&alias, _4); +pp218: + ppch = *++PPCURSOR; + switch (ppch) { + case 'N': + case 'n': goto pp270; + default: goto pp59; } - ZEPHIR_INIT_NVAR(&column); - ZVAL_COPY(&column, _2); - if (UNEXPECTED(Z_TYPE_P(&column) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Column type is corrupt", "phalcon/Mvc/Model/Resultset/Complex.zep", 141); - return; +pp219: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp272; + default: goto pp59; } - ZEPHIR_OBS_NVAR(&type); - zephir_array_fetch_string(&type, &column, SL("type"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 144); - if (ZEPHIR_IS_STRING(&type, "object")) { - ZEPHIR_OBS_NVAR(&source); - zephir_array_fetch_string(&source, &column, SL("column"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 150); - ZEPHIR_OBS_NVAR(&attributes); - zephir_array_fetch_string(&attributes, &column, SL("attributes"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 151); - ZEPHIR_OBS_NVAR(&columnMap); - zephir_array_fetch_string(&columnMap, &column, SL("columnMap"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 152); - ZEPHIR_INIT_NVAR(&rowModel); - array_init(&rowModel); - zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model/Resultset/Complex.zep", 170); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _6$$11) - { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _6$$11); - ZEPHIR_OBS_NVAR(&columnValue); - ZEPHIR_INIT_NVAR(&_8$$12); - ZEPHIR_CONCAT_SVSV(&_8$$12, "_", &source, "_", &attribute); - zephir_array_fetch(&columnValue, &row, &_8$$12, PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 163); - zephir_array_update_zval(&rowModel, &attribute, &columnValue, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_7$$11, &attributes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_7$$11)) { - break; - } - ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&columnValue); - ZEPHIR_INIT_NVAR(&_9$$13); - ZEPHIR_CONCAT_SVSV(&_9$$13, "_", &source, "_", &attribute); - zephir_array_fetch(&columnValue, &row, &_9$$13, PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 163); - zephir_array_update_zval(&rowModel, &attribute, &columnValue, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&attribute); - do { - if (ZEPHIR_IS_LONG(&hydrateMode, 0)) { - ZEPHIR_OBS_NVAR(&keepSnapshots); - if (!(zephir_array_isset_string_fetch(&keepSnapshots, &column, SL("keepSnapshots"), 0))) { - ZEPHIR_INIT_NVAR(&keepSnapshots); - ZVAL_BOOL(&keepSnapshots, 0); - } - if (ZEPHIR_GLOBAL(orm).late_state_binding) { - ZEPHIR_OBS_NVAR(&_10$$16); - zephir_array_fetch_string(&_10$$16, &column, SL("instance"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 178); - if (zephir_instance_of_ev(&_10$$16, phalcon_mvc_model_ce)) { - zephir_array_fetch_string(&_11$$17, &column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 179); - ZEPHIR_INIT_NVAR(&modelName); - zephir_get_class(&modelName, &_11$$17, 0); - } else { - ZEPHIR_INIT_NVAR(&modelName); - ZVAL_STRING(&modelName, "Phalcon\\Mvc\\Model"); - } - zephir_array_fetch_string(&_12$$16, &column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 185); - ZVAL_LONG(&_13$$16, dirtyState); - _14$$16 = zephir_fetch_class(&modelName); - ZEPHIR_CALL_CE_STATIC(&value, _14$$16, "cloneresultmap", NULL, 0, &_12$$16, &rowModel, &columnMap, &_13$$16, &keepSnapshots); - zephir_check_call_status(); - } else { - zephir_array_fetch_string(&_16$$19, &column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 197); - ZVAL_LONG(&_17$$19, dirtyState); - ZEPHIR_CALL_CE_STATIC(&value, phalcon_mvc_model_ce, "cloneresultmap", &_15, 0, &_16$$19, &rowModel, &columnMap, &_17$$19, &keepSnapshots); - zephir_check_call_status(); - } - break; - } - ZEPHIR_CALL_CE_STATIC(&value, phalcon_mvc_model_ce, "cloneresultmaphydrate", &_18, 0, &rowModel, &columnMap, &hydrateMode); - zephir_check_call_status(); - break; - } while(0); - - ZEPHIR_OBS_NVAR(&attribute); - zephir_array_fetch_string(&attribute, &column, SL("balias"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 221); - } else { - ZEPHIR_OBS_NVAR(&sqlAlias); - if (zephir_array_isset_string_fetch(&sqlAlias, &column, SL("sqlAlias"), 0)) { - ZEPHIR_OBS_NVAR(&value); - zephir_array_fetch(&value, &row, &sqlAlias, PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 227); - } else { - ZEPHIR_OBS_NVAR(&value); - zephir_array_isset_fetch(&value, &row, &alias, 0); - } - if (zephir_array_isset_string(&column, SL("balias"))) { - ZEPHIR_CPY_WRT(&attribute, &alias); - } else { - ZEPHIR_INIT_NVAR(&_19$$25); - ZVAL_STRING(&_19$$25, "_"); - ZEPHIR_INIT_NVAR(&_20$$25); - ZVAL_STRING(&_20$$25, ""); - ZEPHIR_INIT_NVAR(&attribute); - zephir_fast_str_replace(&attribute, &_19$$25, &_20$$25, &alias); - } +pp220: + ppch = *++PPCURSOR; + switch (ppch) { + case 'A': + case 'a': goto pp274; + default: goto pp59; } - if (!(zephir_array_isset_string_fetch(&eager, &column, SL("eager"), 1))) { - do { - if (ZEPHIR_IS_LONG(&hydrateMode, 1)) { - zephir_array_update_zval(&activeRow, &attribute, &value, PH_COPY | PH_SEPARATE); - break; - } - zephir_update_property_zval_zval(&activeRow, &attribute, &value); - break; - } while(0); - +pp221: + ppch = *++PPCURSOR; + switch (ppch) { + case 'N': + case 'n': goto pp275; + default: goto pp59; } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_1, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &_1, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3)) { - break; +pp222: + ppch = *++PPCURSOR; + switch (ppch) { + case 'U': + case 'u': goto pp276; + default: goto pp59; } - ZEPHIR_CALL_METHOD(&alias, &_1, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&column, &_1, "current", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&column) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Column type is corrupt", "phalcon/Mvc/Model/Resultset/Complex.zep", 141); - return; - } - ZEPHIR_OBS_NVAR(&type); - zephir_array_fetch_string(&type, &column, SL("type"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 144); - if (ZEPHIR_IS_STRING(&type, "object")) { - ZEPHIR_OBS_NVAR(&source); - zephir_array_fetch_string(&source, &column, SL("column"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 150); - ZEPHIR_OBS_NVAR(&attributes); - zephir_array_fetch_string(&attributes, &column, SL("attributes"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 151); - ZEPHIR_OBS_NVAR(&columnMap); - zephir_array_fetch_string(&columnMap, &column, SL("columnMap"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 152); - ZEPHIR_INIT_NVAR(&rowModel); - array_init(&rowModel); - zephir_is_iterable(&attributes, 0, "phalcon/Mvc/Model/Resultset/Complex.zep", 170); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attributes), _21$$31) - { - ZEPHIR_INIT_NVAR(&attribute); - ZVAL_COPY(&attribute, _21$$31); - ZEPHIR_OBS_NVAR(&columnValue); - ZEPHIR_INIT_NVAR(&_23$$32); - ZEPHIR_CONCAT_SVSV(&_23$$32, "_", &source, "_", &attribute); - zephir_array_fetch(&columnValue, &row, &_23$$32, PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 163); - zephir_array_update_zval(&rowModel, &attribute, &columnValue, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_22$$31, &attributes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_22$$31)) { - break; - } - ZEPHIR_CALL_METHOD(&attribute, &attributes, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&columnValue); - ZEPHIR_INIT_NVAR(&_24$$33); - ZEPHIR_CONCAT_SVSV(&_24$$33, "_", &source, "_", &attribute); - zephir_array_fetch(&columnValue, &row, &_24$$33, PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 163); - zephir_array_update_zval(&rowModel, &attribute, &columnValue, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&attribute); - do { - if (ZEPHIR_IS_LONG(&hydrateMode, 0)) { - ZEPHIR_OBS_NVAR(&keepSnapshots); - if (!(zephir_array_isset_string_fetch(&keepSnapshots, &column, SL("keepSnapshots"), 0))) { - ZEPHIR_INIT_NVAR(&keepSnapshots); - ZVAL_BOOL(&keepSnapshots, 0); - } - if (ZEPHIR_GLOBAL(orm).late_state_binding) { - ZEPHIR_OBS_NVAR(&_25$$36); - zephir_array_fetch_string(&_25$$36, &column, SL("instance"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 178); - if (zephir_instance_of_ev(&_25$$36, phalcon_mvc_model_ce)) { - zephir_array_fetch_string(&_26$$37, &column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 179); - ZEPHIR_INIT_NVAR(&modelName); - zephir_get_class(&modelName, &_26$$37, 0); - } else { - ZEPHIR_INIT_NVAR(&modelName); - ZVAL_STRING(&modelName, "Phalcon\\Mvc\\Model"); - } - zephir_array_fetch_string(&_27$$36, &column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 185); - ZVAL_LONG(&_28$$36, dirtyState); - _29$$36 = zephir_fetch_class(&modelName); - ZEPHIR_CALL_CE_STATIC(&value, _29$$36, "cloneresultmap", NULL, 0, &_27$$36, &rowModel, &columnMap, &_28$$36, &keepSnapshots); - zephir_check_call_status(); - } else { - zephir_array_fetch_string(&_30$$39, &column, SL("instance"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 197); - ZVAL_LONG(&_31$$39, dirtyState); - ZEPHIR_CALL_CE_STATIC(&value, phalcon_mvc_model_ce, "cloneresultmap", &_15, 0, &_30$$39, &rowModel, &columnMap, &_31$$39, &keepSnapshots); - zephir_check_call_status(); - } - break; - } - ZEPHIR_CALL_CE_STATIC(&value, phalcon_mvc_model_ce, "cloneresultmaphydrate", &_18, 0, &rowModel, &columnMap, &hydrateMode); - zephir_check_call_status(); - break; - } while(0); - - ZEPHIR_OBS_NVAR(&attribute); - zephir_array_fetch_string(&attribute, &column, SL("balias"), PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 221); - } else { - ZEPHIR_OBS_NVAR(&sqlAlias); - if (zephir_array_isset_string_fetch(&sqlAlias, &column, SL("sqlAlias"), 0)) { - ZEPHIR_OBS_NVAR(&value); - zephir_array_fetch(&value, &row, &sqlAlias, PH_NOISY, "phalcon/Mvc/Model/Resultset/Complex.zep", 227); - } else { - ZEPHIR_OBS_NVAR(&value); - zephir_array_isset_fetch(&value, &row, &alias, 0); - } - if (zephir_array_isset_string(&column, SL("balias"))) { - ZEPHIR_CPY_WRT(&attribute, &alias); - } else { - ZEPHIR_INIT_NVAR(&_32$$45); - ZVAL_STRING(&_32$$45, "_"); - ZEPHIR_INIT_NVAR(&_33$$45); - ZVAL_STRING(&_33$$45, ""); - ZEPHIR_INIT_NVAR(&attribute); - zephir_fast_str_replace(&attribute, &_32$$45, &_33$$45, &alias); - } - } - ZEPHIR_OBS_NVAR(&eager); - if (!(zephir_array_isset_string_fetch(&eager, &column, SL("eager"), 0))) { - do { - if (ZEPHIR_IS_LONG(&hydrateMode, 1)) { - zephir_array_update_zval(&activeRow, &attribute, &value, PH_COPY | PH_SEPARATE); - break; - } - zephir_update_property_zval_zval(&activeRow, &attribute, &value); - break; - } while(0); - - } - ZEPHIR_CALL_METHOD(NULL, &_1, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&column); - ZEPHIR_INIT_NVAR(&alias); - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &activeRow); - RETURN_CCTOR(&activeRow); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, toArray) -{ - zval records; - zval current, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_1 = NULL, *_2 = NULL, *_3 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(¤t); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&records); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&records); - array_init(&records); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "rewind", NULL, 92); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_0, this_ptr, "valid", &_1, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_0))) { - break; - } - ZEPHIR_CALL_METHOD(¤t, this_ptr, "current", &_2, 480); - zephir_check_call_status(); - zephir_array_append(&records, ¤t, PH_SEPARATE, "phalcon/Mvc/Model/Resultset/Complex.zep", 282); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "next", &_3, 0); - zephir_check_call_status(); - } - RETURN_CTOR(&records); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, serialize) -{ - zval data; - zval container, serializer, _0, _1, _2, _3$$4, _4$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&serializer); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&data); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The dependency injector container is not valid", "phalcon/Mvc/Model/Resultset/Complex.zep", 303); - return; - } - ZEPHIR_INIT_VAR(&data); - zephir_create_array(&data, 4, 0); - zephir_memory_observe(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC); - zephir_array_update_string(&data, SL("cache"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "toarray", NULL, 0); - zephir_check_call_status(); - zephir_array_update_string(&data, SL("rows"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("columnTypes"), PH_NOISY_CC); - zephir_array_update_string(&data, SL("columnTypes"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("hydrateMode"), PH_NOISY_CC); - zephir_array_update_string(&data, SL("hydrateMode"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "serializer"); - ZEPHIR_CALL_METHOD(&_1, &container, "has", NULL, 0, &_2); - zephir_check_call_status(); - if (zephir_is_true(&_1)) { - ZEPHIR_INIT_VAR(&_4$$4); - ZVAL_STRING(&_4$$4, "serializer"); - ZEPHIR_CALL_METHOD(&_3$$4, &container, "getshared", NULL, 0, &_4$$4); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&serializer, &_3$$4); - ZEPHIR_CALL_METHOD(NULL, &serializer, "setdata", NULL, 0, &data); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&serializer, "serialize", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_RETURN_CALL_FUNCTION("serialize", NULL, 15, &data); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, unserialize) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *data, data_sub, __$true, __$false, resultset, container, serializer, _0, _1, _4, _5, _6, _7, _8, _9, _2$$4, _3$$4; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&data_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&resultset); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&serializer); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(data) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &data); - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("disableHydration"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("disableHydration"), &__$false); - } - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The dependency injector container is not valid", "phalcon/Mvc/Model/Resultset/Complex.zep", 339); - return; - } - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "serializer"); - ZEPHIR_CALL_METHOD(&_0, &container, "has", NULL, 0, &_1); - zephir_check_call_status(); - if (zephir_is_true(&_0)) { - ZEPHIR_INIT_VAR(&_3$$4); - ZVAL_STRING(&_3$$4, "serializer"); - ZEPHIR_CALL_METHOD(&_2$$4, &container, "getshared", NULL, 0, &_3$$4); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&serializer, &_2$$4); - ZEPHIR_CALL_METHOD(NULL, &serializer, "unserialize", NULL, 0, data); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&resultset, &serializer, "getdata", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_FUNCTION(&resultset, "unserialize", NULL, 16, data); - zephir_check_call_status(); - } - if (UNEXPECTED(Z_TYPE_P(&resultset) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid serialization data", "phalcon/Mvc/Model/Resultset/Complex.zep", 352); - return; - } - zephir_array_fetch_string(&_4, &resultset, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 355); - zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_4); - zephir_array_fetch_string(&_5, &resultset, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 356); - ZVAL_UNDEF(&_6); - ZVAL_LONG(&_6, zephir_fast_count_int(&_5)); - zephir_update_property_zval(this_ptr, ZEND_STRL("count"), &_6); - zephir_array_fetch_string(&_7, &resultset, SL("cache"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 357); - zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), &_7); - zephir_array_fetch_string(&_8, &resultset, SL("columnTypes"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 358); - zephir_update_property_zval(this_ptr, ZEND_STRL("columnTypes"), &_8); - zephir_array_fetch_string(&_9, &resultset, SL("hydrateMode"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 359); - zephir_update_property_zval(this_ptr, ZEND_STRL("hydrateMode"), &_9); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, __serialize) -{ - zval records, cache, columnTypes, hydrateMode, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&records); - ZVAL_UNDEF(&cache); - ZVAL_UNDEF(&columnTypes); - ZVAL_UNDEF(&hydrateMode); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&records, this_ptr, "toarray", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&cache, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("columnTypes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&columnTypes, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("hydrateMode"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&hydrateMode, &_0); - zephir_create_array(return_value, 4, 0); - zephir_array_update_string(return_value, SL("cache"), &cache, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("rows"), &records, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("columnTypes"), &columnTypes, PH_COPY | PH_SEPARATE); - zephir_array_update_string(return_value, SL("hydrateMode"), &hydrateMode, PH_COPY | PH_SEPARATE); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Complex, __unserialize) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *data_param = NULL, __$true, __$false, _0, _1, _2, _3, _4, _5; - zval data; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&data); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(data) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &data_param); - zephir_get_arrval(&data, data_param); - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("disableHydration"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("disableHydration"), &__$false); - } - zephir_array_fetch_string(&_0, &data, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 390); - zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_0); - zephir_array_fetch_string(&_1, &data, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 391); - ZVAL_UNDEF(&_2); - ZVAL_LONG(&_2, zephir_fast_count_int(&_1)); - zephir_update_property_zval(this_ptr, ZEND_STRL("count"), &_2); - zephir_array_fetch_string(&_3, &data, SL("cache"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 392); - zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), &_3); - zephir_array_fetch_string(&_4, &data, SL("columnTypes"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 393); - zephir_update_property_zval(this_ptr, ZEND_STRL("columnTypes"), &_4); - zephir_array_fetch_string(&_5, &data, SL("hydrateMode"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Complex.zep", 394); - zephir_update_property_zval(this_ptr, ZEND_STRL("hydrateMode"), &_5); - ZEPHIR_MM_RESTORE(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Resultset_Simple) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Resultset, Simple, phalcon, mvc_model_resultset_simple, phalcon_mvc_model_resultset_ce, phalcon_mvc_model_resultset_simple_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_model_resultset_simple_ce, SL("columnMap"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_resultset_simple_ce, SL("model"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_resultset_simple_ce, SL("keepSnapshots"), 0, ZEND_ACC_PROTECTED); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool keepSnapshots; - zval *columnMap, columnMap_sub, *model, model_sub, *result, result_sub, *cache = NULL, cache_sub, *keepSnapshots_param = NULL, __$true, __$false, __$null; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&columnMap_sub); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&result_sub); - ZVAL_UNDEF(&cache_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_NULL(&__$null); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 5) - Z_PARAM_ZVAL(columnMap) - Z_PARAM_ZVAL(model) - Z_PARAM_ZVAL(result) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(cache) - Z_PARAM_BOOL(keepSnapshots) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 2, &columnMap, &model, &result, &cache, &keepSnapshots_param); - if (!cache) { - cache = &cache_sub; - cache = &__$null; - } - if (!keepSnapshots_param) { - keepSnapshots = 0; - } else { - } - zephir_update_property_zval(this_ptr, ZEND_STRL("model"), model); - zephir_update_property_zval(this_ptr, ZEND_STRL("columnMap"), columnMap); - if (keepSnapshots) { - zephir_update_property_zval(this_ptr, ZEND_STRL("keepSnapshots"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("keepSnapshots"), &__$false); - } - ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_resultset_simple_ce, getThis(), "__construct", NULL, 0, result, cache); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, current) -{ - zend_class_entry *_6$$6; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval __$true, __$false, row, hydrateMode, columnMap, activeRow, modelName, _0, _1$$6, _3$$6, _4$$6, _5$$6, _2$$7, _7$$9, _8$$9, _9$$9; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&row); - ZVAL_UNDEF(&hydrateMode); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&activeRow); - ZVAL_UNDEF(&modelName); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$6); - ZVAL_UNDEF(&_3$$6); - ZVAL_UNDEF(&_4$$6); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_2$$7); - ZVAL_UNDEF(&_7$$9); - ZVAL_UNDEF(&_8$$9); - ZVAL_UNDEF(&_9$$9); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("activeRow"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&activeRow, &_0); - if (Z_TYPE_P(&activeRow) != IS_NULL) { - RETURN_CCTOR(&activeRow); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("row"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&row, &_0); - if (Z_TYPE_P(&row) != IS_ARRAY) { - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &__$false); +pp223: + ppch = *++PPCURSOR; + switch (ppch) { + case 'N': + case 'n': goto pp277; + case 'R': + case 'r': goto pp279; + default: goto pp59; + } +pp224: + ppch = *++PPCURSOR; + switch (ppch) { + case 'H': + case 'h': goto pp280; + default: goto pp59; + } +pp225: + ppaccept = 3; + ppch = *(PPMARKER = ++PPCURSOR); + switch (ppch) { + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + case 0x08: + case '\t': + case '\n': + case '\v': + case '\f': + case '\r': + case 0x0E: + case 0x0F: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + case 0x18: + case 0x19: + case 0x1A: + case 0x1B: + case 0x1C: + case 0x1D: + case 0x1E: + case 0x1F: + case '[': + case 0x7F: goto pp168; + case '\\': goto pp165; + case ']': goto pp167; + default: goto pp163; + } +pp226: + ++PPCURSOR; + { + token->opcode = PHQL_T_BPLACEHOLDER; + token->value = estrndup(q, PPCURSOR - q - 1); + token->len = PPCURSOR - q - 1; + q = PPCURSOR; + return 0; } - RETURN_MM_NULL(); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("hydrateMode"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&hydrateMode, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&columnMap, &_0); - do { - if (ZEPHIR_IS_LONG(&hydrateMode, 0)) { - if (ZEPHIR_GLOBAL(orm).late_state_binding) { - zephir_memory_observe(&_1$$6); - zephir_read_property(&_1$$6, this_ptr, ZEND_STRL("model"), PH_NOISY_CC); - if (zephir_instance_of_ev(&_1$$6, phalcon_mvc_model_ce)) { - zephir_read_property(&_2$$7, this_ptr, ZEND_STRL("model"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&modelName); - zephir_get_class(&modelName, &_2$$7, 0); - } else { - ZEPHIR_INIT_NVAR(&modelName); - ZVAL_STRING(&modelName, "Phalcon\\Mvc\\Model"); - } - zephir_read_property(&_3$$6, this_ptr, ZEND_STRL("model"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_4$$6, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_5$$6, 0); - _6$$6 = zephir_fetch_class(&modelName); - ZEPHIR_CALL_CE_STATIC(&activeRow, _6$$6, "cloneresultmap", NULL, 0, &_3$$6, &row, &columnMap, &_5$$6, &_4$$6); - zephir_check_call_status(); - } else { - zephir_read_property(&_7$$9, this_ptr, ZEND_STRL("model"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_8$$9, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_9$$9, 0); - ZEPHIR_CALL_CE_STATIC(&activeRow, phalcon_mvc_model_ce, "cloneresultmap", NULL, 0, &_7$$9, &row, &columnMap, &_9$$9, &_8$$9); - zephir_check_call_status(); +pp228: + ppch = *++PPCURSOR; + switch (ppch) { + case 'N': + case 'n': goto pp282; + default: goto pp59; } - break; +pp229: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp283; + default: goto pp59; + } +pp230: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp231; + } +pp231: + { + token->opcode = PHQL_T_CASE; + return 0; } - ZEPHIR_CALL_CE_STATIC(&activeRow, phalcon_mvc_model_ce, "cloneresultmaphydrate", NULL, 0, &row, &columnMap, &hydrateMode); - zephir_check_call_status(); - break; - } while(0); - - zephir_update_property_zval(this_ptr, ZEND_STRL("activeRow"), &activeRow); - RETURN_CCTOR(&activeRow); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, toArray) -{ - zend_string *_9$$8, *_22$$19; - zend_ulong _8$$8, _21$$19; - zval renamedRecords, renamed; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_12 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *renameColumns_param = NULL, __$null, result, records, record, renamedKey, key, value, columnMap, _2, _0$$3, _3$$5, *_4$$7, _5$$7, *_6$$8, _7$$8, _10$$11, _11$$11, _13$$13, _14$$13, _15$$16, _16$$16, _17$$18, _18$$18, *_19$$19, _20$$19, _23$$22, _24$$22, _25$$24, _26$$24, _27$$27, _28$$27, _29$$29, _30$$29; - zend_bool renameColumns, _1; - zval *this_ptr = getThis(); - - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&records); - ZVAL_UNDEF(&record); - ZVAL_UNDEF(&renamedKey); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_5$$7); - ZVAL_UNDEF(&_7$$8); - ZVAL_UNDEF(&_10$$11); - ZVAL_UNDEF(&_11$$11); - ZVAL_UNDEF(&_13$$13); - ZVAL_UNDEF(&_14$$13); - ZVAL_UNDEF(&_15$$16); - ZVAL_UNDEF(&_16$$16); - ZVAL_UNDEF(&_17$$18); - ZVAL_UNDEF(&_18$$18); - ZVAL_UNDEF(&_20$$19); - ZVAL_UNDEF(&_23$$22); - ZVAL_UNDEF(&_24$$22); - ZVAL_UNDEF(&_25$$24); - ZVAL_UNDEF(&_26$$24); - ZVAL_UNDEF(&_27$$27); - ZVAL_UNDEF(&_28$$27); - ZVAL_UNDEF(&_29$$29); - ZVAL_UNDEF(&_30$$29); - ZVAL_UNDEF(&renamedRecords); - ZVAL_UNDEF(&renamed); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(renameColumns) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &renameColumns_param); - if (!renameColumns_param) { - renameColumns = 1; - } else { +pp232: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp233; + } +pp233: + { + token->opcode = PHQL_T_CAST; + return 0; } - zephir_memory_observe(&records); - zephir_read_property(&records, this_ptr, ZEND_STRL("rows"), PH_NOISY_CC); - if (Z_TYPE_P(&records) != IS_ARRAY) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("result"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&result, &_0$$3); - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("row"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0$$3) != IS_NULL) { - ZEPHIR_CALL_METHOD(NULL, &result, "execute", NULL, 0); - zephir_check_call_status(); +pp234: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp284; + default: goto pp59; + } +pp235: + ppch = *++PPCURSOR; + switch (ppch) { + case 'S': + case 's': goto pp285; + default: goto pp59; + } +pp236: + ppch = *++PPCURSOR; + switch (ppch) { + case 'T': + case 't': goto pp287; + default: goto pp59; + } +pp237: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp238; + } +pp238: + { + token->opcode = PHQL_T_DESC; + return 0; } - ZEPHIR_CALL_METHOD(&records, &result, "fetchall", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("row"), &__$null); - zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &records); - } - _1 = renameColumns; - if (_1) { - zephir_memory_observe(&_2); - zephir_read_property(&_2, this_ptr, ZEND_STRL("model"), PH_NOISY_CC); - _1 = !(zephir_instance_of_ev(&_2, phalcon_mvc_model_row_ce)); - } - if (_1) { - zephir_read_property(&_3$$5, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&columnMap, &_3$$5); - if (Z_TYPE_P(&columnMap) != IS_ARRAY) { - RETURN_CCTOR(&records); +pp239: + ppch = *++PPCURSOR; + switch (ppch) { + case 'I': + case 'i': goto pp288; + default: goto pp59; + } +pp240: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp241; + } +pp241: + { + token->opcode = PHQL_T_ELSE; + return 0; } - ZEPHIR_INIT_VAR(&renamedRecords); - array_init(&renamedRecords); - if (Z_TYPE_P(&records) == IS_ARRAY) { - zephir_is_iterable(&records, 0, "phalcon/Mvc/Model/Resultset/Simple.zep", 246); - if (Z_TYPE_P(&records) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&records), _4$$7) - { - ZEPHIR_INIT_NVAR(&record); - ZVAL_COPY(&record, _4$$7); - ZEPHIR_INIT_NVAR(&renamed); - array_init(&renamed); - zephir_is_iterable(&record, 0, "phalcon/Mvc/Model/Resultset/Simple.zep", 244); - if (Z_TYPE_P(&record) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&record), _8$$8, _9$$8, _6$$8) - { - ZEPHIR_INIT_NVAR(&key); - if (_9$$8 != NULL) { - ZVAL_STR_COPY(&key, _9$$8); - } else { - ZVAL_LONG(&key, _8$$8); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _6$$8); - if (Z_TYPE_P(&key) == IS_STRING) { - ZEPHIR_OBS_NVAR(&renamedKey); - if (UNEXPECTED(!(zephir_array_isset_fetch(&renamedKey, &columnMap, &key, 0)))) { - ZEPHIR_INIT_NVAR(&_10$$11); - object_init_ex(&_10$$11, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_11$$11); - ZEPHIR_CONCAT_SVS(&_11$$11, "Column '", &key, "' is not part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_10$$11, "__construct", &_12, 33, &_11$$11); - zephir_check_call_status(); - zephir_throw_exception_debug(&_10$$11, "phalcon/Mvc/Model/Resultset/Simple.zep", 226); - ZEPHIR_MM_RESTORE(); - return; - } - if (Z_TYPE_P(&renamedKey) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&renamedKey); - if (UNEXPECTED(!(zephir_array_isset_long_fetch(&renamedKey, &renamedKey, 0, 0)))) { - ZEPHIR_INIT_NVAR(&_13$$13); - object_init_ex(&_13$$13, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_14$$13); - ZEPHIR_CONCAT_SVS(&_14$$13, "Column '", &key, "' is not part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_13$$13, "__construct", &_12, 33, &_14$$13); - zephir_check_call_status(); - zephir_throw_exception_debug(&_13$$13, "phalcon/Mvc/Model/Resultset/Simple.zep", 233); - ZEPHIR_MM_RESTORE(); - return; - } - } - zephir_array_update_zval(&renamed, &renamedKey, &value, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &record, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_7$$8, &record, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_7$$8)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &record, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &record, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&key) == IS_STRING) { - ZEPHIR_OBS_NVAR(&renamedKey); - if (UNEXPECTED(!(zephir_array_isset_fetch(&renamedKey, &columnMap, &key, 0)))) { - ZEPHIR_INIT_NVAR(&_15$$16); - object_init_ex(&_15$$16, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_16$$16); - ZEPHIR_CONCAT_SVS(&_16$$16, "Column '", &key, "' is not part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_15$$16, "__construct", &_12, 33, &_16$$16); - zephir_check_call_status(); - zephir_throw_exception_debug(&_15$$16, "phalcon/Mvc/Model/Resultset/Simple.zep", 226); - ZEPHIR_MM_RESTORE(); - return; - } - if (Z_TYPE_P(&renamedKey) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&renamedKey); - if (UNEXPECTED(!(zephir_array_isset_long_fetch(&renamedKey, &renamedKey, 0, 0)))) { - ZEPHIR_INIT_NVAR(&_17$$18); - object_init_ex(&_17$$18, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_18$$18); - ZEPHIR_CONCAT_SVS(&_18$$18, "Column '", &key, "' is not part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_17$$18, "__construct", &_12, 33, &_18$$18); - zephir_check_call_status(); - zephir_throw_exception_debug(&_17$$18, "phalcon/Mvc/Model/Resultset/Simple.zep", 233); - ZEPHIR_MM_RESTORE(); - return; - } - } - zephir_array_update_zval(&renamed, &renamedKey, &value, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &record, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - zephir_array_append(&renamedRecords, &renamed, PH_SEPARATE, "phalcon/Mvc/Model/Resultset/Simple.zep", 244); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &records, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5$$7, &records, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5$$7)) { - break; - } - ZEPHIR_CALL_METHOD(&record, &records, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&renamed); - array_init(&renamed); - zephir_is_iterable(&record, 0, "phalcon/Mvc/Model/Resultset/Simple.zep", 244); - if (Z_TYPE_P(&record) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&record), _21$$19, _22$$19, _19$$19) - { - ZEPHIR_INIT_NVAR(&key); - if (_22$$19 != NULL) { - ZVAL_STR_COPY(&key, _22$$19); - } else { - ZVAL_LONG(&key, _21$$19); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _19$$19); - if (Z_TYPE_P(&key) == IS_STRING) { - ZEPHIR_OBS_NVAR(&renamedKey); - if (UNEXPECTED(!(zephir_array_isset_fetch(&renamedKey, &columnMap, &key, 0)))) { - ZEPHIR_INIT_NVAR(&_23$$22); - object_init_ex(&_23$$22, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_24$$22); - ZEPHIR_CONCAT_SVS(&_24$$22, "Column '", &key, "' is not part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_23$$22, "__construct", &_12, 33, &_24$$22); - zephir_check_call_status(); - zephir_throw_exception_debug(&_23$$22, "phalcon/Mvc/Model/Resultset/Simple.zep", 226); - ZEPHIR_MM_RESTORE(); - return; - } - if (Z_TYPE_P(&renamedKey) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&renamedKey); - if (UNEXPECTED(!(zephir_array_isset_long_fetch(&renamedKey, &renamedKey, 0, 0)))) { - ZEPHIR_INIT_NVAR(&_25$$24); - object_init_ex(&_25$$24, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_26$$24); - ZEPHIR_CONCAT_SVS(&_26$$24, "Column '", &key, "' is not part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_25$$24, "__construct", &_12, 33, &_26$$24); - zephir_check_call_status(); - zephir_throw_exception_debug(&_25$$24, "phalcon/Mvc/Model/Resultset/Simple.zep", 233); - ZEPHIR_MM_RESTORE(); - return; - } - } - zephir_array_update_zval(&renamed, &renamedKey, &value, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &record, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_20$$19, &record, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_20$$19)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &record, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &record, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&key) == IS_STRING) { - ZEPHIR_OBS_NVAR(&renamedKey); - if (UNEXPECTED(!(zephir_array_isset_fetch(&renamedKey, &columnMap, &key, 0)))) { - ZEPHIR_INIT_NVAR(&_27$$27); - object_init_ex(&_27$$27, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_28$$27); - ZEPHIR_CONCAT_SVS(&_28$$27, "Column '", &key, "' is not part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_27$$27, "__construct", &_12, 33, &_28$$27); - zephir_check_call_status(); - zephir_throw_exception_debug(&_27$$27, "phalcon/Mvc/Model/Resultset/Simple.zep", 226); - ZEPHIR_MM_RESTORE(); - return; - } - if (Z_TYPE_P(&renamedKey) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&renamedKey); - if (UNEXPECTED(!(zephir_array_isset_long_fetch(&renamedKey, &renamedKey, 0, 0)))) { - ZEPHIR_INIT_NVAR(&_29$$29); - object_init_ex(&_29$$29, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_NVAR(&_30$$29); - ZEPHIR_CONCAT_SVS(&_30$$29, "Column '", &key, "' is not part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_29$$29, "__construct", &_12, 33, &_30$$29); - zephir_check_call_status(); - zephir_throw_exception_debug(&_29$$29, "phalcon/Mvc/Model/Resultset/Simple.zep", 233); - ZEPHIR_MM_RESTORE(); - return; - } - } - zephir_array_update_zval(&renamed, &renamedKey, &value, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &record, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - zephir_array_append(&renamedRecords, &renamed, PH_SEPARATE, "phalcon/Mvc/Model/Resultset/Simple.zep", 244); - ZEPHIR_CALL_METHOD(NULL, &records, "next", NULL, 0); - zephir_check_call_status(); - } +pp242: + ppch = *++PPCURSOR; + switch (ppch) { + case 'T': + case 't': goto pp289; + default: goto pp59; } - ZEPHIR_INIT_NVAR(&record); - } - RETURN_CTOR(&renamedRecords); - } - RETURN_CCTOR(&records); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, serialize) -{ - zval data; - zval container, serializer, _0, _1, _2, _3, _4$$4, _5$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&serializer); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&data); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The dependency injector container is not valid", "phalcon/Mvc/Model/Resultset/Simple.zep", 266); - return; - } - ZEPHIR_INIT_VAR(&data); - zephir_create_array(&data, 6, 0); - zephir_memory_observe(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("model"), PH_NOISY_CC); - zephir_array_update_string(&data, SL("model"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC); - zephir_array_update_string(&data, SL("cache"), &_0, PH_COPY | PH_SEPARATE); - ZVAL_BOOL(&_2, 0); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "toarray", NULL, 0, &_2); - zephir_check_call_status(); - zephir_array_update_string(&data, SL("rows"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC); - zephir_array_update_string(&data, SL("columnMap"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("hydrateMode"), PH_NOISY_CC); - zephir_array_update_string(&data, SL("hydrateMode"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC); - zephir_array_update_string(&data, SL("keepSnapshots"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "serializer"); - ZEPHIR_CALL_METHOD(&_1, &container, "has", NULL, 0, &_3); - zephir_check_call_status(); - if (zephir_is_true(&_1)) { - ZEPHIR_INIT_VAR(&_5$$4); - ZVAL_STRING(&_5$$4, "serializer"); - ZEPHIR_CALL_METHOD(&_4$$4, &container, "getshared", NULL, 0, &_5$$4); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&serializer, &_4$$4); - ZEPHIR_CALL_METHOD(NULL, &serializer, "setdata", NULL, 0, &data); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&serializer, "serialize", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_RETURN_CALL_FUNCTION("serialize", NULL, 15, &data); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, unserialize) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *data, data_sub, resultset, keepSnapshots, container, serializer, _0, _1, _4, _5, _6, _7, _8, _9, _10, _2$$4, _3$$4; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&data_sub); - ZVAL_UNDEF(&resultset); - ZVAL_UNDEF(&keepSnapshots); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&serializer); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(data) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &data); - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The dependency injector container is not valid", "phalcon/Mvc/Model/Resultset/Simple.zep", 303); - return; - } - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "serializer"); - ZEPHIR_CALL_METHOD(&_0, &container, "has", NULL, 0, &_1); - zephir_check_call_status(); - if (zephir_is_true(&_0)) { - ZEPHIR_INIT_VAR(&_3$$4); - ZVAL_STRING(&_3$$4, "serializer"); - ZEPHIR_CALL_METHOD(&_2$$4, &container, "getshared", NULL, 0, &_3$$4); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&serializer, &_2$$4); - ZEPHIR_CALL_METHOD(NULL, &serializer, "unserialize", NULL, 0, data); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&resultset, &serializer, "getdata", NULL, 0); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_FUNCTION(&resultset, "unserialize", NULL, 16, data); - zephir_check_call_status(); - } - if (UNEXPECTED(Z_TYPE_P(&resultset) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Invalid serialization data", "phalcon/Mvc/Model/Resultset/Simple.zep", 316); - return; - } - zephir_array_fetch_string(&_4, &resultset, SL("model"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 319); - zephir_update_property_zval(this_ptr, ZEND_STRL("model"), &_4); - zephir_array_fetch_string(&_5, &resultset, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 320); - zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_5); - zephir_array_fetch_string(&_6, &resultset, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 321); - ZVAL_UNDEF(&_7); - ZVAL_LONG(&_7, zephir_fast_count_int(&_6)); - zephir_update_property_zval(this_ptr, ZEND_STRL("count"), &_7); - zephir_array_fetch_string(&_8, &resultset, SL("cache"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 322); - zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), &_8); - zephir_array_fetch_string(&_9, &resultset, SL("columnMap"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 323); - zephir_update_property_zval(this_ptr, ZEND_STRL("columnMap"), &_9); - zephir_array_fetch_string(&_10, &resultset, SL("hydrateMode"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 324); - zephir_update_property_zval(this_ptr, ZEND_STRL("hydrateMode"), &_10); - if (zephir_array_isset_string_fetch(&keepSnapshots, &resultset, SL("keepSnapshots"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("keepSnapshots"), &keepSnapshots); - } - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, __serialize) -{ - zval _0, _1, _2; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_create_array(return_value, 6, 0); - zephir_memory_observe(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("model"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("model"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("cache"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("cache"), &_0, PH_COPY | PH_SEPARATE); - ZVAL_BOOL(&_2, 0); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "toarray", NULL, 0, &_2); - zephir_check_call_status(); - zephir_array_update_string(return_value, SL("rows"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("columnMap"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("hydrateMode"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("hydrateMode"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("keepSnapshots"), PH_NOISY_CC); - zephir_array_update_string(return_value, SL("keepSnapshots"), &_0, PH_COPY | PH_SEPARATE); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, __unserialize) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *data_param = NULL, keepSnapshots, _0, _1, _2, _3, _4, _5, _6; - zval data; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&keepSnapshots); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(data) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &data_param); - zephir_get_arrval(&data, data_param); - zephir_array_fetch_string(&_0, &data, SL("model"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 347); - zephir_update_property_zval(this_ptr, ZEND_STRL("model"), &_0); - zephir_array_fetch_string(&_1, &data, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 348); - zephir_update_property_zval(this_ptr, ZEND_STRL("rows"), &_1); - zephir_array_fetch_string(&_2, &data, SL("rows"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 349); - ZVAL_UNDEF(&_3); - ZVAL_LONG(&_3, zephir_fast_count_int(&_2)); - zephir_update_property_zval(this_ptr, ZEND_STRL("count"), &_3); - zephir_array_fetch_string(&_4, &data, SL("cache"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 350); - zephir_update_property_zval(this_ptr, ZEND_STRL("cache"), &_4); - zephir_array_fetch_string(&_5, &data, SL("columnMap"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 351); - zephir_update_property_zval(this_ptr, ZEND_STRL("columnMap"), &_5); - zephir_array_fetch_string(&_6, &data, SL("hydrateMode"), PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Resultset/Simple.zep", 352); - zephir_update_property_zval(this_ptr, ZEND_STRL("hydrateMode"), &_6); - if (zephir_array_isset_string_fetch(&keepSnapshots, &data, SL("keepSnapshots"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("keepSnapshots"), &keepSnapshots); - } - ZEPHIR_MM_RESTORE(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Binder_BindableInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model\\Binder, BindableInterface, phalcon, mvc_model_binder_bindableinterface, phalcon_mvc_model_binder_bindableinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Binder_BindableInterface, getModelName); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query_Builder) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model\\Query, Builder, phalcon, mvc_model_query_builder, phalcon_mvc_model_query_builder_method_entry, 0); - - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("bindParams"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("bindTypes"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("columns"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("conditions"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("container"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("distinct"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_query_builder_ce, SL("forUpdate"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("group"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("having"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_model_query_builder_ce, SL("hiddenParamNumber"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("joins"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("limit"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("models"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_model_query_builder_ce, SL("offset"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_builder_ce, SL("order"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_mvc_model_query_builder_ce, SL("sharedLock"), 0, ZEND_ACC_PROTECTED); - phalcon_mvc_model_query_builder_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Query_Builder; - - zend_class_implements(phalcon_mvc_model_query_builder_ce, 1, phalcon_mvc_model_query_builderinterface_ce); - zend_class_implements(phalcon_mvc_model_query_builder_ce, 1, phalcon_di_injectionawareinterface_ce); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, __construct) -{ - zend_bool _7$$38; - zval mergedConditions, mergedParams, mergedTypes; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *params = NULL, params_sub, *container = NULL, container_sub, __$null, conditions, columns, groupClause, havingClause, limitClause, forUpdate, sharedLock, orderClause, offsetClause, joinsClause, singleConditionArray, limit, offset, fromClause, singleCondition, singleParams, singleTypes, distinct, bind, bindTypes, *_0$$7, _1$$7, _6$$7, _2$$11, _3$$12, _4$$16, _5$$17; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(¶ms_sub); - ZVAL_UNDEF(&container_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&groupClause); - ZVAL_UNDEF(&havingClause); - ZVAL_UNDEF(&limitClause); - ZVAL_UNDEF(&forUpdate); - ZVAL_UNDEF(&sharedLock); - ZVAL_UNDEF(&orderClause); - ZVAL_UNDEF(&offsetClause); - ZVAL_UNDEF(&joinsClause); - ZVAL_UNDEF(&singleConditionArray); - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&offset); - ZVAL_UNDEF(&fromClause); - ZVAL_UNDEF(&singleCondition); - ZVAL_UNDEF(&singleParams); - ZVAL_UNDEF(&singleTypes); - ZVAL_UNDEF(&distinct); - ZVAL_UNDEF(&bind); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&_1$$7); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_2$$11); - ZVAL_UNDEF(&_3$$12); - ZVAL_UNDEF(&_4$$16); - ZVAL_UNDEF(&_5$$17); - ZVAL_UNDEF(&mergedConditions); - ZVAL_UNDEF(&mergedParams); - ZVAL_UNDEF(&mergedTypes); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(params) - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(container, phalcon_di_diinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, ¶ms, &container); - if (!params) { - params = ¶ms_sub; - params = &__$null; - } - if (!container) { - container = &container_sub; - container = &__$null; - } - if (Z_TYPE_P(params) == IS_ARRAY) { - zephir_memory_observe(&conditions); - if (zephir_array_isset_long_fetch(&conditions, params, 0, 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("conditions"), &conditions); - } else { - ZEPHIR_OBS_NVAR(&conditions); - if (zephir_array_isset_string_fetch(&conditions, params, SL("conditions"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("conditions"), &conditions); +pp243: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp290; + default: goto pp59; } - } - if (Z_TYPE_P(&conditions) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&mergedConditions); - array_init(&mergedConditions); - ZEPHIR_INIT_VAR(&mergedParams); - array_init(&mergedParams); - ZEPHIR_INIT_VAR(&mergedTypes); - array_init(&mergedTypes); - zephir_is_iterable(&conditions, 0, "phalcon/Mvc/Model/Query/Builder.zep", 189); - if (Z_TYPE_P(&conditions) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&conditions), _0$$7) - { - ZEPHIR_INIT_NVAR(&singleConditionArray); - ZVAL_COPY(&singleConditionArray, _0$$7); - if (Z_TYPE_P(&singleConditionArray) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&singleCondition); - zephir_array_isset_long_fetch(&singleCondition, &singleConditionArray, 0, 0); - ZEPHIR_OBS_NVAR(&singleParams); - zephir_array_isset_long_fetch(&singleParams, &singleConditionArray, 1, 0); - ZEPHIR_OBS_NVAR(&singleTypes); - zephir_array_isset_long_fetch(&singleTypes, &singleConditionArray, 2, 0); - if (Z_TYPE_P(&singleCondition) == IS_STRING) { - zephir_array_append(&mergedConditions, &singleCondition, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 176); - } - if (Z_TYPE_P(&singleParams) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_2$$11); - zephir_add_function(&_2$$11, &mergedParams, &singleParams); - ZEPHIR_CPY_WRT(&mergedParams, &_2$$11); - } - if (Z_TYPE_P(&singleTypes) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_3$$12); - zephir_add_function(&_3$$12, &mergedTypes, &singleTypes); - ZEPHIR_CPY_WRT(&mergedTypes, &_3$$12); - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &conditions, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1$$7, &conditions, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1$$7)) { - break; - } - ZEPHIR_CALL_METHOD(&singleConditionArray, &conditions, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&singleConditionArray) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&singleCondition); - zephir_array_isset_long_fetch(&singleCondition, &singleConditionArray, 0, 0); - ZEPHIR_OBS_NVAR(&singleParams); - zephir_array_isset_long_fetch(&singleParams, &singleConditionArray, 1, 0); - ZEPHIR_OBS_NVAR(&singleTypes); - zephir_array_isset_long_fetch(&singleTypes, &singleConditionArray, 2, 0); - if (Z_TYPE_P(&singleCondition) == IS_STRING) { - zephir_array_append(&mergedConditions, &singleCondition, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 176); - } - if (Z_TYPE_P(&singleParams) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_4$$16); - zephir_add_function(&_4$$16, &mergedParams, &singleParams); - ZEPHIR_CPY_WRT(&mergedParams, &_4$$16); - } - if (Z_TYPE_P(&singleTypes) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_5$$17); - zephir_add_function(&_5$$17, &mergedTypes, &singleTypes); - ZEPHIR_CPY_WRT(&mergedTypes, &_5$$17); - } - } - ZEPHIR_CALL_METHOD(NULL, &conditions, "next", NULL, 0); - zephir_check_call_status(); - } +pp244: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp245; } - ZEPHIR_INIT_NVAR(&singleConditionArray); - ZEPHIR_INIT_VAR(&_6$$7); - zephir_fast_join_str(&_6$$7, SL(" AND "), &mergedConditions); - zephir_update_property_zval(this_ptr, ZEND_STRL("conditions"), &_6$$7); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &mergedParams); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &mergedTypes); - } - zephir_memory_observe(&bind); - if (zephir_array_isset_string_fetch(&bind, params, SL("bind"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &bind); - } - zephir_memory_observe(&bindTypes); - if (zephir_array_isset_string_fetch(&bindTypes, params, SL("bindTypes"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); - } - zephir_memory_observe(&distinct); - if (zephir_array_isset_string_fetch(&distinct, params, SL("distinct"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("distinct"), &distinct); - } - zephir_memory_observe(&fromClause); - if (zephir_array_isset_string_fetch(&fromClause, params, SL("models"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &fromClause); - } - zephir_memory_observe(&columns); - if (zephir_array_isset_string_fetch(&columns, params, SL("columns"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("columns"), &columns); - } - zephir_memory_observe(&joinsClause); - if (zephir_array_isset_string_fetch(&joinsClause, params, SL("joins"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("joins"), &joinsClause); - } - zephir_memory_observe(&groupClause); - if (zephir_array_isset_string_fetch(&groupClause, params, SL("group"), 0)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "groupby", NULL, 0, &groupClause); - zephir_check_call_status(); - } - zephir_memory_observe(&havingClause); - if (zephir_array_isset_string_fetch(&havingClause, params, SL("having"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("having"), &havingClause); - } - zephir_memory_observe(&orderClause); - if (zephir_array_isset_string_fetch(&orderClause, params, SL("order"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("order"), &orderClause); +pp245: + { + token->opcode = PHQL_T_FROM; + return 0; } - zephir_memory_observe(&limitClause); - if (zephir_array_isset_string_fetch(&limitClause, params, SL("limit"), 0)) { - if (Z_TYPE_P(&limitClause) == IS_ARRAY) { - zephir_memory_observe(&limit); - if (zephir_array_isset_long_fetch(&limit, &limitClause, 0, 0)) { - if (Z_TYPE_P(&limit) == IS_LONG) { - zephir_update_property_zval(this_ptr, ZEND_STRL("limit"), &limit); - } - zephir_memory_observe(&offset); - if (zephir_array_isset_long_fetch(&offset, &limitClause, 1, 0)) { - if (Z_TYPE_P(&offset) == IS_LONG) { - zephir_update_property_zval(this_ptr, ZEND_STRL("offset"), &offset); - } - } - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("limit"), &limitClause); - } - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("limit"), &limitClause); +pp246: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp247; } +pp247: + { + token->opcode = PHQL_T_FULL; + return 0; } - if (zephir_array_isset_string_fetch(&offsetClause, params, SL("offset"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("offset"), &offsetClause); - } - if (zephir_array_isset_string_fetch(&forUpdate, params, SL("for_update"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("forUpdate"), &forUpdate); - } - if (zephir_array_isset_string_fetch(&sharedLock, params, SL("shared_lock"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("sharedLock"), &sharedLock); - } - } else { - _7$$38 = Z_TYPE_P(params) == IS_STRING; - if (_7$$38) { - _7$$38 = !ZEPHIR_IS_STRING_IDENTICAL(params, ""); +pp248: + ppch = *++PPCURSOR; + switch (ppch) { + case 'P': + case 'p': goto pp292; + default: goto pp59; + } +pp249: + ppch = *++PPCURSOR; + switch (ppch) { + case 'N': + case 'n': goto pp294; + default: goto pp59; + } +pp250: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp295; + default: goto pp59; + } +pp251: + ppch = *++PPCURSOR; + switch (ppch) { + case 'R': + case 'r': goto pp297; + default: goto pp59; + } +pp252: + ppch = *++PPCURSOR; + switch (ppch) { + case 'R': + case 'r': goto pp299; + default: goto pp59; + } +pp253: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp254; + } +pp254: + { + token->opcode = PHQL_T_INTO; + return 0; } - if (_7$$38) { - zephir_update_property_zval(this_ptr, ZEND_STRL("conditions"), params); +pp255: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp256; + } +pp256: + { + token->opcode = PHQL_T_JOIN; + return 0; } - } - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, addFrom) -{ - zend_bool _2; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model_param = NULL, *alias_param = NULL, models, currentModel, _0, _1$$4; - zval model, alias; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(¤tModel); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(model) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(alias) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &model_param, &alias_param); - zephir_get_strval(&model, model_param); - if (!alias_param) { - ZEPHIR_INIT_VAR(&alias); - } else { - zephir_get_strval(&alias, alias_param); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&models, &_0); - if (Z_TYPE_P(&models) != IS_ARRAY) { - if (Z_TYPE_P(&models) != IS_NULL) { - ZEPHIR_CPY_WRT(¤tModel, &models); - ZEPHIR_INIT_VAR(&_1$$4); - zephir_create_array(&_1$$4, 1, 0); - zephir_array_fast_append(&_1$$4, ¤tModel); - ZEPHIR_CPY_WRT(&models, &_1$$4); - } else { - ZEPHIR_INIT_NVAR(&models); - array_init(&models); - } - } - _2 = 1 == 1; - if (_2) { - _2 = !ZEPHIR_IS_NULL(&alias); - } - if (_2) { - zephir_array_update_zval(&models, &alias, &model, PH_COPY | PH_SEPARATE); - } else { - zephir_array_append(&models, &model, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 344); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("models"), &models); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, andHaving) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval bindParams, bindTypes; - zval *conditions_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, currentConditions, _0$$3; - zval conditions; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(¤tConditions); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(conditions) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams_param, &bindTypes_param); - if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { - zephir_get_strval(&conditions, conditions_param); - } else { - ZEPHIR_INIT_VAR(&conditions); - } - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - } else { - zephir_get_arrval(&bindParams, bindParams_param); - } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - } else { - zephir_get_arrval(&bindTypes, bindTypes_param); - } - zephir_memory_observe(¤tConditions); - zephir_read_property(¤tConditions, this_ptr, ZEND_STRL("having"), PH_NOISY_CC); - if (zephir_is_true(¤tConditions)) { - ZEPHIR_INIT_VAR(&_0$$3); - ZEPHIR_CONCAT_SVSVS(&_0$$3, "(", ¤tConditions, ") AND (", &conditions, ")"); - zephir_get_strval(&conditions, &_0$$3); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "having", NULL, 0, &conditions, &bindParams, &bindTypes); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, andWhere) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval bindParams, bindTypes; - zval *conditions_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, currentConditions, _0$$3; - zval conditions; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(¤tConditions); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(conditions) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams_param, &bindTypes_param); - if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { - zephir_get_strval(&conditions, conditions_param); - } else { - ZEPHIR_INIT_VAR(&conditions); - } - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - } else { - zephir_get_arrval(&bindParams, bindParams_param); - } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - } else { - zephir_get_arrval(&bindTypes, bindTypes_param); - } - zephir_memory_observe(¤tConditions); - zephir_read_property(¤tConditions, this_ptr, ZEND_STRL("conditions"), PH_NOISY_CC); - if (zephir_is_true(¤tConditions)) { - ZEPHIR_INIT_VAR(&_0$$3); - ZEPHIR_CONCAT_SVSVS(&_0$$3, "(", ¤tConditions, ") AND (", &conditions, ")"); - zephir_get_strval(&conditions, &_0$$3); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "where", NULL, 0, &conditions, &bindParams, &bindTypes); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, autoescape) -{ - zend_bool _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *identifier_param = NULL; - zval identifier; - - ZVAL_UNDEF(&identifier); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(identifier) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &identifier_param); - zephir_get_strval(&identifier, identifier_param); - _0 = zephir_memnstr_str(&identifier, SL("["), "phalcon/Mvc/Model/Query/Builder.zep", 418); - if (!(_0)) { - _0 = zephir_memnstr_str(&identifier, SL("."), "phalcon/Mvc/Model/Query/Builder.zep", 418); - } - _1 = _0; - if (!(_1)) { - _1 = zephir_is_numeric(&identifier); - } - if (_1) { - RETURN_CTOR(&identifier); - } - ZEPHIR_CONCAT_SVS(return_value, "[", &identifier, "]"); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, betweenHaving) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, *operator_param = NULL, _0; - zval expr, operator; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&minimum_sub); - ZVAL_UNDEF(&maximum_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_STR(expr) - Z_PARAM_ZVAL(minimum) - Z_PARAM_ZVAL(maximum) - Z_PARAM_OPTIONAL - Z_PARAM_STR(operator) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 1, &expr_param, &minimum, &maximum, &operator_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - if (!operator_param) { - ZEPHIR_INIT_VAR(&operator); - ZVAL_STRING(&operator, "and"); - } else { - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "Having"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionbetween", NULL, 0, &_0, &operator, &expr, minimum, maximum); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, betweenWhere) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, *operator_param = NULL, _0; - zval expr, operator; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&minimum_sub); - ZVAL_UNDEF(&maximum_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_STR(expr) - Z_PARAM_ZVAL(minimum) - Z_PARAM_ZVAL(maximum) - Z_PARAM_OPTIONAL - Z_PARAM_STR(operator) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 1, &expr_param, &minimum, &maximum, &operator_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - if (!operator_param) { - ZEPHIR_INIT_VAR(&operator); - ZVAL_STRING(&operator, "and"); - } else { - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "Where"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionbetween", NULL, 0, &_0, &operator, &expr, minimum, maximum); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, columns) -{ - zval *columns, columns_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&columns_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(columns) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &columns); - zephir_update_property_zval(this_ptr, ZEND_STRL("columns"), columns); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, distinct) -{ - zval *distinct, distinct_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&distinct_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(distinct) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &distinct); - zephir_update_property_zval(this_ptr, ZEND_STRL("distinct"), distinct); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, forUpdate) -{ - zval *forUpdate_param = NULL, __$true, __$false; - zend_bool forUpdate; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(forUpdate) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &forUpdate_param); - if (forUpdate) { - zephir_update_property_zval(this_ptr, ZEND_STRL("forUpdate"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("forUpdate"), &__$false); - } - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, from) -{ - zval *models, models_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&models_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(models) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &models); - zephir_update_property_zval(this_ptr, ZEND_STRL("models"), models); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getBindParams) -{ - - RETURN_MEMBER(getThis(), "bindParams"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getBindTypes) -{ - - RETURN_MEMBER(getThis(), "bindTypes"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getColumns) -{ - - RETURN_MEMBER(getThis(), "columns"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getDI) -{ - - RETURN_MEMBER(getThis(), "container"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getDistinct) -{ - - RETURN_MEMBER(getThis(), "distinct"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getFrom) -{ - - RETURN_MEMBER(getThis(), "models"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getGroupBy) -{ - - RETURN_MEMBER(getThis(), "group"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getHaving) -{ - - RETURN_MEMBER(getThis(), "having"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getJoins) -{ - - RETURN_MEMBER(getThis(), "joins"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getLimit) -{ - - RETURN_MEMBER(getThis(), "limit"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getModels) -{ - zend_bool _1; - zval models, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&models, &_0); - _1 = Z_TYPE_P(&models) == IS_ARRAY; - if (_1) { - _1 = zephir_fast_count_int(&models) == 1; - } - if (_1) { - ZEPHIR_MAKE_REF(&models); - ZEPHIR_RETURN_CALL_FUNCTION("reset", NULL, 477, &models); - ZEPHIR_UNREF(&models); - zephir_check_call_status(); - RETURN_MM(); - } - RETURN_CCTOR(&models); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getOffset) -{ - - RETURN_MEMBER(getThis(), "offset"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getOrderBy) -{ - - RETURN_MEMBER(getThis(), "order"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getPhql) -{ - zend_string *_12$$26, *_21$$35, *_32$$43; - zend_ulong _11$$26, _20$$35, _31$$43; - zval _2$$8; - zend_bool noPrimary = 0, _86$$86; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$null, container, models, conditions, model, metaData, modelInstance, primaryKeys, firstPrimaryKey, columnMap, modelAlias, attributeField, phql, column, columns, selectedColumns, selectedColumn, selectedModel, selectedModels, columnAlias, modelColumnAlias, joins, join, joinModel, joinConditions, joinAlias, joinType, group, groupItems, groupItem, having, order, orderItems, orderItem, limit, number, offset, forUpdate, distinct, _0, _1$$8, _3$$17, _4$$17, _5$$19, _6$$13, _7$$13, _8$$13, *_9$$26, _10$$26, _17$$26, _13$$29, _14$$29, _15$$32, _16$$32, *_18$$35, _19$$35, _26$$35, _22$$37, _23$$38, _24$$40, _25$$41, _27$$42, _28$$42, *_29$$43, _30$$43, _37$$43, _38$$43, _33$$45, _34$$45, _35$$48, _36$$48, _39$$50, _40$$50, *_41$$51, _42$$51, _43$$53, _44$$53, _45$$54, _46$$54, _47$$55, _48$$55, _49$$56, _50$$58, _51$$58, _52$$59, _53$$59, _54$$60, _55$$60, _56$$61, _57$$63, *_58$$64, _59$$64, _62$$64, _63$$64, _60$$65, _61$$66, _64$$68, *_65$$70, _66$$70, _77$$70, _78$$70, itemExplode$$73, _67$$73, _68$$73, _69$$73, _70$$73, _71$$71, itemExplode$$76, _72$$76, _73$$76, _74$$76, _75$$76, _76$$74, _79$$77, _80$$83, _81$$86, _82$$86, _83$$86, _84$$86, _85$$86, _87$$87, _88$$87, _89$$87, _90$$87, _91$$87; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&models); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&metaData); - ZVAL_UNDEF(&modelInstance); - ZVAL_UNDEF(&primaryKeys); - ZVAL_UNDEF(&firstPrimaryKey); - ZVAL_UNDEF(&columnMap); - ZVAL_UNDEF(&modelAlias); - ZVAL_UNDEF(&attributeField); - ZVAL_UNDEF(&phql); - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&selectedColumns); - ZVAL_UNDEF(&selectedColumn); - ZVAL_UNDEF(&selectedModel); - ZVAL_UNDEF(&selectedModels); - ZVAL_UNDEF(&columnAlias); - ZVAL_UNDEF(&modelColumnAlias); - ZVAL_UNDEF(&joins); - ZVAL_UNDEF(&join); - ZVAL_UNDEF(&joinModel); - ZVAL_UNDEF(&joinConditions); - ZVAL_UNDEF(&joinAlias); - ZVAL_UNDEF(&joinType); - ZVAL_UNDEF(&group); - ZVAL_UNDEF(&groupItems); - ZVAL_UNDEF(&groupItem); - ZVAL_UNDEF(&having); - ZVAL_UNDEF(&order); - ZVAL_UNDEF(&orderItems); - ZVAL_UNDEF(&orderItem); - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&number); - ZVAL_UNDEF(&offset); - ZVAL_UNDEF(&forUpdate); - ZVAL_UNDEF(&distinct); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$8); - ZVAL_UNDEF(&_3$$17); - ZVAL_UNDEF(&_4$$17); - ZVAL_UNDEF(&_5$$19); - ZVAL_UNDEF(&_6$$13); - ZVAL_UNDEF(&_7$$13); - ZVAL_UNDEF(&_8$$13); - ZVAL_UNDEF(&_10$$26); - ZVAL_UNDEF(&_17$$26); - ZVAL_UNDEF(&_13$$29); - ZVAL_UNDEF(&_14$$29); - ZVAL_UNDEF(&_15$$32); - ZVAL_UNDEF(&_16$$32); - ZVAL_UNDEF(&_19$$35); - ZVAL_UNDEF(&_26$$35); - ZVAL_UNDEF(&_22$$37); - ZVAL_UNDEF(&_23$$38); - ZVAL_UNDEF(&_24$$40); - ZVAL_UNDEF(&_25$$41); - ZVAL_UNDEF(&_27$$42); - ZVAL_UNDEF(&_28$$42); - ZVAL_UNDEF(&_30$$43); - ZVAL_UNDEF(&_37$$43); - ZVAL_UNDEF(&_38$$43); - ZVAL_UNDEF(&_33$$45); - ZVAL_UNDEF(&_34$$45); - ZVAL_UNDEF(&_35$$48); - ZVAL_UNDEF(&_36$$48); - ZVAL_UNDEF(&_39$$50); - ZVAL_UNDEF(&_40$$50); - ZVAL_UNDEF(&_42$$51); - ZVAL_UNDEF(&_43$$53); - ZVAL_UNDEF(&_44$$53); - ZVAL_UNDEF(&_45$$54); - ZVAL_UNDEF(&_46$$54); - ZVAL_UNDEF(&_47$$55); - ZVAL_UNDEF(&_48$$55); - ZVAL_UNDEF(&_49$$56); - ZVAL_UNDEF(&_50$$58); - ZVAL_UNDEF(&_51$$58); - ZVAL_UNDEF(&_52$$59); - ZVAL_UNDEF(&_53$$59); - ZVAL_UNDEF(&_54$$60); - ZVAL_UNDEF(&_55$$60); - ZVAL_UNDEF(&_56$$61); - ZVAL_UNDEF(&_57$$63); - ZVAL_UNDEF(&_59$$64); - ZVAL_UNDEF(&_62$$64); - ZVAL_UNDEF(&_63$$64); - ZVAL_UNDEF(&_60$$65); - ZVAL_UNDEF(&_61$$66); - ZVAL_UNDEF(&_64$$68); - ZVAL_UNDEF(&_66$$70); - ZVAL_UNDEF(&_77$$70); - ZVAL_UNDEF(&_78$$70); - ZVAL_UNDEF(&itemExplode$$73); - ZVAL_UNDEF(&_67$$73); - ZVAL_UNDEF(&_68$$73); - ZVAL_UNDEF(&_69$$73); - ZVAL_UNDEF(&_70$$73); - ZVAL_UNDEF(&_71$$71); - ZVAL_UNDEF(&itemExplode$$76); - ZVAL_UNDEF(&_72$$76); - ZVAL_UNDEF(&_73$$76); - ZVAL_UNDEF(&_74$$76); - ZVAL_UNDEF(&_75$$76); - ZVAL_UNDEF(&_76$$74); - ZVAL_UNDEF(&_79$$77); - ZVAL_UNDEF(&_80$$83); - ZVAL_UNDEF(&_81$$86); - ZVAL_UNDEF(&_82$$86); - ZVAL_UNDEF(&_83$$86); - ZVAL_UNDEF(&_84$$86); - ZVAL_UNDEF(&_85$$86); - ZVAL_UNDEF(&_87$$87); - ZVAL_UNDEF(&_88$$87); - ZVAL_UNDEF(&_89$$87); - ZVAL_UNDEF(&_90$$87); - ZVAL_UNDEF(&_91$$87); - ZVAL_UNDEF(&_2$$8); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (Z_TYPE_P(&container) != IS_OBJECT) { - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &container); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("models"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&models, &_0); - if (Z_TYPE_P(&models) == IS_ARRAY) { - if (UNEXPECTED(!(zephir_fast_count_int(&models)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "At least one model is required to build the query", "phalcon/Mvc/Model/Query/Builder.zep", 705); - return; - } - } else { - if (UNEXPECTED(!zephir_is_true(&models))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "At least one model is required to build the query", "phalcon/Mvc/Model/Query/Builder.zep", 711); - return; - } - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("conditions"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&conditions, &_0); - if (zephir_is_numeric(&conditions)) { - if (Z_TYPE_P(&models) == IS_ARRAY) { - if (UNEXPECTED(zephir_fast_count_int(&models) > 1)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Cannot build the query. Invalid condition", "phalcon/Mvc/Model/Query/Builder.zep", 726); - return; +pp257: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp258; } - zephir_memory_observe(&model); - zephir_array_fetch_long(&model, &models, 0, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 729); - } else { - ZEPHIR_CPY_WRT(&model, &models); +pp258: + { + token->opcode = PHQL_T_LEFT; + return 0; } - ZEPHIR_INIT_VAR(&_1$$8); - ZVAL_STRING(&_1$$8, "modelsMetadata"); - ZEPHIR_CALL_METHOD(&metaData, &container, "getshared", NULL, 0, &_1$$8); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2$$8); - zephir_create_array(&_2$$8, 2, 0); - zephir_array_fast_append(&_2$$8, &__$null); - zephir_array_fast_append(&_2$$8, &container); - ZEPHIR_INIT_VAR(&modelInstance); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&modelInstance, &model, &_2$$8); - zephir_check_call_status(); - noPrimary = 1; - ZEPHIR_CALL_METHOD(&primaryKeys, &metaData, "getprimarykeyattributes", NULL, 0, &modelInstance); - zephir_check_call_status(); - if (zephir_fast_count_int(&primaryKeys)) { - zephir_memory_observe(&firstPrimaryKey); - if (zephir_array_isset_long_fetch(&firstPrimaryKey, &primaryKeys, 0, 0)) { - if (ZEPHIR_GLOBAL(orm).column_renaming) { - ZEPHIR_CALL_METHOD(&columnMap, &metaData, "getcolumnmap", NULL, 0, &modelInstance); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&columnMap); - ZVAL_NULL(&columnMap); - } - if (Z_TYPE_P(&columnMap) == IS_ARRAY) { - zephir_memory_observe(&attributeField); - if (UNEXPECTED(!(zephir_array_isset_fetch(&attributeField, &columnMap, &firstPrimaryKey, 0)))) { - ZEPHIR_INIT_VAR(&_3$$17); - object_init_ex(&_3$$17, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_4$$17); - ZEPHIR_CONCAT_SVS(&_4$$17, "Column '", &firstPrimaryKey, "' isn't part of the column map"); - ZEPHIR_CALL_METHOD(NULL, &_3$$17, "__construct", NULL, 33, &_4$$17); - zephir_check_call_status(); - zephir_throw_exception_debug(&_3$$17, "phalcon/Mvc/Model/Query/Builder.zep", 765); - ZEPHIR_MM_RESTORE(); - return; - } - } else { - ZEPHIR_CPY_WRT(&attributeField, &firstPrimaryKey); - } - if (Z_TYPE_P(&conditions) == IS_STRING) { - ZEPHIR_INIT_VAR(&_5$$19); - ZEPHIR_CONCAT_SVS(&_5$$19, "'", &conditions, "'"); - ZEPHIR_CPY_WRT(&conditions, &_5$$19); - } - ZEPHIR_CALL_METHOD(&_6$$13, this_ptr, "autoescape", NULL, 478, &model); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_7$$13, this_ptr, "autoescape", NULL, 478, &attributeField); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_8$$13); - ZEPHIR_CONCAT_VSVSV(&_8$$13, &_6$$13, ".", &_7$$13, " = ", &conditions); - ZEPHIR_CPY_WRT(&conditions, &_8$$13); - noPrimary = 0; +pp259: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp260; } +pp260: + { + token->opcode = PHQL_T_LIKE; + return 0; } - if (UNEXPECTED(noPrimary)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "Source related to this model does not have a primary key defined", "phalcon/Mvc/Model/Query/Builder.zep", 792); - return; - } - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("distinct"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&distinct, &_0); - if (((Z_TYPE_P(&distinct) == IS_TRUE || Z_TYPE_P(&distinct) == IS_FALSE) == 1)) { - ZEPHIR_INIT_VAR(&phql); - if (zephir_is_true(&distinct)) { - ZVAL_STRING(&phql, "SELECT DISTINCT "); - } else { - ZVAL_STRING(&phql, "SELECT ALL "); - } - } else { - ZEPHIR_INIT_NVAR(&phql); - ZVAL_STRING(&phql, "SELECT "); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("columns"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&columns, &_0); - if (Z_TYPE_P(&columns) != IS_NULL) { - if (Z_TYPE_P(&columns) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&selectedColumns); - array_init(&selectedColumns); - zephir_is_iterable(&columns, 0, "phalcon/Mvc/Model/Query/Builder.zep", 825); - if (Z_TYPE_P(&columns) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&columns), _11$$26, _12$$26, _9$$26) - { - ZEPHIR_INIT_NVAR(&columnAlias); - if (_12$$26 != NULL) { - ZVAL_STR_COPY(&columnAlias, _12$$26); - } else { - ZVAL_LONG(&columnAlias, _11$$26); - } - ZEPHIR_INIT_NVAR(&column); - ZVAL_COPY(&column, _9$$26); - if (Z_TYPE_P(&columnAlias) == IS_LONG) { - zephir_array_append(&selectedColumns, &column, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 819); - } else { - ZEPHIR_CALL_METHOD(&_13$$29, this_ptr, "autoescape", NULL, 478, &columnAlias); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_14$$29); - ZEPHIR_CONCAT_VSV(&_14$$29, &column, " AS ", &_13$$29); - zephir_array_append(&selectedColumns, &_14$$29, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 821); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_10$$26, &columns, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_10$$26)) { - break; - } - ZEPHIR_CALL_METHOD(&columnAlias, &columns, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&column, &columns, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&columnAlias) == IS_LONG) { - zephir_array_append(&selectedColumns, &column, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 819); - } else { - ZEPHIR_CALL_METHOD(&_15$$32, this_ptr, "autoescape", NULL, 478, &columnAlias); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_16$$32); - ZEPHIR_CONCAT_VSV(&_16$$32, &column, " AS ", &_15$$32); - zephir_array_append(&selectedColumns, &_16$$32, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 821); - } - ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); - zephir_check_call_status(); - } +pp261: + ppch = *++PPCURSOR; + switch (ppch) { + case 'T': + case 't': goto pp300; + default: goto pp59; } - ZEPHIR_INIT_NVAR(&column); - ZEPHIR_INIT_NVAR(&columnAlias); - ZEPHIR_INIT_VAR(&_17$$26); - zephir_fast_join_str(&_17$$26, SL(", "), &selectedColumns); - zephir_concat_self(&phql, &_17$$26); - } else { - zephir_concat_self(&phql, &columns); - } - } else { - if (Z_TYPE_P(&models) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&selectedColumns); - array_init(&selectedColumns); - zephir_is_iterable(&models, 0, "phalcon/Mvc/Model/Query/Builder.zep", 846); - if (Z_TYPE_P(&models) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&models), _20$$35, _21$$35, _18$$35) - { - ZEPHIR_INIT_NVAR(&modelColumnAlias); - if (_21$$35 != NULL) { - ZVAL_STR_COPY(&modelColumnAlias, _21$$35); - } else { - ZVAL_LONG(&modelColumnAlias, _20$$35); - } - ZEPHIR_INIT_NVAR(&model); - ZVAL_COPY(&model, _18$$35); - ZEPHIR_INIT_NVAR(&selectedColumn); - if (Z_TYPE_P(&modelColumnAlias) == IS_LONG) { - ZEPHIR_CALL_METHOD(&_22$$37, this_ptr, "autoescape", NULL, 478, &model); - zephir_check_call_status(); - ZEPHIR_CONCAT_VS(&selectedColumn, &_22$$37, ".*"); - } else { - ZEPHIR_CALL_METHOD(&_23$$38, this_ptr, "autoescape", NULL, 478, &modelColumnAlias); - zephir_check_call_status(); - ZEPHIR_CONCAT_VS(&selectedColumn, &_23$$38, ".*"); - } - zephir_array_append(&selectedColumns, &selectedColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 843); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &models, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_19$$35, &models, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_19$$35)) { - break; - } - ZEPHIR_CALL_METHOD(&modelColumnAlias, &models, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&model, &models, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&selectedColumn); - if (Z_TYPE_P(&modelColumnAlias) == IS_LONG) { - ZEPHIR_CALL_METHOD(&_24$$40, this_ptr, "autoescape", NULL, 478, &model); - zephir_check_call_status(); - ZEPHIR_CONCAT_VS(&selectedColumn, &_24$$40, ".*"); - } else { - ZEPHIR_CALL_METHOD(&_25$$41, this_ptr, "autoescape", NULL, 478, &modelColumnAlias); - zephir_check_call_status(); - ZEPHIR_CONCAT_VS(&selectedColumn, &_25$$41, ".*"); - } - zephir_array_append(&selectedColumns, &selectedColumn, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 843); - ZEPHIR_CALL_METHOD(NULL, &models, "next", NULL, 0); - zephir_check_call_status(); - } +pp262: + ppch = *++PPCURSOR; + switch (ppch) { + case 'B': + case 'b': goto pp302; + default: goto pp86; } - ZEPHIR_INIT_NVAR(&model); - ZEPHIR_INIT_NVAR(&modelColumnAlias); - ZEPHIR_INIT_VAR(&_26$$35); - zephir_fast_join_str(&_26$$35, SL(", "), &selectedColumns); - zephir_concat_self(&phql, &_26$$35); - } else { - ZEPHIR_CALL_METHOD(&_27$$42, this_ptr, "autoescape", NULL, 478, &models); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_28$$42); - ZEPHIR_CONCAT_VS(&_28$$42, &_27$$42, ".*"); - zephir_concat_self(&phql, &_28$$42); - } - } - if (Z_TYPE_P(&models) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&selectedModels); - array_init(&selectedModels); - zephir_is_iterable(&models, 0, "phalcon/Mvc/Model/Query/Builder.zep", 868); - if (Z_TYPE_P(&models) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&models), _31$$43, _32$$43, _29$$43) - { - ZEPHIR_INIT_NVAR(&modelAlias); - if (_32$$43 != NULL) { - ZVAL_STR_COPY(&modelAlias, _32$$43); - } else { - ZVAL_LONG(&modelAlias, _31$$43); - } - ZEPHIR_INIT_NVAR(&model); - ZVAL_COPY(&model, _29$$43); - if (Z_TYPE_P(&modelAlias) == IS_STRING) { - ZEPHIR_CALL_METHOD(&_33$$45, this_ptr, "autoescape", NULL, 478, &model); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_34$$45, this_ptr, "autoescape", NULL, 478, &modelAlias); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&selectedModel); - ZEPHIR_CONCAT_VSV(&selectedModel, &_33$$45, " AS ", &_34$$45); - } else { - ZEPHIR_CALL_METHOD(&selectedModel, this_ptr, "autoescape", NULL, 478, &model); - zephir_check_call_status(); - } - zephir_array_append(&selectedModels, &selectedModel, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 865); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &models, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_30$$43, &models, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_30$$43)) { - break; - } - ZEPHIR_CALL_METHOD(&modelAlias, &models, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&model, &models, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&modelAlias) == IS_STRING) { - ZEPHIR_CALL_METHOD(&_35$$48, this_ptr, "autoescape", NULL, 478, &model); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_36$$48, this_ptr, "autoescape", NULL, 478, &modelAlias); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&selectedModel); - ZEPHIR_CONCAT_VSV(&selectedModel, &_35$$48, " AS ", &_36$$48); - } else { - ZEPHIR_CALL_METHOD(&selectedModel, this_ptr, "autoescape", NULL, 478, &model); - zephir_check_call_status(); - } - zephir_array_append(&selectedModels, &selectedModel, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 865); - ZEPHIR_CALL_METHOD(NULL, &models, "next", NULL, 0); - zephir_check_call_status(); +pp263: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp264; } - } - ZEPHIR_INIT_NVAR(&model); - ZEPHIR_INIT_NVAR(&modelAlias); - ZEPHIR_INIT_VAR(&_37$$43); - zephir_fast_join_str(&_37$$43, SL(", "), &selectedModels); - ZEPHIR_INIT_VAR(&_38$$43); - ZEPHIR_CONCAT_SV(&_38$$43, " FROM ", &_37$$43); - zephir_concat_self(&phql, &_38$$43); - } else { - ZEPHIR_CALL_METHOD(&_39$$50, this_ptr, "autoescape", NULL, 478, &models); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_40$$50); - ZEPHIR_CONCAT_SV(&_40$$50, " FROM ", &_39$$50); - zephir_concat_self(&phql, &_40$$50); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("joins"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&joins, &_0); - if (Z_TYPE_P(&joins) == IS_ARRAY) { - zephir_is_iterable(&joins, 0, "phalcon/Mvc/Model/Query/Builder.zep", 923); - if (Z_TYPE_P(&joins) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&joins), _41$$51) +pp264: { - ZEPHIR_INIT_NVAR(&join); - ZVAL_COPY(&join, _41$$51); - ZEPHIR_OBS_NVAR(&joinModel); - zephir_array_fetch_long(&joinModel, &join, 0, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 883); - ZEPHIR_OBS_NVAR(&joinConditions); - zephir_array_fetch_long(&joinConditions, &join, 1, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 888); - ZEPHIR_OBS_NVAR(&joinAlias); - zephir_array_fetch_long(&joinAlias, &join, 2, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 893); - ZEPHIR_OBS_NVAR(&joinType); - zephir_array_fetch_long(&joinType, &join, 3, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 898); - if (zephir_is_true(&joinType)) { - ZEPHIR_CALL_METHOD(&_43$$53, this_ptr, "autoescape", NULL, 478, &joinModel); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_44$$53); - ZEPHIR_CONCAT_SVSV(&_44$$53, " ", &joinType, " JOIN ", &_43$$53); - zephir_concat_self(&phql, &_44$$53); - } else { - ZEPHIR_CALL_METHOD(&_45$$54, this_ptr, "autoescape", NULL, 478, &joinModel); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_46$$54); - ZEPHIR_CONCAT_SV(&_46$$54, " JOIN ", &_45$$54); - zephir_concat_self(&phql, &_46$$54); - } - if (zephir_is_true(&joinAlias)) { - ZEPHIR_CALL_METHOD(&_47$$55, this_ptr, "autoescape", NULL, 478, &joinAlias); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_48$$55); - ZEPHIR_CONCAT_SV(&_48$$55, " AS ", &_47$$55); - zephir_concat_self(&phql, &_48$$55); - } - if (zephir_is_true(&joinConditions)) { - ZEPHIR_INIT_NVAR(&_49$$56); - ZEPHIR_CONCAT_SV(&_49$$56, " ON ", &joinConditions); - zephir_concat_self(&phql, &_49$$56); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &joins, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_42$$51, &joins, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_42$$51)) { - break; - } - ZEPHIR_CALL_METHOD(&join, &joins, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&joinModel); - zephir_array_fetch_long(&joinModel, &join, 0, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 883); - ZEPHIR_OBS_NVAR(&joinConditions); - zephir_array_fetch_long(&joinConditions, &join, 1, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 888); - ZEPHIR_OBS_NVAR(&joinAlias); - zephir_array_fetch_long(&joinAlias, &join, 2, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 893); - ZEPHIR_OBS_NVAR(&joinType); - zephir_array_fetch_long(&joinType, &join, 3, PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 898); - if (zephir_is_true(&joinType)) { - ZEPHIR_CALL_METHOD(&_50$$58, this_ptr, "autoescape", NULL, 478, &joinModel); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_51$$58); - ZEPHIR_CONCAT_SVSV(&_51$$58, " ", &joinType, " JOIN ", &_50$$58); - zephir_concat_self(&phql, &_51$$58); - } else { - ZEPHIR_CALL_METHOD(&_52$$59, this_ptr, "autoescape", NULL, 478, &joinModel); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_53$$59); - ZEPHIR_CONCAT_SV(&_53$$59, " JOIN ", &_52$$59); - zephir_concat_self(&phql, &_53$$59); - } - if (zephir_is_true(&joinAlias)) { - ZEPHIR_CALL_METHOD(&_54$$60, this_ptr, "autoescape", NULL, 478, &joinAlias); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_55$$60); - ZEPHIR_CONCAT_SV(&_55$$60, " AS ", &_54$$60); - zephir_concat_self(&phql, &_55$$60); - } - if (zephir_is_true(&joinConditions)) { - ZEPHIR_INIT_NVAR(&_56$$61); - ZEPHIR_CONCAT_SV(&_56$$61, " ON ", &joinConditions); - zephir_concat_self(&phql, &_56$$61); - } - ZEPHIR_CALL_METHOD(NULL, &joins, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&join); - } - if (Z_TYPE_P(&conditions) == IS_STRING) { - if (!(ZEPHIR_IS_EMPTY(&conditions))) { - ZEPHIR_INIT_VAR(&_57$$63); - ZEPHIR_CONCAT_SV(&_57$$63, " WHERE ", &conditions); - zephir_concat_self(&phql, &_57$$63); + token->opcode = PHQL_T_NULL; + return 0; } - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("group"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&group, &_0); - if (!(ZEPHIR_IS_EMPTY(&group))) { - ZEPHIR_INIT_VAR(&groupItems); - array_init(&groupItems); - zephir_is_iterable(&group, 0, "phalcon/Mvc/Model/Query/Builder.zep", 943); - if (Z_TYPE_P(&group) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&group), _58$$64) +pp265: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp303; + default: goto pp59; + } +pp266: + ppch = *++PPCURSOR; + switch (ppch) { + case 'R': + case 'r': goto pp304; + default: goto pp59; + } +pp267: + ppch = *++PPCURSOR; + switch (ppch) { + case 'R': + case 'r': goto pp306; + default: goto pp59; + } +pp268: + ppch = *++PPCURSOR; + switch (ppch) { + case 'T': + case 't': goto pp308; + default: goto pp59; + } +pp269: + ppch = *++PPCURSOR; + switch (ppch) { + case 'C': + case 'c': goto pp310; + default: goto pp59; + } +pp270: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp271; + } +pp271: { - ZEPHIR_INIT_NVAR(&groupItem); - ZVAL_COPY(&groupItem, _58$$64); - ZEPHIR_CALL_METHOD(&_60$$65, this_ptr, "autoescape", NULL, 478, &groupItem); - zephir_check_call_status(); - zephir_array_append(&groupItems, &_60$$65, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 940); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &group, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_59$$64, &group, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_59$$64)) { - break; - } - ZEPHIR_CALL_METHOD(&groupItem, &group, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_61$$66, this_ptr, "autoescape", NULL, 478, &groupItem); - zephir_check_call_status(); - zephir_array_append(&groupItems, &_61$$66, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 940); - ZEPHIR_CALL_METHOD(NULL, &group, "next", NULL, 0); - zephir_check_call_status(); + token->opcode = PHQL_T_THEN; + return 0; + } +pp272: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp273; } +pp273: + { + token->opcode = PHQL_T_TRUE; + return 0; } - ZEPHIR_INIT_NVAR(&groupItem); - ZEPHIR_INIT_VAR(&_62$$64); - zephir_fast_join_str(&_62$$64, SL(", "), &groupItems); - ZEPHIR_INIT_VAR(&_63$$64); - ZEPHIR_CONCAT_SV(&_63$$64, " GROUP BY ", &_62$$64); - zephir_concat_self(&phql, &_63$$64); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("having"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&having, &_0); - if (Z_TYPE_P(&having) != IS_NULL) { - if (!(ZEPHIR_IS_EMPTY(&having))) { - ZEPHIR_INIT_VAR(&_64$$68); - ZEPHIR_CONCAT_SV(&_64$$68, " HAVING ", &having); - zephir_concat_self(&phql, &_64$$68); +pp274: + ppch = *++PPCURSOR; + switch (ppch) { + case 'T': + case 't': goto pp311; + default: goto pp59; + } +pp275: + ppch = *++PPCURSOR; + switch (ppch) { + case 'G': + case 'g': goto pp312; + default: goto pp59; + } +pp276: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp314; + default: goto pp59; + } +pp277: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp278; + } +pp278: + { + token->opcode = PHQL_T_WHEN; + return 0; } - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("order"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&order, &_0); - if (Z_TYPE_P(&order) != IS_NULL) { - if (Z_TYPE_P(&order) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&orderItems); - array_init(&orderItems); - zephir_is_iterable(&order, 0, "phalcon/Mvc/Model/Query/Builder.zep", 987); - if (Z_TYPE_P(&order) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&order), _65$$70) - { - ZEPHIR_INIT_NVAR(&orderItem); - ZVAL_COPY(&orderItem, _65$$70); - if (Z_TYPE_P(&orderItem) == IS_LONG) { - zephir_array_append(&orderItems, &orderItem, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 970); - continue; - } - if (zephir_memnstr_str(&orderItem, SL(" "), "phalcon/Mvc/Model/Query/Builder.zep", 975) != 0) { - ZEPHIR_INIT_NVAR(&itemExplode$$73); - zephir_fast_explode_str(&itemExplode$$73, SL(" "), &orderItem, LONG_MAX); - zephir_array_fetch_long(&_68$$73, &itemExplode$$73, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query/Builder.zep", 979); - ZEPHIR_CALL_METHOD(&_67$$73, this_ptr, "autoescape", NULL, 478, &_68$$73); - zephir_check_call_status(); - zephir_array_fetch_long(&_69$$73, &itemExplode$$73, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query/Builder.zep", 979); - ZEPHIR_INIT_NVAR(&_70$$73); - ZEPHIR_CONCAT_VSV(&_70$$73, &_67$$73, " ", &_69$$73); - zephir_array_append(&orderItems, &_70$$73, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 979); - continue; - } - ZEPHIR_CALL_METHOD(&_71$$71, this_ptr, "autoescape", NULL, 478, &orderItem); - zephir_check_call_status(); - zephir_array_append(&orderItems, &_71$$71, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 984); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &order, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_66$$70, &order, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_66$$70)) { - break; - } - ZEPHIR_CALL_METHOD(&orderItem, &order, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&orderItem) == IS_LONG) { - zephir_array_append(&orderItems, &orderItem, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 970); - continue; - } - if (zephir_memnstr_str(&orderItem, SL(" "), "phalcon/Mvc/Model/Query/Builder.zep", 975) != 0) { - ZEPHIR_INIT_NVAR(&itemExplode$$76); - zephir_fast_explode_str(&itemExplode$$76, SL(" "), &orderItem, LONG_MAX); - zephir_array_fetch_long(&_73$$76, &itemExplode$$76, 0, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query/Builder.zep", 979); - ZEPHIR_CALL_METHOD(&_72$$76, this_ptr, "autoescape", NULL, 478, &_73$$76); - zephir_check_call_status(); - zephir_array_fetch_long(&_74$$76, &itemExplode$$76, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Model/Query/Builder.zep", 979); - ZEPHIR_INIT_NVAR(&_75$$76); - ZEPHIR_CONCAT_VSV(&_75$$76, &_72$$76, " ", &_74$$76); - zephir_array_append(&orderItems, &_75$$76, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 979); - continue; - } - ZEPHIR_CALL_METHOD(&_76$$74, this_ptr, "autoescape", NULL, 478, &orderItem); - zephir_check_call_status(); - zephir_array_append(&orderItems, &_76$$74, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 984); - ZEPHIR_CALL_METHOD(NULL, &order, "next", NULL, 0); - zephir_check_call_status(); - } +pp279: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp315; + default: goto pp59; } - ZEPHIR_INIT_NVAR(&orderItem); - ZEPHIR_INIT_VAR(&_77$$70); - zephir_fast_join_str(&_77$$70, SL(", "), &orderItems); - ZEPHIR_INIT_VAR(&_78$$70); - ZEPHIR_CONCAT_SV(&_78$$70, " ORDER BY ", &_77$$70); - zephir_concat_self(&phql, &_78$$70); - } else { - ZEPHIR_INIT_VAR(&_79$$77); - ZEPHIR_CONCAT_SV(&_79$$77, " ORDER BY ", &order); - zephir_concat_self(&phql, &_79$$77); +pp280: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp281; + } +pp281: + { + token->opcode = PHQL_T_WITH; + return 0; } - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("limit"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&limit, &_0); - if (Z_TYPE_P(&limit) != IS_NULL) { - ZEPHIR_INIT_VAR(&number); - ZVAL_NULL(&number); - if (Z_TYPE_P(&limit) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&number); - zephir_array_fetch_string(&number, &limit, SL("number"), PH_NOISY, "phalcon/Mvc/Model/Query/Builder.zep", 1001); - zephir_memory_observe(&offset); - if (zephir_array_isset_string_fetch(&offset, &limit, SL("offset"), 0)) { - if (!(zephir_is_numeric(&offset))) { - ZEPHIR_INIT_NVAR(&offset); - ZVAL_LONG(&offset, 0); - } +pp282: + ppch = *++PPCURSOR; + switch (ppch) { + case 'S': + case 's': goto pp317; + default: goto pp59; } - } else { - if (zephir_is_numeric(&limit)) { - ZEPHIR_CPY_WRT(&number, &limit); - zephir_read_property(&_80$$83, this_ptr, ZEND_STRL("offset"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&offset, &_80$$83); - if (Z_TYPE_P(&offset) != IS_NULL) { - if (!(zephir_is_numeric(&offset))) { - ZEPHIR_INIT_NVAR(&offset); - ZVAL_LONG(&offset, 0); - } - } +pp283: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp318; + default: goto pp59; + } +pp284: + ppch = *++PPCURSOR; + switch (ppch) { + case 'R': + case 'r': goto pp319; + default: goto pp59; + } +pp285: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp286; } +pp286: + { + token->opcode = PHQL_T_CROSS; + return 0; } - if (zephir_is_numeric(&number)) { - zephir_concat_self_str(&phql, SL(" LIMIT :APL0:")); - ZVAL_LONG(&_81$$86, 10); - ZEPHIR_CALL_FUNCTION(&_82$$86, "intval", NULL, 42, &number, &_81$$86); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_83$$86); - ZVAL_STRING(&_83$$86, "APL0"); - zephir_update_property_array(this_ptr, SL("bindParams"), &_83$$86, &_82$$86); - ZEPHIR_INIT_VAR(&_84$$86); - ZVAL_STRING(&_84$$86, "APL0"); - ZEPHIR_INIT_VAR(&_85$$86); - ZVAL_LONG(&_85$$86, 1); - zephir_update_property_array(this_ptr, SL("bindTypes"), &_84$$86, &_85$$86); - _86$$86 = zephir_is_numeric(&offset); - if (_86$$86) { - _86$$86 = !ZEPHIR_IS_LONG_IDENTICAL(&offset, 0); +pp287: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp320; + default: goto pp59; } - if (_86$$86) { - zephir_concat_self_str(&phql, SL(" OFFSET :APL1:")); - ZVAL_LONG(&_87$$87, 10); - ZEPHIR_CALL_FUNCTION(&_88$$87, "intval", NULL, 42, &offset, &_87$$87); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_89$$87); - ZVAL_STRING(&_89$$87, "APL1"); - zephir_update_property_array(this_ptr, SL("bindParams"), &_89$$87, &_88$$87); - ZEPHIR_INIT_VAR(&_90$$87); - ZVAL_STRING(&_90$$87, "APL1"); - ZEPHIR_INIT_VAR(&_91$$87); - ZVAL_LONG(&_91$$87, 1); - zephir_update_property_array(this_ptr, SL("bindTypes"), &_90$$87, &_91$$87); +pp288: + ppch = *++PPCURSOR; + switch (ppch) { + case 'N': + case 'n': goto pp322; + default: goto pp59; + } +pp289: + ppch = *++PPCURSOR; + switch (ppch) { + case 'S': + case 's': goto pp323; + default: goto pp59; + } +pp290: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp291; } +pp291: + { + token->opcode = PHQL_T_FALSE; + return 0; } - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("forUpdate"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&forUpdate, &_0); - if (((Z_TYPE_P(&forUpdate) == IS_TRUE || Z_TYPE_P(&forUpdate) == IS_FALSE) == 1)) { - if (zephir_is_true(&forUpdate)) { - zephir_concat_self_str(&phql, SL(" FOR UPDATE")); +pp292: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp293; + } +pp293: + { + token->opcode = PHQL_T_GROUP; + return 0; } - } - RETURN_CCTOR(&phql); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getQuery) -{ - zval _2; - zval query, bindParams, bindTypes, phql, container, _0, _1, _3, _4, _5$$6; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&query); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(&phql); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_2); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&phql, this_ptr, "getphql", NULL, 479); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "A dependency injection container is required to access the services related to the ORM", "phalcon/Mvc/Model/Query/Builder.zep", 1058); - return; - } - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 2, 0); - zephir_array_fast_append(&_2, &phql); - zephir_array_fast_append(&_2, &container); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "Phalcon\\Mvc\\Model\\Query"); - ZEPHIR_CALL_METHOD(&_1, &container, "get", NULL, 0, &_3, &_2); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&query, &_1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&bindParams, &_0); - if (Z_TYPE_P(&bindParams) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(NULL, &query, "setbindparams", NULL, 0, &bindParams); - zephir_check_call_status(); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&bindTypes, &_0); - if (Z_TYPE_P(&bindTypes) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(NULL, &query, "setbindtypes", NULL, 0, &bindTypes); - zephir_check_call_status(); - } - zephir_memory_observe(&_4); - zephir_read_property(&_4, this_ptr, ZEND_STRL("sharedLock"), PH_NOISY_CC); - if (((Z_TYPE_P(&_4) == IS_TRUE || Z_TYPE_P(&_4) == IS_FALSE) == 1)) { - zephir_read_property(&_5$$6, this_ptr, ZEND_STRL("sharedLock"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &query, "setsharedlock", NULL, 0, &_5$$6); - zephir_check_call_status(); - } - RETURN_CCTOR(&query); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, getWhere) -{ - - RETURN_MEMBER(getThis(), "conditions"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, groupBy) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *group = NULL, group_sub, _0$$4, _1$$4, _2$$4, _3$$3; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&group_sub); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(group) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &group); - ZEPHIR_SEPARATE_PARAM(group); - if (Z_TYPE_P(group) == IS_STRING) { - if (zephir_memnstr_str(group, SL(","), "phalcon/Mvc/Model/Query/Builder.zep", 1114)) { - ZEPHIR_INIT_VAR(&_0$$4); - ZEPHIR_INIT_VAR(&_1$$4); - ZVAL_STRING(&_1$$4, " "); - ZEPHIR_INIT_VAR(&_2$$4); - ZVAL_STRING(&_2$$4, ""); - zephir_fast_str_replace(&_0$$4, &_1$$4, &_2$$4, group); - ZEPHIR_CPY_WRT(group, &_0$$4); - } - ZEPHIR_INIT_VAR(&_3$$3); - zephir_fast_explode_str(&_3$$3, SL(","), group, LONG_MAX); - ZEPHIR_CPY_WRT(group, &_3$$3); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("group"), group); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, having) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval bindParams, bindTypes; - zval *conditions_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, currentBindParams, currentBindTypes, _0$$3, _1$$5; - zval conditions; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(¤tBindParams); - ZVAL_UNDEF(¤tBindTypes); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$5); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(conditions) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams_param, &bindTypes_param); - zephir_get_strval(&conditions, conditions_param); - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - } else { - zephir_get_arrval(&bindParams, bindParams_param); - } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - } else { - zephir_get_arrval(&bindTypes, bindTypes_param); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("having"), &conditions); - zephir_memory_observe(¤tBindParams); - zephir_read_property(¤tBindParams, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC); - if (Z_TYPE_P(¤tBindParams) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_0$$3); - zephir_add_function(&_0$$3, ¤tBindParams, &bindParams); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &_0$$3); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &bindParams); - } - zephir_memory_observe(¤tBindTypes); - zephir_read_property(¤tBindTypes, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC); - if (Z_TYPE_P(¤tBindTypes) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_1$$5); - zephir_add_function(&_1$$5, ¤tBindTypes, &bindTypes); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &_1$$5); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); - } - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, inHaving) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval values; - zval *expr_param = NULL, *values_param = NULL, *operator_param = NULL, _0; - zval expr, operator; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&values); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(expr) - Z_PARAM_ARRAY(values) - Z_PARAM_OPTIONAL - Z_PARAM_STR(operator) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &expr_param, &values_param, &operator_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); - if (!operator_param) { - ZEPHIR_INIT_VAR(&operator); - ZVAL_STRING(&operator, "and"); - } else { - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "Having"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionin", NULL, 0, &_0, &operator, &expr, &values); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, innerJoin) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model_param = NULL, *conditions_param = NULL, *alias_param = NULL, _1; - zval model, conditions, alias; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(model) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(conditions) - Z_PARAM_STR_OR_NULL(alias) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &model_param, &conditions_param, &alias_param); - if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { - zephir_get_strval(&model, model_param); - } else { - ZEPHIR_INIT_VAR(&model); - } - if (!conditions_param) { - ZEPHIR_INIT_VAR(&conditions); - } else { - zephir_get_strval(&conditions, conditions_param); - } - if (!alias_param) { - ZEPHIR_INIT_VAR(&alias); - } else { - zephir_get_strval(&alias, alias_param); - } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 4, 0); - zephir_array_fast_append(&_0, &model); - zephir_array_fast_append(&_0, &conditions); - zephir_array_fast_append(&_0, &alias); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "INNER"); - zephir_array_fast_append(&_0, &_1); - zephir_update_property_array_append(this_ptr, SL("joins"), &_0); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, inWhere) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval values; - zval *expr_param = NULL, *values_param = NULL, *operator_param = NULL, _0; - zval expr, operator; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&values); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(expr) - Z_PARAM_ARRAY(values) - Z_PARAM_OPTIONAL - Z_PARAM_STR(operator) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &expr_param, &values_param, &operator_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); - if (!operator_param) { - ZEPHIR_INIT_VAR(&operator); - ZVAL_STRING(&operator, "and"); - } else { - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "Where"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionin", NULL, 0, &_0, &operator, &expr, &values); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, join) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model_param = NULL, *conditions_param = NULL, *alias_param = NULL, *type_param = NULL; - zval model, conditions, alias, type; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_STR(model) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(conditions) - Z_PARAM_STR_OR_NULL(alias) - Z_PARAM_STR_OR_NULL(type) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 3, &model_param, &conditions_param, &alias_param, &type_param); - if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { - zephir_get_strval(&model, model_param); - } else { - ZEPHIR_INIT_VAR(&model); - } - if (!conditions_param) { - ZEPHIR_INIT_VAR(&conditions); - } else { - zephir_get_strval(&conditions, conditions_param); - } - if (!alias_param) { - ZEPHIR_INIT_VAR(&alias); - } else { - zephir_get_strval(&alias, alias_param); - } - if (!type_param) { - ZEPHIR_INIT_VAR(&type); - } else { - zephir_get_strval(&type, type_param); - } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 4, 0); - zephir_array_fast_append(&_0, &model); - zephir_array_fast_append(&_0, &conditions); - zephir_array_fast_append(&_0, &alias); - zephir_array_fast_append(&_0, &type); - zephir_update_property_array_append(this_ptr, SL("joins"), &_0); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, leftJoin) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model_param = NULL, *conditions_param = NULL, *alias_param = NULL, _1; - zval model, conditions, alias; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(model) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(conditions) - Z_PARAM_STR_OR_NULL(alias) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &model_param, &conditions_param, &alias_param); - if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { - zephir_get_strval(&model, model_param); - } else { - ZEPHIR_INIT_VAR(&model); - } - if (!conditions_param) { - ZEPHIR_INIT_VAR(&conditions); - } else { - zephir_get_strval(&conditions, conditions_param); - } - if (!alias_param) { - ZEPHIR_INIT_VAR(&alias); - } else { - zephir_get_strval(&alias, alias_param); - } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 4, 0); - zephir_array_fast_append(&_0, &model); - zephir_array_fast_append(&_0, &conditions); - zephir_array_fast_append(&_0, &alias); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "LEFT"); - zephir_array_fast_append(&_0, &_1); - zephir_update_property_array_append(this_ptr, SL("joins"), &_0); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, limit) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *limit_param = NULL, *offset = NULL, offset_sub, __$null, _0, _1, _2$$4, _3$$4; - zend_long limit, ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&offset_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_LONG(limit) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(offset) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &limit_param, &offset); - if (!offset) { - offset = &offset_sub; - offset = &__$null; - } - ZVAL_LONG(&_0, limit); - ZEPHIR_CALL_FUNCTION(&_1, "abs", NULL, 284, &_0); - zephir_check_call_status(); - limit = zephir_get_numberval(&_1); - if (UNEXPECTED(limit == 0)) { - RETURN_THIS(); - } - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, limit); - zephir_update_property_zval(this_ptr, ZEND_STRL("limit"), &_0); - if (zephir_is_numeric(offset)) { - ZVAL_LONG(&_2$$4, zephir_get_intval(offset)); - ZEPHIR_CALL_FUNCTION(&_3$$4, "abs", NULL, 284, &_2$$4); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("offset"), &_3$$4); - } - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, notBetweenHaving) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, *operator_param = NULL, _0; - zval expr, operator; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&minimum_sub); - ZVAL_UNDEF(&maximum_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_STR(expr) - Z_PARAM_ZVAL(minimum) - Z_PARAM_ZVAL(maximum) - Z_PARAM_OPTIONAL - Z_PARAM_STR(operator) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 1, &expr_param, &minimum, &maximum, &operator_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - if (!operator_param) { - ZEPHIR_INIT_VAR(&operator); - ZVAL_STRING(&operator, "and"); - } else { - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "Having"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionnotbetween", NULL, 0, &_0, &operator, &expr, minimum, maximum); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, notBetweenWhere) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, *operator_param = NULL, _0; - zval expr, operator; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&minimum_sub); - ZVAL_UNDEF(&maximum_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_STR(expr) - Z_PARAM_ZVAL(minimum) - Z_PARAM_ZVAL(maximum) - Z_PARAM_OPTIONAL - Z_PARAM_STR(operator) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 1, &expr_param, &minimum, &maximum, &operator_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - if (!operator_param) { - ZEPHIR_INIT_VAR(&operator); - ZVAL_STRING(&operator, "and"); - } else { - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "Where"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionnotbetween", NULL, 0, &_0, &operator, &expr, minimum, maximum); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, notInHaving) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval values; - zval *expr_param = NULL, *values_param = NULL, *operator_param = NULL, _0; - zval expr, operator; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&values); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(expr) - Z_PARAM_ARRAY(values) - Z_PARAM_OPTIONAL - Z_PARAM_STR(operator) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &expr_param, &values_param, &operator_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); - if (!operator_param) { - ZEPHIR_INIT_VAR(&operator); - ZVAL_STRING(&operator, "and"); - } else { - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "Having"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionnotin", NULL, 0, &_0, &operator, &expr, &values); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, notInWhere) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval values; - zval *expr_param = NULL, *values_param = NULL, *operator_param = NULL, _0; - zval expr, operator; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&values); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(expr) - Z_PARAM_ARRAY(values) - Z_PARAM_OPTIONAL - Z_PARAM_STR(operator) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &expr_param, &values_param, &operator_param); - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); - if (!operator_param) { - ZEPHIR_INIT_VAR(&operator); - ZVAL_STRING(&operator, "and"); - } else { - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "Where"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "conditionnotin", NULL, 0, &_0, &operator, &expr, &values); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, offset) -{ - zval *offset_param = NULL, _0; - zend_long offset; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(offset) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &offset_param); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, offset); - zephir_update_property_zval(this_ptr, ZEND_STRL("offset"), &_0); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, orderBy) -{ - zval *orderBy, orderBy_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&orderBy_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(orderBy) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &orderBy); - zephir_update_property_zval(this_ptr, ZEND_STRL("order"), orderBy); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, orHaving) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval bindParams, bindTypes; - zval *conditions_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, currentConditions, _0$$3; - zval conditions; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(¤tConditions); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(conditions) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams_param, &bindTypes_param); - if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { - zephir_get_strval(&conditions, conditions_param); - } else { - ZEPHIR_INIT_VAR(&conditions); - } - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - } else { - zephir_get_arrval(&bindParams, bindParams_param); - } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - } else { - zephir_get_arrval(&bindTypes, bindTypes_param); - } - zephir_memory_observe(¤tConditions); - zephir_read_property(¤tConditions, this_ptr, ZEND_STRL("having"), PH_NOISY_CC); - if (zephir_is_true(¤tConditions)) { - ZEPHIR_INIT_VAR(&_0$$3); - ZEPHIR_CONCAT_SVSVS(&_0$$3, "(", ¤tConditions, ") OR (", &conditions, ")"); - zephir_get_strval(&conditions, &_0$$3); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "having", NULL, 0, &conditions, &bindParams, &bindTypes); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, orWhere) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval bindParams, bindTypes; - zval *conditions_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, currentConditions, _0$$3; - zval conditions; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(¤tConditions); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(conditions) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams_param, &bindTypes_param); - if (UNEXPECTED(Z_TYPE_P(conditions_param) != IS_STRING && Z_TYPE_P(conditions_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'conditions' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(conditions_param) == IS_STRING)) { - zephir_get_strval(&conditions, conditions_param); - } else { - ZEPHIR_INIT_VAR(&conditions); - } - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - } else { - zephir_get_arrval(&bindParams, bindParams_param); - } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - } else { - zephir_get_arrval(&bindTypes, bindTypes_param); - } - zephir_memory_observe(¤tConditions); - zephir_read_property(¤tConditions, this_ptr, ZEND_STRL("conditions"), PH_NOISY_CC); - if (zephir_is_true(¤tConditions)) { - ZEPHIR_INIT_VAR(&_0$$3); - ZEPHIR_CONCAT_SVSVS(&_0$$3, "(", ¤tConditions, ") OR (", &conditions, ")"); - zephir_get_strval(&conditions, &_0$$3); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "where", NULL, 0, &conditions, &bindParams, &bindTypes); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, rightJoin) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *model_param = NULL, *conditions_param = NULL, *alias_param = NULL, _1; - zval model, conditions, alias; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&model); - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(model) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(conditions) - Z_PARAM_STR_OR_NULL(alias) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &model_param, &conditions_param, &alias_param); - if (UNEXPECTED(Z_TYPE_P(model_param) != IS_STRING && Z_TYPE_P(model_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'model' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(model_param) == IS_STRING)) { - zephir_get_strval(&model, model_param); - } else { - ZEPHIR_INIT_VAR(&model); - } - if (!conditions_param) { - ZEPHIR_INIT_VAR(&conditions); - } else { - zephir_get_strval(&conditions, conditions_param); - } - if (!alias_param) { - ZEPHIR_INIT_VAR(&alias); - } else { - zephir_get_strval(&alias, alias_param); - } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 4, 0); - zephir_array_fast_append(&_0, &model); - zephir_array_fast_append(&_0, &conditions); - zephir_array_fast_append(&_0, &alias); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "RIGHT"); - zephir_array_fast_append(&_0, &_1); - zephir_update_property_array_append(this_ptr, SL("joins"), &_0); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, setBindParams) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool merge; - zval *bindParams_param = NULL, *merge_param = NULL, currentBindParams, _0$$4; - zval bindParams; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(¤tBindParams); - ZVAL_UNDEF(&_0$$4); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(bindParams) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(merge) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &bindParams_param, &merge_param); - ZEPHIR_OBS_COPY_OR_DUP(&bindParams, bindParams_param); - if (!merge_param) { - merge = 0; - } else { - } - if (merge) { - zephir_memory_observe(¤tBindParams); - zephir_read_property(¤tBindParams, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC); - if (Z_TYPE_P(¤tBindParams) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_0$$4); - zephir_add_function(&_0$$4, ¤tBindParams, &bindParams); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &_0$$4); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &bindParams); - } - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &bindParams); - } - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, setBindTypes) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool merge; - zval *bindTypes_param = NULL, *merge_param = NULL, currentBindTypes, _0$$4; - zval bindTypes; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&bindTypes); - ZVAL_UNDEF(¤tBindTypes); - ZVAL_UNDEF(&_0$$4); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(bindTypes) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(merge) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &bindTypes_param, &merge_param); - ZEPHIR_OBS_COPY_OR_DUP(&bindTypes, bindTypes_param); - if (!merge_param) { - merge = 0; - } else { - } - if (UNEXPECTED(merge)) { - zephir_memory_observe(¤tBindTypes); - zephir_read_property(¤tBindTypes, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC); - if (Z_TYPE_P(¤tBindTypes) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_0$$4); - zephir_add_function(&_0$$4, ¤tBindTypes, &bindTypes); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &_0$$4); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); +pp294: + ppch = *++PPCURSOR; + switch (ppch) { + case 'G': + case 'g': goto pp325; + default: goto pp59; + } +pp295: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp296; + } +pp296: + { + token->opcode = PHQL_T_ILIKE; + return 0; } - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); - } - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, setDI) -{ - zval *container, container_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &container); - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, where) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval bindParams, bindTypes; - zval *conditions_param = NULL, *bindParams_param = NULL, *bindTypes_param = NULL, currentBindParams, currentBindTypes, _0$$4, _1$$7; - zval conditions; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&conditions); - ZVAL_UNDEF(¤tBindParams); - ZVAL_UNDEF(¤tBindTypes); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$7); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&bindTypes); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(conditions) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(bindParams) - Z_PARAM_ARRAY(bindTypes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &conditions_param, &bindParams_param, &bindTypes_param); - zephir_get_strval(&conditions, conditions_param); - if (!bindParams_param) { - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - } else { - zephir_get_arrval(&bindParams, bindParams_param); - } - if (!bindTypes_param) { - ZEPHIR_INIT_VAR(&bindTypes); - array_init(&bindTypes); - } else { - zephir_get_arrval(&bindTypes, bindTypes_param); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("conditions"), &conditions); - if (zephir_fast_count_int(&bindParams) > 0) { - zephir_memory_observe(¤tBindParams); - zephir_read_property(¤tBindParams, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC); - if (Z_TYPE_P(¤tBindParams) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_0$$4); - zephir_add_function(&_0$$4, ¤tBindParams, &bindParams); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &_0$$4); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindParams"), &bindParams); - } - } - if (zephir_fast_count_int(&bindTypes) > 0) { - zephir_read_property(¤tBindTypes, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(¤tBindTypes) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_1$$7); - zephir_add_function(&_1$$7, ¤tBindTypes, &bindTypes); - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &_1$$7); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindTypes"), &bindTypes); - } - } - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, conditionBetween) -{ - zval _6; - zend_bool _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *clause_param = NULL, *operator_param = NULL, *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, hiddenParam, nextHiddenParam, minimumKey, maximumKey, operatorMethod, _5, _1$$3, _2$$3, _3$$3; - zval clause, operator, expr, _4; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&clause); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&minimum_sub); - ZVAL_UNDEF(&maximum_sub); - ZVAL_UNDEF(&hiddenParam); - ZVAL_UNDEF(&nextHiddenParam); - ZVAL_UNDEF(&minimumKey); - ZVAL_UNDEF(&maximumKey); - ZVAL_UNDEF(&operatorMethod); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_6); - ZEND_PARSE_PARAMETERS_START(5, 5) - Z_PARAM_STR(clause) - Z_PARAM_STR(operator) - Z_PARAM_STR(expr) - Z_PARAM_ZVAL(minimum) - Z_PARAM_ZVAL(maximum) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 5, 0, &clause_param, &operator_param, &expr_param, &minimum, &maximum); - if (UNEXPECTED(Z_TYPE_P(clause_param) != IS_STRING && Z_TYPE_P(clause_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'clause' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(clause_param) == IS_STRING)) { - zephir_get_strval(&clause, clause_param); - } else { - ZEPHIR_INIT_VAR(&clause); - } - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "and"); - if (_0) { - _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "or"); - } - if (UNEXPECTED(_0)) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "Operator % is not available."); - ZEPHIR_CALL_FUNCTION(&_3$$3, "sprintf", NULL, 117, &_2$$3, &operator); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_3$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model/Query/Builder.zep", 1597); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_VAR(&_4); - ZEPHIR_CONCAT_VV(&_4, &operator, &clause); - ZEPHIR_CPY_WRT(&operatorMethod, &_4); - zephir_memory_observe(&hiddenParam); - zephir_read_property(&hiddenParam, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&nextHiddenParam); - ZVAL_LONG(&nextHiddenParam, (zephir_get_numberval(&hiddenParam) + 1)); - ZEPHIR_INIT_VAR(&minimumKey); - ZEPHIR_CONCAT_SV(&minimumKey, "AP", &hiddenParam); - ZEPHIR_INIT_VAR(&maximumKey); - ZEPHIR_CONCAT_SV(&maximumKey, "AP", &nextHiddenParam); - ZEPHIR_INIT_VAR(&_5); - ZEPHIR_CONCAT_VSVSVS(&_5, &expr, " BETWEEN :", &minimumKey, ": AND :", &maximumKey, ":"); - ZEPHIR_INIT_VAR(&_6); - zephir_create_array(&_6, 2, 0); - zephir_array_update_zval(&_6, &minimumKey, minimum, PH_COPY); - zephir_array_update_zval(&_6, &maximumKey, maximum, PH_COPY); - ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &operatorMethod, NULL, 0, &_5, &_6); - zephir_check_call_status(); - SEPARATE_ZVAL(&nextHiddenParam); - zephir_increment(&nextHiddenParam); - zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &nextHiddenParam); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, conditionIn) -{ - zend_bool _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, hiddenParam = 0; - zval values; - zval *clause_param = NULL, *operator_param = NULL, *expr_param = NULL, *values_param = NULL, key, queryKey, value, bindKeys, bindParams, operatorMethod, _6, *_7, _8, _13, _14, _15, _1$$3, _2$$3, _3$$3, _9$$5, _11$$6; - zval clause, operator, expr, _4, _5$$4, _10$$5, _12$$6; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&clause); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_10$$5); - ZVAL_UNDEF(&_12$$6); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&queryKey); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&bindKeys); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&operatorMethod); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_13); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_15); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_9$$5); - ZVAL_UNDEF(&_11$$6); - ZVAL_UNDEF(&values); - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_STR(clause) - Z_PARAM_STR(operator) - Z_PARAM_STR(expr) - Z_PARAM_ARRAY(values) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 0, &clause_param, &operator_param, &expr_param, &values_param); - if (UNEXPECTED(Z_TYPE_P(clause_param) != IS_STRING && Z_TYPE_P(clause_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'clause' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(clause_param) == IS_STRING)) { - zephir_get_strval(&clause, clause_param); - } else { - ZEPHIR_INIT_VAR(&clause); - } - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); - _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "and"); - if (_0) { - _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "or"); - } - if (UNEXPECTED(_0)) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "Operator % is not available."); - ZEPHIR_CALL_FUNCTION(&_3$$3, "sprintf", NULL, 117, &_2$$3, &operator); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_3$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model/Query/Builder.zep", 1645); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_VAR(&_4); - ZEPHIR_CONCAT_VV(&_4, &operator, &clause); - ZEPHIR_CPY_WRT(&operatorMethod, &_4); - if (!(zephir_fast_count_int(&values))) { - ZEPHIR_INIT_VAR(&_5$$4); - ZEPHIR_CONCAT_VSV(&_5$$4, &expr, " != ", &expr); - ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &operatorMethod, NULL, 0, &_5$$4); - zephir_check_call_status(); - RETURN_THIS(); - } - zephir_memory_observe(&_6); - zephir_read_property(&_6, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); - hiddenParam = zephir_get_intval(&_6); - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - ZEPHIR_INIT_VAR(&bindKeys); - array_init(&bindKeys); - zephir_is_iterable(&values, 0, "phalcon/Mvc/Model/Query/Builder.zep", 1676); - if (Z_TYPE_P(&values) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&values), _7) - { - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _7); - ZEPHIR_INIT_NVAR(&_9$$5); - ZVAL_LONG(&_9$$5, hiddenParam); - ZEPHIR_INIT_NVAR(&_10$$5); - ZEPHIR_CONCAT_SV(&_10$$5, "AP", &_9$$5); - ZEPHIR_CPY_WRT(&key, &_10$$5); - ZEPHIR_INIT_NVAR(&queryKey); - ZEPHIR_CONCAT_SVS(&queryKey, ":", &key, ":"); - zephir_array_append(&bindKeys, &queryKey, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 1667); - zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); - hiddenParam++; - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_8, &values, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_8)) { - break; +pp297: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp298; } - ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_11$$6); - ZVAL_LONG(&_11$$6, hiddenParam); - ZEPHIR_INIT_NVAR(&_12$$6); - ZEPHIR_CONCAT_SV(&_12$$6, "AP", &_11$$6); - ZEPHIR_CPY_WRT(&key, &_12$$6); - ZEPHIR_INIT_NVAR(&queryKey); - ZEPHIR_CONCAT_SVS(&queryKey, ":", &key, ":"); - zephir_array_append(&bindKeys, &queryKey, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 1667); - zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); - hiddenParam++; - ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); - zephir_check_call_status(); +pp298: + { + token->opcode = PHQL_T_INNER; + return 0; } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_VAR(&_13); - zephir_fast_join_str(&_13, SL(", "), &bindKeys); - ZEPHIR_INIT_VAR(&_14); - ZEPHIR_CONCAT_VSVS(&_14, &expr, " IN (", &_13, ")"); - ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &operatorMethod, NULL, 0, &_14, &bindParams); - zephir_check_call_status(); - ZVAL_UNDEF(&_15); - ZVAL_LONG(&_15, hiddenParam); - zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &_15); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, conditionNotBetween) -{ - zval _6; - zend_bool _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *clause_param = NULL, *operator_param = NULL, *expr_param = NULL, *minimum, minimum_sub, *maximum, maximum_sub, hiddenParam, nextHiddenParam, minimumKey, maximumKey, operatorMethod, _5, _1$$3, _2$$3, _3$$3; - zval clause, operator, expr, _4; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&clause); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&minimum_sub); - ZVAL_UNDEF(&maximum_sub); - ZVAL_UNDEF(&hiddenParam); - ZVAL_UNDEF(&nextHiddenParam); - ZVAL_UNDEF(&minimumKey); - ZVAL_UNDEF(&maximumKey); - ZVAL_UNDEF(&operatorMethod); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_6); - ZEND_PARSE_PARAMETERS_START(5, 5) - Z_PARAM_STR(clause) - Z_PARAM_STR(operator) - Z_PARAM_STR(expr) - Z_PARAM_ZVAL(minimum) - Z_PARAM_ZVAL(maximum) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 5, 0, &clause_param, &operator_param, &expr_param, &minimum, &maximum); - if (UNEXPECTED(Z_TYPE_P(clause_param) != IS_STRING && Z_TYPE_P(clause_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'clause' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(clause_param) == IS_STRING)) { - zephir_get_strval(&clause, clause_param); - } else { - ZEPHIR_INIT_VAR(&clause); - } - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "and"); - if (_0) { - _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "or"); - } - if (UNEXPECTED(_0)) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "Operator % is not available."); - ZEPHIR_CALL_FUNCTION(&_3$$3, "sprintf", NULL, 117, &_2$$3, &operator); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_3$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model/Query/Builder.zep", 1699); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_VAR(&_4); - ZEPHIR_CONCAT_VV(&_4, &operator, &clause); - ZEPHIR_CPY_WRT(&operatorMethod, &_4); - zephir_memory_observe(&hiddenParam); - zephir_read_property(&hiddenParam, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&nextHiddenParam); - ZVAL_LONG(&nextHiddenParam, (zephir_get_numberval(&hiddenParam) + 1)); - ZEPHIR_INIT_VAR(&minimumKey); - ZEPHIR_CONCAT_SV(&minimumKey, "AP", &hiddenParam); - ZEPHIR_INIT_VAR(&maximumKey); - ZEPHIR_CONCAT_SV(&maximumKey, "AP", &nextHiddenParam); - ZEPHIR_INIT_VAR(&_5); - ZEPHIR_CONCAT_VSVSVS(&_5, &expr, " NOT BETWEEN :", &minimumKey, ": AND :", &maximumKey, ":"); - ZEPHIR_INIT_VAR(&_6); - zephir_create_array(&_6, 2, 0); - zephir_array_update_zval(&_6, &minimumKey, minimum, PH_COPY); - zephir_array_update_zval(&_6, &maximumKey, maximum, PH_COPY); - ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &operatorMethod, NULL, 0, &_5, &_6); - zephir_check_call_status(); - SEPARATE_ZVAL(&nextHiddenParam); - zephir_increment(&nextHiddenParam); - zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &nextHiddenParam); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Builder, conditionNotIn) -{ - zend_bool _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, hiddenParam = 0; - zval values; - zval *clause_param = NULL, *operator_param = NULL, *expr_param = NULL, *values_param = NULL, key, queryKey, value, bindKeys, bindParams, operatorMethod, _6, *_7, _8, _13, _14, _15, _1$$3, _2$$3, _3$$3, _9$$5, _11$$6; - zval clause, operator, expr, _4, _5$$4, _10$$5, _12$$6; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&clause); - ZVAL_UNDEF(&operator); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_10$$5); - ZVAL_UNDEF(&_12$$6); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&queryKey); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&bindKeys); - ZVAL_UNDEF(&bindParams); - ZVAL_UNDEF(&operatorMethod); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_13); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_15); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_9$$5); - ZVAL_UNDEF(&_11$$6); - ZVAL_UNDEF(&values); - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_STR(clause) - Z_PARAM_STR(operator) - Z_PARAM_STR(expr) - Z_PARAM_ARRAY(values) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 0, &clause_param, &operator_param, &expr_param, &values_param); - if (UNEXPECTED(Z_TYPE_P(clause_param) != IS_STRING && Z_TYPE_P(clause_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'clause' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(clause_param) == IS_STRING)) { - zephir_get_strval(&clause, clause_param); - } else { - ZEPHIR_INIT_VAR(&clause); - } - if (UNEXPECTED(Z_TYPE_P(operator_param) != IS_STRING && Z_TYPE_P(operator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'operator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(operator_param) == IS_STRING)) { - zephir_get_strval(&operator, operator_param); - } else { - ZEPHIR_INIT_VAR(&operator); - } - if (UNEXPECTED(Z_TYPE_P(expr_param) != IS_STRING && Z_TYPE_P(expr_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'expr' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(expr_param) == IS_STRING)) { - zephir_get_strval(&expr, expr_param); - } else { - ZEPHIR_INIT_VAR(&expr); - } - ZEPHIR_OBS_COPY_OR_DUP(&values, values_param); - _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "and"); - if (_0) { - _0 = !ZEPHIR_IS_STRING_IDENTICAL(&operator, "or"); - } - if (UNEXPECTED(_0)) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "Operator % is not available."); - ZEPHIR_CALL_FUNCTION(&_3$$3, "sprintf", NULL, 117, &_2$$3, &operator); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_3$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Mvc/Model/Query/Builder.zep", 1746); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_VAR(&_4); - ZEPHIR_CONCAT_VV(&_4, &operator, &clause); - ZEPHIR_CPY_WRT(&operatorMethod, &_4); - if (!(zephir_fast_count_int(&values))) { - ZEPHIR_INIT_VAR(&_5$$4); - ZEPHIR_CONCAT_VSV(&_5$$4, &expr, " != ", &expr); - ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &operatorMethod, NULL, 0, &_5$$4); - zephir_check_call_status(); - RETURN_THIS(); - } - zephir_memory_observe(&_6); - zephir_read_property(&_6, this_ptr, ZEND_STRL("hiddenParamNumber"), PH_NOISY_CC); - hiddenParam = zephir_get_intval(&_6); - ZEPHIR_INIT_VAR(&bindParams); - array_init(&bindParams); - ZEPHIR_INIT_VAR(&bindKeys); - array_init(&bindKeys); - zephir_is_iterable(&values, 0, "phalcon/Mvc/Model/Query/Builder.zep", 1777); - if (Z_TYPE_P(&values) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&values), _7) - { - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _7); - ZEPHIR_INIT_NVAR(&_9$$5); - ZVAL_LONG(&_9$$5, hiddenParam); - ZEPHIR_INIT_NVAR(&_10$$5); - ZEPHIR_CONCAT_SV(&_10$$5, "AP", &_9$$5); - ZEPHIR_CPY_WRT(&key, &_10$$5); - ZEPHIR_INIT_NVAR(&queryKey); - ZEPHIR_CONCAT_SVS(&queryKey, ":", &key, ":"); - zephir_array_append(&bindKeys, &queryKey, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 1768); - zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); - hiddenParam++; - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_8, &values, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_8)) { - break; +pp299: + ppch = *++PPCURSOR; + switch (ppch) { + case 'T': + case 't': goto pp327; + default: goto pp59; } - ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_11$$6); - ZVAL_LONG(&_11$$6, hiddenParam); - ZEPHIR_INIT_NVAR(&_12$$6); - ZEPHIR_CONCAT_SV(&_12$$6, "AP", &_11$$6); - ZEPHIR_CPY_WRT(&key, &_12$$6); - ZEPHIR_INIT_NVAR(&queryKey); - ZEPHIR_CONCAT_SVS(&queryKey, ":", &key, ":"); - zephir_array_append(&bindKeys, &queryKey, PH_SEPARATE, "phalcon/Mvc/Model/Query/Builder.zep", 1768); - zephir_array_update_zval(&bindParams, &key, &value, PH_COPY | PH_SEPARATE); - hiddenParam++; - ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); - zephir_check_call_status(); +pp300: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp301; + } +pp301: + { + token->opcode = PHQL_T_LIMIT; + return 0; } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_VAR(&_13); - zephir_fast_join_str(&_13, SL(", "), &bindKeys); - ZEPHIR_INIT_VAR(&_14); - ZEPHIR_CONCAT_VSVS(&_14, &expr, " NOT IN (", &_13, ")"); - ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &operatorMethod, NULL, 0, &_14, &bindParams); - zephir_check_call_status(); - ZVAL_UNDEF(&_15); - ZVAL_LONG(&_15, hiddenParam); - zephir_update_property_zval(this_ptr, ZEND_STRL("hiddenParamNumber"), &_15); - RETURN_THIS(); -} - -zend_object *zephir_init_properties_Phalcon_Mvc_Model_Query_Builder(zend_class_entry *class_type) -{ - zval _0, _2, _4, _6, _1$$3, _3$$4, _5$$5, _7$$6; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("joins"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("joins"), &_1$$3); +pp302: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp329; + default: goto pp86; + } +pp303: + ppch = *++PPCURSOR; + switch (ppch) { + case 'T': + case 't': goto pp330; + default: goto pp59; + } +pp304: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp305; + } +pp305: + { + token->opcode = PHQL_T_ORDER; + return 0; } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("group"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("group"), &_3$$4); +pp306: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp307; + } +pp307: + { + token->opcode = PHQL_T_OUTER; + return 0; } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("bindTypes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("bindTypes"), &_5$$5); +pp308: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp309; + } +pp309: + { + token->opcode = PHQL_T_RIGHT; + return 0; } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("bindParams"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("bindParams"), &_7$$6); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query_BuilderInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model\\Query, BuilderInterface, phalcon, mvc_model_query_builderinterface, phalcon_mvc_model_query_builderinterface_method_entry); - - zephir_declare_class_constant_string(phalcon_mvc_model_query_builderinterface_ce, SL("OPERATOR_AND"), "and"); - - zephir_declare_class_constant_string(phalcon_mvc_model_query_builderinterface_ce, SL("OPERATOR_OR"), "or"); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, addFrom); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, andWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, betweenWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, columns); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, distinct); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, forUpdate); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, from); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getBindParams); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getBindTypes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getColumns); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getDistinct); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getFrom); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getGroupBy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getHaving); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getJoins); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getLimit); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getOffset); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getOrderBy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getPhql); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getQuery); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, groupBy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, having); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, innerJoin); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, inWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, join); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, leftJoin); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, limit); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, getModels); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, notBetweenWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, notInWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, offset); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, orderBy); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, orWhere); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, rightJoin); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, setBindParams); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, setBindTypes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_BuilderInterface, where); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query_Lang) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model\\Query, Lang, phalcon, mvc_model_query_lang, phalcon_mvc_model_query_lang_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Lang, parsePHQL) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *phql_param = NULL; - zval phql; - - ZVAL_UNDEF(&phql); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(phql) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &phql_param); - if (UNEXPECTED(Z_TYPE_P(phql_param) != IS_STRING && Z_TYPE_P(phql_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'phql' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(phql_param) == IS_STRING)) { - zephir_get_strval(&phql, phql_param); - } else { - ZEPHIR_INIT_VAR(&phql); - } - ZEPHIR_LAST_CALL_STATUS = phql_parse_phql(return_value, &phql); - zephir_check_call_status(); - RETURN_MM(); -} - - - -/* Driver template for the LEMON parser generator. -** The author disclaims copyright to this source code. -*/ -/* First off, code is include which follows the "include" declaration -** in the input file. */ -// 30 "parser.php.lemon" - - -// 12 "parser.php.c" -/* Next is all token values, in a form suitable for use by makeheaders. -** This section will be null unless lemon is run with the -m switch. -*/ -/* Make sure the INTERFACE macro is defined. -*/ -#ifndef INTERFACE -# define INTERFACE 1 -#endif -/* The next thing included is series of defines which control -** various aspects of the generated parser. -** PPCODETYPE is the data type used for storing terminal -** and nonterminal numbers. "unsigned char" is -** used if there are fewer than 250 terminals -** and nonterminals. "int" is used otherwise. -** PPNOCODE is a number of type PPCODETYPE which corresponds -** to no legal terminal or nonterminal number. This -** number is used to fill in empty slots of the hash -** table. -** PPFALLBACK If defined, this indicates that one or more tokens -** have fall-back values which should be used if the -** original value of the token will not parse. -** PPACTIONTYPE is the data type used for storing terminal -** and nonterminal numbers. "unsigned char" is -** used if there are fewer than 250 rules and -** states combined. "int" is used otherwise. -** phql_TOKENTYPE is the data type used for minor tokens given -** directly to the parser from the tokenizer. -** PPMINORTYPE is the data type used for all minor tokens. -** This is typically a union of many types, one of -** which is phql_TOKENTYPE. The entry in the union -** for base tokens is called "pp0". -** PPSTACKDEPTH is the maximum depth of the parser's stack. -** phql_ARG_SDECL A static variable declaration for the %extra_argument -** phql_ARG_PDECL A parameter declaration for the %extra_argument -** phql_ARG_STORE Code to store %extra_argument into pppParser -** phql_ARG_FETCH Code to extract %extra_argument from pppParser -** PPNSTATE the combined number of states. -** PPNRULE the number of rules in the grammar -** PPERRORSYMBOL is the code number of the error symbol. If not -** defined, then do no error processing. -*/ -#define PPCODETYPE unsigned char -#define PPNOCODE 135 -#define PPACTIONTYPE unsigned short int -#define phql_TOKENTYPE phql_parser_token* -typedef union { - phql_TOKENTYPE pp0; - zval pp202; - int pp269; -} PPMINORTYPE; -#define PPSTACKDEPTH 100 -#define phql_ARG_SDECL phql_parser_status *status; -#define phql_ARG_PDECL ,phql_parser_status *status -#define phql_ARG_FETCH phql_parser_status *status = pppParser->status -#define phql_ARG_STORE pppParser->status = status -#define PPNSTATE 295 -#define PPNRULE 162 -#define PPERRORSYMBOL 80 -#define PPERRSYMDT pp269 -#define PP_NO_ACTION (PPNSTATE+PPNRULE+2) -#define PP_ACCEPT_ACTION (PPNSTATE+PPNRULE+1) -#define PP_ERROR_ACTION (PPNSTATE+PPNRULE) - -/* Next are that tables used to determine what action to take based on the -** current state and lookahead token. These tables are used to implement -** functions that take a state number and lookahead value and return an -** action integer. -** -** Suppose the action integer is N. Then the action is determined as -** follows -** -** 0 <= N < PPNSTATE Shift N. That is, push the lookahead -** token onto the stack and goto state N. -** -** PPNSTATE <= N < PPNSTATE+PPNRULE Reduce by rule N-PPNSTATE. -** -** N == PPNSTATE+PPNRULE A syntax error has occurred. -** -** N == PPNSTATE+PPNRULE+1 The parser accepts its input. -** -** N == PPNSTATE+PPNRULE+2 No such action. Denotes unused -** slots in the pp_action[] table. -** -** The action table is constructed as a single large table named pp_action[]. -** Given state S and lookahead X, the action is computed as -** -** pp_action[ pp_shift_ofst[S] + X ] -** -** If the index value pp_shift_ofst[S]+X is out of range or if the value -** pp_lookahead[pp_shift_ofst[S]+X] is not equal to X or if pp_shift_ofst[S] -** is equal to PP_SHIFT_USE_DFLT, it means that the action is not in the table -** and that pp_default[S] should be used instead. -** -** The formula above is for computing the action when the lookahead is -** a terminal symbol. If the lookahead is a non-terminal (as occurs after -** a reduce action) then the pp_reduce_ofst[] array is used in place of -** the pp_shift_ofst[] array and PP_REDUCE_USE_DFLT is used in place of -** PP_SHIFT_USE_DFLT. -** -** The following are the tables generated in this section: -** -** pp_action[] A single table containing all actions. -** pp_lookahead[] A table containing the lookahead for each entry in -** pp_action. Used to detect hash collisions. -** pp_shift_ofst[] For each state, the offset into pp_action for -** shifting terminals. -** pp_reduce_ofst[] For each state, the offset into pp_action for -** shifting non-terminals after a reduce. -** pp_default[] Default action for each state. -*/ -static PPACTIONTYPE pp_action[] = { - /* 0 */ 120, 126, 128, 55, 57, 59, 61, 63, 65, 45, - /* 10 */ 47, 67, 72, 49, 51, 53, 41, 39, 43, 37, - /* 20 */ 34, 122, 74, 69, 120, 126, 128, 55, 57, 59, - /* 30 */ 61, 63, 65, 45, 47, 67, 72, 49, 51, 53, - /* 40 */ 41, 39, 43, 37, 34, 122, 74, 69, 19, 20, - /* 50 */ 21, 22, 23, 32, 33, 120, 126, 128, 55, 57, - /* 60 */ 59, 61, 63, 65, 45, 47, 67, 72, 49, 51, - /* 70 */ 53, 41, 39, 43, 37, 34, 122, 74, 69, 37, - /* 80 */ 34, 122, 74, 69, 94, 222, 81, 220, 95, 90, - /* 90 */ 111, 211, 113, 114, 213, 156, 79, 188, 89, 120, - /* 100 */ 126, 128, 55, 57, 59, 61, 63, 65, 45, 47, - /* 110 */ 67, 72, 49, 51, 53, 41, 39, 43, 37, 34, - /* 120 */ 122, 74, 69, 55, 57, 59, 61, 63, 65, 45, - /* 130 */ 47, 67, 72, 49, 51, 53, 41, 39, 43, 37, - /* 140 */ 34, 122, 74, 69, 132, 249, 120, 126, 128, 55, - /* 150 */ 57, 59, 61, 63, 65, 45, 47, 67, 72, 49, - /* 160 */ 51, 53, 41, 39, 43, 37, 34, 122, 74, 69, - /* 170 */ 41, 39, 43, 37, 34, 122, 74, 69, 142, 7, - /* 180 */ 120, 126, 128, 55, 57, 59, 61, 63, 65, 45, - /* 190 */ 47, 67, 72, 49, 51, 53, 41, 39, 43, 37, - /* 200 */ 34, 122, 74, 69, 120, 126, 128, 55, 57, 59, - /* 210 */ 61, 63, 65, 45, 47, 67, 72, 49, 51, 53, - /* 220 */ 41, 39, 43, 37, 34, 122, 74, 69, 45, 47, - /* 230 */ 67, 72, 49, 51, 53, 41, 39, 43, 37, 34, - /* 240 */ 122, 74, 69, 122, 74, 69, 154, 156, 148, 188, - /* 250 */ 120, 126, 128, 55, 57, 59, 61, 63, 65, 45, - /* 260 */ 47, 67, 72, 49, 51, 53, 41, 39, 43, 37, - /* 270 */ 34, 122, 74, 69, 170, 242, 158, 35, 95, 99, - /* 280 */ 171, 173, 8, 76, 112, 113, 114, 161, 49, 51, - /* 290 */ 53, 41, 39, 43, 37, 34, 122, 74, 69, 83, - /* 300 */ 170, 130, 295, 35, 84, 92, 171, 173, 296, 194, - /* 310 */ 210, 196, 198, 161, 202, 206, 107, 176, 177, 183, - /* 320 */ 184, 185, 135, 139, 145, 100, 151, 130, 432, 124, - /* 330 */ 17, 180, 178, 179, 181, 182, 297, 228, 236, 224, - /* 340 */ 225, 6, 6, 176, 177, 183, 184, 185, 135, 139, - /* 350 */ 145, 115, 151, 164, 164, 298, 94, 180, 178, 179, - /* 360 */ 181, 182, 215, 107, 24, 35, 70, 230, 171, 173, - /* 370 */ 98, 175, 175, 95, 104, 216, 92, 232, 76, 299, - /* 380 */ 123, 226, 234, 92, 160, 160, 119, 186, 186, 130, - /* 390 */ 193, 35, 191, 251, 171, 173, 91, 76, 278, 94, - /* 400 */ 292, 161, 240, 105, 175, 176, 177, 183, 184, 185, - /* 410 */ 135, 139, 145, 103, 151, 130, 82, 160, 9, 180, - /* 420 */ 178, 179, 181, 182, 194, 210, 196, 198, 26, 202, - /* 430 */ 206, 176, 177, 183, 184, 185, 135, 139, 145, 10, - /* 440 */ 151, 164, 31, 153, 190, 180, 178, 179, 181, 182, - /* 450 */ 170, 218, 96, 35, 85, 109, 171, 173, 137, 175, - /* 460 */ 175, 168, 6, 161, 110, 28, 239, 15, 162, 167, - /* 470 */ 168, 102, 160, 160, 165, 186, 11, 130, 217, 35, - /* 480 */ 13, 431, 171, 173, 12, 201, 121, 247, 199, 161, - /* 490 */ 227, 162, 14, 176, 177, 183, 184, 185, 135, 139, - /* 500 */ 145, 27, 151, 130, 175, 175, 16, 180, 178, 179, - /* 510 */ 181, 182, 244, 248, 281, 288, 284, 160, 160, 176, - /* 520 */ 177, 183, 184, 185, 135, 139, 145, 18, 151, 205, - /* 530 */ 254, 262, 203, 180, 178, 179, 181, 182, 67, 72, - /* 540 */ 49, 51, 53, 41, 39, 43, 37, 34, 122, 74, - /* 550 */ 69, 209, 78, 25, 207, 223, 219, 253, 258, 458, - /* 560 */ 1, 2, 3, 4, 5, 6, 133, 29, 168, 107, - /* 570 */ 6, 77, 260, 263, 175, 31, 272, 69, 257, 283, - /* 580 */ 284, 256, 131, 260, 261, 75, 127, 160, 235, 108, - /* 590 */ 175, 273, 267, 175, 86, 261, 109, 289, 94, 30, - /* 600 */ 175, 175, 164, 160, 175, 279, 160, 80, 214, 219, - /* 610 */ 84, 212, 247, 160, 160, 87, 84, 160, 88, 260, - /* 620 */ 175, 238, 107, 287, 93, 97, 36, 175, 107, 101, - /* 630 */ 175, 259, 106, 160, 110, 38, 169, 175, 246, 175, - /* 640 */ 160, 175, 286, 160, 175, 40, 42, 44, 269, 46, - /* 650 */ 160, 386, 160, 175, 160, 48, 50, 160, 116, 125, - /* 660 */ 118, 52, 117, 175, 175, 175, 160, 175, 264, 258, - /* 670 */ 54, 134, 56, 175, 175, 58, 160, 160, 160, 175, - /* 680 */ 160, 60, 62, 136, 64, 76, 160, 160, 175, 268, - /* 690 */ 175, 66, 160, 175, 138, 140, 143, 149, 144, 175, - /* 700 */ 175, 160, 175, 160, 146, 187, 160, 68, 71, 175, - /* 710 */ 276, 73, 160, 160, 129, 160, 141, 147, 150, 152, - /* 720 */ 155, 163, 160, 157, 166, 175, 175, 192, 159, 175, - /* 730 */ 195, 172, 175, 174, 175, 175, 323, 175, 160, 160, - /* 740 */ 189, 175, 160, 231, 197, 160, 175, 160, 160, 175, - /* 750 */ 160, 175, 241, 324, 160, 250, 200, 325, 175, 160, - /* 760 */ 326, 175, 160, 204, 160, 327, 328, 294, 208, 329, - /* 770 */ 175, 160, 84, 175, 160, 330, 331, 221, 229, 245, - /* 780 */ 243, 233, 255, 160, 107, 237, 160, 334, 271, 335, - /* 790 */ 252, 270, 265, 342, 266, 274, 275, 277, 385, 280, - /* 800 */ 282, 285, 290, 291, 348, 293, -}; -static PPCODETYPE pp_lookahead[] = { - /* 0 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 10 */ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - /* 20 */ 21, 22, 23, 24, 1, 2, 3, 4, 5, 6, - /* 30 */ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - /* 40 */ 17, 18, 19, 20, 21, 22, 23, 24, 61, 62, - /* 50 */ 63, 64, 65, 54, 55, 1, 2, 3, 4, 5, - /* 60 */ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - /* 70 */ 16, 17, 18, 19, 20, 21, 22, 23, 24, 20, - /* 80 */ 21, 22, 23, 24, 31, 31, 97, 33, 120, 121, - /* 90 */ 101, 102, 103, 104, 26, 72, 28, 74, 45, 1, - /* 100 */ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - /* 110 */ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - /* 120 */ 22, 23, 24, 4, 5, 6, 7, 8, 9, 10, - /* 130 */ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - /* 140 */ 21, 22, 23, 24, 46, 51, 1, 2, 3, 4, - /* 150 */ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - /* 160 */ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - /* 170 */ 17, 18, 19, 20, 21, 22, 23, 24, 33, 88, - /* 180 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 190 */ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - /* 200 */ 21, 22, 23, 24, 1, 2, 3, 4, 5, 6, - /* 210 */ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, - /* 220 */ 17, 18, 19, 20, 21, 22, 23, 24, 10, 11, - /* 230 */ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - /* 240 */ 22, 23, 24, 22, 23, 24, 71, 72, 69, 74, - /* 250 */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - /* 260 */ 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - /* 270 */ 21, 22, 23, 24, 18, 56, 73, 21, 120, 121, - /* 280 */ 24, 25, 89, 27, 102, 103, 104, 31, 14, 15, - /* 290 */ 16, 17, 18, 19, 20, 21, 22, 23, 24, 100, - /* 300 */ 18, 45, 0, 21, 105, 26, 24, 25, 0, 34, - /* 310 */ 35, 36, 37, 31, 39, 40, 117, 61, 62, 63, - /* 320 */ 64, 65, 66, 67, 68, 46, 70, 45, 46, 24, - /* 330 */ 26, 75, 76, 77, 78, 79, 0, 83, 83, 29, - /* 340 */ 30, 87, 87, 61, 62, 63, 64, 65, 66, 67, - /* 350 */ 68, 105, 70, 99, 99, 0, 31, 75, 76, 77, - /* 360 */ 78, 79, 18, 117, 60, 21, 12, 13, 24, 25, - /* 370 */ 45, 117, 117, 120, 121, 31, 26, 23, 27, 0, - /* 380 */ 75, 127, 127, 26, 130, 130, 99, 133, 133, 45, - /* 390 */ 31, 21, 33, 42, 24, 25, 46, 27, 47, 31, - /* 400 */ 49, 31, 57, 46, 117, 61, 62, 63, 64, 65, - /* 410 */ 66, 67, 68, 45, 70, 45, 26, 130, 90, 75, - /* 420 */ 76, 77, 78, 79, 34, 35, 36, 37, 52, 39, - /* 430 */ 40, 61, 62, 63, 64, 65, 66, 67, 68, 91, - /* 440 */ 70, 99, 99, 128, 129, 75, 76, 77, 78, 79, - /* 450 */ 18, 18, 31, 21, 33, 32, 24, 25, 83, 117, - /* 460 */ 117, 26, 87, 31, 31, 122, 123, 59, 45, 127, - /* 470 */ 26, 50, 130, 130, 132, 133, 92, 45, 32, 21, - /* 480 */ 58, 46, 24, 25, 93, 35, 99, 99, 38, 31, - /* 490 */ 46, 45, 47, 61, 62, 63, 64, 65, 66, 67, - /* 500 */ 68, 53, 70, 45, 117, 117, 126, 75, 76, 77, - /* 510 */ 78, 79, 124, 125, 115, 116, 117, 130, 130, 61, - /* 520 */ 62, 63, 64, 65, 66, 67, 68, 126, 70, 35, - /* 530 */ 44, 45, 38, 75, 76, 77, 78, 79, 12, 13, - /* 540 */ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - /* 550 */ 24, 35, 95, 126, 38, 98, 99, 105, 26, 81, - /* 560 */ 82, 83, 84, 85, 86, 87, 83, 26, 26, 117, - /* 570 */ 87, 94, 99, 109, 117, 99, 112, 24, 46, 116, - /* 580 */ 117, 108, 99, 99, 111, 45, 99, 130, 46, 31, - /* 590 */ 117, 113, 108, 117, 31, 111, 32, 119, 31, 123, - /* 600 */ 117, 117, 99, 130, 117, 100, 130, 96, 98, 99, - /* 610 */ 105, 100, 99, 130, 130, 50, 105, 130, 120, 99, - /* 620 */ 117, 99, 117, 99, 120, 50, 99, 117, 117, 120, - /* 630 */ 117, 111, 120, 130, 31, 99, 133, 117, 125, 117, - /* 640 */ 130, 117, 118, 130, 117, 99, 99, 99, 26, 99, - /* 650 */ 130, 0, 130, 117, 130, 99, 99, 130, 106, 75, - /* 660 */ 41, 99, 107, 117, 117, 117, 130, 117, 46, 26, - /* 670 */ 99, 46, 99, 117, 117, 99, 130, 130, 130, 117, - /* 680 */ 130, 99, 99, 45, 99, 27, 130, 130, 117, 46, - /* 690 */ 117, 99, 130, 117, 46, 45, 31, 31, 46, 117, - /* 700 */ 117, 130, 117, 130, 45, 29, 130, 99, 99, 117, - /* 710 */ 59, 99, 130, 130, 99, 130, 99, 99, 46, 99, - /* 720 */ 129, 131, 130, 99, 46, 117, 117, 31, 99, 117, - /* 730 */ 35, 99, 117, 99, 117, 117, 31, 117, 130, 130, - /* 740 */ 99, 117, 130, 99, 35, 130, 117, 130, 130, 117, - /* 750 */ 130, 117, 99, 31, 130, 99, 35, 31, 117, 130, - /* 760 */ 31, 117, 130, 35, 130, 31, 31, 100, 35, 31, - /* 770 */ 117, 130, 105, 117, 130, 31, 31, 31, 46, 26, - /* 780 */ 53, 45, 45, 130, 117, 46, 130, 0, 31, 0, - /* 790 */ 43, 112, 44, 0, 45, 88, 114, 126, 0, 48, - /* 800 */ 26, 4, 88, 114, 0, 28, -}; -#define PP_SHIFT_USE_DFLT (-14) -static short pp_shift_ofst[] = { - /* 0 */ 351, 302, 308, 336, 355, 379, 94, 219, 345, 376, - /* 10 */ 408, 422, -14, 445, -14, -13, 304, -13, -14, -14, - /* 20 */ -14, -14, -14, -14, -13, -14, 448, 458, 541, 458, - /* 30 */ -14, -1, -14, -14, 458, 458, 221, 458, 221, 458, - /* 40 */ 59, 458, 59, 458, 59, 458, 526, 458, 526, 458, - /* 50 */ 153, 458, 153, 458, 153, 458, 218, 458, 218, 458, - /* 60 */ 218, 458, 218, 458, 218, 458, 218, 458, 274, 354, - /* 70 */ 458, 553, 458, 274, 540, 256, 310, 344, 68, 558, - /* 80 */ 390, -14, 558, -14, 421, 563, 565, 53, -14, 567, - /* 90 */ 350, -14, 567, -14, -14, -14, 575, 325, 567, 279, - /* 100 */ -14, -14, 368, 567, 357, -14, -14, -14, 564, 603, - /* 110 */ -14, 275, -14, -14, 558, 359, 619, -14, 458, 249, - /* 120 */ 458, 249, 305, -14, 584, -14, 458, 119, 458, 119, - /* 130 */ 370, 98, -14, 625, -14, 638, 658, 648, -14, 650, - /* 140 */ 458, 145, 665, 652, -14, 659, 458, 179, 666, 672, - /* 150 */ -14, 458, 23, 175, -14, -14, 458, 203, 458, 249, - /* 160 */ -14, 423, 676, 282, 249, 678, -14, 435, 432, -14, - /* 170 */ -14, 458, 553, 458, 553, -14, -14, -14, -14, -14, - /* 180 */ -14, -14, -14, -14, -14, -14, -14, -14, 458, 249, - /* 190 */ -14, 696, -14, -14, 695, 705, 709, 722, 450, 721, - /* 200 */ 726, 729, 494, 728, 734, 735, 516, 733, 738, 744, - /* 210 */ 745, -14, -14, 344, -14, -14, 446, 433, -14, 54, - /* 220 */ 746, -14, -14, -14, -14, -14, 444, -14, 732, -14, - /* 230 */ 458, 553, 736, 256, 542, -14, 739, -14, 221, -14, - /* 240 */ 458, 249, 727, 458, 753, 458, -14, 249, -14, 458, - /* 250 */ 249, 747, 558, 486, 737, 458, 532, 787, 458, -14, - /* 260 */ 249, -14, 757, 622, 748, 749, 458, 643, 789, 757, - /* 270 */ -14, -14, -14, 94, 651, 793, -13, 798, 558, 751, - /* 280 */ 558, 774, 558, -14, 797, 458, -14, 249, -14, 94, - /* 290 */ 651, 804, 777, 558, -14, -}; -#define PP_REDUCE_USE_DFLT (-33) -static short pp_reduce_ofst[] = { - /* 0 */ 478, -33, -33, -33, -33, -33, 91, 193, 328, 348, - /* 10 */ 384, 391, -33, -33, -33, 380, -33, 401, -33, -33, - /* 20 */ -33, -33, -33, -33, 427, -33, -33, 343, -33, 476, - /* 30 */ -33, -33, -33, -33, 522, 527, -33, 536, -33, 546, - /* 40 */ -33, 547, -33, 548, -33, 550, -33, 556, -33, 557, - /* 50 */ -33, 562, -33, 571, -33, 573, -33, 576, -33, 582, - /* 60 */ -33, 583, -33, 585, -33, 592, -33, 608, -33, -33, - /* 70 */ 609, -33, 612, -33, -33, 254, 477, 457, -33, 511, - /* 80 */ -11, -33, 199, -33, -33, -33, -33, 498, -33, -32, - /* 90 */ -33, -33, 504, -33, -33, -33, -33, 509, 158, -33, - /* 100 */ -33, -33, 512, 253, -33, -33, -33, -33, -33, -33, - /* 110 */ -33, 182, -33, -33, 246, 552, 555, -33, 287, -33, - /* 120 */ 387, -33, -33, -33, -33, -33, 487, -33, 615, -33, - /* 130 */ 483, -33, -33, -33, -33, -33, 375, -33, -33, -33, - /* 140 */ 617, -33, -33, -33, -33, -33, 618, -33, -33, -33, - /* 150 */ -33, 620, 315, 591, -33, -33, 624, -33, 629, -33, - /* 160 */ -33, -33, 590, 342, -33, -33, -33, -33, 503, -33, - /* 170 */ -33, 632, -33, 634, -33, -33, -33, -33, -33, -33, - /* 180 */ -33, -33, -33, -33, -33, -33, -33, -33, 641, -33, - /* 190 */ -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - /* 200 */ -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - /* 210 */ -33, -33, -33, 510, -33, -33, -33, -33, -33, -33, - /* 220 */ -33, -33, -33, -33, -33, -33, -33, -33, -33, -33, - /* 230 */ 644, -33, -33, 255, -33, -33, -33, -33, -33, -33, - /* 240 */ 653, -33, -33, 388, -33, 513, -33, -33, -33, 656, - /* 250 */ -33, -33, 452, -33, -33, 473, -33, -33, 520, -33, - /* 260 */ -33, -33, 464, -33, -33, -33, 484, -33, -33, 679, - /* 270 */ -33, -33, -33, 707, 682, -33, 671, -33, 505, -33, - /* 280 */ 399, -33, 463, -33, -33, 524, -33, -33, -33, 714, - /* 290 */ 689, -33, -33, 667, -33, -}; -static PPACTIONTYPE pp_default[] = { - /* 0 */ 457, 457, 457, 457, 457, 457, 364, 373, 378, 366, - /* 10 */ 384, 380, 300, 457, 379, 457, 381, 457, 382, 387, - /* 20 */ 388, 389, 390, 391, 457, 383, 457, 457, 365, 457, - /* 30 */ 367, 369, 370, 371, 457, 457, 392, 457, 394, 457, - /* 40 */ 395, 457, 396, 457, 397, 457, 398, 457, 399, 457, - /* 50 */ 400, 457, 401, 457, 402, 457, 403, 457, 404, 457, - /* 60 */ 405, 457, 406, 457, 407, 457, 408, 457, 409, 457, - /* 70 */ 457, 410, 457, 411, 457, 457, 304, 457, 457, 457, - /* 80 */ 315, 301, 457, 312, 352, 457, 350, 457, 353, 457, - /* 90 */ 457, 354, 457, 359, 361, 360, 351, 457, 457, 457, - /* 100 */ 355, 356, 457, 457, 457, 357, 358, 362, 456, 457, - /* 110 */ 455, 314, 316, 318, 457, 322, 333, 319, 457, 332, - /* 120 */ 457, 419, 457, 437, 457, 438, 457, 439, 457, 440, - /* 130 */ 457, 457, 443, 457, 415, 457, 457, 457, 418, 457, - /* 140 */ 457, 457, 457, 457, 420, 457, 457, 457, 457, 457, - /* 150 */ 421, 457, 457, 457, 422, 423, 457, 457, 457, 425, - /* 160 */ 427, 456, 430, 457, 436, 457, 428, 457, 457, 433, - /* 170 */ 435, 457, 441, 457, 442, 444, 445, 446, 447, 448, - /* 180 */ 449, 450, 451, 452, 453, 454, 434, 429, 457, 426, - /* 190 */ 424, 457, 320, 321, 457, 457, 457, 457, 457, 457, - /* 200 */ 457, 457, 457, 457, 457, 457, 457, 457, 457, 457, - /* 210 */ 457, 317, 313, 457, 305, 307, 456, 457, 308, 311, - /* 220 */ 457, 309, 310, 306, 302, 303, 457, 413, 457, 416, - /* 230 */ 457, 412, 457, 457, 457, 414, 457, 417, 393, 368, - /* 240 */ 457, 377, 457, 457, 372, 457, 374, 376, 375, 457, - /* 250 */ 363, 457, 457, 457, 457, 457, 457, 457, 457, 336, - /* 260 */ 338, 337, 457, 457, 457, 457, 457, 457, 457, 457, - /* 270 */ 339, 341, 340, 364, 457, 457, 457, 457, 457, 457, - /* 280 */ 457, 343, 457, 344, 457, 457, 346, 347, 345, 364, - /* 290 */ 457, 457, 457, 457, 349, -}; -#define PP_SZ_ACTTAB (sizeof(pp_action)/sizeof(pp_action[0])) - -/* The next table maps tokens into fallback tokens. If a construct -** like the following: -** -** %fallback ID X Y Z. -** -** appears in the grammer, then ID becomes a fallback token for X, Y, -** and Z. Whenever one of the tokens X, Y, or Z is input to the parser -** but it does not parse, the type of the token is changed to ID and -** the parse is retried before an error is thrown. -*/ -#ifdef PPFALLBACK -static const PPCODETYPE ppFallback[] = { -}; -#endif /* PPFALLBACK */ - -/* The following structure represents a single element of the -** parser's stack. Information stored includes: -** -** + The state number for the parser at this level of the stack. -** -** + The value of the token stored at this level of the stack. -** (In other words, the "major" token.) -** -** + The semantic value stored at this level of the stack. This is -** the information used by the action routines in the grammar. -** It is sometimes called the "minor" token. -*/ -struct ppStackEntry { - int stateno; /* The state-number */ - int major; /* The major token value. This is the code - ** number for the token at this stack level */ - PPMINORTYPE minor; /* The user-supplied minor token value. This - ** is the value of the token */ -}; -typedef struct ppStackEntry ppStackEntry; - -/* The state of the parser is completely contained in an instance of -** the following structure */ -struct ppParser { - int ppidx; /* Index of top element in stack */ - int pperrcnt; /* Shifts left before out of the error */ - phql_ARG_SDECL /* A place to hold %extra_argument */ - ppStackEntry ppstack[PPSTACKDEPTH]; /* The parser's stack */ -}; -typedef struct ppParser ppParser; - -#ifndef NDEBUG -static FILE *ppTraceFILE = 0; -static char *ppTracePrompt = 0; -#endif /* NDEBUG */ - -#ifndef NDEBUG -static void phql_Trace(FILE *TraceFILE, char *zTracePrompt){ - ppTraceFILE = TraceFILE; - ppTracePrompt = zTracePrompt; - if( ppTraceFILE==0 ) ppTracePrompt = 0; - else if( ppTracePrompt==0 ) ppTraceFILE = 0; -} -#endif /* NDEBUG */ - -#ifndef NDEBUG -/* For tracing shifts, the names of all terminals and nonterminals -** are required. The following table supplies these names */ -static const char *ppTokenName[] = { - "$", "AGAINST", "BETWEEN", "BETWEEN_NOT", - "EQUALS", "NOTEQUALS", "LESS", "GREATER", - "GREATEREQUAL", "LESSEQUAL", "AND", "OR", - "LIKE", "ILIKE", "BITWISE_AND", "BITWISE_OR", - "BITWISE_XOR", "DIVIDE", "TIMES", "MOD", - "PLUS", "MINUS", "IS", "IN", - "NOT", "BITWISE_NOT", "COMMA", "SELECT", - "FROM", "DISTINCT", "ALL", "IDENTIFIER", - "DOT", "AS", "INNER", "JOIN", - "CROSS", "LEFT", "OUTER", "RIGHT", - "FULL", "ON", "INSERT", "INTO", - "VALUES", "PARENTHESES_OPEN", "PARENTHESES_CLOSE", "UPDATE", - "SET", "DELETE", "WITH", "WHERE", - "ORDER", "BY", "ASC", "DESC", - "GROUP", "HAVING", "FOR", "LIMIT", - "OFFSET", "INTEGER", "HINTEGER", "NPLACEHOLDER", - "SPLACEHOLDER", "BPLACEHOLDER", "EXISTS", "CAST", - "CONVERT", "USING", "CASE", "END", - "WHEN", "THEN", "ELSE", "NULL", - "STRING", "DOUBLE", "TRUE", "FALSE", - "error", "program", "query_language", "select_statement", - "insert_statement", "update_statement", "delete_statement", "select_clause", - "where_clause", "group_clause", "having_clause", "order_clause", - "select_limit_clause", "for_update_clause", "distinct_all", "column_list", - "associated_name_list", "join_list_or_null", "column_item", "expr", - "associated_name", "join_list", "join_item", "join_clause", - "join_type", "aliased_or_qualified_name", "join_associated_name", "join_conditions", - "values_list", "field_list", "value_list", "value_item", - "field_item", "update_clause", "limit_clause", "update_item_list", - "update_item", "qualified_name", "new_value", "delete_clause", - "with_item", "with_list", "order_list", "order_item", - "group_list", "group_item", "integer_or_placeholder", "argument_list", - "when_clauses", "when_clause", "function_call", "distinct_or_null", - "argument_list_or_null", "argument_item", -}; -#endif /* NDEBUG */ - -#ifndef NDEBUG -/* For tracing reduce actions, the names of all rules are required. -*/ -static const char *ppRuleName[] = { - /* 0 */ "program ::= query_language", - /* 1 */ "query_language ::= select_statement", - /* 2 */ "query_language ::= insert_statement", - /* 3 */ "query_language ::= update_statement", - /* 4 */ "query_language ::= delete_statement", - /* 5 */ "select_statement ::= select_clause where_clause group_clause having_clause order_clause select_limit_clause for_update_clause", - /* 6 */ "select_clause ::= SELECT distinct_all column_list FROM associated_name_list join_list_or_null", - /* 7 */ "distinct_all ::= DISTINCT", - /* 8 */ "distinct_all ::= ALL", - /* 9 */ "distinct_all ::=", - /* 10 */ "column_list ::= column_list COMMA column_item", - /* 11 */ "column_list ::= column_item", - /* 12 */ "column_item ::= TIMES", - /* 13 */ "column_item ::= IDENTIFIER DOT TIMES", - /* 14 */ "column_item ::= expr AS IDENTIFIER", - /* 15 */ "column_item ::= expr IDENTIFIER", - /* 16 */ "column_item ::= expr", - /* 17 */ "associated_name_list ::= associated_name_list COMMA associated_name", - /* 18 */ "associated_name_list ::= associated_name", - /* 19 */ "join_list_or_null ::= join_list", - /* 20 */ "join_list_or_null ::=", - /* 21 */ "join_list ::= join_list join_item", - /* 22 */ "join_list ::= join_item", - /* 23 */ "join_item ::= join_clause", - /* 24 */ "join_clause ::= join_type aliased_or_qualified_name join_associated_name join_conditions", - /* 25 */ "join_associated_name ::= AS IDENTIFIER", - /* 26 */ "join_associated_name ::= IDENTIFIER", - /* 27 */ "join_associated_name ::=", - /* 28 */ "join_type ::= INNER JOIN", - /* 29 */ "join_type ::= CROSS JOIN", - /* 30 */ "join_type ::= LEFT OUTER JOIN", - /* 31 */ "join_type ::= LEFT JOIN", - /* 32 */ "join_type ::= RIGHT OUTER JOIN", - /* 33 */ "join_type ::= RIGHT JOIN", - /* 34 */ "join_type ::= FULL OUTER JOIN", - /* 35 */ "join_type ::= FULL JOIN", - /* 36 */ "join_type ::= JOIN", - /* 37 */ "join_conditions ::= ON expr", - /* 38 */ "join_conditions ::=", - /* 39 */ "insert_statement ::= INSERT INTO aliased_or_qualified_name VALUES PARENTHESES_OPEN values_list PARENTHESES_CLOSE", - /* 40 */ "insert_statement ::= INSERT INTO aliased_or_qualified_name PARENTHESES_OPEN field_list PARENTHESES_CLOSE VALUES PARENTHESES_OPEN values_list PARENTHESES_CLOSE", - /* 41 */ "values_list ::= values_list COMMA value_item", - /* 42 */ "values_list ::= value_item", - /* 43 */ "value_item ::= expr", - /* 44 */ "field_list ::= field_list COMMA field_item", - /* 45 */ "field_list ::= field_item", - /* 46 */ "field_item ::= IDENTIFIER", - /* 47 */ "update_statement ::= update_clause where_clause limit_clause", - /* 48 */ "update_clause ::= UPDATE associated_name SET update_item_list", - /* 49 */ "update_item_list ::= update_item_list COMMA update_item", - /* 50 */ "update_item_list ::= update_item", - /* 51 */ "update_item ::= qualified_name EQUALS new_value", - /* 52 */ "new_value ::= expr", - /* 53 */ "delete_statement ::= delete_clause where_clause limit_clause", - /* 54 */ "delete_clause ::= DELETE FROM associated_name", - /* 55 */ "associated_name ::= aliased_or_qualified_name AS IDENTIFIER", - /* 56 */ "associated_name ::= aliased_or_qualified_name IDENTIFIER", - /* 57 */ "associated_name ::= aliased_or_qualified_name", - /* 58 */ "associated_name ::= aliased_or_qualified_name AS IDENTIFIER WITH with_item", - /* 59 */ "associated_name ::= aliased_or_qualified_name AS IDENTIFIER WITH PARENTHESES_OPEN with_list PARENTHESES_CLOSE", - /* 60 */ "associated_name ::= aliased_or_qualified_name IDENTIFIER WITH PARENTHESES_OPEN with_list PARENTHESES_CLOSE", - /* 61 */ "associated_name ::= aliased_or_qualified_name IDENTIFIER WITH with_item", - /* 62 */ "associated_name ::= aliased_or_qualified_name WITH PARENTHESES_OPEN with_list PARENTHESES_CLOSE", - /* 63 */ "associated_name ::= aliased_or_qualified_name WITH with_item", - /* 64 */ "with_list ::= with_list COMMA with_item", - /* 65 */ "with_list ::= with_item", - /* 66 */ "with_item ::= IDENTIFIER", - /* 67 */ "aliased_or_qualified_name ::= qualified_name", - /* 68 */ "where_clause ::= WHERE expr", - /* 69 */ "where_clause ::=", - /* 70 */ "order_clause ::= ORDER BY order_list", - /* 71 */ "order_clause ::=", - /* 72 */ "order_list ::= order_list COMMA order_item", - /* 73 */ "order_list ::= order_item", - /* 74 */ "order_item ::= expr", - /* 75 */ "order_item ::= expr ASC", - /* 76 */ "order_item ::= expr DESC", - /* 77 */ "group_clause ::= GROUP BY group_list", - /* 78 */ "group_clause ::=", - /* 79 */ "group_list ::= group_list COMMA group_item", - /* 80 */ "group_list ::= group_item", - /* 81 */ "group_item ::= expr", - /* 82 */ "having_clause ::= HAVING expr", - /* 83 */ "having_clause ::=", - /* 84 */ "for_update_clause ::= FOR UPDATE", - /* 85 */ "for_update_clause ::=", - /* 86 */ "select_limit_clause ::= LIMIT integer_or_placeholder", - /* 87 */ "select_limit_clause ::= LIMIT integer_or_placeholder COMMA integer_or_placeholder", - /* 88 */ "select_limit_clause ::= LIMIT integer_or_placeholder OFFSET integer_or_placeholder", - /* 89 */ "select_limit_clause ::=", - /* 90 */ "limit_clause ::= LIMIT integer_or_placeholder", - /* 91 */ "limit_clause ::=", - /* 92 */ "integer_or_placeholder ::= INTEGER", - /* 93 */ "integer_or_placeholder ::= HINTEGER", - /* 94 */ "integer_or_placeholder ::= NPLACEHOLDER", - /* 95 */ "integer_or_placeholder ::= SPLACEHOLDER", - /* 96 */ "integer_or_placeholder ::= BPLACEHOLDER", - /* 97 */ "expr ::= MINUS expr", - /* 98 */ "expr ::= expr MINUS expr", - /* 99 */ "expr ::= expr PLUS expr", - /* 100 */ "expr ::= expr TIMES expr", - /* 101 */ "expr ::= expr DIVIDE expr", - /* 102 */ "expr ::= expr MOD expr", - /* 103 */ "expr ::= expr AND expr", - /* 104 */ "expr ::= expr OR expr", - /* 105 */ "expr ::= expr BITWISE_AND expr", - /* 106 */ "expr ::= expr BITWISE_OR expr", - /* 107 */ "expr ::= expr BITWISE_XOR expr", - /* 108 */ "expr ::= expr EQUALS expr", - /* 109 */ "expr ::= expr NOTEQUALS expr", - /* 110 */ "expr ::= expr LESS expr", - /* 111 */ "expr ::= expr GREATER expr", - /* 112 */ "expr ::= expr GREATEREQUAL expr", - /* 113 */ "expr ::= expr LESSEQUAL expr", - /* 114 */ "expr ::= expr LIKE expr", - /* 115 */ "expr ::= expr NOT LIKE expr", - /* 116 */ "expr ::= expr ILIKE expr", - /* 117 */ "expr ::= expr NOT ILIKE expr", - /* 118 */ "expr ::= expr IN PARENTHESES_OPEN argument_list PARENTHESES_CLOSE", - /* 119 */ "expr ::= expr NOT IN PARENTHESES_OPEN argument_list PARENTHESES_CLOSE", - /* 120 */ "expr ::= PARENTHESES_OPEN select_statement PARENTHESES_CLOSE", - /* 121 */ "expr ::= expr IN PARENTHESES_OPEN select_statement PARENTHESES_CLOSE", - /* 122 */ "expr ::= expr NOT IN PARENTHESES_OPEN select_statement PARENTHESES_CLOSE", - /* 123 */ "expr ::= EXISTS PARENTHESES_OPEN select_statement PARENTHESES_CLOSE", - /* 124 */ "expr ::= expr AGAINST expr", - /* 125 */ "expr ::= CAST PARENTHESES_OPEN expr AS IDENTIFIER PARENTHESES_CLOSE", - /* 126 */ "expr ::= CONVERT PARENTHESES_OPEN expr USING IDENTIFIER PARENTHESES_CLOSE", - /* 127 */ "expr ::= CASE expr when_clauses END", - /* 128 */ "when_clauses ::= when_clauses when_clause", - /* 129 */ "when_clauses ::= when_clause", - /* 130 */ "when_clause ::= WHEN expr THEN expr", - /* 131 */ "when_clause ::= ELSE expr", - /* 132 */ "expr ::= function_call", - /* 133 */ "function_call ::= IDENTIFIER PARENTHESES_OPEN distinct_or_null argument_list_or_null PARENTHESES_CLOSE", - /* 134 */ "distinct_or_null ::= DISTINCT", - /* 135 */ "distinct_or_null ::=", - /* 136 */ "argument_list_or_null ::= argument_list", - /* 137 */ "argument_list_or_null ::=", - /* 138 */ "argument_list ::= argument_list COMMA argument_item", - /* 139 */ "argument_list ::= argument_item", - /* 140 */ "argument_item ::= TIMES", - /* 141 */ "argument_item ::= expr", - /* 142 */ "expr ::= expr IS NULL", - /* 143 */ "expr ::= expr IS NOT NULL", - /* 144 */ "expr ::= expr BETWEEN expr", - /* 145 */ "expr ::= expr BETWEEN_NOT expr", - /* 146 */ "expr ::= NOT expr", - /* 147 */ "expr ::= BITWISE_NOT expr", - /* 148 */ "expr ::= PARENTHESES_OPEN expr PARENTHESES_CLOSE", - /* 149 */ "expr ::= qualified_name", - /* 150 */ "expr ::= INTEGER", - /* 151 */ "expr ::= HINTEGER", - /* 152 */ "expr ::= STRING", - /* 153 */ "expr ::= DOUBLE", - /* 154 */ "expr ::= NULL", - /* 155 */ "expr ::= TRUE", - /* 156 */ "expr ::= FALSE", - /* 157 */ "expr ::= NPLACEHOLDER", - /* 158 */ "expr ::= SPLACEHOLDER", - /* 159 */ "expr ::= BPLACEHOLDER", - /* 160 */ "qualified_name ::= IDENTIFIER DOT IDENTIFIER", - /* 161 */ "qualified_name ::= IDENTIFIER", -}; -#endif /* NDEBUG */ - -const char *phql_TokenName(int tokenType){ -#ifndef NDEBUG - if( tokenType>0 && tokenType<(sizeof(ppTokenName)/sizeof(ppTokenName[0])) ){ - return ppTokenName[tokenType]; - }else{ - return "Unknown"; - } -#else - return ""; -#endif -} - -void *phql_Alloc(void *(*mallocProc)(size_t)){ - ppParser *pParser; - pParser = (ppParser*)(*mallocProc)( (size_t)sizeof(ppParser) ); - if( pParser ){ - pParser->ppidx = -1; - } - return pParser; -} - -/* The following function deletes the value associated with a -** symbol. The symbol can be either a terminal or nonterminal. -** "ppmajor" is the symbol code, and "pppminor" is a pointer to -** the value. -*/ -static void pp_destructor(PPCODETYPE ppmajor, PPMINORTYPE *pppminor){ - switch( ppmajor ){ - /* Here is inserted the actions which take place when a - ** terminal or non-terminal is destroyed. This can happen - ** when the symbol is popped from the stack during a - ** reduce or during error processing or when a parser is - ** being destroyed before it is finished parsing. - ** - ** Note: during a reduce, the only symbols destroyed are those - ** which appear on the RHS of the rule, but which are not used - ** inside the C code. - */ - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: - case 18: - case 19: - case 20: - case 21: - case 22: - case 23: - case 24: - case 25: - case 26: - case 27: - case 28: - case 29: - case 30: - case 31: - case 32: - case 33: - case 34: - case 35: - case 36: - case 37: - case 38: - case 39: - case 40: - case 41: - case 42: - case 43: - case 44: - case 45: - case 46: - case 47: - case 48: - case 49: - case 50: - case 51: - case 52: - case 53: - case 54: - case 55: - case 56: - case 57: - case 58: - case 59: - case 60: - case 61: - case 62: - case 63: - case 64: - case 65: - case 66: - case 67: - case 68: - case 69: - case 70: - case 71: - case 72: - case 73: - case 74: - case 75: - case 76: - case 77: - case 78: - case 79: -// 101 "parser.php.lemon" -{ - if ((pppminor->pp0)) { - if ((pppminor->pp0)->free_flag) { - efree((pppminor->pp0)->token); +pp310: + ppch = *++PPCURSOR; + switch (ppch) { + case 'T': + case 't': goto pp332; + default: goto pp59; + } +pp311: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp334; + default: goto pp59; + } +pp312: + ppch = *++PPCURSOR; + switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp313; + } +pp313: + { + token->opcode = PHQL_T_USING; + return 0; } - efree((pppminor->pp0)); - } -} -// 826 "parser.php.c" - break; - case 82: - case 83: - case 84: - case 85: - case 86: - case 87: - case 89: - case 95: - case 96: - case 98: - case 99: - case 100: - case 101: - case 102: - case 103: - case 104: - case 105: - case 109: - case 110: - case 112: - case 113: - case 115: - case 116: - case 117: - case 119: - case 120: - case 121: - case 122: - case 123: - case 124: - case 125: - case 127: - case 130: - case 133: -// 114 "parser.php.lemon" -{ - zval_ptr_dtor(&(pppminor->pp202)); -} -// 866 "parser.php.c" - break; - case 88: - case 90: - case 91: - case 92: - case 93: - case 94: - case 106: - case 107: - case 114: - case 131: - case 132: -// 496 "parser.php.lemon" -{ - zephir_safe_zval_ptr_dtor((pppminor->pp202)); -} -// 883 "parser.php.c" - break; - default: break; /* If no destructor action specified: do nothing */ - } -} - -static int pp_pop_parser_stack(ppParser *pParser){ - PPCODETYPE ppmajor; - ppStackEntry *pptos = &pParser->ppstack[pParser->ppidx]; - - if( pParser->ppidx<0 ) return 0; -#ifndef NDEBUG - if( ppTraceFILE && pParser->ppidx>=0 ){ - fprintf(ppTraceFILE,"%sPopping %s\n", - ppTracePrompt, - ppTokenName[pptos->major]); - } -#endif - ppmajor = pptos->major; - pp_destructor( ppmajor, &pptos->minor); - pParser->ppidx--; - return ppmajor; -} - -static void phql_Free( - void *p, /* The parser to be deleted */ - void (*freeProc)(void*) /* Function used to reclaim memory */ -){ - ppParser *pParser = (ppParser*)p; - if( pParser==0 ) return; - while( pParser->ppidx>=0 ) pp_pop_parser_stack(pParser); - (*freeProc)((void*)pParser); -} - -static int pp_find_shift_action( - ppParser *pParser, /* The parser */ - int iLookAhead /* The look-ahead token */ -){ - int i; - int stateno = pParser->ppstack[pParser->ppidx].stateno; - - /* if( pParser->ppidx<0 ) return PP_NO_ACTION; */ - i = pp_shift_ofst[stateno]; - if( i==PP_SHIFT_USE_DFLT ){ - return pp_default[stateno]; - } - if( iLookAhead==PPNOCODE ){ - return PP_NO_ACTION; - } - i += iLookAhead; - if( i<0 || i>=PP_SZ_ACTTAB || pp_lookahead[i]!=iLookAhead ){ -#ifdef PPFALLBACK - int iFallback; /* Fallback token */ - if( iLookAhead %s\n", - ppTracePrompt, ppTokenName[iLookAhead], ppTokenName[iFallback]); - } -#endif - return pp_find_shift_action(pParser, iFallback); - } -#endif - return pp_default[stateno]; - }else{ - return pp_action[i]; - } -} - -static int pp_find_reduce_action( - ppParser *pParser, /* The parser */ - int iLookAhead /* The look-ahead token */ -){ - int i; - int stateno = pParser->ppstack[pParser->ppidx].stateno; - - i = pp_reduce_ofst[stateno]; - if( i==PP_REDUCE_USE_DFLT ){ - return pp_default[stateno]; - } - if( iLookAhead==PPNOCODE ){ - return PP_NO_ACTION; - } - i += iLookAhead; - if( i<0 || i>=PP_SZ_ACTTAB || pp_lookahead[i]!=iLookAhead ){ - return pp_default[stateno]; - }else{ - return pp_action[i]; - } -} - -static void pp_shift( - ppParser *pppParser, /* The parser to be shifted */ - int ppNewState, /* The new state to shift in */ - int ppMajor, /* The major token to shift in */ - PPMINORTYPE *pppMinor /* Pointer ot the minor token to shift in */ -){ - ppStackEntry *pptos; - pppParser->ppidx++; - if( pppParser->ppidx>=PPSTACKDEPTH ){ - phql_ARG_FETCH; - pppParser->ppidx--; -#ifndef NDEBUG - if( ppTraceFILE ){ - fprintf(ppTraceFILE,"%sStack Overflow!\n",ppTracePrompt); - } -#endif - while( pppParser->ppidx>=0 ) pp_pop_parser_stack(pppParser); - /* Here code is inserted which will execute if the parser - ** stack every overflows */ - phql_ARG_STORE; /* Suppress warning about unused %extra_argument var */ - return; - } - pptos = &pppParser->ppstack[pppParser->ppidx]; - pptos->stateno = ppNewState; - pptos->major = ppMajor; - pptos->minor = *pppMinor; -#ifndef NDEBUG - if( ppTraceFILE && pppParser->ppidx>0 ){ - int i; - fprintf(ppTraceFILE,"%sShift %d\n",ppTracePrompt,ppNewState); - fprintf(ppTraceFILE,"%sStack:",ppTracePrompt); - for(i=1; i<=pppParser->ppidx; i++) - fprintf(ppTraceFILE," %s",ppTokenName[pppParser->ppstack[i].major]); - fprintf(ppTraceFILE,"\n"); - } -#endif -} - -/* The following table contains information about every rule that -** is used during the reduce. -*/ -static struct { - PPCODETYPE lhs; /* Symbol on the left-hand side of the rule */ - unsigned char nrhs; /* Number of right-hand side symbols in the rule */ -} ppRuleInfo[] = { - { 81, 1 }, - { 82, 1 }, - { 82, 1 }, - { 82, 1 }, - { 82, 1 }, - { 83, 7 }, - { 87, 6 }, - { 94, 1 }, - { 94, 1 }, - { 94, 0 }, - { 95, 3 }, - { 95, 1 }, - { 98, 1 }, - { 98, 3 }, - { 98, 3 }, - { 98, 2 }, - { 98, 1 }, - { 96, 3 }, - { 96, 1 }, - { 97, 1 }, - { 97, 0 }, - { 101, 2 }, - { 101, 1 }, - { 102, 1 }, - { 103, 4 }, - { 106, 2 }, - { 106, 1 }, - { 106, 0 }, - { 104, 2 }, - { 104, 2 }, - { 104, 3 }, - { 104, 2 }, - { 104, 3 }, - { 104, 2 }, - { 104, 3 }, - { 104, 2 }, - { 104, 1 }, - { 107, 2 }, - { 107, 0 }, - { 84, 7 }, - { 84, 10 }, - { 108, 3 }, - { 108, 1 }, - { 111, 1 }, - { 109, 3 }, - { 109, 1 }, - { 112, 1 }, - { 85, 3 }, - { 113, 4 }, - { 115, 3 }, - { 115, 1 }, - { 116, 3 }, - { 118, 1 }, - { 86, 3 }, - { 119, 3 }, - { 100, 3 }, - { 100, 2 }, - { 100, 1 }, - { 100, 5 }, - { 100, 7 }, - { 100, 6 }, - { 100, 4 }, - { 100, 5 }, - { 100, 3 }, - { 121, 3 }, - { 121, 1 }, - { 120, 1 }, - { 105, 1 }, - { 88, 2 }, - { 88, 0 }, - { 91, 3 }, - { 91, 0 }, - { 122, 3 }, - { 122, 1 }, - { 123, 1 }, - { 123, 2 }, - { 123, 2 }, - { 89, 3 }, - { 89, 0 }, - { 124, 3 }, - { 124, 1 }, - { 125, 1 }, - { 90, 2 }, - { 90, 0 }, - { 93, 2 }, - { 93, 0 }, - { 92, 2 }, - { 92, 4 }, - { 92, 4 }, - { 92, 0 }, - { 114, 2 }, - { 114, 0 }, - { 126, 1 }, - { 126, 1 }, - { 126, 1 }, - { 126, 1 }, - { 126, 1 }, - { 99, 2 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 3 }, - { 99, 4 }, - { 99, 3 }, - { 99, 4 }, - { 99, 5 }, - { 99, 6 }, - { 99, 3 }, - { 99, 5 }, - { 99, 6 }, - { 99, 4 }, - { 99, 3 }, - { 99, 6 }, - { 99, 6 }, - { 99, 4 }, - { 128, 2 }, - { 128, 1 }, - { 129, 4 }, - { 129, 2 }, - { 99, 1 }, - { 130, 5 }, - { 131, 1 }, - { 131, 0 }, - { 132, 1 }, - { 132, 0 }, - { 127, 3 }, - { 127, 1 }, - { 133, 1 }, - { 133, 1 }, - { 99, 3 }, - { 99, 4 }, - { 99, 3 }, - { 99, 3 }, - { 99, 2 }, - { 99, 2 }, - { 99, 3 }, - { 99, 1 }, - { 99, 1 }, - { 99, 1 }, - { 99, 1 }, - { 99, 1 }, - { 99, 1 }, - { 99, 1 }, - { 99, 1 }, - { 99, 1 }, - { 99, 1 }, - { 99, 1 }, - { 117, 3 }, - { 117, 1 }, -}; - -static void pp_accept(ppParser*); /* Forward Declaration */ - -static void pp_reduce( - ppParser *pppParser, /* The parser */ - int ppruleno /* Number of the rule by which to reduce */ -){ - int ppgoto; /* The next state */ - int ppact; /* The next action */ - PPMINORTYPE ppgotominor; /* The LHS of the rule reduced */ - ppStackEntry *ppmsp; /* The top of the parser's stack */ - int ppsize; /* Amount to pop the stack */ - phql_ARG_FETCH; - ppmsp = &pppParser->ppstack[pppParser->ppidx]; -#ifndef NDEBUG - if( ppTraceFILE && ppruleno>=0 - && ppruleno - ** { ... } // User supplied code - ** // - ** break; - */ - case 0: -// 110 "parser.php.lemon" -{ - ZVAL_ZVAL(&status->ret, &ppmsp[0].minor.pp202, 1, 1); -} -// 1262 "parser.php.c" - break; - case 1: - case 2: - case 3: - case 4: - case 18: - case 19: - case 22: - case 23: - case 43: - case 50: - case 52: - case 65: - case 67: - case 73: - case 80: - case 81: - case 132: - case 136: - case 141: - case 149: -// 118 "parser.php.lemon" -{ - ppgotominor.pp202 = ppmsp[0].minor.pp202; -} -// 1288 "parser.php.c" - break; - case 5: -// 138 "parser.php.lemon" -{ - phql_ret_select_statement(&ppgotominor.pp202, &ppmsp[-6].minor.pp202, &ppmsp[-5].minor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[-4].minor.pp202, &ppmsp[-3].minor.pp202, &ppmsp[-1].minor.pp202, &ppmsp[0].minor.pp202); -} -// 1295 "parser.php.c" - break; - case 6: -// 146 "parser.php.lemon" -{ - phql_ret_select_clause(&ppgotominor.pp202, &ppmsp[-4].minor.pp202, &ppmsp[-3].minor.pp202, &ppmsp[-1].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(27,&ppmsp[-5].minor); - pp_destructor(28,&ppmsp[-2].minor); -} -// 1304 "parser.php.c" - break; - case 7: -// 154 "parser.php.lemon" -{ - phql_ret_distinct_all(&ppgotominor.pp202, 1); - pp_destructor(29,&ppmsp[0].minor); -} -// 1312 "parser.php.c" - break; - case 8: -// 158 "parser.php.lemon" -{ - phql_ret_distinct_all(&ppgotominor.pp202, 0); - pp_destructor(30,&ppmsp[0].minor); -} -// 1320 "parser.php.c" - break; - case 9: - case 20: - case 27: - case 38: - case 69: - case 71: - case 78: - case 83: - case 85: - case 89: - case 91: - case 135: - case 137: -// 162 "parser.php.lemon" -{ - ZVAL_UNDEF(&ppgotominor.pp202); -} -// 1339 "parser.php.c" - break; - case 10: - case 17: - case 41: - case 44: - case 49: - case 64: - case 72: - case 79: - case 138: -// 170 "parser.php.lemon" -{ - phql_ret_zval_list(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(26,&ppmsp[-1].minor); -} -// 1355 "parser.php.c" - break; - case 11: - case 42: - case 45: - case 129: - case 139: -// 174 "parser.php.lemon" -{ - phql_ret_zval_list(&ppgotominor.pp202, &ppmsp[0].minor.pp202, NULL); -} -// 1366 "parser.php.c" - break; - case 12: - case 140: -// 182 "parser.php.lemon" -{ - phql_ret_column_item(&ppgotominor.pp202, PHQL_T_STARALL, NULL, NULL, NULL); - pp_destructor(18,&ppmsp[0].minor); -} -// 1375 "parser.php.c" - break; - case 13: -// 186 "parser.php.lemon" -{ - phql_ret_column_item(&ppgotominor.pp202, PHQL_T_DOMAINALL, NULL, ppmsp[-2].minor.pp0, NULL); - pp_destructor(32,&ppmsp[-1].minor); - pp_destructor(18,&ppmsp[0].minor); -} -// 1384 "parser.php.c" - break; - case 14: -// 190 "parser.php.lemon" -{ - phql_ret_column_item(&ppgotominor.pp202, PHQL_T_EXPR, &ppmsp[-2].minor.pp202, NULL, ppmsp[0].minor.pp0); - pp_destructor(33,&ppmsp[-1].minor); -} -// 1392 "parser.php.c" - break; - case 15: -// 194 "parser.php.lemon" -{ - phql_ret_column_item(&ppgotominor.pp202, PHQL_T_EXPR, &ppmsp[-1].minor.pp202, NULL, ppmsp[0].minor.pp0); -} -// 1399 "parser.php.c" - break; - case 16: -// 198 "parser.php.lemon" -{ - phql_ret_column_item(&ppgotominor.pp202, PHQL_T_EXPR, &ppmsp[0].minor.pp202, NULL, NULL); -} -// 1406 "parser.php.c" - break; - case 21: - case 128: -// 226 "parser.php.lemon" -{ - phql_ret_zval_list(&ppgotominor.pp202, &ppmsp[-1].minor.pp202, &ppmsp[0].minor.pp202); -} -// 1414 "parser.php.c" - break; - case 24: -// 247 "parser.php.lemon" -{ - phql_ret_join_item(&ppgotominor.pp202, &ppmsp[-3].minor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[-1].minor.pp202, &ppmsp[0].minor.pp202); -} -// 1421 "parser.php.c" - break; - case 25: -// 255 "parser.php.lemon" -{ - phql_ret_qualified_name(&ppgotominor.pp202, NULL, NULL, ppmsp[0].minor.pp0); - pp_destructor(33,&ppmsp[-1].minor); -} -// 1429 "parser.php.c" - break; - case 26: - case 46: - case 66: - case 161: -// 259 "parser.php.lemon" -{ - phql_ret_qualified_name(&ppgotominor.pp202, NULL, NULL, ppmsp[0].minor.pp0); -} -// 1439 "parser.php.c" - break; - case 28: -// 271 "parser.php.lemon" -{ - phql_ret_join_type(&ppgotominor.pp202, PHQL_T_INNERJOIN); - pp_destructor(34,&ppmsp[-1].minor); - pp_destructor(35,&ppmsp[0].minor); -} -// 1448 "parser.php.c" - break; - case 29: -// 275 "parser.php.lemon" -{ - phql_ret_join_type(&ppgotominor.pp202, PHQL_T_CROSSJOIN); - pp_destructor(36,&ppmsp[-1].minor); - pp_destructor(35,&ppmsp[0].minor); -} -// 1457 "parser.php.c" - break; - case 30: -// 279 "parser.php.lemon" -{ - phql_ret_join_type(&ppgotominor.pp202, PHQL_T_LEFTJOIN); - pp_destructor(37,&ppmsp[-2].minor); - pp_destructor(38,&ppmsp[-1].minor); - pp_destructor(35,&ppmsp[0].minor); -} -// 1467 "parser.php.c" - break; - case 31: -// 283 "parser.php.lemon" -{ - phql_ret_join_type(&ppgotominor.pp202, PHQL_T_LEFTJOIN); - pp_destructor(37,&ppmsp[-1].minor); - pp_destructor(35,&ppmsp[0].minor); -} -// 1476 "parser.php.c" - break; - case 32: -// 287 "parser.php.lemon" -{ - phql_ret_join_type(&ppgotominor.pp202, PHQL_T_RIGHTJOIN); - pp_destructor(39,&ppmsp[-2].minor); - pp_destructor(38,&ppmsp[-1].minor); - pp_destructor(35,&ppmsp[0].minor); -} -// 1486 "parser.php.c" - break; - case 33: -// 291 "parser.php.lemon" -{ - phql_ret_join_type(&ppgotominor.pp202, PHQL_T_RIGHTJOIN); - pp_destructor(39,&ppmsp[-1].minor); - pp_destructor(35,&ppmsp[0].minor); -} -// 1495 "parser.php.c" - break; - case 34: -// 295 "parser.php.lemon" -{ - phql_ret_join_type(&ppgotominor.pp202, PHQL_T_FULLJOIN); - pp_destructor(40,&ppmsp[-2].minor); - pp_destructor(38,&ppmsp[-1].minor); - pp_destructor(35,&ppmsp[0].minor); -} -// 1505 "parser.php.c" - break; - case 35: -// 299 "parser.php.lemon" -{ - phql_ret_join_type(&ppgotominor.pp202, PHQL_T_FULLJOIN); - pp_destructor(40,&ppmsp[-1].minor); - pp_destructor(35,&ppmsp[0].minor); -} -// 1514 "parser.php.c" - break; - case 36: -// 303 "parser.php.lemon" -{ - phql_ret_join_type(&ppgotominor.pp202, PHQL_T_INNERJOIN); - pp_destructor(35,&ppmsp[0].minor); -} -// 1522 "parser.php.c" - break; - case 37: -// 311 "parser.php.lemon" -{ - ppgotominor.pp202 = ppmsp[0].minor.pp202; - pp_destructor(41,&ppmsp[-1].minor); -} -// 1530 "parser.php.c" - break; - case 39: -// 324 "parser.php.lemon" -{ - phql_ret_insert_statement(&ppgotominor.pp202, &ppmsp[-4].minor.pp202, NULL, &ppmsp[-1].minor.pp202); - pp_destructor(42,&ppmsp[-6].minor); - pp_destructor(43,&ppmsp[-5].minor); - pp_destructor(44,&ppmsp[-3].minor); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); -} -// 1542 "parser.php.c" - break; - case 40: -// 328 "parser.php.lemon" -{ - phql_ret_insert_statement(&ppgotominor.pp202, &ppmsp[-7].minor.pp202, &ppmsp[-5].minor.pp202, &ppmsp[-1].minor.pp202); - pp_destructor(42,&ppmsp[-9].minor); - pp_destructor(43,&ppmsp[-8].minor); - pp_destructor(45,&ppmsp[-6].minor); - pp_destructor(46,&ppmsp[-4].minor); - pp_destructor(44,&ppmsp[-3].minor); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); -} -// 1556 "parser.php.c" - break; - case 47: -// 374 "parser.php.lemon" -{ - phql_ret_update_statement(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[-1].minor.pp202, &ppmsp[0].minor.pp202); -} -// 1563 "parser.php.c" - break; - case 48: -// 382 "parser.php.lemon" -{ - phql_ret_update_clause(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(47,&ppmsp[-3].minor); - pp_destructor(48,&ppmsp[-1].minor); -} -// 1572 "parser.php.c" - break; - case 51: -// 402 "parser.php.lemon" -{ - phql_ret_update_item(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(4,&ppmsp[-1].minor); -} -// 1580 "parser.php.c" - break; - case 53: -// 416 "parser.php.lemon" -{ - phql_ret_delete_statement(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[-1].minor.pp202, &ppmsp[0].minor.pp202); -} -// 1587 "parser.php.c" - break; - case 54: -// 424 "parser.php.lemon" -{ - phql_ret_delete_clause(&ppgotominor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(49,&ppmsp[-2].minor); - pp_destructor(28,&ppmsp[-1].minor); -} -// 1596 "parser.php.c" - break; - case 55: -// 432 "parser.php.lemon" -{ - phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, ppmsp[0].minor.pp0, NULL); - pp_destructor(33,&ppmsp[-1].minor); -} -// 1604 "parser.php.c" - break; - case 56: -// 436 "parser.php.lemon" -{ - phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-1].minor.pp202, ppmsp[0].minor.pp0, NULL); -} -// 1611 "parser.php.c" - break; - case 57: -// 440 "parser.php.lemon" -{ - phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[0].minor.pp202, NULL, NULL); -} -// 1618 "parser.php.c" - break; - case 58: -// 444 "parser.php.lemon" -{ - phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-4].minor.pp202, ppmsp[-2].minor.pp0, &ppmsp[0].minor.pp202); - pp_destructor(33,&ppmsp[-3].minor); - pp_destructor(50,&ppmsp[-1].minor); -} -// 1627 "parser.php.c" - break; - case 59: -// 448 "parser.php.lemon" -{ - phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-6].minor.pp202, ppmsp[-4].minor.pp0, &ppmsp[-1].minor.pp202); - pp_destructor(33,&ppmsp[-5].minor); - pp_destructor(50,&ppmsp[-3].minor); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); -} -// 1638 "parser.php.c" - break; - case 60: -// 452 "parser.php.lemon" -{ - phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-5].minor.pp202, ppmsp[-4].minor.pp0, &ppmsp[-1].minor.pp202); - pp_destructor(50,&ppmsp[-3].minor); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); -} -// 1648 "parser.php.c" - break; - case 61: -// 456 "parser.php.lemon" -{ - phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-3].minor.pp202, ppmsp[-2].minor.pp0, &ppmsp[0].minor.pp202); - pp_destructor(50,&ppmsp[-1].minor); -} -// 1656 "parser.php.c" - break; - case 62: -// 460 "parser.php.lemon" -{ - phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-4].minor.pp202, NULL, &ppmsp[-1].minor.pp202); - pp_destructor(50,&ppmsp[-3].minor); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); -} -// 1666 "parser.php.c" - break; - case 63: -// 464 "parser.php.lemon" -{ - phql_ret_assoc_name(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, NULL, &ppmsp[0].minor.pp202); - pp_destructor(50,&ppmsp[-1].minor); -} -// 1674 "parser.php.c" - break; - case 68: -// 500 "parser.php.lemon" -{ - ppgotominor.pp202 = ppmsp[0].minor.pp202; - pp_destructor(51,&ppmsp[-1].minor); -} -// 1682 "parser.php.c" - break; - case 70: -// 512 "parser.php.lemon" -{ - ppgotominor.pp202 = ppmsp[0].minor.pp202; - pp_destructor(52,&ppmsp[-2].minor); - pp_destructor(53,&ppmsp[-1].minor); -} -// 1691 "parser.php.c" - break; - case 74: -// 536 "parser.php.lemon" -{ - phql_ret_order_item(&ppgotominor.pp202, &ppmsp[0].minor.pp202, 0); -} -// 1698 "parser.php.c" - break; - case 75: -// 540 "parser.php.lemon" -{ - phql_ret_order_item(&ppgotominor.pp202, &ppmsp[-1].minor.pp202, PHQL_T_ASC); - pp_destructor(54,&ppmsp[0].minor); -} -// 1706 "parser.php.c" - break; - case 76: -// 544 "parser.php.lemon" -{ - phql_ret_order_item(&ppgotominor.pp202, &ppmsp[-1].minor.pp202, PHQL_T_DESC); - pp_destructor(55,&ppmsp[0].minor); -} -// 1714 "parser.php.c" - break; - case 77: -// 552 "parser.php.lemon" -{ - ppgotominor.pp202 = ppmsp[0].minor.pp202; - pp_destructor(56,&ppmsp[-2].minor); - pp_destructor(53,&ppmsp[-1].minor); -} -// 1723 "parser.php.c" - break; - case 82: -// 584 "parser.php.lemon" -{ - ppgotominor.pp202 = ppmsp[0].minor.pp202; - pp_destructor(57,&ppmsp[-1].minor); -} -// 1731 "parser.php.c" - break; - case 84: -// 596 "parser.php.lemon" -{ - phql_ret_for_update_clause(&ppgotominor.pp202); - pp_destructor(58,&ppmsp[-1].minor); - pp_destructor(47,&ppmsp[0].minor); -} -// 1740 "parser.php.c" - break; - case 86: - case 90: -// 608 "parser.php.lemon" -{ - phql_ret_limit_clause(&ppgotominor.pp202, &ppmsp[0].minor.pp202, NULL); - pp_destructor(59,&ppmsp[-1].minor); -} -// 1749 "parser.php.c" - break; - case 87: -// 612 "parser.php.lemon" -{ - phql_ret_limit_clause(&ppgotominor.pp202, &ppmsp[0].minor.pp202, &ppmsp[-2].minor.pp202); - pp_destructor(59,&ppmsp[-3].minor); - pp_destructor(26,&ppmsp[-1].minor); -} -// 1758 "parser.php.c" - break; - case 88: -// 616 "parser.php.lemon" -{ - phql_ret_limit_clause(&ppgotominor.pp202, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(59,&ppmsp[-3].minor); - pp_destructor(60,&ppmsp[-1].minor); -} -// 1767 "parser.php.c" - break; - case 92: - case 150: -// 636 "parser.php.lemon" -{ - phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_INTEGER, ppmsp[0].minor.pp0); -} -// 1775 "parser.php.c" - break; - case 93: - case 151: -// 640 "parser.php.lemon" -{ - phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_HINTEGER, ppmsp[0].minor.pp0); -} -// 1783 "parser.php.c" - break; - case 94: - case 157: -// 644 "parser.php.lemon" -{ - phql_ret_placeholder_zval(&ppgotominor.pp202, PHQL_T_NPLACEHOLDER, ppmsp[0].minor.pp0); -} -// 1791 "parser.php.c" - break; - case 95: - case 158: -// 648 "parser.php.lemon" -{ - phql_ret_placeholder_zval(&ppgotominor.pp202, PHQL_T_SPLACEHOLDER, ppmsp[0].minor.pp0); -} -// 1799 "parser.php.c" - break; - case 96: - case 159: -// 652 "parser.php.lemon" -{ - phql_ret_placeholder_zval(&ppgotominor.pp202, PHQL_T_BPLACEHOLDER, ppmsp[0].minor.pp0); -} -// 1807 "parser.php.c" - break; - case 97: -// 660 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_MINUS, NULL, &ppmsp[0].minor.pp202); - pp_destructor(21,&ppmsp[-1].minor); -} -// 1815 "parser.php.c" - break; - case 98: -// 664 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_SUB, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(21,&ppmsp[-1].minor); -} -// 1823 "parser.php.c" - break; - case 99: -// 668 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_ADD, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(20,&ppmsp[-1].minor); -} -// 1831 "parser.php.c" - break; - case 100: -// 672 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_MUL, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(18,&ppmsp[-1].minor); -} -// 1839 "parser.php.c" - break; - case 101: -// 676 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_DIV, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(17,&ppmsp[-1].minor); -} -// 1847 "parser.php.c" - break; - case 102: -// 680 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_MOD, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(19,&ppmsp[-1].minor); -} -// 1855 "parser.php.c" - break; - case 103: -// 684 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_AND, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(10,&ppmsp[-1].minor); -} -// 1863 "parser.php.c" - break; - case 104: -// 688 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_OR, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(11,&ppmsp[-1].minor); -} -// 1871 "parser.php.c" - break; - case 105: -// 692 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_BITWISE_AND, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(14,&ppmsp[-1].minor); -} -// 1879 "parser.php.c" - break; - case 106: -// 696 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_BITWISE_OR, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(15,&ppmsp[-1].minor); -} -// 1887 "parser.php.c" - break; - case 107: -// 700 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_BITWISE_XOR, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(16,&ppmsp[-1].minor); -} -// 1895 "parser.php.c" - break; - case 108: -// 704 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_EQUALS, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(4,&ppmsp[-1].minor); -} -// 1903 "parser.php.c" - break; - case 109: -// 708 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_NOTEQUALS, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(5,&ppmsp[-1].minor); -} -// 1911 "parser.php.c" - break; - case 110: -// 712 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_LESS, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(6,&ppmsp[-1].minor); -} -// 1919 "parser.php.c" - break; - case 111: -// 716 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_GREATER, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(7,&ppmsp[-1].minor); -} -// 1927 "parser.php.c" - break; - case 112: -// 720 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_GREATEREQUAL, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(8,&ppmsp[-1].minor); -} -// 1935 "parser.php.c" - break; - case 113: -// 724 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_LESSEQUAL, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(9,&ppmsp[-1].minor); -} -// 1943 "parser.php.c" - break; - case 114: -// 728 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_LIKE, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(12,&ppmsp[-1].minor); -} -// 1951 "parser.php.c" - break; - case 115: -// 732 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_NLIKE, &ppmsp[-3].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(24,&ppmsp[-2].minor); - pp_destructor(12,&ppmsp[-1].minor); -} -// 1960 "parser.php.c" - break; - case 116: -// 736 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_ILIKE, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(13,&ppmsp[-1].minor); -} -// 1968 "parser.php.c" - break; - case 117: -// 740 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_NILIKE, &ppmsp[-3].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(24,&ppmsp[-2].minor); - pp_destructor(13,&ppmsp[-1].minor); -} -// 1977 "parser.php.c" - break; - case 118: - case 121: -// 744 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_IN, &ppmsp[-4].minor.pp202, &ppmsp[-1].minor.pp202); - pp_destructor(23,&ppmsp[-3].minor); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); -} -// 1988 "parser.php.c" - break; - case 119: - case 122: -// 748 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_NOTIN, &ppmsp[-5].minor.pp202, &ppmsp[-1].minor.pp202); - pp_destructor(24,&ppmsp[-4].minor); - pp_destructor(23,&ppmsp[-3].minor); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); -} -// 2000 "parser.php.c" - break; - case 120: -// 752 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_SUBQUERY, &ppmsp[-1].minor.pp202, NULL); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); -} -// 2009 "parser.php.c" - break; - case 123: -// 764 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_EXISTS, NULL, &ppmsp[-1].minor.pp202); - pp_destructor(66,&ppmsp[-3].minor); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); -} -// 2019 "parser.php.c" - break; - case 124: -// 768 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_AGAINST, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(1,&ppmsp[-1].minor); -} -// 2027 "parser.php.c" - break; - case 125: -// 772 "parser.php.lemon" -{ - { - zval qualified; - phql_ret_raw_qualified_name(&qualified, ppmsp[-1].minor.pp0, NULL); - phql_ret_expr(&ppgotominor.pp202, PHQL_T_CAST, &ppmsp[-3].minor.pp202, &qualified); - } - pp_destructor(67,&ppmsp[-5].minor); - pp_destructor(45,&ppmsp[-4].minor); - pp_destructor(33,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); -} -// 2042 "parser.php.c" - break; - case 126: -// 780 "parser.php.lemon" -{ - { - zval qualified; - phql_ret_raw_qualified_name(&qualified, ppmsp[-1].minor.pp0, NULL); - phql_ret_expr(&ppgotominor.pp202, PHQL_T_CONVERT, &ppmsp[-3].minor.pp202, &qualified); - } - pp_destructor(68,&ppmsp[-5].minor); - pp_destructor(45,&ppmsp[-4].minor); - pp_destructor(69,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); -} -// 2057 "parser.php.c" - break; - case 127: -// 788 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_CASE, &ppmsp[-2].minor.pp202, &ppmsp[-1].minor.pp202); - pp_destructor(70,&ppmsp[-3].minor); - pp_destructor(71,&ppmsp[0].minor); -} -// 2066 "parser.php.c" - break; - case 130: -// 800 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_WHEN, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(72,&ppmsp[-3].minor); - pp_destructor(73,&ppmsp[-1].minor); -} -// 2075 "parser.php.c" - break; - case 131: -// 804 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_ELSE, &ppmsp[0].minor.pp202, NULL); - pp_destructor(74,&ppmsp[-1].minor); -} -// 2083 "parser.php.c" - break; - case 133: -// 816 "parser.php.lemon" -{ - phql_ret_func_call(&ppgotominor.pp202, ppmsp[-4].minor.pp0, &ppmsp[-1].minor.pp202, &ppmsp[-2].minor.pp202); - pp_destructor(45,&ppmsp[-3].minor); - pp_destructor(46,&ppmsp[0].minor); -} -// 2092 "parser.php.c" - break; - case 134: -// 824 "parser.php.lemon" -{ - phql_ret_distinct(&ppgotominor.pp202); - pp_destructor(29,&ppmsp[0].minor); -} -// 2100 "parser.php.c" - break; - case 142: -// 868 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_ISNULL, &ppmsp[-2].minor.pp202, NULL); - pp_destructor(22,&ppmsp[-1].minor); - pp_destructor(75,&ppmsp[0].minor); -} -// 2109 "parser.php.c" - break; - case 143: -// 872 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_ISNOTNULL, &ppmsp[-3].minor.pp202, NULL); - pp_destructor(22,&ppmsp[-2].minor); - pp_destructor(24,&ppmsp[-1].minor); - pp_destructor(75,&ppmsp[0].minor); -} -// 2119 "parser.php.c" - break; - case 144: -// 876 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_BETWEEN, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(2,&ppmsp[-1].minor); -} -// 2127 "parser.php.c" - break; - case 145: -// 880 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_BETWEEN_NOT, &ppmsp[-2].minor.pp202, &ppmsp[0].minor.pp202); - pp_destructor(3,&ppmsp[-1].minor); -} -// 2135 "parser.php.c" - break; - case 146: -// 884 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_NOT, NULL, &ppmsp[0].minor.pp202); - pp_destructor(24,&ppmsp[-1].minor); -} -// 2143 "parser.php.c" - break; - case 147: -// 888 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_BITWISE_NOT, NULL, &ppmsp[0].minor.pp202); - pp_destructor(25,&ppmsp[-1].minor); -} -// 2151 "parser.php.c" - break; - case 148: -// 892 "parser.php.lemon" -{ - phql_ret_expr(&ppgotominor.pp202, PHQL_T_ENCLOSED, &ppmsp[-1].minor.pp202, NULL); - pp_destructor(45,&ppmsp[-2].minor); - pp_destructor(46,&ppmsp[0].minor); -} -// 2160 "parser.php.c" - break; - case 152: -// 908 "parser.php.lemon" -{ - phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_STRING, ppmsp[0].minor.pp0); -} -// 2167 "parser.php.c" - break; - case 153: -// 912 "parser.php.lemon" -{ - phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_DOUBLE, ppmsp[0].minor.pp0); -} -// 2174 "parser.php.c" - break; - case 154: -// 916 "parser.php.lemon" -{ - phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_NULL, NULL); - pp_destructor(75,&ppmsp[0].minor); -} -// 2182 "parser.php.c" - break; - case 155: -// 920 "parser.php.lemon" -{ - phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_TRUE, NULL); - pp_destructor(78,&ppmsp[0].minor); -} -// 2190 "parser.php.c" - break; - case 156: -// 924 "parser.php.lemon" -{ - phql_ret_literal_zval(&ppgotominor.pp202, PHQL_T_FALSE, NULL); - pp_destructor(79,&ppmsp[0].minor); -} -// 2198 "parser.php.c" - break; - case 160: -// 947 "parser.php.lemon" -{ - phql_ret_qualified_name(&ppgotominor.pp202, NULL, ppmsp[-2].minor.pp0, ppmsp[0].minor.pp0); - pp_destructor(32,&ppmsp[-1].minor); -} -// 2206 "parser.php.c" - break; - }; - ppgoto = ppRuleInfo[ppruleno].lhs; - ppsize = ppRuleInfo[ppruleno].nrhs; - pppParser->ppidx -= ppsize; - ppact = pp_find_reduce_action(pppParser,ppgoto); - if( ppact < PPNSTATE ){ - pp_shift(pppParser,ppact,ppgoto,&ppgotominor); - }else if( ppact == PPNSTATE + PPNRULE + 1 ){ - pp_accept(pppParser); - } -} - -static void pp_parse_failed( - ppParser *pppParser /* The parser */ -){ - phql_ARG_FETCH; -#ifndef NDEBUG - if( ppTraceFILE ){ - fprintf(ppTraceFILE,"%sFail!\n",ppTracePrompt); - } -#endif - while( pppParser->ppidx>=0 ) pp_pop_parser_stack(pppParser); - /* Here code is inserted which will be executed whenever the - ** parser fails */ - phql_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} - -static void pp_syntax_error( - ppParser *pppParser, /* The parser */ - int ppmajor, /* The major type of the error token */ - PPMINORTYPE ppminor /* The minor type of the error token */ -){ - phql_ARG_FETCH; -#define PPTOKEN (ppminor.pp0) -// 34 "parser.php.lemon" - - if (status->scanner_state->start_length) { - { - - char *token_name = NULL; - int token_found = 0; - unsigned int token_length; - const phql_token_names *tokens = phql_tokens; - int active_token = status->scanner_state->active_token; - int near_length = status->scanner_state->start_length; - - if (active_token) { - - do { - if (tokens->code == active_token) { - token_name = tokens->name; - token_length = tokens->length; - token_found = 1; - break; - } - ++tokens; - } while (tokens[0].code != 0); - - } - - if (!token_name) { - token_length = strlen("UNKNOWN"); - token_name = estrndup("UNKNOWN", token_length); - token_found = 0; - } - - status->syntax_error_len = 96 + status->token->len + token_length + near_length + status->phql_length;; - status->syntax_error = emalloc(sizeof(char) * status->syntax_error_len); - - if (near_length > 0) { - if (status->token->value) { - snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected token %s(%s), near to '%s', when parsing: %s (%d)", token_name, status->token->value, status->scanner_state->start, status->phql, status->phql_length); - } else { - snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected token %s, near to '%s', when parsing: %s (%d)", token_name, status->scanner_state->start, status->phql, status->phql_length); - } - } else { - if (active_token != PHQL_T_IGNORE) { - if (status->token->value) { - snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected token %s(%s), at the end of query, when parsing: %s (%d)", token_name, status->token->value, status->phql, status->phql_length); - } else { - snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected token %s, at the end of query, when parsing: %s (%d)", token_name, status->phql, status->phql_length); - } - } else { - snprintf(status->syntax_error, status->syntax_error_len, "Syntax error, unexpected EOF, at the end of query"); - } - status->syntax_error[status->syntax_error_len - 1] = '\0'; - } - - if (!token_found) { - if (token_name) { - efree(token_name); - } - } - } - } else { - status->syntax_error_len = strlen("Syntax error, unexpected EOF"); - status->syntax_error = estrndup("Syntax error, unexpected EOF", status->syntax_error_len); - } - - status->status = PHQL_PARSING_FAILED; - -// 2315 "parser.php.c" - phql_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} - -static void pp_accept( - ppParser *pppParser /* The parser */ -){ - phql_ARG_FETCH; -#ifndef NDEBUG - if( ppTraceFILE ){ - fprintf(ppTraceFILE,"%sAccept!\n",ppTracePrompt); - } -#endif - while( pppParser->ppidx>=0 ) pp_pop_parser_stack(pppParser); - /* Here code is inserted which will be executed whenever the - ** parser accepts */ - phql_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} - -/* The main parser program. -** The first argument is a pointer to a structure obtained from -** "phql_Alloc" which describes the current state of the parser. -** The second argument is the major token number. The third is -** the minor token. The fourth optional argument is whatever the -** user wants (and specified in the grammar) and is available for -** use by the action routines. -** -** Inputs: -**
    -**
  • A pointer to the parser (an opaque structure.) -**
  • The major token number. -**
  • The minor token number. -**
  • An option argument of a grammar-specified type. -**
-** -** Outputs: -** None. -*/ -static void phql_( - void *ppp, /* The parser */ - int ppmajor, /* The major token code number */ - phql_TOKENTYPE ppminor /* The value for the token */ - phql_ARG_PDECL /* Optional %extra_argument parameter */ -){ - PPMINORTYPE ppminorunion; - int ppact; /* The parser action. */ - int ppendofinput; /* True if we are at the end of input */ - int pperrorhit = 0; /* True if ppmajor has invoked an error */ - ppParser *pppParser; /* The parser */ - - /* (re)initialize the parser, if necessary */ - pppParser = (ppParser*)ppp; - if( pppParser->ppidx<0 ){ - if( ppmajor==0 ) return; - pppParser->ppidx = 0; - pppParser->pperrcnt = -1; - pppParser->ppstack[0].stateno = 0; - pppParser->ppstack[0].major = 0; - } - ppminorunion.pp0 = ppminor; - ppendofinput = (ppmajor==0); - phql_ARG_STORE; - -#ifndef NDEBUG - if( ppTraceFILE ){ - fprintf(ppTraceFILE,"%sInput %s\n",ppTracePrompt,ppTokenName[ppmajor]); - } -#endif - - do{ - ppact = pp_find_shift_action(pppParser,ppmajor); - if( ppactpperrcnt--; - if( ppendofinput && pppParser->ppidx>=0 ){ - ppmajor = 0; - }else{ - ppmajor = PPNOCODE; - } - }else if( ppact < PPNSTATE + PPNRULE ){ - pp_reduce(pppParser,ppact-PPNSTATE); - }else if( ppact == PP_ERROR_ACTION ){ - int ppmx; -#ifndef NDEBUG - if( ppTraceFILE ){ - fprintf(ppTraceFILE,"%sSyntax Error!\n",ppTracePrompt); - } -#endif -#ifdef PPERRORSYMBOL - /* A syntax error has occurred. - ** The response to an error depends upon whether or not the - ** grammar defines an error token "ERROR". - ** - ** This is what we do if the grammar does define ERROR: - ** - ** * Call the %syntax_error function. - ** - ** * Begin popping the stack until we enter a state where - ** it is legal to shift the error symbol, then shift - ** the error symbol. - ** - ** * Set the error count to three. - ** - ** * Begin accepting and shifting new tokens. No new error - ** processing will occur until three tokens have been - ** shifted successfully. - ** - */ - if( pppParser->pperrcnt<0 ){ - pp_syntax_error(pppParser,ppmajor,ppminorunion); - } - ppmx = pppParser->ppstack[pppParser->ppidx].major; - if( ppmx==PPERRORSYMBOL || pperrorhit ){ -#ifndef NDEBUG - if( ppTraceFILE ){ - fprintf(ppTraceFILE,"%sDiscard input token %s\n", - ppTracePrompt,ppTokenName[ppmajor]); - } -#endif - pp_destructor(ppmajor,&ppminorunion); - ppmajor = PPNOCODE; - }else{ - while( - pppParser->ppidx >= 0 && - ppmx != PPERRORSYMBOL && - (ppact = pp_find_shift_action(pppParser,PPERRORSYMBOL)) >= PPNSTATE - ){ - pp_pop_parser_stack(pppParser); - } - if( pppParser->ppidx < 0 || ppmajor==0 ){ - pp_destructor(ppmajor,&ppminorunion); - pp_parse_failed(pppParser); - ppmajor = PPNOCODE; - }else if( ppmx!=PPERRORSYMBOL ){ - PPMINORTYPE u2; - u2.PPERRSYMDT = 0; - pp_shift(pppParser,ppact,PPERRORSYMBOL,&u2); - } - } - pppParser->pperrcnt = 3; - pperrorhit = 1; -#else /* PPERRORSYMBOL is not defined */ - /* This is what we do if the grammar does not define ERROR: - ** - ** * Report an error message, and throw away the input token. - ** - ** * If the input token is $, then fail the parse. - ** - ** As before, subsequent error messages are suppressed until - ** three input tokens have been successfully shifted. - */ - if( pppParser->pperrcnt<=0 ){ - pp_syntax_error(pppParser,ppmajor,ppminorunion); - } - pppParser->pperrcnt = 3; - pp_destructor(ppmajor,&ppminorunion); - if( ppendofinput ){ - pp_parse_failed(pppParser); - } - ppmajor = PPNOCODE; -#endif - }else{ - pp_accept(pppParser); - ppmajor = PPNOCODE; - } - }while( ppmajor!=PPNOCODE && pppParser->ppidx>=0 ); - return; -} -/* base.c - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the - * LICENSE.txt file that was distributed with this source code. - */ - -const phql_token_names phql_tokens[] = -{ - { SL("INTEGER"), PHQL_T_INTEGER }, - { SL("DOUBLE"), PHQL_T_DOUBLE }, - { SL("STRING"), PHQL_T_STRING }, - { SL("IDENTIFIER"), PHQL_T_IDENTIFIER }, - { SL("HEXAINTEGER"), PHQL_T_HINTEGER }, - { SL("MINUS"), PHQL_T_MINUS }, - { SL("+"), PHQL_T_ADD }, - { SL("-"), PHQL_T_SUB }, - { SL("*"), PHQL_T_MUL }, - { SL("/"), PHQL_T_DIV }, - { SL("&"), PHQL_T_BITWISE_AND }, - { SL("|"), PHQL_T_BITWISE_OR }, - { SL("%%"), PHQL_T_MOD }, - { SL("AND"), PHQL_T_AND }, - { SL("OR"), PHQL_T_OR }, - { SL("LIKE"), PHQL_T_LIKE }, - { SL("ILIKE"), PHQL_T_ILIKE }, - { SL("DOT"), PHQL_T_DOT }, - { SL("COLON"), PHQL_T_COLON }, - { SL("COMMA"), PHQL_T_COMMA }, - { SL("EQUALS"), PHQL_T_EQUALS }, - { SL("NOT EQUALS"), PHQL_T_NOTEQUALS }, - { SL("NOT"), PHQL_T_NOT }, - { SL("<"), PHQL_T_LESS }, - { SL("<="), PHQL_T_LESSEQUAL }, - { SL(">"), PHQL_T_GREATER }, - { SL(">="), PHQL_T_GREATEREQUAL }, - { SL("("), PHQL_T_PARENTHESES_OPEN }, - { SL(")"), PHQL_T_PARENTHESES_CLOSE }, - { SL("NUMERIC PLACEHOLDER"), PHQL_T_NPLACEHOLDER }, - { SL("STRING PLACEHOLDER"), PHQL_T_SPLACEHOLDER }, - { SL("UPDATE"), PHQL_T_UPDATE }, - { SL("SET"), PHQL_T_SET }, - { SL("WHERE"), PHQL_T_WHERE }, - { SL("DELETE"), PHQL_T_DELETE }, - { SL("FROM"), PHQL_T_FROM }, - { SL("AS"), PHQL_T_AS }, - { SL("INSERT"), PHQL_T_INSERT }, - { SL("INTO"), PHQL_T_INTO }, - { SL("VALUES"), PHQL_T_VALUES }, - { SL("SELECT"), PHQL_T_SELECT }, - { SL("ORDER"), PHQL_T_ORDER }, - { SL("BY"), PHQL_T_BY }, - { SL("LIMIT"), PHQL_T_LIMIT }, - { SL("OFFSET"), PHQL_T_OFFSET }, - { SL("GROUP"), PHQL_T_GROUP }, - { SL("HAVING"), PHQL_T_HAVING }, - { SL("IN"), PHQL_T_IN }, - { SL("ON"), PHQL_T_ON }, - { SL("INNER"), PHQL_T_INNER }, - { SL("JOIN"), PHQL_T_JOIN }, - { SL("LEFT"), PHQL_T_LEFT }, - { SL("RIGHT"), PHQL_T_RIGHT }, - { SL("IS"), PHQL_T_IS }, - { SL("NULL"), PHQL_T_NULL }, - { SL("NOT IN"), PHQL_T_NOTIN }, - { SL("CROSS"), PHQL_T_CROSS }, - { SL("OUTER"), PHQL_T_OUTER }, - { SL("FULL"), PHQL_T_FULL }, - { SL("ASC"), PHQL_T_ASC }, - { SL("DESC"), PHQL_T_DESC }, - { SL("BETWEEN"), PHQL_T_BETWEEN }, - { SL("DISTINCT"), PHQL_T_DISTINCT }, - { SL("AGAINST"), PHQL_T_AGAINST }, - { SL("CAST"), PHQL_T_CAST }, - { SL("CONVERT"), PHQL_T_CONVERT }, - { SL("USING"), PHQL_T_USING }, - { SL("ALL"), PHQL_T_ALL }, - { SL("EXISTS"), PHQL_T_EXISTS }, - { SL("CASE"), PHQL_T_CASE }, - { SL("WHEN"), PHQL_T_WHEN }, - { SL("THEN"), PHQL_T_THEN }, - { SL("ELSE"), PHQL_T_ELSE }, - { SL("END"), PHQL_T_END }, - { SL("FOR"), PHQL_T_FOR }, - { SL("WITH"), PHQL_T_WITH }, - { NULL, 0, 0 } -}; - -static void *phql_wrapper_alloc(size_t bytes) -{ - return emalloc(bytes); -} - -static void phql_wrapper_free(void *pointer) -{ - efree(pointer); -} - -static void phql_parse_with_token(void* phql_parser, int opcode, int parsercode, phql_scanner_token *token, phql_parser_status *parser_status) -{ - - phql_parser_token *pToken; - - pToken = emalloc(sizeof(phql_parser_token)); - pToken->opcode = opcode; - pToken->token = token->value; - pToken->token_len = token->len; - pToken->free_flag = 1; - phql_(phql_parser, parsercode, pToken, parser_status); - - token->value = NULL; - token->len = 0; -} - -static void phql_scanner_error_msg(phql_parser_status *parser_status, zval **error_msg) -{ - - char *error = NULL, *error_part; - unsigned int length; - phql_scanner_state *state = parser_status->scanner_state; - - ZVAL_UNDEF(*error_msg); - - if (state->start) { - length = 64 + state->start_length + parser_status->phql_length; - error = emalloc(sizeof(char) * length); - if (state->start_length > 16) { - error_part = estrndup(state->start, 16); - snprintf(error, length, "Scanning error before '%s...' when parsing: %s (%d)", error_part, parser_status->phql, parser_status->phql_length); - efree(error_part); - } else { - snprintf(error, length, "Scanning error before '%s' when parsing: %s (%d)", state->start, parser_status->phql, parser_status->phql_length); - } - error[length - 1] = '\0'; - ZVAL_STRING(*error_msg, error); - } else { - ZVAL_STRING(*error_msg, "Scanning error near to EOF"); - } - - if (error) { - efree(error); - } -} - -static int phql_parse_phql(zval *result, zval *phql) -{ - zval err_msg, *error_msg = &err_msg; - ZVAL_UNDEF(error_msg); - ZVAL_NULL(result); - - if (phql_internal_parse_phql(&result, Z_STRVAL_P(phql), Z_STRLEN_P(phql), &error_msg) == FAILURE) { - ZEPHIR_THROW_EXCEPTION_STRW(phalcon_mvc_model_exception_ce, Z_STRVAL_P(error_msg)); - return FAILURE; - } - - return SUCCESS; -} - -static int phql_internal_parse_phql(zval **result, char *phql, unsigned int phql_length, zval **error_msg) -{ - zend_phalcon_globals *phalcon_globals_ptr = ZEPHIR_VGLOBAL; - phql_parser_status *parser_status = NULL; - int scanner_status, status = SUCCESS, error_length, cache_level; - phql_scanner_state *state; - phql_scanner_token token; - void* phql_parser; - char *error; - unsigned long phql_key = 0; - zval *temp_ast; - - if (!phql) { - ZVAL_STRING(*error_msg, "PHQL statement cannot be NULL"); - return FAILURE; - } - - cache_level = phalcon_globals_ptr->orm.cache_level; - if (cache_level >= 0) { - phql_key = zend_inline_hash_func(phql, phql_length + 1); - if (phalcon_globals_ptr->orm.parser_cache != NULL) { - if ((temp_ast = zend_hash_index_find(phalcon_globals_ptr->orm.parser_cache, phql_key)) != NULL) { - ZVAL_ZVAL(*result, temp_ast, 1, 0); - Z_TRY_ADDREF_P(*result); - return SUCCESS; - } - } - } - - phql_parser = phql_Alloc(phql_wrapper_alloc); - - parser_status = emalloc(sizeof(phql_parser_status)); - state = emalloc(sizeof(phql_scanner_state)); - - parser_status->status = PHQL_PARSING_OK; - parser_status->scanner_state = state; - ZVAL_UNDEF(&parser_status->ret); - - parser_status->syntax_error = NULL; - parser_status->token = &token; - parser_status->enable_literals = phalcon_globals_ptr->orm.enable_literals; - parser_status->phql = phql; - parser_status->phql_length = phql_length; - - state->active_token = 0; - state->start = phql; - state->start_length = 0; - state->end = state->start; - - token.value = NULL; - token.len = 0; - - while (0 <= (scanner_status = phql_get_token(state, &token))) { - - /* Calculate the 'start' length */ - state->start_length = (phql + phql_length - state->start); - - state->active_token = token.opcode; - - /* Parse the token found */ - switch (token.opcode) { - - case PHQL_T_IGNORE: - break; - - case PHQL_T_ADD: - phql_(phql_parser, PHQL_PLUS, NULL, parser_status); - break; - case PHQL_T_SUB: - phql_(phql_parser, PHQL_MINUS, NULL, parser_status); - break; - case PHQL_T_MUL: - phql_(phql_parser, PHQL_TIMES, NULL, parser_status); - break; - case PHQL_T_DIV: - phql_(phql_parser, PHQL_DIVIDE, NULL, parser_status); - break; - case PHQL_T_MOD: - phql_(phql_parser, PHQL_MOD, NULL, parser_status); - break; - case PHQL_T_AND: - phql_(phql_parser, PHQL_AND, NULL, parser_status); - break; - case PHQL_T_OR: - phql_(phql_parser, PHQL_OR, NULL, parser_status); - break; - case PHQL_T_EQUALS: - phql_(phql_parser, PHQL_EQUALS, NULL, parser_status); - break; - case PHQL_T_NOTEQUALS: - phql_(phql_parser, PHQL_NOTEQUALS, NULL, parser_status); - break; - case PHQL_T_LESS: - phql_(phql_parser, PHQL_LESS, NULL, parser_status); - break; - case PHQL_T_GREATER: - phql_(phql_parser, PHQL_GREATER, NULL, parser_status); - break; - case PHQL_T_GREATEREQUAL: - phql_(phql_parser, PHQL_GREATEREQUAL, NULL, parser_status); - break; - case PHQL_T_LESSEQUAL: - phql_(phql_parser, PHQL_LESSEQUAL, NULL, parser_status); - break; - - case PHQL_T_IDENTIFIER: - phql_parse_with_token(phql_parser, PHQL_T_IDENTIFIER, PHQL_IDENTIFIER, &token, parser_status); - break; - - case PHQL_T_DOT: - phql_(phql_parser, PHQL_DOT, NULL, parser_status); - break; - case PHQL_T_COMMA: - phql_(phql_parser, PHQL_COMMA, NULL, parser_status); - break; - - case PHQL_T_PARENTHESES_OPEN: - phql_(phql_parser, PHQL_PARENTHESES_OPEN, NULL, parser_status); - break; - case PHQL_T_PARENTHESES_CLOSE: - phql_(phql_parser, PHQL_PARENTHESES_CLOSE, NULL, parser_status); - break; - - case PHQL_T_LIKE: - phql_(phql_parser, PHQL_LIKE, NULL, parser_status); - break; - case PHQL_T_ILIKE: - phql_(phql_parser, PHQL_ILIKE, NULL, parser_status); - break; - case PHQL_T_NOT: - phql_(phql_parser, PHQL_NOT, NULL, parser_status); - break; - case PHQL_T_BITWISE_AND: - phql_(phql_parser, PHQL_BITWISE_AND, NULL, parser_status); - break; - case PHQL_T_BITWISE_OR: - phql_(phql_parser, PHQL_BITWISE_OR, NULL, parser_status); - break; - case PHQL_T_BITWISE_NOT: - phql_(phql_parser, PHQL_BITWISE_NOT, NULL, parser_status); - break; - case PHQL_T_BITWISE_XOR: - phql_(phql_parser, PHQL_BITWISE_XOR, NULL, parser_status); - break; - case PHQL_T_AGAINST: - phql_(phql_parser, PHQL_AGAINST, NULL, parser_status); - break; - case PHQL_T_CASE: - phql_(phql_parser, PHQL_CASE, NULL, parser_status); - break; - case PHQL_T_WHEN: - phql_(phql_parser, PHQL_WHEN, NULL, parser_status); - break; - case PHQL_T_THEN: - phql_(phql_parser, PHQL_THEN, NULL, parser_status); - break; - case PHQL_T_END: - phql_(phql_parser, PHQL_END, NULL, parser_status); - break; - case PHQL_T_ELSE: - phql_(phql_parser, PHQL_ELSE, NULL, parser_status); - break; - case PHQL_T_FOR: - phql_(phql_parser, PHQL_FOR, NULL, parser_status); - break; - case PHQL_T_WITH: - phql_(phql_parser, PHQL_WITH, NULL, parser_status); - break; - - case PHQL_T_INTEGER: - if (parser_status->enable_literals) { - phql_parse_with_token(phql_parser, PHQL_T_INTEGER, PHQL_INTEGER, &token, parser_status); - } else { - ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements"); - parser_status->status = PHQL_PARSING_FAILED; - } - break; - case PHQL_T_DOUBLE: - if (parser_status->enable_literals) { - phql_parse_with_token(phql_parser, PHQL_T_DOUBLE, PHQL_DOUBLE, &token, parser_status); - } else { - ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements"); - parser_status->status = PHQL_PARSING_FAILED; - } - break; - case PHQL_T_STRING: - if (parser_status->enable_literals) { - phql_parse_with_token(phql_parser, PHQL_T_STRING, PHQL_STRING, &token, parser_status); - } else { - ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements"); - parser_status->status = PHQL_PARSING_FAILED; - } - break; - case PHQL_T_TRUE: - if (parser_status->enable_literals) { - phql_(phql_parser, PHQL_TRUE, NULL, parser_status); - } else { - ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements"); - parser_status->status = PHQL_PARSING_FAILED; - } - break; - case PHQL_T_FALSE: - if (parser_status->enable_literals) { - phql_(phql_parser, PHQL_FALSE, NULL, parser_status); - } else { - ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements"); - parser_status->status = PHQL_PARSING_FAILED; - } - break; - case PHQL_T_HINTEGER: - if (parser_status->enable_literals) { - phql_parse_with_token(phql_parser, PHQL_T_HINTEGER, PHQL_HINTEGER, &token, parser_status); - } else { - ZVAL_STRING(*error_msg, "Literals are disabled in PHQL statements"); - parser_status->status = PHQL_PARSING_FAILED; - } - break; - - case PHQL_T_NPLACEHOLDER: - phql_parse_with_token(phql_parser, PHQL_T_NPLACEHOLDER, PHQL_NPLACEHOLDER, &token, parser_status); - break; - case PHQL_T_SPLACEHOLDER: - phql_parse_with_token(phql_parser, PHQL_T_SPLACEHOLDER, PHQL_SPLACEHOLDER, &token, parser_status); - break; - case PHQL_T_BPLACEHOLDER: - phql_parse_with_token(phql_parser, PHQL_T_BPLACEHOLDER, PHQL_BPLACEHOLDER, &token, parser_status); - break; - - case PHQL_T_FROM: - phql_(phql_parser, PHQL_FROM, NULL, parser_status); - break; - case PHQL_T_UPDATE: - phql_(phql_parser, PHQL_UPDATE, NULL, parser_status); - break; - case PHQL_T_SET: - phql_(phql_parser, PHQL_SET, NULL, parser_status); - break; - case PHQL_T_WHERE: - phql_(phql_parser, PHQL_WHERE, NULL, parser_status); - break; - case PHQL_T_DELETE: - phql_(phql_parser, PHQL_DELETE, NULL, parser_status); - break; - case PHQL_T_INSERT: - phql_(phql_parser, PHQL_INSERT, NULL, parser_status); - break; - case PHQL_T_INTO: - phql_(phql_parser, PHQL_INTO, NULL, parser_status); - break; - case PHQL_T_VALUES: - phql_(phql_parser, PHQL_VALUES, NULL, parser_status); - break; - case PHQL_T_SELECT: - phql_(phql_parser, PHQL_SELECT, NULL, parser_status); - break; - case PHQL_T_AS: - phql_(phql_parser, PHQL_AS, NULL, parser_status); - break; - case PHQL_T_ORDER: - phql_(phql_parser, PHQL_ORDER, NULL, parser_status); - break; - case PHQL_T_BY: - phql_(phql_parser, PHQL_BY, NULL, parser_status); - break; - case PHQL_T_LIMIT: - phql_(phql_parser, PHQL_LIMIT, NULL, parser_status); - break; - case PHQL_T_OFFSET: - phql_(phql_parser, PHQL_OFFSET, NULL, parser_status); - break; - case PHQL_T_GROUP: - phql_(phql_parser, PHQL_GROUP, NULL, parser_status); - break; - case PHQL_T_HAVING: - phql_(phql_parser, PHQL_HAVING, NULL, parser_status); - break; - case PHQL_T_ASC: - phql_(phql_parser, PHQL_ASC, NULL, parser_status); - break; - case PHQL_T_DESC: - phql_(phql_parser, PHQL_DESC, NULL, parser_status); - break; - case PHQL_T_IN: - phql_(phql_parser, PHQL_IN, NULL, parser_status); - break; - case PHQL_T_ON: - phql_(phql_parser, PHQL_ON, NULL, parser_status); - break; - case PHQL_T_INNER: - phql_(phql_parser, PHQL_INNER, NULL, parser_status); - break; - case PHQL_T_JOIN: - phql_(phql_parser, PHQL_JOIN, NULL, parser_status); - break; - case PHQL_T_LEFT: - phql_(phql_parser, PHQL_LEFT, NULL, parser_status); - break; - case PHQL_T_RIGHT: - phql_(phql_parser, PHQL_RIGHT, NULL, parser_status); - break; - case PHQL_T_CROSS: - phql_(phql_parser, PHQL_CROSS, NULL, parser_status); - break; - case PHQL_T_FULL: - phql_(phql_parser, PHQL_FULL, NULL, parser_status); - break; - case PHQL_T_OUTER: - phql_(phql_parser, PHQL_OUTER, NULL, parser_status); - break; - case PHQL_T_IS: - phql_(phql_parser, PHQL_IS, NULL, parser_status); - break; - case PHQL_T_NULL: - phql_(phql_parser, PHQL_NULL, NULL, parser_status); - break; - case PHQL_T_BETWEEN: - phql_(phql_parser, PHQL_BETWEEN, NULL, parser_status); - break; - case PHQL_T_BETWEEN_NOT: - phql_(phql_parser, PHQL_BETWEEN_NOT, NULL, parser_status); - break; - case PHQL_T_DISTINCT: - phql_(phql_parser, PHQL_DISTINCT, NULL, parser_status); - break; - case PHQL_T_ALL: - phql_(phql_parser, PHQL_ALL, NULL, parser_status); - break; - case PHQL_T_CAST: - phql_(phql_parser, PHQL_CAST, NULL, parser_status); - break; - case PHQL_T_CONVERT: - phql_(phql_parser, PHQL_CONVERT, NULL, parser_status); - break; - case PHQL_T_USING: - phql_(phql_parser, PHQL_USING, NULL, parser_status); - break; - case PHQL_T_EXISTS: - phql_(phql_parser, PHQL_EXISTS, NULL, parser_status); - break; - - default: - parser_status->status = PHQL_PARSING_FAILED; - error_length = sizeof(char) * 32; - error = emalloc(error_length); - snprintf(error, error_length, "Scanner: Unknown opcode %d", token.opcode); - error[error_length - 1] = '\0'; - ZVAL_STRING(*error_msg, error); - efree(error); - break; - } - - if (parser_status->status != PHQL_PARSING_OK) { - status = FAILURE; - break; - } - - state->end = state->start; - } - - if (status != FAILURE) { - switch (scanner_status) { - - case PHQL_SCANNER_RETCODE_ERR: - case PHQL_SCANNER_RETCODE_IMPOSSIBLE: - if (Z_TYPE_P(*error_msg) == IS_UNDEF) { - phql_scanner_error_msg(parser_status, error_msg); - } - - status = FAILURE; - break; - - default: - phql_(phql_parser, 0, NULL, parser_status); - } - } - - state->active_token = 0; - state->start = NULL; - - if (parser_status->status != PHQL_PARSING_OK) { - status = FAILURE; - if (parser_status->syntax_error) { - if (Z_TYPE_P(*error_msg) == IS_UNDEF) { - ZVAL_STRING(*error_msg, parser_status->syntax_error); - } - - efree(parser_status->syntax_error); - } - } - - phql_Free(phql_parser, phql_wrapper_free); - - if (status != FAILURE) { - if (parser_status->status == PHQL_PARSING_OK) { - if (Z_TYPE_P(&parser_status->ret) == IS_ARRAY) { - - if (phalcon_globals_ptr->orm.cache_level >= 1) { - if (Z_TYPE_P(&parser_status->ret) == IS_ARRAY) { - add_assoc_long(&parser_status->ret, "id", phalcon_globals_ptr->orm.unique_cache_id++); - } - } - - ZVAL_ZVAL(*result, &parser_status->ret, 1, 1); - - if (cache_level >= 0) { - - if (!phalcon_globals_ptr->orm.parser_cache) { - ALLOC_HASHTABLE(phalcon_globals_ptr->orm.parser_cache); - zend_hash_init(phalcon_globals_ptr->orm.parser_cache, 0, NULL, ZVAL_PTR_DTOR, 0); - } - - Z_TRY_ADDREF_P(*result); - - zend_hash_index_update( - phalcon_globals_ptr->orm.parser_cache, - phql_key, - *result - ); - } - - } - } - } - - efree(parser_status); - efree(state); - - return status; -} - - -/* Generated by re2c 1.1.1 */ -/* scanner.re - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the - * LICENSE.txt file that was distributed with this source code. - */ - -#ifdef HAVE_CONFIG_H -#endif - - - -#define PPCTYPE unsigned char -#define PPCURSOR (s->start) -#define PPLIMIT (s->end) -#define PPMARKER q - -static int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) { - - char *q = PPCURSOR; - int status = PHQL_SCANNER_RETCODE_IMPOSSIBLE; - - - while (PHQL_SCANNER_RETCODE_IMPOSSIBLE == status) { - - - { - PPCTYPE ppch; - unsigned int ppaccept = 0; - ppch = *PPCURSOR; - switch (ppch) { - case 0x00: goto pp2; - case '\t': - case '\n': - case '\r': - case ' ': goto pp6; - case '!': goto pp9; - case '"': goto pp11; - case '%': goto pp12; - case '&': goto pp14; - case '\'': goto pp16; - case '(': goto pp17; - case ')': goto pp19; - case '*': goto pp21; - case '+': goto pp23; - case ',': goto pp25; - case '-': goto pp27; - case '.': goto pp29; - case '/': goto pp31; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto pp33; - case ':': goto pp36; - case '<': goto pp38; - case '=': goto pp40; - case '>': goto pp42; - case '?': goto pp44; - case '@': goto pp45; - case 'A': - case 'a': goto pp46; - case 'B': - case 'b': goto pp48; - case 'C': - case 'c': goto pp49; - case 'D': - case 'd': goto pp50; - case 'E': - case 'e': goto pp51; - case 'F': - case 'f': goto pp52; - case 'G': - case 'g': goto pp53; - case 'H': - case 'h': goto pp55; - case 'I': - case 'i': goto pp56; - case 'J': - case 'j': goto pp57; - case 'K': - case 'M': - case 'P': - case 'Q': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'k': - case 'm': - case 'p': - case 'q': - case 'y': - case 'z': goto pp58; - case 'L': - case 'l': goto pp60; - case 'N': - case 'n': goto pp61; - case 'O': - case 'o': goto pp62; - case 'R': - case 'r': goto pp63; - case 'S': - case 's': goto pp64; - case 'T': - case 't': goto pp65; - case 'U': - case 'u': goto pp66; - case 'V': - case 'v': goto pp67; - case 'W': - case 'w': goto pp68; - case '[': goto pp69; - case '\\': goto pp70; - case '^': goto pp71; - case 'x': goto pp73; - case '{': goto pp75; - case '|': goto pp76; - case '~': goto pp78; - default: goto pp4; - } -pp2: - ++PPCURSOR; - { - status = PHQL_SCANNER_RETCODE_EOF; - break; - } -pp4: - ++PPCURSOR; -pp5: - { - status = PHQL_SCANNER_RETCODE_ERR; - break; - } -pp6: - ppch = *++PPCURSOR; - switch (ppch) { - case '\t': - case '\n': - case '\r': - case ' ': goto pp6; - default: goto pp8; - } -pp8: - { - token->opcode = PHQL_T_IGNORE; - return 0; - } -pp9: - ppch = *++PPCURSOR; - switch (ppch) { - case '!': goto pp80; - case '=': goto pp82; - default: goto pp10; - } -pp10: - { - token->opcode = PHQL_T_NOT; - return 0; - } -pp11: - ppaccept = 0; - ppch = *(PPMARKER = ++PPCURSOR); - if (ppch <= 0x00) goto pp5; - goto pp85; -pp12: - ++PPCURSOR; - { - token->opcode = PHQL_T_MOD; - return 0; - } -pp14: - ppch = *++PPCURSOR; - switch (ppch) { - case '&': goto pp90; - default: goto pp15; - } -pp15: - { - token->opcode = PHQL_T_BITWISE_AND; - return 0; - } -pp16: - ppaccept = 0; - ppch = *(PPMARKER = ++PPCURSOR); - if (ppch <= 0x00) goto pp5; - goto pp93; -pp17: - ++PPCURSOR; - { - token->opcode = PHQL_T_PARENTHESES_OPEN; - return 0; - } -pp19: - ++PPCURSOR; - { - token->opcode = PHQL_T_PARENTHESES_CLOSE; - return 0; - } -pp21: - ++PPCURSOR; - { - token->opcode = PHQL_T_MUL; - return 0; - } -pp23: - ++PPCURSOR; - { - token->opcode = PHQL_T_ADD; - return 0; - } -pp25: - ++PPCURSOR; - { - token->opcode = PHQL_T_COMMA; - return 0; - } -pp27: - ++PPCURSOR; - { - token->opcode = PHQL_T_SUB; - return 0; - } -pp29: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto pp95; - default: goto pp30; - } -pp30: - { - token->opcode = PHQL_T_DOT; - return 0; - } -pp31: - ++PPCURSOR; - { - token->opcode = PHQL_T_DIV; - return 0; - } -pp33: - ppch = *++PPCURSOR; - switch (ppch) { - case '.': goto pp95; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto pp33; - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'x': goto pp98; - default: goto pp35; - } -pp35: - { - token->opcode = PHQL_T_INTEGER; - token->value = estrndup(q, PPCURSOR - q); - token->len = PPCURSOR - q; - q = PPCURSOR; - return 0; - } -pp36: - ppaccept = 1; - ppch = *(PPMARKER = ++PPCURSOR); - switch (ppch) { - case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp100; - default: goto pp37; - } -pp37: - { - token->opcode = PHQL_T_COLON; - return 0; - } -pp38: - ppch = *++PPCURSOR; - switch (ppch) { - case '=': goto pp102; - case '>': goto pp104; - default: goto pp39; - } -pp39: - { - token->opcode = PHQL_T_LESS; - return 0; - } -pp40: - ++PPCURSOR; - { - token->opcode = PHQL_T_EQUALS; - return 0; - } -pp42: - ppch = *++PPCURSOR; - switch (ppch) { - case '=': goto pp106; - default: goto pp43; - } -pp43: - { - token->opcode = PHQL_T_GREATER; - return 0; - } -pp44: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto pp108; - default: goto pp5; - } -pp45: - ppch = *++PPCURSOR; - switch (ppch) { - case '>': goto pp111; - case '@': goto pp113; - default: goto pp5; - } -pp46: - ppch = *++PPCURSOR; - switch (ppch) { - case 'G': - case 'g': goto pp115; - case 'L': - case 'l': goto pp116; - case 'N': - case 'n': goto pp117; - case 'S': - case 's': goto pp118; - default: goto pp74; - } -pp47: - { - token->value = estrndup(q, PPCURSOR - q); - token->len = PPCURSOR - q; - if (token->len > 2 && !memcmp(token->value, "0x", 2)) { - token->opcode = PHQL_T_HINTEGER; - } else { - int i, alpha = 0; - for (i = 0; i < token->len; i++) { - unsigned char ch = token->value[i]; - if (!((ch >= '0') && (ch <= '9'))) { - alpha = 1; - break; - } - } - if (alpha) { - token->opcode = PHQL_T_IDENTIFIER; - } else { - token->opcode = PHQL_T_INTEGER; - } - } - q = PPCURSOR; - return 0; - } -pp48: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp120; - case 'Y': - case 'y': goto pp121; - default: goto pp74; - } -pp49: - ppch = *++PPCURSOR; - switch (ppch) { - case 'A': - case 'a': goto pp123; - case 'O': - case 'o': goto pp124; - case 'R': - case 'r': goto pp125; - default: goto pp74; - } -pp50: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp126; - case 'I': - case 'i': goto pp127; - default: goto pp74; - } -pp51: - ppch = *++PPCURSOR; - switch (ppch) { - case 'L': - case 'l': goto pp128; - case 'N': - case 'n': goto pp129; - case 'X': goto pp130; - case 'x': goto pp131; - default: goto pp74; - } -pp52: - ppch = *++PPCURSOR; - switch (ppch) { - case 'A': - case 'a': goto pp132; - case 'O': - case 'o': goto pp133; - case 'R': - case 'r': goto pp134; - case 'U': - case 'u': goto pp135; - default: goto pp74; - } -pp53: - ppch = *++PPCURSOR; - switch (ppch) { - case 'R': - case 'r': goto pp136; - default: goto pp59; - } -pp54: - { - token->opcode = PHQL_T_IDENTIFIER; - if ((PPCURSOR - q) > 1) { - if (q[0] == '\\') { - token->value = estrndup(q + 1, PPCURSOR - q - 1); - token->len = PPCURSOR - q - 1; - } else { - token->value = estrndup(q, PPCURSOR - q); - token->len = PPCURSOR - q; - } - } else { - token->value = estrndup(q, PPCURSOR - q); - token->len = PPCURSOR - q; - } - q = PPCURSOR; - return 0; - } -pp55: - ppch = *++PPCURSOR; - switch (ppch) { - case 'A': - case 'a': goto pp137; - default: goto pp59; - } -pp56: - ppch = *++PPCURSOR; - switch (ppch) { - case 'L': - case 'l': goto pp138; - case 'N': - case 'n': goto pp139; - case 'S': - case 's': goto pp141; - default: goto pp59; - } -pp57: - ppch = *++PPCURSOR; - switch (ppch) { - case 'O': - case 'o': goto pp143; - default: goto pp59; - } -pp58: - ppch = *++PPCURSOR; -pp59: - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp54; - } -pp60: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp144; - case 'I': - case 'i': goto pp145; - default: goto pp59; - } -pp61: - ppch = *++PPCURSOR; - switch (ppch) { - case 'O': - case 'o': goto pp146; - case 'U': - case 'u': goto pp147; - default: goto pp59; - } -pp62: - ppch = *++PPCURSOR; - switch (ppch) { - case 'F': - case 'f': goto pp148; - case 'N': - case 'n': goto pp149; - case 'R': - case 'r': goto pp151; - case 'U': - case 'u': goto pp153; - default: goto pp59; - } -pp63: - ppch = *++PPCURSOR; - switch (ppch) { - case 'I': - case 'i': goto pp154; - default: goto pp59; - } -pp64: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp155; - default: goto pp59; - } -pp65: - ppch = *++PPCURSOR; - switch (ppch) { - case 'H': - case 'h': goto pp156; - case 'R': - case 'r': goto pp157; - default: goto pp59; - } -pp66: - ppch = *++PPCURSOR; - switch (ppch) { - case 'P': - case 'p': goto pp158; - case 'S': - case 's': goto pp159; - default: goto pp59; - } -pp67: - ppch = *++PPCURSOR; - switch (ppch) { - case 'A': - case 'a': goto pp160; - default: goto pp59; - } -pp68: - ppch = *++PPCURSOR; - switch (ppch) { - case 'H': - case 'h': goto pp161; - case 'I': - case 'i': goto pp162; - default: goto pp59; - } -pp69: - ppaccept = 0; - ppch = *(PPMARKER = ++PPCURSOR); - switch (ppch) { - case 0x00: - case 0x01: - case 0x02: - case 0x03: - case 0x04: - case 0x05: - case 0x06: - case 0x07: - case 0x08: - case '\t': - case '\n': - case '\v': - case '\f': - case '\r': - case 0x0E: - case 0x0F: - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - case 0x18: - case 0x19: - case 0x1A: - case 0x1B: - case 0x1C: - case 0x1D: - case 0x1E: - case 0x1F: - case '[': - case 0x7F: goto pp5; - default: goto pp164; - } -pp70: - ppch = *++PPCURSOR; - switch (ppch) { - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp5; - } -pp71: - ++PPCURSOR; - { - token->opcode = PHQL_T_BITWISE_XOR; - return 0; - } -pp73: - ppch = *++PPCURSOR; -pp74: - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'x': goto pp73; - case ':': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'y': - case 'z': goto pp58; - default: goto pp47; - } -pp75: - ppaccept = 0; - ppch = *(PPMARKER = ++PPCURSOR); - switch (ppch) { - case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp169; - default: goto pp5; - } -pp76: - ppch = *++PPCURSOR; - switch (ppch) { - case '|': goto pp171; - default: goto pp77; - } -pp77: - { - token->opcode = PHQL_T_BITWISE_OR; - return 0; - } -pp78: - ++PPCURSOR; - { - token->opcode = PHQL_T_BITWISE_NOT; - return 0; - } -pp80: - ++PPCURSOR; - { - token->opcode = PHQL_T_TS_NEGATE; - return 0; - } -pp82: - ++PPCURSOR; - { - token->opcode = PHQL_T_NOTEQUALS; - return 0; - } -pp84: - ppch = *++PPCURSOR; -pp85: - switch (ppch) { - case 0x00: goto pp86; - case '"': goto pp87; - case '\\': goto pp89; - default: goto pp84; - } -pp86: - PPCURSOR = PPMARKER; - switch (ppaccept) { - case 0: goto pp5; - case 1: goto pp37; - case 2: goto pp209; - default: goto pp168; - } -pp87: - ++PPCURSOR; - { - token->opcode = PHQL_T_STRING; - token->value = estrndup(q, PPCURSOR - q - 1); - token->len = PPCURSOR - q - 1; - q = PPCURSOR; - return 0; - } -pp89: - ppch = *++PPCURSOR; - switch (ppch) { - case '\n': goto pp86; - default: goto pp84; - } -pp90: - ++PPCURSOR; - { - token->opcode = PHQL_T_TS_AND; - return 0; - } -pp92: - ppch = *++PPCURSOR; -pp93: - switch (ppch) { - case 0x00: goto pp86; - case '\'': goto pp87; - case '\\': goto pp94; - default: goto pp92; - } -pp94: - ppch = *++PPCURSOR; - switch (ppch) { - case '\n': goto pp86; - default: goto pp92; - } -pp95: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto pp95; - default: goto pp97; - } -pp97: - { - token->opcode = PHQL_T_DOUBLE; - token->value = estrndup(q, PPCURSOR - q); - token->len = PPCURSOR - q; - q = PPCURSOR; - return 0; - } -pp98: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'x': goto pp98; - default: goto pp47; - } -pp100: - ppch = *++PPCURSOR; - switch (ppch) { - case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp100; - case ':': goto pp173; - default: goto pp86; - } -pp102: - ++PPCURSOR; - { - token->opcode = PHQL_T_LESSEQUAL; - return 0; - } -pp104: - ++PPCURSOR; - { - token->opcode = PHQL_T_NOTEQUALS; - return 0; - } -pp106: - ++PPCURSOR; - { - token->opcode = PHQL_T_GREATEREQUAL; - return 0; - } -pp108: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto pp108; - default: goto pp110; - } -pp110: - { - token->opcode = PHQL_T_NPLACEHOLDER; - token->value = estrndup(q, PPCURSOR - q); - token->len = PPCURSOR - q; - q = PPCURSOR; - return 0; - } -pp111: - ++PPCURSOR; - { - token->opcode = PHQL_T_TS_CONTAINS_ANOTHER; - return 0; - } -pp113: - ++PPCURSOR; - { - token->opcode = PHQL_T_TS_MATCHES; - return 0; - } -pp115: - ppch = *++PPCURSOR; - switch (ppch) { - case 'A': - case 'a': goto pp175; - default: goto pp59; - } -pp116: - ppch = *++PPCURSOR; - switch (ppch) { - case 'L': - case 'l': goto pp176; - default: goto pp59; - } -pp117: - ppch = *++PPCURSOR; - switch (ppch) { - case 'D': - case 'd': goto pp178; - default: goto pp59; - } -pp118: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - case 'C': - case 'c': goto pp180; - default: goto pp119; - } -pp119: - { - token->opcode = PHQL_T_AS; - return 0; - } -pp120: - ppch = *++PPCURSOR; - switch (ppch) { - case 'T': - case 't': goto pp182; - default: goto pp74; - } -pp121: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp122; - } -pp122: - { - token->opcode = PHQL_T_BY; - return 0; - } -pp123: - ppch = *++PPCURSOR; - switch (ppch) { - case 'S': - case 's': goto pp183; - default: goto pp74; - } -pp124: - ppch = *++PPCURSOR; - switch (ppch) { - case 'N': - case 'n': goto pp184; - default: goto pp59; - } -pp125: - ppch = *++PPCURSOR; - switch (ppch) { - case 'O': - case 'o': goto pp185; - default: goto pp59; - } -pp126: - ppch = *++PPCURSOR; - switch (ppch) { - case 'L': - case 'l': goto pp186; - case 'S': - case 's': goto pp187; - default: goto pp74; - } -pp127: - ppch = *++PPCURSOR; - switch (ppch) { - case 'S': - case 's': goto pp188; - default: goto pp59; - } -pp128: - ppch = *++PPCURSOR; - switch (ppch) { - case 'S': - case 's': goto pp189; - default: goto pp59; - } -pp129: - ppch = *++PPCURSOR; - switch (ppch) { - case 'D': - case 'd': goto pp190; - default: goto pp59; - } -pp130: - ppch = *++PPCURSOR; - switch (ppch) { - case 'I': - case 'i': goto pp192; - default: goto pp59; - } -pp131: - ppch = *++PPCURSOR; - switch (ppch) { - case 'I': - case 'i': goto pp192; - default: goto pp74; - } -pp132: - ppch = *++PPCURSOR; - switch (ppch) { - case 'L': - case 'l': goto pp193; - default: goto pp74; - } -pp133: - ppch = *++PPCURSOR; - switch (ppch) { - case 'R': - case 'r': goto pp194; - default: goto pp59; - } -pp134: - ppch = *++PPCURSOR; - switch (ppch) { - case 'O': - case 'o': goto pp196; - default: goto pp59; - } -pp135: - ppch = *++PPCURSOR; - switch (ppch) { - case 'L': - case 'l': goto pp197; - default: goto pp59; - } -pp136: - ppch = *++PPCURSOR; - switch (ppch) { - case 'O': - case 'o': goto pp198; - default: goto pp59; - } -pp137: - ppch = *++PPCURSOR; - switch (ppch) { - case 'V': - case 'v': goto pp199; - default: goto pp59; - } -pp138: - ppch = *++PPCURSOR; - switch (ppch) { - case 'I': - case 'i': goto pp200; - default: goto pp59; - } -pp139: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'o': - case 'p': - case 'q': - case 'r': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - case 'N': - case 'n': goto pp201; - case 'S': - case 's': goto pp202; - case 'T': - case 't': goto pp203; - default: goto pp140; - } -pp140: - { - token->opcode = PHQL_T_IN; - return 0; - } -pp141: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp142; - } -pp142: - { - token->opcode = PHQL_T_IS; - return 0; - } -pp143: - ppch = *++PPCURSOR; - switch (ppch) { - case 'I': - case 'i': goto pp204; - default: goto pp59; - } -pp144: - ppch = *++PPCURSOR; - switch (ppch) { - case 'F': - case 'f': goto pp205; - default: goto pp59; - } -pp145: - ppch = *++PPCURSOR; - switch (ppch) { - case 'K': - case 'k': goto pp206; - case 'M': - case 'm': goto pp207; - default: goto pp59; - } -pp146: - ppch = *++PPCURSOR; - switch (ppch) { - case 'T': - case 't': goto pp208; - default: goto pp59; - } -pp147: - ppch = *++PPCURSOR; - switch (ppch) { - case 'L': - case 'l': goto pp210; - default: goto pp59; - } -pp148: - ppch = *++PPCURSOR; - switch (ppch) { - case 'F': - case 'f': goto pp211; - default: goto pp59; - } -pp149: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp150; - } -pp150: - { - token->opcode = PHQL_T_ON; - return 0; - } -pp151: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - case 'D': - case 'd': goto pp212; - default: goto pp152; - } -pp152: - { - token->opcode = PHQL_T_OR; - return 0; - } -pp153: - ppch = *++PPCURSOR; - switch (ppch) { - case 'T': - case 't': goto pp213; - default: goto pp59; - } -pp154: - ppch = *++PPCURSOR; - switch (ppch) { - case 'G': - case 'g': goto pp214; - default: goto pp59; - } -pp155: - ppch = *++PPCURSOR; - switch (ppch) { - case 'L': - case 'l': goto pp215; - case 'T': - case 't': goto pp216; - default: goto pp59; - } -pp156: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp218; - default: goto pp59; - } -pp157: - ppch = *++PPCURSOR; - switch (ppch) { - case 'U': - case 'u': goto pp219; - default: goto pp59; - } -pp158: - ppch = *++PPCURSOR; - switch (ppch) { - case 'D': - case 'd': goto pp220; - default: goto pp59; - } -pp159: - ppch = *++PPCURSOR; - switch (ppch) { - case 'I': - case 'i': goto pp221; - default: goto pp59; - } -pp160: - ppch = *++PPCURSOR; - switch (ppch) { - case 'L': - case 'l': goto pp222; - default: goto pp59; - } -pp161: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp223; - default: goto pp59; - } -pp162: - ppch = *++PPCURSOR; - switch (ppch) { - case 'T': - case 't': goto pp224; - default: goto pp59; - } -pp163: - ppch = *++PPCURSOR; -pp164: - switch (ppch) { - case 0x00: - case 0x01: - case 0x02: - case 0x03: - case 0x04: - case 0x05: - case 0x06: - case 0x07: - case 0x08: - case '\t': - case '\n': - case '\v': - case '\f': - case '\r': - case 0x0E: - case 0x0F: - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - case 0x18: - case 0x19: - case 0x1A: - case 0x1B: - case 0x1C: - case 0x1D: - case 0x1E: - case 0x1F: - case '[': - case 0x7F: goto pp86; - case '\\': goto pp165; - case ']': goto pp167; - default: goto pp163; - } -pp165: - ppch = *++PPCURSOR; - switch (ppch) { - case 0x00: - case 0x01: - case 0x02: - case 0x03: - case 0x04: - case 0x05: - case 0x06: - case 0x07: - case 0x08: - case '\t': - case '\n': - case '\v': - case '\f': - case '\r': - case 0x0E: - case 0x0F: - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - case 0x18: - case 0x19: - case 0x1A: - case 0x1B: - case 0x1C: - case 0x1D: - case 0x1E: - case 0x1F: - case 0x7F: goto pp86; - case '\\': goto pp165; - case ']': goto pp225; - default: goto pp163; - } -pp167: - ++PPCURSOR; -pp168: - { - token->opcode = PHQL_T_IDENTIFIER; - token->value = estrndup(q, PPCURSOR - q - 1); - token->len = PPCURSOR - q - 1; - q = PPCURSOR; - return 0; - } -pp169: - ppch = *++PPCURSOR; - switch (ppch) { - case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp169; - case '}': goto pp226; - default: goto pp86; - } -pp171: - ++PPCURSOR; - { - token->opcode = PHQL_T_TS_OR; - return 0; - } -pp173: - ++PPCURSOR; - { - token->opcode = PHQL_T_SPLACEHOLDER; - token->value = estrndup(q, PPCURSOR - q - 1); - token->len = PPCURSOR - q - 1; - q = PPCURSOR; - return 0; - } -pp175: - ppch = *++PPCURSOR; - switch (ppch) { - case 'I': - case 'i': goto pp228; - default: goto pp59; - } -pp176: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp177; - } -pp177: - { - token->opcode = PHQL_T_ALL; - return 0; - } -pp178: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp179; - } -pp179: - { - token->opcode = PHQL_T_AND; - return 0; - } -pp180: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp181; - } -pp181: - { - token->opcode = PHQL_T_ASC; - return 0; - } -pp182: - ppch = *++PPCURSOR; - switch (ppch) { - case 'W': - case 'w': goto pp229; - default: goto pp59; - } -pp183: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp230; - case 'T': - case 't': goto pp232; - default: goto pp59; - } -pp184: - ppch = *++PPCURSOR; - switch (ppch) { - case 'V': - case 'v': goto pp234; - default: goto pp59; - } -pp185: - ppch = *++PPCURSOR; - switch (ppch) { - case 'S': - case 's': goto pp235; - default: goto pp59; - } -pp186: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp236; - default: goto pp59; - } -pp187: - ppch = *++PPCURSOR; - switch (ppch) { - case 'C': - case 'c': goto pp237; - default: goto pp59; - } -pp188: - ppch = *++PPCURSOR; - switch (ppch) { - case 'T': - case 't': goto pp239; - default: goto pp59; - } -pp189: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp240; - default: goto pp59; - } -pp190: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp191; - } -pp191: - { - token->opcode = PHQL_T_END; - return 0; - } -pp192: - ppch = *++PPCURSOR; - switch (ppch) { - case 'S': - case 's': goto pp242; - default: goto pp59; - } -pp193: - ppch = *++PPCURSOR; - switch (ppch) { - case 'S': - case 's': goto pp243; - default: goto pp59; - } -pp194: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp195; - } -pp195: - { - token->opcode = PHQL_T_FOR; - return 0; - } -pp196: - ppch = *++PPCURSOR; - switch (ppch) { - case 'M': - case 'm': goto pp244; - default: goto pp59; - } -pp197: - ppch = *++PPCURSOR; - switch (ppch) { - case 'L': - case 'l': goto pp246; - default: goto pp59; - } -pp198: - ppch = *++PPCURSOR; - switch (ppch) { - case 'U': - case 'u': goto pp248; - default: goto pp59; - } -pp199: - ppch = *++PPCURSOR; - switch (ppch) { - case 'I': - case 'i': goto pp249; - default: goto pp59; - } -pp200: - ppch = *++PPCURSOR; - switch (ppch) { - case 'K': - case 'k': goto pp250; - default: goto pp59; - } -pp201: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp251; - default: goto pp59; - } -pp202: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp252; - default: goto pp59; - } -pp203: - ppch = *++PPCURSOR; - switch (ppch) { - case 'O': - case 'o': goto pp253; - default: goto pp59; - } -pp204: - ppch = *++PPCURSOR; - switch (ppch) { - case 'N': - case 'n': goto pp255; - default: goto pp59; - } -pp205: - ppch = *++PPCURSOR; - switch (ppch) { - case 'T': - case 't': goto pp257; - default: goto pp59; - } -pp206: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp259; - default: goto pp59; - } -pp207: - ppch = *++PPCURSOR; - switch (ppch) { - case 'I': - case 'i': goto pp261; - default: goto pp59; - } -pp208: - ppaccept = 2; - ppch = *(PPMARKER = ++PPCURSOR); - switch (ppch) { - case ' ': goto pp262; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp209; - } -pp209: - { - token->opcode = PHQL_T_NOT; - return 0; - } -pp210: - ppch = *++PPCURSOR; - switch (ppch) { - case 'L': - case 'l': goto pp263; - default: goto pp59; - } -pp211: - ppch = *++PPCURSOR; - switch (ppch) { - case 'S': - case 's': goto pp265; - default: goto pp59; - } -pp212: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp266; - default: goto pp59; - } -pp213: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp267; - default: goto pp59; - } -pp214: - ppch = *++PPCURSOR; - switch (ppch) { - case 'H': - case 'h': goto pp268; - default: goto pp59; - } -pp215: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp269; - default: goto pp59; - } -pp216: +pp314: ppch = *++PPCURSOR; switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp217; - } -pp217: - { - token->opcode = PHQL_T_SET; - return 0; - } -pp218: - ppch = *++PPCURSOR; - switch (ppch) { - case 'N': - case 'n': goto pp270; - default: goto pp59; - } -pp219: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp272; - default: goto pp59; - } -pp220: - ppch = *++PPCURSOR; - switch (ppch) { - case 'A': - case 'a': goto pp274; - default: goto pp59; - } -pp221: - ppch = *++PPCURSOR; - switch (ppch) { - case 'N': - case 'n': goto pp275; - default: goto pp59; - } -pp222: - ppch = *++PPCURSOR; - switch (ppch) { - case 'U': - case 'u': goto pp276; - default: goto pp59; - } -pp223: - ppch = *++PPCURSOR; - switch (ppch) { - case 'N': - case 'n': goto pp277; - case 'R': - case 'r': goto pp279; - default: goto pp59; - } -pp224: - ppch = *++PPCURSOR; - switch (ppch) { - case 'H': - case 'h': goto pp280; - default: goto pp59; - } -pp225: - ppaccept = 3; - ppch = *(PPMARKER = ++PPCURSOR); - switch (ppch) { - case 0x00: - case 0x01: - case 0x02: - case 0x03: - case 0x04: - case 0x05: - case 0x06: - case 0x07: - case 0x08: - case '\t': - case '\n': - case '\v': - case '\f': - case '\r': - case 0x0E: - case 0x0F: - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - case 0x18: - case 0x19: - case 0x1A: - case 0x1B: - case 0x1C: - case 0x1D: - case 0x1E: - case 0x1F: - case '[': - case 0x7F: goto pp168; - case '\\': goto pp165; - case ']': goto pp167; - default: goto pp163; - } -pp226: - ++PPCURSOR; - { - token->opcode = PHQL_T_BPLACEHOLDER; - token->value = estrndup(q, PPCURSOR - q - 1); - token->len = PPCURSOR - q - 1; - q = PPCURSOR; - return 0; - } -pp228: - ppch = *++PPCURSOR; - switch (ppch) { - case 'N': - case 'n': goto pp282; - default: goto pp59; - } -pp229: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp283; + case 's': goto pp336; default: goto pp59; } -pp230: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp231; - } -pp231: - { - token->opcode = PHQL_T_CASE; - return 0; - } -pp232: +pp315: ppch = *++PPCURSOR; switch (ppch) { case '0': @@ -81289,616 +70948,35 @@ static int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) { case 'x': case 'y': case 'z': goto pp58; - default: goto pp233; + default: goto pp316; } -pp233: +pp316: { - token->opcode = PHQL_T_CAST; + token->opcode = PHQL_T_WHERE; return 0; } -pp234: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp284; - default: goto pp59; - } -pp235: - ppch = *++PPCURSOR; - switch (ppch) { - case 'S': - case 's': goto pp285; - default: goto pp59; - } -pp236: - ppch = *++PPCURSOR; - switch (ppch) { - case 'T': - case 't': goto pp287; - default: goto pp59; - } -pp237: +pp317: ppch = *++PPCURSOR; switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp238; - } -pp238: - { - token->opcode = PHQL_T_DESC; - return 0; - } -pp239: - ppch = *++PPCURSOR; - switch (ppch) { - case 'I': - case 'i': goto pp288; + case 't': goto pp338; default: goto pp59; } -pp240: +pp318: ppch = *++PPCURSOR; switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp241; - } -pp241: - { - token->opcode = PHQL_T_ELSE; - return 0; - } -pp242: - ppch = *++PPCURSOR; - switch (ppch) { - case 'T': - case 't': goto pp289; - default: goto pp59; - } -pp243: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp290; + case 'n': goto pp340; default: goto pp59; } -pp244: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp245; - } -pp245: - { - token->opcode = PHQL_T_FROM; - return 0; - } -pp246: +pp319: ppch = *++PPCURSOR; switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp247; - } -pp247: - { - token->opcode = PHQL_T_FULL; - return 0; - } -pp248: - ppch = *++PPCURSOR; - switch (ppch) { - case 'P': - case 'p': goto pp292; - default: goto pp59; - } -pp249: - ppch = *++PPCURSOR; - switch (ppch) { - case 'N': - case 'n': goto pp294; - default: goto pp59; - } -pp250: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp295; - default: goto pp59; - } -pp251: - ppch = *++PPCURSOR; - switch (ppch) { - case 'R': - case 'r': goto pp297; - default: goto pp59; - } -pp252: - ppch = *++PPCURSOR; - switch (ppch) { - case 'R': - case 'r': goto pp299; + case 't': goto pp342; default: goto pp59; } -pp253: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp254; - } -pp254: - { - token->opcode = PHQL_T_INTO; - return 0; - } -pp255: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp256; - } -pp256: - { - token->opcode = PHQL_T_JOIN; - return 0; - } -pp257: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp258; - } -pp258: - { - token->opcode = PHQL_T_LEFT; - return 0; - } -pp259: +pp320: ppch = *++PPCURSOR; switch (ppch) { case '0': @@ -81966,28 +71044,21 @@ static int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) { case 'x': case 'y': case 'z': goto pp58; - default: goto pp260; + default: goto pp321; } -pp260: +pp321: { - token->opcode = PHQL_T_LIKE; + token->opcode = PHQL_T_DELETE; return 0; } -pp261: +pp322: ppch = *++PPCURSOR; switch (ppch) { - case 'T': - case 't': goto pp300; + case 'C': + case 'c': goto pp344; default: goto pp59; } -pp262: - ppch = *++PPCURSOR; - switch (ppch) { - case 'B': - case 'b': goto pp302; - default: goto pp86; - } -pp263: +pp323: ppch = *++PPCURSOR; switch (ppch) { case '0': @@ -82055,49 +71126,14 @@ static int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) { case 'x': case 'y': case 'z': goto pp58; - default: goto pp264; + default: goto pp324; } -pp264: +pp324: { - token->opcode = PHQL_T_NULL; + token->opcode = PHQL_T_EXISTS; return 0; } -pp265: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp303; - default: goto pp59; - } -pp266: - ppch = *++PPCURSOR; - switch (ppch) { - case 'R': - case 'r': goto pp304; - default: goto pp59; - } -pp267: - ppch = *++PPCURSOR; - switch (ppch) { - case 'R': - case 'r': goto pp306; - default: goto pp59; - } -pp268: - ppch = *++PPCURSOR; - switch (ppch) { - case 'T': - case 't': goto pp308; - default: goto pp59; - } -pp269: - ppch = *++PPCURSOR; - switch (ppch) { - case 'C': - case 'c': goto pp310; - default: goto pp59; - } -pp270: +pp325: ppch = *++PPCURSOR; switch (ppch) { case '0': @@ -82165,14 +71201,14 @@ static int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) { case 'x': case 'y': case 'z': goto pp58; - default: goto pp271; + default: goto pp326; } -pp271: +pp326: { - token->opcode = PHQL_T_THEN; + token->opcode = PHQL_T_HAVING; return 0; } -pp272: +pp327: ppch = *++PPCURSOR; switch (ppch) { case '0': @@ -82240,35 +71276,21 @@ static int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) { case 'x': case 'y': case 'z': goto pp58; - default: goto pp273; + default: goto pp328; } -pp273: +pp328: { - token->opcode = PHQL_T_TRUE; + token->opcode = PHQL_T_INSERT; return 0; } -pp274: +pp329: ppch = *++PPCURSOR; switch (ppch) { case 'T': - case 't': goto pp311; - default: goto pp59; - } -pp275: - ppch = *++PPCURSOR; - switch (ppch) { - case 'G': - case 'g': goto pp312; - default: goto pp59; - } -pp276: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp314; - default: goto pp59; + case 't': goto pp345; + default: goto pp86; } -pp277: +pp330: ppch = *++PPCURSOR; switch (ppch) { case '0': @@ -82336,21 +71358,14 @@ static int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) { case 'x': case 'y': case 'z': goto pp58; - default: goto pp278; + default: goto pp331; } -pp278: +pp331: { - token->opcode = PHQL_T_WHEN; + token->opcode = PHQL_T_OFFSET; return 0; } -pp279: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp315; - default: goto pp59; - } -pp280: +pp332: ppch = *++PPCURSOR; switch (ppch) { case '0': @@ -82418,35 +71433,14 @@ static int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) { case 'x': case 'y': case 'z': goto pp58; - default: goto pp281; + default: goto pp333; } -pp281: +pp333: { - token->opcode = PHQL_T_WITH; + token->opcode = PHQL_T_SELECT; return 0; } -pp282: - ppch = *++PPCURSOR; - switch (ppch) { - case 'S': - case 's': goto pp317; - default: goto pp59; - } -pp283: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp318; - default: goto pp59; - } -pp284: - ppch = *++PPCURSOR; - switch (ppch) { - case 'R': - case 'r': goto pp319; - default: goto pp59; - } -pp285: +pp334: ppch = *++PPCURSOR; switch (ppch) { case '0': @@ -82514,35 +71508,14 @@ static int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) { case 'x': case 'y': case 'z': goto pp58; - default: goto pp286; + default: goto pp335; } -pp286: +pp335: { - token->opcode = PHQL_T_CROSS; + token->opcode = PHQL_T_UPDATE; return 0; } -pp287: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp320; - default: goto pp59; - } -pp288: - ppch = *++PPCURSOR; - switch (ppch) { - case 'N': - case 'n': goto pp322; - default: goto pp59; - } -pp289: - ppch = *++PPCURSOR; - switch (ppch) { - case 'S': - case 's': goto pp323; - default: goto pp59; - } -pp290: +pp336: ppch = *++PPCURSOR; switch (ppch) { case '0': @@ -82610,14 +71583,14 @@ static int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) { case 'x': case 'y': case 'z': goto pp58; - default: goto pp291; + default: goto pp337; } -pp291: +pp337: { - token->opcode = PHQL_T_FALSE; + token->opcode = PHQL_T_VALUES; return 0; } -pp292: +pp338: ppch = *++PPCURSOR; switch (ppch) { case '0': @@ -82685,21 +71658,89 @@ static int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) { case 'x': case 'y': case 'z': goto pp58; - default: goto pp293; + default: goto pp339; } -pp293: +pp339: { - token->opcode = PHQL_T_GROUP; + token->opcode = PHQL_T_AGAINST; return 0; } -pp294: +pp340: ppch = *++PPCURSOR; switch (ppch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case ':': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': case 'G': - case 'g': goto pp325; - default: goto pp59; + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto pp58; + default: goto pp341; } -pp295: +pp341: + { + token->opcode = PHQL_T_BETWEEN; + return 0; + } +pp342: ppch = *++PPCURSOR; switch (ppch) { case '0': @@ -82767,14 +71808,28 @@ static int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) { case 'x': case 'y': case 'z': goto pp58; - default: goto pp296; + default: goto pp343; } -pp296: +pp343: { - token->opcode = PHQL_T_ILIKE; + token->opcode = PHQL_T_CONVERT; return 0; } -pp297: +pp344: + ppch = *++PPCURSOR; + switch (ppch) { + case 'T': + case 't': goto pp346; + default: goto pp59; + } +pp345: + ppch = *++PPCURSOR; + switch (ppch) { + case 'W': + case 'w': goto pp348; + default: goto pp86; + } +pp346: ppch = *++PPCURSOR; switch (ppch) { case '0': @@ -82842,1490 +71897,3522 @@ static int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) { case 'x': case 'y': case 'z': goto pp58; - default: goto pp298; + default: goto pp347; + } +pp347: + { + token->opcode = PHQL_T_DISTINCT; + return 0; + } +pp348: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp349; + default: goto pp86; + } +pp349: + ppch = *++PPCURSOR; + switch (ppch) { + case 'E': + case 'e': goto pp350; + default: goto pp86; + } +pp350: + ppch = *++PPCURSOR; + switch (ppch) { + case 'N': + case 'n': goto pp351; + default: goto pp86; + } +pp351: + ++PPCURSOR; + { + token->opcode = PHQL_T_BETWEEN_NOT; + return 0; + } + } + + } + + return status; +} + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query_Status) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model\\Query, Status, phalcon, mvc_model_query_status, phalcon_mvc_model_query_status_method_entry, 0); + + zend_declare_property_null(phalcon_mvc_model_query_status_ce, SL("model"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_query_status_ce, SL("success"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_mvc_model_query_status_ce, 1, phalcon_mvc_model_query_statusinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Mvc_Model_Query_Status, __construct) +{ + zval *success_param = NULL, *model = NULL, model_sub, __$true, __$false, __$null; + zend_bool success; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_NULL(&__$null); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_BOOL(success) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 1, &success_param, &model); + if (!model) { + model = &model_sub; + model = &__$null; + } + if (success) { + zephir_update_property_zval(this_ptr, ZEND_STRL("success"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("success"), &__$false); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("model"), model); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Query_Status, getMessages) +{ + zval model, _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("model"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&model, &_0); + if (Z_TYPE_P(&model) != IS_OBJECT) { + array_init(return_value); + RETURN_MM(); + } + ZEPHIR_RETURN_CALL_METHOD(&model, "getmessages", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Query_Status, getModel) +{ + + RETURN_MEMBER(getThis(), "model"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Query_Status, success) +{ + + RETURN_MEMBER(getThis(), "success"); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query_StatusInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model\\Query, StatusInterface, phalcon, mvc_model_query_statusinterface, phalcon_mvc_model_query_statusinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_StatusInterface, getMessages); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_StatusInterface, getModel); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_StatusInterface, success); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Behavior_SoftDelete) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Behavior, SoftDelete, phalcon, mvc_model_behavior_softdelete, phalcon_mvc_model_behavior_ce, phalcon_mvc_model_behavior_softdelete_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Mvc_Model_Behavior_SoftDelete, notify) +{ + zend_bool _9; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_6 = NULL, *_7 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *type_param = NULL, *model, model_sub, options, value, field, updateModel, message, modelsManager, metaData, _0, _1, _2, _8, _3$$7, *_4$$7, _5$$7, _10$$10, _11$$10; + zval type; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&updateModel); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&modelsManager); + ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_3$$7); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_10$$10); + ZVAL_UNDEF(&_11$$10); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(type) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &type_param, &model); + if (UNEXPECTED(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(type_param) == IS_STRING)) { + zephir_get_strval(&type, type_param); + } else { + ZEPHIR_INIT_VAR(&type); + } + if (!ZEPHIR_IS_STRING_IDENTICAL(&type, "beforeDelete")) { + RETURN_MM_NULL(); + } + ZEPHIR_CALL_METHOD(&options, this_ptr, "getoptions", NULL, 0); + zephir_check_call_status(); + zephir_memory_observe(&value); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&value, &options, SL("value"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The option 'value' is required", "phalcon/Mvc/Model/Behavior/SoftDelete.zep", 42); + return; + } + zephir_memory_observe(&field); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&field, &options, SL("field"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The option 'field' is required", "phalcon/Mvc/Model/Behavior/SoftDelete.zep", 49); + return; + } + ZVAL_BOOL(&_0, 1); + ZEPHIR_CALL_METHOD(NULL, model, "skipoperation", NULL, 0, &_0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, model, "readattribute", NULL, 0, &field); + zephir_check_call_status(); + if (ZEPHIR_IS_IDENTICAL(&_1, &value)) { + RETURN_MM_NULL(); + } + ZEPHIR_CALL_METHOD(&modelsManager, model, "getmodelsmanager", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&updateModel); + if (zephir_clone(&updateModel, model) == FAILURE) { + RETURN_MM(); + } + ZEPHIR_CALL_METHOD(NULL, &updateModel, "writeattribute", NULL, 0, &field, &value); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_2, &updateModel, "save", NULL, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&_2))) { + ZEPHIR_CALL_METHOD(&_3$$7, &updateModel, "getmessages", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&_3$$7, 0, "phalcon/Mvc/Model/Behavior/SoftDelete.zep", 84); + if (Z_TYPE_P(&_3$$7) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_3$$7), _4$$7) + { + ZEPHIR_INIT_NVAR(&message); + ZVAL_COPY(&message, _4$$7); + ZEPHIR_CALL_METHOD(NULL, model, "appendmessage", &_6, 0, &message); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_3$$7, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5$$7, &_3$$7, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5$$7)) { + break; + } + ZEPHIR_CALL_METHOD(&message, &_3$$7, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, model, "appendmessage", &_7, 0, &message); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_3$$7, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&message); + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", NULL, 0, &field, &value); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_8, &modelsManager, "iskeepingsnapshots", NULL, 0, model); + zephir_check_call_status(); + _9 = zephir_is_true(&_8); + if (_9) { + _9 = ZEPHIR_GLOBAL(orm).update_snapshot_on_save; + } + if (_9) { + ZEPHIR_CALL_METHOD(&metaData, model, "getmodelsmetadata", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_10$$10, &updateModel, "getsnapshotdata", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, model, "setsnapshotdata", NULL, 0, &_10$$10); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_11$$10, &updateModel, "getoldsnapshotdata", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, model, "setoldsnapshotdata", NULL, 0, &_11$$10); + zephir_check_call_status(); + } + ZEPHIR_MM_RESTORE(); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Behavior_Timestampable) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Behavior, Timestampable, phalcon, mvc_model_behavior_timestampable, phalcon_mvc_model_behavior_ce, phalcon_mvc_model_behavior_timestampable_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Mvc_Model_Behavior_Timestampable, notify) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *type_param = NULL, *model, model_sub, options, timestamp, singleField, field, _0, *_1$$6, _2$$6; + zval type; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&model_sub); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(×tamp); + ZVAL_UNDEF(&singleField); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2$$6); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(type) + Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &type_param, &model); + if (UNEXPECTED(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(type_param) == IS_STRING)) { + zephir_get_strval(&type, type_param); + } else { + ZEPHIR_INIT_VAR(&type); + } + ZEPHIR_CALL_METHOD(&_0, this_ptr, "musttakeaction", NULL, 0, &type); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + RETURN_MM_NULL(); + } + ZEPHIR_CALL_METHOD(&options, this_ptr, "getoptions", NULL, 0, &type); + zephir_check_call_status(); + if (Z_TYPE_P(&options) != IS_ARRAY) { + RETURN_MM_NULL(); + } + zephir_memory_observe(&field); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&field, &options, SL("field"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The option 'field' is required", "phalcon/Mvc/Model/Behavior/Timestampable.zep", 50); + return; + } + ZEPHIR_CALL_METHOD(×tamp, this_ptr, "gettimestamp", NULL, 435, &options); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&field) == IS_ARRAY)) { + zephir_is_iterable(&field, 0, "phalcon/Mvc/Model/Behavior/Timestampable.zep", 63); + if (Z_TYPE_P(&field) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&field), _1$$6) + { + ZEPHIR_INIT_NVAR(&singleField); + ZVAL_COPY(&singleField, _1$$6); + ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", &_3, 0, &singleField, ×tamp); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &field, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2$$6, &field, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2$$6)) { + break; + } + ZEPHIR_CALL_METHOD(&singleField, &field, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", &_4, 0, &singleField, ×tamp); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &field, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&singleField); + } else { + ZEPHIR_CALL_METHOD(NULL, model, "writeattribute", NULL, 0, &field, ×tamp); + zephir_check_call_status(); + } + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Behavior_Timestampable, getTimestamp) +{ + zend_bool _0$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *options_param = NULL, format, generator; + zval options; + + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&format); + ZVAL_UNDEF(&generator); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &options_param); + zephir_get_arrval(&options, options_param); + zephir_memory_observe(&format); + if (zephir_array_isset_string_fetch(&format, &options, SL("format"), 0)) { + ZEPHIR_RETURN_CALL_FUNCTION("date", NULL, 436, &format); + zephir_check_call_status(); + RETURN_MM(); + } + zephir_memory_observe(&generator); + if (zephir_array_isset_string_fetch(&generator, &options, SL("generator"), 0)) { + _0$$4 = Z_TYPE_P(&generator) == IS_OBJECT; + if (_0$$4) { + _0$$4 = zephir_is_instance_of(&generator, SL("Closure")); + } + if (_0$$4) { + ZEPHIR_CALL_USER_FUNC(return_value, &generator); + zephir_check_call_status(); + RETURN_MM(); + } + } + zephir_time(return_value); + RETURN_MM(); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Binder_BindableInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model\\Binder, BindableInterface, phalcon, mvc_model_binder_bindableinterface, phalcon_mvc_model_binder_bindableinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Binder_BindableInterface, getModelName); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Transaction_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Transaction, Exception, phalcon, mvc_model_transaction_exception, phalcon_mvc_model_exception_ce, NULL, 0); + + return SUCCESS; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Transaction_Failed) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\Transaction, Failed, phalcon, mvc_model_transaction_failed, phalcon_mvc_model_transaction_exception_ce, phalcon_mvc_model_transaction_failed_method_entry, 0); + + zend_declare_property_null(phalcon_mvc_model_transaction_failed_ce, SL("record"), ZEND_ACC_PROTECTED); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Failed, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *message_param = NULL, *record = NULL, record_sub, __$null; + zval message; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&record_sub); + ZVAL_NULL(&__$null); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(record, phalcon_mvc_modelinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &message_param, &record); + if (UNEXPECTED(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(message_param) == IS_STRING)) { + zephir_get_strval(&message, message_param); + } else { + ZEPHIR_INIT_VAR(&message); + } + if (!record) { + record = &record_sub; + record = &__$null; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("record"), record); + ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_transaction_failed_ce, getThis(), "__construct", NULL, 0, &message); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Failed, getRecord) +{ + + RETURN_MEMBER(getThis(), "record"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Failed, getRecordMessages) +{ + zval record, _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&record); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("record"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&record, &_0); + if (Z_TYPE_P(&record) != IS_NULL) { + ZEPHIR_RETURN_CALL_METHOD(&record, "getmessages", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getmessage", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Transaction_Manager) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model\\Transaction, Manager, phalcon, mvc_model_transaction_manager, phalcon_mvc_model_transaction_manager_method_entry, 0); + + zend_declare_property_null(phalcon_mvc_model_transaction_manager_ce, SL("container"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_mvc_model_transaction_manager_ce, SL("initialized"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_mvc_model_transaction_manager_ce, SL("number"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_mvc_model_transaction_manager_ce, SL("rollbackPendent"), 1, ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_mvc_model_transaction_manager_ce, SL("service"), "db", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_model_transaction_manager_ce, SL("transactions"), ZEND_ACC_PROTECTED); + phalcon_mvc_model_transaction_manager_ce->create_object = zephir_init_properties_Phalcon_Mvc_Model_Transaction_Manager; + + zend_class_implements(phalcon_mvc_model_transaction_manager_ce, 1, phalcon_mvc_model_transaction_managerinterface_ce); + zend_class_implements(phalcon_mvc_model_transaction_manager_ce, 1, phalcon_di_injectionawareinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *container = NULL, container_sub, __$null; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&container_sub); + ZVAL_NULL(&__$null); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(container, phalcon_di_diinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &container); + if (!container) { + container = &container_sub; + ZEPHIR_CPY_WRT(container, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(container); + } + if (!(zephir_is_true(container))) { + ZEPHIR_CALL_CE_STATIC(container, phalcon_di_di_ce, "getdefault", NULL, 0); + zephir_check_call_status(); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); + if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_transaction_exception_ce, "A dependency injection container is required to access the services related to the ORM", "phalcon/Mvc/Model/Transaction/Manager.zep", 114); + return; + } + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, collectTransactions) +{ + zval transactions, _0, _1, *_2, _3, _4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&transactions); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("transactions"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&transactions, &_0); + ZEPHIR_INIT_VAR(&_1); + zephir_is_iterable(&transactions, 0, "phalcon/Mvc/Model/Transaction/Manager.zep", 131); + if (Z_TYPE_P(&transactions) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&transactions), _2) + { + ZEPHIR_INIT_NVAR(&_1); + ZVAL_COPY(&_1, _2); + RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("number"))); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &transactions, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &transactions, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&_1, &transactions, "current", NULL, 0); + zephir_check_call_status(); + RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("number"))); + ZEPHIR_CALL_METHOD(NULL, &transactions, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&_1); + ZEPHIR_INIT_VAR(&_4); + array_init(&_4); + zephir_update_property_zval(this_ptr, ZEND_STRL("transactions"), &_4); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, commit) +{ + zval transactions, transaction, connection, _0, *_1, _2, _3$$3, _4$$5; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&transactions); + ZVAL_UNDEF(&transaction); + ZVAL_UNDEF(&connection); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$5); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("transactions"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&transactions, &_0); + zephir_is_iterable(&transactions, 0, "phalcon/Mvc/Model/Transaction/Manager.zep", 150); + if (Z_TYPE_P(&transactions) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&transactions), _1) + { + ZEPHIR_INIT_NVAR(&transaction); + ZVAL_COPY(&transaction, _1); + ZEPHIR_CALL_METHOD(&connection, &transaction, "getconnection", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_3$$3, &connection, "isundertransaction", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_3$$3)) { + ZEPHIR_CALL_METHOD(NULL, &connection, "commit", NULL, 0); + zephir_check_call_status(); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &transactions, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &transactions, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&transaction, &transactions, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&connection, &transaction, "getconnection", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4$$5, &connection, "isundertransaction", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_4$$5)) { + ZEPHIR_CALL_METHOD(NULL, &connection, "commit", NULL, 0); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(NULL, &transactions, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&transaction); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, get) +{ + zval _2$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *autoBegin_param = NULL, __$true, __$false, _0, _4, _1$$3, _3$$4; + zend_bool autoBegin; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_2$$4); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(autoBegin) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &autoBegin_param); + if (!autoBegin_param) { + autoBegin = 1; + } else { + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("initialized"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_is_true(&_0))) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("rollbackPendent"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_1$$3)) { + ZEPHIR_INIT_VAR(&_2$$4); + zephir_create_array(&_2$$4, 2, 0); + zephir_array_fast_append(&_2$$4, this_ptr); + ZEPHIR_INIT_VAR(&_3$$4); + ZVAL_STRING(&_3$$4, "rollbackPendent"); + zephir_array_fast_append(&_2$$4, &_3$$4); + ZEPHIR_CALL_FUNCTION(NULL, "register_shutdown_function", NULL, 483, &_2$$4); + zephir_check_call_status(); + } + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("initialized"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("initialized"), &__$false); + } + } + if (autoBegin) { + ZVAL_BOOL(&_4, 1); + } else { + ZVAL_BOOL(&_4, 0); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getorcreatetransaction", NULL, 0, &_4); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, getDbService) +{ + + RETURN_MEMBER(getThis(), "service"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, getDI) +{ + + RETURN_MEMBER(getThis(), "container"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, getOrCreateTransaction) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *autoBegin_param = NULL, container, transaction, transactions, _0, _6, _7, _1$$4, *_2$$4, _3$$4, _4$$6, _5$$8; + zend_bool autoBegin; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&transaction); + ZVAL_UNDEF(&transactions); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$6); + ZVAL_UNDEF(&_5$$8); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(autoBegin) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &autoBegin_param); + if (!autoBegin_param) { + autoBegin = 1; + } else { + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_0); + if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_transaction_exception_ce, "A dependency injection container is required to access the services related to the ORM", "phalcon/Mvc/Model/Transaction/Manager.zep", 210); + return; + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("number"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_0)) { + zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("transactions"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&transactions, &_1$$4); + zephir_is_iterable(&transactions, 0, "phalcon/Mvc/Model/Transaction/Manager.zep", 223); + if (Z_TYPE_P(&transactions) == IS_ARRAY) { + ZEND_HASH_REVERSE_FOREACH_VAL(Z_ARRVAL_P(&transactions), _2$$4) + { + ZEPHIR_INIT_NVAR(&transaction); + ZVAL_COPY(&transaction, _2$$4); + if (Z_TYPE_P(&transaction) == IS_OBJECT) { + ZVAL_BOOL(&_4$$6, 0); + ZEPHIR_CALL_METHOD(NULL, &transaction, "setisnewtransaction", NULL, 0, &_4$$6); + zephir_check_call_status(); + RETURN_CCTOR(&transaction); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &transactions, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3$$4, &transactions, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3$$4)) { + break; + } + ZEPHIR_CALL_METHOD(&transaction, &transactions, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&transaction) == IS_OBJECT) { + ZVAL_BOOL(&_5$$8, 0); + ZEPHIR_CALL_METHOD(NULL, &transaction, "setisnewtransaction", NULL, 0, &_5$$8); + zephir_check_call_status(); + RETURN_CCTOR(&transaction); + } + ZEPHIR_CALL_METHOD(NULL, &transactions, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&transaction); + } + ZEPHIR_INIT_NVAR(&transaction); + object_init_ex(&transaction, phalcon_mvc_model_transaction_ce); + zephir_read_property(&_6, this_ptr, ZEND_STRL("service"), PH_NOISY_CC | PH_READONLY); + if (autoBegin) { + ZVAL_BOOL(&_7, 1); + } else { + ZVAL_BOOL(&_7, 0); + } + ZEPHIR_CALL_METHOD(NULL, &transaction, "__construct", NULL, 484, &container, &_7, &_6); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &transaction, "settransactionmanager", NULL, 485, this_ptr); + zephir_check_call_status(); + zephir_update_property_array_append(this_ptr, SL("transactions"), &transaction); + RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("number"))); + RETURN_CCTOR(&transaction); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, getRollbackPendent) +{ + + RETURN_MEMBER(getThis(), "rollbackPendent"); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, has) +{ + zval _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("number"), PH_NOISY_CC | PH_READONLY); + RETURN_BOOL(ZEPHIR_GT_LONG(&_0, 0)); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, notifyCommit) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *transaction, transaction_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&transaction_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(transaction, phalcon_mvc_model_transactioninterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &transaction); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "collecttransaction", NULL, 0, transaction); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, notifyRollback) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *transaction, transaction_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&transaction_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(transaction, phalcon_mvc_model_transactioninterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &transaction); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "collecttransaction", NULL, 0, transaction); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, rollback) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *collect_param = NULL, transactions, transaction, connection, _0, *_1, _2, _3$$3, _5$$6; + zend_bool collect; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&transactions); + ZVAL_UNDEF(&transaction); + ZVAL_UNDEF(&connection); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_5$$6); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(collect) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &collect_param); + if (!collect_param) { + collect = 1; + } else { + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("transactions"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&transactions, &_0); + zephir_is_iterable(&transactions, 0, "phalcon/Mvc/Model/Transaction/Manager.zep", 294); + if (Z_TYPE_P(&transactions) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&transactions), _1) + { + ZEPHIR_INIT_NVAR(&transaction); + ZVAL_COPY(&transaction, _1); + ZEPHIR_CALL_METHOD(&connection, &transaction, "getconnection", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_3$$3, &connection, "isundertransaction", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_3$$3)) { + ZEPHIR_CALL_METHOD(NULL, &connection, "rollback", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &connection, "close", NULL, 0); + zephir_check_call_status(); + } + if (collect) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "collecttransaction", &_4, 0, &transaction); + zephir_check_call_status(); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &transactions, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &transactions, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; } -pp298: - { - token->opcode = PHQL_T_INNER; - return 0; + ZEPHIR_CALL_METHOD(&transaction, &transactions, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&connection, &transaction, "getconnection", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5$$6, &connection, "isundertransaction", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_5$$6)) { + ZEPHIR_CALL_METHOD(NULL, &connection, "rollback", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &connection, "close", NULL, 0); + zephir_check_call_status(); + } + if (collect) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "collecttransaction", &_4, 0, &transaction); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(NULL, &transactions, "next", NULL, 0); + zephir_check_call_status(); } -pp299: - ppch = *++PPCURSOR; - switch (ppch) { - case 'T': - case 't': goto pp327; - default: goto pp59; + } + ZEPHIR_INIT_NVAR(&transaction); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, rollbackPendent) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_CALL_METHOD(NULL, this_ptr, "rollback", NULL, 0); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, setDbService) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *service_param = NULL; + zval service; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&service); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(service) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &service_param); + if (UNEXPECTED(Z_TYPE_P(service_param) != IS_STRING && Z_TYPE_P(service_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'service' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(service_param) == IS_STRING)) { + zephir_get_strval(&service, service_param); + } else { + ZEPHIR_INIT_VAR(&service); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("service"), &service); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, setDI) +{ + zval *container, container_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&container_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &container); + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, setRollbackPendent) +{ + zval *rollbackPendent_param = NULL, __$true, __$false; + zend_bool rollbackPendent; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(rollbackPendent) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &rollbackPendent_param); + if (rollbackPendent) { + zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackPendent"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("rollbackPendent"), &__$false); + } + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, collectTransaction) +{ + zval newTransactions; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *transaction, transaction_sub, managedTransaction, _0, *_1, _2; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&transaction_sub); + ZVAL_UNDEF(&managedTransaction); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&newTransactions); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(transaction, phalcon_mvc_model_transactioninterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &transaction); + ZEPHIR_INIT_VAR(&newTransactions); + array_init(&newTransactions); + zephir_read_property(&_0, this_ptr, ZEND_STRL("transactions"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_0, 0, "phalcon/Mvc/Model/Transaction/Manager.zep", 359); + if (Z_TYPE_P(&_0) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) + { + ZEPHIR_INIT_NVAR(&managedTransaction); + ZVAL_COPY(&managedTransaction, _1); + if (!ZEPHIR_IS_EQUAL(&managedTransaction, transaction)) { + zephir_array_append(&newTransactions, transaction, PH_SEPARATE, "phalcon/Mvc/Model/Transaction/Manager.zep", 353); + } else { + RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("number"))); } -pp300: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp301; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&managedTransaction, &_0, "current", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_EQUAL(&managedTransaction, transaction)) { + zephir_array_append(&newTransactions, transaction, PH_SEPARATE, "phalcon/Mvc/Model/Transaction/Manager.zep", 353); + } else { + RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("number"))); + } + ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&managedTransaction); + zephir_update_property_zval(this_ptr, ZEND_STRL("transactions"), &newTransactions); + ZEPHIR_MM_RESTORE(); +} + +zend_object *zephir_init_properties_Phalcon_Mvc_Model_Transaction_Manager(zend_class_entry *class_type) +{ + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("transactions"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("transactions"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Transaction_ManagerInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model\\Transaction, ManagerInterface, phalcon, mvc_model_transaction_managerinterface, phalcon_mvc_model_transaction_managerinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, collectTransactions); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, commit); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, get); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, getDbService); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, getRollbackPendent); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, has); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, notifyCommit); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, notifyRollback); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, rollback); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, rollbackPendent); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, setDbService); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Transaction_ManagerInterface, setRollbackPendent); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_Collection) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Micro, Collection, phalcon, mvc_micro_collection, phalcon_mvc_micro_collection_method_entry, 0); + + zend_declare_property_null(phalcon_mvc_micro_collection_ce, SL("handler"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_micro_collection_ce, SL("handlers"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_mvc_micro_collection_ce, SL("lazy"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_mvc_micro_collection_ce, SL("prefix"), "", ZEND_ACC_PROTECTED); + phalcon_mvc_micro_collection_ce->create_object = zephir_init_properties_Phalcon_Mvc_Micro_Collection; + + zend_class_implements(phalcon_mvc_micro_collection_ce, 1, phalcon_mvc_micro_collectioninterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Mvc_Micro_Collection, delete) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; + zval routePattern, name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(routePattern) + Z_PARAM_ZVAL(handler) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); + if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { + zephir_get_strval(&routePattern, routePattern_param); + } else { + ZEPHIR_INIT_VAR(&routePattern); + } + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { + zephir_get_strval(&name, name_param); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "DELETE"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_Collection, get) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; + zval routePattern, name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(routePattern) + Z_PARAM_ZVAL(handler) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); + if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { + zephir_get_strval(&routePattern, routePattern_param); + } else { + ZEPHIR_INIT_VAR(&routePattern); + } + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { + zephir_get_strval(&name, name_param); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "GET"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_Collection, getHandler) +{ + + RETURN_MEMBER(getThis(), "handler"); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_Collection, getHandlers) +{ + + RETURN_MEMBER(getThis(), "handlers"); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_Collection, getPrefix) +{ + + RETURN_MEMBER(getThis(), "prefix"); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_Collection, head) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; + zval routePattern, name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(routePattern) + Z_PARAM_ZVAL(handler) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); + if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { + zephir_get_strval(&routePattern, routePattern_param); + } else { + ZEPHIR_INIT_VAR(&routePattern); + } + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { + zephir_get_strval(&name, name_param); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "HEAD"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_Collection, isLazy) +{ + + RETURN_MEMBER(getThis(), "lazy"); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_Collection, map) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; + zval routePattern, name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(routePattern) + Z_PARAM_ZVAL(handler) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); + if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { + zephir_get_strval(&routePattern, routePattern_param); + } else { + ZEPHIR_INIT_VAR(&routePattern); + } + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { + zephir_get_strval(&name, name_param); + } + ZVAL_NULL(&_0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_Collection, mapVia) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *routePattern_param = NULL, *handler, handler_sub, *method, method_sub, *name_param = NULL; + zval routePattern, name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&method_sub); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_STR(routePattern) + Z_PARAM_ZVAL(handler) + Z_PARAM_ZVAL(method) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 1, &routePattern_param, &handler, &method, &name_param); + if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { + zephir_get_strval(&routePattern, routePattern_param); + } else { + ZEPHIR_INIT_VAR(&routePattern); + } + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { + zephir_get_strval(&name, name_param); + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, method, &routePattern, handler, &name); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_Collection, options) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; + zval routePattern, name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(routePattern) + Z_PARAM_ZVAL(handler) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); + if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { + zephir_get_strval(&routePattern, routePattern_param); + } else { + ZEPHIR_INIT_VAR(&routePattern); + } + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { + zephir_get_strval(&name, name_param); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "OPTIONS"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_Collection, patch) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; + zval routePattern, name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(routePattern) + Z_PARAM_ZVAL(handler) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); + if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { + zephir_get_strval(&routePattern, routePattern_param); + } else { + ZEPHIR_INIT_VAR(&routePattern); + } + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { + zephir_get_strval(&name, name_param); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "PATCH"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_Collection, post) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; + zval routePattern, name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(routePattern) + Z_PARAM_ZVAL(handler) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); + if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { + zephir_get_strval(&routePattern, routePattern_param); + } else { + ZEPHIR_INIT_VAR(&routePattern); + } + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { + zephir_get_strval(&name, name_param); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "POST"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_Collection, put) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL, _0; + zval routePattern, name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(routePattern) + Z_PARAM_ZVAL(handler) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 1, &routePattern_param, &handler, &name_param); + if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { + zephir_get_strval(&routePattern, routePattern_param); + } else { + ZEPHIR_INIT_VAR(&routePattern); + } + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { + zephir_get_strval(&name, name_param); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "PUT"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmap", NULL, 0, &_0, &routePattern, handler, &name); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_Collection, setHandler) +{ + zend_bool lazy; + zval *handler, handler_sub, *lazy_param = NULL, __$true, __$false; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&handler_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(handler) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(lazy) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 1, &handler, &lazy_param); + if (!lazy_param) { + lazy = 0; + } else { + } + zephir_update_property_zval(this_ptr, ZEND_STRL("handler"), handler); + if (lazy) { + zephir_update_property_zval(this_ptr, ZEND_STRL("lazy"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("lazy"), &__$false); + } + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_Collection, setLazy) +{ + zval *lazy_param = NULL, __$true, __$false; + zend_bool lazy; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(lazy) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &lazy_param); + if (UNEXPECTED(Z_TYPE_P(lazy_param) != IS_TRUE && Z_TYPE_P(lazy_param) != IS_FALSE)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'lazy' must be of the type bool")); + RETURN_NULL(); + } + lazy = (Z_TYPE_P(lazy_param) == IS_TRUE); + if (lazy) { + zephir_update_property_zval(this_ptr, ZEND_STRL("lazy"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("lazy"), &__$false); + } + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_Collection, setPrefix) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *prefix_param = NULL; + zval prefix; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&prefix); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(prefix) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &prefix_param); + if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) { + zephir_get_strval(&prefix, prefix_param); + } else { + ZEPHIR_INIT_VAR(&prefix); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("prefix"), &prefix); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_Collection, addMap) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval routePattern, name; + zval *method, method_sub, *routePattern_param = NULL, *handler, handler_sub, *name_param = NULL; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&method_sub); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&routePattern); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_ZVAL(method) + Z_PARAM_STR(routePattern) + Z_PARAM_ZVAL(handler) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 1, &method, &routePattern_param, &handler, &name_param); + if (UNEXPECTED(Z_TYPE_P(routePattern_param) != IS_STRING && Z_TYPE_P(routePattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'routePattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(routePattern_param) == IS_STRING)) { + zephir_get_strval(&routePattern, routePattern_param); + } else { + ZEPHIR_INIT_VAR(&routePattern); + } + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { + zephir_get_strval(&name, name_param); + } + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 4, 0); + zephir_array_fast_append(&_0, method); + zephir_array_fast_append(&_0, &routePattern); + zephir_array_fast_append(&_0, handler); + zephir_array_fast_append(&_0, &name); + zephir_update_property_array_append(this_ptr, SL("handlers"), &_0); + ZEPHIR_MM_RESTORE(); +} + +zend_object *zephir_init_properties_Phalcon_Mvc_Micro_Collection(zend_class_entry *class_type) +{ + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("handlers"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("handlers"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_CollectionInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Micro, CollectionInterface, phalcon, mvc_micro_collectioninterface, phalcon_mvc_micro_collectioninterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, delete); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, get); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, getHandler); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, getHandlers); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, getPrefix); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, head); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, isLazy); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, map); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, options); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, patch); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, post); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, put); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, setHandler); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, setLazy); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_CollectionInterface, setPrefix); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Micro, Exception, phalcon, mvc_micro_exception, zend_ce_exception, NULL, 0); + + return SUCCESS; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_LazyLoader) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Micro, LazyLoader, phalcon, mvc_micro_lazyloader, phalcon_mvc_micro_lazyloader_method_entry, 0); + + zend_declare_property_null(phalcon_mvc_micro_lazyloader_ce, SL("definition"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_micro_lazyloader_ce, SL("handler"), ZEND_ACC_PROTECTED); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *definition_param = NULL; + zval definition; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&definition); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(definition) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &definition_param); + if (UNEXPECTED(Z_TYPE_P(definition_param) != IS_STRING && Z_TYPE_P(definition_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'definition' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(definition_param) == IS_STRING)) { + zephir_get_strval(&definition, definition_param); + } else { + ZEPHIR_INIT_VAR(&definition); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("definition"), &definition); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, callMethod) +{ + zval _4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *method_param = NULL, *arguments = NULL, arguments_sub, *modelBinder = NULL, modelBinder_sub, __$null, handler, definition, bindCacheKey, _0, _1$$4, _2$$4, _3$$5; + zval method; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&arguments_sub); + ZVAL_UNDEF(&modelBinder_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&handler); + ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&bindCacheKey); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(method) + Z_PARAM_ZVAL(arguments) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(modelBinder, phalcon_mvc_model_binderinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 1, &method_param, &arguments, &modelBinder); + if (UNEXPECTED(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 of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(method_param) == IS_STRING)) { + zephir_get_strval(&method, method_param); + } else { + ZEPHIR_INIT_VAR(&method); + } + ZEPHIR_SEPARATE_PARAM(arguments); + if (!modelBinder) { + modelBinder = &modelBinder_sub; + modelBinder = &__$null; + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("handler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&handler, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("definition"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&definition, &_0); + if (Z_TYPE_P(&handler) != IS_OBJECT) { + if (!(zephir_class_exists(&definition, 1))) { + ZEPHIR_INIT_VAR(&_1$$4); + object_init_ex(&_1$$4, phalcon_mvc_micro_exception_ce); + ZEPHIR_INIT_VAR(&_2$$4); + ZEPHIR_CONCAT_SVS(&_2$$4, "Handler '", &definition, "' doesn't exist"); + ZEPHIR_CALL_METHOD(NULL, &_1$$4, "__construct", NULL, 33, &_2$$4); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$4, "phalcon/Mvc/Micro/LazyLoader.zep", 55); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_NVAR(&handler); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&handler, &definition); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("handler"), &handler); + } + if (Z_TYPE_P(modelBinder) != IS_NULL) { + ZEPHIR_INIT_VAR(&bindCacheKey); + ZEPHIR_CONCAT_SVSV(&bindCacheKey, "_PHMB_", &definition, "_", &method); + ZEPHIR_CALL_METHOD(&_3$$5, modelBinder, "bindtohandler", NULL, 0, &handler, arguments, &bindCacheKey, &method); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(arguments, &_3$$5); + } + ZEPHIR_INIT_VAR(&_4); + zephir_create_array(&_4, 2, 0); + zephir_array_fast_append(&_4, &handler); + zephir_array_fast_append(&_4, &method); + ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_4, arguments); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, getDefinition) +{ + + RETURN_MEMBER(getThis(), "definition"); +} + +static PHP_METHOD(Phalcon_Mvc_Micro_LazyLoader, getHandler) +{ + + RETURN_MEMBER(getThis(), "handler"); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Micro_MiddlewareInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Micro, MiddlewareInterface, phalcon, mvc_micro_middlewareinterface, phalcon_mvc_micro_middlewareinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Micro_MiddlewareInterface, call); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Application_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Application, Exception, phalcon, mvc_application_exception, phalcon_application_exception_ce, NULL, 0); + + return SUCCESS; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Url_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Url, Exception, phalcon, mvc_url_exception, zend_ce_exception, NULL, 0); + + return SUCCESS; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Url_UrlInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Url, UrlInterface, phalcon, mvc_url_urlinterface, phalcon_mvc_url_urlinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Url_UrlInterface, get); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Url_UrlInterface, getBasePath); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Url_UrlInterface, getBaseUri); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Url_UrlInterface, setBasePath); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Url_UrlInterface, setBaseUri); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Url_UrlInterface, path); + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +static void phalcon_get_uri(zval *return_value, zval *path) +{ + int i, found = 0, mark = 0; + char *cursor, *str, ch; + + if (Z_TYPE_P(path) != IS_STRING) { + RETURN_EMPTY_STRING(); + } + + if (Z_STRLEN_P(path) > 0) { + cursor = Z_STRVAL_P(path) + Z_STRLEN_P(path) - 1; + for (i = Z_STRLEN_P(path); i > 0; i--) { + ch = *cursor; + if (ch == '/' || ch == '\\') { + found++; + if (found == 1) { + mark = i - 1; + } else { + str = emalloc(mark - i + 1); + memcpy(str, Z_STRVAL_P(path) + i, mark - i); + str[mark - i] = '\0'; + ZVAL_STRINGL(return_value, str, mark - i); + return; + } } -pp301: - { - token->opcode = PHQL_T_LIMIT; - return 0; + cursor--; } -pp302: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp329; - default: goto pp86; + } + + RETURN_EMPTY_STRING(); +} + +zval *phalcon_replace_marker(int named, zval *paths, zval *replacements, unsigned long *position, char *cursor, char *marker) +{ + unsigned int length = 0, variable_length, ch, j; + char *item = NULL, *cursor_var, *variable = NULL; + int not_valid = 0; + zval *zv, *tmp; + + if (named) { + length = cursor - marker - 1; + item = estrndup(marker + 1, length); + cursor_var = item; + marker = item; + for (j = 0; j < length; j++) { + ch = *cursor_var; + if (ch == '\0') { + not_valid = 1; + break; } -pp303: - ppch = *++PPCURSOR; - switch (ppch) { - case 'T': - case 't': goto pp330; - default: goto pp59; + if (j == 0 && !((ch >= 'a' && ch <='z') || (ch >= 'A' && ch <= 'Z'))){ + not_valid = 1; + break; } -pp304: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp305; + if ((ch >= 'a' && ch <='z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || ch == '-' || ch == '_' || ch == ':') { + if (ch == ':') { + variable_length = cursor_var - marker; + variable = estrndup(marker, variable_length); + break; + } + } else { + not_valid = 1; + break; } -pp305: - { - token->opcode = PHQL_T_ORDER; - return 0; + cursor_var++; } -pp306: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp307; + } + + if (!not_valid) { + + if (zend_hash_index_exists(Z_ARRVAL_P(paths), *position)) { + if (named) { + if (variable) { + efree(item); + item = variable; + length = variable_length; + } + if (zend_hash_str_exists(Z_ARRVAL_P(replacements), item, length)) { + if ((zv = zend_hash_str_find(Z_ARRVAL_P(replacements), item, length)) != NULL) { + efree(item); + (*position)++; + return zv; + } + } + } else { + if ((zv = zend_hash_index_find(Z_ARRVAL_P(paths), *position)) != NULL) { + if (Z_TYPE_P(zv) == IS_STRING) { + if (zend_hash_str_exists(Z_ARRVAL_P(replacements), Z_STRVAL_P(zv), Z_STRLEN_P(zv))) { + if ((tmp = zend_hash_str_find(Z_ARRVAL_P(replacements), Z_STRVAL_P(zv), Z_STRLEN_P(zv))) != NULL) { + (*position)++; + return tmp; + } + } + } + } } -pp307: - { - token->opcode = PHQL_T_OUTER; - return 0; } -pp308: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp309; - } -pp309: - { - token->opcode = PHQL_T_RIGHT; - return 0; + + (*position)++; + } + + if (item) { + efree(item); + } + + return NULL; +} + +static void phalcon_replace_paths(zval *return_value, zval *pattern, zval *paths, zval *replacements) +{ + + char *cursor, *marker = NULL; + unsigned int bracket_count = 0, parentheses_count = 0, intermediate = 0; + unsigned char ch; + smart_str route_str = {0}; + zend_ulong position = 1; + int i; + zval *replace, replace_copy; + int use_copy, looking_placeholder = 0; + + if (Z_TYPE_P(pattern) != IS_STRING || Z_TYPE_P(replacements) != IS_ARRAY || Z_TYPE_P(paths) != IS_ARRAY) { + ZVAL_NULL(return_value); + php_error_docref(NULL, E_WARNING, "Invalid arguments supplied for phalcon_replace_paths()"); + return; + } + + if (Z_STRLEN_P(pattern) <= 0) { + ZVAL_FALSE(return_value); + return; + } + + cursor = Z_STRVAL_P(pattern); + if (*cursor == '/') { + ++cursor; + i = 1; + } + else { + i = 0; + } + + if (!zend_hash_num_elements(Z_ARRVAL_P(paths))) { + ZVAL_STRINGL(return_value, Z_STRVAL_P(pattern) + i, Z_STRLEN_P(pattern) - i); + return; + } + + for (; i < Z_STRLEN_P(pattern); ++i) { + + ch = *cursor; + if (ch == '\0') { + break; } -pp310: - ppch = *++PPCURSOR; - switch (ppch) { - case 'T': - case 't': goto pp332; - default: goto pp59; + + if (parentheses_count == 0 && !looking_placeholder) { + if (ch == '{') { + if (bracket_count == 0) { + marker = cursor; + intermediate = 0; + } + bracket_count++; + } else { + if (ch == '}') { + bracket_count--; + if (intermediate > 0) { + if (bracket_count == 0) { + replace = phalcon_replace_marker(1, paths, replacements, &position, cursor, marker); + if (replace) { + use_copy = 0; + if (Z_TYPE_P(replace) != IS_STRING) { + use_copy = zend_make_printable_zval(replace, &replace_copy); + if (use_copy) { + replace = &replace_copy; + } + } + smart_str_appendl(&route_str, Z_STRVAL_P(replace), Z_STRLEN_P(replace)); + if (use_copy) { + zval_dtor(&replace_copy); + } + } + cursor++; + continue; + } + } + } } -pp311: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp334; - default: goto pp59; + } + + if (bracket_count == 0 && !looking_placeholder) { + if (ch == '(') { + if (parentheses_count == 0) { + marker = cursor; + intermediate = 0; + } + parentheses_count++; + } else { + if (ch == ')') { + parentheses_count--; + if (intermediate > 0) { + if (parentheses_count == 0) { + replace = phalcon_replace_marker(0, paths, replacements, &position, cursor, marker); + if (replace) { + use_copy = 0; + if (Z_TYPE_P(replace) != IS_STRING) { + use_copy = zend_make_printable_zval(replace, &replace_copy); + if (use_copy) { + replace = &replace_copy; + } + } + smart_str_appendl(&route_str, Z_STRVAL_P(replace), Z_STRLEN_P(replace)); + if (use_copy) { + zval_dtor(&replace_copy); + } + } + cursor++; + continue; + } + } + } } -pp312: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp313; + } + + if (bracket_count == 0 && parentheses_count == 0) { + if (looking_placeholder) { + if (intermediate > 0) { + if (ch < 'a' || ch > 'z' || i == (Z_STRLEN_P(pattern) - 1)) { + replace = phalcon_replace_marker(0, paths, replacements, &position, cursor, marker); + if (replace) { + use_copy = 0; + if (Z_TYPE_P(replace) != IS_STRING) { + use_copy = zend_make_printable_zval(replace, &replace_copy); + if (use_copy) { + replace = &replace_copy; + } + } + smart_str_appendl(&route_str, Z_STRVAL_P(replace), Z_STRLEN_P(replace)); + if (use_copy) { + zval_dtor(&replace_copy); + } + } + looking_placeholder = 0; + continue; + } + } + } else { + if (ch == ':') { + looking_placeholder = 1; + marker = cursor; + intermediate = 0; + } } -pp313: - { - token->opcode = PHQL_T_USING; - return 0; } -pp314: - ppch = *++PPCURSOR; - switch (ppch) { - case 'S': - case 's': goto pp336; - default: goto pp59; + + if (bracket_count > 0 || parentheses_count > 0 || looking_placeholder) { + intermediate++; + } else { + smart_str_appendc(&route_str, ch); + } + + cursor++; + } + smart_str_0(&route_str); + + if (route_str.s) { + RETURN_STR(route_str.s); + } else { + smart_str_free(&route_str); + RETURN_EMPTY_STRING(); + } +} + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_Annotations) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Router, Annotations, phalcon, mvc_router_annotations, phalcon_mvc_router_ce, phalcon_mvc_router_annotations_method_entry, 0); + + zend_declare_property_string(phalcon_mvc_router_annotations_ce, SL("actionSuffix"), "Action", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_router_annotations_ce, SL("actionPreformatCallback"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_mvc_router_annotations_ce, SL("controllerSuffix"), "Controller", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_router_annotations_ce, SL("handlers"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_mvc_router_annotations_ce, SL("routePrefix"), "", ZEND_ACC_PROTECTED); + phalcon_mvc_router_annotations_ce->create_object = zephir_init_properties_Phalcon_Mvc_Router_Annotations; + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Mvc_Router_Annotations, addModuleResource) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *module_param = NULL, *handler_param = NULL, *prefix_param = NULL; + zval module, handler, prefix; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&module); + ZVAL_UNDEF(&handler); + ZVAL_UNDEF(&prefix); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(module) + Z_PARAM_STR(handler) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(prefix) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 1, &module_param, &handler_param, &prefix_param); + if (UNEXPECTED(Z_TYPE_P(module_param) != IS_STRING && Z_TYPE_P(module_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'module' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(module_param) == IS_STRING)) { + zephir_get_strval(&module, module_param); + } else { + ZEPHIR_INIT_VAR(&module); + } + if (UNEXPECTED(Z_TYPE_P(handler_param) != IS_STRING && Z_TYPE_P(handler_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'handler' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(handler_param) == IS_STRING)) { + zephir_get_strval(&handler, handler_param); + } else { + ZEPHIR_INIT_VAR(&handler); + } + if (!prefix_param) { + ZEPHIR_INIT_VAR(&prefix); + } else { + if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) { + zephir_get_strval(&prefix, prefix_param); + } else { + ZEPHIR_INIT_VAR(&prefix); + } + } + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 3, 0); + zephir_array_fast_append(&_0, &prefix); + zephir_array_fast_append(&_0, &handler); + zephir_array_fast_append(&_0, &module); + zephir_update_property_array_append(this_ptr, SL("handlers"), &_0); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Annotations, addResource) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *handler_param = NULL, *prefix_param = NULL; + zval handler, prefix; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&handler); + ZVAL_UNDEF(&prefix); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(handler) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(prefix) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &handler_param, &prefix_param); + if (UNEXPECTED(Z_TYPE_P(handler_param) != IS_STRING && Z_TYPE_P(handler_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'handler' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(handler_param) == IS_STRING)) { + zephir_get_strval(&handler, handler_param); + } else { + ZEPHIR_INIT_VAR(&handler); + } + if (!prefix_param) { + ZEPHIR_INIT_VAR(&prefix); + } else { + if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) { + zephir_get_strval(&prefix, prefix_param); + } else { + ZEPHIR_INIT_VAR(&prefix); + } + } + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 2, 0); + zephir_array_fast_append(&_0, &prefix); + zephir_array_fast_append(&_0, &handler); + zephir_update_property_array_append(this_ptr, SL("handlers"), &_0); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Annotations, getResources) +{ + + RETURN_MEMBER(getThis(), "handlers"); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Annotations, handle) +{ + zend_string *_20$$18, *_41$$41; + zend_ulong _19$$18, _40$$41; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL, *_13 = NULL, *_16 = NULL, *_24 = NULL, *_35 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *uri_param = NULL, __$null, annotationsService, handlers, controllerSuffix, scope, prefix, route, compiledPattern, container, handler, controllerName, lowerControllerName, namespaceName, moduleName, handlerAnnotations, classAnnotations, annotations, annotation, methodAnnotations, method, collection, _0, _1, *_2, _3, _5$$6, _7$$6, _8$$6, _9$$7, _10$$7, _11$$4, _12$$12, *_14$$15, _15$$15, *_17$$18, _18$$18, _21$$19, *_22$$19, _23$$19, _25$$23, *_26$$23, _27$$23, _28$$29, _29$$29, _30$$29, _31$$30, _32$$30, _33$$27, _34$$35, *_36$$38, _37$$38, *_38$$41, _39$$41, _42$$42, *_43$$42, _44$$42, _45$$46, *_46$$46, _47$$46; + zval uri, sufixed; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&uri); + ZVAL_UNDEF(&sufixed); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&annotationsService); + ZVAL_UNDEF(&handlers); + ZVAL_UNDEF(&controllerSuffix); + ZVAL_UNDEF(&scope); + ZVAL_UNDEF(&prefix); + ZVAL_UNDEF(&route); + ZVAL_UNDEF(&compiledPattern); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&handler); + ZVAL_UNDEF(&controllerName); + ZVAL_UNDEF(&lowerControllerName); + ZVAL_UNDEF(&namespaceName); + ZVAL_UNDEF(&moduleName); + ZVAL_UNDEF(&handlerAnnotations); + ZVAL_UNDEF(&classAnnotations); + ZVAL_UNDEF(&annotations); + ZVAL_UNDEF(&annotation); + ZVAL_UNDEF(&methodAnnotations); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&_9$$7); + ZVAL_UNDEF(&_10$$7); + ZVAL_UNDEF(&_11$$4); + ZVAL_UNDEF(&_12$$12); + ZVAL_UNDEF(&_15$$15); + ZVAL_UNDEF(&_18$$18); + ZVAL_UNDEF(&_21$$19); + ZVAL_UNDEF(&_23$$19); + ZVAL_UNDEF(&_25$$23); + ZVAL_UNDEF(&_27$$23); + ZVAL_UNDEF(&_28$$29); + ZVAL_UNDEF(&_29$$29); + ZVAL_UNDEF(&_30$$29); + ZVAL_UNDEF(&_31$$30); + ZVAL_UNDEF(&_32$$30); + ZVAL_UNDEF(&_33$$27); + ZVAL_UNDEF(&_34$$35); + ZVAL_UNDEF(&_37$$38); + ZVAL_UNDEF(&_39$$41); + ZVAL_UNDEF(&_42$$42); + ZVAL_UNDEF(&_44$$42); + ZVAL_UNDEF(&_45$$46); + ZVAL_UNDEF(&_47$$46); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(uri) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &uri_param); + if (UNEXPECTED(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 of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(uri_param) == IS_STRING)) { + zephir_get_strval(&uri, uri_param); + } else { + ZEPHIR_INIT_VAR(&uri); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_0); + if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'annotations' service", "phalcon/Mvc/Router/Annotations.zep", 114); + return; + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("handlers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&handlers, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("controllerSuffix"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&controllerSuffix, &_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "annotations"); + ZEPHIR_CALL_METHOD(&annotationsService, &container, "getshared", NULL, 0, &_1); + zephir_check_call_status(); + zephir_is_iterable(&handlers, 0, "phalcon/Mvc/Router/Annotations.zep", 250); + if (Z_TYPE_P(&handlers) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&handlers), _2) + { + ZEPHIR_INIT_NVAR(&scope); + ZVAL_COPY(&scope, _2); + if (Z_TYPE_P(&scope) != IS_ARRAY) { + continue; } -pp315: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp316; + ZEPHIR_OBS_NVAR(&prefix); + zephir_array_fetch_long(&prefix, &scope, 0, PH_NOISY, "phalcon/Mvc/Router/Annotations.zep", 129); + if (!(ZEPHIR_IS_EMPTY(&prefix))) { + ZEPHIR_INIT_NVAR(&route); + object_init_ex(&route, phalcon_mvc_router_route_ce); + ZEPHIR_CALL_METHOD(NULL, &route, "__construct", &_4, 101, &prefix); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5$$6, &route, "getcompiledpattern", &_6, 486); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_7$$6); + ZVAL_STRING(&_7$$6, "$#"); + ZEPHIR_INIT_NVAR(&_8$$6); + ZVAL_STRING(&_8$$6, "#"); + ZEPHIR_INIT_NVAR(&compiledPattern); + zephir_fast_str_replace(&compiledPattern, &_7$$6, &_8$$6, &_5$$6); + if (zephir_memnstr_str(&compiledPattern, SL("^"), "phalcon/Mvc/Router/Annotations.zep", 146)) { + ZEPHIR_INIT_NVAR(&_9$$7); + ZEPHIR_INIT_NVAR(&_10$$7); + zephir_preg_match(&_10$$7, &compiledPattern, &uri, &_9$$7, 0, 0 , 0 ); + if (!(zephir_is_true(&_10$$7))) { + continue; + } + } else if (!(zephir_start_with(&uri, &prefix, NULL))) { + continue; + } } -pp316: - { - token->opcode = PHQL_T_WHERE; - return 0; - } -pp317: - ppch = *++PPCURSOR; - switch (ppch) { - case 'T': - case 't': goto pp338; - default: goto pp59; + ZEPHIR_OBS_NVAR(&handler); + zephir_array_fetch_long(&handler, &scope, 1, PH_NOISY, "phalcon/Mvc/Router/Annotations.zep", 161); + if (zephir_memnstr_str(&handler, SL("\\"), "phalcon/Mvc/Router/Annotations.zep", 163)) { + ZEPHIR_INIT_NVAR(&controllerName); + zephir_get_class_ns(&controllerName, &handler, 0); + ZEPHIR_INIT_NVAR(&namespaceName); + zephir_get_ns_class(&namespaceName, &handler, 0); + } else { + ZEPHIR_CPY_WRT(&controllerName, &handler); + ZEPHIR_OBS_NVAR(&namespaceName); + zephir_fetch_property(&namespaceName, this_ptr, SL("defaultNamespace"), PH_SILENT_CC); } -pp318: - ppch = *++PPCURSOR; - switch (ppch) { - case 'N': - case 'n': goto pp340; - default: goto pp59; + zephir_update_property_zval(this_ptr, ZEND_STRL("routePrefix"), &__$null); + ZEPHIR_OBS_NVAR(&moduleName); + zephir_array_isset_long_fetch(&moduleName, &scope, 2, 0); + ZEPHIR_INIT_NVAR(&_11$$4); + if (Z_TYPE_P(&moduleName) != IS_NULL) { + ZEPHIR_CPY_WRT(&_11$$4, &moduleName); + } else { + ZEPHIR_INIT_NVAR(&_11$$4); + ZVAL_STRING(&_11$$4, ""); } -pp319: - ppch = *++PPCURSOR; - switch (ppch) { - case 'T': - case 't': goto pp342; - default: goto pp59; + ZEPHIR_CPY_WRT(&moduleName, &_11$$4); + ZEPHIR_INIT_NVAR(&_11$$4); + ZEPHIR_CONCAT_VV(&_11$$4, &controllerName, &controllerSuffix); + zephir_get_strval(&sufixed, &_11$$4); + if (Z_TYPE_P(&namespaceName) != IS_NULL) { + ZEPHIR_INIT_NVAR(&_12$$12); + ZEPHIR_CONCAT_VSV(&_12$$12, &namespaceName, "\\", &sufixed); + zephir_get_strval(&sufixed, &_12$$12); } -pp320: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp321; + ZEPHIR_CALL_METHOD(&handlerAnnotations, &annotationsService, "get", &_13, 0, &sufixed); + zephir_check_call_status(); + if (Z_TYPE_P(&handlerAnnotations) != IS_OBJECT) { + continue; } -pp321: - { - token->opcode = PHQL_T_DELETE; - return 0; - } -pp322: - ppch = *++PPCURSOR; - switch (ppch) { - case 'C': - case 'c': goto pp344; - default: goto pp59; + ZEPHIR_CALL_METHOD(&classAnnotations, &handlerAnnotations, "getclassannotations", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&classAnnotations) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(&annotations, &classAnnotations, "getannotations", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&annotations) == IS_ARRAY) { + zephir_is_iterable(&annotations, 0, "phalcon/Mvc/Router/Annotations.zep", 218); + if (Z_TYPE_P(&annotations) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&annotations), _14$$15) + { + ZEPHIR_INIT_NVAR(&annotation); + ZVAL_COPY(&annotation, _14$$15); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processcontrollerannotation", &_16, 0, &controllerName, &annotation); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &annotations, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_15$$15, &annotations, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_15$$15)) { + break; + } + ZEPHIR_CALL_METHOD(&annotation, &annotations, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processcontrollerannotation", &_16, 0, &controllerName, &annotation); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &annotations, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&annotation); + } } -pp323: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp324; + ZEPHIR_CALL_METHOD(&methodAnnotations, &handlerAnnotations, "getmethodsannotations", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&methodAnnotations) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&lowerControllerName); + zephir_uncamelize(&lowerControllerName, &controllerName, NULL ); + zephir_is_iterable(&methodAnnotations, 0, "phalcon/Mvc/Router/Annotations.zep", 244); + if (Z_TYPE_P(&methodAnnotations) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&methodAnnotations), _19$$18, _20$$18, _17$$18) + { + ZEPHIR_INIT_NVAR(&method); + if (_20$$18 != NULL) { + ZVAL_STR_COPY(&method, _20$$18); + } else { + ZVAL_LONG(&method, _19$$18); + } + ZEPHIR_INIT_NVAR(&collection); + ZVAL_COPY(&collection, _17$$18); + if (Z_TYPE_P(&collection) != IS_OBJECT) { + continue; + } + ZEPHIR_CALL_METHOD(&_21$$19, &collection, "getannotations", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&_21$$19, 0, "phalcon/Mvc/Router/Annotations.zep", 243); + if (Z_TYPE_P(&_21$$19) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_21$$19), _22$$19) + { + ZEPHIR_INIT_NVAR(&annotation); + ZVAL_COPY(&annotation, _22$$19); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_21$$19, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_23$$19, &_21$$19, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_23$$19)) { + break; + } + ZEPHIR_CALL_METHOD(&annotation, &_21$$19, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_21$$19, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&annotation); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &methodAnnotations, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_18$$18, &methodAnnotations, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_18$$18)) { + break; + } + ZEPHIR_CALL_METHOD(&method, &methodAnnotations, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&collection, &methodAnnotations, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&collection) != IS_OBJECT) { + continue; + } + ZEPHIR_CALL_METHOD(&_25$$23, &collection, "getannotations", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&_25$$23, 0, "phalcon/Mvc/Router/Annotations.zep", 243); + if (Z_TYPE_P(&_25$$23) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_25$$23), _26$$23) + { + ZEPHIR_INIT_NVAR(&annotation); + ZVAL_COPY(&annotation, _26$$23); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_25$$23, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_27$$23, &_25$$23, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_27$$23)) { + break; + } + ZEPHIR_CALL_METHOD(&annotation, &_25$$23, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_25$$23, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&annotation); + ZEPHIR_CALL_METHOD(NULL, &methodAnnotations, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&collection); + ZEPHIR_INIT_NVAR(&method); } -pp324: - { - token->opcode = PHQL_T_EXISTS; - return 0; - } -pp325: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp326; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &handlers, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &handlers, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; } -pp326: - { - token->opcode = PHQL_T_HAVING; - return 0; + ZEPHIR_CALL_METHOD(&scope, &handlers, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&scope) != IS_ARRAY) { + continue; + } + ZEPHIR_OBS_NVAR(&prefix); + zephir_array_fetch_long(&prefix, &scope, 0, PH_NOISY, "phalcon/Mvc/Router/Annotations.zep", 129); + if (!(ZEPHIR_IS_EMPTY(&prefix))) { + ZEPHIR_INIT_NVAR(&route); + object_init_ex(&route, phalcon_mvc_router_route_ce); + ZEPHIR_CALL_METHOD(NULL, &route, "__construct", &_4, 101, &prefix); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_28$$29, &route, "getcompiledpattern", &_6, 486); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_29$$29); + ZVAL_STRING(&_29$$29, "$#"); + ZEPHIR_INIT_NVAR(&_30$$29); + ZVAL_STRING(&_30$$29, "#"); + ZEPHIR_INIT_NVAR(&compiledPattern); + zephir_fast_str_replace(&compiledPattern, &_29$$29, &_30$$29, &_28$$29); + if (zephir_memnstr_str(&compiledPattern, SL("^"), "phalcon/Mvc/Router/Annotations.zep", 146)) { + ZEPHIR_INIT_NVAR(&_31$$30); + ZEPHIR_INIT_NVAR(&_32$$30); + zephir_preg_match(&_32$$30, &compiledPattern, &uri, &_31$$30, 0, 0 , 0 ); + if (!(zephir_is_true(&_32$$30))) { + continue; + } + } else if (!(zephir_start_with(&uri, &prefix, NULL))) { + continue; + } + } + ZEPHIR_OBS_NVAR(&handler); + zephir_array_fetch_long(&handler, &scope, 1, PH_NOISY, "phalcon/Mvc/Router/Annotations.zep", 161); + if (zephir_memnstr_str(&handler, SL("\\"), "phalcon/Mvc/Router/Annotations.zep", 163)) { + ZEPHIR_INIT_NVAR(&controllerName); + zephir_get_class_ns(&controllerName, &handler, 0); + ZEPHIR_INIT_NVAR(&namespaceName); + zephir_get_ns_class(&namespaceName, &handler, 0); + } else { + ZEPHIR_CPY_WRT(&controllerName, &handler); + ZEPHIR_OBS_NVAR(&namespaceName); + zephir_fetch_property(&namespaceName, this_ptr, SL("defaultNamespace"), PH_SILENT_CC); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("routePrefix"), &__$null); + ZEPHIR_OBS_NVAR(&moduleName); + zephir_array_isset_long_fetch(&moduleName, &scope, 2, 0); + ZEPHIR_INIT_NVAR(&_33$$27); + if (Z_TYPE_P(&moduleName) != IS_NULL) { + ZEPHIR_CPY_WRT(&_33$$27, &moduleName); + } else { + ZEPHIR_INIT_NVAR(&_33$$27); + ZVAL_STRING(&_33$$27, ""); + } + ZEPHIR_CPY_WRT(&moduleName, &_33$$27); + ZEPHIR_INIT_NVAR(&_33$$27); + ZEPHIR_CONCAT_VV(&_33$$27, &controllerName, &controllerSuffix); + zephir_get_strval(&sufixed, &_33$$27); + if (Z_TYPE_P(&namespaceName) != IS_NULL) { + ZEPHIR_INIT_NVAR(&_34$$35); + ZEPHIR_CONCAT_VSV(&_34$$35, &namespaceName, "\\", &sufixed); + zephir_get_strval(&sufixed, &_34$$35); + } + ZEPHIR_CALL_METHOD(&handlerAnnotations, &annotationsService, "get", &_35, 0, &sufixed); + zephir_check_call_status(); + if (Z_TYPE_P(&handlerAnnotations) != IS_OBJECT) { + continue; + } + ZEPHIR_CALL_METHOD(&classAnnotations, &handlerAnnotations, "getclassannotations", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&classAnnotations) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(&annotations, &classAnnotations, "getannotations", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&annotations) == IS_ARRAY) { + zephir_is_iterable(&annotations, 0, "phalcon/Mvc/Router/Annotations.zep", 218); + if (Z_TYPE_P(&annotations) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&annotations), _36$$38) + { + ZEPHIR_INIT_NVAR(&annotation); + ZVAL_COPY(&annotation, _36$$38); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processcontrollerannotation", &_16, 0, &controllerName, &annotation); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &annotations, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_37$$38, &annotations, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_37$$38)) { + break; + } + ZEPHIR_CALL_METHOD(&annotation, &annotations, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processcontrollerannotation", &_16, 0, &controllerName, &annotation); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &annotations, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&annotation); + } + } + ZEPHIR_CALL_METHOD(&methodAnnotations, &handlerAnnotations, "getmethodsannotations", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&methodAnnotations) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&lowerControllerName); + zephir_uncamelize(&lowerControllerName, &controllerName, NULL ); + zephir_is_iterable(&methodAnnotations, 0, "phalcon/Mvc/Router/Annotations.zep", 244); + if (Z_TYPE_P(&methodAnnotations) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&methodAnnotations), _40$$41, _41$$41, _38$$41) + { + ZEPHIR_INIT_NVAR(&method); + if (_41$$41 != NULL) { + ZVAL_STR_COPY(&method, _41$$41); + } else { + ZVAL_LONG(&method, _40$$41); + } + ZEPHIR_INIT_NVAR(&collection); + ZVAL_COPY(&collection, _38$$41); + if (Z_TYPE_P(&collection) != IS_OBJECT) { + continue; + } + ZEPHIR_CALL_METHOD(&_42$$42, &collection, "getannotations", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&_42$$42, 0, "phalcon/Mvc/Router/Annotations.zep", 243); + if (Z_TYPE_P(&_42$$42) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_42$$42), _43$$42) + { + ZEPHIR_INIT_NVAR(&annotation); + ZVAL_COPY(&annotation, _43$$42); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_42$$42, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_44$$42, &_42$$42, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_44$$42)) { + break; + } + ZEPHIR_CALL_METHOD(&annotation, &_42$$42, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_42$$42, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&annotation); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &methodAnnotations, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_39$$41, &methodAnnotations, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_39$$41)) { + break; + } + ZEPHIR_CALL_METHOD(&method, &methodAnnotations, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&collection, &methodAnnotations, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&collection) != IS_OBJECT) { + continue; + } + ZEPHIR_CALL_METHOD(&_45$$46, &collection, "getannotations", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&_45$$46, 0, "phalcon/Mvc/Router/Annotations.zep", 243); + if (Z_TYPE_P(&_45$$46) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_45$$46), _46$$46) + { + ZEPHIR_INIT_NVAR(&annotation); + ZVAL_COPY(&annotation, _46$$46); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_45$$46, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_47$$46, &_45$$46, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_47$$46)) { + break; + } + ZEPHIR_CALL_METHOD(&annotation, &_45$$46, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_45$$46, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&annotation); + ZEPHIR_CALL_METHOD(NULL, &methodAnnotations, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&collection); + ZEPHIR_INIT_NVAR(&method); + } + ZEPHIR_CALL_METHOD(NULL, &handlers, "next", NULL, 0); + zephir_check_call_status(); } -pp327: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp328; - } -pp328: - { - token->opcode = PHQL_T_INSERT; - return 0; + } + ZEPHIR_INIT_NVAR(&scope); + ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_router_annotations_ce, getThis(), "handle", NULL, 0, &uri); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Annotations, processActionAnnotation) +{ + zend_string *_12$$18, *_18$$21; + zend_ulong _11$$18, _17$$21; + zend_bool isRoute = 0, _8, _21; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_13 = NULL, *_14 = NULL, *_19 = NULL, *_20 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *module_param = NULL, *namespaceName_param = NULL, *controller_param = NULL, *action_param = NULL, *annotation, annotation_sub, name, proxyActionName, actionName, routePrefix, paths, value, uri, route, methods, converts, param, convert, converterParam, routeName, beforeMatch, _0, _1, _2, _5, _6, _3$$6, _4$$6, _7$$16, *_9$$18, _10$$18, *_15$$21, _16$$21; + zval module, namespaceName, controller, action; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&module); + ZVAL_UNDEF(&namespaceName); + ZVAL_UNDEF(&controller); + ZVAL_UNDEF(&action); + ZVAL_UNDEF(&annotation_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&proxyActionName); + ZVAL_UNDEF(&actionName); + ZVAL_UNDEF(&routePrefix); + ZVAL_UNDEF(&paths); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&uri); + ZVAL_UNDEF(&route); + ZVAL_UNDEF(&methods); + ZVAL_UNDEF(&converts); + ZVAL_UNDEF(¶m); + ZVAL_UNDEF(&convert); + ZVAL_UNDEF(&converterParam); + ZVAL_UNDEF(&routeName); + ZVAL_UNDEF(&beforeMatch); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_3$$6); + ZVAL_UNDEF(&_4$$6); + ZVAL_UNDEF(&_7$$16); + ZVAL_UNDEF(&_10$$18); + ZVAL_UNDEF(&_16$$21); + ZEND_PARSE_PARAMETERS_START(5, 5) + Z_PARAM_STR(module) + Z_PARAM_STR(namespaceName) + Z_PARAM_STR(controller) + Z_PARAM_STR(action) + Z_PARAM_OBJECT_OF_CLASS(annotation, phalcon_annotations_annotation_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 5, 0, &module_param, &namespaceName_param, &controller_param, &action_param, &annotation); + if (UNEXPECTED(Z_TYPE_P(module_param) != IS_STRING && Z_TYPE_P(module_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'module' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(module_param) == IS_STRING)) { + zephir_get_strval(&module, module_param); + } else { + ZEPHIR_INIT_VAR(&module); + } + if (UNEXPECTED(Z_TYPE_P(namespaceName_param) != IS_STRING && Z_TYPE_P(namespaceName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'namespaceName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(namespaceName_param) == IS_STRING)) { + zephir_get_strval(&namespaceName, namespaceName_param); + } else { + ZEPHIR_INIT_VAR(&namespaceName); + } + if (UNEXPECTED(Z_TYPE_P(controller_param) != IS_STRING && Z_TYPE_P(controller_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controller' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(controller_param) == IS_STRING)) { + zephir_get_strval(&controller, controller_param); + } else { + ZEPHIR_INIT_VAR(&controller); + } + if (UNEXPECTED(Z_TYPE_P(action_param) != IS_STRING && Z_TYPE_P(action_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'action' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(action_param) == IS_STRING)) { + zephir_get_strval(&action, action_param); + } else { + ZEPHIR_INIT_VAR(&action); + } + isRoute = 0; + ZEPHIR_INIT_VAR(&methods); + ZVAL_NULL(&methods); + ZEPHIR_CALL_METHOD(&name, annotation, "getname", NULL, 0); + zephir_check_call_status(); + do { + if (ZEPHIR_IS_STRING(&name, "Route")) { + isRoute = 1; + break; } -pp329: - ppch = *++PPCURSOR; - switch (ppch) { - case 'T': - case 't': goto pp345; - default: goto pp86; - } -pp330: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp331; - } -pp331: - { - token->opcode = PHQL_T_OFFSET; - return 0; + if (ZEPHIR_IS_STRING(&name, "Get") || ZEPHIR_IS_STRING(&name, "Post") || ZEPHIR_IS_STRING(&name, "Put") || ZEPHIR_IS_STRING(&name, "Patch") || ZEPHIR_IS_STRING(&name, "Delete") || ZEPHIR_IS_STRING(&name, "Options")) { + isRoute = 1; + ZEPHIR_INIT_NVAR(&methods); + zephir_fast_strtoupper(&methods, &name); + break; } -pp332: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp333; + } while(0); + + if (!(isRoute)) { + RETURN_MM_NULL(); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("actionSuffix"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, ""); + ZEPHIR_INIT_VAR(&proxyActionName); + zephir_fast_str_replace(&proxyActionName, &_0, &_1, &action); + zephir_read_property(&_2, this_ptr, ZEND_STRL("routePrefix"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&routePrefix, &_2); + zephir_read_property(&_2, this_ptr, ZEND_STRL("actionPreformatCallback"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) != IS_NULL) { + zephir_read_property(&_3$$6, this_ptr, ZEND_STRL("actionPreformatCallback"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&_4$$6, "call_user_func", NULL, 188, &_3$$6, &proxyActionName); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&proxyActionName, &_4$$6); + } + ZEPHIR_INIT_VAR(&actionName); + zephir_fast_strtolower(&actionName, &proxyActionName); + ZEPHIR_INIT_VAR(&_5); + ZVAL_STRING(&_5, "paths"); + ZEPHIR_CALL_METHOD(&paths, annotation, "getnamedargument", NULL, 0, &_5); + zephir_check_call_status(); + if (Z_TYPE_P(&paths) != IS_ARRAY) { + ZEPHIR_INIT_NVAR(&paths); + array_init(&paths); + } + if (!(ZEPHIR_IS_EMPTY(&module))) { + zephir_array_update_string(&paths, SL("module"), &module, PH_COPY | PH_SEPARATE); + } + if (!(ZEPHIR_IS_EMPTY(&namespaceName))) { + zephir_array_update_string(&paths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE); + } + zephir_array_update_string(&paths, SL("controller"), &controller, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&paths, SL("action"), &actionName, PH_COPY | PH_SEPARATE); + ZVAL_LONG(&_6, 0); + ZEPHIR_CALL_METHOD(&value, annotation, "getargument", NULL, 0, &_6); + zephir_check_call_status(); + if (Z_TYPE_P(&value) != IS_NULL) { + if (!ZEPHIR_IS_STRING(&value, "/")) { + ZEPHIR_INIT_VAR(&uri); + ZEPHIR_CONCAT_VV(&uri, &routePrefix, &value); + } else { + if (Z_TYPE_P(&routePrefix) != IS_NULL) { + ZEPHIR_CPY_WRT(&uri, &routePrefix); + } else { + ZEPHIR_CPY_WRT(&uri, &value); } -pp333: - { - token->opcode = PHQL_T_SELECT; - return 0; } -pp334: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp335; - } -pp335: + } else { + ZEPHIR_INIT_NVAR(&uri); + ZEPHIR_CONCAT_VV(&uri, &routePrefix, &actionName); + } + ZEPHIR_CALL_METHOD(&route, this_ptr, "add", NULL, 0, &uri, &paths); + zephir_check_call_status(); + if (Z_TYPE_P(&methods) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$16); + ZVAL_STRING(&_7$$16, "methods"); + ZEPHIR_CALL_METHOD(&methods, annotation, "getnamedargument", NULL, 0, &_7$$16); + zephir_check_call_status(); + } + _8 = Z_TYPE_P(&methods) == IS_ARRAY; + if (!(_8)) { + _8 = Z_TYPE_P(&methods) == IS_STRING; + } + if (_8) { + ZEPHIR_CALL_METHOD(NULL, &route, "via", NULL, 0, &methods); + zephir_check_call_status(); + } + ZEPHIR_INIT_NVAR(&_5); + ZVAL_STRING(&_5, "converts"); + ZEPHIR_CALL_METHOD(&converts, annotation, "getnamedargument", NULL, 0, &_5); + zephir_check_call_status(); + if (Z_TYPE_P(&converts) == IS_ARRAY) { + zephir_is_iterable(&converts, 0, "phalcon/Mvc/Router/Annotations.zep", 373); + if (Z_TYPE_P(&converts) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&converts), _11$$18, _12$$18, _9$$18) { - token->opcode = PHQL_T_UPDATE; - return 0; - } -pp336: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp337; + ZEPHIR_INIT_NVAR(¶m); + if (_12$$18 != NULL) { + ZVAL_STR_COPY(¶m, _12$$18); + } else { + ZVAL_LONG(¶m, _11$$18); + } + ZEPHIR_INIT_NVAR(&convert); + ZVAL_COPY(&convert, _9$$18); + ZEPHIR_CALL_METHOD(NULL, &route, "convert", &_13, 0, ¶m, &convert); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &converts, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_10$$18, &converts, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_10$$18)) { + break; + } + ZEPHIR_CALL_METHOD(¶m, &converts, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&convert, &converts, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &route, "convert", &_14, 0, ¶m, &convert); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &converts, "next", NULL, 0); + zephir_check_call_status(); } -pp337: - { - token->opcode = PHQL_T_VALUES; - return 0; } -pp338: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp339; - } -pp339: + ZEPHIR_INIT_NVAR(&convert); + ZEPHIR_INIT_NVAR(¶m); + } + ZEPHIR_INIT_NVAR(&_5); + ZVAL_STRING(&_5, "converters"); + ZEPHIR_CALL_METHOD(&converts, annotation, "getnamedargument", NULL, 0, &_5); + zephir_check_call_status(); + if (Z_TYPE_P(&converts) == IS_ARRAY) { + zephir_is_iterable(&converts, 0, "phalcon/Mvc/Router/Annotations.zep", 384); + if (Z_TYPE_P(&converts) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&converts), _17$$21, _18$$21, _15$$21) { - token->opcode = PHQL_T_AGAINST; - return 0; - } -pp340: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp341; + ZEPHIR_INIT_NVAR(&converterParam); + if (_18$$21 != NULL) { + ZVAL_STR_COPY(&converterParam, _18$$21); + } else { + ZVAL_LONG(&converterParam, _17$$21); + } + ZEPHIR_INIT_NVAR(&convert); + ZVAL_COPY(&convert, _15$$21); + ZEPHIR_CALL_METHOD(NULL, &route, "convert", &_19, 0, &converterParam, &convert); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &converts, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_16$$21, &converts, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_16$$21)) { + break; + } + ZEPHIR_CALL_METHOD(&converterParam, &converts, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&convert, &converts, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &route, "convert", &_20, 0, &converterParam, &convert); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &converts, "next", NULL, 0); + zephir_check_call_status(); } -pp341: - { - token->opcode = PHQL_T_BETWEEN; - return 0; } -pp342: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp343; - } -pp343: - { - token->opcode = PHQL_T_CONVERT; - return 0; + ZEPHIR_INIT_NVAR(&convert); + ZEPHIR_INIT_NVAR(&converterParam); + } + ZEPHIR_INIT_NVAR(&_5); + ZVAL_STRING(&_5, "beforeMatch"); + ZEPHIR_CALL_METHOD(&beforeMatch, annotation, "getnamedargument", NULL, 0, &_5); + zephir_check_call_status(); + _21 = Z_TYPE_P(&beforeMatch) == IS_ARRAY; + if (!(_21)) { + _21 = Z_TYPE_P(&beforeMatch) == IS_STRING; + } + if (_21) { + ZEPHIR_CALL_METHOD(NULL, &route, "beforematch", NULL, 0, &beforeMatch); + zephir_check_call_status(); + } + ZEPHIR_INIT_NVAR(&_5); + ZVAL_STRING(&_5, "name"); + ZEPHIR_CALL_METHOD(&routeName, annotation, "getnamedargument", NULL, 0, &_5); + zephir_check_call_status(); + if (Z_TYPE_P(&routeName) == IS_STRING) { + ZEPHIR_CALL_METHOD(NULL, &route, "setname", NULL, 0, &routeName); + zephir_check_call_status(); + } + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Annotations, processControllerAnnotation) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *handler_param = NULL, *annotation, annotation_sub, _0, _1$$3, _2$$3; + zval handler; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&handler); + ZVAL_UNDEF(&annotation_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(handler) + Z_PARAM_OBJECT_OF_CLASS(annotation, phalcon_annotations_annotation_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &handler_param, &annotation); + if (UNEXPECTED(Z_TYPE_P(handler_param) != IS_STRING && Z_TYPE_P(handler_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'handler' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(handler_param) == IS_STRING)) { + zephir_get_strval(&handler, handler_param); + } else { + ZEPHIR_INIT_VAR(&handler); + } + ZEPHIR_CALL_METHOD(&_0, annotation, "getname", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_STRING(&_0, "RoutePrefix")) { + ZVAL_LONG(&_2$$3, 0); + ZEPHIR_CALL_METHOD(&_1$$3, annotation, "getargument", NULL, 0, &_2$$3); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("routePrefix"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Annotations, setActionSuffix) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *actionSuffix_param = NULL; + zval actionSuffix; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&actionSuffix); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(actionSuffix) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &actionSuffix_param); + if (UNEXPECTED(Z_TYPE_P(actionSuffix_param) != IS_STRING && Z_TYPE_P(actionSuffix_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionSuffix' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(actionSuffix_param) == IS_STRING)) { + zephir_get_strval(&actionSuffix, actionSuffix_param); + } else { + ZEPHIR_INIT_VAR(&actionSuffix); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("actionSuffix"), &actionSuffix); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Annotations, setActionPreformatCallback) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *callback = NULL, callback_sub, __$null, _0$$4; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&callback_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0$$4); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(callback) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &callback); + if (!callback) { + callback = &callback_sub; + callback = &__$null; + } + if (EXPECTED(zephir_is_callable(callback))) { + zephir_update_property_zval(this_ptr, ZEND_STRL("actionPreformatCallback"), callback); + } else if (Z_TYPE_P(callback) == IS_NULL) { + ZEPHIR_INIT_VAR(&_0$$4); + ZEPHIR_INIT_NVAR(&_0$$4); + zephir_create_closure_ex(&_0$$4, NULL, phalcon_9__closure_ce, SL("__invoke")); + zephir_update_property_zval(this_ptr, ZEND_STRL("actionPreformatCallback"), &_0$$4); + } else { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "The 'callback' parameter must be either a callable or NULL.", "phalcon/Mvc/Router/Annotations.zep", 463); + return; + } + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Annotations, getActionPreformatCallback) +{ + + RETURN_MEMBER(getThis(), "actionPreformatCallback"); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Annotations, setControllerSuffix) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *controllerSuffix_param = NULL; + zval controllerSuffix; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&controllerSuffix); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(controllerSuffix) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &controllerSuffix_param); + if (UNEXPECTED(Z_TYPE_P(controllerSuffix_param) != IS_STRING && Z_TYPE_P(controllerSuffix_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerSuffix' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(controllerSuffix_param) == IS_STRING)) { + zephir_get_strval(&controllerSuffix, controllerSuffix_param); + } else { + ZEPHIR_INIT_VAR(&controllerSuffix); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("controllerSuffix"), &controllerSuffix); + ZEPHIR_MM_RESTORE(); +} + +zend_object *zephir_init_properties_Phalcon_Mvc_Router_Annotations(zend_class_entry *class_type) +{ + zval _0, _2, _4, _6, _8, _10, _12, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8, _13$$9; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_9$$7); + ZVAL_UNDEF(&_11$$8); + ZVAL_UNDEF(&_13$$9); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("routes"), &_1$$3); } -pp344: - ppch = *++PPCURSOR; - switch (ppch) { - case 'T': - case 't': goto pp346; - default: goto pp59; - } -pp345: - ppch = *++PPCURSOR; - switch (ppch) { - case 'W': - case 'w': goto pp348; - default: goto pp86; - } -pp346: - ppch = *++PPCURSOR; - switch (ppch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case ':': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto pp58; - default: goto pp347; - } -pp347: - { - token->opcode = PHQL_T_DISTINCT; - return 0; + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_3$$4); } -pp348: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp349; - default: goto pp86; - } -pp349: - ppch = *++PPCURSOR; - switch (ppch) { - case 'E': - case 'e': goto pp350; - default: goto pp86; - } -pp350: - ppch = *++PPCURSOR; - switch (ppch) { - case 'N': - case 'n': goto pp351; - default: goto pp86; - } -pp351: - ++PPCURSOR; - { - token->opcode = PHQL_T_BETWEEN_NOT; - return 0; + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("matches"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("matches"), &_5$$5); + } + zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("keyRouteIds"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_6) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$6); + array_init(&_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("keyRouteIds"), &_7$$6); } + zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("keyRouteNames"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_8) == IS_NULL) { + ZEPHIR_INIT_VAR(&_9$$7); + array_init(&_9$$7); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("keyRouteNames"), &_9$$7); } - + zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("defaultParams"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_10) == IS_NULL) { + ZEPHIR_INIT_VAR(&_11$$8); + array_init(&_11$$8); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("defaultParams"), &_11$$8); + } + zephir_read_property_ex(&_12, this_ptr, ZEND_STRL("handlers"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_12) == IS_NULL) { + ZEPHIR_INIT_VAR(&_13$$9); + array_init(&_13$$9); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("handlers"), &_13$$9); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } +} - return status; + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Router, Exception, phalcon, mvc_router_exception, zend_ce_exception, NULL, 0); + + return SUCCESS; } + #ifdef HAVE_CONFIG_H #endif @@ -84333,633 +75420,722 @@ static int phql_get_token(phql_scanner_state *s, phql_scanner_token *token) { -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query_Status) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_Group) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model\\Query, Status, phalcon, mvc_model_query_status, phalcon_mvc_model_query_status_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Router, Group, phalcon, mvc_router_group, phalcon_mvc_router_group_method_entry, 0); - zend_declare_property_null(phalcon_mvc_model_query_status_ce, SL("model"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_model_query_status_ce, SL("success"), ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_mvc_model_query_status_ce, 1, phalcon_mvc_model_query_statusinterface_ce); + zend_declare_property_null(phalcon_mvc_router_group_ce, SL("beforeMatch"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_router_group_ce, SL("hostname"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_router_group_ce, SL("paths"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_router_group_ce, SL("prefix"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_mvc_router_group_ce, SL("routes"), ZEND_ACC_PROTECTED); + phalcon_mvc_router_group_ce->create_object = zephir_init_properties_Phalcon_Mvc_Router_Group; + + zend_class_implements(phalcon_mvc_router_group_ce, 1, phalcon_mvc_router_groupinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Status, __construct) +static PHP_METHOD(Phalcon_Mvc_Router_Group, __construct) { - zval *success_param = NULL, *model = NULL, model_sub, __$true, __$false, __$null; - zend_bool success; + zend_bool _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *paths = NULL, paths_sub, __$null; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(paths) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &paths); + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + _0 = Z_TYPE_P(paths) == IS_ARRAY; + if (!(_0)) { + _0 = Z_TYPE_P(paths) == IS_STRING; + } + if (_0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("paths"), paths); + } + if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("initialize")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0, paths); + zephir_check_call_status(); + } + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Group, add) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, *httpMethods = NULL, httpMethods_sub, __$null; + zval pattern; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_UNDEF(&httpMethods_sub); + ZVAL_NULL(&__$null); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(pattern) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_ZVAL_OR_NULL(httpMethods) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &httpMethods); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); + } else { + ZEPHIR_INIT_VAR(&pattern); + } + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + if (!httpMethods) { + httpMethods = &httpMethods_sub; + httpMethods = &__$null; + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, httpMethods); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Group, addConnect) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; + zval pattern; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(pattern) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(paths) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &pattern_param, &paths); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); + } else { + ZEPHIR_INIT_VAR(&pattern); + } + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "CONNECT"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Group, addDelete) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; + zval pattern; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(pattern) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(paths) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &pattern_param, &paths); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); + } else { + ZEPHIR_INIT_VAR(&pattern); + } + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "DELETE"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Group, addGet) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; + zval pattern; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_BOOL(success) + Z_PARAM_STR(pattern) Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(model, phalcon_mvc_modelinterface_ce) + Z_PARAM_ZVAL_OR_NULL(paths) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 1, &success_param, &model); - if (!model) { - model = &model_sub; - model = &__$null; + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &pattern_param, &paths); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); } - if (success) { - zephir_update_property_zval(this_ptr, ZEND_STRL("success"), &__$true); + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("success"), &__$false); + ZEPHIR_INIT_VAR(&pattern); } - zephir_update_property_zval(this_ptr, ZEND_STRL("model"), model); + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "GET"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Status, getMessages) +static PHP_METHOD(Phalcon_Mvc_Router_Group, addHead) { - zval model, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; + zval pattern; zval *this_ptr = getThis(); - ZVAL_UNDEF(&model); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(pattern) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(paths) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("model"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&model, &_0); - if (Z_TYPE_P(&model) != IS_OBJECT) { - array_init(return_value); - RETURN_MM(); + zephir_fetch_params(1, 1, 1, &pattern_param, &paths); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_RETURN_CALL_METHOD(&model, "getmessages", NULL, 0); + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); + } else { + ZEPHIR_INIT_VAR(&pattern); + } + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "HEAD"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_Query_Status, getModel) -{ - - RETURN_MEMBER(getThis(), "model"); -} - -static PHP_METHOD(Phalcon_Mvc_Model_Query_Status, success) -{ - - RETURN_MEMBER(getThis(), "success"); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_Query_StatusInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model\\Query, StatusInterface, phalcon, mvc_model_query_statusinterface, phalcon_mvc_model_query_statusinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_StatusInterface, getMessages); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_StatusInterface, getModel); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_Query_StatusInterface, success); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Apcu) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\MetaData, Apcu, phalcon, mvc_model_metadata_apcu, phalcon_mvc_model_metadata_ce, phalcon_mvc_model_metadata_apcu_method_entry, 0); - - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Apcu, __construct) +static PHP_METHOD(Phalcon_Mvc_Router_Group, addOptions) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval *factory, factory_sub, *options_param = NULL, _0, _1, _2, _3, _4, _5; + zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; + zval pattern; zval *this_ptr = getThis(); - ZVAL_UNDEF(&factory_sub); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&options); bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_cache_adapterfactory_ce) + Z_PARAM_STR(pattern) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY_OR_NULL(options) + Z_PARAM_ZVAL_OR_NULL(paths) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &factory, &options_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); + zephir_fetch_params(1, 1, 1, &pattern_param, &paths); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + ZEPHIR_INIT_VAR(&pattern); } - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "prefix"); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "ph-mm-apcu-"); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getarrval", NULL, 0, &options, &_1, &_2); - zephir_check_call_status(); - zephir_array_update_string(&options, SL("prefix"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "lifetime"); - ZVAL_LONG(&_4, 172800); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "getarrval", NULL, 0, &options, &_1, &_4); - zephir_check_call_status(); - zephir_array_update_string(&options, SL("lifetime"), &_3, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "apcu"); - ZEPHIR_CALL_METHOD(&_5, factory, "newinstance", NULL, 0, &_1, &options); + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "OPTIONS"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("adapter"), &_5); - ZEPHIR_MM_RESTORE(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Libmemcached) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\MetaData, Libmemcached, phalcon, mvc_model_metadata_libmemcached, phalcon_mvc_model_metadata_ce, phalcon_mvc_model_metadata_libmemcached_method_entry, 0); - - return SUCCESS; + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Libmemcached, __construct) +static PHP_METHOD(Phalcon_Mvc_Router_Group, addPatch) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval *factory, factory_sub, *options_param = NULL, _0, _1, _2, _3, _4, _5, _6; + zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; + zval pattern; zval *this_ptr = getThis(); - ZVAL_UNDEF(&factory_sub); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&options); + bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_cache_adapterfactory_ce) + Z_PARAM_STR(pattern) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + Z_PARAM_ZVAL_OR_NULL(paths) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &factory, &options_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); + zephir_fetch_params(1, 1, 1, &pattern_param, &paths); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + ZEPHIR_INIT_VAR(&pattern); } - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "persistentId"); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "ph-mm-mcid-"); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getarrval", NULL, 0, &options, &_1, &_2); - zephir_check_call_status(); - zephir_array_update_string(&options, SL("persistentId"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "prefix"); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "ph-mm-memc-"); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "getarrval", NULL, 0, &options, &_1, &_2); - zephir_check_call_status(); - zephir_array_update_string(&options, SL("prefix"), &_3, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "lifetime"); - ZVAL_LONG(&_5, 172800); - ZEPHIR_CALL_METHOD(&_4, this_ptr, "getarrval", NULL, 0, &options, &_1, &_5); - zephir_check_call_status(); - zephir_array_update_string(&options, SL("lifetime"), &_4, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "libmemcached"); - ZEPHIR_CALL_METHOD(&_6, factory, "newinstance", NULL, 0, &_1, &options); + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "PATCH"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("adapter"), &_6); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Libmemcached, reset) +static PHP_METHOD(Phalcon_Mvc_Router_Group, addPost) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; + zval pattern; zval *this_ptr = getThis(); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(pattern) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(paths) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "clear", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_metadata_libmemcached_ce, getThis(), "reset", NULL, 0); + zephir_fetch_params(1, 1, 1, &pattern_param, &paths); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); + } else { + ZEPHIR_INIT_VAR(&pattern); + } + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "POST"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Memory) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\MetaData, Memory, phalcon, mvc_model_metadata_memory, phalcon_mvc_model_metadata_ce, phalcon_mvc_model_metadata_memory_method_entry, 0); - - return SUCCESS; + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Memory, __construct) +static PHP_METHOD(Phalcon_Mvc_Router_Group, addPurge) { - zval *options = NULL, options_sub, __$null; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; + zval pattern; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&options_sub); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(pattern) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(options) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(0, 1, &options); - if (!options) { - options = &options_sub; - options = &__$null; - } -} - -static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Memory, read) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *key_param = NULL; - zval key; - - ZVAL_UNDEF(&key); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + Z_PARAM_ZVAL_OR_NULL(paths) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + zephir_fetch_params(1, 1, 1, &pattern_param, &paths); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - ZEPHIR_INIT_VAR(&key); + ZEPHIR_INIT_VAR(&pattern); } - RETURN_MM_NULL(); + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "PURGE"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Memory, write) +static PHP_METHOD(Phalcon_Mvc_Router_Group, addPut) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval data; - zval *key_param = NULL, *data_param = NULL; - zval key; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; + zval pattern; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&data); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(key) - Z_PARAM_ARRAY(data) + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(pattern) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(paths) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &key_param, &data_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + zephir_fetch_params(1, 1, 1, &pattern_param, &paths); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - ZEPHIR_INIT_VAR(&key); + ZEPHIR_INIT_VAR(&pattern); } - zephir_get_arrval(&data, data_param); - RETURN_MM_NULL(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Redis) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\MetaData, Redis, phalcon, mvc_model_metadata_redis, phalcon_mvc_model_metadata_ce, phalcon_mvc_model_metadata_redis_method_entry, 0); - - return SUCCESS; + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "PUT"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Redis, __construct) +static PHP_METHOD(Phalcon_Mvc_Router_Group, addTrace) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval *factory, factory_sub, *options_param = NULL, _0, _1, _2, _3, _4, _5; + zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; + zval pattern; zval *this_ptr = getThis(); - ZVAL_UNDEF(&factory_sub); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&options); + bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_cache_adapterfactory_ce) + Z_PARAM_STR(pattern) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + Z_PARAM_ZVAL_OR_NULL(paths) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &factory, &options_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); + zephir_fetch_params(1, 1, 1, &pattern_param, &paths); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + ZEPHIR_INIT_VAR(&pattern); } - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "prefix"); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "ph-mm-reds-"); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getarrval", NULL, 0, &options, &_1, &_2); - zephir_check_call_status(); - zephir_array_update_string(&options, SL("prefix"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "lifetime"); - ZVAL_LONG(&_4, 172800); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "getarrval", NULL, 0, &options, &_1, &_4); - zephir_check_call_status(); - zephir_array_update_string(&options, SL("lifetime"), &_3, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "redis"); - ZEPHIR_CALL_METHOD(&_5, factory, "newinstance", NULL, 0, &_1, &options); + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "TRACE"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("adapter"), &_5); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Redis, reset) +static PHP_METHOD(Phalcon_Mvc_Router_Group, beforeMatch) +{ + zval *beforeMatch, beforeMatch_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&beforeMatch_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(beforeMatch) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &beforeMatch); + zephir_update_property_zval(this_ptr, ZEND_STRL("beforeMatch"), beforeMatch); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Group, clear) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "clear", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_model_metadata_redis_ce, getThis(), "reset", NULL, 0); - zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("routes"), &_0); ZEPHIR_MM_RESTORE(); } +static PHP_METHOD(Phalcon_Mvc_Router_Group, getBeforeMatch) +{ + RETURN_MEMBER(getThis(), "beforeMatch"); +} +static PHP_METHOD(Phalcon_Mvc_Router_Group, getHostname) +{ -#ifdef HAVE_CONFIG_H -#endif + RETURN_MEMBER(getThis(), "hostname"); +} +static PHP_METHOD(Phalcon_Mvc_Router_Group, getPaths) +{ + RETURN_MEMBER(getThis(), "paths"); +} +static PHP_METHOD(Phalcon_Mvc_Router_Group, getPrefix) +{ + RETURN_MEMBER(getThis(), "prefix"); +} -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Stream) +static PHP_METHOD(Phalcon_Mvc_Router_Group, getRoutes) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Model\\MetaData, Stream, phalcon, mvc_model_metadata_stream, phalcon_mvc_model_metadata_ce, phalcon_mvc_model_metadata_stream_method_entry, 0); - zend_declare_property_string(phalcon_mvc_model_metadata_stream_ce, SL("metaDataDir"), "./", ZEND_ACC_PROTECTED); - return SUCCESS; + RETURN_MEMBER(getThis(), "routes"); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Stream, __construct) +static PHP_METHOD(Phalcon_Mvc_Router_Group, setHostname) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *options_param = NULL, metaDataDir; - zval options; + zval *hostname_param = NULL; + zval hostname; zval *this_ptr = getThis(); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&metaDataDir); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZVAL_UNDEF(&hostname); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(hostname) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &options_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - zephir_memory_observe(&metaDataDir); - if (zephir_array_isset_string_fetch(&metaDataDir, &options, SL("metaDataDir"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("metaDataDir"), &metaDataDir); - } - ZEPHIR_MM_RESTORE(); + zephir_fetch_params(1, 1, 0, &hostname_param); + zephir_get_strval(&hostname, hostname_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("hostname"), &hostname); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Stream, read) +static PHP_METHOD(Phalcon_Mvc_Router_Group, setPaths) +{ + zval *paths, paths_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&paths_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(paths) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &paths); + zephir_update_property_zval(this_ptr, ZEND_STRL("paths"), paths); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Group, setPrefix) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *key_param = NULL, path, _0, _1, _2, _3; - zval key; + zval *prefix_param = NULL; + zval prefix; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&path); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&prefix); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + Z_PARAM_STR(prefix) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("metaDataDir"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "_"); - zephir_prepare_virtual_path(&_1, &key, &_2); - ZEPHIR_INIT_VAR(&path); - ZEPHIR_CONCAT_VVS(&path, &_0, &_1, ".php"); - if (!((zephir_file_exists(&path) == SUCCESS))) { - RETURN_MM_NULL(); - } - ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(&_3); - if (zephir_require_zval_ret(&_3, &path) == FAILURE) { - RETURN_MM_NULL(); - } - RETURN_CCTOR(&_3); + zephir_fetch_params(1, 1, 0, &prefix_param); + zephir_get_strval(&prefix, prefix_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("prefix"), &prefix); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Stream, write) +static PHP_METHOD(Phalcon_Mvc_Router_Group, addRoute) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval data; - zval *key_param = NULL, *data_param = NULL, option, path, _6, _7, _0$$3, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3; - zval key; + zval *pattern_param = NULL, *paths = NULL, paths_sub, *httpMethods = NULL, httpMethods_sub, __$null, mergedPaths, route, defaultPaths, processedPaths, _0, _1; + zval pattern; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&option); - ZVAL_UNDEF(&path); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&data); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(key) - Z_PARAM_ARRAY(data) + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_UNDEF(&httpMethods_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&mergedPaths); + ZVAL_UNDEF(&route); + ZVAL_UNDEF(&defaultPaths); + ZVAL_UNDEF(&processedPaths); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(pattern) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_ZVAL_OR_NULL(httpMethods) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &key_param, &data_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &httpMethods); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - ZEPHIR_INIT_VAR(&key); + ZEPHIR_INIT_VAR(&pattern); } - zephir_get_arrval(&data, data_param); - /* try_start_1: */ - - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("metaDataDir"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1$$3); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "_"); - zephir_prepare_virtual_path(&_1$$3, &key, &_2$$3); - ZEPHIR_INIT_VAR(&path); - ZEPHIR_CONCAT_VVS(&path, &_0$$3, &_1$$3, ".php"); - ZEPHIR_INIT_VAR(&option); - ZVAL_BOOL(&option, ZEPHIR_GLOBAL(orm).exception_on_failed_metadata_save); - ZEPHIR_INIT_VAR(&_3$$3); - ZEPHIR_INIT_VAR(&_4$$3); - ZEPHIR_INIT_NVAR(&_4$$3); - zephir_var_export_ex(&_4$$3, &data); - ZEPHIR_INIT_VAR(&_5$$3); - ZEPHIR_CONCAT_SVS(&_5$$3, "create_object = zephir_init_properties_Phalcon_Mvc_Router_Route; + + zend_class_implements(phalcon_mvc_router_route_ce, 1, phalcon_mvc_router_routeinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Strategy_Annotations, getMetaData) +static PHP_METHOD(Phalcon_Mvc_Router_Route, __construct) { - zend_bool _71$$6, _135$$44; - zend_string *_8; - zend_ulong _7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, *container, container_sub, __$true, annotations, className, reflection, propertiesAnnotations, property, propAnnotations, columnAnnotation, columnName, feature, fieldTypes, fieldBindTypes, numericTyped, primaryKeys, nonPrimaryKeys, identityField, notNull, attributes, defaultValues, defaultValue, emptyStringValues, skipOnInsert, skipOnUpdate, _0, *_5, _6, _1$$4, _2$$4, _3$$5, _4$$5, _9$$6, _10$$6, _65$$6, _66$$6, _67$$6, _68$$6, _69$$6, _70$$6, _72$$6, _11$$9, _12$$9, _13$$10, _14$$10, _15$$11, _16$$11, _17$$12, _18$$12, _19$$13, _20$$13, _21$$14, _22$$14, _23$$15, _24$$15, _25$$16, _26$$16, _27$$17, _28$$17, _29$$18, _30$$18, _31$$19, _32$$19, _33$$20, _34$$20, _35$$21, _36$$21, _37$$22, _38$$22, _39$$23, _40$$23, _41$$24, _42$$24, _43$$25, _44$$25, _45$$26, _46$$26, _47$$27, _48$$27, _49$$28, _50$$28, _51$$29, _52$$29, _53$$30, _54$$30, _55$$31, _56$$31, _57$$32, _58$$32, _59$$33, _60$$33, _61$$34, _62$$34, _63$$35, _64$$35, _73$$44, _74$$44, _129$$44, _130$$44, _131$$44, _132$$44, _133$$44, _134$$44, _136$$44, _75$$47, _76$$47, _77$$48, _78$$48, _79$$49, _80$$49, _81$$50, _82$$50, _83$$51, _84$$51, _85$$52, _86$$52, _87$$53, _88$$53, _89$$54, _90$$54, _91$$55, _92$$55, _93$$56, _94$$56, _95$$57, _96$$57, _97$$58, _98$$58, _99$$59, _100$$59, _101$$60, _102$$60, _103$$61, _104$$61, _105$$62, _106$$62, _107$$63, _108$$63, _109$$64, _110$$64, _111$$65, _112$$65, _113$$66, _114$$66, _115$$67, _116$$67, _117$$68, _118$$68, _119$$69, _120$$69, _121$$70, _122$$70, _123$$71, _124$$71, _125$$72, _126$$72, _127$$73, _128$$73; + zval *pattern_param = NULL, *paths = NULL, paths_sub, *httpMethods = NULL, httpMethods_sub, __$null, routeId, uniqueId, _0; + zval pattern, _1; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&container_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&annotations); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&reflection); - ZVAL_UNDEF(&propertiesAnnotations); - ZVAL_UNDEF(&property); - ZVAL_UNDEF(&propAnnotations); - ZVAL_UNDEF(&columnAnnotation); - ZVAL_UNDEF(&columnName); - ZVAL_UNDEF(&feature); - ZVAL_UNDEF(&fieldTypes); - ZVAL_UNDEF(&fieldBindTypes); - ZVAL_UNDEF(&numericTyped); - ZVAL_UNDEF(&primaryKeys); - ZVAL_UNDEF(&nonPrimaryKeys); - ZVAL_UNDEF(&identityField); - ZVAL_UNDEF(¬Null); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&defaultValues); - ZVAL_UNDEF(&defaultValue); - ZVAL_UNDEF(&emptyStringValues); - ZVAL_UNDEF(&skipOnInsert); - ZVAL_UNDEF(&skipOnUpdate); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&paths_sub); + ZVAL_UNDEF(&httpMethods_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&routeId); + ZVAL_UNDEF(&uniqueId); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_6); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(pattern) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_ZVAL_OR_NULL(httpMethods) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &httpMethods); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); + } else { + ZEPHIR_INIT_VAR(&pattern); + } + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + if (!httpMethods) { + httpMethods = &httpMethods_sub; + httpMethods = &__$null; + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "reconfigure", NULL, 0, &pattern, paths); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "via", NULL, 0, httpMethods); + zephir_check_call_status(); + zephir_memory_observe(&_0); + zephir_read_static_property_ce(&_0, phalcon_mvc_router_route_ce, SL("uniqueId"), PH_NOISY_CC); + ZEPHIR_CPY_WRT(&uniqueId, &_0); + ZEPHIR_CPY_WRT(&routeId, &uniqueId); + zephir_cast_to_string(&_1, &routeId); + zephir_update_property_zval(this_ptr, ZEND_STRL("id"), &_1); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, (zephir_get_numberval(&uniqueId) + 1)); + zephir_update_static_property_ce(phalcon_mvc_router_route_ce, ZEND_STRL("uniqueId"), &_0); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Route, beforeMatch) +{ + zval *callback, callback_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&callback_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(callback) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &callback); + zephir_update_property_zval(this_ptr, ZEND_STRL("beforeMatch"), callback); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Route, compilePattern) +{ + zend_bool _14; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *pattern_param = NULL, _0$$4, _1$$4, _2$$5, _3$$5, _4$$6, _5$$6, _6$$7, _7$$7, _8$$8, _9$$8, _10$$8, _11$$9, _12$$9, _13$$9; + zval pattern, idPattern; + + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&idPattern); + ZVAL_UNDEF(&_0$$4); ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_2$$5); ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_9$$6); - ZVAL_UNDEF(&_10$$6); - ZVAL_UNDEF(&_65$$6); - ZVAL_UNDEF(&_66$$6); - ZVAL_UNDEF(&_67$$6); - ZVAL_UNDEF(&_68$$6); - ZVAL_UNDEF(&_69$$6); - ZVAL_UNDEF(&_70$$6); - ZVAL_UNDEF(&_72$$6); + ZVAL_UNDEF(&_4$$6); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_7$$7); + ZVAL_UNDEF(&_8$$8); + ZVAL_UNDEF(&_9$$8); + ZVAL_UNDEF(&_10$$8); ZVAL_UNDEF(&_11$$9); ZVAL_UNDEF(&_12$$9); - ZVAL_UNDEF(&_13$$10); - ZVAL_UNDEF(&_14$$10); - ZVAL_UNDEF(&_15$$11); - ZVAL_UNDEF(&_16$$11); - ZVAL_UNDEF(&_17$$12); - ZVAL_UNDEF(&_18$$12); - ZVAL_UNDEF(&_19$$13); - ZVAL_UNDEF(&_20$$13); - ZVAL_UNDEF(&_21$$14); - ZVAL_UNDEF(&_22$$14); - ZVAL_UNDEF(&_23$$15); - ZVAL_UNDEF(&_24$$15); - ZVAL_UNDEF(&_25$$16); - ZVAL_UNDEF(&_26$$16); - ZVAL_UNDEF(&_27$$17); - ZVAL_UNDEF(&_28$$17); - ZVAL_UNDEF(&_29$$18); - ZVAL_UNDEF(&_30$$18); - ZVAL_UNDEF(&_31$$19); - ZVAL_UNDEF(&_32$$19); - ZVAL_UNDEF(&_33$$20); - ZVAL_UNDEF(&_34$$20); - ZVAL_UNDEF(&_35$$21); - ZVAL_UNDEF(&_36$$21); - ZVAL_UNDEF(&_37$$22); - ZVAL_UNDEF(&_38$$22); - ZVAL_UNDEF(&_39$$23); - ZVAL_UNDEF(&_40$$23); - ZVAL_UNDEF(&_41$$24); - ZVAL_UNDEF(&_42$$24); - ZVAL_UNDEF(&_43$$25); - ZVAL_UNDEF(&_44$$25); - ZVAL_UNDEF(&_45$$26); - ZVAL_UNDEF(&_46$$26); - ZVAL_UNDEF(&_47$$27); - ZVAL_UNDEF(&_48$$27); - ZVAL_UNDEF(&_49$$28); - ZVAL_UNDEF(&_50$$28); - ZVAL_UNDEF(&_51$$29); - ZVAL_UNDEF(&_52$$29); - ZVAL_UNDEF(&_53$$30); - ZVAL_UNDEF(&_54$$30); - ZVAL_UNDEF(&_55$$31); - ZVAL_UNDEF(&_56$$31); - ZVAL_UNDEF(&_57$$32); - ZVAL_UNDEF(&_58$$32); - ZVAL_UNDEF(&_59$$33); - ZVAL_UNDEF(&_60$$33); - ZVAL_UNDEF(&_61$$34); - ZVAL_UNDEF(&_62$$34); - ZVAL_UNDEF(&_63$$35); - ZVAL_UNDEF(&_64$$35); - ZVAL_UNDEF(&_73$$44); - ZVAL_UNDEF(&_74$$44); - ZVAL_UNDEF(&_129$$44); - ZVAL_UNDEF(&_130$$44); - ZVAL_UNDEF(&_131$$44); - ZVAL_UNDEF(&_132$$44); - ZVAL_UNDEF(&_133$$44); - ZVAL_UNDEF(&_134$$44); - ZVAL_UNDEF(&_136$$44); - ZVAL_UNDEF(&_75$$47); - ZVAL_UNDEF(&_76$$47); - ZVAL_UNDEF(&_77$$48); - ZVAL_UNDEF(&_78$$48); - ZVAL_UNDEF(&_79$$49); - ZVAL_UNDEF(&_80$$49); - ZVAL_UNDEF(&_81$$50); - ZVAL_UNDEF(&_82$$50); - ZVAL_UNDEF(&_83$$51); - ZVAL_UNDEF(&_84$$51); - ZVAL_UNDEF(&_85$$52); - ZVAL_UNDEF(&_86$$52); - ZVAL_UNDEF(&_87$$53); - ZVAL_UNDEF(&_88$$53); - ZVAL_UNDEF(&_89$$54); - ZVAL_UNDEF(&_90$$54); - ZVAL_UNDEF(&_91$$55); - ZVAL_UNDEF(&_92$$55); - ZVAL_UNDEF(&_93$$56); - ZVAL_UNDEF(&_94$$56); - ZVAL_UNDEF(&_95$$57); - ZVAL_UNDEF(&_96$$57); - ZVAL_UNDEF(&_97$$58); - ZVAL_UNDEF(&_98$$58); - ZVAL_UNDEF(&_99$$59); - ZVAL_UNDEF(&_100$$59); - ZVAL_UNDEF(&_101$$60); - ZVAL_UNDEF(&_102$$60); - ZVAL_UNDEF(&_103$$61); - ZVAL_UNDEF(&_104$$61); - ZVAL_UNDEF(&_105$$62); - ZVAL_UNDEF(&_106$$62); - ZVAL_UNDEF(&_107$$63); - ZVAL_UNDEF(&_108$$63); - ZVAL_UNDEF(&_109$$64); - ZVAL_UNDEF(&_110$$64); - ZVAL_UNDEF(&_111$$65); - ZVAL_UNDEF(&_112$$65); - ZVAL_UNDEF(&_113$$66); - ZVAL_UNDEF(&_114$$66); - ZVAL_UNDEF(&_115$$67); - ZVAL_UNDEF(&_116$$67); - ZVAL_UNDEF(&_117$$68); - ZVAL_UNDEF(&_118$$68); - ZVAL_UNDEF(&_119$$69); - ZVAL_UNDEF(&_120$$69); - ZVAL_UNDEF(&_121$$70); - ZVAL_UNDEF(&_122$$70); - ZVAL_UNDEF(&_123$$71); - ZVAL_UNDEF(&_124$$71); - ZVAL_UNDEF(&_125$$72); - ZVAL_UNDEF(&_126$$72); - ZVAL_UNDEF(&_127$$73); - ZVAL_UNDEF(&_128$$73); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + ZVAL_UNDEF(&_13$$9); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(pattern) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &container); - if (UNEXPECTED(Z_TYPE_P(container) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "The dependency injector is invalid", "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 113); - return; + zephir_fetch_params(1, 1, 0, &pattern_param); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "annotations"); - ZEPHIR_CALL_METHOD(&annotations, container, "get", NULL, 0, &_0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&className); - zephir_get_class(&className, model, 0); - ZEPHIR_CALL_METHOD(&reflection, &annotations, "get", NULL, 0, &className); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&reflection) != IS_OBJECT)) { - ZEPHIR_INIT_VAR(&_1$$4); - object_init_ex(&_1$$4, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_2$$4); - ZEPHIR_CONCAT_SV(&_2$$4, "No annotations were found in class ", &className); - ZEPHIR_CALL_METHOD(NULL, &_1$$4, "__construct", NULL, 33, &_2$$4); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$4, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 124); - ZEPHIR_MM_RESTORE(); - return; + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); + } else { + ZEPHIR_INIT_VAR(&pattern); } - ZEPHIR_CALL_METHOD(&propertiesAnnotations, &reflection, "getpropertiesannotations", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(!(zephir_fast_count_int(&propertiesAnnotations)))) { - ZEPHIR_INIT_VAR(&_3$$5); - object_init_ex(&_3$$5, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_4$$5); - ZEPHIR_CONCAT_SV(&_4$$5, "No properties with annotations were found in class ", &className); - ZEPHIR_CALL_METHOD(NULL, &_3$$5, "__construct", NULL, 33, &_4$$5); - zephir_check_call_status(); - zephir_throw_exception_debug(&_3$$5, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 135); - ZEPHIR_MM_RESTORE(); - return; + if (zephir_memnstr_str(&pattern, SL(":"), "phalcon/Mvc/Router/Route.zep", 141)) { + ZEPHIR_INIT_VAR(&idPattern); + ZVAL_STRING(&idPattern, "/([\\w0-9\\_\\-]+)"); + if (zephir_memnstr_str(&pattern, SL("/:module"), "phalcon/Mvc/Router/Route.zep", 146)) { + ZEPHIR_INIT_VAR(&_0$$4); + ZEPHIR_INIT_VAR(&_1$$4); + ZVAL_STRING(&_1$$4, "/:module"); + zephir_fast_str_replace(&_0$$4, &_1$$4, &idPattern, &pattern); + zephir_get_strval(&pattern, &_0$$4); + } + if (zephir_memnstr_str(&pattern, SL("/:controller"), "phalcon/Mvc/Router/Route.zep", 151)) { + ZEPHIR_INIT_VAR(&_2$$5); + ZEPHIR_INIT_VAR(&_3$$5); + ZVAL_STRING(&_3$$5, "/:controller"); + zephir_fast_str_replace(&_2$$5, &_3$$5, &idPattern, &pattern); + zephir_get_strval(&pattern, &_2$$5); + } + if (zephir_memnstr_str(&pattern, SL("/:namespace"), "phalcon/Mvc/Router/Route.zep", 156)) { + ZEPHIR_INIT_VAR(&_4$$6); + ZEPHIR_INIT_VAR(&_5$$6); + ZVAL_STRING(&_5$$6, "/:namespace"); + zephir_fast_str_replace(&_4$$6, &_5$$6, &idPattern, &pattern); + zephir_get_strval(&pattern, &_4$$6); + } + if (zephir_memnstr_str(&pattern, SL("/:action"), "phalcon/Mvc/Router/Route.zep", 161)) { + ZEPHIR_INIT_VAR(&_6$$7); + ZEPHIR_INIT_VAR(&_7$$7); + ZVAL_STRING(&_7$$7, "/:action"); + zephir_fast_str_replace(&_6$$7, &_7$$7, &idPattern, &pattern); + zephir_get_strval(&pattern, &_6$$7); + } + if (zephir_memnstr_str(&pattern, SL("/:params"), "phalcon/Mvc/Router/Route.zep", 166)) { + ZEPHIR_INIT_VAR(&_8$$8); + ZEPHIR_INIT_VAR(&_9$$8); + ZVAL_STRING(&_9$$8, "/:params"); + ZEPHIR_INIT_VAR(&_10$$8); + ZVAL_STRING(&_10$$8, "(/.*)*"); + zephir_fast_str_replace(&_8$$8, &_9$$8, &_10$$8, &pattern); + zephir_get_strval(&pattern, &_8$$8); + } + if (zephir_memnstr_str(&pattern, SL("/:int"), "phalcon/Mvc/Router/Route.zep", 171)) { + ZEPHIR_INIT_VAR(&_11$$9); + ZEPHIR_INIT_VAR(&_12$$9); + ZVAL_STRING(&_12$$9, "/:int"); + ZEPHIR_INIT_VAR(&_13$$9); + ZVAL_STRING(&_13$$9, "/([0-9]+)"); + zephir_fast_str_replace(&_11$$9, &_12$$9, &_13$$9, &pattern); + zephir_get_strval(&pattern, &_11$$9); + } } - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - ZEPHIR_INIT_VAR(&primaryKeys); - array_init(&primaryKeys); - ZEPHIR_INIT_VAR(&nonPrimaryKeys); - array_init(&nonPrimaryKeys); - ZEPHIR_INIT_VAR(&numericTyped); - array_init(&numericTyped); - ZEPHIR_INIT_VAR(¬Null); - array_init(¬Null); - ZEPHIR_INIT_VAR(&fieldTypes); - array_init(&fieldTypes); - ZEPHIR_INIT_VAR(&fieldBindTypes); - array_init(&fieldBindTypes); - ZEPHIR_INIT_VAR(&identityField); - ZVAL_BOOL(&identityField, 0); - ZEPHIR_INIT_VAR(&skipOnInsert); - array_init(&skipOnInsert); - ZEPHIR_INIT_VAR(&skipOnUpdate); - array_init(&skipOnUpdate); - ZEPHIR_INIT_VAR(&defaultValues); - array_init(&defaultValues); - ZEPHIR_INIT_VAR(&emptyStringValues); - array_init(&emptyStringValues); - zephir_is_iterable(&propertiesAnnotations, 0, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 392); - if (Z_TYPE_P(&propertiesAnnotations) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&propertiesAnnotations), _7, _8, _5) - { - ZEPHIR_INIT_NVAR(&property); - if (_8 != NULL) { - ZVAL_STR_COPY(&property, _8); - } else { - ZVAL_LONG(&property, _7); - } - ZEPHIR_INIT_NVAR(&propAnnotations); - ZVAL_COPY(&propAnnotations, _5); - ZEPHIR_INIT_NVAR(&_10$$6); - ZVAL_STRING(&_10$$6, "Column"); - ZEPHIR_CALL_METHOD(&_9$$6, &propAnnotations, "has", NULL, 0, &_10$$6); - zephir_check_call_status(); - if (!(zephir_is_true(&_9$$6))) { - continue; - } - ZEPHIR_INIT_NVAR(&_10$$6); - ZVAL_STRING(&_10$$6, "Column"); - ZEPHIR_CALL_METHOD(&columnAnnotation, &propAnnotations, "get", NULL, 0, &_10$$6); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_10$$6); - ZVAL_STRING(&_10$$6, "column"); - ZEPHIR_CALL_METHOD(&columnName, &columnAnnotation, "getnamedparameter", NULL, 0, &_10$$6); - zephir_check_call_status(); - if (ZEPHIR_IS_EMPTY(&columnName)) { - ZEPHIR_CPY_WRT(&columnName, &property); - } - ZEPHIR_INIT_NVAR(&_10$$6); - ZVAL_STRING(&_10$$6, "type"); - ZEPHIR_CALL_METHOD(&feature, &columnAnnotation, "getnamedparameter", NULL, 0, &_10$$6); - zephir_check_call_status(); - do { - if (ZEPHIR_IS_STRING(&feature, "biginteger")) { - ZEPHIR_INIT_NVAR(&_11$$9); - ZVAL_LONG(&_11$$9, 14); - zephir_array_update_zval(&fieldTypes, &columnName, &_11$$9, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_12$$9); - ZVAL_LONG(&_12$$9, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_12$$9, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "bit")) { - ZEPHIR_INIT_NVAR(&_13$$10); - ZVAL_LONG(&_13$$10, 19); - zephir_array_update_zval(&fieldTypes, &columnName, &_13$$10, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_14$$10); - ZVAL_LONG(&_14$$10, 1); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_14$$10, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "blob")) { - ZEPHIR_INIT_NVAR(&_15$$11); - ZVAL_LONG(&_15$$11, 11); - zephir_array_update_zval(&fieldTypes, &columnName, &_15$$11, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_16$$11); - ZVAL_LONG(&_16$$11, 3); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_16$$11, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "boolean")) { - ZEPHIR_INIT_NVAR(&_17$$12); - ZVAL_LONG(&_17$$12, 8); - zephir_array_update_zval(&fieldTypes, &columnName, &_17$$12, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_18$$12); - ZVAL_LONG(&_18$$12, 5); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_18$$12, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "char")) { - ZEPHIR_INIT_NVAR(&_19$$13); - ZVAL_LONG(&_19$$13, 5); - zephir_array_update_zval(&fieldTypes, &columnName, &_19$$13, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_20$$13); - ZVAL_LONG(&_20$$13, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_20$$13, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "date")) { - ZEPHIR_INIT_NVAR(&_21$$14); - ZVAL_LONG(&_21$$14, 1); - zephir_array_update_zval(&fieldTypes, &columnName, &_21$$14, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_22$$14); - ZVAL_LONG(&_22$$14, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_22$$14, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "datetime")) { - ZEPHIR_INIT_NVAR(&_23$$15); - ZVAL_LONG(&_23$$15, 4); - zephir_array_update_zval(&fieldTypes, &columnName, &_23$$15, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_24$$15); - ZVAL_LONG(&_24$$15, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_24$$15, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "decimal")) { - ZEPHIR_INIT_NVAR(&_25$$16); - ZVAL_LONG(&_25$$16, 3); - zephir_array_update_zval(&fieldTypes, &columnName, &_25$$16, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_26$$16); - ZVAL_LONG(&_26$$16, 32); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_26$$16, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "double")) { - ZEPHIR_INIT_NVAR(&_27$$17); - ZVAL_LONG(&_27$$17, 9); - zephir_array_update_zval(&fieldTypes, &columnName, &_27$$17, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_28$$17); - ZVAL_LONG(&_28$$17, 32); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_28$$17, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "enum")) { - ZEPHIR_INIT_NVAR(&_29$$18); - ZVAL_LONG(&_29$$18, 18); - zephir_array_update_zval(&fieldTypes, &columnName, &_29$$18, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_30$$18); - ZVAL_LONG(&_30$$18, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_30$$18, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "float")) { - ZEPHIR_INIT_NVAR(&_31$$19); - ZVAL_LONG(&_31$$19, 7); - zephir_array_update_zval(&fieldTypes, &columnName, &_31$$19, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_32$$19); - ZVAL_LONG(&_32$$19, 32); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_32$$19, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "integer")) { - ZEPHIR_INIT_NVAR(&_33$$20); - ZVAL_LONG(&_33$$20, 0); - zephir_array_update_zval(&fieldTypes, &columnName, &_33$$20, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_34$$20); - ZVAL_LONG(&_34$$20, 1); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_34$$20, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "json")) { - ZEPHIR_INIT_NVAR(&_35$$21); - ZVAL_LONG(&_35$$21, 15); - zephir_array_update_zval(&fieldTypes, &columnName, &_35$$21, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_36$$21); - ZVAL_LONG(&_36$$21, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_36$$21, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "jsonb")) { - ZEPHIR_INIT_NVAR(&_37$$22); - ZVAL_LONG(&_37$$22, 16); - zephir_array_update_zval(&fieldTypes, &columnName, &_37$$22, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_38$$22); - ZVAL_LONG(&_38$$22, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_38$$22, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "longblob")) { - ZEPHIR_INIT_NVAR(&_39$$23); - ZVAL_LONG(&_39$$23, 13); - zephir_array_update_zval(&fieldTypes, &columnName, &_39$$23, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_40$$23); - ZVAL_LONG(&_40$$23, 3); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_40$$23, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "longtext")) { - ZEPHIR_INIT_NVAR(&_41$$24); - ZVAL_LONG(&_41$$24, 24); - zephir_array_update_zval(&fieldTypes, &columnName, &_41$$24, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_42$$24); - ZVAL_LONG(&_42$$24, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_42$$24, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "mediumblob")) { - ZEPHIR_INIT_NVAR(&_43$$25); - ZVAL_LONG(&_43$$25, 12); - zephir_array_update_zval(&fieldTypes, &columnName, &_43$$25, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_44$$25); - ZVAL_LONG(&_44$$25, 3); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_44$$25, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "mediumint")) { - ZEPHIR_INIT_NVAR(&_45$$26); - ZVAL_LONG(&_45$$26, 21); - zephir_array_update_zval(&fieldTypes, &columnName, &_45$$26, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_46$$26); - ZVAL_LONG(&_46$$26, 1); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_46$$26, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "mediumtext")) { - ZEPHIR_INIT_NVAR(&_47$$27); - ZVAL_LONG(&_47$$27, 23); - zephir_array_update_zval(&fieldTypes, &columnName, &_47$$27, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_48$$27); - ZVAL_LONG(&_48$$27, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_48$$27, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "smallint")) { - ZEPHIR_INIT_NVAR(&_49$$28); - ZVAL_LONG(&_49$$28, 22); - zephir_array_update_zval(&fieldTypes, &columnName, &_49$$28, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_50$$28); - ZVAL_LONG(&_50$$28, 1); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_50$$28, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "text")) { - ZEPHIR_INIT_NVAR(&_51$$29); - ZVAL_LONG(&_51$$29, 6); - zephir_array_update_zval(&fieldTypes, &columnName, &_51$$29, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_52$$29); - ZVAL_LONG(&_52$$29, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_52$$29, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "time")) { - ZEPHIR_INIT_NVAR(&_53$$30); - ZVAL_LONG(&_53$$30, 20); - zephir_array_update_zval(&fieldTypes, &columnName, &_53$$30, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_54$$30); - ZVAL_LONG(&_54$$30, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_54$$30, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "timestamp")) { - ZEPHIR_INIT_NVAR(&_55$$31); - ZVAL_LONG(&_55$$31, 17); - zephir_array_update_zval(&fieldTypes, &columnName, &_55$$31, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_56$$31); - ZVAL_LONG(&_56$$31, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_56$$31, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "tinyblob")) { - ZEPHIR_INIT_NVAR(&_57$$32); - ZVAL_LONG(&_57$$32, 10); - zephir_array_update_zval(&fieldTypes, &columnName, &_57$$32, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_58$$32); - ZVAL_LONG(&_58$$32, 3); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_58$$32, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "tinyint")) { - ZEPHIR_INIT_NVAR(&_59$$33); - ZVAL_LONG(&_59$$33, 26); - zephir_array_update_zval(&fieldTypes, &columnName, &_59$$33, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_60$$33); - ZVAL_LONG(&_60$$33, 1); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_60$$33, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "tinytext")) { - ZEPHIR_INIT_NVAR(&_61$$34); - ZVAL_LONG(&_61$$34, 25); - zephir_array_update_zval(&fieldTypes, &columnName, &_61$$34, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_62$$34); - ZVAL_LONG(&_62$$34, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_62$$34, PH_COPY | PH_SEPARATE); - break; - } - ZEPHIR_INIT_NVAR(&_63$$35); - ZVAL_LONG(&_63$$35, 2); - zephir_array_update_zval(&fieldTypes, &columnName, &_63$$35, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_64$$35); - ZVAL_LONG(&_64$$35, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_64$$35, PH_COPY | PH_SEPARATE); - } while(0); + _14 = zephir_memnstr_str(&pattern, SL("("), "phalcon/Mvc/Router/Route.zep", 182); + if (!(_14)) { + _14 = zephir_memnstr_str(&pattern, SL("["), "phalcon/Mvc/Router/Route.zep", 182); + } + if (_14) { + ZEPHIR_CONCAT_SVS(return_value, "#^", &pattern, "$#u"); + RETURN_MM(); + } + RETURN_CTOR(&pattern); +} - ZEPHIR_INIT_NVAR(&_10$$6); - ZVAL_STRING(&_10$$6, "Primary"); - ZEPHIR_CALL_METHOD(&_65$$6, &propAnnotations, "has", NULL, 0, &_10$$6); - zephir_check_call_status(); - if (zephir_is_true(&_65$$6)) { - zephir_array_append(&primaryKeys, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 336); - } else { - zephir_array_append(&nonPrimaryKeys, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 338); - } - ZEPHIR_INIT_NVAR(&_10$$6); - ZVAL_STRING(&_10$$6, "Identity"); - ZEPHIR_CALL_METHOD(&_66$$6, &propAnnotations, "has", NULL, 0, &_10$$6); - zephir_check_call_status(); - if (zephir_is_true(&_66$$6)) { - ZEPHIR_CPY_WRT(&identityField, &columnName); - } - ZEPHIR_INIT_NVAR(&_10$$6); - ZVAL_STRING(&_10$$6, "skip_on_insert"); - ZEPHIR_CALL_METHOD(&_67$$6, &columnAnnotation, "getnamedparameter", NULL, 0, &_10$$6); - zephir_check_call_status(); - if (zephir_is_true(&_67$$6)) { - zephir_array_append(&skipOnInsert, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 353); - } - ZEPHIR_INIT_NVAR(&_10$$6); - ZVAL_STRING(&_10$$6, "skip_on_update"); - ZEPHIR_CALL_METHOD(&_68$$6, &columnAnnotation, "getnamedparameter", NULL, 0, &_10$$6); - zephir_check_call_status(); - if (zephir_is_true(&_68$$6)) { - zephir_array_append(&skipOnUpdate, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 360); - } - ZEPHIR_INIT_NVAR(&_10$$6); - ZVAL_STRING(&_10$$6, "allow_empty_string"); - ZEPHIR_CALL_METHOD(&_69$$6, &columnAnnotation, "getnamedparameter", NULL, 0, &_10$$6); - zephir_check_call_status(); - if (zephir_is_true(&_69$$6)) { - zephir_array_update_zval(&emptyStringValues, &columnName, &columnName, PH_COPY | PH_SEPARATE); - } - ZEPHIR_INIT_NVAR(&_10$$6); - ZVAL_STRING(&_10$$6, "nullable"); - ZEPHIR_CALL_METHOD(&_70$$6, &columnAnnotation, "getnamedparameter", NULL, 0, &_10$$6); - zephir_check_call_status(); - if (!(zephir_is_true(&_70$$6))) { - zephir_array_append(¬Null, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 374); - } - ZEPHIR_INIT_NVAR(&_10$$6); - ZVAL_STRING(&_10$$6, "default"); - ZEPHIR_CALL_METHOD(&defaultValue, &columnAnnotation, "getnamedparameter", NULL, 0, &_10$$6); - zephir_check_call_status(); - _71$$6 = Z_TYPE_P(&defaultValue) != IS_NULL; - if (!(_71$$6)) { - ZEPHIR_INIT_NVAR(&_10$$6); - ZVAL_STRING(&_10$$6, "nullable"); - ZEPHIR_CALL_METHOD(&_72$$6, &columnAnnotation, "getnamedparameter", NULL, 0, &_10$$6); - zephir_check_call_status(); - _71$$6 = zephir_is_true(&_72$$6); - } - if (_71$$6) { - zephir_array_update_zval(&defaultValues, &columnName, &defaultValue, PH_COPY | PH_SEPARATE); - } - zephir_array_append(&attributes, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 386); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &propertiesAnnotations, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_6, &propertiesAnnotations, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_6)) { - break; - } - ZEPHIR_CALL_METHOD(&property, &propertiesAnnotations, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&propAnnotations, &propertiesAnnotations, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_74$$44); - ZVAL_STRING(&_74$$44, "Column"); - ZEPHIR_CALL_METHOD(&_73$$44, &propAnnotations, "has", NULL, 0, &_74$$44); - zephir_check_call_status(); - if (!(zephir_is_true(&_73$$44))) { - continue; - } - ZEPHIR_INIT_NVAR(&_74$$44); - ZVAL_STRING(&_74$$44, "Column"); - ZEPHIR_CALL_METHOD(&columnAnnotation, &propAnnotations, "get", NULL, 0, &_74$$44); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_74$$44); - ZVAL_STRING(&_74$$44, "column"); - ZEPHIR_CALL_METHOD(&columnName, &columnAnnotation, "getnamedparameter", NULL, 0, &_74$$44); - zephir_check_call_status(); - if (ZEPHIR_IS_EMPTY(&columnName)) { - ZEPHIR_CPY_WRT(&columnName, &property); - } - ZEPHIR_INIT_NVAR(&_74$$44); - ZVAL_STRING(&_74$$44, "type"); - ZEPHIR_CALL_METHOD(&feature, &columnAnnotation, "getnamedparameter", NULL, 0, &_74$$44); - zephir_check_call_status(); - do { - if (ZEPHIR_IS_STRING(&feature, "biginteger")) { - ZEPHIR_INIT_NVAR(&_75$$47); - ZVAL_LONG(&_75$$47, 14); - zephir_array_update_zval(&fieldTypes, &columnName, &_75$$47, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_76$$47); - ZVAL_LONG(&_76$$47, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_76$$47, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "bit")) { - ZEPHIR_INIT_NVAR(&_77$$48); - ZVAL_LONG(&_77$$48, 19); - zephir_array_update_zval(&fieldTypes, &columnName, &_77$$48, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_78$$48); - ZVAL_LONG(&_78$$48, 1); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_78$$48, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "blob")) { - ZEPHIR_INIT_NVAR(&_79$$49); - ZVAL_LONG(&_79$$49, 11); - zephir_array_update_zval(&fieldTypes, &columnName, &_79$$49, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_80$$49); - ZVAL_LONG(&_80$$49, 3); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_80$$49, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "boolean")) { - ZEPHIR_INIT_NVAR(&_81$$50); - ZVAL_LONG(&_81$$50, 8); - zephir_array_update_zval(&fieldTypes, &columnName, &_81$$50, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_82$$50); - ZVAL_LONG(&_82$$50, 5); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_82$$50, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "char")) { - ZEPHIR_INIT_NVAR(&_83$$51); - ZVAL_LONG(&_83$$51, 5); - zephir_array_update_zval(&fieldTypes, &columnName, &_83$$51, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_84$$51); - ZVAL_LONG(&_84$$51, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_84$$51, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "date")) { - ZEPHIR_INIT_NVAR(&_85$$52); - ZVAL_LONG(&_85$$52, 1); - zephir_array_update_zval(&fieldTypes, &columnName, &_85$$52, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_86$$52); - ZVAL_LONG(&_86$$52, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_86$$52, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "datetime")) { - ZEPHIR_INIT_NVAR(&_87$$53); - ZVAL_LONG(&_87$$53, 4); - zephir_array_update_zval(&fieldTypes, &columnName, &_87$$53, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_88$$53); - ZVAL_LONG(&_88$$53, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_88$$53, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "decimal")) { - ZEPHIR_INIT_NVAR(&_89$$54); - ZVAL_LONG(&_89$$54, 3); - zephir_array_update_zval(&fieldTypes, &columnName, &_89$$54, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_90$$54); - ZVAL_LONG(&_90$$54, 32); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_90$$54, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "double")) { - ZEPHIR_INIT_NVAR(&_91$$55); - ZVAL_LONG(&_91$$55, 9); - zephir_array_update_zval(&fieldTypes, &columnName, &_91$$55, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_92$$55); - ZVAL_LONG(&_92$$55, 32); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_92$$55, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "enum")) { - ZEPHIR_INIT_NVAR(&_93$$56); - ZVAL_LONG(&_93$$56, 18); - zephir_array_update_zval(&fieldTypes, &columnName, &_93$$56, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_94$$56); - ZVAL_LONG(&_94$$56, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_94$$56, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "float")) { - ZEPHIR_INIT_NVAR(&_95$$57); - ZVAL_LONG(&_95$$57, 7); - zephir_array_update_zval(&fieldTypes, &columnName, &_95$$57, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_96$$57); - ZVAL_LONG(&_96$$57, 32); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_96$$57, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "integer")) { - ZEPHIR_INIT_NVAR(&_97$$58); - ZVAL_LONG(&_97$$58, 0); - zephir_array_update_zval(&fieldTypes, &columnName, &_97$$58, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_98$$58); - ZVAL_LONG(&_98$$58, 1); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_98$$58, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "json")) { - ZEPHIR_INIT_NVAR(&_99$$59); - ZVAL_LONG(&_99$$59, 15); - zephir_array_update_zval(&fieldTypes, &columnName, &_99$$59, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_100$$59); - ZVAL_LONG(&_100$$59, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_100$$59, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "jsonb")) { - ZEPHIR_INIT_NVAR(&_101$$60); - ZVAL_LONG(&_101$$60, 16); - zephir_array_update_zval(&fieldTypes, &columnName, &_101$$60, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_102$$60); - ZVAL_LONG(&_102$$60, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_102$$60, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "longblob")) { - ZEPHIR_INIT_NVAR(&_103$$61); - ZVAL_LONG(&_103$$61, 13); - zephir_array_update_zval(&fieldTypes, &columnName, &_103$$61, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_104$$61); - ZVAL_LONG(&_104$$61, 3); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_104$$61, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "longtext")) { - ZEPHIR_INIT_NVAR(&_105$$62); - ZVAL_LONG(&_105$$62, 24); - zephir_array_update_zval(&fieldTypes, &columnName, &_105$$62, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_106$$62); - ZVAL_LONG(&_106$$62, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_106$$62, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "mediumblob")) { - ZEPHIR_INIT_NVAR(&_107$$63); - ZVAL_LONG(&_107$$63, 12); - zephir_array_update_zval(&fieldTypes, &columnName, &_107$$63, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_108$$63); - ZVAL_LONG(&_108$$63, 3); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_108$$63, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "mediumint")) { - ZEPHIR_INIT_NVAR(&_109$$64); - ZVAL_LONG(&_109$$64, 21); - zephir_array_update_zval(&fieldTypes, &columnName, &_109$$64, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_110$$64); - ZVAL_LONG(&_110$$64, 1); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_110$$64, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "mediumtext")) { - ZEPHIR_INIT_NVAR(&_111$$65); - ZVAL_LONG(&_111$$65, 23); - zephir_array_update_zval(&fieldTypes, &columnName, &_111$$65, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_112$$65); - ZVAL_LONG(&_112$$65, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_112$$65, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "smallint")) { - ZEPHIR_INIT_NVAR(&_113$$66); - ZVAL_LONG(&_113$$66, 22); - zephir_array_update_zval(&fieldTypes, &columnName, &_113$$66, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_114$$66); - ZVAL_LONG(&_114$$66, 1); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_114$$66, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "text")) { - ZEPHIR_INIT_NVAR(&_115$$67); - ZVAL_LONG(&_115$$67, 6); - zephir_array_update_zval(&fieldTypes, &columnName, &_115$$67, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_116$$67); - ZVAL_LONG(&_116$$67, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_116$$67, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "time")) { - ZEPHIR_INIT_NVAR(&_117$$68); - ZVAL_LONG(&_117$$68, 20); - zephir_array_update_zval(&fieldTypes, &columnName, &_117$$68, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_118$$68); - ZVAL_LONG(&_118$$68, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_118$$68, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "timestamp")) { - ZEPHIR_INIT_NVAR(&_119$$69); - ZVAL_LONG(&_119$$69, 17); - zephir_array_update_zval(&fieldTypes, &columnName, &_119$$69, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_120$$69); - ZVAL_LONG(&_120$$69, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_120$$69, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "tinyblob")) { - ZEPHIR_INIT_NVAR(&_121$$70); - ZVAL_LONG(&_121$$70, 10); - zephir_array_update_zval(&fieldTypes, &columnName, &_121$$70, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_122$$70); - ZVAL_LONG(&_122$$70, 3); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_122$$70, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "tinyint")) { - ZEPHIR_INIT_NVAR(&_123$$71); - ZVAL_LONG(&_123$$71, 26); - zephir_array_update_zval(&fieldTypes, &columnName, &_123$$71, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_124$$71); - ZVAL_LONG(&_124$$71, 1); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_124$$71, PH_COPY | PH_SEPARATE); - zephir_array_update_zval(&numericTyped, &columnName, &__$true, PH_COPY | PH_SEPARATE); - break; - } - if (ZEPHIR_IS_STRING(&feature, "tinytext")) { - ZEPHIR_INIT_NVAR(&_125$$72); - ZVAL_LONG(&_125$$72, 25); - zephir_array_update_zval(&fieldTypes, &columnName, &_125$$72, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_126$$72); - ZVAL_LONG(&_126$$72, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_126$$72, PH_COPY | PH_SEPARATE); - break; - } - ZEPHIR_INIT_NVAR(&_127$$73); - ZVAL_LONG(&_127$$73, 2); - zephir_array_update_zval(&fieldTypes, &columnName, &_127$$73, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_128$$73); - ZVAL_LONG(&_128$$73, 2); - zephir_array_update_zval(&fieldBindTypes, &columnName, &_128$$73, PH_COPY | PH_SEPARATE); - } while(0); +static PHP_METHOD(Phalcon_Mvc_Router_Route, convert) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *name_param = NULL, *converter, converter_sub; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&converter_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_ZVAL(converter) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &name_param, &converter); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_update_property_array(this_ptr, SL("converters"), &name, converter); + RETURN_THIS(); +} - ZEPHIR_INIT_NVAR(&_74$$44); - ZVAL_STRING(&_74$$44, "Primary"); - ZEPHIR_CALL_METHOD(&_129$$44, &propAnnotations, "has", NULL, 0, &_74$$44); - zephir_check_call_status(); - if (zephir_is_true(&_129$$44)) { - zephir_array_append(&primaryKeys, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 336); - } else { - zephir_array_append(&nonPrimaryKeys, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 338); - } - ZEPHIR_INIT_NVAR(&_74$$44); - ZVAL_STRING(&_74$$44, "Identity"); - ZEPHIR_CALL_METHOD(&_130$$44, &propAnnotations, "has", NULL, 0, &_74$$44); - zephir_check_call_status(); - if (zephir_is_true(&_130$$44)) { - ZEPHIR_CPY_WRT(&identityField, &columnName); +static PHP_METHOD(Phalcon_Mvc_Router_Route, extractNamedParams) +{ + long _0, _5$$10, _26$$18; + zend_long cursor = 0, cursorVar = 0, marker = 0, bracketCount, parenthesesCount, foundPattern, intermediate, numberMatches; + zend_bool notValid = 0, _6$$11, _7$$11, _8$$11, _9$$11, _10$$11, _11$$11, _12$$11, _13$$11, _14$$11, _15$$11, _16$$11, _17$$11, _25$$17, _29$$34, _30$$35, _31$$35, _32$$35; + char ch = 0, prevCh; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *pattern_param = NULL, tmp, matches, _1$$10, _2$$10, _3$$10, _18$$15, _19$$15, _20$$15, _22$$15, _23$$15; + zval pattern, route, item, variable, regexp, _4$$10, _21$$15, _24$$15, _27$$25, _28$$28; + + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&route); + ZVAL_UNDEF(&item); + ZVAL_UNDEF(&variable); + ZVAL_UNDEF(®exp); + ZVAL_UNDEF(&_4$$10); + ZVAL_UNDEF(&_21$$15); + ZVAL_UNDEF(&_24$$15); + ZVAL_UNDEF(&_27$$25); + ZVAL_UNDEF(&_28$$28); + ZVAL_UNDEF(&tmp); + ZVAL_UNDEF(&matches); + ZVAL_UNDEF(&_1$$10); + ZVAL_UNDEF(&_2$$10); + ZVAL_UNDEF(&_3$$10); + ZVAL_UNDEF(&_18$$15); + ZVAL_UNDEF(&_19$$15); + ZVAL_UNDEF(&_20$$15); + ZVAL_UNDEF(&_22$$15); + ZVAL_UNDEF(&_23$$15); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(pattern) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &pattern_param); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); + } else { + ZEPHIR_INIT_VAR(&pattern); + } + prevCh = '\0'; + bracketCount = 0; + parenthesesCount = 0; + foundPattern = 0; + intermediate = 0; + numberMatches = 0; + if (zephir_fast_strlen_ev(&pattern) == 0) { + RETURN_MM_BOOL(0); + } + ZEPHIR_INIT_VAR(&matches); + array_init(&matches); + ZEPHIR_INIT_VAR(&route); + for (_0 = 0; _0 < Z_STRLEN_P(&pattern); _0++) { + cursor = _0; + ch = ZEPHIR_STRING_OFFSET(&pattern, _0); + if (parenthesesCount == 0) { + if (ch == '{') { + if (bracketCount == 0) { + marker = (cursor + 1); + intermediate = 0; + notValid = 0; } - ZEPHIR_INIT_NVAR(&_74$$44); - ZVAL_STRING(&_74$$44, "skip_on_insert"); - ZEPHIR_CALL_METHOD(&_131$$44, &columnAnnotation, "getnamedparameter", NULL, 0, &_74$$44); - zephir_check_call_status(); - if (zephir_is_true(&_131$$44)) { - zephir_array_append(&skipOnInsert, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 353); + bracketCount++; + } else if (ch == '}') { + bracketCount--; + if (intermediate > 0) { + if (bracketCount == 0) { + numberMatches++; + ZEPHIR_INIT_NVAR(&variable); + ZEPHIR_INIT_NVAR(®exp); + ZVAL_LONG(&_1$$10, marker); + ZVAL_LONG(&_2$$10, (cursor - marker)); + ZEPHIR_INIT_NVAR(&_3$$10); + zephir_substr(&_3$$10, &pattern, zephir_get_intval(&_1$$10), zephir_get_intval(&_2$$10), 0); + zephir_cast_to_string(&_4$$10, &_3$$10); + ZEPHIR_CPY_WRT(&item, &_4$$10); + for (_5$$10 = 0; _5$$10 < Z_STRLEN_P(&item); _5$$10++) { + cursorVar = _5$$10; + ch = ZEPHIR_STRING_OFFSET(&item, _5$$10); + if (ch == '\0') { + break; + } + _6$$11 = cursorVar == 0; + if (_6$$11) { + _7$$11 = ch >= 'a'; + if (_7$$11) { + _7$$11 = ch <= 'z'; + } + _8$$11 = _7$$11; + if (!(_8$$11)) { + _9$$11 = ch >= 'A'; + if (_9$$11) { + _9$$11 = ch <= 'Z'; + } + _8$$11 = _9$$11; + } + _6$$11 = !(_8$$11); + } + if (_6$$11) { + notValid = 1; + break; + } + _10$$11 = ch >= 'a'; + if (_10$$11) { + _10$$11 = ch <= 'z'; + } + _11$$11 = _10$$11; + if (!(_11$$11)) { + _12$$11 = ch >= 'A'; + if (_12$$11) { + _12$$11 = ch <= 'Z'; + } + _11$$11 = _12$$11; + } + _13$$11 = _11$$11; + if (!(_13$$11)) { + _14$$11 = ch >= '0'; + if (_14$$11) { + _14$$11 = ch <= '9'; + } + _13$$11 = _14$$11; + } + _15$$11 = _13$$11; + if (!(_15$$11)) { + _15$$11 = ch == '-'; + } + _16$$11 = _15$$11; + if (!(_16$$11)) { + _16$$11 = ch == '_'; + } + _17$$11 = _16$$11; + if (!(_17$$11)) { + _17$$11 = ch == ':'; + } + if (_17$$11) { + if (ch == ':') { + ZVAL_LONG(&_18$$15, 0); + ZVAL_LONG(&_19$$15, cursorVar); + ZEPHIR_INIT_NVAR(&_20$$15); + zephir_substr(&_20$$15, &item, 0 , zephir_get_intval(&_19$$15), 0); + zephir_cast_to_string(&_21$$15, &_20$$15); + ZEPHIR_CPY_WRT(&variable, &_21$$15); + ZVAL_LONG(&_22$$15, (cursorVar + 1)); + ZEPHIR_INIT_NVAR(&_23$$15); + zephir_substr(&_23$$15, &item, zephir_get_intval(&_22$$15), 0, ZEPHIR_SUBSTR_NO_LENGTH); + zephir_cast_to_string(&_24$$15, &_23$$15); + ZEPHIR_CPY_WRT(®exp, &_24$$15); + break; + } + } else { + notValid = 1; + break; + } + } + if (!(notValid)) { + ZEPHIR_INIT_NVAR(&tmp); + ZVAL_LONG(&tmp, numberMatches); + _25$$17 = zephir_is_true(&variable); + if (_25$$17) { + _25$$17 = zephir_is_true(®exp); + } + if (_25$$17) { + foundPattern = 0; + for (_26$$18 = 0; _26$$18 < Z_STRLEN_P(®exp); _26$$18++) { + ch = ZEPHIR_STRING_OFFSET(®exp, _26$$18); + if (ch == '\0') { + break; + } + if (!(foundPattern)) { + if (ch == '(') { + foundPattern = 1; + } + } else { + if (ch == ')') { + foundPattern = 2; + break; + } + } + } + if (foundPattern != 2) { + ZEPHIR_INIT_NVAR(&_27$$25); + ZEPHIR_CONCAT_SVS(&_27$$25, "(", ®exp, ")"); + zephir_concat_self(&route, &_27$$25); + } else { + zephir_concat_self(&route, ®exp); + } + zephir_array_update_zval(&matches, &variable, &tmp, PH_COPY | PH_SEPARATE); + } else { + zephir_concat_self_str(&route, "([^/]*)", sizeof("([^/]*)") - 1); + zephir_array_update_zval(&matches, &item, &tmp, PH_COPY | PH_SEPARATE); + } + } else { + ZEPHIR_INIT_NVAR(&_28$$28); + ZEPHIR_CONCAT_SVS(&_28$$28, "{", &item, "}"); + zephir_concat_self(&route, &_28$$28); + } + continue; + } } - ZEPHIR_INIT_NVAR(&_74$$44); - ZVAL_STRING(&_74$$44, "skip_on_update"); - ZEPHIR_CALL_METHOD(&_132$$44, &columnAnnotation, "getnamedparameter", NULL, 0, &_74$$44); - zephir_check_call_status(); - if (zephir_is_true(&_132$$44)) { - zephir_array_append(&skipOnUpdate, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 360); + } + } + if (bracketCount == 0) { + if (ch == '(') { + parenthesesCount++; + } else if (ch == ')') { + parenthesesCount--; + if (parenthesesCount == 0) { + numberMatches++; } - ZEPHIR_INIT_NVAR(&_74$$44); - ZVAL_STRING(&_74$$44, "allow_empty_string"); - ZEPHIR_CALL_METHOD(&_133$$44, &columnAnnotation, "getnamedparameter", NULL, 0, &_74$$44); - zephir_check_call_status(); - if (zephir_is_true(&_133$$44)) { - zephir_array_update_zval(&emptyStringValues, &columnName, &columnName, PH_COPY | PH_SEPARATE); + } + } + if (bracketCount > 0) { + intermediate++; + } else { + _29$$34 = parenthesesCount == 0; + if (_29$$34) { + _29$$34 = prevCh != '\\'; + } + if (_29$$34) { + _30$$35 = ch == '.'; + if (!(_30$$35)) { + _30$$35 = ch == '+'; } - ZEPHIR_INIT_NVAR(&_74$$44); - ZVAL_STRING(&_74$$44, "nullable"); - ZEPHIR_CALL_METHOD(&_134$$44, &columnAnnotation, "getnamedparameter", NULL, 0, &_74$$44); - zephir_check_call_status(); - if (!(zephir_is_true(&_134$$44))) { - zephir_array_append(¬Null, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 374); + _31$$35 = _30$$35; + if (!(_31$$35)) { + _31$$35 = ch == '|'; } - ZEPHIR_INIT_NVAR(&_74$$44); - ZVAL_STRING(&_74$$44, "default"); - ZEPHIR_CALL_METHOD(&defaultValue, &columnAnnotation, "getnamedparameter", NULL, 0, &_74$$44); - zephir_check_call_status(); - _135$$44 = Z_TYPE_P(&defaultValue) != IS_NULL; - if (!(_135$$44)) { - ZEPHIR_INIT_NVAR(&_74$$44); - ZVAL_STRING(&_74$$44, "nullable"); - ZEPHIR_CALL_METHOD(&_136$$44, &columnAnnotation, "getnamedparameter", NULL, 0, &_74$$44); - zephir_check_call_status(); - _135$$44 = zephir_is_true(&_136$$44); + _32$$35 = _31$$35; + if (!(_32$$35)) { + _32$$35 = ch == '#'; } - if (_135$$44) { - zephir_array_update_zval(&defaultValues, &columnName, &defaultValue, PH_COPY | PH_SEPARATE); + if (_32$$35) { + zephir_concat_self_str(&route, "\\", sizeof("\\") - 1); } - zephir_array_append(&attributes, &columnName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Annotations.zep", 386); - ZEPHIR_CALL_METHOD(NULL, &propertiesAnnotations, "next", NULL, 0); - zephir_check_call_status(); + } + zephir_concat_self_char(&route, ch); + prevCh = ch; } } - ZEPHIR_INIT_NVAR(&propAnnotations); - ZEPHIR_INIT_NVAR(&property); - zephir_create_array(return_value, 12, 0); - zephir_array_update_long(return_value, 0, &attributes, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 1, &primaryKeys, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 2, &nonPrimaryKeys, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 3, ¬Null, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 4, &fieldTypes, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 5, &numericTyped, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 8, &identityField, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 9, &fieldBindTypes, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 10, &skipOnInsert, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 11, &skipOnUpdate, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 12, &defaultValues, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 13, &emptyStringValues, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); + zephir_create_array(return_value, 2, 0); + zephir_array_fast_append(return_value, &route); + zephir_array_fast_append(return_value, &matches); RETURN_MM(); } +static PHP_METHOD(Phalcon_Mvc_Router_Route, getBeforeMatch) +{ + RETURN_MEMBER(getThis(), "beforeMatch"); +} +static PHP_METHOD(Phalcon_Mvc_Router_Route, getCompiledPattern) +{ -#ifdef HAVE_CONFIG_H -#endif + RETURN_MEMBER(getThis(), "compiledPattern"); +} +static PHP_METHOD(Phalcon_Mvc_Router_Route, getConverters) +{ + RETURN_MEMBER(getThis(), "converters"); +} +static PHP_METHOD(Phalcon_Mvc_Router_Route, getGroup) +{ + RETURN_MEMBER(getThis(), "group"); +} -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Strategy_Introspection) +static PHP_METHOD(Phalcon_Mvc_Router_Route, getHttpMethods) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Model\\MetaData\\Strategy, Introspection, phalcon, mvc_model_metadata_strategy_introspection, phalcon_mvc_model_metadata_strategy_introspection_method_entry, 0); - zend_class_implements(phalcon_mvc_model_metadata_strategy_introspection_ce, 1, phalcon_mvc_model_metadata_strategy_strategyinterface_ce); - return SUCCESS; + RETURN_MEMBER(getThis(), "methods"); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Strategy_Introspection, getColumnMaps) +static PHP_METHOD(Phalcon_Mvc_Router_Route, getHostname) { - zend_string *_3$$3; - zend_ulong _2$$3; + + RETURN_MEMBER(getThis(), "hostname"); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Route, getId) +{ + + RETURN_MEMBER(getThis(), "id"); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Route, getMatch) +{ + + RETURN_MEMBER(getThis(), "match"); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Route, getName) +{ + + RETURN_MEMBER(getThis(), "name"); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Route, getPaths) +{ + + RETURN_MEMBER(getThis(), "paths"); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Route, getPattern) +{ + + RETURN_MEMBER(getThis(), "pattern"); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Route, getReversedPaths) +{ + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, *container, container_sub, orderedColumnMap, userColumnMap, reversedColumnMap, name, userName, *_0$$3, _1$$3; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&container_sub); - ZVAL_UNDEF(&orderedColumnMap); - ZVAL_UNDEF(&userColumnMap); - ZVAL_UNDEF(&reversedColumnMap); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&userName); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("paths"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_FUNCTION("array_flip", NULL, 100, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Route, getRouteId) +{ + + RETURN_MEMBER(getThis(), "id"); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Route, getRoutePaths) +{ + zend_long _0$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *paths = NULL, paths_sub, __$null, moduleName, controllerName, actionName, parts, routePaths, realClassName, namespaceName; + + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&moduleName); + ZVAL_UNDEF(&controllerName); + ZVAL_UNDEF(&actionName); + ZVAL_UNDEF(&parts); + ZVAL_UNDEF(&routePaths); + ZVAL_UNDEF(&realClassName); + ZVAL_UNDEF(&namespaceName); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(paths) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &container); - ZEPHIR_INIT_VAR(&orderedColumnMap); - ZVAL_NULL(&orderedColumnMap); - ZEPHIR_INIT_VAR(&reversedColumnMap); - ZVAL_NULL(&reversedColumnMap); - if ((zephir_method_exists_ex(model, ZEND_STRL("columnmap")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(&userColumnMap, model, "columnmap", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&userColumnMap) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_model_exception_ce, "columnMap() not returned an array", "phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep", 44); - return; + zephir_fetch_params(1, 0, 1, &paths); + if (!paths) { + paths = &paths_sub; + ZEPHIR_CPY_WRT(paths, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(paths); + } + if (Z_TYPE_P(paths) == IS_NULL) { + ZEPHIR_INIT_NVAR(paths); + array_init(paths); + } + if (Z_TYPE_P(paths) == IS_STRING) { + ZEPHIR_INIT_VAR(&moduleName); + ZVAL_NULL(&moduleName); + ZEPHIR_INIT_VAR(&controllerName); + ZVAL_NULL(&controllerName); + ZEPHIR_INIT_VAR(&actionName); + ZVAL_NULL(&actionName); + ZEPHIR_INIT_VAR(&parts); + zephir_fast_explode_str(&parts, SL("::"), paths, LONG_MAX); + do { + _0$$4 = zephir_fast_count_int(&parts); + if (_0$$4 == 3) { + ZEPHIR_OBS_NVAR(&moduleName); + zephir_array_fetch_long(&moduleName, &parts, 0, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 467); + ZEPHIR_OBS_NVAR(&controllerName); + zephir_array_fetch_long(&controllerName, &parts, 1, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 468); + ZEPHIR_OBS_NVAR(&actionName); + zephir_array_fetch_long(&actionName, &parts, 2, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 469); + break; + } + if (_0$$4 == 2) { + ZEPHIR_OBS_NVAR(&controllerName); + zephir_array_fetch_long(&controllerName, &parts, 0, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 473); + ZEPHIR_OBS_NVAR(&actionName); + zephir_array_fetch_long(&actionName, &parts, 1, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 474); + break; + } + if (_0$$4 == 1) { + ZEPHIR_OBS_NVAR(&controllerName); + zephir_array_fetch_long(&controllerName, &parts, 0, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 478); + break; + } + } while(0); + + ZEPHIR_INIT_VAR(&routePaths); + array_init(&routePaths); + if (Z_TYPE_P(&moduleName) != IS_NULL) { + zephir_array_update_string(&routePaths, SL("module"), &moduleName, PH_COPY | PH_SEPARATE); } - ZEPHIR_INIT_NVAR(&reversedColumnMap); - array_init(&reversedColumnMap); - ZEPHIR_CPY_WRT(&orderedColumnMap, &userColumnMap); - zephir_is_iterable(&userColumnMap, 0, "phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep", 53); - if (Z_TYPE_P(&userColumnMap) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&userColumnMap), _2$$3, _3$$3, _0$$3) - { - ZEPHIR_INIT_NVAR(&name); - if (_3$$3 != NULL) { - ZVAL_STR_COPY(&name, _3$$3); - } else { - ZVAL_LONG(&name, _2$$3); - } - ZEPHIR_INIT_NVAR(&userName); - ZVAL_COPY(&userName, _0$$3); - zephir_array_update_zval(&reversedColumnMap, &userName, &name, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &userColumnMap, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1$$3, &userColumnMap, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1$$3)) { - break; + if (Z_TYPE_P(&controllerName) != IS_NULL) { + if (zephir_memnstr_str(&controllerName, SL("\\"), "phalcon/Mvc/Router/Route.zep", 492)) { + ZEPHIR_INIT_VAR(&realClassName); + zephir_get_class_ns(&realClassName, &controllerName, 0); + ZEPHIR_INIT_VAR(&namespaceName); + zephir_get_ns_class(&namespaceName, &controllerName, 0); + if (zephir_is_true(&namespaceName)) { + zephir_array_update_string(&routePaths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE); } - ZEPHIR_CALL_METHOD(&name, &userColumnMap, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&userName, &userColumnMap, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&reversedColumnMap, &userName, &name, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &userColumnMap, "next", NULL, 0); - zephir_check_call_status(); + } else { + ZEPHIR_CPY_WRT(&realClassName, &controllerName); } + zephir_array_update_string(&routePaths, SL("controller"), &realClassName, PH_COPY | PH_SEPARATE); } - ZEPHIR_INIT_NVAR(&userName); - ZEPHIR_INIT_NVAR(&name); + if (Z_TYPE_P(&actionName) != IS_NULL) { + zephir_array_update_string(&routePaths, SL("action"), &actionName, PH_COPY | PH_SEPARATE); + } + } else { + ZEPHIR_CPY_WRT(&routePaths, paths); } - zephir_create_array(return_value, 2, 0); - zephir_array_fast_append(return_value, &orderedColumnMap); - zephir_array_fast_append(return_value, &reversedColumnMap); - RETURN_MM(); + if (UNEXPECTED(Z_TYPE_P(&routePaths) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "The route contains invalid paths", "phalcon/Mvc/Router/Route.zep", 519); + return; + } + RETURN_CCTOR(&routePaths); } -static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Strategy_Introspection, getMetaData) +static PHP_METHOD(Phalcon_Mvc_Router_Route, match) +{ + zval *callback, callback_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&callback_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(callback) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &callback); + zephir_update_property_zval(this_ptr, ZEND_STRL("match"), callback); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Route, reConfigure) { - zend_bool _17$$9, _26$$17; - zval completeTable; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *model, model_sub, *container, container_sub, __$true, schema, table, readConnection, columns, attributes, primaryKeys, nonPrimaryKeys, numericTyped, notNull, fieldTypes, automaticDefault, identityField, fieldBindTypes, defaultValues, column, fieldName, defaultValue, emptyStringValues, _0, *_9, _10, _1$$4, _2$$3, _3$$3, _4$$3, _5$$7, _6$$6, _7$$6, _8$$6, _11$$9, _12$$9, _13$$9, _14$$9, _15$$9, _16$$9, _18$$9, _19$$15, _20$$17, _21$$17, _22$$17, _23$$17, _24$$17, _25$$17, _27$$17, _28$$23; + zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, routePaths, pcrePattern, compiledPattern, extracted, _0$$4, _1$$4; + zval pattern; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&model_sub); - ZVAL_UNDEF(&container_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&table); - ZVAL_UNDEF(&readConnection); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&primaryKeys); - ZVAL_UNDEF(&nonPrimaryKeys); - ZVAL_UNDEF(&numericTyped); - ZVAL_UNDEF(¬Null); - ZVAL_UNDEF(&fieldTypes); - ZVAL_UNDEF(&automaticDefault); - ZVAL_UNDEF(&identityField); - ZVAL_UNDEF(&fieldBindTypes); - ZVAL_UNDEF(&defaultValues); - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&fieldName); - ZVAL_UNDEF(&defaultValue); - ZVAL_UNDEF(&emptyStringValues); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&routePaths); + ZVAL_UNDEF(&pcrePattern); + ZVAL_UNDEF(&compiledPattern); + ZVAL_UNDEF(&extracted); + ZVAL_UNDEF(&_0$$4); ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$7); - ZVAL_UNDEF(&_6$$6); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_8$$6); - ZVAL_UNDEF(&_11$$9); - ZVAL_UNDEF(&_12$$9); - ZVAL_UNDEF(&_13$$9); - ZVAL_UNDEF(&_14$$9); - ZVAL_UNDEF(&_15$$9); - ZVAL_UNDEF(&_16$$9); - ZVAL_UNDEF(&_18$$9); - ZVAL_UNDEF(&_19$$15); - ZVAL_UNDEF(&_20$$17); - ZVAL_UNDEF(&_21$$17); - ZVAL_UNDEF(&_22$$17); - ZVAL_UNDEF(&_23$$17); - ZVAL_UNDEF(&_24$$17); - ZVAL_UNDEF(&_25$$17); - ZVAL_UNDEF(&_27$$17); - ZVAL_UNDEF(&_28$$23); - ZVAL_UNDEF(&completeTable); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(model, phalcon_mvc_modelinterface_ce) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(pattern) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(paths) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &model, &container); - ZEPHIR_CALL_METHOD(&schema, model, "getschema", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&table, model, "getsource", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&readConnection, model, "getreadconnection", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, &readConnection, "tableexists", NULL, 0, &table, &schema); + zephir_fetch_params(1, 1, 1, &pattern_param, &paths); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); + } else { + ZEPHIR_INIT_VAR(&pattern); + } + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + ZEPHIR_CALL_SELF(&routePaths, "getroutepaths", NULL, 0, paths); zephir_check_call_status(); - if (UNEXPECTED(!zephir_is_true(&_0))) { - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_VAR(&_1$$4); - ZEPHIR_CONCAT_VSV(&_1$$4, &schema, "'.'", &table); - zephir_get_strval(&completeTable, &_1$$4); + if (!(zephir_start_with_str(&pattern, SL("#")))) { + if (zephir_memnstr_str(&pattern, SL("{"), "phalcon/Mvc/Router/Route.zep", 559)) { + ZEPHIR_CALL_METHOD(&extracted, this_ptr, "extractnamedparams", NULL, 0, &pattern); + zephir_check_call_status(); + zephir_memory_observe(&pcrePattern); + zephir_array_fetch_long(&pcrePattern, &extracted, 0, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 564); + ZEPHIR_INIT_VAR(&_0$$4); + zephir_array_fetch_long(&_1$$4, &extracted, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Router/Route.zep", 565); + zephir_fast_array_merge(&_0$$4, &routePaths, &_1$$4); + ZEPHIR_CPY_WRT(&routePaths, &_0$$4); } else { - zephir_get_strval(&completeTable, &table); + ZEPHIR_CPY_WRT(&pcrePattern, &pattern); } - ZEPHIR_INIT_VAR(&_2$$3); - object_init_ex(&_2$$3, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_3$$3); - zephir_get_class(&_3$$3, model, 0); - ZEPHIR_INIT_VAR(&_4$$3); - ZEPHIR_CONCAT_SVSV(&_4$$3, "Table '", &completeTable, "' doesn't exist in database when dumping meta-data for ", &_3$$3); - ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 33, &_4$$3); + ZEPHIR_CALL_METHOD(&compiledPattern, this_ptr, "compilepattern", NULL, 0, &pcrePattern); zephir_check_call_status(); - zephir_throw_exception_debug(&_2$$3, "phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep", 92); - ZEPHIR_MM_RESTORE(); - return; + } else { + ZEPHIR_CPY_WRT(&compiledPattern, &pattern); } - ZEPHIR_CALL_METHOD(&columns, &readConnection, "describecolumns", NULL, 0, &table, &schema); + zephir_update_property_zval(this_ptr, ZEND_STRL("pattern"), &pattern); + zephir_update_property_zval(this_ptr, ZEND_STRL("compiledPattern"), &compiledPattern); + zephir_update_property_zval(this_ptr, ZEND_STRL("paths"), &routePaths); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Route, reset) +{ + zval _0; + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, 0); + zephir_update_static_property_ce(phalcon_mvc_router_route_ce, ZEND_STRL("uniqueId"), &_0); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Route, setGroup) +{ + zval *group, group_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&group_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(group, phalcon_mvc_router_groupinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &group); + zephir_update_property_zval(this_ptr, ZEND_STRL("group"), group); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Route, setHttpMethods) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *httpMethods, httpMethods_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&httpMethods_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(httpMethods) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &httpMethods); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "via", NULL, 0, httpMethods); zephir_check_call_status(); - if (UNEXPECTED(!(zephir_fast_count_int(&columns)))) { - if (zephir_is_true(&schema)) { - ZEPHIR_INIT_VAR(&_5$$7); - ZEPHIR_CONCAT_VSV(&_5$$7, &schema, "'.'", &table); - zephir_get_strval(&completeTable, &_5$$7); - } else { - zephir_get_strval(&completeTable, &table); - } - ZEPHIR_INIT_VAR(&_6$$6); - object_init_ex(&_6$$6, phalcon_mvc_model_exception_ce); - ZEPHIR_INIT_VAR(&_7$$6); - zephir_get_class(&_7$$6, model, 0); - ZEPHIR_INIT_VAR(&_8$$6); - ZEPHIR_CONCAT_SVSV(&_8$$6, "Cannot obtain table columns for the mapped source '", &completeTable, "' used in model ", &_7$$6); - ZEPHIR_CALL_METHOD(NULL, &_6$$6, "__construct", NULL, 33, &_8$$6); - zephir_check_call_status(); - zephir_throw_exception_debug(&_6$$6, "phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep", 112); - ZEPHIR_MM_RESTORE(); - return; + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Route, setHostname) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *hostname_param = NULL; + zval hostname; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&hostname); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(hostname) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &hostname_param); + if (UNEXPECTED(Z_TYPE_P(hostname_param) != IS_STRING && Z_TYPE_P(hostname_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'hostname' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - ZEPHIR_INIT_VAR(&primaryKeys); - array_init(&primaryKeys); - ZEPHIR_INIT_VAR(&nonPrimaryKeys); - array_init(&nonPrimaryKeys); - ZEPHIR_INIT_VAR(&numericTyped); - array_init(&numericTyped); - ZEPHIR_INIT_VAR(¬Null); - array_init(¬Null); - ZEPHIR_INIT_VAR(&fieldTypes); - array_init(&fieldTypes); - ZEPHIR_INIT_VAR(&fieldBindTypes); - array_init(&fieldBindTypes); - ZEPHIR_INIT_VAR(&automaticDefault); - array_init(&automaticDefault); - ZEPHIR_INIT_VAR(&identityField); - ZVAL_BOOL(&identityField, 0); - ZEPHIR_INIT_VAR(&defaultValues); - array_init(&defaultValues); - ZEPHIR_INIT_VAR(&emptyStringValues); - array_init(&emptyStringValues); - zephir_is_iterable(&columns, 0, "phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep", 189); - if (Z_TYPE_P(&columns) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&columns), _9) - { - ZEPHIR_INIT_NVAR(&column); - ZVAL_COPY(&column, _9); - ZEPHIR_CALL_METHOD(&fieldName, &column, "getname", NULL, 0); - zephir_check_call_status(); - zephir_array_append(&attributes, &fieldName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep", 132); - ZEPHIR_CALL_METHOD(&_11$$9, &column, "isprimary", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&_11$$9)) { - zephir_array_append(&primaryKeys, &fieldName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep", 138); - } else { - zephir_array_append(&nonPrimaryKeys, &fieldName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep", 140); - } - ZEPHIR_CALL_METHOD(&_12$$9, &column, "isnumeric", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&_12$$9)) { - zephir_array_update_zval(&numericTyped, &fieldName, &__$true, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(&_13$$9, &column, "isnotnull", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&_13$$9)) { - zephir_array_append(¬Null, &fieldName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep", 154); - } - ZEPHIR_CALL_METHOD(&_14$$9, &column, "isautoincrement", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&_14$$9)) { - ZEPHIR_CPY_WRT(&identityField, &fieldName); - } - ZEPHIR_CALL_METHOD(&_15$$9, &column, "gettype", NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&fieldTypes, &fieldName, &_15$$9, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_16$$9, &column, "getbindtype", NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&fieldBindTypes, &fieldName, &_16$$9, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&defaultValue, &column, "getdefault", NULL, 0); - zephir_check_call_status(); - _17$$9 = Z_TYPE_P(&defaultValue) != IS_NULL; - if (!(_17$$9)) { - ZEPHIR_CALL_METHOD(&_18$$9, &column, "isnotnull", NULL, 0); - zephir_check_call_status(); - _17$$9 = !zephir_is_true(&_18$$9); - } - if (_17$$9) { - ZEPHIR_CALL_METHOD(&_19$$15, &column, "isautoincrement", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_19$$15))) { - zephir_array_update_zval(&defaultValues, &fieldName, &defaultValue, PH_COPY | PH_SEPARATE); - } - } - } ZEND_HASH_FOREACH_END(); + if (EXPECTED(Z_TYPE_P(hostname_param) == IS_STRING)) { + zephir_get_strval(&hostname, hostname_param); } else { - ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_10, &columns, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_10)) { - break; - } - ZEPHIR_CALL_METHOD(&column, &columns, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&fieldName, &column, "getname", NULL, 0); - zephir_check_call_status(); - zephir_array_append(&attributes, &fieldName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep", 132); - ZEPHIR_CALL_METHOD(&_20$$17, &column, "isprimary", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&_20$$17)) { - zephir_array_append(&primaryKeys, &fieldName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep", 138); - } else { - zephir_array_append(&nonPrimaryKeys, &fieldName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep", 140); - } - ZEPHIR_CALL_METHOD(&_21$$17, &column, "isnumeric", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&_21$$17)) { - zephir_array_update_zval(&numericTyped, &fieldName, &__$true, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(&_22$$17, &column, "isnotnull", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&_22$$17)) { - zephir_array_append(¬Null, &fieldName, PH_SEPARATE, "phalcon/Mvc/Model/MetaData/Strategy/Introspection.zep", 154); - } - ZEPHIR_CALL_METHOD(&_23$$17, &column, "isautoincrement", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&_23$$17)) { - ZEPHIR_CPY_WRT(&identityField, &fieldName); - } - ZEPHIR_CALL_METHOD(&_24$$17, &column, "gettype", NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&fieldTypes, &fieldName, &_24$$17, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_25$$17, &column, "getbindtype", NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&fieldBindTypes, &fieldName, &_25$$17, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&defaultValue, &column, "getdefault", NULL, 0); - zephir_check_call_status(); - _26$$17 = Z_TYPE_P(&defaultValue) != IS_NULL; - if (!(_26$$17)) { - ZEPHIR_CALL_METHOD(&_27$$17, &column, "isnotnull", NULL, 0); - zephir_check_call_status(); - _26$$17 = !zephir_is_true(&_27$$17); - } - if (_26$$17) { - ZEPHIR_CALL_METHOD(&_28$$23, &column, "isautoincrement", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&_28$$23))) { - zephir_array_update_zval(&defaultValues, &fieldName, &defaultValue, PH_COPY | PH_SEPARATE); - } - } - ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); - zephir_check_call_status(); + ZEPHIR_INIT_VAR(&hostname); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("hostname"), &hostname); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Route, setName) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *name_param = NULL; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Mvc_Router_Route, via) +{ + zval *httpMethods, httpMethods_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&httpMethods_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(httpMethods) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &httpMethods); + zephir_update_property_zval(this_ptr, ZEND_STRL("methods"), httpMethods); + RETURN_THISW(); +} + +zend_object *zephir_init_properties_Phalcon_Mvc_Router_Route(zend_class_entry *class_type) +{ + zval _0, _2, _4, _1$$3, _3$$4, _5$$5; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("paths"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("paths"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("methods"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("methods"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("converters"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("converters"), &_5$$5); } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } - ZEPHIR_INIT_NVAR(&column); - zephir_create_array(return_value, 12, 0); - zephir_array_update_long(return_value, 0, &attributes, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 1, &primaryKeys, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 2, &nonPrimaryKeys, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 3, ¬Null, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 4, &fieldTypes, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 5, &numericTyped, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 8, &identityField, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 9, &fieldBindTypes, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 10, &automaticDefault, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 11, &automaticDefault, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 12, &defaultValues, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_long(return_value, 13, &emptyStringValues, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - RETURN_MM(); } @@ -86482,15 +77080,29 @@ static PHP_METHOD(Phalcon_Mvc_Model_MetaData_Strategy_Introspection, getMetaData -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Model_MetaData_Strategy_StrategyInterface) +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_RouteInterface) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Model\\MetaData\\Strategy, StrategyInterface, phalcon, mvc_model_metadata_strategy_strategyinterface, phalcon_mvc_model_metadata_strategy_strategyinterface_method_entry); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Router, RouteInterface, phalcon, mvc_router_routeinterface, phalcon_mvc_router_routeinterface_method_entry); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaData_Strategy_StrategyInterface, getColumnMaps); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Model_MetaData_Strategy_StrategyInterface, getMetaData); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, compilePattern); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, convert); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getCompiledPattern); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getHostname); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getHttpMethods); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getName); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getPaths); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getPattern); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getReversedPaths); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getRouteId); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, setHostname); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, setHttpMethods); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, setName); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, reConfigure); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, reset); +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, via); @@ -95687,6723 +86299,14036 @@ static void vv_reduce( vv_destructor(29,&vvmsp[-2].minor); vv_destructor(52,&vvmsp[0].minor); } -// 2779 "parser.php.c" - break; - case 146: -// 766 "parser.php.lemon" +// 2779 "parser.php.c" + break; + case 146: +// 766 "parser.php.lemon" +{ + phvolt_ret_func_call(&vvgotominor.vv186, &vvmsp[-2].minor.vv186, NULL, status->scanner_state); + vv_destructor(29,&vvmsp[-1].minor); + vv_destructor(52,&vvmsp[0].minor); +} +// 2788 "parser.php.c" + break; + }; + vvgoto = vvRuleInfo[vvruleno].lhs; + vvsize = vvRuleInfo[vvruleno].nrhs; + vvpParser->vvidx -= vvsize; + vvact = vv_find_reduce_action(vvpParser,vvgoto); + if( vvact < VVNSTATE ){ + vv_shift(vvpParser,vvact,vvgoto,&vvgotominor); + }else if( vvact == VVNSTATE + VVNRULE + 1 ){ + vv_accept(vvpParser); + } +} + +static void vv_parse_failed( + vvParser *vvpParser /* The parser */ +){ + phvolt_ARG_FETCH; +#ifndef NDEBUG + if( vvTraceFILE ){ + fprintf(vvTraceFILE,"%sFail!\n",vvTracePrompt); + } +#endif + while( vvpParser->vvidx>=0 ) vv_pop_parser_stack(vvpParser); + /* Here code is inserted which will be executed whenever the + ** parser fails */ + phvolt_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ +} + +static void vv_syntax_error( + vvParser *vvpParser, /* The parser */ + int vvmajor, /* The major type of the error token */ + VVMINORTYPE vvminor /* The minor type of the error token */ +){ + phvolt_ARG_FETCH; +#define VTOKEN (vvminor.vv0) +// 54 "parser.php.lemon" + + { + smart_str error_str = {0}; + + char *token_name = NULL; + const phvolt_token_names *tokens = phvolt_tokens; + int token_len = 0; + int active_token = status->scanner_state->active_token; + + if (status->scanner_state->start_length) { + + if (active_token) { + + do { + if (tokens->code == active_token) { + token_name = tokens->name; + token_len = tokens->len; + break; + } + ++tokens; + } while (tokens[0].code != 0); + + } + + smart_str_appendl(&error_str, "Syntax error, unexpected token ", sizeof("Syntax error, unexpected token ") - 1); + if (!token_name) { + smart_str_appendl(&error_str, "UNKNOWN", sizeof("UNKNOWN") - 1); + } else { + smart_str_appendl(&error_str, token_name, token_len); + } + + if (status->token->value) { + smart_str_appendc(&error_str, '('); + smart_str_appendl(&error_str, status->token->value, status->token->len); + smart_str_appendc(&error_str, ')'); + } + + smart_str_appendl(&error_str, " in ", sizeof(" in ") - 1); + smart_str_appendl(&error_str, Z_STRVAL_P(status->scanner_state->active_file), Z_STRLEN_P(status->scanner_state->active_file)); + smart_str_appendl(&error_str, " on line ", sizeof(" on line ") - 1); + + { + char stmp[MAX_LENGTH_OF_LONG + 1]; + int str_len; + str_len = slprintf(stmp, sizeof(stmp), "%u", status->scanner_state->active_line); + smart_str_appendl(&error_str, stmp, str_len); + } + + } else { + + smart_str_appendl(&error_str, "Syntax error, unexpected EOF in ", sizeof("Syntax error, unexpected EOF in ") - 1); + smart_str_appendl(&error_str, Z_STRVAL_P(status->scanner_state->active_file), Z_STRLEN_P(status->scanner_state->active_file)); + + /* Report unclosed 'if' blocks */ + if ((status->scanner_state->if_level + status->scanner_state->old_if_level) > 0) { + if ((status->scanner_state->if_level + status->scanner_state->old_if_level) == 1) { + smart_str_appendl(&error_str, ", there is one 'if' block without close", sizeof(", there is one 'if' block without close") - 1); + } else { + smart_str_appendl(&error_str, ", there are ", sizeof(", there are ") - 1); + { + char stmp[MAX_LENGTH_OF_LONG + 1]; + int str_len; + str_len = slprintf(stmp, sizeof(stmp), "%u", status->scanner_state->if_level + status->scanner_state->old_if_level); + smart_str_appendl(&error_str, stmp, str_len); + } + smart_str_appendl(&error_str, " 'if' blocks without close", sizeof(" 'if' blocks without close") - 1); + } + } + + /* Report unclosed 'for' blocks */ + if (status->scanner_state->for_level > 0) { + if (status->scanner_state->for_level == 1) { + smart_str_appendl(&error_str, ", there is one 'for' block without close", sizeof(", there is one 'for' block without close") - 1); + } else { + smart_str_appendl(&error_str, ", there are ", sizeof(", there are ") - 1); + { + char stmp[MAX_LENGTH_OF_LONG + 1]; + int str_len; + str_len = slprintf(stmp, sizeof(stmp), "%u", status->scanner_state->if_level); + smart_str_appendl(&error_str, stmp, str_len); + } + smart_str_appendl(&error_str, " 'for' blocks without close", sizeof(" 'for' blocks without close") - 1); + } + } + + /* Report unclosed 'switch' blocks */ + if (status->scanner_state->switch_level > 0) { + smart_str_appendl(&error_str, ", there is a 'switch' block without 'endswitch'", sizeof(", there is a 'switch' block without 'endswitch'") - 1); + } + } + + smart_str_0(&error_str); + + if (error_str.s) { + status->syntax_error = estrndup(ZSTR_VAL(error_str.s), ZSTR_LEN(error_str.s)); + status->syntax_error_len = ZSTR_LEN(error_str.s); + } else { + status->syntax_error = NULL; + } + } + + status->status = PHVOLT_PARSING_FAILED; + +// 2934 "parser.php.c" + phvolt_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ +} + +static void vv_accept( + vvParser *vvpParser /* The parser */ +){ + phvolt_ARG_FETCH; +#ifndef NDEBUG + if( vvTraceFILE ){ + fprintf(vvTraceFILE,"%sAccept!\n",vvTracePrompt); + } +#endif + while( vvpParser->vvidx>=0 ) vv_pop_parser_stack(vvpParser); + /* Here code is inserted which will be executed whenever the + ** parser accepts */ + phvolt_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ +} + +/* The main parser program. +** The first argument is a pointer to a structure obtained from +** "phvolt_Alloc" which describes the current state of the parser. +** The second argument is the major token number. The third is +** the minor token. The fourth optional argument is whatever the +** user wants (and specified in the grammar) and is available for +** use by the action routines. +** +** Inputs: +**
    +**
  • A pointer to the parser (an opaque structure.) +**
  • The major token number. +**
  • The minor token number. +**
  • An option argument of a grammar-specified type. +**
+** +** Outputs: +** None. +*/ +static void phvolt_( + void *vvp, /* The parser */ + int vvmajor, /* The major token code number */ + phvolt_TOKENTYPE vvminor /* The value for the token */ + phvolt_ARG_PDECL /* Optional %extra_argument parameter */ +){ + VVMINORTYPE vvminorunion; + int vvact; /* The parser action. */ + int vvendofinput; /* True if we are at the end of input */ + int vverrorhit = 0; /* True if vvmajor has invoked an error */ + vvParser *vvpParser; /* The parser */ + + /* (re)initialize the parser, if necessary */ + vvpParser = (vvParser*)vvp; + if( vvpParser->vvidx<0 ){ + if( vvmajor==0 ) return; + vvpParser->vvidx = 0; + vvpParser->vverrcnt = -1; + vvpParser->vvstack[0].stateno = 0; + vvpParser->vvstack[0].major = 0; + } + vvminorunion.vv0 = vvminor; + vvendofinput = (vvmajor==0); + phvolt_ARG_STORE; + +#ifndef NDEBUG + if( vvTraceFILE ){ + fprintf(vvTraceFILE,"%sInput %s\n",vvTracePrompt,vvTokenName[vvmajor]); + } +#endif + + do{ + vvact = vv_find_shift_action(vvpParser,vvmajor); + if( vvactvverrcnt--; + if( vvendofinput && vvpParser->vvidx>=0 ){ + vvmajor = 0; + }else{ + vvmajor = VVNOCODE; + } + }else if( vvact < VVNSTATE + VVNRULE ){ + vv_reduce(vvpParser,vvact-VVNSTATE); + }else if( vvact == VV_ERROR_ACTION ){ + int vvmx; +#ifndef NDEBUG + if( vvTraceFILE ){ + fprintf(vvTraceFILE,"%sSyntax Error!\n",vvTracePrompt); + } +#endif +#ifdef VVERRORSYMBOL + /* A syntax error has occurred. + ** The response to an error depends upon whether or not the + ** grammar defines an error token "ERROR". + ** + ** This is what we do if the grammar does define ERROR: + ** + ** * Call the %syntax_error function. + ** + ** * Begin popping the stack until we enter a state where + ** it is legal to shift the error symbol, then shift + ** the error symbol. + ** + ** * Set the error count to three. + ** + ** * Begin accepting and shifting new tokens. No new error + ** processing will occur until three tokens have been + ** shifted successfully. + ** + */ + if( vvpParser->vverrcnt<0 ){ + vv_syntax_error(vvpParser,vvmajor,vvminorunion); + } + vvmx = vvpParser->vvstack[vvpParser->vvidx].major; + if( vvmx==VVERRORSYMBOL || vverrorhit ){ +#ifndef NDEBUG + if( vvTraceFILE ){ + fprintf(vvTraceFILE,"%sDiscard input token %s\n", + vvTracePrompt,vvTokenName[vvmajor]); + } +#endif + vv_destructor(vvmajor,&vvminorunion); + vvmajor = VVNOCODE; + }else{ + while( + vvpParser->vvidx >= 0 && + vvmx != VVERRORSYMBOL && + (vvact = vv_find_shift_action(vvpParser,VVERRORSYMBOL)) >= VVNSTATE + ){ + vv_pop_parser_stack(vvpParser); + } + if( vvpParser->vvidx < 0 || vvmajor==0 ){ + vv_destructor(vvmajor,&vvminorunion); + vv_parse_failed(vvpParser); + vvmajor = VVNOCODE; + }else if( vvmx!=VVERRORSYMBOL ){ + VVMINORTYPE u2; + u2.VVERRSYMDT = 0; + vv_shift(vvpParser,vvact,VVERRORSYMBOL,&u2); + } + } + vvpParser->vverrcnt = 3; + vverrorhit = 1; +#else /* VVERRORSYMBOL is not defined */ + /* This is what we do if the grammar does not define ERROR: + ** + ** * Report an error message, and throw away the input token. + ** + ** * If the input token is $, then fail the parse. + ** + ** As before, subsequent error messages are suppressed until + ** three input tokens have been successfully shifted. + */ + if( vvpParser->vverrcnt<=0 ){ + vv_syntax_error(vvpParser,vvmajor,vvminorunion); + } + vvpParser->vverrcnt = 3; + vv_destructor(vvmajor,&vvminorunion); + if( vvendofinput ){ + vv_parse_failed(vvpParser); + } + vvmajor = VVNOCODE; +#endif + }else{ + vv_accept(vvpParser); + vvmajor = VVNOCODE; + } + }while( vvmajor!=VVNOCODE && vvpParser->vvidx>=0 ); + return; +} +/* base.c + * + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the + * LICENSE.txt file that was distributed with this source code. + */ + +const phvolt_token_names phvolt_tokens[] = +{ + { SL("INTEGER"), PHVOLT_T_INTEGER }, + { SL("DOUBLE"), PHVOLT_T_DOUBLE }, + { SL("STRING"), PHVOLT_T_STRING }, + { SL("IDENTIFIER"), PHVOLT_T_IDENTIFIER }, + { SL("MINUS"), PHVOLT_T_MINUS }, + { SL("+"), PHVOLT_T_ADD }, + { SL("-"), PHVOLT_T_SUB }, + { SL("*"), PHVOLT_T_MUL }, + { SL("/"), PHVOLT_T_DIV }, + { SL("%%"), PHVOLT_T_MOD }, + { SL("!"), PHVOLT_T_NOT }, + { SL("~"), PHVOLT_T_CONCAT }, + { SL("AND"), PHVOLT_T_AND }, + { SL("OR"), PHVOLT_T_OR }, + { SL("DOT"), PHVOLT_T_DOT }, + { SL("COMMA"), PHVOLT_T_COMMA }, + { SL("EQUALS"), PHVOLT_T_EQUALS }, + { SL("NOT EQUALS"), PHVOLT_T_NOTEQUALS }, + { SL("IDENTICAL"), PHVOLT_T_IDENTICAL }, + { SL("NOT IDENTICAL"), PHVOLT_T_NOTIDENTICAL }, + { SL("NOT"), PHVOLT_T_NOT }, + { SL("RANGE"), PHVOLT_T_RANGE }, + { SL("COLON"), PHVOLT_T_COLON }, + { SL("QUESTION MARK"), PHVOLT_T_QUESTION }, + { SL("<"), PHVOLT_T_LESS }, + { SL("<="), PHVOLT_T_LESSEQUAL }, + { SL(">"), PHVOLT_T_GREATER }, + { SL(">="), PHVOLT_T_GREATEREQUAL }, + { SL("("), PHVOLT_T_PARENTHESES_OPEN }, + { SL(")"), PHVOLT_T_PARENTHESES_CLOSE }, + { SL("["), PHVOLT_T_SBRACKET_OPEN }, + { SL("]"), PHVOLT_T_SBRACKET_CLOSE }, + { SL("{"), PHVOLT_T_CBRACKET_OPEN }, + { SL("}"), PHVOLT_T_CBRACKET_CLOSE }, + { SL("{%"), PHVOLT_T_OPEN_DELIMITER }, + { SL("%}"), PHVOLT_T_CLOSE_DELIMITER }, + { SL("{{"), PHVOLT_T_OPEN_EDELIMITER }, + { SL("}}"), PHVOLT_T_CLOSE_EDELIMITER }, + { SL("IF"), PHVOLT_T_IF }, + { SL("ELSE"), PHVOLT_T_ELSE }, + { SL("ELSEIF"), PHVOLT_T_ELSEIF }, + { SL("ELSEFOR"), PHVOLT_T_ELSEFOR }, + { SL("ENDIF"), PHVOLT_T_ENDIF }, + { SL("FOR"), PHVOLT_T_FOR }, + { SL("SWITCH"), PHVOLT_T_SWITCH }, + { SL("CASE"), PHVOLT_T_CASE }, + { SL("DEFAULT"), PHVOLT_T_DEFAULT }, + { SL("ENDSWITCH"), PHVOLT_T_ENDSWITCH }, + { SL("IN"), PHVOLT_T_IN }, + { SL("ENDFOR"), PHVOLT_T_ENDFOR }, + { SL("SET"), PHVOLT_T_SET }, + { SL("ASSIGN"), PHVOLT_T_ASSIGN }, + { SL("+="), PHVOLT_T_ADD_ASSIGN }, + { SL("-="), PHVOLT_T_SUB_ASSIGN }, + { SL("*="), PHVOLT_T_MUL_ASSIGN }, + { SL("/="), PHVOLT_T_DIV_ASSIGN }, + { SL("++"), PHVOLT_T_INCR }, + { SL("--"), PHVOLT_T_DECR }, + { SL("BLOCK"), PHVOLT_T_BLOCK }, + { SL("ENDBLOCK"), PHVOLT_T_ENDBLOCK }, + { SL("CACHE"), PHVOLT_T_CACHE }, + { SL("ENDCACHE"), PHVOLT_T_ENDCACHE }, + { SL("EXTENDS"), PHVOLT_T_EXTENDS }, + { SL("IS"), PHVOLT_T_IS }, + { SL("DEFINED"), PHVOLT_T_DEFINED }, + { SL("EMPTY"), PHVOLT_T_EMPTY }, + { SL("EVEN"), PHVOLT_T_EVEN }, + { SL("ODD"), PHVOLT_T_ODD }, + { SL("NUMERIC"), PHVOLT_T_NUMERIC }, + { SL("SCALAR"), PHVOLT_T_SCALAR }, + { SL("ITERABLE"), PHVOLT_T_ITERABLE }, + { SL("INCLUDE"), PHVOLT_T_INCLUDE }, + { SL("DO"), PHVOLT_T_DO }, + { SL("WHITESPACE"), PHVOLT_T_IGNORE }, + { SL("AUTOESCAPE"), PHVOLT_T_AUTOESCAPE }, + { SL("ENDAUTOESCAPE"), PHVOLT_T_ENDAUTOESCAPE }, + { SL("CONTINUE"), PHVOLT_T_CONTINUE }, + { SL("BREAK"), PHVOLT_T_BREAK }, + { SL("WITH"), PHVOLT_T_WITH }, + { SL("RETURN"), PHVOLT_T_RETURN }, + { SL("MACRO"), PHVOLT_T_MACRO }, + { SL("ENDMACRO"), PHVOLT_T_ENDMACRO }, + { SL("CALL"), PHVOLT_T_CALL }, + { SL("WITH"), PHVOLT_T_WITH }, + { NULL, 0, 0 } +}; + +/* {{{ phvolt_wrapper_alloc + Wrapper to alloc memory within the parser. */ +static void *phvolt_wrapper_alloc(size_t bytes) +{ + return emalloc(bytes); +} +/* }}} */ + +/* {{{ phvolt_wrapper_free + Wrapper to free memory within the parser. */ +static void phvolt_wrapper_free(void *pointer) +{ + efree(pointer); +} +/* }}} */ + +/* {{{ phvolt_parse_with_token + Creates a parser_token to be passed to the parser. */ +static void phvolt_parse_with_token(void* phvolt_parser, int opcode, int parsercode, phvolt_scanner_token *token, + phvolt_parser_status *parser_status) +{ + phvolt_parser_token *pToken; + + pToken = emalloc(sizeof(phvolt_parser_token)); + pToken->opcode = opcode; + pToken->token = token->value; + pToken->token_len = token->len; + pToken->free_flag = 1; + + phvolt_(phvolt_parser, parsercode, pToken, parser_status); + + token->value = NULL; + token->len = 0; +} +/* }}} */ + +/* {{{ phvolt_create_error_msg + Creates an error message. */ +static void phvolt_create_error_msg(phvolt_parser_status *parser_status, char *message) +{ + unsigned int length = (128 + Z_STRLEN_P(parser_status->scanner_state->active_file)); + char *str = emalloc(sizeof(char) * length); + + snprintf(str, length, "%s in %s on line %d", message, + Z_STRVAL_P(parser_status->scanner_state->active_file), parser_status->scanner_state->active_line); + str[length - 1] = '\0'; + + parser_status->syntax_error = estrndup(str, strlen(str)); + efree(str); +} +/* }}} */ + +/* {{{ phvolt_scanner_error_msg + Creates an error message when it's triggered by the scanner. */ +static void phvolt_scanner_error_msg(phvolt_parser_status *parser_status, zval **error_msg) +{ + char *error, *error_part; + int length; + phvolt_scanner_state *state = parser_status->scanner_state; + + ZVAL_NULL(*error_msg); + + if (state->start) { + error = emalloc(sizeof(char) * 72 + state->start_length + Z_STRLEN_P(state->active_file)); + if (state->start_length > 16) { + length = 72 + Z_STRLEN_P(state->active_file); + error_part = estrndup(state->start, 16); + snprintf(error, length, "Scanning error before '%s...' in %s on line %d", + error_part, Z_STRVAL_P(state->active_file), state->active_line); + error[length - 1] = '\0'; + efree(error_part); + } else { + length = 48 + state->start_length + Z_STRLEN_P(state->active_file); + snprintf(error, length, "Scanning error before '%s' in %s on line %d", + state->start, Z_STRVAL_P(state->active_file), state->active_line); + } + } else { + error = emalloc(sizeof(char) * (32 + Z_STRLEN_P(state->active_file))); + length = 32 + Z_STRLEN_P(state->active_file); + snprintf(error, length, "Scanning error near to EOF in %s", Z_STRVAL_P(state->active_file)); + } + + error[length - 1] = '\0'; + ZVAL_STRING(*error_msg, error); + + efree(error); +} +/* }}} */ + +/* {{{ phvolt_parse_view + Receives the volt code tokenizes and parses it. */ +static int phvolt_parse_view(zval *result, zval *view_code, zval *template_path) +{ + zval em, *error_msg = &em; + ZVAL_NULL(result); + ZVAL_NULL(error_msg); + + if (Z_TYPE_P(view_code) != IS_STRING) { + ZEPHIR_THROW_EXCEPTION_STRW(phalcon_mvc_view_exception_ce, "View code must be a string"); + return FAILURE; + } + + if (phvolt_internal_parse_view(&result, view_code, template_path, &error_msg) == FAILURE) { + ZEPHIR_THROW_EXCEPTION_STRW(phalcon_mvc_view_exception_ce, Z_STRVAL_P(error_msg)); + zval_dtor(error_msg); + return FAILURE; + } + + return SUCCESS; +} +/* }}} */ + +/* {{{ phvolt_parse_view + Checks whether the token has only blank characters. */ +static int phvolt_is_blank_string(phvolt_scanner_token *token) +{ + char *marker = token->value; + unsigned int ch, i; + + for (i = 0; i < token->len; i++) { + ch = *marker; + if (ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r' && ch != 11) { + return 0; + } + marker++; + } + + return 1; +} +/* }}} */ + +/* {{{ Parses a volt template returning an intermediate array representation + Checks whether the token has only blank characters. */ +static int phvolt_internal_parse_view(zval **result, zval *view_code, zval *template_path, zval **error_msg) { - phvolt_ret_func_call(&vvgotominor.vv186, &vvmsp[-2].minor.vv186, NULL, status->scanner_state); - vv_destructor(29,&vvmsp[-1].minor); - vv_destructor(52,&vvmsp[0].minor); -} -// 2788 "parser.php.c" - break; - }; - vvgoto = vvRuleInfo[vvruleno].lhs; - vvsize = vvRuleInfo[vvruleno].nrhs; - vvpParser->vvidx -= vvsize; - vvact = vv_find_reduce_action(vvpParser,vvgoto); - if( vvact < VVNSTATE ){ - vv_shift(vvpParser,vvact,vvgoto,&vvgotominor); - }else if( vvact == VVNSTATE + VVNRULE + 1 ){ - vv_accept(vvpParser); - } -} + char *error; + phvolt_scanner_state *state; + phvolt_scanner_token token; + int scanner_status, status = SUCCESS; + phvolt_parser_status *parser_status = NULL; + void* phvolt_parser; -static void vv_parse_failed( - vvParser *vvpParser /* The parser */ -){ - phvolt_ARG_FETCH; + /** Check if the view has code */ + if (!Z_STRVAL_P(view_code)) { + ZVAL_STRING(*error_msg, "View code cannot be null"); + return FAILURE; + } + + if (!Z_STRLEN_P(view_code)) { + array_init(*result); + return SUCCESS; + } + + /** Start the reentrant parser */ + phvolt_parser = phvolt_Alloc(phvolt_wrapper_alloc); + if (unlikely(!phvolt_parser)) { + ZVAL_STRING(*error_msg, "Memory allocation error"); + return FAILURE; + } + + parser_status = emalloc(sizeof(phvolt_parser_status)); + state = emalloc(sizeof(phvolt_scanner_state)); + + parser_status->status = PHVOLT_PARSING_OK; + parser_status->scanner_state = state; + ZVAL_UNDEF(&parser_status->ret); + + parser_status->token = &token; + parser_status->syntax_error = NULL; + + /** Initialize the scanner state */ + state->active_token = 0; + state->start = Z_STRVAL_P(view_code); + state->mode = PHVOLT_MODE_RAW; + state->raw_buffer = emalloc(sizeof(char) * PHVOLT_RAW_BUFFER_SIZE); + state->raw_buffer_size = PHVOLT_RAW_BUFFER_SIZE; + state->raw_buffer_cursor = 0; + state->active_file = template_path; + state->active_line = 1; + state->statement_position = 0; + state->extends_mode = 0; + state->block_level = 0; + state->macro_level = 0; + state->start_length = 0; + state->old_if_level = 0; + state->if_level = 0; + state->for_level = 0; + state->switch_level = 0; + state->whitespace_control = 0; + state->forced_raw_state = 0; + + state->end = state->start; + + token.value = NULL; + token.len = 0; + + /* To enable parser tracing decalre "#undef NDEBUG" in the lemon file */ #ifndef NDEBUG - if( vvTraceFILE ){ - fprintf(vvTraceFILE,"%sFail!\n",vvTracePrompt); - } + phvolt_Trace(stderr, "[PARSER] "); #endif - while( vvpParser->vvidx>=0 ) vv_pop_parser_stack(vvpParser); - /* Here code is inserted which will be executed whenever the - ** parser fails */ - phvolt_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ + while (0 <= (scanner_status = phvolt_get_token(state, &token))) { + + state->active_token = token.opcode; + + state->start_length = (Z_STRVAL_P(view_code) + Z_STRLEN_P(view_code) - state->start); + + switch (token.opcode) { + case PHVOLT_T_IGNORE: + break; + + case PHVOLT_T_ADD: + phvolt_(phvolt_parser, PHVOLT_PLUS, NULL, parser_status); + break; + + case PHVOLT_T_SUB: + phvolt_(phvolt_parser, PHVOLT_MINUS, NULL, parser_status); + break; + + case PHVOLT_T_MUL: + phvolt_(phvolt_parser, PHVOLT_TIMES, NULL, parser_status); + break; + + case PHVOLT_T_DIV: + phvolt_(phvolt_parser, PHVOLT_DIVIDE, NULL, parser_status); + break; + + case PHVOLT_T_MOD: + phvolt_(phvolt_parser, PHVOLT_MOD, NULL, parser_status); + break; + + case PHVOLT_T_AND: + phvolt_(phvolt_parser, PHVOLT_AND, NULL, parser_status); + break; + + case PHVOLT_T_OR: + phvolt_(phvolt_parser, PHVOLT_OR, NULL, parser_status); + break; + + case PHVOLT_T_IS: + phvolt_(phvolt_parser, PHVOLT_IS, NULL, parser_status); + break; + + case PHVOLT_T_EQUALS: + phvolt_(phvolt_parser, PHVOLT_EQUALS, NULL, parser_status); + break; + + case PHVOLT_T_NOTEQUALS: + phvolt_(phvolt_parser, PHVOLT_NOTEQUALS, NULL, parser_status); + break; + + case PHVOLT_T_LESS: + phvolt_(phvolt_parser, PHVOLT_LESS, NULL, parser_status); + break; + + case PHVOLT_T_GREATER: + phvolt_(phvolt_parser, PHVOLT_GREATER, NULL, parser_status); + break; + + case PHVOLT_T_GREATEREQUAL: + phvolt_(phvolt_parser, PHVOLT_GREATEREQUAL, NULL, parser_status); + break; + + case PHVOLT_T_LESSEQUAL: + phvolt_(phvolt_parser, PHVOLT_LESSEQUAL, NULL, parser_status); + break; + + case PHVOLT_T_IDENTICAL: + phvolt_(phvolt_parser, PHVOLT_IDENTICAL, NULL, parser_status); + break; + + case PHVOLT_T_NOTIDENTICAL: + phvolt_(phvolt_parser, PHVOLT_NOTIDENTICAL, NULL, parser_status); + break; + + case PHVOLT_T_NOT: + phvolt_(phvolt_parser, PHVOLT_NOT, NULL, parser_status); + break; + + case PHVOLT_T_DOT: + phvolt_(phvolt_parser, PHVOLT_DOT, NULL, parser_status); + break; + + case PHVOLT_T_CONCAT: + phvolt_(phvolt_parser, PHVOLT_CONCAT, NULL, parser_status); + break; + + case PHVOLT_T_RANGE: + phvolt_(phvolt_parser, PHVOLT_RANGE, NULL, parser_status); + break; + + case PHVOLT_T_PIPE: + phvolt_(phvolt_parser, PHVOLT_PIPE, NULL, parser_status); + break; + + case PHVOLT_T_COMMA: + phvolt_(phvolt_parser, PHVOLT_COMMA, NULL, parser_status); + break; + + case PHVOLT_T_COLON: + phvolt_(phvolt_parser, PHVOLT_COLON, NULL, parser_status); + break; + + case PHVOLT_T_QUESTION: + phvolt_(phvolt_parser, PHVOLT_QUESTION, NULL, parser_status); + break; + + case PHVOLT_T_PARENTHESES_OPEN: + phvolt_(phvolt_parser, PHVOLT_PARENTHESES_OPEN, NULL, parser_status); + break; + + case PHVOLT_T_PARENTHESES_CLOSE: + phvolt_(phvolt_parser, PHVOLT_PARENTHESES_CLOSE, NULL, parser_status); + break; + + case PHVOLT_T_SBRACKET_OPEN: + phvolt_(phvolt_parser, PHVOLT_SBRACKET_OPEN, NULL, parser_status); + break; + + case PHVOLT_T_SBRACKET_CLOSE: + phvolt_(phvolt_parser, PHVOLT_SBRACKET_CLOSE, NULL, parser_status); + break; + + case PHVOLT_T_CBRACKET_OPEN: + phvolt_(phvolt_parser, PHVOLT_CBRACKET_OPEN, NULL, parser_status); + break; + + case PHVOLT_T_CBRACKET_CLOSE: + phvolt_(phvolt_parser, PHVOLT_CBRACKET_CLOSE, NULL, parser_status); + break; + + case PHVOLT_T_OPEN_DELIMITER: + phvolt_(phvolt_parser, PHVOLT_OPEN_DELIMITER, NULL, parser_status); + break; + + case PHVOLT_T_CLOSE_DELIMITER: + phvolt_(phvolt_parser, PHVOLT_CLOSE_DELIMITER, NULL, parser_status); + break; + + case PHVOLT_T_OPEN_EDELIMITER: + if (state->extends_mode == 1 && state->block_level == 0) { + phvolt_create_error_msg(parser_status, "Child templates only may contain blocks"); + parser_status->status = PHVOLT_PARSING_FAILED; + break; + } + phvolt_(phvolt_parser, PHVOLT_OPEN_EDELIMITER, NULL, parser_status); + break; + + case PHVOLT_T_CLOSE_EDELIMITER: + phvolt_(phvolt_parser, PHVOLT_CLOSE_EDELIMITER, NULL, parser_status); + break; + + case PHVOLT_T_NULL: + phvolt_(phvolt_parser, PHVOLT_NULL, NULL, parser_status); + break; + + case PHVOLT_T_TRUE: + phvolt_(phvolt_parser, PHVOLT_TRUE, NULL, parser_status); + break; + + case PHVOLT_T_FALSE: + phvolt_(phvolt_parser, PHVOLT_FALSE, NULL, parser_status); + break; + + case PHVOLT_T_INTEGER: + phvolt_parse_with_token(phvolt_parser, PHVOLT_T_INTEGER, PHVOLT_INTEGER, &token, parser_status); + break; + + case PHVOLT_T_DOUBLE: + phvolt_parse_with_token(phvolt_parser, PHVOLT_T_DOUBLE, PHVOLT_DOUBLE, &token, parser_status); + break; + + case PHVOLT_T_STRING: + phvolt_parse_with_token(phvolt_parser, PHVOLT_T_STRING, PHVOLT_STRING, &token, parser_status); + break; + + case PHVOLT_T_IDENTIFIER: + phvolt_parse_with_token(phvolt_parser, PHVOLT_T_IDENTIFIER, PHVOLT_IDENTIFIER, &token, parser_status); + break; + + case PHVOLT_T_IF: + if (state->extends_mode == 1 && state->block_level == 0){ + phvolt_create_error_msg(parser_status, "Child templates only may contain blocks"); + parser_status->status = PHVOLT_PARSING_FAILED; + break; + } else { + state->if_level++; + state->block_level++; + } + phvolt_(phvolt_parser, PHVOLT_IF, NULL, parser_status); + break; + + case PHVOLT_T_ELSE: + if (state->if_level == 0 && state->for_level > 0) { + phvolt_(phvolt_parser, PHVOLT_ELSEFOR, NULL, parser_status); + } else { + phvolt_(phvolt_parser, PHVOLT_ELSE, NULL, parser_status); + } + break; + + case PHVOLT_T_ELSEFOR: + phvolt_(phvolt_parser, PHVOLT_ELSEFOR, NULL, parser_status); + break; + + case PHVOLT_T_ELSEIF: + if (state->if_level == 0) { + phvolt_create_error_msg(parser_status, "Unexpected ENDIF"); + parser_status->status = PHVOLT_PARSING_FAILED; + break; + } + phvolt_(phvolt_parser, PHVOLT_ELSEIF, NULL, parser_status); + break; + + case PHVOLT_T_ENDIF: + state->block_level--; + state->if_level--; + phvolt_(phvolt_parser, PHVOLT_ENDIF, NULL, parser_status); + break; + + case PHVOLT_T_FOR: + if (state->extends_mode == 1 && state->block_level == 0){ + phvolt_create_error_msg(parser_status, "Child templates only may contain blocks"); + parser_status->status = PHVOLT_PARSING_FAILED; + break; + } else { + state->old_if_level = state->if_level; + state->if_level = 0; + state->for_level++; + state->block_level++; + } + phvolt_(phvolt_parser, PHVOLT_FOR, NULL, parser_status); + break; + + case PHVOLT_T_IN: + phvolt_(phvolt_parser, PHVOLT_IN, NULL, parser_status); + break; + + case PHVOLT_T_ENDFOR: + state->block_level--; + state->for_level--; + state->if_level = state->old_if_level; + phvolt_(phvolt_parser, PHVOLT_ENDFOR, NULL, parser_status); + break; + + case PHVOLT_T_SWITCH: + if (state->extends_mode == 1 && state->block_level == 0){ + phvolt_create_error_msg(parser_status, "Child templates only may contain blocks"); + parser_status->status = PHVOLT_PARSING_FAILED; + break; + } else if (state->switch_level > 0) { + phvolt_create_error_msg(parser_status, "A nested switch detected. There is no nested switch-case statements support"); + parser_status->status = PHVOLT_PARSING_FAILED; + break; + } else { + state->switch_level = 1; + state->block_level++; + } + phvolt_(phvolt_parser, PHVOLT_SWITCH, NULL, parser_status); + break; + + case PHVOLT_T_CASE: + if (state->switch_level == 0) { + phvolt_create_error_msg(parser_status, "Unexpected CASE"); + parser_status->status = PHVOLT_PARSING_FAILED; + break; + } + phvolt_(phvolt_parser, PHVOLT_CASE, NULL, parser_status); + break; + + /* only for switch-case statements */ + case PHVOLT_T_DEFAULT: + if (state->switch_level != 0) { + phvolt_(phvolt_parser, PHVOLT_DEFAULT, NULL, parser_status); + efree(token.value); + } else { + phvolt_parse_with_token(phvolt_parser, PHVOLT_T_IDENTIFIER, PHVOLT_IDENTIFIER, &token, parser_status); + } + + break; + + case PHVOLT_T_ENDSWITCH: + if (state->switch_level == 0) { + phvolt_create_error_msg(parser_status, "Unexpected ENDSWITCH"); + parser_status->status = PHVOLT_PARSING_FAILED; + break; + } else { + state->switch_level = 0; + state->block_level--; + } + + phvolt_(phvolt_parser, PHVOLT_ENDSWITCH, NULL, parser_status); + break; + + case PHVOLT_T_RAW_FRAGMENT: + if (token.len > 0) { + if (state->extends_mode == 1 && state->block_level == 0){ + if (!phvolt_is_blank_string(&token)) { + phvolt_create_error_msg(parser_status, "Child templates only may contain blocks"); + parser_status->status = PHVOLT_PARSING_FAILED; + } + efree(token.value); + break; + } else { + if (!phvolt_is_blank_string(&token)) { + state->statement_position++; + } + } + phvolt_parse_with_token(phvolt_parser, PHVOLT_T_RAW_FRAGMENT, PHVOLT_RAW_FRAGMENT, &token, parser_status); + } else { + efree(token.value); + } + break; + + case PHVOLT_T_SET: + if (state->extends_mode == 1 && state->block_level == 0){ + phvolt_create_error_msg(parser_status, "Child templates only may contain blocks"); + parser_status->status = PHVOLT_PARSING_FAILED; + break; + } + phvolt_(phvolt_parser, PHVOLT_SET, NULL, parser_status); + break; + + case PHVOLT_T_ASSIGN: + phvolt_(phvolt_parser, PHVOLT_ASSIGN, NULL, parser_status); + break; + + case PHVOLT_T_ADD_ASSIGN: + phvolt_(phvolt_parser, PHVOLT_ADD_ASSIGN, NULL, parser_status); + break; + + case PHVOLT_T_SUB_ASSIGN: + phvolt_(phvolt_parser, PHVOLT_SUB_ASSIGN, NULL, parser_status); + break; + + case PHVOLT_T_MUL_ASSIGN: + phvolt_(phvolt_parser, PHVOLT_MUL_ASSIGN, NULL, parser_status); + break; + + case PHVOLT_T_DIV_ASSIGN: + phvolt_(phvolt_parser, PHVOLT_DIV_ASSIGN, NULL, parser_status); + break; + + case PHVOLT_T_INCR: + phvolt_(phvolt_parser, PHVOLT_INCR, NULL, parser_status); + break; + + case PHVOLT_T_DECR: + phvolt_(phvolt_parser, PHVOLT_DECR, NULL, parser_status); + break; + + case PHVOLT_T_BLOCK: + if (state->block_level > 0) { + phvolt_create_error_msg(parser_status, "Embedding blocks into other blocks is not supported"); + parser_status->status = PHVOLT_PARSING_FAILED; + break; + } else { + state->block_level++; + } + phvolt_(phvolt_parser, PHVOLT_BLOCK, NULL, parser_status); + break; + + case PHVOLT_T_ENDBLOCK: + state->block_level--; + phvolt_(phvolt_parser, PHVOLT_ENDBLOCK, NULL, parser_status); + break; + + case PHVOLT_T_MACRO: + if (state->macro_level > 0) { + phvolt_create_error_msg(parser_status, "Embedding macros into other macros is not allowed"); + parser_status->status = PHVOLT_PARSING_FAILED; + break; + } else { + state->macro_level++; + } + phvolt_(phvolt_parser, PHVOLT_MACRO, NULL, parser_status); + break; + case PHVOLT_T_ENDMACRO: + state->macro_level--; + phvolt_(phvolt_parser, PHVOLT_ENDMACRO, NULL, parser_status); + break; + + case PHVOLT_T_CALL: + phvolt_(phvolt_parser, PHVOLT_CALL, NULL, parser_status); + break; + case PHVOLT_T_ENDCALL: + phvolt_(phvolt_parser, PHVOLT_ENDCALL, NULL, parser_status); + break; + + case PHVOLT_T_CACHE: + phvolt_(phvolt_parser, PHVOLT_CACHE, NULL, parser_status); + break; + case PHVOLT_T_ENDCACHE: + phvolt_(phvolt_parser, PHVOLT_ENDCACHE, NULL, parser_status); + break; + + case PHVOLT_T_RAW: + phvolt_(phvolt_parser, PHVOLT_RAW, NULL, parser_status); + state->forced_raw_state++; + break; + case PHVOLT_T_ENDRAW: + phvolt_(phvolt_parser, PHVOLT_ENDRAW, NULL, parser_status); + state->forced_raw_state--; + break; + + case PHVOLT_T_INCLUDE: + phvolt_(phvolt_parser, PHVOLT_INCLUDE, NULL, parser_status); + break; + + case PHVOLT_T_WITH: + phvolt_(phvolt_parser, PHVOLT_WITH, NULL, parser_status); + break; + + case PHVOLT_T_DEFINED: + phvolt_(phvolt_parser, PHVOLT_DEFINED, NULL, parser_status); + break; + + case PHVOLT_T_EMPTY: + phvolt_(phvolt_parser, PHVOLT_EMPTY, NULL, parser_status); + break; + + case PHVOLT_T_EVEN: + phvolt_(phvolt_parser, PHVOLT_EVEN, NULL, parser_status); + break; + + case PHVOLT_T_ODD: + phvolt_(phvolt_parser, PHVOLT_ODD, NULL, parser_status); + break; + + case PHVOLT_T_NUMERIC: + phvolt_(phvolt_parser, PHVOLT_NUMERIC, NULL, parser_status); + break; + + case PHVOLT_T_SCALAR: + phvolt_(phvolt_parser, PHVOLT_SCALAR, NULL, parser_status); + break; + + case PHVOLT_T_ITERABLE: + phvolt_(phvolt_parser, PHVOLT_ITERABLE, NULL, parser_status); + break; + + case PHVOLT_T_DO: + phvolt_(phvolt_parser, PHVOLT_DO, NULL, parser_status); + break; + case PHVOLT_T_RETURN: + phvolt_(phvolt_parser, PHVOLT_RETURN, NULL, parser_status); + break; + + case PHVOLT_T_AUTOESCAPE: + phvolt_(phvolt_parser, PHVOLT_AUTOESCAPE, NULL, parser_status); + break; + + case PHVOLT_T_ENDAUTOESCAPE: + phvolt_(phvolt_parser, PHVOLT_ENDAUTOESCAPE, NULL, parser_status); + break; + + case PHVOLT_T_BREAK: + phvolt_(phvolt_parser, PHVOLT_BREAK, NULL, parser_status); + break; + + case PHVOLT_T_CONTINUE: + phvolt_(phvolt_parser, PHVOLT_CONTINUE, NULL, parser_status); + break; + + case PHVOLT_T_EXTENDS: + if (state->statement_position != 1) { + phvolt_create_error_msg(parser_status, "Extends statement must be placed at the first line in the template"); + parser_status->status = PHVOLT_PARSING_FAILED; + break; + } else { + state->extends_mode = 1; + } + phvolt_(phvolt_parser, PHVOLT_EXTENDS, NULL, parser_status); + break; + + default: + parser_status->status = PHVOLT_PARSING_FAILED; + error = emalloc(sizeof(char) * (48 + Z_STRLEN_P(state->active_file))); + snprintf(error, 48 + Z_STRLEN_P(state->active_file) + state->active_line, + "Scanner: unknown opcode %d on in %s line %d", token.opcode, + Z_STRVAL_P(state->active_file), state->active_line); + + if (Z_TYPE_P(*error_msg) == IS_NULL) { + ZVAL_STRING((*error_msg), error); + } + + efree(error); + break; + } + + if (parser_status->status != PHVOLT_PARSING_OK) { + status = FAILURE; + break; + } + + state->end = state->start; + } + + if (status != FAILURE) { + switch (scanner_status) { + case PHVOLT_SCANNER_RETCODE_ERR: + case PHVOLT_SCANNER_RETCODE_IMPOSSIBLE: + if (!*error_msg) { + phvolt_scanner_error_msg(parser_status, error_msg); + } else { + if (Z_TYPE_P(*error_msg) == IS_NULL) { + phvolt_scanner_error_msg(parser_status, error_msg); + } + } + status = FAILURE; + break; + default: + phvolt_(phvolt_parser, 0, NULL, parser_status); + } + } + + state->active_token = 0; + state->start = NULL; + efree(state->raw_buffer); + + if (parser_status->status != PHVOLT_PARSING_OK) { + status = FAILURE; + if (parser_status->syntax_error) { + ZVAL_STRING(*error_msg, parser_status->syntax_error); + efree(parser_status->syntax_error); + } + } + + if (status != FAILURE) { + if (parser_status->status == PHVOLT_PARSING_OK) { + if (Z_TYPE(parser_status->ret) != IS_UNDEF) { + ZVAL_ZVAL(*result, &parser_status->ret, 1, 1); + } else { + array_init(*result); + } + } + } + + phvolt_Free(phvolt_parser, phvolt_wrapper_free); + + efree(parser_status); + efree(state); + + return status; + } +/* }}} */ -static void vv_syntax_error( - vvParser *vvpParser, /* The parser */ - int vvmajor, /* The major type of the error token */ - VVMINORTYPE vvminor /* The minor type of the error token */ -){ - phvolt_ARG_FETCH; -#define VTOKEN (vvminor.vv0) -// 54 "parser.php.lemon" - { - smart_str error_str = {0}; - char *token_name = NULL; - const phvolt_token_names *tokens = phvolt_tokens; - int token_len = 0; - int active_token = status->scanner_state->active_token; +/* Generated by re2c 1.1.1 */ +/* scanner.re + * + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the + * LICENSE.txt file that was distributed with this source code. + */ + + +/* for re2c */ +#define VVCTYPE unsigned char +#define VVCURSOR (s->start) +#define VVLIMIT (s->end) +#define VVMARKER (s->marker) + +static void phvolt_rtrim(phvolt_scanner_token *token) { + + char *cursor, *removed_str; + int i; + char ch; + + if (token->len > 0) { + + cursor = token->value; + cursor += (token->len - 1); + for (i = token->len; i > 0; i--) { + ch = (*cursor); + if (ch == '\t' || ch == '\n' || ch == '\r' || ch == ' ' || ch == '\v') { + cursor--; + continue; + } + break; + } + + if (i >= 0) { + removed_str = emalloc(i + 1); + memcpy(removed_str, token->value, i); + removed_str[i] = '\0'; + + efree(token->value); + token->value = removed_str; + token->len = i; + } + } + +} + +static void phvolt_ltrim(phvolt_scanner_token *token) { + + char *cursor, *removed_str; + int i; + + if (token->len > 0) { + + cursor = token->value; + for (i = 0; i < token->len; i++) { + char ch = (*cursor); + if (ch == '\t' || ch == '\n' || ch == '\r' || ch == ' ' || ch == '\v') { + cursor++; + continue; + } + break; + } + + if (i >= 0) { + removed_str = emalloc(token->len - i + 1); + memcpy(removed_str, token->value + i, token->len - i); + removed_str[token->len - i] = '\0'; + + efree(token->value); + token->value = removed_str; + token->len = token->len - i; + } + } + +} + +static int phvolt_get_token(phvolt_scanner_state *s, phvolt_scanner_token *token) { + unsigned char next, double_next; + char *start = VVCURSOR; + int status = PHVOLT_SCANNER_RETCODE_IMPOSSIBLE; + + while (PHVOLT_SCANNER_RETCODE_IMPOSSIBLE == status) { + if (s->mode == PHVOLT_MODE_RAW || s->mode == PHVOLT_MODE_COMMENT) { + next = '\0'; + double_next = '\0'; + + if (*VVCURSOR == '\n') { + s->active_line++; + } + + if (*VVCURSOR != '\0') { + next = *(VVCURSOR + 1); + if (next != '\0') { + double_next = *(VVCURSOR + 2); + } + } + + if (*VVCURSOR == '\0' || (*VVCURSOR == '{' && (next == '%' || next == '{' || next == '#'))) { + if (next != '#') { + s->mode = PHVOLT_MODE_CODE; + + if (s->raw_buffer_cursor > 0) { + token->opcode = PHVOLT_T_RAW_FRAGMENT; + token->value = emalloc(sizeof(char) * s->raw_buffer_cursor + 1); + memcpy(token->value, s->raw_buffer, s->raw_buffer_cursor); + token->value[s->raw_buffer_cursor] = 0; + token->len = s->raw_buffer_cursor; + + if (s->whitespace_control == 1) { + phvolt_ltrim(token); + s->whitespace_control = 0; + } + + if (double_next == '-') { + phvolt_rtrim(token); + } + + s->raw_buffer_cursor = 0; + } else { + token->opcode = PHVOLT_T_IGNORE; + } + } else { + while ((next = *(++VVCURSOR))) { + if (next == '#' && *(VVCURSOR + 1) == '}') { + VVCURSOR += 2; + token->opcode = PHVOLT_T_IGNORE; + return 0; + } else { + if (next == '\n') { + s->active_line++; + } + } + } + + return PHVOLT_SCANNER_RETCODE_EOF; + } + + return 0; + + } else { + if (s->raw_buffer_cursor == s->raw_buffer_size) { + s->raw_buffer_size += PHVOLT_RAW_BUFFER_SIZE; + s->raw_buffer = erealloc(s->raw_buffer, s->raw_buffer_size); + } + + memcpy(s->raw_buffer+s->raw_buffer_cursor, VVCURSOR, 1); + s->raw_buffer_cursor++; + + ++VVCURSOR; + } + + } else { + + { + VVCTYPE vvch; + unsigned int vvaccept = 0; + vvch = *VVCURSOR; + switch (vvch) { + case 0x00: goto vv2; + case '\t': + case '\r': + case ' ': goto vv6; + case '\n': goto vv9; + case '!': goto vv11; + case '"': goto vv13; + case '%': goto vv14; + case '\'': goto vv16; + case '(': goto vv17; + case ')': goto vv19; + case '*': goto vv21; + case '+': goto vv23; + case ',': goto vv25; + case '-': goto vv27; + case '.': goto vv29; + case '/': goto vv31; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto vv33; + case ':': goto vv36; + case '<': goto vv38; + case '=': goto vv40; + case '>': goto vv42; + case '?': goto vv44; + case 'A': + case 'a': goto vv46; + case 'B': + case 'b': goto vv48; + case 'C': + case 'c': goto vv49; + case 'D': + case 'd': goto vv50; + case 'E': + case 'e': goto vv51; + case 'F': + case 'f': goto vv52; + case 'G': + case 'H': + case 'J': + case 'K': + case 'L': + case 'P': + case 'Q': + case 'U': + case 'V': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'g': + case 'h': + case 'j': + case 'k': + case 'l': + case 'p': + case 'q': + case 'u': + case 'v': + case 'x': + case 'y': + case 'z': goto vv53; + case 'I': goto vv55; + case 'M': + case 'm': goto vv56; + case 'N': + case 'n': goto vv57; + case 'O': + case 'o': goto vv58; + case 'R': + case 'r': goto vv59; + case 'S': + case 's': goto vv60; + case 'T': + case 't': goto vv61; + case 'W': + case 'w': goto vv62; + case '[': goto vv63; + case '\\': goto vv65; + case ']': goto vv66; + case 'i': goto vv68; + case '{': goto vv69; + case '|': goto vv71; + case '}': goto vv73; + case '~': goto vv75; + default: goto vv4; + } +vv2: + ++VVCURSOR; + { + status = PHVOLT_SCANNER_RETCODE_EOF; + break; + } +vv4: + ++VVCURSOR; +vv5: + { + status = PHVOLT_SCANNER_RETCODE_ERR; + break; + } +vv6: + vvch = *++VVCURSOR; + switch (vvch) { + case '\t': + case '\r': + case ' ': goto vv6; + default: goto vv8; + } +vv8: + { + token->opcode = PHVOLT_T_IGNORE; + return 0; + } +vv9: + ++VVCURSOR; + { + s->active_line++; + token->opcode = PHVOLT_T_IGNORE; + return 0; + } +vv11: + vvch = *++VVCURSOR; + switch (vvch) { + case '=': goto vv77; + default: goto vv12; + } +vv12: + { + token->opcode = PHVOLT_T_NOT; + return 0; + } +vv13: + vvaccept = 0; + vvch = *(VVMARKER = ++VVCURSOR); + if (vvch <= 0x00) goto vv5; + goto vv80; +vv14: + vvch = *++VVCURSOR; + switch (vvch) { + case '}': goto vv85; + default: goto vv15; + } +vv15: + { + token->opcode = PHVOLT_T_MOD; + return 0; + } +vv16: + vvaccept = 0; + vvch = *(VVMARKER = ++VVCURSOR); + if (vvch <= 0x00) goto vv5; + goto vv88; +vv17: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_PARENTHESES_OPEN; + return 0; + } +vv19: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_PARENTHESES_CLOSE; + return 0; + } +vv21: + vvch = *++VVCURSOR; + switch (vvch) { + case '=': goto vv90; + default: goto vv22; + } +vv22: + { + token->opcode = PHVOLT_T_MUL; + return 0; + } +vv23: + vvch = *++VVCURSOR; + switch (vvch) { + case '+': goto vv92; + case '=': goto vv94; + default: goto vv24; + } +vv24: + { + token->opcode = PHVOLT_T_ADD; + return 0; + } +vv25: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_COMMA; + return 0; + } +vv27: + vvaccept = 1; + vvch = *(VVMARKER = ++VVCURSOR); + switch (vvch) { + case '%': goto vv96; + case '-': goto vv97; + case '=': goto vv99; + case '}': goto vv101; + default: goto vv28; + } +vv28: + { + token->opcode = PHVOLT_T_SUB; + return 0; + } +vv29: + vvch = *++VVCURSOR; + switch (vvch) { + case '.': goto vv102; + default: goto vv30; + } +vv30: + { + token->opcode = PHVOLT_T_DOT; + return 0; + } +vv31: + vvch = *++VVCURSOR; + switch (vvch) { + case '=': goto vv104; + default: goto vv32; + } +vv32: + { + token->opcode = PHVOLT_T_DIV; + return 0; + } +vv33: + vvaccept = 2; + vvch = *(VVMARKER = ++VVCURSOR); + switch (vvch) { + case '.': goto vv106; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto vv33; + default: goto vv35; + } +vv35: + { + token->opcode = PHVOLT_T_INTEGER; + token->value = estrndup(start, VVCURSOR - start); + token->len = VVCURSOR - start; + return 0; + } +vv36: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_COLON; + return 0; + } +vv38: + vvch = *++VVCURSOR; + switch (vvch) { + case '=': goto vv107; + case '>': goto vv109; + default: goto vv39; + } +vv39: + { + token->opcode = PHVOLT_T_LESS; + return 0; + } +vv40: + vvch = *++VVCURSOR; + switch (vvch) { + case '=': goto vv111; + default: goto vv41; + } +vv41: + { + token->opcode = PHVOLT_T_ASSIGN; + return 0; + } +vv42: + vvch = *++VVCURSOR; + switch (vvch) { + case '=': goto vv113; + default: goto vv43; + } +vv43: + { + token->opcode = PHVOLT_T_GREATER; + return 0; + } +vv44: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_QUESTION; + return 0; + } +vv46: + vvch = *++VVCURSOR; + switch (vvch) { + case 'N': + case 'n': goto vv115; + case 'U': + case 'u': goto vv116; + default: goto vv54; + } +vv47: + { + token->opcode = PHVOLT_T_IDENTIFIER; + token->value = estrndup(start, VVCURSOR - start); + token->len = VVCURSOR - start; + return 0; + } +vv48: + vvch = *++VVCURSOR; + switch (vvch) { + case 'L': + case 'l': goto vv117; + case 'R': + case 'r': goto vv118; + default: goto vv54; + } +vv49: + vvch = *++VVCURSOR; + switch (vvch) { + case 'A': + case 'a': goto vv119; + case 'O': + case 'o': goto vv120; + default: goto vv54; + } +vv50: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv121; + case 'O': + case 'o': goto vv122; + default: goto vv54; + } +vv51: + vvch = *++VVCURSOR; + switch (vvch) { + case 'L': + case 'l': goto vv124; + case 'M': + case 'm': goto vv125; + case 'N': + case 'n': goto vv126; + case 'V': + case 'v': goto vv127; + case 'X': + case 'x': goto vv128; + default: goto vv54; + } +vv52: + vvch = *++VVCURSOR; + switch (vvch) { + case 'A': + case 'a': goto vv129; + case 'O': + case 'o': goto vv130; + default: goto vv54; + } +vv53: + vvch = *++VVCURSOR; +vv54: + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv47; + } +vv55: + vvch = *++VVCURSOR; + switch (vvch) { + case 'F': + case 'f': goto vv131; + case 'N': + case 'n': goto vv133; + case 'S': + case 's': goto vv135; + case 'T': + case 't': goto vv137; + default: goto vv54; + } +vv56: + vvch = *++VVCURSOR; + switch (vvch) { + case 'A': + case 'a': goto vv138; + default: goto vv54; + } +vv57: + vvch = *++VVCURSOR; + switch (vvch) { + case 'O': + case 'o': goto vv139; + case 'U': + case 'u': goto vv140; + default: goto vv54; + } +vv58: + vvch = *++VVCURSOR; + switch (vvch) { + case 'D': + case 'd': goto vv141; + case 'R': + case 'r': goto vv142; + default: goto vv54; + } +vv59: + vvch = *++VVCURSOR; + switch (vvch) { + case 'A': + case 'a': goto vv144; + case 'E': + case 'e': goto vv145; + default: goto vv54; + } +vv60: + vvch = *++VVCURSOR; + switch (vvch) { + case 'C': + case 'c': goto vv146; + case 'E': + case 'e': goto vv147; + case 'W': + case 'w': goto vv148; + default: goto vv54; + } +vv61: + vvch = *++VVCURSOR; + switch (vvch) { + case 'R': + case 'r': goto vv149; + default: goto vv54; + } +vv62: + vvch = *++VVCURSOR; + switch (vvch) { + case 'I': + case 'i': goto vv150; + default: goto vv54; + } +vv63: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_SBRACKET_OPEN; + return 0; + } +vv65: + vvch = *++VVCURSOR; + switch (vvch) { + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv5; + } +vv66: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_SBRACKET_CLOSE; + return 0; + } +vv68: + vvch = *++VVCURSOR; + switch (vvch) { + case 'F': + case 'f': goto vv131; + case 'N': + case 'n': goto vv133; + case 'S': goto vv135; + case 'T': + case 't': goto vv137; + case 's': goto vv151; + default: goto vv54; + } +vv69: + vvch = *++VVCURSOR; + switch (vvch) { + case '%': goto vv152; + case '{': goto vv154; + default: goto vv70; + } +vv70: + { + token->opcode = PHVOLT_T_CBRACKET_OPEN; + return 0; + } +vv71: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_PIPE; + return 0; + } +vv73: + vvch = *++VVCURSOR; + switch (vvch) { + case '}': goto vv156; + default: goto vv74; + } +vv74: + { + token->opcode = PHVOLT_T_CBRACKET_CLOSE; + return 0; + } +vv75: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_CONCAT; + return 0; + } +vv77: + vvch = *++VVCURSOR; + switch (vvch) { + case '=': goto vv158; + default: goto vv78; + } +vv78: + { + token->opcode = PHVOLT_T_NOTEQUALS; + return 0; + } +vv79: + vvch = *++VVCURSOR; +vv80: + switch (vvch) { + case 0x00: goto vv81; + case '"': goto vv82; + case '\\': goto vv84; + default: goto vv79; + } +vv81: + VVCURSOR = VVMARKER; + switch (vvaccept) { + case 0: goto vv5; + case 1: goto vv28; + case 2: goto vv35; + default: goto vv136; + } +vv82: + ++VVCURSOR; + { + start++; + token->opcode = PHVOLT_T_STRING; + token->value = estrndup(start, VVCURSOR - start - 1); + token->len = VVCURSOR - start - 1; + return 0; + } +vv84: + vvch = *++VVCURSOR; + switch (vvch) { + case '\n': goto vv81; + default: goto vv79; + } +vv85: + ++VVCURSOR; + { + s->mode = PHVOLT_MODE_RAW; + token->opcode = PHVOLT_T_CLOSE_DELIMITER; + return 0; + } +vv87: + vvch = *++VVCURSOR; +vv88: + switch (vvch) { + case 0x00: goto vv81; + case '\'': goto vv82; + case '\\': goto vv89; + default: goto vv87; + } +vv89: + vvch = *++VVCURSOR; + switch (vvch) { + case '\n': goto vv81; + default: goto vv87; + } +vv90: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_MUL_ASSIGN; + return 0; + } +vv92: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_INCR; + return 0; + } +vv94: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_ADD_ASSIGN; + return 0; + } +vv96: + vvch = *++VVCURSOR; + switch (vvch) { + case '}': goto vv160; + default: goto vv81; + } +vv97: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_DECR; + return 0; + } +vv99: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_SUB_ASSIGN; + return 0; + } +vv101: + vvch = *++VVCURSOR; + switch (vvch) { + case '}': goto vv162; + default: goto vv81; + } +vv102: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_RANGE; + return 0; + } +vv104: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_DIV_ASSIGN; + return 0; + } +vv106: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto vv164; + default: goto vv81; + } +vv107: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_LESSEQUAL; + return 0; + } +vv109: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_NOTEQUALS; + return 0; + } +vv111: + vvch = *++VVCURSOR; + switch (vvch) { + case '=': goto vv167; + default: goto vv112; + } +vv112: + { + token->opcode = PHVOLT_T_EQUALS; + return 0; + } +vv113: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_GREATEREQUAL; + return 0; + } +vv115: + vvch = *++VVCURSOR; + switch (vvch) { + case 'D': + case 'd': goto vv169; + default: goto vv54; + } +vv116: + vvch = *++VVCURSOR; + switch (vvch) { + case 'T': + case 't': goto vv171; + default: goto vv54; + } +vv117: + vvch = *++VVCURSOR; + switch (vvch) { + case 'O': + case 'o': goto vv172; + default: goto vv54; + } +vv118: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv173; + default: goto vv54; + } +vv119: + vvch = *++VVCURSOR; + switch (vvch) { + case 'C': + case 'c': goto vv174; + case 'L': + case 'l': goto vv175; + case 'S': + case 's': goto vv176; + default: goto vv54; + } +vv120: + vvch = *++VVCURSOR; + switch (vvch) { + case 'N': + case 'n': goto vv177; + default: goto vv54; + } +vv121: + vvch = *++VVCURSOR; + switch (vvch) { + case 'F': + case 'f': goto vv178; + default: goto vv54; + } +vv122: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv123; + } +vv123: + { + s->statement_position++; + token->opcode = PHVOLT_T_DO; + return 0; + } +vv124: + vvch = *++VVCURSOR; + switch (vvch) { + case 'S': + case 's': goto vv179; + default: goto vv54; + } +vv125: + vvch = *++VVCURSOR; + switch (vvch) { + case 'P': + case 'p': goto vv180; + default: goto vv54; + } +vv126: + vvch = *++VVCURSOR; + switch (vvch) { + case 'D': + case 'd': goto vv181; + default: goto vv54; + } +vv127: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv182; + default: goto vv54; + } +vv128: + vvch = *++VVCURSOR; + switch (vvch) { + case 'T': + case 't': goto vv183; + default: goto vv54; + } +vv129: + vvch = *++VVCURSOR; + switch (vvch) { + case 'L': + case 'l': goto vv184; + default: goto vv54; + } +vv130: + vvch = *++VVCURSOR; + switch (vvch) { + case 'R': + case 'r': goto vv185; + default: goto vv54; + } +vv131: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv132; + } +vv132: + { + s->statement_position++; + token->opcode = PHVOLT_T_IF; + return 0; + } +vv133: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + case 'C': + case 'c': goto vv187; + default: goto vv134; + } +vv134: + { + token->opcode = PHVOLT_T_IN; + return 0; + } +vv135: + vvaccept = 3; + vvch = *(VVMARKER = ++VVCURSOR); + switch (vvch) { + case ' ': goto vv188; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv136; + } +vv136: + { + if (s->active_token == PHVOLT_T_DOT) { + token->opcode = PHVOLT_T_IDENTIFIER; + token->value = estrndup(start, VVCURSOR - start); + token->len = VVCURSOR - start; + } else { + s->statement_position++; + token->opcode = PHVOLT_T_IS; + } - if (status->scanner_state->start_length) { + return 0; + } +vv137: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv189; + default: goto vv54; + } +vv138: + vvch = *++VVCURSOR; + switch (vvch) { + case 'C': + case 'c': goto vv190; + default: goto vv54; + } +vv139: + vvch = *++VVCURSOR; + switch (vvch) { + case 'T': + case 't': goto vv191; + default: goto vv54; + } +vv140: + vvch = *++VVCURSOR; + switch (vvch) { + case 'L': + case 'l': goto vv193; + case 'M': + case 'm': goto vv194; + default: goto vv54; + } +vv141: + vvch = *++VVCURSOR; + switch (vvch) { + case 'D': + case 'd': goto vv195; + default: goto vv54; + } +vv142: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv143; + } +vv143: + { + token->opcode = PHVOLT_T_OR; + return 0; + } +vv144: + vvch = *++VVCURSOR; + switch (vvch) { + case 'W': + case 'w': goto vv197; + default: goto vv54; + } +vv145: + vvch = *++VVCURSOR; + switch (vvch) { + case 'T': + case 't': goto vv199; + default: goto vv54; + } +vv146: + vvch = *++VVCURSOR; + switch (vvch) { + case 'A': + case 'a': goto vv200; + default: goto vv54; + } +vv147: + vvch = *++VVCURSOR; + switch (vvch) { + case 'T': + case 't': goto vv201; + default: goto vv54; + } +vv148: + vvch = *++VVCURSOR; + switch (vvch) { + case 'I': + case 'i': goto vv203; + default: goto vv54; + } +vv149: + vvch = *++VVCURSOR; + switch (vvch) { + case 'U': + case 'u': goto vv204; + default: goto vv54; + } +vv150: + vvch = *++VVCURSOR; + switch (vvch) { + case 'T': + case 't': goto vv205; + default: goto vv54; + } +vv151: + vvaccept = 3; + vvch = *(VVMARKER = ++VVCURSOR); + switch (vvch) { + case ' ': goto vv206; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv136; + } +vv152: + vvch = *++VVCURSOR; + switch (vvch) { + case '-': goto vv207; + default: goto vv153; + } +vv153: + { + s->whitespace_control = 0; + token->opcode = PHVOLT_T_OPEN_DELIMITER; + return 0; + } +vv154: + vvch = *++VVCURSOR; + switch (vvch) { + case '-': goto vv209; + default: goto vv155; + } +vv155: + { + s->whitespace_control = 0; + s->statement_position++; + token->opcode = PHVOLT_T_OPEN_EDELIMITER; + return 0; + } +vv156: + ++VVCURSOR; + { + s->mode = PHVOLT_MODE_RAW; + token->opcode = PHVOLT_T_CLOSE_EDELIMITER; + return 0; + } +vv158: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_NOTIDENTICAL; + return 0; + } +vv160: + ++VVCURSOR; + { + s->mode = PHVOLT_MODE_RAW; + s->whitespace_control = 1; + token->opcode = PHVOLT_T_CLOSE_DELIMITER; + return 0; + } +vv162: + ++VVCURSOR; + { + s->mode = PHVOLT_MODE_RAW; + s->whitespace_control = 1; + token->opcode = PHVOLT_T_CLOSE_EDELIMITER; + return 0; + } +vv164: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto vv164; + default: goto vv166; + } +vv166: + { + token->opcode = PHVOLT_T_DOUBLE; + token->value = estrndup(start, VVCURSOR - start); + token->len = VVCURSOR - start; + return 0; + } +vv167: + ++VVCURSOR; + { + token->opcode = PHVOLT_T_IDENTICAL; + return 0; + } +vv169: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv170; + } +vv170: + { + token->opcode = PHVOLT_T_AND; + return 0; + } +vv171: + vvch = *++VVCURSOR; + switch (vvch) { + case 'O': + case 'o': goto vv211; + default: goto vv54; + } +vv172: + vvch = *++VVCURSOR; + switch (vvch) { + case 'C': + case 'c': goto vv212; + default: goto vv54; + } +vv173: + vvch = *++VVCURSOR; + switch (vvch) { + case 'A': + case 'a': goto vv213; + default: goto vv54; + } +vv174: + vvch = *++VVCURSOR; + switch (vvch) { + case 'H': + case 'h': goto vv214; + default: goto vv54; + } +vv175: + vvch = *++VVCURSOR; + switch (vvch) { + case 'L': + case 'l': goto vv215; + default: goto vv54; + } +vv176: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv217; + default: goto vv54; + } +vv177: + vvch = *++VVCURSOR; + switch (vvch) { + case 'T': + case 't': goto vv219; + default: goto vv54; + } +vv178: + vvch = *++VVCURSOR; + switch (vvch) { + case 'A': + case 'a': goto vv220; + case 'I': + case 'i': goto vv221; + default: goto vv54; + } +vv179: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv222; + default: goto vv54; + } +vv180: + vvch = *++VVCURSOR; + switch (vvch) { + case 'T': + case 't': goto vv224; + default: goto vv54; + } +vv181: + vvch = *++VVCURSOR; + switch (vvch) { + case 'A': + case 'a': goto vv225; + case 'B': + case 'b': goto vv226; + case 'C': + case 'c': goto vv227; + case 'F': + case 'f': goto vv228; + case 'I': + case 'i': goto vv229; + case 'M': + case 'm': goto vv230; + case 'R': + case 'r': goto vv231; + case 'S': + case 's': goto vv232; + default: goto vv54; + } +vv182: + vvch = *++VVCURSOR; + switch (vvch) { + case 'N': + case 'n': goto vv233; + default: goto vv54; + } +vv183: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv235; + default: goto vv54; + } +vv184: + vvch = *++VVCURSOR; + switch (vvch) { + case 'S': + case 's': goto vv236; + default: goto vv54; + } +vv185: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv186; + } +vv186: + { + s->statement_position++; + token->opcode = PHVOLT_T_FOR; + return 0; + } +vv187: + vvch = *++VVCURSOR; + switch (vvch) { + case 'L': + case 'l': goto vv237; + default: goto vv54; + } +vv188: + vvch = *++VVCURSOR; + switch (vvch) { + case 'N': + case 'n': goto vv238; + default: goto vv81; + } +vv189: + vvch = *++VVCURSOR; + switch (vvch) { + case 'R': + case 'r': goto vv239; + default: goto vv54; + } +vv190: + vvch = *++VVCURSOR; + switch (vvch) { + case 'R': + case 'r': goto vv240; + default: goto vv54; + } +vv191: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv192; + } +vv192: + { + s->statement_position++; + token->opcode = PHVOLT_T_NOT; + return 0; + } +vv193: + vvch = *++VVCURSOR; + switch (vvch) { + case 'L': + case 'l': goto vv241; + default: goto vv54; + } +vv194: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv243; + default: goto vv54; + } +vv195: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv196; + } +vv196: + { + s->statement_position++; + token->opcode = PHVOLT_T_ODD; + return 0; + } +vv197: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv198; + } +vv198: + { + s->statement_position++; + token->opcode = PHVOLT_T_RAW; + return 0; + } +vv199: + vvch = *++VVCURSOR; + switch (vvch) { + case 'U': + case 'u': goto vv244; + default: goto vv54; + } +vv200: + vvch = *++VVCURSOR; + switch (vvch) { + case 'L': + case 'l': goto vv245; + default: goto vv54; + } +vv201: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv202; + } +vv202: + { + if (s->active_token == PHVOLT_T_DOT) { + token->opcode = PHVOLT_T_IDENTIFIER; + token->value = estrndup(start, VVCURSOR - start); + token->len = VVCURSOR - start; + } else { + token->opcode = PHVOLT_T_SET; + } - if (active_token) { + return 0; + } +vv203: + vvch = *++VVCURSOR; + switch (vvch) { + case 'T': + case 't': goto vv246; + default: goto vv54; + } +vv204: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv247; + default: goto vv54; + } +vv205: + vvch = *++VVCURSOR; + switch (vvch) { + case 'H': + case 'h': goto vv249; + default: goto vv54; + } +vv206: + vvch = *++VVCURSOR; + switch (vvch) { + case 'N': + case 'n': goto vv238; + default: goto vv252; + } +vv207: + ++VVCURSOR; + { + s->whitespace_control = 0; + token->opcode = PHVOLT_T_OPEN_DELIMITER; + return 0; + } +vv209: + ++VVCURSOR; + { + s->whitespace_control = 0; + s->statement_position++; + token->opcode = PHVOLT_T_OPEN_EDELIMITER; + return 0; + } +vv211: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv253; + default: goto vv54; + } +vv212: + vvch = *++VVCURSOR; + switch (vvch) { + case 'K': + case 'k': goto vv254; + default: goto vv54; + } +vv213: + vvch = *++VVCURSOR; + switch (vvch) { + case 'K': + case 'k': goto vv256; + default: goto vv54; + } +vv214: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv258; + default: goto vv54; + } +vv215: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv216; + } +vv216: + { + s->statement_position++; + token->opcode = PHVOLT_T_CALL; + return 0; + } +vv217: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv218; + } +vv218: + { + token->opcode = PHVOLT_T_CASE; + return 0; + } +vv219: + vvch = *++VVCURSOR; + switch (vvch) { + case 'I': + case 'i': goto vv260; + default: goto vv54; + } +vv220: + vvch = *++VVCURSOR; + switch (vvch) { + case 'U': + case 'u': goto vv261; + default: goto vv54; + } +vv221: + vvch = *++VVCURSOR; + switch (vvch) { + case 'N': + case 'n': goto vv262; + default: goto vv54; + } +vv222: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'G': + case 'H': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'g': + case 'h': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + case 'F': + case 'f': goto vv263; + case 'I': + case 'i': goto vv264; + default: goto vv223; + } +vv223: + { + token->opcode = PHVOLT_T_ELSE; + return 0; + } +vv224: + vvch = *++VVCURSOR; + switch (vvch) { + case 'Y': + case 'y': goto vv265; + default: goto vv54; + } +vv225: + vvch = *++VVCURSOR; + switch (vvch) { + case 'U': + case 'u': goto vv267; + default: goto vv54; + } +vv226: + vvch = *++VVCURSOR; + switch (vvch) { + case 'L': + case 'l': goto vv268; + default: goto vv54; + } +vv227: + vvch = *++VVCURSOR; + switch (vvch) { + case 'A': + case 'a': goto vv269; + default: goto vv54; + } +vv228: + vvch = *++VVCURSOR; + switch (vvch) { + case 'O': + case 'o': goto vv270; + default: goto vv54; + } +vv229: + vvch = *++VVCURSOR; + switch (vvch) { + case 'F': + case 'f': goto vv271; + default: goto vv54; + } +vv230: + vvch = *++VVCURSOR; + switch (vvch) { + case 'A': + case 'a': goto vv273; + default: goto vv54; + } +vv231: + vvch = *++VVCURSOR; + switch (vvch) { + case 'A': + case 'a': goto vv274; + default: goto vv54; + } +vv232: + vvch = *++VVCURSOR; + switch (vvch) { + case 'W': + case 'w': goto vv275; + default: goto vv54; + } +vv233: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv234; + } +vv234: + { + s->statement_position++; + token->opcode = PHVOLT_T_EVEN; + return 0; + } +vv235: + vvch = *++VVCURSOR; + switch (vvch) { + case 'N': + case 'n': goto vv276; + default: goto vv54; + } +vv236: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv277; + default: goto vv54; + } +vv237: + vvch = *++VVCURSOR; + switch (vvch) { + case 'U': + case 'u': goto vv279; + default: goto vv54; + } +vv238: + vvch = *++VVCURSOR; + switch (vvch) { + case 'O': + case 'o': goto vv280; + default: goto vv81; + } +vv239: + vvch = *++VVCURSOR; + switch (vvch) { + case 'A': + case 'a': goto vv281; + default: goto vv54; + } +vv240: + vvch = *++VVCURSOR; + switch (vvch) { + case 'O': + case 'o': goto vv282; + default: goto vv54; + } +vv241: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv242; + } +vv242: + { + token->opcode = PHVOLT_T_NULL; + return 0; + } +vv243: + vvch = *++VVCURSOR; + switch (vvch) { + case 'R': + case 'r': goto vv284; + default: goto vv54; + } +vv244: + vvch = *++VVCURSOR; + switch (vvch) { + case 'R': + case 'r': goto vv285; + default: goto vv54; + } +vv245: + vvch = *++VVCURSOR; + switch (vvch) { + case 'A': + case 'a': goto vv286; + default: goto vv54; + } +vv246: + vvch = *++VVCURSOR; + switch (vvch) { + case 'C': + case 'c': goto vv287; + default: goto vv54; + } +vv247: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv248; + } +vv248: + { + token->opcode = PHVOLT_T_TRUE; + return 0; + } +vv249: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv250; + } +vv250: + { + token->opcode = PHVOLT_T_WITH; + return 0; + } +vv251: + vvch = *++VVCURSOR; +vv252: + switch (vvch) { + case ' ': goto vv251; + case 'n': goto vv288; + default: goto vv81; + } +vv253: + vvch = *++VVCURSOR; + switch (vvch) { + case 'S': + case 's': goto vv289; + default: goto vv54; + } +vv254: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv255; + } +vv255: + { + s->statement_position++; + token->opcode = PHVOLT_T_BLOCK; + return 0; + } +vv256: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv257; + } +vv257: + { + s->statement_position++; + token->opcode = PHVOLT_T_BREAK; + return 0; + } +vv258: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv259; + } +vv259: + { + s->statement_position++; + token->opcode = PHVOLT_T_CACHE; + return 0; + } +vv260: + vvch = *++VVCURSOR; + switch (vvch) { + case 'N': + case 'n': goto vv290; + default: goto vv54; + } +vv261: + vvch = *++VVCURSOR; + switch (vvch) { + case 'L': + case 'l': goto vv291; + default: goto vv54; + } +vv262: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv292; + default: goto vv54; + } +vv263: + vvch = *++VVCURSOR; + switch (vvch) { + case 'O': + case 'o': goto vv293; + default: goto vv54; + } +vv264: + vvch = *++VVCURSOR; + switch (vvch) { + case 'F': + case 'f': goto vv294; + default: goto vv54; + } +vv265: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv266; + } +vv266: + { + s->statement_position++; + token->opcode = PHVOLT_T_EMPTY; + return 0; + } +vv267: + vvch = *++VVCURSOR; + switch (vvch) { + case 'T': + case 't': goto vv296; + default: goto vv54; + } +vv268: + vvch = *++VVCURSOR; + switch (vvch) { + case 'O': + case 'o': goto vv297; + default: goto vv54; + } +vv269: + vvch = *++VVCURSOR; + switch (vvch) { + case 'C': + case 'c': goto vv298; + case 'L': + case 'l': goto vv299; + default: goto vv54; + } +vv270: + vvch = *++VVCURSOR; + switch (vvch) { + case 'R': + case 'r': goto vv300; + default: goto vv54; + } +vv271: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv272; + } +vv272: + { + token->opcode = PHVOLT_T_ENDIF; + return 0; + } +vv273: + vvch = *++VVCURSOR; + switch (vvch) { + case 'C': + case 'c': goto vv302; + default: goto vv54; + } +vv274: + vvch = *++VVCURSOR; + switch (vvch) { + case 'W': + case 'w': goto vv303; + default: goto vv54; + } +vv275: + vvch = *++VVCURSOR; + switch (vvch) { + case 'I': + case 'i': goto vv305; + default: goto vv54; + } +vv276: + vvch = *++VVCURSOR; + switch (vvch) { + case 'D': + case 'd': goto vv306; + default: goto vv54; + } +vv277: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv278; + } +vv278: + { + token->opcode = PHVOLT_T_FALSE; + return 0; + } +vv279: + vvch = *++VVCURSOR; + switch (vvch) { + case 'D': + case 'd': goto vv307; + default: goto vv54; + } +vv280: + vvch = *++VVCURSOR; + switch (vvch) { + case 'T': + case 't': goto vv308; + default: goto vv81; + } +vv281: + vvch = *++VVCURSOR; + switch (vvch) { + case 'B': + case 'b': goto vv310; + default: goto vv54; + } +vv282: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv283; + } +vv283: + { + s->statement_position++; + token->opcode = PHVOLT_T_MACRO; + return 0; + } +vv284: + vvch = *++VVCURSOR; + switch (vvch) { + case 'I': + case 'i': goto vv311; + default: goto vv54; + } +vv285: + vvch = *++VVCURSOR; + switch (vvch) { + case 'N': + case 'n': goto vv312; + default: goto vv54; + } +vv286: + vvch = *++VVCURSOR; + switch (vvch) { + case 'R': + case 'r': goto vv314; + default: goto vv54; + } +vv287: + vvch = *++VVCURSOR; + switch (vvch) { + case 'H': + case 'h': goto vv316; + default: goto vv54; + } +vv288: + vvch = *++VVCURSOR; + switch (vvch) { + case 'o': goto vv318; + default: goto vv81; + } +vv289: + vvch = *++VVCURSOR; + switch (vvch) { + case 'C': + case 'c': goto vv319; + default: goto vv54; + } +vv290: + vvch = *++VVCURSOR; + switch (vvch) { + case 'U': + case 'u': goto vv320; + default: goto vv54; + } +vv291: + vvch = *++VVCURSOR; + switch (vvch) { + case 'T': + case 't': goto vv321; + default: goto vv54; + } +vv292: + vvch = *++VVCURSOR; + switch (vvch) { + case 'D': + case 'd': goto vv323; + default: goto vv54; + } +vv293: + vvch = *++VVCURSOR; + switch (vvch) { + case 'R': + case 'r': goto vv325; + default: goto vv54; + } +vv294: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv295; + } +vv295: + { + token->opcode = PHVOLT_T_ELSEIF; + return 0; + } +vv296: + vvch = *++VVCURSOR; + switch (vvch) { + case 'O': + case 'o': goto vv327; + default: goto vv54; + } +vv297: + vvch = *++VVCURSOR; + switch (vvch) { + case 'C': + case 'c': goto vv328; + default: goto vv54; + } +vv298: + vvch = *++VVCURSOR; + switch (vvch) { + case 'H': + case 'h': goto vv329; + default: goto vv54; + } +vv299: + vvch = *++VVCURSOR; + switch (vvch) { + case 'L': + case 'l': goto vv330; + default: goto vv54; + } +vv300: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv301; + } +vv301: + { + token->opcode = PHVOLT_T_ENDFOR; + return 0; + } +vv302: + vvch = *++VVCURSOR; + switch (vvch) { + case 'R': + case 'r': goto vv332; + default: goto vv54; + } +vv303: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv304; + } +vv304: + { + s->statement_position++; + token->opcode = PHVOLT_T_ENDRAW; + return 0; + } +vv305: + vvch = *++VVCURSOR; + switch (vvch) { + case 'T': + case 't': goto vv333; + default: goto vv54; + } +vv306: + vvch = *++VVCURSOR; + switch (vvch) { + case 'S': + case 's': goto vv334; + default: goto vv54; + } +vv307: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv336; + default: goto vv54; + } +vv308: + ++VVCURSOR; + { + s->statement_position++; + token->opcode = PHVOLT_T_NOTEQUALS; + return 0; + } +vv310: + vvch = *++VVCURSOR; + switch (vvch) { + case 'L': + case 'l': goto vv338; + default: goto vv54; + } +vv311: + vvch = *++VVCURSOR; + switch (vvch) { + case 'C': + case 'c': goto vv339; + default: goto vv54; + } +vv312: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv313; + } +vv313: + { + token->opcode = PHVOLT_T_RETURN; + return 0; + } +vv314: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv315; + } +vv315: + { + s->statement_position++; + token->opcode = PHVOLT_T_SCALAR; + return 0; + } +vv316: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv317; + } +vv317: + { + s->statement_position++; + token->opcode = PHVOLT_T_SWITCH; + return 0; + } +vv318: + vvch = *++VVCURSOR; + switch (vvch) { + case 't': goto vv341; + default: goto vv81; + } +vv319: + vvch = *++VVCURSOR; + switch (vvch) { + case 'A': + case 'a': goto vv343; + default: goto vv54; + } +vv320: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv344; + default: goto vv54; + } +vv321: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv322; + } +vv322: + { + token->opcode = PHVOLT_T_DEFAULT; + token->value = estrndup(start, VVCURSOR - start); + token->len = VVCURSOR - start; + return 0; + } +vv323: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv324; + } +vv324: + { + s->statement_position++; + token->opcode = PHVOLT_T_DEFINED; + return 0; + } +vv325: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv326; + } +vv326: + { + token->opcode = PHVOLT_T_ELSEFOR; + return 0; + } +vv327: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv346; + default: goto vv54; + } +vv328: + vvch = *++VVCURSOR; + switch (vvch) { + case 'K': + case 'k': goto vv347; + default: goto vv54; + } +vv329: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv349; + default: goto vv54; + } +vv330: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv331; + } +vv331: + { + token->opcode = PHVOLT_T_ENDCALL; + return 0; + } +vv332: + vvch = *++VVCURSOR; + switch (vvch) { + case 'O': + case 'o': goto vv351; + default: goto vv54; + } +vv333: + vvch = *++VVCURSOR; + switch (vvch) { + case 'C': + case 'c': goto vv353; + default: goto vv54; + } +vv334: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv335; + } +vv335: + { + s->statement_position++; + token->opcode = PHVOLT_T_EXTENDS; + return 0; + } +vv336: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv337; + } +vv337: + { + s->statement_position++; + token->opcode = PHVOLT_T_INCLUDE; + return 0; + } +vv338: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv354; + default: goto vv54; + } +vv339: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv340; + } +vv340: + { + s->statement_position++; + token->opcode = PHVOLT_T_NUMERIC; + return 0; + } +vv341: + ++VVCURSOR; + { + s->statement_position++; + token->opcode = PHVOLT_T_NOTEQUALS; + return 0; + } +vv343: + vvch = *++VVCURSOR; + switch (vvch) { + case 'P': + case 'p': goto vv356; + default: goto vv54; + } +vv344: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv345; + } +vv345: + { + s->statement_position++; + token->opcode = PHVOLT_T_CONTINUE; + return 0; + } +vv346: + vvch = *++VVCURSOR; + switch (vvch) { + case 'S': + case 's': goto vv357; + default: goto vv54; + } +vv347: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv348; + } +vv348: + { + token->opcode = PHVOLT_T_ENDBLOCK; + return 0; + } +vv349: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv350; + } +vv350: + { + token->opcode = PHVOLT_T_ENDCACHE; + return 0; + } +vv351: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv352; + } +vv352: + { + token->opcode = PHVOLT_T_ENDMACRO; + return 0; + } +vv353: + vvch = *++VVCURSOR; + switch (vvch) { + case 'H': + case 'h': goto vv358; + default: goto vv54; + } +vv354: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv355; + } +vv355: + { + s->statement_position++; + token->opcode = PHVOLT_T_ITERABLE; + return 0; + } +vv356: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv360; + default: goto vv54; + } +vv357: + vvch = *++VVCURSOR; + switch (vvch) { + case 'C': + case 'c': goto vv362; + default: goto vv54; + } +vv358: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv359; + } +vv359: + { + token->opcode = PHVOLT_T_ENDSWITCH; + return 0; + } +vv360: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv361; + } +vv361: + { + s->statement_position++; + token->opcode = PHVOLT_T_AUTOESCAPE; + return 0; + } +vv362: + vvch = *++VVCURSOR; + switch (vvch) { + case 'A': + case 'a': goto vv363; + default: goto vv54; + } +vv363: + vvch = *++VVCURSOR; + switch (vvch) { + case 'P': + case 'p': goto vv364; + default: goto vv54; + } +vv364: + vvch = *++VVCURSOR; + switch (vvch) { + case 'E': + case 'e': goto vv365; + default: goto vv54; + } +vv365: + vvch = *++VVCURSOR; + switch (vvch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '\\': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto vv53; + default: goto vv366; + } +vv366: + { + s->statement_position++; + token->opcode = PHVOLT_T_ENDAUTOESCAPE; + return 0; + } + } - do { - if (tokens->code == active_token) { - token_name = tokens->name; - token_len = tokens->len; - break; - } - ++tokens; - } while (tokens[0].code != 0); - } + } + } - smart_str_appendl(&error_str, "Syntax error, unexpected token ", sizeof("Syntax error, unexpected token ") - 1); - if (!token_name) { - smart_str_appendl(&error_str, "UNKNOWN", sizeof("UNKNOWN") - 1); - } else { - smart_str_appendl(&error_str, token_name, token_len); - } + return status; +} - if (status->token->value) { - smart_str_appendc(&error_str, '('); - smart_str_appendl(&error_str, status->token->value, status->token->len); - smart_str_appendc(&error_str, ')'); - } - smart_str_appendl(&error_str, " in ", sizeof(" in ") - 1); - smart_str_appendl(&error_str, Z_STRVAL_P(status->scanner_state->active_file), Z_STRLEN_P(status->scanner_state->active_file)); - smart_str_appendl(&error_str, " on line ", sizeof(" on line ") - 1); - { - char stmp[MAX_LENGTH_OF_LONG + 1]; - int str_len; - str_len = slprintf(stmp, sizeof(stmp), "%u", status->scanner_state->active_line); - smart_str_appendl(&error_str, stmp, str_len); - } +#ifdef HAVE_CONFIG_H +#endif - } else { - smart_str_appendl(&error_str, "Syntax error, unexpected EOF in ", sizeof("Syntax error, unexpected EOF in ") - 1); - smart_str_appendl(&error_str, Z_STRVAL_P(status->scanner_state->active_file), Z_STRLEN_P(status->scanner_state->active_file)); - /* Report unclosed 'if' blocks */ - if ((status->scanner_state->if_level + status->scanner_state->old_if_level) > 0) { - if ((status->scanner_state->if_level + status->scanner_state->old_if_level) == 1) { - smart_str_appendl(&error_str, ", there is one 'if' block without close", sizeof(", there is one 'if' block without close") - 1); - } else { - smart_str_appendl(&error_str, ", there are ", sizeof(", there are ") - 1); - { - char stmp[MAX_LENGTH_OF_LONG + 1]; - int str_len; - str_len = slprintf(stmp, sizeof(stmp), "%u", status->scanner_state->if_level + status->scanner_state->old_if_level); - smart_str_appendl(&error_str, stmp, str_len); - } - smart_str_appendl(&error_str, " 'if' blocks without close", sizeof(" 'if' blocks without close") - 1); - } - } - /* Report unclosed 'for' blocks */ - if (status->scanner_state->for_level > 0) { - if (status->scanner_state->for_level == 1) { - smart_str_appendl(&error_str, ", there is one 'for' block without close", sizeof(", there is one 'for' block without close") - 1); - } else { - smart_str_appendl(&error_str, ", there are ", sizeof(", there are ") - 1); - { - char stmp[MAX_LENGTH_OF_LONG + 1]; - int str_len; - str_len = slprintf(stmp, sizeof(stmp), "%u", status->scanner_state->if_level); - smart_str_appendl(&error_str, stmp, str_len); - } - smart_str_appendl(&error_str, " 'for' blocks without close", sizeof(" 'for' blocks without close") - 1); - } - } - /* Report unclosed 'switch' blocks */ - if (status->scanner_state->switch_level > 0) { - smart_str_appendl(&error_str, ", there is a 'switch' block without 'endswitch'", sizeof(", there is a 'switch' block without 'endswitch'") - 1); - } - } +ZEPHIR_INIT_CLASS(Phalcon_Mvc_Controller_BindModelInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Controller, BindModelInterface, phalcon, mvc_controller_bindmodelinterface, phalcon_mvc_controller_bindmodelinterface_method_entry); - smart_str_0(&error_str); + return SUCCESS; +} - if (error_str.s) { - status->syntax_error = estrndup(ZSTR_VAL(error_str.s), ZSTR_LEN(error_str.s)); - status->syntax_error_len = ZSTR_LEN(error_str.s); - } else { - status->syntax_error = NULL; - } - } +ZEPHIR_DOC_METHOD(Phalcon_Mvc_Controller_BindModelInterface, getModelName); - status->status = PHVOLT_PARSING_FAILED; -// 2934 "parser.php.c" - phvolt_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} -static void vv_accept( - vvParser *vvpParser /* The parser */ -){ - phvolt_ARG_FETCH; -#ifndef NDEBUG - if( vvTraceFILE ){ - fprintf(vvTraceFILE,"%sAccept!\n",vvTracePrompt); - } +#ifdef HAVE_CONFIG_H #endif - while( vvpParser->vvidx>=0 ) vv_pop_parser_stack(vvpParser); - /* Here code is inserted which will be executed whenever the - ** parser accepts */ - phvolt_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} -/* The main parser program. -** The first argument is a pointer to a structure obtained from -** "phvolt_Alloc" which describes the current state of the parser. -** The second argument is the major token number. The third is -** the minor token. The fourth optional argument is whatever the -** user wants (and specified in the grammar) and is available for -** use by the action routines. -** -** Inputs: -**
    -**
  • A pointer to the parser (an opaque structure.) -**
  • The major token number. -**
  • The minor token number. -**
  • An option argument of a grammar-specified type. -**
-** -** Outputs: -** None. -*/ -static void phvolt_( - void *vvp, /* The parser */ - int vvmajor, /* The major token code number */ - phvolt_TOKENTYPE vvminor /* The value for the token */ - phvolt_ARG_PDECL /* Optional %extra_argument parameter */ -){ - VVMINORTYPE vvminorunion; - int vvact; /* The parser action. */ - int vvendofinput; /* True if we are at the end of input */ - int vverrorhit = 0; /* True if vvmajor has invoked an error */ - vvParser *vvpParser; /* The parser */ - /* (re)initialize the parser, if necessary */ - vvpParser = (vvParser*)vvp; - if( vvpParser->vvidx<0 ){ - if( vvmajor==0 ) return; - vvpParser->vvidx = 0; - vvpParser->vverrcnt = -1; - vvpParser->vvstack[0].stateno = 0; - vvpParser->vvstack[0].major = 0; - } - vvminorunion.vv0 = vvminor; - vvendofinput = (vvmajor==0); - phvolt_ARG_STORE; -#ifndef NDEBUG - if( vvTraceFILE ){ - fprintf(vvTraceFILE,"%sInput %s\n",vvTracePrompt,vvTokenName[vvmajor]); - } -#endif - do{ - vvact = vv_find_shift_action(vvpParser,vvmajor); - if( vvactvverrcnt--; - if( vvendofinput && vvpParser->vvidx>=0 ){ - vvmajor = 0; - }else{ - vvmajor = VVNOCODE; - } - }else if( vvact < VVNSTATE + VVNRULE ){ - vv_reduce(vvpParser,vvact-VVNSTATE); - }else if( vvact == VV_ERROR_ACTION ){ - int vvmx; -#ifndef NDEBUG - if( vvTraceFILE ){ - fprintf(vvTraceFILE,"%sSyntax Error!\n",vvTracePrompt); - } -#endif -#ifdef VVERRORSYMBOL - /* A syntax error has occurred. - ** The response to an error depends upon whether or not the - ** grammar defines an error token "ERROR". - ** - ** This is what we do if the grammar does define ERROR: - ** - ** * Call the %syntax_error function. - ** - ** * Begin popping the stack until we enter a state where - ** it is legal to shift the error symbol, then shift - ** the error symbol. - ** - ** * Set the error count to three. - ** - ** * Begin accepting and shifting new tokens. No new error - ** processing will occur until three tokens have been - ** shifted successfully. - ** - */ - if( vvpParser->vverrcnt<0 ){ - vv_syntax_error(vvpParser,vvmajor,vvminorunion); - } - vvmx = vvpParser->vvstack[vvpParser->vvidx].major; - if( vvmx==VVERRORSYMBOL || vverrorhit ){ -#ifndef NDEBUG - if( vvTraceFILE ){ - fprintf(vvTraceFILE,"%sDiscard input token %s\n", - vvTracePrompt,vvTokenName[vvmajor]); - } -#endif - vv_destructor(vvmajor,&vvminorunion); - vvmajor = VVNOCODE; - }else{ - while( - vvpParser->vvidx >= 0 && - vvmx != VVERRORSYMBOL && - (vvact = vv_find_shift_action(vvpParser,VVERRORSYMBOL)) >= VVNSTATE - ){ - vv_pop_parser_stack(vvpParser); - } - if( vvpParser->vvidx < 0 || vvmajor==0 ){ - vv_destructor(vvmajor,&vvminorunion); - vv_parse_failed(vvpParser); - vvmajor = VVNOCODE; - }else if( vvmx!=VVERRORSYMBOL ){ - VVMINORTYPE u2; - u2.VVERRSYMDT = 0; - vv_shift(vvpParser,vvact,VVERRORSYMBOL,&u2); - } - } - vvpParser->vverrcnt = 3; - vverrorhit = 1; -#else /* VVERRORSYMBOL is not defined */ - /* This is what we do if the grammar does not define ERROR: - ** - ** * Report an error message, and throw away the input token. - ** - ** * If the input token is $, then fail the parse. - ** - ** As before, subsequent error messages are suppressed until - ** three input tokens have been successfully shifted. - */ - if( vvpParser->vverrcnt<=0 ){ - vv_syntax_error(vvpParser,vvmajor,vvminorunion); - } - vvpParser->vverrcnt = 3; - vv_destructor(vvmajor,&vvminorunion); - if( vvendofinput ){ - vv_parse_failed(vvpParser); - } - vvmajor = VVNOCODE; -#endif - }else{ - vv_accept(vvpParser); - vvmajor = VVNOCODE; - } - }while( vvmajor!=VVNOCODE && vvpParser->vvidx>=0 ); - return; -} -/* base.c - * - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the - * LICENSE.txt file that was distributed with this source code. - */ -const phvolt_token_names phvolt_tokens[] = +ZEPHIR_INIT_CLASS(Phalcon_Assets_Asset) { - { SL("INTEGER"), PHVOLT_T_INTEGER }, - { SL("DOUBLE"), PHVOLT_T_DOUBLE }, - { SL("STRING"), PHVOLT_T_STRING }, - { SL("IDENTIFIER"), PHVOLT_T_IDENTIFIER }, - { SL("MINUS"), PHVOLT_T_MINUS }, - { SL("+"), PHVOLT_T_ADD }, - { SL("-"), PHVOLT_T_SUB }, - { SL("*"), PHVOLT_T_MUL }, - { SL("/"), PHVOLT_T_DIV }, - { SL("%%"), PHVOLT_T_MOD }, - { SL("!"), PHVOLT_T_NOT }, - { SL("~"), PHVOLT_T_CONCAT }, - { SL("AND"), PHVOLT_T_AND }, - { SL("OR"), PHVOLT_T_OR }, - { SL("DOT"), PHVOLT_T_DOT }, - { SL("COMMA"), PHVOLT_T_COMMA }, - { SL("EQUALS"), PHVOLT_T_EQUALS }, - { SL("NOT EQUALS"), PHVOLT_T_NOTEQUALS }, - { SL("IDENTICAL"), PHVOLT_T_IDENTICAL }, - { SL("NOT IDENTICAL"), PHVOLT_T_NOTIDENTICAL }, - { SL("NOT"), PHVOLT_T_NOT }, - { SL("RANGE"), PHVOLT_T_RANGE }, - { SL("COLON"), PHVOLT_T_COLON }, - { SL("QUESTION MARK"), PHVOLT_T_QUESTION }, - { SL("<"), PHVOLT_T_LESS }, - { SL("<="), PHVOLT_T_LESSEQUAL }, - { SL(">"), PHVOLT_T_GREATER }, - { SL(">="), PHVOLT_T_GREATEREQUAL }, - { SL("("), PHVOLT_T_PARENTHESES_OPEN }, - { SL(")"), PHVOLT_T_PARENTHESES_CLOSE }, - { SL("["), PHVOLT_T_SBRACKET_OPEN }, - { SL("]"), PHVOLT_T_SBRACKET_CLOSE }, - { SL("{"), PHVOLT_T_CBRACKET_OPEN }, - { SL("}"), PHVOLT_T_CBRACKET_CLOSE }, - { SL("{%"), PHVOLT_T_OPEN_DELIMITER }, - { SL("%}"), PHVOLT_T_CLOSE_DELIMITER }, - { SL("{{"), PHVOLT_T_OPEN_EDELIMITER }, - { SL("}}"), PHVOLT_T_CLOSE_EDELIMITER }, - { SL("IF"), PHVOLT_T_IF }, - { SL("ELSE"), PHVOLT_T_ELSE }, - { SL("ELSEIF"), PHVOLT_T_ELSEIF }, - { SL("ELSEFOR"), PHVOLT_T_ELSEFOR }, - { SL("ENDIF"), PHVOLT_T_ENDIF }, - { SL("FOR"), PHVOLT_T_FOR }, - { SL("SWITCH"), PHVOLT_T_SWITCH }, - { SL("CASE"), PHVOLT_T_CASE }, - { SL("DEFAULT"), PHVOLT_T_DEFAULT }, - { SL("ENDSWITCH"), PHVOLT_T_ENDSWITCH }, - { SL("IN"), PHVOLT_T_IN }, - { SL("ENDFOR"), PHVOLT_T_ENDFOR }, - { SL("SET"), PHVOLT_T_SET }, - { SL("ASSIGN"), PHVOLT_T_ASSIGN }, - { SL("+="), PHVOLT_T_ADD_ASSIGN }, - { SL("-="), PHVOLT_T_SUB_ASSIGN }, - { SL("*="), PHVOLT_T_MUL_ASSIGN }, - { SL("/="), PHVOLT_T_DIV_ASSIGN }, - { SL("++"), PHVOLT_T_INCR }, - { SL("--"), PHVOLT_T_DECR }, - { SL("BLOCK"), PHVOLT_T_BLOCK }, - { SL("ENDBLOCK"), PHVOLT_T_ENDBLOCK }, - { SL("CACHE"), PHVOLT_T_CACHE }, - { SL("ENDCACHE"), PHVOLT_T_ENDCACHE }, - { SL("EXTENDS"), PHVOLT_T_EXTENDS }, - { SL("IS"), PHVOLT_T_IS }, - { SL("DEFINED"), PHVOLT_T_DEFINED }, - { SL("EMPTY"), PHVOLT_T_EMPTY }, - { SL("EVEN"), PHVOLT_T_EVEN }, - { SL("ODD"), PHVOLT_T_ODD }, - { SL("NUMERIC"), PHVOLT_T_NUMERIC }, - { SL("SCALAR"), PHVOLT_T_SCALAR }, - { SL("ITERABLE"), PHVOLT_T_ITERABLE }, - { SL("INCLUDE"), PHVOLT_T_INCLUDE }, - { SL("DO"), PHVOLT_T_DO }, - { SL("WHITESPACE"), PHVOLT_T_IGNORE }, - { SL("AUTOESCAPE"), PHVOLT_T_AUTOESCAPE }, - { SL("ENDAUTOESCAPE"), PHVOLT_T_ENDAUTOESCAPE }, - { SL("CONTINUE"), PHVOLT_T_CONTINUE }, - { SL("BREAK"), PHVOLT_T_BREAK }, - { SL("WITH"), PHVOLT_T_WITH }, - { SL("RETURN"), PHVOLT_T_RETURN }, - { SL("MACRO"), PHVOLT_T_MACRO }, - { SL("ENDMACRO"), PHVOLT_T_ENDMACRO }, - { SL("CALL"), PHVOLT_T_CALL }, - { SL("WITH"), PHVOLT_T_WITH }, - { NULL, 0, 0 } -}; + ZEPHIR_REGISTER_CLASS(Phalcon\\Assets, Asset, phalcon, assets_asset, phalcon_assets_asset_method_entry, 0); -/* {{{ phvolt_wrapper_alloc - Wrapper to alloc memory within the parser. */ -static void *phvolt_wrapper_alloc(size_t bytes) -{ - return emalloc(bytes); + zend_declare_property_null(phalcon_assets_asset_ce, SL("attributes"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_assets_asset_ce, SL("isAutoVersion"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_assets_asset_ce, SL("filter"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_assets_asset_ce, SL("isLocal"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_assets_asset_ce, SL("path"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_assets_asset_ce, SL("sourcePath"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_assets_asset_ce, SL("targetPath"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_assets_asset_ce, SL("targetUri"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_assets_asset_ce, SL("type"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_assets_asset_ce, SL("version"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_assets_asset_ce, 1, phalcon_assets_assetinterface_ce); + return SUCCESS; } -/* }}} */ -/* {{{ phvolt_wrapper_free - Wrapper to free memory within the parser. */ -static void phvolt_wrapper_free(void *pointer) +static PHP_METHOD(Phalcon_Assets_Asset, __construct) { - efree(pointer); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval attributes; + zend_bool isLocal, filter, isAutoVersion; + zval *type_param = NULL, *path_param = NULL, *isLocal_param = NULL, *filter_param = NULL, *attributes_param = NULL, *version_param = NULL, *isAutoVersion_param = NULL, __$true, __$false; + zval type, path, version; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&path); + ZVAL_UNDEF(&version); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&attributes); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 7) + Z_PARAM_STR(type) + Z_PARAM_STR(path) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(isLocal) + Z_PARAM_BOOL(filter) + Z_PARAM_ARRAY(attributes) + Z_PARAM_STR_OR_NULL(version) + Z_PARAM_BOOL(isAutoVersion) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 5, &type_param, &path_param, &isLocal_param, &filter_param, &attributes_param, &version_param, &isAutoVersion_param); + zephir_get_strval(&type, type_param); + zephir_get_strval(&path, path_param); + if (!isLocal_param) { + isLocal = 1; + } else { + } + if (!filter_param) { + filter = 1; + } else { + } + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + if (!version_param) { + ZEPHIR_INIT_VAR(&version); + } else { + zephir_get_strval(&version, version_param); + } + if (!isAutoVersion_param) { + isAutoVersion = 0; + } else { + } + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &type); + zephir_update_property_zval(this_ptr, ZEND_STRL("path"), &path); + if (isLocal) { + zephir_update_property_zval(this_ptr, ZEND_STRL("isLocal"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("isLocal"), &__$false); + } + if (filter) { + zephir_update_property_zval(this_ptr, ZEND_STRL("filter"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("filter"), &__$false); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &attributes); + zephir_update_property_zval(this_ptr, ZEND_STRL("version"), &version); + if (isAutoVersion) { + zephir_update_property_zval(this_ptr, ZEND_STRL("isAutoVersion"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("isAutoVersion"), &__$false); + } + ZEPHIR_MM_RESTORE(); } -/* }}} */ -/* {{{ phvolt_parse_with_token - Creates a parser_token to be passed to the parser. */ -static void phvolt_parse_with_token(void* phvolt_parser, int opcode, int parsercode, phvolt_scanner_token *token, - phvolt_parser_status *parser_status) +static PHP_METHOD(Phalcon_Assets_Asset, getAssetKey) { - phvolt_parser_token *pToken; - - pToken = emalloc(sizeof(phvolt_parser_token)); - pToken->opcode = opcode; - pToken->token = token->value; - pToken->token_len = token->len; - pToken->free_flag = 1; + zval key, _0, _1, _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - phvolt_(phvolt_parser, parsercode, pToken, parser_status); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - token->value = NULL; - token->len = 0; + ZEPHIR_CALL_METHOD(&_0, this_ptr, "gettype", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getpath", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&key); + ZEPHIR_CONCAT_VSV(&key, &_0, ":", &_1); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "sha256"); + ZEPHIR_RETURN_CALL_FUNCTION("hash", NULL, 71, &_2, &key); + zephir_check_call_status(); + RETURN_MM(); } -/* }}} */ -/* {{{ phvolt_create_error_msg - Creates an error message. */ -static void phvolt_create_error_msg(phvolt_parser_status *parser_status, char *message) +static PHP_METHOD(Phalcon_Assets_Asset, getAttributes) { - unsigned int length = (128 + Z_STRLEN_P(parser_status->scanner_state->active_file)); - char *str = emalloc(sizeof(char) * length); - - snprintf(str, length, "%s in %s on line %d", message, - Z_STRVAL_P(parser_status->scanner_state->active_file), parser_status->scanner_state->active_line); - str[length - 1] = '\0'; - parser_status->syntax_error = estrndup(str, strlen(str)); - efree(str); + RETURN_MEMBER(getThis(), "attributes"); } -/* }}} */ -/* {{{ phvolt_scanner_error_msg - Creates an error message when it's triggered by the scanner. */ -static void phvolt_scanner_error_msg(phvolt_parser_status *parser_status, zval **error_msg) +static PHP_METHOD(Phalcon_Assets_Asset, getContent) { - char *error, *error_part; - int length; - phvolt_scanner_state *state = parser_status->scanner_state; - - ZVAL_NULL(*error_msg); + zend_bool _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *basePath_param = NULL, completePath, content, _0, _1, _2, _4; + zval basePath; + zval *this_ptr = getThis(); - if (state->start) { - error = emalloc(sizeof(char) * 72 + state->start_length + Z_STRLEN_P(state->active_file)); - if (state->start_length > 16) { - length = 72 + Z_STRLEN_P(state->active_file); - error_part = estrndup(state->start, 16); - snprintf(error, length, "Scanning error before '%s...' in %s on line %d", - error_part, Z_STRVAL_P(state->active_file), state->active_line); - error[length - 1] = '\0'; - efree(error_part); - } else { - length = 48 + state->start_length + Z_STRLEN_P(state->active_file); - snprintf(error, length, "Scanning error before '%s' in %s on line %d", - state->start, Z_STRVAL_P(state->active_file), state->active_line); - } + ZVAL_UNDEF(&basePath); + ZVAL_UNDEF(&completePath); + ZVAL_UNDEF(&content); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(basePath) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &basePath_param); + if (!basePath_param) { + ZEPHIR_INIT_VAR(&basePath); } else { - error = emalloc(sizeof(char) * (32 + Z_STRLEN_P(state->active_file))); - length = 32 + Z_STRLEN_P(state->active_file); - snprintf(error, length, "Scanning error near to EOF in %s", Z_STRVAL_P(state->active_file)); + zephir_get_strval(&basePath, basePath_param); + } + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "sourcePath"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkpath", NULL, 72, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&completePath); + ZEPHIR_CONCAT_VV(&completePath, &basePath, &_0); + zephir_read_property(&_2, this_ptr, ZEND_STRL("isLocal"), PH_NOISY_CC | PH_READONLY); + _3 = ZEPHIR_IS_TRUE_IDENTICAL(&_2); + if (_3) { + ZEPHIR_CALL_METHOD(&_4, this_ptr, "phpfileexists", NULL, 0, &completePath); + zephir_check_call_status(); + _3 = !ZEPHIR_IS_TRUE_IDENTICAL(&_4); + } + if (_3) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwexception", NULL, 73, &completePath); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(&content, this_ptr, "phpfilegetcontents", NULL, 0, &completePath); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&content)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwexception", NULL, 73, &completePath); + zephir_check_call_status(); } + RETURN_CCTOR(&content); +} - error[length - 1] = '\0'; - ZVAL_STRING(*error_msg, error); +static PHP_METHOD(Phalcon_Assets_Asset, getFilter) +{ - efree(error); + RETURN_MEMBER(getThis(), "filter"); } -/* }}} */ -/* {{{ phvolt_parse_view - Receives the volt code tokenizes and parses it. */ -static int phvolt_parse_view(zval *result, zval *view_code, zval *template_path) +static PHP_METHOD(Phalcon_Assets_Asset, getPath) { - zval em, *error_msg = &em; - ZVAL_NULL(result); - ZVAL_NULL(error_msg); - if (Z_TYPE_P(view_code) != IS_STRING) { - ZEPHIR_THROW_EXCEPTION_STRW(phalcon_mvc_view_exception_ce, "View code must be a string"); - return FAILURE; - } + RETURN_MEMBER(getThis(), "path"); +} - if (phvolt_internal_parse_view(&result, view_code, template_path, &error_msg) == FAILURE) { - ZEPHIR_THROW_EXCEPTION_STRW(phalcon_mvc_view_exception_ce, Z_STRVAL_P(error_msg)); - zval_dtor(error_msg); - return FAILURE; - } +static PHP_METHOD(Phalcon_Assets_Asset, getRealSourcePath) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *basePath_param = NULL, source, _0, _1, _2$$3, _3$$3; + zval basePath, _4$$3; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&basePath); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(basePath) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &basePath_param); + if (!basePath_param) { + ZEPHIR_INIT_VAR(&basePath); + } else { + zephir_get_strval(&basePath, basePath_param); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "sourcePath"); + ZEPHIR_CALL_METHOD(&source, this_ptr, "checkpath", NULL, 72, &_0); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("isLocal"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_1)) { + ZEPHIR_INIT_VAR(&_2$$3); + ZEPHIR_CONCAT_VV(&_2$$3, &basePath, &source); + ZEPHIR_CALL_FUNCTION(&_3$$3, "realpath", NULL, 74, &_2$$3); + zephir_check_call_status(); + zephir_cast_to_string(&_4$$3, &_3$$3); + ZEPHIR_CPY_WRT(&source, &_4$$3); + } + RETURN_CCTOR(&source); } -/* }}} */ -/* {{{ phvolt_parse_view - Checks whether the token has only blank characters. */ -static int phvolt_is_blank_string(phvolt_scanner_token *token) +static PHP_METHOD(Phalcon_Assets_Asset, getRealTargetPath) { - char *marker = token->value; - unsigned int ch, i; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *basePath_param = NULL, completePath, target, _0, _1, _2$$3, _3$$4; + zval basePath; + zval *this_ptr = getThis(); - for (i = 0; i < token->len; i++) { - ch = *marker; - if (ch != ' ' && ch != '\t' && ch != '\n' && ch != '\r' && ch != 11) { - return 0; + ZVAL_UNDEF(&basePath); + ZVAL_UNDEF(&completePath); + ZVAL_UNDEF(&target); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$4); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(basePath) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &basePath_param); + if (!basePath_param) { + ZEPHIR_INIT_VAR(&basePath); + } else { + zephir_get_strval(&basePath, basePath_param); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "targetPath"); + ZEPHIR_CALL_METHOD(&target, this_ptr, "checkpath", NULL, 72, &_0); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("isLocal"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_1)) { + ZEPHIR_INIT_VAR(&completePath); + ZEPHIR_CONCAT_VV(&completePath, &basePath, &target); + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "phpfileexists", NULL, 0, &completePath); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_2$$3)) { + ZEPHIR_CALL_FUNCTION(&_3$$4, "realpath", NULL, 74, &completePath); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&completePath, &_3$$4); + if (ZEPHIR_IS_FALSE_IDENTICAL(&completePath)) { + ZEPHIR_INIT_NVAR(&completePath); + ZVAL_STRING(&completePath, ""); + } } - marker++; + RETURN_CCTOR(&completePath); } - - return 1; + RETURN_CCTOR(&target); } -/* }}} */ -/* {{{ Parses a volt template returning an intermediate array representation - Checks whether the token has only blank characters. */ -static int phvolt_internal_parse_view(zval **result, zval *view_code, zval *template_path, zval **error_msg) +static PHP_METHOD(Phalcon_Assets_Asset, getRealTargetUri) { - char *error; - phvolt_scanner_state *state; - phvolt_scanner_token token; - int scanner_status, status = SUCCESS; - phvolt_parser_status *parser_status = NULL; - void* phvolt_parser; + zend_bool _2; + zval modTime, target, ver, _0, _1, _3, _4$$3, _5$$3, _6$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - /** Check if the view has code */ - if (!Z_STRVAL_P(view_code)) { - ZVAL_STRING(*error_msg, "View code cannot be null"); - return FAILURE; - } + ZVAL_UNDEF(&modTime); + ZVAL_UNDEF(&target); + ZVAL_UNDEF(&ver); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$4); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - if (!Z_STRLEN_P(view_code)) { - array_init(*result); - return SUCCESS; + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "targetUri"); + ZEPHIR_CALL_METHOD(&target, this_ptr, "checkpath", NULL, 72, &_0); + zephir_check_call_status(); + zephir_memory_observe(&ver); + zephir_read_property(&ver, this_ptr, ZEND_STRL("version"), PH_NOISY_CC); + zephir_read_property(&_1, this_ptr, ZEND_STRL("isAutoVersion"), PH_NOISY_CC | PH_READONLY); + _2 = zephir_is_true(&_1); + if (_2) { + zephir_read_property(&_3, this_ptr, ZEND_STRL("isLocal"), PH_NOISY_CC | PH_READONLY); + _2 = zephir_is_true(&_3); } - - /** Start the reentrant parser */ - phvolt_parser = phvolt_Alloc(phvolt_wrapper_alloc); - if (unlikely(!phvolt_parser)) { - ZVAL_STRING(*error_msg, "Memory allocation error"); - return FAILURE; + if (_2) { + ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "getrealsourcepath", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&modTime); + zephir_filemtime(&modTime, &_4$$3); + ZEPHIR_INIT_VAR(&_5$$3); + if (zephir_is_true(&ver)) { + ZEPHIR_INIT_NVAR(&_5$$3); + ZEPHIR_CONCAT_VSV(&_5$$3, &ver, ".", &modTime); + } else { + ZEPHIR_CPY_WRT(&_5$$3, &modTime); + } + ZEPHIR_CPY_WRT(&ver, &_5$$3); + } + if (1 != ZEPHIR_IS_EMPTY(&ver)) { + ZEPHIR_INIT_VAR(&_6$$4); + ZEPHIR_CONCAT_VSV(&_6$$4, &target, "?ver=", &ver); + ZEPHIR_CPY_WRT(&target, &_6$$4); } + RETURN_CCTOR(&target); +} - parser_status = emalloc(sizeof(phvolt_parser_status)); - state = emalloc(sizeof(phvolt_scanner_state)); +static PHP_METHOD(Phalcon_Assets_Asset, getSourcePath) +{ - parser_status->status = PHVOLT_PARSING_OK; - parser_status->scanner_state = state; - ZVAL_UNDEF(&parser_status->ret); + RETURN_MEMBER(getThis(), "sourcePath"); +} - parser_status->token = &token; - parser_status->syntax_error = NULL; +static PHP_METHOD(Phalcon_Assets_Asset, getTargetPath) +{ - /** Initialize the scanner state */ - state->active_token = 0; - state->start = Z_STRVAL_P(view_code); - state->mode = PHVOLT_MODE_RAW; - state->raw_buffer = emalloc(sizeof(char) * PHVOLT_RAW_BUFFER_SIZE); - state->raw_buffer_size = PHVOLT_RAW_BUFFER_SIZE; - state->raw_buffer_cursor = 0; - state->active_file = template_path; - state->active_line = 1; - state->statement_position = 0; - state->extends_mode = 0; - state->block_level = 0; - state->macro_level = 0; - state->start_length = 0; - state->old_if_level = 0; - state->if_level = 0; - state->for_level = 0; - state->switch_level = 0; - state->whitespace_control = 0; - state->forced_raw_state = 0; + RETURN_MEMBER(getThis(), "targetPath"); +} - state->end = state->start; +static PHP_METHOD(Phalcon_Assets_Asset, getTargetUri) +{ - token.value = NULL; - token.len = 0; + RETURN_MEMBER(getThis(), "targetUri"); +} - /* To enable parser tracing decalre "#undef NDEBUG" in the lemon file */ -#ifndef NDEBUG - phvolt_Trace(stderr, "[PARSER] "); -#endif - while (0 <= (scanner_status = phvolt_get_token(state, &token))) { +static PHP_METHOD(Phalcon_Assets_Asset, getType) +{ - state->active_token = token.opcode; + RETURN_MEMBER(getThis(), "type"); +} - state->start_length = (Z_STRVAL_P(view_code) + Z_STRLEN_P(view_code) - state->start); +static PHP_METHOD(Phalcon_Assets_Asset, getVersion) +{ - switch (token.opcode) { - case PHVOLT_T_IGNORE: - break; + RETURN_MEMBER(getThis(), "version"); +} - case PHVOLT_T_ADD: - phvolt_(phvolt_parser, PHVOLT_PLUS, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Asset, isAutoVersion) +{ - case PHVOLT_T_SUB: - phvolt_(phvolt_parser, PHVOLT_MINUS, NULL, parser_status); - break; + RETURN_MEMBER(getThis(), "isAutoVersion"); +} - case PHVOLT_T_MUL: - phvolt_(phvolt_parser, PHVOLT_TIMES, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Asset, isLocal) +{ - case PHVOLT_T_DIV: - phvolt_(phvolt_parser, PHVOLT_DIVIDE, NULL, parser_status); - break; + RETURN_MEMBER(getThis(), "isLocal"); +} - case PHVOLT_T_MOD: - phvolt_(phvolt_parser, PHVOLT_MOD, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Asset, setAttributes) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *attributes_param = NULL; + zval attributes; + zval *this_ptr = getThis(); - case PHVOLT_T_AND: - phvolt_(phvolt_parser, PHVOLT_AND, NULL, parser_status); - break; + ZVAL_UNDEF(&attributes); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &attributes_param); + zephir_get_arrval(&attributes, attributes_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &attributes); + RETURN_THIS(); +} - case PHVOLT_T_OR: - phvolt_(phvolt_parser, PHVOLT_OR, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Asset, setAutoVersion) +{ + zval *flag_param = NULL, __$true, __$false; + zend_bool flag; + zval *this_ptr = getThis(); - case PHVOLT_T_IS: - phvolt_(phvolt_parser, PHVOLT_IS, NULL, parser_status); - break; + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(flag) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &flag_param); + if (flag) { + zephir_update_property_zval(this_ptr, ZEND_STRL("isAutoVersion"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("isAutoVersion"), &__$false); + } + RETURN_THISW(); +} - case PHVOLT_T_EQUALS: - phvolt_(phvolt_parser, PHVOLT_EQUALS, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Asset, setFilter) +{ + zval *filter_param = NULL, __$true, __$false; + zend_bool filter; + zval *this_ptr = getThis(); - case PHVOLT_T_NOTEQUALS: - phvolt_(phvolt_parser, PHVOLT_NOTEQUALS, NULL, parser_status); - break; + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(filter) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &filter_param); + if (filter) { + zephir_update_property_zval(this_ptr, ZEND_STRL("filter"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("filter"), &__$false); + } + RETURN_THISW(); +} - case PHVOLT_T_LESS: - phvolt_(phvolt_parser, PHVOLT_LESS, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Asset, setIsLocal) +{ + zval *flag_param = NULL, __$true, __$false; + zend_bool flag; + zval *this_ptr = getThis(); - case PHVOLT_T_GREATER: - phvolt_(phvolt_parser, PHVOLT_GREATER, NULL, parser_status); - break; + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(flag) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &flag_param); + if (flag) { + zephir_update_property_zval(this_ptr, ZEND_STRL("isLocal"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("isLocal"), &__$false); + } + RETURN_THISW(); +} - case PHVOLT_T_GREATEREQUAL: - phvolt_(phvolt_parser, PHVOLT_GREATEREQUAL, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Asset, setSourcePath) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *sourcePath_param = NULL; + zval sourcePath; + zval *this_ptr = getThis(); - case PHVOLT_T_LESSEQUAL: - phvolt_(phvolt_parser, PHVOLT_LESSEQUAL, NULL, parser_status); - break; + ZVAL_UNDEF(&sourcePath); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(sourcePath) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &sourcePath_param); + zephir_get_strval(&sourcePath, sourcePath_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("sourcePath"), &sourcePath); + RETURN_THIS(); +} - case PHVOLT_T_IDENTICAL: - phvolt_(phvolt_parser, PHVOLT_IDENTICAL, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Asset, setTargetPath) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *targetPath_param = NULL; + zval targetPath; + zval *this_ptr = getThis(); - case PHVOLT_T_NOTIDENTICAL: - phvolt_(phvolt_parser, PHVOLT_NOTIDENTICAL, NULL, parser_status); - break; + ZVAL_UNDEF(&targetPath); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(targetPath) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &targetPath_param); + zephir_get_strval(&targetPath, targetPath_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("targetPath"), &targetPath); + RETURN_THIS(); +} - case PHVOLT_T_NOT: - phvolt_(phvolt_parser, PHVOLT_NOT, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Asset, setTargetUri) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *targetUri_param = NULL; + zval targetUri; + zval *this_ptr = getThis(); - case PHVOLT_T_DOT: - phvolt_(phvolt_parser, PHVOLT_DOT, NULL, parser_status); - break; + ZVAL_UNDEF(&targetUri); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(targetUri) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &targetUri_param); + zephir_get_strval(&targetUri, targetUri_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("targetUri"), &targetUri); + RETURN_THIS(); +} - case PHVOLT_T_CONCAT: - phvolt_(phvolt_parser, PHVOLT_CONCAT, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Asset, setType) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *type_param = NULL; + zval type; + zval *this_ptr = getThis(); - case PHVOLT_T_RANGE: - phvolt_(phvolt_parser, PHVOLT_RANGE, NULL, parser_status); - break; + ZVAL_UNDEF(&type); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(type) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &type_param); + zephir_get_strval(&type, type_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &type); + RETURN_THIS(); +} - case PHVOLT_T_PIPE: - phvolt_(phvolt_parser, PHVOLT_PIPE, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Asset, setPath) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *path_param = NULL; + zval path; + zval *this_ptr = getThis(); - case PHVOLT_T_COMMA: - phvolt_(phvolt_parser, PHVOLT_COMMA, NULL, parser_status); - break; + ZVAL_UNDEF(&path); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(path) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &path_param); + zephir_get_strval(&path, path_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("path"), &path); + RETURN_THIS(); +} - case PHVOLT_T_COLON: - phvolt_(phvolt_parser, PHVOLT_COLON, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Asset, setVersion) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *version_param = NULL; + zval version; + zval *this_ptr = getThis(); - case PHVOLT_T_QUESTION: - phvolt_(phvolt_parser, PHVOLT_QUESTION, NULL, parser_status); - break; + ZVAL_UNDEF(&version); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(version) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &version_param); + zephir_get_strval(&version, version_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("version"), &version); + RETURN_THIS(); +} - case PHVOLT_T_PARENTHESES_OPEN: - phvolt_(phvolt_parser, PHVOLT_PARENTHESES_OPEN, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Asset, checkPath) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *property_param = NULL, _0, _1; + zval property; + zval *this_ptr = getThis(); - case PHVOLT_T_PARENTHESES_CLOSE: - phvolt_(phvolt_parser, PHVOLT_PARENTHESES_CLOSE, NULL, parser_status); - break; + ZVAL_UNDEF(&property); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(property) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &property_param); + zephir_get_strval(&property, property_param); + zephir_memory_observe(&_0); + zephir_read_property_zval(&_0, this_ptr, &property, PH_NOISY_CC); + if (1 == ZEPHIR_IS_EMPTY(&_0)) { + RETURN_MM_MEMBER(getThis(), "path"); + } + zephir_memory_observe(&_1); + zephir_read_property_zval(&_1, this_ptr, &property, PH_NOISY_CC); + RETURN_CCTOR(&_1); +} - case PHVOLT_T_SBRACKET_OPEN: - phvolt_(phvolt_parser, PHVOLT_SBRACKET_OPEN, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Asset, throwException) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *completePath_param = NULL, _0; + zval completePath, _1; - case PHVOLT_T_SBRACKET_CLOSE: - phvolt_(phvolt_parser, PHVOLT_SBRACKET_CLOSE, NULL, parser_status); - break; + ZVAL_UNDEF(&completePath); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(completePath) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &completePath_param); + zephir_get_strval(&completePath, completePath_param); + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, phalcon_assets_exception_ce); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_SVS(&_1, "Asset's content for '", &completePath, "' cannot be read"); + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 33, &_1); + zephir_check_call_status(); + zephir_throw_exception_debug(&_0, "phalcon/Assets/Asset.zep", 472); + ZEPHIR_MM_RESTORE(); + return; +} - case PHVOLT_T_CBRACKET_OPEN: - phvolt_(phvolt_parser, PHVOLT_CBRACKET_OPEN, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Asset, phpFileExists) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *filename_param = NULL; + zval filename; - case PHVOLT_T_CBRACKET_CLOSE: - phvolt_(phvolt_parser, PHVOLT_CBRACKET_CLOSE, NULL, parser_status); - break; + ZVAL_UNDEF(&filename); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(filename) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &filename_param); + zephir_get_strval(&filename, filename_param); + RETURN_MM_BOOL((zephir_file_exists(&filename) == SUCCESS)); +} - case PHVOLT_T_OPEN_DELIMITER: - phvolt_(phvolt_parser, PHVOLT_OPEN_DELIMITER, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Asset, phpFileGetContents) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *filename_param = NULL; + zval filename; - case PHVOLT_T_CLOSE_DELIMITER: - phvolt_(phvolt_parser, PHVOLT_CLOSE_DELIMITER, NULL, parser_status); - break; + ZVAL_UNDEF(&filename); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(filename) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &filename_param); + zephir_get_strval(&filename, filename_param); + zephir_file_get_contents(return_value, &filename); + RETURN_MM(); +} - case PHVOLT_T_OPEN_EDELIMITER: - if (state->extends_mode == 1 && state->block_level == 0) { - phvolt_create_error_msg(parser_status, "Child templates only may contain blocks"); - parser_status->status = PHVOLT_PARSING_FAILED; - break; - } - phvolt_(phvolt_parser, PHVOLT_OPEN_EDELIMITER, NULL, parser_status); - break; - case PHVOLT_T_CLOSE_EDELIMITER: - phvolt_(phvolt_parser, PHVOLT_CLOSE_EDELIMITER, NULL, parser_status); - break; - case PHVOLT_T_NULL: - phvolt_(phvolt_parser, PHVOLT_NULL, NULL, parser_status); - break; - case PHVOLT_T_TRUE: - phvolt_(phvolt_parser, PHVOLT_TRUE, NULL, parser_status); - break; +#ifdef HAVE_CONFIG_H +#endif - case PHVOLT_T_FALSE: - phvolt_(phvolt_parser, PHVOLT_FALSE, NULL, parser_status); - break; - case PHVOLT_T_INTEGER: - phvolt_parse_with_token(phvolt_parser, PHVOLT_T_INTEGER, PHVOLT_INTEGER, &token, parser_status); - break; - case PHVOLT_T_DOUBLE: - phvolt_parse_with_token(phvolt_parser, PHVOLT_T_DOUBLE, PHVOLT_DOUBLE, &token, parser_status); - break; - case PHVOLT_T_STRING: - phvolt_parse_with_token(phvolt_parser, PHVOLT_T_STRING, PHVOLT_STRING, &token, parser_status); - break; - case PHVOLT_T_IDENTIFIER: - phvolt_parse_with_token(phvolt_parser, PHVOLT_T_IDENTIFIER, PHVOLT_IDENTIFIER, &token, parser_status); - break; +ZEPHIR_INIT_CLASS(Phalcon_Assets_AssetInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Assets, AssetInterface, phalcon, assets_assetinterface, phalcon_assets_assetinterface_method_entry); - case PHVOLT_T_IF: - if (state->extends_mode == 1 && state->block_level == 0){ - phvolt_create_error_msg(parser_status, "Child templates only may contain blocks"); - parser_status->status = PHVOLT_PARSING_FAILED; - break; - } else { - state->if_level++; - state->block_level++; - } - phvolt_(phvolt_parser, PHVOLT_IF, NULL, parser_status); - break; + return SUCCESS; +} - case PHVOLT_T_ELSE: - if (state->if_level == 0 && state->for_level > 0) { - phvolt_(phvolt_parser, PHVOLT_ELSEFOR, NULL, parser_status); - } else { - phvolt_(phvolt_parser, PHVOLT_ELSE, NULL, parser_status); - } - break; +ZEPHIR_DOC_METHOD(Phalcon_Assets_AssetInterface, getAssetKey); +ZEPHIR_DOC_METHOD(Phalcon_Assets_AssetInterface, getAttributes); +ZEPHIR_DOC_METHOD(Phalcon_Assets_AssetInterface, getFilter); +ZEPHIR_DOC_METHOD(Phalcon_Assets_AssetInterface, getType); +ZEPHIR_DOC_METHOD(Phalcon_Assets_AssetInterface, setAttributes); +ZEPHIR_DOC_METHOD(Phalcon_Assets_AssetInterface, setFilter); +ZEPHIR_DOC_METHOD(Phalcon_Assets_AssetInterface, setType); - case PHVOLT_T_ELSEFOR: - phvolt_(phvolt_parser, PHVOLT_ELSEFOR, NULL, parser_status); - break; - case PHVOLT_T_ELSEIF: - if (state->if_level == 0) { - phvolt_create_error_msg(parser_status, "Unexpected ENDIF"); - parser_status->status = PHVOLT_PARSING_FAILED; - break; - } - phvolt_(phvolt_parser, PHVOLT_ELSEIF, NULL, parser_status); - break; - case PHVOLT_T_ENDIF: - state->block_level--; - state->if_level--; - phvolt_(phvolt_parser, PHVOLT_ENDIF, NULL, parser_status); - break; +#ifdef HAVE_CONFIG_H +#endif - case PHVOLT_T_FOR: - if (state->extends_mode == 1 && state->block_level == 0){ - phvolt_create_error_msg(parser_status, "Child templates only may contain blocks"); - parser_status->status = PHVOLT_PARSING_FAILED; - break; - } else { - state->old_if_level = state->if_level; - state->if_level = 0; - state->for_level++; - state->block_level++; - } - phvolt_(phvolt_parser, PHVOLT_FOR, NULL, parser_status); - break; - case PHVOLT_T_IN: - phvolt_(phvolt_parser, PHVOLT_IN, NULL, parser_status); - break; - case PHVOLT_T_ENDFOR: - state->block_level--; - state->for_level--; - state->if_level = state->old_if_level; - phvolt_(phvolt_parser, PHVOLT_ENDFOR, NULL, parser_status); - break; - case PHVOLT_T_SWITCH: - if (state->extends_mode == 1 && state->block_level == 0){ - phvolt_create_error_msg(parser_status, "Child templates only may contain blocks"); - parser_status->status = PHVOLT_PARSING_FAILED; - break; - } else if (state->switch_level > 0) { - phvolt_create_error_msg(parser_status, "A nested switch detected. There is no nested switch-case statements support"); - parser_status->status = PHVOLT_PARSING_FAILED; - break; - } else { - state->switch_level = 1; - state->block_level++; - } - phvolt_(phvolt_parser, PHVOLT_SWITCH, NULL, parser_status); - break; - case PHVOLT_T_CASE: - if (state->switch_level == 0) { - phvolt_create_error_msg(parser_status, "Unexpected CASE"); - parser_status->status = PHVOLT_PARSING_FAILED; - break; - } - phvolt_(phvolt_parser, PHVOLT_CASE, NULL, parser_status); - break; +ZEPHIR_INIT_CLASS(Phalcon_Assets_Collection) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Assets, Collection, phalcon, assets_collection, phalcon_assets_collection_method_entry, 0); - /* only for switch-case statements */ - case PHVOLT_T_DEFAULT: - if (state->switch_level != 0) { - phvolt_(phvolt_parser, PHVOLT_DEFAULT, NULL, parser_status); - efree(token.value); - } else { - phvolt_parse_with_token(phvolt_parser, PHVOLT_T_IDENTIFIER, PHVOLT_IDENTIFIER, &token, parser_status); - } + zend_declare_property_null(phalcon_assets_collection_ce, SL("assets"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_assets_collection_ce, SL("attributes"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_assets_collection_ce, SL("autoVersion"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_assets_collection_ce, SL("codes"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_assets_collection_ce, SL("filters"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_assets_collection_ce, SL("isLocal"), 1, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_assets_collection_ce, SL("join"), 1, ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_assets_collection_ce, SL("prefix"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_assets_collection_ce, SL("sourcePath"), "", ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_assets_collection_ce, SL("targetIsLocal"), 1, ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_assets_collection_ce, SL("targetPath"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_assets_collection_ce, SL("targetUri"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_assets_collection_ce, SL("version"), "", ZEND_ACC_PROTECTED); + phalcon_assets_collection_ce->create_object = zephir_init_properties_Phalcon_Assets_Collection; - break; + zend_class_implements(phalcon_assets_collection_ce, 1, zend_ce_countable); + zend_class_implements(phalcon_assets_collection_ce, 1, zend_ce_aggregate); + return SUCCESS; +} - case PHVOLT_T_ENDSWITCH: - if (state->switch_level == 0) { - phvolt_create_error_msg(parser_status, "Unexpected ENDSWITCH"); - parser_status->status = PHVOLT_PARSING_FAILED; - break; - } else { - state->switch_level = 0; - state->block_level--; - } +static PHP_METHOD(Phalcon_Assets_Collection, add) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *asset, asset_sub; + zval *this_ptr = getThis(); - phvolt_(phvolt_parser, PHVOLT_ENDSWITCH, NULL, parser_status); - break; + ZVAL_UNDEF(&asset_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(asset, phalcon_assets_assetinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &asset); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addasset", NULL, 167, asset); + zephir_check_call_status(); + RETURN_THIS(); +} - case PHVOLT_T_RAW_FRAGMENT: - if (token.len > 0) { - if (state->extends_mode == 1 && state->block_level == 0){ - if (!phvolt_is_blank_string(&token)) { - phvolt_create_error_msg(parser_status, "Child templates only may contain blocks"); - parser_status->status = PHVOLT_PARSING_FAILED; - } - efree(token.value); - break; - } else { - if (!phvolt_is_blank_string(&token)) { - state->statement_position++; - } - } - phvolt_parse_with_token(phvolt_parser, PHVOLT_T_RAW_FRAGMENT, PHVOLT_RAW_FRAGMENT, &token, parser_status); - } else { - efree(token.value); - } - break; +static PHP_METHOD(Phalcon_Assets_Collection, addCss) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval attributes; + zend_bool filter, autoVersion; + zval *path_param = NULL, *isLocal = NULL, isLocal_sub, *filter_param = NULL, *attributes_param = NULL, *version_param = NULL, *autoVersion_param = NULL, __$null, _0, _1, _2; + zval path, version; + zval *this_ptr = getThis(); - case PHVOLT_T_SET: - if (state->extends_mode == 1 && state->block_level == 0){ - phvolt_create_error_msg(parser_status, "Child templates only may contain blocks"); - parser_status->status = PHVOLT_PARSING_FAILED; - break; - } - phvolt_(phvolt_parser, PHVOLT_SET, NULL, parser_status); - break; + ZVAL_UNDEF(&path); + ZVAL_UNDEF(&version); + ZVAL_UNDEF(&isLocal_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&attributes); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 6) + Z_PARAM_STR(path) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(isLocal) + Z_PARAM_BOOL(filter) + Z_PARAM_ARRAY(attributes) + Z_PARAM_STR_OR_NULL(version) + Z_PARAM_BOOL(autoVersion) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 5, &path_param, &isLocal, &filter_param, &attributes_param, &version_param, &autoVersion_param); + zephir_get_strval(&path, path_param); + if (!isLocal) { + isLocal = &isLocal_sub; + isLocal = &__$null; + } + if (!filter_param) { + filter = 1; + } else { + } + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + if (!version_param) { + ZEPHIR_INIT_VAR(&version); + } else { + zephir_get_strval(&version, version_param); + } + if (!autoVersion_param) { + autoVersion = 0; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "Css"); + if (filter) { + ZVAL_BOOL(&_1, 1); + } else { + ZVAL_BOOL(&_1, 0); + } + if (autoVersion) { + ZVAL_BOOL(&_2, 1); + } else { + ZVAL_BOOL(&_2, 0); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "processadd", NULL, 168, &_0, &path, isLocal, &_1, &attributes, &version, &_2); + zephir_check_call_status(); + RETURN_MM(); +} - case PHVOLT_T_ASSIGN: - phvolt_(phvolt_parser, PHVOLT_ASSIGN, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Collection, addFilter) +{ + zval *filter, filter_sub; + zval *this_ptr = getThis(); - case PHVOLT_T_ADD_ASSIGN: - phvolt_(phvolt_parser, PHVOLT_ADD_ASSIGN, NULL, parser_status); - break; + ZVAL_UNDEF(&filter_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(filter, phalcon_assets_filterinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &filter); + zephir_update_property_array_append(this_ptr, SL("filters"), filter); + RETURN_THISW(); +} - case PHVOLT_T_SUB_ASSIGN: - phvolt_(phvolt_parser, PHVOLT_SUB_ASSIGN, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Collection, addInline) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *code, code_sub; + zval *this_ptr = getThis(); - case PHVOLT_T_MUL_ASSIGN: - phvolt_(phvolt_parser, PHVOLT_MUL_ASSIGN, NULL, parser_status); - break; + ZVAL_UNDEF(&code_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(code, phalcon_assets_inline_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &code); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addasset", NULL, 167, code); + zephir_check_call_status(); + RETURN_THIS(); +} - case PHVOLT_T_DIV_ASSIGN: - phvolt_(phvolt_parser, PHVOLT_DIV_ASSIGN, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Collection, addInlineCss) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval attributes; + zend_bool filter; + zval *content_param = NULL, *filter_param = NULL, *attributes_param = NULL, _0, _1; + zval content; + zval *this_ptr = getThis(); - case PHVOLT_T_INCR: - phvolt_(phvolt_parser, PHVOLT_INCR, NULL, parser_status); - break; + ZVAL_UNDEF(&content); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&attributes); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(content) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(filter) + Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &content_param, &filter_param, &attributes_param); + zephir_get_strval(&content, content_param); + if (!filter_param) { + filter = 1; + } else { + } + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "Css"); + if (filter) { + ZVAL_BOOL(&_1, 1); + } else { + ZVAL_BOOL(&_1, 0); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "processaddinline", NULL, 169, &_0, &content, &_1, &attributes); + zephir_check_call_status(); + RETURN_MM(); +} - case PHVOLT_T_DECR: - phvolt_(phvolt_parser, PHVOLT_DECR, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Collection, addInlineJs) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval attributes; + zend_bool filter; + zval *content_param = NULL, *filter_param = NULL, *attributes_param = NULL, _0, _1; + zval content; + zval *this_ptr = getThis(); - case PHVOLT_T_BLOCK: - if (state->block_level > 0) { - phvolt_create_error_msg(parser_status, "Embedding blocks into other blocks is not supported"); - parser_status->status = PHVOLT_PARSING_FAILED; - break; - } else { - state->block_level++; - } - phvolt_(phvolt_parser, PHVOLT_BLOCK, NULL, parser_status); - break; + ZVAL_UNDEF(&content); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&attributes); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(content) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(filter) + Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &content_param, &filter_param, &attributes_param); + zephir_get_strval(&content, content_param); + if (!filter_param) { + filter = 1; + } else { + } + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "Js"); + if (filter) { + ZVAL_BOOL(&_1, 1); + } else { + ZVAL_BOOL(&_1, 0); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "processaddinline", NULL, 169, &_0, &content, &_1, &attributes); + zephir_check_call_status(); + RETURN_MM(); +} - case PHVOLT_T_ENDBLOCK: - state->block_level--; - phvolt_(phvolt_parser, PHVOLT_ENDBLOCK, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Collection, addJs) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval attributes; + zend_bool filter, autoVersion; + zval *path_param = NULL, *isLocal = NULL, isLocal_sub, *filter_param = NULL, *attributes_param = NULL, *version_param = NULL, *autoVersion_param = NULL, __$null, _0, _1, _2; + zval path, version; + zval *this_ptr = getThis(); - case PHVOLT_T_MACRO: - if (state->macro_level > 0) { - phvolt_create_error_msg(parser_status, "Embedding macros into other macros is not allowed"); - parser_status->status = PHVOLT_PARSING_FAILED; - break; - } else { - state->macro_level++; - } - phvolt_(phvolt_parser, PHVOLT_MACRO, NULL, parser_status); - break; - case PHVOLT_T_ENDMACRO: - state->macro_level--; - phvolt_(phvolt_parser, PHVOLT_ENDMACRO, NULL, parser_status); - break; + ZVAL_UNDEF(&path); + ZVAL_UNDEF(&version); + ZVAL_UNDEF(&isLocal_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&attributes); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 6) + Z_PARAM_STR(path) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(isLocal) + Z_PARAM_BOOL(filter) + Z_PARAM_ARRAY(attributes) + Z_PARAM_STR_OR_NULL(version) + Z_PARAM_BOOL(autoVersion) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 5, &path_param, &isLocal, &filter_param, &attributes_param, &version_param, &autoVersion_param); + zephir_get_strval(&path, path_param); + if (!isLocal) { + isLocal = &isLocal_sub; + isLocal = &__$null; + } + if (!filter_param) { + filter = 1; + } else { + } + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + if (!version_param) { + ZEPHIR_INIT_VAR(&version); + } else { + zephir_get_strval(&version, version_param); + } + if (!autoVersion_param) { + autoVersion = 0; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "Js"); + if (filter) { + ZVAL_BOOL(&_1, 1); + } else { + ZVAL_BOOL(&_1, 0); + } + if (autoVersion) { + ZVAL_BOOL(&_2, 1); + } else { + ZVAL_BOOL(&_2, 0); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "processadd", NULL, 168, &_0, &path, isLocal, &_1, &attributes, &version, &_2); + zephir_check_call_status(); + RETURN_MM(); +} - case PHVOLT_T_CALL: - phvolt_(phvolt_parser, PHVOLT_CALL, NULL, parser_status); - break; - case PHVOLT_T_ENDCALL: - phvolt_(phvolt_parser, PHVOLT_ENDCALL, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Collection, count) +{ + zval _0; + zval *this_ptr = getThis(); - case PHVOLT_T_CACHE: - phvolt_(phvolt_parser, PHVOLT_CACHE, NULL, parser_status); - break; - case PHVOLT_T_ENDCACHE: - phvolt_(phvolt_parser, PHVOLT_ENDCACHE, NULL, parser_status); - break; + ZVAL_UNDEF(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("assets"), PH_NOISY_CC | PH_READONLY); + RETURN_LONG(zephir_fast_count_int(&_0)); +} - case PHVOLT_T_RAW: - phvolt_(phvolt_parser, PHVOLT_RAW, NULL, parser_status); - state->forced_raw_state++; - break; - case PHVOLT_T_ENDRAW: - phvolt_(phvolt_parser, PHVOLT_ENDRAW, NULL, parser_status); - state->forced_raw_state--; - break; +static PHP_METHOD(Phalcon_Assets_Collection, getAssets) +{ - case PHVOLT_T_INCLUDE: - phvolt_(phvolt_parser, PHVOLT_INCLUDE, NULL, parser_status); - break; + RETURN_MEMBER(getThis(), "assets"); +} - case PHVOLT_T_WITH: - phvolt_(phvolt_parser, PHVOLT_WITH, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Collection, getAttributes) +{ - case PHVOLT_T_DEFINED: - phvolt_(phvolt_parser, PHVOLT_DEFINED, NULL, parser_status); - break; + RETURN_MEMBER(getThis(), "attributes"); +} - case PHVOLT_T_EMPTY: - phvolt_(phvolt_parser, PHVOLT_EMPTY, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Collection, getCodes) +{ - case PHVOLT_T_EVEN: - phvolt_(phvolt_parser, PHVOLT_EVEN, NULL, parser_status); - break; + RETURN_MEMBER(getThis(), "codes"); +} - case PHVOLT_T_ODD: - phvolt_(phvolt_parser, PHVOLT_ODD, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Collection, getFilters) +{ - case PHVOLT_T_NUMERIC: - phvolt_(phvolt_parser, PHVOLT_NUMERIC, NULL, parser_status); - break; + RETURN_MEMBER(getThis(), "filters"); +} - case PHVOLT_T_SCALAR: - phvolt_(phvolt_parser, PHVOLT_SCALAR, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Collection, getIterator) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - case PHVOLT_T_ITERABLE: - phvolt_(phvolt_parser, PHVOLT_ITERABLE, NULL, parser_status); - break; + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - case PHVOLT_T_DO: - phvolt_(phvolt_parser, PHVOLT_DO, NULL, parser_status); - break; - case PHVOLT_T_RETURN: - phvolt_(phvolt_parser, PHVOLT_RETURN, NULL, parser_status); - break; + object_init_ex(return_value, spl_ce_ArrayIterator); + zephir_read_property(&_0, this_ptr, ZEND_STRL("assets"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 13, &_0); + zephir_check_call_status(); + RETURN_MM(); +} - case PHVOLT_T_AUTOESCAPE: - phvolt_(phvolt_parser, PHVOLT_AUTOESCAPE, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Collection, getJoin) +{ - case PHVOLT_T_ENDAUTOESCAPE: - phvolt_(phvolt_parser, PHVOLT_ENDAUTOESCAPE, NULL, parser_status); - break; + RETURN_MEMBER(getThis(), "join"); +} - case PHVOLT_T_BREAK: - phvolt_(phvolt_parser, PHVOLT_BREAK, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Collection, getPrefix) +{ - case PHVOLT_T_CONTINUE: - phvolt_(phvolt_parser, PHVOLT_CONTINUE, NULL, parser_status); - break; + RETURN_MEMBER(getThis(), "prefix"); +} - case PHVOLT_T_EXTENDS: - if (state->statement_position != 1) { - phvolt_create_error_msg(parser_status, "Extends statement must be placed at the first line in the template"); - parser_status->status = PHVOLT_PARSING_FAILED; - break; - } else { - state->extends_mode = 1; - } - phvolt_(phvolt_parser, PHVOLT_EXTENDS, NULL, parser_status); - break; +static PHP_METHOD(Phalcon_Assets_Collection, getRealTargetPath) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *basePath_param = NULL, completePath, _0; + zval basePath; + zval *this_ptr = getThis(); - default: - parser_status->status = PHVOLT_PARSING_FAILED; - error = emalloc(sizeof(char) * (48 + Z_STRLEN_P(state->active_file))); - snprintf(error, 48 + Z_STRLEN_P(state->active_file) + state->active_line, - "Scanner: unknown opcode %d on in %s line %d", token.opcode, - Z_STRVAL_P(state->active_file), state->active_line); + ZVAL_UNDEF(&basePath); + ZVAL_UNDEF(&completePath); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(basePath) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &basePath_param); + if (UNEXPECTED(Z_TYPE_P(basePath_param) != IS_STRING && Z_TYPE_P(basePath_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'basePath' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(basePath_param) == IS_STRING)) { + zephir_get_strval(&basePath, basePath_param); + } else { + ZEPHIR_INIT_VAR(&basePath); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("targetPath"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&completePath); + ZEPHIR_CONCAT_VV(&completePath, &basePath, &_0); + if (1 == (zephir_file_exists(&completePath) == SUCCESS)) { + ZEPHIR_RETURN_CALL_FUNCTION("realpath", NULL, 74, &completePath); + zephir_check_call_status(); + RETURN_MM(); + } + RETURN_CCTOR(&completePath); +} - if (Z_TYPE_P(*error_msg) == IS_NULL) { - ZVAL_STRING((*error_msg), error); - } +static PHP_METHOD(Phalcon_Assets_Collection, getSourcePath) +{ - efree(error); - break; - } + RETURN_MEMBER(getThis(), "sourcePath"); +} - if (parser_status->status != PHVOLT_PARSING_OK) { - status = FAILURE; - break; - } +static PHP_METHOD(Phalcon_Assets_Collection, getTargetIsLocal) +{ - state->end = state->start; - } + RETURN_MEMBER(getThis(), "targetIsLocal"); +} - if (status != FAILURE) { - switch (scanner_status) { - case PHVOLT_SCANNER_RETCODE_ERR: - case PHVOLT_SCANNER_RETCODE_IMPOSSIBLE: - if (!*error_msg) { - phvolt_scanner_error_msg(parser_status, error_msg); - } else { - if (Z_TYPE_P(*error_msg) == IS_NULL) { - phvolt_scanner_error_msg(parser_status, error_msg); - } - } - status = FAILURE; - break; - default: - phvolt_(phvolt_parser, 0, NULL, parser_status); - } - } +static PHP_METHOD(Phalcon_Assets_Collection, getTargetPath) +{ - state->active_token = 0; - state->start = NULL; - efree(state->raw_buffer); + RETURN_MEMBER(getThis(), "targetPath"); +} - if (parser_status->status != PHVOLT_PARSING_OK) { - status = FAILURE; - if (parser_status->syntax_error) { - ZVAL_STRING(*error_msg, parser_status->syntax_error); - efree(parser_status->syntax_error); - } - } +static PHP_METHOD(Phalcon_Assets_Collection, getTargetUri) +{ - if (status != FAILURE) { - if (parser_status->status == PHVOLT_PARSING_OK) { - if (Z_TYPE(parser_status->ret) != IS_UNDEF) { - ZVAL_ZVAL(*result, &parser_status->ret, 1, 1); - } else { - array_init(*result); - } - } - } + RETURN_MEMBER(getThis(), "targetUri"); +} - phvolt_Free(phvolt_parser, phvolt_wrapper_free); +static PHP_METHOD(Phalcon_Assets_Collection, getVersion) +{ - efree(parser_status); - efree(state); + RETURN_MEMBER(getThis(), "version"); +} - return status; +static PHP_METHOD(Phalcon_Assets_Collection, has) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *asset, asset_sub, key, storedAsset, _0, *_1, _2, _3$$3, _4$$5; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&asset_sub); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&storedAsset); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$5); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(asset, phalcon_assets_assetinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &asset); + ZEPHIR_CALL_METHOD(&key, asset, "getassetkey", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("assets"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_0, 0, "phalcon/Assets/Collection.zep", 381); + if (Z_TYPE_P(&_0) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) + { + ZEPHIR_INIT_NVAR(&storedAsset); + ZVAL_COPY(&storedAsset, _1); + ZEPHIR_CALL_METHOD(&_3$$3, &storedAsset, "getassetkey", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_IDENTICAL(&key, &_3$$3)) { + RETURN_MM_BOOL(1); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&storedAsset, &_0, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4$$5, &storedAsset, "getassetkey", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_IDENTICAL(&key, &_4$$5)) { + RETURN_MM_BOOL(1); + } + ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&storedAsset); + RETURN_MM_BOOL(0); } -/* }}} */ - +static PHP_METHOD(Phalcon_Assets_Collection, isAutoVersion) +{ -/* Generated by re2c 1.1.1 */ -/* scanner.re - * - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the - * LICENSE.txt file that was distributed with this source code. - */ + RETURN_MEMBER(getThis(), "autoVersion"); +} +static PHP_METHOD(Phalcon_Assets_Collection, isLocal) +{ -/* for re2c */ -#define VVCTYPE unsigned char -#define VVCURSOR (s->start) -#define VVLIMIT (s->end) -#define VVMARKER (s->marker) + RETURN_MEMBER(getThis(), "isLocal"); +} -static void phvolt_rtrim(phvolt_scanner_token *token) { +static PHP_METHOD(Phalcon_Assets_Collection, join) +{ + zval *flag_param = NULL, __$true, __$false; + zend_bool flag; + zval *this_ptr = getThis(); - char *cursor, *removed_str; - int i; - char ch; + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(flag) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &flag_param); + if (flag) { + zephir_update_property_zval(this_ptr, ZEND_STRL("join"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("join"), &__$false); + } + RETURN_THISW(); +} - if (token->len > 0) { +static PHP_METHOD(Phalcon_Assets_Collection, setAttributes) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *attributes_param = NULL; + zval attributes; + zval *this_ptr = getThis(); - cursor = token->value; - cursor += (token->len - 1); - for (i = token->len; i > 0; i--) { - ch = (*cursor); - if (ch == '\t' || ch == '\n' || ch == '\r' || ch == ' ' || ch == '\v') { - cursor--; - continue; - } - break; - } + ZVAL_UNDEF(&attributes); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &attributes_param); + zephir_get_arrval(&attributes, attributes_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &attributes); + RETURN_THIS(); +} - if (i >= 0) { - removed_str = emalloc(i + 1); - memcpy(removed_str, token->value, i); - removed_str[i] = '\0'; +static PHP_METHOD(Phalcon_Assets_Collection, setAutoVersion) +{ + zval *flag_param = NULL, __$true, __$false; + zend_bool flag; + zval *this_ptr = getThis(); - efree(token->value); - token->value = removed_str; - token->len = i; - } + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(flag) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &flag_param); + if (flag) { + zephir_update_property_zval(this_ptr, ZEND_STRL("autoVersion"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("autoVersion"), &__$false); } - + RETURN_THISW(); } -static void phvolt_ltrim(phvolt_scanner_token *token) { - - char *cursor, *removed_str; - int i; - - if (token->len > 0) { +static PHP_METHOD(Phalcon_Assets_Collection, setFilters) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *filters_param = NULL; + zval filters; + zval *this_ptr = getThis(); - cursor = token->value; - for (i = 0; i < token->len; i++) { - char ch = (*cursor); - if (ch == '\t' || ch == '\n' || ch == '\r' || ch == ' ' || ch == '\v') { - cursor++; - continue; - } - break; - } + ZVAL_UNDEF(&filters); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(filters) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &filters_param); + zephir_get_arrval(&filters, filters_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("filters"), &filters); + RETURN_THIS(); +} - if (i >= 0) { - removed_str = emalloc(token->len - i + 1); - memcpy(removed_str, token->value + i, token->len - i); - removed_str[token->len - i] = '\0'; +static PHP_METHOD(Phalcon_Assets_Collection, setIsLocal) +{ + zval *flag_param = NULL, __$true, __$false; + zend_bool flag; + zval *this_ptr = getThis(); - efree(token->value); - token->value = removed_str; - token->len = token->len - i; - } + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(flag) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &flag_param); + if (flag) { + zephir_update_property_zval(this_ptr, ZEND_STRL("isLocal"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("isLocal"), &__$false); } - + RETURN_THISW(); } -static int phvolt_get_token(phvolt_scanner_state *s, phvolt_scanner_token *token) { - unsigned char next, double_next; - char *start = VVCURSOR; - int status = PHVOLT_SCANNER_RETCODE_IMPOSSIBLE; - - while (PHVOLT_SCANNER_RETCODE_IMPOSSIBLE == status) { - if (s->mode == PHVOLT_MODE_RAW || s->mode == PHVOLT_MODE_COMMENT) { - next = '\0'; - double_next = '\0'; +static PHP_METHOD(Phalcon_Assets_Collection, setPrefix) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *prefix_param = NULL; + zval prefix; + zval *this_ptr = getThis(); - if (*VVCURSOR == '\n') { - s->active_line++; - } + ZVAL_UNDEF(&prefix); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(prefix) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &prefix_param); + zephir_get_strval(&prefix, prefix_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("prefix"), &prefix); + RETURN_THIS(); +} - if (*VVCURSOR != '\0') { - next = *(VVCURSOR + 1); - if (next != '\0') { - double_next = *(VVCURSOR + 2); - } - } +static PHP_METHOD(Phalcon_Assets_Collection, setTargetIsLocal) +{ + zval *flag_param = NULL, __$true, __$false; + zend_bool flag; + zval *this_ptr = getThis(); - if (*VVCURSOR == '\0' || (*VVCURSOR == '{' && (next == '%' || next == '{' || next == '#'))) { - if (next != '#') { - s->mode = PHVOLT_MODE_CODE; + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(flag) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &flag_param); + if (flag) { + zephir_update_property_zval(this_ptr, ZEND_STRL("targetIsLocal"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("targetIsLocal"), &__$false); + } + RETURN_THISW(); +} - if (s->raw_buffer_cursor > 0) { - token->opcode = PHVOLT_T_RAW_FRAGMENT; - token->value = emalloc(sizeof(char) * s->raw_buffer_cursor + 1); - memcpy(token->value, s->raw_buffer, s->raw_buffer_cursor); - token->value[s->raw_buffer_cursor] = 0; - token->len = s->raw_buffer_cursor; +static PHP_METHOD(Phalcon_Assets_Collection, setTargetPath) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *targetPath_param = NULL; + zval targetPath; + zval *this_ptr = getThis(); - if (s->whitespace_control == 1) { - phvolt_ltrim(token); - s->whitespace_control = 0; - } + ZVAL_UNDEF(&targetPath); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(targetPath) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &targetPath_param); + zephir_get_strval(&targetPath, targetPath_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("targetPath"), &targetPath); + RETURN_THIS(); +} - if (double_next == '-') { - phvolt_rtrim(token); - } +static PHP_METHOD(Phalcon_Assets_Collection, setTargetUri) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *targetUri_param = NULL; + zval targetUri; + zval *this_ptr = getThis(); - s->raw_buffer_cursor = 0; - } else { - token->opcode = PHVOLT_T_IGNORE; - } - } else { - while ((next = *(++VVCURSOR))) { - if (next == '#' && *(VVCURSOR + 1) == '}') { - VVCURSOR += 2; - token->opcode = PHVOLT_T_IGNORE; - return 0; - } else { - if (next == '\n') { - s->active_line++; - } - } - } + ZVAL_UNDEF(&targetUri); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(targetUri) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &targetUri_param); + zephir_get_strval(&targetUri, targetUri_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("targetUri"), &targetUri); + RETURN_THIS(); +} - return PHVOLT_SCANNER_RETCODE_EOF; - } +static PHP_METHOD(Phalcon_Assets_Collection, setSourcePath) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *sourcePath_param = NULL; + zval sourcePath; + zval *this_ptr = getThis(); - return 0; + ZVAL_UNDEF(&sourcePath); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(sourcePath) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &sourcePath_param); + zephir_get_strval(&sourcePath, sourcePath_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("sourcePath"), &sourcePath); + RETURN_THIS(); +} - } else { - if (s->raw_buffer_cursor == s->raw_buffer_size) { - s->raw_buffer_size += PHVOLT_RAW_BUFFER_SIZE; - s->raw_buffer = erealloc(s->raw_buffer, s->raw_buffer_size); - } +static PHP_METHOD(Phalcon_Assets_Collection, setVersion) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *version_param = NULL; + zval version; + zval *this_ptr = getThis(); - memcpy(s->raw_buffer+s->raw_buffer_cursor, VVCURSOR, 1); - s->raw_buffer_cursor++; + ZVAL_UNDEF(&version); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(version) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &version_param); + zephir_get_strval(&version, version_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("version"), &version); + RETURN_THIS(); +} - ++VVCURSOR; - } +static PHP_METHOD(Phalcon_Assets_Collection, addAsset) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *asset, asset_sub, _0, _1$$4; + zval *this_ptr = getThis(); - } else { - - { - VVCTYPE vvch; - unsigned int vvaccept = 0; - vvch = *VVCURSOR; - switch (vvch) { - case 0x00: goto vv2; - case '\t': - case '\r': - case ' ': goto vv6; - case '\n': goto vv9; - case '!': goto vv11; - case '"': goto vv13; - case '%': goto vv14; - case '\'': goto vv16; - case '(': goto vv17; - case ')': goto vv19; - case '*': goto vv21; - case '+': goto vv23; - case ',': goto vv25; - case '-': goto vv27; - case '.': goto vv29; - case '/': goto vv31; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto vv33; - case ':': goto vv36; - case '<': goto vv38; - case '=': goto vv40; - case '>': goto vv42; - case '?': goto vv44; - case 'A': - case 'a': goto vv46; - case 'B': - case 'b': goto vv48; - case 'C': - case 'c': goto vv49; - case 'D': - case 'd': goto vv50; - case 'E': - case 'e': goto vv51; - case 'F': - case 'f': goto vv52; - case 'G': - case 'H': - case 'J': - case 'K': - case 'L': - case 'P': - case 'Q': - case 'U': - case 'V': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'g': - case 'h': - case 'j': - case 'k': - case 'l': - case 'p': - case 'q': - case 'u': - case 'v': - case 'x': - case 'y': - case 'z': goto vv53; - case 'I': goto vv55; - case 'M': - case 'm': goto vv56; - case 'N': - case 'n': goto vv57; - case 'O': - case 'o': goto vv58; - case 'R': - case 'r': goto vv59; - case 'S': - case 's': goto vv60; - case 'T': - case 't': goto vv61; - case 'W': - case 'w': goto vv62; - case '[': goto vv63; - case '\\': goto vv65; - case ']': goto vv66; - case 'i': goto vv68; - case '{': goto vv69; - case '|': goto vv71; - case '}': goto vv73; - case '~': goto vv75; - default: goto vv4; - } -vv2: - ++VVCURSOR; - { - status = PHVOLT_SCANNER_RETCODE_EOF; - break; - } -vv4: - ++VVCURSOR; -vv5: - { - status = PHVOLT_SCANNER_RETCODE_ERR; - break; - } -vv6: - vvch = *++VVCURSOR; - switch (vvch) { - case '\t': - case '\r': - case ' ': goto vv6; - default: goto vv8; - } -vv8: - { - token->opcode = PHVOLT_T_IGNORE; - return 0; - } -vv9: - ++VVCURSOR; - { - s->active_line++; - token->opcode = PHVOLT_T_IGNORE; - return 0; - } -vv11: - vvch = *++VVCURSOR; - switch (vvch) { - case '=': goto vv77; - default: goto vv12; - } -vv12: - { - token->opcode = PHVOLT_T_NOT; - return 0; - } -vv13: - vvaccept = 0; - vvch = *(VVMARKER = ++VVCURSOR); - if (vvch <= 0x00) goto vv5; - goto vv80; -vv14: - vvch = *++VVCURSOR; - switch (vvch) { - case '}': goto vv85; - default: goto vv15; - } -vv15: - { - token->opcode = PHVOLT_T_MOD; - return 0; - } -vv16: - vvaccept = 0; - vvch = *(VVMARKER = ++VVCURSOR); - if (vvch <= 0x00) goto vv5; - goto vv88; -vv17: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_PARENTHESES_OPEN; - return 0; - } -vv19: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_PARENTHESES_CLOSE; - return 0; - } -vv21: - vvch = *++VVCURSOR; - switch (vvch) { - case '=': goto vv90; - default: goto vv22; - } -vv22: - { - token->opcode = PHVOLT_T_MUL; - return 0; - } -vv23: - vvch = *++VVCURSOR; - switch (vvch) { - case '+': goto vv92; - case '=': goto vv94; - default: goto vv24; - } -vv24: - { - token->opcode = PHVOLT_T_ADD; - return 0; - } -vv25: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_COMMA; - return 0; - } -vv27: - vvaccept = 1; - vvch = *(VVMARKER = ++VVCURSOR); - switch (vvch) { - case '%': goto vv96; - case '-': goto vv97; - case '=': goto vv99; - case '}': goto vv101; - default: goto vv28; - } -vv28: - { - token->opcode = PHVOLT_T_SUB; - return 0; - } -vv29: - vvch = *++VVCURSOR; - switch (vvch) { - case '.': goto vv102; - default: goto vv30; - } -vv30: - { - token->opcode = PHVOLT_T_DOT; - return 0; - } -vv31: - vvch = *++VVCURSOR; - switch (vvch) { - case '=': goto vv104; - default: goto vv32; - } -vv32: - { - token->opcode = PHVOLT_T_DIV; - return 0; - } -vv33: - vvaccept = 2; - vvch = *(VVMARKER = ++VVCURSOR); - switch (vvch) { - case '.': goto vv106; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto vv33; - default: goto vv35; - } -vv35: - { - token->opcode = PHVOLT_T_INTEGER; - token->value = estrndup(start, VVCURSOR - start); - token->len = VVCURSOR - start; - return 0; - } -vv36: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_COLON; - return 0; - } -vv38: - vvch = *++VVCURSOR; - switch (vvch) { - case '=': goto vv107; - case '>': goto vv109; - default: goto vv39; - } -vv39: - { - token->opcode = PHVOLT_T_LESS; - return 0; - } -vv40: - vvch = *++VVCURSOR; - switch (vvch) { - case '=': goto vv111; - default: goto vv41; - } -vv41: - { - token->opcode = PHVOLT_T_ASSIGN; - return 0; - } -vv42: - vvch = *++VVCURSOR; - switch (vvch) { - case '=': goto vv113; - default: goto vv43; - } -vv43: - { - token->opcode = PHVOLT_T_GREATER; - return 0; - } -vv44: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_QUESTION; - return 0; - } -vv46: - vvch = *++VVCURSOR; - switch (vvch) { - case 'N': - case 'n': goto vv115; - case 'U': - case 'u': goto vv116; - default: goto vv54; - } -vv47: - { - token->opcode = PHVOLT_T_IDENTIFIER; - token->value = estrndup(start, VVCURSOR - start); - token->len = VVCURSOR - start; - return 0; - } -vv48: - vvch = *++VVCURSOR; - switch (vvch) { - case 'L': - case 'l': goto vv117; - case 'R': - case 'r': goto vv118; - default: goto vv54; - } -vv49: - vvch = *++VVCURSOR; - switch (vvch) { - case 'A': - case 'a': goto vv119; - case 'O': - case 'o': goto vv120; - default: goto vv54; - } -vv50: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv121; - case 'O': - case 'o': goto vv122; - default: goto vv54; - } -vv51: - vvch = *++VVCURSOR; - switch (vvch) { - case 'L': - case 'l': goto vv124; - case 'M': - case 'm': goto vv125; - case 'N': - case 'n': goto vv126; - case 'V': - case 'v': goto vv127; - case 'X': - case 'x': goto vv128; - default: goto vv54; - } -vv52: - vvch = *++VVCURSOR; - switch (vvch) { - case 'A': - case 'a': goto vv129; - case 'O': - case 'o': goto vv130; - default: goto vv54; - } -vv53: - vvch = *++VVCURSOR; -vv54: - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv47; - } -vv55: - vvch = *++VVCURSOR; - switch (vvch) { - case 'F': - case 'f': goto vv131; - case 'N': - case 'n': goto vv133; - case 'S': - case 's': goto vv135; - case 'T': - case 't': goto vv137; - default: goto vv54; - } -vv56: - vvch = *++VVCURSOR; - switch (vvch) { - case 'A': - case 'a': goto vv138; - default: goto vv54; - } -vv57: - vvch = *++VVCURSOR; - switch (vvch) { - case 'O': - case 'o': goto vv139; - case 'U': - case 'u': goto vv140; - default: goto vv54; - } -vv58: - vvch = *++VVCURSOR; - switch (vvch) { - case 'D': - case 'd': goto vv141; - case 'R': - case 'r': goto vv142; - default: goto vv54; - } -vv59: - vvch = *++VVCURSOR; - switch (vvch) { - case 'A': - case 'a': goto vv144; - case 'E': - case 'e': goto vv145; - default: goto vv54; - } -vv60: - vvch = *++VVCURSOR; - switch (vvch) { - case 'C': - case 'c': goto vv146; - case 'E': - case 'e': goto vv147; - case 'W': - case 'w': goto vv148; - default: goto vv54; - } -vv61: - vvch = *++VVCURSOR; - switch (vvch) { - case 'R': - case 'r': goto vv149; - default: goto vv54; - } -vv62: - vvch = *++VVCURSOR; - switch (vvch) { - case 'I': - case 'i': goto vv150; - default: goto vv54; - } -vv63: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_SBRACKET_OPEN; - return 0; - } -vv65: - vvch = *++VVCURSOR; - switch (vvch) { - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv5; - } -vv66: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_SBRACKET_CLOSE; - return 0; - } -vv68: - vvch = *++VVCURSOR; - switch (vvch) { - case 'F': - case 'f': goto vv131; - case 'N': - case 'n': goto vv133; - case 'S': goto vv135; - case 'T': - case 't': goto vv137; - case 's': goto vv151; - default: goto vv54; - } -vv69: - vvch = *++VVCURSOR; - switch (vvch) { - case '%': goto vv152; - case '{': goto vv154; - default: goto vv70; - } -vv70: - { - token->opcode = PHVOLT_T_CBRACKET_OPEN; - return 0; - } -vv71: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_PIPE; - return 0; - } -vv73: - vvch = *++VVCURSOR; - switch (vvch) { - case '}': goto vv156; - default: goto vv74; - } -vv74: - { - token->opcode = PHVOLT_T_CBRACKET_CLOSE; - return 0; - } -vv75: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_CONCAT; - return 0; - } -vv77: - vvch = *++VVCURSOR; - switch (vvch) { - case '=': goto vv158; - default: goto vv78; - } -vv78: - { - token->opcode = PHVOLT_T_NOTEQUALS; - return 0; - } -vv79: - vvch = *++VVCURSOR; -vv80: - switch (vvch) { - case 0x00: goto vv81; - case '"': goto vv82; - case '\\': goto vv84; - default: goto vv79; - } -vv81: - VVCURSOR = VVMARKER; - switch (vvaccept) { - case 0: goto vv5; - case 1: goto vv28; - case 2: goto vv35; - default: goto vv136; - } -vv82: - ++VVCURSOR; - { - start++; - token->opcode = PHVOLT_T_STRING; - token->value = estrndup(start, VVCURSOR - start - 1); - token->len = VVCURSOR - start - 1; - return 0; + ZVAL_UNDEF(&asset_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(asset, phalcon_assets_assetinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &asset); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, 0, asset); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + RETURN_MM_BOOL(0); + } + if (zephir_instance_of_ev(asset, phalcon_assets_asset_ce)) { + ZEPHIR_CALL_METHOD(&_1$$4, asset, "getassetkey", NULL, 0); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("assets"), &_1$$4, asset); + RETURN_MM_BOOL(1); + } + zephir_update_property_array_append(this_ptr, SL("codes"), asset); + RETURN_MM_BOOL(1); +} + +static PHP_METHOD(Phalcon_Assets_Collection, processAdd) +{ + zend_class_entry *_3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval attributes; + zend_bool filter, autoVersion; + zval *className_param = NULL, *path_param = NULL, *isLocal = NULL, isLocal_sub, *filter_param = NULL, *attributes_param = NULL, *version_param = NULL, *autoVersion_param = NULL, __$null, attrs, flag, name, _1, _2, _4, _5; + zval className, path, version, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&path); + ZVAL_UNDEF(&version); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&isLocal_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&attrs); + ZVAL_UNDEF(&flag); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&attributes); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 7) + Z_PARAM_STR(className) + Z_PARAM_STR(path) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(isLocal) + Z_PARAM_BOOL(filter) + Z_PARAM_ARRAY(attributes) + Z_PARAM_STR_OR_NULL(version) + Z_PARAM_BOOL(autoVersion) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 5, &className_param, &path_param, &isLocal, &filter_param, &attributes_param, &version_param, &autoVersion_param); + zephir_get_strval(&className, className_param); + zephir_get_strval(&path, path_param); + if (!isLocal) { + isLocal = &isLocal_sub; + isLocal = &__$null; + } + if (!filter_param) { + filter = 1; + } else { } -vv84: - vvch = *++VVCURSOR; - switch (vvch) { - case '\n': goto vv81; - default: goto vv79; - } -vv85: - ++VVCURSOR; - { - s->mode = PHVOLT_MODE_RAW; - token->opcode = PHVOLT_T_CLOSE_DELIMITER; - return 0; + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + if (!version_param) { + ZEPHIR_INIT_VAR(&version); + } else { + zephir_get_strval(&version, version_param); + } + if (!autoVersion_param) { + autoVersion = 0; + } else { } -vv87: - vvch = *++VVCURSOR; -vv88: - switch (vvch) { - case 0x00: goto vv81; - case '\'': goto vv82; - case '\\': goto vv89; - default: goto vv87; - } -vv89: - vvch = *++VVCURSOR; - switch (vvch) { - case '\n': goto vv81; - default: goto vv87; - } -vv90: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_MUL_ASSIGN; - return 0; + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_CONCAT_SV(&_0, "Phalcon\\Assets\\Asset\\", &className); + ZEPHIR_CPY_WRT(&name, &_0); + zephir_memory_observe(&flag); + zephir_read_property(&flag, this_ptr, ZEND_STRL("isLocal"), PH_NOISY_CC); + ZEPHIR_CALL_METHOD(&attrs, this_ptr, "processattributes", NULL, 170, &attributes); + zephir_check_call_status(); + if (Z_TYPE_P(isLocal) != IS_NULL) { + ZEPHIR_INIT_NVAR(&flag); + ZVAL_BOOL(&flag, zephir_get_boolval(isLocal)); + } + ZEPHIR_INIT_VAR(&_1); + zephir_fetch_safe_class(&_2, &name); + _3 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_2), Z_STRLEN_P(&_2), ZEND_FETCH_CLASS_AUTO); + if(!_3) { + RETURN_MM_NULL(); + } + object_init_ex(&_1, _3); + if (zephir_has_constructor(&_1)) { + if (filter) { + ZVAL_BOOL(&_4, 1); + } else { + ZVAL_BOOL(&_4, 0); } -vv92: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_INCR; - return 0; + if (autoVersion) { + ZVAL_BOOL(&_5, 1); + } else { + ZVAL_BOOL(&_5, 0); } -vv94: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_ADD_ASSIGN; - return 0; + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 0, &path, &flag, &_4, &attrs, &version, &_5); + zephir_check_call_status(); + } + + ZEPHIR_CALL_METHOD(NULL, this_ptr, "add", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Assets_Collection, processAddInline) +{ + zend_class_entry *_2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval attributes; + zend_bool filter; + zval *className_param = NULL, *content_param = NULL, *filter_param = NULL, *attributes_param = NULL, asset, attrs, name, _1, _3, _4; + zval className, content, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&content); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&asset); + ZVAL_UNDEF(&attrs); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&attributes); + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_STR(className) + Z_PARAM_STR(content) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(filter) + Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 2, &className_param, &content_param, &filter_param, &attributes_param); + zephir_get_strval(&className, className_param); + zephir_get_strval(&content, content_param); + if (!filter_param) { + filter = 1; + } else { } -vv96: - vvch = *++VVCURSOR; - switch (vvch) { - case '}': goto vv160; - default: goto vv81; - } -vv97: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_DECR; - return 0; + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_CONCAT_SV(&_0, "Phalcon\\Assets\\Inline\\", &className); + ZEPHIR_CPY_WRT(&name, &_0); + ZEPHIR_CALL_METHOD(&attrs, this_ptr, "processattributes", NULL, 170, &attributes); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&asset); + zephir_fetch_safe_class(&_1, &name); + _2 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_1), Z_STRLEN_P(&_1), ZEND_FETCH_CLASS_AUTO); + if(!_2) { + RETURN_MM_NULL(); + } + object_init_ex(&asset, _2); + if (zephir_has_constructor(&asset)) { + if (filter) { + ZVAL_BOOL(&_3, 1); + } else { + ZVAL_BOOL(&_3, 0); } -vv99: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_SUB_ASSIGN; - return 0; + ZEPHIR_CALL_METHOD(NULL, &asset, "__construct", NULL, 0, &content, &_3, &attrs); + zephir_check_call_status(); + } + + ZEPHIR_CALL_METHOD(&_4, &asset, "getassetkey", NULL, 0); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("codes"), &_4, &asset); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Assets_Collection, processAttributes) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *attributes_param = NULL, _0; + zval attributes; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &attributes_param); + zephir_get_arrval(&attributes, attributes_param); + ZEPHIR_INIT_VAR(&_0); + if (1 != ZEPHIR_IS_EMPTY(&attributes)) { + ZEPHIR_CPY_WRT(&_0, &attributes); + } else { + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC); + } + RETURN_CCTOR(&_0); +} + +zend_object *zephir_init_properties_Phalcon_Assets_Collection(zend_class_entry *class_type) +{ + zval _0, _2, _4, _6, _1$$3, _3$$4, _5$$5, _7$$6; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("filters"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("filters"), &_1$$3); } -vv101: - vvch = *++VVCURSOR; - switch (vvch) { - case '}': goto vv162; - default: goto vv81; - } -vv102: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_RANGE; - return 0; + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("codes"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("codes"), &_3$$4); } -vv104: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_DIV_ASSIGN; - return 0; + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("attributes"), &_5$$5); } -vv106: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto vv164; - default: goto vv81; - } -vv107: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_LESSEQUAL; - return 0; + zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("assets"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_6) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$6); + array_init(&_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("assets"), &_7$$6); } -vv109: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_NOTEQUALS; - return 0; + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Assets_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Assets, Exception, phalcon, assets_exception, zend_ce_exception, NULL, 0); + + return SUCCESS; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Assets_FilterInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Assets, FilterInterface, phalcon, assets_filterinterface, phalcon_assets_filterinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Assets_FilterInterface, filter); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Assets_Inline) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Assets, Inline, phalcon, assets_inline, phalcon_assets_inline_method_entry, 0); + + zend_declare_property_null(phalcon_assets_inline_ce, SL("attributes"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_assets_inline_ce, SL("content"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_assets_inline_ce, SL("filter"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_assets_inline_ce, SL("type"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_assets_inline_ce, 1, phalcon_assets_assetinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Assets_Inline, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval attributes; + zend_bool filter; + zval *type_param = NULL, *content_param = NULL, *filter_param = NULL, *attributes_param = NULL, __$true, __$false; + zval type, content; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&content); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&attributes); + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_STR(type) + Z_PARAM_STR(content) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(filter) + Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 2, &type_param, &content_param, &filter_param, &attributes_param); + zephir_get_strval(&type, type_param); + zephir_get_strval(&content, content_param); + if (!filter_param) { + filter = 1; + } else { } -vv111: - vvch = *++VVCURSOR; - switch (vvch) { - case '=': goto vv167; - default: goto vv112; - } -vv112: - { - token->opcode = PHVOLT_T_EQUALS; - return 0; + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &type); + zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &content); + if (filter) { + zephir_update_property_zval(this_ptr, ZEND_STRL("filter"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("filter"), &__$false); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &attributes); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Assets_Inline, getAssetKey) +{ + zval key, _0, _1, _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "gettype", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getcontent", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&key); + ZEPHIR_CONCAT_VSV(&key, &_0, ":", &_1); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "sha256"); + ZEPHIR_RETURN_CALL_FUNCTION("hash", NULL, 71, &_2, &key); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Assets_Inline, getAttributes) +{ + + RETURN_MEMBER(getThis(), "attributes"); +} + +static PHP_METHOD(Phalcon_Assets_Inline, getContent) +{ + + RETURN_MEMBER(getThis(), "content"); +} + +static PHP_METHOD(Phalcon_Assets_Inline, getFilter) +{ + + RETURN_MEMBER(getThis(), "filter"); +} + +static PHP_METHOD(Phalcon_Assets_Inline, getType) +{ + + RETURN_MEMBER(getThis(), "type"); +} + +static PHP_METHOD(Phalcon_Assets_Inline, setAttributes) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *attributes_param = NULL; + zval attributes; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&attributes); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &attributes_param); + zephir_get_arrval(&attributes, attributes_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &attributes); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Assets_Inline, setFilter) +{ + zval *filter_param = NULL, __$true, __$false; + zend_bool filter; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(filter) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &filter_param); + if (filter) { + zephir_update_property_zval(this_ptr, ZEND_STRL("filter"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("filter"), &__$false); + } + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Assets_Inline, setType) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *type_param = NULL; + zval type; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&type); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(type) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &type_param); + zephir_get_strval(&type, type_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &type); + RETURN_THIS(); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Assets_Manager) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Assets, Manager, phalcon, assets_manager, phalcon_di_abstractinjectionaware_ce, phalcon_assets_manager_method_entry, 0); + + zend_declare_property_null(phalcon_assets_manager_ce, SL("collections"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_assets_manager_ce, SL("implicitOutput"), 1, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_assets_manager_ce, SL("options"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_assets_manager_ce, SL("tagFactory"), ZEND_ACC_PROTECTED); + phalcon_assets_manager_ce->create_object = zephir_init_properties_Phalcon_Assets_Manager; + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Assets_Manager, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval options; + zval *tagFactory, tagFactory_sub, *options_param = NULL; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&tagFactory_sub); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(tagFactory, phalcon_html_tagfactory_ce) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &tagFactory, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("tagFactory"), tagFactory); + zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, addAsset) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *asset, asset_sub, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&asset_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(asset, phalcon_assets_asset_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &asset); + ZEPHIR_CALL_METHOD(&_0, asset, "gettype", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addassetbytype", NULL, 0, &_0, asset); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, addAssetByType) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *type_param = NULL, *asset, asset_sub, collection; + zval type; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&asset_sub); + ZVAL_UNDEF(&collection); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(type) + Z_PARAM_OBJECT_OF_CLASS(asset, phalcon_assets_asset_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &type_param, &asset); + if (UNEXPECTED(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(type_param) == IS_STRING)) { + zephir_get_strval(&type, type_param); + } else { + ZEPHIR_INIT_VAR(&type); + } + ZEPHIR_CALL_METHOD(&collection, this_ptr, "checkandcreatecollection", NULL, 171, &type); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &collection, "add", NULL, 0, asset); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, addCss) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval attributes; + zend_bool local, filter, autoVersion; + zval *path_param = NULL, *local_param = NULL, *filter_param = NULL, *attributes_param = NULL, *version_param = NULL, *autoVersion_param = NULL, _0, _1, _2, _3, _4; + zval path, version; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&path); + ZVAL_UNDEF(&version); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&attributes); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 6) + Z_PARAM_STR(path) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(local) + Z_PARAM_BOOL(filter) + Z_PARAM_ARRAY(attributes) + Z_PARAM_STR_OR_NULL(version) + Z_PARAM_BOOL(autoVersion) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 5, &path_param, &local_param, &filter_param, &attributes_param, &version_param, &autoVersion_param); + if (UNEXPECTED(Z_TYPE_P(path_param) != IS_STRING && Z_TYPE_P(path_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(path_param) == IS_STRING)) { + zephir_get_strval(&path, path_param); + } else { + ZEPHIR_INIT_VAR(&path); + } + if (!local_param) { + local = 1; + } else { } -vv113: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_GREATEREQUAL; - return 0; + if (!filter_param) { + filter = 1; + } else { } -vv115: - vvch = *++VVCURSOR; - switch (vvch) { - case 'D': - case 'd': goto vv169; - default: goto vv54; - } -vv116: - vvch = *++VVCURSOR; - switch (vvch) { - case 'T': - case 't': goto vv171; - default: goto vv54; - } -vv117: - vvch = *++VVCURSOR; - switch (vvch) { - case 'O': - case 'o': goto vv172; - default: goto vv54; - } -vv118: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv173; - default: goto vv54; - } -vv119: - vvch = *++VVCURSOR; - switch (vvch) { - case 'C': - case 'c': goto vv174; - case 'L': - case 'l': goto vv175; - case 'S': - case 's': goto vv176; - default: goto vv54; - } -vv120: - vvch = *++VVCURSOR; - switch (vvch) { - case 'N': - case 'n': goto vv177; - default: goto vv54; - } -vv121: - vvch = *++VVCURSOR; - switch (vvch) { - case 'F': - case 'f': goto vv178; - default: goto vv54; - } -vv122: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv123; - } -vv123: - { - s->statement_position++; - token->opcode = PHVOLT_T_DO; - return 0; + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + if (!version_param) { + ZEPHIR_INIT_VAR(&version); + } else { + zephir_get_strval(&version, version_param); + } + if (!autoVersion_param) { + autoVersion = 0; + } else { } -vv124: - vvch = *++VVCURSOR; - switch (vvch) { - case 'S': - case 's': goto vv179; - default: goto vv54; - } -vv125: - vvch = *++VVCURSOR; - switch (vvch) { - case 'P': - case 'p': goto vv180; - default: goto vv54; - } -vv126: - vvch = *++VVCURSOR; - switch (vvch) { - case 'D': - case 'd': goto vv181; - default: goto vv54; - } -vv127: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv182; - default: goto vv54; - } -vv128: - vvch = *++VVCURSOR; - switch (vvch) { - case 'T': - case 't': goto vv183; - default: goto vv54; - } -vv129: - vvch = *++VVCURSOR; - switch (vvch) { - case 'L': - case 'l': goto vv184; - default: goto vv54; - } -vv130: - vvch = *++VVCURSOR; - switch (vvch) { - case 'R': - case 'r': goto vv185; - default: goto vv54; - } -vv131: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv132; - } -vv132: - { - s->statement_position++; - token->opcode = PHVOLT_T_IF; - return 0; + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, phalcon_assets_asset_css_ce); + if (local) { + ZVAL_BOOL(&_1, 1); + } else { + ZVAL_BOOL(&_1, 0); + } + if (filter) { + ZVAL_BOOL(&_2, 1); + } else { + ZVAL_BOOL(&_2, 0); + } + if (autoVersion) { + ZVAL_BOOL(&_3, 1); + } else { + ZVAL_BOOL(&_3, 0); + } + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 172, &path, &_1, &_2, &attributes, &version, &_3); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "css"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addassetbytype", NULL, 0, &_4, &_0); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, addInlineCode) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *code, code_sub, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&code_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(code, phalcon_assets_inline_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &code); + ZEPHIR_CALL_METHOD(&_0, code, "gettype", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addinlinecodebytype", NULL, 0, &_0, code); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, addInlineCodeByType) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *type_param = NULL, *code, code_sub, collection; + zval type; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&code_sub); + ZVAL_UNDEF(&collection); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(type) + Z_PARAM_OBJECT_OF_CLASS(code, phalcon_assets_inline_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &type_param, &code); + if (UNEXPECTED(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(type_param) == IS_STRING)) { + zephir_get_strval(&type, type_param); + } else { + ZEPHIR_INIT_VAR(&type); + } + ZEPHIR_CALL_METHOD(&collection, this_ptr, "checkandcreatecollection", NULL, 171, &type); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &collection, "addinline", NULL, 0, code); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, addInlineCss) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval attributes; + zend_bool filter; + zval *content_param = NULL, *filter_param = NULL, *attributes_param = NULL, _0, _1, _2; + zval content; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&content); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&attributes); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(content) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(filter) + Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &content_param, &filter_param, &attributes_param); + zephir_get_strval(&content, content_param); + if (!filter_param) { + filter = 1; + } else { } -vv133: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - case 'C': - case 'c': goto vv187; - default: goto vv134; - } -vv134: - { - token->opcode = PHVOLT_T_IN; - return 0; + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, phalcon_assets_inline_css_ce); + if (filter) { + ZVAL_BOOL(&_1, 1); + } else { + ZVAL_BOOL(&_1, 0); + } + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 173, &content, &_1, &attributes); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "css"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addinlinecodebytype", NULL, 0, &_2, &_0); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, addInlineJs) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval attributes; + zend_bool filter; + zval *content_param = NULL, *filter_param = NULL, *attributes_param = NULL, _0, _1, _2; + zval content; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&content); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&attributes); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(content) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(filter) + Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &content_param, &filter_param, &attributes_param); + zephir_get_strval(&content, content_param); + if (!filter_param) { + filter = 1; + } else { } -vv135: - vvaccept = 3; - vvch = *(VVMARKER = ++VVCURSOR); - switch (vvch) { - case ' ': goto vv188; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv136; - } -vv136: - { - if (s->active_token == PHVOLT_T_DOT) { - token->opcode = PHVOLT_T_IDENTIFIER; - token->value = estrndup(start, VVCURSOR - start); - token->len = VVCURSOR - start; - } else { - s->statement_position++; - token->opcode = PHVOLT_T_IS; - } + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, phalcon_assets_inline_js_ce); + if (filter) { + ZVAL_BOOL(&_1, 1); + } else { + ZVAL_BOOL(&_1, 0); + } + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 174, &content, &_1, &attributes); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "js"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addinlinecodebytype", NULL, 0, &_2, &_0); + zephir_check_call_status(); + RETURN_THIS(); +} - return 0; +static PHP_METHOD(Phalcon_Assets_Manager, addJs) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval attributes; + zend_bool local, filter, autoVersion; + zval *path_param = NULL, *local_param = NULL, *filter_param = NULL, *attributes_param = NULL, *version_param = NULL, *autoVersion_param = NULL, _0, _1, _2, _3, _4; + zval path, version; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&path); + ZVAL_UNDEF(&version); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&attributes); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 6) + Z_PARAM_STR(path) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(local) + Z_PARAM_BOOL(filter) + Z_PARAM_ARRAY(attributes) + Z_PARAM_STR_OR_NULL(version) + Z_PARAM_BOOL(autoVersion) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 5, &path_param, &local_param, &filter_param, &attributes_param, &version_param, &autoVersion_param); + if (UNEXPECTED(Z_TYPE_P(path_param) != IS_STRING && Z_TYPE_P(path_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(path_param) == IS_STRING)) { + zephir_get_strval(&path, path_param); + } else { + ZEPHIR_INIT_VAR(&path); + } + if (!local_param) { + local = 1; + } else { } -vv137: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv189; - default: goto vv54; - } -vv138: - vvch = *++VVCURSOR; - switch (vvch) { - case 'C': - case 'c': goto vv190; - default: goto vv54; - } -vv139: - vvch = *++VVCURSOR; - switch (vvch) { - case 'T': - case 't': goto vv191; - default: goto vv54; - } -vv140: - vvch = *++VVCURSOR; - switch (vvch) { - case 'L': - case 'l': goto vv193; - case 'M': - case 'm': goto vv194; - default: goto vv54; - } -vv141: - vvch = *++VVCURSOR; - switch (vvch) { - case 'D': - case 'd': goto vv195; - default: goto vv54; - } -vv142: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv143; - } -vv143: - { - token->opcode = PHVOLT_T_OR; - return 0; + if (!filter_param) { + filter = 1; + } else { } -vv144: - vvch = *++VVCURSOR; - switch (vvch) { - case 'W': - case 'w': goto vv197; - default: goto vv54; - } -vv145: - vvch = *++VVCURSOR; - switch (vvch) { - case 'T': - case 't': goto vv199; - default: goto vv54; - } -vv146: - vvch = *++VVCURSOR; - switch (vvch) { - case 'A': - case 'a': goto vv200; - default: goto vv54; - } -vv147: - vvch = *++VVCURSOR; - switch (vvch) { - case 'T': - case 't': goto vv201; - default: goto vv54; - } -vv148: - vvch = *++VVCURSOR; - switch (vvch) { - case 'I': - case 'i': goto vv203; - default: goto vv54; - } -vv149: - vvch = *++VVCURSOR; - switch (vvch) { - case 'U': - case 'u': goto vv204; - default: goto vv54; - } -vv150: - vvch = *++VVCURSOR; - switch (vvch) { - case 'T': - case 't': goto vv205; - default: goto vv54; - } -vv151: - vvaccept = 3; - vvch = *(VVMARKER = ++VVCURSOR); - switch (vvch) { - case ' ': goto vv206; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv136; + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + if (!version_param) { + ZEPHIR_INIT_VAR(&version); + } else { + zephir_get_strval(&version, version_param); + } + if (!autoVersion_param) { + autoVersion = 0; + } else { + } + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, phalcon_assets_asset_js_ce); + if (local) { + ZVAL_BOOL(&_1, 1); + } else { + ZVAL_BOOL(&_1, 0); + } + if (filter) { + ZVAL_BOOL(&_2, 1); + } else { + ZVAL_BOOL(&_2, 0); + } + if (autoVersion) { + ZVAL_BOOL(&_3, 1); + } else { + ZVAL_BOOL(&_3, 0); + } + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 175, &path, &_1, &_2, &attributes, &version, &_3); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "js"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addassetbytype", NULL, 0, &_4, &_0); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, collection) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checkandcreatecollection", NULL, 171, &name); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, collectionAssetsByType) +{ + zend_bool _2$$3, _4$$5; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval type; + zval *assets_param = NULL, *type_param = NULL, asset, *_0, _1, _3$$3, _5$$5; + zval assets, filtered; + + ZVAL_UNDEF(&assets); + ZVAL_UNDEF(&filtered); + ZVAL_UNDEF(&asset); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&type); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ARRAY(assets) + Z_PARAM_STR(type) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &assets_param, &type_param); + zephir_get_arrval(&assets, assets_param); + zephir_get_strval(&type, type_param); + ZEPHIR_INIT_VAR(&filtered); + array_init(&filtered); + zephir_is_iterable(&assets, 0, "phalcon/Assets/Manager.zep", 253); + if (Z_TYPE_P(&assets) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&assets), _0) + { + ZEPHIR_INIT_NVAR(&asset); + ZVAL_COPY(&asset, _0); + _2$$3 = zephir_instance_of_ev(&asset, phalcon_assets_assetinterface_ce); + if (_2$$3) { + ZEPHIR_CALL_METHOD(&_3$$3, &asset, "gettype", NULL, 0); + zephir_check_call_status(); + _2$$3 = ZEPHIR_IS_IDENTICAL(&type, &_3$$3); } -vv152: - vvch = *++VVCURSOR; - switch (vvch) { - case '-': goto vv207; - default: goto vv153; + if (_2$$3) { + zephir_array_append(&filtered, &asset, PH_SEPARATE, "phalcon/Assets/Manager.zep", 249); } -vv153: - { - s->whitespace_control = 0; - token->opcode = PHVOLT_T_OPEN_DELIMITER; - return 0; - } -vv154: - vvch = *++VVCURSOR; - switch (vvch) { - case '-': goto vv209; - default: goto vv155; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &assets, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &assets, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; } -vv155: - { - s->whitespace_control = 0; - s->statement_position++; - token->opcode = PHVOLT_T_OPEN_EDELIMITER; - return 0; - } -vv156: - ++VVCURSOR; - { - s->mode = PHVOLT_MODE_RAW; - token->opcode = PHVOLT_T_CLOSE_EDELIMITER; - return 0; - } -vv158: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_NOTIDENTICAL; - return 0; - } -vv160: - ++VVCURSOR; - { - s->mode = PHVOLT_MODE_RAW; - s->whitespace_control = 1; - token->opcode = PHVOLT_T_CLOSE_DELIMITER; - return 0; + ZEPHIR_CALL_METHOD(&asset, &assets, "current", NULL, 0); + zephir_check_call_status(); + _4$$5 = zephir_instance_of_ev(&asset, phalcon_assets_assetinterface_ce); + if (_4$$5) { + ZEPHIR_CALL_METHOD(&_5$$5, &asset, "gettype", NULL, 0); + zephir_check_call_status(); + _4$$5 = ZEPHIR_IS_IDENTICAL(&type, &_5$$5); + } + if (_4$$5) { + zephir_array_append(&filtered, &asset, PH_SEPARATE, "phalcon/Assets/Manager.zep", 249); + } + ZEPHIR_CALL_METHOD(NULL, &assets, "next", NULL, 0); + zephir_check_call_status(); } -vv162: - ++VVCURSOR; - { - s->mode = PHVOLT_MODE_RAW; - s->whitespace_control = 1; - token->opcode = PHVOLT_T_CLOSE_EDELIMITER; - return 0; + } + ZEPHIR_INIT_NVAR(&asset); + RETURN_CTOR(&filtered); +} + +static PHP_METHOD(Phalcon_Assets_Manager, exists) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, &name); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, get) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *name_param = NULL, _0, _1, _2; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("collections"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(1 != zephir_array_isset(&_0, &name))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_assets_exception_ce, "The collection does not exist in the manager", "phalcon/Assets/Manager.zep", 289); + return; + } + zephir_read_property(&_1, this_ptr, ZEND_STRL("collections"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_2, &_1, &name, PH_NOISY | PH_READONLY, "phalcon/Assets/Manager.zep", 292); + RETURN_CTOR(&_2); +} + +static PHP_METHOD(Phalcon_Assets_Manager, getCollections) +{ + + RETURN_MEMBER(getThis(), "collections"); +} + +static PHP_METHOD(Phalcon_Assets_Manager, getCss) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "css"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checkandcreatecollection", NULL, 171, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, getJs) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "js"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checkandcreatecollection", NULL, 171, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, getOptions) +{ + + RETURN_MEMBER(getThis(), "options"); +} + +static PHP_METHOD(Phalcon_Assets_Manager, has) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *name_param = NULL, _0; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("collections"), PH_NOISY_CC | PH_READONLY); + RETURN_MM_BOOL(zephir_array_isset(&_0, &name)); +} + +static PHP_METHOD(Phalcon_Assets_Manager, output) +{ + zend_bool filterNeeded = 0, _57; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_22 = NULL, *_25 = NULL, *_33 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval type, output; + zval *collection, collection_sub, *type_param = NULL, asset, assets, callback, callbackMethod, collectionSourcePath, collectionTargetPath, completeSourcePath, completeTargetPath, content, filter, filters, filteredContent, filteredJoinedContent, html, join, mustFilter, options, prefixedPath, sourceBasePath, sourcePath, targetBasePath, targetPath, typeCss, _0, _1, _2, *_8, _9, _3$$9, _4$$9, _5$$8, _6$$10, _7$$10, _10$$12, _15$$12, _11$$14, _12$$14, _13$$15, _14$$15, _16$$17, _17$$17, _18$$18, _19$$18, _20$$21, _21$$21, _23$$21, _24$$21, _26$$21, *_27$$25, _28$$25, _29$$30, _30$$36, _31$$36, _32$$36, _34$$36, _35$$40, _40$$40, _36$$42, _37$$42, _38$$43, _39$$43, _41$$45, _42$$45, _43$$46, _44$$46, _45$$49, _46$$49, _47$$49, _48$$49, _49$$49, *_50$$53, _51$$53, _52$$58, _53$$64, _54$$64, _55$$64, _56$$64, _58$$67, _59$$67, _60$$67, _61$$67; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&collection_sub); + ZVAL_UNDEF(&asset); + ZVAL_UNDEF(&assets); + ZVAL_UNDEF(&callback); + ZVAL_UNDEF(&callbackMethod); + ZVAL_UNDEF(&collectionSourcePath); + ZVAL_UNDEF(&collectionTargetPath); + ZVAL_UNDEF(&completeSourcePath); + ZVAL_UNDEF(&completeTargetPath); + ZVAL_UNDEF(&content); + ZVAL_UNDEF(&filter); + ZVAL_UNDEF(&filters); + ZVAL_UNDEF(&filteredContent); + ZVAL_UNDEF(&filteredJoinedContent); + ZVAL_UNDEF(&html); + ZVAL_UNDEF(&join); + ZVAL_UNDEF(&mustFilter); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&prefixedPath); + ZVAL_UNDEF(&sourceBasePath); + ZVAL_UNDEF(&sourcePath); + ZVAL_UNDEF(&targetBasePath); + ZVAL_UNDEF(&targetPath); + ZVAL_UNDEF(&typeCss); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_3$$9); + ZVAL_UNDEF(&_4$$9); + ZVAL_UNDEF(&_5$$8); + ZVAL_UNDEF(&_6$$10); + ZVAL_UNDEF(&_7$$10); + ZVAL_UNDEF(&_10$$12); + ZVAL_UNDEF(&_15$$12); + ZVAL_UNDEF(&_11$$14); + ZVAL_UNDEF(&_12$$14); + ZVAL_UNDEF(&_13$$15); + ZVAL_UNDEF(&_14$$15); + ZVAL_UNDEF(&_16$$17); + ZVAL_UNDEF(&_17$$17); + ZVAL_UNDEF(&_18$$18); + ZVAL_UNDEF(&_19$$18); + ZVAL_UNDEF(&_20$$21); + ZVAL_UNDEF(&_21$$21); + ZVAL_UNDEF(&_23$$21); + ZVAL_UNDEF(&_24$$21); + ZVAL_UNDEF(&_26$$21); + ZVAL_UNDEF(&_28$$25); + ZVAL_UNDEF(&_29$$30); + ZVAL_UNDEF(&_30$$36); + ZVAL_UNDEF(&_31$$36); + ZVAL_UNDEF(&_32$$36); + ZVAL_UNDEF(&_34$$36); + ZVAL_UNDEF(&_35$$40); + ZVAL_UNDEF(&_40$$40); + ZVAL_UNDEF(&_36$$42); + ZVAL_UNDEF(&_37$$42); + ZVAL_UNDEF(&_38$$43); + ZVAL_UNDEF(&_39$$43); + ZVAL_UNDEF(&_41$$45); + ZVAL_UNDEF(&_42$$45); + ZVAL_UNDEF(&_43$$46); + ZVAL_UNDEF(&_44$$46); + ZVAL_UNDEF(&_45$$49); + ZVAL_UNDEF(&_46$$49); + ZVAL_UNDEF(&_47$$49); + ZVAL_UNDEF(&_48$$49); + ZVAL_UNDEF(&_49$$49); + ZVAL_UNDEF(&_51$$53); + ZVAL_UNDEF(&_52$$58); + ZVAL_UNDEF(&_53$$64); + ZVAL_UNDEF(&_54$$64); + ZVAL_UNDEF(&_55$$64); + ZVAL_UNDEF(&_56$$64); + ZVAL_UNDEF(&_58$$67); + ZVAL_UNDEF(&_59$$67); + ZVAL_UNDEF(&_60$$67); + ZVAL_UNDEF(&_61$$67); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&output); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(collection, phalcon_assets_collection_ce) + Z_PARAM_STR(type) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &collection, &type_param); + zephir_get_strval(&type, type_param); + ZEPHIR_INIT_VAR(&completeSourcePath); + ZVAL_STRING(&completeSourcePath, ""); + ZEPHIR_INIT_VAR(&completeTargetPath); + ZVAL_STRING(&completeTargetPath, ""); + ZEPHIR_INIT_VAR(&filteredContent); + ZVAL_STRING(&filteredContent, ""); + ZEPHIR_INIT_VAR(&filteredJoinedContent); + ZVAL_STRING(&filteredJoinedContent, ""); + ZEPHIR_INIT_VAR(&join); + ZVAL_BOOL(&join, 0); + ZEPHIR_INIT_VAR(&output); + zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&options, &_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "css"); + if (ZEPHIR_IS_IDENTICAL(&_1, &type)) { + ZEPHIR_INIT_VAR(&callbackMethod); + ZVAL_STRING(&callbackMethod, "cssLink"); + } else { + ZEPHIR_INIT_NVAR(&callbackMethod); + ZVAL_STRING(&callbackMethod, "jsLink"); + } + ZEPHIR_INIT_VAR(&callback); + zephir_create_array(&callback, 2, 0); + zephir_array_fast_append(&callback, this_ptr); + zephir_array_fast_append(&callback, &callbackMethod); + ZEPHIR_CALL_METHOD(&_2, collection, "getassets", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&assets, this_ptr, "collectionassetsbytype", NULL, 0, &_2, &type); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&filters, collection, "getfilters", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&typeCss); + ZVAL_STRING(&typeCss, "css"); + if (1 != ZEPHIR_IS_EMPTY(&filters)) { + zephir_memory_observe(&sourceBasePath); + if (!(zephir_array_isset_string_fetch(&sourceBasePath, &options, SL("sourceBasePath"), 0))) { + ZEPHIR_INIT_NVAR(&sourceBasePath); + ZVAL_STRING(&sourceBasePath, ""); } -vv164: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto vv164; - default: goto vv166; - } -vv166: - { - token->opcode = PHVOLT_T_DOUBLE; - token->value = estrndup(start, VVCURSOR - start); - token->len = VVCURSOR - start; - return 0; + zephir_memory_observe(&targetBasePath); + if (!(zephir_array_isset_string_fetch(&targetBasePath, &options, SL("targetBasePath"), 0))) { + ZEPHIR_INIT_NVAR(&targetBasePath); + ZVAL_STRING(&targetBasePath, ""); } -vv167: - ++VVCURSOR; - { - token->opcode = PHVOLT_T_IDENTICAL; - return 0; + ZEPHIR_CALL_METHOD(&collectionSourcePath, collection, "getsourcepath", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&completeSourcePath, &sourceBasePath); + if (1 != ZEPHIR_IS_EMPTY(&collectionSourcePath)) { + zephir_concat_self(&completeSourcePath, &collectionSourcePath); } -vv169: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv170; - } -vv170: - { - token->opcode = PHVOLT_T_AND; - return 0; + ZEPHIR_CALL_METHOD(&collectionTargetPath, collection, "gettargetpath", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&completeTargetPath, &targetBasePath); + if (1 != ZEPHIR_IS_EMPTY(&collectionTargetPath)) { + zephir_concat_self(&completeTargetPath, &collectionTargetPath); } -vv171: - vvch = *++VVCURSOR; - switch (vvch) { - case 'O': - case 'o': goto vv211; - default: goto vv54; - } -vv172: - vvch = *++VVCURSOR; - switch (vvch) { - case 'C': - case 'c': goto vv212; - default: goto vv54; - } -vv173: - vvch = *++VVCURSOR; - switch (vvch) { - case 'A': - case 'a': goto vv213; - default: goto vv54; - } -vv174: - vvch = *++VVCURSOR; - switch (vvch) { - case 'H': - case 'h': goto vv214; - default: goto vv54; - } -vv175: - vvch = *++VVCURSOR; - switch (vvch) { - case 'L': - case 'l': goto vv215; - default: goto vv54; - } -vv176: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv217; - default: goto vv54; - } -vv177: - vvch = *++VVCURSOR; - switch (vvch) { - case 'T': - case 't': goto vv219; - default: goto vv54; - } -vv178: - vvch = *++VVCURSOR; - switch (vvch) { - case 'A': - case 'a': goto vv220; - case 'I': - case 'i': goto vv221; - default: goto vv54; - } -vv179: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv222; - default: goto vv54; - } -vv180: - vvch = *++VVCURSOR; - switch (vvch) { - case 'T': - case 't': goto vv224; - default: goto vv54; - } -vv181: - vvch = *++VVCURSOR; - switch (vvch) { - case 'A': - case 'a': goto vv225; - case 'B': - case 'b': goto vv226; - case 'C': - case 'c': goto vv227; - case 'F': - case 'f': goto vv228; - case 'I': - case 'i': goto vv229; - case 'M': - case 'm': goto vv230; - case 'R': - case 'r': goto vv231; - case 'S': - case 's': goto vv232; - default: goto vv54; - } -vv182: - vvch = *++VVCURSOR; - switch (vvch) { - case 'N': - case 'n': goto vv233; - default: goto vv54; - } -vv183: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv235; - default: goto vv54; - } -vv184: - vvch = *++VVCURSOR; - switch (vvch) { - case 'S': - case 's': goto vv236; - default: goto vv54; + ZEPHIR_INIT_NVAR(&filteredJoinedContent); + ZVAL_STRING(&filteredJoinedContent, ""); + ZEPHIR_CALL_METHOD(&join, collection, "getjoin", NULL, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&join))) { + if (1 == ZEPHIR_IS_EMPTY(&completeTargetPath)) { + ZEPHIR_INIT_VAR(&_3$$9); + object_init_ex(&_3$$9, phalcon_assets_exception_ce); + ZEPHIR_INIT_VAR(&_4$$9); + ZEPHIR_CONCAT_SVS(&_4$$9, "Path '", &completeTargetPath, "' is not a valid target path (1)"); + ZEPHIR_CALL_METHOD(NULL, &_3$$9, "__construct", NULL, 33, &_4$$9); + zephir_check_call_status(); + zephir_throw_exception_debug(&_3$$9, "phalcon/Assets/Manager.zep", 457); + ZEPHIR_MM_RESTORE(); + return; } -vv185: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv186; + ZEPHIR_CALL_FUNCTION(&_5$$8, "is_dir", NULL, 137, &completeTargetPath); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_5$$8)) { + ZEPHIR_INIT_VAR(&_6$$10); + object_init_ex(&_6$$10, phalcon_assets_exception_ce); + ZEPHIR_INIT_VAR(&_7$$10); + ZEPHIR_CONCAT_SVS(&_7$$10, "Path '", &completeTargetPath, "' is not a valid target path (2), it is a directory."); + ZEPHIR_CALL_METHOD(NULL, &_6$$10, "__construct", NULL, 33, &_7$$10); + zephir_check_call_status(); + zephir_throw_exception_debug(&_6$$10, "phalcon/Assets/Manager.zep", 463); + ZEPHIR_MM_RESTORE(); + return; } -vv186: - { - s->statement_position++; - token->opcode = PHVOLT_T_FOR; - return 0; } -vv187: - vvch = *++VVCURSOR; - switch (vvch) { - case 'L': - case 'l': goto vv237; - default: goto vv54; + } + zephir_is_iterable(&assets, 0, "phalcon/Assets/Manager.zep", 652); + if (Z_TYPE_P(&assets) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&assets), _8) + { + ZEPHIR_INIT_NVAR(&asset); + ZVAL_COPY(&asset, _8); + filterNeeded = 0; + if (1 != ZEPHIR_IS_EMPTY(&filters)) { + ZEPHIR_CALL_METHOD(&sourcePath, &asset, "getpath", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_10$$12, &asset, "islocal", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_10$$12)) { + filterNeeded = 1; + ZEPHIR_CALL_METHOD(&sourcePath, &asset, "getrealsourcepath", NULL, 0, &completeSourcePath); + zephir_check_call_status(); + if (1 == ZEPHIR_IS_EMPTY(&sourcePath)) { + ZEPHIR_CALL_METHOD(&sourcePath, &asset, "getpath", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_11$$14); + object_init_ex(&_11$$14, phalcon_assets_exception_ce); + ZEPHIR_INIT_NVAR(&_12$$14); + ZEPHIR_CONCAT_SVS(&_12$$14, "Asset '", &sourcePath, "' does not have a valid source path"); + ZEPHIR_CALL_METHOD(NULL, &_11$$14, "__construct", NULL, 33, &_12$$14); + zephir_check_call_status(); + zephir_throw_exception_debug(&_11$$14, "phalcon/Assets/Manager.zep", 493); + ZEPHIR_MM_RESTORE(); + return; + } + } + ZEPHIR_CALL_METHOD(&targetPath, &asset, "getrealtargetpath", NULL, 0, &completeTargetPath); + zephir_check_call_status(); + if (1 == ZEPHIR_IS_EMPTY(&targetPath)) { + ZEPHIR_INIT_NVAR(&_13$$15); + object_init_ex(&_13$$15, phalcon_assets_exception_ce); + ZEPHIR_INIT_NVAR(&_14$$15); + ZEPHIR_CONCAT_SVS(&_14$$15, "Asset '", &sourcePath, "' does not have a valid target path"); + ZEPHIR_CALL_METHOD(NULL, &_13$$15, "__construct", NULL, 33, &_14$$15); + zephir_check_call_status(); + zephir_throw_exception_debug(&_13$$15, "phalcon/Assets/Manager.zep", 509); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&_15$$12, &asset, "islocal", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_15$$12)) { + if (ZEPHIR_IS_IDENTICAL(&targetPath, &sourcePath)) { + ZEPHIR_INIT_NVAR(&_16$$17); + object_init_ex(&_16$$17, phalcon_assets_exception_ce); + ZEPHIR_INIT_NVAR(&_17$$17); + ZEPHIR_CONCAT_SVS(&_17$$17, "Asset '", &targetPath, "' have the same source and target paths"); + ZEPHIR_CALL_METHOD(NULL, &_16$$17, "__construct", NULL, 33, &_17$$17); + zephir_check_call_status(); + zephir_throw_exception_debug(&_16$$17, "phalcon/Assets/Manager.zep", 519); + ZEPHIR_MM_RESTORE(); + return; + } + if (1 == (zephir_file_exists(&targetPath) == SUCCESS)) { + ZEPHIR_INIT_NVAR(&_18$$18); + zephir_filemtime(&_18$$18, &targetPath); + ZEPHIR_INIT_NVAR(&_19$$18); + zephir_filemtime(&_19$$18, &sourcePath); + if (!ZEPHIR_IS_IDENTICAL(&_18$$18, &_19$$18)) { + filterNeeded = 1; + } + } else { + filterNeeded = 1; + } + } + } else { + ZEPHIR_CALL_METHOD(&_20$$21, &asset, "getrealtargeturi", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_21$$21, &asset, "getrealsourcepath", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&prefixedPath, this_ptr, "calculateprefixedpath", &_22, 176, collection, &_20$$21, &_21$$21); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_23$$21, &asset, "getattributes", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_24$$21, &asset, "islocal", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&html, this_ptr, "docallback", &_25, 177, &callback, &_23$$21, &prefixedPath, &_24$$21); + zephir_check_call_status(); + zephir_read_property(&_26$$21, this_ptr, ZEND_STRL("implicitOutput"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_26$$21)) { + zend_print_zval(&html, 0); + } else { + zephir_concat_self(&output, &html); + } + continue; } -vv188: - vvch = *++VVCURSOR; - switch (vvch) { - case 'N': - case 'n': goto vv238; - default: goto vv81; + if (filterNeeded) { + ZEPHIR_CALL_METHOD(&content, &asset, "getcontent", NULL, 0, &completeSourcePath); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&mustFilter, &asset, "getfilter", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&mustFilter)) { + zephir_is_iterable(&filters, 0, "phalcon/Assets/Manager.zep", 595); + if (Z_TYPE_P(&filters) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&filters), _27$$25) + { + ZEPHIR_INIT_NVAR(&filter); + ZVAL_COPY(&filter, _27$$25); + if (1 != Z_TYPE_P(&filter) == IS_OBJECT) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_assets_exception_ce, "Filter is invalid", "phalcon/Assets/Manager.zep", 581); + return; + } + ZEPHIR_CALL_METHOD(&filteredContent, &filter, "filter", NULL, 0, &content); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&content, &filteredContent); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &filters, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_28$$25, &filters, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_28$$25)) { + break; + } + ZEPHIR_CALL_METHOD(&filter, &filters, "current", NULL, 0); + zephir_check_call_status(); + if (1 != Z_TYPE_P(&filter) == IS_OBJECT) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_assets_exception_ce, "Filter is invalid", "phalcon/Assets/Manager.zep", 581); + return; + } + ZEPHIR_CALL_METHOD(&filteredContent, &filter, "filter", NULL, 0, &content); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&content, &filteredContent); + ZEPHIR_CALL_METHOD(NULL, &filters, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&filter); + if (zephir_is_true(&join)) { + zephir_concat_self(&filteredJoinedContent, &filteredContent); + ZEPHIR_CALL_METHOD(&_29$$30, &asset, "gettype", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_IDENTICAL(&_29$$30, &typeCss)) { + zephir_concat_self_str(&filteredJoinedContent, SL(";")); + } + } + } else { + if (zephir_is_true(&join)) { + zephir_concat_self(&filteredJoinedContent, &content); + } else { + ZEPHIR_CPY_WRT(&filteredContent, &content); + } + } + if (!zephir_is_true(&join)) { + zephir_file_put_contents(NULL, &targetPath, &filteredContent); + } } -vv189: - vvch = *++VVCURSOR; - switch (vvch) { - case 'R': - case 'r': goto vv239; - default: goto vv54; + if (!zephir_is_true(&join)) { + ZEPHIR_CALL_METHOD(&_30$$36, &asset, "getrealtargeturi", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_31$$36, &asset, "getrealsourcepath", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&prefixedPath, this_ptr, "calculateprefixedpath", &_22, 176, collection, &_30$$36, &_31$$36); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_32$$36, collection, "getattributes", &_33, 0); + zephir_check_call_status(); + ZVAL_BOOL(&_34$$36, 1); + ZEPHIR_CALL_METHOD(&html, this_ptr, "docallback", &_25, 177, &callback, &_32$$36, &prefixedPath, &_34$$36); + zephir_check_call_status(); + zephir_read_property(&_34$$36, this_ptr, ZEND_STRL("implicitOutput"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_34$$36)) { + zend_print_zval(&html, 0); + } else { + zephir_concat_self(&output, &html); + } } -vv190: - vvch = *++VVCURSOR; - switch (vvch) { - case 'R': - case 'r': goto vv240; - default: goto vv54; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &assets, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_9, &assets, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_9)) { + break; } -vv191: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv192; + ZEPHIR_CALL_METHOD(&asset, &assets, "current", NULL, 0); + zephir_check_call_status(); + filterNeeded = 0; + if (1 != ZEPHIR_IS_EMPTY(&filters)) { + ZEPHIR_CALL_METHOD(&sourcePath, &asset, "getpath", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_35$$40, &asset, "islocal", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_35$$40)) { + filterNeeded = 1; + ZEPHIR_CALL_METHOD(&sourcePath, &asset, "getrealsourcepath", NULL, 0, &completeSourcePath); + zephir_check_call_status(); + if (1 == ZEPHIR_IS_EMPTY(&sourcePath)) { + ZEPHIR_CALL_METHOD(&sourcePath, &asset, "getpath", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_36$$42); + object_init_ex(&_36$$42, phalcon_assets_exception_ce); + ZEPHIR_INIT_NVAR(&_37$$42); + ZEPHIR_CONCAT_SVS(&_37$$42, "Asset '", &sourcePath, "' does not have a valid source path"); + ZEPHIR_CALL_METHOD(NULL, &_36$$42, "__construct", NULL, 33, &_37$$42); + zephir_check_call_status(); + zephir_throw_exception_debug(&_36$$42, "phalcon/Assets/Manager.zep", 493); + ZEPHIR_MM_RESTORE(); + return; + } + } + ZEPHIR_CALL_METHOD(&targetPath, &asset, "getrealtargetpath", NULL, 0, &completeTargetPath); + zephir_check_call_status(); + if (1 == ZEPHIR_IS_EMPTY(&targetPath)) { + ZEPHIR_INIT_NVAR(&_38$$43); + object_init_ex(&_38$$43, phalcon_assets_exception_ce); + ZEPHIR_INIT_NVAR(&_39$$43); + ZEPHIR_CONCAT_SVS(&_39$$43, "Asset '", &sourcePath, "' does not have a valid target path"); + ZEPHIR_CALL_METHOD(NULL, &_38$$43, "__construct", NULL, 33, &_39$$43); + zephir_check_call_status(); + zephir_throw_exception_debug(&_38$$43, "phalcon/Assets/Manager.zep", 509); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&_40$$40, &asset, "islocal", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_40$$40)) { + if (ZEPHIR_IS_IDENTICAL(&targetPath, &sourcePath)) { + ZEPHIR_INIT_NVAR(&_41$$45); + object_init_ex(&_41$$45, phalcon_assets_exception_ce); + ZEPHIR_INIT_NVAR(&_42$$45); + ZEPHIR_CONCAT_SVS(&_42$$45, "Asset '", &targetPath, "' have the same source and target paths"); + ZEPHIR_CALL_METHOD(NULL, &_41$$45, "__construct", NULL, 33, &_42$$45); + zephir_check_call_status(); + zephir_throw_exception_debug(&_41$$45, "phalcon/Assets/Manager.zep", 519); + ZEPHIR_MM_RESTORE(); + return; + } + if (1 == (zephir_file_exists(&targetPath) == SUCCESS)) { + ZEPHIR_INIT_NVAR(&_43$$46); + zephir_filemtime(&_43$$46, &targetPath); + ZEPHIR_INIT_NVAR(&_44$$46); + zephir_filemtime(&_44$$46, &sourcePath); + if (!ZEPHIR_IS_IDENTICAL(&_43$$46, &_44$$46)) { + filterNeeded = 1; + } + } else { + filterNeeded = 1; + } + } + } else { + ZEPHIR_CALL_METHOD(&_45$$49, &asset, "getrealtargeturi", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_46$$49, &asset, "getrealsourcepath", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&prefixedPath, this_ptr, "calculateprefixedpath", &_22, 176, collection, &_45$$49, &_46$$49); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_47$$49, &asset, "getattributes", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_48$$49, &asset, "islocal", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&html, this_ptr, "docallback", &_25, 177, &callback, &_47$$49, &prefixedPath, &_48$$49); + zephir_check_call_status(); + zephir_read_property(&_49$$49, this_ptr, ZEND_STRL("implicitOutput"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_49$$49)) { + zend_print_zval(&html, 0); + } else { + zephir_concat_self(&output, &html); + } + continue; + } + if (filterNeeded) { + ZEPHIR_CALL_METHOD(&content, &asset, "getcontent", NULL, 0, &completeSourcePath); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&mustFilter, &asset, "getfilter", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&mustFilter)) { + zephir_is_iterable(&filters, 0, "phalcon/Assets/Manager.zep", 595); + if (Z_TYPE_P(&filters) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&filters), _50$$53) + { + ZEPHIR_INIT_NVAR(&filter); + ZVAL_COPY(&filter, _50$$53); + if (1 != Z_TYPE_P(&filter) == IS_OBJECT) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_assets_exception_ce, "Filter is invalid", "phalcon/Assets/Manager.zep", 581); + return; + } + ZEPHIR_CALL_METHOD(&filteredContent, &filter, "filter", NULL, 0, &content); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&content, &filteredContent); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &filters, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_51$$53, &filters, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_51$$53)) { + break; + } + ZEPHIR_CALL_METHOD(&filter, &filters, "current", NULL, 0); + zephir_check_call_status(); + if (1 != Z_TYPE_P(&filter) == IS_OBJECT) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_assets_exception_ce, "Filter is invalid", "phalcon/Assets/Manager.zep", 581); + return; + } + ZEPHIR_CALL_METHOD(&filteredContent, &filter, "filter", NULL, 0, &content); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&content, &filteredContent); + ZEPHIR_CALL_METHOD(NULL, &filters, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&filter); + if (zephir_is_true(&join)) { + zephir_concat_self(&filteredJoinedContent, &filteredContent); + ZEPHIR_CALL_METHOD(&_52$$58, &asset, "gettype", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_IDENTICAL(&_52$$58, &typeCss)) { + zephir_concat_self_str(&filteredJoinedContent, SL(";")); + } + } + } else { + if (zephir_is_true(&join)) { + zephir_concat_self(&filteredJoinedContent, &content); + } else { + ZEPHIR_CPY_WRT(&filteredContent, &content); + } + } + if (!zephir_is_true(&join)) { + zephir_file_put_contents(NULL, &targetPath, &filteredContent); + } + } + if (!zephir_is_true(&join)) { + ZEPHIR_CALL_METHOD(&_53$$64, &asset, "getrealtargeturi", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_54$$64, &asset, "getrealsourcepath", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&prefixedPath, this_ptr, "calculateprefixedpath", &_22, 176, collection, &_53$$64, &_54$$64); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_55$$64, collection, "getattributes", &_33, 0); + zephir_check_call_status(); + ZVAL_BOOL(&_56$$64, 1); + ZEPHIR_CALL_METHOD(&html, this_ptr, "docallback", &_25, 177, &callback, &_55$$64, &prefixedPath, &_56$$64); + zephir_check_call_status(); + zephir_read_property(&_56$$64, this_ptr, ZEND_STRL("implicitOutput"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_56$$64)) { + zend_print_zval(&html, 0); + } else { + zephir_concat_self(&output, &html); + } + } + ZEPHIR_CALL_METHOD(NULL, &assets, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&asset); + _57 = 1 != ZEPHIR_IS_EMPTY(&filters); + if (_57) { + _57 = zephir_is_true(&join); + } + if (_57) { + zephir_file_put_contents(NULL, &completeTargetPath, &filteredJoinedContent); + ZEPHIR_CALL_METHOD(&_58$$67, collection, "gettargeturi", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&prefixedPath, this_ptr, "calculateprefixedpath", &_22, 176, collection, &_58$$67, &completeTargetPath); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_59$$67, collection, "getattributes", &_33, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_60$$67, collection, "gettargetislocal", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&html, this_ptr, "docallback", &_25, 177, &callback, &_59$$67, &prefixedPath, &_60$$67); + zephir_check_call_status(); + zephir_read_property(&_61$$67, this_ptr, ZEND_STRL("implicitOutput"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_61$$67)) { + zend_print_zval(&html, 0); + } else { + zephir_concat_self(&output, &html); + } + } + RETURN_CTOR(&output); +} + +static PHP_METHOD(Phalcon_Assets_Manager, outputCss) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, collection, _0; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &name_param); + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { + zephir_get_strval(&name, name_param); + } + ZEPHIR_CALL_METHOD(&collection, this_ptr, "getcss", NULL, 0); + zephir_check_call_status(); + if (1 != ZEPHIR_IS_EMPTY(&name)) { + ZEPHIR_CALL_METHOD(&collection, this_ptr, "get", NULL, 0, &name); + zephir_check_call_status(); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "css"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "output", NULL, 0, &collection, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, outputInline) +{ + zval html, joinedContent, output; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *collection, collection_sub, *type, type_sub, attributes, code, codes, content, filter, filters, join, *_0$$3, _1$$3, _25$$3, *_2$$4, _3$$4, _4$$5, _5$$7, _6$$10, _7$$10, _8$$10, _9$$10, _10$$10, *_11$$11, _12$$11, _13$$12, _14$$14, _15$$17, _16$$17, _17$$17, _18$$17, _19$$17, _20$$18, _21$$18, _22$$18, _23$$18, _24$$18; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&collection_sub); + ZVAL_UNDEF(&type_sub); + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&code); + ZVAL_UNDEF(&codes); + ZVAL_UNDEF(&content); + ZVAL_UNDEF(&filter); + ZVAL_UNDEF(&filters); + ZVAL_UNDEF(&join); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_25$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_6$$10); + ZVAL_UNDEF(&_7$$10); + ZVAL_UNDEF(&_8$$10); + ZVAL_UNDEF(&_9$$10); + ZVAL_UNDEF(&_10$$10); + ZVAL_UNDEF(&_12$$11); + ZVAL_UNDEF(&_13$$12); + ZVAL_UNDEF(&_14$$14); + ZVAL_UNDEF(&_15$$17); + ZVAL_UNDEF(&_16$$17); + ZVAL_UNDEF(&_17$$17); + ZVAL_UNDEF(&_18$$17); + ZVAL_UNDEF(&_19$$17); + ZVAL_UNDEF(&_20$$18); + ZVAL_UNDEF(&_21$$18); + ZVAL_UNDEF(&_22$$18); + ZVAL_UNDEF(&_23$$18); + ZVAL_UNDEF(&_24$$18); + ZVAL_UNDEF(&html); + ZVAL_UNDEF(&joinedContent); + ZVAL_UNDEF(&output); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(collection, phalcon_assets_collection_ce) + Z_PARAM_ZVAL(type) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &collection, &type); + ZEPHIR_INIT_VAR(&output); + ZEPHIR_INIT_VAR(&html); + ZEPHIR_INIT_VAR(&joinedContent); + ZEPHIR_CALL_METHOD(&codes, collection, "getcodes", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&filters, collection, "getfilters", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&join, collection, "getjoin", NULL, 0); + zephir_check_call_status(); + if (1 != ZEPHIR_IS_EMPTY(&codes)) { + zephir_is_iterable(&codes, 0, "phalcon/Assets/Manager.zep", 764); + if (Z_TYPE_P(&codes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&codes), _0$$3) + { + ZEPHIR_INIT_NVAR(&code); + ZVAL_COPY(&code, _0$$3); + ZEPHIR_CALL_METHOD(&attributes, &code, "getattributes", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&content, &code, "getcontent", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&filters, 0, "phalcon/Assets/Manager.zep", 752); + if (Z_TYPE_P(&filters) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&filters), _2$$4) + { + ZEPHIR_INIT_NVAR(&filter); + ZVAL_COPY(&filter, _2$$4); + if (Z_TYPE_P(&filter) != IS_OBJECT) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_assets_exception_ce, "The filter is not valid", "phalcon/Assets/Manager.zep", 742); + return; + } + ZEPHIR_CALL_METHOD(&_4$$5, &filter, "filter", NULL, 0, &content); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&content, &_4$$5); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &filters, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3$$4, &filters, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3$$4)) { + break; + } + ZEPHIR_CALL_METHOD(&filter, &filters, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&filter) != IS_OBJECT) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_assets_exception_ce, "The filter is not valid", "phalcon/Assets/Manager.zep", 742); + return; + } + ZEPHIR_CALL_METHOD(&_5$$7, &filter, "filter", NULL, 0, &content); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&content, &_5$$7); + ZEPHIR_CALL_METHOD(NULL, &filters, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&filter); + if (ZEPHIR_IS_TRUE_IDENTICAL(&join)) { + zephir_concat_self(&joinedContent, &content); + } else { + zephir_read_property(&_6$$10, this_ptr, ZEND_STRL("tagFactory"), PH_NOISY_CC | PH_READONLY); + ZVAL_BOOL(&_8$$10, 1); + ZEPHIR_CALL_METHOD(&_7$$10, &_6$$10, "element", NULL, 0, type, &content, &attributes, &_8$$10); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_9$$10); + ZEPHIR_GET_CONSTANT(&_9$$10, "PHP_EOL"); + ZEPHIR_INIT_NVAR(&_10$$10); + ZEPHIR_CONCAT_VV(&_10$$10, &_7$$10, &_9$$10); + zephir_concat_self(&html, &_10$$10); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &codes, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1$$3, &codes, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&code, &codes, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&attributes, &code, "getattributes", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&content, &code, "getcontent", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&filters, 0, "phalcon/Assets/Manager.zep", 752); + if (Z_TYPE_P(&filters) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&filters), _11$$11) + { + ZEPHIR_INIT_NVAR(&filter); + ZVAL_COPY(&filter, _11$$11); + if (Z_TYPE_P(&filter) != IS_OBJECT) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_assets_exception_ce, "The filter is not valid", "phalcon/Assets/Manager.zep", 742); + return; + } + ZEPHIR_CALL_METHOD(&_13$$12, &filter, "filter", NULL, 0, &content); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&content, &_13$$12); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &filters, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_12$$11, &filters, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_12$$11)) { + break; + } + ZEPHIR_CALL_METHOD(&filter, &filters, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&filter) != IS_OBJECT) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_assets_exception_ce, "The filter is not valid", "phalcon/Assets/Manager.zep", 742); + return; + } + ZEPHIR_CALL_METHOD(&_14$$14, &filter, "filter", NULL, 0, &content); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&content, &_14$$14); + ZEPHIR_CALL_METHOD(NULL, &filters, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&filter); + if (ZEPHIR_IS_TRUE_IDENTICAL(&join)) { + zephir_concat_self(&joinedContent, &content); + } else { + zephir_read_property(&_15$$17, this_ptr, ZEND_STRL("tagFactory"), PH_NOISY_CC | PH_READONLY); + ZVAL_BOOL(&_17$$17, 1); + ZEPHIR_CALL_METHOD(&_16$$17, &_15$$17, "element", NULL, 0, type, &content, &attributes, &_17$$17); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_18$$17); + ZEPHIR_GET_CONSTANT(&_18$$17, "PHP_EOL"); + ZEPHIR_INIT_NVAR(&_19$$17); + ZEPHIR_CONCAT_VV(&_19$$17, &_16$$17, &_18$$17); + zephir_concat_self(&html, &_19$$17); + } + ZEPHIR_CALL_METHOD(NULL, &codes, "next", NULL, 0); + zephir_check_call_status(); } -vv192: - { - s->statement_position++; - token->opcode = PHVOLT_T_NOT; - return 0; } -vv193: - vvch = *++VVCURSOR; - switch (vvch) { - case 'L': - case 'l': goto vv241; - default: goto vv54; - } -vv194: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv243; - default: goto vv54; - } -vv195: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv196; - } -vv196: - { - s->statement_position++; - token->opcode = PHVOLT_T_ODD; - return 0; + ZEPHIR_INIT_NVAR(&code); + if (ZEPHIR_IS_TRUE_IDENTICAL(&join)) { + zephir_read_property(&_20$$18, this_ptr, ZEND_STRL("tagFactory"), PH_NOISY_CC | PH_READONLY); + ZVAL_BOOL(&_22$$18, 1); + ZEPHIR_CALL_METHOD(&_21$$18, &_20$$18, "element", NULL, 0, type, &joinedContent, &attributes, &_22$$18); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_23$$18); + ZEPHIR_GET_CONSTANT(&_23$$18, "PHP_EOL"); + ZEPHIR_INIT_VAR(&_24$$18); + ZEPHIR_CONCAT_VV(&_24$$18, &_21$$18, &_23$$18); + zephir_concat_self(&html, &_24$$18); } -vv197: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv198; - } -vv198: - { - s->statement_position++; - token->opcode = PHVOLT_T_RAW; - return 0; + zephir_read_property(&_25$$3, this_ptr, ZEND_STRL("implicitOutput"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_25$$3)) { + zend_print_zval(&html, 0); + } else { + zephir_concat_self(&output, &html); } -vv199: - vvch = *++VVCURSOR; - switch (vvch) { - case 'U': - case 'u': goto vv244; - default: goto vv54; - } -vv200: - vvch = *++VVCURSOR; - switch (vvch) { - case 'L': - case 'l': goto vv245; - default: goto vv54; - } -vv201: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv202; - } -vv202: - { - if (s->active_token == PHVOLT_T_DOT) { - token->opcode = PHVOLT_T_IDENTIFIER; - token->value = estrndup(start, VVCURSOR - start); - token->len = VVCURSOR - start; - } else { - token->opcode = PHVOLT_T_SET; - } + } + RETURN_CTOR(&output); +} - return 0; +static PHP_METHOD(Phalcon_Assets_Manager, outputInlineCss) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, collection, _0; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &name_param); + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { + zephir_get_strval(&name, name_param); + } + ZEPHIR_CALL_METHOD(&collection, this_ptr, "getcss", NULL, 0); + zephir_check_call_status(); + if (1 != ZEPHIR_IS_EMPTY(&name)) { + ZEPHIR_CALL_METHOD(&collection, this_ptr, "get", NULL, 0, &name); + zephir_check_call_status(); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "style"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "outputinline", NULL, 0, &collection, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, outputInlineJs) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, collection, _0; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &name_param); + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { + zephir_get_strval(&name, name_param); + } + ZEPHIR_CALL_METHOD(&collection, this_ptr, "getjs", NULL, 0); + zephir_check_call_status(); + if (1 != ZEPHIR_IS_EMPTY(&name)) { + ZEPHIR_CALL_METHOD(&collection, this_ptr, "get", NULL, 0, &name); + zephir_check_call_status(); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "script"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "outputinline", NULL, 0, &collection, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, outputJs) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, collection, _0; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &name_param); + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { + zephir_get_strval(&name, name_param); + } + ZEPHIR_CALL_METHOD(&collection, this_ptr, "getjs", NULL, 0); + zephir_check_call_status(); + if (1 != ZEPHIR_IS_EMPTY(&name)) { + ZEPHIR_CALL_METHOD(&collection, this_ptr, "get", NULL, 0, &name); + zephir_check_call_status(); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "js"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "output", NULL, 0, &collection, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, set) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *name_param = NULL, *collection, collection_sub; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&collection_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_OBJECT_OF_CLASS(collection, phalcon_assets_collection_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &name_param, &collection); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_update_property_array(this_ptr, SL("collections"), &name, collection); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, setOptions) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *options_param = NULL; + zval options; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &options_param); + zephir_get_arrval(&options, options_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, useImplicitOutput) +{ + zval *implicitOutput_param = NULL, __$true, __$false; + zend_bool implicitOutput; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(implicitOutput) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &implicitOutput_param); + if (implicitOutput) { + zephir_update_property_zval(this_ptr, ZEND_STRL("implicitOutput"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("implicitOutput"), &__$false); + } + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, calculatePrefixedPath) +{ + zend_bool _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval path, filePath; + zval *collection, collection_sub, *path_param = NULL, *filePath_param = NULL, modificationTime, prefixedPath, version, _0, _1, _3, _4$$3, _5$$4; + + ZVAL_UNDEF(&collection_sub); + ZVAL_UNDEF(&modificationTime); + ZVAL_UNDEF(&prefixedPath); + ZVAL_UNDEF(&version); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&path); + ZVAL_UNDEF(&filePath); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_OBJECT_OF_CLASS(collection, phalcon_assets_collection_ce) + Z_PARAM_STR(path) + Z_PARAM_STR(filePath) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 0, &collection, &path_param, &filePath_param); + zephir_get_strval(&path, path_param); + zephir_get_strval(&filePath, filePath_param); + ZEPHIR_CALL_METHOD(&_0, collection, "getprefix", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&prefixedPath); + ZEPHIR_CONCAT_VV(&prefixedPath, &_0, &path); + ZEPHIR_CALL_METHOD(&version, collection, "getversion", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, collection, "isautoversion", NULL, 0); + zephir_check_call_status(); + _2 = ZEPHIR_IS_TRUE_IDENTICAL(&_1); + if (_2) { + ZEPHIR_CALL_METHOD(&_3, collection, "islocal", NULL, 0); + zephir_check_call_status(); + _2 = ZEPHIR_IS_TRUE_IDENTICAL(&_3); + } + if (_2) { + ZEPHIR_INIT_VAR(&modificationTime); + zephir_filemtime(&modificationTime, &filePath); + ZEPHIR_INIT_VAR(&_4$$3); + if (zephir_is_true(&version)) { + ZEPHIR_INIT_NVAR(&_4$$3); + ZEPHIR_CONCAT_VSV(&_4$$3, &version, ".", &modificationTime); + } else { + ZEPHIR_CPY_WRT(&_4$$3, &modificationTime); } -vv203: - vvch = *++VVCURSOR; - switch (vvch) { - case 'T': - case 't': goto vv246; - default: goto vv54; - } -vv204: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv247; - default: goto vv54; - } -vv205: - vvch = *++VVCURSOR; - switch (vvch) { - case 'H': - case 'h': goto vv249; - default: goto vv54; - } -vv206: - vvch = *++VVCURSOR; - switch (vvch) { - case 'N': - case 'n': goto vv238; - default: goto vv252; - } -vv207: - ++VVCURSOR; - { - s->whitespace_control = 0; - token->opcode = PHVOLT_T_OPEN_DELIMITER; - return 0; + ZEPHIR_CPY_WRT(&version, &_4$$3); + } + if (zephir_is_true(&version)) { + ZEPHIR_INIT_VAR(&_5$$4); + ZEPHIR_CONCAT_VSV(&_5$$4, &prefixedPath, "?ver=", &version); + ZEPHIR_CPY_WRT(&prefixedPath, &_5$$4); + } + RETURN_CCTOR(&prefixedPath); +} + +static PHP_METHOD(Phalcon_Assets_Manager, checkAndCreateCollection) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *type_param = NULL, _0, _2, _3, _1$$3; + zval type; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(type) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &type_param); + zephir_get_strval(&type, type_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("collections"), PH_NOISY_CC | PH_READONLY); + if (1 != zephir_array_isset(&_0, &type)) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_assets_collection_ce); + if (zephir_has_constructor(&_1$$3)) { + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 0); + zephir_check_call_status(); } -vv209: - ++VVCURSOR; - { - s->whitespace_control = 0; - s->statement_position++; - token->opcode = PHVOLT_T_OPEN_EDELIMITER; - return 0; + + zephir_update_property_array(this_ptr, SL("collections"), &type, &_1$$3); + } + zephir_read_property(&_2, this_ptr, ZEND_STRL("collections"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_3, &_2, &type, PH_NOISY | PH_READONLY, "phalcon/Assets/Manager.zep", 928); + RETURN_CTOR(&_3); +} + +static PHP_METHOD(Phalcon_Assets_Manager, cssLink) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool local; + zval *parameters = NULL, parameters_sub, *local_param = NULL, _0, _1, _2, _3; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(¶meters_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL(parameters) + Z_PARAM_BOOL(local) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 2, ¶meters, &local_param); + if (!parameters) { + parameters = ¶meters_sub; + ZEPHIR_INIT_VAR(parameters); + array_init(parameters); + } + if (!local_param) { + local = 1; + } else { } -vv211: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv253; - default: goto vv54; - } -vv212: - vvch = *++VVCURSOR; - switch (vvch) { - case 'K': - case 'k': goto vv254; - default: goto vv54; - } -vv213: - vvch = *++VVCURSOR; - switch (vvch) { - case 'K': - case 'k': goto vv256; - default: goto vv54; - } -vv214: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv258; - default: goto vv54; - } -vv215: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv216; - } -vv216: - { - s->statement_position++; - token->opcode = PHVOLT_T_CALL; - return 0; + if (local) { + ZVAL_BOOL(&_0, 1); + } else { + ZVAL_BOOL(&_0, 0); + } + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "link"); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "text/css"); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "href"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "processparameters", NULL, 178, parameters, &_0, &_1, &_2, &_3); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, doCallback) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool local; + zval prefixedPath; + zval attributes, parameters; + zval *callback, callback_sub, *attributes_param = NULL, *prefixedPath_param = NULL, *local_param = NULL, _1, _0$$4; + + ZVAL_UNDEF(&callback_sub); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(¶meters); + ZVAL_UNDEF(&prefixedPath); + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_ZVAL(callback) + Z_PARAM_ARRAY(attributes) + Z_PARAM_STR(prefixedPath) + Z_PARAM_BOOL(local) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 4, 0, &callback, &attributes_param, &prefixedPath_param, &local_param); + zephir_get_arrval(&attributes, attributes_param); + zephir_get_strval(&prefixedPath, prefixedPath_param); + if (1 != ZEPHIR_IS_EMPTY(&attributes)) { + zephir_array_update_long(&attributes, 0, &prefixedPath, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + ZEPHIR_INIT_VAR(¶meters); + zephir_create_array(¶meters, 1, 0); + zephir_array_fast_append(¶meters, &attributes); + } else { + ZEPHIR_INIT_VAR(&_0$$4); + zephir_create_array(&_0$$4, 1, 0); + zephir_array_fast_append(&_0$$4, &prefixedPath); + ZEPHIR_CPY_WRT(¶meters, &_0$$4); + } + ZEPHIR_INIT_VAR(&_1); + ZVAL_BOOL(&_1, local); + zephir_array_append(¶meters, &_1, PH_SEPARATE, "phalcon/Assets/Manager.zep", 976); + ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, callback, ¶meters); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, jsLink) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool local; + zval *parameters = NULL, parameters_sub, *local_param = NULL, _0, _1, _2, _3; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(¶meters_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL(parameters) + Z_PARAM_BOOL(local) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 2, ¶meters, &local_param); + if (!parameters) { + parameters = ¶meters_sub; + ZEPHIR_INIT_VAR(parameters); + array_init(parameters); + } + if (!local_param) { + local = 1; + } else { } -vv217: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv218; - } -vv218: - { - token->opcode = PHVOLT_T_CASE; - return 0; + if (local) { + ZVAL_BOOL(&_0, 1); + } else { + ZVAL_BOOL(&_0, 0); + } + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "script"); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "application/javascript"); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "src"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "processparameters", NULL, 178, parameters, &_0, &_1, &_2, &_3); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Assets_Manager, processParameters) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval helperClass, type, name, _13; + zend_bool local; + zval *parameters, parameters_sub, *local_param = NULL, *helperClass_param = NULL, *type_param = NULL, *name_param = NULL, helper, output, params, tag, _4, _11, _12, _0$$3, _1$$3, _2$$4, _3$$6, _5$$8, _6$$9, _7$$10, _8$$11, _9$$11, _10$$11; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(¶meters_sub); + ZVAL_UNDEF(&helper); + ZVAL_UNDEF(&output); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&tag); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$6); + ZVAL_UNDEF(&_5$$8); + ZVAL_UNDEF(&_6$$9); + ZVAL_UNDEF(&_7$$10); + ZVAL_UNDEF(&_8$$11); + ZVAL_UNDEF(&_9$$11); + ZVAL_UNDEF(&_10$$11); + ZVAL_UNDEF(&helperClass); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_13); + ZEND_PARSE_PARAMETERS_START(5, 5) + Z_PARAM_ZVAL(parameters) + Z_PARAM_BOOL(local) + Z_PARAM_STR(helperClass) + Z_PARAM_STR(type) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 5, 0, ¶meters, &local_param, &helperClass_param, &type_param, &name_param); + zephir_get_strval(&helperClass, helperClass_param); + zephir_get_strval(&type, type_param); + zephir_get_strval(&name, name_param); + ZEPHIR_CPY_WRT(¶ms, parameters); + if (Z_TYPE_P(¶ms) != IS_ARRAY) { + ZEPHIR_INIT_VAR(&_0$$3); + zephir_create_array(&_0$$3, 2, 0); + zephir_array_fast_append(&_0$$3, parameters); + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_BOOL(&_1$$3, local); + zephir_array_fast_append(&_0$$3, &_1$$3); + ZEPHIR_CPY_WRT(¶ms, &_0$$3); + } + if (1 == zephir_array_isset_long(¶ms, 1)) { + zephir_memory_observe(&_2$$4); + zephir_array_fetch_long(&_2$$4, ¶ms, 1, PH_NOISY, "phalcon/Assets/Manager.zep", 1020); + local = zephir_get_boolval(&_2$$4); + zephir_array_unset_long(¶ms, 1, PH_SEPARATE); + } else { + if (1 == zephir_array_isset_string(¶ms, SL("local"))) { + zephir_memory_observe(&_3$$6); + zephir_array_fetch_string(&_3$$6, ¶ms, SL("local"), PH_NOISY, "phalcon/Assets/Manager.zep", 1024); + local = zephir_get_boolval(&_3$$6); + zephir_array_unset_string(¶ms, SL("local"), PH_SEPARATE); + } + } + if (1 != zephir_array_isset_string(¶ms, SL("type"))) { + zephir_array_update_string(¶ms, SL("type"), &type, PH_COPY | PH_SEPARATE); + } + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "link"); + if (ZEPHIR_IS_IDENTICAL(&_4, &helperClass)) { + ZEPHIR_INIT_VAR(&_5$$8); + ZVAL_STRING(&_5$$8, "stylesheet"); + zephir_array_update_string(¶ms, SL("rel"), &_5$$8, PH_COPY | PH_SEPARATE); + } + if (1 != zephir_array_isset(¶ms, &name)) { + ZEPHIR_INIT_VAR(&_6$$9); + ZVAL_STRING(&_6$$9, ""); + zephir_array_update_zval(¶ms, &name, &_6$$9, PH_COPY | PH_SEPARATE); + if (1 == zephir_array_isset_long(¶ms, 0)) { + zephir_array_fetch_long(&_7$$10, ¶ms, 0, PH_NOISY | PH_READONLY, "phalcon/Assets/Manager.zep", 1044); + zephir_array_update_zval(¶ms, &name, &_7$$10, PH_COPY | PH_SEPARATE); + zephir_array_unset_long(¶ms, 0, PH_SEPARATE); + } + } + zephir_memory_observe(&tag); + zephir_array_fetch(&tag, ¶ms, &name, PH_NOISY, "phalcon/Assets/Manager.zep", 1049); + zephir_array_unset(¶ms, &name, PH_SEPARATE); + if (local) { + ZEPHIR_INIT_VAR(&_8$$11); + ZEPHIR_INIT_VAR(&_9$$11); + ZVAL_STRING(&_9$$11, "/"); + zephir_fast_trim(&_8$$11, &tag, &_9$$11, ZEPHIR_TRIM_LEFT); + ZEPHIR_INIT_VAR(&_10$$11); + ZEPHIR_CONCAT_SV(&_10$$11, "/", &_8$$11); + ZEPHIR_CPY_WRT(&tag, &_10$$11); + } + zephir_read_property(&_11, this_ptr, ZEND_STRL("tagFactory"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&helper, &_11, "newinstance", NULL, 0, &helperClass); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_12); + ZVAL_STRING(&_12, ""); + ZEPHIR_CALL_METHOD(NULL, &helper, "__invoke", NULL, 0, &_12); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &helper, "add", NULL, 0, &tag, ¶ms); + zephir_check_call_status(); + zephir_cast_to_string(&_13, &helper); + ZEPHIR_CPY_WRT(&output, &_13); + ZEPHIR_CALL_METHOD(NULL, &helper, "reset", NULL, 0); + zephir_check_call_status(); + RETURN_CCTOR(&output); +} + +zend_object *zephir_init_properties_Phalcon_Assets_Manager(zend_class_entry *class_type) +{ + zval _0, _2, _1$$3, _3$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_1$$3); } -vv219: - vvch = *++VVCURSOR; - switch (vvch) { - case 'I': - case 'i': goto vv260; - default: goto vv54; - } -vv220: - vvch = *++VVCURSOR; - switch (vvch) { - case 'U': - case 'u': goto vv261; - default: goto vv54; - } -vv221: - vvch = *++VVCURSOR; - switch (vvch) { - case 'N': - case 'n': goto vv262; - default: goto vv54; - } -vv222: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'G': - case 'H': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'g': - case 'h': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - case 'F': - case 'f': goto vv263; - case 'I': - case 'i': goto vv264; - default: goto vv223; - } -vv223: - { - token->opcode = PHVOLT_T_ELSE; - return 0; + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("collections"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("collections"), &_3$$4); } -vv224: - vvch = *++VVCURSOR; - switch (vvch) { - case 'Y': - case 'y': goto vv265; - default: goto vv54; - } -vv225: - vvch = *++VVCURSOR; - switch (vvch) { - case 'U': - case 'u': goto vv267; - default: goto vv54; - } -vv226: - vvch = *++VVCURSOR; - switch (vvch) { - case 'L': - case 'l': goto vv268; - default: goto vv54; - } -vv227: - vvch = *++VVCURSOR; - switch (vvch) { - case 'A': - case 'a': goto vv269; - default: goto vv54; - } -vv228: - vvch = *++VVCURSOR; - switch (vvch) { - case 'O': - case 'o': goto vv270; - default: goto vv54; - } -vv229: - vvch = *++VVCURSOR; - switch (vvch) { - case 'F': - case 'f': goto vv271; - default: goto vv54; - } -vv230: - vvch = *++VVCURSOR; - switch (vvch) { - case 'A': - case 'a': goto vv273; - default: goto vv54; - } -vv231: - vvch = *++VVCURSOR; - switch (vvch) { - case 'A': - case 'a': goto vv274; - default: goto vv54; - } -vv232: - vvch = *++VVCURSOR; - switch (vvch) { - case 'W': - case 'w': goto vv275; - default: goto vv54; - } -vv233: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv234; - } -vv234: - { - s->statement_position++; - token->opcode = PHVOLT_T_EVEN; - return 0; + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Assets_Asset_Css) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Assets\\Asset, Css, phalcon, assets_asset_css, phalcon_assets_asset_ce, phalcon_assets_asset_css_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Assets_Asset_Css, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval attributes; + zend_bool local, filter, autoVersion; + zval *path_param = NULL, *local_param = NULL, *filter_param = NULL, *attributes_param = NULL, *version_param = NULL, *autoVersion_param = NULL, _0, _1, _2, _3; + zval path, version; + + ZVAL_UNDEF(&path); + ZVAL_UNDEF(&version); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&attributes); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 6) + Z_PARAM_STR(path) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(local) + Z_PARAM_BOOL(filter) + Z_PARAM_ARRAY(attributes) + Z_PARAM_STR_OR_NULL(version) + Z_PARAM_BOOL(autoVersion) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 5, &path_param, &local_param, &filter_param, &attributes_param, &version_param, &autoVersion_param); + if (UNEXPECTED(Z_TYPE_P(path_param) != IS_STRING && Z_TYPE_P(path_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(path_param) == IS_STRING)) { + zephir_get_strval(&path, path_param); + } else { + ZEPHIR_INIT_VAR(&path); + } + if (!local_param) { + local = 1; + } else { } -vv235: - vvch = *++VVCURSOR; - switch (vvch) { - case 'N': - case 'n': goto vv276; - default: goto vv54; - } -vv236: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv277; - default: goto vv54; - } -vv237: - vvch = *++VVCURSOR; - switch (vvch) { - case 'U': - case 'u': goto vv279; - default: goto vv54; - } -vv238: - vvch = *++VVCURSOR; - switch (vvch) { - case 'O': - case 'o': goto vv280; - default: goto vv81; - } -vv239: - vvch = *++VVCURSOR; - switch (vvch) { - case 'A': - case 'a': goto vv281; - default: goto vv54; - } -vv240: - vvch = *++VVCURSOR; - switch (vvch) { - case 'O': - case 'o': goto vv282; - default: goto vv54; - } -vv241: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv242; - } -vv242: - { - token->opcode = PHVOLT_T_NULL; - return 0; + if (!filter_param) { + filter = 1; + } else { } -vv243: - vvch = *++VVCURSOR; - switch (vvch) { - case 'R': - case 'r': goto vv284; - default: goto vv54; - } -vv244: - vvch = *++VVCURSOR; - switch (vvch) { - case 'R': - case 'r': goto vv285; - default: goto vv54; - } -vv245: - vvch = *++VVCURSOR; - switch (vvch) { - case 'A': - case 'a': goto vv286; - default: goto vv54; - } -vv246: - vvch = *++VVCURSOR; - switch (vvch) { - case 'C': - case 'c': goto vv287; - default: goto vv54; - } -vv247: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv248; - } -vv248: - { - token->opcode = PHVOLT_T_TRUE; - return 0; + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + if (!version_param) { + ZEPHIR_INIT_VAR(&version); + } else { + zephir_get_strval(&version, version_param); + } + if (!autoVersion_param) { + autoVersion = 0; + } else { } -vv249: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv250; - } -vv250: - { - token->opcode = PHVOLT_T_WITH; - return 0; + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "css"); + if (local) { + ZVAL_BOOL(&_1, 1); + } else { + ZVAL_BOOL(&_1, 0); + } + if (filter) { + ZVAL_BOOL(&_2, 1); + } else { + ZVAL_BOOL(&_2, 0); + } + if (autoVersion) { + ZVAL_BOOL(&_3, 1); + } else { + ZVAL_BOOL(&_3, 0); + } + ZEPHIR_CALL_PARENT(NULL, phalcon_assets_asset_css_ce, getThis(), "__construct", NULL, 0, &_0, &path, &_1, &_2, &attributes, &version, &_3); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Assets_Asset_Js) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Assets\\Asset, Js, phalcon, assets_asset_js, phalcon_assets_asset_ce, phalcon_assets_asset_js_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Assets_Asset_Js, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval attributes; + zend_bool local, filter, autoVersion; + zval *path_param = NULL, *local_param = NULL, *filter_param = NULL, *attributes_param = NULL, *version_param = NULL, *autoVersion_param = NULL, _0, _1, _2, _3; + zval path, version; + + ZVAL_UNDEF(&path); + ZVAL_UNDEF(&version); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&attributes); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 6) + Z_PARAM_STR(path) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(local) + Z_PARAM_BOOL(filter) + Z_PARAM_ARRAY(attributes) + Z_PARAM_STR_OR_NULL(version) + Z_PARAM_BOOL(autoVersion) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 5, &path_param, &local_param, &filter_param, &attributes_param, &version_param, &autoVersion_param); + if (UNEXPECTED(Z_TYPE_P(path_param) != IS_STRING && Z_TYPE_P(path_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'path' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(path_param) == IS_STRING)) { + zephir_get_strval(&path, path_param); + } else { + ZEPHIR_INIT_VAR(&path); + } + if (!local_param) { + local = 1; + } else { } -vv251: - vvch = *++VVCURSOR; -vv252: - switch (vvch) { - case ' ': goto vv251; - case 'n': goto vv288; - default: goto vv81; - } -vv253: - vvch = *++VVCURSOR; - switch (vvch) { - case 'S': - case 's': goto vv289; - default: goto vv54; - } -vv254: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv255; - } -vv255: - { - s->statement_position++; - token->opcode = PHVOLT_T_BLOCK; - return 0; + if (!filter_param) { + filter = 1; + } else { } -vv256: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv257; - } -vv257: - { - s->statement_position++; - token->opcode = PHVOLT_T_BREAK; - return 0; + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + if (!version_param) { + ZEPHIR_INIT_VAR(&version); + } else { + zephir_get_strval(&version, version_param); + } + if (!autoVersion_param) { + autoVersion = 0; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "js"); + if (local) { + ZVAL_BOOL(&_1, 1); + } else { + ZVAL_BOOL(&_1, 0); + } + if (filter) { + ZVAL_BOOL(&_2, 1); + } else { + ZVAL_BOOL(&_2, 0); + } + if (autoVersion) { + ZVAL_BOOL(&_3, 1); + } else { + ZVAL_BOOL(&_3, 0); + } + ZEPHIR_CALL_PARENT(NULL, phalcon_assets_asset_js_ce, getThis(), "__construct", NULL, 0, &_0, &path, &_1, &_2, &attributes, &version, &_3); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Assets_Filters_Cssmin) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Assets\\Filters, Cssmin, phalcon, assets_filters_cssmin, phalcon_assets_filters_cssmin_method_entry, 0); + + zend_class_implements(phalcon_assets_filters_cssmin_ce, 1, phalcon_assets_filterinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Assets_Filters_Cssmin, filter) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *content_param = NULL; + zval content; + + ZVAL_UNDEF(&content); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(content) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &content_param); + if (UNEXPECTED(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 of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(content_param) == IS_STRING)) { + zephir_get_strval(&content, content_param); + } else { + ZEPHIR_INIT_VAR(&content); + } + RETURN_CTOR(&content); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Assets_Filters_Jsmin) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Assets\\Filters, Jsmin, phalcon, assets_filters_jsmin, phalcon_assets_filters_jsmin_method_entry, 0); + + zend_class_implements(phalcon_assets_filters_jsmin_ce, 1, phalcon_assets_filterinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Assets_Filters_Jsmin, filter) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *content_param = NULL; + zval content; + + ZVAL_UNDEF(&content); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(content) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &content_param); + if (UNEXPECTED(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 of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(content_param) == IS_STRING)) { + zephir_get_strval(&content, content_param); + } else { + ZEPHIR_INIT_VAR(&content); + } + RETURN_CTOR(&content); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Assets_Filters_None) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Assets\\Filters, None, phalcon, assets_filters_none, phalcon_assets_filters_none_method_entry, 0); + + zend_class_implements(phalcon_assets_filters_none_ce, 1, phalcon_assets_filterinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Assets_Filters_None, filter) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *content_param = NULL; + zval content; + + ZVAL_UNDEF(&content); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(content) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &content_param); + if (UNEXPECTED(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 of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(content_param) == IS_STRING)) { + zephir_get_strval(&content, content_param); + } else { + ZEPHIR_INIT_VAR(&content); + } + RETURN_CTOR(&content); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Assets_Inline_Css) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Assets\\Inline, Css, phalcon, assets_inline_css, phalcon_assets_inline_ce, phalcon_assets_inline_css_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Assets_Inline_Css, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval attributes; + zend_bool filter; + zval *content_param = NULL, *filter_param = NULL, *attributes_param = NULL, _0$$3, _1, _2; + zval content; + + ZVAL_UNDEF(&content); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&attributes); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(content) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(filter) + Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &content_param, &filter_param, &attributes_param); + zephir_get_strval(&content, content_param); + if (!filter_param) { + filter = 1; + } else { } -vv258: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv259; - } -vv259: - { - s->statement_position++; - token->opcode = PHVOLT_T_CACHE; - return 0; + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + if (1 == ZEPHIR_IS_EMPTY(&attributes)) { + ZEPHIR_INIT_VAR(&_0$$3); + zephir_create_array(&_0$$3, 1, 0); + add_assoc_stringl_ex(&_0$$3, SL("type"), SL("text/css")); + ZEPHIR_CPY_WRT(&attributes, &_0$$3); + } + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "css"); + if (filter) { + ZVAL_BOOL(&_2, 1); + } else { + ZVAL_BOOL(&_2, 0); + } + ZEPHIR_CALL_PARENT(NULL, phalcon_assets_inline_css_ce, getThis(), "__construct", NULL, 0, &_1, &content, &_2, &attributes); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Assets_Inline_Js) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Assets\\Inline, Js, phalcon, assets_inline_js, phalcon_assets_inline_ce, phalcon_assets_inline_js_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Assets_Inline_Js, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval attributes; + zend_bool filter; + zval *content_param = NULL, *filter_param = NULL, *attributes_param = NULL, _0$$3, _1, _2; + zval content; + + ZVAL_UNDEF(&content); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&attributes); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(content) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(filter) + Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &content_param, &filter_param, &attributes_param); + zephir_get_strval(&content, content_param); + if (!filter_param) { + filter = 1; + } else { } -vv260: - vvch = *++VVCURSOR; - switch (vvch) { - case 'N': - case 'n': goto vv290; - default: goto vv54; - } -vv261: - vvch = *++VVCURSOR; - switch (vvch) { - case 'L': - case 'l': goto vv291; - default: goto vv54; - } -vv262: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv292; - default: goto vv54; - } -vv263: - vvch = *++VVCURSOR; - switch (vvch) { - case 'O': - case 'o': goto vv293; - default: goto vv54; - } -vv264: - vvch = *++VVCURSOR; - switch (vvch) { - case 'F': - case 'f': goto vv294; - default: goto vv54; - } -vv265: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv266; - } -vv266: - { - s->statement_position++; - token->opcode = PHVOLT_T_EMPTY; - return 0; + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + if (1 == ZEPHIR_IS_EMPTY(&attributes)) { + ZEPHIR_INIT_VAR(&_0$$3); + zephir_create_array(&_0$$3, 1, 0); + add_assoc_stringl_ex(&_0$$3, SL("type"), SL("application/javascript")); + ZEPHIR_CPY_WRT(&attributes, &_0$$3); + } + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "js"); + if (filter) { + ZVAL_BOOL(&_2, 1); + } else { + ZVAL_BOOL(&_2, 0); + } + ZEPHIR_CALL_PARENT(NULL, phalcon_assets_inline_js_ce, getThis(), "__construct", NULL, 0, &_1, &content, &_2, &attributes); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption, Crypt, phalcon, encryption_crypt, phalcon_encryption_crypt_method_entry, 0); + + zend_declare_property_string(phalcon_encryption_crypt_ce, SL("authData"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_encryption_crypt_ce, SL("authTag"), "", ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_encryption_crypt_ce, SL("authTagLength"), 16, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_encryption_crypt_ce, SL("availableCiphers"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_encryption_crypt_ce, SL("cipher"), "aes-256-cfb", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_encryption_crypt_ce, SL("hashAlgorithm"), "sha256", ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_encryption_crypt_ce, SL("ivLength"), 16, ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_encryption_crypt_ce, SL("key"), "", ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_encryption_crypt_ce, SL("padding"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_encryption_crypt_ce, SL("padFactory"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_encryption_crypt_ce, SL("useSigning"), 1, ZEND_ACC_PROTECTED); + phalcon_encryption_crypt_ce->create_object = zephir_init_properties_Phalcon_Encryption_Crypt; + zephir_declare_class_constant_string(phalcon_encryption_crypt_ce, SL("DEFAULT_ALGORITHM"), "sha256"); + + zephir_declare_class_constant_string(phalcon_encryption_crypt_ce, SL("DEFAULT_CIPHER"), "aes-256-cfb"); + + zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_ANSI_X_923"), 1); + + zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_DEFAULT"), 0); + + zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_ISO_10126"), 3); + + zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_ISO_IEC_7816_4"), 4); + + zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_PKCS7"), 2); + + zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_SPACE"), 6); + + zephir_declare_class_constant_long(phalcon_encryption_crypt_ce, SL("PADDING_ZERO"), 5); + + zend_class_implements(phalcon_encryption_crypt_ce, 1, phalcon_encryption_crypt_cryptinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool useSigning; + zval *cipher_param = NULL, *useSigning_param = NULL, *padFactory = NULL, padFactory_sub, __$null, _0, _1, _2, _3; + zval cipher; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(&padFactory_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 3) + Z_PARAM_OPTIONAL + Z_PARAM_STR(cipher) + Z_PARAM_BOOL(useSigning) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(padFactory, phalcon_encryption_crypt_padfactory_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 3, &cipher_param, &useSigning_param, &padFactory); + if (!cipher_param) { + ZEPHIR_INIT_VAR(&cipher); + ZVAL_STRING(&cipher, "aes-256-cfb"); + } else { + zephir_get_strval(&cipher, cipher_param); + } + if (!useSigning_param) { + useSigning = 1; + } else { } -vv267: - vvch = *++VVCURSOR; - switch (vvch) { - case 'T': - case 't': goto vv296; - default: goto vv54; - } -vv268: - vvch = *++VVCURSOR; - switch (vvch) { - case 'O': - case 'o': goto vv297; - default: goto vv54; - } -vv269: - vvch = *++VVCURSOR; - switch (vvch) { - case 'C': - case 'c': goto vv298; - case 'L': - case 'l': goto vv299; - default: goto vv54; - } -vv270: - vvch = *++VVCURSOR; - switch (vvch) { - case 'R': - case 'r': goto vv300; - default: goto vv54; - } -vv271: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv272; - } -vv272: - { - token->opcode = PHVOLT_T_ENDIF; - return 0; + if (!padFactory) { + padFactory = &padFactory_sub; + ZEPHIR_CPY_WRT(padFactory, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(padFactory); + } + if (Z_TYPE_P(padFactory) == IS_NULL) { + ZEPHIR_INIT_NVAR(padFactory); + object_init_ex(padFactory, phalcon_encryption_crypt_padfactory_ce); + ZEPHIR_CALL_METHOD(NULL, padFactory, "__construct", NULL, 225); + zephir_check_call_status(); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("padFactory"), padFactory); + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "sha256"); + zephir_update_property_zval(this_ptr, ZEND_STRL("hashAlgorithm"), &_0); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "initializeavailableciphers", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_2, &_1, "setcipher", NULL, 0, &cipher); + zephir_check_call_status(); + if (useSigning) { + ZVAL_BOOL(&_3, 1); + } else { + ZVAL_BOOL(&_3, 0); + } + ZEPHIR_CALL_METHOD(NULL, &_2, "usesigning", NULL, 0, &_3); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, decrypt) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL, *key_param = NULL, __$true, __$null, blockSize, cipher, cipherText, decrypted, decryptKey, digest, hashAlgorithm, hashLength, iv, ivLength, mode, padded, _0, _1, _6, _7, _2$$5, _3$$5, _4$$5, _5$$6, _8$$7; + zval input, key; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&key); + ZVAL_BOOL(&__$true, 1); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&blockSize); + ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(&cipherText); + ZVAL_UNDEF(&decrypted); + ZVAL_UNDEF(&decryptKey); + ZVAL_UNDEF(&digest); + ZVAL_UNDEF(&hashAlgorithm); + ZVAL_UNDEF(&hashLength); + ZVAL_UNDEF(&iv); + ZVAL_UNDEF(&ivLength); + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&padded); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_8$$7); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(input) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(key) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &input_param, &key_param); + zephir_get_strval(&input, input_param); + if (!key_param) { + ZEPHIR_INIT_VAR(&key); + } else { + zephir_get_strval(&key, key_param); + } + zephir_memory_observe(&decryptKey); + zephir_read_property(&decryptKey, this_ptr, ZEND_STRL("key"), PH_NOISY_CC); + if (1 != ZEPHIR_IS_EMPTY(&key)) { + ZEPHIR_CPY_WRT(&decryptKey, &key); + } + if (1 == ZEPHIR_IS_EMPTY(&decryptKey)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Decryption key cannot be empty", "phalcon/Encryption/Crypt.zep", 175); + return; + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&cipher, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("ivLength"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&ivLength, &_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "cipher"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkcipherhashisavailable", NULL, 0, &cipher, &_1); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&mode, this_ptr, "getmode", NULL, 226); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&blockSize, this_ptr, "getblocksize", NULL, 227, &mode); + zephir_check_call_status(); + ZVAL_LONG(&_0, 0); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "8bit"); + ZEPHIR_CALL_FUNCTION(&iv, "mb_substr", NULL, 228, &input, &_0, &ivLength, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&digest); + ZVAL_STRING(&digest, ""); + ZEPHIR_CALL_METHOD(&hashAlgorithm, this_ptr, "gethashalgorithm", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("useSigning"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_INIT_VAR(&_2$$5); + ZVAL_STRING(&_2$$5, ""); + ZEPHIR_CALL_FUNCTION(&_3$$5, "hash", NULL, 71, &hashAlgorithm, &_2$$5, &__$true); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&hashLength); + ZVAL_LONG(&hashLength, zephir_fast_strlen_ev(&_3$$5)); + ZEPHIR_INIT_NVAR(&_2$$5); + ZVAL_STRING(&_2$$5, "8bit"); + ZEPHIR_CALL_FUNCTION(&digest, "mb_substr", NULL, 228, &input, &ivLength, &hashLength, &_2$$5); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4$$5); + zephir_add_function(&_4$$5, &ivLength, &hashLength); + ZEPHIR_INIT_NVAR(&_2$$5); + ZVAL_STRING(&_2$$5, "8bit"); + ZEPHIR_CALL_FUNCTION(&cipherText, "mb_substr", NULL, 228, &input, &_4$$5, &__$null, &_2$$5); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_VAR(&_5$$6); + ZVAL_STRING(&_5$$6, "8bit"); + ZEPHIR_CALL_FUNCTION(&cipherText, "mb_substr", NULL, 228, &input, &ivLength, &__$null, &_5$$6); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(&decrypted, this_ptr, "decryptgcmccmauth", NULL, 0, &mode, &cipherText, &decryptKey, &iv); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&padded, &decrypted); + ZEPHIR_CALL_METHOD(&_6, this_ptr, "decryptgetunpadded", NULL, 0, &mode, &blockSize, &decrypted); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&decrypted, &_6); + zephir_read_property(&_7, this_ptr, ZEND_STRL("useSigning"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_7)) { + ZEPHIR_CALL_FUNCTION(&_8$$7, "hash_hmac", NULL, 229, &hashAlgorithm, &padded, &decryptKey, &__$true); + zephir_check_call_status(); + if (!ZEPHIR_IS_IDENTICAL(&digest, &_8$$7)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_mismatch_ce, "Hash does not match.", "phalcon/Encryption/Crypt.zep", 224); + return; } -vv273: - vvch = *++VVCURSOR; - switch (vvch) { - case 'C': - case 'c': goto vv302; - default: goto vv54; - } -vv274: - vvch = *++VVCURSOR; - switch (vvch) { - case 'W': - case 'w': goto vv303; - default: goto vv54; - } -vv275: - vvch = *++VVCURSOR; - switch (vvch) { - case 'I': - case 'i': goto vv305; - default: goto vv54; - } -vv276: - vvch = *++VVCURSOR; - switch (vvch) { - case 'D': - case 'd': goto vv306; - default: goto vv54; - } -vv277: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv278; - } -vv278: - { - token->opcode = PHVOLT_T_FALSE; - return 0; + } + RETURN_CCTOR(&decrypted); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, decryptBase64) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool safe; + zval *input_param = NULL, *key_param = NULL, *safe_param = NULL, _0$$3, _1$$3, _2$$3, _3$$3, _4$$3, _5; + zval input, key; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(input) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(key) + Z_PARAM_BOOL(safe) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &input_param, &key_param, &safe_param); + zephir_get_strval(&input, input_param); + if (!key_param) { + ZEPHIR_INIT_VAR(&key); + } else { + zephir_get_strval(&key, key_param); + } + if (!safe_param) { + safe = 0; + } else { } -vv279: - vvch = *++VVCURSOR; - switch (vvch) { - case 'D': - case 'd': goto vv307; - default: goto vv54; - } -vv280: - vvch = *++VVCURSOR; - switch (vvch) { - case 'T': - case 't': goto vv308; - default: goto vv81; - } -vv281: - vvch = *++VVCURSOR; - switch (vvch) { - case 'B': - case 'b': goto vv310; - default: goto vv54; - } -vv282: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv283; - } -vv283: - { - s->statement_position++; - token->opcode = PHVOLT_T_MACRO; - return 0; + if (safe) { + ZEPHIR_INIT_VAR(&_0$$3); + ZVAL_STRING(&_0$$3, "-_"); + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "+/"); + ZEPHIR_CALL_FUNCTION(&_2$$3, "strtr", NULL, 5, &input, &_0$$3, &_1$$3); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_0$$3); + ZVAL_STRING(&_0$$3, "==="); + ZVAL_DOUBLE(&_3$$3, zephir_safe_mod_long_long(((zephir_fast_strlen_ev(&input) + 3)), 4)); + ZEPHIR_INIT_NVAR(&_1$$3); + zephir_substr(&_1$$3, &_0$$3, zephir_get_intval(&_3$$3), 0, ZEPHIR_SUBSTR_NO_LENGTH); + ZEPHIR_INIT_VAR(&_4$$3); + ZEPHIR_CONCAT_VV(&_4$$3, &_2$$3, &_1$$3); + zephir_get_strval(&input, &_4$$3); + } + ZEPHIR_CALL_FUNCTION(&_5, "base64_decode", NULL, 230, &input); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "decrypt", NULL, 0, &_5, &key); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, encrypt) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL, *key_param = NULL, __$true, blockSize, cipher, digest, encryptKey, encrypted, iv, ivLength, mode, padded, _0, _1, _2$$6; + zval input, key; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&key); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&blockSize); + ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(&digest); + ZVAL_UNDEF(&encryptKey); + ZVAL_UNDEF(&encrypted); + ZVAL_UNDEF(&iv); + ZVAL_UNDEF(&ivLength); + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&padded); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$6); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(input) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(key) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &input_param, &key_param); + zephir_get_strval(&input, input_param); + if (!key_param) { + ZEPHIR_INIT_VAR(&key); + } else { + zephir_get_strval(&key, key_param); + } + zephir_memory_observe(&encryptKey); + zephir_read_property(&encryptKey, this_ptr, ZEND_STRL("key"), PH_NOISY_CC); + if (1 != ZEPHIR_IS_EMPTY(&key)) { + ZEPHIR_CPY_WRT(&encryptKey, &key); + } + if (1 == ZEPHIR_IS_EMPTY(&encryptKey)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Encryption key cannot be empty", "phalcon/Encryption/Crypt.zep", 282); + return; + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&cipher, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("ivLength"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&ivLength, &_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "cipher"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkcipherhashisavailable", NULL, 0, &cipher, &_1); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&mode, this_ptr, "getmode", NULL, 226); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&blockSize, this_ptr, "getblocksize", NULL, 227, &mode); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&iv, this_ptr, "phpopensslrandompseudobytes", NULL, 0, &ivLength); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&iv)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Cannot calculate Random Pseudo Bytes", "phalcon/Encryption/Crypt.zep", 295); + return; + } + ZEPHIR_CALL_METHOD(&padded, this_ptr, "encryptgetpadded", NULL, 0, &mode, &input, &blockSize); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&encrypted, this_ptr, "encryptgcmccm", NULL, 0, &mode, &padded, &encryptKey, &iv); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("useSigning"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_CALL_METHOD(&_2$$6, this_ptr, "gethashalgorithm", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&digest, "hash_hmac", NULL, 229, &_2$$6, &padded, &encryptKey, &__$true); + zephir_check_call_status(); + ZEPHIR_CONCAT_VVV(return_value, &iv, &digest, &encrypted); + RETURN_MM(); + } + ZEPHIR_CONCAT_VV(return_value, &iv, &encrypted); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, encryptBase64) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool safe; + zval *input_param = NULL, *key_param = NULL, *safe_param = NULL, _0$$3, _1$$3, _2$$3, _3$$3, _4$$3, _5; + zval input, key; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(input) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(key) + Z_PARAM_BOOL(safe) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &input_param, &key_param, &safe_param); + zephir_get_strval(&input, input_param); + if (!key_param) { + ZEPHIR_INIT_VAR(&key); + } else { + zephir_get_strval(&key, key_param); + } + if (!safe_param) { + safe = 0; + } else { } -vv284: - vvch = *++VVCURSOR; - switch (vvch) { - case 'I': - case 'i': goto vv311; - default: goto vv54; - } -vv285: - vvch = *++VVCURSOR; - switch (vvch) { - case 'N': - case 'n': goto vv312; - default: goto vv54; - } -vv286: - vvch = *++VVCURSOR; - switch (vvch) { - case 'R': - case 'r': goto vv314; - default: goto vv54; - } -vv287: - vvch = *++VVCURSOR; - switch (vvch) { - case 'H': - case 'h': goto vv316; - default: goto vv54; - } -vv288: - vvch = *++VVCURSOR; - switch (vvch) { - case 'o': goto vv318; - default: goto vv81; - } -vv289: - vvch = *++VVCURSOR; - switch (vvch) { - case 'C': - case 'c': goto vv319; - default: goto vv54; - } -vv290: - vvch = *++VVCURSOR; - switch (vvch) { - case 'U': - case 'u': goto vv320; - default: goto vv54; - } -vv291: - vvch = *++VVCURSOR; - switch (vvch) { - case 'T': - case 't': goto vv321; - default: goto vv54; - } -vv292: - vvch = *++VVCURSOR; - switch (vvch) { - case 'D': - case 'd': goto vv323; - default: goto vv54; - } -vv293: - vvch = *++VVCURSOR; - switch (vvch) { - case 'R': - case 'r': goto vv325; - default: goto vv54; - } -vv294: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv295; - } -vv295: - { - token->opcode = PHVOLT_T_ELSEIF; - return 0; + if (safe) { + ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "encrypt", NULL, 0, &input, &key); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_1$$3, "base64_encode", NULL, 231, &_0$$3); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "+/"); + ZEPHIR_INIT_VAR(&_3$$3); + ZVAL_STRING(&_3$$3, "-_"); + ZEPHIR_CALL_FUNCTION(&_4$$3, "strtr", NULL, 5, &_1$$3, &_2$$3, &_3$$3); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_2$$3); + ZVAL_STRING(&_2$$3, "="); + zephir_fast_trim(return_value, &_4$$3, &_2$$3, ZEPHIR_TRIM_RIGHT); + RETURN_MM(); + } + ZEPHIR_CALL_METHOD(&_5, this_ptr, "encrypt", NULL, 0, &input, &key); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_FUNCTION("base64_encode", NULL, 231, &_5); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, getAvailableCiphers) +{ + + RETURN_MEMBER(getThis(), "availableCiphers"); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, getAuthData) +{ + + RETURN_MEMBER(getThis(), "authData"); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, getAuthTag) +{ + + RETURN_MEMBER(getThis(), "authTag"); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, getAuthTagLength) +{ + + RETURN_MEMBER(getThis(), "authTagLength"); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, getAvailableHashAlgorithms) +{ + zval _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "hash_hmac_algos"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "phpfunctionexists", NULL, 0, &_1); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_RETURN_CALL_FUNCTION("hash_hmac_algos", NULL, 232); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_RETURN_CALL_FUNCTION("hash_algos", NULL, 233); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, getHashAlgorithm) +{ + + RETURN_MEMBER(getThis(), "hashAlgorithm"); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, getCipher) +{ + + RETURN_MEMBER(getThis(), "cipher"); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, getKey) +{ + + RETURN_MEMBER(getThis(), "key"); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, isValidDecryptLength) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL, length, _0, _1; + zval input; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&length); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(input) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &input_param); + zephir_get_strval(&input, input_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&length, this_ptr, "phpopensslcipherivlength", NULL, 0, &_0); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&length)) { + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_FUNCTION(&_1, "mb_strlen", NULL, 234, &input); + zephir_check_call_status(); + RETURN_MM_BOOL(ZEPHIR_LE(&length, &_1)); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, setAuthData) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *data_param = NULL; + zval data; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&data); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(data) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &data_param); + zephir_get_strval(&data, data_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("authData"), &data); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, setAuthTag) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *tag_param = NULL; + zval tag; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&tag); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(tag) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &tag_param); + zephir_get_strval(&tag, tag_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("authTag"), &tag); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, setAuthTagLength) +{ + zval *length_param = NULL, _0; + zend_long length; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(length) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &length_param); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, length); + zephir_update_property_zval(this_ptr, ZEND_STRL("authTagLength"), &_0); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, setCipher) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *cipher_param = NULL, _0, _1; + zval cipher; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(cipher) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &cipher_param); + zephir_get_strval(&cipher, cipher_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "cipher"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkcipherhashisavailable", NULL, 0, &cipher, &_0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getivlength", NULL, 235, &cipher); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("ivLength"), &_1); + zephir_update_property_zval(this_ptr, ZEND_STRL("cipher"), &cipher); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, setKey) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *key_param = NULL; + zval key; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&key); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(key) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("key"), &key); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, setHashAlgorithm) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *hashAlgorithm_param = NULL, _0; + zval hashAlgorithm; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&hashAlgorithm); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(hashAlgorithm) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &hashAlgorithm_param); + zephir_get_strval(&hashAlgorithm, hashAlgorithm_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "hash"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkcipherhashisavailable", NULL, 0, &hashAlgorithm, &_0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("hashAlgorithm"), &hashAlgorithm); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, setPadding) +{ + zval *scheme_param = NULL, _0; + zend_long scheme; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(scheme) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &scheme_param); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, scheme); + zephir_update_property_zval(this_ptr, ZEND_STRL("padding"), &_0); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, useSigning) +{ + zval *useSigning_param = NULL, __$true, __$false; + zend_bool useSigning; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(useSigning) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &useSigning_param); + if (useSigning) { + zephir_update_property_zval(this_ptr, ZEND_STRL("useSigning"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("useSigning"), &__$false); + } + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, checkCipherHashIsAvailable) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *cipher_param = NULL, *type_param = NULL, available, lower, method, _0, _1$$5, _2$$5, _3$$5; + zval cipher, type; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&available); + ZVAL_UNDEF(&lower); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$5); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_3$$5); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(cipher) + Z_PARAM_STR(type) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &cipher_param, &type_param); + zephir_get_strval(&cipher, cipher_param); + zephir_get_strval(&type, type_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "hash"); + ZEPHIR_INIT_VAR(&method); + if (ZEPHIR_IS_IDENTICAL(&_0, &cipher)) { + ZVAL_STRING(&method, "getAvailableHashAlgorithms"); + } else { + ZVAL_STRING(&method, "getAvailableCiphers"); + } + ZEPHIR_CALL_METHOD_ZVAL(&available, this_ptr, &method, NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&lower, "mb_strtolower", NULL, 10, &cipher); + zephir_check_call_status(); + if (1 != zephir_fast_in_array(&lower, &available)) { + ZEPHIR_INIT_VAR(&_1$$5); + object_init_ex(&_1$$5, phalcon_encryption_crypt_exception_exception_ce); + ZEPHIR_INIT_VAR(&_2$$5); + ZVAL_STRING(&_2$$5, "The %s algorithm '%s' is not supported on this system."); + ZEPHIR_CALL_FUNCTION(&_3$$5, "sprintf", NULL, 117, &_2$$5, &type, &cipher); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_1$$5, "__construct", NULL, 33, &_3$$5); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$5, "phalcon/Encryption/Crypt.zep", 608); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, cryptPadText) +{ + zend_bool _4$$3; + zval _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long blockSize, paddingType, ZEPHIR_LAST_CALL_STATUS, paddingSize = 0; + zval *input_param = NULL, *mode_param = NULL, *blockSize_param = NULL, *paddingType_param = NULL, padding, service, _0, _2, _9, _10, _3$$3, _5$$3, _6$$3, _7$$3, _8$$3; + zval input, mode; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&padding); + ZVAL_UNDEF(&service); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_STR(input) + Z_PARAM_STR(mode) + Z_PARAM_LONG(blockSize) + Z_PARAM_LONG(paddingType) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 4, 0, &input_param, &mode_param, &blockSize_param, &paddingType_param); + zephir_get_strval(&input, input_param); + zephir_get_strval(&mode, mode_param); + ZEPHIR_INIT_VAR(&padding); + ZVAL_STRING(&padding, ""); + paddingSize = 0; + ZEPHIR_INIT_VAR(&_1); + zephir_create_array(&_1, 2, 0); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "cbc"); + zephir_array_fast_append(&_1, &_2); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "ecb"); + zephir_array_fast_append(&_1, &_2); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkismode", NULL, 236, &_1, &mode); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_CALL_FUNCTION(&_3$$3, "mb_strlen", NULL, 234, &input); + zephir_check_call_status(); + paddingSize = (blockSize - zephir_safe_mod_zval_long(&_3$$3, blockSize)); + _4$$3 = paddingSize >= 256; + if (!(_4$$3)) { + _4$$3 = paddingSize < 0; } -vv296: - vvch = *++VVCURSOR; - switch (vvch) { - case 'O': - case 'o': goto vv327; - default: goto vv54; - } -vv297: - vvch = *++VVCURSOR; - switch (vvch) { - case 'C': - case 'c': goto vv328; - default: goto vv54; - } -vv298: - vvch = *++VVCURSOR; - switch (vvch) { - case 'H': - case 'h': goto vv329; - default: goto vv54; - } -vv299: - vvch = *++VVCURSOR; - switch (vvch) { - case 'L': - case 'l': goto vv330; - default: goto vv54; - } -vv300: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv301; - } -vv301: - { - token->opcode = PHVOLT_T_ENDFOR; - return 0; + if (_4$$3) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Padding size cannot be less than 0 or greater than 256", "phalcon/Encryption/Crypt.zep", 641); + return; } -vv302: - vvch = *++VVCURSOR; - switch (vvch) { - case 'R': - case 'r': goto vv332; - default: goto vv54; - } -vv303: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv304; + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("padFactory"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_6$$3, paddingType); + ZEPHIR_CALL_METHOD(&service, &_5$$3, "padnumbertoservice", NULL, 0, &_6$$3); + zephir_check_call_status(); + zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("padFactory"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_7$$3, &_6$$3, "newinstance", NULL, 0, &service); + zephir_check_call_status(); + ZVAL_LONG(&_8$$3, paddingSize); + ZEPHIR_CALL_METHOD(&padding, &_7$$3, "pad", NULL, 0, &_8$$3); + zephir_check_call_status(); + } + if (0 == paddingSize) { + RETURN_CTOR(&input); + } + ZVAL_LONG(&_9, 0); + ZVAL_LONG(&_10, paddingSize); + ZEPHIR_INIT_NVAR(&_2); + zephir_substr(&_2, &padding, 0 , zephir_get_intval(&_10), 0); + ZEPHIR_CONCAT_VV(return_value, &input, &_2); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, cryptUnpadText) +{ + zval _3; + zend_bool _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long blockSize, paddingType, ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL, *mode_param = NULL, *blockSize_param = NULL, *paddingType_param = NULL, length, paddingSize, service, _2, _4, _5$$3, _6$$3, _7$$3, _8$$3, _9$$6, _10$$6; + zval input, mode; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&length); + ZVAL_UNDEF(&paddingSize); + ZVAL_UNDEF(&service); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$6); + ZVAL_UNDEF(&_10$$6); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_STR(input) + Z_PARAM_STR(mode) + Z_PARAM_LONG(blockSize) + Z_PARAM_LONG(paddingType) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 4, 0, &input_param, &mode_param, &blockSize_param, &paddingType_param); + zephir_get_strval(&input, input_param); + zephir_get_strval(&mode, mode_param); + ZEPHIR_INIT_VAR(&length); + ZVAL_LONG(&length, zephir_fast_strlen_ev(&input)); + ZEPHIR_INIT_VAR(&paddingSize); + ZVAL_LONG(&paddingSize, 0); + _0 = ZEPHIR_GT_LONG(&length, 0); + if (_0) { + _0 = (zephir_safe_mod_zval_long(&length, blockSize) == 0); + } + _1 = _0; + if (_1) { + ZEPHIR_INIT_VAR(&_3); + zephir_create_array(&_3, 2, 0); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "cbc"); + zephir_array_fast_append(&_3, &_4); + ZEPHIR_INIT_NVAR(&_4); + ZVAL_STRING(&_4, "ecb"); + zephir_array_fast_append(&_3, &_4); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "checkismode", NULL, 236, &_3, &mode); + zephir_check_call_status(); + _1 = ZEPHIR_IS_TRUE_IDENTICAL(&_2); + } + if (_1) { + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("padFactory"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_6$$3, paddingType); + ZEPHIR_CALL_METHOD(&service, &_5$$3, "padnumbertoservice", NULL, 0, &_6$$3); + zephir_check_call_status(); + zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("padFactory"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_7$$3, &_6$$3, "newinstance", NULL, 0, &service); + zephir_check_call_status(); + ZVAL_LONG(&_8$$3, blockSize); + ZEPHIR_CALL_METHOD(&paddingSize, &_7$$3, "unpad", NULL, 0, &input, &_8$$3); + zephir_check_call_status(); + if (ZEPHIR_GT_LONG(&paddingSize, 0)) { + if (ZEPHIR_LE_LONG(&paddingSize, blockSize)) { + if (ZEPHIR_LT(&paddingSize, &length)) { + ZEPHIR_INIT_VAR(&_9$$6); + zephir_sub_function(&_9$$6, &length, &paddingSize); + ZVAL_LONG(&_10$$6, 0); + zephir_substr(return_value, &input, 0 , zephir_get_intval(&_9$$6), 0); + RETURN_MM(); + } + RETURN_MM_STRING(""); } -vv304: - { - s->statement_position++; - token->opcode = PHVOLT_T_ENDRAW; - return 0; + ZEPHIR_INIT_NVAR(&paddingSize); + ZVAL_LONG(&paddingSize, 0); + } + } + if (ZEPHIR_IS_LONG_IDENTICAL(&paddingSize, 0)) { + RETURN_CTOR(&input); + } + RETURN_MM_STRING(""); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, decryptGetUnpadded) +{ + zval _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long blockSize, ZEPHIR_LAST_CALL_STATUS; + zval *mode_param = NULL, *blockSize_param = NULL, decrypted, *decrypted_param = NULL, padding, _0, _2, _3$$3, _4$$3; + zval mode; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&decrypted); + ZVAL_UNDEF(&padding); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(mode) + Z_PARAM_LONG(blockSize) + Z_PARAM_STR(decrypted) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 0, &mode_param, &blockSize_param, &decrypted_param); + zephir_get_strval(&mode, mode_param); + zephir_get_strval(&decrypted, decrypted_param); + ZEPHIR_INIT_VAR(&_1); + zephir_create_array(&_1, 2, 0); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "cbc"); + zephir_array_fast_append(&_1, &_2); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "ecb"); + zephir_array_fast_append(&_1, &_2); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkismode", NULL, 236, &_1, &mode); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("padding"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&padding, &_3$$3); + ZVAL_LONG(&_3$$3, blockSize); + ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "cryptunpadtext", NULL, 0, &decrypted, &mode, &_3$$3, &padding); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&decrypted, &_4$$3); + } + RETURN_CCTOR(&decrypted); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, decryptGcmCcmAuth) +{ + zval _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *mode_param = NULL, *cipherText_param = NULL, *decryptKey_param = NULL, *iv_param = NULL, authData, authTag, authTagLength, cipher, encrypted, decrypted, _0, _1, _3, _4$$3, _5$$3, _6$$4; + zval mode, cipherText, decryptKey, iv; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&cipherText); + ZVAL_UNDEF(&decryptKey); + ZVAL_UNDEF(&iv); + ZVAL_UNDEF(&authData); + ZVAL_UNDEF(&authTag); + ZVAL_UNDEF(&authTagLength); + ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(&encrypted); + ZVAL_UNDEF(&decrypted); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_STR(mode) + Z_PARAM_STR(cipherText) + Z_PARAM_STR(decryptKey) + Z_PARAM_STR(iv) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 4, 0, &mode_param, &cipherText_param, &decryptKey_param, &iv_param); + zephir_get_strval(&mode, mode_param); + zephir_get_strval(&cipherText, cipherText_param); + zephir_get_strval(&decryptKey, decryptKey_param); + zephir_get_strval(&iv, iv_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&cipher, &_0); + ZEPHIR_INIT_VAR(&_2); + zephir_create_array(&_2, 2, 0); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "ccm"); + zephir_array_fast_append(&_2, &_3); + ZEPHIR_INIT_NVAR(&_3); + ZVAL_STRING(&_3, "gcm"); + zephir_array_fast_append(&_2, &_3); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "checkismode", NULL, 236, &_2, &mode); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_1)) { + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("authData"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&authData, &_4$$3); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("authTagLength"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&authTagLength, &_4$$3); + zephir_negate(&authTagLength); + ZEPHIR_INIT_VAR(&authTag); + zephir_substr(&authTag, &cipherText, zephir_get_intval(&authTagLength), 0, ZEPHIR_SUBSTR_NO_LENGTH); + ZEPHIR_INIT_VAR(&_5$$3); + ZVAL_STRING(&_5$$3, ""); + ZEPHIR_INIT_VAR(&encrypted); + zephir_fast_str_replace(&encrypted, &authTag, &_5$$3, &cipherText); + ZVAL_LONG(&_4$$3, 1); + ZEPHIR_CALL_FUNCTION(&decrypted, "openssl_decrypt", NULL, 237, &encrypted, &cipher, &decryptKey, &_4$$3, &iv, &authTag, &authData); + zephir_check_call_status(); + } else { + ZVAL_LONG(&_6$$4, 1); + ZEPHIR_CALL_FUNCTION(&decrypted, "openssl_decrypt", NULL, 237, &cipherText, &cipher, &decryptKey, &_6$$4, &iv); + zephir_check_call_status(); + } + if (ZEPHIR_IS_FALSE_IDENTICAL(&decrypted)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Could not decrypt data", "phalcon/Encryption/Crypt.zep", 782); + return; + } + RETURN_CCTOR(&decrypted); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, encryptGetPadded) +{ + zval _3; + zend_bool _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long blockSize, ZEPHIR_LAST_CALL_STATUS; + zval *mode_param = NULL, *input_param = NULL, *blockSize_param = NULL, _0, _2, _4, _5$$3, _6$$3; + zval mode, input; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(mode) + Z_PARAM_STR(input) + Z_PARAM_LONG(blockSize) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 0, &mode_param, &input_param, &blockSize_param); + zephir_get_strval(&mode, mode_param); + zephir_get_strval(&input, input_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("padding"), PH_NOISY_CC | PH_READONLY); + _1 = !ZEPHIR_IS_LONG_IDENTICAL(&_0, 0); + if (_1) { + ZEPHIR_INIT_VAR(&_3); + zephir_create_array(&_3, 2, 0); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "cbc"); + zephir_array_fast_append(&_3, &_4); + ZEPHIR_INIT_NVAR(&_4); + ZVAL_STRING(&_4, "ecb"); + zephir_array_fast_append(&_3, &_4); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "checkismode", NULL, 236, &_3, &mode); + zephir_check_call_status(); + _1 = ZEPHIR_IS_TRUE_IDENTICAL(&_2); + } + if (_1) { + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("padding"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_6$$3, blockSize); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "cryptpadtext", NULL, 0, &input, &mode, &_6$$3, &_5$$3); + zephir_check_call_status(); + RETURN_MM(); + } + RETURN_CTOR(&input); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, encryptGcmCcm) +{ + zval _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *mode_param = NULL, *padded_param = NULL, *encryptKey_param = NULL, *iv_param = NULL, authData, authTag, authTagLength, cipher, encrypted, _0, _1, _3, _4$$3, _5$$5; + zval mode, padded, encryptKey, iv; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&padded); + ZVAL_UNDEF(&encryptKey); + ZVAL_UNDEF(&iv); + ZVAL_UNDEF(&authData); + ZVAL_UNDEF(&authTag); + ZVAL_UNDEF(&authTagLength); + ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(&encrypted); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_STR(mode) + Z_PARAM_STR(padded) + Z_PARAM_STR(encryptKey) + Z_PARAM_STR(iv) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 4, 0, &mode_param, &padded_param, &encryptKey_param, &iv_param); + zephir_get_strval(&mode, mode_param); + zephir_get_strval(&padded, padded_param); + zephir_get_strval(&encryptKey, encryptKey_param); + zephir_get_strval(&iv, iv_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&cipher, &_0); + ZEPHIR_INIT_VAR(&authTag); + ZVAL_STRING(&authTag, ""); + ZEPHIR_INIT_VAR(&_2); + zephir_create_array(&_2, 2, 0); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "ccm"); + zephir_array_fast_append(&_2, &_3); + ZEPHIR_INIT_NVAR(&_3); + ZVAL_STRING(&_3, "gcm"); + zephir_array_fast_append(&_2, &_3); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "checkismode", NULL, 236, &_2, &mode); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_1)) { + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("authData"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&authData, &_4$$3); + if (1 == ZEPHIR_IS_EMPTY(&authData)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Auth data must be provided when using AEAD mode", "phalcon/Encryption/Crypt.zep", 841); + return; } -vv305: - vvch = *++VVCURSOR; - switch (vvch) { - case 'T': - case 't': goto vv333; - default: goto vv54; - } -vv306: - vvch = *++VVCURSOR; - switch (vvch) { - case 'S': - case 's': goto vv334; - default: goto vv54; + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("authTag"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&authTag, &_4$$3); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("authTagLength"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&authTagLength, &_4$$3); + ZVAL_LONG(&_4$$3, 1); + ZEPHIR_MAKE_REF(&authTag); + ZEPHIR_CALL_FUNCTION(&encrypted, "openssl_encrypt", NULL, 238, &padded, &cipher, &encryptKey, &_4$$3, &iv, &authTag, &authData, &authTagLength); + ZEPHIR_UNREF(&authTag); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("authTag"), &authTag); + } else { + ZVAL_LONG(&_5$$5, 1); + ZEPHIR_CALL_FUNCTION(&encrypted, "openssl_encrypt", NULL, 238, &padded, &cipher, &encryptKey, &_5$$5, &iv); + zephir_check_call_status(); + } + if (ZEPHIR_IS_FALSE_IDENTICAL(&encrypted)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Could not encrypt data", "phalcon/Encryption/Crypt.zep", 870); + return; + } + ZEPHIR_CONCAT_VV(return_value, &encrypted, &authTag); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, initializeAvailableCiphers) +{ + zend_bool _4$$4, _5$$4, _6$$4, _7$$6, _8$$6, _9$$6; + zval allowed; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval __$true, available, cipher, _0, _1, *_2, _3; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&available); + ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&allowed); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "openssl_get_cipher_methods"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "phpfunctionexists", NULL, 0, &_1); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "This class requires the openssl extension for PHP", "phalcon/Encryption/Crypt.zep", 892); + return; + } + ZEPHIR_CALL_FUNCTION(&available, "openssl_get_cipher_methods", NULL, 239, &__$true); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&allowed); + array_init(&allowed); + zephir_is_iterable(&available, 0, "phalcon/Encryption/Crypt.zep", 909); + if (Z_TYPE_P(&available) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&available), _2) + { + ZEPHIR_INIT_NVAR(&cipher); + ZVAL_COPY(&cipher, _2); + _4$$4 = 1 != zephir_start_with_str(&cipher, SL("des")); + if (_4$$4) { + _4$$4 = 1 != zephir_start_with_str(&cipher, SL("rc2")); } -vv307: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv336; - default: goto vv54; + _5$$4 = _4$$4; + if (_5$$4) { + _5$$4 = 1 != zephir_start_with_str(&cipher, SL("rc4")); } -vv308: - ++VVCURSOR; - { - s->statement_position++; - token->opcode = PHVOLT_T_NOTEQUALS; - return 0; - } -vv310: - vvch = *++VVCURSOR; - switch (vvch) { - case 'L': - case 'l': goto vv338; - default: goto vv54; + _6$$4 = _5$$4; + if (_6$$4) { + _6$$4 = 1 != zephir_end_with_str(&cipher, SL("ecb")); } -vv311: - vvch = *++VVCURSOR; - switch (vvch) { - case 'C': - case 'c': goto vv339; - default: goto vv54; + if (_6$$4) { + zephir_array_update_zval(&allowed, &cipher, &cipher, PH_COPY | PH_SEPARATE); } -vv312: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv313; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &available, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &available, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; } -vv313: - { - token->opcode = PHVOLT_T_RETURN; - return 0; + ZEPHIR_CALL_METHOD(&cipher, &available, "current", NULL, 0); + zephir_check_call_status(); + _7$$6 = 1 != zephir_start_with_str(&cipher, SL("des")); + if (_7$$6) { + _7$$6 = 1 != zephir_start_with_str(&cipher, SL("rc2")); + } + _8$$6 = _7$$6; + if (_8$$6) { + _8$$6 = 1 != zephir_start_with_str(&cipher, SL("rc4")); + } + _9$$6 = _8$$6; + if (_9$$6) { + _9$$6 = 1 != zephir_end_with_str(&cipher, SL("ecb")); + } + if (_9$$6) { + zephir_array_update_zval(&allowed, &cipher, &cipher, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, &available, "next", NULL, 0); + zephir_check_call_status(); } -vv314: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv315; - } -vv315: - { - s->statement_position++; - token->opcode = PHVOLT_T_SCALAR; - return 0; + } + ZEPHIR_INIT_NVAR(&cipher); + zephir_update_property_zval(this_ptr, ZEND_STRL("availableCiphers"), &allowed); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, checkIsMode) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval mode; + zval *modes_param = NULL, *mode_param = NULL; + zval modes; + + ZVAL_UNDEF(&modes); + ZVAL_UNDEF(&mode); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ARRAY(modes) + Z_PARAM_STR(mode) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &modes_param, &mode_param); + zephir_get_arrval(&modes, modes_param); + zephir_get_strval(&mode, mode_param); + RETURN_MM_BOOL(zephir_fast_in_array(&mode, &modes)); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, getBlockSize) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *mode_param = NULL, _0, _2, _3, _4; + zval mode, _1; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(mode) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &mode_param); + zephir_get_strval(&mode, mode_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("ivLength"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_GT_LONG(&_0, 0)) { + RETURN_MM_MEMBER(getThis(), "ivLength"); + } + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_SV(&_1, "-", &mode); + zephir_read_property(&_2, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, ""); + ZEPHIR_CALL_FUNCTION(&_4, "str_ireplace", NULL, 240, &_1, &_3, &_2); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getivlength", NULL, 235, &_4); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, getIvLength) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *cipher_param = NULL, length; + zval cipher; + + ZVAL_UNDEF(&cipher); + ZVAL_UNDEF(&length); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(cipher) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &cipher_param); + zephir_get_strval(&cipher, cipher_param); + ZEPHIR_CALL_FUNCTION(&length, "openssl_cipher_iv_length", NULL, 241, &cipher); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&length)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_crypt_exception_exception_ce, "Cannot calculate the initialization vector (IV) length of the cipher", "phalcon/Encryption/Crypt.zep", 962); + return; + } + RETURN_CCTOR(&length); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, getMode) +{ + zval position, _0, _1, _2, _3, _4, _5; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&position); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "-"); + ZEPHIR_CALL_FUNCTION(&_2, "strrpos", NULL, 242, &_0, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&position); + ZVAL_LONG(&position, zephir_get_intval(&_2)); + zephir_read_property(&_3, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_4, this_ptr, ZEND_STRL("cipher"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_5, ((zephir_get_numberval(&position) - zephir_fast_strlen_ev(&_4)) + 1)); + ZEPHIR_INIT_NVAR(&_1); + zephir_substr(&_1, &_3, zephir_get_intval(&_5), 0, ZEPHIR_SUBSTR_NO_LENGTH); + ZEPHIR_RETURN_CALL_FUNCTION("mb_strtolower", NULL, 10, &_1); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, phpFunctionExists) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *name_param = NULL; + zval name; + + ZVAL_UNDEF(&name); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); + RETURN_MM_BOOL((zephir_function_exists(&name) == SUCCESS)); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, phpOpensslCipherIvLength) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *cipher_param = NULL; + zval cipher; + + ZVAL_UNDEF(&cipher); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(cipher) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &cipher_param); + zephir_get_strval(&cipher, cipher_param); + ZEPHIR_RETURN_CALL_FUNCTION("openssl_cipher_iv_length", NULL, 241, &cipher); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt, phpOpensslRandomPseudoBytes) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *length_param = NULL, _0; + zend_long length, ZEPHIR_LAST_CALL_STATUS; + + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(length) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &length_param); + ZVAL_LONG(&_0, length); + ZEPHIR_RETURN_CALL_FUNCTION("openssl_random_pseudo_bytes", NULL, 243, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +zend_object *zephir_init_properties_Phalcon_Encryption_Crypt(zend_class_entry *class_type) +{ + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("availableCiphers"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("availableCiphers"), &_1$$3); } -vv316: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv317; - } -vv317: - { - s->statement_position++; - token->opcode = PHVOLT_T_SWITCH; - return 0; + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption, Security, phalcon, encryption_security, phalcon_di_abstractinjectionaware_ce, phalcon_encryption_security_method_entry, 0); + + zend_declare_property_long(phalcon_encryption_security_ce, SL("defaultHash"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_encryption_security_ce, SL("numberBytes"), 16, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_encryption_security_ce, SL("random"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_encryption_security_ce, SL("requestToken"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_encryption_security_ce, SL("token"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_encryption_security_ce, SL("tokenKey"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_encryption_security_ce, SL("tokenKeySessionId"), "$PHALCON/CSRF/KEY$", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_encryption_security_ce, SL("tokenValueSessionId"), "$PHALCON/CSRF$", ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_encryption_security_ce, SL("workFactor"), 10, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_encryption_security_ce, SL("localSession"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_encryption_security_ce, SL("localRequest"), ZEND_ACC_PRIVATE); + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_ARGON2I"), 10); + + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_ARGON2ID"), 11); + + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_BCRYPT"), 0); + + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_DEFAULT"), 0); + + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_BLOWFISH"), 4); + + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_BLOWFISH_A"), 5); + + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_BLOWFISH_X"), 6); + + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_BLOWFISH_Y"), 7); + + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_EXT_DES"), 2); + + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_MD5"), 3); + + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_SHA256"), 8); + + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_SHA512"), 9); + + zephir_declare_class_constant_long(phalcon_encryption_security_ce, SL("CRYPT_STD_DES"), 1); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Security, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *session = NULL, session_sub, *request = NULL, request_sub, __$null, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&session_sub); + ZVAL_UNDEF(&request_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(session, phalcon_session_managerinterface_ce) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(request, phalcon_http_requestinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 2, &session, &request); + if (!session) { + session = &session_sub; + session = &__$null; + } + if (!request) { + request = &request_sub; + request = &__$null; + } + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, phalcon_encryption_security_random_ce); + if (zephir_has_constructor(&_0)) { + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); + zephir_check_call_status(); + } + + zephir_update_property_zval(this_ptr, ZEND_STRL("random"), &_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("localRequest"), request); + zephir_update_property_zval(this_ptr, ZEND_STRL("localSession"), session); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Encryption_Security, checkHash) +{ + zend_bool _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long maxPassLength, ZEPHIR_LAST_CALL_STATUS; + zval *password_param = NULL, *passwordHash_param = NULL, *maxPassLength_param = NULL; + zval password, passwordHash; + + ZVAL_UNDEF(&password); + ZVAL_UNDEF(&passwordHash); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(password) + Z_PARAM_STR(passwordHash) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(maxPassLength) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 1, &password_param, &passwordHash_param, &maxPassLength_param); + zephir_get_strval(&password, password_param); + zephir_get_strval(&passwordHash, passwordHash_param); + if (!maxPassLength_param) { + maxPassLength = 0; + } else { + } + _0 = maxPassLength > 0; + if (_0) { + _0 = zephir_fast_strlen_ev(&password) > maxPassLength; + } + if (_0) { + RETURN_MM_BOOL(0); + } + ZEPHIR_RETURN_CALL_FUNCTION("password_verify", NULL, 247, &password, &passwordHash); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security, checkToken) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool destroyIfValid, _1, _2; + zval *tokenKey_param = NULL, *tokenValue = NULL, tokenValue_sub, *destroyIfValid_param = NULL, __$null, equals, knownToken, userToken, _0; + zval tokenKey; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&tokenKey); + ZVAL_UNDEF(&tokenValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&equals); + ZVAL_UNDEF(&knownToken); + ZVAL_UNDEF(&userToken); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 3) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(tokenKey) + Z_PARAM_ZVAL_OR_NULL(tokenValue) + Z_PARAM_BOOL(destroyIfValid) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 3, &tokenKey_param, &tokenValue, &destroyIfValid_param); + if (!tokenKey_param) { + ZEPHIR_INIT_VAR(&tokenKey); + } else { + zephir_get_strval(&tokenKey, tokenKey_param); + } + if (!tokenValue) { + tokenValue = &tokenValue_sub; + tokenValue = &__$null; + } + if (!destroyIfValid_param) { + destroyIfValid = 1; + } else { + } + ZEPHIR_CALL_METHOD(&_0, this_ptr, "processtokenkey", NULL, 248, &tokenKey); + zephir_check_call_status(); + zephir_get_strval(&tokenKey, &_0); + if (!(!(ZEPHIR_IS_EMPTY(&tokenKey)))) { + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_METHOD(&userToken, this_ptr, "processusertoken", NULL, 249, &tokenKey, tokenValue); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&knownToken, this_ptr, "getrequesttoken", NULL, 0); + zephir_check_call_status(); + _1 = Z_TYPE_P(&knownToken) == IS_NULL; + if (!(_1)) { + _1 = Z_TYPE_P(&userToken) == IS_NULL; + } + if (_1) { + RETURN_MM_BOOL(0); + } + ZEPHIR_INIT_VAR(&equals); + ZEPHIR_INIT_NVAR(&equals); + ZVAL_BOOL(&equals, zephir_hash_equals(&knownToken, &userToken)); + _2 = zephir_is_true(&equals); + if (_2) { + _2 = destroyIfValid; + } + if (_2) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "destroytoken", NULL, 0); + zephir_check_call_status(); + } + RETURN_CCTOR(&equals); +} + +static PHP_METHOD(Phalcon_Encryption_Security, computeHmac) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool raw; + zval *data_param = NULL, *key_param = NULL, *algo_param = NULL, *raw_param = NULL, hmac, _0, _1$$3, _2$$3, _3$$3; + zval data, key, algo; + + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&algo); + ZVAL_UNDEF(&hmac); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_STR(data) + Z_PARAM_STR(key) + Z_PARAM_STR(algo) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(raw) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 1, &data_param, &key_param, &algo_param, &raw_param); + zephir_get_strval(&data, data_param); + zephir_get_strval(&key, key_param); + zephir_get_strval(&algo, algo_param); + if (!raw_param) { + raw = 0; + } else { + } + ZVAL_BOOL(&_0, (raw ? 1 : 0)); + ZEPHIR_CALL_FUNCTION(&hmac, "hash_hmac", NULL, 229, &algo, &data, &key, &_0); + zephir_check_call_status(); + if (UNEXPECTED(!zephir_is_true(&hmac))) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_encryption_security_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "Unknown hashing algorithm: %s"); + ZEPHIR_CALL_FUNCTION(&_3$$3, "sprintf", NULL, 117, &_2$$3, &algo); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_3$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Encryption/Security.zep", 219); + ZEPHIR_MM_RESTORE(); + return; + } + RETURN_CCTOR(&hmac); +} + +static PHP_METHOD(Phalcon_Encryption_Security, destroyToken) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval __$null, session, _0, _1, _2$$3, _3$$3; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&session); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "session"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "localSession"); + ZEPHIR_CALL_METHOD(&session, this_ptr, "getlocalservice", NULL, 0, &_0, &_1); + zephir_check_call_status(); + if (UNEXPECTED(zephir_is_true(&session))) { + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("tokenKeySessionId"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &session, "remove", NULL, 0, &_2$$3); + zephir_check_call_status(); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("tokenValueSessionId"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &session, "remove", NULL, 0, &_3$$3); + zephir_check_call_status(); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("token"), &__$null); + zephir_update_property_zval(this_ptr, ZEND_STRL("tokenKey"), &__$null); + zephir_update_property_zval(this_ptr, ZEND_STRL("requestToken"), &__$null); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Encryption_Security, getDefaultHash) +{ + + RETURN_MEMBER(getThis(), "defaultHash"); +} + +static PHP_METHOD(Phalcon_Encryption_Security, getHashInformation) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *hash_param = NULL; + zval hash; + + ZVAL_UNDEF(&hash); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(hash) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &hash_param); + zephir_get_strval(&hash, hash_param); + ZEPHIR_RETURN_CALL_FUNCTION("password_get_info", NULL, 250, &hash); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security, getRandom) +{ + + RETURN_MEMBER(getThis(), "random"); +} + +static PHP_METHOD(Phalcon_Encryption_Security, getRandomBytes) +{ + + RETURN_MEMBER(getThis(), "numberBytes"); +} + +static PHP_METHOD(Phalcon_Encryption_Security, getRequestToken) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("requestToken"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_EMPTY(&_0)) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsessiontoken", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); + } + RETURN_MM_MEMBER(getThis(), "requestToken"); +} + +static PHP_METHOD(Phalcon_Encryption_Security, getSessionToken) +{ + zval session, _0, _1, _2$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&session); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "session"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "localSession"); + ZEPHIR_CALL_METHOD(&session, this_ptr, "getlocalservice", NULL, 0, &_0, &_1); + zephir_check_call_status(); + if (UNEXPECTED(zephir_is_true(&session))) { + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("tokenValueSessionId"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&session, "get", NULL, 0, &_2$$3); + zephir_check_call_status(); + RETURN_MM(); + } + RETURN_MM_NULL(); +} + +static PHP_METHOD(Phalcon_Encryption_Security, getSaltBytes) +{ + zend_bool _3$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *numberBytes_param = NULL, safeBytes, _0$$3, _1$$4, _2$$4; + zend_long numberBytes, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&safeBytes); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$4); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(numberBytes) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &numberBytes_param); + if (!numberBytes_param) { + numberBytes = 0; + } else { } -vv318: - vvch = *++VVCURSOR; - switch (vvch) { - case 't': goto vv341; - default: goto vv81; - } -vv319: - vvch = *++VVCURSOR; - switch (vvch) { - case 'A': - case 'a': goto vv343; - default: goto vv54; - } -vv320: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv344; - default: goto vv54; - } -vv321: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv322; - } -vv322: - { - token->opcode = PHVOLT_T_DEFAULT; - token->value = estrndup(start, VVCURSOR - start); - token->len = VVCURSOR - start; - return 0; + if (!(numberBytes)) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("numberBytes"), PH_NOISY_CC | PH_READONLY); + numberBytes = zephir_get_numberval(&_0$$3); + } + while (1) { + zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("random"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_2$$4, numberBytes); + ZEPHIR_CALL_METHOD(&safeBytes, &_1$$4, "base64safe", NULL, 0, &_2$$4); + zephir_check_call_status(); + _3$$4 = zephir_is_true(&safeBytes); + if (_3$$4) { + _3$$4 = zephir_fast_strlen_ev(&safeBytes) >= numberBytes; } -vv323: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv324; - } -vv324: - { - s->statement_position++; - token->opcode = PHVOLT_T_DEFINED; - return 0; + if (_3$$4) { + break; } -vv325: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv326; - } -vv326: - { - token->opcode = PHVOLT_T_ELSEFOR; - return 0; + } + RETURN_CCTOR(&safeBytes); +} + +static PHP_METHOD(Phalcon_Encryption_Security, getToken) +{ + zval session, _0, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, _7$$4, _8$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&session); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$4); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "getsessiontoken", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("requestToken"), &_1$$3); + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("random"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("numberBytes"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_3$$3, &_2$$3, "base64safe", NULL, 0, &_4$$3); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("token"), &_3$$3); + ZEPHIR_INIT_VAR(&_5$$3); + ZVAL_STRING(&_5$$3, "session"); + ZEPHIR_INIT_VAR(&_6$$3); + ZVAL_STRING(&_6$$3, "localSession"); + ZEPHIR_CALL_METHOD(&session, this_ptr, "getlocalservice", NULL, 0, &_5$$3, &_6$$3); + zephir_check_call_status(); + if (Z_TYPE_P(&session) != IS_NULL) { + zephir_read_property(&_7$$4, this_ptr, ZEND_STRL("tokenValueSessionId"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_8$$4, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &session, "set", NULL, 0, &_7$$4, &_8$$4); + zephir_check_call_status(); } -vv327: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv346; - default: goto vv54; - } -vv328: - vvch = *++VVCURSOR; - switch (vvch) { - case 'K': - case 'k': goto vv347; - default: goto vv54; - } -vv329: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv349; - default: goto vv54; - } -vv330: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv331; - } -vv331: - { - token->opcode = PHVOLT_T_ENDCALL; - return 0; + } + RETURN_MM_MEMBER(getThis(), "token"); +} + +static PHP_METHOD(Phalcon_Encryption_Security, getTokenKey) +{ + zval session, _0, _1$$3, _2$$3, _3$$4, _4$$4, _5$$4, _6$$4, _7$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&session); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$4); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("tokenKey"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "session"); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "localSession"); + ZEPHIR_CALL_METHOD(&session, this_ptr, "getlocalservice", NULL, 0, &_1$$3, &_2$$3); + zephir_check_call_status(); + if (Z_TYPE_P(&session) != IS_NULL) { + zephir_read_property(&_3$$4, this_ptr, ZEND_STRL("random"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_5$$4, this_ptr, ZEND_STRL("numberBytes"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_4$$4, &_3$$4, "base64safe", NULL, 0, &_5$$4); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("tokenKey"), &_4$$4); + zephir_read_property(&_6$$4, this_ptr, ZEND_STRL("tokenKeySessionId"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_7$$4, this_ptr, ZEND_STRL("tokenKey"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &session, "set", NULL, 0, &_6$$4, &_7$$4); + zephir_check_call_status(); } -vv332: - vvch = *++VVCURSOR; - switch (vvch) { - case 'O': - case 'o': goto vv351; - default: goto vv54; - } -vv333: - vvch = *++VVCURSOR; - switch (vvch) { - case 'C': - case 'c': goto vv353; - default: goto vv54; - } -vv334: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv335; - } -vv335: - { - s->statement_position++; - token->opcode = PHVOLT_T_EXTENDS; - return 0; + } + RETURN_MM_MEMBER(getThis(), "tokenKey"); +} + +static PHP_METHOD(Phalcon_Encryption_Security, getWorkFactor) +{ + + RETURN_MEMBER(getThis(), "workFactor"); +} + +static PHP_METHOD(Phalcon_Encryption_Security, hash) +{ + zend_bool legacy = 0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, bytes = 0; + zval options; + zval *password_param = NULL, *options_param = NULL, algorithm, arguments, cost, formatted, prefix, salt, _0, _1, _6, _2$$6, _3$$7, _4$$9, _5$$9; + zval password; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&password); + ZVAL_UNDEF(&algorithm); + ZVAL_UNDEF(&arguments); + ZVAL_UNDEF(&cost); + ZVAL_UNDEF(&formatted); + ZVAL_UNDEF(&prefix); + ZVAL_UNDEF(&salt); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_2$$6); + ZVAL_UNDEF(&_3$$7); + ZVAL_UNDEF(&_4$$9); + ZVAL_UNDEF(&_5$$9); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(password) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &password_param, &options_param); + zephir_get_strval(&password, password_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + ZEPHIR_CALL_METHOD(&cost, this_ptr, "processcost", NULL, 251, &options); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "%02s"); + ZEPHIR_CALL_FUNCTION(&formatted, "sprintf", NULL, 117, &_0, &cost); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&prefix); + ZVAL_STRING(&prefix, ""); + bytes = 22; + legacy = 1; + zephir_memory_observe(&_1); + zephir_read_property(&_1, this_ptr, ZEND_STRL("defaultHash"), PH_NOISY_CC); + do { + if (ZEPHIR_IS_LONG(&_1, 3)) { + ZEPHIR_INIT_NVAR(&prefix); + ZVAL_STRING(&prefix, "$1$"); + bytes = 12; + break; } -vv336: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv337; - } -vv337: - { - s->statement_position++; - token->opcode = PHVOLT_T_INCLUDE; - return 0; + if (ZEPHIR_IS_LONG(&_1, 8)) { + ZEPHIR_INIT_NVAR(&prefix); + ZVAL_STRING(&prefix, "$5$"); + bytes = 16; + break; } -vv338: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv354; - default: goto vv54; - } -vv339: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv340; - } -vv340: - { - s->statement_position++; - token->opcode = PHVOLT_T_NUMERIC; - return 0; + if (ZEPHIR_IS_LONG(&_1, 9)) { + ZEPHIR_INIT_NVAR(&prefix); + ZVAL_STRING(&prefix, "$6$"); + bytes = 16; + break; } -vv341: - ++VVCURSOR; - { - s->statement_position++; - token->opcode = PHVOLT_T_NOTEQUALS; - return 0; + if (ZEPHIR_IS_LONG(&_1, 5)) { + ZEPHIR_INIT_VAR(&_2$$6); + ZVAL_STRING(&_2$$6, "$2a$%s$"); + ZEPHIR_CALL_FUNCTION(&prefix, "sprintf", NULL, 117, &_2$$6, &formatted); + zephir_check_call_status(); + break; } -vv343: - vvch = *++VVCURSOR; - switch (vvch) { - case 'P': - case 'p': goto vv356; - default: goto vv54; - } -vv344: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv345; - } -vv345: - { - s->statement_position++; - token->opcode = PHVOLT_T_CONTINUE; - return 0; + if (ZEPHIR_IS_LONG(&_1, 6)) { + ZEPHIR_INIT_VAR(&_3$$7); + ZVAL_STRING(&_3$$7, "$2x$%s$"); + ZEPHIR_CALL_FUNCTION(&prefix, "sprintf", NULL, 117, &_3$$7, &formatted); + zephir_check_call_status(); + break; + } + legacy = 0; + break; + } while(0); + + if (UNEXPECTED(legacy)) { + ZVAL_LONG(&_5$$9, bytes); + ZEPHIR_CALL_METHOD(&_4$$9, this_ptr, "getsaltbytes", NULL, 0, &_5$$9); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&salt); + ZEPHIR_CONCAT_VVS(&salt, &prefix, &_4$$9, "$"); + ZEPHIR_RETURN_CALL_FUNCTION("crypt", NULL, 252, &password, &salt); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_INIT_VAR(&_6); + zephir_create_array(&_6, 1, 0); + zephir_array_update_string(&_6, SL("cost"), &cost, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&options, &_6); + ZEPHIR_CALL_METHOD(&algorithm, this_ptr, "processalgorithm", NULL, 253); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&arguments, this_ptr, "processargonoptions", NULL, 254, &options); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_FUNCTION("password_hash", NULL, 255, &password, &algorithm, &arguments); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security, isLegacyHash) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *passwordHash_param = NULL; + zval passwordHash; + + ZVAL_UNDEF(&passwordHash); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(passwordHash) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &passwordHash_param); + zephir_get_strval(&passwordHash, passwordHash_param); + RETURN_MM_BOOL(zephir_start_with_str(&passwordHash, SL("$2a$"))); +} + +static PHP_METHOD(Phalcon_Encryption_Security, setDefaultHash) +{ + zval *defaultHash_param = NULL, _0; + zend_long defaultHash; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(defaultHash) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &defaultHash_param); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, defaultHash); + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultHash"), &_0); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Encryption_Security, setRandomBytes) +{ + zval *randomBytes_param = NULL, _0; + zend_long randomBytes; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(randomBytes) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &randomBytes_param); + if (UNEXPECTED(Z_TYPE_P(randomBytes_param) != IS_LONG)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'randomBytes' must be of the type int")); + RETURN_NULL(); + } + randomBytes = Z_LVAL_P(randomBytes_param); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, randomBytes); + zephir_update_property_zval(this_ptr, ZEND_STRL("numberBytes"), &_0); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Encryption_Security, setWorkFactor) +{ + zval *workFactor_param = NULL, _0; + zend_long workFactor; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(workFactor) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &workFactor_param); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, workFactor); + zephir_update_property_zval(this_ptr, ZEND_STRL("workFactor"), &_0); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Encryption_Security, getLocalService) +{ + zend_bool _1, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, *property_param = NULL, _0, _2, _4, _5, _8, _6$$3, _7$$3; + zval name, property; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&property); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_STR(property) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &name_param, &property_param); + zephir_get_strval(&name, name_param); + zephir_get_strval(&property, property_param); + zephir_memory_observe(&_0); + zephir_read_property_zval(&_0, this_ptr, &property, PH_NOISY_CC); + _1 = Z_TYPE_P(&_0) == IS_NULL; + if (_1) { + zephir_read_property(&_2, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + _1 = Z_TYPE_P(&_2) != IS_NULL; + } + _3 = _1; + if (_3) { + zephir_read_property(&_4, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_5, &_4, "has", NULL, 0, &name); + zephir_check_call_status(); + _3 = ZEPHIR_IS_TRUE_IDENTICAL(&_5); + } + if (_3) { + zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_7$$3, &_6$$3, "getshared", NULL, 0, &name); + zephir_check_call_status(); + zephir_update_property_zval_zval(this_ptr, &property, &_7$$3); + } + zephir_memory_observe(&_8); + zephir_read_property_zval(&_8, this_ptr, &property, PH_NOISY_CC); + RETURN_CCTOR(&_8); +} + +static PHP_METHOD(Phalcon_Encryption_Security, processAlgorithm) +{ + zval algorithm, _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&algorithm); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&algorithm); + ZVAL_STRING(&algorithm, "2y"); + zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultHash"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_1, this_ptr, ZEND_STRL("defaultHash"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_LONG_IDENTICAL(&_0, 10)) { + ZEPHIR_INIT_NVAR(&algorithm); + ZVAL_STRING(&algorithm, "argon2i"); + } else if (ZEPHIR_IS_LONG_IDENTICAL(&_1, 11)) { + ZEPHIR_INIT_NVAR(&algorithm); + ZVAL_STRING(&algorithm, "argon2id"); + } + RETURN_CCTOR(&algorithm); +} + +static PHP_METHOD(Phalcon_Encryption_Security, processArgonOptions) +{ + zend_bool _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *options_param = NULL, value, _0, _2; + zval options; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &options_param); + zephir_get_arrval(&options, options_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultHash"), PH_NOISY_CC | PH_READONLY); + _1 = ZEPHIR_IS_LONG_IDENTICAL(&_0, 10); + if (!(_1)) { + zephir_read_property(&_2, this_ptr, ZEND_STRL("defaultHash"), PH_NOISY_CC | PH_READONLY); + _1 = ZEPHIR_IS_LONG_IDENTICAL(&_2, 11); + } + if (_1) { + zephir_memory_observe(&value); + if (!(zephir_array_isset_string_fetch(&value, &options, SL("memory_cost"), 0))) { + ZEPHIR_INIT_NVAR(&value); + ZVAL_LONG(&value, 65536); } -vv346: - vvch = *++VVCURSOR; - switch (vvch) { - case 'S': - case 's': goto vv357; - default: goto vv54; - } -vv347: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv348; - } -vv348: - { - token->opcode = PHVOLT_T_ENDBLOCK; - return 0; + zephir_array_update_string(&options, SL("memory_cost"), &value, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&value); + if (!(zephir_array_isset_string_fetch(&value, &options, SL("time_cost"), 0))) { + ZEPHIR_INIT_NVAR(&value); + ZVAL_LONG(&value, 4); } -vv349: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv350; - } -vv350: - { - token->opcode = PHVOLT_T_ENDCACHE; - return 0; + zephir_array_update_string(&options, SL("time_cost"), &value, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&value); + if (!(zephir_array_isset_string_fetch(&value, &options, SL("threads"), 0))) { + ZEPHIR_INIT_NVAR(&value); + ZVAL_LONG(&value, 1); } -vv351: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv352; - } -vv352: - { - token->opcode = PHVOLT_T_ENDMACRO; - return 0; + zephir_array_update_string(&options, SL("threads"), &value, PH_COPY | PH_SEPARATE); + } + RETURN_CTOR(&options); +} + +static PHP_METHOD(Phalcon_Encryption_Security, processCost) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *options_param = NULL, cost; + zval options; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&cost); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + zephir_memory_observe(&cost); + if (!(zephir_array_isset_string_fetch(&cost, &options, SL("cost"), 0))) { + ZEPHIR_OBS_NVAR(&cost); + zephir_read_property(&cost, this_ptr, ZEND_STRL("workFactor"), PH_NOISY_CC); + } + if (ZEPHIR_LT_LONG(&cost, 4)) { + ZEPHIR_INIT_NVAR(&cost); + ZVAL_LONG(&cost, 4); + } + if (ZEPHIR_GT_LONG(&cost, 31)) { + ZEPHIR_INIT_NVAR(&cost); + ZVAL_LONG(&cost, 31); + } + RETURN_CCTOR(&cost); +} + +static PHP_METHOD(Phalcon_Encryption_Security, processTokenKey) +{ + zend_bool _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *tokenKey_param = NULL, key, session, _0, _1, _3$$3; + zval tokenKey; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&tokenKey); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&session); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3$$3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(tokenKey) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &tokenKey_param); + if (!tokenKey_param) { + ZEPHIR_INIT_VAR(&tokenKey); + } else { + zephir_get_strval(&tokenKey, tokenKey_param); + } + ZEPHIR_CPY_WRT(&key, &tokenKey); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "session"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "localSession"); + ZEPHIR_CALL_METHOD(&session, this_ptr, "getlocalservice", NULL, 0, &_0, &_1); + zephir_check_call_status(); + _2 = Z_TYPE_P(&session) != IS_NULL; + if (_2) { + _2 = 1 == ZEPHIR_IS_EMPTY(&key); + } + if (_2) { + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("tokenKeySessionId"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&key, &session, "get", NULL, 0, &_3$$3); + zephir_check_call_status(); + } + RETURN_CCTOR(&key); +} + +static PHP_METHOD(Phalcon_Encryption_Security, processUserToken) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *tokenKey_param = NULL, *tokenValue_param = NULL, request, userToken, _0$$3, _1$$3, _2$$4; + zval tokenKey, tokenValue; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&tokenKey); + ZVAL_UNDEF(&tokenValue); + ZVAL_UNDEF(&request); + ZVAL_UNDEF(&userToken); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(tokenKey) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(tokenValue) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &tokenKey_param, &tokenValue_param); + zephir_get_strval(&tokenKey, tokenKey_param); + if (!tokenValue_param) { + ZEPHIR_INIT_VAR(&tokenValue); + } else { + zephir_get_strval(&tokenValue, tokenValue_param); + } + ZEPHIR_CPY_WRT(&userToken, &tokenValue); + if (!(!(ZEPHIR_IS_EMPTY(&tokenValue)))) { + ZEPHIR_INIT_VAR(&_0$$3); + ZVAL_STRING(&_0$$3, "request"); + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "localRequest"); + ZEPHIR_CALL_METHOD(&request, this_ptr, "getlocalservice", NULL, 0, &_0$$3, &_1$$3); + zephir_check_call_status(); + if (Z_TYPE_P(&request) != IS_NULL) { + ZEPHIR_INIT_VAR(&_2$$4); + ZVAL_STRING(&_2$$4, "string"); + ZEPHIR_CALL_METHOD(&userToken, &request, "getpost", NULL, 0, &tokenKey, &_2$$4); + zephir_check_call_status(); } -vv353: - vvch = *++VVCURSOR; - switch (vvch) { - case 'H': - case 'h': goto vv358; - default: goto vv54; - } -vv354: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv355; - } -vv355: - { - s->statement_position++; - token->opcode = PHVOLT_T_ITERABLE; - return 0; + } + RETURN_CCTOR(&userToken); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Security, Exception, phalcon, encryption_security_exception, zend_ce_exception, NULL, 0); + + return SUCCESS; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_Random) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security, Random, phalcon, encryption_security_random, phalcon_encryption_security_random_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Security_Random, base58) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *len_param = NULL, _0, _1, _2; + zend_long len, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(len, is_null_true) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &len_param); + if (!len_param) { + len = 0; + } else { } -vv356: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv360; - default: goto vv54; - } -vv357: - vvch = *++VVCURSOR; - switch (vvch) { - case 'C': - case 'c': goto vv362; - default: goto vv54; - } -vv358: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv359; - } -vv359: - { - token->opcode = PHVOLT_T_ENDSWITCH; - return 0; + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"); + ZVAL_LONG(&_1, 58); + ZVAL_LONG(&_2, len); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "base", NULL, 0, &_0, &_1, &_2); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_Random, base62) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *len_param = NULL, _0, _1, _2; + zend_long len, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(len, is_null_true) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &len_param); + if (!len_param) { + len = 0; + } else { } -vv360: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv361; - } -vv361: - { - s->statement_position++; - token->opcode = PHVOLT_T_AUTOESCAPE; - return 0; + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); + ZVAL_LONG(&_1, 62); + ZVAL_LONG(&_2, len); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "base", NULL, 0, &_0, &_1, &_2); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_Random, base64) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *len_param = NULL, _0, _1; + zend_long len, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(len, is_null_true) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &len_param); + if (!len_param) { + len = 0; + } else { } -vv362: - vvch = *++VVCURSOR; - switch (vvch) { - case 'A': - case 'a': goto vv363; - default: goto vv54; - } -vv363: - vvch = *++VVCURSOR; - switch (vvch) { - case 'P': - case 'p': goto vv364; - default: goto vv54; - } -vv364: - vvch = *++VVCURSOR; - switch (vvch) { - case 'E': - case 'e': goto vv365; - default: goto vv54; - } -vv365: - vvch = *++VVCURSOR; - switch (vvch) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '\\': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto vv53; - default: goto vv366; - } -vv366: - { - s->statement_position++; - token->opcode = PHVOLT_T_ENDAUTOESCAPE; - return 0; + ZVAL_LONG(&_1, len); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "bytes", NULL, 0, &_1); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_FUNCTION("base64_encode", NULL, 231, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_Random, base64Safe) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_bool padding; + zval *len_param = NULL, *padding_param = NULL, s, _0, _1, _2, _3, _4, _5, _6$$3; + zend_long len, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&s); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6$$3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(len, is_null_true) + Z_PARAM_BOOL(padding) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 2, &len_param, &padding_param); + if (!len_param) { + len = 0; + } else { + } + if (!padding_param) { + padding = 0; + } else { + } + ZVAL_LONG(&_1, len); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "base64", NULL, 0, &_1); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_2, "base64_encode", NULL, 231, &_0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "+/"); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "-_"); + ZEPHIR_CALL_FUNCTION(&s, "strtr", NULL, 5, &_2, &_3, &_4); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_3); + ZVAL_STRING(&_3, "#[^a-z0-9_=-]+#i"); + ZEPHIR_INIT_NVAR(&_4); + ZVAL_STRING(&_4, ""); + ZEPHIR_CALL_FUNCTION(&_5, "preg_replace", NULL, 41, &_3, &_4, &s); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&s, &_5); + if (!(padding)) { + ZEPHIR_INIT_VAR(&_6$$3); + ZVAL_STRING(&_6$$3, "="); + zephir_fast_trim(return_value, &s, &_6$$3, ZEPHIR_TRIM_RIGHT); + RETURN_MM(); + } + RETURN_CCTOR(&s); +} + +static PHP_METHOD(Phalcon_Encryption_Security_Random, bytes) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *len_param = NULL, _0; + zend_long len, ZEPHIR_LAST_CALL_STATUS; + + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(len) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &len_param); + if (!len_param) { + len = 16; + } else { } + if (len <= 0) { + len = 16; + } + ZVAL_LONG(&_0, len); + ZEPHIR_RETURN_CALL_FUNCTION("random_bytes", NULL, 267, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_Random, hex) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *len_param = NULL, _0, _1, _2, _3; + zend_long len, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(len, is_null_true) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &len_param); + if (!len_param) { + len = 0; + } else { } + ZVAL_LONG(&_1, len); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "bytes", NULL, 0, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "H*"); + ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 268, &_2, &_0); + zephir_check_call_status(); + ZEPHIR_MAKE_REF(&_3); + ZEPHIR_RETURN_CALL_FUNCTION("array_shift", NULL, 22, &_3); + ZEPHIR_UNREF(&_3); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_Random, number) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *len_param = NULL, _0, _1; + zend_long len, ZEPHIR_LAST_CALL_STATUS; + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(len) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &len_param); + if (UNEXPECTED(len <= 0)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_exception_ce, "Input number must be a positive integer", "phalcon/Encryption/Security/Random.zep", 272); + return; + } + ZVAL_LONG(&_0, 0); + ZVAL_LONG(&_1, len); + ZEPHIR_RETURN_CALL_FUNCTION("random_int", NULL, 269, &_0, &_1); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_Random, uuid) +{ + zval ary, _0, _1, _2, _3, _4, _5, _6, _7; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&ary); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZVAL_LONG(&_1, 16); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "bytes", NULL, 0, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "N1a/n1b/n1c/n1d/n1e/N1f"); + ZEPHIR_CALL_FUNCTION(&_3, "unpack", NULL, 268, &_2, &_0); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&ary, "array_values", NULL, 14, &_3); + zephir_check_call_status(); + zephir_array_fetch_long(&_4, &ary, 2, PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/Random.zep", 311); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_LONG(&_2, ((((int) (zephir_get_numberval(&_4)) & 0x0fff)) | 0x4000)); + zephir_array_update_long(&ary, 2, &_2, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + zephir_array_fetch_long(&_5, &ary, 3, PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/Random.zep", 312); + ZEPHIR_INIT_VAR(&_6); + ZVAL_LONG(&_6, ((((int) (zephir_get_numberval(&_5)) & 0x3fff)) | 0x8000)); + zephir_array_update_long(&ary, 3, &_6, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + ZEPHIR_INIT_VAR(&_7); + ZVAL_STRING(&_7, "%08x-%04x-%04x-%04x-%04x%08x"); + ZEPHIR_MAKE_REF(&ary); + ZEPHIR_CALL_FUNCTION(NULL, "array_unshift", NULL, 270, &ary, &_7); + ZEPHIR_UNREF(&ary); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_7); + ZVAL_STRING(&_7, "sprintf"); + ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_7, &ary); + zephir_check_call_status(); + RETURN_MM(); +} +static PHP_METHOD(Phalcon_Encryption_Security_Random, base) +{ + unsigned char _7$$3, _10$$5; + double _4$$3, _8$$5; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_6 = NULL; + zend_long base, ZEPHIR_LAST_CALL_STATUS; + zval *alphabet_param = NULL, *base_param = NULL, *n = NULL, n_sub, __$null, bytes, idx, _0, _1, *_2, _3, _5$$4, _9$$6; + zval alphabet, byteString; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&alphabet); + ZVAL_UNDEF(&byteString); + ZVAL_UNDEF(&n_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&bytes); + ZVAL_UNDEF(&idx); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_9$$6); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(alphabet) + Z_PARAM_LONG(base) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(n) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 1, &alphabet_param, &base_param, &n); + zephir_get_strval(&alphabet, alphabet_param); + if (!n) { + n = &n_sub; + n = &__$null; + } + ZEPHIR_INIT_VAR(&byteString); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "bytes", NULL, 0, n); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "C*"); + ZEPHIR_CALL_FUNCTION(&bytes, "unpack", NULL, 268, &_1, &_0); + zephir_check_call_status(); + zephir_is_iterable(&bytes, 0, "phalcon/Encryption/Security/Random.zep", 351); + if (Z_TYPE_P(&bytes) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&bytes), _2) + { + ZEPHIR_INIT_NVAR(&idx); + ZVAL_COPY(&idx, _2); + _4$$3 = zephir_safe_mod_zval_long(&idx, 64); + ZEPHIR_INIT_NVAR(&idx); + ZVAL_DOUBLE(&idx, _4$$3); + if (ZEPHIR_GE_LONG(&idx, base)) { + ZVAL_LONG(&_5$$4, (base - 1)); + ZEPHIR_CALL_METHOD(&idx, this_ptr, "number", &_6, 0, &_5$$4); + zephir_check_call_status(); + } + _7$$3 = ZEPHIR_STRING_OFFSET(&alphabet, zephir_get_intval(&idx)); + zephir_concat_self_char(&byteString, _7$$3); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &bytes, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &bytes, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&idx, &bytes, "current", NULL, 0); + zephir_check_call_status(); + _8$$5 = zephir_safe_mod_zval_long(&idx, 64); + ZEPHIR_INIT_NVAR(&idx); + ZVAL_DOUBLE(&idx, _8$$5); + if (ZEPHIR_GE_LONG(&idx, base)) { + ZVAL_LONG(&_9$$6, (base - 1)); + ZEPHIR_CALL_METHOD(&idx, this_ptr, "number", &_6, 0, &_9$$6); + zephir_check_call_status(); + } + _10$$5 = ZEPHIR_STRING_OFFSET(&alphabet, zephir_get_intval(&idx)); + zephir_concat_self_char(&byteString, _10$$5); + ZEPHIR_CALL_METHOD(NULL, &bytes, "next", NULL, 0); + zephir_check_call_status(); } } - - return status; + ZEPHIR_INIT_NVAR(&idx); + RETURN_CTOR(&byteString); } + #ifdef HAVE_CONFIG_H #endif @@ -102411,13 +100336,847 @@ static int phvolt_get_token(phvolt_scanner_state *s, phvolt_scanner_token *token -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Application_Exception) +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Builder) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Application, Exception, phalcon, mvc_application_exception, phalcon_application_exception_ce, NULL, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT, Builder, phalcon, encryption_security_jwt_builder, phalcon_encryption_security_jwt_builder_method_entry, 0); + zend_declare_property_null(phalcon_encryption_security_jwt_builder_ce, SL("claims"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_encryption_security_jwt_builder_ce, SL("encode"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_encryption_security_jwt_builder_ce, SL("jose"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_encryption_security_jwt_builder_ce, SL("passphrase"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_encryption_security_jwt_builder_ce, SL("signer"), ZEND_ACC_PRIVATE); return SUCCESS; } +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *signer, signer_sub, _0, _1, _2, _3, _4; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&signer_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(signer, phalcon_encryption_security_jwt_signer_signerinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &signer); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("signer"), signer); + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, phalcon_support_helper_json_encode_ce); + if (zephir_has_constructor(&_0)) { + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); + zephir_check_call_status(); + } + + zephir_update_property_zval(this_ptr, ZEND_STRL("encode"), &_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("jose"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_2, this_ptr, ZEND_STRL("signer"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_3, &_2, "getalgheader", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "alg"); + ZEPHIR_CALL_METHOD(NULL, &_1, "set", NULL, 0, &_4, &_3); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, init) +{ + zval _2; + zval _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, ""); + zephir_update_property_zval(this_ptr, ZEND_STRL("passphrase"), &_0); + ZEPHIR_INIT_NVAR(&_0); + object_init_ex(&_0, phalcon_support_collection_ce); + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 23); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("claims"), &_0); + ZEPHIR_INIT_VAR(&_1); + object_init_ex(&_1, phalcon_support_collection_ce); + ZEPHIR_INIT_VAR(&_2); + zephir_create_array(&_2, 2, 0); + add_assoc_stringl_ex(&_2, SL("typ"), SL("JWT")); + add_assoc_stringl_ex(&_2, SL("alg"), SL("none")); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 23, &_2); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("jose"), &_1); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, addClaim) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, *value, value_sub, _0; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &name_param, &value); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &name, value); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, addHeader) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, *value, value_sub, _0; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &name_param, &value); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("jose"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &name, value); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getAudience) +{ + zval _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "aud"); + ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getClaims) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "toarray", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getContentType) +{ + zval _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("jose"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "cty"); + ZVAL_NULL(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "string"); + ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getExpirationTime) +{ + zval _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "exp"); + ZVAL_NULL(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "int"); + ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getHeaders) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("jose"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "toarray", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getId) +{ + zval _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "jti"); + ZVAL_NULL(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "string"); + ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getIssuedAt) +{ + zval _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "iat"); + ZVAL_NULL(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "int"); + ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getIssuer) +{ + zval _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "iss"); + ZVAL_NULL(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "string"); + ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getNotBefore) +{ + zval _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "nbf"); + ZVAL_NULL(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "int"); + ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getSubject) +{ + zval _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "sub"); + ZVAL_NULL(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "string"); + ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &_1, &_2, &_3); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getToken) +{ + zval claims, encodedClaims, encodedHeaders, encodedSignature, headers, signature, signatureHash, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&claims); + ZVAL_UNDEF(&encodedClaims); + ZVAL_UNDEF(&encodedHeaders); + ZVAL_UNDEF(&encodedSignature); + ZVAL_UNDEF(&headers); + ZVAL_UNDEF(&signature); + ZVAL_UNDEF(&signatureHash); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_11); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("passphrase"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_EMPTY(&_0)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_validatorexception_ce, "Invalid passphrase (empty)", "phalcon/Encryption/Security/JWT/Builder.zep", 220); + return; + } + zephir_read_property(&_1, this_ptr, ZEND_STRL("encode"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "getclaims", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_2, &_1, "__invoke", NULL, 0, &_3); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&encodedClaims, this_ptr, "encodeurl", NULL, 256, &_2); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&claims); + object_init_ex(&claims, phalcon_encryption_security_jwt_token_item_ce); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "getclaims", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &claims, "__construct", NULL, 257, &_4, &encodedClaims); + zephir_check_call_status(); + zephir_read_property(&_5, this_ptr, ZEND_STRL("encode"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_7, this_ptr, "getheaders", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_6, &_5, "__invoke", NULL, 0, &_7); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&encodedHeaders, this_ptr, "encodeurl", NULL, 256, &_6); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&headers); + object_init_ex(&headers, phalcon_encryption_security_jwt_token_item_ce); + ZEPHIR_CALL_METHOD(&_8, this_ptr, "getheaders", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &headers, "__construct", NULL, 257, &_8, &encodedHeaders); + zephir_check_call_status(); + zephir_read_property(&_9, this_ptr, ZEND_STRL("signer"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_10); + ZEPHIR_CONCAT_VSV(&_10, &encodedHeaders, ".", &encodedClaims); + zephir_read_property(&_11, this_ptr, ZEND_STRL("passphrase"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&signatureHash, &_9, "sign", NULL, 0, &_10, &_11); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&encodedSignature, this_ptr, "encodeurl", NULL, 256, &signatureHash); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&signature); + object_init_ex(&signature, phalcon_encryption_security_jwt_token_signature_ce); + ZEPHIR_CALL_METHOD(NULL, &signature, "__construct", NULL, 258, &signatureHash, &encodedSignature); + zephir_check_call_status(); + object_init_ex(return_value, phalcon_encryption_security_jwt_token_token_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 259, &headers, &claims, &signature); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, getPassphrase) +{ + + RETURN_MEMBER(getThis(), "passphrase"); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setAudience) +{ + zend_bool _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *audience, audience_sub, aud, _1; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&audience_sub); + ZVAL_UNDEF(&aud); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(audience) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &audience); + _0 = Z_TYPE_P(audience) != IS_STRING; + if (_0) { + _0 = Z_TYPE_P(audience) != IS_ARRAY; + } + if (_0) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_validatorexception_ce, "Invalid Audience", "phalcon/Encryption/Security/JWT/Builder.zep", 270); + return; + } + if (Z_TYPE_P(audience) == IS_STRING) { + ZEPHIR_INIT_VAR(&aud); + zephir_create_array(&aud, 1, 0); + zephir_array_fast_append(&aud, audience); + } else { + ZEPHIR_CPY_WRT(&aud, audience); + } + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "aud"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_1, &aud); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setContentType) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *contentType_param = NULL, _0, _1; + zval contentType; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&contentType); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(contentType) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &contentType_param); + zephir_get_strval(&contentType, contentType_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("jose"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "cty"); + ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &_1, &contentType); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setExpirationTime) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *timestamp_param = NULL, _0, _1, _2; + zend_long timestamp, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(timestamp) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, ×tamp_param); + ZEPHIR_INIT_VAR(&_0); + zephir_time(&_0); + if (ZEPHIR_GT_LONG(&_0, timestamp)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_validatorexception_ce, "Invalid Expiration Time", "phalcon/Encryption/Security/JWT/Builder.zep", 315); + return; + } + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "exp"); + ZVAL_LONG(&_2, timestamp); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_1, &_2); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setId) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *id_param = NULL, _0; + zval id; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&id); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(id) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &id_param); + if (UNEXPECTED(Z_TYPE_P(id_param) != IS_STRING && Z_TYPE_P(id_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'id' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(id_param) == IS_STRING)) { + zephir_get_strval(&id, id_param); + } else { + ZEPHIR_INIT_VAR(&id); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "jti"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_0, &id); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setIssuedAt) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *timestamp_param = NULL, _0, _1; + zend_long timestamp, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(timestamp) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, ×tamp_param); + if (UNEXPECTED(Z_TYPE_P(timestamp_param) != IS_LONG)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'timestamp' must be of the type int")); + RETURN_MM_NULL(); + } + timestamp = Z_LVAL_P(timestamp_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "iat"); + ZVAL_LONG(&_1, timestamp); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_0, &_1); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setIssuer) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *issuer_param = NULL, _0; + zval issuer; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&issuer); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(issuer) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &issuer_param); + if (UNEXPECTED(Z_TYPE_P(issuer_param) != IS_STRING && Z_TYPE_P(issuer_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'issuer' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(issuer_param) == IS_STRING)) { + zephir_get_strval(&issuer, issuer_param); + } else { + ZEPHIR_INIT_VAR(&issuer); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "iss"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_0, &issuer); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setNotBefore) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *timestamp_param = NULL, _0, _1, _2; + zend_long timestamp, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(timestamp) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, ×tamp_param); + if (UNEXPECTED(Z_TYPE_P(timestamp_param) != IS_LONG)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'timestamp' must be of the type int")); + RETURN_MM_NULL(); + } + timestamp = Z_LVAL_P(timestamp_param); + ZEPHIR_INIT_VAR(&_0); + zephir_time(&_0); + if (ZEPHIR_LT_LONG(&_0, timestamp)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_validatorexception_ce, "Invalid Not Before", "phalcon/Encryption/Security/JWT/Builder.zep", 389); + return; + } + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "nbf"); + ZVAL_LONG(&_2, timestamp); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_1, &_2); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setSubject) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *subject_param = NULL, _0; + zval subject; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&subject); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(subject) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &subject_param); + if (UNEXPECTED(Z_TYPE_P(subject_param) != IS_STRING && Z_TYPE_P(subject_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'subject' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(subject_param) == IS_STRING)) { + zephir_get_strval(&subject, subject_param); + } else { + ZEPHIR_INIT_VAR(&subject); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "sub"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setclaim", NULL, 0, &_0, &subject); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setPassphrase) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *passphrase_param = NULL, _0, _1, _2, _3; + zval passphrase; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&passphrase); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(passphrase) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &passphrase_param); + if (UNEXPECTED(Z_TYPE_P(passphrase_param) != IS_STRING && Z_TYPE_P(passphrase_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'passphrase' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(passphrase_param) == IS_STRING)) { + zephir_get_strval(&passphrase, passphrase_param); + } else { + ZEPHIR_INIT_VAR(&passphrase); + } + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "/(?=^.{16,}$)((?=.*\\d)|(?=.*\\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/"); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "/(?=^.{16,}$)((?=.*\\d)|(?=.*\\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$/"); + zephir_preg_match(&_2, &_3, &passphrase, &_0, 0, 0 , 0 ); + if (!(zephir_is_true(&_2))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_validatorexception_ce, "Invalid passphrase (too weak)", "phalcon/Encryption/Security/JWT/Builder.zep", 427); + return; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("passphrase"), &passphrase); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, setClaim) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, *value, value_sub, _0; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &name_param, &value); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &name, value); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Builder, encodeUrl) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL, _0, _1, _2, _3, _4; + zval input; + + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(input) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &input_param); + if (UNEXPECTED(Z_TYPE_P(input_param) != IS_STRING && Z_TYPE_P(input_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'input' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(input_param) == IS_STRING)) { + zephir_get_strval(&input, input_param); + } else { + ZEPHIR_INIT_VAR(&input); + } + ZEPHIR_CALL_FUNCTION(&_0, "base64_encode", NULL, 231, &input); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "+/"); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "-_"); + ZEPHIR_CALL_FUNCTION(&_3, "strtr", NULL, 5, &_0, &_1, &_2); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "="); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, ""); + ZEPHIR_INIT_VAR(&_4); + zephir_fast_str_replace(&_4, &_1, &_2, &_3); + RETURN_CCTOR(&_4); +} + @@ -102428,1097 +101187,510 @@ ZEPHIR_INIT_CLASS(Phalcon_Mvc_Application_Exception) -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_Annotations) +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Validator) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT, Validator, phalcon, encryption_security_jwt_validator, phalcon_encryption_security_jwt_validator_method_entry, 0); + + zend_declare_property_null(phalcon_encryption_security_jwt_validator_ce, SL("claims"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_encryption_security_jwt_validator_ce, SL("errors"), ZEND_ACC_PRIVATE); + zend_declare_property_long(phalcon_encryption_security_jwt_validator_ce, SL("timeShift"), 0, ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_encryption_security_jwt_validator_ce, SL("token"), ZEND_ACC_PRIVATE); + phalcon_encryption_security_jwt_validator_ce->create_object = zephir_init_properties_Phalcon_Encryption_Security_JWT_Validator; + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, __construct) +{ + zval _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long timeShift; + zval *token, token_sub, *timeShift_param = NULL, __$null, now, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&token_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&now); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(token, phalcon_encryption_security_jwt_token_token_ce) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(timeShift) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &token, &timeShift_param); + if (!timeShift_param) { + timeShift = 0; + } else { + } + ZEPHIR_INIT_VAR(&now); + zephir_time(&now); + zephir_update_property_zval(this_ptr, ZEND_STRL("token"), token); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, timeShift); + zephir_update_property_zval(this_ptr, ZEND_STRL("timeShift"), &_0); + ZEPHIR_INIT_VAR(&_1); + zephir_create_array(&_1, 7, 0); + zephir_array_update_string(&_1, SL("aud"), &__$null, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_1, SL("exp"), &now, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_1, SL("jti"), &__$null, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_1, SL("iat"), &now, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_1, SL("iss"), &__$null, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_1, SL("nbf"), &now, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_1, SL("sub"), &__$null, PH_COPY | PH_SEPARATE); + zephir_update_property_zval(this_ptr, ZEND_STRL("claims"), &_1); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, getErrors) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Router, Annotations, phalcon, mvc_router_annotations, phalcon_mvc_router_ce, phalcon_mvc_router_annotations_method_entry, 0); - - zend_declare_property_string(phalcon_mvc_router_annotations_ce, SL("actionSuffix"), "Action", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_annotations_ce, SL("actionPreformatCallback"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_annotations_ce, SL("controllerSuffix"), "Controller", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_annotations_ce, SL("handlers"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_annotations_ce, SL("routePrefix"), "", ZEND_ACC_PROTECTED); - phalcon_mvc_router_annotations_ce->create_object = zephir_init_properties_Phalcon_Mvc_Router_Annotations; - return SUCCESS; + RETURN_MEMBER(getThis(), "errors"); } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, addModuleResource) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, get) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *module_param = NULL, *handler_param = NULL, *prefix_param = NULL; - zval module, handler, prefix; + zval *claim_param = NULL, _0, _1$$3, _2$$3; + zval claim; zval *this_ptr = getThis(); - ZVAL_UNDEF(&module); - ZVAL_UNDEF(&handler); - ZVAL_UNDEF(&prefix); + ZVAL_UNDEF(&claim); ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(module) - Z_PARAM_STR(handler) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(prefix) + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(claim) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &module_param, &handler_param, &prefix_param); - if (UNEXPECTED(Z_TYPE_P(module_param) != IS_STRING && Z_TYPE_P(module_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'module' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(module_param) == IS_STRING)) { - zephir_get_strval(&module, module_param); - } else { - ZEPHIR_INIT_VAR(&module); - } - if (UNEXPECTED(Z_TYPE_P(handler_param) != IS_STRING && Z_TYPE_P(handler_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'handler' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(handler_param) == IS_STRING)) { - zephir_get_strval(&handler, handler_param); - } else { - ZEPHIR_INIT_VAR(&handler); - } - if (!prefix_param) { - ZEPHIR_INIT_VAR(&prefix); - } else { - if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) { - zephir_get_strval(&prefix, prefix_param); - } else { - ZEPHIR_INIT_VAR(&prefix); - } + zephir_fetch_params(1, 1, 0, &claim_param); + zephir_get_strval(&claim, claim_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset(&_0, &claim)) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_2$$3, &_1$$3, &claim, PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/JWT/Validator.zep", 87); + RETURN_CTOR(&_2$$3); } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 3, 0); - zephir_array_fast_append(&_0, &prefix); - zephir_array_fast_append(&_0, &handler); - zephir_array_fast_append(&_0, &module); - zephir_update_property_array_append(this_ptr, SL("handlers"), &_0); - RETURN_THIS(); + RETURN_MM_NULL(); } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, addResource) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, set) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *handler_param = NULL, *prefix_param = NULL; - zval handler, prefix; + zval *claim_param = NULL, *value, value_sub; + zval claim; zval *this_ptr = getThis(); - ZVAL_UNDEF(&handler); - ZVAL_UNDEF(&prefix); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(handler) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(prefix) + ZVAL_UNDEF(&claim); + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(claim) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &handler_param, &prefix_param); - if (UNEXPECTED(Z_TYPE_P(handler_param) != IS_STRING && Z_TYPE_P(handler_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'handler' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(handler_param) == IS_STRING)) { - zephir_get_strval(&handler, handler_param); - } else { - ZEPHIR_INIT_VAR(&handler); - } - if (!prefix_param) { - ZEPHIR_INIT_VAR(&prefix); - } else { - if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) { - zephir_get_strval(&prefix, prefix_param); - } else { - ZEPHIR_INIT_VAR(&prefix); - } - } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 2, 0); - zephir_array_fast_append(&_0, &prefix); - zephir_array_fast_append(&_0, &handler); - zephir_update_property_array_append(this_ptr, SL("handlers"), &_0); + zephir_fetch_params(1, 2, 0, &claim_param, &value); + zephir_get_strval(&claim, claim_param); + zephir_update_property_array(this_ptr, SL("claims"), &claim, value); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, getResources) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, setToken) { + zval *token, token_sub; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "handlers"); + ZVAL_UNDEF(&token_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(token, phalcon_encryption_security_jwt_token_token_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &token); + zephir_update_property_zval(this_ptr, ZEND_STRL("token"), token); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, handle) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateAudience) { - zend_string *_20$$18, *_41$$41; - zend_ulong _19$$18, _40$$41; + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL, *_13 = NULL, *_16 = NULL, *_24 = NULL, *_35 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *uri_param = NULL, __$null, annotationsService, handlers, controllerSuffix, scope, prefix, route, compiledPattern, container, handler, controllerName, lowerControllerName, namespaceName, moduleName, handlerAnnotations, classAnnotations, annotations, annotation, methodAnnotations, method, collection, _0, _1, *_2, _3, _5$$6, _7$$6, _8$$6, _9$$7, _10$$7, _11$$4, _12$$12, *_14$$15, _15$$15, *_17$$18, _18$$18, _21$$19, *_22$$19, _23$$19, _25$$23, *_26$$23, _27$$23, _28$$29, _29$$29, _30$$29, _31$$30, _32$$30, _33$$27, _34$$35, *_36$$38, _37$$38, *_38$$41, _39$$41, _42$$42, *_43$$42, _44$$42, _45$$46, *_46$$46, _47$$46; - zval uri, sufixed; + zval *audience = NULL, audience_sub, item, tokenAudience, _2, _3, _4, _5, *_6, _7, _1$$4, _8$$6, _9$$8; zval *this_ptr = getThis(); - ZVAL_UNDEF(&uri); - ZVAL_UNDEF(&sufixed); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&annotationsService); - ZVAL_UNDEF(&handlers); - ZVAL_UNDEF(&controllerSuffix); - ZVAL_UNDEF(&scope); - ZVAL_UNDEF(&prefix); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&compiledPattern); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&handler); - ZVAL_UNDEF(&controllerName); - ZVAL_UNDEF(&lowerControllerName); - ZVAL_UNDEF(&namespaceName); - ZVAL_UNDEF(&moduleName); - ZVAL_UNDEF(&handlerAnnotations); - ZVAL_UNDEF(&classAnnotations); - ZVAL_UNDEF(&annotations); - ZVAL_UNDEF(&annotation); - ZVAL_UNDEF(&methodAnnotations); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&audience_sub); + ZVAL_UNDEF(&item); + ZVAL_UNDEF(&tokenAudience); + ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_1$$4); ZVAL_UNDEF(&_8$$6); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_10$$7); - ZVAL_UNDEF(&_11$$4); - ZVAL_UNDEF(&_12$$12); - ZVAL_UNDEF(&_15$$15); - ZVAL_UNDEF(&_18$$18); - ZVAL_UNDEF(&_21$$19); - ZVAL_UNDEF(&_23$$19); - ZVAL_UNDEF(&_25$$23); - ZVAL_UNDEF(&_27$$23); - ZVAL_UNDEF(&_28$$29); - ZVAL_UNDEF(&_29$$29); - ZVAL_UNDEF(&_30$$29); - ZVAL_UNDEF(&_31$$30); - ZVAL_UNDEF(&_32$$30); - ZVAL_UNDEF(&_33$$27); - ZVAL_UNDEF(&_34$$35); - ZVAL_UNDEF(&_37$$38); - ZVAL_UNDEF(&_39$$41); - ZVAL_UNDEF(&_42$$42); - ZVAL_UNDEF(&_44$$42); - ZVAL_UNDEF(&_45$$46); - ZVAL_UNDEF(&_47$$46); + ZVAL_UNDEF(&_9$$8); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(uri) + Z_PARAM_ZVAL(audience) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &uri_param); - if (UNEXPECTED(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 of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(uri_param) == IS_STRING)) { - zephir_get_strval(&uri, uri_param); - } else { - ZEPHIR_INIT_VAR(&uri); + zephir_fetch_params(1, 1, 0, &audience); + ZEPHIR_SEPARATE_PARAM(audience); + _0 = Z_TYPE_P(audience) != IS_STRING; + if (_0) { + _0 = Z_TYPE_P(audience) != IS_ARRAY; } - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (UNEXPECTED(Z_TYPE_P(&container) != IS_OBJECT)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "A dependency injection container is required to access the 'annotations' service", "phalcon/Mvc/Router/Annotations.zep", 114); + if (_0) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_validatorexception_ce, "Audience must be a string or an array", "phalcon/Encryption/Security/JWT/Validator.zep", 137); return; } - zephir_read_property(&_0, this_ptr, ZEND_STRL("handlers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&handlers, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("controllerSuffix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&controllerSuffix, &_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "annotations"); - ZEPHIR_CALL_METHOD(&annotationsService, &container, "getshared", NULL, 0, &_1); + if (Z_TYPE_P(audience) == IS_STRING) { + ZEPHIR_INIT_VAR(&_1$$4); + zephir_create_array(&_1$$4, 1, 0); + zephir_array_fast_append(&_1$$4, audience); + ZEPHIR_CPY_WRT(audience, &_1$$4); + } + zephir_read_property(&_2, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_3, &_2, "getclaims", NULL, 0); zephir_check_call_status(); - zephir_is_iterable(&handlers, 0, "phalcon/Mvc/Router/Annotations.zep", 250); - if (Z_TYPE_P(&handlers) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&handlers), _2) + ZEPHIR_INIT_VAR(&_4); + array_init(&_4); + ZEPHIR_INIT_VAR(&_5); + ZVAL_STRING(&_5, "aud"); + ZEPHIR_CALL_METHOD(&tokenAudience, &_3, "get", NULL, 0, &_5, &_4); + zephir_check_call_status(); + zephir_is_iterable(audience, 0, "phalcon/Encryption/Security/JWT/Validator.zep", 152); + if (Z_TYPE_P(audience) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(audience), _6) { - ZEPHIR_INIT_NVAR(&scope); - ZVAL_COPY(&scope, _2); - if (Z_TYPE_P(&scope) != IS_ARRAY) { - continue; - } - ZEPHIR_OBS_NVAR(&prefix); - zephir_array_fetch_long(&prefix, &scope, 0, PH_NOISY, "phalcon/Mvc/Router/Annotations.zep", 129); - if (!(ZEPHIR_IS_EMPTY(&prefix))) { - ZEPHIR_INIT_NVAR(&route); - object_init_ex(&route, phalcon_mvc_router_route_ce); - ZEPHIR_CALL_METHOD(NULL, &route, "__construct", &_4, 101, &prefix); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_5$$6, &route, "getcompiledpattern", &_6, 486); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_7$$6); - ZVAL_STRING(&_7$$6, "$#"); + ZEPHIR_INIT_NVAR(&item); + ZVAL_COPY(&item, _6); + if (1 != zephir_fast_in_array(&item, &tokenAudience)) { + ZVAL_UNDEF(&_8$$6); ZEPHIR_INIT_NVAR(&_8$$6); - ZVAL_STRING(&_8$$6, "#"); - ZEPHIR_INIT_NVAR(&compiledPattern); - zephir_fast_str_replace(&compiledPattern, &_7$$6, &_8$$6, &_5$$6); - if (zephir_memnstr_str(&compiledPattern, SL("^"), "phalcon/Mvc/Router/Annotations.zep", 146)) { - ZEPHIR_INIT_NVAR(&_9$$7); - ZEPHIR_INIT_NVAR(&_10$$7); - zephir_preg_match(&_10$$7, &compiledPattern, &uri, &_9$$7, 0, 0 , 0 ); - if (!(zephir_is_true(&_10$$7))) { - continue; - } - } else if (!(zephir_start_with(&uri, &prefix, NULL))) { - continue; - } - } - ZEPHIR_OBS_NVAR(&handler); - zephir_array_fetch_long(&handler, &scope, 1, PH_NOISY, "phalcon/Mvc/Router/Annotations.zep", 161); - if (zephir_memnstr_str(&handler, SL("\\"), "phalcon/Mvc/Router/Annotations.zep", 163)) { - ZEPHIR_INIT_NVAR(&controllerName); - zephir_get_class_ns(&controllerName, &handler, 0); - ZEPHIR_INIT_NVAR(&namespaceName); - zephir_get_ns_class(&namespaceName, &handler, 0); - } else { - ZEPHIR_CPY_WRT(&controllerName, &handler); - ZEPHIR_OBS_NVAR(&namespaceName); - zephir_fetch_property(&namespaceName, this_ptr, SL("defaultNamespace"), PH_SILENT_CC); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("routePrefix"), &__$null); - ZEPHIR_OBS_NVAR(&moduleName); - zephir_array_isset_long_fetch(&moduleName, &scope, 2, 0); - ZEPHIR_INIT_NVAR(&_11$$4); - if (Z_TYPE_P(&moduleName) != IS_NULL) { - ZEPHIR_CPY_WRT(&_11$$4, &moduleName); - } else { - ZEPHIR_INIT_NVAR(&_11$$4); - ZVAL_STRING(&_11$$4, ""); - } - ZEPHIR_CPY_WRT(&moduleName, &_11$$4); - ZEPHIR_INIT_NVAR(&_11$$4); - ZEPHIR_CONCAT_VV(&_11$$4, &controllerName, &controllerSuffix); - zephir_get_strval(&sufixed, &_11$$4); - if (Z_TYPE_P(&namespaceName) != IS_NULL) { - ZEPHIR_INIT_NVAR(&_12$$12); - ZEPHIR_CONCAT_VSV(&_12$$12, &namespaceName, "\\", &sufixed); - zephir_get_strval(&sufixed, &_12$$12); - } - ZEPHIR_CALL_METHOD(&handlerAnnotations, &annotationsService, "get", &_13, 0, &sufixed); - zephir_check_call_status(); - if (Z_TYPE_P(&handlerAnnotations) != IS_OBJECT) { - continue; - } - ZEPHIR_CALL_METHOD(&classAnnotations, &handlerAnnotations, "getclassannotations", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&classAnnotations) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(&annotations, &classAnnotations, "getannotations", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&annotations) == IS_ARRAY) { - zephir_is_iterable(&annotations, 0, "phalcon/Mvc/Router/Annotations.zep", 218); - if (Z_TYPE_P(&annotations) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&annotations), _14$$15) - { - ZEPHIR_INIT_NVAR(&annotation); - ZVAL_COPY(&annotation, _14$$15); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processcontrollerannotation", &_16, 0, &controllerName, &annotation); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &annotations, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_15$$15, &annotations, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_15$$15)) { - break; - } - ZEPHIR_CALL_METHOD(&annotation, &annotations, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processcontrollerannotation", &_16, 0, &controllerName, &annotation); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &annotations, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&annotation); - } - } - ZEPHIR_CALL_METHOD(&methodAnnotations, &handlerAnnotations, "getmethodsannotations", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&methodAnnotations) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&lowerControllerName); - zephir_uncamelize(&lowerControllerName, &controllerName, NULL ); - zephir_is_iterable(&methodAnnotations, 0, "phalcon/Mvc/Router/Annotations.zep", 244); - if (Z_TYPE_P(&methodAnnotations) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&methodAnnotations), _19$$18, _20$$18, _17$$18) - { - ZEPHIR_INIT_NVAR(&method); - if (_20$$18 != NULL) { - ZVAL_STR_COPY(&method, _20$$18); - } else { - ZVAL_LONG(&method, _19$$18); - } - ZEPHIR_INIT_NVAR(&collection); - ZVAL_COPY(&collection, _17$$18); - if (Z_TYPE_P(&collection) != IS_OBJECT) { - continue; - } - ZEPHIR_CALL_METHOD(&_21$$19, &collection, "getannotations", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&_21$$19, 0, "phalcon/Mvc/Router/Annotations.zep", 243); - if (Z_TYPE_P(&_21$$19) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_21$$19), _22$$19) - { - ZEPHIR_INIT_NVAR(&annotation); - ZVAL_COPY(&annotation, _22$$19); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_21$$19, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_23$$19, &_21$$19, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_23$$19)) { - break; - } - ZEPHIR_CALL_METHOD(&annotation, &_21$$19, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_21$$19, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&annotation); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &methodAnnotations, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_18$$18, &methodAnnotations, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_18$$18)) { - break; - } - ZEPHIR_CALL_METHOD(&method, &methodAnnotations, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&collection, &methodAnnotations, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&collection) != IS_OBJECT) { - continue; - } - ZEPHIR_CALL_METHOD(&_25$$23, &collection, "getannotations", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&_25$$23, 0, "phalcon/Mvc/Router/Annotations.zep", 243); - if (Z_TYPE_P(&_25$$23) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_25$$23), _26$$23) - { - ZEPHIR_INIT_NVAR(&annotation); - ZVAL_COPY(&annotation, _26$$23); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_25$$23, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_27$$23, &_25$$23, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_27$$23)) { - break; - } - ZEPHIR_CALL_METHOD(&annotation, &_25$$23, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_25$$23, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&annotation); - ZEPHIR_CALL_METHOD(NULL, &methodAnnotations, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&collection); - ZEPHIR_INIT_NVAR(&method); + ZVAL_STRING(&_8$$6, "Validation: audience not allowed"); + zephir_update_property_array_append(this_ptr, SL("errors"), &_8$$6); } } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &handlers, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, audience, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_3, &handlers, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_7, audience, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_3)) { + if (!zend_is_true(&_7)) { break; } - ZEPHIR_CALL_METHOD(&scope, &handlers, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&item, audience, "current", NULL, 0); zephir_check_call_status(); - if (Z_TYPE_P(&scope) != IS_ARRAY) { - continue; - } - ZEPHIR_OBS_NVAR(&prefix); - zephir_array_fetch_long(&prefix, &scope, 0, PH_NOISY, "phalcon/Mvc/Router/Annotations.zep", 129); - if (!(ZEPHIR_IS_EMPTY(&prefix))) { - ZEPHIR_INIT_NVAR(&route); - object_init_ex(&route, phalcon_mvc_router_route_ce); - ZEPHIR_CALL_METHOD(NULL, &route, "__construct", &_4, 101, &prefix); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_28$$29, &route, "getcompiledpattern", &_6, 486); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_29$$29); - ZVAL_STRING(&_29$$29, "$#"); - ZEPHIR_INIT_NVAR(&_30$$29); - ZVAL_STRING(&_30$$29, "#"); - ZEPHIR_INIT_NVAR(&compiledPattern); - zephir_fast_str_replace(&compiledPattern, &_29$$29, &_30$$29, &_28$$29); - if (zephir_memnstr_str(&compiledPattern, SL("^"), "phalcon/Mvc/Router/Annotations.zep", 146)) { - ZEPHIR_INIT_NVAR(&_31$$30); - ZEPHIR_INIT_NVAR(&_32$$30); - zephir_preg_match(&_32$$30, &compiledPattern, &uri, &_31$$30, 0, 0 , 0 ); - if (!(zephir_is_true(&_32$$30))) { - continue; - } - } else if (!(zephir_start_with(&uri, &prefix, NULL))) { - continue; - } - } - ZEPHIR_OBS_NVAR(&handler); - zephir_array_fetch_long(&handler, &scope, 1, PH_NOISY, "phalcon/Mvc/Router/Annotations.zep", 161); - if (zephir_memnstr_str(&handler, SL("\\"), "phalcon/Mvc/Router/Annotations.zep", 163)) { - ZEPHIR_INIT_NVAR(&controllerName); - zephir_get_class_ns(&controllerName, &handler, 0); - ZEPHIR_INIT_NVAR(&namespaceName); - zephir_get_ns_class(&namespaceName, &handler, 0); - } else { - ZEPHIR_CPY_WRT(&controllerName, &handler); - ZEPHIR_OBS_NVAR(&namespaceName); - zephir_fetch_property(&namespaceName, this_ptr, SL("defaultNamespace"), PH_SILENT_CC); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("routePrefix"), &__$null); - ZEPHIR_OBS_NVAR(&moduleName); - zephir_array_isset_long_fetch(&moduleName, &scope, 2, 0); - ZEPHIR_INIT_NVAR(&_33$$27); - if (Z_TYPE_P(&moduleName) != IS_NULL) { - ZEPHIR_CPY_WRT(&_33$$27, &moduleName); - } else { - ZEPHIR_INIT_NVAR(&_33$$27); - ZVAL_STRING(&_33$$27, ""); - } - ZEPHIR_CPY_WRT(&moduleName, &_33$$27); - ZEPHIR_INIT_NVAR(&_33$$27); - ZEPHIR_CONCAT_VV(&_33$$27, &controllerName, &controllerSuffix); - zephir_get_strval(&sufixed, &_33$$27); - if (Z_TYPE_P(&namespaceName) != IS_NULL) { - ZEPHIR_INIT_NVAR(&_34$$35); - ZEPHIR_CONCAT_VSV(&_34$$35, &namespaceName, "\\", &sufixed); - zephir_get_strval(&sufixed, &_34$$35); - } - ZEPHIR_CALL_METHOD(&handlerAnnotations, &annotationsService, "get", &_35, 0, &sufixed); - zephir_check_call_status(); - if (Z_TYPE_P(&handlerAnnotations) != IS_OBJECT) { - continue; - } - ZEPHIR_CALL_METHOD(&classAnnotations, &handlerAnnotations, "getclassannotations", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&classAnnotations) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(&annotations, &classAnnotations, "getannotations", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&annotations) == IS_ARRAY) { - zephir_is_iterable(&annotations, 0, "phalcon/Mvc/Router/Annotations.zep", 218); - if (Z_TYPE_P(&annotations) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&annotations), _36$$38) - { - ZEPHIR_INIT_NVAR(&annotation); - ZVAL_COPY(&annotation, _36$$38); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processcontrollerannotation", &_16, 0, &controllerName, &annotation); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &annotations, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_37$$38, &annotations, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_37$$38)) { - break; - } - ZEPHIR_CALL_METHOD(&annotation, &annotations, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processcontrollerannotation", &_16, 0, &controllerName, &annotation); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &annotations, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&annotation); - } - } - ZEPHIR_CALL_METHOD(&methodAnnotations, &handlerAnnotations, "getmethodsannotations", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&methodAnnotations) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&lowerControllerName); - zephir_uncamelize(&lowerControllerName, &controllerName, NULL ); - zephir_is_iterable(&methodAnnotations, 0, "phalcon/Mvc/Router/Annotations.zep", 244); - if (Z_TYPE_P(&methodAnnotations) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&methodAnnotations), _40$$41, _41$$41, _38$$41) - { - ZEPHIR_INIT_NVAR(&method); - if (_41$$41 != NULL) { - ZVAL_STR_COPY(&method, _41$$41); - } else { - ZVAL_LONG(&method, _40$$41); - } - ZEPHIR_INIT_NVAR(&collection); - ZVAL_COPY(&collection, _38$$41); - if (Z_TYPE_P(&collection) != IS_OBJECT) { - continue; - } - ZEPHIR_CALL_METHOD(&_42$$42, &collection, "getannotations", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&_42$$42, 0, "phalcon/Mvc/Router/Annotations.zep", 243); - if (Z_TYPE_P(&_42$$42) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_42$$42), _43$$42) - { - ZEPHIR_INIT_NVAR(&annotation); - ZVAL_COPY(&annotation, _43$$42); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_42$$42, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_44$$42, &_42$$42, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_44$$42)) { - break; - } - ZEPHIR_CALL_METHOD(&annotation, &_42$$42, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_42$$42, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&annotation); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &methodAnnotations, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_39$$41, &methodAnnotations, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_39$$41)) { - break; - } - ZEPHIR_CALL_METHOD(&method, &methodAnnotations, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&collection, &methodAnnotations, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&collection) != IS_OBJECT) { - continue; - } - ZEPHIR_CALL_METHOD(&_45$$46, &collection, "getannotations", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&_45$$46, 0, "phalcon/Mvc/Router/Annotations.zep", 243); - if (Z_TYPE_P(&_45$$46) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_45$$46), _46$$46) - { - ZEPHIR_INIT_NVAR(&annotation); - ZVAL_COPY(&annotation, _46$$46); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_45$$46, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_47$$46, &_45$$46, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_47$$46)) { - break; - } - ZEPHIR_CALL_METHOD(&annotation, &_45$$46, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processactionannotation", &_24, 0, &moduleName, &namespaceName, &lowerControllerName, &method, &annotation); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_45$$46, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&annotation); - ZEPHIR_CALL_METHOD(NULL, &methodAnnotations, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&collection); - ZEPHIR_INIT_NVAR(&method); + if (1 != zephir_fast_in_array(&item, &tokenAudience)) { + ZVAL_UNDEF(&_9$$8); + ZEPHIR_INIT_NVAR(&_9$$8); + ZVAL_STRING(&_9$$8, "Validation: audience not allowed"); + zephir_update_property_array_append(this_ptr, SL("errors"), &_9$$8); } - ZEPHIR_CALL_METHOD(NULL, &handlers, "next", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, audience, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&scope); - ZEPHIR_CALL_PARENT(NULL, phalcon_mvc_router_annotations_ce, getThis(), "handle", NULL, 0, &uri); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + ZEPHIR_INIT_NVAR(&item); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, processActionAnnotation) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateExpiration) { - zend_string *_12$$18, *_18$$21; - zend_ulong _11$$18, _17$$21; - zend_bool isRoute = 0, _8, _21; + zend_bool _7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_13 = NULL, *_14 = NULL, *_19 = NULL, *_20 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *module_param = NULL, *namespaceName_param = NULL, *controller_param = NULL, *action_param = NULL, *annotation, annotation_sub, name, proxyActionName, actionName, routePrefix, paths, value, uri, route, methods, converts, param, convert, converterParam, routeName, beforeMatch, _0, _1, _2, _5, _6, _3$$6, _4$$6, _7$$16, *_9$$18, _10$$18, *_15$$21, _16$$21; - zval module, namespaceName, controller, action; + zval *timestamp_param = NULL, _0, _1, _2, _3, _4, _5, _6, _8, _9, _10$$3; + zend_long timestamp, ZEPHIR_LAST_CALL_STATUS, tokenExpirationTime = 0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&module); - ZVAL_UNDEF(&namespaceName); - ZVAL_UNDEF(&controller); - ZVAL_UNDEF(&action); - ZVAL_UNDEF(&annotation_sub); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&proxyActionName); - ZVAL_UNDEF(&actionName); - ZVAL_UNDEF(&routePrefix); - ZVAL_UNDEF(&paths); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&uri); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&methods); - ZVAL_UNDEF(&converts); - ZVAL_UNDEF(¶m); - ZVAL_UNDEF(&convert); - ZVAL_UNDEF(&converterParam); - ZVAL_UNDEF(&routeName); - ZVAL_UNDEF(&beforeMatch); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_5); ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_3$$6); - ZVAL_UNDEF(&_4$$6); - ZVAL_UNDEF(&_7$$16); - ZVAL_UNDEF(&_10$$18); - ZVAL_UNDEF(&_16$$21); - ZEND_PARSE_PARAMETERS_START(5, 5) - Z_PARAM_STR(module) - Z_PARAM_STR(namespaceName) - Z_PARAM_STR(controller) - Z_PARAM_STR(action) - Z_PARAM_OBJECT_OF_CLASS(annotation, phalcon_annotations_annotation_ce) + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(timestamp) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 5, 0, &module_param, &namespaceName_param, &controller_param, &action_param, &annotation); - if (UNEXPECTED(Z_TYPE_P(module_param) != IS_STRING && Z_TYPE_P(module_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'module' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(module_param) == IS_STRING)) { - zephir_get_strval(&module, module_param); - } else { - ZEPHIR_INIT_VAR(&module); - } - if (UNEXPECTED(Z_TYPE_P(namespaceName_param) != IS_STRING && Z_TYPE_P(namespaceName_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'namespaceName' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(namespaceName_param) == IS_STRING)) { - zephir_get_strval(&namespaceName, namespaceName_param); - } else { - ZEPHIR_INIT_VAR(&namespaceName); - } - if (UNEXPECTED(Z_TYPE_P(controller_param) != IS_STRING && Z_TYPE_P(controller_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controller' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(controller_param) == IS_STRING)) { - zephir_get_strval(&controller, controller_param); - } else { - ZEPHIR_INIT_VAR(&controller); - } - if (UNEXPECTED(Z_TYPE_P(action_param) != IS_STRING && Z_TYPE_P(action_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'action' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(action_param) == IS_STRING)) { - zephir_get_strval(&action, action_param); - } else { - ZEPHIR_INIT_VAR(&action); - } - isRoute = 0; - ZEPHIR_INIT_VAR(&methods); - ZVAL_NULL(&methods); - ZEPHIR_CALL_METHOD(&name, annotation, "getname", NULL, 0); + zephir_fetch_params(1, 1, 0, ×tamp_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "getclaims", NULL, 0); zephir_check_call_status(); - do { - if (ZEPHIR_IS_STRING(&name, "Route")) { - isRoute = 1; - break; - } - if (ZEPHIR_IS_STRING(&name, "Get") || ZEPHIR_IS_STRING(&name, "Post") || ZEPHIR_IS_STRING(&name, "Put") || ZEPHIR_IS_STRING(&name, "Patch") || ZEPHIR_IS_STRING(&name, "Delete") || ZEPHIR_IS_STRING(&name, "Options")) { - isRoute = 1; - ZEPHIR_INIT_NVAR(&methods); - zephir_fast_strtoupper(&methods, &name); - break; - } - } while(0); - - if (!(isRoute)) { - RETURN_MM_NULL(); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("actionSuffix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, ""); - ZEPHIR_INIT_VAR(&proxyActionName); - zephir_fast_str_replace(&proxyActionName, &_0, &_1, &action); - zephir_read_property(&_2, this_ptr, ZEND_STRL("routePrefix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&routePrefix, &_2); - zephir_read_property(&_2, this_ptr, ZEND_STRL("actionPreformatCallback"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) != IS_NULL) { - zephir_read_property(&_3$$6, this_ptr, ZEND_STRL("actionPreformatCallback"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_4$$6, "call_user_func", NULL, 188, &_3$$6, &proxyActionName); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&proxyActionName, &_4$$6); - } - ZEPHIR_INIT_VAR(&actionName); - zephir_fast_strtolower(&actionName, &proxyActionName); - ZEPHIR_INIT_VAR(&_5); - ZVAL_STRING(&_5, "paths"); - ZEPHIR_CALL_METHOD(&paths, annotation, "getnamedargument", NULL, 0, &_5); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "exp"); + ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_3); zephir_check_call_status(); - if (Z_TYPE_P(&paths) != IS_ARRAY) { - ZEPHIR_INIT_NVAR(&paths); - array_init(&paths); - } - if (!(ZEPHIR_IS_EMPTY(&module))) { - zephir_array_update_string(&paths, SL("module"), &module, PH_COPY | PH_SEPARATE); - } - if (!(ZEPHIR_IS_EMPTY(&namespaceName))) { - zephir_array_update_string(&paths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE); - } - zephir_array_update_string(&paths, SL("controller"), &controller, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&paths, SL("action"), &actionName, PH_COPY | PH_SEPARATE); - ZVAL_LONG(&_6, 0); - ZEPHIR_CALL_METHOD(&value, annotation, "getargument", NULL, 0, &_6); + tokenExpirationTime = zephir_get_intval(&_2); + zephir_read_property(&_4, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_5, &_4, "getclaims", NULL, 0); zephir_check_call_status(); - if (Z_TYPE_P(&value) != IS_NULL) { - if (!ZEPHIR_IS_STRING(&value, "/")) { - ZEPHIR_INIT_VAR(&uri); - ZEPHIR_CONCAT_VV(&uri, &routePrefix, &value); - } else { - if (Z_TYPE_P(&routePrefix) != IS_NULL) { - ZEPHIR_CPY_WRT(&uri, &routePrefix); - } else { - ZEPHIR_CPY_WRT(&uri, &value); - } - } - } else { - ZEPHIR_INIT_NVAR(&uri); - ZEPHIR_CONCAT_VV(&uri, &routePrefix, &actionName); - } - ZEPHIR_CALL_METHOD(&route, this_ptr, "add", NULL, 0, &uri, &paths); + ZEPHIR_INIT_NVAR(&_3); + ZVAL_STRING(&_3, "exp"); + ZEPHIR_CALL_METHOD(&_6, &_5, "has", NULL, 0, &_3); zephir_check_call_status(); - if (Z_TYPE_P(&methods) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$16); - ZVAL_STRING(&_7$$16, "methods"); - ZEPHIR_CALL_METHOD(&methods, annotation, "getnamedargument", NULL, 0, &_7$$16); - zephir_check_call_status(); - } - _8 = Z_TYPE_P(&methods) == IS_ARRAY; - if (!(_8)) { - _8 = Z_TYPE_P(&methods) == IS_STRING; - } - if (_8) { - ZEPHIR_CALL_METHOD(NULL, &route, "via", NULL, 0, &methods); + _7 = zephir_is_true(&_6); + if (_7) { + ZVAL_LONG(&_9, timestamp); + ZEPHIR_CALL_METHOD(&_8, this_ptr, "gettimestamp", NULL, 266, &_9); zephir_check_call_status(); + _7 = ZEPHIR_GT_LONG(&_8, tokenExpirationTime); } - ZEPHIR_INIT_NVAR(&_5); - ZVAL_STRING(&_5, "converts"); - ZEPHIR_CALL_METHOD(&converts, annotation, "getnamedargument", NULL, 0, &_5); - zephir_check_call_status(); - if (Z_TYPE_P(&converts) == IS_ARRAY) { - zephir_is_iterable(&converts, 0, "phalcon/Mvc/Router/Annotations.zep", 373); - if (Z_TYPE_P(&converts) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&converts), _11$$18, _12$$18, _9$$18) - { - ZEPHIR_INIT_NVAR(¶m); - if (_12$$18 != NULL) { - ZVAL_STR_COPY(¶m, _12$$18); - } else { - ZVAL_LONG(¶m, _11$$18); - } - ZEPHIR_INIT_NVAR(&convert); - ZVAL_COPY(&convert, _9$$18); - ZEPHIR_CALL_METHOD(NULL, &route, "convert", &_13, 0, ¶m, &convert); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &converts, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_10$$18, &converts, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_10$$18)) { - break; - } - ZEPHIR_CALL_METHOD(¶m, &converts, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&convert, &converts, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &route, "convert", &_14, 0, ¶m, &convert); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &converts, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&convert); - ZEPHIR_INIT_NVAR(¶m); - } - ZEPHIR_INIT_NVAR(&_5); - ZVAL_STRING(&_5, "converters"); - ZEPHIR_CALL_METHOD(&converts, annotation, "getnamedargument", NULL, 0, &_5); - zephir_check_call_status(); - if (Z_TYPE_P(&converts) == IS_ARRAY) { - zephir_is_iterable(&converts, 0, "phalcon/Mvc/Router/Annotations.zep", 384); - if (Z_TYPE_P(&converts) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&converts), _17$$21, _18$$21, _15$$21) - { - ZEPHIR_INIT_NVAR(&converterParam); - if (_18$$21 != NULL) { - ZVAL_STR_COPY(&converterParam, _18$$21); - } else { - ZVAL_LONG(&converterParam, _17$$21); - } - ZEPHIR_INIT_NVAR(&convert); - ZVAL_COPY(&convert, _15$$21); - ZEPHIR_CALL_METHOD(NULL, &route, "convert", &_19, 0, &converterParam, &convert); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &converts, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_16$$21, &converts, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_16$$21)) { - break; - } - ZEPHIR_CALL_METHOD(&converterParam, &converts, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&convert, &converts, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &route, "convert", &_20, 0, &converterParam, &convert); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &converts, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&convert); - ZEPHIR_INIT_NVAR(&converterParam); + if (_7) { + ZVAL_UNDEF(&_10$$3); + ZEPHIR_INIT_VAR(&_10$$3); + ZVAL_STRING(&_10$$3, "Validation: the token has expired"); + zephir_update_property_array_append(this_ptr, SL("errors"), &_10$$3); } - ZEPHIR_INIT_NVAR(&_5); - ZVAL_STRING(&_5, "beforeMatch"); - ZEPHIR_CALL_METHOD(&beforeMatch, annotation, "getnamedargument", NULL, 0, &_5); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateId) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *id_param = NULL, tokenId, _0, _1, _2, _3, _5$$3; + zval id, _4; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&id); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&tokenId); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(id) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &id_param); + zephir_get_strval(&id, id_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "getclaims", NULL, 0); zephir_check_call_status(); - _21 = Z_TYPE_P(&beforeMatch) == IS_ARRAY; - if (!(_21)) { - _21 = Z_TYPE_P(&beforeMatch) == IS_STRING; - } - if (_21) { - ZEPHIR_CALL_METHOD(NULL, &route, "beforematch", NULL, 0, &beforeMatch); - zephir_check_call_status(); - } - ZEPHIR_INIT_NVAR(&_5); - ZVAL_STRING(&_5, "name"); - ZEPHIR_CALL_METHOD(&routeName, annotation, "getnamedargument", NULL, 0, &_5); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "jti"); + ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_3); zephir_check_call_status(); - if (Z_TYPE_P(&routeName) == IS_STRING) { - ZEPHIR_CALL_METHOD(NULL, &route, "setname", NULL, 0, &routeName); - zephir_check_call_status(); + zephir_cast_to_string(&_4, &_2); + ZEPHIR_CPY_WRT(&tokenId, &_4); + if (!ZEPHIR_IS_IDENTICAL(&id, &tokenId)) { + ZVAL_UNDEF(&_5$$3); + ZEPHIR_INIT_VAR(&_5$$3); + ZVAL_STRING(&_5$$3, "Validation: incorrect Id"); + zephir_update_property_array_append(this_ptr, SL("errors"), &_5$$3); } - ZEPHIR_MM_RESTORE(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, processControllerAnnotation) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateIssuedAt) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *handler_param = NULL, *annotation, annotation_sub, _0, _1$$3, _2$$3; - zval handler; + zval *timestamp_param = NULL, _0, _1, _2, _3, _4, _5, _6$$3; + zend_long timestamp, ZEPHIR_LAST_CALL_STATUS, tokenIssuedAt = 0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&handler); - ZVAL_UNDEF(&annotation_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(handler) - Z_PARAM_OBJECT_OF_CLASS(annotation, phalcon_annotations_annotation_ce) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(timestamp) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &handler_param, &annotation); - if (UNEXPECTED(Z_TYPE_P(handler_param) != IS_STRING && Z_TYPE_P(handler_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'handler' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(handler_param) == IS_STRING)) { - zephir_get_strval(&handler, handler_param); - } else { - ZEPHIR_INIT_VAR(&handler); - } - ZEPHIR_CALL_METHOD(&_0, annotation, "getname", NULL, 0); + zephir_fetch_params(1, 1, 0, ×tamp_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "getclaims", NULL, 0); zephir_check_call_status(); - if (ZEPHIR_IS_STRING(&_0, "RoutePrefix")) { - ZVAL_LONG(&_2$$3, 0); - ZEPHIR_CALL_METHOD(&_1$$3, annotation, "getargument", NULL, 0, &_2$$3); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("routePrefix"), &_1$$3); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "iat"); + ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_3); + zephir_check_call_status(); + tokenIssuedAt = zephir_get_intval(&_2); + ZVAL_LONG(&_5, timestamp); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "gettimestamp", NULL, 266, &_5); + zephir_check_call_status(); + if (ZEPHIR_LE_LONG(&_4, tokenIssuedAt)) { + ZVAL_UNDEF(&_6$$3); + ZEPHIR_INIT_VAR(&_6$$3); + ZVAL_STRING(&_6$$3, "Validation: the token cannot be used yet (future)"); + zephir_update_property_array_append(this_ptr, SL("errors"), &_6$$3); } - ZEPHIR_MM_RESTORE(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, setActionSuffix) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateIssuer) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *actionSuffix_param = NULL; - zval actionSuffix; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *issuer_param = NULL, tokenIssuer, _0, _1, _2, _3, _5$$3; + zval issuer, _4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&actionSuffix); + ZVAL_UNDEF(&issuer); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&tokenIssuer); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5$$3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(actionSuffix) + Z_PARAM_STR(issuer) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &actionSuffix_param); - if (UNEXPECTED(Z_TYPE_P(actionSuffix_param) != IS_STRING && Z_TYPE_P(actionSuffix_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'actionSuffix' must be of the type string")); + zephir_fetch_params(1, 1, 0, &issuer_param); + if (UNEXPECTED(Z_TYPE_P(issuer_param) != IS_STRING && Z_TYPE_P(issuer_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'issuer' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(actionSuffix_param) == IS_STRING)) { - zephir_get_strval(&actionSuffix, actionSuffix_param); + if (EXPECTED(Z_TYPE_P(issuer_param) == IS_STRING)) { + zephir_get_strval(&issuer, issuer_param); } else { - ZEPHIR_INIT_VAR(&actionSuffix); + ZEPHIR_INIT_VAR(&issuer); } - zephir_update_property_zval(this_ptr, ZEND_STRL("actionSuffix"), &actionSuffix); - ZEPHIR_MM_RESTORE(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "getclaims", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "iss"); + ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_3); + zephir_check_call_status(); + zephir_cast_to_string(&_4, &_2); + ZEPHIR_CPY_WRT(&tokenIssuer, &_4); + if (!ZEPHIR_IS_IDENTICAL(&issuer, &tokenIssuer)) { + ZVAL_UNDEF(&_5$$3); + ZEPHIR_INIT_VAR(&_5$$3); + ZVAL_STRING(&_5$$3, "Validation: incorrect issuer"); + zephir_update_property_array_append(this_ptr, SL("errors"), &_5$$3); + } + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, setActionPreformatCallback) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateNotBefore) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *callback = NULL, callback_sub, __$null, _0$$4; + zval *timestamp_param = NULL, _0, _1, _2, _3, _4, _5, _6$$3; + zend_long timestamp, ZEPHIR_LAST_CALL_STATUS, tokenNotBefore = 0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&callback_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0$$4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(callback) + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(timestamp) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &callback); - if (!callback) { - callback = &callback_sub; - callback = &__$null; - } - if (EXPECTED(zephir_is_callable(callback))) { - zephir_update_property_zval(this_ptr, ZEND_STRL("actionPreformatCallback"), callback); - } else if (Z_TYPE_P(callback) == IS_NULL) { - ZEPHIR_INIT_VAR(&_0$$4); - ZEPHIR_INIT_NVAR(&_0$$4); - zephir_create_closure_ex(&_0$$4, NULL, phalcon_9__closure_ce, SL("__invoke")); - zephir_update_property_zval(this_ptr, ZEND_STRL("actionPreformatCallback"), &_0$$4); - } else { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "The 'callback' parameter must be either a callable or NULL.", "phalcon/Mvc/Router/Annotations.zep", 463); - return; + zephir_fetch_params(1, 1, 0, ×tamp_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "getclaims", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "nbf"); + ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_3); + zephir_check_call_status(); + tokenNotBefore = zephir_get_intval(&_2); + ZVAL_LONG(&_5, timestamp); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "gettimestamp", NULL, 266, &_5); + zephir_check_call_status(); + if (ZEPHIR_LE_LONG(&_4, tokenNotBefore)) { + ZVAL_UNDEF(&_6$$3); + ZEPHIR_INIT_VAR(&_6$$3); + ZVAL_STRING(&_6$$3, "Validation: the token cannot be used yet (not before)"); + zephir_update_property_array_append(this_ptr, SL("errors"), &_6$$3); } - ZEPHIR_MM_RESTORE(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, getActionPreformatCallback) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, validateSignature) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval passphrase; + zval *signer, signer_sub, *passphrase_param = NULL, _0, _1, _2, _3, _4, _5, _6$$3; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "actionPreformatCallback"); + ZVAL_UNDEF(&signer_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&passphrase); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(signer, phalcon_encryption_security_jwt_signer_signerinterface_ce) + Z_PARAM_STR(passphrase) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &signer, &passphrase_param); + zephir_get_strval(&passphrase, passphrase_param); + zephir_read_property(&_1, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_2, &_1, "getsignature", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_3, &_2, "gethash", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_4, this_ptr, ZEND_STRL("token"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_5, &_4, "getpayload", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, signer, "verify", NULL, 0, &_3, &_5, &passphrase); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZVAL_UNDEF(&_6$$3); + ZEPHIR_INIT_VAR(&_6$$3); + ZVAL_STRING(&_6$$3, "Validation: the signature does not match"); + zephir_update_property_array_append(this_ptr, SL("errors"), &_6$$3); + } + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Mvc_Router_Annotations, setControllerSuffix) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Validator, getTimestamp) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *controllerSuffix_param = NULL; - zval controllerSuffix; + zval *timestamp_param = NULL, _0; + zend_long timestamp; zval *this_ptr = getThis(); - ZVAL_UNDEF(&controllerSuffix); + ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(controllerSuffix) + Z_PARAM_LONG(timestamp) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &controllerSuffix_param); - if (UNEXPECTED(Z_TYPE_P(controllerSuffix_param) != IS_STRING && Z_TYPE_P(controllerSuffix_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'controllerSuffix' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(controllerSuffix_param) == IS_STRING)) { - zephir_get_strval(&controllerSuffix, controllerSuffix_param); - } else { - ZEPHIR_INIT_VAR(&controllerSuffix); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("controllerSuffix"), &controllerSuffix); - ZEPHIR_MM_RESTORE(); + zephir_fetch_params_without_memory_grow(1, 0, ×tamp_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("timeShift"), PH_NOISY_CC | PH_READONLY); + RETURN_LONG((timestamp + zephir_get_numberval(&_0))); } -zend_object *zephir_init_properties_Phalcon_Mvc_Router_Annotations(zend_class_entry *class_type) +zend_object *zephir_init_properties_Phalcon_Encryption_Security_JWT_Validator(zend_class_entry *class_type) { - zval _0, _2, _4, _6, _8, _10, _12, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8, _13$$9; + zval _0, _2, _1$$3, _3$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_12); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_13$$9); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); @@ -103527,47 +101699,17 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Router_Annotations(zend_class_en { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("errors"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("routes"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("errors"), &_1$$3); } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_2) == IS_NULL) { ZEPHIR_INIT_VAR(&_3$$4); array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("matches"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("matches"), &_5$$5); - } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("keyRouteIds"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("keyRouteIds"), &_7$$6); - } - zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("keyRouteNames"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_8) == IS_NULL) { - ZEPHIR_INIT_VAR(&_9$$7); - array_init(&_9$$7); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("keyRouteNames"), &_9$$7); - } - zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("defaultParams"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_10) == IS_NULL) { - ZEPHIR_INIT_VAR(&_11$$8); - array_init(&_11$$8); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("defaultParams"), &_11$$8); - } - zephir_read_property_ex(&_12, this_ptr, ZEND_STRL("handlers"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_12) == IS_NULL) { - ZEPHIR_INIT_VAR(&_13$$9); - array_init(&_13$$9); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("handlers"), &_13$$9); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("claims"), &_3$$4); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -103584,13 +101726,53 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Router_Annotations(zend_class_en -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_Exception) +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_AbstractItem) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Mvc\\Router, Exception, phalcon, mvc_router_exception, zend_ce_exception, NULL, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT\\Token, AbstractItem, phalcon, encryption_security_jwt_token_abstractitem, phalcon_encryption_security_jwt_token_abstractitem_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + zend_declare_property_null(phalcon_encryption_security_jwt_token_abstractitem_ce, SL("data"), ZEND_ACC_PROTECTED); + phalcon_encryption_security_jwt_token_abstractitem_ce->create_object = zephir_init_properties_Phalcon_Encryption_Security_JWT_Token_AbstractItem; return SUCCESS; } +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_AbstractItem, getEncoded) +{ + zval _0, _1; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_1, &_0, SL("encoded"), PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/JWT/Token/AbstractItem.zep", 28); + RETURN_CTORW(&_1); +} + +zend_object *zephir_init_properties_Phalcon_Encryption_Security_JWT_Token_AbstractItem(zend_class_entry *class_type) +{ + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("data"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } +} + @@ -103601,722 +101783,838 @@ ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_Exception) -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_Group) +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_Enum) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Router, Group, phalcon, mvc_router_group, phalcon_mvc_router_group_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT\\Token, Enum, phalcon, encryption_security_jwt_token_enum, NULL, 0); - zend_declare_property_null(phalcon_mvc_router_group_ce, SL("beforeMatch"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_group_ce, SL("hostname"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_group_ce, SL("paths"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_group_ce, SL("prefix"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_group_ce, SL("routes"), ZEND_ACC_PROTECTED); - phalcon_mvc_router_group_ce->create_object = zephir_init_properties_Phalcon_Mvc_Router_Group; + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("TYPE"), "typ"); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("ALGO"), "alg"); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("CONTENT_TYPE"), "cty"); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("AUDIENCE"), "aud"); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("EXPIRATION_TIME"), "exp"); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("ID"), "jti"); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("ISSUED_AT"), "iat"); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("ISSUER"), "iss"); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("NOT_BEFORE"), "nbf"); + + zephir_declare_class_constant_string(phalcon_encryption_security_jwt_token_enum_ce, SL("SUBJECT"), "sub"); - zend_class_implements(phalcon_mvc_router_group_ce, 1, phalcon_mvc_router_groupinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router_Group, __construct) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_Item) { - zend_bool _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *paths = NULL, paths_sub, __$null; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Security\\JWT\\Token, Item, phalcon, encryption_security_jwt_token_item, phalcon_encryption_security_jwt_token_abstractitem_ce, phalcon_encryption_security_jwt_token_item_method_entry, 0); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &paths); - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - _0 = Z_TYPE_P(paths) == IS_ARRAY; - if (!(_0)) { - _0 = Z_TYPE_P(paths) == IS_STRING; - } - if (_0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("paths"), paths); - } - if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("initialize")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0, paths); - zephir_check_call_status(); - } - ZEPHIR_MM_RESTORE(); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router_Group, add) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Item, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *httpMethods = NULL, httpMethods_sub, __$null; - zval pattern; + zval encoded; + zval *payload_param = NULL, *encoded_param = NULL, _0, _1; + zval payload; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_UNDEF(&httpMethods_sub); - ZVAL_NULL(&__$null); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_ZVAL_OR_NULL(httpMethods) + ZVAL_UNDEF(&payload); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&encoded); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ARRAY(payload) + Z_PARAM_STR(encoded) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &httpMethods); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + zephir_fetch_params(1, 2, 0, &payload_param, &encoded_param); + ZEPHIR_OBS_COPY_OR_DUP(&payload, payload_param); + if (UNEXPECTED(Z_TYPE_P(encoded_param) != IS_STRING && Z_TYPE_P(encoded_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'encoded' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + if (EXPECTED(Z_TYPE_P(encoded_param) == IS_STRING)) { + zephir_get_strval(&encoded, encoded_param); } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!httpMethods) { - httpMethods = &httpMethods_sub; - httpMethods = &__$null; + ZEPHIR_INIT_VAR(&encoded); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, httpMethods); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "encoded"); + zephir_update_property_array(this_ptr, SL("data"), &_0, &encoded); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "payload"); + zephir_update_property_array(this_ptr, SL("data"), &_1, &payload); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addConnect) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Item, get) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; + zval *name_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null, _0, _1, _2, _3; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&defaultValue_sub); ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) + Z_PARAM_STR(name) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_ZVAL_OR_NULL(defaultValue) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + zephir_fetch_params(1, 1, 1, &name_param, &defaultValue); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - ZEPHIR_INIT_VAR(&pattern); + ZEPHIR_INIT_VAR(&name); } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "CONNECT"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, 0, &name); zephir_check_call_status(); - RETURN_MM(); + if (!(zephir_is_true(&_0))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + zephir_read_property(&_1, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_2, &_1, SL("payload"), PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/JWT/Token/Item.zep", 42); + zephir_array_fetch(&_3, &_2, &name, PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/JWT/Token/Item.zep", 42); + RETURN_CTOR(&_3); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addDelete) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Item, getPayload) +{ + zval _0, _1; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_1, &_0, SL("payload"), PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/JWT/Token/Item.zep", 50); + RETURN_CTORW(&_1); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Item, has) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; + zval *name_param = NULL, _0, _1; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&name); ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + ZEPHIR_INIT_VAR(&name); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "DELETE"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); - zephir_check_call_status(); - RETURN_MM(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_1, &_0, SL("payload"), PH_READONLY, "phalcon/Encryption/Security/JWT/Token/Item.zep", 60); + RETURN_MM_BOOL(zephir_array_isset(&_1, &name)); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addGet) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_Parser) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT\\Token, Parser, phalcon, encryption_security_jwt_token_parser, phalcon_encryption_security_jwt_token_parser_method_entry, 0); + + zend_declare_property_null(phalcon_encryption_security_jwt_token_parser_ce, SL("decode"), ZEND_ACC_PRIVATE); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; + zval *decode = NULL, decode_sub, __$null, service; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); + ZVAL_UNDEF(&decode_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&service); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(decode, phalcon_support_helper_json_decode_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); + zephir_fetch_params(1, 0, 1, &decode); + if (!decode) { + decode = &decode_sub; + decode = &__$null; } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + ZEPHIR_CPY_WRT(&service, decode); + if (Z_TYPE_P(&service) == IS_NULL) { + ZEPHIR_INIT_NVAR(&service); + object_init_ex(&service, phalcon_support_helper_json_decode_ce); + if (zephir_has_constructor(&service)) { + ZEPHIR_CALL_METHOD(NULL, &service, "__construct", NULL, 0); + zephir_check_call_status(); + } + } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "GET"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); - zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("decode"), &service); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addHead) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, parse) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; + zval *token_param = NULL, claims, encodedClaims, encodedHeaders, encodedSignature, headers, results, signature; + zval token; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + ZVAL_UNDEF(&token); + ZVAL_UNDEF(&claims); + ZVAL_UNDEF(&encodedClaims); + ZVAL_UNDEF(&encodedHeaders); + ZVAL_UNDEF(&encodedSignature); + ZVAL_UNDEF(&headers); + ZVAL_UNDEF(&results); + ZVAL_UNDEF(&signature); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(token) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + zephir_fetch_params(1, 1, 0, &token_param); + if (UNEXPECTED(Z_TYPE_P(token_param) != IS_STRING && Z_TYPE_P(token_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'token' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + if (EXPECTED(Z_TYPE_P(token_param) == IS_STRING)) { + zephir_get_strval(&token, token_param); } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + ZEPHIR_INIT_VAR(&token); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "HEAD"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + ZEPHIR_CALL_METHOD(&results, this_ptr, "parsetoken", NULL, 261, &token); + zephir_check_call_status(); + zephir_memory_observe(&encodedHeaders); + zephir_array_fetch_long(&encodedHeaders, &results, 0, PH_NOISY, "phalcon/Encryption/Security/JWT/Token/Parser.zep", 55); + zephir_memory_observe(&encodedClaims); + zephir_array_fetch_long(&encodedClaims, &results, 1, PH_NOISY, "phalcon/Encryption/Security/JWT/Token/Parser.zep", 56); + zephir_memory_observe(&encodedSignature); + zephir_array_fetch_long(&encodedSignature, &results, 2, PH_NOISY, "phalcon/Encryption/Security/JWT/Token/Parser.zep", 57); + ZEPHIR_CALL_METHOD(&headers, this_ptr, "decodeheaders", NULL, 262, &encodedHeaders); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&claims, this_ptr, "decodeclaims", NULL, 263, &encodedClaims); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&signature, this_ptr, "decodesignature", NULL, 264, &headers, &encodedSignature); + zephir_check_call_status(); + object_init_ex(return_value, phalcon_encryption_security_jwt_token_token_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 259, &headers, &claims, &signature); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addOptions) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, decodeClaims) { + zval _5$$4; + zend_bool _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; + zval *claims_param = NULL, decoded, _0, _1, _2, _4, _6$$4; + zval claims; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&claims); + ZVAL_UNDEF(&decoded); ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_5$$4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(claims) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 0, &claims_param); + zephir_get_strval(&claims, claims_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("decode"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "decodeurl", NULL, 265, &claims); + zephir_check_call_status(); + ZVAL_BOOL(&_2, 1); + ZEPHIR_CALL_METHOD(&decoded, &_0, "__invoke", NULL, 0, &_1, &_2); + zephir_check_call_status(); + if (Z_TYPE_P(&decoded) != IS_ARRAY) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Invalid Claims (not an array)", "phalcon/Encryption/Security/JWT/Token/Parser.zep", 81); + return; } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); + _3 = zephir_array_isset_string(&decoded, SL("aud")); + if (_3) { + zephir_memory_observe(&_4); + zephir_array_fetch_string(&_4, &decoded, SL("aud"), PH_NOISY, "phalcon/Encryption/Security/JWT/Token/Parser.zep", 87); + _3 = Z_TYPE_P(&_4) != IS_ARRAY; } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + if (_3) { + ZEPHIR_INIT_VAR(&_5$$4); + zephir_create_array(&_5$$4, 1, 0); + zephir_memory_observe(&_6$$4); + zephir_array_fetch_string(&_6$$4, &decoded, SL("aud"), PH_NOISY, "phalcon/Encryption/Security/JWT/Token/Parser.zep", 88); + zephir_array_fast_append(&_5$$4, &_6$$4); + zephir_array_update_string(&decoded, SL("aud"), &_5$$4, PH_COPY | PH_SEPARATE); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "OPTIONS"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + object_init_ex(return_value, phalcon_encryption_security_jwt_token_item_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 257, &decoded, &claims); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addPatch) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, decodeHeaders) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; + zval *headers_param = NULL, decoded, _0, _1, _2; + zval headers; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&headers); + ZVAL_UNDEF(&decoded); ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(headers) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); + zephir_fetch_params(1, 1, 0, &headers_param); + zephir_get_strval(&headers, headers_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("decode"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "decodeurl", NULL, 265, &headers); + zephir_check_call_status(); + ZVAL_BOOL(&_2, 1); + ZEPHIR_CALL_METHOD(&decoded, &_0, "__invoke", NULL, 0, &_1, &_2); + zephir_check_call_status(); + if (Z_TYPE_P(&decoded) != IS_ARRAY) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Invalid Header (not an array)", "phalcon/Encryption/Security/JWT/Token/Parser.zep", 110); + return; } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + if (!(zephir_array_isset_string(&decoded, SL("typ")))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Invalid Header (missing 'typ' element)", "phalcon/Encryption/Security/JWT/Token/Parser.zep", 116); + return; } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "PATCH"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + object_init_ex(return_value, phalcon_encryption_security_jwt_token_item_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 257, &decoded, &headers); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addPost) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, decodeSignature) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; + zval signature; + zval *headers, headers_sub, *signature_param = NULL, algo, decoded, _0, _1, _2; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&headers_sub); + ZVAL_UNDEF(&algo); + ZVAL_UNDEF(&decoded); ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&signature); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(headers, phalcon_encryption_security_jwt_token_item_ce) + Z_PARAM_STR(signature) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + zephir_fetch_params(1, 2, 0, &headers, &signature_param); + zephir_get_strval(&signature, signature_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "alg"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "none"); + ZEPHIR_CALL_METHOD(&algo, headers, "get", NULL, 0, &_0, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "none"); + if (ZEPHIR_IS_IDENTICAL(&_2, &algo)) { + ZEPHIR_INIT_VAR(&decoded); + ZVAL_STRING(&decoded, ""); + ZEPHIR_INIT_NVAR(&signature); } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + ZEPHIR_CALL_METHOD(&decoded, this_ptr, "decodeurl", NULL, 265, &signature); + zephir_check_call_status(); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "POST"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + object_init_ex(return_value, phalcon_encryption_security_jwt_token_signature_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 258, &decoded, &signature); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addPurge) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, parseToken) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; - zval *this_ptr = getThis(); + zval *token_param = NULL, parts; + zval token; - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + ZVAL_UNDEF(&token); + ZVAL_UNDEF(&parts); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(token) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + zephir_fetch_params(1, 1, 0, &token_param); + if (UNEXPECTED(Z_TYPE_P(token_param) != IS_STRING && Z_TYPE_P(token_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'token' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + if (EXPECTED(Z_TYPE_P(token_param) == IS_STRING)) { + zephir_get_strval(&token, token_param); } else { - ZEPHIR_INIT_VAR(&pattern); + ZEPHIR_INIT_VAR(&token); } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + ZEPHIR_INIT_VAR(&parts); + zephir_fast_explode_str(&parts, SL("."), &token, LONG_MAX); + if (zephir_fast_count_int(&parts) != 3) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Invalid JWT string (dots misalignment)", "phalcon/Encryption/Security/JWT/Token/Parser.zep", 162); + return; } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "PURGE"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); - zephir_check_call_status(); - RETURN_MM(); + RETURN_CCTOR(&parts); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addPut) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Parser, decodeUrl) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; - zval *this_ptr = getThis(); + zend_long ZEPHIR_LAST_CALL_STATUS, remainder = 0; + zval *input_param = NULL, data, _3, _4, _5, _0$$3, _1$$3, _2$$3; + zval input; - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(input) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + zephir_fetch_params(1, 1, 0, &input_param); + if (UNEXPECTED(Z_TYPE_P(input_param) != IS_STRING && Z_TYPE_P(input_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'input' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + if (EXPECTED(Z_TYPE_P(input_param) == IS_STRING)) { + zephir_get_strval(&input, input_param); } else { - ZEPHIR_INIT_VAR(&pattern); + ZEPHIR_INIT_VAR(&input); } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + remainder = (long) (zephir_safe_mod_long_long(zephir_fast_strlen_ev(&input), 4)); + if (remainder) { + ZEPHIR_INIT_VAR(&_0$$3); + ZVAL_STRING(&_0$$3, "="); + ZVAL_LONG(&_1$$3, (4 - remainder)); + ZEPHIR_CALL_FUNCTION(&_2$$3, "str_repeat", NULL, 1, &_0$$3, &_1$$3); + zephir_check_call_status(); + zephir_concat_self(&input, &_2$$3); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "PUT"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "-_"); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "+/"); + ZEPHIR_CALL_FUNCTION(&_5, "strtr", NULL, 5, &input, &_3, &_4); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_CALL_FUNCTION(&data, "base64_decode", NULL, 230, &_5); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&data)) { + ZEPHIR_INIT_NVAR(&data); + ZVAL_STRING(&data, ""); + } + RETURN_CCTOR(&data); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addTrace) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_Signature) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Security\\JWT\\Token, Signature, phalcon, encryption_security_jwt_token_signature, phalcon_encryption_security_jwt_token_abstractitem_ce, phalcon_encryption_security_jwt_token_signature_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Signature, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, _0; - zval pattern; + zval *hash_param = NULL, *encoded_param = NULL, _0, _1; + zval hash, encoded; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&hash); + ZVAL_UNDEF(&encoded); ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_STR(hash) + Z_PARAM_STR(encoded) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + zephir_fetch_params(1, 0, 2, &hash_param, &encoded_param); + if (!hash_param) { + ZEPHIR_INIT_VAR(&hash); + ZVAL_STRING(&hash, ""); + } else { + if (UNEXPECTED(Z_TYPE_P(hash_param) != IS_STRING && Z_TYPE_P(hash_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'hash' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(hash_param) == IS_STRING)) { + zephir_get_strval(&hash, hash_param); + } else { + ZEPHIR_INIT_VAR(&hash); + } + } + if (!encoded_param) { + ZEPHIR_INIT_VAR(&encoded); + ZVAL_STRING(&encoded, ""); + } else { + if (UNEXPECTED(Z_TYPE_P(encoded_param) != IS_STRING && Z_TYPE_P(encoded_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'encoded' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + if (EXPECTED(Z_TYPE_P(encoded_param) == IS_STRING)) { + zephir_get_strval(&encoded, encoded_param); } else { - ZEPHIR_INIT_VAR(&pattern); + ZEPHIR_INIT_VAR(&encoded); } - if (!paths) { - paths = &paths_sub; - paths = &__$null; } ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "TRACE"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addroute", NULL, 0, &pattern, paths, &_0); - zephir_check_call_status(); - RETURN_MM(); + ZVAL_STRING(&_0, "encoded"); + zephir_update_property_array(this_ptr, SL("data"), &_0, &encoded); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "hash"); + zephir_update_property_array(this_ptr, SL("data"), &_1, &hash); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, beforeMatch) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Signature, getHash) { - zval *beforeMatch, beforeMatch_sub; + zval _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&beforeMatch_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(beforeMatch) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &beforeMatch); - zephir_update_property_zval(this_ptr, ZEND_STRL("beforeMatch"), beforeMatch); - RETURN_THISW(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_1, &_0, SL("hash"), PH_NOISY | PH_READONLY, "phalcon/Encryption/Security/JWT/Token/Signature.zep", 35); + RETURN_CTORW(&_1); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, clear) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("routes"), &_0); - ZEPHIR_MM_RESTORE(); -} -static PHP_METHOD(Phalcon_Mvc_Router_Group, getBeforeMatch) -{ +#ifdef HAVE_CONFIG_H +#endif - RETURN_MEMBER(getThis(), "beforeMatch"); -} -static PHP_METHOD(Phalcon_Mvc_Router_Group, getHostname) + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Token_Token) { + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT\\Token, Token, phalcon, encryption_security_jwt_token_token, phalcon_encryption_security_jwt_token_token_method_entry, 0); - RETURN_MEMBER(getThis(), "hostname"); + zend_declare_property_null(phalcon_encryption_security_jwt_token_token_ce, SL("claims"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_encryption_security_jwt_token_token_ce, SL("headers"), ZEND_ACC_PRIVATE); + zend_declare_property_null(phalcon_encryption_security_jwt_token_token_ce, SL("signature"), ZEND_ACC_PRIVATE); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router_Group, getPaths) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, __construct) { + zval *headers, headers_sub, *claims, claims_sub, *signature, signature_sub; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "paths"); + ZVAL_UNDEF(&headers_sub); + ZVAL_UNDEF(&claims_sub); + ZVAL_UNDEF(&signature_sub); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_OBJECT_OF_CLASS(headers, phalcon_encryption_security_jwt_token_item_ce) + Z_PARAM_OBJECT_OF_CLASS(claims, phalcon_encryption_security_jwt_token_item_ce) + Z_PARAM_OBJECT_OF_CLASS(signature, phalcon_encryption_security_jwt_token_signature_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(3, 0, &headers, &claims, &signature); + zephir_update_property_zval(this_ptr, ZEND_STRL("headers"), headers); + zephir_update_property_zval(this_ptr, ZEND_STRL("claims"), claims); + zephir_update_property_zval(this_ptr, ZEND_STRL("signature"), signature); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, getPrefix) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, getClaims) { - RETURN_MEMBER(getThis(), "prefix"); + RETURN_MEMBER(getThis(), "claims"); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, getRoutes) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, getHeaders) { - RETURN_MEMBER(getThis(), "routes"); + RETURN_MEMBER(getThis(), "headers"); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, setHostname) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, getPayload) { + zval _0, _1, _2, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *hostname_param = NULL; - zval hostname; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&hostname); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(hostname) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &hostname_param); - zephir_get_strval(&hostname, hostname_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("hostname"), &hostname); - RETURN_THIS(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "getencoded", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_2, this_ptr, ZEND_STRL("claims"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_3, &_2, "getencoded", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CONCAT_VSV(return_value, &_1, ".", &_3); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, setPaths) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, getSignature) { - zval *paths, paths_sub; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&paths_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(paths) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &paths); - zephir_update_property_zval(this_ptr, ZEND_STRL("paths"), paths); - RETURN_THISW(); + RETURN_MEMBER(getThis(), "signature"); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, setPrefix) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, getToken) { + zval _0, _1, _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *prefix_param = NULL; - zval prefix; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&prefix); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(prefix) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &prefix_param); - zephir_get_strval(&prefix, prefix_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("prefix"), &prefix); - RETURN_THIS(); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getpayload", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getsignature", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_2, &_1, "getencoded", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CONCAT_VSV(return_value, &_0, ".", &_2); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Group, addRoute) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, validate) { + zend_string *_5; + zend_ulong _4; + zval methods; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *httpMethods = NULL, httpMethods_sub, __$null, mergedPaths, route, defaultPaths, processedPaths, _0, _1; - zval pattern; - zval *this_ptr = getThis(); + zval *validator, validator_sub, claimId, method, _0, _1, *_2, _3; - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_UNDEF(&httpMethods_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&mergedPaths); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&defaultPaths); - ZVAL_UNDEF(&processedPaths); + ZVAL_UNDEF(&validator_sub); + ZVAL_UNDEF(&claimId); + ZVAL_UNDEF(&method); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_ZVAL_OR_NULL(httpMethods) + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&methods); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(validator, phalcon_encryption_security_jwt_validator_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &httpMethods); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + zephir_fetch_params(1, 1, 0, &validator); + ZEPHIR_INIT_VAR(&methods); + zephir_create_array(&methods, 6, 0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "aud"); + ZEPHIR_CALL_METHOD(&_0, validator, "get", NULL, 0, &_1); + zephir_check_call_status(); + zephir_array_update_string(&methods, SL("validateAudience"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "exp"); + ZEPHIR_CALL_METHOD(&_0, validator, "get", NULL, 0, &_1); + zephir_check_call_status(); + zephir_array_update_string(&methods, SL("validateExpiration"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "jti"); + ZEPHIR_CALL_METHOD(&_0, validator, "get", NULL, 0, &_1); + zephir_check_call_status(); + zephir_array_update_string(&methods, SL("validateId"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "iat"); + ZEPHIR_CALL_METHOD(&_0, validator, "get", NULL, 0, &_1); + zephir_check_call_status(); + zephir_array_update_string(&methods, SL("validateIssuedAt"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "iss"); + ZEPHIR_CALL_METHOD(&_0, validator, "get", NULL, 0, &_1); + zephir_check_call_status(); + zephir_array_update_string(&methods, SL("validateIssuer"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "nbf"); + ZEPHIR_CALL_METHOD(&_0, validator, "get", NULL, 0, &_1); + zephir_check_call_status(); + zephir_array_update_string(&methods, SL("validateNotBefore"), &_0, PH_COPY | PH_SEPARATE); + zephir_is_iterable(&methods, 0, "phalcon/Encryption/Security/JWT/Token/Token.zep", 131); + if (Z_TYPE_P(&methods) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&methods), _4, _5, _2) + { + ZEPHIR_INIT_NVAR(&method); + if (_5 != NULL) { + ZVAL_STR_COPY(&method, _5); + } else { + ZVAL_LONG(&method, _4); + } + ZEPHIR_INIT_NVAR(&claimId); + ZVAL_COPY(&claimId, _2); + ZEPHIR_CALL_METHOD_ZVAL(NULL, validator, &method, NULL, 0, &claimId); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - if (!httpMethods) { - httpMethods = &httpMethods_sub; - httpMethods = &__$null; - } - zephir_memory_observe(&defaultPaths); - zephir_read_property(&defaultPaths, this_ptr, ZEND_STRL("paths"), PH_NOISY_CC); - if (Z_TYPE_P(&defaultPaths) == IS_ARRAY) { - if (Z_TYPE_P(paths) == IS_STRING) { - ZEPHIR_CALL_CE_STATIC(&processedPaths, phalcon_mvc_router_route_ce, "getroutepaths", NULL, 0, paths); + ZEPHIR_CALL_METHOD(NULL, &methods, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &methods, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&method, &methods, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&claimId, &methods, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD_ZVAL(NULL, validator, &method, NULL, 0, &claimId); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &methods, "next", NULL, 0); zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&processedPaths, paths); - } - if (Z_TYPE_P(&processedPaths) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&mergedPaths); - zephir_fast_array_merge(&mergedPaths, &defaultPaths, &processedPaths); - } else { - ZEPHIR_CPY_WRT(&mergedPaths, &defaultPaths); } - } else { - ZEPHIR_CPY_WRT(&mergedPaths, paths); } - ZEPHIR_INIT_VAR(&route); - object_init_ex(&route, phalcon_mvc_router_route_ce); - zephir_read_property(&_0, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZEPHIR_CONCAT_VV(&_1, &_0, &pattern); - ZEPHIR_CALL_METHOD(NULL, &route, "__construct", NULL, 101, &_1, &mergedPaths, httpMethods); - zephir_check_call_status(); - zephir_update_property_array_append(this_ptr, SL("routes"), &route); - ZEPHIR_CALL_METHOD(NULL, &route, "setgroup", NULL, 487, this_ptr); + ZEPHIR_INIT_NVAR(&claimId); + ZEPHIR_INIT_NVAR(&method); + ZEPHIR_RETURN_CALL_METHOD(validator, "geterrors", NULL, 0); zephir_check_call_status(); - RETURN_CCTOR(&route); + RETURN_MM(); } -zend_object *zephir_init_properties_Phalcon_Mvc_Router_Group(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Token_Token, verify) { - zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - + zend_long ZEPHIR_LAST_CALL_STATUS; + zval key; + zval *signer, signer_sub, *key_param = NULL, _0, _1, _2, _3, _4, _5, _6; + zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("routes"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + ZVAL_UNDEF(&signer_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&key); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(signer, phalcon_encryption_security_jwt_signer_signerinterface_ce) + Z_PARAM_STR(key) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &signer, &key_param); + zephir_get_strval(&key, key_param); + ZEPHIR_CALL_METHOD(&_0, signer, "getalgheader", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getheaders", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "alg"); + ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_3); + zephir_check_call_status(); + if (!ZEPHIR_IS_IDENTICAL(&_0, &_2)) { + RETURN_MM_BOOL(0); } + zephir_read_property(&_4, this_ptr, ZEND_STRL("signature"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_5, &_4, "gethash", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_6, this_ptr, "getpayload", NULL, 0); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(signer, "verify", NULL, 0, &_5, &_6, &key); + zephir_check_call_status(); + RETURN_MM(); } @@ -104329,34 +102627,13 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Router_Group(zend_class_entry *c -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_GroupInterface) +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Exceptions_UnsupportedAlgorithmException) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Router, GroupInterface, phalcon, mvc_router_groupinterface, phalcon_mvc_router_groupinterface_method_entry); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Security\\JWT\\Exceptions, UnsupportedAlgorithmException, phalcon, encryption_security_jwt_exceptions_unsupportedalgorithmexception, zend_ce_exception, NULL, 0); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, add); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addConnect); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addDelete); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addGet); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addHead); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addOptions); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addPatch); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addPost); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addPurge); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addPut); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, addTrace); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, beforeMatch); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, clear); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, getBeforeMatch); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, getHostname); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, getPaths); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, getPrefix); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, getRoutes); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, setHostname); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, setPaths); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, setPrefix); @@ -104367,888 +102644,1093 @@ ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_GroupInterface, setPrefix); -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_Route) +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Exceptions_ValidatorException) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Mvc\\Router, Route, phalcon, mvc_router_route, phalcon_mvc_router_route_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Security\\JWT\\Exceptions, ValidatorException, phalcon, encryption_security_jwt_exceptions_validatorexception, zend_ce_exception, NULL, 0); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("beforeMatch"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("compiledPattern"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("converters"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("group"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("hostname"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_mvc_router_route_ce, SL("id"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("methods"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("match"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("name"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("paths"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_mvc_router_route_ce, SL("pattern"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_mvc_router_route_ce, SL("uniqueId"), 0, ZEND_ACC_PROTECTED|ZEND_ACC_STATIC); - phalcon_mvc_router_route_ce->create_object = zephir_init_properties_Phalcon_Mvc_Router_Route; + return SUCCESS; +} - zend_class_implements(phalcon_mvc_router_route_ce, 1, phalcon_mvc_router_routeinterface_ce); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Signer_AbstractSigner) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT\\Signer, AbstractSigner, phalcon, encryption_security_jwt_signer_abstractsigner, phalcon_encryption_security_jwt_signer_abstractsigner_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + zend_declare_property_string(phalcon_encryption_security_jwt_signer_abstractsigner_ce, SL("algorithm"), "", ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_encryption_security_jwt_signer_abstractsigner_ce, 1, phalcon_encryption_security_jwt_signer_signerinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router_Route, __construct) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_AbstractSigner, getAlgorithm) +{ + + RETURN_MEMBER(getThis(), "algorithm"); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Signer_Hmac) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Security\\JWT\\Signer, Hmac, phalcon, encryption_security_jwt_signer_hmac, phalcon_encryption_security_jwt_signer_abstractsigner_ce, phalcon_encryption_security_jwt_signer_hmac_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_Hmac, __construct) +{ + zval supported; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, *httpMethods = NULL, httpMethods_sub, __$null, routeId, uniqueId, _0; - zval pattern, _1; + zval *algo_param = NULL; + zval algo; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&paths_sub); - ZVAL_UNDEF(&httpMethods_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&routeId); - ZVAL_UNDEF(&uniqueId); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(pattern) + ZVAL_UNDEF(&algo); + ZVAL_UNDEF(&supported); + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - Z_PARAM_ZVAL_OR_NULL(httpMethods) + Z_PARAM_STR(algo) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &pattern_param, &paths, &httpMethods); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + zephir_fetch_params(1, 0, 1, &algo_param); + if (!algo_param) { + ZEPHIR_INIT_VAR(&algo); + ZVAL_STRING(&algo, "sha512"); + } else { + if (UNEXPECTED(Z_TYPE_P(algo_param) != IS_STRING && Z_TYPE_P(algo_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'algo' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + if (EXPECTED(Z_TYPE_P(algo_param) == IS_STRING)) { + zephir_get_strval(&algo, algo_param); } else { - ZEPHIR_INIT_VAR(&pattern); + ZEPHIR_INIT_VAR(&algo); } - if (!paths) { - paths = &paths_sub; - paths = &__$null; } - if (!httpMethods) { - httpMethods = &httpMethods_sub; - httpMethods = &__$null; + ZEPHIR_INIT_VAR(&supported); + zephir_create_array(&supported, 3, 0); + add_assoc_long_ex(&supported, SL("sha512"), 1); + add_assoc_long_ex(&supported, SL("sha384"), 1); + add_assoc_long_ex(&supported, SL("sha256"), 1); + if (!(zephir_array_isset(&supported, &algo))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_encryption_security_jwt_exceptions_unsupportedalgorithmexception_ce, "Unsupported HMAC algorithm", "phalcon/Encryption/Security/JWT/Signer/Hmac.zep", 40); + return; } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "reconfigure", NULL, 0, &pattern, paths); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "via", NULL, 0, httpMethods); - zephir_check_call_status(); - zephir_memory_observe(&_0); - zephir_read_static_property_ce(&_0, phalcon_mvc_router_route_ce, SL("uniqueId"), PH_NOISY_CC); - ZEPHIR_CPY_WRT(&uniqueId, &_0); - ZEPHIR_CPY_WRT(&routeId, &uniqueId); - zephir_cast_to_string(&_1, &routeId); - zephir_update_property_zval(this_ptr, ZEND_STRL("id"), &_1); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, (zephir_get_numberval(&uniqueId) + 1)); - zephir_update_static_property_ce(phalcon_mvc_router_route_ce, ZEND_STRL("uniqueId"), &_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("algorithm"), &algo); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, beforeMatch) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_Hmac, getAlgHeader) { - zval *callback, callback_sub; + zval _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zval *this_ptr = getThis(); - ZVAL_UNDEF(&callback_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(callback) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &callback); - zephir_update_property_zval(this_ptr, ZEND_STRL("beforeMatch"), callback); - RETURN_THISW(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("algorithm"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "sha"); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, ""); + zephir_fast_str_replace(&_0, &_2, &_3, &_1); + ZEPHIR_CONCAT_SV(return_value, "HS", &_0); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, compilePattern) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_Hmac, sign) { - zend_bool _14; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *pattern_param = NULL, _0$$4, _1$$4, _2$$5, _3$$5, _4$$6, _5$$6, _6$$7, _7$$7, _8$$8, _9$$8, _10$$8, _11$$9, _12$$9, _13$$9; - zval pattern, idPattern; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *payload_param = NULL, *passphrase_param = NULL; + zval payload, passphrase; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&idPattern); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_4$$6); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_7$$7); - ZVAL_UNDEF(&_8$$8); - ZVAL_UNDEF(&_9$$8); - ZVAL_UNDEF(&_10$$8); - ZVAL_UNDEF(&_11$$9); - ZVAL_UNDEF(&_12$$9); - ZVAL_UNDEF(&_13$$9); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(pattern) + ZVAL_UNDEF(&payload); + ZVAL_UNDEF(&passphrase); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(payload) + Z_PARAM_STR(passphrase) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &pattern_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + zephir_fetch_params(1, 2, 0, &payload_param, &passphrase_param); + if (UNEXPECTED(Z_TYPE_P(payload_param) != IS_STRING && Z_TYPE_P(payload_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'payload' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + if (EXPECTED(Z_TYPE_P(payload_param) == IS_STRING)) { + zephir_get_strval(&payload, payload_param); } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (zephir_memnstr_str(&pattern, SL(":"), "phalcon/Mvc/Router/Route.zep", 141)) { - ZEPHIR_INIT_VAR(&idPattern); - ZVAL_STRING(&idPattern, "/([\\w0-9\\_\\-]+)"); - if (zephir_memnstr_str(&pattern, SL("/:module"), "phalcon/Mvc/Router/Route.zep", 146)) { - ZEPHIR_INIT_VAR(&_0$$4); - ZEPHIR_INIT_VAR(&_1$$4); - ZVAL_STRING(&_1$$4, "/:module"); - zephir_fast_str_replace(&_0$$4, &_1$$4, &idPattern, &pattern); - zephir_get_strval(&pattern, &_0$$4); - } - if (zephir_memnstr_str(&pattern, SL("/:controller"), "phalcon/Mvc/Router/Route.zep", 151)) { - ZEPHIR_INIT_VAR(&_2$$5); - ZEPHIR_INIT_VAR(&_3$$5); - ZVAL_STRING(&_3$$5, "/:controller"); - zephir_fast_str_replace(&_2$$5, &_3$$5, &idPattern, &pattern); - zephir_get_strval(&pattern, &_2$$5); - } - if (zephir_memnstr_str(&pattern, SL("/:namespace"), "phalcon/Mvc/Router/Route.zep", 156)) { - ZEPHIR_INIT_VAR(&_4$$6); - ZEPHIR_INIT_VAR(&_5$$6); - ZVAL_STRING(&_5$$6, "/:namespace"); - zephir_fast_str_replace(&_4$$6, &_5$$6, &idPattern, &pattern); - zephir_get_strval(&pattern, &_4$$6); - } - if (zephir_memnstr_str(&pattern, SL("/:action"), "phalcon/Mvc/Router/Route.zep", 161)) { - ZEPHIR_INIT_VAR(&_6$$7); - ZEPHIR_INIT_VAR(&_7$$7); - ZVAL_STRING(&_7$$7, "/:action"); - zephir_fast_str_replace(&_6$$7, &_7$$7, &idPattern, &pattern); - zephir_get_strval(&pattern, &_6$$7); - } - if (zephir_memnstr_str(&pattern, SL("/:params"), "phalcon/Mvc/Router/Route.zep", 166)) { - ZEPHIR_INIT_VAR(&_8$$8); - ZEPHIR_INIT_VAR(&_9$$8); - ZVAL_STRING(&_9$$8, "/:params"); - ZEPHIR_INIT_VAR(&_10$$8); - ZVAL_STRING(&_10$$8, "(/.*)*"); - zephir_fast_str_replace(&_8$$8, &_9$$8, &_10$$8, &pattern); - zephir_get_strval(&pattern, &_8$$8); - } - if (zephir_memnstr_str(&pattern, SL("/:int"), "phalcon/Mvc/Router/Route.zep", 171)) { - ZEPHIR_INIT_VAR(&_11$$9); - ZEPHIR_INIT_VAR(&_12$$9); - ZVAL_STRING(&_12$$9, "/:int"); - ZEPHIR_INIT_VAR(&_13$$9); - ZVAL_STRING(&_13$$9, "/([0-9]+)"); - zephir_fast_str_replace(&_11$$9, &_12$$9, &_13$$9, &pattern); - zephir_get_strval(&pattern, &_11$$9); - } + ZEPHIR_INIT_VAR(&payload); } - _14 = zephir_memnstr_str(&pattern, SL("("), "phalcon/Mvc/Router/Route.zep", 182); - if (!(_14)) { - _14 = zephir_memnstr_str(&pattern, SL("["), "phalcon/Mvc/Router/Route.zep", 182); + if (UNEXPECTED(Z_TYPE_P(passphrase_param) != IS_STRING && Z_TYPE_P(passphrase_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'passphrase' must be of the type string")); + RETURN_MM_NULL(); } - if (_14) { - ZEPHIR_CONCAT_SVS(return_value, "#^", &pattern, "$#u"); - RETURN_MM(); + if (EXPECTED(Z_TYPE_P(passphrase_param) == IS_STRING)) { + zephir_get_strval(&passphrase, passphrase_param); + } else { + ZEPHIR_INIT_VAR(&passphrase); } - RETURN_CTOR(&pattern); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "gethash", NULL, 260, &payload, &passphrase); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, convert) +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_Hmac, verify) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, *converter, converter_sub; - zval name; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *source_param = NULL, *payload_param = NULL, *passphrase_param = NULL, _0; + zval source, payload, passphrase; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&converter_sub); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&payload); + ZVAL_UNDEF(&passphrase); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(source) + Z_PARAM_STR(payload) + Z_PARAM_STR(passphrase) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 0, &source_param, &payload_param, &passphrase_param); + zephir_get_strval(&source, source_param); + zephir_get_strval(&payload, payload_param); + zephir_get_strval(&passphrase, passphrase_param); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "gethash", NULL, 260, &payload, &passphrase); + zephir_check_call_status(); + RETURN_MM_BOOL(zephir_hash_equals(&source, &_0)); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_Hmac, getHash) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *payload_param = NULL, *passphrase_param = NULL, __$true, _0; + zval payload, passphrase; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&payload); + ZVAL_UNDEF(&passphrase); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_ZVAL(converter) + Z_PARAM_STR(payload) + Z_PARAM_STR(passphrase) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &converter); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - zephir_update_property_array(this_ptr, SL("converters"), &name, converter); - RETURN_THIS(); + zephir_fetch_params(1, 2, 0, &payload_param, &passphrase_param); + zephir_get_strval(&payload, payload_param); + zephir_get_strval(&passphrase, passphrase_param); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getalgorithm", NULL, 0); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_FUNCTION("hash_hmac", NULL, 229, &_0, &payload, &passphrase, &__$true); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, extractNamedParams) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Signer_None) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Security\\JWT\\Signer, None, phalcon, encryption_security_jwt_signer_none, phalcon_encryption_security_jwt_signer_none_method_entry, 0); + + zend_class_implements(phalcon_encryption_security_jwt_signer_none_ce, 1, phalcon_encryption_security_jwt_signer_signerinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_None, getAlgHeader) +{ + + RETURN_STRING("none"); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_None, getAlgorithm) +{ + + RETURN_STRING("None"); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_None, sign) { - long _0, _5$$10, _26$$18; - zend_long cursor = 0, cursorVar = 0, marker = 0, bracketCount, parenthesesCount, foundPattern, intermediate, numberMatches; - zend_bool notValid = 0, _6$$11, _7$$11, _8$$11, _9$$11, _10$$11, _11$$11, _12$$11, _13$$11, _14$$11, _15$$11, _16$$11, _17$$11, _25$$17, _29$$34, _30$$35, _31$$35, _32$$35; - char ch = 0, prevCh; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *pattern_param = NULL, tmp, matches, _1$$10, _2$$10, _3$$10, _18$$15, _19$$15, _20$$15, _22$$15, _23$$15; - zval pattern, route, item, variable, regexp, _4$$10, _21$$15, _24$$15, _27$$25, _28$$28; + zval *payload_param = NULL, *passphrase_param = NULL; + zval payload, passphrase; - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&item); - ZVAL_UNDEF(&variable); - ZVAL_UNDEF(®exp); - ZVAL_UNDEF(&_4$$10); - ZVAL_UNDEF(&_21$$15); - ZVAL_UNDEF(&_24$$15); - ZVAL_UNDEF(&_27$$25); - ZVAL_UNDEF(&_28$$28); - ZVAL_UNDEF(&tmp); - ZVAL_UNDEF(&matches); - ZVAL_UNDEF(&_1$$10); - ZVAL_UNDEF(&_2$$10); - ZVAL_UNDEF(&_3$$10); - ZVAL_UNDEF(&_18$$15); - ZVAL_UNDEF(&_19$$15); - ZVAL_UNDEF(&_20$$15); - ZVAL_UNDEF(&_22$$15); - ZVAL_UNDEF(&_23$$15); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(pattern) + ZVAL_UNDEF(&payload); + ZVAL_UNDEF(&passphrase); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(payload) + Z_PARAM_STR(passphrase) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &pattern_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + zephir_fetch_params(1, 2, 0, &payload_param, &passphrase_param); + if (UNEXPECTED(Z_TYPE_P(payload_param) != IS_STRING && Z_TYPE_P(payload_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'payload' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + if (EXPECTED(Z_TYPE_P(payload_param) == IS_STRING)) { + zephir_get_strval(&payload, payload_param); } else { - ZEPHIR_INIT_VAR(&pattern); - } - prevCh = '\0'; - bracketCount = 0; - parenthesesCount = 0; - foundPattern = 0; - intermediate = 0; - numberMatches = 0; - if (zephir_fast_strlen_ev(&pattern) == 0) { - RETURN_MM_BOOL(0); - } - ZEPHIR_INIT_VAR(&matches); - array_init(&matches); - ZEPHIR_INIT_VAR(&route); - for (_0 = 0; _0 < Z_STRLEN_P(&pattern); _0++) { - cursor = _0; - ch = ZEPHIR_STRING_OFFSET(&pattern, _0); - if (parenthesesCount == 0) { - if (ch == '{') { - if (bracketCount == 0) { - marker = (cursor + 1); - intermediate = 0; - notValid = 0; - } - bracketCount++; - } else if (ch == '}') { - bracketCount--; - if (intermediate > 0) { - if (bracketCount == 0) { - numberMatches++; - ZEPHIR_INIT_NVAR(&variable); - ZEPHIR_INIT_NVAR(®exp); - ZVAL_LONG(&_1$$10, marker); - ZVAL_LONG(&_2$$10, (cursor - marker)); - ZEPHIR_INIT_NVAR(&_3$$10); - zephir_substr(&_3$$10, &pattern, zephir_get_intval(&_1$$10), zephir_get_intval(&_2$$10), 0); - zephir_cast_to_string(&_4$$10, &_3$$10); - ZEPHIR_CPY_WRT(&item, &_4$$10); - for (_5$$10 = 0; _5$$10 < Z_STRLEN_P(&item); _5$$10++) { - cursorVar = _5$$10; - ch = ZEPHIR_STRING_OFFSET(&item, _5$$10); - if (ch == '\0') { - break; - } - _6$$11 = cursorVar == 0; - if (_6$$11) { - _7$$11 = ch >= 'a'; - if (_7$$11) { - _7$$11 = ch <= 'z'; - } - _8$$11 = _7$$11; - if (!(_8$$11)) { - _9$$11 = ch >= 'A'; - if (_9$$11) { - _9$$11 = ch <= 'Z'; - } - _8$$11 = _9$$11; - } - _6$$11 = !(_8$$11); - } - if (_6$$11) { - notValid = 1; - break; - } - _10$$11 = ch >= 'a'; - if (_10$$11) { - _10$$11 = ch <= 'z'; - } - _11$$11 = _10$$11; - if (!(_11$$11)) { - _12$$11 = ch >= 'A'; - if (_12$$11) { - _12$$11 = ch <= 'Z'; - } - _11$$11 = _12$$11; - } - _13$$11 = _11$$11; - if (!(_13$$11)) { - _14$$11 = ch >= '0'; - if (_14$$11) { - _14$$11 = ch <= '9'; - } - _13$$11 = _14$$11; - } - _15$$11 = _13$$11; - if (!(_15$$11)) { - _15$$11 = ch == '-'; - } - _16$$11 = _15$$11; - if (!(_16$$11)) { - _16$$11 = ch == '_'; - } - _17$$11 = _16$$11; - if (!(_17$$11)) { - _17$$11 = ch == ':'; - } - if (_17$$11) { - if (ch == ':') { - ZVAL_LONG(&_18$$15, 0); - ZVAL_LONG(&_19$$15, cursorVar); - ZEPHIR_INIT_NVAR(&_20$$15); - zephir_substr(&_20$$15, &item, 0 , zephir_get_intval(&_19$$15), 0); - zephir_cast_to_string(&_21$$15, &_20$$15); - ZEPHIR_CPY_WRT(&variable, &_21$$15); - ZVAL_LONG(&_22$$15, (cursorVar + 1)); - ZEPHIR_INIT_NVAR(&_23$$15); - zephir_substr(&_23$$15, &item, zephir_get_intval(&_22$$15), 0, ZEPHIR_SUBSTR_NO_LENGTH); - zephir_cast_to_string(&_24$$15, &_23$$15); - ZEPHIR_CPY_WRT(®exp, &_24$$15); - break; - } - } else { - notValid = 1; - break; - } - } - if (!(notValid)) { - ZEPHIR_INIT_NVAR(&tmp); - ZVAL_LONG(&tmp, numberMatches); - _25$$17 = zephir_is_true(&variable); - if (_25$$17) { - _25$$17 = zephir_is_true(®exp); - } - if (_25$$17) { - foundPattern = 0; - for (_26$$18 = 0; _26$$18 < Z_STRLEN_P(®exp); _26$$18++) { - ch = ZEPHIR_STRING_OFFSET(®exp, _26$$18); - if (ch == '\0') { - break; - } - if (!(foundPattern)) { - if (ch == '(') { - foundPattern = 1; - } - } else { - if (ch == ')') { - foundPattern = 2; - break; - } - } - } - if (foundPattern != 2) { - ZEPHIR_INIT_NVAR(&_27$$25); - ZEPHIR_CONCAT_SVS(&_27$$25, "(", ®exp, ")"); - zephir_concat_self(&route, &_27$$25); - } else { - zephir_concat_self(&route, ®exp); - } - zephir_array_update_zval(&matches, &variable, &tmp, PH_COPY | PH_SEPARATE); - } else { - zephir_concat_self_str(&route, "([^/]*)", sizeof("([^/]*)") - 1); - zephir_array_update_zval(&matches, &item, &tmp, PH_COPY | PH_SEPARATE); - } - } else { - ZEPHIR_INIT_NVAR(&_28$$28); - ZEPHIR_CONCAT_SVS(&_28$$28, "{", &item, "}"); - zephir_concat_self(&route, &_28$$28); - } - continue; - } - } - } - } - if (bracketCount == 0) { - if (ch == '(') { - parenthesesCount++; - } else if (ch == ')') { - parenthesesCount--; - if (parenthesesCount == 0) { - numberMatches++; - } - } - } - if (bracketCount > 0) { - intermediate++; - } else { - _29$$34 = parenthesesCount == 0; - if (_29$$34) { - _29$$34 = prevCh != '\\'; - } - if (_29$$34) { - _30$$35 = ch == '.'; - if (!(_30$$35)) { - _30$$35 = ch == '+'; - } - _31$$35 = _30$$35; - if (!(_31$$35)) { - _31$$35 = ch == '|'; - } - _32$$35 = _31$$35; - if (!(_32$$35)) { - _32$$35 = ch == '#'; - } - if (_32$$35) { - zephir_concat_self_str(&route, "\\", sizeof("\\") - 1); - } - } - zephir_concat_self_char(&route, ch); - prevCh = ch; - } + ZEPHIR_INIT_VAR(&payload); } - zephir_create_array(return_value, 2, 0); - zephir_array_fast_append(return_value, &route); - zephir_array_fast_append(return_value, &matches); - RETURN_MM(); + zephir_get_strval(&passphrase, passphrase_param); + RETURN_MM_STRING(""); +} + +static PHP_METHOD(Phalcon_Encryption_Security_JWT_Signer_None, verify) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *source_param = NULL, *payload_param = NULL, *passphrase_param = NULL, _0; + zval source, payload, passphrase; + + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&payload); + ZVAL_UNDEF(&passphrase); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(source) + Z_PARAM_STR(payload) + Z_PARAM_STR(passphrase) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 0, &source_param, &payload_param, &passphrase_param); + zephir_get_strval(&source, source_param); + zephir_get_strval(&payload, payload_param); + zephir_get_strval(&passphrase, passphrase_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, ""); + RETURN_MM_BOOL(ZEPHIR_IS_IDENTICAL(&_0, &source)); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getBeforeMatch) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Security_JWT_Signer_SignerInterface) { + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Encryption\\Security\\JWT\\Signer, SignerInterface, phalcon, encryption_security_jwt_signer_signerinterface, phalcon_encryption_security_jwt_signer_signerinterface_method_entry); - RETURN_MEMBER(getThis(), "beforeMatch"); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getCompiledPattern) +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Security_JWT_Signer_SignerInterface, getAlgHeader); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Security_JWT_Signer_SignerInterface, getAlgorithm); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Security_JWT_Signer_SignerInterface, sign); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Security_JWT_Signer_SignerInterface, verify); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_CryptInterface) { + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Encryption\\Crypt, CryptInterface, phalcon, encryption_crypt_cryptinterface, phalcon_encryption_crypt_cryptinterface_method_entry); - RETURN_MEMBER(getThis(), "compiledPattern"); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getConverters) +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, decrypt); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, decryptBase64); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, encrypt); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, encryptBase64); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, getAvailableCiphers); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, getAuthTag); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, getAuthData); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, getAuthTagLength); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, getCipher); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, getKey); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, setAuthTag); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, setAuthData); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, setAuthTagLength); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, setCipher); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, setKey); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, setPadding); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_CryptInterface, useSigning); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_PadFactory) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Crypt, PadFactory, phalcon, encryption_crypt_padfactory, phalcon_factory_abstractfactory_ce, phalcon_encryption_crypt_padfactory_method_entry, 0); - RETURN_MEMBER(getThis(), "converters"); + zend_declare_property_string(phalcon_encryption_crypt_padfactory_ce, SL("exception"), "Phalcon\\Encryption\\Crypt\\Exception\\Exception", ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getGroup) +static PHP_METHOD(Phalcon_Encryption_Crypt_PadFactory, __construct) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *services_param = NULL; + zval services; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "group"); + ZVAL_UNDEF(&services); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(services) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &services_param); + if (!services_param) { + ZEPHIR_INIT_VAR(&services); + array_init(&services); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getHttpMethods) +static PHP_METHOD(Phalcon_Encryption_Crypt_PadFactory, newInstance) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, definition; + zval name; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "methods"); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&definition); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); + zephir_check_call_status(); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(return_value, &definition); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getHostname) +static PHP_METHOD(Phalcon_Encryption_Crypt_PadFactory, padNumberToService) { + zval map; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *number_param = NULL, _0, _1, _2; + zend_long number, ZEPHIR_LAST_CALL_STATUS; - RETURN_MEMBER(getThis(), "hostname"); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&map); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(number) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &number_param); + ZEPHIR_INIT_VAR(&map); + zephir_create_array(&map, 6, 0); + add_index_stringl(&map, 1, SL("ansi")); + add_index_stringl(&map, 3, SL("iso10126")); + add_index_stringl(&map, 4, SL("isoiek")); + add_index_stringl(&map, 2, SL("pjcs7")); + add_index_stringl(&map, 6, SL("space")); + add_index_stringl(&map, 5, SL("zero")); + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, phalcon_support_helper_arr_get_ce); + if (zephir_has_constructor(&_0)) { + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); + zephir_check_call_status(); + } + + ZVAL_LONG(&_1, number); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "noop"); + ZEPHIR_RETURN_CALL_METHOD(&_0, "__invoke", NULL, 159, &map, &_1, &_2); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getId) +static PHP_METHOD(Phalcon_Encryption_Crypt_PadFactory, getServices) { - RETURN_MEMBER(getThis(), "id"); + zephir_create_array(return_value, 7, 0); + add_assoc_stringl_ex(return_value, SL("ansi"), SL("Phalcon\\Encryption\\Crypt\\Padding\\Ansi")); + add_assoc_stringl_ex(return_value, SL("iso10126"), SL("Phalcon\\Encryption\\Crypt\\Padding\\Iso10126")); + add_assoc_stringl_ex(return_value, SL("isoiek"), SL("Phalcon\\Encryption\\Crypt\\Padding\\IsoIek")); + add_assoc_stringl_ex(return_value, SL("noop"), SL("Phalcon\\Encryption\\Crypt\\Padding\\Noop")); + add_assoc_stringl_ex(return_value, SL("pjcs7"), SL("Phalcon\\Encryption\\Crypt\\Padding\\Pkcs7")); + add_assoc_stringl_ex(return_value, SL("space"), SL("Phalcon\\Encryption\\Crypt\\Padding\\Space")); + add_assoc_stringl_ex(return_value, SL("zero"), SL("Phalcon\\Encryption\\Crypt\\Padding\\Zero")); + return; } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getMatch) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Exception_Exception) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Crypt\\Exception, Exception, phalcon, encryption_crypt_exception_exception, zend_ce_exception, NULL, 0); - RETURN_MEMBER(getThis(), "match"); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getName) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Exception_Mismatch) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Encryption\\Crypt\\Exception, Mismatch, phalcon, encryption_crypt_exception_mismatch, phalcon_encryption_crypt_exception_exception_ce, NULL, 0); - RETURN_MEMBER(getThis(), "name"); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getPaths) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_Ansi) { + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, Ansi, phalcon, encryption_crypt_padding_ansi, phalcon_encryption_crypt_padding_ansi_method_entry, 0); - RETURN_MEMBER(getThis(), "paths"); + zend_class_implements(phalcon_encryption_crypt_padding_ansi_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getPattern) +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Ansi, pad) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *paddingSize_param = NULL, _0, _1, _2, _3; + zend_long paddingSize, ZEPHIR_LAST_CALL_STATUS; - RETURN_MEMBER(getThis(), "pattern"); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(paddingSize) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &paddingSize_param); + ZVAL_LONG(&_0, 0); + ZEPHIR_CALL_FUNCTION(&_1, "chr", NULL, 244, &_0); + zephir_check_call_status(); + ZVAL_LONG(&_0, (paddingSize - 1)); + ZEPHIR_CALL_FUNCTION(&_2, "str_repeat", NULL, 1, &_1, &_0); + zephir_check_call_status(); + ZVAL_LONG(&_0, paddingSize); + ZEPHIR_CALL_FUNCTION(&_3, "chr", NULL, 244, &_0); + zephir_check_call_status(); + ZEPHIR_CONCAT_VV(return_value, &_2, &_3); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getReversedPaths) +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Ansi, unpad) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + zend_long blockSize, ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL, *blockSize_param = NULL, last, length, ord, padding, paddingSize, repeat, _0, _1, _2$$4, _3$$4, _4$$3, _5$$3; + zval input; + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&last); + ZVAL_UNDEF(&length); + ZVAL_UNDEF(&ord); + ZVAL_UNDEF(&padding); + ZVAL_UNDEF(&paddingSize); + ZVAL_UNDEF(&repeat); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(input) + Z_PARAM_LONG(blockSize) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("paths"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_FUNCTION("array_flip", NULL, 100, &_0); + zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); + zephir_get_strval(&input, input_param); + ZEPHIR_INIT_VAR(&paddingSize); + ZVAL_LONG(&paddingSize, 0); + ZEPHIR_INIT_VAR(&length); + ZVAL_LONG(&length, zephir_fast_strlen_ev(&input)); + ZVAL_LONG(&_0, (zephir_get_numberval(&length) - 1)); + ZVAL_LONG(&_1, 1); + ZEPHIR_INIT_VAR(&last); + zephir_substr(&last, &input, zephir_get_intval(&_0), 1 , 0); + ZEPHIR_CALL_FUNCTION(&ord, "ord", NULL, 245, &last); zephir_check_call_status(); - RETURN_MM(); + if (ZEPHIR_LE_LONG(&ord, blockSize)) { + ZEPHIR_CPY_WRT(&paddingSize, &ord); + ZEPHIR_INIT_VAR(&repeat); + ZVAL_STRING(&repeat, ""); + if (ZEPHIR_GT_LONG(&paddingSize, 1)) { + ZVAL_LONG(&_2$$4, 0); + ZEPHIR_CALL_FUNCTION(&_3$$4, "chr", NULL, 244, &_2$$4); + zephir_check_call_status(); + ZVAL_LONG(&_2$$4, (zephir_get_numberval(&paddingSize) - 1)); + ZEPHIR_CALL_FUNCTION(&repeat, "str_repeat", NULL, 1, &_3$$4, &_2$$4); + zephir_check_call_status(); + } + ZEPHIR_INIT_VAR(&padding); + ZEPHIR_CONCAT_VV(&padding, &repeat, &last); + ZEPHIR_INIT_VAR(&_4$$3); + zephir_sub_function(&_4$$3, &length, &paddingSize); + ZEPHIR_INIT_VAR(&_5$$3); + zephir_substr(&_5$$3, &input, zephir_get_intval(&_4$$3), 0, ZEPHIR_SUBSTR_NO_LENGTH); + if (!ZEPHIR_IS_IDENTICAL(&_5$$3, &padding)) { + ZEPHIR_INIT_NVAR(&paddingSize); + ZVAL_LONG(&paddingSize, 0); + } + } + RETURN_CCTOR(&paddingSize); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getRouteId) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_Iso10126) { + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, Iso10126, phalcon, encryption_crypt_padding_iso10126, phalcon_encryption_crypt_padding_iso10126_method_entry, 0); - RETURN_MEMBER(getThis(), "id"); + zend_class_implements(phalcon_encryption_crypt_padding_iso10126_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router_Route, getRoutePaths) +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Iso10126, pad) { - zend_long _0$$4; + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *paths = NULL, paths_sub, __$null, moduleName, controllerName, actionName, parts, routePaths, realClassName, namespaceName; + zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL; + zval *paddingSize_param = NULL, counter, padding, _7, _8, _3$$3, _5$$3; + zend_long paddingSize, ZEPHIR_LAST_CALL_STATUS, _1, _2; - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&moduleName); - ZVAL_UNDEF(&controllerName); - ZVAL_UNDEF(&actionName); - ZVAL_UNDEF(&parts); - ZVAL_UNDEF(&routePaths); - ZVAL_UNDEF(&realClassName); - ZVAL_UNDEF(&namespaceName); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + ZVAL_UNDEF(&counter); + ZVAL_UNDEF(&padding); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_5$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(paddingSize) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &paths); - if (!paths) { - paths = &paths_sub; - ZEPHIR_CPY_WRT(paths, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(paths); - } - if (Z_TYPE_P(paths) == IS_NULL) { - ZEPHIR_INIT_NVAR(paths); - array_init(paths); - } - if (Z_TYPE_P(paths) == IS_STRING) { - ZEPHIR_INIT_VAR(&moduleName); - ZVAL_NULL(&moduleName); - ZEPHIR_INIT_VAR(&controllerName); - ZVAL_NULL(&controllerName); - ZEPHIR_INIT_VAR(&actionName); - ZVAL_NULL(&actionName); - ZEPHIR_INIT_VAR(&parts); - zephir_fast_explode_str(&parts, SL("::"), paths, LONG_MAX); - do { - _0$$4 = zephir_fast_count_int(&parts); - if (_0$$4 == 3) { - ZEPHIR_OBS_NVAR(&moduleName); - zephir_array_fetch_long(&moduleName, &parts, 0, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 467); - ZEPHIR_OBS_NVAR(&controllerName); - zephir_array_fetch_long(&controllerName, &parts, 1, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 468); - ZEPHIR_OBS_NVAR(&actionName); - zephir_array_fetch_long(&actionName, &parts, 2, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 469); - break; - } - if (_0$$4 == 2) { - ZEPHIR_OBS_NVAR(&controllerName); - zephir_array_fetch_long(&controllerName, &parts, 0, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 473); - ZEPHIR_OBS_NVAR(&actionName); - zephir_array_fetch_long(&actionName, &parts, 1, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 474); - break; - } - if (_0$$4 == 1) { - ZEPHIR_OBS_NVAR(&controllerName); - zephir_array_fetch_long(&controllerName, &parts, 0, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 478); - break; - } - } while(0); - - ZEPHIR_INIT_VAR(&routePaths); - array_init(&routePaths); - if (Z_TYPE_P(&moduleName) != IS_NULL) { - zephir_array_update_string(&routePaths, SL("module"), &moduleName, PH_COPY | PH_SEPARATE); - } - if (Z_TYPE_P(&controllerName) != IS_NULL) { - if (zephir_memnstr_str(&controllerName, SL("\\"), "phalcon/Mvc/Router/Route.zep", 492)) { - ZEPHIR_INIT_VAR(&realClassName); - zephir_get_class_ns(&realClassName, &controllerName, 0); - ZEPHIR_INIT_VAR(&namespaceName); - zephir_get_ns_class(&namespaceName, &controllerName, 0); - if (zephir_is_true(&namespaceName)) { - zephir_array_update_string(&routePaths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE); + zephir_fetch_params(1, 1, 0, &paddingSize_param); + ZEPHIR_INIT_VAR(&padding); + ZVAL_STRING(&padding, ""); + _2 = (paddingSize - 2); + _1 = 0; + _0 = 0; + if (_1 <= _2) { + while (1) { + if (_0) { + _1++; + if (!(_1 <= _2)) { + break; } } else { - ZEPHIR_CPY_WRT(&realClassName, &controllerName); + _0 = 1; } - zephir_array_update_string(&routePaths, SL("controller"), &realClassName, PH_COPY | PH_SEPARATE); - } - if (Z_TYPE_P(&actionName) != IS_NULL) { - zephir_array_update_string(&routePaths, SL("action"), &actionName, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&counter); + ZVAL_LONG(&counter, _1); + ZEPHIR_CALL_FUNCTION(&_3$$3, "rand", &_4, 246); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_5$$3, "chr", &_6, 244, &_3$$3); + zephir_check_call_status(); + zephir_concat_self(&padding, &_5$$3); } - } else { - ZEPHIR_CPY_WRT(&routePaths, paths); - } - if (UNEXPECTED(Z_TYPE_P(&routePaths) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_router_exception_ce, "The route contains invalid paths", "phalcon/Mvc/Router/Route.zep", 519); - return; } - RETURN_CCTOR(&routePaths); + ZVAL_LONG(&_7, paddingSize); + ZEPHIR_CALL_FUNCTION(&_8, "chr", &_6, 244, &_7); + zephir_check_call_status(); + zephir_concat_self(&padding, &_8); + RETURN_CCTOR(&padding); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, match) +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Iso10126, unpad) { - zval *callback, callback_sub; - zval *this_ptr = getThis(); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long blockSize, ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL, *blockSize_param = NULL, last, length, _0, _1; + zval input; - ZVAL_UNDEF(&callback_sub); + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&last); + ZVAL_UNDEF(&length); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(input) + Z_PARAM_LONG(blockSize) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); + zephir_get_strval(&input, input_param); + ZEPHIR_INIT_VAR(&length); + ZVAL_LONG(&length, zephir_fast_strlen_ev(&input)); + ZVAL_LONG(&_0, (zephir_get_numberval(&length) - 1)); + ZVAL_LONG(&_1, 1); + ZEPHIR_INIT_VAR(&last); + zephir_substr(&last, &input, zephir_get_intval(&_0), 1 , 0); + ZEPHIR_RETURN_CALL_FUNCTION("ord", NULL, 245, &last); + zephir_check_call_status(); + RETURN_MM(); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_IsoIek) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, IsoIek, phalcon, encryption_crypt_padding_isoiek, phalcon_encryption_crypt_padding_isoiek_method_entry, 0); + + zend_class_implements(phalcon_encryption_crypt_padding_isoiek_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_IsoIek, pad) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *paddingSize_param = NULL, _0, _1, _2, _3; + zend_long paddingSize, ZEPHIR_LAST_CALL_STATUS; + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(callback) + Z_PARAM_LONG(paddingSize) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &callback); - zephir_update_property_zval(this_ptr, ZEND_STRL("match"), callback); - RETURN_THISW(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &paddingSize_param); + ZVAL_LONG(&_0, 0x80); + ZEPHIR_CALL_FUNCTION(&_1, "chr", NULL, 244, &_0); + zephir_check_call_status(); + ZVAL_LONG(&_0, 0); + ZEPHIR_CALL_FUNCTION(&_2, "chr", NULL, 244, &_0); + zephir_check_call_status(); + ZVAL_LONG(&_0, (paddingSize - 1)); + ZEPHIR_CALL_FUNCTION(&_3, "str_repeat", NULL, 1, &_2, &_0); + zephir_check_call_status(); + ZEPHIR_CONCAT_VV(return_value, &_1, &_3); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, reConfigure) +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_IsoIek, unpad) { + zend_bool _0, _5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, routePaths, pcrePattern, compiledPattern, extracted, _0$$4, _1$$4; - zval pattern; - zval *this_ptr = getThis(); + zephir_fcall_cache_entry *_4 = NULL; + zend_long blockSize, ZEPHIR_LAST_CALL_STATUS, counter = 0, paddingSize = 0; + zval *input_param = NULL, *blockSize_param = NULL, length, inputArray, _1, _2, _3, _6, _7; + zval input; - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&routePaths); - ZVAL_UNDEF(&pcrePattern); - ZVAL_UNDEF(&compiledPattern); - ZVAL_UNDEF(&extracted); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&length); + ZVAL_UNDEF(&inputArray); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(input) + Z_PARAM_LONG(blockSize) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - ZEPHIR_CALL_SELF(&routePaths, "getroutepaths", NULL, 0, paths); + zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); + zephir_get_strval(&input, input_param); + paddingSize = 0; + ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 234, &input); zephir_check_call_status(); - if (!(zephir_start_with_str(&pattern, SL("#")))) { - if (zephir_memnstr_str(&pattern, SL("{"), "phalcon/Mvc/Router/Route.zep", 559)) { - ZEPHIR_CALL_METHOD(&extracted, this_ptr, "extractnamedparams", NULL, 0, &pattern); + ZEPHIR_CALL_FUNCTION(&inputArray, "str_split", NULL, 88, &input); + zephir_check_call_status(); + counter = (zephir_get_numberval(&length) - 1); + while (1) { + _0 = counter > 0; + if (_0) { + zephir_array_fetch_long(&_1, &inputArray, counter, PH_NOISY | PH_READONLY, "phalcon/Encryption/Crypt/Padding/IsoIek.zep", 48); + ZVAL_LONG(&_2, 0); + ZEPHIR_CALL_FUNCTION(&_3, "chr", &_4, 244, &_2); zephir_check_call_status(); - zephir_memory_observe(&pcrePattern); - zephir_array_fetch_long(&pcrePattern, &extracted, 0, PH_NOISY, "phalcon/Mvc/Router/Route.zep", 564); - ZEPHIR_INIT_VAR(&_0$$4); - zephir_array_fetch_long(&_1$$4, &extracted, 1, PH_NOISY | PH_READONLY, "phalcon/Mvc/Router/Route.zep", 565); - zephir_fast_array_merge(&_0$$4, &routePaths, &_1$$4); - ZEPHIR_CPY_WRT(&routePaths, &_0$$4); - } else { - ZEPHIR_CPY_WRT(&pcrePattern, &pattern); + _0 = ZEPHIR_IS_IDENTICAL(&_1, &_3); } - ZEPHIR_CALL_METHOD(&compiledPattern, this_ptr, "compilepattern", NULL, 0, &pcrePattern); - zephir_check_call_status(); + _5 = _0; + if (_5) { + _5 = paddingSize < blockSize; + } + if (!(_5)) { + break; + } + paddingSize++; + counter--; + } + zephir_array_fetch_long(&_6, &inputArray, counter, PH_NOISY | PH_READONLY, "phalcon/Encryption/Crypt/Padding/IsoIek.zep", 55); + ZVAL_LONG(&_2, 0x80); + ZEPHIR_CALL_FUNCTION(&_7, "chr", &_4, 244, &_2); + zephir_check_call_status(); + if (ZEPHIR_IS_EQUAL(&_6, &_7)) { + paddingSize++; } else { - ZEPHIR_CPY_WRT(&compiledPattern, &pattern); + paddingSize = 0; } - zephir_update_property_zval(this_ptr, ZEND_STRL("pattern"), &pattern); - zephir_update_property_zval(this_ptr, ZEND_STRL("compiledPattern"), &compiledPattern); - zephir_update_property_zval(this_ptr, ZEND_STRL("paths"), &routePaths); - ZEPHIR_MM_RESTORE(); + RETURN_MM_LONG(paddingSize); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, reset) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_Noop) { - zval _0; + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, Noop, phalcon, encryption_crypt_padding_noop, phalcon_encryption_crypt_padding_noop_method_entry, 0); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, 0); - zephir_update_static_property_ce(phalcon_mvc_router_route_ce, ZEND_STRL("uniqueId"), &_0); + zend_class_implements(phalcon_encryption_crypt_padding_noop_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Mvc_Router_Route, setGroup) +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Noop, pad) { - zval *group, group_sub; - zval *this_ptr = getThis(); + zval *paddingSize_param = NULL; + zend_long paddingSize; - ZVAL_UNDEF(&group_sub); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(group, phalcon_mvc_router_groupinterface_ce) + Z_PARAM_LONG(paddingSize) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &group); - zephir_update_property_zval(this_ptr, ZEND_STRL("group"), group); - RETURN_THISW(); + zephir_fetch_params_without_memory_grow(1, 0, &paddingSize_param); + RETURN_STRING(""); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, setHttpMethods) +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Noop, unpad) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *httpMethods, httpMethods_sub; - zval *this_ptr = getThis(); + zend_long blockSize; + zval *input_param = NULL, *blockSize_param = NULL; + zval input; - ZVAL_UNDEF(&httpMethods_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(httpMethods) + ZVAL_UNDEF(&input); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(input) + Z_PARAM_LONG(blockSize) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &httpMethods); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "via", NULL, 0, httpMethods); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); + zephir_get_strval(&input, input_param); + RETURN_MM_LONG(0); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, setHostname) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_PadInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Encryption\\Crypt\\Padding, PadInterface, phalcon, encryption_crypt_padding_padinterface, phalcon_encryption_crypt_padding_padinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_Padding_PadInterface, pad); +ZEPHIR_DOC_METHOD(Phalcon_Encryption_Crypt_Padding_PadInterface, unpad); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_Pkcs7) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, Pkcs7, phalcon, encryption_crypt_padding_pkcs7, phalcon_encryption_crypt_padding_pkcs7_method_entry, 0); + + zend_class_implements(phalcon_encryption_crypt_padding_pkcs7_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Pkcs7, pad) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *hostname_param = NULL; - zval hostname; - zval *this_ptr = getThis(); + zval *paddingSize_param = NULL, _0, _1; + zend_long paddingSize, ZEPHIR_LAST_CALL_STATUS; - ZVAL_UNDEF(&hostname); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(hostname) + Z_PARAM_LONG(paddingSize) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &hostname_param); - if (UNEXPECTED(Z_TYPE_P(hostname_param) != IS_STRING && Z_TYPE_P(hostname_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'hostname' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(hostname_param) == IS_STRING)) { - zephir_get_strval(&hostname, hostname_param); - } else { - ZEPHIR_INIT_VAR(&hostname); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("hostname"), &hostname); - RETURN_THIS(); + zephir_fetch_params(1, 1, 0, &paddingSize_param); + ZVAL_LONG(&_0, paddingSize); + ZEPHIR_CALL_FUNCTION(&_1, "chr", NULL, 244, &_0); + zephir_check_call_status(); + ZVAL_LONG(&_0, paddingSize); + ZEPHIR_RETURN_CALL_FUNCTION("str_repeat", NULL, 1, &_1, &_0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, setName) +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Pkcs7, unpad) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL; - zval name; - zval *this_ptr = getThis(); + zend_long blockSize, ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL, *blockSize_param = NULL, last, length, ord, padding, paddingSize, _0, _1, _2$$3, _3$$3, _4$$3; + zval input; - ZVAL_UNDEF(&name); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&last); + ZVAL_UNDEF(&length); + ZVAL_UNDEF(&ord); + ZVAL_UNDEF(&padding); + ZVAL_UNDEF(&paddingSize); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(input) + Z_PARAM_LONG(blockSize) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - zephir_get_strval(&name, name_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); - RETURN_THIS(); + zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); + zephir_get_strval(&input, input_param); + ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 234, &input); + zephir_check_call_status(); + ZVAL_LONG(&_0, (zephir_get_numberval(&length) - 1)); + ZVAL_LONG(&_1, 1); + ZEPHIR_INIT_VAR(&last); + zephir_substr(&last, &input, zephir_get_intval(&_0), 1 , 0); + ZEPHIR_CALL_FUNCTION(&ord, "ord", NULL, 245, &last); + zephir_check_call_status(); + if (ZEPHIR_LE_LONG(&ord, blockSize)) { + ZEPHIR_CPY_WRT(&paddingSize, &ord); + ZEPHIR_CALL_FUNCTION(&_2$$3, "chr", NULL, 244, &paddingSize); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&padding, "str_repeat", NULL, 1, &_2$$3, &paddingSize); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3$$3); + zephir_sub_function(&_3$$3, &length, &paddingSize); + ZEPHIR_INIT_VAR(&_4$$3); + zephir_substr(&_4$$3, &input, zephir_get_intval(&_3$$3), 0, ZEPHIR_SUBSTR_NO_LENGTH); + if (!ZEPHIR_IS_IDENTICAL(&_4$$3, &padding)) { + ZEPHIR_INIT_NVAR(&paddingSize); + ZVAL_LONG(&paddingSize, 0); + } + } + RETURN_CCTOR(&paddingSize); } -static PHP_METHOD(Phalcon_Mvc_Router_Route, via) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_Space) { - zval *httpMethods, httpMethods_sub; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, Space, phalcon, encryption_crypt_padding_space, phalcon_encryption_crypt_padding_space_method_entry, 0); - ZVAL_UNDEF(&httpMethods_sub); + zend_class_implements(phalcon_encryption_crypt_padding_space_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Space, pad) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *paddingSize_param = NULL, _0, _1; + zend_long paddingSize, ZEPHIR_LAST_CALL_STATUS; + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(httpMethods) + Z_PARAM_LONG(paddingSize) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &httpMethods); - zephir_update_property_zval(this_ptr, ZEND_STRL("methods"), httpMethods); - RETURN_THISW(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &paddingSize_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, " "); + ZVAL_LONG(&_1, paddingSize); + ZEPHIR_RETURN_CALL_FUNCTION("str_repeat", NULL, 1, &_0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -zend_object *zephir_init_properties_Phalcon_Mvc_Router_Route(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Space, unpad) { - zval _0, _2, _4, _1$$3, _3$$4, _5$$5; + zend_bool _0, _5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - + zephir_fcall_cache_entry *_4 = NULL; + zend_long blockSize, ZEPHIR_LAST_CALL_STATUS, counter = 0, paddingSize = 0; + zval *input_param = NULL, *blockSize_param = NULL, length, inputArray, _1, _2, _3; + zval input; - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("paths"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("paths"), &_1$$3); + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&length); + ZVAL_UNDEF(&inputArray); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(input) + Z_PARAM_LONG(blockSize) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); + zephir_get_strval(&input, input_param); + ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 234, &input); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&inputArray, "str_split", NULL, 88, &input); + zephir_check_call_status(); + counter = (zephir_get_numberval(&length) - 1); + paddingSize = 0; + while (1) { + _0 = counter >= 0; + if (_0) { + zephir_array_fetch_long(&_1, &inputArray, counter, PH_NOISY | PH_READONLY, "phalcon/Encryption/Crypt/Padding/Space.zep", 48); + ZVAL_LONG(&_2, 32); + ZEPHIR_CALL_FUNCTION(&_3, "chr", &_4, 244, &_2); + zephir_check_call_status(); + _0 = ZEPHIR_IS_EQUAL(&_1, &_3); } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("methods"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("methods"), &_3$$4); + _5 = _0; + if (_5) { + _5 = paddingSize <= blockSize; } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("converters"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("converters"), &_5$$5); + if (!(_5)) { + break; } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + paddingSize++; + counter--; } + RETURN_MM_LONG(paddingSize); } @@ -105261,29 +103743,88 @@ zend_object *zephir_init_properties_Phalcon_Mvc_Router_Route(zend_class_entry *c -ZEPHIR_INIT_CLASS(Phalcon_Mvc_Router_RouteInterface) +ZEPHIR_INIT_CLASS(Phalcon_Encryption_Crypt_Padding_Zero) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Mvc\\Router, RouteInterface, phalcon, mvc_router_routeinterface, phalcon_mvc_router_routeinterface_method_entry); + ZEPHIR_REGISTER_CLASS(Phalcon\\Encryption\\Crypt\\Padding, Zero, phalcon, encryption_crypt_padding_zero, phalcon_encryption_crypt_padding_zero_method_entry, 0); + zend_class_implements(phalcon_encryption_crypt_padding_zero_ce, 1, phalcon_encryption_crypt_padding_padinterface_ce); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, compilePattern); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, convert); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getCompiledPattern); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getHostname); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getHttpMethods); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getPaths); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getPattern); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getReversedPaths); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, getRouteId); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, setHostname); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, setHttpMethods); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, setName); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, reConfigure); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, reset); -ZEPHIR_DOC_METHOD(Phalcon_Mvc_Router_RouteInterface, via); +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Zero, pad) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *paddingSize_param = NULL, _0, _1; + zend_long paddingSize, ZEPHIR_LAST_CALL_STATUS; + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(paddingSize) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &paddingSize_param); + ZVAL_LONG(&_0, 0); + ZEPHIR_CALL_FUNCTION(&_1, "chr", NULL, 244, &_0); + zephir_check_call_status(); + ZVAL_LONG(&_0, paddingSize); + ZEPHIR_RETURN_CALL_FUNCTION("str_repeat", NULL, 1, &_1, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Encryption_Crypt_Padding_Zero, unpad) +{ + zend_bool _0, _5; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL; + zend_long blockSize, ZEPHIR_LAST_CALL_STATUS, counter = 0, paddingSize = 0; + zval *input_param = NULL, *blockSize_param = NULL, length, inputArray, _1, _2, _3; + zval input; + + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&length); + ZVAL_UNDEF(&inputArray); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(input) + Z_PARAM_LONG(blockSize) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &input_param, &blockSize_param); + zephir_get_strval(&input, input_param); + ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 234, &input); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&inputArray, "str_split", NULL, 88, &input); + zephir_check_call_status(); + counter = (zephir_get_numberval(&length) - 1); + paddingSize = 0; + while (1) { + _0 = counter >= 0; + if (_0) { + zephir_array_fetch_long(&_1, &inputArray, counter, PH_NOISY | PH_READONLY, "phalcon/Encryption/Crypt/Padding/Zero.zep", 48); + ZVAL_LONG(&_2, 0); + ZEPHIR_CALL_FUNCTION(&_3, "chr", &_4, 244, &_2); + zephir_check_call_status(); + _0 = ZEPHIR_IS_EQUAL(&_1, &_3); + } + _5 = _0; + if (_5) { + _5 = paddingSize <= blockSize; + } + if (!(_5)) { + break; + } + paddingSize++; + counter--; + } + RETURN_MM_LONG(paddingSize); +} + @@ -106988,289 +105529,355 @@ static PHP_METHOD(Phalcon_Config_Adapter_Yaml, phpExtensionLoaded) -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Connection) +ZEPHIR_INIT_CLASS(Phalcon_Annotations_Annotation) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Pdo, Connection, phalcon, datamapper_pdo_connection, phalcon_datamapper_pdo_connection_abstractconnection_ce, phalcon_datamapper_pdo_connection_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Annotations, Annotation, phalcon, annotations_annotation, phalcon_annotations_annotation_method_entry, 0); - zend_declare_property_null(phalcon_datamapper_pdo_connection_ce, SL("arguments"), ZEND_ACC_PROTECTED); - phalcon_datamapper_pdo_connection_ce->create_object = zephir_init_properties_Phalcon_DataMapper_Pdo_Connection; + zend_declare_property_null(phalcon_annotations_annotation_ce, SL("arguments"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_annotations_annotation_ce, SL("exprArguments"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_annotations_annotation_ce, SL("name"), ZEND_ACC_PROTECTED); + phalcon_annotations_annotation_ce->create_object = zephir_init_properties_Phalcon_Annotations_Annotation; return SUCCESS; } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection, __construct) +static PHP_METHOD(Phalcon_Annotations_Annotation, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options, queries, available, _5; - zval *dsn_param = NULL, *username_param = NULL, *password_param = NULL, *options_param = NULL, *queries_param = NULL, *profiler = NULL, profiler_sub, __$true, __$null, parts, _0, _1$$3, _2$$3, _3$$3, _4$$4; - zval dsn, username, password; + zval *reflectionData_param = NULL, name, exprArguments, argument, resolvedArgument, _0$$3, *_1$$4, _2$$4, _3$$5, _5$$8; + zval reflectionData, arguments; zval *this_ptr = getThis(); - ZVAL_UNDEF(&dsn); - ZVAL_UNDEF(&username); - ZVAL_UNDEF(&password); - ZVAL_UNDEF(&profiler_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&parts); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&queries); - ZVAL_UNDEF(&available); - ZVAL_UNDEF(&_5); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 6) - Z_PARAM_STR(dsn) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(username) - Z_PARAM_STR_OR_NULL(password) - Z_PARAM_ARRAY(options) - Z_PARAM_ARRAY(queries) - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(profiler, phalcon_datamapper_pdo_profiler_profilerinterface_ce) + ZVAL_UNDEF(&reflectionData); + ZVAL_UNDEF(&arguments); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&exprArguments); + ZVAL_UNDEF(&argument); + ZVAL_UNDEF(&resolvedArgument); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_5$$8); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(reflectionData) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 5, &dsn_param, &username_param, &password_param, &options_param, &queries_param, &profiler); - zephir_get_strval(&dsn, dsn_param); - if (!username_param) { - ZEPHIR_INIT_VAR(&username); - } else { - zephir_get_strval(&username, username_param); - } - if (!password_param) { - ZEPHIR_INIT_VAR(&password); - } else { - zephir_get_strval(&password, password_param); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - if (!queries_param) { - ZEPHIR_INIT_VAR(&queries); - array_init(&queries); - } else { - zephir_get_arrval(&queries, queries_param); - } - if (!profiler) { - profiler = &profiler_sub; - ZEPHIR_CPY_WRT(profiler, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(profiler); - } - ZEPHIR_INIT_VAR(&parts); - zephir_fast_explode_str(&parts, SL(":"), &dsn, LONG_MAX); - ZEPHIR_INIT_VAR(&available); - zephir_create_array(&available, 4, 0); - zephir_array_update_string(&available, SL("mysql"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&available, SL("pgsql"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&available, SL("sqlite"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&available, SL("mssql"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_fetch_long(&_0, &parts, 0, PH_READONLY, "phalcon/DataMapper/Pdo/Connection.zep", 65); - if (!(zephir_array_isset(&available, &_0))) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, spl_ce_InvalidArgumentException); - zephir_array_fetch_long(&_2$$3, &parts, 0, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/Connection.zep", 67); - ZEPHIR_INIT_VAR(&_3$$3); - ZEPHIR_CONCAT_SVS(&_3$$3, "Driver not supported [", &_2$$3, "]"); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 200, &_3$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/DataMapper/Pdo/Connection.zep", 68); - ZEPHIR_MM_RESTORE(); - return; - } - if (!(zephir_array_isset_long(&options, 3))) { - ZEPHIR_INIT_VAR(&_4$$4); - ZVAL_LONG(&_4$$4, 2); - zephir_array_update_long(&options, 3, &_4$$4, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + zephir_fetch_params(1, 1, 0, &reflectionData_param); + ZEPHIR_OBS_COPY_OR_DUP(&reflectionData, reflectionData_param); + zephir_memory_observe(&name); + if (zephir_array_isset_string_fetch(&name, &reflectionData, SL("name"), 0)) { + zephir_array_fetch_string(&_0$$3, &reflectionData, SL("name"), PH_NOISY | PH_READONLY, "phalcon/Annotations/Annotation.zep", 48); + zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &_0$$3); } - ZEPHIR_INIT_VAR(&_5); - zephir_create_array(&_5, 5, 0); - zephir_array_fast_append(&_5, &dsn); - zephir_array_fast_append(&_5, &username); - zephir_array_fast_append(&_5, &password); - zephir_array_fast_append(&_5, &options); - zephir_array_fast_append(&_5, &queries); - zephir_update_property_zval(this_ptr, ZEND_STRL("arguments"), &_5); - if (Z_TYPE_P(profiler) == IS_NULL) { - ZEPHIR_INIT_NVAR(profiler); - object_init_ex(profiler, phalcon_datamapper_pdo_profiler_profiler_ce); - ZEPHIR_CALL_METHOD(NULL, profiler, "__construct", NULL, 201); - zephir_check_call_status(); + zephir_memory_observe(&exprArguments); + if (zephir_array_isset_string_fetch(&exprArguments, &reflectionData, SL("arguments"), 0)) { + ZEPHIR_INIT_VAR(&arguments); + array_init(&arguments); + zephir_is_iterable(&exprArguments, 0, "phalcon/Annotations/Annotation.zep", 69); + if (Z_TYPE_P(&exprArguments) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&exprArguments), _1$$4) + { + ZEPHIR_INIT_NVAR(&argument); + ZVAL_COPY(&argument, _1$$4); + zephir_array_fetch_string(&_3$$5, &argument, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/Annotations/Annotation.zep", 60); + ZEPHIR_CALL_METHOD(&resolvedArgument, this_ptr, "getexpression", &_4, 0, &_3$$5); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&name); + if (zephir_array_isset_string_fetch(&name, &argument, SL("name"), 0)) { + zephir_array_update_zval(&arguments, &name, &resolvedArgument, PH_COPY | PH_SEPARATE); + } else { + zephir_array_append(&arguments, &resolvedArgument, PH_SEPARATE, "phalcon/Annotations/Annotation.zep", 65); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &exprArguments, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2$$4, &exprArguments, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2$$4)) { + break; + } + ZEPHIR_CALL_METHOD(&argument, &exprArguments, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_fetch_string(&_5$$8, &argument, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/Annotations/Annotation.zep", 60); + ZEPHIR_CALL_METHOD(&resolvedArgument, this_ptr, "getexpression", &_4, 0, &_5$$8); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&name); + if (zephir_array_isset_string_fetch(&name, &argument, SL("name"), 0)) { + zephir_array_update_zval(&arguments, &name, &resolvedArgument, PH_COPY | PH_SEPARATE); + } else { + zephir_array_append(&arguments, &resolvedArgument, PH_SEPARATE, "phalcon/Annotations/Annotation.zep", 65); + } + ZEPHIR_CALL_METHOD(NULL, &exprArguments, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&argument); + zephir_update_property_zval(this_ptr, ZEND_STRL("arguments"), &arguments); + zephir_update_property_zval(this_ptr, ZEND_STRL("exprArguments"), &exprArguments); } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setprofiler", NULL, 0, profiler); - zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection, __debugInfo) +static PHP_METHOD(Phalcon_Annotations_Annotation, getArgument) { - zval _1, _2, _3, _4, _5; - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *position, position_sub, argument, _0; zval *this_ptr = getThis(); + ZVAL_UNDEF(&position_sub); + ZVAL_UNDEF(&argument); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(position) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &position); + zephir_memory_observe(&argument); + zephir_read_property(&_0, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&argument, &_0, position, 0)) { + RETURN_CCTOR(&argument); + } + RETURN_MM_NULL(); +} - zephir_create_array(return_value, 1, 0); - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 5, 0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&_2); - zephir_array_fetch_long(&_2, &_1, 0, PH_NOISY, "phalcon/DataMapper/Pdo/Connection.zep", 102); - zephir_array_fast_append(&_0, &_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "****"); - zephir_array_fast_append(&_0, &_3); - ZEPHIR_INIT_NVAR(&_3); - ZVAL_STRING(&_3, "****"); - zephir_array_fast_append(&_0, &_3); - zephir_read_property(&_4, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_OBS_NVAR(&_2); - zephir_array_fetch_long(&_2, &_4, 3, PH_NOISY, "phalcon/DataMapper/Pdo/Connection.zep", 105); - zephir_array_fast_append(&_0, &_2); - zephir_read_property(&_5, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_OBS_NVAR(&_2); - zephir_array_fetch_long(&_2, &_5, 4, PH_NOISY, "phalcon/DataMapper/Pdo/Connection.zep", 107); - zephir_array_fast_append(&_0, &_2); - zephir_array_update_string(return_value, SL("arguments"), &_0, PH_COPY | PH_SEPARATE); - RETURN_MM(); +static PHP_METHOD(Phalcon_Annotations_Annotation, getArguments) +{ + + RETURN_MEMBER(getThis(), "arguments"); } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection, connect) +static PHP_METHOD(Phalcon_Annotations_Annotation, getExprArguments) +{ + + RETURN_MEMBER(getThis(), "exprArguments"); +} + +static PHP_METHOD(Phalcon_Annotations_Annotation, getExpression) { - zval dsn, options, password, query, queries, username, _0, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, _7$$3, _8$$3, *_9$$3, _10$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_11 = NULL; + zephir_fcall_cache_entry *_4 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *expr_param = NULL, value, item, resolvedItem, arrayValue, name, type, _0$$7, *_1$$7, _2$$7, _3$$8, _5$$11, _6$$15, _7$$15; + zval expr; zval *this_ptr = getThis(); - ZVAL_UNDEF(&dsn); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&password); - ZVAL_UNDEF(&query); - ZVAL_UNDEF(&queries); - ZVAL_UNDEF(&username); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&expr); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&item); + ZVAL_UNDEF(&resolvedItem); + ZVAL_UNDEF(&arrayValue); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&_0$$7); + ZVAL_UNDEF(&_2$$7); + ZVAL_UNDEF(&_3$$8); + ZVAL_UNDEF(&_5$$11); + ZVAL_UNDEF(&_6$$15); + ZVAL_UNDEF(&_7$$15); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(expr) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_is_true(&_0))) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "connect"); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "start", NULL, 0, &_2$$3); - zephir_check_call_status(); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&dsn); - zephir_array_fetch_long(&dsn, &_3$$3, 0, PH_NOISY, "phalcon/DataMapper/Pdo/Connection.zep", 122); - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&username); - zephir_array_fetch_long(&username, &_4$$3, 1, PH_NOISY, "phalcon/DataMapper/Pdo/Connection.zep", 123); - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&password); - zephir_array_fetch_long(&password, &_5$$3, 2, PH_NOISY, "phalcon/DataMapper/Pdo/Connection.zep", 124); - zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&options); - zephir_array_fetch_long(&options, &_6$$3, 3, PH_NOISY, "phalcon/DataMapper/Pdo/Connection.zep", 125); - zephir_read_property(&_7$$3, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&queries); - zephir_array_fetch_long(&queries, &_7$$3, 4, PH_NOISY, "phalcon/DataMapper/Pdo/Connection.zep", 126); - ZEPHIR_INIT_NVAR(&_2$$3); - object_init_ex(&_2$$3, php_pdo_get_dbh_ce()); - ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 0, &dsn, &username, &password, &options); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("pdo"), &_2$$3); - zephir_read_property(&_8$$3, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_8$$3, "finish", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&queries, 0, "phalcon/DataMapper/Pdo/Connection.zep", 136); - if (Z_TYPE_P(&queries) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&queries), _9$$3) - { - ZEPHIR_INIT_NVAR(&query); - ZVAL_COPY(&query, _9$$3); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "exec", &_11, 0, &query); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &queries, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_10$$3, &queries, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_10$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&query, &queries, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "exec", &_11, 0, &query); + zephir_fetch_params(1, 1, 0, &expr_param); + ZEPHIR_OBS_COPY_OR_DUP(&expr, expr_param); + zephir_memory_observe(&type); + zephir_array_fetch_string(&type, &expr, SL("type"), PH_NOISY, "phalcon/Annotations/Annotation.zep", 111); + do { + if (ZEPHIR_IS_LONG(&type, 301) || ZEPHIR_IS_LONG(&type, 302) || ZEPHIR_IS_LONG(&type, 303) || ZEPHIR_IS_LONG(&type, 307)) { + zephir_memory_observe(&value); + zephir_array_fetch_string(&value, &expr, SL("value"), PH_NOISY, "phalcon/Annotations/Annotation.zep", 118); + break; + } + if (ZEPHIR_IS_LONG(&type, 304)) { + ZEPHIR_INIT_NVAR(&value); + ZVAL_NULL(&value); + break; + } + if (ZEPHIR_IS_LONG(&type, 305)) { + ZEPHIR_INIT_NVAR(&value); + ZVAL_BOOL(&value, 0); + break; + } + if (ZEPHIR_IS_LONG(&type, 306)) { + ZEPHIR_INIT_NVAR(&value); + ZVAL_BOOL(&value, 1); + break; + } + if (ZEPHIR_IS_LONG(&type, 308)) { + ZEPHIR_INIT_VAR(&arrayValue); + array_init(&arrayValue); + zephir_array_fetch_string(&_0$$7, &expr, SL("items"), PH_NOISY | PH_READONLY, "phalcon/Annotations/Annotation.zep", 136); + zephir_is_iterable(&_0$$7, 0, "phalcon/Annotations/Annotation.zep", 148); + if (Z_TYPE_P(&_0$$7) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0$$7), _1$$7) + { + ZEPHIR_INIT_NVAR(&item); + ZVAL_COPY(&item, _1$$7); + zephir_array_fetch_string(&_3$$8, &item, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/Annotations/Annotation.zep", 139); + ZEPHIR_CALL_METHOD(&resolvedItem, this_ptr, "getexpression", &_4, 157, &_3$$8); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &queries, "next", NULL, 0); + ZEPHIR_OBS_NVAR(&name); + if (zephir_array_isset_string_fetch(&name, &item, SL("name"), 0)) { + zephir_array_update_zval(&arrayValue, &name, &resolvedItem, PH_COPY | PH_SEPARATE); + } else { + zephir_array_append(&arrayValue, &resolvedItem, PH_SEPARATE, "phalcon/Annotations/Annotation.zep", 144); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_0$$7, "rewind", NULL, 0); zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2$$7, &_0$$7, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2$$7)) { + break; + } + ZEPHIR_CALL_METHOD(&item, &_0$$7, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_fetch_string(&_5$$11, &item, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/Annotations/Annotation.zep", 139); + ZEPHIR_CALL_METHOD(&resolvedItem, this_ptr, "getexpression", &_4, 157, &_5$$11); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&name); + if (zephir_array_isset_string_fetch(&name, &item, SL("name"), 0)) { + zephir_array_update_zval(&arrayValue, &name, &resolvedItem, PH_COPY | PH_SEPARATE); + } else { + zephir_array_append(&arrayValue, &resolvedItem, PH_SEPARATE, "phalcon/Annotations/Annotation.zep", 144); + } + ZEPHIR_CALL_METHOD(NULL, &_0$$7, "next", NULL, 0); + zephir_check_call_status(); + } } + ZEPHIR_INIT_NVAR(&item); + RETURN_CCTOR(&arrayValue); } - ZEPHIR_INIT_NVAR(&query); - } - ZEPHIR_MM_RESTORE(); + if (ZEPHIR_IS_LONG(&type, 300)) { + object_init_ex(return_value, phalcon_annotations_annotation_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 158, &expr); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_INIT_VAR(&_6$$15); + object_init_ex(&_6$$15, phalcon_annotations_exception_ce); + ZEPHIR_INIT_VAR(&_7$$15); + ZEPHIR_CONCAT_SVS(&_7$$15, "The expression ", &type, " is unknown"); + ZEPHIR_CALL_METHOD(NULL, &_6$$15, "__construct", NULL, 33, &_7$$15); + zephir_check_call_status(); + zephir_throw_exception_debug(&_6$$15, "phalcon/Annotations/Annotation.zep", 154); + ZEPHIR_MM_RESTORE(); + return; + } while(0); + + RETURN_CCTOR(&value); } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection, disconnect) +static PHP_METHOD(Phalcon_Annotations_Annotation, getName) +{ + + RETURN_MEMBER(getThis(), "name"); +} + +static PHP_METHOD(Phalcon_Annotations_Annotation, getNamedArgument) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$null, _0, _1, _2; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, argument, _0; + zval name; zval *this_ptr = getThis(); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&argument); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_memory_observe(&argument); + zephir_read_property(&_0, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&argument, &_0, &name, 0)) { + RETURN_CCTOR(&argument); + } + RETURN_MM_NULL(); +} - zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "disconnect"); - ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("pdo"), &__$null); - zephir_read_property(&_2, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_2, "finish", NULL, 0); +static PHP_METHOD(Phalcon_Annotations_Annotation, getNamedParameter) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getnamedargument", NULL, 0, &name); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Annotations_Annotation, hasArgument) +{ + zval *position, position_sub, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&position_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(position) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &position); + zephir_read_property(&_0, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); + RETURN_BOOL(zephir_array_isset(&_0, position)); +} + +static PHP_METHOD(Phalcon_Annotations_Annotation, numberArguments) +{ + zval _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); + RETURN_LONG(zephir_fast_count_int(&_0)); } -zend_object *zephir_init_properties_Phalcon_DataMapper_Pdo_Connection(zend_class_entry *class_type) +zend_object *zephir_init_properties_Phalcon_Annotations_Annotation(zend_class_entry *class_type) { - zval _0, _1$$3; + zval _0, _2, _1$$3, _3$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); @@ -107279,11 +105886,17 @@ zend_object *zephir_init_properties_Phalcon_DataMapper_Pdo_Connection(zend_class { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("exprArguments"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("arguments"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("exprArguments"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("arguments"), &_3$$4); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -107300,1826 +105913,1880 @@ zend_object *zephir_init_properties_Phalcon_DataMapper_Pdo_Connection(zend_class -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_ConnectionLocator) +ZEPHIR_INIT_CLASS(Phalcon_Annotations_AnnotationsFactory) { - ZEPHIR_REGISTER_CLASS(Phalcon\\DataMapper\\Pdo, ConnectionLocator, phalcon, datamapper_pdo_connectionlocator, phalcon_datamapper_pdo_connectionlocator_method_entry, 0); - - zend_declare_property_null(phalcon_datamapper_pdo_connectionlocator_ce, SL("master"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_datamapper_pdo_connectionlocator_ce, SL("read"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_datamapper_pdo_connectionlocator_ce, SL("write"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_datamapper_pdo_connectionlocator_ce, SL("instances"), ZEND_ACC_PRIVATE); - phalcon_datamapper_pdo_connectionlocator_ce->create_object = zephir_init_properties_Phalcon_DataMapper_Pdo_ConnectionLocator; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Annotations, AnnotationsFactory, phalcon, annotations_annotationsfactory, phalcon_factory_abstractfactory_ce, phalcon_annotations_annotationsfactory_method_entry, 0); - zend_class_implements(phalcon_datamapper_pdo_connectionlocator_ce, 1, phalcon_datamapper_pdo_connectionlocatorinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocator, __construct) +static PHP_METHOD(Phalcon_Annotations_AnnotationsFactory, __construct) { - zend_string *_3, *_8; - zend_ulong _2, _7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL, *_9 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval read, write; - zval *master, master_sub, *read_param = NULL, *write_param = NULL, name, callableObject, *_0, _1, *_5, _6; + zval *services_param = NULL; + zval services; zval *this_ptr = getThis(); - ZVAL_UNDEF(&master_sub); + ZVAL_UNDEF(&services); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(services) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &services_param); + if (!services_param) { + ZEPHIR_INIT_VAR(&services); + array_init(&services); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Annotations_AnnotationsFactory, load) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *config = NULL, config_sub, name, options, _0, _1, _2, _3; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&config_sub); ZVAL_UNDEF(&name); - ZVAL_UNDEF(&callableObject); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&read); - ZVAL_UNDEF(&write); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_OBJECT_OF_CLASS(master, phalcon_datamapper_pdo_connection_connectioninterface_ce) + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(config) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &config); + ZEPHIR_SEPARATE_PARAM(config); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfig", NULL, 0, config); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(config, &_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "adapter"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfigelement", NULL, 0, config, &_1); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(config, &_0); + zephir_memory_observe(&name); + zephir_array_fetch_string(&name, config, SL("adapter"), PH_NOISY, "phalcon/Annotations/AnnotationsFactory.zep", 48); + zephir_array_unset_string(config, SL("adapter"), PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + object_init_ex(&_1, phalcon_support_helper_arr_get_ce); + if (zephir_has_constructor(&_1)) { + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 0); + zephir_check_call_status(); + } + + ZEPHIR_INIT_VAR(&_2); + array_init(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "options"); + ZEPHIR_CALL_METHOD(&options, &_1, "__invoke", NULL, 159, config, &_3, &_2); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "newinstance", NULL, 0, &name, &options); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Annotations_AnnotationsFactory, newInstance) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval options, _0; + zval *name_param = NULL, *options_param = NULL, definition; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(name) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(read) - Z_PARAM_ARRAY(write) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &master, &read_param, &write_param); - if (!read_param) { - ZEPHIR_INIT_VAR(&read); - array_init(&read); + zephir_fetch_params(1, 1, 1, &name_param, &options_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - zephir_get_arrval(&read, read_param); + ZEPHIR_INIT_VAR(&name); } - if (!write_param) { - ZEPHIR_INIT_VAR(&write); - array_init(&write); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - zephir_get_arrval(&write, write_param); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setmaster", NULL, 0, master); + ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); zephir_check_call_status(); - zephir_is_iterable(&read, 0, "phalcon/DataMapper/Pdo/ConnectionLocator.zep", 74); - if (Z_TYPE_P(&read) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&read), _2, _3, _0) - { - ZEPHIR_INIT_NVAR(&name); - if (_3 != NULL) { - ZVAL_STR_COPY(&name, _3); - } else { - ZVAL_LONG(&name, _2); - } - ZEPHIR_INIT_NVAR(&callableObject); - ZVAL_COPY(&callableObject, _0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setread", &_4, 0, &name, &callableObject); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 1, 0); + zephir_array_fast_append(&_0, &options); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(return_value, &definition, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Annotations_AnnotationsFactory, getExceptionClass) +{ + + RETURN_STRING("Phalcon\\Annotations\\Exception"); +} + +static PHP_METHOD(Phalcon_Annotations_AnnotationsFactory, getServices) +{ + + zephir_create_array(return_value, 3, 0); + add_assoc_stringl_ex(return_value, SL("apcu"), SL("Phalcon\\Annotations\\Adapter\\Apcu")); + add_assoc_stringl_ex(return_value, SL("memory"), SL("Phalcon\\Annotations\\Adapter\\Memory")); + add_assoc_stringl_ex(return_value, SL("stream"), SL("Phalcon\\Annotations\\Adapter\\Stream")); + return; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Annotations_Collection) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Annotations, Collection, phalcon, annotations_collection, phalcon_annotations_collection_method_entry, 0); + + zend_declare_property_null(phalcon_annotations_collection_ce, SL("annotations"), ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_annotations_collection_ce, SL("position"), 0, ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_annotations_collection_ce, 1, zend_ce_iterator); + zend_class_implements(phalcon_annotations_collection_ce, 1, zend_ce_countable); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Annotations_Collection, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_3 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *reflectionData_param = NULL, annotations, annotationData, *_0, _1, _2$$3, _4$$4; + zval reflectionData; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&reflectionData); + ZVAL_UNDEF(&annotations); + ZVAL_UNDEF(&annotationData); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_4$$4); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(reflectionData) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &reflectionData_param); + if (!reflectionData_param) { + ZEPHIR_INIT_VAR(&reflectionData); + array_init(&reflectionData); } else { - ZEPHIR_CALL_METHOD(NULL, &read, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &read, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&name, &read, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&callableObject, &read, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setread", &_4, 0, &name, &callableObject); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &read, "next", NULL, 0); - zephir_check_call_status(); - } + zephir_get_arrval(&reflectionData, reflectionData_param); } - ZEPHIR_INIT_NVAR(&callableObject); - ZEPHIR_INIT_NVAR(&name); - zephir_is_iterable(&write, 0, "phalcon/DataMapper/Pdo/ConnectionLocator.zep", 77); - if (Z_TYPE_P(&write) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&write), _7, _8, _5) + ZEPHIR_INIT_VAR(&annotations); + array_init(&annotations); + zephir_is_iterable(&reflectionData, 0, "phalcon/Annotations/Collection.zep", 58); + if (Z_TYPE_P(&reflectionData) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&reflectionData), _0) { - ZEPHIR_INIT_NVAR(&name); - if (_8 != NULL) { - ZVAL_STR_COPY(&name, _8); - } else { - ZVAL_LONG(&name, _7); - } - ZEPHIR_INIT_NVAR(&callableObject); - ZVAL_COPY(&callableObject, _5); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setwrite", &_9, 0, &name, &callableObject); + ZEPHIR_INIT_NVAR(&annotationData); + ZVAL_COPY(&annotationData, _0); + ZEPHIR_INIT_NVAR(&_2$$3); + object_init_ex(&_2$$3, phalcon_annotations_annotation_ce); + ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", &_3, 158, &annotationData); zephir_check_call_status(); + zephir_array_append(&annotations, &_2$$3, PH_SEPARATE, "phalcon/Annotations/Collection.zep", 55); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &write, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &reflectionData, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_6, &write, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_1, &reflectionData, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_6)) { + if (!zend_is_true(&_1)) { break; } - ZEPHIR_CALL_METHOD(&name, &write, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&callableObject, &write, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&annotationData, &reflectionData, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setwrite", &_9, 0, &name, &callableObject); + ZEPHIR_INIT_NVAR(&_4$$4); + object_init_ex(&_4$$4, phalcon_annotations_annotation_ce); + ZEPHIR_CALL_METHOD(NULL, &_4$$4, "__construct", &_3, 158, &annotationData); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &write, "next", NULL, 0); + zephir_array_append(&annotations, &_4$$4, PH_SEPARATE, "phalcon/Annotations/Collection.zep", 55); + ZEPHIR_CALL_METHOD(NULL, &reflectionData, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&callableObject); - ZEPHIR_INIT_NVAR(&name); + ZEPHIR_INIT_NVAR(&annotationData); + zephir_update_property_zval(this_ptr, ZEND_STRL("annotations"), &annotations); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocator, getMaster) +static PHP_METHOD(Phalcon_Annotations_Collection, count) { + zval _0; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "master"); + ZVAL_UNDEF(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("annotations"), PH_NOISY_CC | PH_READONLY); + RETURN_LONG(zephir_fast_count_int(&_0)); } -static PHP_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocator, getRead) +static PHP_METHOD(Phalcon_Annotations_Collection, current) +{ + zval annotation, _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&annotation); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_memory_observe(&annotation); + zephir_read_property(&_0, this_ptr, ZEND_STRL("annotations"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_1, this_ptr, ZEND_STRL("position"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&annotation, &_0, &_1, 0))) { + RETURN_MM_BOOL(0); + } + RETURN_CCTOR(&annotation); +} + +static PHP_METHOD(Phalcon_Annotations_Collection, get) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, _0; - zval name; + zval *name_param = NULL, annotation, annotations, _0, *_1, _2, _5, _3$$3, _4$$5; + zval name, _6; zval *this_ptr = getThis(); ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&annotation); + ZVAL_UNDEF(&annotations); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$5); + ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &name_param); - if (!name_param) { - ZEPHIR_INIT_VAR(&name); - ZVAL_STRING(&name, ""); + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("annotations"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&annotations, &_0); + zephir_is_iterable(&annotations, 0, "phalcon/Annotations/Collection.zep", 98); + if (Z_TYPE_P(&annotations) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&annotations), _1) + { + ZEPHIR_INIT_NVAR(&annotation); + ZVAL_COPY(&annotation, _1); + ZEPHIR_CALL_METHOD(&_3$$3, &annotation, "getname", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_EQUAL(&name, &_3$$3)) { + RETURN_CCTOR(&annotation); + } + } ZEND_HASH_FOREACH_END(); } else { - zephir_get_strval(&name, name_param); + ZEPHIR_CALL_METHOD(NULL, &annotations, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &annotations, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&annotation, &annotations, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4$$5, &annotation, "getname", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_EQUAL(&name, &_4$$5)) { + RETURN_CCTOR(&annotation); + } + ZEPHIR_CALL_METHOD(NULL, &annotations, "next", NULL, 0); + zephir_check_call_status(); + } } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "read"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getconnection", NULL, 0, &_0, &name); + ZEPHIR_INIT_NVAR(&annotation); + ZEPHIR_INIT_VAR(&_5); + object_init_ex(&_5, phalcon_annotations_exception_ce); + ZEPHIR_INIT_VAR(&_6); + ZEPHIR_CONCAT_SVS(&_6, "Collection doesn't have an annotation called '", &name, "'"); + ZEPHIR_CALL_METHOD(NULL, &_5, "__construct", NULL, 33, &_6); zephir_check_call_status(); - RETURN_MM(); + zephir_throw_exception_debug(&_5, "phalcon/Annotations/Collection.zep", 100); + ZEPHIR_MM_RESTORE(); + return; } -static PHP_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocator, getWrite) +static PHP_METHOD(Phalcon_Annotations_Collection, getAll) { + zval found; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, _0; + zval *name_param = NULL, annotations, annotation, _0, *_1, _2, _3$$3, _4$$5; zval name; zval *this_ptr = getThis(); ZVAL_UNDEF(&name); + ZVAL_UNDEF(&annotations); + ZVAL_UNDEF(&annotation); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&found); + ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &name_param); - if (!name_param) { - ZEPHIR_INIT_VAR(&name); - ZVAL_STRING(&name, ""); + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); + ZEPHIR_INIT_VAR(&found); + array_init(&found); + zephir_read_property(&_0, this_ptr, ZEND_STRL("annotations"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&annotations, &_0); + zephir_is_iterable(&annotations, 0, "phalcon/Annotations/Collection.zep", 120); + if (Z_TYPE_P(&annotations) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&annotations), _1) + { + ZEPHIR_INIT_NVAR(&annotation); + ZVAL_COPY(&annotation, _1); + ZEPHIR_CALL_METHOD(&_3$$3, &annotation, "getname", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_EQUAL(&name, &_3$$3)) { + zephir_array_append(&found, &annotation, PH_SEPARATE, "phalcon/Annotations/Collection.zep", 116); + } + } ZEND_HASH_FOREACH_END(); } else { - zephir_get_strval(&name, name_param); + ZEPHIR_CALL_METHOD(NULL, &annotations, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &annotations, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&annotation, &annotations, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4$$5, &annotation, "getname", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_EQUAL(&name, &_4$$5)) { + zephir_array_append(&found, &annotation, PH_SEPARATE, "phalcon/Annotations/Collection.zep", 116); + } + ZEPHIR_CALL_METHOD(NULL, &annotations, "next", NULL, 0); + zephir_check_call_status(); + } } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "write"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getconnection", NULL, 0, &_0, &name); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_INIT_NVAR(&annotation); + RETURN_CTOR(&found); } -static PHP_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocator, setMaster) +static PHP_METHOD(Phalcon_Annotations_Collection, getAnnotations) { - zval *callableObject, callableObject_sub; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&callableObject_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(callableObject, phalcon_datamapper_pdo_connection_connectioninterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &callableObject); - zephir_update_property_zval(this_ptr, ZEND_STRL("master"), callableObject); - RETURN_THISW(); + RETURN_MEMBER(getThis(), "annotations"); } -static PHP_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocator, setRead) +static PHP_METHOD(Phalcon_Annotations_Collection, has) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, *callableObject, callableObject_sub; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, annotations, annotation, _0, *_1, _2, _3$$3, _4$$5; zval name; zval *this_ptr = getThis(); ZVAL_UNDEF(&name); - ZVAL_UNDEF(&callableObject_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) + ZVAL_UNDEF(&annotations); + ZVAL_UNDEF(&annotation); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$5); + ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(name) - Z_PARAM_ZVAL(callableObject) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &callableObject); + zephir_fetch_params(1, 1, 0, &name_param); zephir_get_strval(&name, name_param); - zephir_update_property_array(this_ptr, SL("read"), &name, callableObject); - RETURN_THIS(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("annotations"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&annotations, &_0); + zephir_is_iterable(&annotations, 0, "phalcon/Annotations/Collection.zep", 146); + if (Z_TYPE_P(&annotations) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&annotations), _1) + { + ZEPHIR_INIT_NVAR(&annotation); + ZVAL_COPY(&annotation, _1); + ZEPHIR_CALL_METHOD(&_3$$3, &annotation, "getname", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_EQUAL(&name, &_3$$3)) { + RETURN_MM_BOOL(1); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &annotations, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &annotations, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&annotation, &annotations, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4$$5, &annotation, "getname", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_EQUAL(&name, &_4$$5)) { + RETURN_MM_BOOL(1); + } + ZEPHIR_CALL_METHOD(NULL, &annotations, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&annotation); + RETURN_MM_BOOL(0); } -static PHP_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocator, setWrite) +static PHP_METHOD(Phalcon_Annotations_Collection, key) +{ + + RETURN_MEMBER(getThis(), "position"); +} + +static PHP_METHOD(Phalcon_Annotations_Collection, next) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, *callableObject, callableObject_sub; - zval name; zval *this_ptr = getThis(); + RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("position"))); +} - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&callableObject_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_ZVAL(callableObject) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &callableObject); - zephir_get_strval(&name, name_param); - zephir_update_property_array(this_ptr, SL("write"), &name, callableObject); - RETURN_THIS(); +static PHP_METHOD(Phalcon_Annotations_Collection, rewind) +{ + zval _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, 0); + zephir_update_property_zval(this_ptr, ZEND_STRL("position"), &_0); } -static PHP_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocator, getConnection) +static PHP_METHOD(Phalcon_Annotations_Collection, valid) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *type_param = NULL, *name_param = NULL, collection, instanceName, instances, requested, _0, _1, _6, _2$$5, _3$$5, _4$$6, _5$$6; - zval type, name; + zval _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&instanceName); - ZVAL_UNDEF(&instances); - ZVAL_UNDEF(&requested); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_4$$6); - ZVAL_UNDEF(&_5$$6); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(type) - Z_PARAM_OPTIONAL - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &type_param, &name_param); - zephir_get_strval(&type, type_param); - if (!name_param) { - ZEPHIR_INIT_VAR(&name); - ZVAL_STRING(&name, ""); - } else { - zephir_get_strval(&name, name_param); - } - zephir_memory_observe(&collection); - zephir_read_property_zval(&collection, this_ptr, &type, PH_NOISY_CC); - ZEPHIR_CPY_WRT(&requested, &name); - zephir_read_property(&_0, this_ptr, ZEND_STRL("instances"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&instances, &_0); - if (ZEPHIR_IS_EMPTY(&collection)) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getmaster", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, ""); - if (ZEPHIR_IS_IDENTICAL(&_1, &requested)) { - ZEPHIR_CALL_FUNCTION(&requested, "array_rand", NULL, 202, &collection); - zephir_check_call_status(); - } - if (!(zephir_array_isset(&collection, &requested))) { - ZEPHIR_INIT_VAR(&_2$$5); - object_init_ex(&_2$$5, phalcon_datamapper_pdo_exception_connectionnotfound_ce); - ZEPHIR_INIT_VAR(&_3$$5); - ZEPHIR_CONCAT_SVSV(&_3$$5, "Connection not found: ", &type, ":", &requested); - ZEPHIR_CALL_METHOD(NULL, &_2$$5, "__construct", NULL, 33, &_3$$5); - zephir_check_call_status(); - zephir_throw_exception_debug(&_2$$5, "phalcon/DataMapper/Pdo/ConnectionLocator.zep", 206); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_VAR(&instanceName); - ZEPHIR_CONCAT_VSV(&instanceName, &type, "-", &requested); - if (!(zephir_array_isset(&instances, &instanceName))) { - ZEPHIR_INIT_VAR(&_4$$6); - zephir_array_fetch(&_5$$6, &collection, &requested, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/ConnectionLocator.zep", 217); - ZEPHIR_CALL_USER_FUNC(&_4$$6, &_5$$6); - zephir_check_call_status(); - zephir_array_update_zval(&instances, &instanceName, &_4$$6, PH_COPY | PH_SEPARATE); - zephir_update_property_zval(this_ptr, ZEND_STRL("instances"), &instances); - } - zephir_array_fetch(&_6, &instances, &instanceName, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/ConnectionLocator.zep", 221); - RETURN_CTOR(&_6); + zephir_read_property(&_0, this_ptr, ZEND_STRL("annotations"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_1, this_ptr, ZEND_STRL("position"), PH_NOISY_CC | PH_READONLY); + RETURN_BOOL(zephir_array_isset(&_0, &_1)); } -zend_object *zephir_init_properties_Phalcon_DataMapper_Pdo_ConnectionLocator(zend_class_entry *class_type) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Annotations_Exception) { - zval _0, _2, _4, _1$$3, _3$$4, _5$$5; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Annotations, Exception, phalcon, annotations_exception, zend_ce_exception, NULL, 0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("instances"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("instances"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("write"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("write"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("read"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("read"), &_5$$5); + return SUCCESS; +} + + + +/* Driver template for the LEMON parser generator. +** The author disclaims copyright to this source code. +*/ +/* First off, code is include which follows the "include" declaration +** in the input file. */ +// 18 "parser.php.lemon" + + +// 12 "parser.php.c" +/* Next is all token values, in a form suitable for use by makeheaders. +** This section will be null unless lemon is run with the -m switch. +*/ +/* Make sure the INTERFACE macro is defined. +*/ +#ifndef INTERFACE +# define INTERFACE 1 +#endif +/* The next thing included is series of defines which control +** various aspects of the generated parser. +** AACODETYPE is the data type used for storing terminal +** and nonterminal numbers. "unsigned char" is +** used if there are fewer than 250 terminals +** and nonterminals. "int" is used otherwise. +** AANOCODE is a number of type AACODETYPE which corresponds +** to no legal terminal or nonterminal number. This +** number is used to fill in empty slots of the hash +** table. +** AAFALLBACK If defined, this indicates that one or more tokens +** have fall-back values which should be used if the +** original value of the token will not parse. +** AAACTIONTYPE is the data type used for storing terminal +** and nonterminal numbers. "unsigned char" is +** used if there are fewer than 250 rules and +** states combined. "int" is used otherwise. +** phannot_TOKENTYPE is the data type used for minor tokens given +** directly to the parser from the tokenizer. +** AAMINORTYPE is the data type used for all minor tokens. +** This is typically a union of many types, one of +** which is phannot_TOKENTYPE. The entry in the union +** for base tokens is called "aa0". +** AASTACKDEPTH is the maximum depth of the parser's stack. +** phannot_ARG_SDECL A static variable declaration for the %extra_argument +** phannot_ARG_PDECL A parameter declaration for the %extra_argument +** phannot_ARG_STORE Code to store %extra_argument into aapParser +** phannot_ARG_FETCH Code to extract %extra_argument from aapParser +** AANSTATE the combined number of states. +** AANRULE the number of rules in the grammar +** AAERRORSYMBOL is the code number of the error symbol. If not +** defined, then do no error processing. +*/ +#define AACODETYPE unsigned char +#define AANOCODE 28 +#define AAACTIONTYPE unsigned char +#define phannot_TOKENTYPE phannot_parser_token* +typedef union { + phannot_TOKENTYPE aa0; + zval aa8; + int aa55; +} AAMINORTYPE; +#define AASTACKDEPTH 100 +#define phannot_ARG_SDECL phannot_parser_status *status; +#define phannot_ARG_PDECL ,phannot_parser_status *status +#define phannot_ARG_FETCH phannot_parser_status *status = aapParser->status +#define phannot_ARG_STORE aapParser->status = status +#define AANSTATE 40 +#define AANRULE 25 +#define AAERRORSYMBOL 18 +#define AAERRSYMDT aa55 +#define AA_NO_ACTION (AANSTATE+AANRULE+2) +#define AA_ACCEPT_ACTION (AANSTATE+AANRULE+1) +#define AA_ERROR_ACTION (AANSTATE+AANRULE) + +/* Next are that tables used to determine what action to take based on the +** current state and lookahead token. These tables are used to implement +** functions that take a state number and lookahead value and return an +** action integer. +** +** Suppose the action integer is N. Then the action is determined as +** follows +** +** 0 <= N < AANSTATE Shift N. That is, push the lookahead +** token onto the stack and goto state N. +** +** AANSTATE <= N < AANSTATE+AANRULE Reduce by rule N-AANSTATE. +** +** N == AANSTATE+AANRULE A syntax error has occurred. +** +** N == AANSTATE+AANRULE+1 The parser accepts its input. +** +** N == AANSTATE+AANRULE+2 No such action. Denotes unused +** slots in the aa_action[] table. +** +** The action table is constructed as a single large table named aa_action[]. +** Given state S and lookahead X, the action is computed as +** +** aa_action[ aa_shift_ofst[S] + X ] +** +** If the index value aa_shift_ofst[S]+X is out of range or if the value +** aa_lookahead[aa_shift_ofst[S]+X] is not equal to X or if aa_shift_ofst[S] +** is equal to AA_SHIFT_USE_DFLT, it means that the action is not in the table +** and that aa_default[S] should be used instead. +** +** The formula above is for computing the action when the lookahead is +** a terminal symbol. If the lookahead is a non-terminal (as occurs after +** a reduce action) then the aa_reduce_ofst[] array is used in place of +** the aa_shift_ofst[] array and AA_REDUCE_USE_DFLT is used in place of +** AA_SHIFT_USE_DFLT. +** +** The following are the tables generated in this section: +** +** aa_action[] A single table containing all actions. +** aa_lookahead[] A table containing the lookahead for each entry in +** aa_action. Used to detect hash collisions. +** aa_shift_ofst[] For each state, the offset into aa_action for +** shifting terminals. +** aa_reduce_ofst[] For each state, the offset into aa_action for +** shifting non-terminals after a reduce. +** aa_default[] Default action for each state. +*/ +static AAACTIONTYPE aa_action[] = { + /* 0 */ 4, 28, 15, 38, 12, 14, 16, 18, 20, 21, + /* 10 */ 22, 23, 24, 4, 31, 4, 28, 15, 40, 12, + /* 20 */ 30, 16, 18, 20, 21, 22, 23, 24, 3, 31, + /* 30 */ 4, 17, 15, 6, 19, 35, 16, 18, 20, 21, + /* 40 */ 22, 23, 24, 5, 31, 15, 7, 27, 11, 16, + /* 50 */ 54, 54, 15, 25, 27, 11, 16, 15, 32, 27, + /* 60 */ 11, 16, 66, 1, 2, 39, 41, 15, 4, 10, + /* 70 */ 11, 16, 15, 9, 9, 37, 16, 8, 13, 36, + /* 80 */ 9, 29, 34, 54, 54, 54, 54, 54, 26, 54, + /* 90 */ 54, 54, 54, 54, 54, 54, 33, +}; +static AACODETYPE aa_lookahead[] = { + /* 0 */ 2, 3, 22, 5, 6, 25, 26, 9, 10, 11, + /* 10 */ 12, 13, 14, 2, 16, 2, 3, 22, 0, 6, + /* 20 */ 25, 26, 9, 10, 11, 12, 13, 14, 22, 16, + /* 30 */ 2, 3, 22, 4, 6, 25, 26, 9, 10, 11, + /* 40 */ 12, 13, 14, 3, 16, 22, 23, 24, 25, 26, + /* 50 */ 27, 27, 22, 23, 24, 25, 26, 22, 23, 24, + /* 60 */ 25, 26, 19, 20, 21, 22, 0, 22, 2, 24, + /* 70 */ 25, 26, 22, 1, 1, 25, 26, 5, 7, 8, + /* 80 */ 1, 7, 8, 27, 27, 27, 27, 27, 15, 27, + /* 90 */ 27, 27, 27, 27, 27, 27, 17, +}; +#define AA_SHIFT_USE_DFLT (-3) +static signed char aa_shift_ofst[] = { + /* 0 */ 11, 18, 66, -3, 40, 29, -2, 72, -3, 13, + /* 10 */ -3, -3, 71, 28, -3, -3, -3, -3, -3, -3, + /* 20 */ -3, -3, -3, -3, 13, 73, -3, -3, 74, 28, + /* 30 */ -3, 13, 79, -3, 28, -3, 28, -3, -3, -3, +}; +#define AA_REDUCE_USE_DFLT (-21) +static signed char aa_reduce_ofst[] = { + /* 0 */ 43, -21, 6, -21, -21, -21, 23, -21, -21, 45, + /* 10 */ -21, -21, -21, -20, -21, -21, -21, -21, -21, -21, + /* 20 */ -21, -21, -21, -21, 30, -21, -21, -21, -21, -5, + /* 30 */ -21, 35, -21, -21, 10, -21, 50, -21, -21, -21, +}; +static AAACTIONTYPE aa_default[] = { + /* 0 */ 65, 65, 65, 42, 65, 46, 65, 65, 44, 65, + /* 10 */ 47, 49, 58, 65, 50, 54, 55, 56, 57, 58, + /* 20 */ 59, 60, 61, 62, 65, 65, 63, 48, 56, 65, + /* 30 */ 52, 65, 65, 64, 65, 53, 65, 51, 45, 43, +}; +#define AA_SZ_ACTTAB (sizeof(aa_action)/sizeof(aa_action[0])) + +/* The next table maps tokens into fallback tokens. If a construct +** like the following: +** +** %fallback ID X Y Z. +** +** appears in the grammer, then ID becomes a fallback token for X, Y, +** and Z. Whenever one of the tokens X, Y, or Z is input to the parser +** but it does not parse, the type of the token is changed to ID and +** the parse is retried before an error is thrown. +*/ +#ifdef AAFALLBACK +static const AACODETYPE aaFallback[] = { +}; +#endif /* AAFALLBACK */ + +/* The following structure represents a single element of the +** parser's stack. Information stored includes: +** +** + The state number for the parser at this level of the stack. +** +** + The value of the token stored at this level of the stack. +** (In other words, the "major" token.) +** +** + The semantic value stored at this level of the stack. This is +** the information used by the action routines in the grammar. +** It is sometimes called the "minor" token. +*/ +struct aaStackEntry { + int stateno; /* The state-number */ + int major; /* The major token value. This is the code + ** number for the token at this stack level */ + AAMINORTYPE minor; /* The user-supplied minor token value. This + ** is the value of the token */ +}; +typedef struct aaStackEntry aaStackEntry; + +/* The state of the parser is completely contained in an instance of +** the following structure */ +struct aaParser { + int aaidx; /* Index of top element in stack */ + int aaerrcnt; /* Shifts left before out of the error */ + phannot_ARG_SDECL /* A place to hold %extra_argument */ + aaStackEntry aastack[AASTACKDEPTH]; /* The parser's stack */ +}; +typedef struct aaParser aaParser; + +#ifndef NDEBUG +static FILE *aaTraceFILE = 0; +static char *aaTracePrompt = 0; +#endif /* NDEBUG */ + +#ifndef NDEBUG +static void phannot_Trace(FILE *TraceFILE, char *zTracePrompt){ + aaTraceFILE = TraceFILE; + aaTracePrompt = zTracePrompt; + if( aaTraceFILE==0 ) aaTracePrompt = 0; + else if( aaTracePrompt==0 ) aaTraceFILE = 0; +} +#endif /* NDEBUG */ + +#ifndef NDEBUG +/* For tracing shifts, the names of all terminals and nonterminals +** are required. The following table supplies these names */ +static const char *aaTokenName[] = { + "$", "COMMA", "AT", "IDENTIFIER", + "PARENTHESES_OPEN", "PARENTHESES_CLOSE", "STRING", "EQUALS", + "COLON", "INTEGER", "DOUBLE", "NULL", + "FALSE", "TRUE", "BRACKET_OPEN", "BRACKET_CLOSE", + "SBRACKET_OPEN", "SBRACKET_CLOSE", "error", "program", + "annotation_language", "annotation_list", "annotation", "argument_list", + "argument_item", "expr", "array", +}; +#endif /* NDEBUG */ + +#ifndef NDEBUG +/* For tracing reduce actions, the names of all rules are required. +*/ +static const char *aaRuleName[] = { + /* 0 */ "program ::= annotation_language", + /* 1 */ "annotation_language ::= annotation_list", + /* 2 */ "annotation_list ::= annotation_list annotation", + /* 3 */ "annotation_list ::= annotation", + /* 4 */ "annotation ::= AT IDENTIFIER PARENTHESES_OPEN argument_list PARENTHESES_CLOSE", + /* 5 */ "annotation ::= AT IDENTIFIER PARENTHESES_OPEN PARENTHESES_CLOSE", + /* 6 */ "annotation ::= AT IDENTIFIER", + /* 7 */ "argument_list ::= argument_list COMMA argument_item", + /* 8 */ "argument_list ::= argument_item", + /* 9 */ "argument_item ::= expr", + /* 10 */ "argument_item ::= STRING EQUALS expr", + /* 11 */ "argument_item ::= STRING COLON expr", + /* 12 */ "argument_item ::= IDENTIFIER EQUALS expr", + /* 13 */ "argument_item ::= IDENTIFIER COLON expr", + /* 14 */ "expr ::= annotation", + /* 15 */ "expr ::= array", + /* 16 */ "expr ::= IDENTIFIER", + /* 17 */ "expr ::= INTEGER", + /* 18 */ "expr ::= STRING", + /* 19 */ "expr ::= DOUBLE", + /* 20 */ "expr ::= NULL", + /* 21 */ "expr ::= FALSE", + /* 22 */ "expr ::= TRUE", + /* 23 */ "array ::= BRACKET_OPEN argument_list BRACKET_CLOSE", + /* 24 */ "array ::= SBRACKET_OPEN argument_list SBRACKET_CLOSE", +}; +#endif /* NDEBUG */ + +const char *phannot_TokenName(int tokenType){ +#ifndef NDEBUG + if( tokenType>0 && tokenType<(sizeof(aaTokenName)/sizeof(aaTokenName[0])) ){ + return aaTokenName[tokenType]; + }else{ + return "Unknown"; + } +#else + return ""; +#endif +} + +void *phannot_Alloc(void *(*mallocProc)(size_t)){ + aaParser *pParser; + pParser = (aaParser*)(*mallocProc)( (size_t)sizeof(aaParser) ); + if( pParser ){ + pParser->aaidx = -1; + } + return pParser; +} + +/* The following function deletes the value associated with a +** symbol. The symbol can be either a terminal or nonterminal. +** "aamajor" is the symbol code, and "aapminor" is a pointer to +** the value. +*/ +static void aa_destructor(AACODETYPE aamajor, AAMINORTYPE *aapminor){ + switch( aamajor ){ + /* Here is inserted the actions which take place when a + ** terminal or non-terminal is destroyed. This can happen + ** when the symbol is popped from the stack during a + ** reduce or during error processing or when a parser is + ** being destroyed before it is finished parsing. + ** + ** Note: during a reduce, the only symbols destroyed are those + ** which appear on the RHS of the rule, but which are not used + ** inside the C code. + */ + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: +// 67 "parser.php.lemon" +{ + if ((aapminor->aa0)) { + if ((aapminor->aa0)->free_flag) { + efree((aapminor->aa0)->token); } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + efree((aapminor->aa0)); } } +// 380 "parser.php.c" + break; + case 20: + case 21: + case 22: + case 23: + case 24: + case 25: +// 80 "parser.php.lemon" +{ + zval_ptr_dtor(&(aapminor->aa8)); +} +// 392 "parser.php.c" + break; + default: break; /* If no destructor action specified: do nothing */ + } +} +static int aa_pop_parser_stack(aaParser *pParser){ + AACODETYPE aamajor; + aaStackEntry *aatos = &pParser->aastack[pParser->aaidx]; - - -#ifdef HAVE_CONFIG_H + if( pParser->aaidx<0 ) return 0; +#ifndef NDEBUG + if( aaTraceFILE && pParser->aaidx>=0 ){ + fprintf(aaTraceFILE,"%sPopping %s\n", + aaTracePrompt, + aaTokenName[aatos->major]); + } #endif + aamajor = aatos->major; + aa_destructor( aamajor, &aatos->minor); + pParser->aaidx--; + return aamajor; +} +static void phannot_Free( + void *p, /* The parser to be deleted */ + void (*freeProc)(void*) /* Function used to reclaim memory */ +){ + aaParser *pParser = (aaParser*)p; + if( pParser==0 ) return; + while( pParser->aaidx>=0 ) aa_pop_parser_stack(pParser); + (*freeProc)((void*)pParser); +} +static int aa_find_shift_action( + aaParser *pParser, /* The parser */ + int iLookAhead /* The look-ahead token */ +){ + int i; + int stateno = pParser->aastack[pParser->aaidx].stateno; - - -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_ConnectionLocatorInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\DataMapper\\Pdo, ConnectionLocatorInterface, phalcon, datamapper_pdo_connectionlocatorinterface, phalcon_datamapper_pdo_connectionlocatorinterface_method_entry); - - return SUCCESS; + /* if( pParser->aaidx<0 ) return AA_NO_ACTION; */ + i = aa_shift_ofst[stateno]; + if( i==AA_SHIFT_USE_DFLT ){ + return aa_default[stateno]; + } + if( iLookAhead==AANOCODE ){ + return AA_NO_ACTION; + } + i += iLookAhead; + if( i<0 || i>=AA_SZ_ACTTAB || aa_lookahead[i]!=iLookAhead ){ +#ifdef AAFALLBACK + int iFallback; /* Fallback token */ + if( iLookAhead %s\n", + aaTracePrompt, aaTokenName[iLookAhead], aaTokenName[iFallback]); + } +#endif + return aa_find_shift_action(pParser, iFallback); + } +#endif + return aa_default[stateno]; + }else{ + return aa_action[i]; + } } -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocatorInterface, getMaster); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocatorInterface, getRead); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocatorInterface, getWrite); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocatorInterface, setMaster); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocatorInterface, setRead); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocatorInterface, setWrite); - +static int aa_find_reduce_action( + aaParser *pParser, /* The parser */ + int iLookAhead /* The look-ahead token */ +){ + int i; + int stateno = pParser->aastack[pParser->aaidx].stateno; + i = aa_reduce_ofst[stateno]; + if( i==AA_REDUCE_USE_DFLT ){ + return aa_default[stateno]; + } + if( iLookAhead==AANOCODE ){ + return AA_NO_ACTION; + } + i += iLookAhead; + if( i<0 || i>=AA_SZ_ACTTAB || aa_lookahead[i]!=iLookAhead ){ + return aa_default[stateno]; + }else{ + return aa_action[i]; + } +} -#ifdef HAVE_CONFIG_H +static void aa_shift( + aaParser *aapParser, /* The parser to be shifted */ + int aaNewState, /* The new state to shift in */ + int aaMajor, /* The major token to shift in */ + AAMINORTYPE *aapMinor /* Pointer ot the minor token to shift in */ +){ + aaStackEntry *aatos; + aapParser->aaidx++; + if( aapParser->aaidx>=AASTACKDEPTH ){ + phannot_ARG_FETCH; + aapParser->aaidx--; +#ifndef NDEBUG + if( aaTraceFILE ){ + fprintf(aaTraceFILE,"%sStack Overflow!\n",aaTracePrompt); + } #endif + while( aapParser->aaidx>=0 ) aa_pop_parser_stack(aapParser); + /* Here code is inserted which will execute if the parser + ** stack every overflows */ + phannot_ARG_STORE; /* Suppress warning about unused %extra_argument var */ + return; + } + aatos = &aapParser->aastack[aapParser->aaidx]; + aatos->stateno = aaNewState; + aatos->major = aaMajor; + aatos->minor = *aapMinor; +#ifndef NDEBUG + if( aaTraceFILE && aapParser->aaidx>0 ){ + int i; + fprintf(aaTraceFILE,"%sShift %d\n",aaTracePrompt,aaNewState); + fprintf(aaTraceFILE,"%sStack:",aaTracePrompt); + for(i=1; i<=aapParser->aaidx; i++) + fprintf(aaTraceFILE," %s",aaTokenName[aapParser->aastack[i].major]); + fprintf(aaTraceFILE,"\n"); + } +#endif +} +/* The following table contains information about every rule that +** is used during the reduce. +*/ +static struct { + AACODETYPE lhs; /* Symbol on the left-hand side of the rule */ + unsigned char nrhs; /* Number of right-hand side symbols in the rule */ +} aaRuleInfo[] = { + { 19, 1 }, + { 20, 1 }, + { 21, 2 }, + { 21, 1 }, + { 22, 5 }, + { 22, 4 }, + { 22, 2 }, + { 23, 3 }, + { 23, 1 }, + { 24, 1 }, + { 24, 3 }, + { 24, 3 }, + { 24, 3 }, + { 24, 3 }, + { 25, 1 }, + { 25, 1 }, + { 25, 1 }, + { 25, 1 }, + { 25, 1 }, + { 25, 1 }, + { 25, 1 }, + { 25, 1 }, + { 25, 1 }, + { 26, 3 }, + { 26, 3 }, +}; +static void aa_accept(aaParser*); /* Forward Declaration */ +static void aa_reduce( + aaParser *aapParser, /* The parser */ + int aaruleno /* Number of the rule by which to reduce */ +){ + int aagoto; /* The next state */ + int aaact; /* The next action */ + AAMINORTYPE aagotominor; /* The LHS of the rule reduced */ + aaStackEntry *aamsp; /* The top of the parser's stack */ + int aasize; /* Amount to pop the stack */ + phannot_ARG_FETCH; + aamsp = &aapParser->aastack[aapParser->aaidx]; +#ifndef NDEBUG + if( aaTraceFILE && aaruleno>=0 + && aaruleno + ** { ... } // User supplied code + ** // + ** break; + */ + case 0: +// 76 "parser.php.lemon" { - ZEPHIR_REGISTER_CLASS(Phalcon\\DataMapper\\Pdo\\Connection, AbstractConnection, phalcon, datamapper_pdo_connection_abstractconnection, phalcon_datamapper_pdo_connection_abstractconnection_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_datamapper_pdo_connection_abstractconnection_ce, SL("pdo"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_datamapper_pdo_connection_abstractconnection_ce, SL("profiler"), ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_datamapper_pdo_connection_abstractconnection_ce, 1, phalcon_datamapper_pdo_connection_connectioninterface_ce); - return SUCCESS; + ZVAL_ZVAL(&status->ret, &aamsp[0].minor.aa8, 1, 1); } - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, __call) +// 634 "parser.php.c" + break; + case 1: + case 14: + case 15: +// 84 "parser.php.lemon" { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval arguments, _2; - zval *name, name_sub, *arguments_param = NULL, className, message, _0, _3, _1$$3; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name_sub); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&arguments); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(name) - Z_PARAM_ARRAY(arguments) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name, &arguments_param); - zephir_get_arrval(&arguments, arguments_param); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); - if (!((zephir_method_exists(&_0, name) == SUCCESS))) { - ZEPHIR_INIT_VAR(&className); - zephir_get_class(&className, this_ptr, 0); - ZEPHIR_INIT_VAR(&message); - ZEPHIR_CONCAT_SVSVS(&message, "Class '", &className, "' does not have a method '", name, "'"); - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, spl_ce_BadMethodCallException); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 75, &message); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 59); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 2, 0); - zephir_memory_observe(&_3); - zephir_read_property(&_3, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC); - zephir_array_fast_append(&_2, &_3); - zephir_array_fast_append(&_2, name); - ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_2, &arguments); - zephir_check_call_status(); - RETURN_MM(); + aagotominor.aa8 = aamsp[0].minor.aa8; } - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, beginTransaction) +// 643 "parser.php.c" + break; + case 2: +// 92 "parser.php.lemon" { - zval result, _0, _1, _2, _3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "beginTransaction"); - ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); - zephir_check_call_status(); - zephir_read_property(&_2, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&result, &_2, "begintransaction", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_3, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_3, "finish", NULL, 0); - zephir_check_call_status(); - RETURN_CCTOR(&result); + phannot_ret_zval_list(&aagotominor.aa8, &aamsp[-1].minor.aa8, &aamsp[0].minor.aa8); } - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, commit) +// 650 "parser.php.c" + break; + case 3: + case 8: +// 96 "parser.php.lemon" { - zval result, _0, _1, _2, _3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "commit"); - ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); - zephir_check_call_status(); - zephir_read_property(&_2, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&result, &_2, "commit", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_3, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_3, "finish", NULL, 0); - zephir_check_call_status(); - RETURN_CCTOR(&result); + phannot_ret_zval_list(&aagotominor.aa8, NULL, &aamsp[0].minor.aa8); } - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, connect) +// 658 "parser.php.c" + break; + case 4: +// 104 "parser.php.lemon" { + phannot_ret_annotation(&aagotominor.aa8, aamsp[-3].minor.aa0, &aamsp[-1].minor.aa8, status->scanner_state); + aa_destructor(2,&aamsp[-4].minor); + aa_destructor(4,&aamsp[-2].minor); + aa_destructor(5,&aamsp[0].minor); } - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, disconnect) +// 668 "parser.php.c" + break; + case 5: +// 108 "parser.php.lemon" { + phannot_ret_annotation(&aagotominor.aa8, aamsp[-2].minor.aa0, NULL, status->scanner_state); + aa_destructor(2,&aamsp[-3].minor); + aa_destructor(4,&aamsp[-1].minor); + aa_destructor(5,&aamsp[0].minor); } - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, errorCode) +// 678 "parser.php.c" + break; + case 6: +// 112 "parser.php.lemon" { - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "errorcode", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + phannot_ret_annotation(&aagotominor.aa8, aamsp[0].minor.aa0, NULL, status->scanner_state); + aa_destructor(2,&aamsp[-1].minor); } - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, errorInfo) +// 686 "parser.php.c" + break; + case 7: +// 120 "parser.php.lemon" { - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "errorinfo", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + phannot_ret_zval_list(&aagotominor.aa8, &aamsp[-2].minor.aa8, &aamsp[0].minor.aa8); + aa_destructor(1,&aamsp[-1].minor); } - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, exec) +// 694 "parser.php.c" + break; + case 9: +// 132 "parser.php.lemon" { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *statement_param = NULL, affectedRows, _0, _1, _2, _3; - zval statement; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&statement); - ZVAL_UNDEF(&affectedRows); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(statement) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &statement_param); - zephir_get_strval(&statement, statement_param); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "exec"); - ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); - zephir_check_call_status(); - zephir_read_property(&_2, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&affectedRows, &_2, "exec", NULL, 0, &statement); - zephir_check_call_status(); - zephir_read_property(&_3, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_3, "finish", NULL, 0, &statement); - zephir_check_call_status(); - RETURN_CCTOR(&affectedRows); + phannot_ret_named_item(&aagotominor.aa8, NULL, &aamsp[0].minor.aa8); } - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchAffected) +// 701 "parser.php.c" + break; + case 10: + case 12: +// 136 "parser.php.lemon" { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval values; - zval *statement_param = NULL, *values_param = NULL, sth; - zval statement; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&statement); - ZVAL_UNDEF(&sth); - ZVAL_UNDEF(&values); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(statement) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(values) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &statement_param, &values_param); - zephir_get_strval(&statement, statement_param); - if (!values_param) { - ZEPHIR_INIT_VAR(&values); - array_init(&values); - } else { - zephir_get_arrval(&values, values_param); - } - ZEPHIR_CALL_METHOD(&sth, this_ptr, "perform", NULL, 0, &statement, &values); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&sth, "rowcount", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + phannot_ret_named_item(&aagotominor.aa8, aamsp[-2].minor.aa0, &aamsp[0].minor.aa8); + aa_destructor(7,&aamsp[-1].minor); } - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchAll) +// 710 "parser.php.c" + break; + case 11: + case 13: +// 140 "parser.php.lemon" { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval values, _0; - zval *statement_param = NULL, *values_param = NULL, _1; - zval statement; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&statement); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(statement) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(values) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &statement_param, &values_param); - zephir_get_strval(&statement, statement_param); - if (!values_param) { - ZEPHIR_INIT_VAR(&values); - array_init(&values); - } else { - zephir_get_arrval(&values, values_param); - } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 1, 0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_LONG(&_1, 2); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "fetchAll"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "fetchdata", NULL, 0, &_1, &_0, &statement, &values); - zephir_check_call_status(); - RETURN_MM(); + phannot_ret_named_item(&aagotominor.aa8, aamsp[-2].minor.aa0, &aamsp[0].minor.aa8); + aa_destructor(8,&aamsp[-1].minor); } - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchAssoc) +// 719 "parser.php.c" + break; + case 16: +// 164 "parser.php.lemon" { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_2 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval values; - zval *statement_param = NULL, *values_param = NULL, data, row, sth, _0, _1$$3, _3$$3; - zval statement; - zval *this_ptr = getThis(); + phannot_ret_literal_zval(&aagotominor.aa8, PHANNOT_T_IDENTIFIER, aamsp[0].minor.aa0); +} +// 726 "parser.php.c" + break; + case 17: +// 168 "parser.php.lemon" +{ + phannot_ret_literal_zval(&aagotominor.aa8, PHANNOT_T_INTEGER, aamsp[0].minor.aa0); +} +// 733 "parser.php.c" + break; + case 18: +// 172 "parser.php.lemon" +{ + phannot_ret_literal_zval(&aagotominor.aa8, PHANNOT_T_STRING, aamsp[0].minor.aa0); +} +// 740 "parser.php.c" + break; + case 19: +// 176 "parser.php.lemon" +{ + phannot_ret_literal_zval(&aagotominor.aa8, PHANNOT_T_DOUBLE, aamsp[0].minor.aa0); +} +// 747 "parser.php.c" + break; + case 20: +// 180 "parser.php.lemon" +{ + phannot_ret_literal_zval(&aagotominor.aa8, PHANNOT_T_NULL, NULL); + aa_destructor(11,&aamsp[0].minor); +} +// 755 "parser.php.c" + break; + case 21: +// 184 "parser.php.lemon" +{ + phannot_ret_literal_zval(&aagotominor.aa8, PHANNOT_T_FALSE, NULL); + aa_destructor(12,&aamsp[0].minor); +} +// 763 "parser.php.c" + break; + case 22: +// 188 "parser.php.lemon" +{ + phannot_ret_literal_zval(&aagotominor.aa8, PHANNOT_T_TRUE, NULL); + aa_destructor(13,&aamsp[0].minor); +} +// 771 "parser.php.c" + break; + case 23: +// 192 "parser.php.lemon" +{ + phannot_ret_array(&aagotominor.aa8, &aamsp[-1].minor.aa8); + aa_destructor(14,&aamsp[-2].minor); + aa_destructor(15,&aamsp[0].minor); +} +// 780 "parser.php.c" + break; + case 24: +// 196 "parser.php.lemon" +{ + phannot_ret_array(&aagotominor.aa8, &aamsp[-1].minor.aa8); + aa_destructor(16,&aamsp[-2].minor); + aa_destructor(17,&aamsp[0].minor); +} +// 789 "parser.php.c" + break; + }; + aagoto = aaRuleInfo[aaruleno].lhs; + aasize = aaRuleInfo[aaruleno].nrhs; + aapParser->aaidx -= aasize; + aaact = aa_find_reduce_action(aapParser,aagoto); + if( aaact < AANSTATE ){ + aa_shift(aapParser,aaact,aagoto,&aagotominor); + }else if( aaact == AANSTATE + AANRULE + 1 ){ + aa_accept(aapParser); + } +} - ZVAL_UNDEF(&statement); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&row); - ZVAL_UNDEF(&sth); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&values); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(statement) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(values) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &statement_param, &values_param); - zephir_get_strval(&statement, statement_param); - if (!values_param) { - ZEPHIR_INIT_VAR(&values); - array_init(&values); - } else { - zephir_get_arrval(&values, values_param); - } - ZEPHIR_INIT_VAR(&data); - array_init(&data); - ZEPHIR_CALL_METHOD(&sth, this_ptr, "perform", NULL, 0, &statement, &values); - zephir_check_call_status(); - ZVAL_LONG(&_0, 2); - ZEPHIR_CALL_METHOD(&row, &sth, "fetch", NULL, 0, &_0); - zephir_check_call_status(); - while (1) { - if (!(zephir_is_true(&row))) { - break; - } - ZEPHIR_CALL_FUNCTION(&_1$$3, "current", &_2, 4, &row); - zephir_check_call_status(); - zephir_array_update_zval(&data, &_1$$3, &row, PH_COPY | PH_SEPARATE); - ZVAL_LONG(&_3$$3, 2); - ZEPHIR_CALL_METHOD(&row, &sth, "fetch", NULL, 0, &_3$$3); - zephir_check_call_status(); - } - RETURN_CCTOR(&data); +static void aa_parse_failed( + aaParser *aapParser /* The parser */ +){ + phannot_ARG_FETCH; +#ifndef NDEBUG + if( aaTraceFILE ){ + fprintf(aaTraceFILE,"%sFail!\n",aaTracePrompt); + } +#endif + while( aapParser->aaidx>=0 ) aa_pop_parser_stack(aapParser); + /* Here code is inserted which will be executed whenever the + ** parser fails */ + phannot_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchColumn) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long column, ZEPHIR_LAST_CALL_STATUS; - zval values, _0; - zval *statement_param = NULL, *values_param = NULL, *column_param = NULL, _1; - zval statement; - zval *this_ptr = getThis(); +static void aa_syntax_error( + aaParser *aapParser, /* The parser */ + int aamajor, /* The major type of the error token */ + AAMINORTYPE aaminor /* The minor type of the error token */ +){ + phannot_ARG_FETCH; +#define ATOKEN (aaminor.aa0) +// 22 "parser.php.lemon" - ZVAL_UNDEF(&statement); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(statement) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(values) - Z_PARAM_LONG(column) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &statement_param, &values_param, &column_param); - zephir_get_strval(&statement, statement_param); - if (!values_param) { - ZEPHIR_INIT_VAR(&values); - array_init(&values); - } else { - zephir_get_arrval(&values, values_param); - } - if (!column_param) { - column = 0; - } else { + if (status->scanner_state->start_length) { + char *token_name = NULL; + const phannot_token_names *tokens = phannot_tokens; + int active_token = status->scanner_state->active_token; + unsigned int near_length = status->scanner_state->start_length; + + if (active_token) { + do { + if (tokens->code == active_token) { + token_name = tokens->name; + break; + } + ++tokens; + } while (tokens[0].code != 0); } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 2, 0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_LONG(&_1, 7); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_LONG(&_1, column); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "fetchAll"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "fetchdata", NULL, 0, &_1, &_0, &statement, &values); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchGroup) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long flags, ZEPHIR_LAST_CALL_STATUS; - zval values, _0; - zval *statement_param = NULL, *values_param = NULL, *flags_param = NULL, _1; - zval statement; - zval *this_ptr = getThis(); + if (!token_name) { + token_name = "UNKNOWN"; + } - ZVAL_UNDEF(&statement); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(statement) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(values) - Z_PARAM_LONG(flags) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &statement_param, &values_param, &flags_param); - zephir_get_strval(&statement, statement_param); - if (!values_param) { - ZEPHIR_INIT_VAR(&values); - array_init(&values); + if (near_length > 0) { + if (status->token->value) { + spprintf(&status->syntax_error, 0, "Syntax error, unexpected token %s(%s), near to '%s' in %s on line %d", token_name, status->token->value, status->scanner_state->start, status->scanner_state->active_file, status->scanner_state->active_line); + } else { + spprintf(&status->syntax_error, 0, "Syntax error, unexpected token %s, near to '%s' in %s on line %d", token_name, status->scanner_state->start, status->scanner_state->active_file, status->scanner_state->active_line); + } + } else { + if (active_token != PHANNOT_T_IGNORE) { + if (status->token->value) { + spprintf(&status->syntax_error, 0, "Syntax error, unexpected token %s(%s), at the end of docblock in %s on line %d", token_name, status->token->value, status->scanner_state->active_file, status->scanner_state->active_line); + } else { + spprintf(&status->syntax_error, 0, "Syntax error, unexpected token %s, at the end of docblock in %s on line %d", token_name, status->scanner_state->active_file, status->scanner_state->active_line); + } + } else { + spprintf(&status->syntax_error, 0, "Syntax error, unexpected EOF, at the end of docblock in %s on line %d", status->scanner_state->active_file, status->scanner_state->active_line); + } + } } else { - zephir_get_arrval(&values, values_param); + spprintf(&status->syntax_error, 0, "Syntax error, unexpected EOF in %s", status->scanner_state->active_file); } - if (!flags_param) { - flags = 2; - } else { - } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 1, 0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_LONG(&_1, (65536 | flags)); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "fetchAll"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "fetchdata", NULL, 0, &_1, &_0, &statement, &values); - zephir_check_call_status(); - RETURN_MM(); + + status->status = PHANNOT_PARSING_FAILED; + +// 876 "parser.php.c" + phannot_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchObject) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval values, arguments; - zval *statement_param = NULL, *values_param = NULL, *className_param = NULL, *arguments_param = NULL, sth; - zval statement, className; - zval *this_ptr = getThis(); +static void aa_accept( + aaParser *aapParser /* The parser */ +){ + phannot_ARG_FETCH; +#ifndef NDEBUG + if( aaTraceFILE ){ + fprintf(aaTraceFILE,"%sAccept!\n",aaTracePrompt); + } +#endif + while( aapParser->aaidx>=0 ) aa_pop_parser_stack(aapParser); + /* Here code is inserted which will be executed whenever the + ** parser accepts */ + phannot_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ +} - ZVAL_UNDEF(&statement); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&sth); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&arguments); - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_STR(statement) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(values) - Z_PARAM_STR(className) - Z_PARAM_ARRAY(arguments) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 3, &statement_param, &values_param, &className_param, &arguments_param); - zephir_get_strval(&statement, statement_param); - if (!values_param) { - ZEPHIR_INIT_VAR(&values); - array_init(&values); - } else { - zephir_get_arrval(&values, values_param); - } - if (!className_param) { - ZEPHIR_INIT_VAR(&className); - ZVAL_STRING(&className, "stdClass"); - } else { - zephir_get_strval(&className, className_param); - } - if (!arguments_param) { - ZEPHIR_INIT_VAR(&arguments); - array_init(&arguments); - } else { - zephir_get_arrval(&arguments, arguments_param); - } - ZEPHIR_CALL_METHOD(&sth, this_ptr, "perform", NULL, 0, &statement, &values); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&sth, "fetchobject", NULL, 0, &className, &arguments); - zephir_check_call_status(); - RETURN_MM(); +/* The main parser program. +** The first argument is a pointer to a structure obtained from +** "phannot_Alloc" which describes the current state of the parser. +** The second argument is the major token number. The third is +** the minor token. The fourth optional argument is whatever the +** user wants (and specified in the grammar) and is available for +** use by the action routines. +** +** Inputs: +**
    +**
  • A pointer to the parser (an opaque structure.) +**
  • The major token number. +**
  • The minor token number. +**
  • An option argument of a grammar-specified type. +**
+** +** Outputs: +** None. +*/ +static void phannot_( + void *aap, /* The parser */ + int aamajor, /* The major token code number */ + phannot_TOKENTYPE aaminor /* The value for the token */ + phannot_ARG_PDECL /* Optional %extra_argument parameter */ +){ + AAMINORTYPE aaminorunion; + int aaact; /* The parser action. */ + int aaendofinput; /* True if we are at the end of input */ + int aaerrorhit = 0; /* True if aamajor has invoked an error */ + aaParser *aapParser; /* The parser */ + + /* (re)initialize the parser, if necessary */ + aapParser = (aaParser*)aap; + if( aapParser->aaidx<0 ){ + if( aamajor==0 ) return; + aapParser->aaidx = 0; + aapParser->aaerrcnt = -1; + aapParser->aastack[0].stateno = 0; + aapParser->aastack[0].major = 0; + } + aaminorunion.aa0 = aaminor; + aaendofinput = (aamajor==0); + phannot_ARG_STORE; + +#ifndef NDEBUG + if( aaTraceFILE ){ + fprintf(aaTraceFILE,"%sInput %s\n",aaTracePrompt,aaTokenName[aamajor]); + } +#endif + + do{ + aaact = aa_find_shift_action(aapParser,aamajor); + if( aaactaaerrcnt--; + if( aaendofinput && aapParser->aaidx>=0 ){ + aamajor = 0; + }else{ + aamajor = AANOCODE; + } + }else if( aaact < AANSTATE + AANRULE ){ + aa_reduce(aapParser,aaact-AANSTATE); + }else if( aaact == AA_ERROR_ACTION ){ + int aamx; +#ifndef NDEBUG + if( aaTraceFILE ){ + fprintf(aaTraceFILE,"%sSyntax Error!\n",aaTracePrompt); + } +#endif +#ifdef AAERRORSYMBOL + /* A syntax error has occurred. + ** The response to an error depends upon whether or not the + ** grammar defines an error token "ERROR". + ** + ** This is what we do if the grammar does define ERROR: + ** + ** * Call the %syntax_error function. + ** + ** * Begin popping the stack until we enter a state where + ** it is legal to shift the error symbol, then shift + ** the error symbol. + ** + ** * Set the error count to three. + ** + ** * Begin accepting and shifting new tokens. No new error + ** processing will occur until three tokens have been + ** shifted successfully. + ** + */ + if( aapParser->aaerrcnt<0 ){ + aa_syntax_error(aapParser,aamajor,aaminorunion); + } + aamx = aapParser->aastack[aapParser->aaidx].major; + if( aamx==AAERRORSYMBOL || aaerrorhit ){ +#ifndef NDEBUG + if( aaTraceFILE ){ + fprintf(aaTraceFILE,"%sDiscard input token %s\n", + aaTracePrompt,aaTokenName[aamajor]); + } +#endif + aa_destructor(aamajor,&aaminorunion); + aamajor = AANOCODE; + }else{ + while( + aapParser->aaidx >= 0 && + aamx != AAERRORSYMBOL && + (aaact = aa_find_shift_action(aapParser,AAERRORSYMBOL)) >= AANSTATE + ){ + aa_pop_parser_stack(aapParser); + } + if( aapParser->aaidx < 0 || aamajor==0 ){ + aa_destructor(aamajor,&aaminorunion); + aa_parse_failed(aapParser); + aamajor = AANOCODE; + }else if( aamx!=AAERRORSYMBOL ){ + AAMINORTYPE u2; + u2.AAERRSYMDT = 0; + aa_shift(aapParser,aaact,AAERRORSYMBOL,&u2); + } + } + aapParser->aaerrcnt = 3; + aaerrorhit = 1; +#else /* AAERRORSYMBOL is not defined */ + /* This is what we do if the grammar does not define ERROR: + ** + ** * Report an error message, and throw away the input token. + ** + ** * If the input token is $, then fail the parse. + ** + ** As before, subsequent error messages are suppressed until + ** three input tokens have been successfully shifted. + */ + if( aapParser->aaerrcnt<=0 ){ + aa_syntax_error(aapParser,aamajor,aaminorunion); + } + aapParser->aaerrcnt = 3; + aa_destructor(aamajor,&aaminorunion); + if( aaendofinput ){ + aa_parse_failed(aapParser); + } + aamajor = AANOCODE; +#endif + }else{ + aa_accept(aapParser); + aamajor = AANOCODE; + } + }while( aamajor!=AANOCODE && aapParser->aaidx>=0 ); + return; } +/* base.c + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the + * LICENSE.txt file that was distributed with this source code. + */ -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchObjects) +const phannot_token_names phannot_tokens[] = { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval values, arguments; - zval *statement_param = NULL, *values_param = NULL, *className_param = NULL, *arguments_param = NULL, sth, _0; - zval statement, className; - zval *this_ptr = getThis(); + { "INTEGER", PHANNOT_T_INTEGER }, + { "DOUBLE", PHANNOT_T_DOUBLE }, + { "STRING", PHANNOT_T_STRING }, + { "IDENTIFIER", PHANNOT_T_IDENTIFIER }, + { "@", PHANNOT_T_AT }, + { ",", PHANNOT_T_COMMA }, + { "=", PHANNOT_T_EQUALS }, + { ":", PHANNOT_T_COLON }, + { "(", PHANNOT_T_PARENTHESES_OPEN }, + { ")", PHANNOT_T_PARENTHESES_CLOSE }, + { "{", PHANNOT_T_BRACKET_OPEN }, + { "}", PHANNOT_T_BRACKET_CLOSE }, + { "[", PHANNOT_T_SBRACKET_OPEN }, + { "]", PHANNOT_T_SBRACKET_CLOSE }, + { "ARBITRARY TEXT", PHANNOT_T_ARBITRARY_TEXT }, + { NULL, 0 } +}; - ZVAL_UNDEF(&statement); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&sth); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&arguments); - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_STR(statement) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(values) - Z_PARAM_STR(className) - Z_PARAM_ARRAY(arguments) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 3, &statement_param, &values_param, &className_param, &arguments_param); - zephir_get_strval(&statement, statement_param); - if (!values_param) { - ZEPHIR_INIT_VAR(&values); - array_init(&values); - } else { - zephir_get_arrval(&values, values_param); - } - if (!className_param) { - ZEPHIR_INIT_VAR(&className); - ZVAL_STRING(&className, "stdClass"); - } else { - zephir_get_strval(&className, className_param); - } - if (!arguments_param) { - ZEPHIR_INIT_VAR(&arguments); - array_init(&arguments); - } else { - zephir_get_arrval(&arguments, arguments_param); - } - ZEPHIR_CALL_METHOD(&sth, this_ptr, "perform", NULL, 0, &statement, &values); - zephir_check_call_status(); - ZVAL_LONG(&_0, 8); - ZEPHIR_RETURN_CALL_METHOD(&sth, "fetchall", NULL, 0, &_0, &className, &arguments); - zephir_check_call_status(); - RETURN_MM(); +static void *phannot_wrapper_alloc(size_t bytes){ + return emalloc(bytes); } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchOne) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval values, _0; - zval *statement_param = NULL, *values_param = NULL, _1; - zval statement; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&statement); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(statement) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(values) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &statement_param, &values_param); - zephir_get_strval(&statement, statement_param); - if (!values_param) { - ZEPHIR_INIT_VAR(&values); - array_init(&values); - } else { - zephir_get_arrval(&values, values_param); - } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 1, 0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_LONG(&_1, 2); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "fetch"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "fetchdata", NULL, 0, &_1, &_0, &statement, &values); - zephir_check_call_status(); - RETURN_MM(); +static void phannot_wrapper_free(void *pointer){ + efree(pointer); } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchPairs) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval values, _0; - zval *statement_param = NULL, *values_param = NULL, _1; - zval statement; - zval *this_ptr = getThis(); +static void phannot_parse_with_token(void* phannot_parser, int opcode, int parsercode, phannot_scanner_token *token, phannot_parser_status *parser_status){ - ZVAL_UNDEF(&statement); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(statement) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(values) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &statement_param, &values_param); - zephir_get_strval(&statement, statement_param); - if (!values_param) { - ZEPHIR_INIT_VAR(&values); - array_init(&values); - } else { - zephir_get_arrval(&values, values_param); - } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 1, 0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_LONG(&_1, 12); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "fetchAll"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "fetchdata", NULL, 0, &_1, &_0, &statement, &values); - zephir_check_call_status(); - RETURN_MM(); + phannot_parser_token *pToken; + + pToken = emalloc(sizeof(phannot_parser_token)); + pToken->opcode = opcode; + pToken->token = token->value; + pToken->token_len = token->len; + pToken->free_flag = 1; + + phannot_(phannot_parser, parsercode, pToken, parser_status); + + token->value = NULL; + token->len = 0; } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchValue) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval values; - zval *statement_param = NULL, *values_param = NULL, sth, _0; - zval statement; - zval *this_ptr = getThis(); +static void phannot_scanner_error_msg(phannot_parser_status *parser_status, char **error_msg){ - ZVAL_UNDEF(&statement); - ZVAL_UNDEF(&sth); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&values); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(statement) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(values) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &statement_param, &values_param); - zephir_get_strval(&statement, statement_param); - if (!values_param) { - ZEPHIR_INIT_VAR(&values); - array_init(&values); + phannot_scanner_state *state = parser_status->scanner_state; + + if (state->start) { + if (state->start_length > 16) { + spprintf(error_msg, 0, "Scanning error before '%.16s...' in %s on line %d", state->start, state->active_file, state->active_line); + } else { + spprintf(error_msg, 0, "Scanning error before '%s' in %s on line %d", state->start, state->active_file, state->active_line); + } } else { - zephir_get_arrval(&values, values_param); + spprintf(error_msg, 0, "Scanning error near to EOF in %s", state->active_file); } - ZEPHIR_CALL_METHOD(&sth, this_ptr, "perform", NULL, 0, &statement, &values); - zephir_check_call_status(); - ZVAL_LONG(&_0, 0); - ZEPHIR_RETURN_CALL_METHOD(&sth, "fetchcolumn", NULL, 0, &_0); - zephir_check_call_status(); - RETURN_MM(); } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, getAdapter) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); +static int phannot_parse_annotations(zval *result, zval *comment, zval *file_path, zval *line) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); - zephir_check_call_status(); - RETURN_MM_MEMBER(getThis(), "pdo"); -} + char *comment_str; + int comment_len; + char *file_path_str; + int line_num; -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, getAttribute) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *attribute_param = NULL, _0, _1; - zend_long attribute, ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + char *error_msg = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(attribute) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &attribute_param); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_1, attribute); - ZEPHIR_RETURN_CALL_METHOD(&_0, "getattribute", NULL, 0, &_1); - zephir_check_call_status(); - RETURN_MM(); -} + ZVAL_NULL(result); -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, getAvailableDrivers) -{ - zend_class_entry *_0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + if (Z_TYPE_P(comment) == IS_STRING) { + comment_str = Z_STRVAL_P(comment); + comment_len = Z_STRLEN_P(comment); + } else { + comment_str = ""; + comment_len = 0; + } - _0 = zephir_fetch_class_str_ex(SL("PDO"), ZEND_FETCH_CLASS_AUTO); - ZEPHIR_RETURN_CALL_CE_STATIC(_0, "getavailabledrivers", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} + if (Z_TYPE_P(file_path) == IS_STRING) { + file_path_str = Z_STRVAL_P(file_path); + } else { + file_path_str = "eval"; + } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, getDriverName) -{ - zval _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + if (Z_TYPE_P(line) == IS_LONG) { + line_num = Z_LVAL_P(line); + } else { + line_num = 0; + } - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + if (phannot_internal_parse_annotations(&result, comment_str, comment_len, file_path_str, line_num, &error_msg) == FAILURE) { + if (likely(error_msg != NULL)) { + zephir_throw_exception_string(phalcon_annotations_exception_ce, error_msg, strlen(error_msg)); + efree(error_msg); + } else { + zephir_throw_exception_string(phalcon_annotations_exception_ce, SL("There was an error parsing annotation")); + } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_1, 16); - ZEPHIR_RETURN_CALL_METHOD(&_0, "getattribute", NULL, 0, &_1); - zephir_check_call_status(); - RETURN_MM(); + return FAILURE; + } + + return SUCCESS; } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, getProfiler) +static void phannot_remove_comment_separators(char **ret, int *ret_len, const char *comment, int length, int *start_lines) { + char ch; + int start_mode = 1, j, i, open_parentheses; + smart_str processed_str = {0}; - RETURN_MEMBER(getThis(), "profiler"); -} + (*start_lines) = 0; -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, getQuoteNames) -{ - zval quotes; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *driver_param = NULL, option, _0$$5, _1$$6; - zval driver; - zval *this_ptr = getThis(); + for (i = 0; i < length; i++) { - ZVAL_UNDEF(&driver); - ZVAL_UNDEF(&option); - ZVAL_UNDEF(&_0$$5); - ZVAL_UNDEF(&_1$$6); - ZVAL_UNDEF("es); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_STR(driver) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &driver_param); - if (!driver_param) { - ZEPHIR_INIT_VAR(&driver); - ZVAL_STRING(&driver, ""); - } else { - zephir_get_strval(&driver, driver_param); - } - ZEPHIR_CPY_WRT(&option, &driver); - if (ZEPHIR_IS_EMPTY(&option)) { - ZEPHIR_CALL_METHOD(&option, this_ptr, "getdrivername", NULL, 0); - zephir_check_call_status(); - } - do { - if (ZEPHIR_IS_STRING(&option, "mysql")) { - ZEPHIR_INIT_VAR("es); - zephir_create_array("es, 4, 0); - add_assoc_stringl_ex("es, SL("prefix"), SL("`")); - add_assoc_stringl_ex("es, SL("suffix"), SL("`")); - add_assoc_stringl_ex("es, SL("find"), SL("`")); - add_assoc_stringl_ex("es, SL("replace"), SL("``")); - break; - } - if (ZEPHIR_IS_STRING(&option, "sqlsrv")) { - ZEPHIR_INIT_VAR(&_0$$5); - zephir_create_array(&_0$$5, 4, 0); - add_assoc_stringl_ex(&_0$$5, SL("prefix"), SL("[")); - add_assoc_stringl_ex(&_0$$5, SL("suffix"), SL("]")); - add_assoc_stringl_ex(&_0$$5, SL("find"), SL("]")); - add_assoc_stringl_ex(&_0$$5, SL("replace"), SL("][")); - ZEPHIR_CPY_WRT("es, &_0$$5); - break; + ch = comment[i]; + + if (start_mode) { + if (ch == ' ' || ch == '*' || ch == '/' || ch == '\t' || ch == 11) { + continue; + } + start_mode = 0; } - ZEPHIR_INIT_VAR(&_1$$6); - zephir_create_array(&_1$$6, 4, 0); - add_assoc_stringl_ex(&_1$$6, SL("prefix"), SL("\"")); - add_assoc_stringl_ex(&_1$$6, SL("suffix"), SL("\"")); - add_assoc_stringl_ex(&_1$$6, SL("find"), SL("\"")); - add_assoc_stringl_ex(&_1$$6, SL("replace"), SL("\"\"")); - ZEPHIR_CPY_WRT("es, &_1$$6); - break; - } while(0); - RETURN_CTOR("es); -} + if (ch == '@') { -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, inTransaction) -{ - zval result, _0, _1, _2, _3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + smart_str_appendc(&processed_str, ch); + i++; - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + open_parentheses = 0; + for (j = i; j < length; j++) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "inTransaction"); - ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); - zephir_check_call_status(); - zephir_read_property(&_2, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&result, &_2, "intransaction", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_3, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_3, "finish", NULL, 0); - zephir_check_call_status(); - RETURN_CCTOR(&result); -} + ch = comment[j]; -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, isConnected) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); + if (start_mode) { + if (ch == ' ' || ch == '*' || ch == '/' || ch == '\t' || ch == 11) { + continue; + } + start_mode = 0; + } - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + if (open_parentheses == 0) { - zephir_memory_observe(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC); - RETURN_MM_BOOL(zephir_get_boolval(&_0)); -} + if (isalnum(ch) || '_' == ch || '\\' == ch) { + smart_str_appendc(&processed_str, ch); + continue; + } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, lastInsertId) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, result, _0, _1, _2, _3; - zval name, _4; - zval *this_ptr = getThis(); + if (ch == '(') { + smart_str_appendc(&processed_str, ch); + open_parentheses++; + continue; + } - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &name_param); - if (!name_param) { - ZEPHIR_INIT_VAR(&name); - } else { - zephir_get_strval(&name, name_param); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "lastInsertId"); - ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); - zephir_check_call_status(); - zephir_read_property(&_2, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&result, &_2, "lastinsertid", NULL, 0, &name); - zephir_check_call_status(); - zephir_read_property(&_3, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_3, "finish", NULL, 0); - zephir_check_call_status(); - zephir_cast_to_string(&_4, &result); - RETURN_CTOR(&_4); -} + } else { -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, perform) -{ - zend_string *_5; - zend_ulong _4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_6 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval values; - zval *statement_param = NULL, *values_param = NULL, name, sth, value, _0, _1, *_2, _3, _7; - zval statement; - zval *this_ptr = getThis(); + smart_str_appendc(&processed_str, ch); - ZVAL_UNDEF(&statement); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&sth); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&values); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(statement) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(values) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &statement_param, &values_param); - zephir_get_strval(&statement, statement_param); - if (!values_param) { - ZEPHIR_INIT_VAR(&values); - array_init(&values); - } else { - zephir_get_arrval(&values, values_param); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "perform"); - ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&sth, this_ptr, "prepare", NULL, 0, &statement); - zephir_check_call_status(); - zephir_is_iterable(&values, 0, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 579); - if (Z_TYPE_P(&values) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&values), _4, _5, _2) - { - ZEPHIR_INIT_NVAR(&name); - if (_5 != NULL) { - ZVAL_STR_COPY(&name, _5); - } else { - ZVAL_LONG(&name, _4); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _2); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "performbind", &_6, 0, &sth, &name, &value); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &values, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3)) { + if (ch == '(') { + open_parentheses++; + } else { + if (ch == ')') { + open_parentheses--; + } else { + if (ch == '\n') { + (*start_lines)++; + start_mode = 1; + } + } + } + + if (open_parentheses > 0) { + continue; + } + } + + i = j; + smart_str_appendc(&processed_str, ' '); break; } - ZEPHIR_CALL_METHOD(&name, &values, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "performbind", &_6, 0, &sth, &name, &value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); - zephir_check_call_status(); + } + + if (ch == '\n') { + (*start_lines)++; + start_mode = 1; } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&name); - ZEPHIR_CALL_METHOD(NULL, &sth, "execute", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_7, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_7, "finish", NULL, 0, &statement, &values); - zephir_check_call_status(); - RETURN_CCTOR(&sth); -} -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, prepare) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval *statement_param = NULL, *options_param = NULL, sth, _0, _1, _2, _3, _4; - zval statement; - zval *this_ptr = getThis(); + smart_str_0(&processed_str); - ZVAL_UNDEF(&statement); - ZVAL_UNDEF(&sth); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(statement) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &statement_param, &options_param); - zephir_get_strval(&statement, statement_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); + if (processed_str.s) { + *ret = estrndup(ZSTR_VAL(processed_str.s), ZSTR_LEN(processed_str.s)); + *ret_len = ZSTR_LEN(processed_str.s); + smart_str_free(&processed_str); } else { - zephir_get_arrval(&options, options_param); + *ret = NULL; + *ret_len = 0; } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "prepare"); - ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); - zephir_check_call_status(); - zephir_read_property(&_2, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&sth, &_2, "prepare", NULL, 0, &statement, &options); - zephir_check_call_status(); - zephir_read_property(&_3, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_4, &sth, ZEND_STRL("queryString"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_3, "finish", NULL, 0, &_4); - zephir_check_call_status(); - RETURN_CCTOR(&sth); } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, query) +static int phannot_internal_parse_annotations(zval **result, const char *comment, int comment_len, const char *file_path, int line, char **error_msg) { - zval _2; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *statement_param = NULL, sth, _0, _1, _3, _4, _5; - zval statement; - zval *this_ptr = getThis(); + phannot_scanner_state *state; + phannot_scanner_token token; + int start_lines; + int scanner_status, status = SUCCESS; + phannot_parser_status *parser_status = NULL; + void* phannot_parser; + char *processed_comment; + int processed_comment_len; - ZVAL_UNDEF(&statement); - ZVAL_UNDEF(&sth); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(statement) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &statement_param); - zephir_get_strval(&statement, statement_param); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "query"); - ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 2, 0); - zephir_memory_observe(&_3); - zephir_read_property(&_3, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC); - zephir_array_fast_append(&_2, &_3); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "query"); - zephir_array_fast_append(&_2, &_1); - ZEPHIR_INIT_NVAR(&_1); - zephir_get_args(&_1); - ZEPHIR_INIT_VAR(&sth); - ZEPHIR_CALL_USER_FUNC_ARRAY(&sth, &_2, &_1); - zephir_check_call_status(); - zephir_read_property(&_4, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_5, &sth, ZEND_STRL("queryString"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_4, "finish", NULL, 0, &_5); - zephir_check_call_status(); - RETURN_CCTOR(&sth); -} + *error_msg = NULL; -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, quote) -{ - zval _0$$3, _7$$4, _11$$5; - zend_string *_6; - zend_ulong _5; - zval elements; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *value, value_sub, *type_param = NULL, element, key, quotes, *_3, _4, _1$$3, _2$$3, _8$$4, _9$$4, _10$$4, _12$$5, _13$$5, _14$$5; - zval *this_ptr = getThis(); + if (UNEXPECTED(!comment)) { + ZVAL_BOOL(*result, 0); + spprintf(error_msg, 0, "Empty annotation"); + return FAILURE; + } - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&key); - ZVAL_UNDEF("es); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_10$$4); - ZVAL_UNDEF(&_12$$5); - ZVAL_UNDEF(&_13$$5); - ZVAL_UNDEF(&_14$$5); - ZVAL_UNDEF(&elements); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_11$$5); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(value) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(type) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &value, &type_param); - if (!type_param) { - type = 2; - } else { + if (comment_len < 2) { + ZVAL_BOOL(*result, 0); + return SUCCESS; + } + + phannot_remove_comment_separators(&processed_comment, &processed_comment_len, comment, comment_len, &start_lines); + + if (processed_comment_len < 2) { + ZVAL_BOOL(*result, 0); + if (processed_comment) { + efree(processed_comment); } - ZEPHIR_INIT_VAR(&elements); - array_init(&elements); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&element, value); - ZEPHIR_CALL_METHOD("es, this_ptr, "getquotenames", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&element) != IS_ARRAY) { - zephir_cast_to_string(&_0$$3, &element); - ZEPHIR_CPY_WRT(&element, &_0$$3); - zephir_array_fetch_string(&_1$$3, "es, SL("prefix"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 664); - zephir_array_fetch_string(&_2$$3, "es, SL("suffix"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 664); - ZEPHIR_CONCAT_VVV(return_value, &_1$$3, &element, &_2$$3); - RETURN_MM(); + + return SUCCESS; } - zephir_is_iterable(value, 0, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 673); - if (Z_TYPE_P(value) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(value), _5, _6, _3) - { - ZEPHIR_INIT_NVAR(&key); - if (_6 != NULL) { - ZVAL_STR_COPY(&key, _6); - } else { - ZVAL_LONG(&key, _5); - } - ZEPHIR_INIT_NVAR(&element); - ZVAL_COPY(&element, _3); - zephir_cast_to_string(&_7$$4, &element); - ZEPHIR_CPY_WRT(&element, &_7$$4); - zephir_array_fetch_string(&_8$$4, "es, SL("prefix"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 670); - zephir_array_fetch_string(&_9$$4, "es, SL("suffix"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 670); - ZEPHIR_INIT_NVAR(&_10$$4); - ZEPHIR_CONCAT_VVV(&_10$$4, &_8$$4, &element, &_9$$4); - zephir_array_update_zval(&elements, &key, &_10$$4, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); + + phannot_parser = phannot_Alloc(phannot_wrapper_alloc); + if (unlikely(!phannot_parser)) { + ZVAL_BOOL(*result, 0); + return FAILURE; + } + + parser_status = emalloc(sizeof(phannot_parser_status) + sizeof(phannot_scanner_state)); + state = (phannot_scanner_state*)((char*)parser_status + sizeof(phannot_parser_status)); + + parser_status->status = PHANNOT_PARSING_OK; + parser_status->scanner_state = state; + parser_status->token = &token; + parser_status->syntax_error = NULL; + + state->active_token = 0; + state->start = processed_comment; + state->start_length = 0; + state->mode = PHANNOT_MODE_RAW; + state->active_file = file_path; + + token.value = NULL; + token.len = 0; + + if (line) { + state->active_line = line - start_lines; } else { - ZEPHIR_CALL_METHOD(NULL, value, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_4, value, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_4)) { - break; - } - ZEPHIR_CALL_METHOD(&key, value, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&element, value, "current", NULL, 0); - zephir_check_call_status(); - zephir_cast_to_string(&_11$$5, &element); - ZEPHIR_CPY_WRT(&element, &_11$$5); - zephir_array_fetch_string(&_12$$5, "es, SL("prefix"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 670); - zephir_array_fetch_string(&_13$$5, "es, SL("suffix"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 670); - ZEPHIR_INIT_NVAR(&_14$$5); - ZEPHIR_CONCAT_VVV(&_14$$5, &_12$$5, &element, &_13$$5); - zephir_array_update_zval(&elements, &key, &_14$$5, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, value, "next", NULL, 0); - zephir_check_call_status(); - } + state->active_line = 1; } - ZEPHIR_INIT_NVAR(&element); - ZEPHIR_INIT_NVAR(&key); - zephir_fast_join_str(return_value, SL(", "), &elements); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, rollBack) -{ - zval result, _0, _1, _2, _3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + state->end = state->start; - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + while(0 <= (scanner_status = phannot_get_token(state, &token))) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "rollBack"); - ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); - zephir_check_call_status(); - zephir_read_property(&_2, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&result, &_2, "rollback", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_3, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_3, "finish", NULL, 0); - zephir_check_call_status(); - RETURN_CCTOR(&result); -} + state->active_token = token.opcode; -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, setAttribute) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *attribute_param = NULL, *value, value_sub, _0, _1; - zend_long attribute, ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + state->start_length = processed_comment + processed_comment_len - state->start; - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_LONG(attribute) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &attribute_param, &value); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_1, attribute); - ZEPHIR_RETURN_CALL_METHOD(&_0, "setattribute", NULL, 0, &_1, value); - zephir_check_call_status(); - RETURN_MM(); -} + switch (token.opcode) { -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, setProfiler) -{ - zval *profiler, profiler_sub; - zval *this_ptr = getThis(); + case PHANNOT_T_IGNORE: + break; - ZVAL_UNDEF(&profiler_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(profiler, phalcon_datamapper_pdo_profiler_profilerinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &profiler); - zephir_update_property_zval(this_ptr, ZEND_STRL("profiler"), profiler); -} + case PHANNOT_T_AT: + phannot_(phannot_parser, PHANNOT_AT, NULL, parser_status); + break; + case PHANNOT_T_COMMA: + phannot_(phannot_parser, PHANNOT_COMMA, NULL, parser_status); + break; + case PHANNOT_T_EQUALS: + phannot_(phannot_parser, PHANNOT_EQUALS, NULL, parser_status); + break; + case PHANNOT_T_COLON: + phannot_(phannot_parser, PHANNOT_COLON, NULL, parser_status); + break; -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, performBind) -{ - zend_bool _1$$4; - zval _8, _5$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, _0$$3; - zval *statement, statement_sub, *name, name_sub, *arguments, arguments_sub, key, parameters, type, _7, _9, _2$$4, _3$$7, _4$$7, _6$$8; + case PHANNOT_T_PARENTHESES_OPEN: + phannot_(phannot_parser, PHANNOT_PARENTHESES_OPEN, NULL, parser_status); + break; + case PHANNOT_T_PARENTHESES_CLOSE: + phannot_(phannot_parser, PHANNOT_PARENTHESES_CLOSE, NULL, parser_status); + break; - ZVAL_UNDEF(&statement_sub); - ZVAL_UNDEF(&name_sub); - ZVAL_UNDEF(&arguments_sub); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(¶meters); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$7); - ZVAL_UNDEF(&_4$$7); - ZVAL_UNDEF(&_6$$8); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_5$$4); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_OBJECT_OF_CLASS(statement, zephir_get_internal_ce(SL("pdostatement"))) - Z_PARAM_ZVAL(name) - Z_PARAM_ZVAL(arguments) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &statement, &name, &arguments); - ZEPHIR_SEPARATE_PARAM(arguments); - ZEPHIR_CPY_WRT(&key, name); - if (Z_TYPE_P(&key) == IS_LONG) { - _0$$3 = (zephir_get_numberval(&key) + 1); - ZEPHIR_INIT_NVAR(&key); - ZVAL_LONG(&key, _0$$3); - } - if (Z_TYPE_P(arguments) == IS_ARRAY) { - if (zephir_array_isset_long(arguments, 1)) { - zephir_memory_observe(&type); - zephir_array_fetch_long(&type, arguments, 1, PH_NOISY, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 743); - } else { - ZEPHIR_INIT_NVAR(&type); - ZVAL_LONG(&type, 2); - } - _1$$4 = ZEPHIR_IS_LONG_IDENTICAL(&type, 5); - if (_1$$4) { - zephir_memory_observe(&_2$$4); - zephir_array_fetch_long(&_2$$4, arguments, 0, PH_NOISY, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 748); - _1$$4 = ((Z_TYPE_P(&_2$$4) == IS_TRUE || Z_TYPE_P(&_2$$4) == IS_FALSE) == 1); - } - if (_1$$4) { - ZEPHIR_INIT_VAR(&_3$$7); - zephir_array_fetch_long(&_4$$7, arguments, 0, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 749); - if (zephir_is_true(&_4$$7)) { - ZEPHIR_INIT_NVAR(&_3$$7); - ZVAL_STRING(&_3$$7, "1"); - } else { - ZEPHIR_INIT_NVAR(&_3$$7); - ZVAL_STRING(&_3$$7, "0"); - } - zephir_array_update_long(arguments, 0, &_3$$7, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + case PHANNOT_T_BRACKET_OPEN: + phannot_(phannot_parser, PHANNOT_BRACKET_OPEN, NULL, parser_status); + break; + case PHANNOT_T_BRACKET_CLOSE: + phannot_(phannot_parser, PHANNOT_BRACKET_CLOSE, NULL, parser_status); + break; + + case PHANNOT_T_SBRACKET_OPEN: + phannot_(phannot_parser, PHANNOT_SBRACKET_OPEN, NULL, parser_status); + break; + case PHANNOT_T_SBRACKET_CLOSE: + phannot_(phannot_parser, PHANNOT_SBRACKET_CLOSE, NULL, parser_status); + break; + + case PHANNOT_T_NULL: + phannot_(phannot_parser, PHANNOT_NULL, NULL, parser_status); + break; + case PHANNOT_T_TRUE: + phannot_(phannot_parser, PHANNOT_TRUE, NULL, parser_status); + break; + case PHANNOT_T_FALSE: + phannot_(phannot_parser, PHANNOT_FALSE, NULL, parser_status); + break; + + case PHANNOT_T_INTEGER: + phannot_parse_with_token(phannot_parser, PHANNOT_T_INTEGER, PHANNOT_INTEGER, &token, parser_status); + break; + case PHANNOT_T_DOUBLE: + phannot_parse_with_token(phannot_parser, PHANNOT_T_DOUBLE, PHANNOT_DOUBLE, &token, parser_status); + break; + case PHANNOT_T_STRING: + phannot_parse_with_token(phannot_parser, PHANNOT_T_STRING, PHANNOT_STRING, &token, parser_status); + break; + case PHANNOT_T_IDENTIFIER: + phannot_parse_with_token(phannot_parser, PHANNOT_T_IDENTIFIER, PHANNOT_IDENTIFIER, &token, parser_status); + break; + /*case PHANNOT_T_ARBITRARY_TEXT: + phannot_parse_with_token(phannot_parser, PHANNOT_T_ARBITRARY_TEXT, PHANNOT_ARBITRARY_TEXT, &token, parser_status); + break;*/ + + default: + parser_status->status = PHANNOT_PARSING_FAILED; + if (!*error_msg) { + spprintf(error_msg, 0, "Scanner: unknown opcode %d on in %s line %d", token.opcode, state->active_file, state->active_line); + } + break; } - ZEPHIR_INIT_VAR(&_5$$4); - zephir_create_array(&_5$$4, 1, 0); - zephir_array_fast_append(&_5$$4, &key); - ZEPHIR_INIT_VAR(¶meters); - zephir_fast_array_merge(¶meters, &_5$$4, arguments); - } else { - ZEPHIR_INIT_VAR(&_6$$8); - zephir_create_array(&_6$$8, 2, 0); - zephir_array_fast_append(&_6$$8, &key); - zephir_array_fast_append(&_6$$8, arguments); - ZEPHIR_CPY_WRT(¶meters, &_6$$8); - } - ZEPHIR_INIT_VAR(&_7); - ZEPHIR_INIT_VAR(&_8); - zephir_create_array(&_8, 2, 0); - zephir_array_fast_append(&_8, statement); - ZEPHIR_INIT_VAR(&_9); - ZVAL_STRING(&_9, "bindValue"); - zephir_array_fast_append(&_8, &_9); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_7, &_8, ¶meters); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchData) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval arguments, values, _0; - zval *method_param = NULL, *arguments_param = NULL, *statement_param = NULL, *values_param = NULL, result, sth; - zval method, statement; - zval *this_ptr = getThis(); + if (parser_status->status != PHANNOT_PARSING_OK) { + status = FAILURE; + break; + } - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&statement); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&sth); - ZVAL_UNDEF(&arguments); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(3, 4) - Z_PARAM_STR(method) - Z_PARAM_ARRAY(arguments) - Z_PARAM_STR(statement) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(values) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 1, &method_param, &arguments_param, &statement_param, &values_param); - zephir_get_strval(&method, method_param); - zephir_get_arrval(&arguments, arguments_param); - zephir_get_strval(&statement, statement_param); - if (!values_param) { - ZEPHIR_INIT_VAR(&values); - array_init(&values); - } else { - zephir_get_arrval(&values, values_param); - } - ZEPHIR_CALL_METHOD(&sth, this_ptr, "perform", NULL, 0, &statement, &values); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 2, 0); - zephir_array_fast_append(&_0, &sth); - zephir_array_fast_append(&_0, &method); - ZEPHIR_INIT_VAR(&result); - ZEPHIR_CALL_USER_FUNC_ARRAY(&result, &_0, &arguments); - zephir_check_call_status(); - if (Z_TYPE_P(&result) != IS_ARRAY) { - ZEPHIR_INIT_NVAR(&result); - array_init(&result); + state->end = state->start; } - RETURN_CCTOR(&result); -} - + if (status != FAILURE) { + switch (scanner_status) { + case PHANNOT_SCANNER_RETCODE_ERR: + case PHANNOT_SCANNER_RETCODE_IMPOSSIBLE: + if (!*error_msg) { + phannot_scanner_error_msg(parser_status, error_msg); + } + status = FAILURE; + break; -#ifdef HAVE_CONFIG_H -#endif + default: + phannot_(phannot_parser, 0, NULL, parser_status); + } + } + state->active_token = 0; + state->start = NULL; + if (parser_status->status != PHANNOT_PARSING_OK) { + status = FAILURE; + if (parser_status->syntax_error) { + if (!*error_msg) { + *error_msg = parser_status->syntax_error; + } else { + efree(parser_status->syntax_error); + } + } + } + phannot_Free(phannot_parser, phannot_wrapper_free); + if (status != FAILURE) { + if (parser_status->status == PHANNOT_PARSING_OK) { + ZVAL_ZVAL(*result, &parser_status->ret, 1, 1); + } + } -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\DataMapper\\Pdo\\Connection, ConnectionInterface, phalcon, datamapper_pdo_connection_connectioninterface, phalcon_datamapper_pdo_connection_connectioninterface_method_entry); + efree(processed_comment); + efree(parser_status); - zend_class_implements(phalcon_datamapper_pdo_connection_connectioninterface_ce, 1, phalcon_datamapper_pdo_connection_pdointerface_ce); - return SUCCESS; + return status; } -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, connect); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, disconnect); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchAffected); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchAll); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchAssoc); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchColumn); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchGroup); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchObject); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchObjects); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchOne); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchPairs); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchValue); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, getAdapter); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, getProfiler); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, isConnected); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, perform); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, setProfiler); - #ifdef HAVE_CONFIG_H @@ -109129,60 +107796,324 @@ ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, setProf -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Connection_Decorated) +ZEPHIR_INIT_CLASS(Phalcon_Annotations_Reader) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Pdo\\Connection, Decorated, phalcon, datamapper_pdo_connection_decorated, phalcon_datamapper_pdo_connection_abstractconnection_ce, phalcon_datamapper_pdo_connection_decorated_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Annotations, Reader, phalcon, annotations_reader, phalcon_annotations_reader_method_entry, 0); + zend_class_implements(phalcon_annotations_reader_ce, 1, phalcon_annotations_readerinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_Decorated, __construct) +static PHP_METHOD(Phalcon_Annotations_Reader, parse) +{ + zval annotations; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, line = 0; + zval *className_param = NULL, reflection, comment, arrayKeys, classAnnotations, properties, property, annotationsProperties, propertyAnnotations, methods, method, annotationsMethods, methodAnnotations, constants, constant, anotationsConstants, constantAnnotations, constantReflection, _0$$3, _1$$3, *_2$$5, _3$$5, _5$$7, _6$$7, _7$$10, _8$$10, *_9$$13, _10$$13, _11$$15, _12$$15, _13$$16, _14$$18, _15$$18, _16$$19, *_17$$21, _18$$21, _19$$23, _20$$23, _21$$24, _22$$26, _23$$26, _24$$27; + zval className; + + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&reflection); + ZVAL_UNDEF(&comment); + ZVAL_UNDEF(&arrayKeys); + ZVAL_UNDEF(&classAnnotations); + ZVAL_UNDEF(&properties); + ZVAL_UNDEF(&property); + ZVAL_UNDEF(&annotationsProperties); + ZVAL_UNDEF(&propertyAnnotations); + ZVAL_UNDEF(&methods); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&annotationsMethods); + ZVAL_UNDEF(&methodAnnotations); + ZVAL_UNDEF(&constants); + ZVAL_UNDEF(&constant); + ZVAL_UNDEF(&anotationsConstants); + ZVAL_UNDEF(&constantAnnotations); + ZVAL_UNDEF(&constantReflection); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_7$$10); + ZVAL_UNDEF(&_8$$10); + ZVAL_UNDEF(&_10$$13); + ZVAL_UNDEF(&_11$$15); + ZVAL_UNDEF(&_12$$15); + ZVAL_UNDEF(&_13$$16); + ZVAL_UNDEF(&_14$$18); + ZVAL_UNDEF(&_15$$18); + ZVAL_UNDEF(&_16$$19); + ZVAL_UNDEF(&_18$$21); + ZVAL_UNDEF(&_19$$23); + ZVAL_UNDEF(&_20$$23); + ZVAL_UNDEF(&_21$$24); + ZVAL_UNDEF(&_22$$26); + ZVAL_UNDEF(&_23$$26); + ZVAL_UNDEF(&_24$$27); + ZVAL_UNDEF(&annotations); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(className) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &className_param); + zephir_get_strval(&className, className_param); + ZEPHIR_INIT_VAR(&annotations); + array_init(&annotations); + ZEPHIR_INIT_VAR(&reflection); + object_init_ex(&reflection, zephir_get_internal_ce(SL("reflectionclass"))); + ZEPHIR_CALL_METHOD(NULL, &reflection, "__construct", NULL, 154, &className); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&comment, &reflection, "getdoccomment", NULL, 160); + zephir_check_call_status(); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&comment)) { + ZEPHIR_INIT_VAR(&classAnnotations); + ZEPHIR_CALL_METHOD(&_0$$3, &reflection, "getfilename", NULL, 161); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1$$3, &reflection, "getstartline", NULL, 162); + zephir_check_call_status(); + ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(&classAnnotations, &comment, &_0$$3, &_1$$3); + zephir_check_call_status(); + if (Z_TYPE_P(&classAnnotations) == IS_ARRAY) { + zephir_array_update_string(&annotations, SL("class"), &classAnnotations, PH_COPY | PH_SEPARATE); + } + } + ZEPHIR_CALL_METHOD(&constants, &reflection, "getconstants", NULL, 163); + zephir_check_call_status(); + if (zephir_fast_count_int(&constants)) { + line = 1; + ZEPHIR_INIT_VAR(&arrayKeys); + zephir_array_keys(&arrayKeys, &constants); + ZEPHIR_INIT_VAR(&anotationsConstants); + array_init(&anotationsConstants); + zephir_is_iterable(&arrayKeys, 0, "phalcon/Annotations/Reader.zep", 92); + if (Z_TYPE_P(&arrayKeys) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&arrayKeys), _2$$5) + { + ZEPHIR_INIT_NVAR(&constant); + ZVAL_COPY(&constant, _2$$5); + ZEPHIR_CALL_METHOD(&constantReflection, &reflection, "getreflectionconstant", &_4, 164, &constant); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&comment, &constantReflection, "getdoccomment", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&comment)) { + ZEPHIR_INIT_NVAR(&constantAnnotations); + ZEPHIR_CALL_METHOD(&_5$$7, &reflection, "getfilename", NULL, 161); + zephir_check_call_status(); + ZVAL_LONG(&_6$$7, line); + ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(&constantAnnotations, &comment, &_5$$7, &_6$$7); + zephir_check_call_status(); + if (Z_TYPE_P(&constantAnnotations) == IS_ARRAY) { + zephir_array_update_zval(&anotationsConstants, &constant, &constantAnnotations, PH_COPY | PH_SEPARATE); + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &arrayKeys, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3$$5, &arrayKeys, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3$$5)) { + break; + } + ZEPHIR_CALL_METHOD(&constant, &arrayKeys, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&constantReflection, &reflection, "getreflectionconstant", &_4, 164, &constant); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&comment, &constantReflection, "getdoccomment", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&comment)) { + ZEPHIR_INIT_NVAR(&constantAnnotations); + ZEPHIR_CALL_METHOD(&_7$$10, &reflection, "getfilename", NULL, 161); + zephir_check_call_status(); + ZVAL_LONG(&_8$$10, line); + ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(&constantAnnotations, &comment, &_7$$10, &_8$$10); + zephir_check_call_status(); + if (Z_TYPE_P(&constantAnnotations) == IS_ARRAY) { + zephir_array_update_zval(&anotationsConstants, &constant, &constantAnnotations, PH_COPY | PH_SEPARATE); + } + } + ZEPHIR_CALL_METHOD(NULL, &arrayKeys, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&constant); + if (zephir_fast_count_int(&anotationsConstants)) { + zephir_array_update_string(&annotations, SL("constants"), &anotationsConstants, PH_COPY | PH_SEPARATE); + } + } + ZEPHIR_CALL_METHOD(&properties, &reflection, "getproperties", NULL, 165); + zephir_check_call_status(); + if (zephir_fast_count_int(&properties)) { + line = 1; + ZEPHIR_INIT_VAR(&annotationsProperties); + array_init(&annotationsProperties); + zephir_is_iterable(&properties, 0, "phalcon/Annotations/Reader.zep", 130); + if (Z_TYPE_P(&properties) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&properties), _9$$13) + { + ZEPHIR_INIT_NVAR(&property); + ZVAL_COPY(&property, _9$$13); + ZEPHIR_CALL_METHOD(&comment, &property, "getdoccomment", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&comment)) { + ZEPHIR_INIT_NVAR(&propertyAnnotations); + ZEPHIR_CALL_METHOD(&_11$$15, &reflection, "getfilename", NULL, 161); + zephir_check_call_status(); + ZVAL_LONG(&_12$$15, line); + ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(&propertyAnnotations, &comment, &_11$$15, &_12$$15); + zephir_check_call_status(); + if (Z_TYPE_P(&propertyAnnotations) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&_13$$16); + zephir_read_property(&_13$$16, &property, ZEND_STRL("name"), PH_NOISY_CC); + zephir_array_update_zval(&annotationsProperties, &_13$$16, &propertyAnnotations, PH_COPY | PH_SEPARATE); + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &properties, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_10$$13, &properties, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_10$$13)) { + break; + } + ZEPHIR_CALL_METHOD(&property, &properties, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&comment, &property, "getdoccomment", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&comment)) { + ZEPHIR_INIT_NVAR(&propertyAnnotations); + ZEPHIR_CALL_METHOD(&_14$$18, &reflection, "getfilename", NULL, 161); + zephir_check_call_status(); + ZVAL_LONG(&_15$$18, line); + ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(&propertyAnnotations, &comment, &_14$$18, &_15$$18); + zephir_check_call_status(); + if (Z_TYPE_P(&propertyAnnotations) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&_16$$19); + zephir_read_property(&_16$$19, &property, ZEND_STRL("name"), PH_NOISY_CC); + zephir_array_update_zval(&annotationsProperties, &_16$$19, &propertyAnnotations, PH_COPY | PH_SEPARATE); + } + } + ZEPHIR_CALL_METHOD(NULL, &properties, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&property); + if (zephir_fast_count_int(&annotationsProperties)) { + zephir_array_update_string(&annotations, SL("properties"), &annotationsProperties, PH_COPY | PH_SEPARATE); + } + } + ZEPHIR_CALL_METHOD(&methods, &reflection, "getmethods", NULL, 166); + zephir_check_call_status(); + if (0 == ZEPHIR_IS_EMPTY(&methods)) { + ZEPHIR_INIT_VAR(&annotationsMethods); + array_init(&annotationsMethods); + zephir_is_iterable(&methods, 0, "phalcon/Annotations/Reader.zep", 164); + if (Z_TYPE_P(&methods) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&methods), _17$$21) + { + ZEPHIR_INIT_NVAR(&method); + ZVAL_COPY(&method, _17$$21); + ZEPHIR_CALL_METHOD(&comment, &method, "getdoccomment", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&comment)) { + ZEPHIR_INIT_NVAR(&methodAnnotations); + ZEPHIR_CALL_METHOD(&_19$$23, &method, "getfilename", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_20$$23, &method, "getstartline", NULL, 0); + zephir_check_call_status(); + ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(&methodAnnotations, &comment, &_19$$23, &_20$$23); + zephir_check_call_status(); + if (Z_TYPE_P(&methodAnnotations) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&_21$$24); + zephir_read_property(&_21$$24, &method, ZEND_STRL("name"), PH_NOISY_CC); + zephir_array_update_zval(&annotationsMethods, &_21$$24, &methodAnnotations, PH_COPY | PH_SEPARATE); + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &methods, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_18$$21, &methods, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_18$$21)) { + break; + } + ZEPHIR_CALL_METHOD(&method, &methods, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&comment, &method, "getdoccomment", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&comment)) { + ZEPHIR_INIT_NVAR(&methodAnnotations); + ZEPHIR_CALL_METHOD(&_22$$26, &method, "getfilename", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_23$$26, &method, "getstartline", NULL, 0); + zephir_check_call_status(); + ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(&methodAnnotations, &comment, &_22$$26, &_23$$26); + zephir_check_call_status(); + if (Z_TYPE_P(&methodAnnotations) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&_24$$27); + zephir_read_property(&_24$$27, &method, ZEND_STRL("name"), PH_NOISY_CC); + zephir_array_update_zval(&annotationsMethods, &_24$$27, &methodAnnotations, PH_COPY | PH_SEPARATE); + } + } + ZEPHIR_CALL_METHOD(NULL, &methods, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&method); + if (zephir_fast_count_int(&annotationsMethods)) { + zephir_array_update_string(&annotations, SL("methods"), &annotationsMethods, PH_COPY | PH_SEPARATE); + } + } + RETURN_CTOR(&annotations); +} + +static PHP_METHOD(Phalcon_Annotations_Reader, parseDocBlock) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pdo, pdo_sub, *profiler = NULL, profiler_sub, __$null; - zval *this_ptr = getThis(); + zval *docBlock_param = NULL, *file = NULL, file_sub, *line = NULL, line_sub, __$null; + zval docBlock; - ZVAL_UNDEF(&pdo_sub); - ZVAL_UNDEF(&profiler_sub); + ZVAL_UNDEF(&docBlock); + ZVAL_UNDEF(&file_sub); + ZVAL_UNDEF(&line_sub); ZVAL_NULL(&__$null); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(pdo, php_pdo_get_dbh_ce()) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(docBlock) Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(profiler, phalcon_datamapper_pdo_profiler_profilerinterface_ce) + Z_PARAM_ZVAL_OR_NULL(file) + Z_PARAM_ZVAL_OR_NULL(line) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &pdo, &profiler); - if (!profiler) { - profiler = &profiler_sub; - ZEPHIR_CPY_WRT(profiler, &__$null); + zephir_fetch_params(1, 1, 2, &docBlock_param, &file, &line); + zephir_get_strval(&docBlock, docBlock_param); + if (!file) { + file = &file_sub; + ZEPHIR_CPY_WRT(file, &__$null); } else { - ZEPHIR_SEPARATE_PARAM(profiler); + ZEPHIR_SEPARATE_PARAM(file); } - zephir_update_property_zval(this_ptr, ZEND_STRL("pdo"), pdo); - if (Z_TYPE_P(profiler) == IS_NULL) { - ZEPHIR_INIT_NVAR(profiler); - object_init_ex(profiler, phalcon_datamapper_pdo_profiler_profiler_ce); - ZEPHIR_CALL_METHOD(NULL, profiler, "__construct", NULL, 201); - zephir_check_call_status(); + if (!line) { + line = &line_sub; + line = &__$null; } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setprofiler", NULL, 0, profiler); + if (Z_TYPE_P(file) != IS_STRING) { + ZEPHIR_INIT_NVAR(file); + ZVAL_STRING(file, "eval code"); + } + ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(return_value, &docBlock, file, line); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_Decorated, connect) -{ - -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_Decorated, disconnect) -{ - - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_datamapper_pdo_exception_cannotdisconnect_ce, "Cannot disconnect a Decorated connection instance", "phalcon/DataMapper/Pdo/Connection/Decorated.zep", 66); - return; + RETURN_MM(); } @@ -109195,27 +108126,15 @@ static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_Decorated, disconnect) -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Connection_PdoInterface) +ZEPHIR_INIT_CLASS(Phalcon_Annotations_ReaderInterface) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\DataMapper\\Pdo\\Connection, PdoInterface, phalcon, datamapper_pdo_connection_pdointerface, phalcon_datamapper_pdo_connection_pdointerface_method_entry); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Annotations, ReaderInterface, phalcon, annotations_readerinterface, phalcon_annotations_readerinterface_method_entry); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, beginTransaction); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, commit); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, errorCode); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, errorInfo); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, exec); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, getAttribute); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, getAvailableDrivers); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, inTransaction); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, lastInsertId); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, prepare); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, query); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, quote); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, rollBack); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, setAttribute); +ZEPHIR_DOC_METHOD(Phalcon_Annotations_ReaderInterface, parse); +ZEPHIR_DOC_METHOD(Phalcon_Annotations_ReaderInterface, parseDocBlock); @@ -109226,419 +108145,320 @@ ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, setAttribute); -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger) +ZEPHIR_INIT_CLASS(Phalcon_Annotations_Reflection) { - ZEPHIR_REGISTER_CLASS(Phalcon\\DataMapper\\Pdo\\Profiler, MemoryLogger, phalcon, datamapper_pdo_profiler_memorylogger, phalcon_datamapper_pdo_profiler_memorylogger_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Annotations, Reflection, phalcon, annotations_reflection, phalcon_annotations_reflection_method_entry, 0); - zend_declare_property_null(phalcon_datamapper_pdo_profiler_memorylogger_ce, SL("messages"), ZEND_ACC_PROTECTED); - phalcon_datamapper_pdo_profiler_memorylogger_ce->create_object = zephir_init_properties_Phalcon_DataMapper_Pdo_Profiler_MemoryLogger; + zend_declare_property_null(phalcon_annotations_reflection_ce, SL("classAnnotations"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_annotations_reflection_ce, SL("constantAnnotations"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_annotations_reflection_ce, SL("propertyAnnotations"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_annotations_reflection_ce, SL("methodAnnotations"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_annotations_reflection_ce, SL("reflectionData"), ZEND_ACC_PROTECTED); + phalcon_annotations_reflection_ce->create_object = zephir_init_properties_Phalcon_Annotations_Reflection; - zend_class_implements(phalcon_datamapper_pdo_profiler_memorylogger_ce, 1, phalcon_logger_loggerinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, alert) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval context; - zval *message_param = NULL, *context_param = NULL, _0; - zval message; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); - } else { - zephir_get_arrval(&context, context_param); - } - ZVAL_LONG(&_0, 2); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, &_0, &message, &context); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, critical) +static PHP_METHOD(Phalcon_Annotations_Reflection, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval context; - zval *message_param = NULL, *context_param = NULL, _0; - zval message; + zval *reflectionData_param = NULL; + zval reflectionData; zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) + ZVAL_UNDEF(&reflectionData); + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) + Z_PARAM_ARRAY(reflectionData) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); + zephir_fetch_params(1, 0, 1, &reflectionData_param); + if (!reflectionData_param) { + ZEPHIR_INIT_VAR(&reflectionData); + array_init(&reflectionData); } else { - zephir_get_arrval(&context, context_param); + zephir_get_arrval(&reflectionData, reflectionData_param); } - ZVAL_LONG(&_0, 1); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, &_0, &message, &context); - zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("reflectionData"), &reflectionData); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, debug) +static PHP_METHOD(Phalcon_Annotations_Reflection, getClassAnnotations) { + zval reflectionClass, _0, _1$$3, _2$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval context; - zval *message_param = NULL, *context_param = NULL, _0; - zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&reflectionClass); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); - } else { - zephir_get_arrval(&context, context_param); - } - ZVAL_LONG(&_0, 7); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, &_0, &message, &context); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, emergency) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval context; - zval *message_param = NULL, *context_param = NULL, _0; - zval message; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); - } else { - zephir_get_arrval(&context, context_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("classAnnotations"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + zephir_memory_observe(&reflectionClass); + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("reflectionData"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_string_fetch(&reflectionClass, &_1$$3, SL("class"), 0)) { + ZEPHIR_INIT_VAR(&_2$$4); + object_init_ex(&_2$$4, phalcon_annotations_collection_ce); + ZEPHIR_CALL_METHOD(NULL, &_2$$4, "__construct", NULL, 38, &reflectionClass); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("classAnnotations"), &_2$$4); + } } - ZVAL_LONG(&_0, 0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, &_0, &message, &context); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM_MEMBER(getThis(), "classAnnotations"); } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, error) +static PHP_METHOD(Phalcon_Annotations_Reflection, getConstantsAnnotations) { + zend_string *_5$$4; + zend_ulong _4$$4; + zend_bool _1$$3; + zval reflectionConstants, constant, reflectionConstant, _0, *_2$$4, _3$$4, _6$$5, _8$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_7 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval context; - zval *message_param = NULL, *context_param = NULL, _0; - zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&reflectionConstants); + ZVAL_UNDEF(&constant); + ZVAL_UNDEF(&reflectionConstant); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_8$$6); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); - } else { - zephir_get_arrval(&context, context_param); - } - ZVAL_LONG(&_0, 3); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, &_0, &message, &context); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, getAdapter) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL; - zval name; - ZVAL_UNDEF(&name); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - zephir_get_strval(&name, name_param); - object_init_ex(return_value, phalcon_logger_adapter_noop_ce); - if (zephir_has_constructor(return_value)) { - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); - zephir_check_call_status(); + zephir_memory_observe(&reflectionConstants); + zephir_read_property(&_0, this_ptr, ZEND_STRL("reflectionData"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_string_fetch(&reflectionConstants, &_0, SL("constants"), 0)) { + _1$$3 = Z_TYPE_P(&reflectionConstants) == IS_ARRAY; + if (_1$$3) { + _1$$3 = zephir_fast_count_int(&reflectionConstants) > 0; + } + if (_1$$3) { + zephir_is_iterable(&reflectionConstants, 0, "phalcon/Annotations/Reflection.zep", 97); + if (Z_TYPE_P(&reflectionConstants) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&reflectionConstants), _4$$4, _5$$4, _2$$4) + { + ZEPHIR_INIT_NVAR(&constant); + if (_5$$4 != NULL) { + ZVAL_STR_COPY(&constant, _5$$4); + } else { + ZVAL_LONG(&constant, _4$$4); + } + ZEPHIR_INIT_NVAR(&reflectionConstant); + ZVAL_COPY(&reflectionConstant, _2$$4); + ZEPHIR_INIT_NVAR(&_6$$5); + object_init_ex(&_6$$5, phalcon_annotations_collection_ce); + ZEPHIR_CALL_METHOD(NULL, &_6$$5, "__construct", &_7, 38, &reflectionConstant); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("constantAnnotations"), &constant, &_6$$5); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &reflectionConstants, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3$$4, &reflectionConstants, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3$$4)) { + break; + } + ZEPHIR_CALL_METHOD(&constant, &reflectionConstants, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&reflectionConstant, &reflectionConstants, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_8$$6); + object_init_ex(&_8$$6, phalcon_annotations_collection_ce); + ZEPHIR_CALL_METHOD(NULL, &_8$$6, "__construct", &_7, 38, &reflectionConstant); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("constantAnnotations"), &constant, &_8$$6); + ZEPHIR_CALL_METHOD(NULL, &reflectionConstants, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&reflectionConstant); + ZEPHIR_INIT_NVAR(&constant); + } } - - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, getAdapters) -{ - - array_init(return_value); - return; -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, getLogLevel) -{ - - RETURN_LONG(8); -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, getMessages) -{ - - RETURN_MEMBER(getThis(), "messages"); -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, getName) -{ - - RETURN_STRING("memory logger"); + RETURN_MM_MEMBER(getThis(), "constantAnnotations"); } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, info) +static PHP_METHOD(Phalcon_Annotations_Reflection, getPropertiesAnnotations) { + zend_string *_5$$4; + zend_ulong _4$$4; + zend_bool _1$$3; + zval reflectionProperties, property, reflectionProperty, _0, *_2$$4, _3$$4, _6$$5, _8$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_7 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval context; - zval *message_param = NULL, *context_param = NULL, _0; - zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&reflectionProperties); + ZVAL_UNDEF(&property); + ZVAL_UNDEF(&reflectionProperty); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_8$$6); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); - } else { - zephir_get_arrval(&context, context_param); - } - ZVAL_LONG(&_0, 6); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, &_0, &message, &context); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, notice) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval context; - zval *message_param = NULL, *context_param = NULL, _0; - zval message; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); - } else { - zephir_get_arrval(&context, context_param); + zephir_memory_observe(&reflectionProperties); + zephir_read_property(&_0, this_ptr, ZEND_STRL("reflectionData"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_string_fetch(&reflectionProperties, &_0, SL("properties"), 0)) { + _1$$3 = Z_TYPE_P(&reflectionProperties) == IS_ARRAY; + if (_1$$3) { + _1$$3 = zephir_fast_count_int(&reflectionProperties) > 0; + } + if (_1$$3) { + zephir_is_iterable(&reflectionProperties, 0, "phalcon/Annotations/Reflection.zep", 119); + if (Z_TYPE_P(&reflectionProperties) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&reflectionProperties), _4$$4, _5$$4, _2$$4) + { + ZEPHIR_INIT_NVAR(&property); + if (_5$$4 != NULL) { + ZVAL_STR_COPY(&property, _5$$4); + } else { + ZVAL_LONG(&property, _4$$4); + } + ZEPHIR_INIT_NVAR(&reflectionProperty); + ZVAL_COPY(&reflectionProperty, _2$$4); + ZEPHIR_INIT_NVAR(&_6$$5); + object_init_ex(&_6$$5, phalcon_annotations_collection_ce); + ZEPHIR_CALL_METHOD(NULL, &_6$$5, "__construct", &_7, 38, &reflectionProperty); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("propertyAnnotations"), &property, &_6$$5); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &reflectionProperties, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3$$4, &reflectionProperties, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3$$4)) { + break; + } + ZEPHIR_CALL_METHOD(&property, &reflectionProperties, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&reflectionProperty, &reflectionProperties, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_8$$6); + object_init_ex(&_8$$6, phalcon_annotations_collection_ce); + ZEPHIR_CALL_METHOD(NULL, &_8$$6, "__construct", &_7, 38, &reflectionProperty); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("propertyAnnotations"), &property, &_8$$6); + ZEPHIR_CALL_METHOD(NULL, &reflectionProperties, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&reflectionProperty); + ZEPHIR_INIT_NVAR(&property); + } } - ZVAL_LONG(&_0, 5); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, &_0, &message, &context); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM_MEMBER(getThis(), "propertyAnnotations"); } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, warning) +static PHP_METHOD(Phalcon_Annotations_Reflection, getMethodsAnnotations) { + zend_string *_5$$4; + zend_ulong _4$$4; + zend_bool _1$$3; + zval reflectionMethods, methodName, reflectionMethod, _0, *_2$$4, _3$$4, _6$$5, _8$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_7 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval context; - zval *message_param = NULL, *context_param = NULL, _0; - zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&reflectionMethods); + ZVAL_UNDEF(&methodName); + ZVAL_UNDEF(&reflectionMethod); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_8$$6); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); - } else { - zephir_get_arrval(&context, context_param); - } - ZVAL_LONG(&_0, 4); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, &_0, &message, &context); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, log) -{ - zend_string *_3; - zend_ulong _2; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval context, replace; - zval message; - zval *level, level_sub, *message_param = NULL, *context_param = NULL, key, value, *_0, _1, _6, _4$$3, _5$$4; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&level_sub); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&context); - ZVAL_UNDEF(&replace); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_ZVAL(level) - Z_PARAM_STR(message) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &level, &message_param, &context_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); - } else { - zephir_get_arrval(&context, context_param); - } - ZEPHIR_INIT_VAR(&replace); - array_init(&replace); - zephir_is_iterable(&context, 0, "phalcon/DataMapper/Pdo/Profiler/MemoryLogger.zep", 170); - if (Z_TYPE_P(&context) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&context), _2, _3, _0) - { - ZEPHIR_INIT_NVAR(&key); - if (_3 != NULL) { - ZVAL_STR_COPY(&key, _3); - } else { - ZVAL_LONG(&key, _2); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0); - ZEPHIR_INIT_NVAR(&_4$$3); - ZEPHIR_CONCAT_SVS(&_4$$3, "{", &key, "}"); - zephir_array_update_zval(&replace, &_4$$3, &value, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &context, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &context, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; + zephir_memory_observe(&reflectionMethods); + zephir_read_property(&_0, this_ptr, ZEND_STRL("reflectionData"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_string_fetch(&reflectionMethods, &_0, SL("methods"), 0)) { + _1$$3 = Z_TYPE_P(&reflectionMethods) == IS_ARRAY; + if (_1$$3) { + _1$$3 = zephir_fast_count_int(&reflectionMethods) > 0; + } + if (_1$$3) { + zephir_is_iterable(&reflectionMethods, 0, "phalcon/Annotations/Reflection.zep", 141); + if (Z_TYPE_P(&reflectionMethods) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&reflectionMethods), _4$$4, _5$$4, _2$$4) + { + ZEPHIR_INIT_NVAR(&methodName); + if (_5$$4 != NULL) { + ZVAL_STR_COPY(&methodName, _5$$4); + } else { + ZVAL_LONG(&methodName, _4$$4); + } + ZEPHIR_INIT_NVAR(&reflectionMethod); + ZVAL_COPY(&reflectionMethod, _2$$4); + ZEPHIR_INIT_NVAR(&_6$$5); + object_init_ex(&_6$$5, phalcon_annotations_collection_ce); + ZEPHIR_CALL_METHOD(NULL, &_6$$5, "__construct", &_7, 38, &reflectionMethod); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("methodAnnotations"), &methodName, &_6$$5); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &reflectionMethods, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3$$4, &reflectionMethods, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3$$4)) { + break; + } + ZEPHIR_CALL_METHOD(&methodName, &reflectionMethods, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&reflectionMethod, &reflectionMethods, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_8$$6); + object_init_ex(&_8$$6, phalcon_annotations_collection_ce); + ZEPHIR_CALL_METHOD(NULL, &_8$$6, "__construct", &_7, 38, &reflectionMethod); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("methodAnnotations"), &methodName, &_8$$6); + ZEPHIR_CALL_METHOD(NULL, &reflectionMethods, "next", NULL, 0); + zephir_check_call_status(); + } } - ZEPHIR_CALL_METHOD(&key, &context, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &context, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_5$$4); - ZEPHIR_CONCAT_SVS(&_5$$4, "{", &key, "}"); - zephir_array_update_zval(&replace, &_5$$4, &value, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &context, "next", NULL, 0); - zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&reflectionMethod); + ZEPHIR_INIT_NVAR(&methodName); } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - ZEPHIR_CALL_FUNCTION(&_6, "strtr", NULL, 5, &message, &replace); - zephir_check_call_status(); - zephir_update_property_array_append(this_ptr, SL("messages"), &_6); - ZEPHIR_MM_RESTORE(); + RETURN_MM_MEMBER(getThis(), "methodAnnotations"); } -zend_object *zephir_init_properties_Phalcon_DataMapper_Pdo_Profiler_MemoryLogger(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Annotations_Reflection, getReflectionData) { - zval _0, _1$$3; + + RETURN_MEMBER(getThis(), "reflectionData"); +} + +zend_object *zephir_init_properties_Phalcon_Annotations_Reflection(zend_class_entry *class_type) +{ + zval _0, _2, _4, _6, _1$$3, _3$$4, _5$$5, _7$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); @@ -109647,11 +108467,29 @@ zend_object *zephir_init_properties_Phalcon_DataMapper_Pdo_Profiler_MemoryLogger { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("reflectionData"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("messages"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("reflectionData"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("methodAnnotations"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("methodAnnotations"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("propertyAnnotations"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("propertyAnnotations"), &_5$$5); + } + zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("constantAnnotations"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_6) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$6); + array_init(&_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("constantAnnotations"), &_7$$6); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -109660,388 +108498,882 @@ zend_object *zephir_init_properties_Phalcon_DataMapper_Pdo_Profiler_MemoryLogger - -#ifdef HAVE_CONFIG_H -#endif - +/* Generated by re2c 1.1.1 */ +/* scanner.re + * This file is part of the Phalcon Framework. + * + * (c) Phalcon Team + * + * For the full copyright and license information, please view the + * LICENSE.txt file that was distributed with this source code. + */ +#define AACTYPE unsigned char +#define AACURSOR (s->start) +#define AALIMIT (s->end) +#define AAMARKER q -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Profiler_Profiler) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\DataMapper\\Pdo\\Profiler, Profiler, phalcon, datamapper_pdo_profiler_profiler, phalcon_datamapper_pdo_profiler_profiler_method_entry, 0); +static int phannot_get_token(phannot_scanner_state *s, phannot_scanner_token *token) { - zend_declare_property_bool(phalcon_datamapper_pdo_profiler_profiler_ce, SL("active"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_datamapper_pdo_profiler_profiler_ce, SL("context"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_datamapper_pdo_profiler_profiler_ce, SL("logFormat"), "", ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_datamapper_pdo_profiler_profiler_ce, SL("logLevel"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_datamapper_pdo_profiler_profiler_ce, SL("logger"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_datamapper_pdo_profiler_profiler_ce, SL("encode"), ZEND_ACC_PRIVATE); - phalcon_datamapper_pdo_profiler_profiler_ce->create_object = zephir_init_properties_Phalcon_DataMapper_Pdo_Profiler_Profiler; + char next, *q = AACURSOR, *start = AACURSOR; + int status = PHANNOT_SCANNER_RETCODE_IMPOSSIBLE; - zend_class_implements(phalcon_datamapper_pdo_profiler_profiler_ce, 1, phalcon_datamapper_pdo_profiler_profilerinterface_ce); - return SUCCESS; -} + while (PHANNOT_SCANNER_RETCODE_IMPOSSIBLE == status) { -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *logger = NULL, logger_sub, __$null, _0, _1; - zval *this_ptr = getThis(); + if (s->mode == PHANNOT_MODE_RAW) { - ZVAL_UNDEF(&logger_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(logger, phalcon_logger_loggerinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &logger); - if (!logger) { - logger = &logger_sub; - ZEPHIR_CPY_WRT(logger, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(logger); - } - if (Z_TYPE_P(logger) == IS_NULL) { - ZEPHIR_INIT_NVAR(logger); - object_init_ex(logger, phalcon_datamapper_pdo_profiler_memorylogger_ce); - if (zephir_has_constructor(logger)) { - ZEPHIR_CALL_METHOD(NULL, logger, "__construct", NULL, 0); - zephir_check_call_status(); - } + if (*AACURSOR == '\n') { + s->active_line++; + } - } - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, "{method} ({duration}s): {statement} {backtrace}"); - zephir_update_property_zval(this_ptr, ZEND_STRL("logFormat"), &_0); - ZVAL_UNDEF(&_1); - ZVAL_LONG(&_1, 7); - zephir_update_property_zval(this_ptr, ZEND_STRL("logLevel"), &_1); - zephir_update_property_zval(this_ptr, ZEND_STRL("logger"), logger); - ZEPHIR_INIT_NVAR(&_0); - object_init_ex(&_0, phalcon_support_helper_json_encode_ce); - if (zephir_has_constructor(&_0)) { - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); - zephir_check_call_status(); - } + next = *(AACURSOR+1); - zephir_update_property_zval(this_ptr, ZEND_STRL("encode"), &_0); - ZEPHIR_MM_RESTORE(); -} + if (*AACURSOR == '\0' || *AACURSOR == '@') { + if ((next >= 'A' && next <= 'Z') || (next >= 'a' && next <= 'z')) { + s->mode = PHANNOT_MODE_ANNOTATION; + continue; + } + } -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, finish) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval values; - zval *statement_param = NULL, *values_param = NULL, __$true, ex, finish, _0, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, _7$$3, _8$$3, _9$$3, _10$$3, _11$$3, _12$$3, _13$$3, _14$$3, _15$$3; - zval statement; - zval *this_ptr = getThis(); + ++AACURSOR; + token->opcode = PHANNOT_T_IGNORE; + return 0; - ZVAL_UNDEF(&statement); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&ex); - ZVAL_UNDEF(&finish); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_9$$3); - ZVAL_UNDEF(&_10$$3); - ZVAL_UNDEF(&_11$$3); - ZVAL_UNDEF(&_12$$3); - ZVAL_UNDEF(&_13$$3); - ZVAL_UNDEF(&_14$$3); - ZVAL_UNDEF(&_15$$3); - ZVAL_UNDEF(&values); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(statement) - Z_PARAM_ARRAY(values) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &statement_param, &values_param); - if (!statement_param) { - ZEPHIR_INIT_VAR(&statement); - } else { - zephir_get_strval(&statement, statement_param); - } - if (!values_param) { - ZEPHIR_INIT_VAR(&values); - array_init(&values); - } else { - zephir_get_arrval(&values, values_param); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("active"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(zephir_is_true(&_0))) { - ZEPHIR_INIT_VAR(&ex); - object_init_ex(&ex, phalcon_datamapper_pdo_exception_exception_ce); - ZEPHIR_CALL_METHOD(NULL, &ex, "__construct", NULL, 33); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&finish, "hrtime", NULL, 203, &__$true); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1$$3, &ex, "gettraceasstring", NULL, 204); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "backtrace"); - zephir_update_property_array(this_ptr, SL("context"), &_2$$3, &_1$$3); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("context"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_4$$3, &_3$$3, SL("start"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/Profiler/Profiler.zep", 91); - ZEPHIR_INIT_VAR(&_5$$3); - zephir_sub_function(&_5$$3, &finish, &_4$$3); - ZEPHIR_INIT_VAR(&_6$$3); - ZVAL_STRING(&_6$$3, "duration"); - zephir_update_property_array(this_ptr, SL("context"), &_6$$3, &_5$$3); - ZEPHIR_INIT_VAR(&_7$$3); - ZVAL_STRING(&_7$$3, "finish"); - zephir_update_property_array(this_ptr, SL("context"), &_7$$3, &finish); - ZEPHIR_INIT_VAR(&_8$$3); - ZVAL_STRING(&_8$$3, "statement"); - zephir_update_property_array(this_ptr, SL("context"), &_8$$3, &statement); - ZEPHIR_INIT_NVAR(&_5$$3); - if (ZEPHIR_IS_EMPTY(&values)) { - ZEPHIR_INIT_NVAR(&_5$$3); - ZVAL_STRING(&_5$$3, ""); } else { - zephir_read_property(&_9$$3, this_ptr, ZEND_STRL("encode"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_5$$3, &_9$$3, "__invoke", NULL, 0, &values); - zephir_check_call_status(); + + + { + AACTYPE aach; + unsigned int aaaccept = 0; + aach = *AACURSOR; + switch (aach) { + case 0x00: goto aa2; + case '\t': + case '\r': + case ' ': goto aa6; + case '\n': goto aa9; + case '"': goto aa11; + case '\'': goto aa12; + case '(': goto aa13; + case ')': goto aa15; + case ',': goto aa17; + case '-': goto aa19; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto aa20; + case ':': goto aa23; + case '=': goto aa25; + case '@': goto aa27; + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto aa29; + case 'F': + case 'f': goto aa32; + case 'N': + case 'n': goto aa33; + case 'T': + case 't': goto aa34; + case '[': goto aa35; + case '\\': goto aa37; + case ']': goto aa38; + case '{': goto aa40; + case '}': goto aa42; + default: goto aa4; + } +aa2: + ++AACURSOR; + { + status = PHANNOT_SCANNER_RETCODE_EOF; + break; + } +aa4: + ++AACURSOR; +aa5: + { + status = PHANNOT_SCANNER_RETCODE_ERR; + break; + } +aa6: + aach = *++AACURSOR; + switch (aach) { + case '\t': + case '\r': + case ' ': goto aa6; + default: goto aa8; + } +aa8: + { + token->opcode = PHANNOT_T_IGNORE; + return 0; + } +aa9: + ++AACURSOR; + { + s->active_line++; + token->opcode = PHANNOT_T_IGNORE; + return 0; + } +aa11: + aaaccept = 0; + aach = *(AAMARKER = ++AACURSOR); + if (aach <= 0x00) goto aa5; + goto aa45; +aa12: + aaaccept = 0; + aach = *(AAMARKER = ++AACURSOR); + if (aach <= 0x00) goto aa5; + goto aa51; +aa13: + ++AACURSOR; + { + token->opcode = PHANNOT_T_PARENTHESES_OPEN; + return 0; + } +aa15: + ++AACURSOR; + { + token->opcode = PHANNOT_T_PARENTHESES_CLOSE; + return 0; + } +aa17: + ++AACURSOR; + { + token->opcode = PHANNOT_T_COMMA; + return 0; + } +aa19: + aach = *++AACURSOR; + switch (aach) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto aa20; + default: goto aa5; + } +aa20: + aaaccept = 1; + aach = *(AAMARKER = ++AACURSOR); + switch (aach) { + case '.': goto aa53; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto aa20; + default: goto aa22; + } +aa22: + { + token->opcode = PHANNOT_T_INTEGER; + token->value = estrndup(start, AACURSOR - start); + token->len = AACURSOR - start; + q = AACURSOR; + return 0; + } +aa23: + ++AACURSOR; + { + token->opcode = PHANNOT_T_COLON; + return 0; + } +aa25: + ++AACURSOR; + { + token->opcode = PHANNOT_T_EQUALS; + return 0; + } +aa27: + ++AACURSOR; + { + token->opcode = PHANNOT_T_AT; + return 0; + } +aa29: + aaaccept = 2; + aach = *(AAMARKER = ++AACURSOR); +aa30: + switch (aach) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto aa29; + case '\\': goto aa54; + default: goto aa31; + } +aa31: + { + token->opcode = PHANNOT_T_IDENTIFIER; + token->value = estrndup(start, AACURSOR - start); + token->len = AACURSOR - start; + q = AACURSOR; + return 0; + } +aa32: + aaaccept = 2; + aach = *(AAMARKER = ++AACURSOR); + switch (aach) { + case 'A': + case 'a': goto aa55; + default: goto aa30; + } +aa33: + aaaccept = 2; + aach = *(AAMARKER = ++AACURSOR); + switch (aach) { + case 'U': + case 'u': goto aa56; + default: goto aa30; + } +aa34: + aaaccept = 2; + aach = *(AAMARKER = ++AACURSOR); + switch (aach) { + case 'R': + case 'r': goto aa57; + default: goto aa30; + } +aa35: + ++AACURSOR; + { + token->opcode = PHANNOT_T_SBRACKET_OPEN; + return 0; + } +aa37: + aach = *++AACURSOR; + switch (aach) { + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto aa29; + default: goto aa5; + } +aa38: + ++AACURSOR; + { + token->opcode = PHANNOT_T_SBRACKET_CLOSE; + return 0; + } +aa40: + ++AACURSOR; + { + token->opcode = PHANNOT_T_BRACKET_OPEN; + return 0; + } +aa42: + ++AACURSOR; + { + token->opcode = PHANNOT_T_BRACKET_CLOSE; + return 0; + } +aa44: + aach = *++AACURSOR; +aa45: + switch (aach) { + case 0x00: goto aa46; + case '"': goto aa47; + case '\\': goto aa49; + default: goto aa44; + } +aa46: + AACURSOR = AAMARKER; + switch (aaaccept) { + case 0: goto aa5; + case 1: goto aa22; + case 2: goto aa31; + case 3: goto aa66; + case 4: goto aa68; + default: goto aa70; + } +aa47: + ++AACURSOR; + { + token->opcode = PHANNOT_T_STRING; + token->value = estrndup(q, AACURSOR - q - 1); + token->len = AACURSOR - q - 1; + q = AACURSOR; + return 0; + } +aa49: + aach = *++AACURSOR; + switch (aach) { + case '\n': goto aa46; + default: goto aa44; + } +aa50: + aach = *++AACURSOR; +aa51: + switch (aach) { + case 0x00: goto aa46; + case '\'': goto aa47; + case '\\': goto aa52; + default: goto aa50; + } +aa52: + aach = *++AACURSOR; + switch (aach) { + case '\n': goto aa46; + default: goto aa50; + } +aa53: + aach = *++AACURSOR; + switch (aach) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto aa58; + default: goto aa46; + } +aa54: + aach = *++AACURSOR; + switch (aach) { + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto aa29; + default: goto aa46; + } +aa55: + aaaccept = 2; + aach = *(AAMARKER = ++AACURSOR); + switch (aach) { + case 'L': + case 'l': goto aa61; + default: goto aa30; + } +aa56: + aaaccept = 2; + aach = *(AAMARKER = ++AACURSOR); + switch (aach) { + case 'L': + case 'l': goto aa62; + default: goto aa30; + } +aa57: + aaaccept = 2; + aach = *(AAMARKER = ++AACURSOR); + switch (aach) { + case 'U': + case 'u': goto aa63; + default: goto aa30; + } +aa58: + aach = *++AACURSOR; + switch (aach) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto aa58; + default: goto aa60; + } +aa60: + { + token->opcode = PHANNOT_T_DOUBLE; + token->value = estrndup(start, AACURSOR - start); + token->len = AACURSOR - start; + q = AACURSOR; + return 0; + } +aa61: + aaaccept = 2; + aach = *(AAMARKER = ++AACURSOR); + switch (aach) { + case 'S': + case 's': goto aa64; + default: goto aa30; + } +aa62: + aaaccept = 2; + aach = *(AAMARKER = ++AACURSOR); + switch (aach) { + case 'L': + case 'l': goto aa65; + default: goto aa30; + } +aa63: + aaaccept = 2; + aach = *(AAMARKER = ++AACURSOR); + switch (aach) { + case 'E': + case 'e': goto aa67; + default: goto aa30; + } +aa64: + aaaccept = 2; + aach = *(AAMARKER = ++AACURSOR); + switch (aach) { + case 'E': + case 'e': goto aa69; + default: goto aa30; + } +aa65: + aaaccept = 3; + aach = *(AAMARKER = ++AACURSOR); + switch (aach) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto aa29; + case '\\': goto aa54; + default: goto aa66; + } +aa66: + { + token->opcode = PHANNOT_T_NULL; + return 0; + } +aa67: + aaaccept = 4; + aach = *(AAMARKER = ++AACURSOR); + switch (aach) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto aa29; + case '\\': goto aa54; + default: goto aa68; + } +aa68: + { + token->opcode = PHANNOT_T_TRUE; + return 0; + } +aa69: + aaaccept = 5; + aach = *(AAMARKER = ++AACURSOR); + switch (aach) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'R': + case 'S': + case 'T': + case 'U': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case '_': + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + case 'g': + case 'h': + case 'i': + case 'j': + case 'k': + case 'l': + case 'm': + case 'n': + case 'o': + case 'p': + case 'q': + case 'r': + case 's': + case 't': + case 'u': + case 'v': + case 'w': + case 'x': + case 'y': + case 'z': goto aa29; + case '\\': goto aa54; + default: goto aa70; + } +aa70: + { + token->opcode = PHANNOT_T_FALSE; + return 0; + } } - ZEPHIR_INIT_VAR(&_10$$3); - ZVAL_STRING(&_10$$3, "values"); - zephir_update_property_array(this_ptr, SL("context"), &_10$$3, &_5$$3); - zephir_read_property(&_11$$3, this_ptr, ZEND_STRL("logger"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_12$$3, this_ptr, ZEND_STRL("logLevel"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_13$$3, this_ptr, ZEND_STRL("logFormat"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_14$$3, this_ptr, ZEND_STRL("context"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_11$$3, "log", NULL, 0, &_12$$3, &_13$$3, &_14$$3); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_15$$3); - array_init(&_15$$3); - zephir_update_property_zval(this_ptr, ZEND_STRL("context"), &_15$$3); - } - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, getLogFormat) -{ - - RETURN_MEMBER(getThis(), "logFormat"); -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, getLogger) -{ - - RETURN_MEMBER(getThis(), "logger"); -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, getLogLevel) -{ - - RETURN_MEMBER(getThis(), "logLevel"); -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, isActive) -{ - - RETURN_MEMBER(getThis(), "active"); -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, setActive) -{ - zval *active_param = NULL, __$true, __$false; - zend_bool active; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(active) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &active_param); - if (active) { - zephir_update_property_zval(this_ptr, ZEND_STRL("active"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("active"), &__$false); - } - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, setLogFormat) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *logFormat_param = NULL; - zval logFormat; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&logFormat); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(logFormat) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &logFormat_param); - zephir_get_strval(&logFormat, logFormat_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("logFormat"), &logFormat); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, setLogLevel) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *logLevel_param = NULL; - zval logLevel; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&logLevel); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(logLevel) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &logLevel_param); - zephir_get_strval(&logLevel, logLevel_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("logLevel"), &logLevel); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, start) -{ - zval _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *method_param = NULL, __$true, _0, _2$$3; - zval method; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&method); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(method) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &method_param); - zephir_get_strval(&method, method_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("active"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(zephir_is_true(&_0))) { - ZEPHIR_INIT_VAR(&_1$$3); - zephir_create_array(&_1$$3, 2, 0); - zephir_array_update_string(&_1$$3, SL("method"), &method, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_FUNCTION(&_2$$3, "hrtime", NULL, 203, &__$true); - zephir_check_call_status(); - zephir_array_update_string(&_1$$3, SL("start"), &_2$$3, PH_COPY | PH_SEPARATE); - zephir_update_property_zval(this_ptr, ZEND_STRL("context"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); -} -zend_object *zephir_init_properties_Phalcon_DataMapper_Pdo_Profiler_Profiler(zend_class_entry *class_type) -{ - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("context"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("context"), &_1$$3); } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\DataMapper\\Pdo\\Profiler, ProfilerInterface, phalcon, datamapper_pdo_profiler_profilerinterface, phalcon_datamapper_pdo_profiler_profilerinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface, finish); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface, getLogger); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface, getLogFormat); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface, getLogLevel); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface, isActive); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface, setActive); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface, setLogFormat); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface, setLogLevel); -ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface, start); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Exception_CannotDisconnect) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Pdo\\Exception, CannotDisconnect, phalcon, datamapper_pdo_exception_cannotdisconnect, phalcon_datamapper_pdo_exception_exception_ce, NULL, 0); - - return SUCCESS; -} - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Exception_ConnectionNotFound) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Pdo\\Exception, ConnectionNotFound, phalcon, datamapper_pdo_exception_connectionnotfound, phalcon_datamapper_pdo_exception_exception_ce, NULL, 0); - - return SUCCESS; + return status; } - #ifdef HAVE_CONFIG_H #endif @@ -110049,1388 +109381,784 @@ ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Exception_ConnectionNotFound) -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Exception_Exception) +ZEPHIR_INIT_CLASS(Phalcon_Annotations_Adapter_AbstractAdapter) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Pdo\\Exception, Exception, phalcon, datamapper_pdo_exception_exception, zend_ce_exception, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - + ZEPHIR_REGISTER_CLASS(Phalcon\\Annotations\\Adapter, AbstractAdapter, phalcon, annotations_adapter_abstractadapter, phalcon_annotations_adapter_abstractadapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Query_AbstractConditions) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Query, AbstractConditions, phalcon, datamapper_query_abstractconditions, phalcon_datamapper_query_abstractquery_ce, phalcon_datamapper_query_abstractconditions_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + zend_declare_property_null(phalcon_annotations_adapter_abstractadapter_ce, SL("annotations"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_annotations_adapter_abstractadapter_ce, SL("reader"), ZEND_ACC_PROTECTED); + phalcon_annotations_adapter_abstractadapter_ce->create_object = zephir_init_properties_Phalcon_Annotations_Adapter_AbstractAdapter; + zend_class_implements(phalcon_annotations_adapter_abstractadapter_ce, 1, phalcon_annotations_adapter_adapterinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, limit) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *limit_param = NULL, _0, _1; - zend_long limit; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(limit) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &limit_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "LIMIT"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_LONG(&_1, limit); - zephir_update_property_array(this_ptr, SL("store"), &_0, &_1); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, offset) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *offset_param = NULL, _0, _1; - zend_long offset; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(offset) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &offset_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "OFFSET"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_LONG(&_1, offset); - zephir_update_property_array(this_ptr, SL("store"), &_0, &_1); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, andWhere) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _0; - zval condition; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&condition); - ZVAL_UNDEF(&value_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(condition) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) - Z_PARAM_LONG(type) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &condition_param, &value, &type_param); - zephir_get_strval(&condition, condition_param); - if (!value) { - value = &value_sub; - value = &__$null; - } - if (!type_param) { - type = -1; - } else { - } - ZVAL_LONG(&_0, type); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "where", NULL, 0, &condition, value, &_0); - zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, appendWhere) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _0, _1; - zval condition; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&condition); - ZVAL_UNDEF(&value_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(condition) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) - Z_PARAM_LONG(type) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &condition_param, &value, &type_param); - zephir_get_strval(&condition, condition_param); - if (!value) { - value = &value_sub; - value = &__$null; - } - if (!type_param) { - type = -1; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "WHERE"); - ZVAL_LONG(&_1, type); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendcondition", NULL, 0, &_0, &condition, value, &_1); - zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, orderBy) +static PHP_METHOD(Phalcon_Annotations_Adapter_AbstractAdapter, get) { + zend_bool _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *orderBy, orderBy_sub, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&orderBy_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(orderBy) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &orderBy); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "ORDER"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processvalue", NULL, 0, &_0, orderBy); - zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, orWhere) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _0, _1, _2; - zval condition; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&condition); - ZVAL_UNDEF(&value_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(condition) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) - Z_PARAM_LONG(type) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &condition_param, &value, &type_param); - zephir_get_strval(&condition, condition_param); - if (!value) { - value = &value_sub; - value = &__$null; - } - if (!type_param) { - type = -1; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "WHERE"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "OR "); - ZVAL_LONG(&_2, type); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addcondition", NULL, 0, &_0, &_1, &condition, value, &_2); - zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, where) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _0, _1, _2; - zval condition; + zval *className, className_sub, classAnnotations, parsedAnnotations, realClassName, reader, _0, _1$$5, _2$$5; zval *this_ptr = getThis(); - ZVAL_UNDEF(&condition); - ZVAL_UNDEF(&value_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&className_sub); + ZVAL_UNDEF(&classAnnotations); + ZVAL_UNDEF(&parsedAnnotations); + ZVAL_UNDEF(&realClassName); + ZVAL_UNDEF(&reader); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(condition) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) - Z_PARAM_LONG(type) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &condition_param, &value, &type_param); - zephir_get_strval(&condition, condition_param); - if (!value) { - value = &value_sub; - value = &__$null; - } - if (!type_param) { - type = -1; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "WHERE"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "AND "); - ZVAL_LONG(&_2, type); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addcondition", NULL, 0, &_0, &_1, &condition, value, &_2); - zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, whereEquals) -{ - zend_string *_3; - zend_ulong _2; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *columnsValues_param = NULL, key, value, *_0, _1, _5$$5, _6$$6, _7$$7, _8$$10, _9$$11, _10$$12; - zval columnsValues; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&columnsValues); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_6$$6); - ZVAL_UNDEF(&_7$$7); - ZVAL_UNDEF(&_8$$10); - ZVAL_UNDEF(&_9$$11); - ZVAL_UNDEF(&_10$$12); + ZVAL_UNDEF(&_1$$5); + ZVAL_UNDEF(&_2$$5); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(columnsValues) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &columnsValues_param); - zephir_get_arrval(&columnsValues, columnsValues_param); - zephir_is_iterable(&columnsValues, 0, "phalcon/DataMapper/Query/AbstractConditions.zep", 162); - if (Z_TYPE_P(&columnsValues) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&columnsValues), _2, _3, _0) - { - ZEPHIR_INIT_NVAR(&key); - if (_3 != NULL) { - ZVAL_STR_COPY(&key, _3); - } else { - ZVAL_LONG(&key, _2); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0); - if (zephir_is_numeric(&key)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "where", &_4, 0, &value); - zephir_check_call_status(); - } else if (Z_TYPE_P(&value) == IS_NULL) { - ZEPHIR_INIT_NVAR(&_5$$5); - ZEPHIR_CONCAT_VS(&_5$$5, &key, " IS NULL"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "where", &_4, 0, &_5$$5); - zephir_check_call_status(); - } else if (Z_TYPE_P(&value) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_6$$6); - ZEPHIR_CONCAT_VS(&_6$$6, &key, " IN "); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "where", &_4, 0, &_6$$6, &value); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&_7$$7); - ZEPHIR_CONCAT_VS(&_7$$7, &key, " = "); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "where", &_4, 0, &_7$$7, &value); - zephir_check_call_status(); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &columnsValues, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &columnsValues, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &columnsValues, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &columnsValues, "current", NULL, 0); - zephir_check_call_status(); - if (zephir_is_numeric(&key)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "where", &_4, 0, &value); - zephir_check_call_status(); - } else if (Z_TYPE_P(&value) == IS_NULL) { - ZEPHIR_INIT_NVAR(&_8$$10); - ZEPHIR_CONCAT_VS(&_8$$10, &key, " IS NULL"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "where", &_4, 0, &_8$$10); - zephir_check_call_status(); - } else if (Z_TYPE_P(&value) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_9$$11); - ZEPHIR_CONCAT_VS(&_9$$11, &key, " IN "); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "where", &_4, 0, &_9$$11, &value); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&_10$$12); - ZEPHIR_CONCAT_VS(&_10$$12, &key, " = "); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "where", &_4, 0, &_10$$12, &value); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(NULL, &columnsValues, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, addCondition) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *store_param = NULL, *andor_param = NULL, *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _0$$3, _1$$3, _2, _3; - zval store, andor, condition, _4; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&store); - ZVAL_UNDEF(&andor); - ZVAL_UNDEF(&condition); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&value_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 5) - Z_PARAM_STR(store) - Z_PARAM_STR(andor) - Z_PARAM_STR(condition) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) - Z_PARAM_LONG(type) + Z_PARAM_ZVAL(className) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 2, &store_param, &andor_param, &condition_param, &value, &type_param); - zephir_get_strval(&store, store_param); - zephir_get_strval(&andor, andor_param); - zephir_get_strval(&condition, condition_param); - if (!value) { - value = &value_sub; - value = &__$null; - } - if (!type_param) { - type = -1; + zephir_fetch_params(1, 1, 0, &className); + if (Z_TYPE_P(className) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&realClassName); + zephir_get_class(&realClassName, className, 0); } else { - } - if (!(ZEPHIR_IS_EMPTY(value))) { - ZVAL_LONG(&_1$$3, type); - ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "bindinline", NULL, 0, value, &_1$$3); - zephir_check_call_status(); - zephir_concat_self(&condition, &_0$$3); - } - zephir_read_property(&_2, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_3, &_2, &store, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 185); - if (ZEPHIR_IS_EMPTY(&_3)) { - ZEPHIR_INIT_NVAR(&andor); + ZEPHIR_CPY_WRT(&realClassName, className); } - ZEPHIR_INIT_VAR(&_4); - ZEPHIR_CONCAT_VV(&_4, &andor, &condition); - zephir_update_property_array_multi(this_ptr, SL("store"), &_4, SL("za"), 2, &store); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, buildBy) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *type_param = NULL, _0, _1, _2, _3, _4, _5; - zval type; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(type) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &type_param); - zephir_get_strval(&type, type_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_1, &_0, &type, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 201); - if (ZEPHIR_IS_EMPTY(&_1)) { - RETURN_MM_STRING(""); + zephir_read_property(&_0, this_ptr, ZEND_STRL("annotations"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset(&_0, &realClassName)) { + zephir_read_property(&_1$$5, this_ptr, ZEND_STRL("annotations"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_2$$5, &_1$$5, &realClassName, PH_NOISY | PH_READONLY, "phalcon/Annotations/Adapter/AbstractAdapter.zep", 51); + RETURN_CTOR(&_2$$5); } - zephir_read_property(&_3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_4, &_3, &type, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 206); - ZEPHIR_INIT_VAR(&_5); - ZVAL_STRING(&_5, ","); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "indent", NULL, 0, &_4, &_5); + ZEPHIR_CALL_METHOD(&classAnnotations, this_ptr, "read", NULL, 0, &realClassName); zephir_check_call_status(); - ZEPHIR_CONCAT_SVSV(return_value, " ", &type, " BY", &_2); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, buildCondition) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *type_param = NULL, _0, _1, _2, _3, _4; - zval type; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(type) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &type_param); - zephir_get_strval(&type, type_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_1, &_0, &type, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 218); - if (ZEPHIR_IS_EMPTY(&_1)) { - RETURN_MM_STRING(""); + _3 = Z_TYPE_P(&classAnnotations) == IS_NULL; + if (!(_3)) { + _3 = ZEPHIR_IS_FALSE_IDENTICAL(&classAnnotations); } - zephir_read_property(&_3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_4, &_3, &type, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 223); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "indent", NULL, 0, &_4); - zephir_check_call_status(); - ZEPHIR_CONCAT_SVV(return_value, " ", &type, &_2); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, buildLimitEarly) -{ - zend_bool _3, _6; - zval _0, _1, _2, _4, _5, _7, _8, _9$$3, _10$$3, _11$$3; - zval limit; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9$$3); - ZVAL_UNDEF(&_10$$3); - ZVAL_UNDEF(&_11$$3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&limit); - zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_1, &_0, "getdrivername", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "sqlsrv"); - _3 = ZEPHIR_IS_IDENTICAL(&_2, &_1); if (_3) { - zephir_read_property(&_4, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_5, &_4, SL("LIMIT"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 237); - _3 = ZEPHIR_GT_LONG(&_5, 0); - } - _6 = _3; - if (_6) { - zephir_read_property(&_7, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_8, &_7, SL("OFFSET"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 239); - _6 = ZEPHIR_IS_LONG_IDENTICAL(&_8, 0); - } - if (_6) { - zephir_read_property(&_9$$3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_10$$3, &_9$$3, SL("LIMIT"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 240); - ZEPHIR_INIT_VAR(&_11$$3); - ZEPHIR_CONCAT_SV(&_11$$3, " TOP ", &_10$$3); - zephir_get_strval(&limit, &_11$$3); - } - RETURN_CTOR(&limit); -} - -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, buildLimit) -{ - zval method, suffix, _0, _1, _2; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&suffix); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&suffix, &_0, "getdrivername", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "sqlsrv"); - if (!ZEPHIR_IS_IDENTICAL(&_1, &suffix)) { - ZEPHIR_INIT_NVAR(&suffix); - ZVAL_STRING(&suffix, "common"); - } - ZEPHIR_INIT_VAR(&_2); - zephir_ucfirst(&_2, &suffix); - ZEPHIR_INIT_VAR(&method); - ZEPHIR_CONCAT_SV(&method, "buildLimit", &_2); - ZEPHIR_RETURN_CALL_METHOD_ZVAL(this_ptr, &method, NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, buildLimitCommon) -{ - zval _0, _1, _5, _6, _10, _2$$3, _3$$3, _4$$3, _7$$4, _8$$4, _9$$4, _11$$5, _12$$5; - zval limit; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_11$$5); - ZVAL_UNDEF(&_12$$5); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&limit); - zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_1, &_0, SL("LIMIT"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 275); - if (!ZEPHIR_IS_LONG_IDENTICAL(&_1, 0)) { - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_3$$3, &_2$$3, SL("LIMIT"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 276); - ZEPHIR_INIT_VAR(&_4$$3); - ZEPHIR_CONCAT_SV(&_4$$3, "LIMIT ", &_3$$3); - zephir_concat_self(&limit, &_4$$3); - } - zephir_read_property(&_5, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_6, &_5, SL("OFFSET"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 279); - if (!ZEPHIR_IS_LONG_IDENTICAL(&_6, 0)) { - zephir_read_property(&_7$$4, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_8$$4, &_7$$4, SL("OFFSET"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 280); - ZEPHIR_INIT_VAR(&_9$$4); - ZEPHIR_CONCAT_SV(&_9$$4, " OFFSET ", &_8$$4); - zephir_concat_self(&limit, &_9$$4); - } - ZEPHIR_INIT_VAR(&_10); - ZVAL_STRING(&_10, ""); - if (!ZEPHIR_IS_IDENTICAL(&_10, &limit)) { - ZEPHIR_INIT_VAR(&_11$$5); - zephir_fast_trim(&_11$$5, &limit, NULL , ZEPHIR_TRIM_LEFT); - ZEPHIR_INIT_VAR(&_12$$5); - ZEPHIR_CONCAT_SV(&_12$$5, " ", &_11$$5); - zephir_get_strval(&limit, &_12$$5); - } - RETURN_CTOR(&limit); -} - -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, buildLimitSqlsrv) -{ - zend_bool _2; - zval _0, _1, _3, _4, _5$$3, _6$$3, _7$$3, _8$$3, _9$$3; - zval limit; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_9$$3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&limit); - zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_1, &_0, SL("LIMIT"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 299); - _2 = ZEPHIR_GT_LONG(&_1, 0); - if (_2) { - zephir_read_property(&_3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_4, &_3, SL("OFFSET"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 299); - _2 = ZEPHIR_GT_LONG(&_4, 0); - } - if (_2) { - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_6$$3, &_5$$3, SL("OFFSET"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 300); - zephir_read_property(&_7$$3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_8$$3, &_7$$3, SL("LIMIT"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 301); - ZEPHIR_INIT_VAR(&_9$$3); - ZEPHIR_CONCAT_SVSSVS(&_9$$3, " OFFSET ", &_6$$3, " ROWS", " FETCH NEXT ", &_8$$3, " ROWS ONLY"); - zephir_get_strval(&limit, &_9$$3); - } - RETURN_CTOR(&limit); -} - -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, appendCondition) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *store_param = NULL, *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, key, _2, _3, _5, _6, _7, _8, _9, _10, _0$$3, _1$$3, _4$$4; - zval store, condition; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&store); - ZVAL_UNDEF(&condition); - ZVAL_UNDEF(&value_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_4$$4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 4) - Z_PARAM_STR(store) - Z_PARAM_STR(condition) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) - Z_PARAM_LONG(type) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 2, &store_param, &condition_param, &value, &type_param); - zephir_get_strval(&store, store_param); - zephir_get_strval(&condition, condition_param); - if (!value) { - value = &value_sub; - value = &__$null; - } - if (!type_param) { - type = -1; - } else { - } - if (!(ZEPHIR_IS_EMPTY(value))) { - ZVAL_LONG(&_1$$3, type); - ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "bindinline", NULL, 0, value, &_1$$3); + ZEPHIR_CALL_METHOD(&reader, this_ptr, "getreader", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&parsedAnnotations, &reader, "parse", NULL, 0, &realClassName); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&classAnnotations); + object_init_ex(&classAnnotations, phalcon_annotations_reflection_ce); + ZEPHIR_CALL_METHOD(NULL, &classAnnotations, "__construct", NULL, 37, &parsedAnnotations); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("annotations"), &realClassName, &classAnnotations); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, &realClassName, &classAnnotations); zephir_check_call_status(); - zephir_concat_self(&condition, &_0$$3); - } - zephir_read_property(&_2, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_3, &_2, &store, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 327); - if (ZEPHIR_IS_EMPTY(&_3)) { - ZEPHIR_INIT_VAR(&_4$$4); - ZVAL_STRING(&_4$$4, ""); - zephir_update_property_array_multi(this_ptr, SL("store"), &_4$$4, SL("za"), 2, &store); } - zephir_read_property(&_5, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_6, &_5, &store, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 331); - ZEPHIR_CALL_FUNCTION(&key, "array_key_last", NULL, 40, &_6); - zephir_check_call_status(); - zephir_read_property(&_7, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_8, &_7, &store, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 333); - zephir_array_fetch(&_9, &_8, &key, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 333); - ZEPHIR_INIT_VAR(&_10); - ZEPHIR_CONCAT_VV(&_10, &_9, &condition); - zephir_update_property_array_multi(this_ptr, SL("store"), &_10, SL("zz"), 2, &store, &key); - ZEPHIR_MM_RESTORE(); + RETURN_CCTOR(&classAnnotations); } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, processValue) +static PHP_METHOD(Phalcon_Annotations_Adapter_AbstractAdapter, getConstant) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *store_param = NULL, *data = NULL, data_sub, _0$$3, _1$$4, _2$$4, _3$$4; - zval store; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *className_param = NULL, *constantName_param = NULL, constants, constant; + zval className, constantName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&store); - ZVAL_UNDEF(&data_sub); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&constantName); + ZVAL_UNDEF(&constants); + ZVAL_UNDEF(&constant); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(store) - Z_PARAM_ZVAL(data) + Z_PARAM_STR(className) + Z_PARAM_STR(constantName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &store_param, &data); - zephir_get_strval(&store, store_param); - ZEPHIR_SEPARATE_PARAM(data); - if (Z_TYPE_P(data) == IS_STRING) { - ZEPHIR_INIT_VAR(&_0$$3); - zephir_create_array(&_0$$3, 1, 0); - zephir_array_fast_append(&_0$$3, data); - ZEPHIR_CPY_WRT(data, &_0$$3); - } - if (Z_TYPE_P(data) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_1$$4); - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_3$$4, &_2$$4, &store, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 350); - zephir_fast_array_merge(&_1$$4, &_3$$4, data); - zephir_update_property_array(this_ptr, SL("store"), &store, &_1$$4); + zephir_fetch_params(1, 2, 0, &className_param, &constantName_param); + zephir_get_strval(&className, className_param); + zephir_get_strval(&constantName, constantName_param); + ZEPHIR_CALL_METHOD(&constants, this_ptr, "getconstants", NULL, 0, &className); + zephir_check_call_status(); + if (!(zephir_array_isset_fetch(&constant, &constants, &constantName, 1))) { + object_init_ex(return_value, phalcon_annotations_collection_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 38); + zephir_check_call_status(); + RETURN_MM(); } - ZEPHIR_MM_RESTORE(); + RETURN_CTOR(&constant); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Query_AbstractQuery) +static PHP_METHOD(Phalcon_Annotations_Adapter_AbstractAdapter, getConstants) { - ZEPHIR_REGISTER_CLASS(Phalcon\\DataMapper\\Query, AbstractQuery, phalcon, datamapper_query_abstractquery, phalcon_datamapper_query_abstractquery_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_datamapper_query_abstractquery_ce, SL("bind"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_datamapper_query_abstractquery_ce, SL("connection"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_datamapper_query_abstractquery_ce, SL("store"), ZEND_ACC_PROTECTED); - phalcon_datamapper_query_abstractquery_ce->create_object = zephir_init_properties_Phalcon_DataMapper_Query_AbstractQuery; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *className_param = NULL, classAnnotations; + zval className; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&classAnnotations); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(className) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &className_param); + zephir_get_strval(&className, className_param); + ZEPHIR_CALL_METHOD(&classAnnotations, this_ptr, "get", NULL, 0, &className); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(&classAnnotations, "getconstantsannotations", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, __construct) +static PHP_METHOD(Phalcon_Annotations_Adapter_AbstractAdapter, getProperty) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connection, connection_sub, *bind, bind_sub, _0, _1; + zval *className_param = NULL, *propertyName_param = NULL, classAnnotations, properties, property; + zval className, propertyName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connection_sub); - ZVAL_UNDEF(&bind_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&propertyName); + ZVAL_UNDEF(&classAnnotations); + ZVAL_UNDEF(&properties); + ZVAL_UNDEF(&property); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_datamapper_pdo_connection_ce) - Z_PARAM_OBJECT_OF_CLASS(bind, phalcon_datamapper_query_bind_ce) + Z_PARAM_STR(className) + Z_PARAM_STR(propertyName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &connection, &bind); - zephir_update_property_zval(this_ptr, ZEND_STRL("bind"), bind); - zephir_update_property_zval(this_ptr, ZEND_STRL("connection"), connection); - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "UNION"); - zephir_update_property_array(this_ptr, SL("store"), &_1, &_0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "reset", NULL, 0); + zephir_fetch_params(1, 2, 0, &className_param, &propertyName_param); + zephir_get_strval(&className, className_param); + zephir_get_strval(&propertyName, propertyName_param); + ZEPHIR_CALL_METHOD(&classAnnotations, this_ptr, "get", NULL, 0, &className); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + ZEPHIR_CALL_METHOD(&properties, &classAnnotations, "getpropertiesannotations", NULL, 0); + zephir_check_call_status(); + if (!(zephir_array_isset_fetch(&property, &properties, &propertyName, 1))) { + object_init_ex(return_value, phalcon_annotations_collection_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 38); + zephir_check_call_status(); + RETURN_MM(); + } + RETURN_CTOR(&property); } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, bindInline) +static PHP_METHOD(Phalcon_Annotations_Adapter_AbstractAdapter, getProperties) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *value, value_sub, *type_param = NULL, _0, _1; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *className_param = NULL, classAnnotations; + zval className; zval *this_ptr = getThis(); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(value) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(type) + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&classAnnotations); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(className) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &value, &type_param); - if (!type_param) { - type = -1; - } else { - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_1, type); - ZEPHIR_RETURN_CALL_METHOD(&_0, "bindinline", NULL, 0, value, &_1); + zephir_fetch_params(1, 1, 0, &className_param); + zephir_get_strval(&className, className_param); + ZEPHIR_CALL_METHOD(&classAnnotations, this_ptr, "get", NULL, 0, &className); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(&classAnnotations, "getpropertiesannotations", NULL, 0); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, bindValue) +static PHP_METHOD(Phalcon_Annotations_Adapter_AbstractAdapter, getMethod) { + zend_string *_3$$3; + zend_ulong _2$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub, *type_param = NULL, _0, _1; - zval key; + zephir_fcall_cache_entry *_5 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *className_param = NULL, *methodName_param = NULL, classAnnotations, methods, method, methodKey, *_0$$3, _1$$3, _4$$4, _6$$6; + zval className, methodName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(type) + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&methodName); + ZVAL_UNDEF(&classAnnotations); + ZVAL_UNDEF(&methods); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&methodKey); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_6$$6); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(className) + Z_PARAM_STR(methodName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &key_param, &value, &type_param); - zephir_get_strval(&key, key_param); - if (!type_param) { - type = -1; - } else { + zephir_fetch_params(1, 2, 0, &className_param, &methodName_param); + zephir_get_strval(&className, className_param); + zephir_get_strval(&methodName, methodName_param); + ZEPHIR_CALL_METHOD(&classAnnotations, this_ptr, "get", NULL, 0, &className); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&methods, &classAnnotations, "getmethodsannotations", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&methods) == IS_ARRAY) { + zephir_is_iterable(&methods, 0, "phalcon/Annotations/Adapter/AbstractAdapter.zep", 167); + if (Z_TYPE_P(&methods) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&methods), _2$$3, _3$$3, _0$$3) + { + ZEPHIR_INIT_NVAR(&methodKey); + if (_3$$3 != NULL) { + ZVAL_STR_COPY(&methodKey, _3$$3); + } else { + ZVAL_LONG(&methodKey, _2$$3); + } + ZEPHIR_INIT_NVAR(&method); + ZVAL_COPY(&method, _0$$3); + ZEPHIR_CALL_FUNCTION(&_4$$4, "strcasecmp", &_5, 39, &methodKey, &methodName); + zephir_check_call_status(); + if (!(zephir_is_true(&_4$$4))) { + RETURN_CCTOR(&method); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &methods, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1$$3, &methods, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&methodKey, &methods, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&method, &methods, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_6$$6, "strcasecmp", &_5, 39, &methodKey, &methodName); + zephir_check_call_status(); + if (!(zephir_is_true(&_6$$6))) { + RETURN_CCTOR(&method); + } + ZEPHIR_CALL_METHOD(NULL, &methods, "next", NULL, 0); + zephir_check_call_status(); + } } - zephir_read_property(&_0, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_1, type); - ZEPHIR_CALL_METHOD(NULL, &_0, "setvalue", NULL, 0, &key, value, &_1); + ZEPHIR_INIT_NVAR(&method); + ZEPHIR_INIT_NVAR(&methodKey); + } + object_init_ex(return_value, phalcon_annotations_collection_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 38); zephir_check_call_status(); - RETURN_THIS(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, bindValues) +static PHP_METHOD(Phalcon_Annotations_Adapter_AbstractAdapter, getMethods) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *values_param = NULL, _0; - zval values; + zval *className_param = NULL, classAnnotations; + zval className; zval *this_ptr = getThis(); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&classAnnotations); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(values) + Z_PARAM_STR(className) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &values_param); - zephir_get_arrval(&values, values_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "setvalues", NULL, 0, &values); + zephir_fetch_params(1, 1, 0, &className_param); + zephir_get_strval(&className, className_param); + ZEPHIR_CALL_METHOD(&classAnnotations, this_ptr, "get", NULL, 0, &className); zephir_check_call_status(); - RETURN_THIS(); + ZEPHIR_RETURN_CALL_METHOD(&classAnnotations, "getmethodsannotations", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, getBindValues) +static PHP_METHOD(Phalcon_Annotations_Adapter_AbstractAdapter, getReader) { - zval _0; + zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "toarray", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("reader"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_annotations_reader_ce); + if (zephir_has_constructor(&_1$$3)) { + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 0); + zephir_check_call_status(); + } + + zephir_update_property_zval(this_ptr, ZEND_STRL("reader"), &_1$$3); + } + RETURN_MM_MEMBER(getThis(), "reader"); } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, getStatement) +static PHP_METHOD(Phalcon_Annotations_Adapter_AbstractAdapter, setReader) { + zval *reader, reader_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&reader_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(reader, phalcon_annotations_readerinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &reader); + zephir_update_property_zval(this_ptr, ZEND_STRL("reader"), reader); } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, perform) +zend_object *zephir_init_properties_Phalcon_Annotations_Adapter_AbstractAdapter(zend_class_entry *class_type) { - zval _0, _1, _2; + zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("annotations"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("annotations"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } +} - zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstatement", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getbindvalues", NULL, 0); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&_0, "perform", NULL, 0, &_1, &_2); - zephir_check_call_status(); - RETURN_MM(); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Annotations_Adapter_AdapterInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Annotations\\Adapter, AdapterInterface, phalcon, annotations_adapter_adapterinterface, phalcon_annotations_adapter_adapterinterface_method_entry); + + return SUCCESS; } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, setFlag) +ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, get); +ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, getConstant); +ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, getConstants); +ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, getProperty); +ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, getProperties); +ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, getMethod); +ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, getMethods); +ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, getReader); +ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, setReader); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Annotations_Adapter_Apcu) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Annotations\\Adapter, Apcu, phalcon, annotations_adapter_apcu, phalcon_annotations_adapter_abstractadapter_ce, phalcon_annotations_adapter_apcu_method_entry, 0); + + zend_declare_property_string(phalcon_annotations_adapter_apcu_ce, SL("prefix"), "", ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_annotations_adapter_apcu_ce, SL("ttl"), 172800, ZEND_ACC_PROTECTED); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Annotations_Adapter_Apcu, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool enable; - zval *flag_param = NULL, *enable_param = NULL, __$true, flags, _0$$4, _1$$4; - zval flag; + zval *options_param = NULL, prefix, ttl; + zval options; zval *this_ptr = getThis(); - ZVAL_UNDEF(&flag); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&flags); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$4); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(flag) + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&prefix); + ZVAL_UNDEF(&ttl); + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(enable) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &flag_param, &enable_param); - zephir_get_strval(&flag, flag_param); - if (!enable_param) { - enable = 1; - } else { - } - if (enable) { - zephir_update_property_array_multi(this_ptr, SL("store"), &__$true, SL("sz"), 3, SL("FLAGS"), &flag); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - zephir_read_property(&_0$$4, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&flags); - zephir_array_fetch_string(&flags, &_0$$4, SL("FLAGS"), PH_NOISY, "phalcon/DataMapper/Query/AbstractQuery.zep", 144); - zephir_array_unset(&flags, &flag, PH_SEPARATE); - ZEPHIR_INIT_VAR(&_1$$4); - ZVAL_STRING(&_1$$4, "FLAGS"); - zephir_update_property_array(this_ptr, SL("store"), &_1$$4, &flags); + zephir_get_arrval(&options, options_param); + } + zephir_memory_observe(&prefix); + if (zephir_array_isset_string_fetch(&prefix, &options, SL("prefix"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("prefix"), &prefix); + } + zephir_memory_observe(&ttl); + if (zephir_array_isset_string_fetch(&ttl, &options, SL("lifetime"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("ttl"), &ttl); } ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, quoteIdentifier) +static PHP_METHOD(Phalcon_Annotations_Adapter_Apcu, read) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, *type_param = NULL, _0, _1; - zval name; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL, _0, _1, _2; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); + ZVAL_UNDEF(&key); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(name) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(type) + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &name_param, &type_param); - zephir_get_strval(&name, name_param); - if (!type_param) { - type = 2; + zephir_fetch_params(1, 1, 0, &key_param); + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); } else { - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_1, type); - ZEPHIR_RETURN_CALL_METHOD(&_0, "quote", NULL, 0, &name, &_1); + ZEPHIR_INIT_VAR(&key); + } + ZEPHIR_INIT_VAR(&_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_CONCAT_SVV(&_2, "_PHAN", &_1, &key); + zephir_fast_strtolower(&_0, &_2); + ZEPHIR_RETURN_CALL_FUNCTION("apcu_fetch", NULL, 107, &_0); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, reset) +static PHP_METHOD(Phalcon_Annotations_Adapter_Apcu, write) { - zval _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL, *data, data_sub, _0, _1, _2, _3; + zval key; zval *this_ptr = getThis(); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&data_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_13); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_15); - ZVAL_UNDEF(&_16); - ZVAL_UNDEF(&_17); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(key) + Z_PARAM_OBJECT_OF_CLASS(data, phalcon_annotations_reflection_ce) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - + zephir_fetch_params(1, 2, 0, &key_param, &data); + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); + } else { + ZEPHIR_INIT_VAR(&key); + } ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "COLUMNS"); - zephir_update_property_array(this_ptr, SL("store"), &_1, &_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); ZEPHIR_INIT_VAR(&_2); - array_init(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "FLAGS"); - zephir_update_property_array(this_ptr, SL("store"), &_3, &_2); - ZEPHIR_INIT_VAR(&_4); - array_init(&_4); - ZEPHIR_INIT_VAR(&_5); - ZVAL_STRING(&_5, "FROM"); - zephir_update_property_array(this_ptr, SL("store"), &_5, &_4); - ZEPHIR_INIT_VAR(&_6); - array_init(&_6); - ZEPHIR_INIT_VAR(&_7); - ZVAL_STRING(&_7, "GROUP"); - zephir_update_property_array(this_ptr, SL("store"), &_7, &_6); - ZEPHIR_INIT_VAR(&_8); - array_init(&_8); - ZEPHIR_INIT_VAR(&_9); - ZVAL_STRING(&_9, "HAVING"); - zephir_update_property_array(this_ptr, SL("store"), &_9, &_8); - ZEPHIR_INIT_VAR(&_10); - ZVAL_STRING(&_10, "LIMIT"); - ZEPHIR_INIT_VAR(&_11); - ZVAL_LONG(&_11, 0); - zephir_update_property_array(this_ptr, SL("store"), &_10, &_11); - ZEPHIR_INIT_VAR(&_12); - array_init(&_12); - ZEPHIR_INIT_VAR(&_13); - ZVAL_STRING(&_13, "ORDER"); - zephir_update_property_array(this_ptr, SL("store"), &_13, &_12); - ZEPHIR_INIT_VAR(&_14); - ZVAL_STRING(&_14, "OFFSET"); - ZEPHIR_INIT_VAR(&_15); - ZVAL_LONG(&_15, 0); - zephir_update_property_array(this_ptr, SL("store"), &_14, &_15); - ZEPHIR_INIT_VAR(&_16); - array_init(&_16); - ZEPHIR_INIT_VAR(&_17); - ZVAL_STRING(&_17, "WHERE"); - zephir_update_property_array(this_ptr, SL("store"), &_17, &_16); - ZEPHIR_MM_RESTORE(); + ZEPHIR_CONCAT_SVV(&_2, "_PHAN", &_1, &key); + zephir_fast_strtolower(&_0, &_2); + zephir_read_property(&_3, this_ptr, ZEND_STRL("ttl"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_FUNCTION("apcu_store", NULL, 108, &_0, data, &_3); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, resetColumns) -{ - zval _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "COLUMNS"); - zephir_update_property_array(this_ptr, SL("store"), &_1, &_0); - ZEPHIR_MM_RESTORE(); -} -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, resetFrom) -{ - zval _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); +#ifdef HAVE_CONFIG_H +#endif - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "FROM"); - zephir_update_property_array(this_ptr, SL("store"), &_1, &_0); - ZEPHIR_MM_RESTORE(); -} -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, resetWhere) -{ - zval _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "WHERE"); - zephir_update_property_array(this_ptr, SL("store"), &_1, &_0); - ZEPHIR_MM_RESTORE(); +ZEPHIR_INIT_CLASS(Phalcon_Annotations_Adapter_Memory) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Annotations\\Adapter, Memory, phalcon, annotations_adapter_memory, phalcon_annotations_adapter_abstractadapter_ce, phalcon_annotations_adapter_memory_method_entry, 0); + + zend_declare_property_null(phalcon_annotations_adapter_memory_ce, SL("data"), ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, resetGroupBy) +static PHP_METHOD(Phalcon_Annotations_Adapter_Memory, read) { - zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *key_param = NULL, data, _0, _1; + zval key; zval *this_ptr = getThis(); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&data); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(key) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); + zephir_fetch_params(1, 1, 0, &key_param); + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); + } else { + ZEPHIR_INIT_VAR(&key); + } + zephir_memory_observe(&data); + zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "GROUP"); - zephir_update_property_array(this_ptr, SL("store"), &_1, &_0); - ZEPHIR_MM_RESTORE(); + zephir_fast_strtolower(&_1, &key); + if (!(zephir_array_isset_fetch(&data, &_0, &_1, 0))) { + RETURN_MM_BOOL(0); + } + RETURN_CCTOR(&data); } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, resetHaving) +static PHP_METHOD(Phalcon_Annotations_Adapter_Memory, write) { - zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *key_param = NULL, *data, data_sub, lowercasedKey; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&data_sub); + ZVAL_UNDEF(&lowercasedKey); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(key) + Z_PARAM_OBJECT_OF_CLASS(data, phalcon_annotations_reflection_ce) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "HAVING"); - zephir_update_property_array(this_ptr, SL("store"), &_1, &_0); + zephir_fetch_params(1, 2, 0, &key_param, &data); + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); + } else { + ZEPHIR_INIT_VAR(&key); + } + ZEPHIR_INIT_VAR(&lowercasedKey); + zephir_fast_strtolower(&lowercasedKey, &key); + zephir_update_property_array(this_ptr, SL("data"), &lowercasedKey, data); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, resetOrderBy) -{ - zval _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "ORDER"); - zephir_update_property_array(this_ptr, SL("store"), &_1, &_0); - ZEPHIR_MM_RESTORE(); -} -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, resetLimit) -{ - zval _0, _1, _2, _3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); +#ifdef HAVE_CONFIG_H +#endif - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "LIMIT"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_LONG(&_1, 0); - zephir_update_property_array(this_ptr, SL("store"), &_0, &_1); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "OFFSET"); - ZEPHIR_INIT_VAR(&_3); - ZVAL_LONG(&_3, 0); - zephir_update_property_array(this_ptr, SL("store"), &_2, &_3); - ZEPHIR_MM_RESTORE(); -} -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, resetFlags) -{ - zval _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "FLAGS"); - zephir_update_property_array(this_ptr, SL("store"), &_1, &_0); - ZEPHIR_MM_RESTORE(); +ZEPHIR_INIT_CLASS(Phalcon_Annotations_Adapter_Stream) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Annotations\\Adapter, Stream, phalcon, annotations_adapter_stream, phalcon_annotations_adapter_abstractadapter_ce, phalcon_annotations_adapter_stream_method_entry, 0); + + zend_declare_property_string(phalcon_annotations_adapter_stream_ce, SL("annotationsDir"), "./", ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, buildFlags) +static PHP_METHOD(Phalcon_Annotations_Adapter_Stream, __construct) { - zval _0, _1, _2, _3, _4, _5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *options_param = NULL, annotationsDir; + zval options; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&annotationsDir); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_1, &_0, SL("FLAGS"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractQuery.zep", 255); - if (ZEPHIR_IS_EMPTY(&_1)) { - RETURN_MM_STRING(""); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); } - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_INIT_VAR(&_3); - zephir_read_property(&_4, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_5, &_4, SL("FLAGS"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractQuery.zep", 259); - zephir_array_keys(&_3, &_5); - zephir_fast_join_str(&_2, SL(" "), &_3); - ZEPHIR_CONCAT_SV(return_value, " ", &_2); - RETURN_MM(); + zephir_memory_observe(&annotationsDir); + if (zephir_array_isset_string_fetch(&annotationsDir, &options, SL("annotationsDir"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("annotationsDir"), &annotationsDir); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, buildReturning) +static PHP_METHOD(Phalcon_Annotations_Adapter_Stream, read) { - zval _0, _1, _2, _3, _4, _5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL, __$false, contents, version, _0, _1, _2, _3, _4, _5, _6, _11, _7$$5, _8$$5, _9$$6, _10$$6; + zval key, path; zval *this_ptr = getThis(); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&path); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&contents); + ZVAL_UNDEF(&version); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_9$$6); + ZVAL_UNDEF(&_10$$6); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(key) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_1, &_0, SL("RETURNING"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractQuery.zep", 269); - if (ZEPHIR_IS_EMPTY(&_1)) { - RETURN_MM_STRING(""); + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("annotationsDir"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "_"); + zephir_prepare_virtual_path(&_1, &key, &_2); + ZEPHIR_INIT_VAR(&_3); + ZEPHIR_CONCAT_VVS(&_3, &_0, &_1, ".php"); + zephir_get_strval(&path, &_3); + if (!((zephir_file_exists(&path) == SUCCESS))) { + RETURN_MM_BOOL(0); } - zephir_read_property(&_3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_4, &_3, SL("RETURNING"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractQuery.zep", 273); + ZEPHIR_INIT_VAR(&contents); + zephir_file_get_contents(&contents, &path); + if (UNEXPECTED(ZEPHIR_IS_EMPTY(&contents))) { + RETURN_MM_BOOL(0); + } + ZEPHIR_GLOBAL(warning).enable = zend_is_true(&__$false); + ZEPHIR_CALL_FUNCTION(&version, "phpversion", NULL, 133); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "8.0"); ZEPHIR_INIT_VAR(&_5); - ZVAL_STRING(&_5, ","); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "indent", NULL, 0, &_4, &_5); + ZVAL_STRING(&_5, ">="); + ZEPHIR_CALL_FUNCTION(&_6, "version_compare", NULL, 134, &version, &_4, &_5); zephir_check_call_status(); - ZEPHIR_CONCAT_SV(return_value, " RETURNING", &_2); - RETURN_MM(); + if (zephir_is_true(&_6)) { + ZEPHIR_INIT_VAR(&_7$$5); + ZEPHIR_INIT_NVAR(&_7$$5); + zephir_create_closure_ex(&_7$$5, NULL, phalcon_4__closure_ce, SL("__invoke")); + ZVAL_LONG(&_8$$5, 2); + ZEPHIR_CALL_FUNCTION(NULL, "set_error_handler", NULL, 135, &_7$$5, &_8$$5); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_VAR(&_9$$6); + ZEPHIR_INIT_NVAR(&_9$$6); + zephir_create_closure_ex(&_9$$6, NULL, phalcon_5__closure_ce, SL("__invoke")); + ZVAL_LONG(&_10$$6, 2); + ZEPHIR_CALL_FUNCTION(NULL, "set_error_handler", NULL, 135, &_9$$6, &_10$$6); + zephir_check_call_status(); + } + ZEPHIR_CALL_FUNCTION(&_11, "unserialize", NULL, 16, &contents); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&contents, &_11); + ZEPHIR_CALL_FUNCTION(NULL, "restore_error_handler", NULL, 136); + zephir_check_call_status(); + if (UNEXPECTED(ZEPHIR_GLOBAL(warning).enable)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_RuntimeException, "Cannot read annotation data", "phalcon/Annotations/Adapter/Stream.zep", 102); + return; + } + RETURN_CCTOR(&contents); } -static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, indent) +static PHP_METHOD(Phalcon_Annotations_Adapter_Stream, write) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval glue, _1; - zval *collection_param = NULL, *glue_param = NULL, _0; - zval collection; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL, *data, data_sub, code, _0, _1, _2, _3, _4; + zval key, path; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&path); + ZVAL_UNDEF(&data_sub); + ZVAL_UNDEF(&code); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&glue); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(collection) - Z_PARAM_OPTIONAL - Z_PARAM_STR(glue) + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(key) + Z_PARAM_OBJECT_OF_CLASS(data, phalcon_annotations_reflection_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &collection_param, &glue_param); - zephir_get_arrval(&collection, collection_param); - if (!glue_param) { - ZEPHIR_INIT_VAR(&glue); - ZVAL_STRING(&glue, ""); - } else { - zephir_get_strval(&glue, glue_param); + zephir_fetch_params(1, 2, 0, &key_param, &data); + if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + RETURN_MM_NULL(); } - if (ZEPHIR_IS_EMPTY(&collection)) { - RETURN_MM_STRING(""); + if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { + zephir_get_strval(&key, key_param); + } else { + ZEPHIR_INIT_VAR(&key); } - ZEPHIR_INIT_VAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("annotationsDir"), PH_NOISY_CC | PH_READONLY); ZEPHIR_INIT_VAR(&_1); - ZEPHIR_CONCAT_VS(&_1, &glue, " "); - zephir_fast_join(&_0, &_1, &collection); - ZEPHIR_CONCAT_SV(return_value, " ", &_0); - RETURN_MM(); -} - -zend_object *zephir_init_properties_Phalcon_DataMapper_Query_AbstractQuery(zend_class_entry *class_type) -{ - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("store"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "_"); + zephir_prepare_virtual_path(&_1, &key, &_2); + ZEPHIR_INIT_VAR(&_3); + ZEPHIR_CONCAT_VVS(&_3, &_0, &_1, ".php"); + zephir_get_strval(&path, &_3); + ZEPHIR_CALL_FUNCTION(&code, "serialize", NULL, 15, data); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4); + zephir_file_put_contents(&_4, &path, &code); + if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&_4))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_annotations_exception_ce, "Annotations directory cannot be written", "phalcon/Annotations/Adapter/Stream.zep", 123); + return; } + ZEPHIR_MM_RESTORE(); } @@ -111443,348 +110171,280 @@ zend_object *zephir_init_properties_Phalcon_DataMapper_Query_AbstractQuery(zend_ -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Query_Bind) +ZEPHIR_INIT_CLASS(Phalcon_Events_AbstractEventsAware) { - ZEPHIR_REGISTER_CLASS(Phalcon\\DataMapper\\Query, Bind, phalcon, datamapper_query_bind, phalcon_datamapper_query_bind_method_entry, 0); - - zend_declare_property_long(phalcon_datamapper_query_bind_ce, SL("inlineCount"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_datamapper_query_bind_ce, SL("store"), ZEND_ACC_PROTECTED); - phalcon_datamapper_query_bind_ce->create_object = zephir_init_properties_Phalcon_DataMapper_Query_Bind; + ZEPHIR_REGISTER_CLASS(Phalcon\\Events, AbstractEventsAware, phalcon, events_abstracteventsaware, phalcon_events_abstracteventsaware_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + zend_declare_property_null(phalcon_events_abstracteventsaware_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_DataMapper_Query_Bind, bindInline) +static PHP_METHOD(Phalcon_Events_AbstractEventsAware, getEventsManager) { - zend_bool _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *value, value_sub, *type_param = NULL, key, _3, _4, _5, _1$$3, _2$$4; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(value) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(type) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &value, &type_param); - if (!type_param) { - type = -1; - } else { - } - _0 = Z_TYPE_P(value) == IS_OBJECT; - if (_0) { - _0 = zephir_instance_of_ev(value, phalcon_datamapper_query_select_ce); - } - if (_0) { - ZEPHIR_CALL_METHOD(&_1$$3, value, "getstatement", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CONCAT_SVS(return_value, "(", &_1$$3, ")"); - RETURN_MM(); - } - if (Z_TYPE_P(value) == IS_ARRAY) { - ZVAL_LONG(&_2$$4, type); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "inlinearray", NULL, 0, value, &_2$$4); - zephir_check_call_status(); - RETURN_MM(); - } - zephir_read_property(&_3, this_ptr, ZEND_STRL("inlineCount"), PH_NOISY_CC | PH_READONLY); - ZVAL_UNDEF(&_4); - ZVAL_LONG(&_4, (zephir_get_numberval(&_3) + 1)); - zephir_update_property_zval(this_ptr, ZEND_STRL("inlineCount"), &_4); - zephir_read_property(&_4, this_ptr, ZEND_STRL("inlineCount"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&key); - ZEPHIR_CONCAT_SVS(&key, "__", &_4, "__"); - ZVAL_LONG(&_5, type); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setvalue", NULL, 0, &key, value, &_5); - zephir_check_call_status(); - ZEPHIR_CONCAT_SV(return_value, ":", &key); - RETURN_MM(); + RETURN_MEMBER(getThis(), "eventsManager"); } -static PHP_METHOD(Phalcon_DataMapper_Query_Bind, remove) +static PHP_METHOD(Phalcon_Events_AbstractEventsAware, setEventsManager) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *key_param = NULL, store, _0; - zval key; + zval *eventsManager, eventsManager_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&store); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&eventsManager_sub); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - zephir_get_strval(&key, key_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&store, &_0); - zephir_array_unset(&store, &key, PH_SEPARATE); - zephir_update_property_zval(this_ptr, ZEND_STRL("store"), &store); - ZEPHIR_MM_RESTORE(); + zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); + zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); } -static PHP_METHOD(Phalcon_DataMapper_Query_Bind, setValue) +static PHP_METHOD(Phalcon_Events_AbstractEventsAware, fireManagerEvent) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub, *type_param = NULL, localType; - zval key; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool cancellable; + zval *eventName_param = NULL, *data = NULL, data_sub, *cancellable_param = NULL, __$null, _0, _1$$3, _2$$3; + zval eventName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&localType); + ZVAL_UNDEF(&eventName); + ZVAL_UNDEF(&data_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(eventName) Z_PARAM_OPTIONAL - Z_PARAM_LONG(type) + Z_PARAM_ZVAL_OR_NULL(data) + Z_PARAM_BOOL(cancellable) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &key_param, &value, &type_param); - zephir_get_strval(&key, key_param); - if (!type_param) { - type = -1; + zephir_fetch_params(1, 1, 2, &eventName_param, &data, &cancellable_param); + zephir_get_strval(&eventName, eventName_param); + if (!data) { + data = &data_sub; + data = &__$null; + } + if (!cancellable_param) { + cancellable = 1; } else { } - ZEPHIR_INIT_VAR(&localType); - ZVAL_LONG(&localType, type); - if (ZEPHIR_IS_LONG_IDENTICAL(&localType, -1)) { - ZEPHIR_CALL_METHOD(&localType, this_ptr, "gettype", NULL, 0, value); + zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) != IS_NULL) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + if (cancellable) { + ZVAL_BOOL(&_2$$3, 1); + } else { + ZVAL_BOOL(&_2$$3, 0); + } + ZEPHIR_RETURN_CALL_METHOD(&_1$$3, "fire", NULL, 0, &eventName, this_ptr, data, &_2$$3); zephir_check_call_status(); + RETURN_MM(); } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 2, 0); - zephir_array_fast_append(&_0, value); - zephir_array_fast_append(&_0, &localType); - zephir_update_property_array(this_ptr, SL("store"), &key, &_0); - ZEPHIR_MM_RESTORE(); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_DataMapper_Query_Bind, setValues) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Events_Event) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Events, Event, phalcon, events_event, phalcon_events_event_method_entry, 0); + + zend_declare_property_null(phalcon_events_event_ce, SL("cancelable"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_events_event_ce, SL("data"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_events_event_ce, SL("source"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_events_event_ce, SL("stopped"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_events_event_ce, SL("type"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_events_event_ce, 1, phalcon_events_eventinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Events_Event, __construct) { - zend_string *_3; - zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *values_param = NULL, *type_param = NULL, key, value, *_0, _1, _4$$3, _6$$4; - zval values; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool cancelable, _0; + zval *type_param = NULL, *source = NULL, source_sub, *data = NULL, data_sub, *cancelable_param = NULL, __$true, __$false, __$null, _1$$3, _2$$3, _3$$3; + zval type; zval *this_ptr = getThis(); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_6$$4); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(values) + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&source_sub); + ZVAL_UNDEF(&data_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_STR(type) Z_PARAM_OPTIONAL - Z_PARAM_LONG(type) + Z_PARAM_ZVAL_OR_NULL(source) + Z_PARAM_ZVAL_OR_NULL(data) + Z_PARAM_BOOL(cancelable) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &values_param, &type_param); - zephir_get_arrval(&values, values_param); - if (!type_param) { - type = -1; + zephir_fetch_params(1, 1, 3, &type_param, &source, &data, &cancelable_param); + if (UNEXPECTED(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(type_param) == IS_STRING)) { + zephir_get_strval(&type, type_param); } else { - } - zephir_is_iterable(&values, 0, "phalcon/DataMapper/Query/Bind.zep", 108); - if (Z_TYPE_P(&values) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&values), _2, _3, _0) - { - ZEPHIR_INIT_NVAR(&key); - if (_3 != NULL) { - ZVAL_STR_COPY(&key, _3); - } else { - ZVAL_LONG(&key, _2); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0); - ZVAL_LONG(&_4$$3, type); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setvalue", &_5, 0, &key, &value, &_4$$3); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); + ZEPHIR_INIT_VAR(&type); + } + if (!source) { + source = &source_sub; + source = &__$null; + } + if (!data) { + data = &data_sub; + data = &__$null; + } + if (!cancelable_param) { + cancelable = 1; } else { - ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &values, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &values, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); - zephir_check_call_status(); - ZVAL_LONG(&_6$$4, type); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setvalue", &_5, 0, &key, &value, &_6$$4); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); - zephir_check_call_status(); } + _0 = Z_TYPE_P(source) != IS_NULL; + if (_0) { + _0 = Z_TYPE_P(source) != IS_OBJECT; + } + if (UNEXPECTED(_0)) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_events_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + zephir_gettype(&_2$$3, source); + ZEPHIR_INIT_VAR(&_3$$3); + ZEPHIR_CONCAT_SVSV(&_3$$3, "The source of ", &type, " event must be an object, got ", &_2$$3); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_3$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Events/Event.zep", 73); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &type); + zephir_update_property_zval(this_ptr, ZEND_STRL("source"), source); + zephir_update_property_zval(this_ptr, ZEND_STRL("data"), data); + if (cancelable) { + zephir_update_property_zval(this_ptr, ZEND_STRL("cancelable"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("cancelable"), &__$false); } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Bind, toArray) +static PHP_METHOD(Phalcon_Events_Event, getData) { - RETURN_MEMBER(getThis(), "store"); + RETURN_MEMBER(getThis(), "data"); } -static PHP_METHOD(Phalcon_DataMapper_Query_Bind, getType) +static PHP_METHOD(Phalcon_Events_Event, getSource) { - zval *value, value_sub; - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(value) + RETURN_MEMBER(getThis(), "source"); +} + +static PHP_METHOD(Phalcon_Events_Event, getType) +{ + + RETURN_MEMBER(getThis(), "type"); +} + +static PHP_METHOD(Phalcon_Events_Event, isCancelable) +{ + + RETURN_MEMBER(getThis(), "cancelable"); +} + +static PHP_METHOD(Phalcon_Events_Event, isStopped) +{ + + RETURN_MEMBER(getThis(), "stopped"); +} + +static PHP_METHOD(Phalcon_Events_Event, setData) +{ + zval *data = NULL, data_sub, __$null; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&data_sub); + ZVAL_NULL(&__$null); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(data) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &value); - if (Z_TYPE_P(value) == IS_NULL) { - RETURN_LONG(0); - } - if (((Z_TYPE_P(value) == IS_TRUE || Z_TYPE_P(value) == IS_FALSE) == 1)) { - RETURN_LONG(5); - } - if (Z_TYPE_P(value) == IS_LONG) { - RETURN_LONG(1); + zephir_fetch_params_without_memory_grow(0, 1, &data); + if (!data) { + data = &data_sub; + data = &__$null; } - RETURN_LONG(2); + zephir_update_property_zval(this_ptr, ZEND_STRL("data"), data); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Bind, inlineArray) +static PHP_METHOD(Phalcon_Events_Event, setType) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *data_param = NULL, *type_param = NULL, key, value, *_0, _1, _11, _2$$3, _3$$3, _4$$3, _6$$3, _7$$4, _8$$4, _9$$4, _10$$4; - zval data, keys; + zval *type_param = NULL; + zval type; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&keys); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_10$$4); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ARRAY(data) - Z_PARAM_LONG(type) + ZVAL_UNDEF(&type); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &data_param, &type_param); - zephir_get_arrval(&data, data_param); - ZEPHIR_INIT_VAR(&keys); - array_init(&keys); - zephir_is_iterable(&data, 0, "phalcon/DataMapper/Query/Bind.zep", 167); - if (Z_TYPE_P(&data) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&data), _0) - { - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0); - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("inlineCount"), PH_NOISY_CC | PH_READONLY); - ZVAL_UNDEF(&_3$$3); - ZVAL_LONG(&_3$$3, (zephir_get_numberval(&_2$$3) + 1)); - zephir_update_property_zval(this_ptr, ZEND_STRL("inlineCount"), &_3$$3); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("inlineCount"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&key); - ZEPHIR_CONCAT_SVS(&key, "__", &_3$$3, "__"); - ZVAL_LONG(&_4$$3, type); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setvalue", &_5, 0, &key, &value, &_4$$3); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_6$$3); - ZEPHIR_CONCAT_SV(&_6$$3, ":", &key); - zephir_array_append(&keys, &_6$$3, PH_SEPARATE, "phalcon/DataMapper/Query/Bind.zep", 164); - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 1, 0, &type_param); + if (UNEXPECTED(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(type_param) == IS_STRING)) { + zephir_get_strval(&type, type_param); } else { - ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &data, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_7$$4, this_ptr, ZEND_STRL("inlineCount"), PH_NOISY_CC | PH_READONLY); - ZVAL_UNDEF(&_8$$4); - ZVAL_LONG(&_8$$4, (zephir_get_numberval(&_7$$4) + 1)); - zephir_update_property_zval(this_ptr, ZEND_STRL("inlineCount"), &_8$$4); - zephir_read_property(&_8$$4, this_ptr, ZEND_STRL("inlineCount"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&key); - ZEPHIR_CONCAT_SVS(&key, "__", &_8$$4, "__"); - ZVAL_LONG(&_9$$4, type); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setvalue", &_5, 0, &key, &value, &_9$$4); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_10$$4); - ZEPHIR_CONCAT_SV(&_10$$4, ":", &key); - zephir_array_append(&keys, &_10$$4, PH_SEPARATE, "phalcon/DataMapper/Query/Bind.zep", 164); - ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&type); } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_VAR(&_11); - zephir_fast_join_str(&_11, SL(", "), &keys); - ZEPHIR_CONCAT_SVS(return_value, "(", &_11, ")"); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &type); + RETURN_THIS(); } -zend_object *zephir_init_properties_Phalcon_DataMapper_Query_Bind(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Events_Event, stop) { - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - + zval __$true, __$false, _0; + zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("store"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("cancelable"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(!zephir_is_true(&_0))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_events_exception_ce, "Trying to cancel a non-cancelable event", "phalcon/Events/Event.zep", 150); + return; } + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("stopped"), &__$false); + } + RETURN_THISW(); } @@ -111797,592 +110457,692 @@ zend_object *zephir_init_properties_Phalcon_DataMapper_Query_Bind(zend_class_ent -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Query_Delete) +ZEPHIR_INIT_CLASS(Phalcon_Events_EventInterface) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Query, Delete, phalcon, datamapper_query_delete, phalcon_datamapper_query_abstractconditions_ce, phalcon_datamapper_query_delete_method_entry, 0); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Events, EventInterface, phalcon, events_eventinterface, phalcon_events_eventinterface_method_entry); return SUCCESS; } -static PHP_METHOD(Phalcon_DataMapper_Query_Delete, __construct) +ZEPHIR_DOC_METHOD(Phalcon_Events_EventInterface, getData); +ZEPHIR_DOC_METHOD(Phalcon_Events_EventInterface, getType); +ZEPHIR_DOC_METHOD(Phalcon_Events_EventInterface, isCancelable); +ZEPHIR_DOC_METHOD(Phalcon_Events_EventInterface, isStopped); +ZEPHIR_DOC_METHOD(Phalcon_Events_EventInterface, setData); +ZEPHIR_DOC_METHOD(Phalcon_Events_EventInterface, setType); +ZEPHIR_DOC_METHOD(Phalcon_Events_EventInterface, stop); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Events_EventsAwareInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Events, EventsAwareInterface, phalcon, events_eventsawareinterface, phalcon_events_eventsawareinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Events_EventsAwareInterface, getEventsManager); +ZEPHIR_DOC_METHOD(Phalcon_Events_EventsAwareInterface, setEventsManager); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Events_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Events, Exception, phalcon, events_exception, zend_ce_exception, NULL, 0); + + return SUCCESS; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Events_Manager) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Events, Manager, phalcon, events_manager, phalcon_events_manager_method_entry, 0); + + zend_declare_property_bool(phalcon_events_manager_ce, SL("collect"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_events_manager_ce, SL("enablePriorities"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_events_manager_ce, SL("events"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_events_manager_ce, SL("responses"), ZEND_ACC_PROTECTED); + phalcon_events_manager_ce->create_object = zephir_init_properties_Phalcon_Events_Manager; + zephir_declare_class_constant_long(phalcon_events_manager_ce, SL("DEFAULT_PRIORITY"), 100); + + zend_class_implements(phalcon_events_manager_ce, 1, phalcon_events_managerinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Events_Manager, attach) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connection, connection_sub, *bind, bind_sub, _0, _1, _2, _3; + zend_long priority, ZEPHIR_LAST_CALL_STATUS; + zval *eventType_param = NULL, *handler, handler_sub, *priority_param = NULL, priorityQueue, _0, _1, _3, _4, _2$$4; + zval eventType; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connection_sub); - ZVAL_UNDEF(&bind_sub); + ZVAL_UNDEF(&eventType); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&priorityQueue); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_datamapper_pdo_connection_ce) - Z_PARAM_OBJECT_OF_CLASS(bind, phalcon_datamapper_query_bind_ce) + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_2$$4); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(eventType) + Z_PARAM_ZVAL(handler) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(priority) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &connection, &bind); - ZEPHIR_CALL_PARENT(NULL, phalcon_datamapper_query_delete_ce, getThis(), "__construct", NULL, 0, connection, bind); + zephir_fetch_params(1, 2, 1, &eventType_param, &handler, &priority_param); + if (UNEXPECTED(Z_TYPE_P(eventType_param) != IS_STRING && Z_TYPE_P(eventType_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventType' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(eventType_param) == IS_STRING)) { + zephir_get_strval(&eventType, eventType_param); + } else { + ZEPHIR_INIT_VAR(&eventType); + } + if (!priority_param) { + priority = 100; + } else { + if (UNEXPECTED(Z_TYPE_P(priority_param) != IS_LONG)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'priority' must be of the type int")); + RETURN_MM_NULL(); + } + priority = Z_LVAL_P(priority_param); + } + ZEPHIR_CALL_METHOD(&_0, this_ptr, "isvalidhandler", NULL, 0, handler); + zephir_check_call_status(); + if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&_0))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_events_exception_ce, "Event handler must be an Object or Callable", "phalcon/Events/Manager.zep", 56); + return; + } + zephir_memory_observe(&priorityQueue); + zephir_read_property(&_1, this_ptr, ZEND_STRL("events"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&priorityQueue, &_1, &eventType, 0))) { + ZEPHIR_INIT_NVAR(&priorityQueue); + object_init_ex(&priorityQueue, spl_ce_SplPriorityQueue); + if (zephir_has_constructor(&priorityQueue)) { + ZEPHIR_CALL_METHOD(NULL, &priorityQueue, "__construct", NULL, 0); + zephir_check_call_status(); + } + + ZVAL_LONG(&_2$$4, 1); + ZEPHIR_CALL_METHOD(NULL, &priorityQueue, "setextractflags", NULL, 271, &_2$$4); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("events"), &eventType, &priorityQueue); + } + zephir_read_property(&_3, this_ptr, ZEND_STRL("enablePriorities"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_is_true(&_3))) { + priority = 100; + } + ZVAL_LONG(&_4, priority); + ZEPHIR_CALL_METHOD(NULL, &priorityQueue, "insert", NULL, 272, handler, &_4); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "FROM"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, ""); - zephir_update_property_array(this_ptr, SL("store"), &_0, &_1); - ZEPHIR_INIT_VAR(&_2); - array_init(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "RETURNING"); - zephir_update_property_array(this_ptr, SL("store"), &_3, &_2); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Delete, from) +static PHP_METHOD(Phalcon_Events_Manager, arePrioritiesEnabled) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *table_param = NULL, _0; - zval table; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&table); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(table) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &table_param); - zephir_get_strval(&table, table_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "FROM"); - zephir_update_property_array(this_ptr, SL("store"), &_0, &table); - RETURN_THIS(); + RETURN_MEMBER(getThis(), "enablePriorities"); } -static PHP_METHOD(Phalcon_DataMapper_Query_Delete, returning) +static PHP_METHOD(Phalcon_Events_Manager, collectResponses) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *columns_param = NULL, _0, _1, _2, _3; - zval columns; + zval *collect_param = NULL, __$true, __$false; + zend_bool collect; zval *this_ptr = getThis(); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(columns) + Z_PARAM_BOOL(collect) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &columns_param); - zephir_get_arrval(&columns, columns_param); - ZEPHIR_INIT_VAR(&_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_2, &_1, SL("RETURNING"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Delete.zep", 63); - zephir_fast_array_merge(&_0, &_2, &columns); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "RETURNING"); - zephir_update_property_array(this_ptr, SL("store"), &_3, &_0); - RETURN_THIS(); + zephir_fetch_params_without_memory_grow(1, 0, &collect_param); + if (collect) { + zephir_update_property_zval(this_ptr, ZEND_STRL("collect"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("collect"), &__$false); + } } -static PHP_METHOD(Phalcon_DataMapper_Query_Delete, getStatement) +static PHP_METHOD(Phalcon_Events_Manager, detach) { - zval _0, _1, _2, _3, _4, _5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL, *_5 = NULL, *_9 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *eventType_param = NULL, *handler, handler_sub, priorityQueue, newPriorityQueue, data, _0, _1, _2$$4, _3$$4, _6$$5, _7$$6, _8$$6; + zval eventType; zval *this_ptr = getThis(); + ZVAL_UNDEF(&eventType); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(&priorityQueue); + ZVAL_UNDEF(&newPriorityQueue); + ZVAL_UNDEF(&data); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_8$$6); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(eventType) + Z_PARAM_ZVAL(handler) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "buildflags", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_1, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_2, &_1, SL("FROM"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Delete.zep", 78); - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, "WHERE"); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "buildcondition", NULL, 0, &_4); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_5, this_ptr, "buildreturning", NULL, 0); + zephir_fetch_params(1, 2, 0, &eventType_param, &handler); + if (UNEXPECTED(Z_TYPE_P(eventType_param) != IS_STRING && Z_TYPE_P(eventType_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventType' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(eventType_param) == IS_STRING)) { + zephir_get_strval(&eventType, eventType_param); + } else { + ZEPHIR_INIT_VAR(&eventType); + } + ZEPHIR_CALL_METHOD(&_0, this_ptr, "isvalidhandler", NULL, 0, handler); zephir_check_call_status(); - ZEPHIR_CONCAT_SVSVVV(return_value, "DELETE", &_0, " FROM ", &_2, &_3, &_5); - RETURN_MM(); + if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&_0))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_events_exception_ce, "Event handler must be an Object or Callable", "phalcon/Events/Manager.zep", 107); + return; + } + zephir_memory_observe(&priorityQueue); + zephir_read_property(&_1, this_ptr, ZEND_STRL("events"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&priorityQueue, &_1, &eventType, 0)) { + ZEPHIR_INIT_VAR(&newPriorityQueue); + object_init_ex(&newPriorityQueue, spl_ce_SplPriorityQueue); + if (zephir_has_constructor(&newPriorityQueue)) { + ZEPHIR_CALL_METHOD(NULL, &newPriorityQueue, "__construct", NULL, 0); + zephir_check_call_status(); + } + + ZVAL_LONG(&_2$$4, 1); + ZEPHIR_CALL_METHOD(NULL, &newPriorityQueue, "setextractflags", NULL, 271, &_2$$4); + zephir_check_call_status(); + ZVAL_LONG(&_2$$4, 3); + ZEPHIR_CALL_METHOD(NULL, &priorityQueue, "setextractflags", NULL, 0, &_2$$4); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &priorityQueue, "top", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3$$4, &priorityQueue, "valid", NULL, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&_3$$4))) { + break; + } + ZEPHIR_CALL_METHOD(&data, &priorityQueue, "current", &_4, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &priorityQueue, "next", &_5, 0); + zephir_check_call_status(); + zephir_array_fetch_string(&_6$$5, &data, SL("data"), PH_NOISY | PH_READONLY, "phalcon/Events/Manager.zep", 132); + if (!ZEPHIR_IS_IDENTICAL(&_6$$5, handler)) { + zephir_array_fetch_string(&_7$$6, &data, SL("data"), PH_NOISY | PH_READONLY, "phalcon/Events/Manager.zep", 134); + zephir_array_fetch_string(&_8$$6, &data, SL("priority"), PH_NOISY | PH_READONLY, "phalcon/Events/Manager.zep", 136); + ZEPHIR_CALL_METHOD(NULL, &newPriorityQueue, "insert", &_9, 272, &_7$$6, &_8$$6); + zephir_check_call_status(); + } + } + zephir_update_property_array(this_ptr, SL("events"), &eventType, &newPriorityQueue); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Delete, reset) +static PHP_METHOD(Phalcon_Events_Manager, detachAll) { - zval _0, _1, _2, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *type_param = NULL, __$null, _0$$4, _1$$5; + zval type; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&type); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&_1$$5); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(type) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_PARENT(NULL, phalcon_datamapper_query_delete_ce, getThis(), "reset", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "FROM"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, ""); - zephir_update_property_array(this_ptr, SL("store"), &_0, &_1); - ZEPHIR_INIT_VAR(&_2); - array_init(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "RETURNING"); - zephir_update_property_array(this_ptr, SL("store"), &_3, &_2); + zephir_fetch_params(1, 0, 1, &type_param); + if (!type_param) { + ZEPHIR_INIT_VAR(&type); + } else { + if (UNEXPECTED(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(type_param) == IS_STRING)) { + zephir_get_strval(&type, type_param); + } else { + ZEPHIR_INIT_VAR(&type); + } + } + if (ZEPHIR_IS_NULL(&type)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("events"), &__$null); + } else { + zephir_read_property(&_0$$4, this_ptr, ZEND_STRL("events"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset(&_0$$4, &type)) { + zephir_unset_property_array(this_ptr, ZEND_STRL("events"), &type); + zephir_read_property(&_1$$5, this_ptr, ZEND_STRL("events"), PH_NOISY_CC | PH_READONLY); + zephir_array_unset(&_1$$5, &type, PH_SEPARATE); + } + } ZEPHIR_MM_RESTORE(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Query_Insert) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Query, Insert, phalcon, datamapper_query_insert, phalcon_datamapper_query_abstractquery_ce, phalcon_datamapper_query_insert_method_entry, 0); - - return SUCCESS; -} - -static PHP_METHOD(Phalcon_DataMapper_Query_Insert, __construct) +static PHP_METHOD(Phalcon_Events_Manager, enablePriorities) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connection, connection_sub, *bind, bind_sub, _0, _1, _2, _3; + zval *enablePriorities_param = NULL, __$true, __$false; + zend_bool enablePriorities; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connection_sub); - ZVAL_UNDEF(&bind_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_datamapper_pdo_connection_ce) - Z_PARAM_OBJECT_OF_CLASS(bind, phalcon_datamapper_query_bind_ce) + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(enablePriorities) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &connection, &bind); - ZEPHIR_CALL_PARENT(NULL, phalcon_datamapper_query_insert_ce, getThis(), "__construct", NULL, 0, connection, bind); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "FROM"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, ""); - zephir_update_property_array(this_ptr, SL("store"), &_0, &_1); - ZEPHIR_INIT_VAR(&_2); - array_init(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "RETURNING"); - zephir_update_property_array(this_ptr, SL("store"), &_3, &_2); - ZEPHIR_MM_RESTORE(); + zephir_fetch_params_without_memory_grow(1, 0, &enablePriorities_param); + if (enablePriorities) { + zephir_update_property_zval(this_ptr, ZEND_STRL("enablePriorities"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("enablePriorities"), &__$false); + } } -static PHP_METHOD(Phalcon_DataMapper_Query_Insert, column) +static PHP_METHOD(Phalcon_Events_Manager, fire) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *column_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _1$$3, _2$$3; - zval column, _0; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool cancelable; + zval *eventType_param = NULL, *source, source_sub, *data = NULL, data_sub, *cancelable_param = NULL, __$null, events, eventParts, type, eventName, event, status, fireEvents, _0, _4, _1$$4, _3$$5; + zval eventType, _2$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&eventType); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&source_sub); + ZVAL_UNDEF(&data_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&events); + ZVAL_UNDEF(&eventParts); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&eventName); + ZVAL_UNDEF(&event); + ZVAL_UNDEF(&status); + ZVAL_UNDEF(&fireEvents); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_3$$5); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(column) + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_STR(eventType) + Z_PARAM_OBJECT(source) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) - Z_PARAM_LONG(type) + Z_PARAM_ZVAL_OR_NULL(data) + Z_PARAM_BOOL(cancelable) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &column_param, &value, &type_param); - zephir_get_strval(&column, column_param); - if (!value) { - value = &value_sub; - value = &__$null; + zephir_fetch_params(1, 2, 2, &eventType_param, &source, &data, &cancelable_param); + if (UNEXPECTED(Z_TYPE_P(eventType_param) != IS_STRING && Z_TYPE_P(eventType_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'eventType' must be of the type string")); + RETURN_MM_NULL(); } - if (!type_param) { - type = -1; + if (EXPECTED(Z_TYPE_P(eventType_param) == IS_STRING)) { + zephir_get_strval(&eventType, eventType_param); + } else { + ZEPHIR_INIT_VAR(&eventType); + } + if (!data) { + data = &data_sub; + data = &__$null; + } + if (!cancelable_param) { + cancelable = 1; } else { } - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_CONCAT_SV(&_0, ":", &column); - zephir_update_property_array_multi(this_ptr, SL("store"), &_0, SL("sz"), 3, SL("COLUMNS"), &column); - if (Z_TYPE_P(value) != IS_NULL) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_2$$3, type); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "setvalue", NULL, 0, &column, value, &_2$$3); + zephir_read_property(&_0, this_ptr, ZEND_STRL("events"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&events, &_0); + if (ZEPHIR_IS_EMPTY(&events)) { + RETURN_MM_NULL(); + } + if (UNEXPECTED(!(zephir_memnstr_str(&eventType, SL(":"), "phalcon/Events/Manager.zep", 197)))) { + ZEPHIR_INIT_VAR(&_1$$4); + object_init_ex(&_1$$4, phalcon_events_exception_ce); + ZEPHIR_INIT_VAR(&_2$$4); + ZEPHIR_CONCAT_SV(&_2$$4, "Invalid event type ", &eventType); + ZEPHIR_CALL_METHOD(NULL, &_1$$4, "__construct", NULL, 33, &_2$$4); zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$4, "phalcon/Events/Manager.zep", 198); + ZEPHIR_MM_RESTORE(); + return; } - RETURN_THIS(); + ZEPHIR_INIT_VAR(&eventParts); + zephir_fast_explode_str(&eventParts, SL(":"), &eventType, LONG_MAX); + zephir_memory_observe(&type); + zephir_array_fetch_long(&type, &eventParts, 0, PH_NOISY, "phalcon/Events/Manager.zep", 202); + zephir_memory_observe(&eventName); + zephir_array_fetch_long(&eventName, &eventParts, 1, PH_NOISY, "phalcon/Events/Manager.zep", 203); + ZEPHIR_INIT_VAR(&status); + ZVAL_NULL(&status); + zephir_read_property(&_0, this_ptr, ZEND_STRL("collect"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_0)) { + ZEPHIR_INIT_VAR(&_3$$5); + array_init(&_3$$5); + zephir_update_property_zval(this_ptr, ZEND_STRL("responses"), &_3$$5); + } + ZEPHIR_INIT_VAR(&event); + object_init_ex(&event, phalcon_events_event_ce); + if (cancelable) { + ZVAL_BOOL(&_4, 1); + } else { + ZVAL_BOOL(&_4, 0); + } + ZEPHIR_CALL_METHOD(NULL, &event, "__construct", NULL, 273, &eventName, source, data, &_4); + zephir_check_call_status(); + zephir_memory_observe(&fireEvents); + if (zephir_array_isset_fetch(&fireEvents, &events, &type, 0)) { + if (Z_TYPE_P(&fireEvents) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(&status, this_ptr, "firequeue", NULL, 274, &fireEvents, &event); + zephir_check_call_status(); + } + } + ZEPHIR_OBS_NVAR(&fireEvents); + if (zephir_array_isset_fetch(&fireEvents, &events, &eventType, 0)) { + if (Z_TYPE_P(&fireEvents) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(&status, this_ptr, "firequeue", NULL, 274, &fireEvents, &event); + zephir_check_call_status(); + } + } + RETURN_CCTOR(&status); } -static PHP_METHOD(Phalcon_DataMapper_Query_Insert, columns) +static PHP_METHOD(Phalcon_Events_Manager, fireQueue) { - zend_string *_3; - zend_ulong _2; + zval _8$$6; + zend_bool collect = 0, cancelable = 0, _7$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL; + zephir_fcall_cache_entry *_2 = NULL, *_3 = NULL, *_4 = NULL, *_6 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *columns_param = NULL, column, value, *_0, _1; - zval columns; + zval *queue, queue_sub, *event, event_sub, status, eventName, data, iterator, source, handler, _0, _1, _5$$4, _9$$10; zval *this_ptr = getThis(); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&value); + ZVAL_UNDEF(&queue_sub); + ZVAL_UNDEF(&event_sub); + ZVAL_UNDEF(&status); + ZVAL_UNDEF(&eventName); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&iterator); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&handler); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(columns) + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_9$$10); + ZVAL_UNDEF(&_8$$6); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(queue, spl_ce_SplPriorityQueue) + Z_PARAM_OBJECT_OF_CLASS(event, phalcon_events_eventinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &columns_param); - zephir_get_arrval(&columns, columns_param); - zephir_is_iterable(&columns, 0, "phalcon/DataMapper/Query/Insert.zep", 76); - if (Z_TYPE_P(&columns) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&columns), _2, _3, _0) - { - ZEPHIR_INIT_NVAR(&column); - if (_3 != NULL) { - ZVAL_STR_COPY(&column, _3); - } else { - ZVAL_LONG(&column, _2); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0); - if (Z_TYPE_P(&column) == IS_LONG) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "column", &_4, 0, &value); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "column", &_4, 0, &column, &value); - zephir_check_call_status(); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); + zephir_fetch_params(1, 2, 0, &queue, &event); + ZEPHIR_INIT_VAR(&status); + ZVAL_NULL(&status); + ZEPHIR_CALL_METHOD(&eventName, event, "gettype", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&eventName) != IS_STRING)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_events_exception_ce, "The event type not valid", "phalcon/Events/Manager.zep", 250); + return; + } + ZEPHIR_CALL_METHOD(&source, event, "getsource", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&data, event, "getdata", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, event, "iscancelable", NULL, 0); + zephir_check_call_status(); + cancelable = zephir_get_boolval(&_0); + zephir_memory_observe(&_1); + zephir_read_property(&_1, this_ptr, ZEND_STRL("collect"), PH_NOISY_CC); + collect = zephir_get_boolval(&_1); + ZEPHIR_INIT_VAR(&iterator); + if (zephir_clone(&iterator, queue) == FAILURE) { + RETURN_MM(); + } + ZEPHIR_CALL_METHOD(NULL, &iterator, "top", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_0, &iterator, "valid", &_2, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&_0))) { + break; + } + ZEPHIR_CALL_METHOD(&handler, &iterator, "current", &_3, 0); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &columns, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &iterator, "next", &_4, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5$$4, this_ptr, "isvalidhandler", &_6, 0, &handler); + zephir_check_call_status(); + if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&_5$$4))) { + continue; + } + _7$$4 = zephir_is_instance_of(&handler, SL("Closure")); + if (!(_7$$4)) { + _7$$4 = zephir_is_callable(&handler); + } + if (_7$$4) { + ZEPHIR_INIT_NVAR(&_8$$6); + zephir_create_array(&_8$$6, 3, 0); + zephir_array_fast_append(&_8$$6, event); + zephir_array_fast_append(&_8$$6, &source); + zephir_array_fast_append(&_8$$6, &data); + ZEPHIR_INIT_NVAR(&status); + ZEPHIR_CALL_USER_FUNC_ARRAY(&status, &handler, &_8$$6); zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; + } else { + if (!((zephir_method_exists(&handler, &eventName) == SUCCESS))) { + continue; } - ZEPHIR_CALL_METHOD(&column, &columns, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &columns, "current", NULL, 0); + ZEPHIR_CALL_METHOD_ZVAL(&status, &handler, &eventName, NULL, 0, event, &source, &data); zephir_check_call_status(); - if (Z_TYPE_P(&column) == IS_LONG) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "column", &_4, 0, &value); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "column", &_4, 0, &column, &value); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); + } + if (collect) { + zephir_update_property_array_append(this_ptr, SL("responses"), &status); + } + if (cancelable) { + ZEPHIR_CALL_METHOD(&_9$$10, event, "isstopped", NULL, 0); zephir_check_call_status(); + if (zephir_is_true(&_9$$10)) { + break; + } } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&column); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_DataMapper_Query_Insert, into) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *table_param = NULL, _0; - zval table; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&table); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(table) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &table_param); - zephir_get_strval(&table, table_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "FROM"); - zephir_update_property_array(this_ptr, SL("store"), &_0, &table); - RETURN_THIS(); + RETURN_CCTOR(&status); } -static PHP_METHOD(Phalcon_DataMapper_Query_Insert, getLastInsertId) +static PHP_METHOD(Phalcon_Events_Manager, getListeners) { + zval listeners; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, _0; - zval name; + zval *type_param = NULL, fireEvents, priorityQueue, _0, _1, _2$$4; + zval type; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&fireEvents); + ZVAL_UNDEF(&priorityQueue); ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&listeners); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &name_param); - if (!name_param) { - ZEPHIR_INIT_VAR(&name); + zephir_fetch_params(1, 1, 0, &type_param); + if (UNEXPECTED(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(type_param) == IS_STRING)) { + zephir_get_strval(&type, type_param); } else { - zephir_get_strval(&name, name_param); + ZEPHIR_INIT_VAR(&type); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "lastinsertid", NULL, 0, &name); + zephir_memory_observe(&fireEvents); + zephir_read_property(&_0, this_ptr, ZEND_STRL("events"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&fireEvents, &_0, &type, 0))) { + array_init(return_value); + RETURN_MM(); + } + ZEPHIR_INIT_VAR(&listeners); + array_init(&listeners); + ZEPHIR_INIT_VAR(&priorityQueue); + if (zephir_clone(&priorityQueue, &fireEvents) == FAILURE) { + RETURN_MM(); + } + ZEPHIR_CALL_METHOD(NULL, &priorityQueue, "top", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &priorityQueue, "valid", NULL, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&_1))) { + break; + } + ZEPHIR_CALL_METHOD(&_2$$4, &priorityQueue, "current", &_3, 0); + zephir_check_call_status(); + zephir_array_append(&listeners, &_2$$4, PH_SEPARATE, "phalcon/Events/Manager.zep", 333); + ZEPHIR_CALL_METHOD(NULL, &priorityQueue, "next", &_4, 0); + zephir_check_call_status(); + } + RETURN_CTOR(&listeners); } -static PHP_METHOD(Phalcon_DataMapper_Query_Insert, getStatement) +static PHP_METHOD(Phalcon_Events_Manager, getResponses) { - zval _0, _1, _2, _3, _4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "buildflags", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_1, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_2, &_1, SL("FROM"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Insert.zep", 113); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "buildcolumns", NULL, 205); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4, this_ptr, "buildreturning", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CONCAT_SVSVVV(return_value, "INSERT", &_0, " INTO ", &_2, &_3, &_4); - RETURN_MM(); + RETURN_MEMBER(getThis(), "responses"); } -static PHP_METHOD(Phalcon_DataMapper_Query_Insert, returning) +static PHP_METHOD(Phalcon_Events_Manager, hasListeners) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *columns_param = NULL, _0, _1, _2, _3; - zval columns; + zval *type_param = NULL, _0; + zval type; zval *this_ptr = getThis(); - ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&type); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(columns) + Z_PARAM_STR(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &columns_param); - zephir_get_arrval(&columns, columns_param); - ZEPHIR_INIT_VAR(&_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_2, &_1, SL("RETURNING"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Insert.zep", 127); - zephir_fast_array_merge(&_0, &_2, &columns); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "RETURNING"); - zephir_update_property_array(this_ptr, SL("store"), &_3, &_0); - RETURN_THIS(); + zephir_fetch_params(1, 1, 0, &type_param); + if (UNEXPECTED(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(type_param) == IS_STRING)) { + zephir_get_strval(&type, type_param); + } else { + ZEPHIR_INIT_VAR(&type); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("events"), PH_NOISY_CC | PH_READONLY); + RETURN_MM_BOOL(zephir_array_isset(&_0, &type)); } -static PHP_METHOD(Phalcon_DataMapper_Query_Insert, reset) +static PHP_METHOD(Phalcon_Events_Manager, isCollecting) { - zval _0, _1, _2, _3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_CALL_PARENT(NULL, phalcon_datamapper_query_insert_ce, getThis(), "reset", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "FROM"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, ""); - zephir_update_property_array(this_ptr, SL("store"), &_0, &_1); - ZEPHIR_INIT_VAR(&_2); - array_init(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "RETURNING"); - zephir_update_property_array(this_ptr, SL("store"), &_3, &_2); - ZEPHIR_MM_RESTORE(); + RETURN_MEMBER(getThis(), "collect"); } -static PHP_METHOD(Phalcon_DataMapper_Query_Insert, set) +static PHP_METHOD(Phalcon_Events_Manager, isValidHandler) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *column_param = NULL, *value = NULL, value_sub, __$null, _0; - zval column; - zval *this_ptr = getThis(); + zend_bool _0; + zval *handler, handler_sub; - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&value_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(column) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) + ZVAL_UNDEF(&handler_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(handler) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &column_param, &value); - zephir_get_strval(&column, column_param); - if (!value) { - value = &value_sub; - ZEPHIR_CPY_WRT(value, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(value); + zephir_fetch_params_without_memory_grow(1, 0, &handler); + _0 = Z_TYPE_P(handler) != IS_OBJECT; + if (_0) { + _0 = !(zephir_is_callable(handler)); } - if (Z_TYPE_P(value) == IS_NULL) { - ZEPHIR_INIT_NVAR(value); - ZVAL_STRING(value, "NULL"); + if (UNEXPECTED(_0)) { + RETURN_BOOL(0); } - zephir_update_property_array_multi(this_ptr, SL("store"), value, SL("sz"), 3, SL("COLUMNS"), &column); - zephir_read_property(&_0, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "remove", NULL, 0, &column); - zephir_check_call_status(); - RETURN_THIS(); + RETURN_BOOL(1); } -static PHP_METHOD(Phalcon_DataMapper_Query_Insert, buildColumns) +zend_object *zephir_init_properties_Phalcon_Events_Manager(zend_class_entry *class_type) { - zend_string *_6; - zend_ulong _5; - zval columns; - zval column, _0, _1, _2, *_3, _4, _10, _11, _12, _13, _14, _15, _16, _17, _7$$3, _9$$4; + zval _0, _2, _1$$3, _3$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_8 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_13); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_15); - ZVAL_UNDEF(&_16); - ZVAL_UNDEF(&_17); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&columns); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + - ZEPHIR_INIT_VAR(&columns); - array_init(&columns); - zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_1, &_0, SL("COLUMNS"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Insert.zep", 176); - ZEPHIR_INIT_VAR(&_2); - zephir_is_iterable(&_1, 0, "phalcon/DataMapper/Query/Insert.zep", 180); - if (Z_TYPE_P(&_1) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_1), _5, _6, _3) - { - ZEPHIR_INIT_NVAR(&column); - if (_6 != NULL) { - ZVAL_STR_COPY(&column, _6); - } else { - ZVAL_LONG(&column, _5); - } - ZEPHIR_INIT_NVAR(&_2); - ZVAL_COPY(&_2, _3); - ZEPHIR_CALL_METHOD(&_7$$3, this_ptr, "quoteidentifier", &_8, 0, &column); - zephir_check_call_status(); - zephir_array_append(&columns, &_7$$3, PH_SEPARATE, "phalcon/DataMapper/Query/Insert.zep", 177); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_1, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_4, &_1, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_4)) { - break; - } - ZEPHIR_CALL_METHOD(&column, &_1, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_2, &_1, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_9$$4, this_ptr, "quoteidentifier", &_8, 0, &column); - zephir_check_call_status(); - zephir_array_append(&columns, &_9$$4, PH_SEPARATE, "phalcon/DataMapper/Query/Insert.zep", 177); - ZEPHIR_CALL_METHOD(NULL, &_1, "next", NULL, 0); - zephir_check_call_status(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("responses"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("responses"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("events"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("events"), &_3$$4); } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } - ZEPHIR_INIT_NVAR(&_2); - ZEPHIR_INIT_NVAR(&column); - ZEPHIR_INIT_VAR(&_10); - ZEPHIR_INIT_VAR(&_12); - ZVAL_STRING(&_12, ","); - ZEPHIR_CALL_METHOD(&_11, this_ptr, "indent", NULL, 0, &columns, &_12); - zephir_check_call_status(); - zephir_fast_trim(&_10, &_11, NULL , ZEPHIR_TRIM_LEFT); - ZEPHIR_INIT_NVAR(&_12); - zephir_read_property(&_14, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_15, &_14, SL("COLUMNS"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Insert.zep", 183); - ZEPHIR_CALL_FUNCTION(&_16, "array_values", NULL, 14, &_15); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_17); - ZVAL_STRING(&_17, ","); - ZEPHIR_CALL_METHOD(&_13, this_ptr, "indent", NULL, 0, &_16, &_17); - zephir_check_call_status(); - zephir_fast_trim(&_12, &_13, NULL , ZEPHIR_TRIM_LEFT); - ZEPHIR_CONCAT_SVSVS(return_value, " (", &_10, ") VALUES (", &_12, ")"); - RETURN_MM(); } @@ -112395,1584 +111155,2069 @@ static PHP_METHOD(Phalcon_DataMapper_Query_Insert, buildColumns) -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Query_QueryFactory) +ZEPHIR_INIT_CLASS(Phalcon_Events_ManagerInterface) { - ZEPHIR_REGISTER_CLASS(Phalcon\\DataMapper\\Query, QueryFactory, phalcon, datamapper_query_queryfactory, phalcon_datamapper_query_queryfactory_method_entry, 0); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Events, ManagerInterface, phalcon, events_managerinterface, phalcon_events_managerinterface_method_entry); - zend_declare_property_string(phalcon_datamapper_query_queryfactory_ce, SL("selectClass"), "", ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_DataMapper_Query_QueryFactory, __construct) +ZEPHIR_DOC_METHOD(Phalcon_Events_ManagerInterface, attach); +ZEPHIR_DOC_METHOD(Phalcon_Events_ManagerInterface, detach); +ZEPHIR_DOC_METHOD(Phalcon_Events_ManagerInterface, detachAll); +ZEPHIR_DOC_METHOD(Phalcon_Events_ManagerInterface, fire); +ZEPHIR_DOC_METHOD(Phalcon_Events_ManagerInterface, getListeners); +ZEPHIR_DOC_METHOD(Phalcon_Events_ManagerInterface, hasListeners); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Exception) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *selectClass_param = NULL; - zval selectClass; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter, Exception, phalcon, filter_exception, zend_ce_exception, NULL, 0); - ZVAL_UNDEF(&selectClass); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_STR(selectClass) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &selectClass_param); - if (!selectClass_param) { - ZEPHIR_INIT_VAR(&selectClass); - ZVAL_STRING(&selectClass, ""); - } else { - zephir_get_strval(&selectClass, selectClass_param); - } - if (ZEPHIR_IS_EMPTY(&selectClass)) { - ZEPHIR_INIT_NVAR(&selectClass); - ZVAL_STRING(&selectClass, "Phalcon\\DataMapper\\Query\\Select"); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("selectClass"), &selectClass); - ZEPHIR_MM_RESTORE(); + return SUCCESS; } -static PHP_METHOD(Phalcon_DataMapper_Query_QueryFactory, newBind) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Filter) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter, Filter, phalcon, filter_filter, phalcon_filter_filter_method_entry, 0); - object_init_ex(return_value, phalcon_datamapper_query_bind_ce); - if (zephir_has_constructor(return_value)) { - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); - zephir_check_call_status(); - } + zend_declare_property_null(phalcon_filter_filter_ce, SL("mapper"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_filter_filter_ce, SL("services"), ZEND_ACC_PROTECTED); + phalcon_filter_filter_ce->create_object = zephir_init_properties_Phalcon_Filter_Filter; + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_ABSINT"), "absint"); - RETURN_MM(); + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_ALNUM"), "alnum"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_ALPHA"), "alpha"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_BOOL"), "bool"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_EMAIL"), "email"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_FLOAT"), "float"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_INT"), "int"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_LOWER"), "lower"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_LOWERFIRST"), "lowerfirst"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_REGEX"), "regex"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_REMOVE"), "remove"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_REPLACE"), "replace"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_SPECIAL"), "special"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_SPECIALFULL"), "specialfull"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_STRING"), "string"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_STRING_LEGACY"), "stringlegacy"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_STRIPTAGS"), "striptags"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_TRIM"), "trim"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_UPPER"), "upper"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_UPPERFIRST"), "upperfirst"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_UPPERWORDS"), "upperwords"); + + zephir_declare_class_constant_string(phalcon_filter_filter_ce, SL("FILTER_URL"), "url"); + + zend_class_implements(phalcon_filter_filter_ce, 1, phalcon_filter_filterinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_DataMapper_Query_QueryFactory, newDelete) +static PHP_METHOD(Phalcon_Filter_Filter, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connection, connection_sub, _0; + zval *mapper_param = NULL; + zval mapper; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connection_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_datamapper_pdo_connection_ce) + ZVAL_UNDEF(&mapper); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(mapper) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &connection); - object_init_ex(return_value, phalcon_datamapper_query_delete_ce); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "newbind", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 206, connection, &_0); + zephir_fetch_params(1, 0, 1, &mapper_param); + if (!mapper_param) { + ZEPHIR_INIT_VAR(&mapper); + array_init(&mapper); + } else { + zephir_get_arrval(&mapper, mapper_param); + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &mapper); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_DataMapper_Query_QueryFactory, newInsert) +static PHP_METHOD(Phalcon_Filter_Filter, __call) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connection, connection_sub, _0; + zval args, _0; + zval *name_param = NULL, *args_param = NULL, sanitizer, _1; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connection_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&sanitizer); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&args); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_datamapper_pdo_connection_ce) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_ARRAY(args) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &connection); - object_init_ex(return_value, phalcon_datamapper_query_insert_ce); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "newbind", NULL, 0); + zephir_fetch_params(1, 2, 0, &name_param, &args_param); + zephir_get_strval(&name, name_param); + zephir_get_arrval(&args, args_param); + ZEPHIR_CALL_METHOD(&sanitizer, this_ptr, "get", NULL, 0, &name); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 207, connection, &_0); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 2, 0); + zephir_array_fast_append(&_0, &sanitizer); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "__invoke"); + zephir_array_fast_append(&_0, &_1); + ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_0, &args); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_DataMapper_Query_QueryFactory, newSelect) +static PHP_METHOD(Phalcon_Filter_Filter, get) { - zend_class_entry *_2; - zval selectClass; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connection, connection_sub, _0, _1, _3; + zval *name_param = NULL, definition, _0, _3, _6, _7, _1$$3, _4$$4, _5$$4; + zval name, _2$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connection_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&definition); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&selectClass); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$4); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_datamapper_pdo_connection_ce) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &connection); - zephir_read_property(&_0, this_ptr, ZEND_STRL("selectClass"), PH_NOISY_CC | PH_READONLY); - zephir_get_strval(&selectClass, &_0); - zephir_fetch_safe_class(&_1, &selectClass); - _2 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_1), Z_STRLEN_P(&_1), ZEND_FETCH_CLASS_AUTO); - if(!_2) { - RETURN_MM_NULL(); - } - object_init_ex(return_value, _2); - if (zephir_has_constructor(return_value)) { - ZEPHIR_CALL_METHOD(&_3, this_ptr, "newbind", NULL, 0); + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("mapper"), PH_NOISY_CC | PH_READONLY); + if (1 != zephir_array_isset(&_0, &name)) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_filter_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + ZEPHIR_CONCAT_SVS(&_2$$3, "Filter ", &name, " is not registered"); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0, connection, &_3); + zephir_throw_exception_debug(&_1$$3, "phalcon/Filter/Filter.zep", 121); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_read_property(&_3, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); + if (1 != zephir_array_isset(&_3, &name)) { + zephir_read_property(&_4$$4, this_ptr, ZEND_STRL("mapper"), PH_NOISY_CC | PH_READONLY); + zephir_memory_observe(&definition); + zephir_array_fetch(&definition, &_4$$4, &name, PH_NOISY, "phalcon/Filter/Filter.zep", 125); + ZEPHIR_CALL_METHOD(&_5$$4, this_ptr, "createinstance", NULL, 275, &definition); zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("services"), &name, &_5$$4); } - - RETURN_MM(); + zephir_read_property(&_6, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_7, &_6, &name, PH_NOISY | PH_READONLY, "phalcon/Filter/Filter.zep", 129); + RETURN_CTOR(&_7); } -static PHP_METHOD(Phalcon_DataMapper_Query_QueryFactory, newUpdate) +static PHP_METHOD(Phalcon_Filter_Filter, has) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connection, connection_sub, _0; + zval *name_param = NULL, _0; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connection_sub); + ZVAL_UNDEF(&name); ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_datamapper_pdo_connection_ce) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &connection); - object_init_ex(return_value, phalcon_datamapper_query_update_ce); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "newbind", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 208, connection, &_0); - zephir_check_call_status(); - RETURN_MM(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Query_Select) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Query, Select, phalcon, datamapper_query_select, phalcon_datamapper_query_abstractconditions_ce, phalcon_datamapper_query_select_method_entry, 0); - - zend_declare_property_string(phalcon_datamapper_query_select_ce, SL("asAlias"), "", ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_datamapper_query_select_ce, SL("forUpdate"), 0, ZEND_ACC_PROTECTED); - zephir_declare_class_constant_string(phalcon_datamapper_query_select_ce, SL("JOIN_INNER"), "INNER"); - - zephir_declare_class_constant_string(phalcon_datamapper_query_select_ce, SL("JOIN_LEFT"), "LEFT"); - - zephir_declare_class_constant_string(phalcon_datamapper_query_select_ce, SL("JOIN_NATURAL"), "NATURAL"); - - zephir_declare_class_constant_string(phalcon_datamapper_query_select_ce, SL("JOIN_RIGHT"), "RIGHT"); - - return SUCCESS; + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("mapper"), PH_NOISY_CC | PH_READONLY); + RETURN_MM_BOOL(zephir_array_isset(&_0, &name)); } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, __call) +static PHP_METHOD(Phalcon_Filter_Filter, sanitize) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval params, proxied, _0$$3, _3$$3; - zval *method_param = NULL, *params_param = NULL, __$true, _5, _1$$3, _2$$3, _4$$3; - zval method, _6; + zend_bool noRecursive, _1; + zval *value, value_sub, *sanitizers, sanitizers_sub, *noRecursive_param = NULL, _0$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&_6); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&proxied); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&sanitizers_sub); ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_3$$3); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(method) - Z_PARAM_ARRAY(params) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ZVAL(value) + Z_PARAM_ZVAL(sanitizers) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(noRecursive) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &method_param, ¶ms_param); - zephir_get_strval(&method, method_param); - zephir_get_arrval(¶ms, params_param); - ZEPHIR_INIT_VAR(&proxied); - zephir_create_array(&proxied, 10, 0); - zephir_array_update_string(&proxied, SL("fetchAffected"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&proxied, SL("fetchAll"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&proxied, SL("fetchAssoc"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&proxied, SL("fetchCol"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&proxied, SL("fetchGroup"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&proxied, SL("fetchObject"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&proxied, SL("fetchObjects"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&proxied, SL("fetchOne"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&proxied, SL("fetchPairs"), &__$true, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&proxied, SL("fetchValue"), &__$true, PH_COPY | PH_SEPARATE); - if (EXPECTED(zephir_array_isset(&proxied, &method))) { - ZEPHIR_INIT_VAR(&_0$$3); - zephir_create_array(&_0$$3, 2, 0); - zephir_memory_observe(&_1$$3); - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC); - zephir_array_fast_append(&_0$$3, &_1$$3); - zephir_array_fast_append(&_0$$3, &method); - ZEPHIR_INIT_VAR(&_2$$3); - ZEPHIR_INIT_VAR(&_3$$3); - zephir_create_array(&_3$$3, 2, 0); - ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "getstatement", NULL, 0); - zephir_check_call_status(); - zephir_array_fast_append(&_3$$3, &_4$$3); - ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "getbindvalues", NULL, 0); + zephir_fetch_params(1, 2, 1, &value, &sanitizers, &noRecursive_param); + if (!noRecursive_param) { + noRecursive = 0; + } else { + } + if (Z_TYPE_P(sanitizers) == IS_ARRAY) { + if (noRecursive) { + ZVAL_BOOL(&_0$$3, 1); + } else { + ZVAL_BOOL(&_0$$3, 0); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "processarraysanitizers", NULL, 276, sanitizers, value, &_0$$3); zephir_check_call_status(); - zephir_array_fast_append(&_3$$3, &_4$$3); - zephir_fast_array_merge(&_2$$3, &_3$$3, ¶ms); - ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_0$$3, &_2$$3); + RETURN_MM(); + } + _1 = Z_TYPE_P(value) == IS_ARRAY; + if (_1) { + _1 = !noRecursive; + } + if (_1) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "processarrayvalues", NULL, 277, value, sanitizers); zephir_check_call_status(); RETURN_MM(); } - ZEPHIR_INIT_VAR(&_5); - object_init_ex(&_5, spl_ce_BadMethodCallException); - ZEPHIR_INIT_VAR(&_6); - ZEPHIR_CONCAT_SVS(&_6, "Unknown method: [", &method, "]"); - ZEPHIR_CALL_METHOD(NULL, &_5, "__construct", NULL, 75, &_6); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "sanitizer", NULL, 278, value, sanitizers); zephir_check_call_status(); - zephir_throw_exception_debug(&_5, "phalcon/DataMapper/Query/Select.zep", 83); - ZEPHIR_MM_RESTORE(); - return; + RETURN_MM(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, andHaving) +static PHP_METHOD(Phalcon_Filter_Filter, set) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _0; - zval condition; + zval *name_param = NULL, *service, service_sub, _0; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&condition); - ZVAL_UNDEF(&value_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&service_sub); ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(condition) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) - Z_PARAM_LONG(type) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_ZVAL(service) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &condition_param, &value, &type_param); - zephir_get_strval(&condition, condition_param); - if (!value) { - value = &value_sub; - value = &__$null; - } - if (!type_param) { - type = -1; - } else { - } - ZVAL_LONG(&_0, type); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "having", NULL, 0, &condition, value, &_0); - zephir_check_call_status(); - RETURN_THIS(); + zephir_fetch_params(1, 2, 0, &name_param, &service); + zephir_get_strval(&name, name_param); + zephir_update_property_array(this_ptr, SL("mapper"), &name, service); + zephir_unset_property_array(this_ptr, ZEND_STRL("services"), &name); + zephir_read_property(&_0, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); + zephir_array_unset(&_0, &name, PH_SEPARATE); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, asAlias) +static PHP_METHOD(Phalcon_Filter_Filter, init) { + zend_string *_3; + zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *asAlias_param = NULL; - zval asAlias; + zephir_fcall_cache_entry *_4 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *mapper_param = NULL, name, service, *_0, _1; + zval mapper; zval *this_ptr = getThis(); - ZVAL_UNDEF(&asAlias); + ZVAL_UNDEF(&mapper); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&service); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(asAlias) + Z_PARAM_ARRAY(mapper) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &asAlias_param); - zephir_get_strval(&asAlias, asAlias_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("asAlias"), &asAlias); - RETURN_THIS(); + zephir_fetch_params(1, 1, 0, &mapper_param); + zephir_get_arrval(&mapper, mapper_param); + zephir_is_iterable(&mapper, 0, "phalcon/Filter/Filter.zep", 231); + if (Z_TYPE_P(&mapper) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&mapper), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&name); + if (_3 != NULL) { + ZVAL_STR_COPY(&name, _3); + } else { + ZVAL_LONG(&name, _2); + } + ZEPHIR_INIT_NVAR(&service); + ZVAL_COPY(&service, _0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", &_4, 0, &name, &service); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &mapper, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &mapper, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&name, &mapper, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&service, &mapper, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", &_4, 0, &name, &service); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &mapper, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&service); + ZEPHIR_INIT_NVAR(&name); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, appendHaving) +static PHP_METHOD(Phalcon_Filter_Filter, createInstance) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _0, _1; - zval condition; - zval *this_ptr = getThis(); + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *definition, definition_sub, instance; - ZVAL_UNDEF(&condition); - ZVAL_UNDEF(&value_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(condition) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) - Z_PARAM_LONG(type) + ZVAL_UNDEF(&definition_sub); + ZVAL_UNDEF(&instance); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(definition) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &condition_param, &value, &type_param); - zephir_get_strval(&condition, condition_param); - if (!value) { - value = &value_sub; - value = &__$null; + zephir_fetch_params(1, 1, 0, &definition); + ZEPHIR_CPY_WRT(&instance, definition); + if (Z_TYPE_P(&instance) == IS_STRING) { + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(return_value, &instance); + zephir_check_call_status(); + RETURN_MM(); } - if (!type_param) { - type = -1; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "HAVING"); - ZVAL_LONG(&_1, type); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendcondition", NULL, 0, &_0, &condition, value, &_1); - zephir_check_call_status(); - RETURN_THIS(); + RETURN_CCTOR(&instance); } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, appendJoin) +static PHP_METHOD(Phalcon_Filter_Filter, processArraySanitizers) { + zend_string *_3; + zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, end, key, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _0$$3, _1$$3, _2$$3; - zval condition; + zephir_fcall_cache_entry *_4 = NULL, *_7 = NULL, *_9 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool noRecursive; + zval *sanitizers_param = NULL, *value = NULL, value_sub, *noRecursive_param = NULL, sanitizer, sanitizerKey, sanitizerName, sanitizerParams, split, *_0, _1, _5$$5, _6$$5, _8$$6, _10$$8, _11$$8, _12$$9; + zval sanitizers; zval *this_ptr = getThis(); - ZVAL_UNDEF(&condition); + ZVAL_UNDEF(&sanitizers); ZVAL_UNDEF(&value_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&end); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(condition) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) - Z_PARAM_LONG(type) + ZVAL_UNDEF(&sanitizer); + ZVAL_UNDEF(&sanitizerKey); + ZVAL_UNDEF(&sanitizerName); + ZVAL_UNDEF(&sanitizerParams); + ZVAL_UNDEF(&split); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&_10$$8); + ZVAL_UNDEF(&_11$$8); + ZVAL_UNDEF(&_12$$9); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ARRAY(sanitizers) + Z_PARAM_ZVAL(value) + Z_PARAM_BOOL(noRecursive) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &condition_param, &value, &type_param); - zephir_get_strval(&condition, condition_param); - if (!value) { - value = &value_sub; - value = &__$null; + zephir_fetch_params(1, 3, 0, &sanitizers_param, &value, &noRecursive_param); + zephir_get_arrval(&sanitizers, sanitizers_param); + ZEPHIR_SEPARATE_PARAM(value); + if (Z_TYPE_P(value) == IS_NULL) { + RETVAL_ZVAL(value, 1, 0); + RETURN_MM(); } - if (!type_param) { - type = -1; + zephir_is_iterable(&sanitizers, 0, "phalcon/Filter/Filter.zep", 305); + if (Z_TYPE_P(&sanitizers) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&sanitizers), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&sanitizerKey); + if (_3 != NULL) { + ZVAL_STR_COPY(&sanitizerKey, _3); + } else { + ZVAL_LONG(&sanitizerKey, _2); + } + ZEPHIR_INIT_NVAR(&sanitizer); + ZVAL_COPY(&sanitizer, _0); + ZEPHIR_CALL_METHOD(&split, this_ptr, "splitsanitizerparameters", &_4, 279, &sanitizerKey, &sanitizer); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&sanitizerName); + zephir_array_fetch_long(&sanitizerName, &split, 0, PH_NOISY, "phalcon/Filter/Filter.zep", 281); + ZEPHIR_OBS_NVAR(&sanitizerParams); + zephir_array_fetch_long(&sanitizerParams, &split, 1, PH_NOISY, "phalcon/Filter/Filter.zep", 282); + if (Z_TYPE_P(value) == IS_ARRAY) { + if (noRecursive) { + ZVAL_BOOL(&_6$$5, 1); + } else { + ZVAL_BOOL(&_6$$5, 0); + } + ZEPHIR_CALL_METHOD(&_5$$5, this_ptr, "processvalueisarray", &_7, 280, value, &sanitizerName, &sanitizerParams, &_6$$5); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(value, &_5$$5); + } else { + ZEPHIR_CALL_METHOD(&_8$$6, this_ptr, "processvalueisnotarray", &_9, 281, value, &sanitizerName, &sanitizerParams); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(value, &_8$$6); + } + } ZEND_HASH_FOREACH_END(); } else { + ZEPHIR_CALL_METHOD(NULL, &sanitizers, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &sanitizers, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&sanitizerKey, &sanitizers, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&sanitizer, &sanitizers, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&split, this_ptr, "splitsanitizerparameters", &_4, 279, &sanitizerKey, &sanitizer); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&sanitizerName); + zephir_array_fetch_long(&sanitizerName, &split, 0, PH_NOISY, "phalcon/Filter/Filter.zep", 281); + ZEPHIR_OBS_NVAR(&sanitizerParams); + zephir_array_fetch_long(&sanitizerParams, &split, 1, PH_NOISY, "phalcon/Filter/Filter.zep", 282); + if (Z_TYPE_P(value) == IS_ARRAY) { + if (noRecursive) { + ZVAL_BOOL(&_11$$8, 1); + } else { + ZVAL_BOOL(&_11$$8, 0); + } + ZEPHIR_CALL_METHOD(&_10$$8, this_ptr, "processvalueisarray", &_7, 280, value, &sanitizerName, &sanitizerParams, &_11$$8); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(value, &_10$$8); + } else { + ZEPHIR_CALL_METHOD(&_12$$9, this_ptr, "processvalueisnotarray", &_9, 281, value, &sanitizerName, &sanitizerParams); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(value, &_12$$9); + } + ZEPHIR_CALL_METHOD(NULL, &sanitizers, "next", NULL, 0); + zephir_check_call_status(); } - if (!(ZEPHIR_IS_EMPTY(value))) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_2$$3, type); - ZEPHIR_CALL_METHOD(&_1$$3, &_0$$3, "bindinline", NULL, 0, value, &_2$$3); - zephir_check_call_status(); - zephir_concat_self(&condition, &_1$$3); } - zephir_read_property(&_3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_4, &_3, SL("FROM"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 158); - ZEPHIR_CALL_FUNCTION(&end, "array_key_last", NULL, 40, &_4); - zephir_check_call_status(); - zephir_read_property(&_5, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_6, &_5, SL("FROM"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 159); - zephir_array_fetch(&_7, &_6, &end, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 159); - ZEPHIR_CALL_FUNCTION(&key, "array_key_last", NULL, 40, &_7); - zephir_check_call_status(); - zephir_read_property(&_8, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_9, &_8, SL("FROM"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 161); - zephir_array_fetch(&_10, &_9, &end, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 161); - zephir_array_fetch(&_11, &_10, &key, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 161); - ZEPHIR_INIT_VAR(&_12); - ZEPHIR_CONCAT_VV(&_12, &_11, &condition); - zephir_update_property_array_multi(this_ptr, SL("store"), &_12, SL("szz"), 4, SL("FROM"), &end, &key); - RETURN_THIS(); + ZEPHIR_INIT_NVAR(&sanitizer); + ZEPHIR_INIT_NVAR(&sanitizerKey); + RETVAL_ZVAL(value, 1, 0); + RETURN_MM(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, columns) +static PHP_METHOD(Phalcon_Filter_Filter, processArrayValues) { zend_string *_3; zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_5 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *columns_param = NULL, key, value, *_0, _1, _6, _7, _8, _9, _4$$5, _5$$8; - zval columns, localColumns; + zval sanitizerName; + zval *values_param = NULL, *sanitizerName_param = NULL, *sanitizerParams_param = NULL, itemKey, itemValue, *_0, _1, _4$$3, _6$$4; + zval values, sanitizerParams, arrayValues; zval *this_ptr = getThis(); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&localColumns); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&sanitizerParams); + ZVAL_UNDEF(&arrayValues); + ZVAL_UNDEF(&itemKey); + ZVAL_UNDEF(&itemValue); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$8); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(columns) + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&sanitizerName); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ARRAY(values) + Z_PARAM_STR(sanitizerName) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(sanitizerParams) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &columns_param); - zephir_get_arrval(&columns, columns_param); - ZEPHIR_INIT_VAR(&localColumns); - array_init(&localColumns); - zephir_is_iterable(&columns, 0, "phalcon/DataMapper/Query/Select.zep", 187); - if (Z_TYPE_P(&columns) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&columns), _2, _3, _0) + zephir_fetch_params(1, 2, 1, &values_param, &sanitizerName_param, &sanitizerParams_param); + zephir_get_arrval(&values, values_param); + zephir_get_strval(&sanitizerName, sanitizerName_param); + if (!sanitizerParams_param) { + ZEPHIR_INIT_VAR(&sanitizerParams); + array_init(&sanitizerParams); + } else { + zephir_get_arrval(&sanitizerParams, sanitizerParams_param); + } + ZEPHIR_INIT_VAR(&arrayValues); + array_init(&arrayValues); + zephir_is_iterable(&values, 0, "phalcon/Filter/Filter.zep", 334); + if (Z_TYPE_P(&values) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&values), _2, _3, _0) { - ZEPHIR_INIT_NVAR(&key); + ZEPHIR_INIT_NVAR(&itemKey); if (_3 != NULL) { - ZVAL_STR_COPY(&key, _3); - } else { - ZVAL_LONG(&key, _2); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0); - if (Z_TYPE_P(&key) == IS_LONG) { - zephir_array_append(&localColumns, &value, PH_SEPARATE, "phalcon/DataMapper/Query/Select.zep", 181); + ZVAL_STR_COPY(&itemKey, _3); } else { - ZEPHIR_INIT_NVAR(&_4$$5); - ZEPHIR_CONCAT_VSV(&_4$$5, &value, " AS ", &key); - zephir_array_append(&localColumns, &_4$$5, PH_SEPARATE, "phalcon/DataMapper/Query/Select.zep", 183); + ZVAL_LONG(&itemKey, _2); } + ZEPHIR_INIT_NVAR(&itemValue); + ZVAL_COPY(&itemValue, _0); + ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "sanitizer", &_5, 278, &itemValue, &sanitizerName, &sanitizerParams); + zephir_check_call_status(); + zephir_array_update_zval(&arrayValues, &itemKey, &_4$$3, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_1, &columns, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_1, &values, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_1)) { break; } - ZEPHIR_CALL_METHOD(&key, &columns, "key", NULL, 0); + ZEPHIR_CALL_METHOD(&itemKey, &values, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &columns, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&itemValue, &values, "current", NULL, 0); zephir_check_call_status(); - if (Z_TYPE_P(&key) == IS_LONG) { - zephir_array_append(&localColumns, &value, PH_SEPARATE, "phalcon/DataMapper/Query/Select.zep", 181); - } else { - ZEPHIR_INIT_NVAR(&_5$$8); - ZEPHIR_CONCAT_VSV(&_5$$8, &value, " AS ", &key); - zephir_array_append(&localColumns, &_5$$8, PH_SEPARATE, "phalcon/DataMapper/Query/Select.zep", 183); - } - ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); + ZEPHIR_CALL_METHOD(&_6$$4, this_ptr, "sanitizer", &_5, 278, &itemValue, &sanitizerName, &sanitizerParams); + zephir_check_call_status(); + zephir_array_update_zval(&arrayValues, &itemKey, &_6$$4, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - ZEPHIR_INIT_VAR(&_6); - zephir_read_property(&_7, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_8, &_7, SL("COLUMNS"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 188); - zephir_fast_array_merge(&_6, &_8, &localColumns); - ZEPHIR_INIT_VAR(&_9); - ZVAL_STRING(&_9, "COLUMNS"); - zephir_update_property_array(this_ptr, SL("store"), &_9, &_6); - RETURN_THIS(); + ZEPHIR_INIT_NVAR(&itemValue); + ZEPHIR_INIT_NVAR(&itemKey); + RETURN_CTOR(&arrayValues); } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, distinct) +static PHP_METHOD(Phalcon_Filter_Filter, sanitizer) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *enable_param = NULL, _0, _1; - zend_bool enable; + zval sanitizerParams, _3; + zval sanitizerName, _1$$4; + zval *value, value_sub, *sanitizerName_param = NULL, *sanitizerParams_param = NULL, params, sanitizerObject, _0, _2$$4; zval *this_ptr = getThis(); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&sanitizerObject); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(0, 1) + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&sanitizerName); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&sanitizerParams); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ZVAL(value) + Z_PARAM_STR(sanitizerName) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(enable) + Z_PARAM_ARRAY(sanitizerParams) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &enable_param); - if (!enable_param) { - enable = 1; + zephir_fetch_params(1, 2, 1, &value, &sanitizerName_param, &sanitizerParams_param); + zephir_get_strval(&sanitizerName, sanitizerName_param); + if (!sanitizerParams_param) { + ZEPHIR_INIT_VAR(&sanitizerParams); + array_init(&sanitizerParams); } else { + zephir_get_arrval(&sanitizerParams, sanitizerParams_param); + } + ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, 0, &sanitizerName); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + if (1 != ZEPHIR_IS_EMPTY(&sanitizerName)) { + ZEPHIR_INIT_VAR(&_1$$4); + ZEPHIR_CONCAT_SVS(&_1$$4, "Sanitizer '", &sanitizerName, "' is not registered"); + ZVAL_LONG(&_2$$4, 1024); + ZEPHIR_CALL_FUNCTION(NULL, "trigger_error", NULL, 7, &_1$$4, &_2$$4); + zephir_check_call_status(); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "DISTINCT"); - if (enable) { - ZVAL_BOOL(&_1, 1); - } else { - ZVAL_BOOL(&_1, 0); + RETVAL_ZVAL(value, 1, 0); + RETURN_MM(); } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setflag", NULL, 0, &_0, &_1); + ZEPHIR_CALL_METHOD(&sanitizerObject, this_ptr, "get", NULL, 0, &sanitizerName); zephir_check_call_status(); - RETURN_THIS(); + ZEPHIR_INIT_VAR(&_3); + zephir_create_array(&_3, 1, 0); + zephir_array_fast_append(&_3, value); + ZEPHIR_INIT_VAR(¶ms); + zephir_fast_array_merge(¶ms, &_3, &sanitizerParams); + ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &sanitizerObject, ¶ms); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, from) +static PHP_METHOD(Phalcon_Filter_Filter, processValueIsArray) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *table_param = NULL; - zval table; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool noRecursive; + zval sanitizerParams; + zval sanitizerName; + zval *value = NULL, value_sub, *sanitizerName_param = NULL, *sanitizerParams_param = NULL, *noRecursive_param = NULL, _0$$3, _1$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&table); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(table) + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&sanitizerName); + ZVAL_UNDEF(&sanitizerParams); + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_ZVAL(value) + Z_PARAM_STR(sanitizerName) + Z_PARAM_ARRAY(sanitizerParams) + Z_PARAM_BOOL(noRecursive) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &table_param); - zephir_get_strval(&table, table_param); - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 1, 0); - zephir_array_fast_append(&_0, &table); - zephir_update_property_array_multi(this_ptr, SL("store"), &_0, SL("sa"), 3, SL("FROM")); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_DataMapper_Query_Select, forUpdate) -{ - zval *enable_param = NULL, __$true, __$false; - zend_bool enable; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(enable) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(0, 1, &enable_param); - if (!enable_param) { - enable = 1; - } else { - } - if (enable) { - zephir_update_property_zval(this_ptr, ZEND_STRL("forUpdate"), &__$true); + zephir_fetch_params(1, 4, 0, &value, &sanitizerName_param, &sanitizerParams_param, &noRecursive_param); + ZEPHIR_SEPARATE_PARAM(value); + zephir_get_strval(&sanitizerName, sanitizerName_param); + zephir_get_arrval(&sanitizerParams, sanitizerParams_param); + if (noRecursive) { + ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "sanitizer", NULL, 278, value, &sanitizerName, &sanitizerParams); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(value, &_0$$3); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("forUpdate"), &__$false); + ZEPHIR_CALL_METHOD(&_1$$4, this_ptr, "processarrayvalues", NULL, 277, value, &sanitizerName, &sanitizerParams); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(value, &_1$$4); } - RETURN_THISW(); + RETVAL_ZVAL(value, 1, 0); + RETURN_MM(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, getStatement) +static PHP_METHOD(Phalcon_Filter_Filter, processValueIsNotArray) { - zval _0, _1, _2, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval sanitizerParams; + zval sanitizerName; + zval *value = NULL, value_sub, *sanitizerName_param = NULL, *sanitizerParams_param = NULL, _0$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&sanitizerName); + ZVAL_UNDEF(&sanitizerParams); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ZVAL(value) + Z_PARAM_STR(sanitizerName) + Z_PARAM_ARRAY(sanitizerParams) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_2, &_1, SL("UNION"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 242); - zephir_fast_join_str(&_0, SL(""), &_2); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "getcurrentstatement", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CONCAT_VV(return_value, &_0, &_3); + zephir_fetch_params(1, 3, 0, &value, &sanitizerName_param, &sanitizerParams_param); + ZEPHIR_SEPARATE_PARAM(value); + zephir_get_strval(&sanitizerName, sanitizerName_param); + zephir_get_arrval(&sanitizerParams, sanitizerParams_param); + if (Z_TYPE_P(value) != IS_ARRAY) { + ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "sanitizer", NULL, 278, value, &sanitizerName, &sanitizerParams); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(value, &_0$$3); + } + RETVAL_ZVAL(value, 1, 0); RETURN_MM(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, groupBy) +static PHP_METHOD(Phalcon_Filter_Filter, splitSanitizerParameters) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *groupBy, groupBy_sub, _0; - zval *this_ptr = getThis(); + zval *sanitizerKey, sanitizerKey_sub, *sanitizer, sanitizer_sub, _0; - ZVAL_UNDEF(&groupBy_sub); + ZVAL_UNDEF(&sanitizerKey_sub); + ZVAL_UNDEF(&sanitizer_sub); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(groupBy) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(sanitizerKey) + Z_PARAM_ZVAL(sanitizer) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &groupBy); + zephir_fetch_params(1, 2, 0, &sanitizerKey, &sanitizer); + if (Z_TYPE_P(sanitizer) == IS_ARRAY) { + zephir_create_array(return_value, 2, 0); + zephir_array_fast_append(return_value, sanitizerKey); + zephir_array_fast_append(return_value, sanitizer); + RETURN_MM(); + } + zephir_create_array(return_value, 2, 0); + zephir_array_fast_append(return_value, sanitizer); ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "GROUP"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processvalue", NULL, 0, &_0, groupBy); - zephir_check_call_status(); - RETURN_THIS(); + array_init(&_0); + zephir_array_fast_append(return_value, &_0); + RETURN_MM(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, hasColumns) +zend_object *zephir_init_properties_Phalcon_Filter_Filter(zend_class_entry *class_type) { - zval _0, _1; - zval *this_ptr = getThis(); + zval _0, _2, _1$$3, _3$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_1, &_0, SL("COLUMNS"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 266); - RETURN_BOOL(zephir_fast_count_int(&_1) > 0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("services"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("mapper"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("mapper"), &_3$$4); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, having) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_FilterFactory) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _0, _1, _2; - zval condition; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter, FilterFactory, phalcon, filter_filterfactory, phalcon_filter_filterfactory_method_entry, 0); - ZVAL_UNDEF(&condition); - ZVAL_UNDEF(&value_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(condition) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) - Z_PARAM_LONG(type) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &condition_param, &value, &type_param); - zephir_get_strval(&condition, condition_param); - if (!value) { - value = &value_sub; - value = &__$null; - } - if (!type_param) { - type = -1; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "HAVING"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "AND "); - ZVAL_LONG(&_2, type); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addcondition", NULL, 0, &_0, &_1, &condition, value, &_2); - zephir_check_call_status(); - RETURN_THIS(); + return SUCCESS; } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, join) +static PHP_METHOD(Phalcon_Filter_FilterFactory, newInstance) { - zend_bool _5, _10; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *join_param = NULL, *table_param = NULL, *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, key, _0, _1, _2, _3, _4, _6, _7, _8, _9, _11, _12, _13, _14, _19, _20, _16$$5, _17$$5, _18$$5; - zval join, table, condition, _21, _15$$4; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&join); - ZVAL_UNDEF(&table); - ZVAL_UNDEF(&condition); - ZVAL_UNDEF(&_21); - ZVAL_UNDEF(&_15$$4); - ZVAL_UNDEF(&value_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&key); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_13); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_19); - ZVAL_UNDEF(&_20); - ZVAL_UNDEF(&_16$$5); - ZVAL_UNDEF(&_17$$5); - ZVAL_UNDEF(&_18$$5); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 5) - Z_PARAM_STR(join) - Z_PARAM_STR(table) - Z_PARAM_STR(condition) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) - Z_PARAM_LONG(type) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 2, &join_param, &table_param, &condition_param, &value, &type_param); - zephir_get_strval(&join, join_param); - zephir_get_strval(&table, table_param); - zephir_get_strval(&condition, condition_param); - if (!value) { - value = &value_sub; - value = &__$null; - } - if (!type_param) { - type = -1; - } else { - } - ZEPHIR_INIT_VAR(&_0); - zephir_fast_trim(&_0, &join, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&join); - zephir_fast_strtoupper(&join, &_0); - ZVAL_LONG(&_1, -4); - ZEPHIR_INIT_VAR(&_2); - zephir_substr(&_2, &join, -4 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - if (!ZEPHIR_IS_STRING_IDENTICAL(&_2, "JOIN")) { - zephir_concat_self_str(&join, " JOIN", sizeof(" JOIN") - 1); - } - ZEPHIR_INIT_VAR(&_3); - zephir_fast_trim(&_3, &condition, NULL , ZEPHIR_TRIM_LEFT); - zephir_get_strval(&condition, &_3); - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, ""); - _5 = !ZEPHIR_IS_IDENTICAL(&_4, &condition); - if (_5) { - ZEPHIR_INIT_VAR(&_6); - ZVAL_LONG(&_7, 0); - ZVAL_LONG(&_8, 3); - ZEPHIR_INIT_VAR(&_9); - zephir_substr(&_9, &condition, 0 , 3 , 0); - zephir_fast_strtoupper(&_6, &_9); - _5 = !ZEPHIR_IS_STRING_IDENTICAL(&_6, "ON "); - } - _10 = _5; - if (_10) { - ZEPHIR_INIT_VAR(&_11); - ZVAL_LONG(&_12, 0); - ZVAL_LONG(&_13, 6); - ZEPHIR_INIT_VAR(&_14); - zephir_substr(&_14, &condition, 0 , 6 , 0); - zephir_fast_strtoupper(&_11, &_14); - _10 = !ZEPHIR_IS_STRING_IDENTICAL(&_11, "USING "); - } - if (_10) { - ZEPHIR_INIT_VAR(&_15$$4); - ZEPHIR_CONCAT_SV(&_15$$4, "ON ", &condition); - ZEPHIR_CPY_WRT(&condition, &_15$$4); - } - if (!(ZEPHIR_IS_EMPTY(value))) { - zephir_read_property(&_16$$5, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_18$$5, type); - ZEPHIR_CALL_METHOD(&_17$$5, &_16$$5, "bindinline", NULL, 0, value, &_18$$5); - zephir_check_call_status(); - zephir_concat_self(&condition, &_17$$5); - } - zephir_read_property(&_19, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_20, &_19, SL("FROM"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 327); - ZEPHIR_CALL_FUNCTION(&key, "array_key_last", NULL, 40, &_20); + + object_init_ex(return_value, phalcon_filter_filter_ce); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getservices", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_21); - ZEPHIR_CONCAT_VSVSV(&_21, &join, " ", &table, " ", &condition); - zephir_update_property_array_multi(this_ptr, SL("store"), &_21, SL("sza"), 4, SL("FROM"), &key); - RETURN_THIS(); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 282, &_0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, orHaving) +static PHP_METHOD(Phalcon_Filter_FilterFactory, getServices) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _0, _1, _2; - zval condition; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&condition); - ZVAL_UNDEF(&value_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(condition) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) - Z_PARAM_LONG(type) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &condition_param, &value, &type_param); - zephir_get_strval(&condition, condition_param); - if (!value) { - value = &value_sub; - value = &__$null; - } - if (!type_param) { - type = -1; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "HAVING"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "OR "); - ZVAL_LONG(&_2, type); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addcondition", NULL, 0, &_0, &_1, &condition, value, &_2); - zephir_check_call_status(); - RETURN_THIS(); + zephir_create_array(return_value, 22, 0); + add_assoc_stringl_ex(return_value, SL("absint"), SL("Phalcon\\Filter\\Sanitize\\AbsInt")); + add_assoc_stringl_ex(return_value, SL("alnum"), SL("Phalcon\\Filter\\Sanitize\\Alnum")); + add_assoc_stringl_ex(return_value, SL("alpha"), SL("Phalcon\\Filter\\Sanitize\\Alpha")); + add_assoc_stringl_ex(return_value, SL("bool"), SL("Phalcon\\Filter\\Sanitize\\BoolVal")); + add_assoc_stringl_ex(return_value, SL("email"), SL("Phalcon\\Filter\\Sanitize\\Email")); + add_assoc_stringl_ex(return_value, SL("float"), SL("Phalcon\\Filter\\Sanitize\\FloatVal")); + add_assoc_stringl_ex(return_value, SL("int"), SL("Phalcon\\Filter\\Sanitize\\IntVal")); + add_assoc_stringl_ex(return_value, SL("lower"), SL("Phalcon\\Filter\\Sanitize\\Lower")); + add_assoc_stringl_ex(return_value, SL("lowerfirst"), SL("Phalcon\\Filter\\Sanitize\\LowerFirst")); + add_assoc_stringl_ex(return_value, SL("regex"), SL("Phalcon\\Filter\\Sanitize\\Regex")); + add_assoc_stringl_ex(return_value, SL("remove"), SL("Phalcon\\Filter\\Sanitize\\Remove")); + add_assoc_stringl_ex(return_value, SL("replace"), SL("Phalcon\\Filter\\Sanitize\\Replace")); + add_assoc_stringl_ex(return_value, SL("special"), SL("Phalcon\\Filter\\Sanitize\\Special")); + add_assoc_stringl_ex(return_value, SL("specialfull"), SL("Phalcon\\Filter\\Sanitize\\SpecialFull")); + add_assoc_stringl_ex(return_value, SL("string"), SL("Phalcon\\Filter\\Sanitize\\StringVal")); + add_assoc_stringl_ex(return_value, SL("stringlegacy"), SL("Phalcon\\Filter\\Sanitize\\StringValLegacy")); + add_assoc_stringl_ex(return_value, SL("striptags"), SL("Phalcon\\Filter\\Sanitize\\Striptags")); + add_assoc_stringl_ex(return_value, SL("trim"), SL("Phalcon\\Filter\\Sanitize\\Trim")); + add_assoc_stringl_ex(return_value, SL("upper"), SL("Phalcon\\Filter\\Sanitize\\Upper")); + add_assoc_stringl_ex(return_value, SL("upperfirst"), SL("Phalcon\\Filter\\Sanitize\\UpperFirst")); + add_assoc_stringl_ex(return_value, SL("upperwords"), SL("Phalcon\\Filter\\Sanitize\\UpperWords")); + add_assoc_stringl_ex(return_value, SL("url"), SL("Phalcon\\Filter\\Sanitize\\Url")); + return; } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, reset) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$true, __$false, _0; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_CALL_PARENT(NULL, phalcon_datamapper_query_select_ce, getThis(), "reset", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, ""); - zephir_update_property_zval(this_ptr, ZEND_STRL("asAlias"), &_0); - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("forUpdate"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("forUpdate"), &__$false); - } - ZEPHIR_MM_RESTORE(); + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_FilterInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Filter, FilterInterface, phalcon, filter_filterinterface, phalcon_filter_filterinterface_method_entry); + + return SUCCESS; } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, subSelect) +ZEPHIR_DOC_METHOD(Phalcon_Filter_FilterInterface, sanitize); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation) { - zval _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter, Validation, phalcon, filter_validation, phalcon_di_injectable_ce, phalcon_filter_validation_method_entry, 0); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zend_declare_property_null(phalcon_filter_validation_ce, SL("combinedFieldsValidators"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_filter_validation_ce, SL("data"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_filter_validation_ce, SL("entity"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_filter_validation_ce, SL("filters"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_filter_validation_ce, SL("labels"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_filter_validation_ce, SL("messages"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_filter_validation_ce, SL("validators"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_filter_validation_ce, SL("values"), ZEND_ACC_PROTECTED); + phalcon_filter_validation_ce->create_object = zephir_init_properties_Phalcon_Filter_Validation; - object_init_ex(return_value, phalcon_datamapper_query_select_ce); - zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_1, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 209, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); + zend_class_implements(phalcon_filter_validation_ce, 1, phalcon_filter_validation_validationinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, union) +static PHP_METHOD(Phalcon_Filter_Validation, __construct) { - zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *validators_param = NULL, _0, _1, _2, _3; + zval validators; zval *this_ptr = getThis(); + ZVAL_UNDEF(&validators); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(validators) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, " UNION "); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getcurrentstatement", NULL, 0, &_1); + zephir_fetch_params(1, 0, 1, &validators_param); + if (!validators_param) { + ZEPHIR_INIT_VAR(&validators); + array_init(&validators); + } else { + zephir_get_arrval(&validators, validators_param); + } + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_INIT_NVAR(&_0); + zephir_create_closure_ex(&_0, NULL, phalcon_7__closure_ce, SL("__invoke")); + ZEPHIR_CALL_FUNCTION(&_1, "array_filter", NULL, 17, &validators, &_0); zephir_check_call_status(); - zephir_update_property_array_multi(this_ptr, SL("store"), &_0, SL("sa"), 3, SL("UNION")); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "reset", NULL, 0); + zephir_update_property_zval(this_ptr, ZEND_STRL("validators"), &_1); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_INIT_NVAR(&_2); + zephir_create_closure_ex(&_2, NULL, phalcon_8__closure_ce, SL("__invoke")); + ZEPHIR_CALL_FUNCTION(&_3, "array_filter", NULL, 17, &validators, &_2); zephir_check_call_status(); - RETURN_THIS(); + zephir_update_property_zval(this_ptr, ZEND_STRL("combinedFieldsValidators"), &_3); + if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("initialize")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0); + zephir_check_call_status(); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, unionAll) +static PHP_METHOD(Phalcon_Filter_Validation, add) { - zval _0, _1; + zval _0$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *field, field_sub, *validator, validator_sub, singleField, *_1$$5, _2$$5; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&validator_sub); + ZVAL_UNDEF(&singleField); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_0$$4); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(field) + Z_PARAM_OBJECT_OF_CLASS(validator, phalcon_filter_validation_validatorinterface_ce) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, " UNION ALL "); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getcurrentstatement", NULL, 0, &_1); - zephir_check_call_status(); - zephir_update_property_array_multi(this_ptr, SL("store"), &_0, SL("sa"), 3, SL("UNION")); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "reset", NULL, 0); - zephir_check_call_status(); + zephir_fetch_params(1, 2, 0, &field, &validator); + if (Z_TYPE_P(field) == IS_ARRAY) { + if (zephir_instance_of_ev(validator, phalcon_filter_validation_abstractcombinedfieldsvalidator_ce)) { + ZEPHIR_INIT_VAR(&_0$$4); + zephir_create_array(&_0$$4, 2, 0); + zephir_array_fast_append(&_0$$4, field); + zephir_array_fast_append(&_0$$4, validator); + zephir_update_property_array_append(this_ptr, SL("combinedFieldsValidators"), &_0$$4); + } else { + zephir_is_iterable(field, 0, "phalcon/Filter/Validation.zep", 120); + if (Z_TYPE_P(field) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(field), _1$$5) + { + ZEPHIR_INIT_NVAR(&singleField); + ZVAL_COPY(&singleField, _1$$5); + zephir_update_property_array_multi(this_ptr, SL("validators"), validator, SL("za"), 2, &singleField); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, field, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2$$5, field, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2$$5)) { + break; + } + ZEPHIR_CALL_METHOD(&singleField, field, "current", NULL, 0); + zephir_check_call_status(); + zephir_update_property_array_multi(this_ptr, SL("validators"), validator, SL("za"), 2, &singleField); + ZEPHIR_CALL_METHOD(NULL, field, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&singleField); + } + } else if (Z_TYPE_P(field) == IS_STRING) { + zephir_update_property_array_multi(this_ptr, SL("validators"), validator, SL("za"), 2, field); + } else { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "Field must be passed as array of fields or string", "phalcon/Filter/Validation.zep", 126); + return; + } RETURN_THIS(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, getCurrentStatement) +static PHP_METHOD(Phalcon_Filter_Validation, appendMessage) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *suffix_param = NULL, statement, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13$$4, _14$$4; - zval suffix, forUpdate; + zval *message, message_sub, messages, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&suffix); - ZVAL_UNDEF(&forUpdate); - ZVAL_UNDEF(&statement); + ZVAL_UNDEF(&message_sub); + ZVAL_UNDEF(&messages); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_13$$4); - ZVAL_UNDEF(&_14$$4); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_STR(suffix) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(message, phalcon_messages_messageinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &suffix_param); - if (!suffix_param) { - ZEPHIR_INIT_VAR(&suffix); - ZVAL_STRING(&suffix, ""); - } else { - zephir_get_strval(&suffix, suffix_param); - } - ZEPHIR_INIT_VAR(&forUpdate); - zephir_read_property(&_0, this_ptr, ZEND_STRL("forUpdate"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_0)) { - ZEPHIR_INIT_NVAR(&forUpdate); - ZVAL_STRING(&forUpdate, " FOR UPDATE"); + zephir_fetch_params(1, 1, 0, &message); + zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&messages, &_0); + if (Z_TYPE_P(&messages) != IS_OBJECT) { + ZEPHIR_INIT_NVAR(&messages); + object_init_ex(&messages, phalcon_messages_messages_ce); + ZEPHIR_CALL_METHOD(NULL, &messages, "__construct", NULL, 8); + zephir_check_call_status(); } - ZEPHIR_CALL_METHOD(&_1, this_ptr, "buildflags", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "buildlimitearly", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "buildcolumns", NULL, 210); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4, this_ptr, "buildfrom", NULL, 211); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_6); - ZVAL_STRING(&_6, "WHERE"); - ZEPHIR_CALL_METHOD(&_5, this_ptr, "buildcondition", NULL, 0, &_6); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_6); - ZVAL_STRING(&_6, "GROUP"); - ZEPHIR_CALL_METHOD(&_7, this_ptr, "buildby", NULL, 0, &_6); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_6); - ZVAL_STRING(&_6, "HAVING"); - ZEPHIR_CALL_METHOD(&_8, this_ptr, "buildcondition", NULL, 0, &_6); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_6); - ZVAL_STRING(&_6, "ORDER"); - ZEPHIR_CALL_METHOD(&_9, this_ptr, "buildby", NULL, 0, &_6); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_10, this_ptr, "buildlimit", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &messages, "appendmessage", NULL, 289, message); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&statement); - ZEPHIR_CONCAT_SVVVVVVVVVV(&statement, "SELECT", &_1, &_2, &_3, &_4, &_5, &_7, &_8, &_9, &_10, &forUpdate); - zephir_read_property(&_11, this_ptr, ZEND_STRL("asAlias"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_12); - ZVAL_STRING(&_12, ""); - if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_12, &_11))) { - zephir_read_property(&_13$$4, this_ptr, ZEND_STRL("asAlias"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_14$$4); - ZEPHIR_CONCAT_SVSV(&_14$$4, "(", &statement, ") AS ", &_13$$4); - ZEPHIR_CPY_WRT(&statement, &_14$$4); - } - ZEPHIR_CONCAT_VV(return_value, &statement, &suffix); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), &messages); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, buildColumns) +static PHP_METHOD(Phalcon_Filter_Validation, bind) { - zval columns, _0, _3, _1$$3, _2$$4; + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *entity, entity_sub, *data, data_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&entity_sub); + ZVAL_UNDEF(&data_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(entity) + Z_PARAM_ZVAL(data) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "hascolumns", NULL, 0); + zephir_fetch_params(1, 2, 0, &entity, &data); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setentity", NULL, 0, entity); zephir_check_call_status(); - if (!(zephir_is_true(&_0))) { - ZEPHIR_INIT_VAR(&columns); - zephir_create_array(&columns, 1, 0); - ZEPHIR_INIT_VAR(&_1$$3); - ZVAL_STRING(&_1$$3, "*"); - zephir_array_fast_append(&columns, &_1$$3); - } else { - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_OBS_NVAR(&columns); - zephir_array_fetch_string(&columns, &_2$$4, SL("COLUMNS"), PH_NOISY, "phalcon/DataMapper/Query/Select.zep", 449); + _0 = Z_TYPE_P(data) != IS_ARRAY; + if (_0) { + _0 = Z_TYPE_P(data) != IS_OBJECT; } - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, ","); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "indent", NULL, 0, &columns, &_3); - zephir_check_call_status(); - RETURN_MM(); + if (UNEXPECTED(_0)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "Data to validate must be an array or object", "phalcon/Filter/Validation.zep", 166); + return; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("data"), data); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Select, buildFrom) +static PHP_METHOD(Phalcon_Filter_Validation, getData) +{ + + RETURN_MEMBER(getThis(), "data"); +} + +static PHP_METHOD(Phalcon_Filter_Validation, getEntity) +{ + + RETURN_MEMBER(getThis(), "entity"); +} + +static PHP_METHOD(Phalcon_Filter_Validation, getFilters) { - zval from; - zval table, _0, _1, _2, _3, *_4, _5, _14, _15, _6$$4, _8$$4, _10$$4, _11$$5, _12$$5, _13$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL, *_9 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *field_param = NULL, filters, fieldFilters, _0; + zval field; zval *this_ptr = getThis(); - ZVAL_UNDEF(&table); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&filters); + ZVAL_UNDEF(&fieldFilters); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_15); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_10$$4); - ZVAL_UNDEF(&_11$$5); - ZVAL_UNDEF(&_12$$5); - ZVAL_UNDEF(&_13$$5); - ZVAL_UNDEF(&from); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(field) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&from); - array_init(&from); - zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_1, &_0, SL("FROM"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 465); - if (ZEPHIR_IS_EMPTY(&_1)) { - RETURN_MM_STRING(""); - } - zephir_read_property(&_2, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_3, &_2, SL("FROM"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 469); - zephir_is_iterable(&_3, 0, "phalcon/DataMapper/Query/Select.zep", 473); - if (Z_TYPE_P(&_3) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_3), _4) - { - ZEPHIR_INIT_NVAR(&table); - ZVAL_COPY(&table, _4); - ZEPHIR_MAKE_REF(&table); - ZEPHIR_CALL_FUNCTION(&_6$$4, "array_shift", &_7, 22, &table); - ZEPHIR_UNREF(&table); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_8$$4, this_ptr, "indent", &_9, 0, &table); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_10$$4); - ZEPHIR_CONCAT_VV(&_10$$4, &_6$$4, &_8$$4); - zephir_array_append(&from, &_10$$4, PH_SEPARATE, "phalcon/DataMapper/Query/Select.zep", 470); - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 0, 1, &field_param); + if (!field_param) { + ZEPHIR_INIT_VAR(&field); } else { - ZEPHIR_CALL_METHOD(NULL, &_3, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5, &_3, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5)) { - break; - } - ZEPHIR_CALL_METHOD(&table, &_3, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_MAKE_REF(&table); - ZEPHIR_CALL_FUNCTION(&_11$$5, "array_shift", &_7, 22, &table); - ZEPHIR_UNREF(&table); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_12$$5, this_ptr, "indent", &_9, 0, &table); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_13$$5); - ZEPHIR_CONCAT_VV(&_13$$5, &_11$$5, &_12$$5); - zephir_array_append(&from, &_13$$5, PH_SEPARATE, "phalcon/DataMapper/Query/Select.zep", 470); - ZEPHIR_CALL_METHOD(NULL, &_3, "next", NULL, 0); - zephir_check_call_status(); - } + zephir_get_strval(&field, field_param); } - ZEPHIR_INIT_NVAR(&table); - ZEPHIR_INIT_VAR(&_15); - ZVAL_STRING(&_15, ","); - ZEPHIR_CALL_METHOD(&_14, this_ptr, "indent", &_9, 0, &from, &_15); - zephir_check_call_status(); - ZEPHIR_CONCAT_SV(return_value, " FROM", &_14); - RETURN_MM(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("filters"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&filters, &_0); + if (!(!(ZEPHIR_IS_EMPTY(&field)))) { + RETURN_CCTOR(&filters); + } + zephir_memory_observe(&fieldFilters); + if (!(zephir_array_isset_fetch(&fieldFilters, &filters, &field, 0))) { + RETURN_MM_NULL(); + } + RETURN_CCTOR(&fieldFilters); } +static PHP_METHOD(Phalcon_Filter_Validation, getLabel) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *field, field_sub, labels, value, _0; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&labels); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(field) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &field); + zephir_read_property(&_0, this_ptr, ZEND_STRL("labels"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&labels, &_0); + if (Z_TYPE_P(field) == IS_ARRAY) { + zephir_fast_join_str(return_value, SL(", "), field); + RETURN_MM(); + } + if (zephir_array_isset_fetch(&value, &labels, field, 1)) { + RETURN_CTOR(&value); + } + RETVAL_ZVAL(field, 1, 0); + RETURN_MM(); +} +static PHP_METHOD(Phalcon_Filter_Validation, getMessages) +{ -#ifdef HAVE_CONFIG_H -#endif - - - - + RETURN_MEMBER(getThis(), "messages"); +} -ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Query_Update) +static PHP_METHOD(Phalcon_Filter_Validation, getValidators) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Query, Update, phalcon, datamapper_query_update, phalcon_datamapper_query_abstractconditions_ce, phalcon_datamapper_query_update_method_entry, 0); - return SUCCESS; + RETURN_MEMBER(getThis(), "validators"); } -static PHP_METHOD(Phalcon_DataMapper_Query_Update, __construct) +static PHP_METHOD(Phalcon_Filter_Validation, getValueByEntity) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connection, connection_sub, *bind, bind_sub, _0, _1, _2, _3; - zval *this_ptr = getThis(); + zval field, method; + zval *entity, entity_sub, *field_param = NULL, _0, _1, _2$$5; - ZVAL_UNDEF(&connection_sub); - ZVAL_UNDEF(&bind_sub); + ZVAL_UNDEF(&entity_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&method); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_datamapper_pdo_connection_ce) - Z_PARAM_OBJECT_OF_CLASS(bind, phalcon_datamapper_query_bind_ce) + Z_PARAM_ZVAL(entity) + Z_PARAM_STR(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &connection, &bind); - ZEPHIR_CALL_PARENT(NULL, phalcon_datamapper_query_update_ce, getThis(), "__construct", NULL, 0, connection, bind); - zephir_check_call_status(); + zephir_fetch_params(1, 2, 0, &entity, &field_param); + zephir_get_strval(&field, field_param); ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "FROM"); + zephir_camelize(&_0, &field, NULL ); ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, ""); - zephir_update_property_array(this_ptr, SL("store"), &_0, &_1); - ZEPHIR_INIT_VAR(&_2); - array_init(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "RETURNING"); - zephir_update_property_array(this_ptr, SL("store"), &_3, &_2); - ZEPHIR_MM_RESTORE(); + ZEPHIR_CONCAT_SV(&_1, "get", &_0); + zephir_get_strval(&method, &_1); + if ((zephir_method_exists(entity, &method) == SUCCESS)) { + ZEPHIR_RETURN_CALL_METHOD_ZVAL(entity, &method, NULL, 0); + zephir_check_call_status(); + RETURN_MM(); + } + if ((zephir_method_exists_ex(entity, ZEND_STRL("readattribute")) == SUCCESS)) { + ZEPHIR_RETURN_CALL_METHOD(entity, "readattribute", NULL, 0, &field); + zephir_check_call_status(); + RETURN_MM(); + } + if (zephir_isset_property_zval(entity, &field)) { + zephir_memory_observe(&_2$$5); + zephir_read_property_zval(&_2$$5, entity, &field, PH_NOISY_CC); + RETURN_CCTOR(&_2$$5); + } + RETURN_MM_NULL(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Update, column) +static PHP_METHOD(Phalcon_Filter_Validation, getValueByData) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long type, ZEPHIR_LAST_CALL_STATUS; - zval *column_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _1$$3, _2$$3; - zval column, _0; + zval field; + zval *data, data_sub, *field_param = NULL, value, values, _0, _1$$5, _2$$7; zval *this_ptr = getThis(); - ZVAL_UNDEF(&column); + ZVAL_UNDEF(&data_sub); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&values); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&value_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(column) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) - Z_PARAM_LONG(type) + ZVAL_UNDEF(&_1$$5); + ZVAL_UNDEF(&_2$$7); + ZVAL_UNDEF(&field); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(data) + Z_PARAM_STR(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &column_param, &value, &type_param); - zephir_get_strval(&column, column_param); - if (!value) { - value = &value_sub; - value = &__$null; + zephir_fetch_params(1, 2, 0, &data, &field_param); + zephir_get_strval(&field, field_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("values"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&values, &_0); + zephir_memory_observe(&value); + if (zephir_array_isset_fetch(&value, &values, &field, 0)) { + RETURN_CCTOR(&value); } - if (!type_param) { - type = -1; - } else { + if (Z_TYPE_P(data) == IS_ARRAY) { + if (zephir_array_isset(data, &field)) { + zephir_array_fetch(&_1$$5, data, &field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation.zep", 296); + RETURN_CTOR(&_1$$5); } - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_CONCAT_SV(&_0, ":", &column); - zephir_update_property_array_multi(this_ptr, SL("store"), &_0, SL("sz"), 3, SL("COLUMNS"), &column); - if (Z_TYPE_P(value) != IS_NULL) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_2$$3, type); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "setvalue", NULL, 0, &column, value, &_2$$3); - zephir_check_call_status(); } - RETURN_THIS(); + if (Z_TYPE_P(data) == IS_OBJECT) { + if (zephir_isset_property_zval(data, &field)) { + zephir_memory_observe(&_2$$7); + zephir_read_property_zval(&_2$$7, data, &field, PH_NOISY_CC); + RETURN_CCTOR(&_2$$7); + } + } + RETURN_MM_NULL(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Update, columns) +static PHP_METHOD(Phalcon_Filter_Validation, getValue) { - zend_string *_3; - zend_ulong _2; + zend_bool isRawFetched = 0, _1$$5, _4$$9; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *columns_param = NULL, column, value, *_0, _1; - zval columns; + zval *field_param = NULL, entity, method, value, data, filters, fieldFilters, container, filterService, _0, _2$$9, _3$$9, _5$$13, _6$$13; + zval field; zval *this_ptr = getThis(); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&column); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&entity); + ZVAL_UNDEF(&method); ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&filters); + ZVAL_UNDEF(&fieldFilters); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&filterService); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2$$9); + ZVAL_UNDEF(&_3$$9); + ZVAL_UNDEF(&_5$$13); + ZVAL_UNDEF(&_6$$13); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(columns) + Z_PARAM_STR(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &columns_param); - zephir_get_arrval(&columns, columns_param); - zephir_is_iterable(&columns, 0, "phalcon/DataMapper/Query/Update.zep", 76); - if (Z_TYPE_P(&columns) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&columns), _2, _3, _0) - { - ZEPHIR_INIT_NVAR(&column); - if (_3 != NULL) { - ZVAL_STR_COPY(&column, _3); - } else { - ZVAL_LONG(&column, _2); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0); - if (Z_TYPE_P(&column) == IS_LONG) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "column", &_4, 0, &value); - zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "column", &_4, 0, &column, &value); - zephir_check_call_status(); - } - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 1, 0, &field_param); + zephir_get_strval(&field, field_param); + isRawFetched = 0; + zephir_read_property(&_0, this_ptr, ZEND_STRL("entity"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&entity, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&data, &_0); + if (Z_TYPE_P(&entity) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(&value, this_ptr, "getvaluebyentity", NULL, 0, &entity, &field); + zephir_check_call_status(); + if (Z_TYPE_P(&value) == IS_NULL) { + isRawFetched = 1; + ZEPHIR_CALL_METHOD(&value, this_ptr, "getvaluebydata", NULL, 0, &data, &field); + zephir_check_call_status(); + } } else { - ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); + _1$$5 = Z_TYPE_P(&data) != IS_ARRAY; + if (_1$$5) { + _1$$5 = Z_TYPE_P(&data) != IS_OBJECT; + } + if (UNEXPECTED(_1$$5)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "There is no data to validate", "phalcon/Filter/Validation.zep", 333); + return; + } + ZEPHIR_CALL_METHOD(&value, this_ptr, "getvaluebydata", NULL, 0, &data, &field); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &columns, "valid", NULL, 0); + } + if (Z_TYPE_P(&value) == IS_NULL) { + RETURN_MM_NULL(); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("filters"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&filters, &_0); + zephir_memory_observe(&fieldFilters); + if (zephir_array_isset_fetch(&fieldFilters, &filters, &field, 0)) { + if (zephir_is_true(&fieldFilters)) { + ZEPHIR_CALL_METHOD(&container, this_ptr, "getdi", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "A dependency injection container is required to access the 'filter' service", "phalcon/Filter/Validation.zep", 354); + return; + } } - ZEPHIR_CALL_METHOD(&column, &columns, "key", NULL, 0); + ZEPHIR_INIT_VAR(&_3$$9); + ZVAL_STRING(&_3$$9, "filter"); + ZEPHIR_CALL_METHOD(&_2$$9, &container, "getshared", NULL, 0, &_3$$9); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &columns, "current", NULL, 0); + ZEPHIR_CPY_WRT(&filterService, &_2$$9); + if (UNEXPECTED(Z_TYPE_P(&filterService) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "Returned 'filter' service is invalid", "phalcon/Filter/Validation.zep", 361); + return; + } + ZEPHIR_CALL_METHOD(&_2$$9, &filterService, "sanitize", NULL, 0, &value, &fieldFilters); zephir_check_call_status(); - if (Z_TYPE_P(&column) == IS_LONG) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "column", &_4, 0, &value); + ZEPHIR_CPY_WRT(&value, &_2$$9); + _4$$9 = Z_TYPE_P(&entity) == IS_OBJECT; + if (_4$$9) { + _4$$9 = isRawFetched == 0; + } + if (_4$$9) { + ZEPHIR_INIT_VAR(&_5$$13); + zephir_camelize(&_5$$13, &field, NULL ); + ZEPHIR_INIT_VAR(&method); + ZEPHIR_CONCAT_SV(&method, "set", &_5$$13); + ZEPHIR_CALL_FUNCTION(&_6$$13, "property_exists", NULL, 290, &entity, &field); + zephir_check_call_status(); + if ((zephir_method_exists(&entity, &method) == SUCCESS)) { + ZEPHIR_CALL_METHOD_ZVAL(NULL, &entity, &method, NULL, 0, &value); zephir_check_call_status(); - } else { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "column", &_4, 0, &column, &value); + } else if ((zephir_method_exists_ex(&entity, ZEND_STRL("writeattribute")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(NULL, &entity, "writeattribute", NULL, 0, &field, &value); zephir_check_call_status(); + } else if (zephir_is_true(&_6$$13)) { + zephir_update_property_zval_zval(&entity, &field, &value); } - ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); - zephir_check_call_status(); + } + RETURN_CCTOR(&value); } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&column); - RETURN_THIS(); + if (Z_TYPE_P(&entity) != IS_OBJECT) { + zephir_update_property_array(this_ptr, SL("values"), &field, &value); + } + RETURN_CCTOR(&value); } -static PHP_METHOD(Phalcon_DataMapper_Query_Update, from) +static PHP_METHOD(Phalcon_Filter_Validation, rule) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *table_param = NULL, _0; - zval table; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *field, field_sub, *validator, validator_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&table); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(table) + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&validator_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(field) + Z_PARAM_OBJECT_OF_CLASS(validator, phalcon_filter_validation_validatorinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &table_param); - zephir_get_strval(&table, table_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "FROM"); - zephir_update_property_array(this_ptr, SL("store"), &_0, &table); - RETURN_THIS(); + zephir_fetch_params(1, 2, 0, &field, &validator); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, field, validator); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Update, getStatement) +static PHP_METHOD(Phalcon_Filter_Validation, rules) { - zval _0, _1, _2, _3, _4, _5, _6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_2 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval validators; + zval *field, field_sub, *validators_param = NULL, validator, *_0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&validator); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&validators); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(field) + Z_PARAM_ARRAY(validators) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "buildflags", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_1, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_2, &_1, SL("FROM"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Update.zep", 101); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "buildcolumns", NULL, 212); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_5); - ZVAL_STRING(&_5, "WHERE"); - ZEPHIR_CALL_METHOD(&_4, this_ptr, "buildcondition", NULL, 0, &_5); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_6, this_ptr, "buildreturning", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CONCAT_SVSVVVV(return_value, "UPDATE", &_0, " ", &_2, &_3, &_4, &_6); - RETURN_MM(); + zephir_fetch_params(1, 2, 0, &field, &validators_param); + ZEPHIR_OBS_COPY_OR_DUP(&validators, validators_param); + zephir_is_iterable(&validators, 0, "phalcon/Filter/Validation.zep", 419); + if (Z_TYPE_P(&validators) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&validators), _0) + { + ZEPHIR_INIT_NVAR(&validator); + ZVAL_COPY(&validator, _0); + if (zephir_instance_of_ev(&validator, phalcon_filter_validation_validatorinterface_ce)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "add", &_2, 0, field, &validator); + zephir_check_call_status(); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &validators, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &validators, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&validator, &validators, "current", NULL, 0); + zephir_check_call_status(); + if (zephir_instance_of_ev(&validator, phalcon_filter_validation_validatorinterface_ce)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "add", &_2, 0, field, &validator); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(NULL, &validators, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&validator); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Update, hasColumns) +static PHP_METHOD(Phalcon_Filter_Validation, setEntity) { - zval _0, _1; + zval *entity, entity_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_1, &_0, SL("COLUMNS"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Update.zep", 113); - RETURN_BOOL(zephir_fast_count_int(&_1) > 0); + ZVAL_UNDEF(&entity_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(entity) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &entity); + if (UNEXPECTED(Z_TYPE_P(entity) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_filter_validation_exception_ce, "Entity must be an object", "phalcon/Filter/Validation.zep", 430); + return; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("entity"), entity); } -static PHP_METHOD(Phalcon_DataMapper_Query_Update, returning) +static PHP_METHOD(Phalcon_Filter_Validation, setFilters) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *columns_param = NULL, _0, _1, _2, _3; - zval columns; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *field, field_sub, *filters, filters_sub, singleField, *_0$$3, _1$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(columns) + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&filters_sub); + ZVAL_UNDEF(&singleField); + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(field) + Z_PARAM_ZVAL(filters) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &columns_param); - zephir_get_arrval(&columns, columns_param); - ZEPHIR_INIT_VAR(&_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_2, &_1, SL("RETURNING"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Update.zep", 126); - zephir_fast_array_merge(&_0, &_2, &columns); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "RETURNING"); - zephir_update_property_array(this_ptr, SL("store"), &_3, &_0); + zephir_fetch_params(1, 2, 0, &field, &filters); + if (Z_TYPE_P(field) == IS_ARRAY) { + zephir_is_iterable(field, 0, "phalcon/Filter/Validation.zep", 450); + if (Z_TYPE_P(field) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(field), _0$$3) + { + ZEPHIR_INIT_NVAR(&singleField); + ZVAL_COPY(&singleField, _0$$3); + zephir_update_property_array(this_ptr, SL("filters"), &singleField, filters); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, field, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1$$3, field, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&singleField, field, "current", NULL, 0); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("filters"), &singleField, filters); + ZEPHIR_CALL_METHOD(NULL, field, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&singleField); + } else if (Z_TYPE_P(field) == IS_STRING) { + zephir_update_property_array(this_ptr, SL("filters"), field, filters); + } else { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "Field must be passed as array of fields or string.", "phalcon/Filter/Validation.zep", 455); + return; + } RETURN_THIS(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Update, reset) +static PHP_METHOD(Phalcon_Filter_Validation, setLabels) { - zval _0, _1, _2, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *labels_param = NULL; + zval labels; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&labels); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(labels) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_PARENT(NULL, phalcon_datamapper_query_update_ce, getThis(), "reset", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "FROM"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, ""); - zephir_update_property_array(this_ptr, SL("store"), &_0, &_1); - ZEPHIR_INIT_VAR(&_2); - array_init(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "RETURNING"); - zephir_update_property_array(this_ptr, SL("store"), &_3, &_2); + zephir_fetch_params(1, 1, 0, &labels_param); + ZEPHIR_OBS_COPY_OR_DUP(&labels, labels_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("labels"), &labels); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Update, set) +static PHP_METHOD(Phalcon_Filter_Validation, setValidators) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *column_param = NULL, *value = NULL, value_sub, __$null, _0; - zval column; + zval *validators_param = NULL; + zval validators; zval *this_ptr = getThis(); - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&value_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(column) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) + ZVAL_UNDEF(&validators); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(validators) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &column_param, &value); - zephir_get_strval(&column, column_param); - if (!value) { - value = &value_sub; - ZEPHIR_CPY_WRT(value, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(value); - } - if (Z_TYPE_P(value) == IS_NULL) { - ZEPHIR_INIT_NVAR(value); - ZVAL_STRING(value, "NULL"); - } - zephir_update_property_array_multi(this_ptr, SL("store"), value, SL("sz"), 3, SL("COLUMNS"), &column); - zephir_read_property(&_0, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "remove", NULL, 0, &column); - zephir_check_call_status(); + zephir_fetch_params(1, 1, 0, &validators_param); + zephir_get_arrval(&validators, validators_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("validators"), &validators); RETURN_THIS(); } -static PHP_METHOD(Phalcon_DataMapper_Query_Update, buildColumns) +static PHP_METHOD(Phalcon_Filter_Validation, validate) { - zend_string *_5; - zend_ulong _4; - zval assignments; - zval column, value, _0, _1, *_2, _3, _11, _12, _6$$3, _8$$3, _9$$4, _10$$4; + zend_bool _2$$7; + zend_string *_6; + zend_ulong _5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL; + zephir_fcall_cache_entry *_10 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *data = NULL, data_sub, *entity = NULL, entity_sub, __$null, combinedFieldsValidators, field, messages, scope, status, validator, validatorData, validators, _0, _1, *_3, _4, *_28, _29, *_7$$9, _8$$9, _9$$10, _11$$10, _12$$13, _13$$13, _14$$15, _15$$15, _16$$18, _17$$18, *_18$$20, _19$$20, _20$$21, _21$$21, _22$$24, _23$$24, _24$$26, _25$$26, _26$$29, _27$$29, _30$$31, _31$$31, _32$$35, _33$$35, _34$$37, _35$$37, _36$$41, _37$$41, _38$$43; zval *this_ptr = getThis(); - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&value); + ZVAL_UNDEF(&data_sub); + ZVAL_UNDEF(&entity_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&combinedFieldsValidators); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&messages); + ZVAL_UNDEF(&scope); + ZVAL_UNDEF(&status); + ZVAL_UNDEF(&validator); + ZVAL_UNDEF(&validatorData); + ZVAL_UNDEF(&validators); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_10$$4); - ZVAL_UNDEF(&assignments); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_29); + ZVAL_UNDEF(&_8$$9); + ZVAL_UNDEF(&_9$$10); + ZVAL_UNDEF(&_11$$10); + ZVAL_UNDEF(&_12$$13); + ZVAL_UNDEF(&_13$$13); + ZVAL_UNDEF(&_14$$15); + ZVAL_UNDEF(&_15$$15); + ZVAL_UNDEF(&_16$$18); + ZVAL_UNDEF(&_17$$18); + ZVAL_UNDEF(&_19$$20); + ZVAL_UNDEF(&_20$$21); + ZVAL_UNDEF(&_21$$21); + ZVAL_UNDEF(&_22$$24); + ZVAL_UNDEF(&_23$$24); + ZVAL_UNDEF(&_24$$26); + ZVAL_UNDEF(&_25$$26); + ZVAL_UNDEF(&_26$$29); + ZVAL_UNDEF(&_27$$29); + ZVAL_UNDEF(&_30$$31); + ZVAL_UNDEF(&_31$$31); + ZVAL_UNDEF(&_32$$35); + ZVAL_UNDEF(&_33$$35); + ZVAL_UNDEF(&_34$$37); + ZVAL_UNDEF(&_35$$37); + ZVAL_UNDEF(&_36$$41); + ZVAL_UNDEF(&_37$$41); + ZVAL_UNDEF(&_38$$43); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(data) + Z_PARAM_ZVAL_OR_NULL(entity) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&assignments); - array_init(&assignments); - zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch_string(&_1, &_0, SL("COLUMNS"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Update.zep", 175); - zephir_is_iterable(&_1, 0, "phalcon/DataMapper/Query/Update.zep", 179); - if (Z_TYPE_P(&_1) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_1), _4, _5, _2) + zephir_fetch_params(1, 0, 2, &data, &entity); + if (!data) { + data = &data_sub; + data = &__$null; + } + if (!entity) { + entity = &entity_sub; + entity = &__$null; + } + zephir_memory_observe(&validatorData); + zephir_read_property(&validatorData, this_ptr, ZEND_STRL("validators"), PH_NOISY_CC); + zephir_read_property(&_0, this_ptr, ZEND_STRL("combinedFieldsValidators"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&combinedFieldsValidators, &_0); + if (UNEXPECTED(Z_TYPE_P(&validatorData) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "There are no validators to validate", "phalcon/Filter/Validation.zep", 493); + return; + } + ZEPHIR_INIT_VAR(&_1); + array_init(&_1); + zephir_update_property_zval(this_ptr, ZEND_STRL("values"), &_1); + ZEPHIR_INIT_VAR(&messages); + object_init_ex(&messages, phalcon_messages_messages_ce); + ZEPHIR_CALL_METHOD(NULL, &messages, "__construct", NULL, 8); + zephir_check_call_status(); + if (Z_TYPE_P(entity) != IS_NULL) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setentity", NULL, 0, entity); + zephir_check_call_status(); + } + if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("beforevalidation")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(&status, this_ptr, "beforevalidation", NULL, 0, data, entity, &messages); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) { + RETURN_CCTOR(&status); + } + } + zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), &messages); + if (Z_TYPE_P(data) != IS_NULL) { + _2$$7 = Z_TYPE_P(data) != IS_ARRAY; + if (_2$$7) { + _2$$7 = Z_TYPE_P(data) != IS_OBJECT; + } + if (UNEXPECTED(_2$$7)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "Invalid data to validate", "phalcon/Filter/Validation.zep", 525); + return; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("data"), data); + } + zephir_is_iterable(&validatorData, 0, "phalcon/Filter/Validation.zep", 556); + if (Z_TYPE_P(&validatorData) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&validatorData), _5, _6, _3) { - ZEPHIR_INIT_NVAR(&column); - if (_5 != NULL) { - ZVAL_STR_COPY(&column, _5); + ZEPHIR_INIT_NVAR(&field); + if (_6 != NULL) { + ZVAL_STR_COPY(&field, _6); } else { - ZVAL_LONG(&column, _4); + ZVAL_LONG(&field, _5); } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _2); - ZEPHIR_CALL_METHOD(&_6$$3, this_ptr, "quoteidentifier", &_7, 0, &column); + ZEPHIR_INIT_NVAR(&validators); + ZVAL_COPY(&validators, _3); + zephir_is_iterable(&validators, 0, "phalcon/Filter/Validation.zep", 554); + if (Z_TYPE_P(&validators) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&validators), _7$$9) + { + ZEPHIR_INIT_NVAR(&validator); + ZVAL_COPY(&validator, _7$$9); + if (UNEXPECTED(Z_TYPE_P(&validator) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "One of the validators is not valid", "phalcon/Filter/Validation.zep", 534); + return; + } + ZEPHIR_CALL_METHOD(&_9$$10, this_ptr, "prechecking", &_10, 0, &field, &validator); + zephir_check_call_status(); + if (zephir_is_true(&_9$$10)) { + continue; + } + ZEPHIR_CALL_METHOD(&_11$$10, &validator, "validate", NULL, 0, this_ptr, &field); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_11$$10)) { + ZEPHIR_INIT_NVAR(&_13$$13); + ZVAL_STRING(&_13$$13, "cancelOnFail"); + ZEPHIR_CALL_METHOD(&_12$$13, &validator, "getoption", NULL, 0, &_13$$13); + zephir_check_call_status(); + if (zephir_is_true(&_12$$13)) { + break; + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &validators, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_8$$9, &validators, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_8$$9)) { + break; + } + ZEPHIR_CALL_METHOD(&validator, &validators, "current", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&validator) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "One of the validators is not valid", "phalcon/Filter/Validation.zep", 534); + return; + } + ZEPHIR_CALL_METHOD(&_14$$15, this_ptr, "prechecking", &_10, 0, &field, &validator); + zephir_check_call_status(); + if (zephir_is_true(&_14$$15)) { + continue; + } + ZEPHIR_CALL_METHOD(&_15$$15, &validator, "validate", NULL, 0, this_ptr, &field); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_15$$15)) { + ZEPHIR_INIT_NVAR(&_17$$18); + ZVAL_STRING(&_17$$18, "cancelOnFail"); + ZEPHIR_CALL_METHOD(&_16$$18, &validator, "getoption", NULL, 0, &_17$$18); + zephir_check_call_status(); + if (zephir_is_true(&_16$$18)) { + break; + } + } + ZEPHIR_CALL_METHOD(NULL, &validators, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&validator); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &validatorData, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_4, &validatorData, "valid", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_8$$3); - ZEPHIR_CONCAT_VSV(&_8$$3, &_6$$3, " = ", &value); - zephir_array_append(&assignments, &_8$$3, PH_SEPARATE, "phalcon/DataMapper/Query/Update.zep", 176); + if (!zend_is_true(&_4)) { + break; + } + ZEPHIR_CALL_METHOD(&field, &validatorData, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&validators, &validatorData, "current", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&validators, 0, "phalcon/Filter/Validation.zep", 554); + if (Z_TYPE_P(&validators) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&validators), _18$$20) + { + ZEPHIR_INIT_NVAR(&validator); + ZVAL_COPY(&validator, _18$$20); + if (UNEXPECTED(Z_TYPE_P(&validator) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "One of the validators is not valid", "phalcon/Filter/Validation.zep", 534); + return; + } + ZEPHIR_CALL_METHOD(&_20$$21, this_ptr, "prechecking", &_10, 0, &field, &validator); + zephir_check_call_status(); + if (zephir_is_true(&_20$$21)) { + continue; + } + ZEPHIR_CALL_METHOD(&_21$$21, &validator, "validate", NULL, 0, this_ptr, &field); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_21$$21)) { + ZEPHIR_INIT_NVAR(&_23$$24); + ZVAL_STRING(&_23$$24, "cancelOnFail"); + ZEPHIR_CALL_METHOD(&_22$$24, &validator, "getoption", NULL, 0, &_23$$24); + zephir_check_call_status(); + if (zephir_is_true(&_22$$24)) { + break; + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &validators, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_19$$20, &validators, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_19$$20)) { + break; + } + ZEPHIR_CALL_METHOD(&validator, &validators, "current", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&validator) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "One of the validators is not valid", "phalcon/Filter/Validation.zep", 534); + return; + } + ZEPHIR_CALL_METHOD(&_24$$26, this_ptr, "prechecking", &_10, 0, &field, &validator); + zephir_check_call_status(); + if (zephir_is_true(&_24$$26)) { + continue; + } + ZEPHIR_CALL_METHOD(&_25$$26, &validator, "validate", NULL, 0, this_ptr, &field); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_25$$26)) { + ZEPHIR_INIT_NVAR(&_27$$29); + ZVAL_STRING(&_27$$29, "cancelOnFail"); + ZEPHIR_CALL_METHOD(&_26$$29, &validator, "getoption", NULL, 0, &_27$$29); + zephir_check_call_status(); + if (zephir_is_true(&_26$$29)) { + break; + } + } + ZEPHIR_CALL_METHOD(NULL, &validators, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&validator); + ZEPHIR_CALL_METHOD(NULL, &validatorData, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&validators); + ZEPHIR_INIT_NVAR(&field); + zephir_is_iterable(&combinedFieldsValidators, 0, "phalcon/Filter/Validation.zep", 589); + if (Z_TYPE_P(&combinedFieldsValidators) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&combinedFieldsValidators), _28) + { + ZEPHIR_INIT_NVAR(&scope); + ZVAL_COPY(&scope, _28); + if (UNEXPECTED(Z_TYPE_P(&scope) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "The validator scope is not valid", "phalcon/Filter/Validation.zep", 558); + return; + } + ZEPHIR_OBS_NVAR(&field); + zephir_array_fetch_long(&field, &scope, 0, PH_NOISY, "phalcon/Filter/Validation.zep", 561); + ZEPHIR_OBS_NVAR(&validator); + zephir_array_fetch_long(&validator, &scope, 1, PH_NOISY, "phalcon/Filter/Validation.zep", 562); + if (UNEXPECTED(Z_TYPE_P(&validator) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "One of the validators is not valid", "phalcon/Filter/Validation.zep", 565); + return; + } + ZEPHIR_CALL_METHOD(&_30$$31, this_ptr, "prechecking", &_10, 0, &field, &validator); + zephir_check_call_status(); + if (zephir_is_true(&_30$$31)) { + continue; + } + ZEPHIR_CALL_METHOD(&_31$$31, &validator, "validate", NULL, 0, this_ptr, &field); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_31$$31)) { + ZEPHIR_INIT_NVAR(&_33$$35); + ZVAL_STRING(&_33$$35, "cancelOnFail"); + ZEPHIR_CALL_METHOD(&_32$$35, &validator, "getoption", NULL, 0, &_33$$35); + zephir_check_call_status(); + if (zephir_is_true(&_32$$35)) { + break; + } + } } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &_1, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &combinedFieldsValidators, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_3, &_1, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_29, &combinedFieldsValidators, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_3)) { + if (!zend_is_true(&_29)) { break; } - ZEPHIR_CALL_METHOD(&column, &_1, "key", NULL, 0); + ZEPHIR_CALL_METHOD(&scope, &combinedFieldsValidators, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &_1, "current", NULL, 0); + if (UNEXPECTED(Z_TYPE_P(&scope) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "The validator scope is not valid", "phalcon/Filter/Validation.zep", 558); + return; + } + ZEPHIR_OBS_NVAR(&field); + zephir_array_fetch_long(&field, &scope, 0, PH_NOISY, "phalcon/Filter/Validation.zep", 561); + ZEPHIR_OBS_NVAR(&validator); + zephir_array_fetch_long(&validator, &scope, 1, PH_NOISY, "phalcon/Filter/Validation.zep", 562); + if (UNEXPECTED(Z_TYPE_P(&validator) != IS_OBJECT)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "One of the validators is not valid", "phalcon/Filter/Validation.zep", 565); + return; + } + ZEPHIR_CALL_METHOD(&_34$$37, this_ptr, "prechecking", &_10, 0, &field, &validator); + zephir_check_call_status(); + if (zephir_is_true(&_34$$37)) { + continue; + } + ZEPHIR_CALL_METHOD(&_35$$37, &validator, "validate", NULL, 0, this_ptr, &field); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_35$$37)) { + ZEPHIR_INIT_NVAR(&_37$$41); + ZVAL_STRING(&_37$$41, "cancelOnFail"); + ZEPHIR_CALL_METHOD(&_36$$41, &validator, "getoption", NULL, 0, &_37$$41); + zephir_check_call_status(); + if (zephir_is_true(&_36$$41)) { + break; + } + } + ZEPHIR_CALL_METHOD(NULL, &combinedFieldsValidators, "next", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_9$$4, this_ptr, "quoteidentifier", &_7, 0, &column); + } + } + ZEPHIR_INIT_NVAR(&scope); + if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("aftervalidation")) == SUCCESS)) { + zephir_read_property(&_38$$43, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "aftervalidation", NULL, 0, data, entity, &_38$$43); + zephir_check_call_status(); + } + RETURN_MM_MEMBER(getThis(), "messages"); +} + +static PHP_METHOD(Phalcon_Filter_Validation, preChecking) +{ + zval results; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_3 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *field, field_sub, *validator, validator_sub, __$false, singleField, allowEmpty, emptyValue, value, *_0$$3, _1$$3, _2$$4, _4$$6, _5$$8, _6$$8, *_7$$11, _8$$11; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&validator_sub); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&singleField); + ZVAL_UNDEF(&allowEmpty); + ZVAL_UNDEF(&emptyValue); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_4$$6); + ZVAL_UNDEF(&_5$$8); + ZVAL_UNDEF(&_6$$8); + ZVAL_UNDEF(&_8$$11); + ZVAL_UNDEF(&results); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(field) + Z_PARAM_OBJECT_OF_CLASS(validator, phalcon_filter_validation_validatorinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &field, &validator); + ZEPHIR_INIT_VAR(&results); + array_init(&results); + if (Z_TYPE_P(field) == IS_ARRAY) { + zephir_is_iterable(field, 0, "phalcon/Filter/Validation.zep", 617); + if (Z_TYPE_P(field) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(field), _0$$3) + { + ZEPHIR_INIT_NVAR(&singleField); + ZVAL_COPY(&singleField, _0$$3); + ZEPHIR_CALL_METHOD(&_2$$4, this_ptr, "prechecking", &_3, 291, &singleField, validator); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_10$$4); - ZEPHIR_CONCAT_VSV(&_10$$4, &_9$$4, " = ", &value); - zephir_array_append(&assignments, &_10$$4, PH_SEPARATE, "phalcon/DataMapper/Query/Update.zep", 176); - ZEPHIR_CALL_METHOD(NULL, &_1, "next", NULL, 0); + zephir_array_append(&results, &_2$$4, PH_SEPARATE, "phalcon/Filter/Validation.zep", 609); + if (zephir_fast_in_array(&__$false, &results)) { + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, field, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1$$3, field, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&singleField, field, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4$$6, this_ptr, "prechecking", &_3, 291, &singleField, validator); + zephir_check_call_status(); + zephir_array_append(&results, &_4$$6, PH_SEPARATE, "phalcon/Filter/Validation.zep", 609); + if (zephir_fast_in_array(&__$false, &results)) { + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); + ZEPHIR_CALL_METHOD(NULL, field, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&singleField); + } else { + ZEPHIR_INIT_VAR(&_5$$8); + ZVAL_STRING(&_5$$8, "allowEmpty"); + ZVAL_BOOL(&_6$$8, 0); + ZEPHIR_CALL_METHOD(&allowEmpty, validator, "getoption", NULL, 0, &_5$$8, &_6$$8); + zephir_check_call_status(); + if (zephir_is_true(&allowEmpty)) { + if ((zephir_method_exists_ex(validator, ZEND_STRL("isallowempty")) == SUCCESS)) { + ZEPHIR_RETURN_CALL_METHOD(validator, "isallowempty", NULL, 0, this_ptr, field); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_CALL_METHOD(&value, this_ptr, "getvalue", NULL, 0, field); zephir_check_call_status(); + if (Z_TYPE_P(&allowEmpty) == IS_ARRAY) { + zephir_is_iterable(&allowEmpty, 0, "phalcon/Filter/Validation.zep", 634); + if (Z_TYPE_P(&allowEmpty) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&allowEmpty), _7$$11) + { + ZEPHIR_INIT_NVAR(&emptyValue); + ZVAL_COPY(&emptyValue, _7$$11); + if (ZEPHIR_IS_IDENTICAL(&emptyValue, &value)) { + RETURN_MM_BOOL(1); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &allowEmpty, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_8$$11, &allowEmpty, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_8$$11)) { + break; + } + ZEPHIR_CALL_METHOD(&emptyValue, &allowEmpty, "current", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_IDENTICAL(&emptyValue, &value)) { + RETURN_MM_BOOL(1); + } + ZEPHIR_CALL_METHOD(NULL, &allowEmpty, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&emptyValue); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(ZEPHIR_IS_EMPTY(&value)); } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&column); - ZEPHIR_INIT_VAR(&_12); - ZVAL_STRING(&_12, ","); - ZEPHIR_CALL_METHOD(&_11, this_ptr, "indent", NULL, 0, &assignments, &_12); - zephir_check_call_status(); - ZEPHIR_CONCAT_SV(return_value, " SET", &_11); - RETURN_MM(); + RETURN_MM_BOOL(0); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Translate_Exception) +zend_object *zephir_init_properties_Phalcon_Filter_Validation(zend_class_entry *class_type) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Translate, Exception, phalcon, translate_exception, zend_ce_exception, NULL, 0); + zval _0, _2, _4, _6, _8, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_9$$7); + - return SUCCESS; + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("values"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("values"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("validators"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("validators"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("labels"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("labels"), &_5$$5); + } + zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("filters"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_6) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$6); + array_init(&_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("filters"), &_7$$6); + } + zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("combinedFieldsValidators"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_8) == IS_NULL) { + ZEPHIR_INIT_VAR(&_9$$7); + array_init(&_9$$7); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("combinedFieldsValidators"), &_9$$7); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } } @@ -113985,87 +113230,13 @@ ZEPHIR_INIT_CLASS(Phalcon_Translate_Exception) -ZEPHIR_INIT_CLASS(Phalcon_Translate_InterpolatorFactory) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_AbstractCombinedFieldsValidator) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Translate, InterpolatorFactory, phalcon, translate_interpolatorfactory, phalcon_factory_abstractfactory_ce, phalcon_translate_interpolatorfactory_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation, AbstractCombinedFieldsValidator, phalcon, filter_validation_abstractcombinedfieldsvalidator, phalcon_filter_validation_abstractvalidator_ce, NULL, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); return SUCCESS; } -static PHP_METHOD(Phalcon_Translate_InterpolatorFactory, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *services_param = NULL; - zval services; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&services); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(services) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &services_param); - if (!services_param) { - ZEPHIR_INIT_VAR(&services); - array_init(&services); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Translate_InterpolatorFactory, newInstance) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, definition; - zval name; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&definition); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); - zephir_check_call_status(); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(return_value, &definition); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Translate_InterpolatorFactory, getExceptionClass) -{ - - RETURN_STRING("Phalcon\\Translate\\Exception"); -} - -static PHP_METHOD(Phalcon_Translate_InterpolatorFactory, getServices) -{ - - zephir_create_array(return_value, 2, 0); - add_assoc_stringl_ex(return_value, SL("associativeArray"), SL("Phalcon\\Translate\\Interpolator\\AssociativeArray")); - add_assoc_stringl_ex(return_value, SL("indexedArray"), SL("Phalcon\\Translate\\Interpolator\\IndexedArray")); - return; -} - @@ -114076,849 +113247,678 @@ static PHP_METHOD(Phalcon_Translate_InterpolatorFactory, getServices) -ZEPHIR_INIT_CLASS(Phalcon_Translate_TranslateFactory) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_AbstractValidator) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Translate, TranslateFactory, phalcon, translate_translatefactory, phalcon_factory_abstractfactory_ce, phalcon_translate_translatefactory_method_entry, 0); - - zend_declare_property_null(phalcon_translate_translatefactory_ce, SL("interpolator"), ZEND_ACC_PRIVATE); - return SUCCESS; -} + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Validation, AbstractValidator, phalcon, filter_validation_abstractvalidator, phalcon_filter_validation_abstractvalidator_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); -static PHP_METHOD(Phalcon_Translate_TranslateFactory, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval services; - zval *interpolator, interpolator_sub, *services_param = NULL; - zval *this_ptr = getThis(); + zend_declare_property_null(phalcon_filter_validation_abstractvalidator_ce, SL("template"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_filter_validation_abstractvalidator_ce, SL("templates"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_filter_validation_abstractvalidator_ce, SL("options"), ZEND_ACC_PROTECTED); + phalcon_filter_validation_abstractvalidator_ce->create_object = zephir_init_properties_Phalcon_Filter_Validation_AbstractValidator; - ZVAL_UNDEF(&interpolator_sub); - ZVAL_UNDEF(&services); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(interpolator, phalcon_translate_interpolatorfactory_ce) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(services) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &interpolator, &services_param); - if (!services_param) { - ZEPHIR_INIT_VAR(&services); - array_init(&services); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("interpolator"), interpolator); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + zend_class_implements(phalcon_filter_validation_abstractvalidator_ce, 1, phalcon_filter_validation_validatorinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Translate_TranslateFactory, load) +static PHP_METHOD(Phalcon_Filter_Validation_AbstractValidator, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *config = NULL, config_sub, name, options, _0, _1; + zval *options_param = NULL, template, whitelist, _0, _2; + zval options, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&config_sub); - ZVAL_UNDEF(&name); ZVAL_UNDEF(&options); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(config) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &config); - ZEPHIR_SEPARATE_PARAM(config); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfig", NULL, 0, config); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(config, &_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "adapter"); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfigelement", NULL, 0, config, &_1); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(config, &_0); - zephir_memory_observe(&name); - zephir_array_fetch_string(&name, config, SL("adapter"), PH_NOISY, "phalcon/Translate/TranslateFactory.zep", 72); - zephir_memory_observe(&options); - if (!(zephir_array_isset_string_fetch(&options, config, SL("options"), 0))) { - ZEPHIR_INIT_NVAR(&options); - array_init(&options); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "newinstance", NULL, 0, &name, &options); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Translate_TranslateFactory, newInstance) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval options, _0; - zval *name_param = NULL, *options_param = NULL, definition, _1; - zval name; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&definition); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&options); + ZVAL_UNDEF(&template); + ZVAL_UNDEF(&whitelist); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(name) + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &name_param, &options_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } + zephir_fetch_params(1, 0, 1, &options_param); if (!options_param) { ZEPHIR_INIT_VAR(&options); array_init(&options); } else { - ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + zephir_get_arrval(&options, options_param); } - ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); + ZEPHIR_INIT_VAR(&whitelist); + object_init_ex(&whitelist, phalcon_support_helper_arr_whitelist_ce); + if (zephir_has_constructor(&whitelist)) { + ZEPHIR_CALL_METHOD(NULL, &whitelist, "__construct", NULL, 0); + zephir_check_call_status(); + } + + ZEPHIR_INIT_VAR(&_1); + zephir_create_array(&_1, 3, 0); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "template"); + zephir_array_fast_append(&_1, &_2); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "message"); + zephir_array_fast_append(&_1, &_2); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_LONG(&_2, 0); + zephir_array_fast_append(&_1, &_2); + ZEPHIR_CALL_METHOD(&_0, &whitelist, "__invoke", NULL, 3, &options, &_1); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 2, 0); - zephir_memory_observe(&_1); - zephir_read_property(&_1, this_ptr, ZEND_STRL("interpolator"), PH_NOISY_CC); - zephir_array_fast_append(&_0, &_1); - zephir_array_fast_append(&_0, &options); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(return_value, &definition, &_0); + ZEPHIR_CALL_FUNCTION(&template, "current", NULL, 4, &_0); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Translate_TranslateFactory, getExceptionClass) -{ - - RETURN_STRING("Phalcon\\Translate\\Exception"); -} - -static PHP_METHOD(Phalcon_Translate_TranslateFactory, getServices) -{ - - zephir_create_array(return_value, 3, 0); - add_assoc_stringl_ex(return_value, SL("csv"), SL("Phalcon\\Translate\\Adapter\\Csv")); - add_assoc_stringl_ex(return_value, SL("gettext"), SL("Phalcon\\Translate\\Adapter\\Gettext")); - add_assoc_stringl_ex(return_value, SL("array"), SL("Phalcon\\Translate\\Adapter\\NativeArray")); - return; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Translate_Interpolator_AssociativeArray) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Translate\\Interpolator, AssociativeArray, phalcon, translate_interpolator_associativearray, phalcon_translate_interpolator_associativearray_method_entry, 0); - - zend_class_implements(phalcon_translate_interpolator_associativearray_ce, 1, phalcon_translate_interpolator_interpolatorinterface_ce); - return SUCCESS; + if (Z_TYPE_P(&template) == IS_ARRAY) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "settemplates", NULL, 0, &template); + zephir_check_call_status(); + } else if (Z_TYPE_P(&template) == IS_STRING) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "settemplate", NULL, 0, &template); + zephir_check_call_status(); + } + if (zephir_is_true(&template)) { + zephir_array_update_string(&options, SL("message"), &template, PH_COPY | PH_SEPARATE); + zephir_array_unset_string(&options, SL("template"), PH_SEPARATE); + zephir_array_unset_long(&options, 0, PH_SEPARATE); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Translate_Interpolator_AssociativeArray, replacePlaceholders) +static PHP_METHOD(Phalcon_Filter_Validation_AbstractValidator, getOption) { + zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval placeholders; - zval *translation_param = NULL, *placeholders_param = NULL, interpolate; - zval translation; + zval *key_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null, value, fieldValue, _0; + zval key; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&translation); - ZVAL_UNDEF(&interpolate); - ZVAL_UNDEF(&placeholders); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&fieldValue); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(translation) + Z_PARAM_STR(key) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(placeholders) + Z_PARAM_ZVAL_OR_NULL(defaultValue) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &translation_param, &placeholders_param); - if (UNEXPECTED(Z_TYPE_P(translation_param) != IS_STRING && Z_TYPE_P(translation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'translation' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 1, &key_param, &defaultValue); + zephir_get_strval(&key, key_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; } - if (EXPECTED(Z_TYPE_P(translation_param) == IS_STRING)) { - zephir_get_strval(&translation, translation_param); - } else { - ZEPHIR_INIT_VAR(&translation); + zephir_memory_observe(&value); + zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&value, &_0, &key, 0))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); } - if (!placeholders_param) { - ZEPHIR_INIT_VAR(&placeholders); - array_init(&placeholders); - } else { - zephir_get_arrval(&placeholders, placeholders_param); + _1 = ZEPHIR_IS_STRING_IDENTICAL(&key, "attribute"); + if (_1) { + _1 = Z_TYPE_P(&value) == IS_ARRAY; } - ZEPHIR_INIT_VAR(&interpolate); - object_init_ex(&interpolate, phalcon_support_helper_str_interpolate_ce); - if (zephir_has_constructor(&interpolate)) { - ZEPHIR_CALL_METHOD(NULL, &interpolate, "__construct", NULL, 0); - zephir_check_call_status(); + if (_1) { + zephir_memory_observe(&fieldValue); + if (zephir_array_isset_fetch(&fieldValue, &value, &key, 0)) { + RETURN_CCTOR(&fieldValue); + } } - - ZEPHIR_RETURN_CALL_METHOD(&interpolate, "__invoke", NULL, 0, &translation, &placeholders); - zephir_check_call_status(); - RETURN_MM(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Translate_Interpolator_IndexedArray) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Translate\\Interpolator, IndexedArray, phalcon, translate_interpolator_indexedarray, phalcon_translate_interpolator_indexedarray_method_entry, 0); - - zend_class_implements(phalcon_translate_interpolator_indexedarray_ce, 1, phalcon_translate_interpolator_interpolatorinterface_ce); - return SUCCESS; + RETURN_CCTOR(&value); } -static PHP_METHOD(Phalcon_Translate_Interpolator_IndexedArray, replacePlaceholders) +static PHP_METHOD(Phalcon_Filter_Validation_AbstractValidator, getTemplate) { + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval placeholders; - zval *translation_param = NULL, *placeholders_param = NULL, _0$$3; - zval translation; + zval *field_param = NULL, _1, _4, _5, _2$$3, _3$$3; + zval field; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&translation); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&placeholders); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(translation) + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(placeholders) + Z_PARAM_STR_OR_NULL(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &translation_param, &placeholders_param); - if (UNEXPECTED(Z_TYPE_P(translation_param) != IS_STRING && Z_TYPE_P(translation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'translation' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(translation_param) == IS_STRING)) { - zephir_get_strval(&translation, translation_param); + zephir_fetch_params(1, 0, 1, &field_param); + if (!field_param) { + ZEPHIR_INIT_VAR(&field); } else { - ZEPHIR_INIT_VAR(&translation); + zephir_get_strval(&field, field_param); } - if (!placeholders_param) { - ZEPHIR_INIT_VAR(&placeholders); - array_init(&placeholders); - } else { - zephir_get_arrval(&placeholders, placeholders_param); + _0 = !ZEPHIR_IS_NULL(&field); + if (_0) { + zephir_read_property(&_1, this_ptr, ZEND_STRL("templates"), PH_NOISY_CC | PH_READONLY); + _0 = zephir_array_isset(&_1, &field); } - if (1 != ZEPHIR_IS_EMPTY(&placeholders)) { - ZEPHIR_MAKE_REF(&placeholders); - ZEPHIR_CALL_FUNCTION(NULL, "array_unshift", NULL, 270, &placeholders, &translation); - ZEPHIR_UNREF(&placeholders); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0$$3); - ZVAL_STRING(&_0$$3, "sprintf"); - ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_0$$3, &placeholders); - zephir_check_call_status(); - RETURN_MM(); + if (_0) { + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("templates"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_3$$3, &_2$$3, &field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/AbstractValidator.zep", 111); + RETURN_CTOR(&_3$$3); } - RETURN_CTOR(&translation); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Translate_Interpolator_InterpolatorInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Translate\\Interpolator, InterpolatorInterface, phalcon, translate_interpolator_interpolatorinterface, phalcon_translate_interpolator_interpolatorinterface_method_entry); - - return SUCCESS; + zephir_read_property(&_4, this_ptr, ZEND_STRL("template"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_4)) { + RETURN_MM_MEMBER(getThis(), "template"); + } + ZEPHIR_INIT_VAR(&_5); + zephir_get_class(&_5, this_ptr, 0); + ZEPHIR_CONCAT_SV(return_value, "The field :field is not valid for ", &_5); + RETURN_MM(); } -ZEPHIR_DOC_METHOD(Phalcon_Translate_Interpolator_InterpolatorInterface, replacePlaceholders); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Translate_Adapter_AbstractAdapter) +static PHP_METHOD(Phalcon_Filter_Validation_AbstractValidator, getTemplates) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Translate\\Adapter, AbstractAdapter, phalcon, translate_adapter_abstractadapter, phalcon_translate_adapter_abstractadapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zend_declare_property_string(phalcon_translate_adapter_abstractadapter_ce, SL("defaultInterpolator"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_translate_adapter_abstractadapter_ce, SL("interpolatorFactory"), ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_translate_adapter_abstractadapter_ce, 1, phalcon_translate_adapter_adapterinterface_ce); - return SUCCESS; + RETURN_MEMBER(getThis(), "templates"); } -static PHP_METHOD(Phalcon_Translate_Adapter_AbstractAdapter, __construct) +static PHP_METHOD(Phalcon_Filter_Validation_AbstractValidator, hasOption) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval options; - zval *interpolator, interpolator_sub, *options_param = NULL, value; + zval *key_param = NULL, _0; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&interpolator_sub); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(interpolator, phalcon_translate_interpolatorfactory_ce) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &interpolator, &options_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - zephir_memory_observe(&value); - if (!(zephir_array_isset_string_fetch(&value, &options, SL("defaultInterpolator"), 0))) { - ZEPHIR_INIT_NVAR(&value); - ZVAL_STRING(&value, "associativeArray"); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultInterpolator"), &value); - zephir_update_property_zval(this_ptr, ZEND_STRL("interpolatorFactory"), interpolator); - ZEPHIR_MM_RESTORE(); + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + RETURN_MM_BOOL(zephir_array_isset(&_0, &key)); } -static PHP_METHOD(Phalcon_Translate_Adapter_AbstractAdapter, _) +static PHP_METHOD(Phalcon_Filter_Validation_AbstractValidator, messageFactory) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval placeholders; - zval *translateKey_param = NULL, *placeholders_param = NULL; - zval translateKey; + zval replacements, _1; + zval *validation, validation_sub, *field, field_sub, *replacements_param = NULL, singleField, _0, _2, _3, _4, _5; zval *this_ptr = getThis(); - ZVAL_UNDEF(&translateKey); - ZVAL_UNDEF(&placeholders); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(translateKey) + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&singleField); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&replacements); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(placeholders) + Z_PARAM_ARRAY(replacements) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &translateKey_param, &placeholders_param); - if (UNEXPECTED(Z_TYPE_P(translateKey_param) != IS_STRING && Z_TYPE_P(translateKey_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'translateKey' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(translateKey_param) == IS_STRING)) { - zephir_get_strval(&translateKey, translateKey_param); + zephir_fetch_params(1, 2, 1, &validation, &field, &replacements_param); + if (!replacements_param) { + ZEPHIR_INIT_VAR(&replacements); + array_init(&replacements); } else { - ZEPHIR_INIT_VAR(&translateKey); + zephir_get_arrval(&replacements, replacements_param); } - if (!placeholders_param) { - ZEPHIR_INIT_VAR(&placeholders); - array_init(&placeholders); + if (Z_TYPE_P(field) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&singleField); + zephir_fast_join_str(&singleField, SL(", "), field); + } else if (Z_TYPE_P(field) == IS_STRING) { + ZEPHIR_CPY_WRT(&singleField, field); } else { - zephir_get_arrval(&placeholders, placeholders_param); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "The field can not be printed", "phalcon/Filter/Validation/AbstractValidator.zep", 166); + return; } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "query", NULL, 0, &translateKey, &placeholders); + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_INIT_VAR(&_1); + zephir_create_array(&_1, 1, 0); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "preparelabel", NULL, 0, validation, &singleField); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Translate_Adapter_AbstractAdapter, offsetExists) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *translateKey, translateKey_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&translateKey_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(translateKey) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &translateKey); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, translateKey); + zephir_array_update_string(&_1, SL(":field"), &_2, PH_COPY | PH_SEPARATE); + zephir_fast_array_merge(&_0, &_1, &replacements); + ZEPHIR_CPY_WRT(&replacements, &_0); + object_init_ex(return_value, phalcon_messages_message_ce); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "gettemplate", NULL, 0, &singleField); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_3, "strtr", NULL, 5, &_2, &replacements); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4); + zephir_get_class(&_4, this_ptr, 0); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "preparecode", NULL, 0, &singleField); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 6, &_3, field, &_4, &_5); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Translate_Adapter_AbstractAdapter, offsetGet) +static PHP_METHOD(Phalcon_Filter_Validation_AbstractValidator, setOption) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval translateKey_sub; - zval *translateKey; + zval *key_param = NULL, *value, value_sub; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&translateKey_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(translateKey) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &translateKey); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "query", NULL, 0, translateKey); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Translate_Adapter_AbstractAdapter, offsetSet) -{ - zval *offset, offset_sub, *value, value_sub; - - ZVAL_UNDEF(&offset_sub); + ZVAL_UNDEF(&key); ZVAL_UNDEF(&value_sub); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(offset) + Z_PARAM_STR(key) Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(2, 0, &offset, &value); - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_translate_exception_ce, "Translate is an immutable ArrayAccess object", "phalcon/Translate/Adapter/AbstractAdapter.zep", 103); - return; -} - -static PHP_METHOD(Phalcon_Translate_Adapter_AbstractAdapter, offsetUnset) -{ - zval *offset, offset_sub; - - ZVAL_UNDEF(&offset_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(offset) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &offset); - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_translate_exception_ce, "Translate is an immutable ArrayAccess object", "phalcon/Translate/Adapter/AbstractAdapter.zep", 115); - return; + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &key_param, &value); + zephir_get_strval(&key, key_param); + zephir_update_property_array(this_ptr, SL("options"), &key, value); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Translate_Adapter_AbstractAdapter, t) +static PHP_METHOD(Phalcon_Filter_Validation_AbstractValidator, setTemplate) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval placeholders; - zval *translateKey_param = NULL, *placeholders_param = NULL; - zval translateKey; + zval *template_param = NULL; + zval template; zval *this_ptr = getThis(); - ZVAL_UNDEF(&translateKey); - ZVAL_UNDEF(&placeholders); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(translateKey) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(placeholders) + ZVAL_UNDEF(&template); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(template) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &translateKey_param, &placeholders_param); - if (UNEXPECTED(Z_TYPE_P(translateKey_param) != IS_STRING && Z_TYPE_P(translateKey_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'translateKey' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(translateKey_param) == IS_STRING)) { - zephir_get_strval(&translateKey, translateKey_param); - } else { - ZEPHIR_INIT_VAR(&translateKey); - } - if (!placeholders_param) { - ZEPHIR_INIT_VAR(&placeholders); - array_init(&placeholders); - } else { - zephir_get_arrval(&placeholders, placeholders_param); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "query", NULL, 0, &translateKey, &placeholders); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &template_param); + zephir_get_strval(&template, template_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("template"), &template); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Translate_Adapter_AbstractAdapter, replacePlaceholders) +static PHP_METHOD(Phalcon_Filter_Validation_AbstractValidator, setTemplates) { + zval _5$$3, _6$$3, _7$$4, _8$$4; + zend_string *_4; + zend_ulong _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval placeholders; - zval *translation_param = NULL, *placeholders_param = NULL, interpolator, _0, _1; - zval translation; + zval *templates_param = NULL, field, template, _0, *_1, _2; + zval templates; zval *this_ptr = getThis(); - ZVAL_UNDEF(&translation); - ZVAL_UNDEF(&interpolator); + ZVAL_UNDEF(&templates); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&template); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&placeholders); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(translation) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(placeholders) + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(templates) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &translation_param, &placeholders_param); - if (UNEXPECTED(Z_TYPE_P(translation_param) != IS_STRING && Z_TYPE_P(translation_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'translation' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(translation_param) == IS_STRING)) { - zephir_get_strval(&translation, translation_param); - } else { - ZEPHIR_INIT_VAR(&translation); - } - if (!placeholders_param) { - ZEPHIR_INIT_VAR(&placeholders); - array_init(&placeholders); + zephir_fetch_params(1, 1, 0, &templates_param); + zephir_get_arrval(&templates, templates_param); + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("templates"), &_0); + zephir_is_iterable(&templates, 0, "phalcon/Filter/Validation/AbstractValidator.zep", 226); + if (Z_TYPE_P(&templates) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&templates), _3, _4, _1) + { + ZEPHIR_INIT_NVAR(&field); + if (_4 != NULL) { + ZVAL_STR_COPY(&field, _4); + } else { + ZVAL_LONG(&field, _3); + } + ZEPHIR_INIT_NVAR(&template); + ZVAL_COPY(&template, _1); + zephir_cast_to_string(&_5$$3, &field); + ZEPHIR_CPY_WRT(&field, &_5$$3); + zephir_cast_to_string(&_6$$3, &template); + ZEPHIR_CPY_WRT(&template, &_6$$3); + zephir_update_property_array(this_ptr, SL("templates"), &field, &template); + } ZEND_HASH_FOREACH_END(); } else { - zephir_get_arrval(&placeholders, placeholders_param); + ZEPHIR_CALL_METHOD(NULL, &templates, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &templates, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&field, &templates, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&template, &templates, "current", NULL, 0); + zephir_check_call_status(); + zephir_cast_to_string(&_7$$4, &field); + ZEPHIR_CPY_WRT(&field, &_7$$4); + zephir_cast_to_string(&_8$$4, &template); + ZEPHIR_CPY_WRT(&template, &_8$$4); + zephir_update_property_array(this_ptr, SL("templates"), &field, &template); + ZEPHIR_CALL_METHOD(NULL, &templates, "next", NULL, 0); + zephir_check_call_status(); + } } - zephir_read_property(&_0, this_ptr, ZEND_STRL("interpolatorFactory"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_1, this_ptr, ZEND_STRL("defaultInterpolator"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&interpolator, &_0, "newinstance", NULL, 0, &_1); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&interpolator, "replaceplaceholders", NULL, 0, &translation, &placeholders); - zephir_check_call_status(); - RETURN_MM(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Translate_Adapter_AdapterInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Translate\\Adapter, AdapterInterface, phalcon, translate_adapter_adapterinterface, phalcon_translate_adapter_adapterinterface_method_entry); - - return SUCCESS; + ZEPHIR_INIT_NVAR(&template); + ZEPHIR_INIT_NVAR(&field); + RETURN_THIS(); } -ZEPHIR_DOC_METHOD(Phalcon_Translate_Adapter_AdapterInterface, has); -ZEPHIR_DOC_METHOD(Phalcon_Translate_Adapter_AdapterInterface, query); -ZEPHIR_DOC_METHOD(Phalcon_Translate_Adapter_AdapterInterface, t); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Translate_Adapter_Csv) +static PHP_METHOD(Phalcon_Filter_Validation_AbstractValidator, validate) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Translate\\Adapter, Csv, phalcon, translate_adapter_csv, phalcon_translate_adapter_abstractadapter_ce, phalcon_translate_adapter_csv_method_entry, 0); - - zend_declare_property_null(phalcon_translate_adapter_csv_ce, SL("translate"), ZEND_ACC_PROTECTED); - phalcon_translate_adapter_csv_ce->create_object = zephir_init_properties_Phalcon_Translate_Adapter_Csv; - - zend_class_implements(phalcon_translate_adapter_csv_ce, 1, zend_ce_arrayaccess); - return SUCCESS; } -static PHP_METHOD(Phalcon_Translate_Adapter_Csv, __construct) +static PHP_METHOD(Phalcon_Filter_Validation_AbstractValidator, allowEmpty) { + zend_bool _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval *interpolator, interpolator_sub, *options_param = NULL, delimiter, enclosure, _0, _1; + zval *field, field_sub, *value, value_sub, allowEmpty, _0, _1, _2$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&interpolator_sub); - ZVAL_UNDEF(&delimiter); - ZVAL_UNDEF(&enclosure); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&allowEmpty); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_2$$3); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(interpolator, phalcon_translate_interpolatorfactory_ce) - Z_PARAM_ARRAY(options) + Z_PARAM_ZVAL(field) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &interpolator, &options_param); - zephir_get_arrval(&options, options_param); - ZEPHIR_CALL_PARENT(NULL, phalcon_translate_adapter_csv_ce, getThis(), "__construct", NULL, 0, interpolator, &options); + zephir_fetch_params(1, 2, 0, &field, &value); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "allowEmpty"); + ZVAL_BOOL(&_1, 0); + ZEPHIR_CALL_METHOD(&allowEmpty, this_ptr, "getoption", NULL, 0, &_0, &_1); zephir_check_call_status(); - if (UNEXPECTED(!(zephir_array_isset_string(&options, SL("content"))))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_translate_exception_ce, "Parameter 'content' is required", "phalcon/Translate/Adapter/Csv.zep", 48); - return; - } - if (zephir_array_isset_string(&options, SL("delimiter"))) { - zephir_memory_observe(&delimiter); - zephir_array_fetch_string(&delimiter, &options, SL("delimiter"), PH_NOISY, "phalcon/Translate/Adapter/Csv.zep", 52); - } else { - ZEPHIR_INIT_NVAR(&delimiter); - ZVAL_STRING(&delimiter, ";"); + if (Z_TYPE_P(&allowEmpty) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&_2$$3); + if (zephir_array_isset(&allowEmpty, field)) { + ZEPHIR_OBS_NVAR(&_2$$3); + zephir_array_fetch(&_2$$3, &allowEmpty, field, PH_NOISY, "phalcon/Filter/Validation/AbstractValidator.zep", 257); + } else { + ZEPHIR_INIT_NVAR(&_2$$3); + ZVAL_BOOL(&_2$$3, 0); + } + ZEPHIR_CPY_WRT(&allowEmpty, &_2$$3); } - if (zephir_array_isset_string(&options, SL("enclosure"))) { - zephir_memory_observe(&enclosure); - zephir_array_fetch_string(&enclosure, &options, SL("enclosure"), PH_NOISY, "phalcon/Translate/Adapter/Csv.zep", 58); - } else { - ZEPHIR_INIT_NVAR(&enclosure); - ZVAL_STRING(&enclosure, "\""); + _3 = zephir_is_true(&allowEmpty); + if (_3) { + _3 = ZEPHIR_IS_EMPTY(value); } - zephir_array_fetch_string(&_0, &options, SL("content"), PH_NOISY | PH_READONLY, "phalcon/Translate/Adapter/Csv.zep", 63); - ZVAL_LONG(&_1, 0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "load", NULL, 0, &_0, &_1, &delimiter, &enclosure); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM_BOOL(_3); } -static PHP_METHOD(Phalcon_Translate_Adapter_Csv, exists) +static PHP_METHOD(Phalcon_Filter_Validation_AbstractValidator, checkArray) { + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *index_param = NULL; - zval index; - zval *this_ptr = getThis(); + zval field; + zval *value = NULL, value_sub, *field_param = NULL, _1$$3; - ZVAL_UNDEF(&index); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(index) + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&field); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(value) + Z_PARAM_STR(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &index_param); - if (UNEXPECTED(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 2, 0, &value, &field_param); + ZEPHIR_SEPARATE_PARAM(value); + zephir_get_strval(&field, field_param); + _0 = Z_TYPE_P(value) == IS_ARRAY; + if (_0) { + _0 = zephir_array_isset(value, &field); } - if (EXPECTED(Z_TYPE_P(index_param) == IS_STRING)) { - zephir_get_strval(&index, index_param); - } else { - ZEPHIR_INIT_VAR(&index); + if (_0) { + zephir_array_fetch(&_1$$3, value, &field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/AbstractValidator.zep", 277); + ZEPHIR_CPY_WRT(value, &_1$$3); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, &index); - zephir_check_call_status(); + RETVAL_ZVAL(value, 1, 0); RETURN_MM(); } -static PHP_METHOD(Phalcon_Translate_Adapter_Csv, has) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *index_param = NULL, _0; - zval index; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&index); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(index) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &index_param); - if (UNEXPECTED(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(index_param) == IS_STRING)) { - zephir_get_strval(&index, index_param); - } else { - ZEPHIR_INIT_VAR(&index); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("translate"), PH_NOISY_CC | PH_READONLY); - RETURN_MM_BOOL(zephir_array_isset(&_0, &index)); -} - -static PHP_METHOD(Phalcon_Translate_Adapter_Csv, query) +static PHP_METHOD(Phalcon_Filter_Validation_AbstractValidator, prepareCode) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval placeholders; - zval *translateKey_param = NULL, *placeholders_param = NULL, translation, _0; - zval translateKey; + zval *field_param = NULL, code, _0, _1, _2$$3; + zval field; zval *this_ptr = getThis(); - ZVAL_UNDEF(&translateKey); - ZVAL_UNDEF(&translation); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&code); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&placeholders); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(translateKey) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(placeholders) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &translateKey_param, &placeholders_param); - if (UNEXPECTED(Z_TYPE_P(translateKey_param) != IS_STRING && Z_TYPE_P(translateKey_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'translateKey' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(translateKey_param) == IS_STRING)) { - zephir_get_strval(&translateKey, translateKey_param); - } else { - ZEPHIR_INIT_VAR(&translateKey); - } - if (!placeholders_param) { - ZEPHIR_INIT_VAR(&placeholders); - array_init(&placeholders); - } else { - zephir_get_arrval(&placeholders, placeholders_param); - } - zephir_memory_observe(&translation); - zephir_read_property(&_0, this_ptr, ZEND_STRL("translate"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&translation, &_0, &translateKey, 0))) { - ZEPHIR_CPY_WRT(&translation, &translateKey); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "replaceplaceholders", NULL, 0, &translation, &placeholders); + zephir_fetch_params(1, 1, 0, &field_param); + zephir_get_strval(&field, field_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "code"); + ZVAL_LONG(&_1, 0); + ZEPHIR_CALL_METHOD(&code, this_ptr, "getoption", NULL, 0, &_0, &_1); zephir_check_call_status(); - RETURN_MM(); + if (Z_TYPE_P(&code) == IS_ARRAY) { + zephir_array_fetch(&_2$$3, &code, &field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/AbstractValidator.zep", 297); + ZEPHIR_CPY_WRT(&code, &_2$$3); + } + RETURN_CCTOR(&code); } -static PHP_METHOD(Phalcon_Translate_Adapter_Csv, load) +static PHP_METHOD(Phalcon_Filter_Validation_AbstractValidator, prepareLabel) { - zend_bool _8$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL; - zend_long length, ZEPHIR_LAST_CALL_STATUS; - zval *file_param = NULL, *length_param = NULL, *delimiter_param = NULL, *enclosure_param = NULL, data, fileHandler, _0, _1$$3, _3$$4, _5$$4, _6$$4, _7$$4, _9$$4, _10$$4; - zval file, delimiter, enclosure, _2$$3; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval field; + zval *validation, validation_sub, *field_param = NULL, label, _0, _1$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&file); - ZVAL_UNDEF(&delimiter); - ZVAL_UNDEF(&enclosure); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&fileHandler); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&label); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_10$$4); - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_STR(file) - Z_PARAM_LONG(length) - Z_PARAM_STR(delimiter) - Z_PARAM_STR(enclosure) + ZVAL_UNDEF(&field); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_STR(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 0, &file_param, &length_param, &delimiter_param, &enclosure_param); - zephir_get_strval(&file, file_param); - zephir_get_strval(&delimiter, delimiter_param); - zephir_get_strval(&enclosure, enclosure_param); + zephir_fetch_params(1, 2, 0, &validation, &field_param); + zephir_get_strval(&field, field_param); ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "rb"); - ZEPHIR_CALL_METHOD(&fileHandler, this_ptr, "phpfopen", NULL, 0, &file, &_0); + ZVAL_STRING(&_0, "label"); + ZEPHIR_CALL_METHOD(&label, this_ptr, "getoption", NULL, 0, &_0); zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&fileHandler) != IS_RESOURCE)) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_translate_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - ZEPHIR_CONCAT_SVS(&_2$$3, "Error opening translation file '", &file, "'"); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Translate/Adapter/Csv.zep", 129); - ZEPHIR_MM_RESTORE(); - return; + if (Z_TYPE_P(&label) == IS_ARRAY) { + zephir_array_fetch(&_1$$3, &label, &field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/AbstractValidator.zep", 318); + ZEPHIR_CPY_WRT(&label, &_1$$3); } - while (1) { - ZVAL_LONG(&_3$$4, length); - ZEPHIR_CALL_FUNCTION(&data, "fgetcsv", &_4, 0, &fileHandler, &_3$$4, &delimiter, &enclosure); + if (ZEPHIR_IS_EMPTY(&label)) { + ZEPHIR_CALL_METHOD(&label, validation, "getlabel", NULL, 0, &field); zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&data)) { - break; - } - zephir_array_fetch_long(&_5$$4, &data, 0, PH_NOISY | PH_READONLY, "phalcon/Translate/Adapter/Csv.zep", 139); - ZVAL_LONG(&_3$$4, 0); - ZVAL_LONG(&_6$$4, 1); - ZEPHIR_INIT_NVAR(&_7$$4); - zephir_substr(&_7$$4, &_5$$4, 0 , 1 , 0); - _8$$4 = ZEPHIR_IS_STRING_IDENTICAL(&_7$$4, "#"); - if (!(_8$$4)) { - _8$$4 = !(zephir_array_isset_long(&data, 1)); + } + RETURN_CCTOR(&label); +} + +zend_object *zephir_init_properties_Phalcon_Filter_Validation_AbstractValidator(zend_class_entry *class_type) +{ + zval _0, _2, _1$$3, _3$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_1$$3); } - if (_8$$4) { - continue; + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("templates"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("templates"), &_3$$4); } - zephir_array_fetch_long(&_9$$4, &data, 1, PH_NOISY | PH_READONLY, "phalcon/Translate/Adapter/Csv.zep", 143); - ZEPHIR_OBS_NVAR(&_10$$4); - zephir_array_fetch_long(&_10$$4, &data, 0, PH_NOISY, "phalcon/Translate/Adapter/Csv.zep", 143); - zephir_update_property_array(this_ptr, SL("translate"), &_10$$4, &_9$$4); + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } - zephir_fclose(&fileHandler); - ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Translate_Adapter_Csv, toArray) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_AbstractValidatorComposite) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation, AbstractValidatorComposite, phalcon, filter_validation_abstractvalidatorcomposite, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_abstractvalidatorcomposite_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - RETURN_MEMBER(getThis(), "translate"); + zend_declare_property_null(phalcon_filter_validation_abstractvalidatorcomposite_ce, SL("validators"), ZEND_ACC_PROTECTED); + phalcon_filter_validation_abstractvalidatorcomposite_ce->create_object = zephir_init_properties_Phalcon_Filter_Validation_AbstractValidatorComposite; + + zend_class_implements(phalcon_filter_validation_abstractvalidatorcomposite_ce, 1, phalcon_filter_validation_validatorcompositeinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Translate_Adapter_Csv, phpFopen) +static PHP_METHOD(Phalcon_Filter_Validation_AbstractValidatorComposite, getValidators) +{ + + RETURN_MEMBER(getThis(), "validators"); +} + +static PHP_METHOD(Phalcon_Filter_Validation_AbstractValidatorComposite, validate) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *filename_param = NULL, *mode_param = NULL; - zval filename, mode; + zval *validation, validation_sub, *field, field_sub, validator, _0, _4, *_5, _6, _1$$3, _2$$3, _3$$3, _7$$4, _8$$6; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&filename); - ZVAL_UNDEF(&mode); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&validator); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$6); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(filename) - Z_PARAM_STR(mode) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &filename_param, &mode_param); - zephir_get_strval(&filename, filename_param); - zephir_get_strval(&mode, mode_param); - ZEPHIR_RETURN_CALL_FUNCTION("fopen", NULL, 140, &filename, &mode); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getvalidators", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + if (UNEXPECTED(zephir_fast_count_int(&_0) == 0)) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_filter_validation_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + zephir_get_class(&_2$$3, this_ptr, 0); + ZEPHIR_INIT_VAR(&_3$$3); + ZEPHIR_CONCAT_VS(&_3$$3, &_2$$3, " does not have any validator added"); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_3$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Filter/Validation/AbstractValidatorComposite.zep", 41); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&_4, this_ptr, "getvalidators", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&_4, 0, "phalcon/Filter/Validation/AbstractValidatorComposite.zep", 50); + if (Z_TYPE_P(&_4) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_4), _5) + { + ZEPHIR_INIT_NVAR(&validator); + ZVAL_COPY(&validator, _5); + ZEPHIR_CALL_METHOD(&_7$$4, &validator, "validate", NULL, 0, validation, field); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_7$$4)) { + RETURN_MM_BOOL(0); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_4, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_6, &_4, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_6)) { + break; + } + ZEPHIR_CALL_METHOD(&validator, &_4, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_8$$6, &validator, "validate", NULL, 0, validation, field); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_8$$6)) { + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_METHOD(NULL, &_4, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&validator); + RETURN_MM_BOOL(1); } -zend_object *zephir_init_properties_Phalcon_Translate_Adapter_Csv(zend_class_entry *class_type) +zend_object *zephir_init_properties_Phalcon_Filter_Validation_AbstractValidatorComposite(zend_class_entry *class_type) { - zval _0, _1$$3; + zval _0, _2, _4, _1$$3, _3$$4, _5$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); @@ -114927,11 +113927,23 @@ zend_object *zephir_init_properties_Phalcon_Translate_Adapter_Csv(zend_class_ent { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("translate"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("translate"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("templates"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("templates"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("validators"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("validators"), &_5$$5); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -114948,546 +113960,756 @@ zend_object *zephir_init_properties_Phalcon_Translate_Adapter_Csv(zend_class_ent -ZEPHIR_INIT_CLASS(Phalcon_Translate_Adapter_Gettext) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Exception) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Translate\\Adapter, Gettext, phalcon, translate_adapter_gettext, phalcon_translate_adapter_abstractadapter_ce, phalcon_translate_adapter_gettext_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation, Exception, phalcon, filter_validation_exception, zend_ce_exception, NULL, 0); - zend_declare_property_null(phalcon_translate_adapter_gettext_ce, SL("category"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_translate_adapter_gettext_ce, SL("defaultDomain"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_translate_adapter_gettext_ce, SL("directory"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_translate_adapter_gettext_ce, SL("locale"), ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_translate_adapter_gettext_ce, 1, zend_ce_arrayaccess); return SUCCESS; } -static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, __construct) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_ValidationInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Filter\\Validation, ValidationInterface, phalcon, filter_validation_validationinterface, phalcon_filter_validation_validationinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidationInterface, add); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidationInterface, appendMessage); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidationInterface, bind); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidationInterface, getEntity); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidationInterface, getFilters); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidationInterface, getLabel); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidationInterface, getMessages); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidationInterface, getValidators); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidationInterface, getValue); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidationInterface, rule); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidationInterface, rules); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidationInterface, setFilters); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidationInterface, setLabels); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidationInterface, validate); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_ValidatorCompositeInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Filter\\Validation, ValidatorCompositeInterface, phalcon, filter_validation_validatorcompositeinterface, phalcon_filter_validation_validatorcompositeinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidatorCompositeInterface, getValidators); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidatorCompositeInterface, validate); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_ValidatorFactory) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation, ValidatorFactory, phalcon, filter_validation_validatorfactory, phalcon_factory_abstractfactory_ce, phalcon_filter_validation_validatorfactory_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Validation_ValidatorFactory, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval *interpolator, interpolator_sub, *options_param = NULL, _0, _1; + zval *services_param = NULL; + zval services; zval *this_ptr = getThis(); - ZVAL_UNDEF(&interpolator_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(interpolator, phalcon_translate_interpolatorfactory_ce) - Z_PARAM_ARRAY(options) + ZVAL_UNDEF(&services); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(services) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &interpolator, &options_param); - ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "gettext"); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "phpfunctionexists", NULL, 0, &_1); - zephir_check_call_status(); - if (UNEXPECTED(!zephir_is_true(&_0))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_translate_exception_ce, "This class requires the gettext extension for PHP", "phalcon/Translate/Adapter/Gettext.zep", 80); - return; + zephir_fetch_params(1, 0, 1, &services_param); + if (!services_param) { + ZEPHIR_INIT_VAR(&services); + array_init(&services); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); } - ZEPHIR_CALL_PARENT(NULL, phalcon_translate_adapter_gettext_ce, getThis(), "__construct", NULL, 0, interpolator, &options); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "prepareoptions", NULL, 0, &options); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, exists) +static PHP_METHOD(Phalcon_Filter_Validation_ValidatorFactory, newInstance) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *index_param = NULL; - zval index; + zval *name_param = NULL, definition; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&index); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&definition); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(index) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &index_param); - if (UNEXPECTED(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be of the type string")); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(index_param) == IS_STRING)) { - zephir_get_strval(&index, index_param); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - ZEPHIR_INIT_VAR(&index); + ZEPHIR_INIT_VAR(&name); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, &index); + ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); + zephir_check_call_status(); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(return_value, &definition); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, getCategory) +static PHP_METHOD(Phalcon_Filter_Validation_ValidatorFactory, getExceptionClass) { - RETURN_MEMBER(getThis(), "category"); + RETURN_STRING("Phalcon\\Validation\\Exception"); } -static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, getDefaultDomain) +static PHP_METHOD(Phalcon_Filter_Validation_ValidatorFactory, getServices) { - RETURN_MEMBER(getThis(), "defaultDomain"); + zephir_create_array(return_value, 21, 0); + add_assoc_stringl_ex(return_value, SL("alnum"), SL("Phalcon\\Filter\\Validation\\Validator\\Alnum")); + add_assoc_stringl_ex(return_value, SL("alpha"), SL("Phalcon\\Filter\\Validation\\Validator\\Alpha")); + add_assoc_stringl_ex(return_value, SL("between"), SL("Phalcon\\Filter\\Validation\\Validator\\Between")); + add_assoc_stringl_ex(return_value, SL("callback"), SL("Phalcon\\Filter\\Validation\\Validator\\Callback")); + add_assoc_stringl_ex(return_value, SL("confirmation"), SL("Phalcon\\Filter\\Validation\\Validator\\Confirmation")); + add_assoc_stringl_ex(return_value, SL("creditCard"), SL("Phalcon\\Filter\\Validation\\Validator\\CreditCard")); + add_assoc_stringl_ex(return_value, SL("date"), SL("Phalcon\\Filter\\Validation\\Validator\\Date")); + add_assoc_stringl_ex(return_value, SL("digit"), SL("Phalcon\\Filter\\Validation\\Validator\\Digit")); + add_assoc_stringl_ex(return_value, SL("email"), SL("Phalcon\\Filter\\Validation\\Validator\\Email")); + add_assoc_stringl_ex(return_value, SL("exception"), SL("Phalcon\\Filter\\Validation\\Validator\\Exception")); + add_assoc_stringl_ex(return_value, SL("exclusionIn"), SL("Phalcon\\Filter\\Validation\\Validator\\ExclusionIn")); + add_assoc_stringl_ex(return_value, SL("file"), SL("Phalcon\\Filter\\Validation\\Validator\\File")); + add_assoc_stringl_ex(return_value, SL("identical"), SL("Phalcon\\Filter\\Validation\\Validator\\Identical")); + add_assoc_stringl_ex(return_value, SL("inclusionIn"), SL("Phalcon\\Filter\\Validation\\Validator\\InclusionIn")); + add_assoc_stringl_ex(return_value, SL("ip"), SL("Phalcon\\Filter\\Validation\\Validator\\Ip")); + add_assoc_stringl_ex(return_value, SL("numericality"), SL("Phalcon\\Filter\\Validation\\Validator\\Numericality")); + add_assoc_stringl_ex(return_value, SL("presenceOf"), SL("Phalcon\\Filter\\Validation\\Validator\\PresenceOf")); + add_assoc_stringl_ex(return_value, SL("regex"), SL("Phalcon\\Filter\\Validation\\Validator\\Regex")); + add_assoc_stringl_ex(return_value, SL("stringLength"), SL("Phalcon\\Filter\\Validation\\Validator\\StringLength")); + add_assoc_stringl_ex(return_value, SL("uniqueness"), SL("Phalcon\\Filter\\Validation\\Validator\\Uniqueness")); + add_assoc_stringl_ex(return_value, SL("url"), SL("Phalcon\\Filter\\Validation\\Validator\\Url")); + return; } -static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, getDirectory) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_ValidatorInterface) { + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Filter\\Validation, ValidatorInterface, phalcon, filter_validation_validatorinterface, phalcon_filter_validation_validatorinterface_method_entry); - RETURN_MEMBER(getThis(), "directory"); + return SUCCESS; } -static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, getLocale) +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidatorInterface, getOption); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidatorInterface, getTemplate); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidatorInterface, getTemplates); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidatorInterface, hasOption); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidatorInterface, setTemplate); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidatorInterface, setTemplates); +ZEPHIR_DOC_METHOD(Phalcon_Filter_Validation_ValidatorInterface, validate); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_Alnum) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, Alnum, phalcon, filter_validation_validator_alnum, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_alnum_method_entry, 0); - RETURN_MEMBER(getThis(), "locale"); + zend_declare_property_string(phalcon_filter_validation_validator_alnum_ce, SL("template"), "Field :field must contain only letters and numbers", ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, has) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Alnum, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *index_param = NULL, result; - zval index; - zval *this_ptr = getThis(); + zval *options_param = NULL; + zval options; - ZVAL_UNDEF(&index); - ZVAL_UNDEF(&result); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(index) + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &index_param); - if (UNEXPECTED(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(index_param) == IS_STRING)) { - zephir_get_strval(&index, index_param); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - ZEPHIR_INIT_VAR(&index); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - ZEPHIR_CALL_METHOD(&result, this_ptr, "query", NULL, 0, &index); + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_alnum_ce, getThis(), "__construct", NULL, 0, &options); zephir_check_call_status(); - RETURN_MM_BOOL(!ZEPHIR_IS_IDENTICAL(&result, &index)); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, nquery) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Alnum, validate) { + zval _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval placeholders; - zend_long count, ZEPHIR_LAST_CALL_STATUS; - zval *msgid1_param = NULL, *msgid2_param = NULL, *count_param = NULL, *placeholders_param = NULL, *domain_param = NULL, translation, _0$$3, _1$$4; - zval msgid1, msgid2, domain; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *validation, validation_sub, *field, field_sub, value, _0, _2, _3$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&msgid1); - ZVAL_UNDEF(&msgid2); - ZVAL_UNDEF(&domain); - ZVAL_UNDEF(&translation); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&placeholders); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(3, 5) - Z_PARAM_STR(msgid1) - Z_PARAM_STR(msgid2) - Z_PARAM_LONG(count) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(placeholders) - Z_PARAM_STR_OR_NULL(domain) + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 2, &msgid1_param, &msgid2_param, &count_param, &placeholders_param, &domain_param); - if (UNEXPECTED(Z_TYPE_P(msgid1_param) != IS_STRING && Z_TYPE_P(msgid1_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'msgid1' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(msgid1_param) == IS_STRING)) { - zephir_get_strval(&msgid1, msgid1_param); - } else { - ZEPHIR_INIT_VAR(&msgid1); - } - if (UNEXPECTED(Z_TYPE_P(msgid2_param) != IS_STRING && Z_TYPE_P(msgid2_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'msgid2' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(msgid2_param) == IS_STRING)) { - zephir_get_strval(&msgid2, msgid2_param); - } else { - ZEPHIR_INIT_VAR(&msgid2); - } - if (UNEXPECTED(Z_TYPE_P(count_param) != IS_LONG)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'count' must be of the type int")); - RETURN_MM_NULL(); - } - count = Z_LVAL_P(count_param); - if (!placeholders_param) { - ZEPHIR_INIT_VAR(&placeholders); - array_init(&placeholders); - } else { - zephir_get_arrval(&placeholders, placeholders_param); - } - if (!domain_param) { - ZEPHIR_INIT_VAR(&domain); - } else { - if (UNEXPECTED(Z_TYPE_P(domain_param) != IS_STRING && Z_TYPE_P(domain_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'domain' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(domain_param) == IS_STRING)) { - zephir_get_strval(&domain, domain_param); - } else { - ZEPHIR_INIT_VAR(&domain); - } + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "allowempty", NULL, 0, field, &value); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + RETURN_MM_BOOL(1); } - if (!(!(ZEPHIR_IS_EMPTY(&domain)))) { - ZVAL_LONG(&_0$$3, count); - ZEPHIR_CALL_FUNCTION(&translation, "ngettext", NULL, 0, &msgid1, &msgid2, &_0$$3); + zephir_cast_to_string(&_1, &value); + ZEPHIR_CALL_FUNCTION(&_2, "ctype_alnum", NULL, 292, &_1); + zephir_check_call_status(); + if (!(zephir_is_true(&_2))) { + ZEPHIR_CALL_METHOD(&_3$$4, this_ptr, "messagefactory", NULL, 0, validation, field); zephir_check_call_status(); - } else { - ZVAL_LONG(&_1$$4, count); - ZEPHIR_CALL_FUNCTION(&translation, "dngettext", NULL, 0, &domain, &msgid1, &msgid2, &_1$$4); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_3$$4); zephir_check_call_status(); + RETURN_MM_BOOL(0); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "replaceplaceholders", NULL, 0, &translation, &placeholders); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, query) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_Alpha) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, Alpha, phalcon, filter_validation_validator_alpha, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_alpha_method_entry, 0); + + zend_declare_property_string(phalcon_filter_validation_validator_alpha_ce, SL("template"), "Field :field must contain only letters", ZEND_ACC_PROTECTED); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Alpha, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval placeholders; - zval *translateKey_param = NULL, *placeholders_param = NULL, _0; - zval translateKey; - zval *this_ptr = getThis(); + zval *options_param = NULL; + zval options; - ZVAL_UNDEF(&translateKey); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&placeholders); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(translateKey) + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(placeholders) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &translateKey_param, &placeholders_param); - if (UNEXPECTED(Z_TYPE_P(translateKey_param) != IS_STRING && Z_TYPE_P(translateKey_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'translateKey' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(translateKey_param) == IS_STRING)) { - zephir_get_strval(&translateKey, translateKey_param); - } else { - ZEPHIR_INIT_VAR(&translateKey); - } - if (!placeholders_param) { - ZEPHIR_INIT_VAR(&placeholders); - array_init(&placeholders); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - zephir_get_arrval(&placeholders, placeholders_param); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - ZEPHIR_CALL_FUNCTION(&_0, "gettext", NULL, 0, &translateKey); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "replaceplaceholders", NULL, 0, &_0, &placeholders); + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_alpha_ce, getThis(), "__construct", NULL, 0, &options); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, resetDomain) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Alpha, validate) { - zval _0; + zval _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *validation, validation_sub, *field, field_sub, value, _0, _1, _3, _4, _5, _6$$4; zval *this_ptr = getThis(); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&value); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getdefaultdomain", NULL, 0); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); - ZEPHIR_RETURN_CALL_FUNCTION("textdomain", NULL, 0, &_0); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "allowempty", NULL, 0, field, &value); zephir_check_call_status(); - RETURN_MM(); + if (zephir_is_true(&_0)) { + RETURN_MM_BOOL(1); + } + ZEPHIR_INIT_VAR(&_1); + zephir_cast_to_string(&_2, &value); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "/[^[:alpha:]]/imu"); + ZEPHIR_INIT_VAR(&_4); + ZEPHIR_INIT_VAR(&_5); + ZVAL_STRING(&_5, "/[^[:alpha:]]/imu"); + zephir_preg_match(&_4, &_5, &_2, &_1, 0, 0 , 0 ); + if (zephir_is_true(&_4)) { + ZEPHIR_CALL_METHOD(&_6$$4, this_ptr, "messagefactory", NULL, 0, validation, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_6$$4); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, setDefaultDomain) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_Between) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, Between, phalcon, filter_validation_validator_between, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_between_method_entry, 0); + + zend_declare_property_string(phalcon_filter_validation_validator_between_ce, SL("template"), "Field :field must be within the range of :min to :max", ZEND_ACC_PROTECTED); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Between, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *domain_param = NULL; - zval domain; - zval *this_ptr = getThis(); + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *options_param = NULL; + zval options; - ZVAL_UNDEF(&domain); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(domain) + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &domain_param); - if (UNEXPECTED(Z_TYPE_P(domain_param) != IS_STRING && Z_TYPE_P(domain_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'domain' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(domain_param) == IS_STRING)) { - zephir_get_strval(&domain, domain_param); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - ZEPHIR_INIT_VAR(&domain); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultDomain"), &domain); + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_between_ce, getThis(), "__construct", NULL, 0, &options); + zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, setDirectory) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Between, validate) { - zend_string *_3$$4; - zend_ulong _2$$4; + zend_bool _4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *directory, directory_sub, key, value, *_0$$4, _1$$4, _5$$7; + zval *validation, validation_sub, *field, field_sub, value, minimum, maximum, replacePairs, _0, _1, _2$$4, _3$$5, _5$$6; zval *this_ptr = getThis(); - ZVAL_UNDEF(&directory_sub); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_5$$7); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(directory) + ZVAL_UNDEF(&minimum); + ZVAL_UNDEF(&maximum); + ZVAL_UNDEF(&replacePairs); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_5$$6); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &directory); - if (ZEPHIR_IS_EMPTY(directory)) { - RETURN_MM_NULL(); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "minimum"); + ZEPHIR_CALL_METHOD(&minimum, this_ptr, "getoption", NULL, 0, &_0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "maximum"); + ZEPHIR_CALL_METHOD(&maximum, this_ptr, "getoption", NULL, 0, &_0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "allowempty", NULL, 0, field, &value); + zephir_check_call_status(); + if (zephir_is_true(&_1)) { + RETURN_MM_BOOL(1); } - zephir_update_property_zval(this_ptr, ZEND_STRL("directory"), directory); - if (Z_TYPE_P(directory) == IS_ARRAY) { - zephir_is_iterable(directory, 0, "phalcon/Translate/Adapter/Gettext.zep", 249); - if (Z_TYPE_P(directory) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(directory), _2$$4, _3$$4, _0$$4) - { - ZEPHIR_INIT_NVAR(&key); - if (_3$$4 != NULL) { - ZVAL_STR_COPY(&key, _3$$4); - } else { - ZVAL_LONG(&key, _2$$4); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0$$4); - ZEPHIR_CALL_FUNCTION(NULL, "bindtextdomain", &_4, 0, &key, &value); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, directory, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1$$4, directory, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1$$4)) { - break; - } - ZEPHIR_CALL_METHOD(&key, directory, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, directory, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(NULL, "bindtextdomain", &_4, 0, &key, &value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, directory, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - } else { - ZEPHIR_CALL_METHOD(&_5$$7, this_ptr, "getdefaultdomain", NULL, 0); + if (Z_TYPE_P(&minimum) == IS_ARRAY) { + zephir_array_fetch(&_2$$4, &minimum, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/Between.zep", 98); + ZEPHIR_CPY_WRT(&minimum, &_2$$4); + } + if (Z_TYPE_P(&maximum) == IS_ARRAY) { + zephir_array_fetch(&_3$$5, &maximum, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/Between.zep", 102); + ZEPHIR_CPY_WRT(&maximum, &_3$$5); + } + _4 = ZEPHIR_LT(&value, &minimum); + if (!(_4)) { + _4 = ZEPHIR_GT(&value, &maximum); + } + if (_4) { + ZEPHIR_INIT_VAR(&replacePairs); + zephir_create_array(&replacePairs, 2, 0); + zephir_array_update_string(&replacePairs, SL(":min"), &minimum, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&replacePairs, SL(":max"), &maximum, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_5$$6, this_ptr, "messagefactory", NULL, 0, validation, field, &replacePairs); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(NULL, "bindtextdomain", &_4, 0, &_5$$7, directory); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_5$$6); zephir_check_call_status(); + RETURN_MM_BOOL(0); } - ZEPHIR_MM_RESTORE(); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, setDomain) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_Callback) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, Callback, phalcon, filter_validation_validator_callback, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_callback_method_entry, 0); + + zend_declare_property_string(phalcon_filter_validation_validator_callback_ce, SL("template"), "Field :field must match the callback function", ZEND_ACC_PROTECTED); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Callback, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *domain_param = NULL; - zval domain; + zval *options_param = NULL; + zval options; - ZVAL_UNDEF(&domain); - bool is_null_true = 1; + ZVAL_UNDEF(&options); ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(domain) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &domain_param); - if (!domain_param) { - ZEPHIR_INIT_VAR(&domain); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - zephir_get_strval(&domain, domain_param); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - ZEPHIR_RETURN_CALL_FUNCTION("textdomain", NULL, 0, &domain); + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_callback_ce, getThis(), "__construct", NULL, 0, &options); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, setLocale) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Callback, validate) { + zend_bool _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval localeArray; - zval *category_param = NULL, *localeArray_param = NULL, _0, _1, _2, _3, _4, _5, _6, _7, _8; - zend_long category, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *validation, validation_sub, *field, field_sub, callback, returnedValue, data, _0, _2$$6; zval *this_ptr = getThis(); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&callback); + ZVAL_UNDEF(&returnedValue); + ZVAL_UNDEF(&data); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&localeArray); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_LONG(category) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(localeArray) + ZVAL_UNDEF(&_2$$6); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &category_param, &localeArray_param); - if (UNEXPECTED(Z_TYPE_P(category_param) != IS_LONG)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'category' must be of the type int")); - RETURN_MM_NULL(); - } - category = Z_LVAL_P(category_param); - if (!localeArray_param) { - ZEPHIR_INIT_VAR(&localeArray); - array_init(&localeArray); - } else { - zephir_get_arrval(&localeArray, localeArray_param); - } - ZVAL_LONG(&_0, category); - ZEPHIR_CALL_FUNCTION(&_1, "setlocale", NULL, 0, &_0, &localeArray); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("locale"), &_1); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, category); - zephir_update_property_zval(this_ptr, ZEND_STRL("category"), &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("locale"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_SV(&_2, "LC_ALL=", &_0); - ZEPHIR_CALL_FUNCTION(NULL, "putenv", NULL, 0, &_2); - zephir_check_call_status(); - zephir_read_property(&_3, this_ptr, ZEND_STRL("locale"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_4); - ZEPHIR_CONCAT_SV(&_4, "LANG=", &_3); - ZEPHIR_CALL_FUNCTION(NULL, "putenv", NULL, 0, &_4); - zephir_check_call_status(); - zephir_read_property(&_5, this_ptr, ZEND_STRL("locale"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_6); - ZEPHIR_CONCAT_SV(&_6, "LANGUAGE=", &_5); - ZEPHIR_CALL_FUNCTION(NULL, "putenv", NULL, 0, &_6); - zephir_check_call_status(); - zephir_read_property(&_7, this_ptr, ZEND_STRL("locale"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_8, 6); - ZEPHIR_CALL_FUNCTION(NULL, "setlocale", NULL, 0, &_8, &_7); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "callback"); + ZEPHIR_CALL_METHOD(&callback, this_ptr, "getoption", NULL, 0, &_0); zephir_check_call_status(); - RETURN_MM_MEMBER(getThis(), "locale"); + if (zephir_is_callable(&callback)) { + ZEPHIR_CALL_METHOD(&data, validation, "getentity", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_EMPTY(&data)) { + ZEPHIR_CALL_METHOD(&data, validation, "getdata", NULL, 0); + zephir_check_call_status(); + } + ZEPHIR_CALL_FUNCTION(&returnedValue, "call_user_func", NULL, 188, &callback, &data); + zephir_check_call_status(); + _1$$3 = Z_TYPE_P(&returnedValue) == IS_OBJECT; + if (_1$$3) { + _1$$3 = zephir_instance_of_ev(&returnedValue, phalcon_filter_validation_validatorinterface_ce); + } + if (((Z_TYPE_P(&returnedValue) == IS_TRUE || Z_TYPE_P(&returnedValue) == IS_FALSE) == 1)) { + if (!(zephir_is_true(&returnedValue))) { + ZEPHIR_CALL_METHOD(&_2$$6, this_ptr, "messagefactory", NULL, 0, validation, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_2$$6); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); + } else if (_1$$3) { + ZEPHIR_RETURN_CALL_METHOD(&returnedValue, "validate", NULL, 0, validation, field); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_validator_exception_ce, "Callback must return bool or Phalcon\\Filter\\Validation\\Validator object", "phalcon/Filter/Validation/Validator/Callback.zep", 114); + return; + } + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, getOptionsDefault) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_Confirmation) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, Confirmation, phalcon, filter_validation_validator_confirmation, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_confirmation_method_entry, 0); - zephir_create_array(return_value, 2, 0); - add_assoc_long_ex(return_value, SL("category"), 6); - add_assoc_stringl_ex(return_value, SL("defaultDomain"), SL("messages")); - return; + zend_declare_property_string(phalcon_filter_validation_validator_confirmation_ce, SL("template"), "Field :field must be the same as :with", ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, prepareOptions) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Confirmation, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *options_param = NULL, _0, _1, _2, _3, _4, _5, _6; + zval *options_param = NULL; zval options; - zval *this_ptr = getThis(); ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + } + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_confirmation_ce, getThis(), "__construct", NULL, 0, &options); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Confirmation, validate) +{ + zval _3, _4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *validation, validation_sub, *field, field_sub, fieldWith, value, valueWith, labelWith, replacePairs, _0, _2, _1$$3, _5$$4, _7$$4, _6$$5; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&fieldWith); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&valueWith); + ZVAL_UNDEF(&labelWith); + ZVAL_UNDEF(&replacePairs); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_6$$5); ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &options_param); - ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); - if (UNEXPECTED(!(zephir_array_isset_string(&options, SL("locale"))))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_translate_exception_ce, "Parameter 'locale' is required", "phalcon/Translate/Adapter/Gettext.zep", 321); - return; - } - if (UNEXPECTED(!(zephir_array_isset_string(&options, SL("directory"))))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_translate_exception_ce, "Parameter 'directory' is required", "phalcon/Translate/Adapter/Gettext.zep", 325); - return; - } + zephir_fetch_params(1, 2, 0, &validation, &field); ZEPHIR_INIT_VAR(&_0); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getoptionsdefault", NULL, 0); - zephir_check_call_status(); - zephir_fast_array_merge(&_0, &_1, &options); - ZEPHIR_CPY_WRT(&options, &_0); - zephir_array_fetch_string(&_2, &options, SL("category"), PH_NOISY | PH_READONLY, "phalcon/Translate/Adapter/Gettext.zep", 333); - zephir_array_fetch_string(&_3, &options, SL("locale"), PH_NOISY | PH_READONLY, "phalcon/Translate/Adapter/Gettext.zep", 333); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setlocale", NULL, 0, &_2, &_3); + ZVAL_STRING(&_0, "with"); + ZEPHIR_CALL_METHOD(&fieldWith, this_ptr, "getoption", NULL, 0, &_0); zephir_check_call_status(); - zephir_array_fetch_string(&_4, &options, SL("defaultDomain"), PH_NOISY | PH_READONLY, "phalcon/Translate/Adapter/Gettext.zep", 334); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdefaultdomain", NULL, 0, &_4); + if (Z_TYPE_P(&fieldWith) == IS_ARRAY) { + zephir_array_fetch(&_1$$3, &fieldWith, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/Confirmation.zep", 87); + ZEPHIR_CPY_WRT(&fieldWith, &_1$$3); + } + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); - zephir_array_fetch_string(&_5, &options, SL("directory"), PH_NOISY | PH_READONLY, "phalcon/Translate/Adapter/Gettext.zep", 335); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdirectory", NULL, 0, &_5); + ZEPHIR_CALL_METHOD(&valueWith, validation, "getvalue", NULL, 0, &fieldWith); zephir_check_call_status(); - zephir_array_fetch_string(&_6, &options, SL("defaultDomain"), PH_NOISY | PH_READONLY, "phalcon/Translate/Adapter/Gettext.zep", 336); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdomain", NULL, 0, &_6); + zephir_cast_to_string(&_3, &value); + zephir_cast_to_string(&_4, &valueWith); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "compare", NULL, 293, &_3, &_4); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + if (!(zephir_is_true(&_2))) { + ZEPHIR_INIT_VAR(&_5$$4); + ZVAL_STRING(&_5$$4, "labelWith"); + ZEPHIR_CALL_METHOD(&labelWith, this_ptr, "getoption", NULL, 0, &_5$$4); + zephir_check_call_status(); + if (Z_TYPE_P(&labelWith) == IS_ARRAY) { + zephir_array_fetch(&_6$$5, &labelWith, &fieldWith, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/Confirmation.zep", 97); + ZEPHIR_CPY_WRT(&labelWith, &_6$$5); + } + if (ZEPHIR_IS_EMPTY(&labelWith)) { + ZEPHIR_CALL_METHOD(&labelWith, validation, "getlabel", NULL, 0, &fieldWith); + zephir_check_call_status(); + } + ZEPHIR_INIT_VAR(&replacePairs); + zephir_create_array(&replacePairs, 1, 0); + zephir_array_update_string(&replacePairs, SL(":with"), &labelWith, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_7$$4, this_ptr, "messagefactory", NULL, 0, validation, field, &replacePairs); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_7$$4); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, phpFunctionExists) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Confirmation, compare) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL; - zval name; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *a_param = NULL, *b_param = NULL, _0, _1, _2, _6, _3$$3, _4$$3, _5$$3; + zval a, b; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + ZVAL_UNDEF(&a); + ZVAL_UNDEF(&b); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(a) + Z_PARAM_STR(b) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - zephir_get_strval(&name, name_param); - RETURN_MM_BOOL((zephir_function_exists(&name) == SUCCESS)); + zephir_fetch_params(1, 2, 0, &a_param, &b_param); + zephir_get_strval(&a, a_param); + zephir_get_strval(&b, b_param); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "ignoreCase"); + ZVAL_BOOL(&_2, 0); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getoption", NULL, 0, &_1, &_2); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + if (UNEXPECTED(!((zephir_function_exists_ex(ZEND_STRL("mb_strtolower")) == SUCCESS)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "Extension 'mbstring' is required", "phalcon/Filter/Validation/Validator/Confirmation.zep", 128); + return; + } + ZEPHIR_INIT_VAR(&_3$$3); + ZVAL_STRING(&_3$$3, "utf-8"); + ZEPHIR_CALL_FUNCTION(&_4$$3, "mb_strtolower", NULL, 10, &a, &_3$$3); + zephir_check_call_status(); + zephir_get_strval(&a, &_4$$3); + ZEPHIR_INIT_NVAR(&_3$$3); + ZVAL_STRING(&_3$$3, "utf-8"); + ZEPHIR_CALL_FUNCTION(&_5$$3, "mb_strtolower", NULL, 10, &b, &_3$$3); + zephir_check_call_status(); + zephir_get_strval(&b, &_5$$3); + } + ZEPHIR_CALL_FUNCTION(&_6, "strcmp", NULL, 294, &a, &b); + zephir_check_call_status(); + RETURN_MM_BOOL(ZEPHIR_IS_LONG_IDENTICAL(&_6, 0)); } @@ -115500,239 +114722,315 @@ static PHP_METHOD(Phalcon_Translate_Adapter_Gettext, phpFunctionExists) -ZEPHIR_INIT_CLASS(Phalcon_Translate_Adapter_NativeArray) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_CreditCard) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Translate\\Adapter, NativeArray, phalcon, translate_adapter_nativearray, phalcon_translate_adapter_abstractadapter_ce, phalcon_translate_adapter_nativearray_method_entry, 0); - - zend_declare_property_null(phalcon_translate_adapter_nativearray_ce, SL("translate"), ZEND_ACC_PRIVATE); - zend_declare_property_bool(phalcon_translate_adapter_nativearray_ce, SL("triggerError"), 0, ZEND_ACC_PRIVATE); - phalcon_translate_adapter_nativearray_ce->create_object = zephir_init_properties_Phalcon_Translate_Adapter_NativeArray; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, CreditCard, phalcon, filter_validation_validator_creditcard, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_creditcard_method_entry, 0); - zend_class_implements(phalcon_translate_adapter_nativearray_ce, 1, zend_ce_arrayaccess); + zend_declare_property_string(phalcon_filter_validation_validator_creditcard_ce, SL("template"), "Field :field is not valid for a credit card number", ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Translate_Adapter_NativeArray, __construct) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_CreditCard, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *options_param = NULL; zval options; - zval *interpolator, interpolator_sub, *options_param = NULL, __$true, __$false, data, error; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&interpolator_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&error); ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(interpolator, phalcon_translate_interpolatorfactory_ce) + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &interpolator, &options_param); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); - ZEPHIR_CALL_PARENT(NULL, phalcon_translate_adapter_nativearray_ce, getThis(), "__construct", NULL, 0, interpolator, &options); - zephir_check_call_status(); - zephir_memory_observe(&data); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&data, &options, SL("content"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_translate_exception_ce, "Translation content was not provided", "phalcon/Translate/Adapter/NativeArray.zep", 57); - return; - } - zephir_memory_observe(&error); - if (zephir_array_isset_string_fetch(&error, &options, SL("triggerError"), 0)) { - if (zephir_get_boolval(&error)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("triggerError"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("triggerError"), &__$false); - } - } - if (UNEXPECTED(Z_TYPE_P(&data) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_translate_exception_ce, "Translation data must be an array", "phalcon/Translate/Adapter/NativeArray.zep", 65); - return; } - zephir_update_property_zval(this_ptr, ZEND_STRL("translate"), &data); + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_creditcard_ce, getThis(), "__construct", NULL, 0, &options); + zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Translate_Adapter_NativeArray, exists) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_CreditCard, validate) { + zval _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *index_param = NULL; - zval index; + zval *validation, validation_sub, *field, field_sub, value, valid, _0, _2$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&index); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(index) + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&valid); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &index_param); - if (UNEXPECTED(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(index_param) == IS_STRING)) { - zephir_get_strval(&index, index_param); - } else { - ZEPHIR_INIT_VAR(&index); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "allowempty", NULL, 0, field, &value); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + RETURN_MM_BOOL(1); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, &index); + zephir_cast_to_string(&_1, &value); + ZEPHIR_CALL_METHOD(&valid, this_ptr, "verifybyluhnalgorithm", NULL, 295, &_1); zephir_check_call_status(); - RETURN_MM(); + if (!(zephir_is_true(&valid))) { + ZEPHIR_CALL_METHOD(&_2$$4, this_ptr, "messagefactory", NULL, 0, validation, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_2$$4); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Translate_Adapter_NativeArray, has) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_CreditCard, verifyByLuhnAlgorithm) { + zend_string *_5; + zend_ulong _4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *index_param = NULL, _0; - zval index; - zval *this_ptr = getThis(); + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *number_param = NULL, digit, digits, position, hash, result, _0, _1, *_2, _3, _8, _6$$4, _7$$5; + zval number; - ZVAL_UNDEF(&index); + ZVAL_UNDEF(&number); + ZVAL_UNDEF(&digit); + ZVAL_UNDEF(&digits); + ZVAL_UNDEF(&position); + ZVAL_UNDEF(&hash); + ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$5); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(index) + Z_PARAM_STR(number) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &index_param); - if (UNEXPECTED(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 0, &number_param); + zephir_get_strval(&number, number_param); + ZEPHIR_INIT_VAR(&hash); + ZVAL_STRING(&hash, ""); + ZEPHIR_CALL_FUNCTION(&_0, "ctype_digit", NULL, 296, &number); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_0)) { + RETURN_MM_BOOL(0); } - if (EXPECTED(Z_TYPE_P(index_param) == IS_STRING)) { - zephir_get_strval(&index, index_param); + ZEPHIR_CALL_FUNCTION(&_1, "str_split", NULL, 88, &number); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&digits, "array_reverse", NULL, 297, &_1); + zephir_check_call_status(); + zephir_is_iterable(&digits, 0, "phalcon/Filter/Validation/Validator/CreditCard.zep", 112); + if (Z_TYPE_P(&digits) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&digits), _4, _5, _2) + { + ZEPHIR_INIT_NVAR(&position); + if (_5 != NULL) { + ZVAL_STR_COPY(&position, _5); + } else { + ZVAL_LONG(&position, _4); + } + ZEPHIR_INIT_NVAR(&digit); + ZVAL_COPY(&digit, _2); + ZEPHIR_INIT_NVAR(&_6$$4); + if (zephir_safe_mod_zval_long(&position, 2)) { + ZEPHIR_INIT_NVAR(&_6$$4); + ZVAL_LONG(&_6$$4, (zephir_get_numberval(&digit) * 2)); + } else { + ZEPHIR_CPY_WRT(&_6$$4, &digit); + } + zephir_concat_self(&hash, &_6$$4); + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_INIT_VAR(&index); + ZEPHIR_CALL_METHOD(NULL, &digits, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &digits, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&position, &digits, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&digit, &digits, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_7$$5); + if (zephir_safe_mod_zval_long(&position, 2)) { + ZEPHIR_INIT_NVAR(&_7$$5); + ZVAL_LONG(&_7$$5, (zephir_get_numberval(&digit) * 2)); + } else { + ZEPHIR_CPY_WRT(&_7$$5, &digit); + } + zephir_concat_self(&hash, &_7$$5); + ZEPHIR_CALL_METHOD(NULL, &digits, "next", NULL, 0); + zephir_check_call_status(); + } } - zephir_read_property(&_0, this_ptr, ZEND_STRL("translate"), PH_NOISY_CC | PH_READONLY); - RETURN_MM_BOOL(zephir_array_isset(&_0, &index)); + ZEPHIR_INIT_NVAR(&digit); + ZEPHIR_INIT_NVAR(&position); + ZEPHIR_CALL_FUNCTION(&_8, "str_split", NULL, 88, &hash); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&result, "array_sum", NULL, 298, &_8); + zephir_check_call_status(); + RETURN_MM_BOOL((zephir_safe_mod_zval_long(&result, 10) == 0)); } -static PHP_METHOD(Phalcon_Translate_Adapter_NativeArray, notFound) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_Date) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, Date, phalcon, filter_validation_validator_date, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_date_method_entry, 0); + + zend_declare_property_string(phalcon_filter_validation_validator_date_ce, SL("template"), "Field :field is not a valid date", ZEND_ACC_PROTECTED); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Date, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *index_param = NULL, _0, _1$$3; - zval index, _2$$3; - zval *this_ptr = getThis(); + zval *options_param = NULL; + zval options; - ZVAL_UNDEF(&index); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(index) + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &index_param); - if (UNEXPECTED(Z_TYPE_P(index_param) != IS_STRING && Z_TYPE_P(index_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'index' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(index_param) == IS_STRING)) { - zephir_get_strval(&index, index_param); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - ZEPHIR_INIT_VAR(&index); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("triggerError"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(ZEPHIR_IS_TRUE_IDENTICAL(&_0))) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_translate_exception_ce); - ZEPHIR_INIT_VAR(&_2$$3); - ZEPHIR_CONCAT_SV(&_2$$3, "Cannot find translation key: ", &index); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_1$$3, "phalcon/Translate/Adapter/NativeArray.zep", 107); - ZEPHIR_MM_RESTORE(); - return; + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - RETURN_CTOR(&index); + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_date_ce, getThis(), "__construct", NULL, 0, &options); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Translate_Adapter_NativeArray, query) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Date, validate) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval placeholders; - zval *translateKey_param = NULL, *placeholders_param = NULL, translation, _0; - zval translateKey; + zval *validation, validation_sub, *field, field_sub, value, format, _0, _1, _3, _2$$4, _4$$6; zval *this_ptr = getThis(); - ZVAL_UNDEF(&translateKey); - ZVAL_UNDEF(&translation); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&format); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&placeholders); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(translateKey) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(placeholders) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_4$$6); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &translateKey_param, &placeholders_param); - if (UNEXPECTED(Z_TYPE_P(translateKey_param) != IS_STRING && Z_TYPE_P(translateKey_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'translateKey' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "allowempty", NULL, 0, field, &value); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + RETURN_MM_BOOL(1); } - if (EXPECTED(Z_TYPE_P(translateKey_param) == IS_STRING)) { - zephir_get_strval(&translateKey, translateKey_param); - } else { - ZEPHIR_INIT_VAR(&translateKey); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "format"); + ZEPHIR_CALL_METHOD(&format, this_ptr, "getoption", NULL, 0, &_1); + zephir_check_call_status(); + if (Z_TYPE_P(&format) == IS_ARRAY) { + zephir_array_fetch(&_2$$4, &format, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/Date.zep", 90); + ZEPHIR_CPY_WRT(&format, &_2$$4); } - if (!placeholders_param) { - ZEPHIR_INIT_VAR(&placeholders); - array_init(&placeholders); - } else { - zephir_get_arrval(&placeholders, placeholders_param); + if (ZEPHIR_IS_EMPTY(&format)) { + ZEPHIR_INIT_NVAR(&format); + ZVAL_STRING(&format, "Y-m-d"); } - zephir_memory_observe(&translation); - zephir_read_property(&_0, this_ptr, ZEND_STRL("translate"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&translation, &_0, &translateKey, 0))) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "notfound", NULL, 0, &translateKey); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "checkdate", NULL, 299, &value, &format); + zephir_check_call_status(); + if (!(zephir_is_true(&_3))) { + ZEPHIR_CALL_METHOD(&_4$$6, this_ptr, "messagefactory", NULL, 0, validation, field); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_4$$6); + zephir_check_call_status(); + RETURN_MM_BOOL(0); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "replaceplaceholders", NULL, 0, &translation, &placeholders); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Translate_Adapter_NativeArray, toArray) -{ - - RETURN_MEMBER(getThis(), "translate"); + RETURN_MM_BOOL(1); } -zend_object *zephir_init_properties_Phalcon_Translate_Adapter_NativeArray(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Date, checkDate) { - zval _0, _1$$3; + zend_bool _2, _4; + zend_class_entry *_0, *_1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *value, value_sub, *format, format_sub, date, errors, _3, _5; - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("translate"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("translate"), &_1$$3); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&format_sub); + ZVAL_UNDEF(&date); + ZVAL_UNDEF(&errors); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(value) + Z_PARAM_ZVAL(format) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &value, &format); + if (!(Z_TYPE_P(value) == IS_STRING)) { + RETURN_MM_BOOL(0); + } + _0 = zephir_fetch_class_str_ex(SL("DateTime"), ZEND_FETCH_CLASS_AUTO); + ZEPHIR_CALL_CE_STATIC(&date, _0, "createfromformat", NULL, 0, format, value); + zephir_check_call_status(); + _1 = zephir_fetch_class_str_ex(SL("DateTime"), ZEND_FETCH_CLASS_AUTO); + ZEPHIR_CALL_CE_STATIC(&errors, _1, "getlasterrors", NULL, 0); + zephir_check_call_status(); + _2 = ZEPHIR_IS_FALSE_IDENTICAL(&errors); + if (!(_2)) { + zephir_array_fetch_string(&_3, &errors, SL("warning_count"), PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/Date.zep", 119); + _4 = ZEPHIR_IS_LONG(&_3, 0); + if (_4) { + zephir_array_fetch_string(&_5, &errors, SL("error_count"), PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/Date.zep", 119); + _4 = ZEPHIR_IS_LONG(&_5, 0); } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + _2 = _4; } + RETURN_MM_BOOL(_2); } @@ -115745,1663 +115043,1329 @@ zend_object *zephir_init_properties_Phalcon_Translate_Adapter_NativeArray(zend_c -ZEPHIR_INIT_CLASS(Phalcon_Dispatcher_AbstractDispatcher) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_Digit) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Dispatcher, AbstractDispatcher, phalcon, dispatcher_abstractdispatcher, phalcon_di_abstractinjectionaware_ce, phalcon_dispatcher_abstractdispatcher_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("activeHandler"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("activeMethodMap"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("actionName"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("actionSuffix"), "Action", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("camelCaseMap"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("defaultAction"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("defaultNamespace"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("defaultHandler"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("handlerHashes"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("handlerName"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("handlerSuffix"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_dispatcher_abstractdispatcher_ce, SL("finished"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_dispatcher_abstractdispatcher_ce, SL("forwarded"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_dispatcher_abstractdispatcher_ce, SL("isControllerInitialize"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("lastHandler"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("modelBinder"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_dispatcher_abstractdispatcher_ce, SL("modelBinding"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("moduleName"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("namespaceName"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("params"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("previousActionName"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("previousHandlerName"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_dispatcher_abstractdispatcher_ce, SL("previousNamespaceName"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_dispatcher_abstractdispatcher_ce, SL("returnedValue"), ZEND_ACC_PROTECTED); - phalcon_dispatcher_abstractdispatcher_ce->create_object = zephir_init_properties_Phalcon_Dispatcher_AbstractDispatcher; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, Digit, phalcon, filter_validation_validator_digit, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_digit_method_entry, 0); - zend_class_implements(phalcon_dispatcher_abstractdispatcher_ce, 1, phalcon_dispatcher_dispatcherinterface_ce); - zend_class_implements(phalcon_dispatcher_abstractdispatcher_ce, 1, phalcon_events_eventsawareinterface_ce); + zend_declare_property_string(phalcon_filter_validation_validator_digit_ce, SL("template"), "Field :field must be numeric", ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, callActionMethod) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Digit, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval params, _0; - zval actionMethod; - zval *handler, handler_sub, *actionMethod_param = NULL, *params_param = NULL; + zval *options_param = NULL; + zval options; - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(&actionMethod); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_ZVAL(handler) - Z_PARAM_STR(actionMethod) + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(params) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &handler, &actionMethod_param, ¶ms_param); - zephir_get_strval(&actionMethod, actionMethod_param); - if (!params_param) { - ZEPHIR_INIT_VAR(¶ms); - array_init(¶ms); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - ZEPHIR_OBS_COPY_OR_DUP(¶ms, params_param); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 2, 0); - zephir_array_fast_append(&_0, handler); - zephir_array_fast_append(&_0, &actionMethod); - ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_0, ¶ms); + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_digit_ce, getThis(), "__construct", NULL, 0, &options); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, dispatch) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Digit, validate) { - zval _44$$10; - zend_bool hasService = 0, hasEventsManager = 0, isNewHandler = 0, _5$$5, _16$$13, _21$$15, _29$$18, _34$$20, _42$$23, _52$$25, _56$$31, _62$$33, _66$$36, _72$$38, _78$$43, _83$$46, _88$$48, _105$$59, _110$$62, _115$$64, _118$$67, _123$$69, _130$$73; + zval _2; + zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_11 = NULL, *_12 = NULL, *_15 = NULL, *_20 = NULL, *_23 = NULL, *_25 = NULL, *_28 = NULL, *_30 = NULL, *_33 = NULL, *_35 = NULL, *_41 = NULL, *_43 = NULL, *_47 = NULL, *_51 = NULL, *_55 = NULL, *_58 = NULL, *_61 = NULL, *_64 = NULL, *_68 = NULL, *_71 = NULL, *_74 = NULL, *_77 = NULL, *_82 = NULL, *_87 = NULL, *_94 = NULL, *_100 = NULL, *_104 = NULL, *_109 = NULL, *_114 = NULL, *_122 = NULL, *_126 = NULL, *_129 = NULL; - zval __$true, __$false, value, handler, container, namespaceName, handlerName, actionName, eventsManager, handlerClass, status, actionMethod, modelBinder, bindCacheKey, handlerHash, e, _0, _1$$3, _2$$3, _3$$5, _4$$5, _6$$5, _7$$4, _8$$7, _9$$11, _10$$11, _13$$13, _14$$13, _17$$13, _18$$12, _19$$15, _22$$15, _24$$10, _36$$10, _37$$10, _38$$10, _102$$10, _26$$18, _27$$18, _31$$20, _32$$20, _39$$23, _40$$23, _45$$26, _46$$26, _48$$26, _49$$25, _50$$25, _53$$31, _54$$31, _57$$31, _59$$30, _60$$33, _63$$33, _65$$36, _67$$36, _69$$35, _70$$38, _73$$38, _75$$41, _76$$43, _79$$43, _80$$46, _81$$46, _84$$46, _85$$45, _86$$48, _89$$48, _90$$50, _91$$50, _92$$51, _93$$51, _95$$51, _96$$54, _97$$54, _98$$57, _99$$57, _101$$57, _103$$59, _106$$59, _107$$62, _108$$62, _111$$62, _112$$61, _113$$64, _116$$64, _117$$67, _119$$67, _120$$66, _121$$69, _124$$69, _125$$72, _127$$71, _128$$73, _131$$73, _132$$76, _133$$75, _134$$77; - zend_long ZEPHIR_LAST_CALL_STATUS, numberDispatches = 0; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *validation, validation_sub, *field, field_sub, value, _0, _3, _4; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); ZVAL_UNDEF(&value); - ZVAL_UNDEF(&handler); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&namespaceName); - ZVAL_UNDEF(&handlerName); - ZVAL_UNDEF(&actionName); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&handlerClass); - ZVAL_UNDEF(&status); - ZVAL_UNDEF(&actionMethod); - ZVAL_UNDEF(&modelBinder); - ZVAL_UNDEF(&bindCacheKey); - ZVAL_UNDEF(&handlerHash); - ZVAL_UNDEF(&e); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_8$$7); - ZVAL_UNDEF(&_9$$11); - ZVAL_UNDEF(&_10$$11); - ZVAL_UNDEF(&_13$$13); - ZVAL_UNDEF(&_14$$13); - ZVAL_UNDEF(&_17$$13); - ZVAL_UNDEF(&_18$$12); - ZVAL_UNDEF(&_19$$15); - ZVAL_UNDEF(&_22$$15); - ZVAL_UNDEF(&_24$$10); - ZVAL_UNDEF(&_36$$10); - ZVAL_UNDEF(&_37$$10); - ZVAL_UNDEF(&_38$$10); - ZVAL_UNDEF(&_102$$10); - ZVAL_UNDEF(&_26$$18); - ZVAL_UNDEF(&_27$$18); - ZVAL_UNDEF(&_31$$20); - ZVAL_UNDEF(&_32$$20); - ZVAL_UNDEF(&_39$$23); - ZVAL_UNDEF(&_40$$23); - ZVAL_UNDEF(&_45$$26); - ZVAL_UNDEF(&_46$$26); - ZVAL_UNDEF(&_48$$26); - ZVAL_UNDEF(&_49$$25); - ZVAL_UNDEF(&_50$$25); - ZVAL_UNDEF(&_53$$31); - ZVAL_UNDEF(&_54$$31); - ZVAL_UNDEF(&_57$$31); - ZVAL_UNDEF(&_59$$30); - ZVAL_UNDEF(&_60$$33); - ZVAL_UNDEF(&_63$$33); - ZVAL_UNDEF(&_65$$36); - ZVAL_UNDEF(&_67$$36); - ZVAL_UNDEF(&_69$$35); - ZVAL_UNDEF(&_70$$38); - ZVAL_UNDEF(&_73$$38); - ZVAL_UNDEF(&_75$$41); - ZVAL_UNDEF(&_76$$43); - ZVAL_UNDEF(&_79$$43); - ZVAL_UNDEF(&_80$$46); - ZVAL_UNDEF(&_81$$46); - ZVAL_UNDEF(&_84$$46); - ZVAL_UNDEF(&_85$$45); - ZVAL_UNDEF(&_86$$48); - ZVAL_UNDEF(&_89$$48); - ZVAL_UNDEF(&_90$$50); - ZVAL_UNDEF(&_91$$50); - ZVAL_UNDEF(&_92$$51); - ZVAL_UNDEF(&_93$$51); - ZVAL_UNDEF(&_95$$51); - ZVAL_UNDEF(&_96$$54); - ZVAL_UNDEF(&_97$$54); - ZVAL_UNDEF(&_98$$57); - ZVAL_UNDEF(&_99$$57); - ZVAL_UNDEF(&_101$$57); - ZVAL_UNDEF(&_103$$59); - ZVAL_UNDEF(&_106$$59); - ZVAL_UNDEF(&_107$$62); - ZVAL_UNDEF(&_108$$62); - ZVAL_UNDEF(&_111$$62); - ZVAL_UNDEF(&_112$$61); - ZVAL_UNDEF(&_113$$64); - ZVAL_UNDEF(&_116$$64); - ZVAL_UNDEF(&_117$$67); - ZVAL_UNDEF(&_119$$67); - ZVAL_UNDEF(&_120$$66); - ZVAL_UNDEF(&_121$$69); - ZVAL_UNDEF(&_124$$69); - ZVAL_UNDEF(&_125$$72); - ZVAL_UNDEF(&_127$$71); - ZVAL_UNDEF(&_128$$73); - ZVAL_UNDEF(&_131$$73); - ZVAL_UNDEF(&_132$$76); - ZVAL_UNDEF(&_133$$75); - ZVAL_UNDEF(&_134$$77); - ZVAL_UNDEF(&_44$$10); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - ZVAL_STRING(&_1$$3, "A dependency injection container is required to access related dispatching services"); - ZVAL_LONG(&_2$$3, 0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwdispatchexception", NULL, 0, &_1$$3, &_2$$3); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "allowempty", NULL, 0, field, &value); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + RETURN_MM_BOOL(1); + } + _1 = Z_TYPE_P(&value) == IS_LONG; + if (!(_1)) { + zephir_cast_to_string(&_2, &value); + ZEPHIR_CALL_FUNCTION(&_3, "ctype_digit", NULL, 296, &_2); zephir_check_call_status(); - RETURN_MM_BOOL(0); + _1 = zephir_is_true(&_3); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - hasEventsManager = Z_TYPE_P(&eventsManager) == IS_OBJECT; - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$false); + if (_1) { + RETURN_MM_BOOL(1); } - if (hasEventsManager) { + ZEPHIR_CALL_METHOD(&_4, this_ptr, "messagefactory", NULL, 0, validation, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_4); + zephir_check_call_status(); + RETURN_MM_BOOL(0); +} - /* try_start_1: */ - ZEPHIR_INIT_VAR(&_4$$5); - ZVAL_STRING(&_4$$5, "dispatch:beforeDispatchLoop"); - ZEPHIR_CALL_METHOD(&_3$$5, &eventsManager, "fire", NULL, 0, &_4$$5, this_ptr); - zephir_check_call_status_or_jump(try_end_1); - _5$$5 = ZEPHIR_IS_FALSE_IDENTICAL(&_3$$5); - if (_5$$5) { - zephir_read_property(&_6$$5, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _5$$5 = !ZEPHIR_IS_FALSE_IDENTICAL(&_6$$5); - } - if (_5$$5) { - RETURN_MM_BOOL(0); - } - try_end_1: - if (EG(exception)) { - ZEPHIR_INIT_VAR(&_7$$4); - ZVAL_OBJ(&_7$$4, EG(exception)); - Z_ADDREF_P(&_7$$4); - if (zephir_is_instance_of(&_7$$4, SL("Exception"))) { - zend_clear_exception(); - ZEPHIR_CPY_WRT(&e, &_7$$4); - ZEPHIR_CALL_METHOD(&status, this_ptr, "handleexception", NULL, 0, &e); - zephir_check_call_status(); - zephir_read_property(&_8$$7, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_8$$7)) { - if (ZEPHIR_IS_FALSE_IDENTICAL(&status)) { - RETURN_MM_BOOL(0); - } - zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 229); - ZEPHIR_MM_RESTORE(); - return; - } - } - } - } - ZEPHIR_INIT_VAR(&value); - ZVAL_NULL(&value); - ZEPHIR_INIT_VAR(&handler); - ZVAL_NULL(&handler); - numberDispatches = 0; - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$false); - } - while (1) { - zephir_read_property(&_0, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - if (!(!(zephir_is_true(&_0)))) { - break; - } - numberDispatches++; - if (UNEXPECTED(numberDispatches == 256)) { - ZEPHIR_INIT_NVAR(&_9$$11); - ZVAL_STRING(&_9$$11, "Dispatcher has detected a cyclic routing causing stability problems"); - ZVAL_LONG(&_10$$11, 1); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwdispatchexception", &_11, 0, &_9$$11, &_10$$11); - zephir_check_call_status(); - break; - } - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$false); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "resolveemptyproperties", &_12, 0); - zephir_check_call_status(); - if (hasEventsManager) { +#ifdef HAVE_CONFIG_H +#endif - /* try_start_2: */ - ZEPHIR_INIT_NVAR(&_14$$13); - ZVAL_STRING(&_14$$13, "dispatch:beforeDispatch"); - ZEPHIR_CALL_METHOD(&_13$$13, &eventsManager, "fire", &_15, 0, &_14$$13, this_ptr); - zephir_check_call_status_or_jump(try_end_2); - _16$$13 = ZEPHIR_IS_FALSE_IDENTICAL(&_13$$13); - if (!(_16$$13)) { - zephir_read_property(&_17$$13, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _16$$13 = ZEPHIR_IS_FALSE_IDENTICAL(&_17$$13); - } - if (_16$$13) { - continue; - } - try_end_2: - if (EG(exception)) { - ZEPHIR_INIT_NVAR(&_18$$12); - ZVAL_OBJ(&_18$$12, EG(exception)); - Z_ADDREF_P(&_18$$12); - if (zephir_is_instance_of(&_18$$12, SL("Exception"))) { - zend_clear_exception(); - ZEPHIR_CPY_WRT(&e, &_18$$12); - ZEPHIR_CALL_METHOD(&_19$$15, this_ptr, "handleexception", &_20, 0, &e); - zephir_check_call_status(); - _21$$15 = ZEPHIR_IS_FALSE_IDENTICAL(&_19$$15); - if (!(_21$$15)) { - zephir_read_property(&_22$$15, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _21$$15 = ZEPHIR_IS_FALSE_IDENTICAL(&_22$$15); - } - if (_21$$15) { - continue; - } - zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 269); - ZEPHIR_MM_RESTORE(); - return; - } - } - } - ZEPHIR_CALL_METHOD(&handlerClass, this_ptr, "gethandlerclass", &_23, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_24$$10, &container, "has", &_25, 0, &handlerClass); - zephir_check_call_status(); - hasService = zephir_get_boolval(&_24$$10); - if (!(hasService)) { - hasService = zephir_class_exists(&handlerClass, 1); - } - if (!(hasService)) { - ZEPHIR_INIT_NVAR(&_26$$18); - ZEPHIR_CONCAT_VS(&_26$$18, &handlerClass, " handler class cannot be loaded"); - ZVAL_LONG(&_27$$18, 2); - ZEPHIR_CALL_METHOD(&status, this_ptr, "throwdispatchexception", &_28, 0, &_26$$18, &_27$$18); - zephir_check_call_status(); - _29$$18 = ZEPHIR_IS_FALSE_IDENTICAL(&status); - if (_29$$18) { - zephir_read_property(&_27$$18, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _29$$18 = ZEPHIR_IS_FALSE_IDENTICAL(&_27$$18); - } - if (_29$$18) { - continue; - } - break; - } - ZEPHIR_CALL_METHOD(&handler, &container, "getshared", &_30, 0, &handlerClass); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&handler) != IS_OBJECT)) { - ZEPHIR_INIT_NVAR(&_31$$20); - ZVAL_STRING(&_31$$20, "Invalid handler returned from the services container"); - ZVAL_LONG(&_32$$20, 3); - ZEPHIR_CALL_METHOD(&status, this_ptr, "throwdispatchexception", &_33, 0, &_31$$20, &_32$$20); - zephir_check_call_status(); - _34$$20 = ZEPHIR_IS_FALSE_IDENTICAL(&status); - if (_34$$20) { - zephir_read_property(&_32$$20, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _34$$20 = ZEPHIR_IS_FALSE_IDENTICAL(&_32$$20); - } - if (_34$$20) { - continue; - } - break; - } - ZEPHIR_CALL_FUNCTION(&handlerHash, "spl_object_hash", &_35, 80, &handler); - zephir_check_call_status(); - zephir_read_property(&_36$$10, this_ptr, ZEND_STRL("handlerHashes"), PH_NOISY_CC | PH_READONLY); - isNewHandler = !((zephir_array_isset(&_36$$10, &handlerHash))); - if (isNewHandler) { - zephir_update_property_array(this_ptr, SL("handlerHashes"), &handlerHash, &__$true); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("activeHandler"), &handler); - zephir_read_property(&_37$$10, this_ptr, ZEND_STRL("namespaceName"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&namespaceName, &_37$$10); - zephir_read_property(&_37$$10, this_ptr, ZEND_STRL("handlerName"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&handlerName, &_37$$10); - zephir_read_property(&_37$$10, this_ptr, ZEND_STRL("actionName"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&actionName, &_37$$10); - ZEPHIR_OBS_NVAR(&_38$$10); - zephir_read_property(&_38$$10, this_ptr, ZEND_STRL("params"), PH_NOISY_CC); - if (UNEXPECTED(Z_TYPE_P(&_38$$10) != IS_ARRAY)) { - ZEPHIR_INIT_NVAR(&_39$$23); - ZVAL_STRING(&_39$$23, "Action parameters must be an Array"); - ZVAL_LONG(&_40$$23, 4); - ZEPHIR_CALL_METHOD(&status, this_ptr, "throwdispatchexception", &_41, 0, &_39$$23, &_40$$23); - zephir_check_call_status(); - _42$$23 = ZEPHIR_IS_FALSE_IDENTICAL(&status); - if (_42$$23) { - zephir_read_property(&_40$$23, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _42$$23 = ZEPHIR_IS_FALSE_IDENTICAL(&_40$$23); - } - if (_42$$23) { - continue; - } - break; - } - ZEPHIR_CALL_METHOD(&actionMethod, this_ptr, "getactivemethod", &_43, 0); + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_Email) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, Email, phalcon, filter_validation_validator_email, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_email_method_entry, 0); + + zend_declare_property_string(phalcon_filter_validation_validator_email_ce, SL("template"), "Field :field must be an email address", ZEND_ACC_PROTECTED); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Email, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *options_param = NULL; + zval options; + + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + } + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_email_ce, getThis(), "__construct", NULL, 0, &options); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Email, validate) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *validation, validation_sub, *field, field_sub, value, _0, _1, _2, _3$$4; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$4); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "allowempty", NULL, 0, field, &value); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + RETURN_MM_BOOL(1); + } + ZVAL_LONG(&_1, 274); + ZEPHIR_CALL_FUNCTION(&_2, "filter_var", NULL, 283, &value, &_1); + zephir_check_call_status(); + if (!(zephir_is_true(&_2))) { + ZEPHIR_CALL_METHOD(&_3$$4, this_ptr, "messagefactory", NULL, 0, validation, field); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_44$$10); - zephir_create_array(&_44$$10, 2, 0); - zephir_array_fast_append(&_44$$10, &handler); - zephir_array_fast_append(&_44$$10, &actionMethod); - if (UNEXPECTED(!(zephir_is_callable(&_44$$10)))) { - if (hasEventsManager) { - ZEPHIR_INIT_NVAR(&_46$$26); - ZVAL_STRING(&_46$$26, "dispatch:beforeNotFoundAction"); - ZEPHIR_CALL_METHOD(&_45$$26, &eventsManager, "fire", &_47, 0, &_46$$26, this_ptr); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_45$$26)) { - continue; - } - zephir_read_property(&_48$$26, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_48$$26)) { - continue; - } - } - ZEPHIR_INIT_NVAR(&_49$$25); - ZEPHIR_CONCAT_SVSVS(&_49$$25, "Action '", &actionName, "' was not found on handler '", &handlerName, "'"); - ZVAL_LONG(&_50$$25, 5); - ZEPHIR_CALL_METHOD(&status, this_ptr, "throwdispatchexception", &_51, 0, &_49$$25, &_50$$25); - zephir_check_call_status(); - _52$$25 = ZEPHIR_IS_FALSE_IDENTICAL(&status); - if (_52$$25) { - zephir_read_property(&_50$$25, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _52$$25 = ZEPHIR_IS_FALSE_IDENTICAL(&_50$$25); - } - if (_52$$25) { - continue; - } - break; - } - if (hasEventsManager) { + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_3$$4); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); +} - /* try_start_3: */ - ZEPHIR_INIT_NVAR(&_54$$31); - ZVAL_STRING(&_54$$31, "dispatch:beforeExecuteRoute"); - ZEPHIR_CALL_METHOD(&_53$$31, &eventsManager, "fire", &_55, 0, &_54$$31, this_ptr); - zephir_check_call_status_or_jump(try_end_3); - _56$$31 = ZEPHIR_IS_FALSE_IDENTICAL(&_53$$31); - if (!(_56$$31)) { - zephir_read_property(&_57$$31, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _56$$31 = ZEPHIR_IS_FALSE_IDENTICAL(&_57$$31); - } - if (_56$$31) { - ZEPHIR_CALL_METHOD(NULL, &container, "remove", &_58, 0, &handlerClass); - zephir_check_call_status_or_jump(try_end_3); - continue; - } - try_end_3: - if (EG(exception)) { - ZEPHIR_INIT_NVAR(&_59$$30); - ZVAL_OBJ(&_59$$30, EG(exception)); - Z_ADDREF_P(&_59$$30); - if (zephir_is_instance_of(&_59$$30, SL("Exception"))) { - zend_clear_exception(); - ZEPHIR_CPY_WRT(&e, &_59$$30); - ZEPHIR_CALL_METHOD(&_60$$33, this_ptr, "handleexception", &_61, 0, &e); - zephir_check_call_status(); - _62$$33 = ZEPHIR_IS_FALSE_IDENTICAL(&_60$$33); - if (!(_62$$33)) { - zephir_read_property(&_63$$33, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _62$$33 = ZEPHIR_IS_FALSE_IDENTICAL(&_63$$33); - } - if (_62$$33) { - ZEPHIR_CALL_METHOD(NULL, &container, "remove", &_64, 0, &handlerClass); - zephir_check_call_status(); - continue; - } - zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 408); - ZEPHIR_MM_RESTORE(); - return; - } - } - } - if ((zephir_method_exists_ex(&handler, ZEND_STRL("beforeexecuteroute")) == SUCCESS)) { +#ifdef HAVE_CONFIG_H +#endif - /* try_start_4: */ - ZEPHIR_CALL_METHOD(&_65$$36, &handler, "beforeexecuteroute", NULL, 0, this_ptr); - zephir_check_call_status_or_jump(try_end_4); - _66$$36 = ZEPHIR_IS_FALSE_IDENTICAL(&_65$$36); - if (!(_66$$36)) { - zephir_read_property(&_67$$36, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _66$$36 = ZEPHIR_IS_FALSE_IDENTICAL(&_67$$36); - } - if (_66$$36) { - ZEPHIR_CALL_METHOD(NULL, &container, "remove", &_68, 0, &handlerClass); - zephir_check_call_status_or_jump(try_end_4); - continue; - } - try_end_4: - if (EG(exception)) { - ZEPHIR_INIT_NVAR(&_69$$35); - ZVAL_OBJ(&_69$$35, EG(exception)); - Z_ADDREF_P(&_69$$35); - if (zephir_is_instance_of(&_69$$35, SL("Exception"))) { - zend_clear_exception(); - ZEPHIR_CPY_WRT(&e, &_69$$35); - ZEPHIR_CALL_METHOD(&_70$$38, this_ptr, "handleexception", &_71, 0, &e); - zephir_check_call_status(); - _72$$38 = ZEPHIR_IS_FALSE_IDENTICAL(&_70$$38); - if (!(_72$$38)) { - zephir_read_property(&_73$$38, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _72$$38 = ZEPHIR_IS_FALSE_IDENTICAL(&_73$$38); - } - if (_72$$38) { - ZEPHIR_CALL_METHOD(NULL, &container, "remove", &_74, 0, &handlerClass); - zephir_check_call_status(); - continue; - } - zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 427); - ZEPHIR_MM_RESTORE(); - return; - } - } - } - if (isNewHandler) { - if ((zephir_method_exists_ex(&handler, ZEND_STRL("initialize")) == SUCCESS)) { - /* try_start_5: */ +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, Exception, phalcon, filter_validation_validator_exception, zend_ce_exception, NULL, 0); - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isControllerInitialize"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("isControllerInitialize"), &__$false); - } - ZEPHIR_CALL_METHOD(NULL, &handler, "initialize", NULL, 0); - zephir_check_call_status_or_jump(try_end_5); + return SUCCESS; +} - try_end_5: - if (EG(exception)) { - ZEPHIR_INIT_NVAR(&_75$$41); - ZVAL_OBJ(&_75$$41, EG(exception)); - Z_ADDREF_P(&_75$$41); - if (zephir_is_instance_of(&_75$$41, SL("Exception"))) { - zend_clear_exception(); - ZEPHIR_CPY_WRT(&e, &_75$$41); - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isControllerInitialize"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("isControllerInitialize"), &__$false); - } - ZEPHIR_CALL_METHOD(&_76$$43, this_ptr, "handleexception", &_77, 0, &e); - zephir_check_call_status(); - _78$$43 = ZEPHIR_IS_FALSE_IDENTICAL(&_76$$43); - if (!(_78$$43)) { - zephir_read_property(&_79$$43, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _78$$43 = ZEPHIR_IS_FALSE_IDENTICAL(&_79$$43); - } - if (_78$$43) { - continue; - } - zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 469); - ZEPHIR_MM_RESTORE(); - return; - } - } - } - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isControllerInitialize"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("isControllerInitialize"), &__$false); - } - if (zephir_is_true(&eventsManager)) { - /* try_start_6: */ - ZEPHIR_INIT_NVAR(&_81$$46); - ZVAL_STRING(&_81$$46, "dispatch:afterInitialize"); - ZEPHIR_CALL_METHOD(&_80$$46, &eventsManager, "fire", &_82, 0, &_81$$46, this_ptr); - zephir_check_call_status_or_jump(try_end_6); - _83$$46 = ZEPHIR_IS_FALSE_IDENTICAL(&_80$$46); - if (!(_83$$46)) { - zephir_read_property(&_84$$46, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _83$$46 = ZEPHIR_IS_FALSE_IDENTICAL(&_84$$46); - } - if (_83$$46) { - continue; - } +#ifdef HAVE_CONFIG_H +#endif - try_end_6: - if (EG(exception)) { - ZEPHIR_INIT_NVAR(&_85$$45); - ZVAL_OBJ(&_85$$45, EG(exception)); - Z_ADDREF_P(&_85$$45); - if (zephir_is_instance_of(&_85$$45, SL("Exception"))) { - zend_clear_exception(); - ZEPHIR_CPY_WRT(&e, &_85$$45); - ZEPHIR_CALL_METHOD(&_86$$48, this_ptr, "handleexception", &_87, 0, &e); - zephir_check_call_status(); - _88$$48 = ZEPHIR_IS_FALSE_IDENTICAL(&_86$$48); - if (!(_88$$48)) { - zephir_read_property(&_89$$48, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _88$$48 = ZEPHIR_IS_FALSE_IDENTICAL(&_89$$48); - } - if (_88$$48) { - continue; - } - zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 488); - ZEPHIR_MM_RESTORE(); - return; - } - } - } - } - zephir_read_property(&_37$$10, this_ptr, ZEND_STRL("modelBinding"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_37$$10)) { - zephir_read_property(&_90$$50, this_ptr, ZEND_STRL("modelBinder"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&modelBinder, &_90$$50); - ZEPHIR_INIT_NVAR(&bindCacheKey); - ZEPHIR_CONCAT_SVSV(&bindCacheKey, "_PHMB_", &handlerClass, "_", &actionMethod); - zephir_read_property(&_90$$50, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_91$$50, &modelBinder, "bindtohandler", NULL, 0, &handler, &_90$$50, &bindCacheKey, &actionMethod); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("params"), &_91$$50); - } - if (hasEventsManager) { - ZEPHIR_INIT_NVAR(&_93$$51); - ZVAL_STRING(&_93$$51, "dispatch:afterBinding"); - ZEPHIR_CALL_METHOD(&_92$$51, &eventsManager, "fire", &_94, 0, &_93$$51, this_ptr); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_92$$51)) { - continue; - } - zephir_read_property(&_95$$51, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_95$$51)) { - continue; - } - } - if ((zephir_method_exists_ex(&handler, ZEND_STRL("afterbinding")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(&_96$$54, &handler, "afterbinding", NULL, 0, this_ptr); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_96$$54)) { - continue; - } - zephir_read_property(&_97$$54, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_97$$54)) { - continue; - } - } - zephir_update_property_zval(this_ptr, ZEND_STRL("lastHandler"), &handler); - /* try_start_7: */ - zephir_read_property(&_99$$57, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_98$$57, this_ptr, "callactionmethod", &_100, 0, &handler, &actionMethod, &_99$$57); - zephir_check_call_status_or_jump(try_end_7); - zephir_update_property_zval(this_ptr, ZEND_STRL("returnedValue"), &_98$$57); - zephir_read_property(&_101$$57, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_101$$57)) { - continue; - } - try_end_7: +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_ExclusionIn) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, ExclusionIn, phalcon, filter_validation_validator_exclusionin, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_exclusionin_method_entry, 0); - if (EG(exception)) { - ZEPHIR_INIT_NVAR(&_102$$10); - ZVAL_OBJ(&_102$$10, EG(exception)); - Z_ADDREF_P(&_102$$10); - if (zephir_is_instance_of(&_102$$10, SL("Exception"))) { - zend_clear_exception(); - ZEPHIR_CPY_WRT(&e, &_102$$10); - ZEPHIR_CALL_METHOD(&_103$$59, this_ptr, "handleexception", &_104, 0, &e); - zephir_check_call_status(); - _105$$59 = ZEPHIR_IS_FALSE_IDENTICAL(&_103$$59); - if (!(_105$$59)) { - zephir_read_property(&_106$$59, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _105$$59 = ZEPHIR_IS_FALSE_IDENTICAL(&_106$$59); - } - if (_105$$59) { - continue; - } - zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 560); - ZEPHIR_MM_RESTORE(); - return; - } - } - if (hasEventsManager) { + zend_declare_property_string(phalcon_filter_validation_validator_exclusionin_ce, SL("template"), "Field :field must not be a part of list: :domain", ZEND_ACC_PROTECTED); + return SUCCESS; +} - /* try_start_8: */ +static PHP_METHOD(Phalcon_Filter_Validation_Validator_ExclusionIn, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *options_param = NULL; + zval options; - ZEPHIR_INIT_NVAR(&_108$$62); - ZVAL_STRING(&_108$$62, "dispatch:afterExecuteRoute"); - ZEPHIR_CALL_METHOD(&_107$$62, &eventsManager, "fire", &_109, 0, &_108$$62, this_ptr, &value); - zephir_check_call_status_or_jump(try_end_8); - _110$$62 = ZEPHIR_IS_FALSE_IDENTICAL(&_107$$62); - if (!(_110$$62)) { - zephir_read_property(&_111$$62, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _110$$62 = ZEPHIR_IS_FALSE_IDENTICAL(&_111$$62); - } - if (_110$$62) { - continue; - } + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + } + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_exclusionin_ce, getThis(), "__construct", NULL, 0, &options); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} - try_end_8: +static PHP_METHOD(Phalcon_Filter_Validation_Validator_ExclusionIn, validate) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *validation, validation_sub, *field, field_sub, value, domain, replacePairs, strict, fieldDomain, _0, _1, _2, _5, _3$$7, _4$$8, _6$$10, _7$$10; + zval *this_ptr = getThis(); - if (EG(exception)) { - ZEPHIR_INIT_NVAR(&_112$$61); - ZVAL_OBJ(&_112$$61, EG(exception)); - Z_ADDREF_P(&_112$$61); - if (zephir_is_instance_of(&_112$$61, SL("Exception"))) { - zend_clear_exception(); - ZEPHIR_CPY_WRT(&e, &_112$$61); - ZEPHIR_CALL_METHOD(&_113$$64, this_ptr, "handleexception", &_114, 0, &e); - zephir_check_call_status(); - _115$$64 = ZEPHIR_IS_FALSE_IDENTICAL(&_113$$64); - if (!(_115$$64)) { - zephir_read_property(&_116$$64, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _115$$64 = ZEPHIR_IS_FALSE_IDENTICAL(&_116$$64); - } - if (_115$$64) { - continue; - } - zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 576); - ZEPHIR_MM_RESTORE(); - return; - } - } + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&domain); + ZVAL_UNDEF(&replacePairs); + ZVAL_UNDEF(&strict); + ZVAL_UNDEF(&fieldDomain); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_3$$7); + ZVAL_UNDEF(&_4$$8); + ZVAL_UNDEF(&_6$$10); + ZVAL_UNDEF(&_7$$10); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "allowempty", NULL, 0, field, &value); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + RETURN_MM_BOOL(1); + } + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "domain"); + ZEPHIR_CALL_METHOD(&domain, this_ptr, "getoption", NULL, 0, &_1); + zephir_check_call_status(); + zephir_memory_observe(&fieldDomain); + if (zephir_array_isset_fetch(&fieldDomain, &domain, field, 0)) { + if (Z_TYPE_P(&fieldDomain) == IS_ARRAY) { + ZEPHIR_CPY_WRT(&domain, &fieldDomain); } - if ((zephir_method_exists_ex(&handler, ZEND_STRL("afterexecuteroute")) == SUCCESS)) { + } + if (UNEXPECTED(Z_TYPE_P(&domain) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "Option 'domain' must be an array", "phalcon/Filter/Validation/Validator/ExclusionIn.zep", 107); + return; + } + ZEPHIR_INIT_VAR(&strict); + ZVAL_BOOL(&strict, 0); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "strict"); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "hasoption", NULL, 0, &_1); + zephir_check_call_status(); + if (zephir_is_true(&_2)) { + ZEPHIR_INIT_VAR(&_3$$7); + ZVAL_STRING(&_3$$7, "strict"); + ZEPHIR_CALL_METHOD(&strict, this_ptr, "getoption", NULL, 0, &_3$$7); + zephir_check_call_status(); + if (Z_TYPE_P(&strict) == IS_ARRAY) { + zephir_array_fetch(&_4$$8, &strict, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/ExclusionIn.zep", 116); + ZEPHIR_CPY_WRT(&strict, &_4$$8); + } + if (UNEXPECTED(((Z_TYPE_P(&strict) == IS_TRUE || Z_TYPE_P(&strict) == IS_FALSE) != 1))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "Option 'strict' must be a bool", "phalcon/Filter/Validation/Validator/ExclusionIn.zep", 120); + return; + } + } + ZEPHIR_CALL_FUNCTION(&_5, "in_array", NULL, 300, &value, &domain, &strict); + zephir_check_call_status(); + if (zephir_is_true(&_5)) { + ZEPHIR_INIT_VAR(&replacePairs); + zephir_create_array(&replacePairs, 1, 0); + ZEPHIR_INIT_VAR(&_6$$10); + zephir_fast_join_str(&_6$$10, SL(", "), &domain); + zephir_array_update_string(&replacePairs, SL(":domain"), &_6$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_7$$10, this_ptr, "messagefactory", NULL, 0, validation, field, &replacePairs); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_7$$10); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); +} - /* try_start_9: */ - ZEPHIR_CALL_METHOD(&_117$$67, &handler, "afterexecuteroute", NULL, 0, this_ptr, &value); - zephir_check_call_status_or_jump(try_end_9); - _118$$67 = ZEPHIR_IS_FALSE_IDENTICAL(&_117$$67); - if (!(_118$$67)) { - zephir_read_property(&_119$$67, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _118$$67 = ZEPHIR_IS_FALSE_IDENTICAL(&_119$$67); - } - if (_118$$67) { - continue; - } - try_end_9: - if (EG(exception)) { - ZEPHIR_INIT_NVAR(&_120$$66); - ZVAL_OBJ(&_120$$66, EG(exception)); - Z_ADDREF_P(&_120$$66); - if (zephir_is_instance_of(&_120$$66, SL("Exception"))) { - zend_clear_exception(); - ZEPHIR_CPY_WRT(&e, &_120$$66); - ZEPHIR_CALL_METHOD(&_121$$69, this_ptr, "handleexception", &_122, 0, &e); - zephir_check_call_status(); - _123$$69 = ZEPHIR_IS_FALSE_IDENTICAL(&_121$$69); - if (!(_123$$69)) { - zephir_read_property(&_124$$69, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _123$$69 = ZEPHIR_IS_FALSE_IDENTICAL(&_124$$69); - } - if (_123$$69) { - continue; - } - zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 593); - ZEPHIR_MM_RESTORE(); - return; - } - } - } - if (hasEventsManager) { +#ifdef HAVE_CONFIG_H +#endif - /* try_start_10: */ - ZEPHIR_INIT_NVAR(&_125$$72); - ZVAL_STRING(&_125$$72, "dispatch:afterDispatch"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", &_126, 0, &_125$$72, this_ptr, &value); - zephir_check_call_status_or_jump(try_end_10); - try_end_10: - if (EG(exception)) { - ZEPHIR_INIT_NVAR(&_127$$71); - ZVAL_OBJ(&_127$$71, EG(exception)); - Z_ADDREF_P(&_127$$71); - if (zephir_is_instance_of(&_127$$71, SL("Exception"))) { - zend_clear_exception(); - ZEPHIR_CPY_WRT(&e, &_127$$71); - ZEPHIR_CALL_METHOD(&_128$$73, this_ptr, "handleexception", &_129, 0, &e); - zephir_check_call_status(); - _130$$73 = ZEPHIR_IS_FALSE_IDENTICAL(&_128$$73); - if (!(_130$$73)) { - zephir_read_property(&_131$$73, this_ptr, ZEND_STRL("finished"), PH_NOISY_CC | PH_READONLY); - _130$$73 = ZEPHIR_IS_FALSE_IDENTICAL(&_131$$73); - } - if (_130$$73) { - continue; - } - zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 610); - ZEPHIR_MM_RESTORE(); - return; - } - } - } - } - if (hasEventsManager) { - /* try_start_11: */ +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_File) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, File, phalcon, filter_validation_validator_file, phalcon_filter_validation_abstractvalidatorcomposite_ce, phalcon_filter_validation_validator_file_method_entry, 0); - ZEPHIR_INIT_VAR(&_132$$76); - ZVAL_STRING(&_132$$76, "dispatch:afterDispatchLoop"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_132$$76, this_ptr); - zephir_check_call_status_or_jump(try_end_11); + return SUCCESS; +} - try_end_11: +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File, __construct) +{ + zend_string *_6; + zend_ulong _5; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_9 = NULL, *_18 = NULL, *_27 = NULL, *_30 = NULL, *_33 = NULL, *_34 = NULL, *_35 = NULL, *_36 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *options_param = NULL, helper, included, key, message, messageFileEmpty, messageIniSize, messageValid, validator, value, *_3, _4, _0$$3, _1$$4, _2$$5, _7$$6, _8$$6, _10$$6, _11$$6, _12$$6, _13$$6, _14$$6, _15$$6, _16$$7, _19$$8, _21$$9, _23$$10, _25$$11, _28$$12, _31$$13, _37$$18, _38$$18, _39$$18, _40$$18, _41$$18, _42$$18, _43$$18, _44$$18, _45$$19, _47$$20, _49$$21, _51$$22, _53$$23, _55$$24, _57$$25; + zval options, _17$$7, _20$$8, _22$$9, _24$$10, _26$$11, _29$$12, _32$$13, _46$$19, _48$$20, _50$$21, _52$$22, _54$$23, _56$$24, _58$$25; + zval *this_ptr = getThis(); - if (EG(exception)) { - ZEPHIR_INIT_VAR(&_133$$75); - ZVAL_OBJ(&_133$$75, EG(exception)); - Z_ADDREF_P(&_133$$75); - if (zephir_is_instance_of(&_133$$75, SL("Exception"))) { - zend_clear_exception(); - ZEPHIR_CPY_WRT(&e, &_133$$75); - ZEPHIR_CALL_METHOD(&_134$$77, this_ptr, "handleexception", NULL, 0, &e); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_17$$7); + ZVAL_UNDEF(&_20$$8); + ZVAL_UNDEF(&_22$$9); + ZVAL_UNDEF(&_24$$10); + ZVAL_UNDEF(&_26$$11); + ZVAL_UNDEF(&_29$$12); + ZVAL_UNDEF(&_32$$13); + ZVAL_UNDEF(&_46$$19); + ZVAL_UNDEF(&_48$$20); + ZVAL_UNDEF(&_50$$21); + ZVAL_UNDEF(&_52$$22); + ZVAL_UNDEF(&_54$$23); + ZVAL_UNDEF(&_56$$24); + ZVAL_UNDEF(&_58$$25); + ZVAL_UNDEF(&helper); + ZVAL_UNDEF(&included); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&messageFileEmpty); + ZVAL_UNDEF(&messageIniSize); + ZVAL_UNDEF(&messageValid); + ZVAL_UNDEF(&validator); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&_10$$6); + ZVAL_UNDEF(&_11$$6); + ZVAL_UNDEF(&_12$$6); + ZVAL_UNDEF(&_13$$6); + ZVAL_UNDEF(&_14$$6); + ZVAL_UNDEF(&_15$$6); + ZVAL_UNDEF(&_16$$7); + ZVAL_UNDEF(&_19$$8); + ZVAL_UNDEF(&_21$$9); + ZVAL_UNDEF(&_23$$10); + ZVAL_UNDEF(&_25$$11); + ZVAL_UNDEF(&_28$$12); + ZVAL_UNDEF(&_31$$13); + ZVAL_UNDEF(&_37$$18); + ZVAL_UNDEF(&_38$$18); + ZVAL_UNDEF(&_39$$18); + ZVAL_UNDEF(&_40$$18); + ZVAL_UNDEF(&_41$$18); + ZVAL_UNDEF(&_42$$18); + ZVAL_UNDEF(&_43$$18); + ZVAL_UNDEF(&_44$$18); + ZVAL_UNDEF(&_45$$19); + ZVAL_UNDEF(&_47$$20); + ZVAL_UNDEF(&_49$$21); + ZVAL_UNDEF(&_51$$22); + ZVAL_UNDEF(&_53$$23); + ZVAL_UNDEF(&_55$$24); + ZVAL_UNDEF(&_57$$25); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + } + ZEPHIR_INIT_VAR(&included); + ZVAL_NULL(&included); + ZEPHIR_INIT_VAR(&message); + ZVAL_NULL(&message); + ZEPHIR_INIT_VAR(&messageFileEmpty); + ZVAL_NULL(&messageFileEmpty); + ZEPHIR_INIT_VAR(&messageIniSize); + ZVAL_NULL(&messageIniSize); + ZEPHIR_INIT_VAR(&messageValid); + ZVAL_NULL(&messageValid); + ZEPHIR_INIT_VAR(&helper); + object_init_ex(&helper, phalcon_support_helper_arr_get_ce); + if (zephir_has_constructor(&helper)) { + ZEPHIR_CALL_METHOD(NULL, &helper, "__construct", NULL, 0); + zephir_check_call_status(); + } + + if (zephir_array_isset_string(&options, SL("messageFileEmpty"))) { + ZEPHIR_INIT_VAR(&_0$$3); + ZVAL_STRING(&_0$$3, "messageFileEmpty"); + ZEPHIR_CALL_METHOD(&messageFileEmpty, &helper, "__invoke", NULL, 159, &options, &_0$$3); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("messageFileEmpty"), PH_SEPARATE); + } + if (zephir_array_isset_string(&options, SL("messageIniSize"))) { + ZEPHIR_INIT_VAR(&_1$$4); + ZVAL_STRING(&_1$$4, "messageIniSize"); + ZEPHIR_CALL_METHOD(&messageIniSize, &helper, "__invoke", NULL, 159, &options, &_1$$4); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("messageIniSize"), PH_SEPARATE); + } + if (zephir_array_isset_string(&options, SL("messageValid"))) { + ZEPHIR_INIT_VAR(&_2$$5); + ZVAL_STRING(&_2$$5, "messageValid"); + ZEPHIR_CALL_METHOD(&messageValid, &helper, "__invoke", NULL, 159, &options, &_2$$5); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("messageValid"), PH_SEPARATE); + } + zephir_is_iterable(&options, 1, "phalcon/Filter/Validation/Validator/File.zep", 283); + if (Z_TYPE_P(&options) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&options), _5, _6, _3) + { + ZEPHIR_INIT_NVAR(&key); + if (_6 != NULL) { + ZVAL_STR_COPY(&key, _6); + } else { + ZVAL_LONG(&key, _5); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _3); + ZEPHIR_INIT_NVAR(&_7$$6); + ZVAL_STRING(&_7$$6, "minSize"); + ZEPHIR_CALL_FUNCTION(&_8$$6, "strcasecmp", &_9, 39, &key, &_7$$6); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_7$$6); + ZVAL_STRING(&_7$$6, "maxSize"); + ZEPHIR_CALL_FUNCTION(&_10$$6, "strcasecmp", &_9, 39, &key, &_7$$6); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_7$$6); + ZVAL_STRING(&_7$$6, "equalSize"); + ZEPHIR_CALL_FUNCTION(&_11$$6, "strcasecmp", &_9, 39, &key, &_7$$6); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_7$$6); + ZVAL_STRING(&_7$$6, "allowedTypes"); + ZEPHIR_CALL_FUNCTION(&_12$$6, "strcasecmp", &_9, 39, &key, &_7$$6); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_7$$6); + ZVAL_STRING(&_7$$6, "maxResolution"); + ZEPHIR_CALL_FUNCTION(&_13$$6, "strcasecmp", &_9, 39, &key, &_7$$6); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_7$$6); + ZVAL_STRING(&_7$$6, "minResolution"); + ZEPHIR_CALL_FUNCTION(&_14$$6, "strcasecmp", &_9, 39, &key, &_7$$6); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_7$$6); + ZVAL_STRING(&_7$$6, "equalResolution"); + ZEPHIR_CALL_FUNCTION(&_15$$6, "strcasecmp", &_9, 39, &key, &_7$$6); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG_IDENTICAL(&_8$$6, 0)) { + ZEPHIR_INIT_NVAR(&_16$$7); + ZVAL_STRING(&_16$$7, "messageMinSize"); + ZEPHIR_CALL_METHOD(&message, &helper, "__invoke", NULL, 159, &options, &_16$$7); zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_134$$77)) { - RETURN_MM_BOOL(0); + ZEPHIR_INIT_NVAR(&_16$$7); + ZVAL_STRING(&_16$$7, "includedMinSize"); + ZEPHIR_CALL_METHOD(&included, &helper, "__invoke", NULL, 159, &options, &_16$$7); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&validator); + object_init_ex(&validator, phalcon_filter_validation_validator_file_size_min_ce); + ZEPHIR_INIT_NVAR(&_17$$7); + zephir_create_array(&_17$$7, 3, 0); + zephir_array_update_string(&_17$$7, SL("size"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_17$$7, SL("message"), &message, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_17$$7, SL("included"), &included, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &validator, "__construct", &_18, 301, &_17$$7); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("messageMinSize"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("includedMinSize"), PH_SEPARATE); + } else if (ZEPHIR_IS_LONG_IDENTICAL(&_10$$6, 0)) { + ZEPHIR_INIT_NVAR(&_19$$8); + ZVAL_STRING(&_19$$8, "messageSize"); + ZEPHIR_CALL_METHOD(&message, &helper, "__invoke", NULL, 159, &options, &_19$$8); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_19$$8); + ZVAL_STRING(&_19$$8, "includedSize"); + ZEPHIR_CALL_METHOD(&included, &helper, "__invoke", NULL, 159, &options, &_19$$8); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&validator); + object_init_ex(&validator, phalcon_filter_validation_validator_file_size_max_ce); + ZEPHIR_INIT_NVAR(&_20$$8); + zephir_create_array(&_20$$8, 3, 0); + zephir_array_update_string(&_20$$8, SL("size"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_20$$8, SL("message"), &message, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_20$$8, SL("included"), &included, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &validator, "__construct", &_18, 301, &_20$$8); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("maxSize"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("messageSize"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("includedSize"), PH_SEPARATE); + } else if (ZEPHIR_IS_LONG_IDENTICAL(&_11$$6, 0)) { + ZEPHIR_INIT_NVAR(&_21$$9); + ZVAL_STRING(&_21$$9, "messageEqualSize"); + ZEPHIR_CALL_METHOD(&message, &helper, "__invoke", NULL, 159, &options, &_21$$9); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&validator); + object_init_ex(&validator, phalcon_filter_validation_validator_file_size_equal_ce); + ZEPHIR_INIT_NVAR(&_22$$9); + zephir_create_array(&_22$$9, 2, 0); + zephir_array_update_string(&_22$$9, SL("size"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_22$$9, SL("message"), &message, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &validator, "__construct", &_18, 301, &_22$$9); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("equalSize"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("messageEqualSize"), PH_SEPARATE); + } else if (ZEPHIR_IS_LONG_IDENTICAL(&_12$$6, 0)) { + ZEPHIR_INIT_NVAR(&_23$$10); + ZVAL_STRING(&_23$$10, "messageType"); + ZEPHIR_CALL_METHOD(&message, &helper, "__invoke", NULL, 159, &options, &_23$$10); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&validator); + object_init_ex(&validator, phalcon_filter_validation_validator_file_mimetype_ce); + ZEPHIR_INIT_NVAR(&_24$$10); + zephir_create_array(&_24$$10, 2, 0); + zephir_array_update_string(&_24$$10, SL("types"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_24$$10, SL("message"), &message, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &validator, "__construct", &_18, 301, &_24$$10); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("allowedTypes"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("messageType"), PH_SEPARATE); + } else if (ZEPHIR_IS_LONG_IDENTICAL(&_13$$6, 0)) { + ZEPHIR_INIT_NVAR(&_25$$11); + ZVAL_STRING(&_25$$11, "messageMaxResolution"); + ZEPHIR_CALL_METHOD(&message, &helper, "__invoke", NULL, 159, &options, &_25$$11); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_25$$11); + ZVAL_STRING(&_25$$11, "includedMaxResolution"); + ZEPHIR_CALL_METHOD(&included, &helper, "__invoke", NULL, 159, &options, &_25$$11); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&validator); + object_init_ex(&validator, phalcon_filter_validation_validator_file_resolution_max_ce); + ZEPHIR_INIT_NVAR(&_26$$11); + zephir_create_array(&_26$$11, 3, 0); + zephir_array_update_string(&_26$$11, SL("resolution"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_26$$11, SL("included"), &included, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_26$$11, SL("message"), &message, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &validator, "__construct", &_27, 302, &_26$$11); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("maxResolution"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("includedMaxResolution"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("messageMaxResolution"), PH_SEPARATE); + } else if (ZEPHIR_IS_LONG_IDENTICAL(&_14$$6, 0)) { + ZEPHIR_INIT_NVAR(&_28$$12); + ZVAL_STRING(&_28$$12, "messageMinResolution"); + ZEPHIR_CALL_METHOD(&message, &helper, "__invoke", NULL, 159, &options, &_28$$12); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_28$$12); + ZVAL_STRING(&_28$$12, "includedMinResolution"); + ZEPHIR_CALL_METHOD(&included, &helper, "__invoke", NULL, 159, &options, &_28$$12); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&validator); + object_init_ex(&validator, phalcon_filter_validation_validator_file_resolution_min_ce); + ZEPHIR_INIT_NVAR(&_29$$12); + zephir_create_array(&_29$$12, 3, 0); + zephir_array_update_string(&_29$$12, SL("resolution"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_29$$12, SL("included"), &included, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_29$$12, SL("message"), &message, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &validator, "__construct", &_30, 303, &_29$$12); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("minResolution"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("includedMinResolution"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("messageMinResolution"), PH_SEPARATE); + } else if (ZEPHIR_IS_LONG_IDENTICAL(&_15$$6, 0)) { + ZEPHIR_INIT_NVAR(&_31$$13); + ZVAL_STRING(&_31$$13, "messageEqualResolution"); + ZEPHIR_CALL_METHOD(&message, &helper, "__invoke", NULL, 159, &options, &_31$$13); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&validator); + object_init_ex(&validator, phalcon_filter_validation_validator_file_resolution_equal_ce); + ZEPHIR_INIT_NVAR(&_32$$13); + zephir_create_array(&_32$$13, 2, 0); + zephir_array_update_string(&_32$$13, SL("resolution"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_32$$13, SL("message"), &message, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &validator, "__construct", &_33, 304, &_32$$13); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("equalResolution"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("messageEqualResolution"), PH_SEPARATE); + } else { + continue; + } + if (Z_TYPE_P(&messageFileEmpty) != IS_NULL) { + ZEPHIR_CALL_METHOD(NULL, &validator, "setmessagefileempty", &_34, 305, &messageFileEmpty); + zephir_check_call_status(); + } + if (Z_TYPE_P(&messageIniSize) != IS_NULL) { + ZEPHIR_CALL_METHOD(NULL, &validator, "setmessageinisize", &_35, 306, &messageIniSize); + zephir_check_call_status(); + } + if (Z_TYPE_P(&messageValid) != IS_NULL) { + ZEPHIR_CALL_METHOD(NULL, &validator, "setmessagevalid", &_36, 307, &messageValid); + zephir_check_call_status(); + } + zephir_update_property_array_append(this_ptr, SL("validators"), &validator); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &options, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_4, &options, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_4)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &options, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &options, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_37$$18); + ZVAL_STRING(&_37$$18, "minSize"); + ZEPHIR_CALL_FUNCTION(&_38$$18, "strcasecmp", &_9, 39, &key, &_37$$18); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_37$$18); + ZVAL_STRING(&_37$$18, "maxSize"); + ZEPHIR_CALL_FUNCTION(&_39$$18, "strcasecmp", &_9, 39, &key, &_37$$18); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_37$$18); + ZVAL_STRING(&_37$$18, "equalSize"); + ZEPHIR_CALL_FUNCTION(&_40$$18, "strcasecmp", &_9, 39, &key, &_37$$18); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_37$$18); + ZVAL_STRING(&_37$$18, "allowedTypes"); + ZEPHIR_CALL_FUNCTION(&_41$$18, "strcasecmp", &_9, 39, &key, &_37$$18); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_37$$18); + ZVAL_STRING(&_37$$18, "maxResolution"); + ZEPHIR_CALL_FUNCTION(&_42$$18, "strcasecmp", &_9, 39, &key, &_37$$18); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_37$$18); + ZVAL_STRING(&_37$$18, "minResolution"); + ZEPHIR_CALL_FUNCTION(&_43$$18, "strcasecmp", &_9, 39, &key, &_37$$18); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_37$$18); + ZVAL_STRING(&_37$$18, "equalResolution"); + ZEPHIR_CALL_FUNCTION(&_44$$18, "strcasecmp", &_9, 39, &key, &_37$$18); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG_IDENTICAL(&_38$$18, 0)) { + ZEPHIR_INIT_NVAR(&_45$$19); + ZVAL_STRING(&_45$$19, "messageMinSize"); + ZEPHIR_CALL_METHOD(&message, &helper, "__invoke", NULL, 159, &options, &_45$$19); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_45$$19); + ZVAL_STRING(&_45$$19, "includedMinSize"); + ZEPHIR_CALL_METHOD(&included, &helper, "__invoke", NULL, 159, &options, &_45$$19); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&validator); + object_init_ex(&validator, phalcon_filter_validation_validator_file_size_min_ce); + ZEPHIR_INIT_NVAR(&_46$$19); + zephir_create_array(&_46$$19, 3, 0); + zephir_array_update_string(&_46$$19, SL("size"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_46$$19, SL("message"), &message, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_46$$19, SL("included"), &included, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &validator, "__construct", &_33, 304, &_46$$19); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("messageMinSize"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("includedMinSize"), PH_SEPARATE); + } else if (ZEPHIR_IS_LONG_IDENTICAL(&_39$$18, 0)) { + ZEPHIR_INIT_NVAR(&_47$$20); + ZVAL_STRING(&_47$$20, "messageSize"); + ZEPHIR_CALL_METHOD(&message, &helper, "__invoke", NULL, 159, &options, &_47$$20); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_47$$20); + ZVAL_STRING(&_47$$20, "includedSize"); + ZEPHIR_CALL_METHOD(&included, &helper, "__invoke", NULL, 159, &options, &_47$$20); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&validator); + object_init_ex(&validator, phalcon_filter_validation_validator_file_size_max_ce); + ZEPHIR_INIT_NVAR(&_48$$20); + zephir_create_array(&_48$$20, 3, 0); + zephir_array_update_string(&_48$$20, SL("size"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_48$$20, SL("message"), &message, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_48$$20, SL("included"), &included, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &validator, "__construct", &_33, 304, &_48$$20); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("maxSize"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("messageSize"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("includedSize"), PH_SEPARATE); + } else if (ZEPHIR_IS_LONG_IDENTICAL(&_40$$18, 0)) { + ZEPHIR_INIT_NVAR(&_49$$21); + ZVAL_STRING(&_49$$21, "messageEqualSize"); + ZEPHIR_CALL_METHOD(&message, &helper, "__invoke", NULL, 159, &options, &_49$$21); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&validator); + object_init_ex(&validator, phalcon_filter_validation_validator_file_size_equal_ce); + ZEPHIR_INIT_NVAR(&_50$$21); + zephir_create_array(&_50$$21, 2, 0); + zephir_array_update_string(&_50$$21, SL("size"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_50$$21, SL("message"), &message, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &validator, "__construct", &_33, 304, &_50$$21); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("equalSize"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("messageEqualSize"), PH_SEPARATE); + } else if (ZEPHIR_IS_LONG_IDENTICAL(&_41$$18, 0)) { + ZEPHIR_INIT_NVAR(&_51$$22); + ZVAL_STRING(&_51$$22, "messageType"); + ZEPHIR_CALL_METHOD(&message, &helper, "__invoke", NULL, 159, &options, &_51$$22); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&validator); + object_init_ex(&validator, phalcon_filter_validation_validator_file_mimetype_ce); + ZEPHIR_INIT_NVAR(&_52$$22); + zephir_create_array(&_52$$22, 2, 0); + zephir_array_update_string(&_52$$22, SL("types"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_52$$22, SL("message"), &message, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &validator, "__construct", &_33, 304, &_52$$22); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("allowedTypes"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("messageType"), PH_SEPARATE); + } else if (ZEPHIR_IS_LONG_IDENTICAL(&_42$$18, 0)) { + ZEPHIR_INIT_NVAR(&_53$$23); + ZVAL_STRING(&_53$$23, "messageMaxResolution"); + ZEPHIR_CALL_METHOD(&message, &helper, "__invoke", NULL, 159, &options, &_53$$23); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_53$$23); + ZVAL_STRING(&_53$$23, "includedMaxResolution"); + ZEPHIR_CALL_METHOD(&included, &helper, "__invoke", NULL, 159, &options, &_53$$23); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&validator); + object_init_ex(&validator, phalcon_filter_validation_validator_file_resolution_max_ce); + ZEPHIR_INIT_NVAR(&_54$$23); + zephir_create_array(&_54$$23, 3, 0); + zephir_array_update_string(&_54$$23, SL("resolution"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_54$$23, SL("included"), &included, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_54$$23, SL("message"), &message, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &validator, "__construct", &_33, 304, &_54$$23); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("maxResolution"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("includedMaxResolution"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("messageMaxResolution"), PH_SEPARATE); + } else if (ZEPHIR_IS_LONG_IDENTICAL(&_43$$18, 0)) { + ZEPHIR_INIT_NVAR(&_55$$24); + ZVAL_STRING(&_55$$24, "messageMinResolution"); + ZEPHIR_CALL_METHOD(&message, &helper, "__invoke", NULL, 159, &options, &_55$$24); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_55$$24); + ZVAL_STRING(&_55$$24, "includedMinResolution"); + ZEPHIR_CALL_METHOD(&included, &helper, "__invoke", NULL, 159, &options, &_55$$24); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&validator); + object_init_ex(&validator, phalcon_filter_validation_validator_file_resolution_min_ce); + ZEPHIR_INIT_NVAR(&_56$$24); + zephir_create_array(&_56$$24, 3, 0); + zephir_array_update_string(&_56$$24, SL("resolution"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_56$$24, SL("included"), &included, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_56$$24, SL("message"), &message, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &validator, "__construct", &_33, 304, &_56$$24); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("minResolution"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("includedMinResolution"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("messageMinResolution"), PH_SEPARATE); + } else if (ZEPHIR_IS_LONG_IDENTICAL(&_44$$18, 0)) { + ZEPHIR_INIT_NVAR(&_57$$25); + ZVAL_STRING(&_57$$25, "messageEqualResolution"); + ZEPHIR_CALL_METHOD(&message, &helper, "__invoke", NULL, 159, &options, &_57$$25); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&validator); + object_init_ex(&validator, phalcon_filter_validation_validator_file_resolution_equal_ce); + ZEPHIR_INIT_NVAR(&_58$$25); + zephir_create_array(&_58$$25, 2, 0); + zephir_array_update_string(&_58$$25, SL("resolution"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_58$$25, SL("message"), &message, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &validator, "__construct", &_33, 304, &_58$$25); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("equalResolution"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("messageEqualResolution"), PH_SEPARATE); + } else { + continue; + } + if (Z_TYPE_P(&messageFileEmpty) != IS_NULL) { + ZEPHIR_CALL_METHOD(NULL, &validator, "setmessagefileempty", &_34, 305, &messageFileEmpty); + zephir_check_call_status(); + } + if (Z_TYPE_P(&messageIniSize) != IS_NULL) { + ZEPHIR_CALL_METHOD(NULL, &validator, "setmessageinisize", &_35, 306, &messageIniSize); + zephir_check_call_status(); + } + if (Z_TYPE_P(&messageValid) != IS_NULL) { + ZEPHIR_CALL_METHOD(NULL, &validator, "setmessagevalid", &_36, 307, &messageValid); + zephir_check_call_status(); } - zephir_throw_exception_debug(&e, "phalcon/Dispatcher/AbstractDispatcher.zep", 627); - ZEPHIR_MM_RESTORE(); - return; - } + zephir_update_property_array_append(this_ptr, SL("validators"), &validator); + ZEPHIR_CALL_METHOD(NULL, &options, "next", NULL, 0); + zephir_check_call_status(); } } - RETURN_CCTOR(&handler); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_file_ce, getThis(), "__construct", NULL, 0, &options); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, forward) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *forward_param = NULL, __$true, __$false, namespaceName, controllerName, params, actionName, taskName, _0, _1, _2, _3; - zval forward; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&forward); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&namespaceName); - ZVAL_UNDEF(&controllerName); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&actionName); - ZVAL_UNDEF(&taskName); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(forward) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &forward_param); - zephir_get_arrval(&forward, forward_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("isControllerInitialize"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(ZEPHIR_IS_TRUE_IDENTICAL(&_0))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_dispatcher_exception_ce, "Forwarding inside a controller's initialize() method is forbidden", "phalcon/Dispatcher/AbstractDispatcher.zep", 661); - return; - } - zephir_read_property(&_1, this_ptr, ZEND_STRL("namespaceName"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("previousNamespaceName"), &_1); - zephir_read_property(&_2, this_ptr, ZEND_STRL("handlerName"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("previousHandlerName"), &_2); - zephir_read_property(&_3, this_ptr, ZEND_STRL("actionName"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("previousActionName"), &_3); - if (zephir_array_isset_string_fetch(&namespaceName, &forward, SL("namespace"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("namespaceName"), &namespaceName); - } - zephir_memory_observe(&taskName); - if (zephir_array_isset_string_fetch(&controllerName, &forward, SL("controller"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("handlerName"), &controllerName); - } else if (zephir_array_isset_string_fetch(&taskName, &forward, SL("task"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("handlerName"), &taskName); - } - if (zephir_array_isset_string_fetch(&actionName, &forward, SL("action"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("actionName"), &actionName); - } - if (zephir_array_isset_string_fetch(¶ms, &forward, SL("params"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("params"), ¶ms); - } - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("finished"), &__$false); - } - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("forwarded"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("forwarded"), &__$false); - } - ZEPHIR_MM_RESTORE(); -} -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getActionName) -{ - RETURN_MEMBER(getThis(), "actionName"); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getActionSuffix) + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_Identical) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, Identical, phalcon, filter_validation_validator_identical, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_identical_method_entry, 0); - RETURN_MEMBER(getThis(), "actionSuffix"); + zend_declare_property_string(phalcon_filter_validation_validator_identical_ce, SL("template"), "Field :field does not have the expected value", ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getActiveMethod) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Identical, __construct) { - zval activeMethodName, _0, _1, _5, _2$$3, _3$$3, _4$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + zval *options_param = NULL; + zval options; - ZVAL_UNDEF(&activeMethodName); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_memory_observe(&activeMethodName); - zephir_read_property(&_0, this_ptr, ZEND_STRL("activeMethodMap"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_1, this_ptr, ZEND_STRL("actionName"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&activeMethodName, &_0, &_1, 0))) { - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("actionName"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "tocamelcase", NULL, 0, &_3$$3); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&activeMethodName, "lcfirst", NULL, 76, &_2$$3); - zephir_check_call_status(); - zephir_memory_observe(&_4$$3); - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("actionName"), PH_NOISY_CC); - zephir_update_property_array(this_ptr, SL("activeMethodMap"), &_4$$3, &activeMethodName); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - zephir_read_property(&_5, this_ptr, ZEND_STRL("actionSuffix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CONCAT_VV(return_value, &activeMethodName, &_5); - RETURN_MM(); + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_identical_ce, getThis(), "__construct", NULL, 0, &options); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getBoundModels) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Identical, validate) { - zval _0, _1; + zend_bool valid = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *validation, validation_sub, *field, field_sub, value, accepted, _0, _1, _2, _3, _4$$4, _5$$5, _6$$7, _7$$8; zval *this_ptr = getThis(); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&accepted); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_7$$8); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("modelBinder"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - array_init(return_value); - RETURN_MM(); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "allowempty", NULL, 0, field, &value); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + RETURN_MM_BOOL(1); } - zephir_read_property(&_1, this_ptr, ZEND_STRL("modelBinder"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_1, "getboundmodels", NULL, 0); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "accepted"); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "hasoption", NULL, 0, &_2); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getDefaultNamespace) -{ - - RETURN_MEMBER(getThis(), "defaultNamespace"); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "value"); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "hasoption", NULL, 0, &_2); + zephir_check_call_status(); + if (zephir_is_true(&_1)) { + ZEPHIR_INIT_VAR(&_4$$4); + ZVAL_STRING(&_4$$4, "accepted"); + ZEPHIR_CALL_METHOD(&accepted, this_ptr, "getoption", NULL, 0, &_4$$4); + zephir_check_call_status(); + } else if (zephir_is_true(&_3)) { + ZEPHIR_INIT_VAR(&_5$$5); + ZVAL_STRING(&_5$$5, "value"); + ZEPHIR_CALL_METHOD(&accepted, this_ptr, "getoption", NULL, 0, &_5$$5); + zephir_check_call_status(); + } + if (zephir_is_true(&accepted)) { + if (Z_TYPE_P(&accepted) == IS_ARRAY) { + zephir_array_fetch(&_6$$7, &accepted, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/Identical.zep", 97); + ZEPHIR_CPY_WRT(&accepted, &_6$$7); + } + valid = ZEPHIR_IS_EQUAL(&value, &accepted); + } + if (!(valid)) { + ZEPHIR_CALL_METHOD(&_7$$8, this_ptr, "messagefactory", NULL, 0, validation, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_7$$8); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getEventsManager) -{ - RETURN_MEMBER(getThis(), "eventsManager"); -} -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getHandlerSuffix) -{ - RETURN_MEMBER(getThis(), "handlerSuffix"); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getModelBinder) -{ - RETURN_MEMBER(getThis(), "modelBinder"); -} -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getModuleName) -{ - RETURN_MEMBER(getThis(), "moduleName"); -} -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getNamespaceName) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_InclusionIn) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, InclusionIn, phalcon, filter_validation_validator_inclusionin, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_inclusionin_method_entry, 0); - RETURN_MEMBER(getThis(), "namespaceName"); + zend_declare_property_string(phalcon_filter_validation_validator_inclusionin_ce, SL("template"), "Field :field must be a part of list: :domain", ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getParam) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_InclusionIn, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *param, param_sub, *filters = NULL, filters_sub, *defaultValue = NULL, defaultValue_sub, __$null; - zval *this_ptr = getThis(); + zval *options_param = NULL; + zval options; - ZVAL_UNDEF(¶m_sub); - ZVAL_UNDEF(&filters_sub); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ZVAL(param) + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(filters) - Z_PARAM_ZVAL_OR_NULL(defaultValue) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, ¶m, &filters, &defaultValue); - if (!filters) { - filters = &filters_sub; - filters = &__$null; - } - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getparameter", NULL, 0, param, filters, defaultValue); + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_inclusionin_ce, getThis(), "__construct", NULL, 0, &options); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getParameter) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_InclusionIn, validate) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *param, param_sub, *filters = NULL, filters_sub, *defaultValue = NULL, defaultValue_sub, __$null, params, filter, paramValue, _0, _3, _4, _5, _1$$5, _2$$5; + zval *validation, validation_sub, *field, field_sub, value, domain, replacePairs, strict, fieldDomain, _0, _1, _2, _5, _3$$7, _4$$8, _6$$10, _7$$10; zval *this_ptr = getThis(); - ZVAL_UNDEF(¶m_sub); - ZVAL_UNDEF(&filters_sub); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&filter); - ZVAL_UNDEF(¶mValue); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&domain); + ZVAL_UNDEF(&replacePairs); + ZVAL_UNDEF(&strict); + ZVAL_UNDEF(&fieldDomain); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_1$$5); - ZVAL_UNDEF(&_2$$5); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ZVAL(param) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(filters) - Z_PARAM_ZVAL_OR_NULL(defaultValue) + ZVAL_UNDEF(&_3$$7); + ZVAL_UNDEF(&_4$$8); + ZVAL_UNDEF(&_6$$10); + ZVAL_UNDEF(&_7$$10); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, ¶m, &filters, &defaultValue); - if (!filters) { - filters = &filters_sub; - filters = &__$null; - } - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "allowempty", NULL, 0, field, &value); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + RETURN_MM_BOOL(1); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(¶ms, &_0); - zephir_memory_observe(¶mValue); - if (!(zephir_array_isset_fetch(¶mValue, ¶ms, param, 0))) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "domain"); + ZEPHIR_CALL_METHOD(&domain, this_ptr, "getoption", NULL, 0, &_1); + zephir_check_call_status(); + zephir_memory_observe(&fieldDomain); + if (zephir_array_isset_fetch(&fieldDomain, &domain, field, 0)) { + if (Z_TYPE_P(&fieldDomain) == IS_ARRAY) { + ZEPHIR_CPY_WRT(&domain, &fieldDomain); + } } - if (Z_TYPE_P(filters) == IS_NULL) { - RETURN_CCTOR(¶mValue); + if (UNEXPECTED(Z_TYPE_P(&domain) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "Option 'domain' must be an array", "phalcon/Filter/Validation/Validator/InclusionIn.zep", 101); + return; } - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$5); - ZVAL_STRING(&_1$$5, "A dependency injection container is required to access the 'filter' service"); - ZVAL_LONG(&_2$$5, 0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwdispatchexception", NULL, 0, &_1$$5, &_2$$5); + ZEPHIR_INIT_VAR(&strict); + ZVAL_BOOL(&strict, 0); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "strict"); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "hasoption", NULL, 0, &_1); + zephir_check_call_status(); + if (zephir_is_true(&_2)) { + ZEPHIR_INIT_VAR(&_3$$7); + ZVAL_STRING(&_3$$7, "strict"); + ZEPHIR_CALL_METHOD(&strict, this_ptr, "getoption", NULL, 0, &_3$$7); zephir_check_call_status(); + if (Z_TYPE_P(&strict) == IS_ARRAY) { + zephir_array_fetch(&_4$$8, &strict, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/InclusionIn.zep", 110); + ZEPHIR_CPY_WRT(&strict, &_4$$8); + } + if (UNEXPECTED(((Z_TYPE_P(&strict) == IS_TRUE || Z_TYPE_P(&strict) == IS_FALSE) != 1))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "Option 'strict' must be a bool", "phalcon/Filter/Validation/Validator/InclusionIn.zep", 114); + return; + } } - zephir_read_property(&_3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_5); - ZVAL_STRING(&_5, "filter"); - ZEPHIR_CALL_METHOD(&_4, &_3, "getshared", NULL, 0, &_5); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&filter, &_4); - ZEPHIR_RETURN_CALL_METHOD(&filter, "sanitize", NULL, 0, ¶mValue, filters); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getParams) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getparameters", NULL, 0); + ZEPHIR_CALL_FUNCTION(&_5, "in_array", NULL, 300, &value, &domain, &strict); zephir_check_call_status(); - RETURN_MM(); + if (!(zephir_is_true(&_5))) { + ZEPHIR_INIT_VAR(&replacePairs); + zephir_create_array(&replacePairs, 1, 0); + ZEPHIR_INIT_VAR(&_6$$10); + zephir_fast_join_str(&_6$$10, SL(", "), &domain); + zephir_array_update_string(&replacePairs, SL(":domain"), &_6$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_7$$10, this_ptr, "messagefactory", NULL, 0, validation, field, &replacePairs); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_7$$10); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getParameters) -{ - RETURN_MEMBER(getThis(), "params"); -} -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, hasParam) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *param, param_sub; - zval *this_ptr = getThis(); - ZVAL_UNDEF(¶m_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(param) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, ¶m); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "hasparameter", NULL, 0, param); - zephir_check_call_status(); - RETURN_MM(); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, hasParameter) -{ - zval *param, param_sub, _0; - zval *this_ptr = getThis(); - ZVAL_UNDEF(¶m_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(param) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, ¶m); - zephir_read_property(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - RETURN_BOOL(zephir_array_isset(&_0, param)); -} -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, isFinished) -{ - RETURN_MEMBER(getThis(), "finished"); -} -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setActionName) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_Ip) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *actionName_param = NULL; - zval actionName; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, Ip, phalcon, filter_validation_validator_ip, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_ip_method_entry, 0); - ZVAL_UNDEF(&actionName); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(actionName) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &actionName_param); - zephir_get_strval(&actionName, actionName_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("actionName"), &actionName); - ZEPHIR_MM_RESTORE(); -} + zend_declare_property_string(phalcon_filter_validation_validator_ip_ce, SL("template"), "Field :field must be a valid IP address", ZEND_ACC_PROTECTED); + zephir_declare_class_constant_long(phalcon_filter_validation_validator_ip_ce, SL("VERSION_4"), 1048576); -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setDefaultAction) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *actionName_param = NULL; - zval actionName; - zval *this_ptr = getThis(); + zephir_declare_class_constant_long(phalcon_filter_validation_validator_ip_ce, SL("VERSION_6"), 2097152); - ZVAL_UNDEF(&actionName); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(actionName) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &actionName_param); - zephir_get_strval(&actionName, actionName_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultAction"), &actionName); - ZEPHIR_MM_RESTORE(); + return SUCCESS; } -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setDefaultNamespace) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Ip, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *defaultNamespace_param = NULL; - zval defaultNamespace; - zval *this_ptr = getThis(); + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *options_param = NULL; + zval options; - ZVAL_UNDEF(&defaultNamespace); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(defaultNamespace) + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &defaultNamespace_param); - zephir_get_strval(&defaultNamespace, defaultNamespace_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultNamespace"), &defaultNamespace); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + } + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_ip_ce, getThis(), "__construct", NULL, 0, &options); + zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getHandlerClass) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Ip, validate) { - zval handlerSuffix, handlerName, namespaceName, camelizedClass, handlerClass, _0; + zval _8; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *validation, validation_sub, *field, field_sub, __$false, value, version, allowPrivate, allowReserved, options, _0, _1, _2, _4, _6, _9, _10, _11, _3$$4, _5$$5, _7$$6, _12$$7; zval *this_ptr = getThis(); - ZVAL_UNDEF(&handlerSuffix); - ZVAL_UNDEF(&handlerName); - ZVAL_UNDEF(&namespaceName); - ZVAL_UNDEF(&camelizedClass); - ZVAL_UNDEF(&handlerClass); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&version); + ZVAL_UNDEF(&allowPrivate); + ZVAL_UNDEF(&allowReserved); + ZVAL_UNDEF(&options); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_12$$7); + ZVAL_UNDEF(&_8); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(NULL, this_ptr, "resolveemptyproperties", NULL, 0); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("handlerSuffix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&handlerSuffix, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("handlerName"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&handlerName, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("namespaceName"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&namespaceName, &_0); - if (!(zephir_memnstr_str(&handlerName, SL("\\"), "phalcon/Dispatcher/AbstractDispatcher.zep", 938))) { - ZEPHIR_CALL_METHOD(&camelizedClass, this_ptr, "tocamelcase", NULL, 0, &handlerName); - zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&camelizedClass, &handlerName); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "allowempty", NULL, 0, field, &value); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + RETURN_MM_BOOL(1); } - ZEPHIR_INIT_VAR(&handlerClass); - if (zephir_is_true(&namespaceName)) { - if (!(zephir_end_with_str(&namespaceName, SL("\\")))) { - zephir_concat_self_str(&namespaceName, SL("\\")); - } - ZEPHIR_CONCAT_VVV(&handlerClass, &namespaceName, &camelizedClass, &handlerSuffix); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "version"); + ZVAL_LONG(&_2, (1048576 | 2097152)); + ZEPHIR_CALL_METHOD(&version, this_ptr, "getoption", NULL, 0, &_1, &_2); + zephir_check_call_status(); + if (Z_TYPE_P(&version) == IS_ARRAY) { + zephir_array_fetch(&_3$$4, &version, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/Ip.zep", 105); + ZEPHIR_CPY_WRT(&version, &_3$$4); + } + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "allowPrivate"); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "getoption", NULL, 0, &_1); + zephir_check_call_status(); + if (zephir_is_true(&_4)) { + ZEPHIR_INIT_VAR(&allowPrivate); + ZVAL_LONG(&allowPrivate, 0); } else { - ZEPHIR_CONCAT_VV(&handlerClass, &camelizedClass, &handlerSuffix); + ZEPHIR_INIT_NVAR(&allowPrivate); + ZVAL_LONG(&allowPrivate, 8388608); } - RETURN_CCTOR(&handlerClass); -} - -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setParam) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *param, param_sub, *value, value_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(¶m_sub); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(param) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, ¶m, &value); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setparameter", NULL, 0, param, value); + if (Z_TYPE_P(&allowPrivate) == IS_ARRAY) { + zephir_array_fetch(&_5$$5, &allowPrivate, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/Ip.zep", 110); + ZEPHIR_CPY_WRT(&allowPrivate, &_5$$5); + } + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "allowReserved"); + ZEPHIR_CALL_METHOD(&_6, this_ptr, "getoption", NULL, 0, &_1); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setParameter) -{ - zval *param, param_sub, *value, value_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(¶m_sub); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(param) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(2, 0, ¶m, &value); - zephir_update_property_array(this_ptr, SL("params"), param, value); -} - -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setParams) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *params_param = NULL; - zval params; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(¶ms); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(params) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, ¶ms_param); - zephir_get_arrval(¶ms, params_param); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setparameters", NULL, 0, ¶ms); + if (zephir_is_true(&_6)) { + ZEPHIR_INIT_VAR(&allowReserved); + ZVAL_LONG(&allowReserved, 0); + } else { + ZEPHIR_INIT_NVAR(&allowReserved); + ZVAL_LONG(&allowReserved, 4194304); + } + if (Z_TYPE_P(&allowReserved) == IS_ARRAY) { + zephir_array_fetch(&_7$$6, &allowReserved, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/Ip.zep", 115); + ZEPHIR_CPY_WRT(&allowReserved, &_7$$6); + } + ZEPHIR_INIT_VAR(&options); + zephir_create_array(&options, 2, 0); + ZEPHIR_INIT_VAR(&_8); + zephir_create_array(&_8, 1, 0); + zephir_array_update_string(&_8, SL("default"), &__$false, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&options, SL("options"), &_8, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_9); + zephir_bitwise_or_function(&_9, &version, &allowPrivate); + ZEPHIR_INIT_VAR(&_10); + zephir_bitwise_or_function(&_10, &_9, &allowReserved); + zephir_array_update_string(&options, SL("flags"), &_10, PH_COPY | PH_SEPARATE); + ZVAL_LONG(&_2, 275); + ZEPHIR_CALL_FUNCTION(&_11, "filter_var", NULL, 283, &value, &_2, &options); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + if (!(zephir_is_true(&_11))) { + ZEPHIR_CALL_METHOD(&_12$$7, this_ptr, "messagefactory", NULL, 0, validation, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_12$$7); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setParameters) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *params_param = NULL; - zval params; - zval *this_ptr = getThis(); - ZVAL_UNDEF(¶ms); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(params) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, ¶ms_param); - zephir_get_arrval(¶ms, params_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("params"), ¶ms); - ZEPHIR_MM_RESTORE(); -} -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setReturnedValue) -{ - zval *value, value_sub; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &value); - zephir_update_property_zval(this_ptr, ZEND_STRL("returnedValue"), value); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setActionSuffix) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *actionSuffix_param = NULL; - zval actionSuffix; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&actionSuffix); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(actionSuffix) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &actionSuffix_param); - zephir_get_strval(&actionSuffix, actionSuffix_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("actionSuffix"), &actionSuffix); - ZEPHIR_MM_RESTORE(); -} -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setEventsManager) -{ - zval *eventsManager, eventsManager_sub; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&eventsManager_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); - zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); -} -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setHandlerSuffix) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_Numericality) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *handlerSuffix_param = NULL; - zval handlerSuffix; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, Numericality, phalcon, filter_validation_validator_numericality, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_numericality_method_entry, 0); - ZVAL_UNDEF(&handlerSuffix); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(handlerSuffix) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &handlerSuffix_param); - zephir_get_strval(&handlerSuffix, handlerSuffix_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("handlerSuffix"), &handlerSuffix); - ZEPHIR_MM_RESTORE(); + zend_declare_property_string(phalcon_filter_validation_validator_numericality_ce, SL("template"), "Field :field does not have a valid numeric format", ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setModelBinder) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Numericality, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *modelBinder, modelBinder_sub, *cache = NULL, cache_sub, __$true, __$false, __$null, container, _0$$3, _1$$3; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&modelBinder_sub); - ZVAL_UNDEF(&cache_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(modelBinder, phalcon_mvc_model_binderinterface_ce) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(cache) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &modelBinder, &cache); - if (!cache) { - cache = &cache_sub; - ZEPHIR_CPY_WRT(cache, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(cache); - } - if (Z_TYPE_P(cache) == IS_STRING) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0$$3); - ZEPHIR_CALL_METHOD(&_1$$3, &container, "get", NULL, 0, cache); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(cache, &_1$$3); - } - if (Z_TYPE_P(cache) != IS_NULL) { - ZEPHIR_CALL_METHOD(NULL, modelBinder, "setcache", NULL, 0, cache); - zephir_check_call_status(); - } - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("modelBinding"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("modelBinding"), &__$false); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("modelBinder"), modelBinder); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setModuleName) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *moduleName_param = NULL; - zval moduleName; - zval *this_ptr = getThis(); + zval *options_param = NULL; + zval options; - ZVAL_UNDEF(&moduleName); - bool is_null_true = 1; + ZVAL_UNDEF(&options); ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(moduleName) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &moduleName_param); - if (!moduleName_param) { - ZEPHIR_INIT_VAR(&moduleName); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - zephir_get_strval(&moduleName, moduleName_param); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - zephir_update_property_zval(this_ptr, ZEND_STRL("moduleName"), &moduleName); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, setNamespaceName) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *namespaceName_param = NULL; - zval namespaceName; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&namespaceName); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(namespaceName) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &namespaceName_param); - zephir_get_strval(&namespaceName, namespaceName_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("namespaceName"), &namespaceName); + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_numericality_ce, getThis(), "__construct", NULL, 0, &options); + zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, getReturnedValue) -{ - - RETURN_MEMBER(getThis(), "returnedValue"); -} - -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, wasForwarded) -{ - - RETURN_MEMBER(getThis(), "forwarded"); -} - -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, resolveEmptyProperties) -{ - zval _0, _2, _4, _1$$3, _3$$4, _5$$5; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - zephir_read_property(&_0, this_ptr, ZEND_STRL("namespaceName"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_is_true(&_0))) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("defaultNamespace"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("namespaceName"), &_1$$3); - } - zephir_read_property(&_2, this_ptr, ZEND_STRL("handlerName"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_is_true(&_2))) { - zephir_read_property(&_3$$4, this_ptr, ZEND_STRL("defaultHandler"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("handlerName"), &_3$$4); - } - zephir_read_property(&_4, this_ptr, ZEND_STRL("actionName"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_is_true(&_4))) { - zephir_read_property(&_5$$5, this_ptr, ZEND_STRL("defaultAction"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("actionName"), &_5$$5); - } -} - -static PHP_METHOD(Phalcon_Dispatcher_AbstractDispatcher, toCamelCase) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Numericality, validate) { + zval pattern, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL, camelCaseInput, _0, _1$$3, _2$$3, _3$$3; - zval input; + zval *validation, validation_sub, *field, field_sub, value, _1, _2, _3, _4$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&camelCaseInput); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&pattern); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(input) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &input_param); - zephir_get_strval(&input, input_param); - zephir_memory_observe(&camelCaseInput); - zephir_read_property(&_0, this_ptr, ZEND_STRL("camelCaseMap"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&camelCaseInput, &_0, &input, 0))) { - ZEPHIR_INIT_VAR(&_1$$3); - ZVAL_STRING(&_1$$3, "/[_-]+/"); - ZEPHIR_CALL_FUNCTION(&_2$$3, "preg_split", NULL, 70, &_1$$3, &input); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_1$$3); - ZVAL_STRING(&_1$$3, "ucfirst"); - ZEPHIR_CALL_FUNCTION(&_3$$3, "array_map", NULL, 81, &_1$$3, &_2$$3); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&camelCaseInput); - zephir_fast_join_str(&camelCaseInput, SL(""), &_3$$3); - zephir_update_property_array(this_ptr, SL("camelCaseMap"), &input, &camelCaseInput); - } - RETURN_CCTOR(&camelCaseInput); -} - -zend_object *zephir_init_properties_Phalcon_Dispatcher_AbstractDispatcher(zend_class_entry *class_type) -{ - zval _0, _2, _4, _6, _1$$3, _3$$4, _5$$5, _7$$6; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("handlerHashes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("handlerHashes"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("camelCaseMap"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("camelCaseMap"), &_5$$5); - } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("activeMethodMap"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("activeMethodMap"), &_7$$6); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Dispatcher_DispatcherInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Dispatcher, DispatcherInterface, phalcon, dispatcher_dispatcherinterface, phalcon_dispatcher_dispatcherinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, dispatch); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, forward); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getActionName); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getActionSuffix); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getHandlerSuffix); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getParam); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getParameter); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getParams); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getParameters); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, getReturnedValue); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, hasParam); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, isFinished); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setActionName); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setActionSuffix); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setDefaultAction); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setDefaultNamespace); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setHandlerSuffix); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setModuleName); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setNamespaceName); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setParam); -ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setParams); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); + zephir_check_call_status(); + zephir_cast_to_string(&_0, &value); + ZEPHIR_CPY_WRT(&value, &_0); + ZEPHIR_INIT_VAR(&pattern); + ZVAL_STRING(&pattern, "/((^[-]?[0-9,]+(\\.[0-9]+)?$)|(^[-]?[0-9.]+(,[0-9]+)?$))/"); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "allowempty", NULL, 0, field, &value); + zephir_check_call_status(); + if (zephir_is_true(&_1)) { + RETURN_MM_BOOL(1); + } + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_INIT_VAR(&_3); + zephir_preg_match(&_3, &pattern, &value, &_2, 0, 0 , 0 ); + if (!(zephir_is_true(&_3))) { + ZEPHIR_CALL_METHOD(&_4$$4, this_ptr, "messagefactory", NULL, 0, validation, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_4$$4); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); +} + @@ -117412,23 +116376,79 @@ ZEPHIR_DOC_METHOD(Phalcon_Dispatcher_DispatcherInterface, setParams); -ZEPHIR_INIT_CLASS(Phalcon_Dispatcher_Exception) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_PresenceOf) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Dispatcher, Exception, phalcon, dispatcher_exception, zend_ce_exception, NULL, 0); - - zephir_declare_class_constant_long(phalcon_dispatcher_exception_ce, SL("EXCEPTION_ACTION_NOT_FOUND"), 5); - - zephir_declare_class_constant_long(phalcon_dispatcher_exception_ce, SL("EXCEPTION_CYCLIC_ROUTING"), 1); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, PresenceOf, phalcon, filter_validation_validator_presenceof, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_presenceof_method_entry, 0); - zephir_declare_class_constant_long(phalcon_dispatcher_exception_ce, SL("EXCEPTION_HANDLER_NOT_FOUND"), 2); + zend_declare_property_string(phalcon_filter_validation_validator_presenceof_ce, SL("template"), "Field :field is required", ZEND_ACC_PROTECTED); + return SUCCESS; +} - zephir_declare_class_constant_long(phalcon_dispatcher_exception_ce, SL("EXCEPTION_INVALID_HANDLER"), 3); +static PHP_METHOD(Phalcon_Filter_Validation_Validator_PresenceOf, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *options_param = NULL; + zval options; - zephir_declare_class_constant_long(phalcon_dispatcher_exception_ce, SL("EXCEPTION_INVALID_PARAMS"), 4); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + } + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_presenceof_ce, getThis(), "__construct", NULL, 0, &options); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} - zephir_declare_class_constant_long(phalcon_dispatcher_exception_ce, SL("EXCEPTION_NO_DI"), 0); +static PHP_METHOD(Phalcon_Filter_Validation_Validator_PresenceOf, validate) +{ + zend_bool _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *validation, validation_sub, *field, field_sub, value, _0, _2$$4; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2$$4); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "allowempty", NULL, 0, field, &value); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + RETURN_MM_BOOL(1); + } + _1 = Z_TYPE_P(&value) == IS_NULL; + if (!(_1)) { + _1 = ZEPHIR_IS_STRING_IDENTICAL(&value, ""); + } + if (_1) { + ZEPHIR_CALL_METHOD(&_2$$4, this_ptr, "messagefactory", NULL, 0, validation, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_2$$4); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); } @@ -117441,103 +116461,169 @@ ZEPHIR_INIT_CLASS(Phalcon_Dispatcher_Exception) -ZEPHIR_INIT_CLASS(Phalcon_Html_Attributes) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_Regex) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html, Attributes, phalcon, html_attributes, phalcon_support_collection_ce, phalcon_html_attributes_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, Regex, phalcon, filter_validation_validator_regex, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_regex_method_entry, 0); - zend_class_implements(phalcon_html_attributes_ce, 1, phalcon_html_attributes_renderinterface_ce); + zend_declare_property_string(phalcon_filter_validation_validator_regex_ce, SL("template"), "Field :field does not match the required format", ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Attributes, render) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Regex, __construct) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + zval *options_param = NULL; + zval options; - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "toarray", NULL, 0); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "renderattributes", NULL, 0, &_0); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + } + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_regex_ce, getThis(), "__construct", NULL, 0, &options); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Attributes, __toString) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Regex, validate) { + zend_bool failed = 0, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *validation, validation_sub, *field, field_sub, matches, value, pattern, _0, _1, _2$$4, _4$$5, _5$$7; zval *this_ptr = getThis(); + + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&matches); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$7); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "render", NULL, 0); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_INIT_VAR(&matches); + ZVAL_NULL(&matches); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "allowempty", NULL, 0, field, &value); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + RETURN_MM_BOOL(1); + } + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "pattern"); + ZEPHIR_CALL_METHOD(&pattern, this_ptr, "getoption", NULL, 0, &_1); + zephir_check_call_status(); + if (Z_TYPE_P(&pattern) == IS_ARRAY) { + zephir_array_fetch(&_2$$4, &pattern, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/Regex.zep", 94); + ZEPHIR_CPY_WRT(&pattern, &_2$$4); + } + _3 = Z_TYPE_P(&value) != IS_NULL; + if (_3) { + ZEPHIR_INIT_NVAR(&_1); + zephir_preg_match(&_1, &pattern, &value, &matches, 0, 0 , 0 ); + _3 = zephir_is_true(&_1); + } + if (_3) { + zephir_array_fetch_long(&_4$$5, &matches, 0, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/Regex.zep", 101); + failed = !ZEPHIR_IS_EQUAL(&_4$$5, &value); + } else { + failed = 1; + } + if (failed) { + ZEPHIR_CALL_METHOD(&_5$$7, this_ptr, "messagefactory", NULL, 0, validation, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_5$$7); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Html_Attributes, renderAttributes) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_StringLength) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, StringLength, phalcon, filter_validation_validator_stringlength, phalcon_filter_validation_abstractvalidatorcomposite_ce, phalcon_filter_validation_validator_stringlength_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Validation_Validator_StringLength, __construct) { - zend_bool _4$$3, _10$$5; zend_string *_3; zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_8 = NULL; + zephir_fcall_cache_entry *_6 = NULL, *_9 = NULL, *_11 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *attributes_param = NULL, __$null, __$true, intersect, key, result, results, value, *_0, _1, _5$$4, _6$$4, _7$$4, _9$$4, _11$$6, _12$$6, _13$$6, _14$$6; - zval attributes, order; + zval *options_param = NULL, included, key, message, validator, value, *_0, _1, _4$$3, _5$$3, _7$$3, _12$$15, _13$$15, _14$$15; + zval options, _8$$4, _10$$9, _15$$16, _16$$21; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&order); - ZVAL_NULL(&__$null); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&intersect); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_8$$4); + ZVAL_UNDEF(&_10$$9); + ZVAL_UNDEF(&_15$$16); + ZVAL_UNDEF(&_16$$21); + ZVAL_UNDEF(&included); ZVAL_UNDEF(&key); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&results); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&validator); ZVAL_UNDEF(&value); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_11$$6); - ZVAL_UNDEF(&_12$$6); - ZVAL_UNDEF(&_13$$6); - ZVAL_UNDEF(&_14$$6); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(attributes) + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_12$$15); + ZVAL_UNDEF(&_13$$15); + ZVAL_UNDEF(&_14$$15); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &attributes_param); - zephir_get_arrval(&attributes, attributes_param); - ZEPHIR_INIT_VAR(&order); - zephir_create_array(&order, 10, 0); - zephir_array_update_string(&order, SL("rel"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&order, SL("type"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&order, SL("for"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&order, SL("src"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&order, SL("href"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&order, SL("action"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&order, SL("id"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&order, SL("name"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&order, SL("value"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&order, SL("class"), &__$null, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_FUNCTION(&intersect, "array_intersect_key", NULL, 2, &order, &attributes); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&results); - zephir_fast_array_merge(&results, &intersect, &attributes); - zephir_array_unset_string(&results, SL("escape"), PH_SEPARATE); - ZEPHIR_INIT_VAR(&result); - ZVAL_STRING(&result, ""); - zephir_is_iterable(&results, 0, "phalcon/Html/Attributes.zep", 76); - if (Z_TYPE_P(&results) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&results), _2, _3, _0) + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + } + ZEPHIR_INIT_VAR(&included); + ZVAL_NULL(&included); + ZEPHIR_INIT_VAR(&message); + ZVAL_NULL(&message); + zephir_is_iterable(&options, 1, "phalcon/Filter/Validation/Validator/StringLength.zep", 167); + if (Z_TYPE_P(&options) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&options), _2, _3, _0) { ZEPHIR_INIT_NVAR(&key); if (_3 != NULL) { @@ -117547,55 +116633,169 @@ static PHP_METHOD(Phalcon_Html_Attributes, renderAttributes) } ZEPHIR_INIT_NVAR(&value); ZVAL_COPY(&value, _0); - _4$$3 = Z_TYPE_P(&key) == IS_STRING; - if (_4$$3) { - _4$$3 = Z_TYPE_P(&value) != IS_NULL; - } - if (_4$$3) { - ZVAL_LONG(&_5$$4, 3); - ZEPHIR_INIT_NVAR(&_6$$4); - ZVAL_STRING(&_6$$4, "utf-8"); - ZEPHIR_CALL_FUNCTION(&_7$$4, "htmlspecialchars", &_8, 286, &value, &_5$$4, &_6$$4, &__$true); + ZEPHIR_INIT_NVAR(&_4$$3); + ZVAL_STRING(&_4$$3, "min"); + ZEPHIR_CALL_FUNCTION(&_5$$3, "strcasecmp", &_6, 39, &key, &_4$$3); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_4$$3); + ZVAL_STRING(&_4$$3, "max"); + ZEPHIR_CALL_FUNCTION(&_7$$3, "strcasecmp", &_6, 39, &key, &_4$$3); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG_IDENTICAL(&_5$$3, 0)) { + if (zephir_array_isset_string(&options, SL("message"))) { + ZEPHIR_OBS_NVAR(&message); + zephir_array_fetch_string(&message, &options, SL("message"), PH_NOISY, "phalcon/Filter/Validation/Validator/StringLength.zep", 107); + } else if (zephir_array_isset_string(&options, SL("messageMinimum"))) { + ZEPHIR_OBS_NVAR(&message); + zephir_array_fetch_string(&message, &options, SL("messageMinimum"), PH_NOISY, "phalcon/Filter/Validation/Validator/StringLength.zep", 109); + } + if (zephir_array_isset_string(&options, SL("included"))) { + ZEPHIR_OBS_NVAR(&included); + zephir_array_fetch_string(&included, &options, SL("included"), PH_NOISY, "phalcon/Filter/Validation/Validator/StringLength.zep", 114); + } else if (zephir_array_isset_string(&options, SL("includedMinimum"))) { + ZEPHIR_OBS_NVAR(&included); + zephir_array_fetch_string(&included, &options, SL("includedMinimum"), PH_NOISY, "phalcon/Filter/Validation/Validator/StringLength.zep", 116); + } + ZEPHIR_INIT_NVAR(&validator); + object_init_ex(&validator, phalcon_filter_validation_validator_stringlength_min_ce); + ZEPHIR_INIT_NVAR(&_8$$4); + zephir_create_array(&_8$$4, 3, 0); + zephir_array_update_string(&_8$$4, SL("min"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_8$$4, SL("message"), &message, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_8$$4, SL("included"), &included, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &validator, "__construct", &_9, 312, &_8$$4); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_9$$4); - ZEPHIR_CONCAT_VSVS(&_9$$4, &key, "=\"", &_7$$4, "\" "); - zephir_concat_self(&result, &_9$$4); + zephir_array_unset_string(&options, SL("min"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("message"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("messageMinimum"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("included"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("includedMinimum"), PH_SEPARATE); + } else if (ZEPHIR_IS_LONG_IDENTICAL(&_7$$3, 0)) { + if (zephir_array_isset_string(&options, SL("message"))) { + ZEPHIR_OBS_NVAR(&message); + zephir_array_fetch_string(&message, &options, SL("message"), PH_NOISY, "phalcon/Filter/Validation/Validator/StringLength.zep", 135); + } else if (zephir_array_isset_string(&options, SL("messageMaximum"))) { + ZEPHIR_OBS_NVAR(&message); + zephir_array_fetch_string(&message, &options, SL("messageMaximum"), PH_NOISY, "phalcon/Filter/Validation/Validator/StringLength.zep", 137); + } + if (zephir_array_isset_string(&options, SL("included"))) { + ZEPHIR_OBS_NVAR(&included); + zephir_array_fetch_string(&included, &options, SL("included"), PH_NOISY, "phalcon/Filter/Validation/Validator/StringLength.zep", 142); + } else if (zephir_array_isset_string(&options, SL("includedMaximum"))) { + ZEPHIR_OBS_NVAR(&included); + zephir_array_fetch_string(&included, &options, SL("includedMaximum"), PH_NOISY, "phalcon/Filter/Validation/Validator/StringLength.zep", 144); + } + ZEPHIR_INIT_NVAR(&validator); + object_init_ex(&validator, phalcon_filter_validation_validator_stringlength_max_ce); + ZEPHIR_INIT_NVAR(&_10$$9); + zephir_create_array(&_10$$9, 3, 0); + zephir_array_update_string(&_10$$9, SL("max"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_10$$9, SL("message"), &message, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_10$$9, SL("included"), &included, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &validator, "__construct", &_11, 313, &_10$$9); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("max"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("message"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("messageMaximum"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("included"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("includedMaximum"), PH_SEPARATE); + } else { + continue; } + zephir_update_property_array_append(this_ptr, SL("validators"), &validator); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &results, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &options, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_1, &results, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_1, &options, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_1)) { break; } - ZEPHIR_CALL_METHOD(&key, &results, "key", NULL, 0); + ZEPHIR_CALL_METHOD(&key, &options, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &results, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&value, &options, "current", NULL, 0); zephir_check_call_status(); - _10$$5 = Z_TYPE_P(&key) == IS_STRING; - if (_10$$5) { - _10$$5 = Z_TYPE_P(&value) != IS_NULL; - } - if (_10$$5) { - ZVAL_LONG(&_11$$6, 3); - ZEPHIR_INIT_NVAR(&_12$$6); - ZVAL_STRING(&_12$$6, "utf-8"); - ZEPHIR_CALL_FUNCTION(&_13$$6, "htmlspecialchars", &_8, 286, &value, &_11$$6, &_12$$6, &__$true); + ZEPHIR_INIT_NVAR(&_12$$15); + ZVAL_STRING(&_12$$15, "min"); + ZEPHIR_CALL_FUNCTION(&_13$$15, "strcasecmp", &_6, 39, &key, &_12$$15); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_12$$15); + ZVAL_STRING(&_12$$15, "max"); + ZEPHIR_CALL_FUNCTION(&_14$$15, "strcasecmp", &_6, 39, &key, &_12$$15); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG_IDENTICAL(&_13$$15, 0)) { + if (zephir_array_isset_string(&options, SL("message"))) { + ZEPHIR_OBS_NVAR(&message); + zephir_array_fetch_string(&message, &options, SL("message"), PH_NOISY, "phalcon/Filter/Validation/Validator/StringLength.zep", 107); + } else if (zephir_array_isset_string(&options, SL("messageMinimum"))) { + ZEPHIR_OBS_NVAR(&message); + zephir_array_fetch_string(&message, &options, SL("messageMinimum"), PH_NOISY, "phalcon/Filter/Validation/Validator/StringLength.zep", 109); + } + if (zephir_array_isset_string(&options, SL("included"))) { + ZEPHIR_OBS_NVAR(&included); + zephir_array_fetch_string(&included, &options, SL("included"), PH_NOISY, "phalcon/Filter/Validation/Validator/StringLength.zep", 114); + } else if (zephir_array_isset_string(&options, SL("includedMinimum"))) { + ZEPHIR_OBS_NVAR(&included); + zephir_array_fetch_string(&included, &options, SL("includedMinimum"), PH_NOISY, "phalcon/Filter/Validation/Validator/StringLength.zep", 116); + } + ZEPHIR_INIT_NVAR(&validator); + object_init_ex(&validator, phalcon_filter_validation_validator_stringlength_min_ce); + ZEPHIR_INIT_NVAR(&_15$$16); + zephir_create_array(&_15$$16, 3, 0); + zephir_array_update_string(&_15$$16, SL("min"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_15$$16, SL("message"), &message, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_15$$16, SL("included"), &included, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &validator, "__construct", &_11, 313, &_15$$16); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_14$$6); - ZEPHIR_CONCAT_VSVS(&_14$$6, &key, "=\"", &_13$$6, "\" "); - zephir_concat_self(&result, &_14$$6); + zephir_array_unset_string(&options, SL("min"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("message"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("messageMinimum"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("included"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("includedMinimum"), PH_SEPARATE); + } else if (ZEPHIR_IS_LONG_IDENTICAL(&_14$$15, 0)) { + if (zephir_array_isset_string(&options, SL("message"))) { + ZEPHIR_OBS_NVAR(&message); + zephir_array_fetch_string(&message, &options, SL("message"), PH_NOISY, "phalcon/Filter/Validation/Validator/StringLength.zep", 135); + } else if (zephir_array_isset_string(&options, SL("messageMaximum"))) { + ZEPHIR_OBS_NVAR(&message); + zephir_array_fetch_string(&message, &options, SL("messageMaximum"), PH_NOISY, "phalcon/Filter/Validation/Validator/StringLength.zep", 137); + } + if (zephir_array_isset_string(&options, SL("included"))) { + ZEPHIR_OBS_NVAR(&included); + zephir_array_fetch_string(&included, &options, SL("included"), PH_NOISY, "phalcon/Filter/Validation/Validator/StringLength.zep", 142); + } else if (zephir_array_isset_string(&options, SL("includedMaximum"))) { + ZEPHIR_OBS_NVAR(&included); + zephir_array_fetch_string(&included, &options, SL("includedMaximum"), PH_NOISY, "phalcon/Filter/Validation/Validator/StringLength.zep", 144); + } + ZEPHIR_INIT_NVAR(&validator); + object_init_ex(&validator, phalcon_filter_validation_validator_stringlength_max_ce); + ZEPHIR_INIT_NVAR(&_16$$21); + zephir_create_array(&_16$$21, 3, 0); + zephir_array_update_string(&_16$$21, SL("max"), &value, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_16$$21, SL("message"), &message, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_16$$21, SL("included"), &included, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &validator, "__construct", &_11, 313, &_16$$21); + zephir_check_call_status(); + zephir_array_unset_string(&options, SL("max"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("message"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("messageMaximum"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("included"), PH_SEPARATE); + zephir_array_unset_string(&options, SL("includedMaximum"), PH_SEPARATE); + } else { + continue; } - ZEPHIR_CALL_METHOD(NULL, &results, "next", NULL, 0); + zephir_update_property_array_append(this_ptr, SL("validators"), &validator); + ZEPHIR_CALL_METHOD(NULL, &options, "next", NULL, 0); zephir_check_call_status(); } } ZEPHIR_INIT_NVAR(&value); ZEPHIR_INIT_NVAR(&key); - RETURN_CCTOR(&result); + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_stringlength_ce, getThis(), "__construct", NULL, 0, &options); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } @@ -117608,980 +116808,1434 @@ static PHP_METHOD(Phalcon_Html_Attributes, renderAttributes) -ZEPHIR_INIT_CLASS(Phalcon_Html_Breadcrumbs) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_Uniqueness) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Html, Breadcrumbs, phalcon, html_breadcrumbs, phalcon_html_breadcrumbs_method_entry, 0); - - zend_declare_property_null(phalcon_html_breadcrumbs_ce, SL("elements"), ZEND_ACC_PRIVATE); - zend_declare_property_string(phalcon_html_breadcrumbs_ce, SL("separator"), " / ", ZEND_ACC_PRIVATE); - zend_declare_property_string(phalcon_html_breadcrumbs_ce, SL("template"), "
%label%
", ZEND_ACC_PRIVATE); - phalcon_html_breadcrumbs_ce->create_object = zephir_init_properties_Phalcon_Html_Breadcrumbs; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, Uniqueness, phalcon, filter_validation_validator_uniqueness, phalcon_filter_validation_abstractcombinedfieldsvalidator_ce, phalcon_filter_validation_validator_uniqueness_method_entry, 0); + zend_declare_property_string(phalcon_filter_validation_validator_uniqueness_ce, SL("template"), "Field :field must be unique", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_filter_validation_validator_uniqueness_ce, SL("columnMap"), ZEND_ACC_PRIVATE); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Breadcrumbs, add) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Uniqueness, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *label_param = NULL, *link_param = NULL; - zval label, link; - zval *this_ptr = getThis(); + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *options_param = NULL; + zval options; - ZVAL_UNDEF(&label); - ZVAL_UNDEF(&link); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(label) + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_STR(link) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &label_param, &link_param); - zephir_get_strval(&label, label_param); - if (!link_param) { - ZEPHIR_INIT_VAR(&link); - ZVAL_STRING(&link, ""); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - zephir_get_strval(&link, link_param); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - zephir_update_property_array(this_ptr, SL("elements"), &link, &label); - RETURN_THIS(); + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_uniqueness_ce, getThis(), "__construct", NULL, 0, &options); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Breadcrumbs, clear) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Uniqueness, validate) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *validation, validation_sub, *field, field_sub, _0, _1$$3; zval *this_ptr = getThis(); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("elements"), &_0); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Html_Breadcrumbs, getSeparator) -{ - - RETURN_MEMBER(getThis(), "separator"); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "isuniqueness", NULL, 0, validation, field); + zephir_check_call_status(); + if (!(zephir_is_true(&_0))) { + ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "messagefactory", NULL, 0, validation, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_1$$3); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Html_Breadcrumbs, remove) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Uniqueness, getColumnNameReal) { + zend_bool _0, _7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *link_param = NULL, elements, _0; - zval link; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval field; + zval *record, record_sub, *field_param = NULL, _1, _6, _8, _2$$3, _3$$3, _4$$3, _5$$3, _9$$4, _10$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&link); - ZVAL_UNDEF(&elements); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(link) + ZVAL_UNDEF(&record_sub); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&_10$$4); + ZVAL_UNDEF(&field); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(record) + Z_PARAM_STR(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &link_param); - zephir_get_strval(&link, link_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&elements, &_0); - zephir_array_unset(&elements, &link, PH_SEPARATE); - zephir_update_property_zval(this_ptr, ZEND_STRL("elements"), &elements); - ZEPHIR_MM_RESTORE(); + zephir_fetch_params(1, 2, 0, &record, &field_param); + if (UNEXPECTED(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 of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(field_param) == IS_STRING)) { + zephir_get_strval(&field, field_param); + } else { + ZEPHIR_INIT_VAR(&field); + } + _0 = ZEPHIR_GLOBAL(orm).column_renaming; + if (_0) { + zephir_read_property(&_1, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); + _0 = !zephir_is_true(&_1); + } + if (_0) { + ZEPHIR_CALL_METHOD(&_2$$3, record, "getdi", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4$$3); + ZVAL_STRING(&_4$$3, "modelsMetadata"); + ZEPHIR_CALL_METHOD(&_3$$3, &_2$$3, "getshared", NULL, 0, &_4$$3); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5$$3, &_3$$3, "getcolumnmap", NULL, 0, record); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("columnMap"), &_5$$3); + } + zephir_memory_observe(&_6); + zephir_read_property(&_6, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC); + _7 = Z_TYPE_P(&_6) == IS_ARRAY; + if (_7) { + zephir_read_property(&_8, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); + _7 = zephir_array_isset(&_8, &field); + } + if (_7) { + zephir_read_property(&_9$$4, this_ptr, ZEND_STRL("columnMap"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_10$$4, &_9$$4, &field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 147); + RETURN_CTOR(&_10$$4); + } + RETURN_CTOR(&field); } -static PHP_METHOD(Phalcon_Html_Breadcrumbs, render) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Uniqueness, isUniqueness) { - zval _6$$3, _8$$3, _10$$4, _12$$4, _15$$6, _17$$6; - zend_string *_4; - zend_ulong _3; - zval element, elements, lastLabel, lastUrl, output, template, url, urls, _0, *_1, _2, _18, _19, _5$$3, _7$$3, _9$$4, _11$$4, _13$$5, _14$$6, _16$$6; + zend_class_entry *_9; + zend_bool isModel = 0, _7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *validation, validation_sub, *field = NULL, field_sub, values, convert, record, params, className, singleField, _0, *_1, _2, _8, _3$$4, _5$$5, _6$$6; zval *this_ptr = getThis(); - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&elements); - ZVAL_UNDEF(&lastLabel); - ZVAL_UNDEF(&lastUrl); - ZVAL_UNDEF(&output); - ZVAL_UNDEF(&template); - ZVAL_UNDEF(&url); - ZVAL_UNDEF(&urls); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&convert); + ZVAL_UNDEF(&record); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&singleField); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_18); - ZVAL_UNDEF(&_19); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_11$$4); - ZVAL_UNDEF(&_13$$5); - ZVAL_UNDEF(&_14$$6); - ZVAL_UNDEF(&_16$$6); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_10$$4); - ZVAL_UNDEF(&_12$$4); - ZVAL_UNDEF(&_15$$6); - ZVAL_UNDEF(&_17$$6); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_6$$6); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&output); - array_init(&output); - zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&elements, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("template"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&template, &_0); - ZEPHIR_INIT_VAR(&urls); - zephir_array_keys(&urls, &elements); - ZEPHIR_MAKE_REF(&urls); - ZEPHIR_CALL_FUNCTION(&lastUrl, "end", NULL, 320, &urls); - ZEPHIR_UNREF(&urls); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_SEPARATE_PARAM(field); + if (Z_TYPE_P(field) != IS_ARRAY) { + ZEPHIR_CPY_WRT(&singleField, field); + ZEPHIR_INIT_NVAR(field); + array_init(field); + zephir_array_append(field, &singleField, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 165); + } + ZEPHIR_INIT_VAR(&values); + array_init(&values); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "convert"); + ZEPHIR_CALL_METHOD(&convert, this_ptr, "getoption", NULL, 0, &_0); zephir_check_call_status(); - zephir_memory_observe(&lastLabel); - zephir_array_fetch(&lastLabel, &elements, &lastUrl, PH_NOISY, "phalcon/Html/Breadcrumbs.zep", 122); - zephir_array_unset(&elements, &lastUrl, PH_SEPARATE); - zephir_is_iterable(&elements, 0, "phalcon/Html/Breadcrumbs.zep", 143); - if (Z_TYPE_P(&elements) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&elements), _3, _4, _1) + zephir_is_iterable(field, 0, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 175); + if (Z_TYPE_P(field) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(field), _1) { - ZEPHIR_INIT_NVAR(&url); - if (_4 != NULL) { - ZVAL_STR_COPY(&url, _4); - } else { - ZVAL_LONG(&url, _3); - } - ZEPHIR_INIT_NVAR(&element); - ZVAL_COPY(&element, _1); - ZEPHIR_INIT_NVAR(&_5$$3); - ZEPHIR_INIT_NVAR(&_6$$3); - zephir_create_array(&_6$$3, 2, 0); - ZEPHIR_INIT_NVAR(&_7$$3); - ZVAL_STRING(&_7$$3, "%label%"); - zephir_array_fast_append(&_6$$3, &_7$$3); - ZEPHIR_INIT_NVAR(&_7$$3); - ZVAL_STRING(&_7$$3, "%link%"); - zephir_array_fast_append(&_6$$3, &_7$$3); - ZEPHIR_INIT_NVAR(&_8$$3); - zephir_create_array(&_8$$3, 2, 0); - zephir_array_fast_append(&_8$$3, &element); - zephir_array_fast_append(&_8$$3, &url); - zephir_fast_str_replace(&_5$$3, &_6$$3, &_8$$3, &template); - zephir_array_append(&output, &_5$$3, PH_SEPARATE, "phalcon/Html/Breadcrumbs.zep", 137); + ZEPHIR_INIT_NVAR(&singleField); + ZVAL_COPY(&singleField, _1); + ZEPHIR_CALL_METHOD(&_3$$4, validation, "getvalue", &_4, 0, &singleField); + zephir_check_call_status(); + zephir_array_update_zval(&values, &singleField, &_3$$4, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &elements, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, field, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_2, &elements, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_2, field, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_2)) { break; } - ZEPHIR_CALL_METHOD(&url, &elements, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&element, &elements, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&singleField, field, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_9$$4); - ZEPHIR_INIT_NVAR(&_10$$4); - zephir_create_array(&_10$$4, 2, 0); - ZEPHIR_INIT_NVAR(&_11$$4); - ZVAL_STRING(&_11$$4, "%label%"); - zephir_array_fast_append(&_10$$4, &_11$$4); - ZEPHIR_INIT_NVAR(&_11$$4); - ZVAL_STRING(&_11$$4, "%link%"); - zephir_array_fast_append(&_10$$4, &_11$$4); - ZEPHIR_INIT_NVAR(&_12$$4); - zephir_create_array(&_12$$4, 2, 0); - zephir_array_fast_append(&_12$$4, &element); - zephir_array_fast_append(&_12$$4, &url); - zephir_fast_str_replace(&_9$$4, &_10$$4, &_12$$4, &template); - zephir_array_append(&output, &_9$$4, PH_SEPARATE, "phalcon/Html/Breadcrumbs.zep", 137); - ZEPHIR_CALL_METHOD(NULL, &elements, "next", NULL, 0); + ZEPHIR_CALL_METHOD(&_5$$5, validation, "getvalue", &_4, 0, &singleField); + zephir_check_call_status(); + zephir_array_update_zval(&values, &singleField, &_5$$5, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, field, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&element); - ZEPHIR_INIT_NVAR(&url); - if (0 != zephir_fast_count_int(&elements)) { - ZEPHIR_INIT_VAR(&_13$$5); - ZEPHIR_CONCAT_SVS(&_13$$5, "
", &lastLabel, "
"); - zephir_array_append(&output, &_13$$5, PH_SEPARATE, "phalcon/Html/Breadcrumbs.zep", 144); - } else { - ZEPHIR_INIT_VAR(&_14$$6); - ZEPHIR_INIT_VAR(&_15$$6); - zephir_create_array(&_15$$6, 2, 0); - ZEPHIR_INIT_VAR(&_16$$6); - ZVAL_STRING(&_16$$6, "%label%"); - zephir_array_fast_append(&_15$$6, &_16$$6); - ZEPHIR_INIT_NVAR(&_16$$6); - ZVAL_STRING(&_16$$6, "%link%"); - zephir_array_fast_append(&_15$$6, &_16$$6); - ZEPHIR_INIT_VAR(&_17$$6); - zephir_create_array(&_17$$6, 2, 0); - zephir_array_fast_append(&_17$$6, &lastLabel); - zephir_array_fast_append(&_17$$6, &lastUrl); - zephir_fast_str_replace(&_14$$6, &_15$$6, &_17$$6, &template); - zephir_array_append(&output, &_14$$6, PH_SEPARATE, "phalcon/Html/Breadcrumbs.zep", 156); + ZEPHIR_INIT_NVAR(&singleField); + if (Z_TYPE_P(&convert) != IS_NULL) { + ZEPHIR_CALL_ZVAL_FUNCTION(&_6$$6, &convert, NULL, 0, &values); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&values, &_6$$6); + if (UNEXPECTED(!(Z_TYPE_P(&values) == IS_ARRAY))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "Value conversion must return an array", "phalcon/Filter/Validation/Validator/Uniqueness.zep", 179); + return; + } } - ZEPHIR_INIT_VAR(&_18); - zephir_read_property(&_0, this_ptr, ZEND_STRL("separator"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_19); - ZEPHIR_CONCAT_SVS(&_19, "
", &_0, "
"); - zephir_fast_join(&_18, &_19, &output); - ZEPHIR_CONCAT_SVS(return_value, "
", &_18, "
"); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Html_Breadcrumbs, setSeparator) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *separator_param = NULL; - zval separator; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&separator); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(separator) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &separator_param); - zephir_get_strval(&separator, separator_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("separator"), &separator); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Html_Breadcrumbs, toArray) -{ - - RETURN_MEMBER(getThis(), "elements"); -} - -zend_object *zephir_init_properties_Phalcon_Html_Breadcrumbs(zend_class_entry *class_type) -{ - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("elements"), &_1$$3); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "model"); + ZEPHIR_CALL_METHOD(&record, this_ptr, "getoption", NULL, 0, &_0); + zephir_check_call_status(); + _7 = ZEPHIR_IS_EMPTY(&record); + if (!(_7)) { + _7 = Z_TYPE_P(&record) != IS_OBJECT; + } + if (_7) { + ZEPHIR_CALL_METHOD(&record, validation, "getentity", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(ZEPHIR_IS_EMPTY(&record))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "Model of record must be set to property \"model\"", "phalcon/Filter/Validation/Validator/Uniqueness.zep", 192); + return; } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); } + isModel = zephir_instance_of_ev(&record, phalcon_mvc_modelinterface_ce); + if (isModel) { + ZEPHIR_CALL_METHOD(¶ms, this_ptr, "isuniquenessmodel", NULL, 0, &record, field, &values); + zephir_check_call_status(); + } else { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "The uniqueness validator works only with Phalcon\\Mvc\\Model", "phalcon/Filter/Validation/Validator/Uniqueness.zep", 212); + return; + } + ZEPHIR_INIT_VAR(&className); + zephir_get_class(&className, &record, 0); + _9 = zephir_fetch_class(&className); + ZEPHIR_CALL_CE_STATIC(&_8, _9, "count", NULL, 0, ¶ms); + zephir_check_call_status(); + RETURN_MM_BOOL(ZEPHIR_IS_LONG(&_8, 0)); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Escaper) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Html, Escaper, phalcon, html_escaper, phalcon_html_escaper_method_entry, 0); - - zend_declare_property_bool(phalcon_html_escaper_ce, SL("doubleEncode"), 1, ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_html_escaper_ce, SL("encoding"), "utf-8", ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_html_escaper_ce, SL("flags"), 11, ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_html_escaper_ce, 1, phalcon_html_escaper_escaperinterface_ce); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Html_Escaper, attributes) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Uniqueness, isUniquenessModel) { - zend_bool _5$$4, _13$$8; - zval _0$$3, _9$$4, _11$$7, _17$$8, _19$$11; - zend_string *_4; - zend_ulong _3; + zval _24$$10, _26$$11, _36$$15, _38$$16, _49$$20, _51$$21, _63$$26, _65$$27, _75$$31, _77$$32, _101$$41, _103$$42, _113$$46, _115$$47, _126$$51, _128$$52, _140$$57, _142$$58, _152$$62, _154$$63; + zend_string *_18$$7, *_95$$38; + zend_ulong _17$$7, _94$$38; + zend_bool _9$$6, _87$$37; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *input, input_sub, key, result, value, *_1, _2, _6$$4, _8$$4, _7$$6, _10$$7, _12$$7, _14$$8, _16$$8, _15$$10, _18$$11, _20$$11; + zephir_fcall_cache_entry *_5 = NULL, *_14 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, index = 0; + zval field, values; + zval *record, record_sub, *field_param = NULL, *values_param = NULL, params, attribute, metaData, primaryField, singleField, fieldExcept, singleExcept, notInValues, exceptConditions, value, except, _0, *_1, _2, _159, _177, _3$$3, _4$$3, _6$$4, _7$$4, _8$$5, _10$$6, _11$$6, _12$$6, _13$$6, *_15$$7, _16$$7, _19$$8, _20$$8, *_21$$9, _22$$9, _27$$9, _28$$9, _23$$10, _25$$11, _29$$12, _30$$12, _31$$13, _32$$13, *_33$$14, _34$$14, _39$$14, _40$$14, _35$$15, _37$$16, _41$$17, _42$$17, _43$$18, _44$$18, _45$$18, *_46$$19, _47$$19, _52$$19, _53$$19, _48$$20, _50$$21, _54$$22, _55$$22, *_56$$23, _57$$23, _58$$24, _59$$24, *_60$$25, _61$$25, _66$$25, _67$$25, _62$$26, _64$$27, _68$$28, _69$$28, _70$$29, _71$$29, *_72$$30, _73$$30, _78$$30, _79$$30, _74$$31, _76$$32, _80$$33, _81$$33, _82$$34, _83$$34, _84$$35, _85$$35, _86$$36, _88$$37, _89$$37, _90$$37, _91$$37, *_92$$38, _93$$38, _96$$39, _97$$39, *_98$$40, _99$$40, _104$$40, _105$$40, _100$$41, _102$$42, _106$$43, _107$$43, _108$$44, _109$$44, *_110$$45, _111$$45, _116$$45, _117$$45, _112$$46, _114$$47, _118$$48, _119$$48, _120$$49, _121$$49, _122$$49, *_123$$50, _124$$50, _129$$50, _130$$50, _125$$51, _127$$52, _131$$53, _132$$53, *_133$$54, _134$$54, _135$$55, _136$$55, *_137$$56, _138$$56, _143$$56, _144$$56, _139$$57, _141$$58, _145$$59, _146$$59, _147$$60, _148$$60, *_149$$61, _150$$61, _155$$61, _156$$61, _151$$62, _153$$63, _157$$64, _158$$64, _160$$65, _161$$65, _162$$65, *_163$$65, _164$$65, _165$$66, _166$$66, _167$$66, _168$$66, _169$$66, _170$$67, _171$$67, _172$$67, _173$$67, _174$$67, _175$$68, _176$$68; zval *this_ptr = getThis(); - ZVAL_UNDEF(&input_sub); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&result); + ZVAL_UNDEF(&record_sub); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&metaData); + ZVAL_UNDEF(&primaryField); + ZVAL_UNDEF(&singleField); + ZVAL_UNDEF(&fieldExcept); + ZVAL_UNDEF(&singleExcept); + ZVAL_UNDEF(¬InValues); + ZVAL_UNDEF(&exceptConditions); ZVAL_UNDEF(&value); + ZVAL_UNDEF(&except); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_159); + ZVAL_UNDEF(&_177); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_10$$7); - ZVAL_UNDEF(&_12$$7); - ZVAL_UNDEF(&_14$$8); - ZVAL_UNDEF(&_16$$8); - ZVAL_UNDEF(&_15$$10); - ZVAL_UNDEF(&_18$$11); - ZVAL_UNDEF(&_20$$11); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_11$$7); - ZVAL_UNDEF(&_17$$8); - ZVAL_UNDEF(&_19$$11); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(input) + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_10$$6); + ZVAL_UNDEF(&_11$$6); + ZVAL_UNDEF(&_12$$6); + ZVAL_UNDEF(&_13$$6); + ZVAL_UNDEF(&_16$$7); + ZVAL_UNDEF(&_19$$8); + ZVAL_UNDEF(&_20$$8); + ZVAL_UNDEF(&_22$$9); + ZVAL_UNDEF(&_27$$9); + ZVAL_UNDEF(&_28$$9); + ZVAL_UNDEF(&_23$$10); + ZVAL_UNDEF(&_25$$11); + ZVAL_UNDEF(&_29$$12); + ZVAL_UNDEF(&_30$$12); + ZVAL_UNDEF(&_31$$13); + ZVAL_UNDEF(&_32$$13); + ZVAL_UNDEF(&_34$$14); + ZVAL_UNDEF(&_39$$14); + ZVAL_UNDEF(&_40$$14); + ZVAL_UNDEF(&_35$$15); + ZVAL_UNDEF(&_37$$16); + ZVAL_UNDEF(&_41$$17); + ZVAL_UNDEF(&_42$$17); + ZVAL_UNDEF(&_43$$18); + ZVAL_UNDEF(&_44$$18); + ZVAL_UNDEF(&_45$$18); + ZVAL_UNDEF(&_47$$19); + ZVAL_UNDEF(&_52$$19); + ZVAL_UNDEF(&_53$$19); + ZVAL_UNDEF(&_48$$20); + ZVAL_UNDEF(&_50$$21); + ZVAL_UNDEF(&_54$$22); + ZVAL_UNDEF(&_55$$22); + ZVAL_UNDEF(&_57$$23); + ZVAL_UNDEF(&_58$$24); + ZVAL_UNDEF(&_59$$24); + ZVAL_UNDEF(&_61$$25); + ZVAL_UNDEF(&_66$$25); + ZVAL_UNDEF(&_67$$25); + ZVAL_UNDEF(&_62$$26); + ZVAL_UNDEF(&_64$$27); + ZVAL_UNDEF(&_68$$28); + ZVAL_UNDEF(&_69$$28); + ZVAL_UNDEF(&_70$$29); + ZVAL_UNDEF(&_71$$29); + ZVAL_UNDEF(&_73$$30); + ZVAL_UNDEF(&_78$$30); + ZVAL_UNDEF(&_79$$30); + ZVAL_UNDEF(&_74$$31); + ZVAL_UNDEF(&_76$$32); + ZVAL_UNDEF(&_80$$33); + ZVAL_UNDEF(&_81$$33); + ZVAL_UNDEF(&_82$$34); + ZVAL_UNDEF(&_83$$34); + ZVAL_UNDEF(&_84$$35); + ZVAL_UNDEF(&_85$$35); + ZVAL_UNDEF(&_86$$36); + ZVAL_UNDEF(&_88$$37); + ZVAL_UNDEF(&_89$$37); + ZVAL_UNDEF(&_90$$37); + ZVAL_UNDEF(&_91$$37); + ZVAL_UNDEF(&_93$$38); + ZVAL_UNDEF(&_96$$39); + ZVAL_UNDEF(&_97$$39); + ZVAL_UNDEF(&_99$$40); + ZVAL_UNDEF(&_104$$40); + ZVAL_UNDEF(&_105$$40); + ZVAL_UNDEF(&_100$$41); + ZVAL_UNDEF(&_102$$42); + ZVAL_UNDEF(&_106$$43); + ZVAL_UNDEF(&_107$$43); + ZVAL_UNDEF(&_108$$44); + ZVAL_UNDEF(&_109$$44); + ZVAL_UNDEF(&_111$$45); + ZVAL_UNDEF(&_116$$45); + ZVAL_UNDEF(&_117$$45); + ZVAL_UNDEF(&_112$$46); + ZVAL_UNDEF(&_114$$47); + ZVAL_UNDEF(&_118$$48); + ZVAL_UNDEF(&_119$$48); + ZVAL_UNDEF(&_120$$49); + ZVAL_UNDEF(&_121$$49); + ZVAL_UNDEF(&_122$$49); + ZVAL_UNDEF(&_124$$50); + ZVAL_UNDEF(&_129$$50); + ZVAL_UNDEF(&_130$$50); + ZVAL_UNDEF(&_125$$51); + ZVAL_UNDEF(&_127$$52); + ZVAL_UNDEF(&_131$$53); + ZVAL_UNDEF(&_132$$53); + ZVAL_UNDEF(&_134$$54); + ZVAL_UNDEF(&_135$$55); + ZVAL_UNDEF(&_136$$55); + ZVAL_UNDEF(&_138$$56); + ZVAL_UNDEF(&_143$$56); + ZVAL_UNDEF(&_144$$56); + ZVAL_UNDEF(&_139$$57); + ZVAL_UNDEF(&_141$$58); + ZVAL_UNDEF(&_145$$59); + ZVAL_UNDEF(&_146$$59); + ZVAL_UNDEF(&_147$$60); + ZVAL_UNDEF(&_148$$60); + ZVAL_UNDEF(&_150$$61); + ZVAL_UNDEF(&_155$$61); + ZVAL_UNDEF(&_156$$61); + ZVAL_UNDEF(&_151$$62); + ZVAL_UNDEF(&_153$$63); + ZVAL_UNDEF(&_157$$64); + ZVAL_UNDEF(&_158$$64); + ZVAL_UNDEF(&_160$$65); + ZVAL_UNDEF(&_161$$65); + ZVAL_UNDEF(&_162$$65); + ZVAL_UNDEF(&_164$$65); + ZVAL_UNDEF(&_165$$66); + ZVAL_UNDEF(&_166$$66); + ZVAL_UNDEF(&_167$$66); + ZVAL_UNDEF(&_168$$66); + ZVAL_UNDEF(&_169$$66); + ZVAL_UNDEF(&_170$$67); + ZVAL_UNDEF(&_171$$67); + ZVAL_UNDEF(&_172$$67); + ZVAL_UNDEF(&_173$$67); + ZVAL_UNDEF(&_174$$67); + ZVAL_UNDEF(&_175$$68); + ZVAL_UNDEF(&_176$$68); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&_24$$10); + ZVAL_UNDEF(&_26$$11); + ZVAL_UNDEF(&_36$$15); + ZVAL_UNDEF(&_38$$16); + ZVAL_UNDEF(&_49$$20); + ZVAL_UNDEF(&_51$$21); + ZVAL_UNDEF(&_63$$26); + ZVAL_UNDEF(&_65$$27); + ZVAL_UNDEF(&_75$$31); + ZVAL_UNDEF(&_77$$32); + ZVAL_UNDEF(&_101$$41); + ZVAL_UNDEF(&_103$$42); + ZVAL_UNDEF(&_113$$46); + ZVAL_UNDEF(&_115$$47); + ZVAL_UNDEF(&_126$$51); + ZVAL_UNDEF(&_128$$52); + ZVAL_UNDEF(&_140$$57); + ZVAL_UNDEF(&_142$$58); + ZVAL_UNDEF(&_152$$62); + ZVAL_UNDEF(&_154$$63); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ZVAL(record) + Z_PARAM_ARRAY(field) + Z_PARAM_ARRAY(values) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &input); - if (EXPECTED((Z_TYPE_P(input) != IS_ARRAY))) { - zephir_cast_to_string(&_0$$3, input); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "phphtmlspecialchars", NULL, 0, &_0$$3); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_INIT_VAR(&result); - ZVAL_STRING(&result, ""); - zephir_is_iterable(input, 0, "phalcon/Html/Escaper.zep", 96); - if (Z_TYPE_P(input) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(input), _3, _4, _1) + zephir_fetch_params(1, 3, 0, &record, &field_param, &values_param); + zephir_get_arrval(&field, field_param); + zephir_get_arrval(&values, values_param); + ZEPHIR_INIT_VAR(&exceptConditions); + array_init(&exceptConditions); + index = 0; + ZEPHIR_INIT_VAR(¶ms); + zephir_create_array(¶ms, 2, 0); + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_array_update_string(¶ms, SL("conditions"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_0); + array_init(&_0); + zephir_array_update_string(¶ms, SL("bind"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "except"); + ZEPHIR_CALL_METHOD(&except, this_ptr, "getoption", NULL, 0, &_0); + zephir_check_call_status(); + zephir_is_iterable(&field, 0, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 405); + if (Z_TYPE_P(&field) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&field), _1) { - ZEPHIR_INIT_NVAR(&key); - if (_4 != NULL) { - ZVAL_STR_COPY(&key, _4); + ZEPHIR_INIT_NVAR(&singleField); + ZVAL_COPY(&singleField, _1); + ZEPHIR_INIT_NVAR(&fieldExcept); + ZVAL_NULL(&fieldExcept); + ZEPHIR_INIT_NVAR(¬InValues); + array_init(¬InValues); + ZEPHIR_OBS_NVAR(&value); + zephir_array_fetch(&value, &values, &singleField, PH_NOISY, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 322); + ZEPHIR_INIT_NVAR(&_3$$3); + ZVAL_STRING(&_3$$3, "attribute"); + ZEPHIR_CALL_METHOD(&attribute, this_ptr, "getoption", NULL, 0, &_3$$3, &singleField); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "getcolumnnamereal", &_5, 0, record, &attribute); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&attribute, &_4$$3); + if (Z_TYPE_P(&value) != IS_NULL) { + ZEPHIR_INIT_NVAR(&_6$$4); + ZVAL_LONG(&_6$$4, index); + ZEPHIR_INIT_NVAR(&_7$$4); + ZEPHIR_CONCAT_VSV(&_7$$4, &attribute, " = ?", &_6$$4); + zephir_array_update_multi(¶ms, &_7$$4, SL("sa"), 3, SL("conditions")); + zephir_array_update_multi(¶ms, &value, SL("sa"), 3, SL("bind")); + index++; } else { - ZVAL_LONG(&key, _3); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _1); - _5$$4 = Z_TYPE_P(&value) == IS_NULL; - if (!(_5$$4)) { - _5$$4 = ZEPHIR_IS_FALSE_IDENTICAL(&value); - } - if (_5$$4) { - continue; - } - ZEPHIR_INIT_NVAR(&_6$$4); - zephir_fast_trim(&_6$$4, &key, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_CPY_WRT(&key, &_6$$4); - if (Z_TYPE_P(&value) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_7$$6); - zephir_fast_join_str(&_7$$6, SL(" "), &value); - ZEPHIR_CPY_WRT(&value, &_7$$6); + ZEPHIR_INIT_NVAR(&_8$$5); + ZEPHIR_CONCAT_VS(&_8$$5, &attribute, " IS NULL"); + zephir_array_update_multi(¶ms, &_8$$5, SL("sa"), 3, SL("conditions")); } - zephir_cast_to_string(&_9$$4, &key); - ZEPHIR_CALL_METHOD(&_8$$4, this_ptr, "phphtmlspecialchars", NULL, 0, &_9$$4); - zephir_check_call_status(); - zephir_concat_self(&result, &_8$$4); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&value)) { - zephir_cast_to_string(&_11$$7, &value); - ZEPHIR_CALL_METHOD(&_10$$7, this_ptr, "phphtmlspecialchars", NULL, 0, &_11$$7); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_12$$7); - ZEPHIR_CONCAT_SVS(&_12$$7, "=\"", &_10$$7, "\""); - zephir_concat_self(&result, &_12$$7); + if (zephir_is_true(&except)) { + _9$$6 = Z_TYPE_P(&except) == IS_ARRAY; + if (_9$$6) { + ZEPHIR_INIT_NVAR(&_10$$6); + zephir_array_keys(&_10$$6, &except); + ZVAL_LONG(&_11$$6, 0); + ZVAL_LONG(&_12$$6, (zephir_fast_count_int(&except) - 1)); + ZEPHIR_CALL_FUNCTION(&_13$$6, "range", &_14, 314, &_11$$6, &_12$$6); + zephir_check_call_status(); + _9$$6 = !ZEPHIR_IS_IDENTICAL(&_10$$6, &_13$$6); + } + if (_9$$6) { + zephir_is_iterable(&except, 0, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 358); + if (Z_TYPE_P(&except) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&except), _17$$7, _18$$7, _15$$7) + { + ZEPHIR_INIT_NVAR(&singleField); + if (_18$$7 != NULL) { + ZVAL_STR_COPY(&singleField, _18$$7); + } else { + ZVAL_LONG(&singleField, _17$$7); + } + ZEPHIR_INIT_NVAR(&fieldExcept); + ZVAL_COPY(&fieldExcept, _15$$7); + ZEPHIR_INIT_NVAR(¬InValues); + array_init(¬InValues); + ZEPHIR_INIT_NVAR(&_20$$8); + ZVAL_STRING(&_20$$8, "attribute"); + ZEPHIR_CALL_METHOD(&_19$$8, this_ptr, "getoption", NULL, 0, &_20$$8, &singleField); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&attribute, this_ptr, "getcolumnnamereal", &_5, 0, record, &_19$$8); + zephir_check_call_status(); + if (Z_TYPE_P(&fieldExcept) == IS_ARRAY) { + zephir_is_iterable(&fieldExcept, 0, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 351); + if (Z_TYPE_P(&fieldExcept) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&fieldExcept), _21$$9) + { + ZEPHIR_INIT_NVAR(&singleExcept); + ZVAL_COPY(&singleExcept, _21$$9); + ZEPHIR_INIT_NVAR(&_23$$10); + ZVAL_LONG(&_23$$10, index); + ZEPHIR_INIT_NVAR(&_24$$10); + ZEPHIR_CONCAT_SV(&_24$$10, "?", &_23$$10); + zephir_array_append(¬InValues, &_24$$10, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 346); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &fieldExcept, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_22$$9, &fieldExcept, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_22$$9)) { + break; + } + ZEPHIR_CALL_METHOD(&singleExcept, &fieldExcept, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_25$$11); + ZVAL_LONG(&_25$$11, index); + ZEPHIR_INIT_NVAR(&_26$$11); + ZEPHIR_CONCAT_SV(&_26$$11, "?", &_25$$11); + zephir_array_append(¬InValues, &_26$$11, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 346); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + ZEPHIR_CALL_METHOD(NULL, &fieldExcept, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&singleExcept); + ZEPHIR_INIT_NVAR(&_27$$9); + zephir_fast_join_str(&_27$$9, SL(","), ¬InValues); + ZEPHIR_INIT_NVAR(&_28$$9); + ZEPHIR_CONCAT_VSVS(&_28$$9, &attribute, " NOT IN (", &_27$$9, ")"); + zephir_array_append(&exceptConditions, &_28$$9, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 351); + } else { + ZEPHIR_INIT_NVAR(&_29$$12); + ZVAL_LONG(&_29$$12, index); + ZEPHIR_INIT_NVAR(&_30$$12); + ZEPHIR_CONCAT_VSV(&_30$$12, &attribute, " <> ?", &_29$$12); + zephir_array_append(&exceptConditions, &_30$$12, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 353); + zephir_array_update_multi(¶ms, &fieldExcept, SL("sa"), 3, SL("bind")); + index++; + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &except, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_16$$7, &except, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_16$$7)) { + break; + } + ZEPHIR_CALL_METHOD(&singleField, &except, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&fieldExcept, &except, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(¬InValues); + array_init(¬InValues); + ZEPHIR_INIT_NVAR(&_32$$13); + ZVAL_STRING(&_32$$13, "attribute"); + ZEPHIR_CALL_METHOD(&_31$$13, this_ptr, "getoption", NULL, 0, &_32$$13, &singleField); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&attribute, this_ptr, "getcolumnnamereal", &_5, 0, record, &_31$$13); + zephir_check_call_status(); + if (Z_TYPE_P(&fieldExcept) == IS_ARRAY) { + zephir_is_iterable(&fieldExcept, 0, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 351); + if (Z_TYPE_P(&fieldExcept) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&fieldExcept), _33$$14) + { + ZEPHIR_INIT_NVAR(&singleExcept); + ZVAL_COPY(&singleExcept, _33$$14); + ZEPHIR_INIT_NVAR(&_35$$15); + ZVAL_LONG(&_35$$15, index); + ZEPHIR_INIT_NVAR(&_36$$15); + ZEPHIR_CONCAT_SV(&_36$$15, "?", &_35$$15); + zephir_array_append(¬InValues, &_36$$15, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 346); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &fieldExcept, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_34$$14, &fieldExcept, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_34$$14)) { + break; + } + ZEPHIR_CALL_METHOD(&singleExcept, &fieldExcept, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_37$$16); + ZVAL_LONG(&_37$$16, index); + ZEPHIR_INIT_NVAR(&_38$$16); + ZEPHIR_CONCAT_SV(&_38$$16, "?", &_37$$16); + zephir_array_append(¬InValues, &_38$$16, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 346); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + ZEPHIR_CALL_METHOD(NULL, &fieldExcept, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&singleExcept); + ZEPHIR_INIT_NVAR(&_39$$14); + zephir_fast_join_str(&_39$$14, SL(","), ¬InValues); + ZEPHIR_INIT_NVAR(&_40$$14); + ZEPHIR_CONCAT_VSVS(&_40$$14, &attribute, " NOT IN (", &_39$$14, ")"); + zephir_array_append(&exceptConditions, &_40$$14, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 351); + } else { + ZEPHIR_INIT_NVAR(&_41$$17); + ZVAL_LONG(&_41$$17, index); + ZEPHIR_INIT_NVAR(&_42$$17); + ZEPHIR_CONCAT_VSV(&_42$$17, &attribute, " <> ?", &_41$$17); + zephir_array_append(&exceptConditions, &_42$$17, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 353); + zephir_array_update_multi(¶ms, &fieldExcept, SL("sa"), 3, SL("bind")); + index++; + } + ZEPHIR_CALL_METHOD(NULL, &except, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&fieldExcept); + ZEPHIR_INIT_NVAR(&singleField); + } else if (zephir_fast_count_int(&field) == 1) { + zephir_array_fetch_long(&_44$$18, &field, 0, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 361); + ZEPHIR_INIT_NVAR(&_45$$18); + ZVAL_STRING(&_45$$18, "attribute"); + ZEPHIR_CALL_METHOD(&_43$$18, this_ptr, "getoption", NULL, 0, &_45$$18, &_44$$18); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&attribute, this_ptr, "getcolumnnamereal", &_5, 0, record, &_43$$18); + zephir_check_call_status(); + if (Z_TYPE_P(&except) == IS_ARRAY) { + zephir_is_iterable(&except, 0, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 371); + if (Z_TYPE_P(&except) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&except), _46$$19) + { + ZEPHIR_INIT_NVAR(&singleExcept); + ZVAL_COPY(&singleExcept, _46$$19); + ZEPHIR_INIT_NVAR(&_48$$20); + ZVAL_LONG(&_48$$20, index); + ZEPHIR_INIT_NVAR(&_49$$20); + ZEPHIR_CONCAT_SV(&_49$$20, "?", &_48$$20); + zephir_array_append(¬InValues, &_49$$20, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 366); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &except, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_47$$19, &except, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_47$$19)) { + break; + } + ZEPHIR_CALL_METHOD(&singleExcept, &except, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_50$$21); + ZVAL_LONG(&_50$$21, index); + ZEPHIR_INIT_NVAR(&_51$$21); + ZEPHIR_CONCAT_SV(&_51$$21, "?", &_50$$21); + zephir_array_append(¬InValues, &_51$$21, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 366); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + ZEPHIR_CALL_METHOD(NULL, &except, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&singleExcept); + ZEPHIR_INIT_NVAR(&_52$$19); + zephir_fast_join_str(&_52$$19, SL(","), ¬InValues); + ZEPHIR_INIT_NVAR(&_53$$19); + ZEPHIR_CONCAT_VSVS(&_53$$19, &attribute, " NOT IN (", &_52$$19, ")"); + zephir_array_append(&exceptConditions, &_53$$19, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 371); + } else { + ZEPHIR_INIT_NVAR(&_54$$22); + ZVAL_LONG(&_54$$22, index); + ZEPHIR_INIT_NVAR(&_55$$22); + ZEPHIR_CONCAT_VSV(&_55$$22, &attribute, " <> ?", &_54$$22); + zephir_array_update_multi(¶ms, &_55$$22, SL("sa"), 3, SL("conditions")); + zephir_array_update_multi(¶ms, &except, SL("sa"), 3, SL("bind")); + index++; + } + } else if (zephir_fast_count_int(&field) > 1) { + zephir_is_iterable(&field, 0, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 398); + if (Z_TYPE_P(&field) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&field), _56$$23) + { + ZEPHIR_INIT_NVAR(&singleField); + ZVAL_COPY(&singleField, _56$$23); + ZEPHIR_INIT_NVAR(&_59$$24); + ZVAL_STRING(&_59$$24, "attribute"); + ZEPHIR_CALL_METHOD(&_58$$24, this_ptr, "getoption", NULL, 0, &_59$$24, &singleField); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&attribute, this_ptr, "getcolumnnamereal", &_5, 0, record, &_58$$24); + zephir_check_call_status(); + if (Z_TYPE_P(&except) == IS_ARRAY) { + zephir_is_iterable(&except, 0, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 391); + if (Z_TYPE_P(&except) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&except), _60$$25) + { + ZEPHIR_INIT_NVAR(&singleExcept); + ZVAL_COPY(&singleExcept, _60$$25); + ZEPHIR_INIT_NVAR(&_62$$26); + ZVAL_LONG(&_62$$26, index); + ZEPHIR_INIT_NVAR(&_63$$26); + ZEPHIR_CONCAT_SV(&_63$$26, "?", &_62$$26); + zephir_array_append(¬InValues, &_63$$26, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 386); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &except, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_61$$25, &except, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_61$$25)) { + break; + } + ZEPHIR_CALL_METHOD(&singleExcept, &except, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_64$$27); + ZVAL_LONG(&_64$$27, index); + ZEPHIR_INIT_NVAR(&_65$$27); + ZEPHIR_CONCAT_SV(&_65$$27, "?", &_64$$27); + zephir_array_append(¬InValues, &_65$$27, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 386); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + ZEPHIR_CALL_METHOD(NULL, &except, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&singleExcept); + ZEPHIR_INIT_NVAR(&_66$$25); + zephir_fast_join_str(&_66$$25, SL(","), ¬InValues); + ZEPHIR_INIT_NVAR(&_67$$25); + ZEPHIR_CONCAT_VSVS(&_67$$25, &attribute, " NOT IN (", &_66$$25, ")"); + zephir_array_append(&exceptConditions, &_67$$25, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 391); + } else { + ZEPHIR_INIT_NVAR(&_68$$28); + ZVAL_LONG(&_68$$28, index); + ZEPHIR_INIT_NVAR(&_69$$28); + ZEPHIR_CONCAT_VSV(&_69$$28, &attribute, " <> ?", &_68$$28); + zephir_array_update_multi(¶ms, &_69$$28, SL("sa"), 3, SL("conditions")); + zephir_array_update_multi(¶ms, &except, SL("sa"), 3, SL("bind")); + index++; + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &field, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_57$$23, &field, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_57$$23)) { + break; + } + ZEPHIR_CALL_METHOD(&singleField, &field, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_71$$29); + ZVAL_STRING(&_71$$29, "attribute"); + ZEPHIR_CALL_METHOD(&_70$$29, this_ptr, "getoption", NULL, 0, &_71$$29, &singleField); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&attribute, this_ptr, "getcolumnnamereal", &_5, 0, record, &_70$$29); + zephir_check_call_status(); + if (Z_TYPE_P(&except) == IS_ARRAY) { + zephir_is_iterable(&except, 0, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 391); + if (Z_TYPE_P(&except) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&except), _72$$30) + { + ZEPHIR_INIT_NVAR(&singleExcept); + ZVAL_COPY(&singleExcept, _72$$30); + ZEPHIR_INIT_NVAR(&_74$$31); + ZVAL_LONG(&_74$$31, index); + ZEPHIR_INIT_NVAR(&_75$$31); + ZEPHIR_CONCAT_SV(&_75$$31, "?", &_74$$31); + zephir_array_append(¬InValues, &_75$$31, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 386); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &except, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_73$$30, &except, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_73$$30)) { + break; + } + ZEPHIR_CALL_METHOD(&singleExcept, &except, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_76$$32); + ZVAL_LONG(&_76$$32, index); + ZEPHIR_INIT_NVAR(&_77$$32); + ZEPHIR_CONCAT_SV(&_77$$32, "?", &_76$$32); + zephir_array_append(¬InValues, &_77$$32, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 386); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + ZEPHIR_CALL_METHOD(NULL, &except, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&singleExcept); + ZEPHIR_INIT_NVAR(&_78$$30); + zephir_fast_join_str(&_78$$30, SL(","), ¬InValues); + ZEPHIR_INIT_NVAR(&_79$$30); + ZEPHIR_CONCAT_VSVS(&_79$$30, &attribute, " NOT IN (", &_78$$30, ")"); + zephir_array_append(&exceptConditions, &_79$$30, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 391); + } else { + ZEPHIR_INIT_NVAR(&_80$$33); + ZVAL_LONG(&_80$$33, index); + ZEPHIR_INIT_NVAR(&_81$$33); + ZEPHIR_CONCAT_VSV(&_81$$33, &attribute, " <> ?", &_80$$33); + zephir_array_update_multi(¶ms, &_81$$33, SL("sa"), 3, SL("conditions")); + zephir_array_update_multi(¶ms, &except, SL("sa"), 3, SL("bind")); + index++; + } + ZEPHIR_CALL_METHOD(NULL, &field, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&singleField); + } } - zephir_concat_self_str(&result, SL(" ")); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, input, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &field, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_2, input, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_2, &field, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_2)) { break; } - ZEPHIR_CALL_METHOD(&key, input, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, input, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&singleField, &field, "current", NULL, 0); zephir_check_call_status(); - _13$$8 = Z_TYPE_P(&value) == IS_NULL; - if (!(_13$$8)) { - _13$$8 = ZEPHIR_IS_FALSE_IDENTICAL(&value); - } - if (_13$$8) { - continue; - } - ZEPHIR_INIT_NVAR(&_14$$8); - zephir_fast_trim(&_14$$8, &key, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_CPY_WRT(&key, &_14$$8); - if (Z_TYPE_P(&value) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_15$$10); - zephir_fast_join_str(&_15$$10, SL(" "), &value); - ZEPHIR_CPY_WRT(&value, &_15$$10); - } - zephir_cast_to_string(&_17$$8, &key); - ZEPHIR_CALL_METHOD(&_16$$8, this_ptr, "phphtmlspecialchars", NULL, 0, &_17$$8); + ZEPHIR_INIT_NVAR(&fieldExcept); + ZVAL_NULL(&fieldExcept); + ZEPHIR_INIT_NVAR(¬InValues); + array_init(¬InValues); + ZEPHIR_OBS_NVAR(&value); + zephir_array_fetch(&value, &values, &singleField, PH_NOISY, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 322); + ZEPHIR_INIT_NVAR(&_82$$34); + ZVAL_STRING(&_82$$34, "attribute"); + ZEPHIR_CALL_METHOD(&attribute, this_ptr, "getoption", NULL, 0, &_82$$34, &singleField); zephir_check_call_status(); - zephir_concat_self(&result, &_16$$8); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&value)) { - zephir_cast_to_string(&_19$$11, &value); - ZEPHIR_CALL_METHOD(&_18$$11, this_ptr, "phphtmlspecialchars", NULL, 0, &_19$$11); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_20$$11); - ZEPHIR_CONCAT_SVS(&_20$$11, "=\"", &_18$$11, "\""); - zephir_concat_self(&result, &_20$$11); + ZEPHIR_CALL_METHOD(&_83$$34, this_ptr, "getcolumnnamereal", &_5, 0, record, &attribute); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&attribute, &_83$$34); + if (Z_TYPE_P(&value) != IS_NULL) { + ZEPHIR_INIT_NVAR(&_84$$35); + ZVAL_LONG(&_84$$35, index); + ZEPHIR_INIT_NVAR(&_85$$35); + ZEPHIR_CONCAT_VSV(&_85$$35, &attribute, " = ?", &_84$$35); + zephir_array_update_multi(¶ms, &_85$$35, SL("sa"), 3, SL("conditions")); + zephir_array_update_multi(¶ms, &value, SL("sa"), 3, SL("bind")); + index++; + } else { + ZEPHIR_INIT_NVAR(&_86$$36); + ZEPHIR_CONCAT_VS(&_86$$36, &attribute, " IS NULL"); + zephir_array_update_multi(¶ms, &_86$$36, SL("sa"), 3, SL("conditions")); } - zephir_concat_self_str(&result, SL(" ")); - ZEPHIR_CALL_METHOD(NULL, input, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - zephir_fast_trim(return_value, &result, NULL , ZEPHIR_TRIM_RIGHT); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Html_Escaper, css) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL, _0; - zval input; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(input) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &input_param); - zephir_get_strval(&input, input_param); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "normalizeencoding", NULL, 321, &input); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "doescapecss", NULL, 322, &_0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Html_Escaper, detectEncoding) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL, __$true, charset, _1, *_2, _3, _4$$5, _6$$7; - zval input; - - ZVAL_UNDEF(&input); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&charset); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(input) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &input_param); - zephir_get_strval(&input, input_param); - ZEPHIR_INIT_VAR(&charset); - zephir_is_basic_charset(&charset, &input); - if (Z_TYPE_P(&charset) == IS_STRING) { - RETURN_CCTOR(&charset); - } - if (!((zephir_function_exists_ex(ZEND_STRL("mb_detect_encoding")) == SUCCESS))) { - RETURN_MM_NULL(); - } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 4, 0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "UTF-32"); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "UTF-8"); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "ISO-8859-1"); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "ASCII"); - zephir_array_fast_append(&_0, &_1); - zephir_is_iterable(&_0, 0, "phalcon/Html/Escaper.zep", 158); - if (Z_TYPE_P(&_0) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _2) - { - ZEPHIR_INIT_NVAR(&charset); - ZVAL_COPY(&charset, _2); - ZEPHIR_CALL_FUNCTION(&_4$$5, "mb_detect_encoding", &_5, 323, &input, &charset, &__$true); + if (zephir_is_true(&except)) { + _87$$37 = Z_TYPE_P(&except) == IS_ARRAY; + if (_87$$37) { + ZEPHIR_INIT_NVAR(&_88$$37); + zephir_array_keys(&_88$$37, &except); + ZVAL_LONG(&_89$$37, 0); + ZVAL_LONG(&_90$$37, (zephir_fast_count_int(&except) - 1)); + ZEPHIR_CALL_FUNCTION(&_91$$37, "range", &_14, 314, &_89$$37, &_90$$37); + zephir_check_call_status(); + _87$$37 = !ZEPHIR_IS_IDENTICAL(&_88$$37, &_91$$37); + } + if (_87$$37) { + zephir_is_iterable(&except, 0, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 358); + if (Z_TYPE_P(&except) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&except), _94$$38, _95$$38, _92$$38) + { + ZEPHIR_INIT_NVAR(&singleField); + if (_95$$38 != NULL) { + ZVAL_STR_COPY(&singleField, _95$$38); + } else { + ZVAL_LONG(&singleField, _94$$38); + } + ZEPHIR_INIT_NVAR(&fieldExcept); + ZVAL_COPY(&fieldExcept, _92$$38); + ZEPHIR_INIT_NVAR(¬InValues); + array_init(¬InValues); + ZEPHIR_INIT_NVAR(&_97$$39); + ZVAL_STRING(&_97$$39, "attribute"); + ZEPHIR_CALL_METHOD(&_96$$39, this_ptr, "getoption", NULL, 0, &_97$$39, &singleField); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&attribute, this_ptr, "getcolumnnamereal", &_5, 0, record, &_96$$39); + zephir_check_call_status(); + if (Z_TYPE_P(&fieldExcept) == IS_ARRAY) { + zephir_is_iterable(&fieldExcept, 0, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 351); + if (Z_TYPE_P(&fieldExcept) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&fieldExcept), _98$$40) + { + ZEPHIR_INIT_NVAR(&singleExcept); + ZVAL_COPY(&singleExcept, _98$$40); + ZEPHIR_INIT_NVAR(&_100$$41); + ZVAL_LONG(&_100$$41, index); + ZEPHIR_INIT_NVAR(&_101$$41); + ZEPHIR_CONCAT_SV(&_101$$41, "?", &_100$$41); + zephir_array_append(¬InValues, &_101$$41, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 346); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &fieldExcept, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_99$$40, &fieldExcept, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_99$$40)) { + break; + } + ZEPHIR_CALL_METHOD(&singleExcept, &fieldExcept, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_102$$42); + ZVAL_LONG(&_102$$42, index); + ZEPHIR_INIT_NVAR(&_103$$42); + ZEPHIR_CONCAT_SV(&_103$$42, "?", &_102$$42); + zephir_array_append(¬InValues, &_103$$42, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 346); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + ZEPHIR_CALL_METHOD(NULL, &fieldExcept, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&singleExcept); + ZEPHIR_INIT_NVAR(&_104$$40); + zephir_fast_join_str(&_104$$40, SL(","), ¬InValues); + ZEPHIR_INIT_NVAR(&_105$$40); + ZEPHIR_CONCAT_VSVS(&_105$$40, &attribute, " NOT IN (", &_104$$40, ")"); + zephir_array_append(&exceptConditions, &_105$$40, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 351); + } else { + ZEPHIR_INIT_NVAR(&_106$$43); + ZVAL_LONG(&_106$$43, index); + ZEPHIR_INIT_NVAR(&_107$$43); + ZEPHIR_CONCAT_VSV(&_107$$43, &attribute, " <> ?", &_106$$43); + zephir_array_append(&exceptConditions, &_107$$43, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 353); + zephir_array_update_multi(¶ms, &fieldExcept, SL("sa"), 3, SL("bind")); + index++; + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &except, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_93$$38, &except, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_93$$38)) { + break; + } + ZEPHIR_CALL_METHOD(&singleField, &except, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&fieldExcept, &except, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(¬InValues); + array_init(¬InValues); + ZEPHIR_INIT_NVAR(&_109$$44); + ZVAL_STRING(&_109$$44, "attribute"); + ZEPHIR_CALL_METHOD(&_108$$44, this_ptr, "getoption", NULL, 0, &_109$$44, &singleField); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&attribute, this_ptr, "getcolumnnamereal", &_5, 0, record, &_108$$44); + zephir_check_call_status(); + if (Z_TYPE_P(&fieldExcept) == IS_ARRAY) { + zephir_is_iterable(&fieldExcept, 0, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 351); + if (Z_TYPE_P(&fieldExcept) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&fieldExcept), _110$$45) + { + ZEPHIR_INIT_NVAR(&singleExcept); + ZVAL_COPY(&singleExcept, _110$$45); + ZEPHIR_INIT_NVAR(&_112$$46); + ZVAL_LONG(&_112$$46, index); + ZEPHIR_INIT_NVAR(&_113$$46); + ZEPHIR_CONCAT_SV(&_113$$46, "?", &_112$$46); + zephir_array_append(¬InValues, &_113$$46, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 346); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &fieldExcept, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_111$$45, &fieldExcept, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_111$$45)) { + break; + } + ZEPHIR_CALL_METHOD(&singleExcept, &fieldExcept, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_114$$47); + ZVAL_LONG(&_114$$47, index); + ZEPHIR_INIT_NVAR(&_115$$47); + ZEPHIR_CONCAT_SV(&_115$$47, "?", &_114$$47); + zephir_array_append(¬InValues, &_115$$47, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 346); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + ZEPHIR_CALL_METHOD(NULL, &fieldExcept, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&singleExcept); + ZEPHIR_INIT_NVAR(&_116$$45); + zephir_fast_join_str(&_116$$45, SL(","), ¬InValues); + ZEPHIR_INIT_NVAR(&_117$$45); + ZEPHIR_CONCAT_VSVS(&_117$$45, &attribute, " NOT IN (", &_116$$45, ")"); + zephir_array_append(&exceptConditions, &_117$$45, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 351); + } else { + ZEPHIR_INIT_NVAR(&_118$$48); + ZVAL_LONG(&_118$$48, index); + ZEPHIR_INIT_NVAR(&_119$$48); + ZEPHIR_CONCAT_VSV(&_119$$48, &attribute, " <> ?", &_118$$48); + zephir_array_append(&exceptConditions, &_119$$48, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 353); + zephir_array_update_multi(¶ms, &fieldExcept, SL("sa"), 3, SL("bind")); + index++; + } + ZEPHIR_CALL_METHOD(NULL, &except, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&fieldExcept); + ZEPHIR_INIT_NVAR(&singleField); + } else if (zephir_fast_count_int(&field) == 1) { + zephir_array_fetch_long(&_121$$49, &field, 0, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 361); + ZEPHIR_INIT_NVAR(&_122$$49); + ZVAL_STRING(&_122$$49, "attribute"); + ZEPHIR_CALL_METHOD(&_120$$49, this_ptr, "getoption", NULL, 0, &_122$$49, &_121$$49); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&attribute, this_ptr, "getcolumnnamereal", &_5, 0, record, &_120$$49); + zephir_check_call_status(); + if (Z_TYPE_P(&except) == IS_ARRAY) { + zephir_is_iterable(&except, 0, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 371); + if (Z_TYPE_P(&except) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&except), _123$$50) + { + ZEPHIR_INIT_NVAR(&singleExcept); + ZVAL_COPY(&singleExcept, _123$$50); + ZEPHIR_INIT_NVAR(&_125$$51); + ZVAL_LONG(&_125$$51, index); + ZEPHIR_INIT_NVAR(&_126$$51); + ZEPHIR_CONCAT_SV(&_126$$51, "?", &_125$$51); + zephir_array_append(¬InValues, &_126$$51, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 366); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &except, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_124$$50, &except, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_124$$50)) { + break; + } + ZEPHIR_CALL_METHOD(&singleExcept, &except, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_127$$52); + ZVAL_LONG(&_127$$52, index); + ZEPHIR_INIT_NVAR(&_128$$52); + ZEPHIR_CONCAT_SV(&_128$$52, "?", &_127$$52); + zephir_array_append(¬InValues, &_128$$52, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 366); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + ZEPHIR_CALL_METHOD(NULL, &except, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&singleExcept); + ZEPHIR_INIT_NVAR(&_129$$50); + zephir_fast_join_str(&_129$$50, SL(","), ¬InValues); + ZEPHIR_INIT_NVAR(&_130$$50); + ZEPHIR_CONCAT_VSVS(&_130$$50, &attribute, " NOT IN (", &_129$$50, ")"); + zephir_array_append(&exceptConditions, &_130$$50, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 371); + } else { + ZEPHIR_INIT_NVAR(&_131$$53); + ZVAL_LONG(&_131$$53, index); + ZEPHIR_INIT_NVAR(&_132$$53); + ZEPHIR_CONCAT_VSV(&_132$$53, &attribute, " <> ?", &_131$$53); + zephir_array_update_multi(¶ms, &_132$$53, SL("sa"), 3, SL("conditions")); + zephir_array_update_multi(¶ms, &except, SL("sa"), 3, SL("bind")); + index++; + } + } else if (zephir_fast_count_int(&field) > 1) { + zephir_is_iterable(&field, 0, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 398); + if (Z_TYPE_P(&field) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&field), _133$$54) + { + ZEPHIR_INIT_NVAR(&singleField); + ZVAL_COPY(&singleField, _133$$54); + ZEPHIR_INIT_NVAR(&_136$$55); + ZVAL_STRING(&_136$$55, "attribute"); + ZEPHIR_CALL_METHOD(&_135$$55, this_ptr, "getoption", NULL, 0, &_136$$55, &singleField); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&attribute, this_ptr, "getcolumnnamereal", &_5, 0, record, &_135$$55); + zephir_check_call_status(); + if (Z_TYPE_P(&except) == IS_ARRAY) { + zephir_is_iterable(&except, 0, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 391); + if (Z_TYPE_P(&except) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&except), _137$$56) + { + ZEPHIR_INIT_NVAR(&singleExcept); + ZVAL_COPY(&singleExcept, _137$$56); + ZEPHIR_INIT_NVAR(&_139$$57); + ZVAL_LONG(&_139$$57, index); + ZEPHIR_INIT_NVAR(&_140$$57); + ZEPHIR_CONCAT_SV(&_140$$57, "?", &_139$$57); + zephir_array_append(¬InValues, &_140$$57, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 386); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &except, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_138$$56, &except, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_138$$56)) { + break; + } + ZEPHIR_CALL_METHOD(&singleExcept, &except, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_141$$58); + ZVAL_LONG(&_141$$58, index); + ZEPHIR_INIT_NVAR(&_142$$58); + ZEPHIR_CONCAT_SV(&_142$$58, "?", &_141$$58); + zephir_array_append(¬InValues, &_142$$58, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 386); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + ZEPHIR_CALL_METHOD(NULL, &except, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&singleExcept); + ZEPHIR_INIT_NVAR(&_143$$56); + zephir_fast_join_str(&_143$$56, SL(","), ¬InValues); + ZEPHIR_INIT_NVAR(&_144$$56); + ZEPHIR_CONCAT_VSVS(&_144$$56, &attribute, " NOT IN (", &_143$$56, ")"); + zephir_array_append(&exceptConditions, &_144$$56, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 391); + } else { + ZEPHIR_INIT_NVAR(&_145$$59); + ZVAL_LONG(&_145$$59, index); + ZEPHIR_INIT_NVAR(&_146$$59); + ZEPHIR_CONCAT_VSV(&_146$$59, &attribute, " <> ?", &_145$$59); + zephir_array_update_multi(¶ms, &_146$$59, SL("sa"), 3, SL("conditions")); + zephir_array_update_multi(¶ms, &except, SL("sa"), 3, SL("bind")); + index++; + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &field, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_134$$54, &field, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_134$$54)) { + break; + } + ZEPHIR_CALL_METHOD(&singleField, &field, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_148$$60); + ZVAL_STRING(&_148$$60, "attribute"); + ZEPHIR_CALL_METHOD(&_147$$60, this_ptr, "getoption", NULL, 0, &_148$$60, &singleField); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&attribute, this_ptr, "getcolumnnamereal", &_5, 0, record, &_147$$60); + zephir_check_call_status(); + if (Z_TYPE_P(&except) == IS_ARRAY) { + zephir_is_iterable(&except, 0, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 391); + if (Z_TYPE_P(&except) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&except), _149$$61) + { + ZEPHIR_INIT_NVAR(&singleExcept); + ZVAL_COPY(&singleExcept, _149$$61); + ZEPHIR_INIT_NVAR(&_151$$62); + ZVAL_LONG(&_151$$62, index); + ZEPHIR_INIT_NVAR(&_152$$62); + ZEPHIR_CONCAT_SV(&_152$$62, "?", &_151$$62); + zephir_array_append(¬InValues, &_152$$62, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 386); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &except, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_150$$61, &except, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_150$$61)) { + break; + } + ZEPHIR_CALL_METHOD(&singleExcept, &except, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_153$$63); + ZVAL_LONG(&_153$$63, index); + ZEPHIR_INIT_NVAR(&_154$$63); + ZEPHIR_CONCAT_SV(&_154$$63, "?", &_153$$63); + zephir_array_append(¬InValues, &_154$$63, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 386); + zephir_array_update_multi(¶ms, &singleExcept, SL("sa"), 3, SL("bind")); + index++; + ZEPHIR_CALL_METHOD(NULL, &except, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&singleExcept); + ZEPHIR_INIT_NVAR(&_155$$61); + zephir_fast_join_str(&_155$$61, SL(","), ¬InValues); + ZEPHIR_INIT_NVAR(&_156$$61); + ZEPHIR_CONCAT_VSVS(&_156$$61, &attribute, " NOT IN (", &_155$$61, ")"); + zephir_array_append(&exceptConditions, &_156$$61, PH_SEPARATE, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 391); + } else { + ZEPHIR_INIT_NVAR(&_157$$64); + ZVAL_LONG(&_157$$64, index); + ZEPHIR_INIT_NVAR(&_158$$64); + ZEPHIR_CONCAT_VSV(&_158$$64, &attribute, " <> ?", &_157$$64); + zephir_array_update_multi(¶ms, &_158$$64, SL("sa"), 3, SL("conditions")); + zephir_array_update_multi(¶ms, &except, SL("sa"), 3, SL("bind")); + index++; + } + ZEPHIR_CALL_METHOD(NULL, &field, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&singleField); + } + } + ZEPHIR_CALL_METHOD(NULL, &field, "next", NULL, 0); zephir_check_call_status(); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_4$$5)) { - RETURN_CCTOR(&charset); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + } + } + ZEPHIR_INIT_NVAR(&singleField); + ZEPHIR_CALL_METHOD(&_159, record, "getdirtystate", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG(&_159, 0)) { + ZEPHIR_CALL_METHOD(&_160$$65, record, "getdi", NULL, 0); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &_0, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3)) { - break; - } - ZEPHIR_CALL_METHOD(&charset, &_0, "current", NULL, 0); + ZEPHIR_INIT_VAR(&_161$$65); + ZVAL_STRING(&_161$$65, "modelsMetadata"); + ZEPHIR_CALL_METHOD(&metaData, &_160$$65, "getshared", NULL, 0, &_161$$65); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_162$$65, &metaData, "getprimarykeyattributes", NULL, 0, record); + zephir_check_call_status(); + zephir_is_iterable(&_162$$65, 0, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 417); + if (Z_TYPE_P(&_162$$65) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_162$$65), _163$$65) + { + ZEPHIR_INIT_NVAR(&primaryField); + ZVAL_COPY(&primaryField, _163$$65); + ZEPHIR_CALL_METHOD(&_165$$66, this_ptr, "getcolumnnamereal", &_5, 0, record, &primaryField); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_166$$66); + ZVAL_LONG(&_166$$66, index); + ZEPHIR_INIT_NVAR(&_167$$66); + ZEPHIR_CONCAT_VSV(&_167$$66, &_165$$66, " <> ?", &_166$$66); + zephir_array_update_multi(¶ms, &_167$$66, SL("sa"), 3, SL("conditions")); + ZEPHIR_CALL_METHOD(&_169$$66, this_ptr, "getcolumnnamereal", &_5, 0, record, &primaryField); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_168$$66, record, "readattribute", NULL, 0, &_169$$66); + zephir_check_call_status(); + zephir_array_update_multi(¶ms, &_168$$66, SL("sa"), 3, SL("bind")); + index++; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_162$$65, "rewind", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_6$$7, "mb_detect_encoding", &_5, 323, &input, &charset, &__$true); + while (1) { + ZEPHIR_CALL_METHOD(&_164$$65, &_162$$65, "valid", NULL, 0); zephir_check_call_status(); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_6$$7)) { - RETURN_CCTOR(&charset); + if (!zend_is_true(&_164$$65)) { + break; } - ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); - zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&primaryField, &_162$$65, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_170$$67, this_ptr, "getcolumnnamereal", &_5, 0, record, &primaryField); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_171$$67); + ZVAL_LONG(&_171$$67, index); + ZEPHIR_INIT_NVAR(&_172$$67); + ZEPHIR_CONCAT_VSV(&_172$$67, &_170$$67, " <> ?", &_171$$67); + zephir_array_update_multi(¶ms, &_172$$67, SL("sa"), 3, SL("conditions")); + ZEPHIR_CALL_METHOD(&_174$$67, this_ptr, "getcolumnnamereal", &_5, 0, record, &primaryField); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_173$$67, record, "readattribute", NULL, 0, &_174$$67); + zephir_check_call_status(); + zephir_array_update_multi(¶ms, &_173$$67, SL("sa"), 3, SL("bind")); + index++; + ZEPHIR_CALL_METHOD(NULL, &_162$$65, "next", NULL, 0); + zephir_check_call_status(); + } } + ZEPHIR_INIT_NVAR(&primaryField); } - ZEPHIR_INIT_NVAR(&charset); - ZEPHIR_RETURN_CALL_FUNCTION("mb_detect_encoding", &_5, 323, &input); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Html_Escaper, escapeCss) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL; - zval input; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&input); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(input) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &input_param); - zephir_get_strval(&input, input_param); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "css", NULL, 0, &input); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Html_Escaper, escapeJs) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL; - zval input; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&input); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(input) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &input_param); - zephir_get_strval(&input, input_param); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "js", NULL, 0, &input); - zephir_check_call_status(); - RETURN_MM(); + if (!(ZEPHIR_IS_EMPTY(&exceptConditions))) { + ZEPHIR_INIT_VAR(&_175$$68); + zephir_fast_join_str(&_175$$68, SL(" OR "), &exceptConditions); + ZEPHIR_INIT_VAR(&_176$$68); + ZEPHIR_CONCAT_SVS(&_176$$68, "(", &_175$$68, ")"); + zephir_array_update_multi(¶ms, &_176$$68, SL("sa"), 3, SL("conditions")); + } + ZEPHIR_INIT_NVAR(&_0); + zephir_array_fetch_string(&_177, ¶ms, SL("conditions"), PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/Uniqueness.zep", 426); + zephir_fast_join_str(&_0, SL(" AND "), &_177); + zephir_array_update_string(¶ms, SL("conditions"), &_0, PH_COPY | PH_SEPARATE); + RETURN_CCTOR(¶ms); } -static PHP_METHOD(Phalcon_Html_Escaper, escapeHtml) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL; - zval input, _0; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(input) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &input_param); - if (!input_param) { - ZEPHIR_INIT_VAR(&input); - } else { - zephir_get_strval(&input, input_param); - } - zephir_cast_to_string(&_0, &input); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "html", NULL, 0, &_0); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Html_Escaper, escapeHtmlAttr) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL; - zval input, _0; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(input) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &input_param); - if (!input_param) { - ZEPHIR_INIT_VAR(&input); - } else { - zephir_get_strval(&input, input_param); - } - zephir_cast_to_string(&_0, &input); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "attributes", NULL, 0, &_0); - zephir_check_call_status(); - RETURN_MM(); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Html_Escaper, escapeUrl) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL; - zval input; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&input); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(input) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &input_param); - zephir_get_strval(&input, input_param); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "url", NULL, 0, &input); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Html_Escaper, getEncoding) -{ - RETURN_MEMBER(getThis(), "encoding"); -} -static PHP_METHOD(Phalcon_Html_Escaper, getFlags) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_Url) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator, Url, phalcon, filter_validation_validator_url, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_url_method_entry, 0); - RETURN_MEMBER(getThis(), "flags"); + zend_declare_property_string(phalcon_filter_validation_validator_url_ce, SL("template"), "Field :field must be a url", ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Escaper, html) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Url, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL, _0, _1, _2; - zval input; - zval *this_ptr = getThis(); + zval *options_param = NULL; + zval options; - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - bool is_null_true = 1; + ZVAL_UNDEF(&options); ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(input) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &input_param); - if (!input_param) { - ZEPHIR_INIT_VAR(&input); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - zephir_get_strval(&input, input_param); - } - if (Z_TYPE_P(&input) == IS_NULL) { - RETURN_MM_STRING(""); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("flags"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_1, this_ptr, ZEND_STRL("encoding"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_2, this_ptr, ZEND_STRL("doubleEncode"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_FUNCTION("htmlspecialchars", NULL, 286, &input, &_0, &_1, &_2); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Html_Escaper, js) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL, _0; - zval input; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(input) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &input_param); - zephir_get_strval(&input, input_param); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "normalizeencoding", NULL, 321, &input); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "doescapejs", NULL, 324, &_0); + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_url_ce, getThis(), "__construct", NULL, 0, &options); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Escaper, normalizeEncoding) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_Url, validate) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL, _0, _1; - zval input; + zval *validation, validation_sub, *field, field_sub, options, result, value, _0, _1, _2$$4, _3$$5, _4$$6; zval *this_ptr = getThis(); - ZVAL_UNDEF(&input); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&value); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(input) + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4$$6); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &input_param); - zephir_get_strval(&input, input_param); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "detectencoding", NULL, 325, &input); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "UTF-32"); - ZEPHIR_RETURN_CALL_FUNCTION("mb_convert_encoding", NULL, 326, &input, &_1, &_0); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "allowempty", NULL, 0, field, &value); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Html_Escaper, setDoubleEncode) -{ - zval *doubleEncode_param = NULL, __$true, __$false; - zend_bool doubleEncode; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(doubleEncode) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &doubleEncode_param); - if (doubleEncode) { - zephir_update_property_zval(this_ptr, ZEND_STRL("doubleEncode"), &__$true); + if (zephir_is_true(&_0)) { + RETURN_MM_BOOL(1); + } + zephir_memory_observe(&options); + zephir_read_property(&_1, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_string_fetch(&options, &_1, SL("options"), 0)) { + ZVAL_LONG(&_2$$4, 273); + ZEPHIR_CALL_FUNCTION(&result, "filter_var", NULL, 283, &value, &_2$$4, &options); + zephir_check_call_status(); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("doubleEncode"), &__$false); + ZVAL_LONG(&_3$$5, 273); + ZEPHIR_CALL_FUNCTION(&result, "filter_var", NULL, 283, &value, &_3$$5); + zephir_check_call_status(); } - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Html_Escaper, setEncoding) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *encoding_param = NULL; - zval encoding; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&encoding); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(encoding) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &encoding_param); - zephir_get_strval(&encoding, encoding_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("encoding"), &encoding); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Html_Escaper, setFlags) -{ - zval *flags_param = NULL, _0; - zend_long flags; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(flags) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &flags_param); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, flags); - zephir_update_property_zval(this_ptr, ZEND_STRL("flags"), &_0); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Html_Escaper, setHtmlQuoteType) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *flags_param = NULL, _0; - zend_long flags, ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(flags) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &flags_param); - ZVAL_LONG(&_0, flags); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "setflags", NULL, 0, &_0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Html_Escaper, url) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL; - zval input; - - ZVAL_UNDEF(&input); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(input) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &input_param); - zephir_get_strval(&input, input_param); - ZEPHIR_RETURN_CALL_FUNCTION("rawurlencode", NULL, 327, &input); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Html_Escaper, phpHtmlSpecialChars) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *input_param = NULL, _0, _1, _2; - zval input; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(input) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &input_param); - zephir_get_strval(&input, input_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("flags"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_1, this_ptr, ZEND_STRL("encoding"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_2, this_ptr, ZEND_STRL("doubleEncode"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_FUNCTION("htmlspecialchars", NULL, 286, &input, &_0, &_1, &_2); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Html_Escaper, doEscapeCss) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *input_param = NULL; - zval input; - - ZVAL_UNDEF(&input); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(input) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &input_param); - zephir_get_strval(&input, input_param); - zephir_escape_css(return_value, &input); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Html_Escaper, doEscapeJs) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *input_param = NULL; - zval input; - - ZVAL_UNDEF(&input); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(input) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &input_param); - zephir_get_strval(&input, input_param); - zephir_escape_js(return_value, &input); - RETURN_MM(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_EscaperFactory) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Html, EscaperFactory, phalcon, html_escaperfactory, phalcon_html_escaperfactory_method_entry, 0); - - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Html_EscaperFactory, newInstance) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - object_init_ex(return_value, phalcon_html_escaper_ce); - if (zephir_has_constructor(return_value)) { - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); + if (!(zephir_is_true(&result))) { + ZEPHIR_CALL_METHOD(&_4$$6, this_ptr, "messagefactory", NULL, 0, validation, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_4$$6); zephir_check_call_status(); + RETURN_MM_BOOL(0); } - - RETURN_MM(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Exception) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html, Exception, phalcon, html_exception, zend_ce_exception, NULL, 0); - - return SUCCESS; + RETURN_MM_BOOL(1); } @@ -118594,337 +118248,517 @@ ZEPHIR_INIT_CLASS(Phalcon_Html_Exception) -ZEPHIR_INIT_CLASS(Phalcon_Html_TagFactory) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_File_AbstractFile) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html, TagFactory, phalcon, html_tagfactory, phalcon_factory_abstractfactory_ce, phalcon_html_tagfactory_method_entry, 0); - - zend_declare_property_null(phalcon_html_tagfactory_ce, SL("escaper"), ZEND_ACC_PRIVATE); - zend_declare_property_null(phalcon_html_tagfactory_ce, SL("services"), ZEND_ACC_PROTECTED); - phalcon_html_tagfactory_ce->create_object = zephir_init_properties_Phalcon_Html_TagFactory; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator\\File, AbstractFile, phalcon, filter_validation_validator_file_abstractfile, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_file_abstractfile_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + zend_declare_property_string(phalcon_filter_validation_validator_file_abstractfile_ce, SL("messageFileEmpty"), "Field :field must not be empty", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_filter_validation_validator_file_abstractfile_ce, SL("messageIniSize"), "File :field exceeds the maximum file size", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_filter_validation_validator_file_abstractfile_ce, SL("messageValid"), "Field :field is not valid", ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_TagFactory, __construct) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_AbstractFile, checkUpload) { + zend_bool _1, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval services; - zval *escaper, escaper_sub, *services_param = NULL; + zval field; + zval *validation, validation_sub, *field_param = NULL, _0, _2, _4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&escaper_sub); - ZVAL_UNDEF(&services); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(escaper, phalcon_html_escaper_escaperinterface_ce) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(services) + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&field); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_STR(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &escaper, &services_param); - if (!services_param) { - ZEPHIR_INIT_VAR(&services); - array_init(&services); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("escaper"), escaper); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); + zephir_fetch_params(1, 2, 0, &validation, &field_param); + zephir_get_strval(&field, field_param); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkuploadmaxsize", NULL, 0, validation, &field); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + _1 = zephir_is_true(&_0); + if (_1) { + ZEPHIR_CALL_METHOD(&_2, this_ptr, "checkuploadisempty", NULL, 0, validation, &field); + zephir_check_call_status(); + _1 = zephir_is_true(&_2); + } + _3 = _1; + if (_3) { + ZEPHIR_CALL_METHOD(&_4, this_ptr, "checkuploadisvalid", NULL, 0, validation, &field); + zephir_check_call_status(); + _3 = zephir_is_true(&_4); + } + RETURN_MM_BOOL(_3); } -static PHP_METHOD(Phalcon_Html_TagFactory, __call) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_AbstractFile, checkUploadIsEmpty) { + zend_bool _0, _1, _2, _4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval arguments, _0; - zval *name_param = NULL, *arguments_param = NULL, helper, _1; - zval name; + zval field; + zval *validation, validation_sub, *field_param = NULL, label, replacePairs, value, _3, _5, _6, _7$$3, _8$$3, _9$$3, _10$$3, _11$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&helper); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&arguments); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&label); + ZVAL_UNDEF(&replacePairs); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$3); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_11$$3); + ZVAL_UNDEF(&field); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_ARRAY(arguments) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_STR(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &arguments_param); - zephir_get_strval(&name, name_param); - zephir_get_arrval(&arguments, arguments_param); - ZEPHIR_CALL_METHOD(&helper, this_ptr, "newinstance", NULL, 0, &name); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 2, 0); - zephir_array_fast_append(&_0, &helper); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "__invoke"); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_0, &arguments); + zephir_fetch_params(1, 2, 0, &validation, &field_param); + zephir_get_strval(&field, field_param); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, &field); zephir_check_call_status(); - RETURN_MM(); + _0 = Z_TYPE_P(&value) == IS_ARRAY; + if (_0) { + _1 = 1 != zephir_array_isset_string(&value, SL("error")); + if (!(_1)) { + _1 = 1 != zephir_array_isset_string(&value, SL("tmp_name")); + } + _2 = _1; + if (!(_2)) { + zephir_array_fetch_string(&_3, &value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/File/AbstractFile.zep", 117); + _2 = !ZEPHIR_IS_LONG_IDENTICAL(&_3, 0); + } + _4 = _2; + if (!(_4)) { + zephir_array_fetch_string(&_6, &value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/File/AbstractFile.zep", 118); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "checkisuploadedfile", NULL, 0, &_6); + zephir_check_call_status(); + _4 = !ZEPHIR_IS_TRUE_IDENTICAL(&_5); + } + _0 = _4; + } + if (_0) { + ZEPHIR_CALL_METHOD(&label, this_ptr, "preparelabel", NULL, 0, validation, &field); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&replacePairs); + zephir_create_array(&replacePairs, 1, 0); + zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_7$$3); + object_init_ex(&_7$$3, phalcon_messages_message_ce); + ZEPHIR_CALL_METHOD(&_8$$3, this_ptr, "getmessagefileempty", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_9$$3, "strtr", NULL, 5, &_8$$3, &replacePairs); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_10$$3); + zephir_get_class(&_10$$3, this_ptr, 0); + ZEPHIR_CALL_METHOD(&_11$$3, this_ptr, "preparecode", NULL, 0, &field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_7$$3, "__construct", NULL, 6, &_9$$3, &field, &_10$$3, &_11$$3); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_7$$3); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Html_TagFactory, has) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_AbstractFile, checkUploadIsValid) { + zend_bool _0, _1, _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, _0; - zval name; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval field; + zval *validation, validation_sub, *field_param = NULL, label, replacePairs, value, _3$$3, _4$$3, _5$$3, _6$$3, _7$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&label); + ZVAL_UNDEF(&replacePairs); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&field); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_STR(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - zephir_get_strval(&name, name_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("mapper"), PH_NOISY_CC | PH_READONLY); - RETURN_MM_BOOL(zephir_array_isset(&_0, &name)); + zephir_fetch_params(1, 2, 0, &validation, &field_param); + zephir_get_strval(&field, field_param); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, &field); + zephir_check_call_status(); + _0 = Z_TYPE_P(&value) == IS_ARRAY; + if (_0) { + _1 = 1 != zephir_array_isset_string(&value, SL("name")); + if (!(_1)) { + _1 = 1 != zephir_array_isset_string(&value, SL("type")); + } + _2 = _1; + if (!(_2)) { + _2 = 1 != zephir_array_isset_string(&value, SL("size")); + } + _0 = _2; + } + if (_0) { + ZEPHIR_CALL_METHOD(&label, this_ptr, "preparelabel", NULL, 0, validation, &field); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&replacePairs); + zephir_create_array(&replacePairs, 1, 0); + zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_3$$3); + object_init_ex(&_3$$3, phalcon_messages_message_ce); + ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "getmessagevalid", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_5$$3, "strtr", NULL, 5, &_4$$3, &replacePairs); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_6$$3); + zephir_get_class(&_6$$3, this_ptr, 0); + ZEPHIR_CALL_METHOD(&_7$$3, this_ptr, "preparecode", NULL, 0, &field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_3$$3, "__construct", NULL, 6, &_5$$3, &field, &_6$$3, &_7$$3); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_3$$3); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Html_TagFactory, newInstance) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_AbstractFile, checkUploadMaxSize) { - zval _2$$3; + zend_bool _1, _2, _3, _4, _5, _6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, definition, _0, _4, _5, _1$$3, _3$$3; - zval name; + zval field; + zval *validation, validation_sub, *field_param = NULL, _SERVER, _POST, _FILES, files, label, length, method, post, replacePairs, server, value, _0, _7, _8$$8, _9$$8, _10$$8, _11$$8, _12$$8; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&_SERVER); + ZVAL_UNDEF(&_POST); + ZVAL_UNDEF(&_FILES); + ZVAL_UNDEF(&files); + ZVAL_UNDEF(&label); + ZVAL_UNDEF(&length); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&post); + ZVAL_UNDEF(&replacePairs); + ZVAL_UNDEF(&server); + ZVAL_UNDEF(&value); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_2$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8$$8); + ZVAL_UNDEF(&_9$$8); + ZVAL_UNDEF(&_10$$8); + ZVAL_UNDEF(&_11$$8); + ZVAL_UNDEF(&_12$$8); + ZVAL_UNDEF(&field); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_STR(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - zephir_get_strval(&name, name_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset(&_0, &name))) { - ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); + zephir_get_global(&_FILES, SL("_FILES")); + zephir_get_global(&_POST, SL("_POST")); + zephir_get_global(&_SERVER, SL("_SERVER")); + zephir_fetch_params(1, 2, 0, &validation, &field_param); + zephir_get_strval(&field, field_param); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, &field); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&server); + array_init(&server); + ZEPHIR_INIT_VAR(&post); + array_init(&post); + ZEPHIR_INIT_VAR(&files); + array_init(&files); + ZEPHIR_INIT_VAR(&method); + ZVAL_STRING(&method, "GET"); + ZEPHIR_INIT_VAR(&length); + ZVAL_LONG(&length, 0); + if (zephir_is_true(&_SERVER)) { + ZEPHIR_CPY_WRT(&server, &_SERVER); + } + if (zephir_is_true(&_POST)) { + ZEPHIR_CPY_WRT(&post, &_POST); + } + if (zephir_is_true(&_FILES)) { + ZEPHIR_CPY_WRT(&files, &_FILES); + } + if (zephir_array_isset_string(&server, SL("REQUEST_METHOD"))) { + ZEPHIR_OBS_NVAR(&method); + zephir_array_fetch_string(&method, &server, SL("REQUEST_METHOD"), PH_NOISY, "phalcon/Filter/Validation/Validator/File/AbstractFile.zep", 218); + } + if (zephir_array_isset_string(&server, SL("CONTENT_LENGTH"))) { + ZEPHIR_OBS_NVAR(&length); + zephir_array_fetch_string(&length, &server, SL("CONTENT_LENGTH"), PH_NOISY, "phalcon/Filter/Validation/Validator/File/AbstractFile.zep", 221); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "POST"); + _1 = ZEPHIR_IS_IDENTICAL(&_0, &method); + if (_1) { + _1 = 1 == ZEPHIR_IS_EMPTY(&post); + } + _2 = _1; + if (_2) { + _2 = 1 == ZEPHIR_IS_EMPTY(&files); + } + _3 = _2; + if (_3) { + _3 = zephir_get_intval(&length) > 0; + } + _4 = _3; + if (!(_4)) { + _5 = Z_TYPE_P(&value) == IS_ARRAY; + if (_5) { + _5 = 1 == zephir_array_isset_string(&value, SL("error")); + } + _6 = _5; + if (_6) { + zephir_array_fetch_string(&_7, &value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/File/AbstractFile.zep", 232); + _6 = ZEPHIR_IS_LONG_IDENTICAL(&_7, 1); + } + _4 = _6; + } + if (_4) { + ZEPHIR_CALL_METHOD(&label, this_ptr, "preparelabel", NULL, 0, validation, &field); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_1$$3); - ZEPHIR_INIT_VAR(&_2$$3); - zephir_create_array(&_2$$3, 1, 0); - zephir_memory_observe(&_3$$3); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("escaper"), PH_NOISY_CC); - zephir_array_fast_append(&_2$$3, &_3$$3); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(&_1$$3, &definition, &_2$$3); + ZEPHIR_INIT_VAR(&replacePairs); + zephir_create_array(&replacePairs, 1, 0); + zephir_array_update_string(&replacePairs, SL(":field"), &label, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_8$$8); + object_init_ex(&_8$$8, phalcon_messages_message_ce); + ZEPHIR_CALL_METHOD(&_9$$8, this_ptr, "getmessageinisize", NULL, 0); zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("services"), &name, &_1$$3); + ZEPHIR_CALL_FUNCTION(&_10$$8, "strtr", NULL, 5, &_9$$8, &replacePairs); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_11$$8); + zephir_get_class(&_11$$8, this_ptr, 0); + ZEPHIR_CALL_METHOD(&_12$$8, this_ptr, "preparecode", NULL, 0, &field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_8$$8, "__construct", NULL, 6, &_10$$8, &field, &_11$$8, &_12$$8); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_8$$8); + zephir_check_call_status(); + RETURN_MM_BOOL(0); } - zephir_read_property(&_4, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_5, &_4, &name, PH_NOISY | PH_READONLY, "phalcon/Html/TagFactory.zep", 176); - RETURN_CTOR(&_5); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Html_TagFactory, set) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_AbstractFile, getFileSizeInBytes) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, *method, method_sub, _0; - zval name; - zval *this_ptr = getThis(); + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *size_param = NULL, byteUnits, matches, unit, _0, _1, _2, _3, _4, _5, _6, _7, _8; + zval size; - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&method_sub); + ZVAL_UNDEF(&size); + ZVAL_UNDEF(&byteUnits); + ZVAL_UNDEF(&matches); + ZVAL_UNDEF(&unit); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_ZVAL(method) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(size) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &method); - zephir_get_strval(&name, name_param); - zephir_update_property_array(this_ptr, SL("mapper"), &name, method); - zephir_unset_property_array(this_ptr, ZEND_STRL("services"), &name); - zephir_read_property(&_0, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); - zephir_array_unset(&_0, &name, PH_SEPARATE); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Html_TagFactory, getExceptionClass) -{ - - RETURN_STRING("Phalcon\\Html\\Exception"); -} - -static PHP_METHOD(Phalcon_Html_TagFactory, getServices) -{ - - zephir_create_array(return_value, 41, 0); - add_assoc_stringl_ex(return_value, SL("a"), SL("Phalcon\\Html\\Helper\\Anchor")); - add_assoc_stringl_ex(return_value, SL("base"), SL("Phalcon\\Html\\Helper\\Base")); - add_assoc_stringl_ex(return_value, SL("body"), SL("Phalcon\\Html\\Helper\\Body")); - add_assoc_stringl_ex(return_value, SL("button"), SL("Phalcon\\Html\\Helper\\Button")); - add_assoc_stringl_ex(return_value, SL("close"), SL("Phalcon\\Html\\Helper\\Close")); - add_assoc_stringl_ex(return_value, SL("doctype"), SL("Phalcon\\Html\\Helper\\Doctype")); - add_assoc_stringl_ex(return_value, SL("element"), SL("Phalcon\\Html\\Helper\\Element")); - add_assoc_stringl_ex(return_value, SL("form"), SL("Phalcon\\Html\\Helper\\Form")); - add_assoc_stringl_ex(return_value, SL("img"), SL("Phalcon\\Html\\Helper\\Img")); - add_assoc_stringl_ex(return_value, SL("inputCheckbox"), SL("Phalcon\\Html\\Helper\\Input\\Checkbox")); - add_assoc_stringl_ex(return_value, SL("inputColor"), SL("Phalcon\\Html\\Helper\\Input\\Color")); - add_assoc_stringl_ex(return_value, SL("inputDate"), SL("Phalcon\\Html\\Helper\\Input\\Date")); - add_assoc_stringl_ex(return_value, SL("inputDateTime"), SL("Phalcon\\Html\\Helper\\Input\\DateTime")); - add_assoc_stringl_ex(return_value, SL("inputDateTimeLocal"), SL("Phalcon\\Html\\Helper\\Input\\DateTimeLocal")); - add_assoc_stringl_ex(return_value, SL("inputEmail"), SL("Phalcon\\Html\\Helper\\Input\\Email")); - add_assoc_stringl_ex(return_value, SL("inputFile"), SL("Phalcon\\Html\\Helper\\Input\\File")); - add_assoc_stringl_ex(return_value, SL("inputHidden"), SL("Phalcon\\Html\\Helper\\Input\\Hidden")); - add_assoc_stringl_ex(return_value, SL("inputImage"), SL("Phalcon\\Html\\Helper\\Input\\Image")); - add_assoc_stringl_ex(return_value, SL("inputInput"), SL("Phalcon\\Html\\Helper\\Input\\Input")); - add_assoc_stringl_ex(return_value, SL("inputMonth"), SL("Phalcon\\Html\\Helper\\Input\\Month")); - add_assoc_stringl_ex(return_value, SL("inputNumeric"), SL("Phalcon\\Html\\Helper\\Input\\Numeric")); - add_assoc_stringl_ex(return_value, SL("inputPassword"), SL("Phalcon\\Html\\Helper\\Input\\Password")); - add_assoc_stringl_ex(return_value, SL("inputRadio"), SL("Phalcon\\Html\\Helper\\Input\\Radio")); - add_assoc_stringl_ex(return_value, SL("inputRange"), SL("Phalcon\\Html\\Helper\\Input\\Range")); - add_assoc_stringl_ex(return_value, SL("inputSearch"), SL("Phalcon\\Html\\Helper\\Input\\Search")); - add_assoc_stringl_ex(return_value, SL("inputSelect"), SL("Phalcon\\Html\\Helper\\Input\\Select")); - add_assoc_stringl_ex(return_value, SL("inputSubmit"), SL("Phalcon\\Html\\Helper\\Input\\Submit")); - add_assoc_stringl_ex(return_value, SL("inputTel"), SL("Phalcon\\Html\\Helper\\Input\\Tel")); - add_assoc_stringl_ex(return_value, SL("inputText"), SL("Phalcon\\Html\\Helper\\Input\\Text")); - add_assoc_stringl_ex(return_value, SL("inputTextarea"), SL("Phalcon\\Html\\Helper\\Input\\Textarea")); - add_assoc_stringl_ex(return_value, SL("inputTime"), SL("Phalcon\\Html\\Helper\\Input\\Time")); - add_assoc_stringl_ex(return_value, SL("inputUrl"), SL("Phalcon\\Html\\Helper\\Input\\Url")); - add_assoc_stringl_ex(return_value, SL("inputWeek"), SL("Phalcon\\Html\\Helper\\Input\\Week")); - add_assoc_stringl_ex(return_value, SL("label"), SL("Phalcon\\Html\\Helper\\Label")); - add_assoc_stringl_ex(return_value, SL("link"), SL("Phalcon\\Html\\Helper\\Link")); - add_assoc_stringl_ex(return_value, SL("meta"), SL("Phalcon\\Html\\Helper\\Meta")); - add_assoc_stringl_ex(return_value, SL("ol"), SL("Phalcon\\Html\\Helper\\Ol")); - add_assoc_stringl_ex(return_value, SL("script"), SL("Phalcon\\Html\\Helper\\Script")); - add_assoc_stringl_ex(return_value, SL("style"), SL("Phalcon\\Html\\Helper\\Style")); - add_assoc_stringl_ex(return_value, SL("title"), SL("Phalcon\\Html\\Helper\\Title")); - add_assoc_stringl_ex(return_value, SL("ul"), SL("Phalcon\\Html\\Helper\\Ul")); - return; -} - -zend_object *zephir_init_properties_Phalcon_Html_TagFactory(zend_class_entry *class_type) -{ - zval _0, _2, _1$$3, _3$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("mapper"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("mapper"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("services"), &_3$$4); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + zephir_fetch_params(1, 1, 0, &size_param); + zephir_get_strval(&size, size_param); + ZEPHIR_INIT_VAR(&byteUnits); + zephir_create_array(&byteUnits, 9, 0); + add_assoc_long_ex(&byteUnits, SL("B"), 0); + add_assoc_long_ex(&byteUnits, SL("K"), 10); + add_assoc_long_ex(&byteUnits, SL("M"), 20); + add_assoc_long_ex(&byteUnits, SL("G"), 30); + add_assoc_long_ex(&byteUnits, SL("T"), 40); + add_assoc_long_ex(&byteUnits, SL("KB"), 10); + add_assoc_long_ex(&byteUnits, SL("MB"), 20); + add_assoc_long_ex(&byteUnits, SL("GB"), 30); + add_assoc_long_ex(&byteUnits, SL("TB"), 40); + ZEPHIR_INIT_VAR(&unit); + ZVAL_STRING(&unit, "B"); + ZEPHIR_INIT_VAR(&matches); + array_init(&matches); + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_INIT_VAR(&_1); + zephir_array_keys(&_1, &byteUnits); + zephir_fast_join_str(&_0, SL("|"), &_1); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_CONCAT_SVS(&_2, "/^([0-9]+(?:\\.[0-9]+)?)(", &_0, ")?/Di"); + ZEPHIR_INIT_VAR(&_3); + zephir_preg_match(&_3, &_2, &size, &matches, 0, 0 , 0 ); + if (1 == zephir_array_isset_long(&matches, 2)) { + ZEPHIR_OBS_NVAR(&unit); + zephir_array_fetch_long(&unit, &matches, 2, PH_NOISY, "phalcon/Filter/Validation/Validator/File/AbstractFile.zep", 288); } + zephir_array_fetch_long(&_4, &matches, 1, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/File/AbstractFile.zep", 291); + ZEPHIR_CALL_FUNCTION(&_5, "floatval", NULL, 18, &_4); + zephir_check_call_status(); + zephir_array_fetch(&_6, &byteUnits, &unit, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/File/AbstractFile.zep", 291); + ZVAL_LONG(&_7, 2); + ZEPHIR_CALL_FUNCTION(&_8, "pow", NULL, 19, &_7, &_6); + zephir_check_call_status(); + mul_function(return_value, &_5, &_8); + RETURN_MM(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Escaper_EscaperInterface) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_AbstractFile, getMessageFileEmpty) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Html\\Escaper, EscaperInterface, phalcon, html_escaper_escaperinterface, phalcon_html_escaper_escaperinterface_method_entry); - return SUCCESS; + RETURN_MEMBER(getThis(), "messageFileEmpty"); } -ZEPHIR_DOC_METHOD(Phalcon_Html_Escaper_EscaperInterface, attributes); -ZEPHIR_DOC_METHOD(Phalcon_Html_Escaper_EscaperInterface, css); -ZEPHIR_DOC_METHOD(Phalcon_Html_Escaper_EscaperInterface, getEncoding); -ZEPHIR_DOC_METHOD(Phalcon_Html_Escaper_EscaperInterface, html); -ZEPHIR_DOC_METHOD(Phalcon_Html_Escaper_EscaperInterface, js); -ZEPHIR_DOC_METHOD(Phalcon_Html_Escaper_EscaperInterface, setEncoding); -ZEPHIR_DOC_METHOD(Phalcon_Html_Escaper_EscaperInterface, setFlags); -ZEPHIR_DOC_METHOD(Phalcon_Html_Escaper_EscaperInterface, url); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Escaper_Exception) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_AbstractFile, getMessageIniSize) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Escaper, Exception, phalcon, html_escaper_exception, zend_ce_exception, NULL, 0); - return SUCCESS; + RETURN_MEMBER(getThis(), "messageIniSize"); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Attributes_AttributesInterface) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_AbstractFile, getMessageValid) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Html\\Attributes, AttributesInterface, phalcon, html_attributes_attributesinterface, phalcon_html_attributes_attributesinterface_method_entry); - return SUCCESS; + RETURN_MEMBER(getThis(), "messageValid"); } -ZEPHIR_DOC_METHOD(Phalcon_Html_Attributes_AttributesInterface, getAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Html_Attributes_AttributesInterface, setAttributes); +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_AbstractFile, isAllowEmpty) +{ + zend_bool _0, _1, _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval field; + zval *validation, validation_sub, *field_param = NULL, value, _3; + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&field); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_STR(field) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &validation, &field_param); + zephir_get_strval(&field, field_param); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, &field); + zephir_check_call_status(); + _0 = 1 == ZEPHIR_IS_EMPTY(&value); + if (!(_0)) { + _1 = Z_TYPE_P(&value) == IS_ARRAY; + if (_1) { + _1 = 1 == zephir_array_isset_string(&value, SL("error")); + } + _2 = _1; + if (_2) { + zephir_array_fetch_string(&_3, &value, SL("error"), PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/File/AbstractFile.zep", 342); + _2 = ZEPHIR_IS_LONG_IDENTICAL(&_3, 4); + } + _0 = _2; + } + RETURN_MM_BOOL(_0); +} +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_AbstractFile, setMessageFileEmpty) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *message_param = NULL; + zval message; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H -#endif + ZVAL_UNDEF(&message); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(message) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &message_param); + zephir_get_strval(&message, message_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("messageFileEmpty"), &message); + ZEPHIR_MM_RESTORE(); +} +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_AbstractFile, setMessageIniSize) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *message_param = NULL; + zval message; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&message); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(message) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &message_param); + zephir_get_strval(&message, message_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("messageIniSize"), &message); + ZEPHIR_MM_RESTORE(); +} +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_AbstractFile, setMessageValid) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *message_param = NULL; + zval message; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&message); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(message) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &message_param); + zephir_get_strval(&message, message_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("messageValid"), &message); + ZEPHIR_MM_RESTORE(); +} -ZEPHIR_INIT_CLASS(Phalcon_Html_Attributes_RenderInterface) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_AbstractFile, checkIsUploadedFile) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Html\\Attributes, RenderInterface, phalcon, html_attributes_renderinterface, phalcon_html_attributes_renderinterface_method_entry); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL; + zval name; - return SUCCESS; + ZVAL_UNDEF(&name); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); + ZEPHIR_RETURN_CALL_FUNCTION("is_uploaded_file", NULL, 20, &name); + zephir_check_call_status(); + RETURN_MM(); } -ZEPHIR_DOC_METHOD(Phalcon_Html_Attributes_RenderInterface, render); @@ -118935,309 +118769,520 @@ ZEPHIR_DOC_METHOD(Phalcon_Html_Attributes_RenderInterface, render); -ZEPHIR_INIT_CLASS(Phalcon_Html_Link_AbstractLink) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_File_MimeType) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Html\\Link, AbstractLink, phalcon, html_link_abstractlink, phalcon_html_link_abstractlink_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator\\File, MimeType, phalcon, filter_validation_validator_file_mimetype, phalcon_filter_validation_validator_file_abstractfile_ce, phalcon_filter_validation_validator_file_mimetype_method_entry, 0); - zend_declare_property_null(phalcon_html_link_abstractlink_ce, SL("attributes"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_html_link_abstractlink_ce, SL("href"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_html_link_abstractlink_ce, SL("rels"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_html_link_abstractlink_ce, SL("templated"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_filter_validation_validator_file_mimetype_ce, SL("template"), "File :field must be of type: :types", ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Link_AbstractLink, __construct) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_MimeType, validate) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes; - zval *rel_param = NULL, *href_param = NULL, *attributes_param = NULL, _0, _1, _2, _3$$3, _4$$3; - zval rel, href; + zval *validation, validation_sub, *field, field_sub, fieldTypes, mime, replacePairs, tmp, types, value, _0, _1, _2$$6, _3$$6, _4$$8, _5$$8; zval *this_ptr = getThis(); - ZVAL_UNDEF(&rel); - ZVAL_UNDEF(&href); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&fieldTypes); + ZVAL_UNDEF(&mime); + ZVAL_UNDEF(&replacePairs); + ZVAL_UNDEF(&tmp); + ZVAL_UNDEF(&types); + ZVAL_UNDEF(&value); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(0, 3) - Z_PARAM_OPTIONAL - Z_PARAM_STR(rel) - Z_PARAM_STR(href) - Z_PARAM_ARRAY(attributes) + ZVAL_UNDEF(&_2$$6); + ZVAL_UNDEF(&_3$$6); + ZVAL_UNDEF(&_4$$8); + ZVAL_UNDEF(&_5$$8); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 3, &rel_param, &href_param, &attributes_param); - if (!rel_param) { - ZEPHIR_INIT_VAR(&rel); - ZVAL_STRING(&rel, ""); - } else { - zephir_get_strval(&rel, rel_param); - } - if (!href_param) { - ZEPHIR_INIT_VAR(&href); - ZVAL_STRING(&href, ""); - } else { - zephir_get_strval(&href, href_param); - } - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - } else { - zephir_get_arrval(&attributes, attributes_param); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkupload", NULL, 0, validation, field); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_0)) { + RETURN_MM_BOOL(0); } - ZEPHIR_INIT_VAR(&_0); - object_init_ex(&_0, phalcon_support_collection_ce); - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 23, &attributes); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &_0); ZEPHIR_INIT_VAR(&_1); - object_init_ex(&_1, phalcon_support_collection_ce); - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 23); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("rels"), &_1); - zephir_update_property_zval(this_ptr, ZEND_STRL("href"), &href); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "hrefistemplated", NULL, 0, &href); + ZVAL_STRING(&_1, "types"); + ZEPHIR_CALL_METHOD(&types, this_ptr, "getoption", NULL, 0, &_1); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("templated"), &_2); - if (1 != ZEPHIR_IS_EMPTY(&rel)) { - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("rels"), PH_NOISY_CC | PH_READONLY); - ZVAL_BOOL(&_4$$3, 1); - ZEPHIR_CALL_METHOD(NULL, &_3$$3, "set", NULL, 0, &rel, &_4$$3); + zephir_memory_observe(&fieldTypes); + if (zephir_array_isset_fetch(&fieldTypes, &types, field, 0)) { + ZEPHIR_CPY_WRT(&types, &fieldTypes); + } + if (UNEXPECTED(Z_TYPE_P(&types) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_filter_validation_exception_ce, "Option 'allowedTypes' must be an array", "phalcon/Filter/Validation/Validator/File/MimeType.zep", 96); + return; + } + if ((zephir_function_exists_ex(ZEND_STRL("finfo_open")) == SUCCESS)) { + ZVAL_LONG(&_2$$6, 16); + ZEPHIR_CALL_FUNCTION(&tmp, "finfo_open", NULL, 308, &_2$$6); + zephir_check_call_status(); + zephir_array_fetch_string(&_3$$6, &value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/File/MimeType.zep", 101); + ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 309, &tmp, &_3$$6); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 310, &tmp); + zephir_check_call_status(); + } else { + ZEPHIR_OBS_NVAR(&mime); + zephir_array_fetch_string(&mime, &value, SL("type"), PH_NOISY, "phalcon/Filter/Validation/Validator/File/MimeType.zep", 105); + } + if (!(zephir_fast_in_array(&mime, &types))) { + ZEPHIR_INIT_VAR(&replacePairs); + zephir_create_array(&replacePairs, 1, 0); + ZEPHIR_INIT_VAR(&_4$$8); + zephir_fast_join_str(&_4$$8, SL(", "), &types); + zephir_array_update_string(&replacePairs, SL(":types"), &_4$$8, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_5$$8, this_ptr, "messagefactory", NULL, 0, validation, field, &replacePairs); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_5$$8); zephir_check_call_status(); + RETURN_MM_BOOL(0); } - ZEPHIR_MM_RESTORE(); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Html_Link_AbstractLink, doGetAttributes) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_0, "toarray", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Html_Link_AbstractLink, doGetHref) -{ +#ifdef HAVE_CONFIG_H +#endif - RETURN_MEMBER(getThis(), "href"); -} -static PHP_METHOD(Phalcon_Html_Link_AbstractLink, doGetRels) -{ - zval _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("rels"), PH_NOISY_CC | PH_READONLY); - ZVAL_BOOL(&_1, 0); - ZEPHIR_RETURN_CALL_METHOD(&_0, "getkeys", NULL, 0, &_1); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Html_Link_AbstractLink, doIsTemplated) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_File_Resolution_Equal) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator\\File\\Resolution, Equal, phalcon, filter_validation_validator_file_resolution_equal, phalcon_filter_validation_validator_file_abstractfile_ce, phalcon_filter_validation_validator_file_resolution_equal_method_entry, 0); - RETURN_MEMBER(getThis(), "templated"); + zend_declare_property_string(phalcon_filter_validation_validator_file_resolution_equal_ce, SL("template"), "The resolution of the field :field has to be equal :resolution", ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Link_AbstractLink, hrefIsTemplated) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_Resolution_Equal, __construct) { - zend_bool _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *href_param = NULL, _0, _1, _3; - zval href; + zval *options_param = NULL; + zval options; - ZVAL_UNDEF(&href); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(href) + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &href_param); - zephir_get_strval(&href, href_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "{"); - ZEPHIR_CALL_FUNCTION(&_1, "mb_strpos", NULL, 86, &href, &_0); - zephir_check_call_status(); - _2 = !ZEPHIR_IS_FALSE_IDENTICAL(&_1); - if (_2) { - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, "}"); - ZEPHIR_CALL_FUNCTION(&_3, "mb_strpos", NULL, 86, &href, &_0); - zephir_check_call_status(); - _2 = !ZEPHIR_IS_FALSE_IDENTICAL(&_3); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - RETURN_MM_BOOL(_2); + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_file_resolution_equal_ce, getThis(), "__construct", NULL, 0, &options); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Link_AbstractLink, doWithAttribute) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_Resolution_Equal, validate) { + zend_bool _5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub, newInstance, _0; - zval key; + zval *validation, validation_sub, *field, field_sub, height, equalHeight, equalWidth, resolution, resolutionArray, tmp, value, width, replacePairs, _0, _1, _2, _3$$4, _4$$5, _6$$6; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&newInstance); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&height); + ZVAL_UNDEF(&equalHeight); + ZVAL_UNDEF(&equalWidth); + ZVAL_UNDEF(&resolution); + ZVAL_UNDEF(&resolutionArray); + ZVAL_UNDEF(&tmp); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&width); + ZVAL_UNDEF(&replacePairs); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_6$$6); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &key_param, &value); - zephir_get_strval(&key, key_param); - ZEPHIR_INIT_VAR(&newInstance); - if (zephir_clone(&newInstance, this_ptr) == FAILURE) { - RETURN_MM(); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkupload", NULL, 0, validation, field); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_0)) { + RETURN_MM_BOOL(0); } - zephir_read_property(&_0, &newInstance, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &key, value); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); - RETURN_CCTOR(&newInstance); + zephir_array_fetch_string(&_1, &value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/File/Resolution/Equal.zep", 88); + ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", NULL, 311, &_1); + zephir_check_call_status(); + zephir_memory_observe(&width); + zephir_array_fetch_long(&width, &tmp, 0, PH_NOISY, "phalcon/Filter/Validation/Validator/File/Resolution/Equal.zep", 89); + zephir_memory_observe(&height); + zephir_array_fetch_long(&height, &tmp, 1, PH_NOISY, "phalcon/Filter/Validation/Validator/File/Resolution/Equal.zep", 90); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "resolution"); + ZEPHIR_CALL_METHOD(&resolution, this_ptr, "getoption", NULL, 0, &_2); + zephir_check_call_status(); + if (Z_TYPE_P(&resolution) == IS_ARRAY) { + zephir_array_fetch(&_3$$4, &resolution, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/File/Resolution/Equal.zep", 95); + ZEPHIR_CPY_WRT(&resolution, &_3$$4); + } + ZEPHIR_INIT_VAR(&resolutionArray); + zephir_fast_explode_str(&resolutionArray, SL("x"), &resolution, LONG_MAX); + zephir_memory_observe(&equalWidth); + zephir_array_fetch_long(&equalWidth, &resolutionArray, 0, PH_NOISY, "phalcon/Filter/Validation/Validator/File/Resolution/Equal.zep", 99); + zephir_memory_observe(&equalHeight); + zephir_array_fetch_long(&equalHeight, &resolutionArray, 1, PH_NOISY, "phalcon/Filter/Validation/Validator/File/Resolution/Equal.zep", 100); + if (Z_TYPE_P(&resolution) == IS_ARRAY) { + zephir_array_fetch(&_4$$5, &resolution, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/File/Resolution/Equal.zep", 103); + ZEPHIR_CPY_WRT(&resolution, &_4$$5); + } + _5 = !ZEPHIR_IS_EQUAL(&width, &equalWidth); + if (!(_5)) { + _5 = !ZEPHIR_IS_EQUAL(&height, &equalHeight); + } + if (_5) { + ZEPHIR_INIT_VAR(&replacePairs); + zephir_create_array(&replacePairs, 1, 0); + zephir_array_update_string(&replacePairs, SL(":resolution"), &resolution, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_6$$6, this_ptr, "messagefactory", NULL, 0, validation, field, &replacePairs); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_6$$6); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Html_Link_AbstractLink, doWithHref) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_File_Resolution_Max) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator\\File\\Resolution, Max, phalcon, filter_validation_validator_file_resolution_max, phalcon_filter_validation_validator_file_abstractfile_ce, phalcon_filter_validation_validator_file_resolution_max_method_entry, 0); + + zend_declare_property_string(phalcon_filter_validation_validator_file_resolution_max_ce, SL("template"), "File :field exceeds the maximum resolution of :resolution", ZEND_ACC_PROTECTED); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_Resolution_Max, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *href_param = NULL, newInstance, _0; - zval href; - zval *this_ptr = getThis(); + zval *options_param = NULL; + zval options; - ZVAL_UNDEF(&href); - ZVAL_UNDEF(&newInstance); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(href) + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &href_param); - zephir_get_strval(&href, href_param); - ZEPHIR_INIT_VAR(&newInstance); - if (zephir_clone(&newInstance, this_ptr) == FAILURE) { - RETURN_MM(); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - zephir_update_property_zval(&newInstance, ZEND_STRL("href"), &href); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "hrefistemplated", NULL, 0, &href); + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_file_resolution_max_ce, getThis(), "__construct", NULL, 0, &options); zephir_check_call_status(); - zephir_update_property_zval(&newInstance, ZEND_STRL("templated"), &_0); - RETURN_CCTOR(&newInstance); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Link_AbstractLink, doWithRel) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_Resolution_Max, validate) { + double _5$$5, _6$$6; + zend_bool result = 0, _7$$7, _8$$8; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, newInstance, _0, _1; - zval key; + zval *validation, validation_sub, *field, field_sub, height, maxHeight, maxWidth, resolution, resolutionArray, tmp, value, width, replacePairs, included, _0, _1, _2, _3$$4, _4$$5, _9$$9, _10$$10; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&newInstance); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&height); + ZVAL_UNDEF(&maxHeight); + ZVAL_UNDEF(&maxWidth); + ZVAL_UNDEF(&resolution); + ZVAL_UNDEF(&resolutionArray); + ZVAL_UNDEF(&tmp); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&width); + ZVAL_UNDEF(&replacePairs); + ZVAL_UNDEF(&included); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_9$$9); + ZVAL_UNDEF(&_10$$10); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - zephir_get_strval(&key, key_param); - ZEPHIR_INIT_VAR(&newInstance); - if (zephir_clone(&newInstance, this_ptr) == FAILURE) { - RETURN_MM(); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_INIT_VAR(&included); + ZVAL_BOOL(&included, 0); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkupload", NULL, 0, validation, field); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_0)) { + RETURN_MM_BOOL(0); } - zephir_read_property(&_0, &newInstance, ZEND_STRL("rels"), PH_NOISY_CC | PH_READONLY); - ZVAL_BOOL(&_1, 1); - ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &key, &_1); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); - RETURN_CCTOR(&newInstance); + zephir_array_fetch_string(&_1, &value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/File/Resolution/Max.zep", 94); + ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", NULL, 311, &_1); + zephir_check_call_status(); + zephir_memory_observe(&width); + zephir_array_fetch_long(&width, &tmp, 0, PH_NOISY, "phalcon/Filter/Validation/Validator/File/Resolution/Max.zep", 95); + zephir_memory_observe(&height); + zephir_array_fetch_long(&height, &tmp, 1, PH_NOISY, "phalcon/Filter/Validation/Validator/File/Resolution/Max.zep", 96); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "resolution"); + ZEPHIR_CALL_METHOD(&resolution, this_ptr, "getoption", NULL, 0, &_2); + zephir_check_call_status(); + if (Z_TYPE_P(&resolution) == IS_ARRAY) { + zephir_array_fetch(&_3$$4, &resolution, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/File/Resolution/Max.zep", 101); + ZEPHIR_CPY_WRT(&resolution, &_3$$4); + } + ZEPHIR_INIT_VAR(&resolutionArray); + zephir_fast_explode_str(&resolutionArray, SL("x"), &resolution, LONG_MAX); + zephir_memory_observe(&maxWidth); + zephir_array_fetch_long(&maxWidth, &resolutionArray, 0, PH_NOISY, "phalcon/Filter/Validation/Validator/File/Resolution/Max.zep", 105); + zephir_memory_observe(&maxHeight); + zephir_array_fetch_long(&maxHeight, &resolutionArray, 1, PH_NOISY, "phalcon/Filter/Validation/Validator/File/Resolution/Max.zep", 106); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "included"); + ZEPHIR_CALL_METHOD(&included, this_ptr, "getoption", NULL, 0, &_2); + zephir_check_call_status(); + if (Z_TYPE_P(&included) == IS_ARRAY) { + zephir_memory_observe(&_4$$5); + zephir_array_fetch(&_4$$5, &included, field, PH_NOISY, "phalcon/Filter/Validation/Validator/File/Resolution/Max.zep", 111); + _5$$5 = zephir_get_boolval(&_4$$5); + ZEPHIR_INIT_NVAR(&included); + ZVAL_BOOL(&included, _5$$5); + } else { + _6$$6 = zephir_get_boolval(&included); + ZEPHIR_INIT_NVAR(&included); + ZVAL_BOOL(&included, _6$$6); + } + if (zephir_is_true(&included)) { + _7$$7 = ZEPHIR_GE(&width, &maxWidth); + if (!(_7$$7)) { + _7$$7 = ZEPHIR_GE(&height, &maxHeight); + } + result = _7$$7; + } else { + _8$$8 = ZEPHIR_GT(&width, &maxWidth); + if (!(_8$$8)) { + _8$$8 = ZEPHIR_GT(&height, &maxHeight); + } + result = _8$$8; + } + if (Z_TYPE_P(&resolution) == IS_ARRAY) { + zephir_array_fetch(&_9$$9, &resolution, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/File/Resolution/Max.zep", 123); + ZEPHIR_CPY_WRT(&resolution, &_9$$9); + } + if (result) { + ZEPHIR_INIT_VAR(&replacePairs); + zephir_create_array(&replacePairs, 1, 0); + zephir_array_update_string(&replacePairs, SL(":resolution"), &resolution, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_10$$10, this_ptr, "messagefactory", NULL, 0, validation, field, &replacePairs); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_10$$10); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Html_Link_AbstractLink, doWithoutAttribute) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_File_Resolution_Min) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator\\File\\Resolution, Min, phalcon, filter_validation_validator_file_resolution_min, phalcon_filter_validation_validator_file_abstractfile_ce, phalcon_filter_validation_validator_file_resolution_min_method_entry, 0); + + zend_declare_property_string(phalcon_filter_validation_validator_file_resolution_min_ce, SL("template"), "File :field can not have the minimum resolution of :resolution", ZEND_ACC_PROTECTED); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_Resolution_Min, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, newInstance, _0; - zval key; - zval *this_ptr = getThis(); + zval *options_param = NULL; + zval options; - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&newInstance); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - zephir_get_strval(&key, key_param); - ZEPHIR_INIT_VAR(&newInstance); - if (zephir_clone(&newInstance, this_ptr) == FAILURE) { - RETURN_MM(); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - zephir_read_property(&_0, &newInstance, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "remove", NULL, 0, &key); + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_file_resolution_min_ce, getThis(), "__construct", NULL, 0, &options); zephir_check_call_status(); - RETURN_CCTOR(&newInstance); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Link_AbstractLink, doWithoutRel) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_Resolution_Min, validate) { + double _5$$5, _6$$6; + zend_bool result = 0, _7$$7, _8$$8; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, newInstance, _0; - zval key; + zval *validation, validation_sub, *field, field_sub, height, minHeight, minWidth, resolution, resolutionArray, tmp, value, width, replacePairs, included, _0, _1, _2, _3$$4, _4$$5, _9$$9, _10$$10; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&newInstance); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&height); + ZVAL_UNDEF(&minHeight); + ZVAL_UNDEF(&minWidth); + ZVAL_UNDEF(&resolution); + ZVAL_UNDEF(&resolutionArray); + ZVAL_UNDEF(&tmp); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&width); + ZVAL_UNDEF(&replacePairs); + ZVAL_UNDEF(&included); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_9$$9); + ZVAL_UNDEF(&_10$$10); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - zephir_get_strval(&key, key_param); - ZEPHIR_INIT_VAR(&newInstance); - if (zephir_clone(&newInstance, this_ptr) == FAILURE) { - RETURN_MM(); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_INIT_VAR(&included); + ZVAL_BOOL(&included, 0); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkupload", NULL, 0, validation, field); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_0)) { + RETURN_MM_BOOL(0); } - zephir_read_property(&_0, &newInstance, ZEND_STRL("rels"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "remove", NULL, 0, &key); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); - RETURN_CCTOR(&newInstance); + zephir_array_fetch_string(&_1, &value, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/File/Resolution/Min.zep", 94); + ZEPHIR_CALL_FUNCTION(&tmp, "getimagesize", NULL, 311, &_1); + zephir_check_call_status(); + zephir_memory_observe(&width); + zephir_array_fetch_long(&width, &tmp, 0, PH_NOISY, "phalcon/Filter/Validation/Validator/File/Resolution/Min.zep", 95); + zephir_memory_observe(&height); + zephir_array_fetch_long(&height, &tmp, 1, PH_NOISY, "phalcon/Filter/Validation/Validator/File/Resolution/Min.zep", 96); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "resolution"); + ZEPHIR_CALL_METHOD(&resolution, this_ptr, "getoption", NULL, 0, &_2); + zephir_check_call_status(); + if (Z_TYPE_P(&resolution) == IS_ARRAY) { + zephir_array_fetch(&_3$$4, &resolution, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/File/Resolution/Min.zep", 101); + ZEPHIR_CPY_WRT(&resolution, &_3$$4); + } + ZEPHIR_INIT_VAR(&resolutionArray); + zephir_fast_explode_str(&resolutionArray, SL("x"), &resolution, LONG_MAX); + zephir_memory_observe(&minWidth); + zephir_array_fetch_long(&minWidth, &resolutionArray, 0, PH_NOISY, "phalcon/Filter/Validation/Validator/File/Resolution/Min.zep", 105); + zephir_memory_observe(&minHeight); + zephir_array_fetch_long(&minHeight, &resolutionArray, 1, PH_NOISY, "phalcon/Filter/Validation/Validator/File/Resolution/Min.zep", 106); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "included"); + ZEPHIR_CALL_METHOD(&included, this_ptr, "getoption", NULL, 0, &_2); + zephir_check_call_status(); + if (Z_TYPE_P(&included) == IS_ARRAY) { + zephir_memory_observe(&_4$$5); + zephir_array_fetch(&_4$$5, &included, field, PH_NOISY, "phalcon/Filter/Validation/Validator/File/Resolution/Min.zep", 111); + _5$$5 = zephir_get_boolval(&_4$$5); + ZEPHIR_INIT_NVAR(&included); + ZVAL_BOOL(&included, _5$$5); + } else { + _6$$6 = zephir_get_boolval(&included); + ZEPHIR_INIT_NVAR(&included); + ZVAL_BOOL(&included, _6$$6); + } + if (zephir_is_true(&included)) { + _7$$7 = ZEPHIR_LE(&width, &minWidth); + if (!(_7$$7)) { + _7$$7 = ZEPHIR_LE(&height, &minHeight); + } + result = _7$$7; + } else { + _8$$8 = ZEPHIR_LT(&width, &minWidth); + if (!(_8$$8)) { + _8$$8 = ZEPHIR_LT(&height, &minHeight); + } + result = _8$$8; + } + if (Z_TYPE_P(&resolution) == IS_ARRAY) { + zephir_array_fetch(&_9$$9, &resolution, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/File/Resolution/Min.zep", 123); + ZEPHIR_CPY_WRT(&resolution, &_9$$9); + } + if (result) { + ZEPHIR_INIT_VAR(&replacePairs); + zephir_create_array(&replacePairs, 1, 0); + zephir_array_update_string(&replacePairs, SL(":resolution"), &resolution, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_10$$10, this_ptr, "messagefactory", NULL, 0, validation, field, &replacePairs); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_10$$10); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); } @@ -119250,273 +119295,210 @@ static PHP_METHOD(Phalcon_Html_Link_AbstractLink, doWithoutRel) -ZEPHIR_INIT_CLASS(Phalcon_Html_Link_AbstractLinkProvider) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_File_Size_Equal) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Html\\Link, AbstractLinkProvider, phalcon, html_link_abstractlinkprovider, phalcon_html_link_abstractlinkprovider_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_html_link_abstractlinkprovider_ce, SL("links"), ZEND_ACC_PROTECTED); - phalcon_html_link_abstractlinkprovider_ce->create_object = zephir_init_properties_Phalcon_Html_Link_AbstractLinkProvider; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator\\File\\Size, Equal, phalcon, filter_validation_validator_file_size_equal, phalcon_filter_validation_validator_file_abstractfile_ce, phalcon_filter_validation_validator_file_size_equal_method_entry, 0); + zend_declare_property_string(phalcon_filter_validation_validator_file_size_equal_ce, SL("template"), "File :field does not have the exact :size file size", ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Link_AbstractLinkProvider, __construct) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_Size_Equal, validate) { - zend_bool _5$$3, _11$$5; + zend_bool included = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL, *_8 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *links_param = NULL, link, *_0, _1, _2$$3, _3$$3, _6$$3, _7$$4, _9$$5, _10$$5, _12$$5, _13$$6; - zval links; + zval *validation, validation_sub, *field, field_sub, bytes, fileSize, replacePairs, size, value, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&links); - ZVAL_UNDEF(&link); + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&bytes); + ZVAL_UNDEF(&fileSize); + ZVAL_UNDEF(&replacePairs); + ZVAL_UNDEF(&size); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_9$$5); - ZVAL_UNDEF(&_10$$5); - ZVAL_UNDEF(&_12$$5); - ZVAL_UNDEF(&_13$$6); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(links) + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_11$$4); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &links_param); - if (!links_param) { - ZEPHIR_INIT_VAR(&links); - array_init(&links); - } else { - zephir_get_arrval(&links, links_param); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkupload", NULL, 0, validation, field); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + RETURN_MM_BOOL(0); } - zephir_is_iterable(&links, 0, "phalcon/Html/Link/AbstractLinkProvider.zep", 42); - if (Z_TYPE_P(&links) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&links), _0) - { - ZEPHIR_INIT_NVAR(&link); - ZVAL_COPY(&link, _0); - ZEPHIR_INIT_NVAR(&_2$$3); - ZVAL_STRING(&_2$$3, "Phalcon\\Html\\Link\\Interfaces\\LinkInterface"); - ZEPHIR_CALL_FUNCTION(&_3$$3, "is_a", &_4, 87, &link, &_2$$3); - zephir_check_call_status(); - _5$$3 = ZEPHIR_IS_TRUE_IDENTICAL(&_3$$3); - if (!(_5$$3)) { - ZEPHIR_INIT_NVAR(&_2$$3); - ZVAL_STRING(&_2$$3, "Psr\\Link\\LinkInterface"); - ZEPHIR_CALL_FUNCTION(&_6$$3, "is_a", &_4, 87, &link, &_2$$3); - zephir_check_call_status(); - _5$$3 = ZEPHIR_IS_TRUE_IDENTICAL(&_6$$3); - } - if (_5$$3) { - ZEPHIR_CALL_METHOD(&_7$$4, this_ptr, "getkey", &_8, 0, &link); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("links"), &_7$$4, &link); - } - } ZEND_HASH_FOREACH_END(); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "size"); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getoption", NULL, 0, &_2); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&size, this_ptr, "checkarray", NULL, 0, &_1, field); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "getfilesizeinbytes", NULL, 0, &size); + zephir_check_call_status(); + ZVAL_LONG(&_4, 6); + ZEPHIR_INIT_VAR(&bytes); + zephir_round(&bytes, &_3, &_4, NULL); + zephir_array_fetch_string(&_5, &value, SL("size"), PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/File/Size/Equal.zep", 89); + ZEPHIR_CALL_FUNCTION(&_6, "floatval", NULL, 18, &_5); + zephir_check_call_status(); + ZVAL_LONG(&_7, 6); + ZEPHIR_INIT_VAR(&fileSize); + zephir_round(&fileSize, &_6, &_7, NULL); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "included"); + ZVAL_BOOL(&_10, 0); + ZEPHIR_CALL_METHOD(&_9, this_ptr, "getoption", NULL, 0, &_2, &_10); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_8, this_ptr, "checkarray", NULL, 0, &_9, field); + zephir_check_call_status(); + included = zephir_get_boolval(&_8); + if (included) { + ZVAL_BOOL(&_10, 1); } else { - ZEPHIR_CALL_METHOD(NULL, &links, "rewind", NULL, 0); + ZVAL_BOOL(&_10, 0); + } + ZEPHIR_CALL_METHOD(&_8, this_ptr, "getconditional", NULL, 0, &bytes, &fileSize, &_10); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_8)) { + ZEPHIR_INIT_VAR(&replacePairs); + zephir_create_array(&replacePairs, 1, 0); + zephir_array_update_string(&replacePairs, SL(":size"), &size, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_11$$4, this_ptr, "messagefactory", NULL, 0, validation, field, &replacePairs); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &links, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&link, &links, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_9$$5); - ZVAL_STRING(&_9$$5, "Phalcon\\Html\\Link\\Interfaces\\LinkInterface"); - ZEPHIR_CALL_FUNCTION(&_10$$5, "is_a", &_4, 87, &link, &_9$$5); - zephir_check_call_status(); - _11$$5 = ZEPHIR_IS_TRUE_IDENTICAL(&_10$$5); - if (!(_11$$5)) { - ZEPHIR_INIT_NVAR(&_9$$5); - ZVAL_STRING(&_9$$5, "Psr\\Link\\LinkInterface"); - ZEPHIR_CALL_FUNCTION(&_12$$5, "is_a", &_4, 87, &link, &_9$$5); - zephir_check_call_status(); - _11$$5 = ZEPHIR_IS_TRUE_IDENTICAL(&_12$$5); - } - if (_11$$5) { - ZEPHIR_CALL_METHOD(&_13$$6, this_ptr, "getkey", &_8, 0, &link); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("links"), &_13$$6, &link); - } - ZEPHIR_CALL_METHOD(NULL, &links, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_11$$4); + zephir_check_call_status(); + RETURN_MM_BOOL(0); } - ZEPHIR_INIT_NVAR(&link); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Html_Link_AbstractLinkProvider, doGetLinks) -{ - - RETURN_MEMBER(getThis(), "links"); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Html_Link_AbstractLinkProvider, doGetLinksByRel) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_Size_Equal, getConditional) { - zval filtered; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *rel_param = NULL, link, rels, _0, *_1, _2; - zval rel; - zval *this_ptr = getThis(); + zend_bool included, _0; + zval *source_param = NULL, *target_param = NULL, *included_param = NULL; + double source, target; - ZVAL_UNDEF(&rel); - ZVAL_UNDEF(&link); - ZVAL_UNDEF(&rels); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&filtered); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(rel) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ZVAL(source) + Z_PARAM_ZVAL(target) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(included) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &rel_param); - zephir_get_strval(&rel, rel_param); - ZEPHIR_INIT_VAR(&filtered); - array_init(&filtered); - zephir_read_property(&_0, this_ptr, ZEND_STRL("links"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_0, 0, "phalcon/Html/Link/AbstractLinkProvider.zep", 80); - if (Z_TYPE_P(&_0) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) - { - ZEPHIR_INIT_NVAR(&link); - ZVAL_COPY(&link, _1); - ZEPHIR_CALL_METHOD(&rels, &link, "getrels", NULL, 0); - zephir_check_call_status(); - if (1 == zephir_fast_in_array(&rel, &rels)) { - zephir_array_append(&filtered, &link, PH_SEPARATE, "phalcon/Html/Link/AbstractLinkProvider.zep", 76); - } - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params_without_memory_grow(2, 1, &source_param, &target_param, &included_param); + source = zephir_get_doubleval(source_param); + target = zephir_get_doubleval(target_param); + if (!included_param) { + included = 0; } else { - ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&link, &_0, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&rels, &link, "getrels", NULL, 0); - zephir_check_call_status(); - if (1 == zephir_fast_in_array(&rel, &rels)) { - zephir_array_append(&filtered, &link, PH_SEPARATE, "phalcon/Html/Link/AbstractLinkProvider.zep", 76); - } - ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); - zephir_check_call_status(); } + _0 = included == 0; + if (_0) { + _0 = source != target; } - ZEPHIR_INIT_NVAR(&link); - RETURN_CTOR(&filtered); + RETURN_BOOL(_0); } -static PHP_METHOD(Phalcon_Html_Link_AbstractLinkProvider, doWithLink) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_File_Size_Max) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *link, link_sub, key, newInstance; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator\\File\\Size, Max, phalcon, filter_validation_validator_file_size_max, phalcon_filter_validation_validator_file_size_equal_ce, phalcon_filter_validation_validator_file_size_max_method_entry, 0); - ZVAL_UNDEF(&link_sub); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&newInstance); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(link) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &link); - ZEPHIR_CALL_METHOD(&key, this_ptr, "getkey", NULL, 0, link); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&newInstance); - if (zephir_clone(&newInstance, this_ptr) == FAILURE) { - RETURN_MM(); - } - zephir_update_property_array(&newInstance, SL("links"), &key, link); - RETURN_CCTOR(&newInstance); + zend_declare_property_string(phalcon_filter_validation_validator_file_size_max_ce, SL("template"), "File :field exceeds the size of :size", ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Link_AbstractLinkProvider, doWithoutLink) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_Size_Max, getConditional) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *link, link_sub, key, newInstance, _0; - zval *this_ptr = getThis(); + zend_bool included; + zval *source_param = NULL, *target_param = NULL, *included_param = NULL; + double source, target; - ZVAL_UNDEF(&link_sub); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&newInstance); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(link) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ZVAL(source) + Z_PARAM_ZVAL(target) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(included) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &link); - ZEPHIR_CALL_METHOD(&key, this_ptr, "getkey", NULL, 0, link); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&newInstance); - if (zephir_clone(&newInstance, this_ptr) == FAILURE) { - RETURN_MM(); + zephir_fetch_params_without_memory_grow(2, 1, &source_param, &target_param, &included_param); + source = zephir_get_doubleval(source_param); + target = zephir_get_doubleval(target_param); + if (!included_param) { + included = 0; + } else { + } + if (included == 1) { + RETURN_BOOL(target >= source); } - zephir_unset_property_array(&newInstance, ZEND_STRL("links"), &key); - zephir_read_property(&_0, &newInstance, ZEND_STRL("links"), PH_NOISY_CC | PH_READONLY); - zephir_array_unset(&_0, &key, PH_SEPARATE); - RETURN_CCTOR(&newInstance); + RETURN_BOOL(target > source); } -static PHP_METHOD(Phalcon_Html_Link_AbstractLinkProvider, getKey) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_File_Size_Min) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *link, link_sub; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator\\File\\Size, Min, phalcon, filter_validation_validator_file_size_min, phalcon_filter_validation_validator_file_size_equal_ce, phalcon_filter_validation_validator_file_size_min_method_entry, 0); - ZVAL_UNDEF(&link_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(link) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &link); - ZEPHIR_RETURN_CALL_FUNCTION("spl_object_hash", NULL, 80, link); - zephir_check_call_status(); - RETURN_MM(); + zend_declare_property_string(phalcon_filter_validation_validator_file_size_min_ce, SL("template"), "File :field can not have the minimum size of :size", ZEND_ACC_PROTECTED); + return SUCCESS; } -zend_object *zephir_init_properties_Phalcon_Html_Link_AbstractLinkProvider(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_File_Size_Min, getConditional) { - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - + zend_bool included; + zval *source_param = NULL, *target_param = NULL, *included_param = NULL; + double source, target; - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("links"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("links"), &_1$$3); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ZVAL(source) + Z_PARAM_ZVAL(target) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(included) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(2, 1, &source_param, &target_param, &included_param); + source = zephir_get_doubleval(source_param); + target = zephir_get_doubleval(target_param); + if (!included_param) { + included = 0; + } else { } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + if (included == 1) { + RETURN_BOOL(target <= source); } + RETURN_BOOL(target < source); } @@ -119529,117 +119511,258 @@ zend_object *zephir_init_properties_Phalcon_Html_Link_AbstractLinkProvider(zend_ -ZEPHIR_INIT_CLASS(Phalcon_Html_Link_EvolvableLink) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_StringLength_Max) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Link, EvolvableLink, phalcon, html_link_evolvablelink, phalcon_html_link_link_ce, phalcon_html_link_evolvablelink_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator\\StringLength, Max, phalcon, filter_validation_validator_stringlength_max, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_stringlength_max_method_entry, 0); - zend_class_implements(phalcon_html_link_evolvablelink_ce, 1, phalcon_html_link_interfaces_evolvablelinkinterface_ce); + zend_declare_property_string(phalcon_filter_validation_validator_stringlength_max_ce, SL("template"), "Field :field must not exceed :max characters long", ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Link_EvolvableLink, withAttribute) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_StringLength_Max, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *attribute, attribute_sub, *value, value_sub; - zval *this_ptr = getThis(); + zval *options_param = NULL; + zval options; - ZVAL_UNDEF(&attribute_sub); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(attribute) - Z_PARAM_ZVAL(value) + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &attribute, &value); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dowithattribute", NULL, 0, attribute, value); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + } + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_stringlength_max_ce, getThis(), "__construct", NULL, 0, &options); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Link_EvolvableLink, withHref) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_StringLength_Max, validate) { + double _6$$7, _7$$8; + zval _1$$4, _2$$5; + zend_bool result = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *href_param = NULL; - zval href; + zval *validation, validation_sub, *field, field_sub, value, length, maximum, replacePairs, included, _0, _3, _4$$6, _5$$7, _8$$11; zval *this_ptr = getThis(); - ZVAL_UNDEF(&href); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(href) + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&length); + ZVAL_UNDEF(&maximum); + ZVAL_UNDEF(&replacePairs); + ZVAL_UNDEF(&included); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4$$6); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_8$$11); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$5); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &href_param); - zephir_get_strval(&href, href_param); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dowithhref", NULL, 0, &href); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "allowempty", NULL, 0, field, &value); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + RETURN_MM_BOOL(1); + } + if ((zephir_function_exists_ex(ZEND_STRL("mb_strlen")) == SUCCESS)) { + zephir_cast_to_string(&_1$$4, &value); + ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 234, &_1$$4); + zephir_check_call_status(); + } else { + zephir_cast_to_string(&_2$$5, &value); + ZEPHIR_INIT_NVAR(&length); + ZVAL_LONG(&length, zephir_fast_strlen_ev(&_2$$5)); + } + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "max"); + ZEPHIR_CALL_METHOD(&maximum, this_ptr, "getoption", NULL, 0, &_3); + zephir_check_call_status(); + if (Z_TYPE_P(&maximum) == IS_ARRAY) { + zephir_array_fetch(&_4$$6, &maximum, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/StringLength/Max.zep", 106); + ZEPHIR_CPY_WRT(&maximum, &_4$$6); + } + ZEPHIR_INIT_NVAR(&_3); + ZVAL_STRING(&_3, "included"); + ZEPHIR_CALL_METHOD(&included, this_ptr, "getoption", NULL, 0, &_3); + zephir_check_call_status(); + if (Z_TYPE_P(&included) == IS_ARRAY) { + zephir_memory_observe(&_5$$7); + zephir_array_fetch(&_5$$7, &included, field, PH_NOISY, "phalcon/Filter/Validation/Validator/StringLength/Max.zep", 112); + _6$$7 = zephir_get_boolval(&_5$$7); + ZEPHIR_INIT_NVAR(&included); + ZVAL_BOOL(&included, _6$$7); + } else { + _7$$8 = zephir_get_boolval(&included); + ZEPHIR_INIT_NVAR(&included); + ZVAL_BOOL(&included, _7$$8); + } + if (zephir_is_true(&included)) { + result = ZEPHIR_GE(&length, &maximum); + } else { + result = ZEPHIR_GT(&length, &maximum); + } + if (result) { + ZEPHIR_INIT_VAR(&replacePairs); + zephir_create_array(&replacePairs, 1, 0); + zephir_array_update_string(&replacePairs, SL(":max"), &maximum, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_8$$11, this_ptr, "messagefactory", NULL, 0, validation, field, &replacePairs); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_8$$11); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Html_Link_EvolvableLink, withRel) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Validation_Validator_StringLength_Min) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *rel_param = NULL; - zval rel; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Filter\\Validation\\Validator\\StringLength, Min, phalcon, filter_validation_validator_stringlength_min, phalcon_filter_validation_abstractvalidator_ce, phalcon_filter_validation_validator_stringlength_min_method_entry, 0); - ZVAL_UNDEF(&rel); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(rel) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &rel_param); - zephir_get_strval(&rel, rel_param); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dowithrel", NULL, 0, &rel); - zephir_check_call_status(); - RETURN_MM(); + zend_declare_property_string(phalcon_filter_validation_validator_stringlength_min_ce, SL("template"), "Field :field must be at least :min characters long", ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Link_EvolvableLink, withoutAttribute) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_StringLength_Min, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *attribute_param = NULL; - zval attribute; - zval *this_ptr = getThis(); + zval *options_param = NULL; + zval options; - ZVAL_UNDEF(&attribute); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(attribute) + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &attribute_param); - zephir_get_strval(&attribute, attribute_param); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dowithoutattribute", NULL, 0, &attribute); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + } + ZEPHIR_CALL_PARENT(NULL, phalcon_filter_validation_validator_stringlength_min_ce, getThis(), "__construct", NULL, 0, &options); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Link_EvolvableLink, withoutRel) +static PHP_METHOD(Phalcon_Filter_Validation_Validator_StringLength_Min, validate) { + double _6$$7, _7$$8; + zval _1$$4, _2$$5; + zend_bool result = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *rel_param = NULL; - zval rel; + zval *validation, validation_sub, *field, field_sub, value, length, minimum, replacePairs, included, _0, _3, _4$$6, _5$$7, _8$$11; zval *this_ptr = getThis(); - ZVAL_UNDEF(&rel); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(rel) + ZVAL_UNDEF(&validation_sub); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&length); + ZVAL_UNDEF(&minimum); + ZVAL_UNDEF(&replacePairs); + ZVAL_UNDEF(&included); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4$$6); + ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_8$$11); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$5); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_ce) + Z_PARAM_ZVAL(field) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &rel_param); - zephir_get_strval(&rel, rel_param); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dowithoutrel", NULL, 0, &rel); + zephir_fetch_params(1, 2, 0, &validation, &field); + ZEPHIR_CALL_METHOD(&value, validation, "getvalue", NULL, 0, field); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "allowempty", NULL, 0, field, &value); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + RETURN_MM_BOOL(1); + } + if ((zephir_function_exists_ex(ZEND_STRL("mb_strlen")) == SUCCESS)) { + zephir_cast_to_string(&_1$$4, &value); + ZEPHIR_CALL_FUNCTION(&length, "mb_strlen", NULL, 234, &_1$$4); + zephir_check_call_status(); + } else { + zephir_cast_to_string(&_2$$5, &value); + ZEPHIR_INIT_NVAR(&length); + ZVAL_LONG(&length, zephir_fast_strlen_ev(&_2$$5)); + } + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "min"); + ZEPHIR_CALL_METHOD(&minimum, this_ptr, "getoption", NULL, 0, &_3); + zephir_check_call_status(); + if (Z_TYPE_P(&minimum) == IS_ARRAY) { + zephir_array_fetch(&_4$$6, &minimum, field, PH_NOISY | PH_READONLY, "phalcon/Filter/Validation/Validator/StringLength/Min.zep", 106); + ZEPHIR_CPY_WRT(&minimum, &_4$$6); + } + ZEPHIR_INIT_NVAR(&_3); + ZVAL_STRING(&_3, "included"); + ZEPHIR_CALL_METHOD(&included, this_ptr, "getoption", NULL, 0, &_3); + zephir_check_call_status(); + if (Z_TYPE_P(&included) == IS_ARRAY) { + zephir_memory_observe(&_5$$7); + zephir_array_fetch(&_5$$7, &included, field, PH_NOISY, "phalcon/Filter/Validation/Validator/StringLength/Min.zep", 112); + _6$$7 = zephir_get_boolval(&_5$$7); + ZEPHIR_INIT_NVAR(&included); + ZVAL_BOOL(&included, _6$$7); + } else { + _7$$8 = zephir_get_boolval(&included); + ZEPHIR_INIT_NVAR(&included); + ZVAL_BOOL(&included, _7$$8); + } + if (zephir_is_true(&included)) { + result = ZEPHIR_LE(&length, &minimum); + } else { + result = ZEPHIR_LT(&length, &minimum); + } + if (result) { + ZEPHIR_INIT_VAR(&replacePairs); + zephir_create_array(&replacePairs, 1, 0); + zephir_array_update_string(&replacePairs, SL(":min"), &minimum, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_8$$11, this_ptr, "messagefactory", NULL, 0, validation, field, &replacePairs); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, validation, "appendmessage", NULL, 0, &_8$$11); + zephir_check_call_status(); + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(1); } @@ -119652,48 +119775,74 @@ static PHP_METHOD(Phalcon_Html_Link_EvolvableLink, withoutRel) -ZEPHIR_INIT_CLASS(Phalcon_Html_Link_EvolvableLinkProvider) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_AbsInt) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Link, EvolvableLinkProvider, phalcon, html_link_evolvablelinkprovider, phalcon_html_link_linkprovider_ce, phalcon_html_link_evolvablelinkprovider_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, AbsInt, phalcon, filter_sanitize_absint, phalcon_filter_sanitize_absint_method_entry, 0); - zend_class_implements(phalcon_html_link_evolvablelinkprovider_ce, 1, phalcon_html_link_interfaces_evolvablelinkproviderinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Link_EvolvableLinkProvider, withLink) +static PHP_METHOD(Phalcon_Filter_Sanitize_AbsInt, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *link, link_sub; - zval *this_ptr = getThis(); + zval *input, input_sub, _0, _1; - ZVAL_UNDEF(&link_sub); + ZVAL_UNDEF(&input_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(link, phalcon_html_link_interfaces_linkinterface_ce) + Z_PARAM_ZVAL(input) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &link); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dowithlink", NULL, 0, link); + zephir_fetch_params(1, 1, 0, &input); + ZVAL_LONG(&_0, 519); + ZEPHIR_CALL_FUNCTION(&_1, "filter_var", NULL, 283, input, &_0); + zephir_check_call_status(); + ZVAL_LONG(&_0, zephir_get_intval(&_1)); + ZEPHIR_RETURN_CALL_FUNCTION("abs", NULL, 284, &_0); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Html_Link_EvolvableLinkProvider, withoutLink) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_Alnum) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, Alnum, phalcon, filter_sanitize_alnum, phalcon_filter_sanitize_alnum_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Sanitize_Alnum, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *link, link_sub; - zval *this_ptr = getThis(); + zval *input, input_sub, _0, _1; - ZVAL_UNDEF(&link_sub); + ZVAL_UNDEF(&input_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(link, phalcon_html_link_interfaces_linkinterface_ce) + Z_PARAM_ZVAL(input) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &link); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dowithoutlink", NULL, 0, link); + zephir_fetch_params(1, 1, 0, &input); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "/[^A-Za-z0-9]/"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, ""); + ZEPHIR_RETURN_CALL_FUNCTION("preg_replace", NULL, 41, &_0, &_1, input); zephir_check_call_status(); RETURN_MM(); } @@ -119708,64 +119857,143 @@ static PHP_METHOD(Phalcon_Html_Link_EvolvableLinkProvider, withoutLink) -ZEPHIR_INIT_CLASS(Phalcon_Html_Link_Link) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_Alpha) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Link, Link, phalcon, html_link_link, phalcon_html_link_abstractlink_ce, phalcon_html_link_link_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, Alpha, phalcon, filter_sanitize_alpha, phalcon_filter_sanitize_alpha_method_entry, 0); - zend_class_implements(phalcon_html_link_link_ce, 1, phalcon_html_link_interfaces_linkinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Link_Link, getAttributes) +static PHP_METHOD(Phalcon_Filter_Sanitize_Alpha, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + zval *input, input_sub, _0, _1; + + ZVAL_UNDEF(&input_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(input) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dogetattributes", NULL, 0); + zephir_fetch_params(1, 1, 0, &input); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "/[^A-Za-z]/"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, ""); + ZEPHIR_RETURN_CALL_FUNCTION("preg_replace", NULL, 41, &_0, &_1, input); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Html_Link_Link, getHref) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dogethref", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Html_Link_Link, getRels) + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_BoolVal) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, BoolVal, phalcon, filter_sanitize_boolval, phalcon_filter_sanitize_boolval_method_entry, 0); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dogetrels", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Link_Link, isTemplated) +static PHP_METHOD(Phalcon_Filter_Sanitize_BoolVal, __invoke) { + zend_bool _1, _2, _4, _5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + zval *input = NULL, input_sub, falseArray, trueArray, _0, _3; + + ZVAL_UNDEF(&input_sub); + ZVAL_UNDEF(&falseArray); + ZVAL_UNDEF(&trueArray); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(input) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "doistemplated", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &input); + ZEPHIR_SEPARATE_PARAM(input); + ZEPHIR_INIT_VAR(&trueArray); + zephir_create_array(&trueArray, 5, 0); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "true"); + zephir_array_fast_append(&trueArray, &_0); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "on"); + zephir_array_fast_append(&trueArray, &_0); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "yes"); + zephir_array_fast_append(&trueArray, &_0); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "y"); + zephir_array_fast_append(&trueArray, &_0); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "1"); + zephir_array_fast_append(&trueArray, &_0); + ZEPHIR_INIT_VAR(&falseArray); + zephir_create_array(&falseArray, 5, 0); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "false"); + zephir_array_fast_append(&falseArray, &_0); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "off"); + zephir_array_fast_append(&falseArray, &_0); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "no"); + zephir_array_fast_append(&falseArray, &_0); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "n"); + zephir_array_fast_append(&falseArray, &_0); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "0"); + zephir_array_fast_append(&falseArray, &_0); + _1 = Z_TYPE_P(input) == IS_STRING; + if (!(_1)) { + _1 = Z_TYPE_P(input) == IS_LONG; + } + _2 = _1; + if (!(_2)) { + _2 = (Z_TYPE_P(input) == IS_TRUE || Z_TYPE_P(input) == IS_FALSE); + } + if (1 != _2) { + RETURN_MM_BOOL(0); + } + ZEPHIR_INIT_VAR(&_3); + if (Z_TYPE_P(input) == IS_STRING) { + ZEPHIR_INIT_NVAR(&_0); + zephir_fast_trim(&_0, input, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_CALL_FUNCTION(&_3, "mb_strtolower", NULL, 10, &_0); + zephir_check_call_status(); + } else { + ZEPHIR_CPY_WRT(&_3, input); + } + ZEPHIR_CPY_WRT(input, &_3); + _4 = ZEPHIR_IS_TRUE_IDENTICAL(input); + if (!(_4)) { + _4 = 1 == zephir_fast_in_array(input, &trueArray); + } + if (_4) { + RETURN_MM_BOOL(1); + } + _5 = ZEPHIR_IS_FALSE_IDENTICAL(input); + if (!(_5)) { + _5 = 1 == zephir_fast_in_array(input, &falseArray); + } + if (_5) { + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(zephir_get_boolval(input)); } @@ -119778,42 +120006,31 @@ static PHP_METHOD(Phalcon_Html_Link_Link, isTemplated) -ZEPHIR_INIT_CLASS(Phalcon_Html_Link_LinkProvider) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_Email) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Link, LinkProvider, phalcon, html_link_linkprovider, phalcon_html_link_abstractlinkprovider_ce, phalcon_html_link_linkprovider_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, Email, phalcon, filter_sanitize_email, phalcon_filter_sanitize_email_method_entry, 0); - zend_class_implements(phalcon_html_link_linkprovider_ce, 1, phalcon_html_link_interfaces_linkproviderinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Link_LinkProvider, getLinks) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dogetlinks", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Html_Link_LinkProvider, getLinksByRel) +static PHP_METHOD(Phalcon_Filter_Sanitize_Email, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *rel, rel_sub; - zval *this_ptr = getThis(); + zval *input, input_sub, _0, _1; - ZVAL_UNDEF(&rel_sub); + ZVAL_UNDEF(&input_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(rel) + Z_PARAM_ZVAL(input) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &rel); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dogetlinksbyrel", NULL, 0, rel); + zephir_fetch_params(1, 1, 0, &input); + ZVAL_LONG(&_0, 517); + ZVAL_LONG(&_1, 1048576); + ZEPHIR_RETURN_CALL_FUNCTION("filter_var", NULL, 283, input, &_0, &_1); zephir_check_call_status(); RETURN_MM(); } @@ -119828,387 +120045,132 @@ static PHP_METHOD(Phalcon_Html_Link_LinkProvider, getLinksByRel) -ZEPHIR_INIT_CLASS(Phalcon_Html_Link_Serializer_Header) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_FloatVal) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Html\\Link\\Serializer, Header, phalcon, html_link_serializer_header, phalcon_html_link_serializer_header_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, FloatVal, phalcon, filter_sanitize_floatval, phalcon_filter_sanitize_floatval_method_entry, 0); - zend_class_implements(phalcon_html_link_serializer_header_ce, 1, phalcon_html_link_serializer_serializerinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Link_Serializer_Header, serialize) -{ - zend_string *_8$$3, *_28$$17; - zend_ulong _7$$3, _27$$17; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *links_param = NULL, attributes, key, link, rels, result, subValue, value, *_0, _1, _2$$3, _3$$3, _4$$3, *_5$$3, _6$$3, _19$$3, _20$$3, *_9$$6, _10$$6, _11$$7, _12$$8, _13$$9, *_14$$12, _15$$12, _16$$13, _17$$14, _18$$15, _21$$17, _22$$17, _23$$17, _24$$17, *_25$$17, _26$$17, _39$$17, _40$$17, *_29$$20, _30$$20, _31$$21, _32$$22, _33$$23, *_34$$26, _35$$26, _36$$27, _37$$28, _38$$29; - zval links, elements, parts; - - ZVAL_UNDEF(&links); - ZVAL_UNDEF(&elements); - ZVAL_UNDEF(&parts); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&link); - ZVAL_UNDEF(&rels); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&subValue); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_19$$3); - ZVAL_UNDEF(&_20$$3); - ZVAL_UNDEF(&_10$$6); - ZVAL_UNDEF(&_11$$7); - ZVAL_UNDEF(&_12$$8); - ZVAL_UNDEF(&_13$$9); - ZVAL_UNDEF(&_15$$12); - ZVAL_UNDEF(&_16$$13); - ZVAL_UNDEF(&_17$$14); - ZVAL_UNDEF(&_18$$15); - ZVAL_UNDEF(&_21$$17); - ZVAL_UNDEF(&_22$$17); - ZVAL_UNDEF(&_23$$17); - ZVAL_UNDEF(&_24$$17); - ZVAL_UNDEF(&_26$$17); - ZVAL_UNDEF(&_39$$17); - ZVAL_UNDEF(&_40$$17); - ZVAL_UNDEF(&_30$$20); - ZVAL_UNDEF(&_31$$21); - ZVAL_UNDEF(&_32$$22); - ZVAL_UNDEF(&_33$$23); - ZVAL_UNDEF(&_35$$26); - ZVAL_UNDEF(&_36$$27); - ZVAL_UNDEF(&_37$$28); - ZVAL_UNDEF(&_38$$29); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(links) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &links_param); - zephir_get_arrval(&links, links_param); - ZEPHIR_INIT_VAR(&result); - ZVAL_NULL(&result); - ZEPHIR_INIT_VAR(&elements); - array_init(&elements); - zephir_is_iterable(&links, 0, "phalcon/Html/Link/Serializer/Header.zep", 70); - if (Z_TYPE_P(&links) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&links), _0) - { - ZEPHIR_INIT_NVAR(&link); - ZVAL_COPY(&link, _0); - ZEPHIR_CALL_METHOD(&_2$$3, &link, "istemplated", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_2$$3)) { - continue; - } - ZEPHIR_CALL_METHOD(&attributes, &link, "getattributes", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&rels, &link, "getrels", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&parts); - zephir_create_array(&parts, 2, 0); - ZEPHIR_INIT_NVAR(&_3$$3); - ZVAL_STRING(&_3$$3, ""); - zephir_array_fast_append(&parts, &_3$$3); - ZEPHIR_INIT_NVAR(&_3$$3); - zephir_fast_join_str(&_3$$3, SL(" "), &rels); - ZEPHIR_INIT_NVAR(&_4$$3); - ZEPHIR_CONCAT_SVS(&_4$$3, "rel=\"", &_3$$3, "\""); - zephir_array_fast_append(&parts, &_4$$3); - zephir_is_iterable(&attributes, 0, "phalcon/Html/Link/Serializer/Header.zep", 64); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&attributes), _7$$3, _8$$3, _5$$3) - { - ZEPHIR_INIT_NVAR(&key); - if (_8$$3 != NULL) { - ZVAL_STR_COPY(&key, _8$$3); - } else { - ZVAL_LONG(&key, _7$$3); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _5$$3); - if (Z_TYPE_P(&value) == IS_ARRAY) { - zephir_is_iterable(&value, 0, "phalcon/Html/Link/Serializer/Header.zep", 50); - if (Z_TYPE_P(&value) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&value), _9$$6) - { - ZEPHIR_INIT_NVAR(&subValue); - ZVAL_COPY(&subValue, _9$$6); - ZEPHIR_INIT_NVAR(&_11$$7); - ZEPHIR_CONCAT_VSVS(&_11$$7, &key, "=\"", &subValue, "\""); - zephir_array_append(&parts, &_11$$7, PH_SEPARATE, "phalcon/Html/Link/Serializer/Header.zep", 48); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &value, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_10$$6, &value, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_10$$6)) { - break; - } - ZEPHIR_CALL_METHOD(&subValue, &value, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_12$$8); - ZEPHIR_CONCAT_VSVS(&_12$$8, &key, "=\"", &subValue, "\""); - zephir_array_append(&parts, &_12$$8, PH_SEPARATE, "phalcon/Html/Link/Serializer/Header.zep", 48); - ZEPHIR_CALL_METHOD(NULL, &value, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&subValue); - continue; - } - if (((Z_TYPE_P(&value) == IS_TRUE || Z_TYPE_P(&value) == IS_FALSE) != 1)) { - ZEPHIR_INIT_NVAR(&_13$$9); - ZEPHIR_CONCAT_VSVS(&_13$$9, &key, "=\"", &value, "\""); - zephir_array_append(&parts, &_13$$9, PH_SEPARATE, "phalcon/Html/Link/Serializer/Header.zep", 54); - continue; - } - if (ZEPHIR_IS_TRUE_IDENTICAL(&value)) { - zephir_array_append(&parts, &key, PH_SEPARATE, "phalcon/Html/Link/Serializer/Header.zep", 59); - continue; - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_6$$3, &attributes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_6$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &attributes, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &attributes, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&value) == IS_ARRAY) { - zephir_is_iterable(&value, 0, "phalcon/Html/Link/Serializer/Header.zep", 50); - if (Z_TYPE_P(&value) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&value), _14$$12) - { - ZEPHIR_INIT_NVAR(&subValue); - ZVAL_COPY(&subValue, _14$$12); - ZEPHIR_INIT_NVAR(&_16$$13); - ZEPHIR_CONCAT_VSVS(&_16$$13, &key, "=\"", &subValue, "\""); - zephir_array_append(&parts, &_16$$13, PH_SEPARATE, "phalcon/Html/Link/Serializer/Header.zep", 48); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &value, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_15$$12, &value, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_15$$12)) { - break; - } - ZEPHIR_CALL_METHOD(&subValue, &value, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_17$$14); - ZEPHIR_CONCAT_VSVS(&_17$$14, &key, "=\"", &subValue, "\""); - zephir_array_append(&parts, &_17$$14, PH_SEPARATE, "phalcon/Html/Link/Serializer/Header.zep", 48); - ZEPHIR_CALL_METHOD(NULL, &value, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&subValue); - continue; - } - if (((Z_TYPE_P(&value) == IS_TRUE || Z_TYPE_P(&value) == IS_FALSE) != 1)) { - ZEPHIR_INIT_NVAR(&_18$$15); - ZEPHIR_CONCAT_VSVS(&_18$$15, &key, "=\"", &value, "\""); - zephir_array_append(&parts, &_18$$15, PH_SEPARATE, "phalcon/Html/Link/Serializer/Header.zep", 54); - continue; - } - if (ZEPHIR_IS_TRUE_IDENTICAL(&value)) { - zephir_array_append(&parts, &key, PH_SEPARATE, "phalcon/Html/Link/Serializer/Header.zep", 59); - continue; - } - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - ZEPHIR_CALL_METHOD(&_19$$3, &link, "gethref", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_20$$3); - zephir_fast_join_str(&_20$$3, SL("; "), &parts); - ZEPHIR_INIT_NVAR(&_4$$3); - ZEPHIR_CONCAT_SVSV(&_4$$3, "<", &_19$$3, ">", &_20$$3); - zephir_array_append(&elements, &_4$$3, PH_SEPARATE, "phalcon/Html/Link/Serializer/Header.zep", 67); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &links, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &links, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&link, &links, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_21$$17, &link, "istemplated", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_21$$17)) { - continue; - } - ZEPHIR_CALL_METHOD(&attributes, &link, "getattributes", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&rels, &link, "getrels", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_22$$17); - zephir_create_array(&_22$$17, 2, 0); - ZEPHIR_INIT_NVAR(&_23$$17); - ZVAL_STRING(&_23$$17, ""); - zephir_array_fast_append(&_22$$17, &_23$$17); - ZEPHIR_INIT_NVAR(&_23$$17); - zephir_fast_join_str(&_23$$17, SL(" "), &rels); - ZEPHIR_INIT_NVAR(&_24$$17); - ZEPHIR_CONCAT_SVS(&_24$$17, "rel=\"", &_23$$17, "\""); - zephir_array_fast_append(&_22$$17, &_24$$17); - ZEPHIR_CPY_WRT(&parts, &_22$$17); - zephir_is_iterable(&attributes, 0, "phalcon/Html/Link/Serializer/Header.zep", 64); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&attributes), _27$$17, _28$$17, _25$$17) - { - ZEPHIR_INIT_NVAR(&key); - if (_28$$17 != NULL) { - ZVAL_STR_COPY(&key, _28$$17); - } else { - ZVAL_LONG(&key, _27$$17); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _25$$17); - if (Z_TYPE_P(&value) == IS_ARRAY) { - zephir_is_iterable(&value, 0, "phalcon/Html/Link/Serializer/Header.zep", 50); - if (Z_TYPE_P(&value) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&value), _29$$20) - { - ZEPHIR_INIT_NVAR(&subValue); - ZVAL_COPY(&subValue, _29$$20); - ZEPHIR_INIT_NVAR(&_31$$21); - ZEPHIR_CONCAT_VSVS(&_31$$21, &key, "=\"", &subValue, "\""); - zephir_array_append(&parts, &_31$$21, PH_SEPARATE, "phalcon/Html/Link/Serializer/Header.zep", 48); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &value, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_30$$20, &value, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_30$$20)) { - break; - } - ZEPHIR_CALL_METHOD(&subValue, &value, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_32$$22); - ZEPHIR_CONCAT_VSVS(&_32$$22, &key, "=\"", &subValue, "\""); - zephir_array_append(&parts, &_32$$22, PH_SEPARATE, "phalcon/Html/Link/Serializer/Header.zep", 48); - ZEPHIR_CALL_METHOD(NULL, &value, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&subValue); - continue; - } - if (((Z_TYPE_P(&value) == IS_TRUE || Z_TYPE_P(&value) == IS_FALSE) != 1)) { - ZEPHIR_INIT_NVAR(&_33$$23); - ZEPHIR_CONCAT_VSVS(&_33$$23, &key, "=\"", &value, "\""); - zephir_array_append(&parts, &_33$$23, PH_SEPARATE, "phalcon/Html/Link/Serializer/Header.zep", 54); - continue; - } - if (ZEPHIR_IS_TRUE_IDENTICAL(&value)) { - zephir_array_append(&parts, &key, PH_SEPARATE, "phalcon/Html/Link/Serializer/Header.zep", 59); - continue; - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_26$$17, &attributes, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_26$$17)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &attributes, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &attributes, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&value) == IS_ARRAY) { - zephir_is_iterable(&value, 0, "phalcon/Html/Link/Serializer/Header.zep", 50); - if (Z_TYPE_P(&value) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&value), _34$$26) - { - ZEPHIR_INIT_NVAR(&subValue); - ZVAL_COPY(&subValue, _34$$26); - ZEPHIR_INIT_NVAR(&_36$$27); - ZEPHIR_CONCAT_VSVS(&_36$$27, &key, "=\"", &subValue, "\""); - zephir_array_append(&parts, &_36$$27, PH_SEPARATE, "phalcon/Html/Link/Serializer/Header.zep", 48); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &value, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_35$$26, &value, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_35$$26)) { - break; - } - ZEPHIR_CALL_METHOD(&subValue, &value, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_37$$28); - ZEPHIR_CONCAT_VSVS(&_37$$28, &key, "=\"", &subValue, "\""); - zephir_array_append(&parts, &_37$$28, PH_SEPARATE, "phalcon/Html/Link/Serializer/Header.zep", 48); - ZEPHIR_CALL_METHOD(NULL, &value, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&subValue); - continue; - } - if (((Z_TYPE_P(&value) == IS_TRUE || Z_TYPE_P(&value) == IS_FALSE) != 1)) { - ZEPHIR_INIT_NVAR(&_38$$29); - ZEPHIR_CONCAT_VSVS(&_38$$29, &key, "=\"", &value, "\""); - zephir_array_append(&parts, &_38$$29, PH_SEPARATE, "phalcon/Html/Link/Serializer/Header.zep", 54); - continue; - } - if (ZEPHIR_IS_TRUE_IDENTICAL(&value)) { - zephir_array_append(&parts, &key, PH_SEPARATE, "phalcon/Html/Link/Serializer/Header.zep", 59); - continue; - } - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - ZEPHIR_CALL_METHOD(&_39$$17, &link, "gethref", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_40$$17); - zephir_fast_join_str(&_40$$17, SL("; "), &parts); - ZEPHIR_INIT_NVAR(&_24$$17); - ZEPHIR_CONCAT_SVSV(&_24$$17, "<", &_39$$17, ">", &_40$$17); - zephir_array_append(&elements, &_24$$17, PH_SEPARATE, "phalcon/Html/Link/Serializer/Header.zep", 67); - ZEPHIR_CALL_METHOD(NULL, &links, "next", NULL, 0); - zephir_check_call_status(); - } +static PHP_METHOD(Phalcon_Filter_Sanitize_FloatVal, __invoke) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *input, input_sub, _1, _2; + + ZVAL_UNDEF(&input_sub); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(input) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &input); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 1, 0); + add_assoc_long_ex(&_0, SL("flags"), 4096); + ZVAL_LONG(&_1, 520); + ZEPHIR_CALL_FUNCTION(&_2, "filter_var", NULL, 283, input, &_1, &_0); + zephir_check_call_status(); + RETURN_MM_DOUBLE(zephir_get_doubleval(&_2)); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_IntVal) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, IntVal, phalcon, filter_sanitize_intval, phalcon_filter_sanitize_intval_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Sanitize_IntVal, __invoke) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *input, input_sub, _0, _1; + + ZVAL_UNDEF(&input_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(input) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &input); + ZVAL_LONG(&_0, 519); + ZEPHIR_CALL_FUNCTION(&_1, "filter_var", NULL, 283, input, &_0); + zephir_check_call_status(); + RETURN_MM_LONG(zephir_get_intval(&_1)); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_Lower) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, Lower, phalcon, filter_sanitize_lower, phalcon_filter_sanitize_lower_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Sanitize_Lower, __invoke) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL, _0$$3, _1$$3, _2; + zval input; + + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(input) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &input_param); + if (UNEXPECTED(Z_TYPE_P(input_param) != IS_STRING && Z_TYPE_P(input_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'input' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_INIT_NVAR(&link); - if (zephir_fast_count_int(&elements) > 0) { - ZEPHIR_INIT_NVAR(&result); - zephir_fast_join_str(&result, SL(","), &elements); + if (EXPECTED(Z_TYPE_P(input_param) == IS_STRING)) { + zephir_get_strval(&input, input_param); + } else { + ZEPHIR_INIT_VAR(&input); } - RETURN_CCTOR(&result); + if (1 == (zephir_function_exists_ex(ZEND_STRL("mb_convert_case")) == SUCCESS)) { + ZVAL_LONG(&_0$$3, 1); + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "UTF-8"); + ZEPHIR_RETURN_CALL_FUNCTION("mb_convert_case", NULL, 12, &input, &_0$$3, &_1$$3); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_CALL_FUNCTION(&_2, "utf8_decode", NULL, 285, &input); + zephir_check_call_status(); + zephir_fast_strtolower(return_value, &_2); + RETURN_MM(); } @@ -120221,14 +120183,41 @@ static PHP_METHOD(Phalcon_Html_Link_Serializer_Header, serialize) -ZEPHIR_INIT_CLASS(Phalcon_Html_Link_Serializer_SerializerInterface) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_LowerFirst) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Html\\Link\\Serializer, SerializerInterface, phalcon, html_link_serializer_serializerinterface, phalcon_html_link_serializer_serializerinterface_method_entry); + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, LowerFirst, phalcon, filter_sanitize_lowerfirst, phalcon_filter_sanitize_lowerfirst_method_entry, 0); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Serializer_SerializerInterface, serialize); +static PHP_METHOD(Phalcon_Filter_Sanitize_LowerFirst, __invoke) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL; + zval input; + + ZVAL_UNDEF(&input); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(input) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &input_param); + if (UNEXPECTED(Z_TYPE_P(input_param) != IS_STRING && Z_TYPE_P(input_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'input' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(input_param) == IS_STRING)) { + zephir_get_strval(&input, input_param); + } else { + ZEPHIR_INIT_VAR(&input); + } + ZEPHIR_RETURN_CALL_FUNCTION("lcfirst", NULL, 76, &input); + zephir_check_call_status(); + RETURN_MM(); +} + @@ -120239,19 +120228,35 @@ ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Serializer_SerializerInterface, serialize); -ZEPHIR_INIT_CLASS(Phalcon_Html_Link_Interfaces_EvolvableLinkInterface) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_Regex) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Html\\Link\\Interfaces, EvolvableLinkInterface, phalcon, html_link_interfaces_evolvablelinkinterface, phalcon_html_link_interfaces_evolvablelinkinterface_method_entry); + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, Regex, phalcon, filter_sanitize_regex, phalcon_filter_sanitize_regex_method_entry, 0); - zend_class_implements(phalcon_html_link_interfaces_evolvablelinkinterface_ce, 1, phalcon_html_link_interfaces_linkinterface_ce); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Interfaces_EvolvableLinkInterface, withHref); -ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Interfaces_EvolvableLinkInterface, withRel); -ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Interfaces_EvolvableLinkInterface, withoutRel); -ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Interfaces_EvolvableLinkInterface, withAttribute); -ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Interfaces_EvolvableLinkInterface, withoutAttribute); +static PHP_METHOD(Phalcon_Filter_Sanitize_Regex, __invoke) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *input, input_sub, *pattern, pattern_sub, *replace, replace_sub; + + ZVAL_UNDEF(&input_sub); + ZVAL_UNDEF(&pattern_sub); + ZVAL_UNDEF(&replace_sub); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ZVAL(input) + Z_PARAM_ZVAL(pattern) + Z_PARAM_ZVAL(replace) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 0, &input, &pattern, &replace); + ZEPHIR_RETURN_CALL_FUNCTION("preg_replace", NULL, 41, pattern, replace, input); + zephir_check_call_status(); + RETURN_MM(); +} + @@ -120262,16 +120267,36 @@ ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Interfaces_EvolvableLinkInterface, withoutAt -ZEPHIR_INIT_CLASS(Phalcon_Html_Link_Interfaces_EvolvableLinkProviderInterface) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_Remove) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Html\\Link\\Interfaces, EvolvableLinkProviderInterface, phalcon, html_link_interfaces_evolvablelinkproviderinterface, phalcon_html_link_interfaces_evolvablelinkproviderinterface_method_entry); + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, Remove, phalcon, filter_sanitize_remove, phalcon_filter_sanitize_remove_method_entry, 0); - zend_class_implements(phalcon_html_link_interfaces_evolvablelinkproviderinterface_ce, 1, phalcon_html_link_interfaces_linkproviderinterface_ce); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Interfaces_EvolvableLinkProviderInterface, withLink); -ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Interfaces_EvolvableLinkProviderInterface, withoutLink); +static PHP_METHOD(Phalcon_Filter_Sanitize_Remove, __invoke) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *input, input_sub, *replace, replace_sub, _0, _1; + + ZVAL_UNDEF(&input_sub); + ZVAL_UNDEF(&replace_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(input) + Z_PARAM_ZVAL(replace) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &input, &replace); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, ""); + ZEPHIR_INIT_VAR(&_1); + zephir_fast_str_replace(&_1, replace, &_0, input); + RETURN_CCTOR(&_1); +} + @@ -120282,17 +120307,35 @@ ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Interfaces_EvolvableLinkProviderInterface, w -ZEPHIR_INIT_CLASS(Phalcon_Html_Link_Interfaces_LinkInterface) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_Replace) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Html\\Link\\Interfaces, LinkInterface, phalcon, html_link_interfaces_linkinterface, phalcon_html_link_interfaces_linkinterface_method_entry); + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, Replace, phalcon, filter_sanitize_replace, phalcon_filter_sanitize_replace_method_entry, 0); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Interfaces_LinkInterface, getAttributes); -ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Interfaces_LinkInterface, getHref); -ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Interfaces_LinkInterface, getRels); -ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Interfaces_LinkInterface, isTemplated); +static PHP_METHOD(Phalcon_Filter_Sanitize_Replace, __invoke) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *input, input_sub, *from, from_sub, *to, to_sub, _0; + + ZVAL_UNDEF(&input_sub); + ZVAL_UNDEF(&from_sub); + ZVAL_UNDEF(&to_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ZVAL(input) + Z_PARAM_ZVAL(from) + Z_PARAM_ZVAL(to) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 0, &input, &from, &to); + ZEPHIR_INIT_VAR(&_0); + zephir_fast_str_replace(&_0, from, to, input); + RETURN_CCTOR(&_0); +} + @@ -120303,15 +120346,33 @@ ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Interfaces_LinkInterface, isTemplated); -ZEPHIR_INIT_CLASS(Phalcon_Html_Link_Interfaces_LinkProviderInterface) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_Special) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Html\\Link\\Interfaces, LinkProviderInterface, phalcon, html_link_interfaces_linkproviderinterface, phalcon_html_link_interfaces_linkproviderinterface_method_entry); + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, Special, phalcon, filter_sanitize_special, phalcon_filter_sanitize_special_method_entry, 0); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Interfaces_LinkProviderInterface, getLinks); -ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Interfaces_LinkProviderInterface, getLinksByRel); +static PHP_METHOD(Phalcon_Filter_Sanitize_Special, __invoke) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *input, input_sub, _0; + + ZVAL_UNDEF(&input_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(input) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &input); + ZVAL_LONG(&_0, 515); + ZEPHIR_RETURN_CALL_FUNCTION("filter_var", NULL, 283, input, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + @@ -120322,518 +120383,979 @@ ZEPHIR_DOC_METHOD(Phalcon_Html_Link_Interfaces_LinkProviderInterface, getLinksBy -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_AbstractHelper) +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_SpecialFull) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Html\\Helper, AbstractHelper, phalcon, html_helper_abstracthelper, phalcon_html_helper_abstracthelper_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, SpecialFull, phalcon, filter_sanitize_specialfull, phalcon_filter_sanitize_specialfull_method_entry, 0); - zend_declare_property_string(phalcon_html_helper_abstracthelper_ce, SL("delimiter"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_html_helper_abstracthelper_ce, SL("escaper"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_html_helper_abstracthelper_ce, SL("indent"), " ", ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_html_helper_abstracthelper_ce, SL("indentLevel"), 1, ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Helper_AbstractHelper, __construct) +static PHP_METHOD(Phalcon_Filter_Sanitize_SpecialFull, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *escaper, escaper_sub, _0; - zval *this_ptr = getThis(); + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *input, input_sub, _0; - ZVAL_UNDEF(&escaper_sub); + ZVAL_UNDEF(&input_sub); ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(escaper, phalcon_html_escaper_escaperinterface_ce) + Z_PARAM_ZVAL(input) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &escaper); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_GET_CONSTANT(&_0, "PHP_EOL"); - zephir_update_property_zval(this_ptr, ZEND_STRL("delimiter"), &_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("escaper"), escaper); - ZEPHIR_MM_RESTORE(); + zephir_fetch_params(1, 1, 0, &input); + ZVAL_LONG(&_0, 522); + ZEPHIR_RETURN_CALL_FUNCTION("filter_var", NULL, 283, input, &_0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Html_Helper_AbstractHelper, close) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_StringVal) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, StringVal, phalcon, filter_sanitize_stringval, phalcon_filter_sanitize_stringval_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Sanitize_StringVal, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool raw; - zval *tag_param = NULL, *raw_param = NULL, _0, _1; - zval tag; - zval *this_ptr = getThis(); + zend_long flags, ZEPHIR_LAST_CALL_STATUS; + zval *input_param = NULL, *flags_param = NULL, _0; + zval input; - ZVAL_UNDEF(&tag); + ZVAL_UNDEF(&input); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(tag) + Z_PARAM_STR(input) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(raw) + Z_PARAM_LONG(flags) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &tag_param, &raw_param); - zephir_get_strval(&tag, tag_param); - if (!raw_param) { - raw = 0; + zephir_fetch_params(1, 1, 1, &input_param, &flags_param); + zephir_get_strval(&input, input_param); + if (!flags_param) { + flags = 11; } else { } - ZEPHIR_INIT_VAR(&_0); - if (raw) { - ZEPHIR_CPY_WRT(&_0, &tag); - } else { - zephir_read_property(&_1, this_ptr, ZEND_STRL("escaper"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_0, &_1, "html", NULL, 0, &tag); + ZVAL_LONG(&_0, flags); + ZEPHIR_RETURN_CALL_FUNCTION("htmlspecialchars", NULL, 286, &input, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_StringValLegacy) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, StringValLegacy, phalcon, filter_sanitize_stringvallegacy, phalcon_filter_sanitize_stringvallegacy_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Sanitize_StringValLegacy, __invoke) +{ + zend_bool _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval input_sub, major, minor, _2$$3; + zval *input; + + ZVAL_UNDEF(&input_sub); + ZVAL_UNDEF(&major); + ZVAL_UNDEF(&minor); + ZVAL_UNDEF(&_2$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(input) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &input); + ZEPHIR_INIT_VAR(&major); + ZEPHIR_GET_CONSTANT(&major, "PHP_MAJOR_VERSION"); + ZEPHIR_INIT_VAR(&minor); + ZEPHIR_GET_CONSTANT(&minor, "PHP_MINOR_VERSION"); + _0 = ZEPHIR_LT_LONG(&major, 8); + if (!(_0)) { + _1 = ZEPHIR_IS_LONG_IDENTICAL(&major, 8); + if (_1) { + _1 = ZEPHIR_IS_LONG_IDENTICAL(&minor, 0); + } + _0 = _1; + } + if (_0) { + ZVAL_LONG(&_2$$3, 513); + ZEPHIR_RETURN_CALL_FUNCTION("filter_var", NULL, 283, input, &_2$$3); zephir_check_call_status(); + RETURN_MM(); } - zephir_get_strval(&tag, &_0); - ZEPHIR_CONCAT_SVS(return_value, ""); + RETVAL_ZVAL(input, 1, 0); RETURN_MM(); } -static PHP_METHOD(Phalcon_Html_Helper_AbstractHelper, indent) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_Striptags) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, Striptags, phalcon, filter_sanitize_striptags, phalcon_filter_sanitize_striptags_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Sanitize_Striptags, __invoke) { - zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + zval *input_param = NULL; + zval input; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&input); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(input) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("indent"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_1, this_ptr, ZEND_STRL("indentLevel"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_FUNCTION("str_repeat", NULL, 1, &_0, &_1); + zephir_fetch_params(1, 1, 0, &input_param); + if (UNEXPECTED(Z_TYPE_P(input_param) != IS_STRING && Z_TYPE_P(input_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'input' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(input_param) == IS_STRING)) { + zephir_get_strval(&input, input_param); + } else { + ZEPHIR_INIT_VAR(&input); + } + ZEPHIR_RETURN_CALL_FUNCTION("strip_tags", NULL, 287, &input); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Html_Helper_AbstractHelper, orderAttributes) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_Trim) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, Trim, phalcon, filter_sanitize_trim, phalcon_filter_sanitize_trim_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Sanitize_Trim, __invoke) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *input_param = NULL; + zval input; + + ZVAL_UNDEF(&input); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(input) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &input_param); + if (UNEXPECTED(Z_TYPE_P(input_param) != IS_STRING && Z_TYPE_P(input_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'input' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(input_param) == IS_STRING)) { + zephir_get_strval(&input, input_param); + } else { + ZEPHIR_INIT_VAR(&input); + } + zephir_fast_trim(return_value, &input, NULL , ZEPHIR_TRIM_BOTH); + RETURN_MM(); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_Upper) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, Upper, phalcon, filter_sanitize_upper, phalcon_filter_sanitize_upper_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Sanitize_Upper, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *overrides_param = NULL, *attributes_param = NULL, __$null, intersect, results, _0; - zval overrides, attributes, order; + zval *input_param = NULL, _0$$3, _1$$3, _2; + zval input; - ZVAL_UNDEF(&overrides); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&order); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&intersect); - ZVAL_UNDEF(&results); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ARRAY(overrides) - Z_PARAM_ARRAY(attributes) + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(input) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &overrides_param, &attributes_param); - zephir_get_arrval(&overrides, overrides_param); - zephir_get_arrval(&attributes, attributes_param); - ZEPHIR_INIT_VAR(&order); - zephir_create_array(&order, 10, 0); - zephir_array_update_string(&order, SL("rel"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&order, SL("type"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&order, SL("for"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&order, SL("src"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&order, SL("href"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&order, SL("action"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&order, SL("id"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&order, SL("name"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&order, SL("value"), &__$null, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&order, SL("class"), &__$null, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_FUNCTION(&intersect, "array_intersect_key", NULL, 2, &order, &attributes); + zephir_fetch_params(1, 1, 0, &input_param); + if (UNEXPECTED(Z_TYPE_P(input_param) != IS_STRING && Z_TYPE_P(input_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'input' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(input_param) == IS_STRING)) { + zephir_get_strval(&input, input_param); + } else { + ZEPHIR_INIT_VAR(&input); + } + if (1 == (zephir_function_exists_ex(ZEND_STRL("mb_convert_case")) == SUCCESS)) { + ZVAL_LONG(&_0$$3, 0); + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "UTF-8"); + ZEPHIR_RETURN_CALL_FUNCTION("mb_convert_case", NULL, 12, &input, &_0$$3, &_1$$3); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_CALL_FUNCTION(&_2, "utf8_decode", NULL, 285, &input); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&results); - zephir_fast_array_merge(&results, &intersect, &attributes); - ZEPHIR_INIT_VAR(&_0); - zephir_fast_array_merge(&_0, &overrides, &results); - ZEPHIR_CPY_WRT(&results, &_0); - zephir_array_unset_string(&results, SL("escape"), PH_SEPARATE); - RETURN_CCTOR(&results); + zephir_fast_strtoupper(return_value, &_2); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Html_Helper_AbstractHelper, renderArrayElements) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_UpperFirst) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, UpperFirst, phalcon, filter_sanitize_upperfirst, phalcon_filter_sanitize_upperfirst_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Sanitize_UpperFirst, __invoke) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *input_param = NULL; + zval input; + + ZVAL_UNDEF(&input); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(input) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &input_param); + if (UNEXPECTED(Z_TYPE_P(input_param) != IS_STRING && Z_TYPE_P(input_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'input' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(input_param) == IS_STRING)) { + zephir_get_strval(&input, input_param); + } else { + ZEPHIR_INIT_VAR(&input); + } + zephir_ucfirst(return_value, &input); + RETURN_MM(); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_UpperWords) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, UpperWords, phalcon, filter_sanitize_upperwords, phalcon_filter_sanitize_upperwords_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Sanitize_UpperWords, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval delimiter; - zval *elements_param = NULL, *delimiter_param = NULL, item, result, *_0, _1, _2$$3, _3$$3, _5$$3, _6$$3, _7$$3, _8$$4, _9$$4, _11$$4, _12$$4, _13$$4; - zval elements, _4$$3, _10$$4; - zval *this_ptr = getThis(); + zval *input_param = NULL, _0$$3, _1$$3, _2; + zval input; - ZVAL_UNDEF(&elements); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_10$$4); - ZVAL_UNDEF(&item); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_11$$4); - ZVAL_UNDEF(&_12$$4); - ZVAL_UNDEF(&_13$$4); - ZVAL_UNDEF(&delimiter); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ARRAY(elements) - Z_PARAM_STR(delimiter) + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(input) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &elements_param, &delimiter_param); - zephir_get_arrval(&elements, elements_param); - zephir_get_strval(&delimiter, delimiter_param); - ZEPHIR_INIT_VAR(&result); - ZVAL_STRING(&result, ""); - zephir_is_iterable(&elements, 0, "phalcon/Html/Helper/AbstractHelper.zep", 140); - if (Z_TYPE_P(&elements) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&elements), _0) - { - ZEPHIR_INIT_NVAR(&item); - ZVAL_COPY(&item, _0); - zephir_array_fetch_long(&_2$$3, &item, 2, PH_NOISY | PH_READONLY, "phalcon/Html/Helper/AbstractHelper.zep", 136); - ZEPHIR_INIT_NVAR(&_3$$3); - ZEPHIR_INIT_NVAR(&_4$$3); - zephir_create_array(&_4$$3, 2, 0); - zephir_array_fast_append(&_4$$3, this_ptr); - ZEPHIR_OBS_NVAR(&_5$$3); - zephir_array_fetch_long(&_5$$3, &item, 0, PH_NOISY, "phalcon/Html/Helper/AbstractHelper.zep", 136); - zephir_array_fast_append(&_4$$3, &_5$$3); - zephir_array_fetch_long(&_6$$3, &item, 1, PH_NOISY | PH_READONLY, "phalcon/Html/Helper/AbstractHelper.zep", 136); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_3$$3, &_4$$3, &_6$$3); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_7$$3); - ZEPHIR_CONCAT_VVV(&_7$$3, &_2$$3, &_3$$3, &delimiter); - zephir_concat_self(&result, &_7$$3); - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 1, 0, &input_param); + if (UNEXPECTED(Z_TYPE_P(input_param) != IS_STRING && Z_TYPE_P(input_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'input' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(input_param) == IS_STRING)) { + zephir_get_strval(&input, input_param); } else { - ZEPHIR_CALL_METHOD(NULL, &elements, "rewind", NULL, 0); + ZEPHIR_INIT_VAR(&input); + } + if (1 == (zephir_function_exists_ex(ZEND_STRL("mb_convert_case")) == SUCCESS)) { + ZVAL_LONG(&_0$$3, 2); + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "UTF-8"); + ZEPHIR_RETURN_CALL_FUNCTION("mb_convert_case", NULL, 12, &input, &_0$$3, &_1$$3); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &elements, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&item, &elements, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_fetch_long(&_8$$4, &item, 2, PH_NOISY | PH_READONLY, "phalcon/Html/Helper/AbstractHelper.zep", 136); - ZEPHIR_INIT_NVAR(&_9$$4); - ZEPHIR_INIT_NVAR(&_10$$4); - zephir_create_array(&_10$$4, 2, 0); - zephir_array_fast_append(&_10$$4, this_ptr); - ZEPHIR_OBS_NVAR(&_11$$4); - zephir_array_fetch_long(&_11$$4, &item, 0, PH_NOISY, "phalcon/Html/Helper/AbstractHelper.zep", 136); - zephir_array_fast_append(&_10$$4, &_11$$4); - zephir_array_fetch_long(&_12$$4, &item, 1, PH_NOISY | PH_READONLY, "phalcon/Html/Helper/AbstractHelper.zep", 136); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_9$$4, &_10$$4, &_12$$4); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_13$$4); - ZEPHIR_CONCAT_VVV(&_13$$4, &_8$$4, &_9$$4, &delimiter); - zephir_concat_self(&result, &_13$$4); - ZEPHIR_CALL_METHOD(NULL, &elements, "next", NULL, 0); - zephir_check_call_status(); - } + RETURN_MM(); } - ZEPHIR_INIT_NVAR(&item); - RETURN_CCTOR(&result); + ZEPHIR_CALL_FUNCTION(&_2, "utf8_decode", NULL, 285, &input); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_FUNCTION("ucwords", NULL, 288, &_2); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Html_Helper_AbstractHelper, renderAttributes) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Filter_Sanitize_Url) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Filter\\Sanitize, Url, phalcon, filter_sanitize_url, phalcon_filter_sanitize_url_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Filter_Sanitize_Url, __invoke) { - zend_bool _4$$3, _8$$5; - zend_string *_3; - zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *attributes_param = NULL, key, result, value, *_0, _1, _5$$4, _6$$4, _7$$4, _9$$6, _10$$6, _11$$6; - zval attributes; + zval *input, input_sub, _0; + + ZVAL_UNDEF(&input_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(input) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &input); + ZVAL_LONG(&_0, 518); + ZEPHIR_RETURN_CALL_FUNCTION("filter_var", NULL, 283, input, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Cli_Console) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli, Console, phalcon, cli_console, phalcon_application_abstractapplication_ce, phalcon_cli_console_method_entry, 0); + + zend_declare_property_null(phalcon_cli_console_ce, SL("arguments"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_cli_console_ce, SL("options"), ZEND_ACC_PROTECTED); + phalcon_cli_console_ce->create_object = zephir_init_properties_Phalcon_Cli_Console; + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Cli_Console, handle) +{ + zend_bool _8; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *arguments_param = NULL, __$false, className, dispatcher, module, moduleName, moduleObject, modules, path, router, task, _0, _1, _5, _6, _7, _9, _26, _27, _28, _29, _30, _31, _35, _2$$4, _3$$4, _4$$4, _10$$6, _11$$9, _15$$9, _20$$9, _21$$9, _22$$9, _12$$10, _13$$10, _14$$10, _16$$12, _17$$12, _18$$16, _19$$16, _23$$18, _24$$18, _25$$18, _32$$20, _33$$20, _34$$20, _36$$22, _37$$22; + zval arguments; zval *this_ptr = getThis(); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&value); + ZVAL_UNDEF(&arguments); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&dispatcher); + ZVAL_UNDEF(&module); + ZVAL_UNDEF(&moduleName); + ZVAL_UNDEF(&moduleObject); + ZVAL_UNDEF(&modules); + ZVAL_UNDEF(&path); + ZVAL_UNDEF(&router); + ZVAL_UNDEF(&task); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_9$$6); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_26); + ZVAL_UNDEF(&_27); + ZVAL_UNDEF(&_28); + ZVAL_UNDEF(&_29); + ZVAL_UNDEF(&_30); + ZVAL_UNDEF(&_31); + ZVAL_UNDEF(&_35); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$4); ZVAL_UNDEF(&_10$$6); - ZVAL_UNDEF(&_11$$6); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(attributes) + ZVAL_UNDEF(&_11$$9); + ZVAL_UNDEF(&_15$$9); + ZVAL_UNDEF(&_20$$9); + ZVAL_UNDEF(&_21$$9); + ZVAL_UNDEF(&_22$$9); + ZVAL_UNDEF(&_12$$10); + ZVAL_UNDEF(&_13$$10); + ZVAL_UNDEF(&_14$$10); + ZVAL_UNDEF(&_16$$12); + ZVAL_UNDEF(&_17$$12); + ZVAL_UNDEF(&_18$$16); + ZVAL_UNDEF(&_19$$16); + ZVAL_UNDEF(&_23$$18); + ZVAL_UNDEF(&_24$$18); + ZVAL_UNDEF(&_25$$18); + ZVAL_UNDEF(&_32$$20); + ZVAL_UNDEF(&_33$$20); + ZVAL_UNDEF(&_34$$20); + ZVAL_UNDEF(&_36$$22); + ZVAL_UNDEF(&_37$$22); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY_OR_NULL(arguments) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &attributes_param); - zephir_get_arrval(&attributes, attributes_param); - ZEPHIR_INIT_VAR(&result); - ZVAL_STRING(&result, ""); - zephir_is_iterable(&attributes, 0, "phalcon/Html/Helper/AbstractHelper.zep", 161); - if (Z_TYPE_P(&attributes) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&attributes), _2, _3, _0) - { - ZEPHIR_INIT_NVAR(&key); - if (_3 != NULL) { - ZVAL_STR_COPY(&key, _3); - } else { - ZVAL_LONG(&key, _2); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0); - _4$$3 = Z_TYPE_P(&key) == IS_STRING; - if (_4$$3) { - _4$$3 = Z_TYPE_P(&value) != IS_NULL; - } - if (_4$$3) { - zephir_read_property(&_5$$4, this_ptr, ZEND_STRL("escaper"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_6$$4, &_5$$4, "attributes", NULL, 0, &value); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_7$$4); - ZEPHIR_CONCAT_VSVS(&_7$$4, &key, "=\"", &_6$$4, "\" "); - zephir_concat_self(&result, &_7$$4); - } - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 0, 1, &arguments_param); + if (!arguments_param) { + ZEPHIR_INIT_VAR(&arguments); } else { - ZEPHIR_CALL_METHOD(NULL, &attributes, "rewind", NULL, 0); + zephir_get_arrval(&arguments, arguments_param); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_console_exception_ce, "A dependency injection container is required to access internal services", "phalcon/Cli/Console.zep", 45); + return; + } + zephir_read_property(&_1, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_1) != IS_NULL) { + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_4$$4); + ZVAL_STRING(&_4$$4, "console:boot"); + ZEPHIR_CALL_METHOD(&_3$$4, &_2$$4, "fire", NULL, 0, &_4$$4, this_ptr); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &attributes, "valid", NULL, 0); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_3$$4)) { + RETURN_MM_BOOL(0); + } + } + zephir_read_property(&_5, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_7); + ZVAL_STRING(&_7, "router"); + ZEPHIR_CALL_METHOD(&_6, &_5, "getshared", NULL, 0, &_7); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&router, &_6); + _8 = !(zephir_fast_count_int(&arguments)); + if (_8) { + zephir_read_property(&_9, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); + _8 = zephir_is_true(&_9); + } + if (_8) { + zephir_read_property(&_10$$6, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &router, "handle", NULL, 0, &_10$$6); + zephir_check_call_status(); + } else { + ZEPHIR_CALL_METHOD(NULL, &router, "handle", NULL, 0, &arguments); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(&moduleName, &router, "getmodulename", NULL, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&moduleName))) { + ZEPHIR_OBS_NVAR(&moduleName); + zephir_read_property(&moduleName, this_ptr, ZEND_STRL("defaultModule"), PH_NOISY_CC); + } + if (zephir_is_true(&moduleName)) { + zephir_read_property(&_11$$9, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_11$$9) != IS_NULL) { + zephir_read_property(&_12$$10, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_14$$10); + ZVAL_STRING(&_14$$10, "console:beforeStartModule"); + ZEPHIR_CALL_METHOD(&_13$$10, &_12$$10, "fire", NULL, 0, &_14$$10, this_ptr, &moduleName); zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; + if (ZEPHIR_IS_FALSE_IDENTICAL(&_13$$10)) { + RETURN_MM_BOOL(0); } - ZEPHIR_CALL_METHOD(&key, &attributes, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &attributes, "current", NULL, 0); + } + zephir_read_property(&_15$$9, this_ptr, ZEND_STRL("modules"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&modules, &_15$$9); + if (UNEXPECTED(!(zephir_array_isset(&modules, &moduleName)))) { + ZEPHIR_INIT_VAR(&_16$$12); + object_init_ex(&_16$$12, phalcon_cli_console_exception_ce); + ZEPHIR_INIT_VAR(&_17$$12); + ZEPHIR_CONCAT_SVS(&_17$$12, "Module '", &moduleName, "' isn't registered in the console container"); + ZEPHIR_CALL_METHOD(NULL, &_16$$12, "__construct", NULL, 33, &_17$$12); zephir_check_call_status(); - _8$$5 = Z_TYPE_P(&key) == IS_STRING; - if (_8$$5) { - _8$$5 = Z_TYPE_P(&value) != IS_NULL; - } - if (_8$$5) { - zephir_read_property(&_9$$6, this_ptr, ZEND_STRL("escaper"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_10$$6, &_9$$6, "attributes", NULL, 0, &value); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_11$$6); - ZEPHIR_CONCAT_VSVS(&_11$$6, &key, "=\"", &_10$$6, "\" "); - zephir_concat_self(&result, &_11$$6); + zephir_throw_exception_debug(&_16$$12, "phalcon/Cli/Console.zep", 87); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_memory_observe(&module); + zephir_array_fetch(&module, &modules, &moduleName, PH_NOISY, "phalcon/Cli/Console.zep", 90); + if (UNEXPECTED(Z_TYPE_P(&module) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_console_exception_ce, "Invalid module definition path", "phalcon/Cli/Console.zep", 93); + return; + } + zephir_memory_observe(&className); + if (!(zephir_array_isset_string_fetch(&className, &module, SL("className"), 0))) { + ZEPHIR_INIT_NVAR(&className); + ZVAL_STRING(&className, "Module"); + } + zephir_memory_observe(&path); + if (zephir_array_isset_string_fetch(&path, &module, SL("path"), 0)) { + if (UNEXPECTED(!((zephir_file_exists(&path) == SUCCESS)))) { + ZEPHIR_INIT_VAR(&_18$$16); + object_init_ex(&_18$$16, phalcon_cli_console_exception_ce); + ZEPHIR_INIT_VAR(&_19$$16); + ZEPHIR_CONCAT_SVS(&_19$$16, "Module definition path '", &path, "' doesn't exist"); + ZEPHIR_CALL_METHOD(NULL, &_18$$16, "__construct", NULL, 33, &_19$$16); + zephir_check_call_status(); + zephir_throw_exception_debug(&_18$$16, "phalcon/Cli/Console.zep", 104); + ZEPHIR_MM_RESTORE(); + return; + } + if (!(zephir_class_exists(&className, zephir_is_true(&__$false) ))) { + if (zephir_require_once_zval(&path) == FAILURE) { + RETURN_MM_NULL(); } - ZEPHIR_CALL_METHOD(NULL, &attributes, "next", NULL, 0); + } + } + zephir_read_property(&_15$$9, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&moduleObject, &_15$$9, "get", NULL, 0, &className); + zephir_check_call_status(); + zephir_read_property(&_20$$9, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &moduleObject, "registerautoloaders", NULL, 0, &_20$$9); + zephir_check_call_status(); + zephir_read_property(&_21$$9, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &moduleObject, "registerservices", NULL, 0, &_21$$9); + zephir_check_call_status(); + zephir_read_property(&_22$$9, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_22$$9) != IS_NULL) { + zephir_read_property(&_23$$18, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_25$$18); + ZVAL_STRING(&_25$$18, "console:afterStartModule"); + ZEPHIR_CALL_METHOD(&_24$$18, &_23$$18, "fire", NULL, 0, &_25$$18, this_ptr, &moduleObject); zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_24$$18)) { + RETURN_MM_BOOL(0); + } } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - RETURN_CCTOR(&result); -} - -static PHP_METHOD(Phalcon_Html_Helper_AbstractHelper, renderElement) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes; - zval *tag_param = NULL, *attributes_param = NULL; - zval tag; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&tag); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(tag) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &tag_param, &attributes_param); - zephir_get_strval(&tag, tag_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - } else { - zephir_get_arrval(&attributes, attributes_param); + zephir_read_property(&_26, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_7); + ZVAL_STRING(&_7, "dispatcher"); + ZEPHIR_CALL_METHOD(&_6, &_26, "getshared", NULL, 0, &_7); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&dispatcher, &_6); + ZEPHIR_CALL_METHOD(&_6, &router, "getmodulename", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setmodulename", NULL, 0, &_6); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_27, &router, "gettaskname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &dispatcher, "settaskname", NULL, 0, &_27); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_28, &router, "getactionname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setactionname", NULL, 0, &_28); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_29, &router, "getparameters", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setparams", NULL, 0, &_29); + zephir_check_call_status(); + zephir_read_property(&_30, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setoptions", NULL, 0, &_30); + zephir_check_call_status(); + zephir_read_property(&_31, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_31) != IS_NULL) { + zephir_read_property(&_32$$20, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_34$$20); + ZVAL_STRING(&_34$$20, "console:beforeHandleTask"); + ZEPHIR_CALL_METHOD(&_33$$20, &_32$$20, "fire", NULL, 0, &_34$$20, this_ptr, &dispatcher); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_33$$20)) { + RETURN_MM_BOOL(0); + } } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "rendertag", NULL, 0, &tag, &attributes); + ZEPHIR_CALL_METHOD(&task, &dispatcher, "dispatch", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + zephir_read_property(&_35, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_35) != IS_NULL) { + zephir_read_property(&_36$$22, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_37$$22); + ZVAL_STRING(&_37$$22, "console:afterHandleTask"); + ZEPHIR_CALL_METHOD(NULL, &_36$$22, "fire", NULL, 0, &_37$$22, this_ptr, &task); + zephir_check_call_status(); + } + RETURN_CCTOR(&task); } -static PHP_METHOD(Phalcon_Html_Helper_AbstractHelper, renderFullElement) +static PHP_METHOD(Phalcon_Cli_Console, setArgument) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_6 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool raw; - zval attributes; - zval *tag_param = NULL, *text_param = NULL, *attributes_param = NULL, *raw_param = NULL, content, _0, _1, _2, _3; - zval tag, text; + zend_bool str, shift, _0; + zval *arguments_param = NULL, *str_param = NULL, *shift_param = NULL, __$true, arg, pos, args, opts, handleArgs, *_1, _2, _3$$5, _4$$5, _5$$5, _7$$6, _8$$7, _9$$7, _10$$7, _11$$7, _12$$7, _13$$7, _14$$7, _15$$8, _16$$8, _17$$8, _18$$9, _19$$9, _20$$9, _21$$10, _22$$10, _23$$14, _24$$14, _25$$14, _26$$15, _27$$16, _28$$16, _29$$16, _30$$16, _31$$16, _32$$16, _33$$16, _34$$17, _35$$17, _36$$17, _37$$18, _38$$18, _39$$18, _40$$19, _41$$19, _42$$22, _43$$22, _44$$24, _45$$25, _46$$26; + zval arguments; zval *this_ptr = getThis(); - ZVAL_UNDEF(&tag); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&content); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&arguments); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&arg); + ZVAL_UNDEF(&pos); + ZVAL_UNDEF(&args); + ZVAL_UNDEF(&opts); + ZVAL_UNDEF(&handleArgs); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(2, 4) - Z_PARAM_STR(tag) - Z_PARAM_STR(text) + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_8$$7); + ZVAL_UNDEF(&_9$$7); + ZVAL_UNDEF(&_10$$7); + ZVAL_UNDEF(&_11$$7); + ZVAL_UNDEF(&_12$$7); + ZVAL_UNDEF(&_13$$7); + ZVAL_UNDEF(&_14$$7); + ZVAL_UNDEF(&_15$$8); + ZVAL_UNDEF(&_16$$8); + ZVAL_UNDEF(&_17$$8); + ZVAL_UNDEF(&_18$$9); + ZVAL_UNDEF(&_19$$9); + ZVAL_UNDEF(&_20$$9); + ZVAL_UNDEF(&_21$$10); + ZVAL_UNDEF(&_22$$10); + ZVAL_UNDEF(&_23$$14); + ZVAL_UNDEF(&_24$$14); + ZVAL_UNDEF(&_25$$14); + ZVAL_UNDEF(&_26$$15); + ZVAL_UNDEF(&_27$$16); + ZVAL_UNDEF(&_28$$16); + ZVAL_UNDEF(&_29$$16); + ZVAL_UNDEF(&_30$$16); + ZVAL_UNDEF(&_31$$16); + ZVAL_UNDEF(&_32$$16); + ZVAL_UNDEF(&_33$$16); + ZVAL_UNDEF(&_34$$17); + ZVAL_UNDEF(&_35$$17); + ZVAL_UNDEF(&_36$$17); + ZVAL_UNDEF(&_37$$18); + ZVAL_UNDEF(&_38$$18); + ZVAL_UNDEF(&_39$$18); + ZVAL_UNDEF(&_40$$19); + ZVAL_UNDEF(&_41$$19); + ZVAL_UNDEF(&_42$$22); + ZVAL_UNDEF(&_43$$22); + ZVAL_UNDEF(&_44$$24); + ZVAL_UNDEF(&_45$$25); + ZVAL_UNDEF(&_46$$26); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 3) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) - Z_PARAM_BOOL(raw) + Z_PARAM_ARRAY_OR_NULL(arguments) + Z_PARAM_BOOL(str) + Z_PARAM_BOOL(shift) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 2, &tag_param, &text_param, &attributes_param, &raw_param); - zephir_get_strval(&tag, tag_param); - zephir_get_strval(&text, text_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); + zephir_fetch_params(1, 0, 3, &arguments_param, &str_param, &shift_param); + if (!arguments_param) { + ZEPHIR_INIT_VAR(&arguments); } else { - zephir_get_arrval(&attributes, attributes_param); + ZEPHIR_OBS_COPY_OR_DUP(&arguments, arguments_param); } - if (!raw_param) { - raw = 0; - } else { - } - if (raw) { - ZEPHIR_CPY_WRT(&content, &text); + if (!str_param) { + str = 1; } else { - zephir_read_property(&_0, this_ptr, ZEND_STRL("escaper"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&content, &_0, "html", NULL, 0, &text); - zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(str_param) != IS_TRUE && Z_TYPE_P(str_param) != IS_FALSE)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'str' must be of the type bool")); + RETURN_MM_NULL(); } - ZEPHIR_CALL_METHOD(&_1, this_ptr, "renderelement", NULL, 0, &tag, &attributes); - zephir_check_call_status(); - if (raw) { - ZVAL_BOOL(&_3, 1); - } else { - ZVAL_BOOL(&_3, 0); + str = (Z_TYPE_P(str_param) == IS_TRUE); } - ZEPHIR_CALL_METHOD(&_2, this_ptr, "close", NULL, 0, &tag, &_3); - zephir_check_call_status(); - ZEPHIR_CONCAT_VVV(return_value, &_1, &content, &_2); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Html_Helper_AbstractHelper, renderTag) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes; - zval *tag_param = NULL, *attributes_param = NULL, close, *close_param = NULL, attrs, escapedAttrs, _3, _4, _5, _0$$3, _1$$3, _2$$3; - zval tag; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&tag); - ZVAL_UNDEF(&close); - ZVAL_UNDEF(&attrs); - ZVAL_UNDEF(&escapedAttrs); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(tag) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) - Z_PARAM_STR(close) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &tag_param, &attributes_param, &close_param); - zephir_get_strval(&tag, tag_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); + if (!shift_param) { + shift = 1; } else { - zephir_get_arrval(&attributes, attributes_param); + if (UNEXPECTED(Z_TYPE_P(shift_param) != IS_TRUE && Z_TYPE_P(shift_param) != IS_FALSE)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'shift' must be of the type bool")); + RETURN_MM_NULL(); } - if (!close_param) { - ZEPHIR_INIT_VAR(&close); - ZVAL_STRING(&close, ""); - } else { - zephir_get_strval(&close, close_param); + shift = (Z_TYPE_P(shift_param) == IS_TRUE); } - ZEPHIR_INIT_VAR(&escapedAttrs); - ZVAL_STRING(&escapedAttrs, ""); - if (1 != ZEPHIR_IS_EMPTY(&attributes)) { - ZEPHIR_INIT_VAR(&_0$$3); - array_init(&_0$$3); - ZEPHIR_CALL_METHOD(&attrs, this_ptr, "orderattributes", NULL, 0, &_0$$3, &attributes); + ZEPHIR_INIT_VAR(&args); + array_init(&args); + ZEPHIR_INIT_VAR(&opts); + array_init(&opts); + ZEPHIR_INIT_VAR(&handleArgs); + array_init(&handleArgs); + _0 = shift; + if (_0) { + _0 = ((zephir_fast_count_int(&arguments)) ? 1 : 0); + } + if (_0) { + ZEPHIR_MAKE_REF(&arguments); + ZEPHIR_CALL_FUNCTION(NULL, "array_shift", NULL, 22, &arguments); + ZEPHIR_UNREF(&arguments); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_1$$3); - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "renderattributes", NULL, 0, &attrs); + } + zephir_is_iterable(&arguments, 0, "phalcon/Cli/Console.zep", 185); + if (Z_TYPE_P(&arguments) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&arguments), _1) + { + ZEPHIR_INIT_NVAR(&arg); + ZVAL_COPY(&arg, _1); + if (Z_TYPE_P(&arg) == IS_STRING) { + ZEPHIR_INIT_NVAR(&_3$$5); + ZVAL_STRING(&_3$$5, "--"); + ZVAL_LONG(&_4$$5, 2); + ZEPHIR_CALL_FUNCTION(&_5$$5, "strncmp", &_6, 190, &arg, &_3$$5, &_4$$5); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG(&_5$$5, 0)) { + ZEPHIR_INIT_NVAR(&_7$$6); + ZVAL_STRING(&_7$$6, "="); + ZEPHIR_INIT_NVAR(&pos); + zephir_fast_strpos(&pos, &arg, &_7$$6, 0 ); + if (zephir_is_true(&pos)) { + ZEPHIR_INIT_NVAR(&_8$$7); + ZVAL_LONG(&_9$$7, (zephir_get_numberval(&pos) + 1)); + ZEPHIR_INIT_NVAR(&_10$$7); + zephir_substr(&_10$$7, &arg, zephir_get_intval(&_9$$7), 0, ZEPHIR_SUBSTR_NO_LENGTH); + zephir_fast_trim(&_8$$7, &_10$$7, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_11$$7); + ZVAL_LONG(&_12$$7, 2); + ZVAL_LONG(&_13$$7, (zephir_get_numberval(&pos) - 2)); + ZEPHIR_INIT_NVAR(&_14$$7); + zephir_substr(&_14$$7, &arg, 2 , zephir_get_intval(&_13$$7), 0); + zephir_fast_trim(&_11$$7, &_14$$7, NULL , ZEPHIR_TRIM_BOTH); + zephir_array_update_zval(&opts, &_11$$7, &_8$$7, PH_COPY | PH_SEPARATE); + } else { + ZEPHIR_INIT_NVAR(&_15$$8); + ZVAL_LONG(&_16$$8, 2); + ZEPHIR_INIT_NVAR(&_17$$8); + zephir_substr(&_17$$8, &arg, 2 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + zephir_fast_trim(&_15$$8, &_17$$8, NULL , ZEPHIR_TRIM_BOTH); + zephir_array_update_zval(&opts, &_15$$8, &__$true, PH_COPY | PH_SEPARATE); + } + } else { + ZEPHIR_INIT_NVAR(&_18$$9); + ZVAL_STRING(&_18$$9, "-"); + ZVAL_LONG(&_19$$9, 1); + ZEPHIR_CALL_FUNCTION(&_20$$9, "strncmp", &_6, 190, &arg, &_18$$9, &_19$$9); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG(&_20$$9, 0)) { + ZVAL_LONG(&_21$$10, 1); + ZEPHIR_INIT_NVAR(&_22$$10); + zephir_substr(&_22$$10, &arg, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + zephir_array_update_zval(&opts, &_22$$10, &__$true, PH_COPY | PH_SEPARATE); + } else { + zephir_array_append(&args, &arg, PH_SEPARATE, "phalcon/Cli/Console.zep", 177); + } + } + } else { + zephir_array_append(&args, &arg, PH_SEPARATE, "phalcon/Cli/Console.zep", 181); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &arguments, "rewind", NULL, 0); zephir_check_call_status(); - zephir_fast_trim(&_1$$3, &_2$$3, NULL , ZEPHIR_TRIM_RIGHT); - ZEPHIR_INIT_NVAR(&escapedAttrs); - ZEPHIR_CONCAT_SV(&escapedAttrs, " ", &_1$$3); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &arguments, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&arg, &arguments, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&arg) == IS_STRING) { + ZEPHIR_INIT_NVAR(&_23$$14); + ZVAL_STRING(&_23$$14, "--"); + ZVAL_LONG(&_24$$14, 2); + ZEPHIR_CALL_FUNCTION(&_25$$14, "strncmp", &_6, 190, &arg, &_23$$14, &_24$$14); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG(&_25$$14, 0)) { + ZEPHIR_INIT_NVAR(&_26$$15); + ZVAL_STRING(&_26$$15, "="); + ZEPHIR_INIT_NVAR(&pos); + zephir_fast_strpos(&pos, &arg, &_26$$15, 0 ); + if (zephir_is_true(&pos)) { + ZEPHIR_INIT_NVAR(&_27$$16); + ZVAL_LONG(&_28$$16, (zephir_get_numberval(&pos) + 1)); + ZEPHIR_INIT_NVAR(&_29$$16); + zephir_substr(&_29$$16, &arg, zephir_get_intval(&_28$$16), 0, ZEPHIR_SUBSTR_NO_LENGTH); + zephir_fast_trim(&_27$$16, &_29$$16, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_30$$16); + ZVAL_LONG(&_31$$16, 2); + ZVAL_LONG(&_32$$16, (zephir_get_numberval(&pos) - 2)); + ZEPHIR_INIT_NVAR(&_33$$16); + zephir_substr(&_33$$16, &arg, 2 , zephir_get_intval(&_32$$16), 0); + zephir_fast_trim(&_30$$16, &_33$$16, NULL , ZEPHIR_TRIM_BOTH); + zephir_array_update_zval(&opts, &_30$$16, &_27$$16, PH_COPY | PH_SEPARATE); + } else { + ZEPHIR_INIT_NVAR(&_34$$17); + ZVAL_LONG(&_35$$17, 2); + ZEPHIR_INIT_NVAR(&_36$$17); + zephir_substr(&_36$$17, &arg, 2 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + zephir_fast_trim(&_34$$17, &_36$$17, NULL , ZEPHIR_TRIM_BOTH); + zephir_array_update_zval(&opts, &_34$$17, &__$true, PH_COPY | PH_SEPARATE); + } + } else { + ZEPHIR_INIT_NVAR(&_37$$18); + ZVAL_STRING(&_37$$18, "-"); + ZVAL_LONG(&_38$$18, 1); + ZEPHIR_CALL_FUNCTION(&_39$$18, "strncmp", &_6, 190, &arg, &_37$$18, &_38$$18); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG(&_39$$18, 0)) { + ZVAL_LONG(&_40$$19, 1); + ZEPHIR_INIT_NVAR(&_41$$19); + zephir_substr(&_41$$19, &arg, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + zephir_array_update_zval(&opts, &_41$$19, &__$true, PH_COPY | PH_SEPARATE); + } else { + zephir_array_append(&args, &arg, PH_SEPARATE, "phalcon/Cli/Console.zep", 177); + } + } + } else { + zephir_array_append(&args, &arg, PH_SEPARATE, "phalcon/Cli/Console.zep", 181); + } + ZEPHIR_CALL_METHOD(NULL, &arguments, "next", NULL, 0); + zephir_check_call_status(); + } } - ZEPHIR_INIT_VAR(&_3); - ZEPHIR_INIT_VAR(&_4); - zephir_fast_trim(&_4, &close, NULL , ZEPHIR_TRIM_BOTH); - if (ZEPHIR_IS_EMPTY(&_4)) { - ZEPHIR_INIT_NVAR(&_3); - ZVAL_STRING(&_3, ""); + ZEPHIR_INIT_NVAR(&arg); + if (str) { + ZEPHIR_INIT_VAR(&_42$$22); + ZEPHIR_CALL_CE_STATIC(&_43$$22, phalcon_cli_router_route_ce, "getdelimiter", NULL, 0); + zephir_check_call_status(); + zephir_fast_join(&_42$$22, &_43$$22, &args); + zephir_update_property_zval(this_ptr, ZEND_STRL("arguments"), &_42$$22); } else { - ZEPHIR_INIT_VAR(&_5); - zephir_fast_trim(&_5, &close, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_3); - ZEPHIR_CONCAT_SV(&_3, " ", &_5); + if (zephir_fast_count_int(&args)) { + ZEPHIR_MAKE_REF(&args); + ZEPHIR_CALL_FUNCTION(&_44$$24, "array_shift", NULL, 22, &args); + ZEPHIR_UNREF(&args); + zephir_check_call_status(); + zephir_array_update_string(&handleArgs, SL("task"), &_44$$24, PH_COPY | PH_SEPARATE); + } + if (zephir_fast_count_int(&args)) { + ZEPHIR_MAKE_REF(&args); + ZEPHIR_CALL_FUNCTION(&_45$$25, "array_shift", NULL, 22, &args); + ZEPHIR_UNREF(&args); + zephir_check_call_status(); + zephir_array_update_string(&handleArgs, SL("action"), &_45$$25, PH_COPY | PH_SEPARATE); + } + if (zephir_fast_count_int(&args)) { + ZEPHIR_INIT_VAR(&_46$$26); + zephir_fast_array_merge(&_46$$26, &handleArgs, &args); + ZEPHIR_CPY_WRT(&handleArgs, &_46$$26); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("arguments"), &handleArgs); } - ZEPHIR_CPY_WRT(&close, &_3); - ZEPHIR_CONCAT_SVVVS(return_value, "<", &tag, &escapedAttrs, &close, ">"); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &opts); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Html_Helper_AbstractHelper, selfClose) +zend_object *zephir_init_properties_Phalcon_Cli_Console(zend_class_entry *class_type) { + zval _0, _2, _4, _1$$3, _3$$4, _5$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes; - zval *tag_param = NULL, *attributes_param = NULL, _0; - zval tag; - zval *this_ptr = getThis(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + - ZVAL_UNDEF(&tag); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(tag) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &tag_param, &attributes_param); - zephir_get_strval(&tag, tag_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - } else { - zephir_get_arrval(&attributes, attributes_param); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("modules"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("modules"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("arguments"), &_5$$5); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "/"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "rendertag", NULL, 0, &tag, &attributes, &_0); - zephir_check_call_status(); - RETURN_MM(); } @@ -120846,260 +121368,342 @@ static PHP_METHOD(Phalcon_Html_Helper_AbstractHelper, selfClose) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_AbstractList) +ZEPHIR_INIT_CLASS(Phalcon_Cli_Dispatcher) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper, AbstractList, phalcon, html_helper_abstractlist, phalcon_html_helper_abstracthelper_ce, phalcon_html_helper_abstractlist_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli, Dispatcher, phalcon, cli_dispatcher, phalcon_dispatcher_abstractdispatcher_ce, phalcon_cli_dispatcher_method_entry, 0); - zend_declare_property_null(phalcon_html_helper_abstractlist_ce, SL("attributes"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_html_helper_abstractlist_ce, SL("elementTag"), "li", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_html_helper_abstractlist_ce, SL("store"), ZEND_ACC_PROTECTED); - phalcon_html_helper_abstractlist_ce->create_object = zephir_init_properties_Phalcon_Html_Helper_AbstractList; + zend_declare_property_string(phalcon_cli_dispatcher_ce, SL("defaultHandler"), "main", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_cli_dispatcher_ce, SL("defaultAction"), "main", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_cli_dispatcher_ce, SL("handlerSuffix"), "Task", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_cli_dispatcher_ce, SL("options"), ZEND_ACC_PROTECTED); + phalcon_cli_dispatcher_ce->create_object = zephir_init_properties_Phalcon_Cli_Dispatcher; + zend_class_implements(phalcon_cli_dispatcher_ce, 1, phalcon_cli_dispatcherinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Helper_AbstractList, __invoke) +static PHP_METHOD(Phalcon_Cli_Dispatcher, callActionMethod) { + zval _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval attributes; - zval *indent_param = NULL, *delimiter_param = NULL, *attributes_param = NULL, _0, _1; - zval indent, delimiter; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval actionMethod; + zval *handler, handler_sub, *actionMethod_param = NULL, params, *params_param = NULL, _0, _1, _2; zval *this_ptr = getThis(); - ZVAL_UNDEF(&indent); - ZVAL_UNDEF(&delimiter); + ZVAL_UNDEF(&handler_sub); + ZVAL_UNDEF(¶ms); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&attributes); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 3) + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&actionMethod); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ZVAL(handler) + Z_PARAM_STR(actionMethod) Z_PARAM_OPTIONAL - Z_PARAM_STR(indent) - Z_PARAM_STR_OR_NULL(delimiter) - Z_PARAM_ARRAY(attributes) + Z_PARAM_ARRAY(params) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 3, &indent_param, &delimiter_param, &attributes_param); - if (!indent_param) { - ZEPHIR_INIT_VAR(&indent); - ZVAL_STRING(&indent, " "); - } else { - zephir_get_strval(&indent, indent_param); - } - if (!delimiter_param) { - ZEPHIR_INIT_VAR(&delimiter); - } else { - zephir_get_strval(&delimiter, delimiter_param); - } - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - } else { - zephir_get_arrval(&attributes, attributes_param); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &attributes); - ZEPHIR_INIT_VAR(&_0); - if (ZEPHIR_IS_EMPTY(&delimiter)) { - ZEPHIR_INIT_NVAR(&_0); - ZEPHIR_GET_CONSTANT(&_0, "PHP_EOL"); + zephir_fetch_params(1, 2, 1, &handler, &actionMethod_param, ¶ms_param); + zephir_get_strval(&actionMethod, actionMethod_param); + if (!params_param) { + ZEPHIR_INIT_VAR(¶ms); + array_init(¶ms); } else { - ZEPHIR_CPY_WRT(&_0, &delimiter); + ZEPHIR_OBS_COPY_OR_DUP(¶ms, params_param); } - zephir_update_property_zval(this_ptr, ZEND_STRL("delimiter"), &_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("indent"), &indent); + ZEPHIR_CALL_FUNCTION(&_0, "array_values", NULL, 14, ¶ms); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(¶ms, &_0); ZEPHIR_INIT_VAR(&_1); - array_init(&_1); - zephir_update_property_zval(this_ptr, ZEND_STRL("store"), &_1); - RETURN_THIS(); + zephir_read_property(&_2, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + zephir_fast_array_merge(&_1, ¶ms, &_2); + ZEPHIR_CPY_WRT(¶ms, &_1); + ZEPHIR_INIT_VAR(&_3); + zephir_create_array(&_3, 2, 0); + zephir_array_fast_append(&_3, handler); + zephir_array_fast_append(&_3, &actionMethod); + ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_3, ¶ms); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Html_Helper_AbstractList, __toString) +static PHP_METHOD(Phalcon_Cli_Dispatcher, getActiveTask) +{ + + RETURN_MEMBER(getThis(), "activeHandler"); +} + +static PHP_METHOD(Phalcon_Cli_Dispatcher, getLastTask) +{ + + RETURN_MEMBER(getThis(), "lastHandler"); +} + +static PHP_METHOD(Phalcon_Cli_Dispatcher, getOption) { - zval contents, _0, _1, _2, _3, _4, _5, _6, _7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *option, option_sub, *filters = NULL, filters_sub, *defaultValue = NULL, defaultValue_sub, __$null, options, filter, optionValue, container, _0, _3, _4, _1$$5, _2$$5; zval *this_ptr = getThis(); - ZVAL_UNDEF(&contents); + ZVAL_UNDEF(&option_sub); + ZVAL_UNDEF(&filters_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&filter); + ZVAL_UNDEF(&optionValue); + ZVAL_UNDEF(&container); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_1$$5); + ZVAL_UNDEF(&_2$$5); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ZVAL(option) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(filters) + Z_PARAM_ZVAL_OR_NULL(defaultValue) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_EMPTY(&_0)) { - RETURN_MM_STRING(""); + zephir_fetch_params(1, 1, 2, &option, &filters, &defaultValue); + if (!filters) { + filters = &filters_sub; + filters = &__$null; } - zephir_read_property(&_1, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_4, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "renderarrayelements", NULL, 0, &_3, &_4); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&contents); - ZEPHIR_CONCAT_VV(&contents, &_1, &_2); - ZEPHIR_CALL_METHOD(&_5, this_ptr, "gettag", NULL, 0); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&options, &_0); + zephir_memory_observe(&optionValue); + if (!(zephir_array_isset_fetch(&optionValue, &options, option, 0))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + if (Z_TYPE_P(filters) == IS_NULL) { + RETURN_CCTOR(&optionValue); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_0); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$5); + ZVAL_STRING(&_1$$5, "A dependency injection container is required to access the 'filter' service"); + ZVAL_LONG(&_2$$5, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwdispatchexception", NULL, 0, &_1$$5, &_2$$5); + zephir_check_call_status(); + } + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "filter"); + ZEPHIR_CALL_METHOD(&_3, &container, "getshared", NULL, 0, &_4); zephir_check_call_status(); - zephir_read_property(&_6, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); - ZVAL_BOOL(&_7, 1); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "renderfullelement", NULL, 0, &_5, &contents, &_6, &_7); + ZEPHIR_CPY_WRT(&filter, &_3); + ZEPHIR_RETURN_CALL_METHOD(&filter, "sanitize", NULL, 0, &optionValue, filters); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Html_Helper_AbstractList, getTag) +static PHP_METHOD(Phalcon_Cli_Dispatcher, getOptions) { + + RETURN_MEMBER(getThis(), "options"); } -zend_object *zephir_init_properties_Phalcon_Html_Helper_AbstractList(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Cli_Dispatcher, getTaskName) { - zval _0, _2, _1$$3, _3$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("store"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("attributes"), &_3$$4); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } + RETURN_MEMBER(getThis(), "handlerName"); } +static PHP_METHOD(Phalcon_Cli_Dispatcher, getTaskSuffix) +{ + RETURN_MEMBER(getThis(), "handlerSuffix"); +} +static PHP_METHOD(Phalcon_Cli_Dispatcher, hasOption) +{ + zval *option, option_sub, _0; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H -#endif + ZVAL_UNDEF(&option_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(option) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &option); + zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + RETURN_BOOL(zephir_array_isset(&_0, option)); +} +static PHP_METHOD(Phalcon_Cli_Dispatcher, setDefaultTask) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *taskName_param = NULL; + zval taskName; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&taskName); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(taskName) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &taskName_param); + zephir_get_strval(&taskName, taskName_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultHandler"), &taskName); + ZEPHIR_MM_RESTORE(); +} +static PHP_METHOD(Phalcon_Cli_Dispatcher, setOptions) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *options_param = NULL; + zval options; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &options_param); + zephir_get_arrval(&options, options_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); + ZEPHIR_MM_RESTORE(); +} -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_AbstractSeries) +static PHP_METHOD(Phalcon_Cli_Dispatcher, setTaskName) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper, AbstractSeries, phalcon, html_helper_abstractseries, phalcon_html_helper_abstracthelper_ce, phalcon_html_helper_abstractseries_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_html_helper_abstractseries_ce, SL("attributes"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_html_helper_abstractseries_ce, SL("store"), ZEND_ACC_PROTECTED); - phalcon_html_helper_abstractseries_ce->create_object = zephir_init_properties_Phalcon_Html_Helper_AbstractSeries; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *taskName_param = NULL; + zval taskName; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&taskName); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(taskName) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &taskName_param); + zephir_get_strval(&taskName, taskName_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("handlerName"), &taskName); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Helper_AbstractSeries, __invoke) +static PHP_METHOD(Phalcon_Cli_Dispatcher, setTaskSuffix) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *indent_param = NULL, *delimiter_param = NULL, _0; - zval indent, delimiter; + zval *taskSuffix_param = NULL; + zval taskSuffix; zval *this_ptr = getThis(); - ZVAL_UNDEF(&indent); - ZVAL_UNDEF(&delimiter); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_STR(indent) - Z_PARAM_STR_OR_NULL(delimiter) + ZVAL_UNDEF(&taskSuffix); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(taskSuffix) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &indent_param, &delimiter_param); - if (!indent_param) { - ZEPHIR_INIT_VAR(&indent); - ZVAL_STRING(&indent, " "); - } else { - zephir_get_strval(&indent, indent_param); - } - if (!delimiter_param) { - ZEPHIR_INIT_VAR(&delimiter); - } else { - zephir_get_strval(&delimiter, delimiter_param); - } - ZEPHIR_INIT_VAR(&_0); - if (Z_TYPE_P(&delimiter) == IS_NULL) { - ZEPHIR_INIT_NVAR(&_0); - ZEPHIR_GET_CONSTANT(&_0, "PHP_EOL"); - } else { - ZEPHIR_CPY_WRT(&_0, &delimiter); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("delimiter"), &_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("indent"), &indent); - RETURN_THIS(); + zephir_fetch_params(1, 1, 0, &taskSuffix_param); + zephir_get_strval(&taskSuffix, taskSuffix_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("handlerSuffix"), &taskSuffix); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Helper_AbstractSeries, __toString) +static PHP_METHOD(Phalcon_Cli_Dispatcher, handleException) { - zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *exception, exception_sub, eventsManager, _0, _1$$3, _2$$3; zval *this_ptr = getThis(); + ZVAL_UNDEF(&exception_sub); + ZVAL_UNDEF(&eventsManager); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(exception, zend_ce_exception) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_1, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "renderarrayelements", NULL, 0, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &exception); + zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_0); + if (Z_TYPE_P(&eventsManager) != IS_NULL) { + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "dispatch:beforeException"); + ZEPHIR_CALL_METHOD(&_1$$3, &eventsManager, "fire", NULL, 0, &_2$$3, this_ptr, exception); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$3)) { + RETURN_MM_BOOL(0); + } + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Helper_AbstractSeries, reset) +static PHP_METHOD(Phalcon_Cli_Dispatcher, throwDispatchException) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long exceptionCode, ZEPHIR_LAST_CALL_STATUS; + zval *message_param = NULL, *exceptionCode_param = NULL, exception, _0, _1; + zval message; zval *this_ptr = getThis(); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&exception); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(exceptionCode) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("store"), &_0); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Html_Helper_AbstractSeries, getTag) -{ + zephir_fetch_params(1, 1, 1, &message_param, &exceptionCode_param); + zephir_get_strval(&message, message_param); + if (!exceptionCode_param) { + exceptionCode = 0; + } else { + } + ZEPHIR_INIT_VAR(&exception); + object_init_ex(&exception, phalcon_cli_dispatcher_exception_ce); + ZVAL_LONG(&_0, exceptionCode); + ZEPHIR_CALL_METHOD(NULL, &exception, "__construct", NULL, 33, &message, &_0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "handleexception", NULL, 0, &exception); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_1)) { + RETURN_MM_BOOL(0); + } + zephir_throw_exception_debug(&exception, "phalcon/Cli/Dispatcher.zep", 224); + ZEPHIR_MM_RESTORE(); + return; } -zend_object *zephir_init_properties_Phalcon_Html_Helper_AbstractSeries(zend_class_entry *class_type) +zend_object *zephir_init_properties_Phalcon_Cli_Dispatcher(zend_class_entry *class_type) { - zval _0, _2, _1$$3, _3$$4; + zval _0, _2, _4, _6, _8, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_9$$7); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); @@ -121108,17 +121712,35 @@ zend_object *zephir_init_properties_Phalcon_Html_Helper_AbstractSeries(zend_clas { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("store"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_1$$3); } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("handlerHashes"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_2) == IS_NULL) { ZEPHIR_INIT_VAR(&_3$$4); array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("attributes"), &_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("handlerHashes"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("camelCaseMap"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("camelCaseMap"), &_5$$5); + } + zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("activeMethodMap"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_6) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$6); + array_init(&_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("activeMethodMap"), &_7$$6); + } + zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_8) == IS_NULL) { + ZEPHIR_INIT_VAR(&_9$$7); + array_init(&_9$$7); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_9$$7); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -121135,92 +121757,23 @@ zend_object *zephir_init_properties_Phalcon_Html_Helper_AbstractSeries(zend_clas -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Anchor) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper, Anchor, phalcon, html_helper_anchor, phalcon_html_helper_abstracthelper_ce, phalcon_html_helper_anchor_method_entry, 0); - - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Html_Helper_Anchor, __invoke) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool raw; - zval attributes; - zval *href_param = NULL, *text_param = NULL, *attributes_param = NULL, *raw_param = NULL, overrides, _0, _1; - zval href, text; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&href); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&overrides); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(2, 4) - Z_PARAM_STR(href) - Z_PARAM_STR(text) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) - Z_PARAM_BOOL(raw) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 2, &href_param, &text_param, &attributes_param, &raw_param); - zephir_get_strval(&href, href_param); - zephir_get_strval(&text, text_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - } else { - zephir_get_arrval(&attributes, attributes_param); - } - if (!raw_param) { - raw = 0; - } else { - } - ZEPHIR_CALL_METHOD(&overrides, this_ptr, "processattributes", NULL, 0, &href, &attributes); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "a"); - if (raw) { - ZVAL_BOOL(&_1, 1); - } else { - ZVAL_BOOL(&_1, 0); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "renderfullelement", NULL, 0, &_0, &text, &overrides, &_1); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Html_Helper_Anchor, processAttributes) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval attributes; - zval *href_param = NULL, *attributes_param = NULL, overrides; - zval href; - - ZVAL_UNDEF(&href); - ZVAL_UNDEF(&overrides); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(href) - Z_PARAM_ARRAY(attributes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &href_param, &attributes_param); - zephir_get_strval(&href, href_param); - zephir_get_arrval(&attributes, attributes_param); - ZEPHIR_INIT_VAR(&overrides); - zephir_create_array(&overrides, 1, 0); - zephir_array_update_string(&overrides, SL("href"), &href, PH_COPY | PH_SEPARATE); - zephir_array_unset_string(&attributes, SL("href"), PH_SEPARATE); - zephir_fast_array_merge(return_value, &overrides, &attributes); - RETURN_MM(); +ZEPHIR_INIT_CLASS(Phalcon_Cli_DispatcherInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Cli, DispatcherInterface, phalcon, cli_dispatcherinterface, phalcon_cli_dispatcherinterface_method_entry); + + zend_class_implements(phalcon_cli_dispatcherinterface_ce, 1, phalcon_dispatcher_dispatcherinterface_ce); + return SUCCESS; } +ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, getActiveTask); +ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, getLastTask); +ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, getOptions); +ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, getTaskName); +ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, getTaskSuffix); +ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, setDefaultTask); +ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, setOptions); +ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, setTaskName); +ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, setTaskSuffix); @@ -121231,409 +121784,939 @@ static PHP_METHOD(Phalcon_Html_Helper_Anchor, processAttributes) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Base) +ZEPHIR_INIT_CLASS(Phalcon_Cli_Router) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper, Base, phalcon, html_helper_base, phalcon_html_helper_abstracthelper_ce, phalcon_html_helper_base_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli, Router, phalcon, cli_router, phalcon_di_abstractinjectionaware_ce, phalcon_cli_router_method_entry, 0); + + zend_declare_property_string(phalcon_cli_router_ce, SL("action"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_cli_router_ce, SL("defaultAction"), "", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_cli_router_ce, SL("defaultModule"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_cli_router_ce, SL("defaultParams"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_cli_router_ce, SL("defaultTask"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_cli_router_ce, SL("matchedRoute"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_cli_router_ce, SL("matches"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_cli_router_ce, SL("module"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_cli_router_ce, SL("params"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_cli_router_ce, SL("routes"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_cli_router_ce, SL("task"), "", ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_cli_router_ce, SL("wasMatched"), 0, ZEND_ACC_PROTECTED); + phalcon_cli_router_ce->create_object = zephir_init_properties_Phalcon_Cli_Router; return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Helper_Base, __invoke) +static PHP_METHOD(Phalcon_Cli_Router, __construct) { + zval routes, _1$$3, _3$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes; - zval *href_param = NULL, *attributes_param = NULL, overrides, _1, _0$$3; - zval href; + zval *defaultRoutes_param = NULL, _0$$3, _2$$3, _4$$3; + zend_bool defaultRoutes; zval *this_ptr = getThis(); - ZVAL_UNDEF(&href); - ZVAL_UNDEF(&overrides); - ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&attributes); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&routes); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$3); + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(href) - Z_PARAM_ARRAY(attributes) + Z_PARAM_BOOL(defaultRoutes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &href_param, &attributes_param); - if (!href_param) { - ZEPHIR_INIT_VAR(&href); + zephir_fetch_params(1, 0, 1, &defaultRoutes_param); + if (!defaultRoutes_param) { + defaultRoutes = 1; } else { - zephir_get_strval(&href, href_param); + } + ZEPHIR_INIT_VAR(&routes); + array_init(&routes); + if (defaultRoutes) { + ZEPHIR_INIT_VAR(&_0$$3); + object_init_ex(&_0$$3, phalcon_cli_router_route_ce); + ZEPHIR_INIT_VAR(&_1$$3); + zephir_create_array(&_1$$3, 1, 0); + add_assoc_long_ex(&_1$$3, SL("task"), 1); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "#^(?::delimiter)?([a-zA-Z0-9\\_\\-]+)[:delimiter]{0,1}$#"); + ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 191, &_2$$3, &_1$$3); + zephir_check_call_status(); + zephir_array_append(&routes, &_0$$3, PH_SEPARATE, "phalcon/Cli/Router.zep", 119); + ZEPHIR_INIT_NVAR(&_2$$3); + object_init_ex(&_2$$3, phalcon_cli_router_route_ce); + ZEPHIR_INIT_VAR(&_3$$3); + zephir_create_array(&_3$$3, 3, 0); + add_assoc_long_ex(&_3$$3, SL("task"), 1); + add_assoc_long_ex(&_3$$3, SL("action"), 2); + add_assoc_long_ex(&_3$$3, SL("params"), 3); + ZEPHIR_INIT_VAR(&_4$$3); + ZVAL_STRING(&_4$$3, "#^(?::delimiter)?([a-zA-Z0-9\\_\\-]+):delimiter([a-zA-Z0-9\\.\\_]+)(:delimiter.*)*$#"); + ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 191, &_4$$3, &_3$$3); + zephir_check_call_status(); + zephir_array_append(&routes, &_2$$3, PH_SEPARATE, "phalcon/Cli/Router.zep", 128); } - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); + zephir_update_property_zval(this_ptr, ZEND_STRL("routes"), &routes); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Cli_Router, add) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, route; + zval pattern; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&route); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(pattern) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(paths) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &pattern_param, &paths); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - zephir_get_arrval(&attributes, attributes_param); + ZEPHIR_INIT_VAR(&pattern); } - ZEPHIR_INIT_VAR(&overrides); - array_init(&overrides); - if (!(ZEPHIR_IS_EMPTY(&href))) { - ZEPHIR_INIT_VAR(&_0$$3); - zephir_create_array(&_0$$3, 1, 0); - zephir_array_update_string(&_0$$3, SL("href"), &href, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&overrides, &_0$$3); + if (!paths) { + paths = &paths_sub; + paths = &__$null; } - zephir_array_unset_string(&attributes, SL("href"), PH_SEPARATE); - ZEPHIR_INIT_VAR(&_1); - zephir_fast_array_merge(&_1, &overrides, &attributes); - ZEPHIR_CPY_WRT(&overrides, &_1); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "base"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "renderelement", NULL, 0, &_1, &overrides); + ZEPHIR_INIT_VAR(&route); + object_init_ex(&route, phalcon_cli_router_route_ce); + ZEPHIR_CALL_METHOD(NULL, &route, "__construct", NULL, 191, &pattern, paths); zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_array_append(this_ptr, SL("routes"), &route); + RETURN_CCTOR(&route); } +static PHP_METHOD(Phalcon_Cli_Router, getActionName) +{ + RETURN_MEMBER(getThis(), "action"); +} +static PHP_METHOD(Phalcon_Cli_Router, getMatchedRoute) +{ -#ifdef HAVE_CONFIG_H -#endif - - + RETURN_MEMBER(getThis(), "matchedRoute"); +} +static PHP_METHOD(Phalcon_Cli_Router, getMatches) +{ + RETURN_MEMBER(getThis(), "matches"); +} -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Body) +static PHP_METHOD(Phalcon_Cli_Router, getModuleName) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper, Body, phalcon, html_helper_body, phalcon_html_helper_abstracthelper_ce, phalcon_html_helper_body_method_entry, 0); - return SUCCESS; + RETURN_MEMBER(getThis(), "module"); } -static PHP_METHOD(Phalcon_Html_Helper_Body, __invoke) +static PHP_METHOD(Phalcon_Cli_Router, getParams) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *attributes_param = NULL, _0; - zval attributes; zval *this_ptr = getThis(); - - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &attributes_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - } else { - zephir_get_arrval(&attributes, attributes_param); - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "body"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "renderelement", NULL, 0, &_0, &attributes); + + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getparameters", NULL, 0); zephir_check_call_status(); RETURN_MM(); } +static PHP_METHOD(Phalcon_Cli_Router, getParameters) +{ + RETURN_MEMBER(getThis(), "params"); +} - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Button) +static PHP_METHOD(Phalcon_Cli_Router, getRouteById) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper, Button, phalcon, html_helper_button, phalcon_html_helper_abstracthelper_ce, phalcon_html_helper_button_method_entry, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *id, id_sub, route, _0, *_1, _2, _3$$3, _4$$5; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&id_sub); + ZVAL_UNDEF(&route); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$5); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(id) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &id); + zephir_read_property(&_0, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_0, 0, "phalcon/Cli/Router.zep", 218); + if (Z_TYPE_P(&_0) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) + { + ZEPHIR_INIT_NVAR(&route); + ZVAL_COPY(&route, _1); + ZEPHIR_CALL_METHOD(&_3$$3, &route, "getrouteid", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_EQUAL(&_3$$3, id)) { + RETURN_CCTOR(&route); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&route, &_0, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4$$5, &route, "getrouteid", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_EQUAL(&_4$$5, id)) { + RETURN_CCTOR(&route); + } + ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&route); + RETURN_MM_BOOL(0); } -static PHP_METHOD(Phalcon_Html_Helper_Button, __invoke) +static PHP_METHOD(Phalcon_Cli_Router, getRouteByName) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool raw; - zval attributes; - zval *text_param = NULL, *attributes_param = NULL, *raw_param = NULL, _0, _1; - zval text; + zval *name_param = NULL, route, _0, *_1, _2, _3$$3, _4$$5; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&route); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(text) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) - Z_PARAM_BOOL(raw) + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$5); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &text_param, &attributes_param, &raw_param); - zephir_get_strval(&text, text_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - zephir_get_arrval(&attributes, attributes_param); + ZEPHIR_INIT_VAR(&name); } - if (!raw_param) { - raw = 0; + zephir_read_property(&_0, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_0, 0, "phalcon/Cli/Router.zep", 234); + if (Z_TYPE_P(&_0) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) + { + ZEPHIR_INIT_NVAR(&route); + ZVAL_COPY(&route, _1); + ZEPHIR_CALL_METHOD(&_3$$3, &route, "getname", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_EQUAL(&_3$$3, &name)) { + RETURN_CCTOR(&route); + } + } ZEND_HASH_FOREACH_END(); } else { + ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&route, &_0, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4$$5, &route, "getname", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_EQUAL(&_4$$5, &name)) { + RETURN_CCTOR(&route); + } + ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); + zephir_check_call_status(); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "button"); - if (raw) { - ZVAL_BOOL(&_1, 1); - } else { - ZVAL_BOOL(&_1, 0); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "renderfullelement", NULL, 0, &_0, &text, &attributes, &_1); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_INIT_NVAR(&route); + RETURN_MM_BOOL(0); } +static PHP_METHOD(Phalcon_Cli_Router, getRoutes) +{ + RETURN_MEMBER(getThis(), "routes"); +} - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Close) +static PHP_METHOD(Phalcon_Cli_Router, getTaskName) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper, Close, phalcon, html_helper_close, phalcon_html_helper_abstracthelper_ce, phalcon_html_helper_close_method_entry, 0); - return SUCCESS; + RETURN_MEMBER(getThis(), "task"); } -static PHP_METHOD(Phalcon_Html_Helper_Close, __invoke) +static PHP_METHOD(Phalcon_Cli_Router, handle) { + zval _34$$55; + zend_string *_8$$12, *_21$$32; + zend_ulong _7$$12, _20$$32; + zval _4$$9, _10$$15, _12$$18, _14$$21, _16$$24, _17$$29, _23$$35, _25$$38, _27$$41, _29$$44; + zend_bool _0$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool raw; - zval *tag_param = NULL, *raw_param = NULL, _0; - zval tag; + zval *arguments = NULL, arguments_sub, __$true, __$false, __$null, moduleName, taskName, actionName, params, route, parts, pattern, routeFound, matches, paths, beforeMatch, converters, converter, part, position, matchPosition, strParams, _1$$3, *_2$$3, _3$$3, *_5$$12, _6$$12, _9$$15, _11$$18, _13$$21, _15$$24, *_18$$32, _19$$32, _22$$35, _24$$38, _26$$41, _28$$44, _30$$46, _31$$46, _32$$46, _33$$46, _35$$55, _36$$56, _37$$58; zval *this_ptr = getThis(); - ZVAL_UNDEF(&tag); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(tag) + ZVAL_UNDEF(&arguments_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&moduleName); + ZVAL_UNDEF(&taskName); + ZVAL_UNDEF(&actionName); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&route); + ZVAL_UNDEF(&parts); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&routeFound); + ZVAL_UNDEF(&matches); + ZVAL_UNDEF(&paths); + ZVAL_UNDEF(&beforeMatch); + ZVAL_UNDEF(&converters); + ZVAL_UNDEF(&converter); + ZVAL_UNDEF(&part); + ZVAL_UNDEF(&position); + ZVAL_UNDEF(&matchPosition); + ZVAL_UNDEF(&strParams); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_6$$12); + ZVAL_UNDEF(&_9$$15); + ZVAL_UNDEF(&_11$$18); + ZVAL_UNDEF(&_13$$21); + ZVAL_UNDEF(&_15$$24); + ZVAL_UNDEF(&_19$$32); + ZVAL_UNDEF(&_22$$35); + ZVAL_UNDEF(&_24$$38); + ZVAL_UNDEF(&_26$$41); + ZVAL_UNDEF(&_28$$44); + ZVAL_UNDEF(&_30$$46); + ZVAL_UNDEF(&_31$$46); + ZVAL_UNDEF(&_32$$46); + ZVAL_UNDEF(&_33$$46); + ZVAL_UNDEF(&_35$$55); + ZVAL_UNDEF(&_36$$56); + ZVAL_UNDEF(&_37$$58); + ZVAL_UNDEF(&_4$$9); + ZVAL_UNDEF(&_10$$15); + ZVAL_UNDEF(&_12$$18); + ZVAL_UNDEF(&_14$$21); + ZVAL_UNDEF(&_16$$24); + ZVAL_UNDEF(&_17$$29); + ZVAL_UNDEF(&_23$$35); + ZVAL_UNDEF(&_25$$38); + ZVAL_UNDEF(&_27$$41); + ZVAL_UNDEF(&_29$$44); + ZVAL_UNDEF(&_34$$55); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(raw) + Z_PARAM_ZVAL_OR_NULL(arguments) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &tag_param, &raw_param); - zephir_get_strval(&tag, tag_param); - if (!raw_param) { - raw = 0; + zephir_fetch_params(1, 0, 1, &arguments); + if (!arguments) { + arguments = &arguments_sub; + arguments = &__$null; + } + ZEPHIR_INIT_VAR(&routeFound); + ZVAL_BOOL(&routeFound, 0); + ZEPHIR_INIT_VAR(&parts); + array_init(&parts); + ZEPHIR_INIT_VAR(¶ms); + array_init(¶ms); + ZEPHIR_INIT_VAR(&matches); + ZVAL_NULL(&matches); + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$true); } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$false); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("matchedRoute"), &__$null); + if (Z_TYPE_P(arguments) != IS_ARRAY) { + _0$$3 = Z_TYPE_P(arguments) != IS_STRING; + if (_0$$3) { + _0$$3 = Z_TYPE_P(arguments) != IS_NULL; + } + if (UNEXPECTED(_0$$3)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_router_exception_ce, "Arguments must be an array or string", "phalcon/Cli/Router.zep", 273); + return; + } + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_1$$3, 0, "phalcon/Cli/Router.zep", 379); + if (Z_TYPE_P(&_1$$3) == IS_ARRAY) { + ZEND_HASH_REVERSE_FOREACH_VAL(Z_ARRVAL_P(&_1$$3), _2$$3) + { + ZEPHIR_INIT_NVAR(&route); + ZVAL_COPY(&route, _2$$3); + ZEPHIR_CALL_METHOD(&pattern, &route, "getcompiledpattern", NULL, 0); + zephir_check_call_status(); + if (zephir_memnstr_str(&pattern, SL("^"), "phalcon/Cli/Router.zep", 282)) { + ZEPHIR_INIT_NVAR(&routeFound); + zephir_preg_match(&routeFound, &pattern, arguments, &matches, 0, 0 , 0 ); + } else { + ZEPHIR_INIT_NVAR(&routeFound); + ZVAL_BOOL(&routeFound, ZEPHIR_IS_EQUAL(&pattern, arguments)); + } + if (zephir_is_true(&routeFound)) { + ZEPHIR_CALL_METHOD(&beforeMatch, &route, "getbeforematch", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&beforeMatch) != IS_NULL) { + if (UNEXPECTED(!(zephir_is_callable(&beforeMatch)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_router_exception_ce, "Before-Match callback is not callable in matched route", "phalcon/Cli/Router.zep", 301); + return; + } + ZEPHIR_INIT_NVAR(&_4$$9); + zephir_create_array(&_4$$9, 3, 0); + zephir_array_fast_append(&_4$$9, arguments); + zephir_array_fast_append(&_4$$9, &route); + zephir_array_fast_append(&_4$$9, this_ptr); + ZEPHIR_INIT_NVAR(&routeFound); + ZEPHIR_CALL_USER_FUNC_ARRAY(&routeFound, &beforeMatch, &_4$$9); + zephir_check_call_status(); + } + } + if (zephir_is_true(&routeFound)) { + ZEPHIR_CALL_METHOD(&paths, &route, "getpaths", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&parts, &paths); + if (Z_TYPE_P(&matches) == IS_ARRAY) { + ZEPHIR_CALL_METHOD(&converters, &route, "getconverters", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&paths, 0, "phalcon/Cli/Router.zep", 366); + if (Z_TYPE_P(&paths) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&paths), _7$$12, _8$$12, _5$$12) + { + ZEPHIR_INIT_NVAR(&part); + if (_8$$12 != NULL) { + ZVAL_STR_COPY(&part, _8$$12); + } else { + ZVAL_LONG(&part, _7$$12); + } + ZEPHIR_INIT_NVAR(&position); + ZVAL_COPY(&position, _5$$12); + ZEPHIR_OBS_NVAR(&matchPosition); + if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { + ZEPHIR_OBS_NVAR(&converter); + if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { + ZEPHIR_INIT_NVAR(&_9$$15); + ZEPHIR_INIT_NVAR(&_10$$15); + zephir_create_array(&_10$$15, 1, 0); + zephir_array_fast_append(&_10$$15, &matchPosition); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_9$$15, &converter, &_10$$15); + zephir_check_call_status(); + zephir_array_update_zval(&parts, &part, &_9$$15, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); + } + } else { + ZEPHIR_OBS_NVAR(&converter); + if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { + ZEPHIR_INIT_NVAR(&_11$$18); + ZEPHIR_INIT_NVAR(&_12$$18); + zephir_create_array(&_12$$18, 1, 0); + zephir_array_fast_append(&_12$$18, &position); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_11$$18, &converter, &_12$$18); + zephir_check_call_status(); + zephir_array_update_zval(&parts, &part, &_11$$18, PH_COPY | PH_SEPARATE); + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &paths, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_6$$12, &paths, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_6$$12)) { + break; + } + ZEPHIR_CALL_METHOD(&part, &paths, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&position, &paths, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&matchPosition); + if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { + ZEPHIR_OBS_NVAR(&converter); + if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { + ZEPHIR_INIT_NVAR(&_13$$21); + ZEPHIR_INIT_NVAR(&_14$$21); + zephir_create_array(&_14$$21, 1, 0); + zephir_array_fast_append(&_14$$21, &matchPosition); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_13$$21, &converter, &_14$$21); + zephir_check_call_status(); + zephir_array_update_zval(&parts, &part, &_13$$21, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); + } + } else { + ZEPHIR_OBS_NVAR(&converter); + if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { + ZEPHIR_INIT_NVAR(&_15$$24); + ZEPHIR_INIT_NVAR(&_16$$24); + zephir_create_array(&_16$$24, 1, 0); + zephir_array_fast_append(&_16$$24, &position); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_15$$24, &converter, &_16$$24); + zephir_check_call_status(); + zephir_array_update_zval(&parts, &part, &_15$$24, PH_COPY | PH_SEPARATE); + } + } + ZEPHIR_CALL_METHOD(NULL, &paths, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&position); + ZEPHIR_INIT_NVAR(&part); + zephir_update_property_zval(this_ptr, ZEND_STRL("matches"), &matches); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("matchedRoute"), &route); + break; + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3$$3, &_1$$3, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&route, &_1$$3, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&pattern, &route, "getcompiledpattern", NULL, 0); + zephir_check_call_status(); + if (zephir_memnstr_str(&pattern, SL("^"), "phalcon/Cli/Router.zep", 282)) { + ZEPHIR_INIT_NVAR(&routeFound); + zephir_preg_match(&routeFound, &pattern, arguments, &matches, 0, 0 , 0 ); + } else { + ZEPHIR_INIT_NVAR(&routeFound); + ZVAL_BOOL(&routeFound, ZEPHIR_IS_EQUAL(&pattern, arguments)); + } + if (zephir_is_true(&routeFound)) { + ZEPHIR_CALL_METHOD(&beforeMatch, &route, "getbeforematch", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&beforeMatch) != IS_NULL) { + if (UNEXPECTED(!(zephir_is_callable(&beforeMatch)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_router_exception_ce, "Before-Match callback is not callable in matched route", "phalcon/Cli/Router.zep", 301); + return; + } + ZEPHIR_INIT_NVAR(&_17$$29); + zephir_create_array(&_17$$29, 3, 0); + zephir_array_fast_append(&_17$$29, arguments); + zephir_array_fast_append(&_17$$29, &route); + zephir_array_fast_append(&_17$$29, this_ptr); + ZEPHIR_INIT_NVAR(&routeFound); + ZEPHIR_CALL_USER_FUNC_ARRAY(&routeFound, &beforeMatch, &_17$$29); + zephir_check_call_status(); + } + } + if (zephir_is_true(&routeFound)) { + ZEPHIR_CALL_METHOD(&paths, &route, "getpaths", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&parts, &paths); + if (Z_TYPE_P(&matches) == IS_ARRAY) { + ZEPHIR_CALL_METHOD(&converters, &route, "getconverters", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&paths, 0, "phalcon/Cli/Router.zep", 366); + if (Z_TYPE_P(&paths) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&paths), _20$$32, _21$$32, _18$$32) + { + ZEPHIR_INIT_NVAR(&part); + if (_21$$32 != NULL) { + ZVAL_STR_COPY(&part, _21$$32); + } else { + ZVAL_LONG(&part, _20$$32); + } + ZEPHIR_INIT_NVAR(&position); + ZVAL_COPY(&position, _18$$32); + ZEPHIR_OBS_NVAR(&matchPosition); + if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { + ZEPHIR_OBS_NVAR(&converter); + if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { + ZEPHIR_INIT_NVAR(&_22$$35); + ZEPHIR_INIT_NVAR(&_23$$35); + zephir_create_array(&_23$$35, 1, 0); + zephir_array_fast_append(&_23$$35, &matchPosition); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_22$$35, &converter, &_23$$35); + zephir_check_call_status(); + zephir_array_update_zval(&parts, &part, &_22$$35, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); + } + } else { + ZEPHIR_OBS_NVAR(&converter); + if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { + ZEPHIR_INIT_NVAR(&_24$$38); + ZEPHIR_INIT_NVAR(&_25$$38); + zephir_create_array(&_25$$38, 1, 0); + zephir_array_fast_append(&_25$$38, &position); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_24$$38, &converter, &_25$$38); + zephir_check_call_status(); + zephir_array_update_zval(&parts, &part, &_24$$38, PH_COPY | PH_SEPARATE); + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &paths, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_19$$32, &paths, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_19$$32)) { + break; + } + ZEPHIR_CALL_METHOD(&part, &paths, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&position, &paths, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&matchPosition); + if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { + ZEPHIR_OBS_NVAR(&converter); + if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { + ZEPHIR_INIT_NVAR(&_26$$41); + ZEPHIR_INIT_NVAR(&_27$$41); + zephir_create_array(&_27$$41, 1, 0); + zephir_array_fast_append(&_27$$41, &matchPosition); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_26$$41, &converter, &_27$$41); + zephir_check_call_status(); + zephir_array_update_zval(&parts, &part, &_26$$41, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); + } + } else { + ZEPHIR_OBS_NVAR(&converter); + if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { + ZEPHIR_INIT_NVAR(&_28$$44); + ZEPHIR_INIT_NVAR(&_29$$44); + zephir_create_array(&_29$$44, 1, 0); + zephir_array_fast_append(&_29$$44, &position); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_28$$44, &converter, &_29$$44); + zephir_check_call_status(); + zephir_array_update_zval(&parts, &part, &_28$$44, PH_COPY | PH_SEPARATE); + } + } + ZEPHIR_CALL_METHOD(NULL, &paths, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&position); + ZEPHIR_INIT_NVAR(&part); + zephir_update_property_zval(this_ptr, ZEND_STRL("matches"), &matches); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("matchedRoute"), &route); + break; + } + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&route); + if (zephir_is_true(&routeFound)) { + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$false); + } + } else { + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$false); + } + zephir_read_property(&_30$$46, this_ptr, ZEND_STRL("defaultModule"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("module"), &_30$$46); + zephir_read_property(&_31$$46, this_ptr, ZEND_STRL("defaultTask"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("task"), &_31$$46); + zephir_read_property(&_32$$46, this_ptr, ZEND_STRL("defaultAction"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("action"), &_32$$46); + zephir_read_property(&_33$$46, this_ptr, ZEND_STRL("defaultParams"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("params"), &_33$$46); + RETURN_THIS(); } - if (raw) { - ZVAL_BOOL(&_0, 1); } else { - ZVAL_BOOL(&_0, 0); + ZEPHIR_CPY_WRT(&parts, arguments); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "close", NULL, 0, &tag, &_0); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_INIT_VAR(&moduleName); + ZVAL_NULL(&moduleName); + ZEPHIR_INIT_VAR(&taskName); + ZVAL_NULL(&taskName); + ZEPHIR_INIT_VAR(&actionName); + ZVAL_NULL(&actionName); + ZEPHIR_OBS_NVAR(&moduleName); + if (zephir_array_isset_string_fetch(&moduleName, &parts, SL("module"), 0)) { + zephir_array_unset_string(&parts, SL("module"), PH_SEPARATE); + } else { + ZEPHIR_OBS_NVAR(&moduleName); + zephir_read_property(&moduleName, this_ptr, ZEND_STRL("defaultModule"), PH_NOISY_CC); + } + ZEPHIR_OBS_NVAR(&taskName); + if (zephir_array_isset_string_fetch(&taskName, &parts, SL("task"), 0)) { + zephir_array_unset_string(&parts, SL("task"), PH_SEPARATE); + } else { + ZEPHIR_OBS_NVAR(&taskName); + zephir_read_property(&taskName, this_ptr, ZEND_STRL("defaultTask"), PH_NOISY_CC); + } + ZEPHIR_OBS_NVAR(&actionName); + if (zephir_array_isset_string_fetch(&actionName, &parts, SL("action"), 0)) { + zephir_array_unset_string(&parts, SL("action"), PH_SEPARATE); + } else { + ZEPHIR_OBS_NVAR(&actionName); + zephir_read_property(&actionName, this_ptr, ZEND_STRL("defaultAction"), PH_NOISY_CC); + } + ZEPHIR_OBS_NVAR(¶ms); + if (zephir_array_isset_string_fetch(¶ms, &parts, SL("params"), 0)) { + if (Z_TYPE_P(¶ms) != IS_ARRAY) { + zephir_cast_to_string(&_34$$55, ¶ms); + ZVAL_LONG(&_35$$55, 1); + ZEPHIR_INIT_VAR(&strParams); + zephir_substr(&strParams, &_34$$55, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + if (zephir_is_true(&strParams)) { + ZEPHIR_CALL_CE_STATIC(&_36$$56, phalcon_cli_router_route_ce, "getdelimiter", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(¶ms); + zephir_fast_explode(¶ms, &_36$$56, &strParams, LONG_MAX); + } else { + ZEPHIR_INIT_NVAR(¶ms); + array_init(¶ms); + } + } + zephir_array_unset_string(&parts, SL("params"), PH_SEPARATE); + } + if (zephir_fast_count_int(¶ms)) { + ZEPHIR_INIT_VAR(&_37$$58); + zephir_fast_array_merge(&_37$$58, ¶ms, &parts); + ZEPHIR_CPY_WRT(¶ms, &_37$$58); + } else { + ZEPHIR_CPY_WRT(¶ms, &parts); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("module"), &moduleName); + zephir_update_property_zval(this_ptr, ZEND_STRL("task"), &taskName); + zephir_update_property_zval(this_ptr, ZEND_STRL("action"), &actionName); + zephir_update_property_zval(this_ptr, ZEND_STRL("params"), ¶ms); + ZEPHIR_MM_RESTORE(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Doctype) +static PHP_METHOD(Phalcon_Cli_Router, setDefaultAction) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Html\\Helper, Doctype, phalcon, html_helper_doctype, phalcon_html_helper_doctype_method_entry, 0); - - zend_declare_property_null(phalcon_html_helper_doctype_ce, SL("delimiter"), ZEND_ACC_PRIVATE); - zend_declare_property_null(phalcon_html_helper_doctype_ce, SL("flag"), ZEND_ACC_PRIVATE); - zephir_declare_class_constant_long(phalcon_html_helper_doctype_ce, SL("HTML32"), 1); - - zephir_declare_class_constant_long(phalcon_html_helper_doctype_ce, SL("HTML401_STRICT"), 2); - - zephir_declare_class_constant_long(phalcon_html_helper_doctype_ce, SL("HTML401_TRANSITIONAL"), 3); - - zephir_declare_class_constant_long(phalcon_html_helper_doctype_ce, SL("HTML401_FRAMESET"), 4); - - zephir_declare_class_constant_long(phalcon_html_helper_doctype_ce, SL("HTML5"), 5); - - zephir_declare_class_constant_long(phalcon_html_helper_doctype_ce, SL("XHTML10_STRICT"), 6); - - zephir_declare_class_constant_long(phalcon_html_helper_doctype_ce, SL("XHTML10_TRANSITIONAL"), 7); - - zephir_declare_class_constant_long(phalcon_html_helper_doctype_ce, SL("XHTML10_FRAMESET"), 8); - - zephir_declare_class_constant_long(phalcon_html_helper_doctype_ce, SL("XHTML11"), 9); - - zephir_declare_class_constant_long(phalcon_html_helper_doctype_ce, SL("XHTML20"), 10); - - zephir_declare_class_constant_long(phalcon_html_helper_doctype_ce, SL("XHTML5"), 11); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *actionName_param = NULL; + zval actionName; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&actionName); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(actionName) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &actionName_param); + zephir_get_strval(&actionName, actionName_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultAction"), &actionName); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Html_Helper_Doctype, __construct) +static PHP_METHOD(Phalcon_Cli_Router, setDefaultModule) { - zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *moduleName_param = NULL; + zval moduleName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&moduleName); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(moduleName) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, 5); - zephir_update_property_zval(this_ptr, ZEND_STRL("flag"), &_0); - ZEPHIR_INIT_VAR(&_1); - ZEPHIR_GET_CONSTANT(&_1, "PHP_EOL"); - zephir_update_property_zval(this_ptr, ZEND_STRL("delimiter"), &_1); - ZEPHIR_MM_RESTORE(); + zephir_fetch_params(1, 1, 0, &moduleName_param); + zephir_get_strval(&moduleName, moduleName_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultModule"), &moduleName); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Html_Helper_Doctype, __invoke) +static PHP_METHOD(Phalcon_Cli_Router, setDefaults) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval delimiter; - zval *flag_param = NULL, *delimiter_param = NULL, _0; - zend_long flag; + zval *defaults_param = NULL, module, task, action, params; + zval defaults; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&delimiter); - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(flag) - Z_PARAM_STR(delimiter) + ZVAL_UNDEF(&defaults); + ZVAL_UNDEF(&module); + ZVAL_UNDEF(&task); + ZVAL_UNDEF(&action); + ZVAL_UNDEF(¶ms); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(defaults) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &flag_param, &delimiter_param); - if (!flag_param) { - flag = 5; - } else { - } - if (!delimiter_param) { - ZEPHIR_INIT_VAR(&delimiter); - ZVAL_STRING(&delimiter, "\n"); - } else { - zephir_get_strval(&delimiter, delimiter_param); + zephir_fetch_params(1, 1, 0, &defaults_param); + ZEPHIR_OBS_COPY_OR_DUP(&defaults, defaults_param); + zephir_memory_observe(&module); + if (zephir_array_isset_string_fetch(&module, &defaults, SL("module"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultModule"), &module); + } + zephir_memory_observe(&task); + if (zephir_array_isset_string_fetch(&task, &defaults, SL("task"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultTask"), &task); + } + zephir_memory_observe(&action); + if (zephir_array_isset_string_fetch(&action, &defaults, SL("action"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultAction"), &action); + } + zephir_memory_observe(¶ms); + if (zephir_array_isset_string_fetch(¶ms, &defaults, SL("params"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultParams"), ¶ms); } - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, flag); - zephir_update_property_zval(this_ptr, ZEND_STRL("flag"), &_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("delimiter"), &delimiter); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Html_Helper_Doctype, __toString) +static PHP_METHOD(Phalcon_Cli_Router, setDefaultTask) { - zval _0, _18, _1$$3, _2$$4, _3$$4, _4$$5, _5$$5, _6$$6, _7$$6, _8$$7, _9$$7, _10$$8, _11$$8, _12$$9, _13$$9, _14$$10, _15$$10, _16$$11, _17$$11; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *taskName_param = NULL; + zval taskName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_18); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_6$$6); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_8$$7); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_10$$8); - ZVAL_UNDEF(&_11$$8); - ZVAL_UNDEF(&_12$$9); - ZVAL_UNDEF(&_13$$9); - ZVAL_UNDEF(&_14$$10); - ZVAL_UNDEF(&_15$$10); - ZVAL_UNDEF(&_16$$11); - ZVAL_UNDEF(&_17$$11); - zephir_read_property(&_0, this_ptr, ZEND_STRL("flag"), PH_NOISY_CC | PH_READONLY); - do { - if (ZEPHIR_IS_LONG(&_0, 1)) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CONCAT_SV(return_value, "", &_1$$3); - return; - } - if (ZEPHIR_IS_LONG(&_0, 2)) { - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_3$$4, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CONCAT_SVSV(return_value, "", &_3$$4); - return; - } - if (ZEPHIR_IS_LONG(&_0, 3)) { - zephir_read_property(&_4$$5, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_5$$5, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CONCAT_SVSV(return_value, "", &_5$$5); - return; - } - if (ZEPHIR_IS_LONG(&_0, 4)) { - zephir_read_property(&_6$$6, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_7$$6, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CONCAT_SVSV(return_value, "", &_7$$6); - return; - } - if (ZEPHIR_IS_LONG(&_0, 6)) { - zephir_read_property(&_8$$7, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_9$$7, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CONCAT_SVSV(return_value, "", &_9$$7); - return; - } - if (ZEPHIR_IS_LONG(&_0, 7)) { - zephir_read_property(&_10$$8, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_11$$8, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CONCAT_SVSV(return_value, "", &_11$$8); - return; + ZVAL_UNDEF(&taskName); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(taskName) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &taskName_param); + zephir_get_strval(&taskName, taskName_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultTask"), &taskName); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Cli_Router, wasMatched) +{ + + RETURN_MEMBER(getThis(), "wasMatched"); +} + +zend_object *zephir_init_properties_Phalcon_Cli_Router(zend_class_entry *class_type) +{ + zval _0, _2, _4, _6, _1$$3, _3$$4, _5$$5, _7$$6; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("routes"), &_1$$3); } - if (ZEPHIR_IS_LONG(&_0, 8)) { - zephir_read_property(&_12$$9, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_13$$9, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CONCAT_SVSV(return_value, "", &_13$$9); - return; + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_3$$4); } - if (ZEPHIR_IS_LONG(&_0, 9)) { - zephir_read_property(&_14$$10, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_15$$10, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CONCAT_SVSV(return_value, "", &_15$$10); - return; + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("matches"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("matches"), &_5$$5); } - if (ZEPHIR_IS_LONG(&_0, 10)) { - zephir_read_property(&_16$$11, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_17$$11, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CONCAT_SVSV(return_value, "", &_17$$11); - return; + zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("defaultParams"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_6) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$6); + array_init(&_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("defaultParams"), &_7$$6); } - } while(0); + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } +} - zephir_read_property(&_18, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CONCAT_SV(return_value, "", &_18); - return; + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Cli_RouterInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Cli, RouterInterface, phalcon, cli_routerinterface, phalcon_cli_routerinterface_method_entry); + + return SUCCESS; } +ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, add); +ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getActionName); +ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getMatchedRoute); +ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getMatches); +ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getModuleName); +ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getParams); +ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getParameters); +ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getRouteById); +ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getRouteByName); +ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getRoutes); +ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getTaskName); +ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, handle); +ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, setDefaultAction); +ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, setDefaultModule); +ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, setDefaults); +ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, setDefaultTask); +ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, wasMatched); @@ -121644,57 +122727,48 @@ static PHP_METHOD(Phalcon_Html_Helper_Doctype, __toString) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Element) +ZEPHIR_INIT_CLASS(Phalcon_Cli_Task) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper, Element, phalcon, html_helper_element, phalcon_html_helper_abstracthelper_ce, phalcon_html_helper_element_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli, Task, phalcon, cli_task, phalcon_di_injectable_ce, phalcon_cli_task_method_entry, 0); + zend_declare_property_null(phalcon_cli_task_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_cli_task_ce, 1, phalcon_cli_taskinterface_ce); + zend_class_implements(phalcon_cli_task_ce, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Helper_Element, __invoke) +static PHP_METHOD(Phalcon_Cli_Task, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool raw; - zval attributes; - zval *tag_param = NULL, *text_param = NULL, *attributes_param = NULL, *raw_param = NULL, _0; - zval tag, text; zval *this_ptr = getThis(); - - ZVAL_UNDEF(&tag); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(2, 4) - Z_PARAM_STR(tag) - Z_PARAM_STR(text) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) - Z_PARAM_BOOL(raw) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 2, &tag_param, &text_param, &attributes_param, &raw_param); - zephir_get_strval(&tag, tag_param); - zephir_get_strval(&text, text_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - } else { - zephir_get_arrval(&attributes, attributes_param); - } - if (!raw_param) { - raw = 0; - } else { - } - if (raw) { - ZVAL_BOOL(&_0, 1); - } else { - ZVAL_BOOL(&_0, 0); + + if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("onconstruct")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "onconstruct", NULL, 0); + zephir_check_call_status(); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "renderfullelement", NULL, 0, &tag, &text, &attributes, &_0); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Cli_Task, getEventsManager) +{ + + RETURN_MEMBER(getThis(), "eventsManager"); +} + +static PHP_METHOD(Phalcon_Cli_Task, setEventsManager) +{ + zval *eventsManager, eventsManager_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&eventsManager_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); + zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); } @@ -121707,52 +122781,13 @@ static PHP_METHOD(Phalcon_Html_Helper_Element, __invoke) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Form) +ZEPHIR_INIT_CLASS(Phalcon_Cli_TaskInterface) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper, Form, phalcon, html_helper_form, phalcon_html_helper_abstracthelper_ce, phalcon_html_helper_form_method_entry, 0); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Cli, TaskInterface, phalcon, cli_taskinterface, NULL); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Helper_Form, __invoke) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *attributes_param = NULL, overrides, _0, _1; - zval attributes; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&overrides); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &attributes_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - } else { - zephir_get_arrval(&attributes, attributes_param); - } - ZEPHIR_INIT_VAR(&overrides); - zephir_create_array(&overrides, 2, 0); - add_assoc_stringl_ex(&overrides, SL("method"), SL("post")); - add_assoc_stringl_ex(&overrides, SL("enctype"), SL("multipart/form-data")); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "orderattributes", NULL, 0, &overrides, &attributes); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&overrides, &_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "form"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "renderelement", NULL, 0, &_1, &overrides); - zephir_check_call_status(); - RETURN_MM(); -} - @@ -121763,53 +122798,28 @@ static PHP_METHOD(Phalcon_Html_Helper_Form, __invoke) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Img) +ZEPHIR_INIT_CLASS(Phalcon_Cli_Dispatcher_Exception) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper, Img, phalcon, html_helper_img, phalcon_html_helper_abstracthelper_ce, phalcon_html_helper_img_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli\\Dispatcher, Exception, phalcon, cli_dispatcher_exception, phalcon_dispatcher_exception_ce, NULL, 0); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Helper_Img, __invoke) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Cli_Router_Exception) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes; - zval *src_param = NULL, *attributes_param = NULL, overrides, _0; - zval src; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli\\Router, Exception, phalcon, cli_router_exception, zend_ce_exception, NULL, 0); - ZVAL_UNDEF(&src); - ZVAL_UNDEF(&overrides); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(src) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &src_param, &attributes_param); - zephir_get_strval(&src, src_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - } else { - zephir_get_arrval(&attributes, attributes_param); - } - ZEPHIR_INIT_VAR(&overrides); - zephir_create_array(&overrides, 1, 0); - zephir_array_update_string(&overrides, SL("src"), &src, PH_COPY | PH_SEPARATE); - zephir_array_unset_string(&attributes, SL("src"), PH_SEPARATE); - ZEPHIR_INIT_VAR(&_0); - zephir_fast_array_merge(&_0, &overrides, &attributes); - ZEPHIR_CPY_WRT(&overrides, &_0); - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, "img"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "selfclose", NULL, 0, &_0, &overrides); - zephir_check_call_status(); - RETURN_MM(); + return SUCCESS; } @@ -121822,343 +122832,828 @@ static PHP_METHOD(Phalcon_Html_Helper_Img, __invoke) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Label) +ZEPHIR_INIT_CLASS(Phalcon_Cli_Router_Route) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper, Label, phalcon, html_helper_label, phalcon_html_helper_abstracthelper_ce, phalcon_html_helper_label_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Cli\\Router, Route, phalcon, cli_router_route, phalcon_cli_router_route_method_entry, 0); + + zend_declare_property_null(phalcon_cli_router_route_ce, SL("beforeMatch"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_cli_router_route_ce, SL("compiledPattern"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_cli_router_route_ce, SL("converters"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_cli_router_route_ce, SL("delimiter"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_cli_router_route_ce, SL("delimiterPath"), " ", ZEND_ACC_PROTECTED|ZEND_ACC_STATIC); + zend_declare_property_string(phalcon_cli_router_route_ce, SL("description"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_cli_router_route_ce, SL("routeId"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_cli_router_route_ce, SL("name"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_cli_router_route_ce, SL("paths"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_cli_router_route_ce, SL("pattern"), "", ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_cli_router_route_ce, SL("uniqueId"), 0, ZEND_ACC_PROTECTED|ZEND_ACC_STATIC); + phalcon_cli_router_route_ce->create_object = zephir_init_properties_Phalcon_Cli_Router_Route; + zephir_declare_class_constant_string(phalcon_cli_router_route_ce, SL("DEFAULT_DELIMITER"), " "); + zend_class_implements(phalcon_cli_router_route_ce, 1, phalcon_cli_router_routeinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Helper_Label, __invoke) +static PHP_METHOD(Phalcon_Cli_Router_Route, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool raw; - zval attributes; - zval *label_param = NULL, *attributes_param = NULL, *raw_param = NULL, _0, _1; - zval label; + zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, routeId, uniqueId, _0, _1; + zval pattern, _2; zval *this_ptr = getThis(); - ZVAL_UNDEF(&label); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&routeId); + ZVAL_UNDEF(&uniqueId); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(label) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(pattern) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) - Z_PARAM_BOOL(raw) + Z_PARAM_ZVAL_OR_NULL(paths) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &label_param, &attributes_param, &raw_param); - zephir_get_strval(&label, label_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - } else { - zephir_get_arrval(&attributes, attributes_param); + zephir_fetch_params(1, 1, 1, &pattern_param, &paths); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); } - if (!raw_param) { - raw = 0; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "label"); - if (raw) { - ZVAL_BOOL(&_1, 1); + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - ZVAL_BOOL(&_1, 0); + ZEPHIR_INIT_VAR(&pattern); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "renderfullelement", NULL, 0, &_0, &label, &attributes, &_1); + if (!paths) { + paths = &paths_sub; + paths = &__$null; + } + zephir_memory_observe(&_0); + zephir_read_static_property_ce(&_0, phalcon_cli_router_route_ce, SL("delimiterPath"), PH_NOISY_CC); + zephir_update_property_zval(this_ptr, ZEND_STRL("delimiter"), &_0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "reconfigure", NULL, 0, &pattern, paths); zephir_check_call_status(); - RETURN_MM(); + zephir_memory_observe(&_1); + zephir_read_static_property_ce(&_1, phalcon_cli_router_route_ce, SL("uniqueId"), PH_NOISY_CC); + ZEPHIR_CPY_WRT(&uniqueId, &_1); + ZEPHIR_CPY_WRT(&routeId, &uniqueId); + zephir_cast_to_string(&_2, &routeId); + zephir_update_property_zval(this_ptr, ZEND_STRL("routeId"), &_2); + ZVAL_UNDEF(&_1); + ZVAL_LONG(&_1, (zephir_get_numberval(&uniqueId) + 1)); + zephir_update_static_property_ce(phalcon_cli_router_route_ce, ZEND_STRL("uniqueId"), &_1); + ZEPHIR_MM_RESTORE(); } +static PHP_METHOD(Phalcon_Cli_Router_Route, beforeMatch) +{ + zval *callback, callback_sub; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&callback_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(callback) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &callback); + zephir_update_property_zval(this_ptr, ZEND_STRL("beforeMatch"), callback); + RETURN_THISW(); +} - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Link) +static PHP_METHOD(Phalcon_Cli_Router_Route, compilePattern) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper, Link, phalcon, html_helper_link, phalcon_html_helper_style_ce, phalcon_html_helper_link_method_entry, 0); + zend_bool _20; + zval map; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *pattern_param = NULL, idPattern, _0$$3, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, _7$$3, _8$$3, _9$$3, _10$$3, _11$$3, _12$$3, _13$$3, _14$$3, _15$$3, _16$$3, _17$$3, _18$$3, _19$$3; + zval pattern; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&idPattern); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$3); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_11$$3); + ZVAL_UNDEF(&_12$$3); + ZVAL_UNDEF(&_13$$3); + ZVAL_UNDEF(&_14$$3); + ZVAL_UNDEF(&_15$$3); + ZVAL_UNDEF(&_16$$3); + ZVAL_UNDEF(&_17$$3); + ZVAL_UNDEF(&_18$$3); + ZVAL_UNDEF(&_19$$3); + ZVAL_UNDEF(&map); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(pattern) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &pattern_param); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); + } else { + ZEPHIR_INIT_VAR(&pattern); + } + if (zephir_memnstr_str(&pattern, SL(":"), "phalcon/Cli/Router/Route.zep", 121)) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&idPattern); + ZEPHIR_CONCAT_VS(&idPattern, &_0$$3, "([a-zA-Z0-9\\_\\-]+)"); + ZEPHIR_INIT_VAR(&map); + zephir_create_array(&map, 7, 0); + zephir_memory_observe(&_1$$3); + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC); + zephir_array_update_string(&map, SL(":delimiter"), &_1$$3, PH_COPY | PH_SEPARATE); + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_3$$3); + ZEPHIR_CONCAT_VS(&_3$$3, &_2$$3, ":module"); + zephir_array_update_zval(&map, &_3$$3, &idPattern, PH_COPY); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_5$$3); + ZEPHIR_CONCAT_VS(&_5$$3, &_4$$3, ":task"); + zephir_array_update_zval(&map, &_5$$3, &idPattern, PH_COPY); + zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_7$$3); + ZEPHIR_CONCAT_VS(&_7$$3, &_6$$3, ":namespace"); + zephir_array_update_zval(&map, &_7$$3, &idPattern, PH_COPY); + zephir_read_property(&_8$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_9$$3); + ZEPHIR_CONCAT_VS(&_9$$3, &_8$$3, ":action"); + zephir_array_update_zval(&map, &_9$$3, &idPattern, PH_COPY); + zephir_read_property(&_10$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_11$$3); + ZEPHIR_CONCAT_VS(&_11$$3, &_10$$3, ":params"); + zephir_read_property(&_12$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_13$$3); + ZEPHIR_CONCAT_SVS(&_13$$3, "(", &_12$$3, ".*)*"); + zephir_array_update_zval(&map, &_11$$3, &_13$$3, PH_COPY); + zephir_read_property(&_14$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_13$$3); + ZEPHIR_CONCAT_VS(&_13$$3, &_14$$3, ":int"); + zephir_read_property(&_15$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_16$$3); + ZEPHIR_CONCAT_VS(&_16$$3, &_15$$3, "([0-9]+)"); + zephir_array_update_zval(&map, &_13$$3, &_16$$3, PH_COPY); + ZEPHIR_INIT_VAR(&_17$$3); + ZEPHIR_INIT_VAR(&_18$$3); + zephir_array_keys(&_18$$3, &map); + ZEPHIR_CALL_FUNCTION(&_19$$3, "array_values", NULL, 14, &map); + zephir_check_call_status(); + zephir_fast_str_replace(&_17$$3, &_18$$3, &_19$$3, &pattern); + zephir_get_strval(&pattern, &_17$$3); + } + _20 = zephir_memnstr_str(&pattern, SL("("), "phalcon/Cli/Router/Route.zep", 146); + if (!(_20)) { + _20 = zephir_memnstr_str(&pattern, SL("["), "phalcon/Cli/Router/Route.zep", 146); + } + if (_20) { + ZEPHIR_CONCAT_SVS(return_value, "#^", &pattern, "$#"); + RETURN_MM(); + } + RETURN_CTOR(&pattern); } -static PHP_METHOD(Phalcon_Html_Helper_Link, add) +static PHP_METHOD(Phalcon_Cli_Router_Route, convert) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes, _0, _2; - zval *url_param = NULL, *attributes_param = NULL, _1, _3; - zval url; + zval *name_param = NULL, *converter, converter_sub; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&url); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(url) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&converter_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_ZVAL(converter) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &url_param, &attributes_param); - zephir_get_strval(&url, url_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); + zephir_fetch_params(1, 2, 0, &name_param, &converter); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - zephir_get_arrval(&attributes, attributes_param); + ZEPHIR_INIT_VAR(&name); } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 3, 0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "renderTag"); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 3, 0); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "gettag", NULL, 0); - zephir_check_call_status(); - zephir_array_fast_append(&_2, &_3); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "getattributes", NULL, 0, &url, &attributes); - zephir_check_call_status(); - zephir_array_fast_append(&_2, &_3); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "/"); - zephir_array_fast_append(&_2, &_1); - zephir_array_fast_append(&_0, &_2); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "indent", NULL, 0); - zephir_check_call_status(); - zephir_array_fast_append(&_0, &_3); - zephir_update_property_array_append(this_ptr, SL("store"), &_0); + zephir_update_property_array(this_ptr, SL("converters"), &name, converter); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Html_Helper_Link, getTag) +static PHP_METHOD(Phalcon_Cli_Router_Route, delimiter) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *delimiter_param = NULL; + zval delimiter; - RETURN_STRING("link"); + ZVAL_UNDEF(&delimiter); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(delimiter) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &delimiter_param); + if (!delimiter_param) { + ZEPHIR_INIT_VAR(&delimiter); + } else { + if (UNEXPECTED(Z_TYPE_P(delimiter_param) != IS_STRING && Z_TYPE_P(delimiter_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'delimiter' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(delimiter_param) == IS_STRING)) { + zephir_get_strval(&delimiter, delimiter_param); + } else { + ZEPHIR_INIT_VAR(&delimiter); + } + } + zephir_update_static_property_ce(phalcon_cli_router_route_ce, ZEND_STRL("delimiterPath"), &delimiter); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Helper_Link, getAttributes) +static PHP_METHOD(Phalcon_Cli_Router_Route, extractNamedParams) { + long _0, _5$$10, _26$$18; + zend_long cursor = 0, cursorVar = 0, marker = 0, bracketCount, parenthesesCount, foundPattern, intermediate, numberMatches; + zend_bool notValid = 0, _6$$11, _7$$11, _8$$11, _9$$11, _10$$11, _11$$11, _12$$11, _13$$11, _14$$11, _15$$11, _16$$11, _17$$11, _25$$17; + zval matches; + char ch = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval attributes, required; - zval *url_param = NULL, *attributes_param = NULL; - zval url; + zval *pattern_param = NULL, tmp, _1$$10, _2$$10, _3$$10, _18$$15, _19$$15, _20$$15, _22$$15, _23$$15, _28$$27, _29$$27; + zval pattern, route, item, variable, regexp, _4$$10, _21$$15, _24$$15, _27$$25, _30$$28; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&url); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&required); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(url) - Z_PARAM_ARRAY(attributes) + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&route); + ZVAL_UNDEF(&item); + ZVAL_UNDEF(&variable); + ZVAL_UNDEF(®exp); + ZVAL_UNDEF(&_4$$10); + ZVAL_UNDEF(&_21$$15); + ZVAL_UNDEF(&_24$$15); + ZVAL_UNDEF(&_27$$25); + ZVAL_UNDEF(&_30$$28); + ZVAL_UNDEF(&tmp); + ZVAL_UNDEF(&_1$$10); + ZVAL_UNDEF(&_2$$10); + ZVAL_UNDEF(&_3$$10); + ZVAL_UNDEF(&_18$$15); + ZVAL_UNDEF(&_19$$15); + ZVAL_UNDEF(&_20$$15); + ZVAL_UNDEF(&_22$$15); + ZVAL_UNDEF(&_23$$15); + ZVAL_UNDEF(&_28$$27); + ZVAL_UNDEF(&_29$$27); + ZVAL_UNDEF(&matches); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(pattern) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &url_param, &attributes_param); - zephir_get_strval(&url, url_param); - zephir_get_arrval(&attributes, attributes_param); - ZEPHIR_INIT_VAR(&required); - zephir_create_array(&required, 1, 0); - zephir_array_update_string(&required, SL("href"), &url, PH_COPY | PH_SEPARATE); - zephir_array_unset_string(&attributes, SL("href"), PH_SEPARATE); - zephir_fast_array_merge(return_value, &required, &attributes); + zephir_fetch_params(1, 1, 0, &pattern_param); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); + } else { + ZEPHIR_INIT_VAR(&pattern); + } + bracketCount = 0; + parenthesesCount = 0; + foundPattern = 0; + intermediate = 0; + numberMatches = 0; + if (zephir_fast_strlen_ev(&pattern) == 0) { + RETURN_MM_BOOL(0); + } + ZEPHIR_INIT_VAR(&matches); + array_init(&matches); + ZEPHIR_INIT_VAR(&route); + for (_0 = 0; _0 < Z_STRLEN_P(&pattern); _0++) { + cursor = _0; + ch = ZEPHIR_STRING_OFFSET(&pattern, _0); + if (parenthesesCount == 0) { + if (ch == '{') { + if (bracketCount == 0) { + marker = (cursor + 1); + intermediate = 0; + notValid = 0; + } + bracketCount++; + } else if (ch == '}') { + bracketCount--; + if (intermediate > 0) { + if (bracketCount == 0) { + numberMatches++; + ZEPHIR_INIT_NVAR(&variable); + ZEPHIR_INIT_NVAR(®exp); + ZVAL_LONG(&_1$$10, marker); + ZVAL_LONG(&_2$$10, (cursor - marker)); + ZEPHIR_INIT_NVAR(&_3$$10); + zephir_substr(&_3$$10, &pattern, zephir_get_intval(&_1$$10), zephir_get_intval(&_2$$10), 0); + zephir_cast_to_string(&_4$$10, &_3$$10); + ZEPHIR_CPY_WRT(&item, &_4$$10); + for (_5$$10 = 0; _5$$10 < Z_STRLEN_P(&item); _5$$10++) { + cursorVar = _5$$10; + ch = ZEPHIR_STRING_OFFSET(&item, _5$$10); + if (ch == '\0') { + break; + } + _6$$11 = cursorVar == 0; + if (_6$$11) { + _7$$11 = ch >= 'a'; + if (_7$$11) { + _7$$11 = ch <= 'z'; + } + _8$$11 = _7$$11; + if (!(_8$$11)) { + _9$$11 = ch >= 'A'; + if (_9$$11) { + _9$$11 = ch <= 'Z'; + } + _8$$11 = _9$$11; + } + _6$$11 = !(_8$$11); + } + if (_6$$11) { + notValid = 1; + break; + } + _10$$11 = ch >= 'a'; + if (_10$$11) { + _10$$11 = ch <= 'z'; + } + _11$$11 = _10$$11; + if (!(_11$$11)) { + _12$$11 = ch >= 'A'; + if (_12$$11) { + _12$$11 = ch <= 'Z'; + } + _11$$11 = _12$$11; + } + _13$$11 = _11$$11; + if (!(_13$$11)) { + _14$$11 = ch >= '0'; + if (_14$$11) { + _14$$11 = ch <= '9'; + } + _13$$11 = _14$$11; + } + _15$$11 = _13$$11; + if (!(_15$$11)) { + _15$$11 = ch == '-'; + } + _16$$11 = _15$$11; + if (!(_16$$11)) { + _16$$11 = ch == '_'; + } + _17$$11 = _16$$11; + if (!(_17$$11)) { + _17$$11 = ch == ':'; + } + if (_17$$11) { + if (ch == ':') { + ZVAL_LONG(&_18$$15, 0); + ZVAL_LONG(&_19$$15, cursorVar); + ZEPHIR_INIT_NVAR(&_20$$15); + zephir_substr(&_20$$15, &item, 0 , zephir_get_intval(&_19$$15), 0); + zephir_cast_to_string(&_21$$15, &_20$$15); + ZEPHIR_CPY_WRT(&variable, &_21$$15); + ZVAL_LONG(&_22$$15, (cursorVar + 1)); + ZEPHIR_INIT_NVAR(&_23$$15); + zephir_substr(&_23$$15, &item, zephir_get_intval(&_22$$15), 0, ZEPHIR_SUBSTR_NO_LENGTH); + zephir_cast_to_string(&_24$$15, &_23$$15); + ZEPHIR_CPY_WRT(®exp, &_24$$15); + break; + } + } else { + notValid = 1; + break; + } + } + if (!(notValid)) { + ZEPHIR_INIT_NVAR(&tmp); + ZVAL_LONG(&tmp, numberMatches); + _25$$17 = zephir_is_true(&variable); + if (_25$$17) { + _25$$17 = zephir_is_true(®exp); + } + if (_25$$17) { + foundPattern = 0; + for (_26$$18 = 0; _26$$18 < Z_STRLEN_P(®exp); _26$$18++) { + ch = ZEPHIR_STRING_OFFSET(®exp, _26$$18); + if (ch == '\0') { + break; + } + if (!(foundPattern)) { + if (ch == '(') { + foundPattern = 1; + } + } else { + if (ch == ')') { + foundPattern = 2; + break; + } + } + } + if (foundPattern != 2) { + ZEPHIR_INIT_NVAR(&_27$$25); + ZEPHIR_CONCAT_SVS(&_27$$25, "(", ®exp, ")"); + zephir_concat_self(&route, &_27$$25); + } else { + zephir_concat_self(&route, ®exp); + } + zephir_array_update_zval(&matches, &variable, &tmp, PH_COPY | PH_SEPARATE); + } else { + zephir_read_property(&_28$$27, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_29$$27); + ZEPHIR_CONCAT_SVS(&_29$$27, "([^", &_28$$27, "]*)"); + zephir_concat_self(&route, &_29$$27); + zephir_array_update_zval(&matches, &item, &tmp, PH_COPY | PH_SEPARATE); + } + } else { + ZEPHIR_INIT_NVAR(&_30$$28); + ZEPHIR_CONCAT_SVS(&_30$$28, "{", &item, "}"); + zephir_concat_self(&route, &_30$$28); + } + continue; + } + } + } + } + if (bracketCount == 0) { + if (ch == '(') { + parenthesesCount++; + } else if (ch == ')') { + parenthesesCount--; + if (parenthesesCount == 0) { + numberMatches++; + } + } + } + if (bracketCount > 0) { + intermediate++; + } else { + zephir_concat_self_char(&route, ch); + } + } + zephir_create_array(return_value, 2, 0); + zephir_array_fast_append(return_value, &route); + zephir_array_fast_append(return_value, &matches); RETURN_MM(); } +static PHP_METHOD(Phalcon_Cli_Router_Route, getBeforeMatch) +{ + + RETURN_MEMBER(getThis(), "beforeMatch"); +} + +static PHP_METHOD(Phalcon_Cli_Router_Route, getCompiledPattern) +{ + RETURN_MEMBER(getThis(), "compiledPattern"); +} +static PHP_METHOD(Phalcon_Cli_Router_Route, getConverters) +{ -#ifdef HAVE_CONFIG_H -#endif + RETURN_MEMBER(getThis(), "converters"); +} +static PHP_METHOD(Phalcon_Cli_Router_Route, getDelimiter) +{ + zval _0; + ZVAL_UNDEF(&_0); + zephir_read_static_property_ce(&_0, phalcon_cli_router_route_ce, SL("delimiterPath"), PH_NOISY_CC | PH_READONLY); + RETURN_CTORW(&_0); +} +static PHP_METHOD(Phalcon_Cli_Router_Route, getDescription) +{ + RETURN_MEMBER(getThis(), "description"); +} -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Meta) +static PHP_METHOD(Phalcon_Cli_Router_Route, getName) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper, Meta, phalcon, html_helper_meta, phalcon_html_helper_abstractseries_ce, phalcon_html_helper_meta_method_entry, 0); - return SUCCESS; + RETURN_MEMBER(getThis(), "name"); } -static PHP_METHOD(Phalcon_Html_Helper_Meta, add) +static PHP_METHOD(Phalcon_Cli_Router_Route, getPaths) +{ + + RETURN_MEMBER(getThis(), "paths"); +} + +static PHP_METHOD(Phalcon_Cli_Router_Route, getPattern) +{ + + RETURN_MEMBER(getThis(), "pattern"); +} + +static PHP_METHOD(Phalcon_Cli_Router_Route, getReversedPaths) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *attributes_param = NULL, _1, _3; - zval attributes, _0, _2; zval *this_ptr = getThis(); - ZVAL_UNDEF(&attributes); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(0, 1) + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("paths"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_FUNCTION("array_flip", NULL, 100, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Cli_Router_Route, getRouteId) +{ + + RETURN_MEMBER(getThis(), "routeId"); +} + +static PHP_METHOD(Phalcon_Cli_Router_Route, reConfigure) +{ + zend_bool _1$$10; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, _0$$4; + zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, moduleName, taskName, actionName, parts, routePaths, realClassName, namespaceName, pcrePattern, compiledPattern, extracted, _2$$9, _3$$18, _4$$18, _5$$21, _6$$21, _7$$21; + zval pattern; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&paths_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&moduleName); + ZVAL_UNDEF(&taskName); + ZVAL_UNDEF(&actionName); + ZVAL_UNDEF(&parts); + ZVAL_UNDEF(&routePaths); + ZVAL_UNDEF(&realClassName); + ZVAL_UNDEF(&namespaceName); + ZVAL_UNDEF(&pcrePattern); + ZVAL_UNDEF(&compiledPattern); + ZVAL_UNDEF(&extracted); + ZVAL_UNDEF(&_2$$9); + ZVAL_UNDEF(&_3$$18); + ZVAL_UNDEF(&_4$$18); + ZVAL_UNDEF(&_5$$21); + ZVAL_UNDEF(&_6$$21); + ZVAL_UNDEF(&_7$$21); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(pattern) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) + Z_PARAM_ZVAL_OR_NULL(paths) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &attributes_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); + zephir_fetch_params(1, 1, 1, &pattern_param, &paths); + if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { + zephir_get_strval(&pattern, pattern_param); } else { - zephir_get_arrval(&attributes, attributes_param); + ZEPHIR_INIT_VAR(&pattern); } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 3, 0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "renderTag"); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 2, 0); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "gettag", NULL, 0); - zephir_check_call_status(); - zephir_array_fast_append(&_2, &_3); - zephir_array_fast_append(&_2, &attributes); - zephir_array_fast_append(&_0, &_2); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "indent", NULL, 0); - zephir_check_call_status(); - zephir_array_fast_append(&_0, &_3); - zephir_update_property_array_append(this_ptr, SL("store"), &_0); - RETURN_THIS(); + if (!paths) { + paths = &paths_sub; + ZEPHIR_CPY_WRT(paths, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(paths); + } + if (Z_TYPE_P(paths) == IS_NULL) { + ZEPHIR_INIT_NVAR(paths); + array_init(paths); + } + if (Z_TYPE_P(paths) == IS_STRING) { + ZEPHIR_INIT_VAR(&moduleName); + ZVAL_NULL(&moduleName); + ZEPHIR_INIT_VAR(&taskName); + ZVAL_NULL(&taskName); + ZEPHIR_INIT_VAR(&actionName); + ZVAL_NULL(&actionName); + ZEPHIR_INIT_VAR(&parts); + zephir_fast_explode_str(&parts, SL("::"), paths, LONG_MAX); + do { + _0$$4 = zephir_fast_count_int(&parts); + if (_0$$4 == 3) { + ZEPHIR_OBS_NVAR(&moduleName); + zephir_array_fetch_long(&moduleName, &parts, 0, PH_NOISY, "phalcon/Cli/Router/Route.zep", 417); + ZEPHIR_OBS_NVAR(&taskName); + zephir_array_fetch_long(&taskName, &parts, 1, PH_NOISY, "phalcon/Cli/Router/Route.zep", 418); + ZEPHIR_OBS_NVAR(&actionName); + zephir_array_fetch_long(&actionName, &parts, 2, PH_NOISY, "phalcon/Cli/Router/Route.zep", 419); + break; + } + if (_0$$4 == 2) { + ZEPHIR_OBS_NVAR(&taskName); + zephir_array_fetch_long(&taskName, &parts, 0, PH_NOISY, "phalcon/Cli/Router/Route.zep", 423); + ZEPHIR_OBS_NVAR(&actionName); + zephir_array_fetch_long(&actionName, &parts, 1, PH_NOISY, "phalcon/Cli/Router/Route.zep", 424); + break; + } + if (_0$$4 == 1) { + ZEPHIR_OBS_NVAR(&taskName); + zephir_array_fetch_long(&taskName, &parts, 0, PH_NOISY, "phalcon/Cli/Router/Route.zep", 428); + break; + } + } while(0); + + ZEPHIR_INIT_VAR(&routePaths); + array_init(&routePaths); + if (Z_TYPE_P(&moduleName) != IS_NULL) { + zephir_array_update_string(&routePaths, SL("module"), &moduleName, PH_COPY | PH_SEPARATE); + } + if (Z_TYPE_P(&taskName) != IS_NULL) { + if (zephir_memnstr_str(&taskName, SL("\\"), "phalcon/Cli/Router/Route.zep", 442)) { + ZEPHIR_INIT_VAR(&realClassName); + zephir_get_class_ns(&realClassName, &taskName, 0); + ZEPHIR_INIT_VAR(&namespaceName); + zephir_get_ns_class(&namespaceName, &taskName, 0); + _1$$10 = Z_TYPE_P(&namespaceName) == IS_NULL; + if (!(_1$$10)) { + _1$$10 = Z_TYPE_P(&realClassName) == IS_NULL; + } + if (UNEXPECTED(_1$$10)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_router_exception_ce, "The route contains invalid paths", "phalcon/Cli/Router/Route.zep", 452); + return; + } + if (zephir_is_true(&namespaceName)) { + zephir_array_update_string(&routePaths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE); + } + } else { + ZEPHIR_CPY_WRT(&realClassName, &taskName); + } + ZEPHIR_INIT_VAR(&_2$$9); + zephir_uncamelize(&_2$$9, &realClassName, NULL ); + zephir_array_update_string(&routePaths, SL("task"), &_2$$9, PH_COPY | PH_SEPARATE); + } + if (Z_TYPE_P(&actionName) != IS_NULL) { + zephir_array_update_string(&routePaths, SL("action"), &actionName, PH_COPY | PH_SEPARATE); + } + } else { + ZEPHIR_CPY_WRT(&routePaths, paths); + } + if (UNEXPECTED(Z_TYPE_P(&routePaths) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_router_exception_ce, "The route contains invalid paths", "phalcon/Cli/Router/Route.zep", 476); + return; + } + if (!(zephir_start_with_str(&pattern, SL("#")))) { + if (zephir_memnstr_str(&pattern, SL("{"), "phalcon/Cli/Router/Route.zep", 484)) { + ZEPHIR_CALL_METHOD(&extracted, this_ptr, "extractnamedparams", NULL, 0, &pattern); + zephir_check_call_status(); + zephir_memory_observe(&pcrePattern); + zephir_array_fetch_long(&pcrePattern, &extracted, 0, PH_NOISY, "phalcon/Cli/Router/Route.zep", 489); + ZEPHIR_INIT_VAR(&_3$$18); + zephir_array_fetch_long(&_4$$18, &extracted, 1, PH_NOISY | PH_READONLY, "phalcon/Cli/Router/Route.zep", 490); + zephir_fast_array_merge(&_3$$18, &routePaths, &_4$$18); + ZEPHIR_CPY_WRT(&routePaths, &_3$$18); + } else { + ZEPHIR_CPY_WRT(&pcrePattern, &pattern); + } + ZEPHIR_CALL_METHOD(&compiledPattern, this_ptr, "compilepattern", NULL, 0, &pcrePattern); + zephir_check_call_status(); + } else { + if (zephir_memnstr_str(&pattern, SL(":delimiter"), "phalcon/Cli/Router/Route.zep", 501)) { + ZEPHIR_INIT_VAR(&_5$$21); + zephir_read_property(&_6$$21, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_7$$21); + ZVAL_STRING(&_7$$21, ":delimiter"); + zephir_fast_str_replace(&_5$$21, &_7$$21, &_6$$21, &pattern); + zephir_get_strval(&pattern, &_5$$21); + } + ZEPHIR_CPY_WRT(&compiledPattern, &pattern); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("pattern"), &pattern); + zephir_update_property_zval(this_ptr, ZEND_STRL("compiledPattern"), &compiledPattern); + zephir_update_property_zval(this_ptr, ZEND_STRL("paths"), &routePaths); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Helper_Meta, addHttp) +static PHP_METHOD(Phalcon_Cli_Router_Route, reset) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *httpEquiv_param = NULL, *content_param = NULL, _0; - zval httpEquiv, content; - zval *this_ptr = getThis(); + zval _0; - ZVAL_UNDEF(&httpEquiv); - ZVAL_UNDEF(&content); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(httpEquiv) - Z_PARAM_STR(content) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &httpEquiv_param, &content_param); - zephir_get_strval(&httpEquiv, httpEquiv_param); - zephir_get_strval(&content, content_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "http-equiv"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addelement", NULL, 329, &_0, &httpEquiv, &content); - zephir_check_call_status(); - RETURN_MM(); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, 0); + zephir_update_static_property_ce(phalcon_cli_router_route_ce, ZEND_STRL("uniqueId"), &_0); } -static PHP_METHOD(Phalcon_Html_Helper_Meta, addName) +static PHP_METHOD(Phalcon_Cli_Router_Route, setDescription) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, *content_param = NULL, _0; - zval name, content; + zval *description_param = NULL; + zval description; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&content); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_STR(content) + ZVAL_UNDEF(&description); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(description) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &content_param); - zephir_get_strval(&name, name_param); - zephir_get_strval(&content, content_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "name"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addelement", NULL, 329, &_0, &name, &content); - zephir_check_call_status(); + zephir_fetch_params(1, 1, 0, &description_param); + if (UNEXPECTED(Z_TYPE_P(description_param) != IS_STRING && Z_TYPE_P(description_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'description' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(description_param) == IS_STRING)) { + zephir_get_strval(&description, description_param); + } else { + ZEPHIR_INIT_VAR(&description); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("description"), &description); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Html_Helper_Meta, addProperty) +static PHP_METHOD(Phalcon_Cli_Router_Route, setName) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, *content_param = NULL, _0; - zval name, content; + zval *name_param = NULL; + zval name; zval *this_ptr = getThis(); ZVAL_UNDEF(&name); - ZVAL_UNDEF(&content); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) + ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(name) - Z_PARAM_STR(content) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &content_param); - zephir_get_strval(&name, name_param); - zephir_get_strval(&content, content_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "property"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "addelement", NULL, 329, &_0, &name, &content); - zephir_check_call_status(); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Html_Helper_Meta, getTag) -{ - - RETURN_STRING("meta"); -} - -static PHP_METHOD(Phalcon_Html_Helper_Meta, addElement) +zend_object *zephir_init_properties_Phalcon_Cli_Router_Route(zend_class_entry *class_type) { - zval attributes; + zval _0, _2, _1$$3, _3$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *element_param = NULL, *value_param = NULL, *content_param = NULL; - zval element, value, content; - zval *this_ptr = getThis(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&content); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_STR(element) - Z_PARAM_STR(value) - Z_PARAM_STR(content) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &element_param, &value_param, &content_param); - zephir_get_strval(&element, element_param); - zephir_get_strval(&value, value_param); - zephir_get_strval(&content, content_param); - ZEPHIR_INIT_VAR(&attributes); - zephir_create_array(&attributes, 2, 0); - zephir_array_update_zval(&attributes, &element, &value, PH_COPY); - zephir_array_update_string(&attributes, SL("content"), &content, PH_COPY | PH_SEPARATE); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "add", NULL, 0, &attributes); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("paths"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("paths"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("converters"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("converters"), &_3$$4); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } } @@ -122171,79 +123666,27 @@ static PHP_METHOD(Phalcon_Html_Helper_Meta, addElement) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Ol) +ZEPHIR_INIT_CLASS(Phalcon_Cli_Router_RouteInterface) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper, Ol, phalcon, html_helper_ol, phalcon_html_helper_abstractlist_ce, phalcon_html_helper_ol_method_entry, 0); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Cli\\Router, RouteInterface, phalcon, cli_router_routeinterface, phalcon_cli_router_routeinterface_method_entry); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Helper_Ol, add) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool raw; - zval attributes, _0, _2; - zval *text_param = NULL, *attributes_param = NULL, *raw_param = NULL, _1, _3, _4; - zval text; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(text) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) - Z_PARAM_BOOL(raw) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &text_param, &attributes_param, &raw_param); - zephir_get_strval(&text, text_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - } else { - zephir_get_arrval(&attributes, attributes_param); - } - if (!raw_param) { - raw = 0; - } else { - } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 3, 0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "renderFullElement"); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 4, 0); - zephir_memory_observe(&_3); - zephir_read_property(&_3, this_ptr, ZEND_STRL("elementTag"), PH_NOISY_CC); - zephir_array_fast_append(&_2, &_3); - zephir_array_fast_append(&_2, &text); - zephir_array_fast_append(&_2, &attributes); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_BOOL(&_1, raw); - zephir_array_fast_append(&_2, &_1); - zephir_array_fast_append(&_0, &_2); - ZEPHIR_CALL_METHOD(&_4, this_ptr, "indent", NULL, 0); - zephir_check_call_status(); - zephir_array_fast_append(&_0, &_4); - zephir_update_property_array_append(this_ptr, SL("store"), &_0); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Html_Helper_Ol, getTag) -{ - - RETURN_STRING("ol"); -} - +ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, compilePattern); +ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, delimiter); +ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, getCompiledPattern); +ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, getDelimiter); +ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, getDescription); +ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, getName); +ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, getPaths); +ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, getPattern); +ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, getReversedPaths); +ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, getRouteId); +ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, reConfigure); +ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, reset); +ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, setDescription); +ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, setName); @@ -122254,101 +123697,13 @@ static PHP_METHOD(Phalcon_Html_Helper_Ol, getTag) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Script) +ZEPHIR_INIT_CLASS(Phalcon_Cli_Console_Exception) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper, Script, phalcon, html_helper_script, phalcon_html_helper_abstractseries_ce, phalcon_html_helper_script_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli\\Console, Exception, phalcon, cli_console_exception, phalcon_application_exception_ce, NULL, 0); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Helper_Script, add) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes, _0, _2; - zval *url_param = NULL, *attributes_param = NULL, _1, _3; - zval url; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&url); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(url) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &url_param, &attributes_param); - zephir_get_strval(&url, url_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - } else { - zephir_get_arrval(&attributes, attributes_param); - } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 3, 0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "renderFullElement"); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 3, 0); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "gettag", NULL, 0); - zephir_check_call_status(); - zephir_array_fast_append(&_2, &_3); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, ""); - zephir_array_fast_append(&_2, &_1); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "getattributes", NULL, 0, &url, &attributes); - zephir_check_call_status(); - zephir_array_fast_append(&_2, &_3); - zephir_array_fast_append(&_0, &_2); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "indent", NULL, 0); - zephir_check_call_status(); - zephir_array_fast_append(&_0, &_3); - zephir_update_property_array_append(this_ptr, SL("store"), &_0); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Html_Helper_Script, getAttributes) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval attributes, required; - zval *url_param = NULL, *attributes_param = NULL; - zval url; - - ZVAL_UNDEF(&url); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&required); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(url) - Z_PARAM_ARRAY(attributes) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &url_param, &attributes_param); - zephir_get_strval(&url, url_param); - zephir_get_arrval(&attributes, attributes_param); - ZEPHIR_INIT_VAR(&required); - zephir_create_array(&required, 2, 0); - zephir_array_update_string(&required, SL("src"), &url, PH_COPY | PH_SEPARATE); - add_assoc_stringl_ex(&required, SL("type"), SL("application/javascript")); - zephir_array_unset_string(&attributes, SL("src"), PH_SEPARATE); - zephir_fast_array_merge(return_value, &required, &attributes); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Html_Helper_Script, getTag) -{ - - RETURN_STRING("script"); -} - @@ -122359,145 +123714,124 @@ static PHP_METHOD(Phalcon_Html_Helper_Script, getTag) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Style) +ZEPHIR_INIT_CLASS(Phalcon_Factory_AbstractConfigFactory) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper, Style, phalcon, html_helper_style, phalcon_html_helper_abstractseries_ce, phalcon_html_helper_style_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Factory, AbstractConfigFactory, phalcon, factory_abstractconfigfactory, phalcon_factory_abstractconfigfactory_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zend_declare_property_bool(phalcon_html_helper_style_ce, SL("isStyle"), 0, ZEND_ACC_PRIVATE); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Helper_Style, add) +static PHP_METHOD(Phalcon_Factory_AbstractConfigFactory, checkConfig) { + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes, _0, _2; - zval *url_param = NULL, *attributes_param = NULL, _1, _3; - zval url; + zval *config = NULL, config_sub, _1$$3, _2$$4, _3$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&url); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(url) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) + ZVAL_UNDEF(&config_sub); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(config) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &url_param, &attributes_param); - zephir_get_strval(&url, url_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - } else { - zephir_get_arrval(&attributes, attributes_param); + zephir_fetch_params(1, 1, 0, &config); + ZEPHIR_SEPARATE_PARAM(config); + _0 = Z_TYPE_P(config) == IS_OBJECT; + if (_0) { + _0 = zephir_instance_of_ev(config, phalcon_config_configinterface_ce); } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 3, 0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "renderTag"); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 3, 0); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "gettag", NULL, 0); - zephir_check_call_status(); - zephir_array_fast_append(&_2, &_3); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "getattributes", NULL, 0, &url, &attributes); - zephir_check_call_status(); - zephir_array_fast_append(&_2, &_3); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "/"); - zephir_array_fast_append(&_2, &_1); - zephir_array_fast_append(&_0, &_2); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "indent", NULL, 0); - zephir_check_call_status(); - zephir_array_fast_append(&_0, &_3); - zephir_update_property_array_append(this_ptr, SL("store"), &_0); - RETURN_THIS(); + if (_0) { + ZEPHIR_CALL_METHOD(&_1$$3, config, "toarray", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(config, &_1$$3); + } + if (UNEXPECTED(Z_TYPE_P(config) != IS_ARRAY)) { + ZEPHIR_INIT_VAR(&_3$$4); + ZVAL_STRING(&_3$$4, "Config must be array or Phalcon\\Config\\Config object"); + ZEPHIR_CALL_METHOD(&_2$$4, this_ptr, "getexception", NULL, 0, &_3$$4); + zephir_check_call_status(); + zephir_throw_exception_debug(&_2$$4, "phalcon/Factory/AbstractConfigFactory.zep", 29); + ZEPHIR_MM_RESTORE(); + return; + } + RETVAL_ZVAL(config, 1, 0); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Html_Helper_Style, setStyle) +static PHP_METHOD(Phalcon_Factory_AbstractConfigFactory, checkConfigElement) { - zval *flag_param = NULL, __$true, __$false; - zend_bool flag; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval element, _1$$3; + zval *config_param = NULL, *element_param = NULL, _0$$3; + zval config; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(flag) + ZVAL_UNDEF(&config); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ARRAY(config) + Z_PARAM_STR(element) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &flag_param); - if (flag) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isStyle"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("isStyle"), &__$false); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &config_param, &element_param); + zephir_get_arrval(&config, config_param); + zephir_get_strval(&element, element_param); + if (UNEXPECTED(!(zephir_array_isset(&config, &element)))) { + ZEPHIR_INIT_VAR(&_1$$3); + ZEPHIR_CONCAT_SVS(&_1$$3, "You must provide '", &element, "' option in factory config parameter."); + ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "getexception", NULL, 0, &_1$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_0$$3, "phalcon/Factory/AbstractConfigFactory.zep", 43); + ZEPHIR_MM_RESTORE(); + return; } - RETURN_THISW(); + RETURN_CTOR(&config); } -static PHP_METHOD(Phalcon_Html_Helper_Style, getAttributes) +static PHP_METHOD(Phalcon_Factory_AbstractConfigFactory, getException) { + zend_class_entry *_1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval attributes, required; - zval *url_param = NULL, *attributes_param = NULL, _0; - zval url; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *message_param = NULL, exception, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&url); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&exception); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&required); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(url) - Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(message) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &url_param, &attributes_param); - zephir_get_strval(&url, url_param); - zephir_get_arrval(&attributes, attributes_param); - ZEPHIR_INIT_VAR(&required); - zephir_create_array(&required, 4, 0); - add_assoc_stringl_ex(&required, SL("rel"), SL("stylesheet")); - zephir_array_update_string(&required, SL("href"), &url, PH_COPY | PH_SEPARATE); - add_assoc_stringl_ex(&required, SL("type"), SL("text/css")); - add_assoc_stringl_ex(&required, SL("media"), SL("screen")); - zephir_read_property(&_0, this_ptr, ZEND_STRL("isStyle"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - zephir_array_unset_string(&required, SL("rel"), PH_SEPARATE); + zephir_fetch_params(1, 1, 0, &message_param); + zephir_get_strval(&message, message_param); + ZEPHIR_CALL_METHOD(&exception, this_ptr, "getexceptionclass", NULL, 0); + zephir_check_call_status(); + zephir_fetch_safe_class(&_0, &exception); + _1 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_0), Z_STRLEN_P(&_0), ZEND_FETCH_CLASS_AUTO); + if(!_1) { + RETURN_MM_NULL(); } - zephir_array_unset_string(&attributes, SL("href"), PH_SEPARATE); - zephir_fast_array_merge(return_value, &required, &attributes); + object_init_ex(return_value, _1); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0, &message); + zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Html_Helper_Style, getTag) +static PHP_METHOD(Phalcon_Factory_AbstractConfigFactory, getExceptionClass) { - zval _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_INIT_VAR(&_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("isStyle"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_1)) { - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, "style"); - } else { - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, "link"); - } - RETURN_CCTOR(&_0); + RETURN_STRING("Exception"); } @@ -122510,287 +123844,145 @@ static PHP_METHOD(Phalcon_Html_Helper_Style, getTag) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Title) +ZEPHIR_INIT_CLASS(Phalcon_Factory_AbstractFactory) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper, Title, phalcon, html_helper_title, phalcon_html_helper_abstracthelper_ce, phalcon_html_helper_title_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Factory, AbstractFactory, phalcon, factory_abstractfactory, phalcon_factory_abstractconfigfactory_ce, phalcon_factory_abstractfactory_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zend_declare_property_null(phalcon_html_helper_title_ce, SL("append"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_html_helper_title_ce, SL("prepend"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_html_helper_title_ce, SL("title"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_html_helper_title_ce, SL("separator"), "", ZEND_ACC_PROTECTED); - phalcon_html_helper_title_ce->create_object = zephir_init_properties_Phalcon_Html_Helper_Title; + zend_declare_property_null(phalcon_factory_abstractfactory_ce, SL("mapper"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_factory_abstractfactory_ce, SL("services"), ZEND_ACC_PROTECTED); + phalcon_factory_abstractfactory_ce->create_object = zephir_init_properties_Phalcon_Factory_AbstractFactory; return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Helper_Title, __invoke) +static PHP_METHOD(Phalcon_Factory_AbstractFactory, getServices) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *indent_param = NULL, *delimiter_param = NULL, _0; - zval indent, delimiter; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&indent); - ZVAL_UNDEF(&delimiter); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_STR(indent) - Z_PARAM_STR_OR_NULL(delimiter) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &indent_param, &delimiter_param); - if (!indent_param) { - ZEPHIR_INIT_VAR(&indent); - ZVAL_STRING(&indent, " "); - } else { - zephir_get_strval(&indent, indent_param); - } - if (!delimiter_param) { - ZEPHIR_INIT_VAR(&delimiter); - } else { - zephir_get_strval(&delimiter, delimiter_param); - } - ZEPHIR_INIT_VAR(&_0); - if (Z_TYPE_P(&delimiter) == IS_NULL) { - ZEPHIR_INIT_NVAR(&_0); - ZEPHIR_GET_CONSTANT(&_0, "PHP_EOL"); - } else { - ZEPHIR_CPY_WRT(&_0, &delimiter); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("delimiter"), &_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("indent"), &indent); - RETURN_THIS(); } -static PHP_METHOD(Phalcon_Html_Helper_Title, __toString) +static PHP_METHOD(Phalcon_Factory_AbstractFactory, getService) { - zval _1; - zval items, _0, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, _0, _3, _4, _1$$3; + zval name, _2$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&items); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("prepend"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_create_array(&_1, 1, 0); - zephir_memory_observe(&_2); - zephir_read_property(&_2, this_ptr, ZEND_STRL("title"), PH_NOISY_CC); - zephir_array_fast_append(&_1, &_2); - zephir_read_property(&_3, this_ptr, ZEND_STRL("append"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&items, "array_merge", NULL, 330, &_0, &_1, &_3); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_4); - array_init(&_4); - zephir_update_property_zval(this_ptr, ZEND_STRL("append"), &_4); - ZEPHIR_INIT_VAR(&_5); - array_init(&_5); - zephir_update_property_zval(this_ptr, ZEND_STRL("prepend"), &_5); - ZEPHIR_INIT_VAR(&_6); - ZEPHIR_INIT_NVAR(&_6); - ZVAL_STRING(&_6, ""); - zephir_update_property_zval(this_ptr, ZEND_STRL("title"), &_6); - zephir_read_property(&_7, this_ptr, ZEND_STRL("indent"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_6); - zephir_read_property(&_9, this_ptr, ZEND_STRL("separator"), PH_NOISY_CC | PH_READONLY); - zephir_fast_join(&_6, &_9, &items); - ZEPHIR_INIT_VAR(&_10); - array_init(&_10); - ZEPHIR_INIT_VAR(&_11); - ZVAL_STRING(&_11, "title"); - ZVAL_BOOL(&_12, 1); - ZEPHIR_CALL_METHOD(&_8, this_ptr, "renderfullelement", NULL, 0, &_11, &_6, &_10, &_12); - zephir_check_call_status(); - zephir_read_property(&_12, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CONCAT_VVV(return_value, &_7, &_8, &_12); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Html_Helper_Title, append) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool raw; - zval *text_param = NULL, *raw_param = NULL, _0, _1; - zval text; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(text) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(raw) + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &text_param, &raw_param); - zephir_get_strval(&text, text_param); - if (!raw_param) { - raw = 0; - } else { - } - ZEPHIR_INIT_VAR(&_0); - if (raw) { - ZEPHIR_CPY_WRT(&_0, &text); - } else { - zephir_read_property(&_1, this_ptr, ZEND_STRL("escaper"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_0, &_1, "html", NULL, 0, &text); - zephir_check_call_status(); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); } - zephir_get_strval(&text, &_0); - zephir_update_property_array_append(this_ptr, SL("append"), &text); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Html_Helper_Title, get) -{ - - RETURN_MEMBER(getThis(), "title"); -} - -static PHP_METHOD(Phalcon_Html_Helper_Title, set) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool raw; - zval *text_param = NULL, *raw_param = NULL, _0, _1; - zval text; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(text) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(raw) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &text_param, &raw_param); - zephir_get_strval(&text, text_param); - if (!raw_param) { - raw = 0; - } else { - } - ZEPHIR_INIT_VAR(&_0); - if (raw) { - ZEPHIR_CPY_WRT(&_0, &text); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - zephir_read_property(&_1, this_ptr, ZEND_STRL("escaper"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_0, &_1, "html", NULL, 0, &text); - zephir_check_call_status(); + ZEPHIR_INIT_VAR(&name); } - zephir_get_strval(&text, &_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("title"), &text); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Html_Helper_Title, setSeparator) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool raw; - zval *separator_param = NULL, *raw_param = NULL, _0, _1; - zval separator; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&separator); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(separator) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(raw) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &separator_param, &raw_param); - zephir_get_strval(&separator, separator_param); - if (!raw_param) { - raw = 0; - } else { - } - ZEPHIR_INIT_VAR(&_0); - if (raw) { - ZEPHIR_CPY_WRT(&_0, &separator); - } else { - zephir_read_property(&_1, this_ptr, ZEND_STRL("escaper"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_0, &_1, "html", NULL, 0, &separator); + zephir_read_property(&_0, this_ptr, ZEND_STRL("mapper"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(!(zephir_array_isset(&_0, &name)))) { + ZEPHIR_INIT_VAR(&_2$$3); + ZEPHIR_CONCAT_SVS(&_2$$3, "Service ", &name, " is not registered"); + ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "getexception", NULL, 0, &_2$$3); zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Factory/AbstractFactory.zep", 40); + ZEPHIR_MM_RESTORE(); + return; } - zephir_update_property_zval(this_ptr, ZEND_STRL("separator"), &_0); - RETURN_THIS(); + zephir_read_property(&_3, this_ptr, ZEND_STRL("mapper"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_4, &_3, &name, PH_NOISY | PH_READONLY, "phalcon/Factory/AbstractFactory.zep", 43); + RETURN_CTOR(&_4); } -static PHP_METHOD(Phalcon_Html_Helper_Title, prepend) +static PHP_METHOD(Phalcon_Factory_AbstractFactory, init) { + zend_string *_4; + zend_ulong _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool raw; - zval *text_param = NULL, *raw_param = NULL, prepend, _0, _1, _2; - zval text; + zval *services_param = NULL, adapters, name, service, _0, *_1, _2, _5$$3, _6$$4; + zval services; zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&prepend); + ZVAL_UNDEF(&services); + ZVAL_UNDEF(&adapters); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&service); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(text) + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$4); + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(raw) + Z_PARAM_ARRAY(services) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &text_param, &raw_param); - zephir_get_strval(&text, text_param); - if (!raw_param) { - raw = 0; + zephir_fetch_params(1, 0, 1, &services_param); + if (!services_param) { + ZEPHIR_INIT_VAR(&services); + array_init(&services); } else { - } + ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); + } + ZEPHIR_CALL_METHOD(&adapters, this_ptr, "getservices", NULL, 0); + zephir_check_call_status(); ZEPHIR_INIT_VAR(&_0); - if (raw) { - ZEPHIR_CPY_WRT(&_0, &text); + zephir_fast_array_merge(&_0, &adapters, &services); + ZEPHIR_CPY_WRT(&adapters, &_0); + zephir_is_iterable(&adapters, 0, "phalcon/Factory/AbstractFactory.zep", 60); + if (Z_TYPE_P(&adapters) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&adapters), _3, _4, _1) + { + ZEPHIR_INIT_NVAR(&name); + if (_4 != NULL) { + ZVAL_STR_COPY(&name, _4); + } else { + ZVAL_LONG(&name, _3); + } + ZEPHIR_INIT_NVAR(&service); + ZVAL_COPY(&service, _1); + zephir_update_property_array(this_ptr, SL("mapper"), &name, &service); + zephir_unset_property_array(this_ptr, ZEND_STRL("services"), &name); + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); + zephir_array_unset(&_5$$3, &name, PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); } else { - zephir_read_property(&_1, this_ptr, ZEND_STRL("escaper"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_0, &_1, "html", NULL, 0, &text); + ZEPHIR_CALL_METHOD(NULL, &adapters, "rewind", NULL, 0); zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &adapters, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&name, &adapters, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&service, &adapters, "current", NULL, 0); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("mapper"), &name, &service); + zephir_unset_property_array(this_ptr, ZEND_STRL("services"), &name); + zephir_read_property(&_6$$4, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); + zephir_array_unset(&_6$$4, &name, PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &adapters, "next", NULL, 0); + zephir_check_call_status(); + } } - zephir_get_strval(&text, &_0); - zephir_read_property(&_2, this_ptr, ZEND_STRL("prepend"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&prepend, &_2); - ZEPHIR_MAKE_REF(&prepend); - ZEPHIR_CALL_FUNCTION(NULL, "array_unshift", NULL, 270, &prepend, &text); - ZEPHIR_UNREF(&prepend); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("prepend"), &prepend); - RETURN_THIS(); + ZEPHIR_INIT_NVAR(&service); + ZEPHIR_INIT_NVAR(&name); + ZEPHIR_MM_RESTORE(); } -zend_object *zephir_init_properties_Phalcon_Html_Helper_Title(zend_class_entry *class_type) +zend_object *zephir_init_properties_Phalcon_Factory_AbstractFactory(zend_class_entry *class_type) { zval _0, _2, _1$$3, _3$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; @@ -122806,17 +123998,17 @@ zend_object *zephir_init_properties_Phalcon_Html_Helper_Title(zend_class_entry * { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("prepend"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("prepend"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("services"), &_1$$3); } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("append"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("mapper"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_2) == IS_NULL) { ZEPHIR_INIT_VAR(&_3$$4); array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("append"), &_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("mapper"), &_3$$4); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -122833,19 +124025,13 @@ zend_object *zephir_init_properties_Phalcon_Html_Helper_Title(zend_class_entry * -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Ul) +ZEPHIR_INIT_CLASS(Phalcon_Factory_Exception) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper, Ul, phalcon, html_helper_ul, phalcon_html_helper_ol_ce, phalcon_html_helper_ul_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Factory, Exception, phalcon, factory_exception, zend_ce_exception, NULL, 0); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Helper_Ul, getTag) -{ - - RETURN_STRING("ul"); -} - @@ -122856,396 +124042,477 @@ static PHP_METHOD(Phalcon_Html_Helper_Ul, getTag) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_AbstractInput) +ZEPHIR_INIT_CLASS(Phalcon_Logger_AbstractLogger) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, AbstractInput, phalcon, html_helper_input_abstractinput, phalcon_html_helper_abstracthelper_ce, phalcon_html_helper_input_abstractinput_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + ZEPHIR_REGISTER_CLASS(Phalcon\\Logger, AbstractLogger, phalcon, logger_abstractlogger, phalcon_logger_abstractlogger_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zend_declare_property_string(phalcon_html_helper_input_abstractinput_ce, SL("type"), "text", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_html_helper_input_abstractinput_ce, SL("attributes"), ZEND_ACC_PROTECTED); - phalcon_html_helper_input_abstractinput_ce->create_object = zephir_init_properties_Phalcon_Html_Helper_Input_AbstractInput; + zend_declare_property_null(phalcon_logger_abstractlogger_ce, SL("adapters"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_abstractlogger_ce, SL("excluded"), ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_logger_abstractlogger_ce, SL("logLevel"), 8, ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_logger_abstractlogger_ce, SL("name"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_abstractlogger_ce, SL("timezone"), ZEND_ACC_PROTECTED); + phalcon_logger_abstractlogger_ce->create_object = zephir_init_properties_Phalcon_Logger_AbstractLogger; + zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("ALERT"), 2); + + zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("CRITICAL"), 1); + + zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("CUSTOM"), 8); + + zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("DEBUG"), 7); + + zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("EMERGENCY"), 0); + + zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("ERROR"), 3); + + zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("INFO"), 6); + + zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("NOTICE"), 5); + + zephir_declare_class_constant_long(phalcon_logger_abstractlogger_ce, SL("WARNING"), 4); return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Helper_Input_AbstractInput, __invoke) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes, _0; - zval *name_param = NULL, *value_param = NULL, *attributes_param = NULL, _1, _3, _4, _2$$3; - zval name, value; + zval adapters; + zval *name_param = NULL, *adapters_param = NULL, *timezone = NULL, timezone_sub, __$null, defaultTimezone; + zval name; zval *this_ptr = getThis(); ZVAL_UNDEF(&name); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&timezone_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&defaultTimezone); + ZVAL_UNDEF(&adapters); bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 3) Z_PARAM_STR(name) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(value) - Z_PARAM_ARRAY(attributes) + Z_PARAM_ARRAY(adapters) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(timezone, php_date_get_timezone_ce()) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &name_param, &value_param, &attributes_param); + zephir_fetch_params(1, 1, 2, &name_param, &adapters_param, &timezone); zephir_get_strval(&name, name_param); - if (!value_param) { - ZEPHIR_INIT_VAR(&value); + if (!adapters_param) { + ZEPHIR_INIT_VAR(&adapters); + array_init(&adapters); } else { - zephir_get_strval(&value, value_param); + zephir_get_arrval(&adapters, adapters_param); } - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); + if (!timezone) { + timezone = &timezone_sub; + ZEPHIR_CPY_WRT(timezone, &__$null); } else { - zephir_get_arrval(&attributes, attributes_param); + ZEPHIR_SEPARATE_PARAM(timezone); } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 2, 0); - zephir_memory_observe(&_1); - zephir_read_property(&_1, this_ptr, ZEND_STRL("type"), PH_NOISY_CC); - zephir_array_update_string(&_0, SL("type"), &_1, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_0, SL("name"), &name, PH_COPY | PH_SEPARATE); - zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &_0); - if (!(zephir_array_isset_string(&attributes, SL("id")))) { - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "id"); - zephir_update_property_array(this_ptr, SL("attributes"), &_2$$3, &name); + if (Z_TYPE_P(timezone) == IS_NULL) { + ZEPHIR_CALL_FUNCTION(&defaultTimezone, "date_default_timezone_get", NULL, 97); + zephir_check_call_status(); + if (UNEXPECTED(1 == ZEPHIR_IS_EMPTY(&defaultTimezone))) { + ZEPHIR_INIT_NVAR(&defaultTimezone); + ZVAL_STRING(&defaultTimezone, "UTC"); + } + ZEPHIR_INIT_NVAR(timezone); + object_init_ex(timezone, php_date_get_timezone_ce()); + ZEPHIR_CALL_METHOD(NULL, timezone, "__construct", NULL, 0, &defaultTimezone); + zephir_check_call_status(); } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setvalue", NULL, 0, &value); + zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); + zephir_update_property_zval(this_ptr, ZEND_STRL("timezone"), timezone); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setadapters", NULL, 0, &adapters); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_3); - zephir_read_property(&_4, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); - zephir_fast_array_merge(&_3, &_4, &attributes); - zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &_3); - RETURN_THIS(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Helper_Input_AbstractInput, __toString) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, addAdapter) { - zval _0, _1, _2, _3; - zval attributes; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, *adapter, adapter_sub; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&adapter_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_OBJECT_OF_CLASS(adapter, phalcon_logger_adapter_adapterinterface_ce) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&attributes, &_0); - ZEPHIR_INIT_VAR(&_1); - array_init(&_1); - zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &_1); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "input"); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "/"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "rendertag", NULL, 0, &_2, &attributes, &_3); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 2, 0, &name_param, &adapter); + zephir_get_strval(&name, name_param); + zephir_update_property_array(this_ptr, SL("adapters"), &name, adapter); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Html_Helper_Input_AbstractInput, setValue) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, excludeAdapters) { - zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *value_param = NULL, _1$$3; - zval value; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *adapters_param = NULL, __$true, adapter, registered, *_0, _1; + zval adapters; zval *this_ptr = getThis(); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_1$$3); - bool is_null_true = 1; + ZVAL_UNDEF(&adapters); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&adapter); + ZVAL_UNDEF(®istered); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(value) + Z_PARAM_ARRAY(adapters) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &value_param); - if (!value_param) { - ZEPHIR_INIT_VAR(&value); + zephir_fetch_params(1, 0, 1, &adapters_param); + if (!adapters_param) { + ZEPHIR_INIT_VAR(&adapters); + array_init(&adapters); } else { - zephir_get_strval(&value, value_param); - } - _0 = zephir_is_numeric(&value); - if (!(_0)) { - _0 = !(ZEPHIR_IS_EMPTY(&value)); + zephir_get_arrval(&adapters, adapters_param); } - if (_0) { - ZEPHIR_INIT_VAR(&_1$$3); - ZVAL_STRING(&_1$$3, "value"); - zephir_update_property_array(this_ptr, SL("attributes"), &_1$$3, &value); + zephir_memory_observe(®istered); + zephir_read_property(®istered, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC); + zephir_is_iterable(&adapters, 0, "phalcon/Logger/AbstractLogger.zep", 153); + if (Z_TYPE_P(&adapters) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&adapters), _0) + { + ZEPHIR_INIT_NVAR(&adapter); + ZVAL_COPY(&adapter, _0); + if (1 == zephir_array_isset(®istered, &adapter)) { + zephir_update_property_array(this_ptr, SL("excluded"), &adapter, &__$true); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &adapters, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &adapters, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&adapter, &adapters, "current", NULL, 0); + zephir_check_call_status(); + if (1 == zephir_array_isset(®istered, &adapter)) { + zephir_update_property_array(this_ptr, SL("excluded"), &adapter, &__$true); + } + ZEPHIR_CALL_METHOD(NULL, &adapters, "next", NULL, 0); + zephir_check_call_status(); + } } + ZEPHIR_INIT_NVAR(&adapter); RETURN_THIS(); } -zend_object *zephir_init_properties_Phalcon_Html_Helper_Input_AbstractInput(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, getAdapter) { - zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - + zval *name_param = NULL, _0, _1, _2; + zval name; + zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("attributes"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); + if (1 != zephir_array_isset(&_0, &name)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "Adapter does not exist for this logger", "phalcon/Logger/AbstractLogger.zep", 169); + return; } + zephir_read_property(&_1, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_2, &_1, &name, PH_NOISY | PH_READONLY, "phalcon/Logger/AbstractLogger.zep", 172); + RETURN_CTOR(&_2); } +static PHP_METHOD(Phalcon_Logger_AbstractLogger, getAdapters) +{ + RETURN_MEMBER(getThis(), "adapters"); +} +static PHP_METHOD(Phalcon_Logger_AbstractLogger, getLogLevel) +{ -#ifdef HAVE_CONFIG_H -#endif - - - - + RETURN_MEMBER(getThis(), "logLevel"); +} -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Checkbox) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, getName) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Checkbox, phalcon, html_helper_input_checkbox, phalcon_html_helper_input_abstractinput_ce, phalcon_html_helper_input_checkbox_method_entry, 0); - - zend_declare_property_null(phalcon_html_helper_input_checkbox_ce, SL("label"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_html_helper_input_checkbox_ce, SL("type"), "checkbox", ZEND_ACC_PROTECTED); - phalcon_html_helper_input_checkbox_ce->create_object = zephir_init_properties_Phalcon_Html_Helper_Input_Checkbox; - return SUCCESS; + RETURN_MEMBER(getThis(), "name"); } -static PHP_METHOD(Phalcon_Html_Helper_Input_Checkbox, __construct) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, removeAdapter) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *escaper, escaper_sub; + zval *name_param = NULL, _0, _1; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&escaper_sub); + ZVAL_UNDEF(&name); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(escaper, phalcon_html_escaper_escaperinterface_ce) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &escaper); - ZEPHIR_CALL_PARENT(NULL, phalcon_html_helper_input_checkbox_ce, getThis(), "__construct", NULL, 0, escaper); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 3, 0); - add_assoc_stringl_ex(&_0, SL("start"), SL("")); - add_assoc_stringl_ex(&_0, SL("text"), SL("")); - add_assoc_stringl_ex(&_0, SL("end"), SL("")); - zephir_update_property_zval(this_ptr, ZEND_STRL("label"), &_0); - ZEPHIR_MM_RESTORE(); + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); + if (1 != zephir_array_isset(&_0, &name)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "Adapter does not exist for this logger", "phalcon/Logger/AbstractLogger.zep", 214); + return; + } + zephir_unset_property_array(this_ptr, ZEND_STRL("adapters"), &name); + zephir_read_property(&_1, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); + zephir_array_unset(&_1, &name, PH_SEPARATE); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Html_Helper_Input_Checkbox, __toString) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, setAdapters) { - zval _1; - zval element, label, unchecked, _0, _2, _3, _4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *adapters_param = NULL; + zval adapters; zval *this_ptr = getThis(); - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&label); - ZVAL_UNDEF(&unchecked); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&adapters); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(adapters) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processchecked", NULL, 95); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&unchecked, this_ptr, "processunchecked", NULL, 96); - zephir_check_call_status(); - ZEPHIR_CALL_PARENT(&element, phalcon_html_helper_input_checkbox_ce, getThis(), "__tostring", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("label"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&label, &_0); - ZEPHIR_INIT_VAR(&_1); - zephir_create_array(&_1, 3, 0); - add_assoc_stringl_ex(&_1, SL("start"), SL("")); - add_assoc_stringl_ex(&_1, SL("text"), SL("")); - add_assoc_stringl_ex(&_1, SL("end"), SL("")); - zephir_update_property_zval(this_ptr, ZEND_STRL("label"), &_1); - zephir_array_fetch_string(&_2, &label, SL("start"), PH_NOISY | PH_READONLY, "phalcon/Html/Helper/Input/Checkbox.zep", 70); - zephir_array_fetch_string(&_3, &label, SL("text"), PH_NOISY | PH_READONLY, "phalcon/Html/Helper/Input/Checkbox.zep", 72); - zephir_array_fetch_string(&_4, &label, SL("end"), PH_NOISY | PH_READONLY, "phalcon/Html/Helper/Input/Checkbox.zep", 72); - ZEPHIR_CONCAT_VVVVV(return_value, &unchecked, &_2, &element, &_3, &_4); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &adapters_param); + zephir_get_arrval(&adapters, adapters_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("adapters"), &adapters); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Html_Helper_Input_Checkbox, label) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, setLogLevel) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *attributes_param = NULL, text, _0, _2, _3, _5, _6; - zval attributes, _1, _4; + zval *level_param = NULL, levels, _0; + zend_long level, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&text); + ZVAL_UNDEF(&levels); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(level) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &attributes_param); - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); + zephir_fetch_params(1, 1, 0, &level_param); + ZEPHIR_CALL_METHOD(&levels, this_ptr, "getlevels", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + if (1 == zephir_array_isset_long(&levels, level)) { + ZEPHIR_INIT_NVAR(&_0); + ZVAL_LONG(&_0, level); } else { - zephir_get_arrval(&attributes, attributes_param); - } - zephir_memory_observe(&text); - if (!(zephir_array_isset_string_fetch(&text, &attributes, SL("text"), 0))) { - ZEPHIR_INIT_NVAR(&text); - ZVAL_STRING(&text, ""); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_LONG(&_0, 8); } - zephir_array_unset_string(&attributes, SL("text"), PH_SEPARATE); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_INIT_VAR(&_1); - zephir_create_array(&_1, 1, 0); - zephir_read_property(&_2, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&_3); - zephir_array_fetch_string(&_3, &_2, SL("id"), PH_NOISY, "phalcon/Html/Helper/Input/Checkbox.zep", 95); - zephir_array_update_string(&_1, SL("for"), &_3, PH_COPY | PH_SEPARATE); - zephir_fast_array_merge(&_0, &_1, &attributes); - ZEPHIR_CPY_WRT(&attributes, &_0); - ZEPHIR_INIT_VAR(&_4); - zephir_create_array(&_4, 3, 0); - ZEPHIR_INIT_VAR(&_6); - ZVAL_STRING(&_6, "label"); - ZEPHIR_CALL_METHOD(&_5, this_ptr, "rendertag", NULL, 0, &_6, &attributes); - zephir_check_call_status(); - zephir_array_update_string(&_4, SL("start"), &_5, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_4, SL("text"), &text, PH_COPY | PH_SEPARATE); - add_assoc_stringl_ex(&_4, SL("end"), SL("")); - zephir_update_property_zval(this_ptr, ZEND_STRL("label"), &_4); + zephir_update_property_zval(this_ptr, ZEND_STRL("logLevel"), &_0); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Html_Helper_Input_Checkbox, processChecked) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, addMessage) { - zval attributes; - zval checked, value, _0, _1$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval context; + zval message; + zval *level_param = NULL, *message_param = NULL, *context_param = NULL, adapter, collection, item, levelName, levels, method, _0, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, *_7$$3, _8$$3, _9$$5, _10$$7; + zend_long level, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&checked); - ZVAL_UNDEF(&value); + ZVAL_UNDEF(&adapter); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&item); + ZVAL_UNDEF(&levelName); + ZVAL_UNDEF(&levels); + ZVAL_UNDEF(&method); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$6); - ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_10$$7); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_LONG(level) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&attributes, &_0); - zephir_memory_observe(&checked); - if (!(zephir_array_isset_string_fetch(&checked, &attributes, SL("checked"), 0))) { - ZEPHIR_INIT_NVAR(&checked); - ZVAL_NULL(&checked); + zephir_fetch_params(1, 2, 1, &level_param, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); + } else { + zephir_get_arrval(&context, context_param); } - zephir_array_unset_string(&attributes, SL("checked"), PH_SEPARATE); - if (Z_TYPE_P(&checked) != IS_NULL) { - zephir_memory_observe(&value); - if (!(zephir_array_isset_string_fetch(&value, &attributes, SL("value"), 0))) { - ZEPHIR_INIT_NVAR(&value); - ZVAL_NULL(&value); + zephir_read_property(&_0, this_ptr, ZEND_STRL("logLevel"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_GE_LONG(&_0, level)) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); + if (zephir_fast_count_int(&_1$$3) == 0) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "No adapters specified", "phalcon/Logger/AbstractLogger.zep", 273); + return; } - if (ZEPHIR_IS_IDENTICAL(&checked, &value)) { - ZEPHIR_INIT_VAR(&_1$$6); - ZVAL_STRING(&_1$$6, "checked"); - zephir_array_update_string(&attributes, SL("checked"), &_1$$6, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&levels, this_ptr, "getlevels", NULL, 0); + zephir_check_call_status(); + if (1 == zephir_array_isset_long(&levels, level)) { + zephir_memory_observe(&levelName); + zephir_array_fetch_long(&levelName, &levels, level, PH_NOISY, "phalcon/Logger/AbstractLogger.zep", 277); + } else { + ZEPHIR_OBS_NVAR(&levelName); + zephir_array_fetch_long(&levelName, &levels, 8, PH_NOISY, "phalcon/Logger/AbstractLogger.zep", 277); + } + ZEPHIR_INIT_VAR(&item); + object_init_ex(&item, phalcon_logger_item_ce); + ZEPHIR_INIT_VAR(&_2$$3); + object_init_ex(&_2$$3, php_date_get_immutable_ce()); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("timezone"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_4$$3); + ZVAL_STRING(&_4$$3, "now"); + ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 0, &_4$$3, &_3$$3); + zephir_check_call_status(); + ZVAL_LONG(&_5$$3, level); + ZEPHIR_CALL_METHOD(NULL, &item, "__construct", NULL, 98, &message, &levelName, &_5$$3, &_2$$3, &context); + zephir_check_call_status(); + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("excluded"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&collection, "array_diff_key", NULL, 99, &_5$$3, &_6$$3); + zephir_check_call_status(); + zephir_is_iterable(&collection, 0, "phalcon/Logger/AbstractLogger.zep", 303); + if (Z_TYPE_P(&collection) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&collection), _7$$3) + { + ZEPHIR_INIT_NVAR(&adapter); + ZVAL_COPY(&adapter, _7$$3); + ZEPHIR_INIT_NVAR(&method); + ZVAL_STRING(&method, "process"); + ZEPHIR_CALL_METHOD(&_9$$5, &adapter, "intransaction", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_9$$5)) { + ZEPHIR_INIT_NVAR(&method); + ZVAL_STRING(&method, "add"); + } + ZEPHIR_CALL_METHOD_ZVAL(NULL, &adapter, &method, NULL, 0, &item); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &collection, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_8$$3, &collection, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_8$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&adapter, &collection, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&method); + ZVAL_STRING(&method, "process"); + ZEPHIR_CALL_METHOD(&_10$$7, &adapter, "intransaction", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_10$$7)) { + ZEPHIR_INIT_NVAR(&method); + ZVAL_STRING(&method, "add"); + } + ZEPHIR_CALL_METHOD_ZVAL(NULL, &adapter, &method, NULL, 0, &item); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &collection, "next", NULL, 0); + zephir_check_call_status(); + } } + ZEPHIR_INIT_NVAR(&adapter); + ZEPHIR_INIT_NVAR(&_4$$3); + array_init(&_4$$3); + zephir_update_property_zval(this_ptr, ZEND_STRL("excluded"), &_4$$3); } - zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &attributes); - ZEPHIR_MM_RESTORE(); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Html_Helper_Input_Checkbox, processUnchecked) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, getLevelNumber) { - zval attributes, _1$$4; - zval unchecked, _0, _2$$4, _3$$4, _4$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *level, level_sub, levelName, levels, _0$$3, _1$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&unchecked); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&level_sub); + ZVAL_UNDEF(&levelName); + ZVAL_UNDEF(&levels); + ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_1$$4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(level) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&attributes, &_0); - zephir_memory_observe(&unchecked); - if (!(zephir_array_isset_string_fetch(&unchecked, &attributes, SL("unchecked"), 0))) { - ZEPHIR_INIT_NVAR(&unchecked); - ZVAL_STRING(&unchecked, ""); - } - zephir_array_unset_string(&attributes, SL("unchecked"), PH_SEPARATE); - if (!(ZEPHIR_IS_EMPTY(&unchecked))) { - ZEPHIR_INIT_VAR(&_1$$4); - zephir_create_array(&_1$$4, 2, 0); - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&_3$$4); - zephir_array_fetch_string(&_3$$4, &_2$$4, SL("name"), PH_NOISY, "phalcon/Html/Helper/Input/Checkbox.zep", 156); - zephir_array_update_string(&_1$$4, SL("name"), &_3$$4, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_1$$4, SL("value"), &unchecked, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_4$$4); - ZVAL_STRING(&_4$$4, "hidden"); - ZEPHIR_CALL_METHOD(&unchecked, this_ptr, "rendertag", NULL, 0, &_4$$4, &_1$$4); + zephir_fetch_params(1, 1, 0, &level); + if (Z_TYPE_P(level) == IS_STRING) { + ZEPHIR_INIT_VAR(&levelName); + zephir_fast_strtoupper(&levelName, level); + ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "getlevels", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&levels, "array_flip", NULL, 100, &_0$$3); + zephir_check_call_status(); + if (zephir_array_isset(&levels, &levelName)) { + zephir_array_fetch(&_1$$4, &levels, &levelName, PH_NOISY | PH_READONLY, "phalcon/Logger/AbstractLogger.zep", 328); + RETURN_CTOR(&_1$$4); + } + } else if (1 == zephir_is_numeric(level)) { + ZEPHIR_CALL_METHOD(&levels, this_ptr, "getlevels", NULL, 0); zephir_check_call_status(); + if (zephir_array_isset(&levels, level)) { + RETURN_MM_LONG(zephir_get_intval(level)); + } } - zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &attributes); - RETURN_CCTOR(&unchecked); + RETURN_MM_LONG(8); } -zend_object *zephir_init_properties_Phalcon_Html_Helper_Input_Checkbox(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Logger_AbstractLogger, getLevels) +{ + + zephir_create_array(return_value, 9, 0); + add_index_stringl(return_value, 2, SL("ALERT")); + add_index_stringl(return_value, 1, SL("CRITICAL")); + add_index_stringl(return_value, 7, SL("DEBUG")); + add_index_stringl(return_value, 0, SL("EMERGENCY")); + add_index_stringl(return_value, 3, SL("ERROR")); + add_index_stringl(return_value, 6, SL("INFO")); + add_index_stringl(return_value, 5, SL("NOTICE")); + add_index_stringl(return_value, 4, SL("WARNING")); + add_index_stringl(return_value, 8, SL("CUSTOM")); + return; +} + +zend_object *zephir_init_properties_Phalcon_Logger_AbstractLogger(zend_class_entry *class_type) { zval _0, _2, _1$$3, _3$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; @@ -123261,17 +124528,17 @@ zend_object *zephir_init_properties_Phalcon_Html_Helper_Input_Checkbox(zend_clas { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("excluded"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("attributes"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("excluded"), &_1$$3); } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("label"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("adapters"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_2) == IS_NULL) { ZEPHIR_INIT_VAR(&_3$$4); array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("label"), &_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("adapters"), &_3$$4); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -123288,84 +124555,112 @@ zend_object *zephir_init_properties_Phalcon_Html_Helper_Input_Checkbox(zend_clas -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Color) +ZEPHIR_INIT_CLASS(Phalcon_Logger_AdapterFactory) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Color, phalcon, html_helper_input_color, phalcon_html_helper_input_abstractinput_ce, NULL, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger, AdapterFactory, phalcon, logger_adapterfactory, phalcon_factory_abstractfactory_ce, phalcon_logger_adapterfactory_method_entry, 0); - zend_declare_property_string(phalcon_html_helper_input_color_ce, SL("type"), "color", ZEND_ACC_PROTECTED); return SUCCESS; } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Date) +static PHP_METHOD(Phalcon_Logger_AdapterFactory, __construct) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Date, phalcon, html_helper_input_date, phalcon_html_helper_input_abstractinput_ce, NULL, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *services_param = NULL; + zval services; + zval *this_ptr = getThis(); - zend_declare_property_string(phalcon_html_helper_input_date_ce, SL("type"), "date", ZEND_ACC_PROTECTED); - return SUCCESS; + ZVAL_UNDEF(&services); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(services) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &services_param); + if (!services_param) { + ZEPHIR_INIT_VAR(&services); + array_init(&services); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_DateTime) +static PHP_METHOD(Phalcon_Logger_AdapterFactory, newInstance) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, DateTime, phalcon, html_helper_input_datetime, phalcon_html_helper_input_abstractinput_ce, NULL, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval options, _0; + zval *name_param = NULL, *fileName_param = NULL, *options_param = NULL, definition; + zval name, fileName; + zval *this_ptr = getThis(); - zend_declare_property_string(phalcon_html_helper_input_datetime_ce, SL("type"), "datetime", ZEND_ACC_PROTECTED); - return SUCCESS; + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&fileName); + ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(name) + Z_PARAM_STR(fileName) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 1, &name_param, &fileName_param, &options_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + if (UNEXPECTED(Z_TYPE_P(fileName_param) != IS_STRING && Z_TYPE_P(fileName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'fileName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(fileName_param) == IS_STRING)) { + zephir_get_strval(&fileName, fileName_param); + } else { + ZEPHIR_INIT_VAR(&fileName); + } + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 2, 0); + zephir_array_fast_append(&_0, &fileName); + zephir_array_fast_append(&_0, &options); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(return_value, &definition, &_0); + zephir_check_call_status(); + RETURN_MM(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_DateTimeLocal) +static PHP_METHOD(Phalcon_Logger_AdapterFactory, getExceptionClass) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, DateTimeLocal, phalcon, html_helper_input_datetimelocal, phalcon_html_helper_input_abstractinput_ce, NULL, 0); - zend_declare_property_string(phalcon_html_helper_input_datetimelocal_ce, SL("type"), "datetime-local", ZEND_ACC_PROTECTED); - return SUCCESS; + RETURN_STRING("Phalcon\\Logger\\Exception"); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Email) +static PHP_METHOD(Phalcon_Logger_AdapterFactory, getServices) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Email, phalcon, html_helper_input_email, phalcon_html_helper_input_abstractinput_ce, NULL, 0); - zend_declare_property_string(phalcon_html_helper_input_email_ce, SL("type"), "email", ZEND_ACC_PROTECTED); - return SUCCESS; + zephir_create_array(return_value, 3, 0); + add_assoc_stringl_ex(return_value, SL("noop"), SL("Phalcon\\Logger\\Adapter\\Noop")); + add_assoc_stringl_ex(return_value, SL("stream"), SL("Phalcon\\Logger\\Adapter\\Stream")); + add_assoc_stringl_ex(return_value, SL("syslog"), SL("Phalcon\\Logger\\Adapter\\Syslog")); + return; } @@ -123378,29 +124673,28 @@ ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Email) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_File) +ZEPHIR_INIT_CLASS(Phalcon_Logger_Enum) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, File, phalcon, html_helper_input_file, phalcon_html_helper_input_abstractinput_ce, NULL, 0); - - zend_declare_property_string(phalcon_html_helper_input_file_ce, SL("type"), "file", ZEND_ACC_PROTECTED); - return SUCCESS; -} + ZEPHIR_REGISTER_CLASS(Phalcon\\Logger, Enum, phalcon, logger_enum, NULL, 0); + zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("ALERT"), 2); + zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("CRITICAL"), 1); + zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("CUSTOM"), 8); -#ifdef HAVE_CONFIG_H -#endif + zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("DEBUG"), 7); + zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("EMERGENCY"), 0); + zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("ERROR"), 3); + zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("INFO"), 6); + zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("NOTICE"), 5); -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Hidden) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Hidden, phalcon, html_helper_input_hidden, phalcon_html_helper_input_abstractinput_ce, NULL, 0); + zephir_declare_class_constant_long(phalcon_logger_enum_ce, SL("WARNING"), 4); - zend_declare_property_string(phalcon_html_helper_input_hidden_ce, SL("type"), "hidden", ZEND_ACC_PROTECTED); return SUCCESS; } @@ -123414,11 +124708,10 @@ ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Hidden) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Image) +ZEPHIR_INIT_CLASS(Phalcon_Logger_Exception) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Image, phalcon, html_helper_input_image, phalcon_html_helper_input_abstractinput_ce, NULL, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger, Exception, phalcon, logger_exception, zend_ce_exception, NULL, 0); - zend_declare_property_string(phalcon_html_helper_input_image_ce, SL("type"), "image", ZEND_ACC_PROTECTED); return SUCCESS; } @@ -123432,120 +124725,116 @@ ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Image) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Input) +ZEPHIR_INIT_CLASS(Phalcon_Logger_Item) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Input, phalcon, html_helper_input_input, phalcon_html_helper_input_abstractinput_ce, phalcon_html_helper_input_input_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Logger, Item, phalcon, logger_item, phalcon_logger_item_method_entry, 0); + + zend_declare_property_null(phalcon_logger_item_ce, SL("context"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_item_ce, SL("dateTime"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_item_ce, SL("message"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_item_ce, SL("level"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_item_ce, SL("levelName"), ZEND_ACC_PROTECTED); + phalcon_logger_item_ce->create_object = zephir_init_properties_Phalcon_Logger_Item; return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Helper_Input_Input, setType) +static PHP_METHOD(Phalcon_Logger_Item, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *type_param = NULL; - zval type; + zval context; + zend_long level; + zval *message_param = NULL, *levelName_param = NULL, *level_param = NULL, *dateTime, dateTime_sub, *context_param = NULL, _0; + zval message, levelName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&type); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(type) + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&levelName); + ZVAL_UNDEF(&dateTime_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(4, 5) + Z_PARAM_STR(message) + Z_PARAM_STR(levelName) + Z_PARAM_LONG(level) + Z_PARAM_OBJECT_OF_CLASS(dateTime, php_date_get_immutable_ce()) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &type_param); - zephir_get_strval(&type, type_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &type); - RETURN_THIS(); + zephir_fetch_params(1, 4, 1, &message_param, &levelName_param, &level_param, &dateTime, &context_param); + zephir_get_strval(&message, message_param); + zephir_get_strval(&levelName, levelName_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); + } else { + zephir_get_arrval(&context, context_param); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("message"), &message); + zephir_update_property_zval(this_ptr, ZEND_STRL("levelName"), &levelName); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, level); + zephir_update_property_zval(this_ptr, ZEND_STRL("level"), &_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("dateTime"), dateTime); + zephir_update_property_zval(this_ptr, ZEND_STRL("context"), &context); + ZEPHIR_MM_RESTORE(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Month) +static PHP_METHOD(Phalcon_Logger_Item, getContext) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Month, phalcon, html_helper_input_month, phalcon_html_helper_input_abstractinput_ce, NULL, 0); - zend_declare_property_string(phalcon_html_helper_input_month_ce, SL("type"), "month", ZEND_ACC_PROTECTED); - return SUCCESS; + RETURN_MEMBER(getThis(), "context"); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Numeric) +static PHP_METHOD(Phalcon_Logger_Item, getDateTime) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Numeric, phalcon, html_helper_input_numeric, phalcon_html_helper_input_abstractinput_ce, NULL, 0); - zend_declare_property_string(phalcon_html_helper_input_numeric_ce, SL("type"), "number", ZEND_ACC_PROTECTED); - return SUCCESS; + RETURN_MEMBER(getThis(), "dateTime"); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Password) +static PHP_METHOD(Phalcon_Logger_Item, getMessage) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Password, phalcon, html_helper_input_password, phalcon_html_helper_input_abstractinput_ce, NULL, 0); - zend_declare_property_string(phalcon_html_helper_input_password_ce, SL("type"), "password", ZEND_ACC_PROTECTED); - return SUCCESS; + RETURN_MEMBER(getThis(), "message"); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Radio) +static PHP_METHOD(Phalcon_Logger_Item, getLevel) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Radio, phalcon, html_helper_input_radio, phalcon_html_helper_input_checkbox_ce, NULL, 0); - zend_declare_property_string(phalcon_html_helper_input_radio_ce, SL("type"), "radio", ZEND_ACC_PROTECTED); - return SUCCESS; + RETURN_MEMBER(getThis(), "level"); } +static PHP_METHOD(Phalcon_Logger_Item, getLevelName) +{ + RETURN_MEMBER(getThis(), "levelName"); +} - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Range) +zend_object *zephir_init_properties_Phalcon_Logger_Item(zend_class_entry *class_type) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Range, phalcon, html_helper_input_range, phalcon_html_helper_input_abstractinput_ce, NULL, 0); + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + - zend_declare_property_string(phalcon_html_helper_input_range_ce, SL("type"), "range", ZEND_ACC_PROTECTED); - return SUCCESS; + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("context"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("context"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } } @@ -123558,399 +124847,566 @@ ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Range) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Search) +ZEPHIR_INIT_CLASS(Phalcon_Logger_Logger) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Search, phalcon, html_helper_input_search, phalcon_html_helper_input_abstractinput_ce, NULL, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger, Logger, phalcon, logger_logger, phalcon_logger_abstractlogger_ce, phalcon_logger_logger_method_entry, 0); - zend_declare_property_string(phalcon_html_helper_input_search_ce, SL("type"), "search", ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_logger_logger_ce, 1, phalcon_logger_loggerinterface_ce); return SUCCESS; } +static PHP_METHOD(Phalcon_Logger_Logger, alert) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); + } else { + zephir_get_arrval(&context, context_param); + } + ZVAL_LONG(&_0, 2); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} +static PHP_METHOD(Phalcon_Logger_Logger, critical) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H -#endif - - - - + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); + } else { + zephir_get_arrval(&context, context_param); + } + ZVAL_LONG(&_0, 1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Select) +static PHP_METHOD(Phalcon_Logger_Logger, debug) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Select, phalcon, html_helper_input_select, phalcon_html_helper_abstractlist_ce, phalcon_html_helper_input_select_method_entry, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; + zval *this_ptr = getThis(); - zend_declare_property_string(phalcon_html_helper_input_select_ce, SL("elementTag"), "option", ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_html_helper_input_select_ce, SL("inOptGroup"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_html_helper_input_select_ce, SL("selected"), "", ZEND_ACC_PROTECTED); - return SUCCESS; + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); + } else { + zephir_get_arrval(&context, context_param); + } + ZVAL_LONG(&_0, 7); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Helper_Input_Select, add) +static PHP_METHOD(Phalcon_Logger_Logger, emergency) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool raw; - zval attributes, _1, _3; - zval *text_param = NULL, *value_param = NULL, *attributes_param = NULL, *raw_param = NULL, _0, _2, _4, _5; - zval text, value; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&value); + ZVAL_UNDEF(&message); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_STR(text) + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(value) - Z_PARAM_ARRAY(attributes) - Z_PARAM_BOOL(raw) + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 3, &text_param, &value_param, &attributes_param, &raw_param); - zephir_get_strval(&text, text_param); - if (!value_param) { - ZEPHIR_INIT_VAR(&value); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); } else { - zephir_get_strval(&value, value_param); + zephir_get_arrval(&context, context_param); } - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); + ZVAL_LONG(&_0, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Logger_Logger, error) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); } else { - zephir_get_arrval(&attributes, attributes_param); + zephir_get_arrval(&context, context_param); } - if (!raw_param) { - raw = 0; - } else { - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "processvalue", NULL, 328, &attributes, &value); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&attributes, &_0); - ZEPHIR_INIT_VAR(&_1); - zephir_create_array(&_1, 3, 0); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "renderFullElement"); - zephir_array_fast_append(&_1, &_2); - ZEPHIR_INIT_VAR(&_3); - zephir_create_array(&_3, 4, 0); - zephir_memory_observe(&_4); - zephir_read_property(&_4, this_ptr, ZEND_STRL("elementTag"), PH_NOISY_CC); - zephir_array_fast_append(&_3, &_4); - zephir_array_fast_append(&_3, &text); - zephir_array_fast_append(&_3, &attributes); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_BOOL(&_2, raw); - zephir_array_fast_append(&_3, &_2); - zephir_array_fast_append(&_1, &_3); - ZEPHIR_CALL_METHOD(&_5, this_ptr, "indent", NULL, 0); - zephir_check_call_status(); - zephir_array_fast_append(&_1, &_5); - zephir_update_property_array_append(this_ptr, SL("store"), &_1); - RETURN_THIS(); + ZVAL_LONG(&_0, 3); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Helper_Input_Select, addPlaceholder) +static PHP_METHOD(Phalcon_Logger_Logger, info) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool raw; - zval attributes, _1, _3; - zval *text_param = NULL, *value = NULL, value_sub, *attributes_param = NULL, *raw_param = NULL, __$null, _2, _4, _5; - zval text, _0$$3; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&value_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_STR(text) + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) - Z_PARAM_ARRAY(attributes) - Z_PARAM_BOOL(raw) + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 3, &text_param, &value, &attributes_param, &raw_param); - zephir_get_strval(&text, text_param); - if (!value) { - value = &value_sub; - value = &__$null; - } - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - } else { - zephir_get_arrval(&attributes, attributes_param); - } - if (!raw_param) { - raw = 0; + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); } else { - } - if (Z_TYPE_P(value) != IS_NULL) { - zephir_cast_to_string(&_0$$3, value); - zephir_array_update_string(&attributes, SL("value"), &_0$$3, PH_COPY | PH_SEPARATE); + zephir_get_arrval(&context, context_param); } - ZEPHIR_INIT_VAR(&_1); - zephir_create_array(&_1, 3, 0); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "renderFullElement"); - zephir_array_fast_append(&_1, &_2); - ZEPHIR_INIT_VAR(&_3); - zephir_create_array(&_3, 4, 0); - zephir_memory_observe(&_4); - zephir_read_property(&_4, this_ptr, ZEND_STRL("elementTag"), PH_NOISY_CC); - zephir_array_fast_append(&_3, &_4); - zephir_array_fast_append(&_3, &text); - zephir_array_fast_append(&_3, &attributes); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_BOOL(&_2, raw); - zephir_array_fast_append(&_3, &_2); - zephir_array_fast_append(&_1, &_3); - ZEPHIR_CALL_METHOD(&_5, this_ptr, "indent", NULL, 0); + ZVAL_LONG(&_0, 6); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); zephir_check_call_status(); - zephir_array_fast_append(&_1, &_5); - zephir_update_property_array_append(this_ptr, SL("store"), &_1); - RETURN_THIS(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Helper_Input_Select, optGroup) +static PHP_METHOD(Phalcon_Logger_Logger, log) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes, _1$$3, _3$$3, _8$$4; - zval *label_param = NULL, *attributes_param = NULL, __$true, __$false, _0, _11, _2$$3, _4$$3, _5$$3, _6$$4, _7$$4, _9$$4, _10$$4; - zval label; + zval context; + zval message, _0; + zval *level, level_sub, *message_param = NULL, *context_param = NULL, intLevel; zval *this_ptr = getThis(); - ZVAL_UNDEF(&label); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&level_sub); + ZVAL_UNDEF(&intLevel); + ZVAL_UNDEF(&message); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_10$$4); - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_8$$4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ZVAL(level) + Z_PARAM_STR(message) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(label) - Z_PARAM_ARRAY(attributes) + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &label_param, &attributes_param); - if (!label_param) { - ZEPHIR_INIT_VAR(&label); - } else { - zephir_get_strval(&label, label_param); - } - if (!attributes_param) { - ZEPHIR_INIT_VAR(&attributes); - array_init(&attributes); - } else { - zephir_get_arrval(&attributes, attributes_param); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("inOptGroup"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_is_true(&_0))) { - ZEPHIR_INIT_VAR(&_1$$3); - zephir_create_array(&_1$$3, 3, 0); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "optGroupStart"); - zephir_array_fast_append(&_1$$3, &_2$$3); - ZEPHIR_INIT_VAR(&_3$$3); - zephir_create_array(&_3$$3, 2, 0); - zephir_array_fast_append(&_3$$3, &label); - zephir_array_fast_append(&_3$$3, &attributes); - zephir_array_fast_append(&_1$$3, &_3$$3); - ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "indent", NULL, 0); - zephir_check_call_status(); - zephir_array_fast_append(&_1$$3, &_4$$3); - zephir_update_property_array_append(this_ptr, SL("store"), &_1$$3); - ZEPHIR_INIT_NVAR(&_2$$3); - ZVAL_LONG(&_2$$3, 1); - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("indentLevel"), PH_NOISY_CC); - ZEPHIR_ADD_ASSIGN(&_5$$3, &_2$$3) - zephir_update_property_zval(this_ptr, ZEND_STRL("indentLevel"), &_5$$3); + zephir_fetch_params(1, 2, 1, &level, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); } else { - ZEPHIR_INIT_VAR(&_7$$4); - ZVAL_LONG(&_7$$4, 1); - zephir_read_property(&_6$$4, this_ptr, ZEND_STRL("indentLevel"), PH_NOISY_CC); - ZEPHIR_SUB_ASSIGN(&_6$$4, &_7$$4) - zephir_update_property_zval(this_ptr, ZEND_STRL("indentLevel"), &_6$$4); - ZEPHIR_INIT_VAR(&_8$$4); - zephir_create_array(&_8$$4, 3, 0); - ZEPHIR_INIT_VAR(&_9$$4); - ZVAL_STRING(&_9$$4, "optGroupEnd"); - zephir_array_fast_append(&_8$$4, &_9$$4); - ZEPHIR_INIT_NVAR(&_9$$4); - array_init(&_9$$4); - zephir_array_fast_append(&_8$$4, &_9$$4); - ZEPHIR_CALL_METHOD(&_10$$4, this_ptr, "indent", NULL, 0); - zephir_check_call_status(); - zephir_array_fast_append(&_8$$4, &_10$$4); - zephir_update_property_array_append(this_ptr, SL("store"), &_8$$4); + zephir_get_arrval(&context, context_param); } - zephir_memory_observe(&_11); - zephir_read_property(&_11, this_ptr, ZEND_STRL("inOptGroup"), PH_NOISY_CC); - if (!zephir_is_true(&_11)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("inOptGroup"), &__$true); + ZEPHIR_CALL_METHOD(&intLevel, this_ptr, "getlevelnumber", NULL, 0, level); + zephir_check_call_status(); + zephir_cast_to_string(&_0, &message); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &intLevel, &_0, &context); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Logger_Logger, notice) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("inOptGroup"), &__$false); + zephir_get_arrval(&context, context_param); } - RETURN_THIS(); + ZVAL_LONG(&_0, 5); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Helper_Input_Select, selected) +static PHP_METHOD(Phalcon_Logger_Logger, warning) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *selected_param = NULL; - zval selected; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&selected); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(selected) + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &selected_param); - zephir_get_strval(&selected, selected_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("selected"), &selected); - RETURN_THIS(); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); + } else { + zephir_get_arrval(&context, context_param); + } + ZVAL_LONG(&_0, 4); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addmessage", NULL, 0, &_0, &message, &context); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Html_Helper_Input_Select, getTag) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Logger_LoggerFactory) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger, LoggerFactory, phalcon, logger_loggerfactory, phalcon_factory_abstractconfigfactory_ce, phalcon_logger_loggerfactory_method_entry, 0); - RETURN_STRING("select"); + zend_declare_property_null(phalcon_logger_loggerfactory_ce, SL("adapterFactory"), ZEND_ACC_PRIVATE); + return SUCCESS; } -static PHP_METHOD(Phalcon_Html_Helper_Input_Select, optGroupEnd) +static PHP_METHOD(Phalcon_Logger_LoggerFactory, __construct) { + zval *factory, factory_sub; + zval *this_ptr = getThis(); - RETURN_STRING(""); + ZVAL_UNDEF(&factory_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_logger_adapterfactory_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &factory); + zephir_update_property_zval(this_ptr, ZEND_STRL("adapterFactory"), factory); } -static PHP_METHOD(Phalcon_Html_Helper_Input_Select, optGroupStart) +static PHP_METHOD(Phalcon_Logger_LoggerFactory, load) { + zend_string *_7; + zend_ulong _6; + zval data; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval attributes; - zval *label_param = NULL, *attributes_param = NULL, _0; - zval label; + zval *config = NULL, config_sub, adapter, adapterClass, adapterFileName, adapterName, adapterOptions, adapters, name, timezone, options, _0, _1, _2, _3, *_4, _5, _8$$3, _9$$3, _10$$3, _11$$3, _12$$4, _13$$4, _14$$4, _15$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&label); + ZVAL_UNDEF(&config_sub); + ZVAL_UNDEF(&adapter); + ZVAL_UNDEF(&adapterClass); + ZVAL_UNDEF(&adapterFileName); + ZVAL_UNDEF(&adapterName); + ZVAL_UNDEF(&adapterOptions); + ZVAL_UNDEF(&adapters); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&timezone); + ZVAL_UNDEF(&options); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&attributes); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(label) - Z_PARAM_ARRAY(attributes) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$3); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_11$$3); + ZVAL_UNDEF(&_12$$4); + ZVAL_UNDEF(&_13$$4); + ZVAL_UNDEF(&_14$$4); + ZVAL_UNDEF(&_15$$4); + ZVAL_UNDEF(&data); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(config) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &label_param, &attributes_param); - zephir_get_strval(&label, label_param); - zephir_get_arrval(&attributes, attributes_param); - zephir_array_update_string(&attributes, SL("label"), &label, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "optgroup"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "rendertag", NULL, 0, &_0, &attributes); + zephir_fetch_params(1, 1, 0, &config); + ZEPHIR_SEPARATE_PARAM(config); + ZEPHIR_INIT_VAR(&data); + array_init(&data); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfig", NULL, 0, config); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(config, &_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "name"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfigelement", NULL, 0, config, &_1); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(config, &_0); + zephir_memory_observe(&name); + zephir_array_fetch_string(&name, config, SL("name"), PH_NOISY, "phalcon/Logger/LoggerFactory.zep", 62); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "timezone"); + ZEPHIR_CALL_METHOD(&timezone, this_ptr, "getarrval", NULL, 0, config, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_1); + array_init(&_1); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "options"); + ZEPHIR_CALL_METHOD(&options, this_ptr, "getarrval", NULL, 0, config, &_2, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_2); + array_init(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "adapters"); + ZEPHIR_CALL_METHOD(&adapters, this_ptr, "getarrval", NULL, 0, &options, &_3, &_2); + zephir_check_call_status(); + zephir_is_iterable(&adapters, 0, "phalcon/Logger/LoggerFactory.zep", 81); + if (Z_TYPE_P(&adapters) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&adapters), _6, _7, _4) + { + ZEPHIR_INIT_NVAR(&adapterName); + if (_7 != NULL) { + ZVAL_STR_COPY(&adapterName, _7); + } else { + ZVAL_LONG(&adapterName, _6); + } + ZEPHIR_INIT_NVAR(&adapter); + ZVAL_COPY(&adapter, _4); + ZEPHIR_INIT_NVAR(&_8$$3); + ZVAL_STRING(&_8$$3, "adapter"); + ZEPHIR_CALL_METHOD(&adapterClass, this_ptr, "getarrval", NULL, 0, &adapter, &_8$$3); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_8$$3); + ZVAL_STRING(&_8$$3, "name"); + ZEPHIR_CALL_METHOD(&adapterFileName, this_ptr, "getarrval", NULL, 0, &adapter, &_8$$3); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_8$$3); + array_init(&_8$$3); + ZEPHIR_INIT_NVAR(&_9$$3); + ZVAL_STRING(&_9$$3, "options"); + ZEPHIR_CALL_METHOD(&adapterOptions, this_ptr, "getarrval", NULL, 0, &adapter, &_9$$3, &_8$$3); + zephir_check_call_status(); + zephir_read_property(&_10$$3, this_ptr, ZEND_STRL("adapterFactory"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_11$$3, &_10$$3, "newinstance", NULL, 0, &adapterClass, &adapterFileName, &adapterOptions); + zephir_check_call_status(); + zephir_array_update_zval(&data, &adapterName, &_11$$3, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &adapters, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5, &adapters, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5)) { + break; + } + ZEPHIR_CALL_METHOD(&adapterName, &adapters, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&adapter, &adapters, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_12$$4); + ZVAL_STRING(&_12$$4, "adapter"); + ZEPHIR_CALL_METHOD(&adapterClass, this_ptr, "getarrval", NULL, 0, &adapter, &_12$$4); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_12$$4); + ZVAL_STRING(&_12$$4, "name"); + ZEPHIR_CALL_METHOD(&adapterFileName, this_ptr, "getarrval", NULL, 0, &adapter, &_12$$4); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_12$$4); + array_init(&_12$$4); + ZEPHIR_INIT_NVAR(&_13$$4); + ZVAL_STRING(&_13$$4, "options"); + ZEPHIR_CALL_METHOD(&adapterOptions, this_ptr, "getarrval", NULL, 0, &adapter, &_13$$4, &_12$$4); + zephir_check_call_status(); + zephir_read_property(&_14$$4, this_ptr, ZEND_STRL("adapterFactory"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_15$$4, &_14$$4, "newinstance", NULL, 0, &adapterClass, &adapterFileName, &adapterOptions); + zephir_check_call_status(); + zephir_array_update_zval(&data, &adapterName, &_15$$4, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &adapters, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&adapter); + ZEPHIR_INIT_NVAR(&adapterName); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "newinstance", NULL, 0, &name, &data, &timezone); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Html_Helper_Input_Select, processValue) +static PHP_METHOD(Phalcon_Logger_LoggerFactory, newInstance) { - zend_bool _0, _2$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *attributes_param = NULL, *value = NULL, value_sub, __$null, _1$$3, _3$$3, _4$$4; - zval attributes; - zval *this_ptr = getThis(); + zend_long ZEPHIR_LAST_CALL_STATUS; + zval adapters; + zval *name_param = NULL, *adapters_param = NULL, *timezone = NULL, timezone_sub, __$null; + zval name; - ZVAL_UNDEF(&attributes); - ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&timezone_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&adapters); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(name) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) + Z_PARAM_ARRAY(adapters) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(timezone, php_date_get_timezone_ce()) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &attributes_param, &value); - zephir_get_arrval(&attributes, attributes_param); - if (!value) { - value = &value_sub; - value = &__$null; - } - _0 = zephir_is_numeric(value); - if (!(_0)) { - _0 = !(ZEPHIR_IS_EMPTY(value)); + zephir_fetch_params(1, 1, 2, &name_param, &adapters_param, &timezone); + zephir_get_strval(&name, name_param); + if (!adapters_param) { + ZEPHIR_INIT_VAR(&adapters); + array_init(&adapters); + } else { + zephir_get_arrval(&adapters, adapters_param); } - if (_0) { - zephir_array_update_string(&attributes, SL("value"), value, PH_COPY | PH_SEPARATE); - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("selected"), PH_NOISY_CC | PH_READONLY); - _2$$3 = !(ZEPHIR_IS_EMPTY(&_1$$3)); - if (_2$$3) { - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("selected"), PH_NOISY_CC | PH_READONLY); - _2$$3 = ZEPHIR_IS_IDENTICAL(value, &_3$$3); - } - if (_2$$3) { - ZEPHIR_INIT_VAR(&_4$$4); - ZVAL_STRING(&_4$$4, "selected"); - zephir_array_update_string(&attributes, SL("selected"), &_4$$4, PH_COPY | PH_SEPARATE); - } + if (!timezone) { + timezone = &timezone_sub; + timezone = &__$null; } - RETURN_CTOR(&attributes); + object_init_ex(return_value, phalcon_logger_logger_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 414, &name, &adapters, timezone); + zephir_check_call_status(); + RETURN_MM(); } +static PHP_METHOD(Phalcon_Logger_LoggerFactory, getArrVal) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *collection_param = NULL, *index, index_sub, *defaultValue = NULL, defaultValue_sub, __$null, value; + zval collection; + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&value); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ARRAY(collection) + Z_PARAM_ZVAL(index) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(defaultValue) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 1, &collection_param, &index, &defaultValue); + ZEPHIR_OBS_COPY_OR_DUP(&collection, collection_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } + zephir_memory_observe(&value); + if (UNEXPECTED(!(zephir_array_isset_fetch(&value, &collection, index, 0)))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + RETURN_CCTOR(&value); +} - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Submit) +static PHP_METHOD(Phalcon_Logger_LoggerFactory, getExceptionClass) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Submit, phalcon, html_helper_input_submit, phalcon_html_helper_input_abstractinput_ce, NULL, 0); - zend_declare_property_string(phalcon_html_helper_input_submit_ce, SL("type"), "submit", ZEND_ACC_PROTECTED); - return SUCCESS; + RETURN_STRING("Phalcon\\Logger\\Exception"); } @@ -123963,14 +125419,26 @@ ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Submit) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Tel) +ZEPHIR_INIT_CLASS(Phalcon_Logger_LoggerInterface) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Tel, phalcon, html_helper_input_tel, phalcon_html_helper_input_abstractinput_ce, NULL, 0); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Logger, LoggerInterface, phalcon, logger_loggerinterface, phalcon_logger_loggerinterface_method_entry); - zend_declare_property_string(phalcon_html_helper_input_tel_ce, SL("type"), "tel", ZEND_ACC_PROTECTED); return SUCCESS; } +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, alert); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, critical); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, debug); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, emergency); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, error); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, getAdapter); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, getAdapters); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, getLogLevel); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, getName); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, info); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, log); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, notice); +ZEPHIR_DOC_METHOD(Phalcon_Logger_LoggerInterface, warning); @@ -123981,61 +125449,92 @@ ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Tel) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Text) +ZEPHIR_INIT_CLASS(Phalcon_Logger_Formatter_AbstractFormatter) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Text, phalcon, html_helper_input_text, phalcon_html_helper_input_abstractinput_ce, NULL, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Formatter, AbstractFormatter, phalcon, logger_formatter_abstractformatter, phalcon_support_helper_str_abstractstr_ce, phalcon_logger_formatter_abstractformatter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + zend_declare_property_string(phalcon_logger_formatter_abstractformatter_ce, SL("dateFormat"), "c", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_logger_formatter_abstractformatter_ce, SL("interpolatorLeft"), "%", ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_logger_formatter_abstractformatter_ce, SL("interpolatorRight"), "%", ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_logger_formatter_abstractformatter_ce, 1, phalcon_logger_formatter_formatterinterface_ce); return SUCCESS; } +static PHP_METHOD(Phalcon_Logger_Formatter_AbstractFormatter, getDateFormat) +{ + RETURN_MEMBER(getThis(), "dateFormat"); +} +static PHP_METHOD(Phalcon_Logger_Formatter_AbstractFormatter, setDateFormat) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *format_param = NULL; + zval format; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H -#endif - - - - + ZVAL_UNDEF(&format); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(format) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &format_param); + zephir_get_strval(&format, format_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("dateFormat"), &format); + ZEPHIR_MM_RESTORE(); +} -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Textarea) +static PHP_METHOD(Phalcon_Logger_Formatter_AbstractFormatter, getFormattedDate) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Textarea, phalcon, html_helper_input_textarea, phalcon_html_helper_input_abstractinput_ce, phalcon_html_helper_input_textarea_method_entry, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *item, item_sub, _0, _1; + zval *this_ptr = getThis(); - zend_declare_property_string(phalcon_html_helper_input_textarea_ce, SL("type"), "textarea", ZEND_ACC_PROTECTED); - return SUCCESS; + ZVAL_UNDEF(&item_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &item); + ZEPHIR_CALL_METHOD(&_0, item, "getdatetime", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("dateFormat"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "format", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Html_Helper_Input_Textarea, __toString) +static PHP_METHOD(Phalcon_Logger_Formatter_AbstractFormatter, getInterpolatedMessage) { - zval attributes; - zval value, _0, _1, _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval message; + zval *item, item_sub, *message_param = NULL, _0, _1, _2; zval *this_ptr = getThis(); - ZVAL_UNDEF(&value); + ZVAL_UNDEF(&item_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&message); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) + Z_PARAM_STR(message) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&attributes, &_0); - ZEPHIR_INIT_VAR(&_1); - array_init(&_1); - zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &_1); - zephir_memory_observe(&value); - if (!(zephir_array_isset_string_fetch(&value, &attributes, SL("value"), 0))) { - ZEPHIR_INIT_NVAR(&value); - ZVAL_STRING(&value, ""); - } - zephir_array_unset_string(&attributes, SL("type"), PH_SEPARATE); - zephir_array_unset_string(&attributes, SL("value"), PH_SEPARATE); - zephir_read_property(&_2, this_ptr, ZEND_STRL("type"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "renderfullelement", NULL, 0, &_2, &value, &attributes); + zephir_fetch_params(1, 2, 0, &item, &message_param); + zephir_get_strval(&message, message_param); + ZEPHIR_CALL_METHOD(&_0, item, "getcontext", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("interpolatorLeft"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_2, this_ptr, ZEND_STRL("interpolatorRight"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "tointerpolate", NULL, 0, &message, &_0, &_1, &_2); zephir_check_call_status(); RETURN_MM(); } @@ -124050,14 +125549,14 @@ static PHP_METHOD(Phalcon_Html_Helper_Input_Textarea, __toString) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Time) +ZEPHIR_INIT_CLASS(Phalcon_Logger_Formatter_FormatterInterface) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Time, phalcon, html_helper_input_time, phalcon_html_helper_input_abstractinput_ce, NULL, 0); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Logger\\Formatter, FormatterInterface, phalcon, logger_formatter_formatterinterface, phalcon_logger_formatter_formatterinterface_method_entry); - zend_declare_property_string(phalcon_html_helper_input_time_ce, SL("type"), "time", ZEND_ACC_PROTECTED); return SUCCESS; } +ZEPHIR_DOC_METHOD(Phalcon_Logger_Formatter_FormatterInterface, format); @@ -124068,30 +125567,93 @@ ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Time) -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Url) +ZEPHIR_INIT_CLASS(Phalcon_Logger_Formatter_Json) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Url, phalcon, html_helper_input_url, phalcon_html_helper_input_abstractinput_ce, NULL, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Formatter, Json, phalcon, logger_formatter_json, phalcon_logger_formatter_abstractformatter_ce, phalcon_logger_formatter_json_method_entry, 0); - zend_declare_property_string(phalcon_html_helper_input_url_ce, SL("type"), "url", ZEND_ACC_PROTECTED); return SUCCESS; } +static PHP_METHOD(Phalcon_Logger_Formatter_Json, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *dateFormat_param = NULL, *interpolatorLeft_param = NULL, *interpolatorRight_param = NULL; + zval dateFormat, interpolatorLeft, interpolatorRight; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&dateFormat); + ZVAL_UNDEF(&interpolatorLeft); + ZVAL_UNDEF(&interpolatorRight); + ZEND_PARSE_PARAMETERS_START(0, 3) + Z_PARAM_OPTIONAL + Z_PARAM_STR(dateFormat) + Z_PARAM_STR(interpolatorLeft) + Z_PARAM_STR(interpolatorRight) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 3, &dateFormat_param, &interpolatorLeft_param, &interpolatorRight_param); + if (!dateFormat_param) { + ZEPHIR_INIT_VAR(&dateFormat); + ZVAL_STRING(&dateFormat, "c"); + } else { + zephir_get_strval(&dateFormat, dateFormat_param); + } + if (!interpolatorLeft_param) { + ZEPHIR_INIT_VAR(&interpolatorLeft); + ZVAL_STRING(&interpolatorLeft, "%"); + } else { + zephir_get_strval(&interpolatorLeft, interpolatorLeft_param); + } + if (!interpolatorRight_param) { + ZEPHIR_INIT_VAR(&interpolatorRight); + ZVAL_STRING(&interpolatorRight, "%"); + } else { + zephir_get_strval(&interpolatorRight, interpolatorRight_param); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("dateFormat"), &dateFormat); + zephir_update_property_zval(this_ptr, ZEND_STRL("interpolatorLeft"), &interpolatorLeft); + zephir_update_property_zval(this_ptr, ZEND_STRL("interpolatorRight"), &interpolatorRight); + ZEPHIR_MM_RESTORE(); +} - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Week) +static PHP_METHOD(Phalcon_Logger_Formatter_Json, format) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Html\\Helper\\Input, Week, phalcon, html_helper_input_week, phalcon_html_helper_input_abstractinput_ce, NULL, 0); + zval _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *item, item_sub, message, options, _0, _2; + zval *this_ptr = getThis(); - zend_declare_property_string(phalcon_html_helper_input_week_ce, SL("type"), "week", ZEND_ACC_PROTECTED); - return SUCCESS; + ZVAL_UNDEF(&item_sub); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &item); + ZEPHIR_CALL_METHOD(&_0, item, "getmessage", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&message, this_ptr, "getinterpolatedmessage", NULL, 0, item, &_0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&options); + ZVAL_LONG(&options, (((((1 + 4) + 2) + 8) + 64) + 4194304)); + ZEPHIR_INIT_VAR(&_1); + zephir_create_array(&_1, 3, 0); + ZEPHIR_CALL_METHOD(&_2, item, "getlevelname", NULL, 0); + zephir_check_call_status(); + zephir_array_update_string(&_1, SL("level"), &_2, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_1, SL("message"), &message, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "getformatteddate", NULL, 0, item); + zephir_check_call_status(); + zephir_array_update_string(&_1, SL("timestamp"), &_2, PH_COPY | PH_SEPARATE); + zephir_json_encode(return_value, &_1, zephir_get_intval(&options) ); + RETURN_MM(); } @@ -124104,528 +125666,427 @@ ZEPHIR_INIT_CLASS(Phalcon_Html_Helper_Input_Week) -ZEPHIR_INIT_CLASS(Phalcon_Cli_Console) +ZEPHIR_INIT_CLASS(Phalcon_Logger_Formatter_Line) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli, Console, phalcon, cli_console, phalcon_application_abstractapplication_ce, phalcon_cli_console_method_entry, 0); - - zend_declare_property_null(phalcon_cli_console_ce, SL("arguments"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_cli_console_ce, SL("options"), ZEND_ACC_PROTECTED); - phalcon_cli_console_ce->create_object = zephir_init_properties_Phalcon_Cli_Console; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Formatter, Line, phalcon, logger_formatter_line, phalcon_logger_formatter_abstractformatter_ce, phalcon_logger_formatter_line_method_entry, 0); + zend_declare_property_null(phalcon_logger_formatter_line_ce, SL("format"), ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Cli_Console, handle) +static PHP_METHOD(Phalcon_Logger_Formatter_Line, __construct) { - zend_bool _8; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *arguments_param = NULL, __$false, className, dispatcher, module, moduleName, moduleObject, modules, path, router, task, _0, _1, _5, _6, _7, _9, _26, _27, _28, _29, _30, _31, _35, _2$$4, _3$$4, _4$$4, _10$$6, _11$$9, _15$$9, _20$$9, _21$$9, _22$$9, _12$$10, _13$$10, _14$$10, _16$$12, _17$$12, _18$$16, _19$$16, _23$$18, _24$$18, _25$$18, _32$$20, _33$$20, _34$$20, _36$$22, _37$$22; - zval arguments; + zval *format_param = NULL, *dateFormat_param = NULL, *interpolatorLeft_param = NULL, *interpolatorRight_param = NULL; + zval format, dateFormat, interpolatorLeft, interpolatorRight; zval *this_ptr = getThis(); - ZVAL_UNDEF(&arguments); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&dispatcher); - ZVAL_UNDEF(&module); - ZVAL_UNDEF(&moduleName); - ZVAL_UNDEF(&moduleObject); - ZVAL_UNDEF(&modules); - ZVAL_UNDEF(&path); - ZVAL_UNDEF(&router); - ZVAL_UNDEF(&task); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_26); - ZVAL_UNDEF(&_27); - ZVAL_UNDEF(&_28); - ZVAL_UNDEF(&_29); - ZVAL_UNDEF(&_30); - ZVAL_UNDEF(&_31); - ZVAL_UNDEF(&_35); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_10$$6); - ZVAL_UNDEF(&_11$$9); - ZVAL_UNDEF(&_15$$9); - ZVAL_UNDEF(&_20$$9); - ZVAL_UNDEF(&_21$$9); - ZVAL_UNDEF(&_22$$9); - ZVAL_UNDEF(&_12$$10); - ZVAL_UNDEF(&_13$$10); - ZVAL_UNDEF(&_14$$10); - ZVAL_UNDEF(&_16$$12); - ZVAL_UNDEF(&_17$$12); - ZVAL_UNDEF(&_18$$16); - ZVAL_UNDEF(&_19$$16); - ZVAL_UNDEF(&_23$$18); - ZVAL_UNDEF(&_24$$18); - ZVAL_UNDEF(&_25$$18); - ZVAL_UNDEF(&_32$$20); - ZVAL_UNDEF(&_33$$20); - ZVAL_UNDEF(&_34$$20); - ZVAL_UNDEF(&_36$$22); - ZVAL_UNDEF(&_37$$22); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) + ZVAL_UNDEF(&format); + ZVAL_UNDEF(&dateFormat); + ZVAL_UNDEF(&interpolatorLeft); + ZVAL_UNDEF(&interpolatorRight); + ZEND_PARSE_PARAMETERS_START(0, 4) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY_OR_NULL(arguments) + Z_PARAM_STR(format) + Z_PARAM_STR(dateFormat) + Z_PARAM_STR(interpolatorLeft) + Z_PARAM_STR(interpolatorRight) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &arguments_param); - if (!arguments_param) { - ZEPHIR_INIT_VAR(&arguments); + zephir_fetch_params(1, 0, 4, &format_param, &dateFormat_param, &interpolatorLeft_param, &interpolatorRight_param); + if (!format_param) { + ZEPHIR_INIT_VAR(&format); + ZVAL_STRING(&format, "[%date%][%level%] %message%"); } else { - zephir_get_arrval(&arguments, arguments_param); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_console_exception_ce, "A dependency injection container is required to access internal services", "phalcon/Cli/Console.zep", 45); - return; - } - zephir_read_property(&_1, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_1) != IS_NULL) { - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_4$$4); - ZVAL_STRING(&_4$$4, "console:boot"); - ZEPHIR_CALL_METHOD(&_3$$4, &_2$$4, "fire", NULL, 0, &_4$$4, this_ptr); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_3$$4)) { - RETURN_MM_BOOL(0); - } - } - zephir_read_property(&_5, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_7); - ZVAL_STRING(&_7, "router"); - ZEPHIR_CALL_METHOD(&_6, &_5, "getshared", NULL, 0, &_7); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&router, &_6); - _8 = !(zephir_fast_count_int(&arguments)); - if (_8) { - zephir_read_property(&_9, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); - _8 = zephir_is_true(&_9); + zephir_get_strval(&format, format_param); } - if (_8) { - zephir_read_property(&_10$$6, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &router, "handle", NULL, 0, &_10$$6); - zephir_check_call_status(); + if (!dateFormat_param) { + ZEPHIR_INIT_VAR(&dateFormat); + ZVAL_STRING(&dateFormat, "c"); } else { - ZEPHIR_CALL_METHOD(NULL, &router, "handle", NULL, 0, &arguments); - zephir_check_call_status(); + zephir_get_strval(&dateFormat, dateFormat_param); } - ZEPHIR_CALL_METHOD(&moduleName, &router, "getmodulename", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&moduleName))) { - ZEPHIR_OBS_NVAR(&moduleName); - zephir_read_property(&moduleName, this_ptr, ZEND_STRL("defaultModule"), PH_NOISY_CC); + if (!interpolatorLeft_param) { + ZEPHIR_INIT_VAR(&interpolatorLeft); + ZVAL_STRING(&interpolatorLeft, "%"); + } else { + zephir_get_strval(&interpolatorLeft, interpolatorLeft_param); } - if (zephir_is_true(&moduleName)) { - zephir_read_property(&_11$$9, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_11$$9) != IS_NULL) { - zephir_read_property(&_12$$10, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_14$$10); - ZVAL_STRING(&_14$$10, "console:beforeStartModule"); - ZEPHIR_CALL_METHOD(&_13$$10, &_12$$10, "fire", NULL, 0, &_14$$10, this_ptr, &moduleName); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_13$$10)) { - RETURN_MM_BOOL(0); - } - } - zephir_read_property(&_15$$9, this_ptr, ZEND_STRL("modules"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&modules, &_15$$9); - if (UNEXPECTED(!(zephir_array_isset(&modules, &moduleName)))) { - ZEPHIR_INIT_VAR(&_16$$12); - object_init_ex(&_16$$12, phalcon_cli_console_exception_ce); - ZEPHIR_INIT_VAR(&_17$$12); - ZEPHIR_CONCAT_SVS(&_17$$12, "Module '", &moduleName, "' isn't registered in the console container"); - ZEPHIR_CALL_METHOD(NULL, &_16$$12, "__construct", NULL, 33, &_17$$12); - zephir_check_call_status(); - zephir_throw_exception_debug(&_16$$12, "phalcon/Cli/Console.zep", 87); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_memory_observe(&module); - zephir_array_fetch(&module, &modules, &moduleName, PH_NOISY, "phalcon/Cli/Console.zep", 90); - if (UNEXPECTED(Z_TYPE_P(&module) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_console_exception_ce, "Invalid module definition path", "phalcon/Cli/Console.zep", 93); - return; - } - zephir_memory_observe(&className); - if (!(zephir_array_isset_string_fetch(&className, &module, SL("className"), 0))) { - ZEPHIR_INIT_NVAR(&className); - ZVAL_STRING(&className, "Module"); - } - zephir_memory_observe(&path); - if (zephir_array_isset_string_fetch(&path, &module, SL("path"), 0)) { - if (UNEXPECTED(!((zephir_file_exists(&path) == SUCCESS)))) { - ZEPHIR_INIT_VAR(&_18$$16); - object_init_ex(&_18$$16, phalcon_cli_console_exception_ce); - ZEPHIR_INIT_VAR(&_19$$16); - ZEPHIR_CONCAT_SVS(&_19$$16, "Module definition path '", &path, "' doesn't exist"); - ZEPHIR_CALL_METHOD(NULL, &_18$$16, "__construct", NULL, 33, &_19$$16); - zephir_check_call_status(); - zephir_throw_exception_debug(&_18$$16, "phalcon/Cli/Console.zep", 104); - ZEPHIR_MM_RESTORE(); - return; - } - if (!(zephir_class_exists(&className, zephir_is_true(&__$false) ))) { - if (zephir_require_once_zval(&path) == FAILURE) { - RETURN_MM_NULL(); - } - } - } - zephir_read_property(&_15$$9, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&moduleObject, &_15$$9, "get", NULL, 0, &className); - zephir_check_call_status(); - zephir_read_property(&_20$$9, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &moduleObject, "registerautoloaders", NULL, 0, &_20$$9); - zephir_check_call_status(); - zephir_read_property(&_21$$9, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &moduleObject, "registerservices", NULL, 0, &_21$$9); - zephir_check_call_status(); - zephir_read_property(&_22$$9, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_22$$9) != IS_NULL) { - zephir_read_property(&_23$$18, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_25$$18); - ZVAL_STRING(&_25$$18, "console:afterStartModule"); - ZEPHIR_CALL_METHOD(&_24$$18, &_23$$18, "fire", NULL, 0, &_25$$18, this_ptr, &moduleObject); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_24$$18)) { - RETURN_MM_BOOL(0); - } - } + if (!interpolatorRight_param) { + ZEPHIR_INIT_VAR(&interpolatorRight); + ZVAL_STRING(&interpolatorRight, "%"); + } else { + zephir_get_strval(&interpolatorRight, interpolatorRight_param); } - zephir_read_property(&_26, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_7); - ZVAL_STRING(&_7, "dispatcher"); - ZEPHIR_CALL_METHOD(&_6, &_26, "getshared", NULL, 0, &_7); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&dispatcher, &_6); - ZEPHIR_CALL_METHOD(&_6, &router, "getmodulename", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setmodulename", NULL, 0, &_6); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_27, &router, "gettaskname", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &dispatcher, "settaskname", NULL, 0, &_27); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_28, &router, "getactionname", NULL, 0); + zephir_update_property_zval(this_ptr, ZEND_STRL("format"), &format); + zephir_update_property_zval(this_ptr, ZEND_STRL("dateFormat"), &dateFormat); + zephir_update_property_zval(this_ptr, ZEND_STRL("interpolatorLeft"), &interpolatorLeft); + zephir_update_property_zval(this_ptr, ZEND_STRL("interpolatorRight"), &interpolatorRight); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Logger_Formatter_Line, format) +{ + zval _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *item, item_sub, message, _0, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&item_sub); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &item); + zephir_read_property(&_0, this_ptr, ZEND_STRL("format"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + zephir_create_array(&_1, 3, 0); + zephir_read_property(&_2, this_ptr, ZEND_STRL("interpolatorLeft"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_3, this_ptr, ZEND_STRL("interpolatorRight"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_4); + ZEPHIR_CONCAT_VSV(&_4, &_2, "date", &_3); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "getformatteddate", NULL, 0, item); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setactionname", NULL, 0, &_28); + zephir_array_update_zval(&_1, &_4, &_5, PH_COPY); + zephir_read_property(&_6, this_ptr, ZEND_STRL("interpolatorLeft"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_7, this_ptr, ZEND_STRL("interpolatorRight"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_8); + ZEPHIR_CONCAT_VSV(&_8, &_6, "level", &_7); + ZEPHIR_CALL_METHOD(&_5, item, "getlevelname", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_29, &router, "getparameters", NULL, 0); + zephir_array_update_zval(&_1, &_8, &_5, PH_COPY); + zephir_read_property(&_9, this_ptr, ZEND_STRL("interpolatorLeft"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_10, this_ptr, ZEND_STRL("interpolatorRight"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_11); + ZEPHIR_CONCAT_VSV(&_11, &_9, "message", &_10); + ZEPHIR_CALL_METHOD(&_5, item, "getmessage", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setparams", NULL, 0, &_29); + zephir_array_update_zval(&_1, &_11, &_5, PH_COPY); + ZEPHIR_CALL_FUNCTION(&message, "strtr", NULL, 5, &_0, &_1); zephir_check_call_status(); - zephir_read_property(&_30, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setoptions", NULL, 0, &_30); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getinterpolatedmessage", NULL, 0, item, &message); zephir_check_call_status(); - zephir_read_property(&_31, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_31) != IS_NULL) { - zephir_read_property(&_32$$20, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_34$$20); - ZVAL_STRING(&_34$$20, "console:beforeHandleTask"); - ZEPHIR_CALL_METHOD(&_33$$20, &_32$$20, "fire", NULL, 0, &_34$$20, this_ptr, &dispatcher); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_33$$20)) { - RETURN_MM_BOOL(0); - } + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Logger_Formatter_Line, getFormat) +{ + + RETURN_MEMBER(getThis(), "format"); +} + +static PHP_METHOD(Phalcon_Logger_Formatter_Line, setFormat) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *format_param = NULL; + zval format; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&format); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(format) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &format_param); + zephir_get_strval(&format, format_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("format"), &format); + RETURN_THIS(); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_AbstractAdapter) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Logger\\Adapter, AbstractAdapter, phalcon, logger_adapter_abstractadapter, phalcon_logger_adapter_abstractadapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + zend_declare_property_string(phalcon_logger_adapter_abstractadapter_ce, SL("defaultFormatter"), "Phalcon\\Logger\\Formatter\\Line", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_adapter_abstractadapter_ce, SL("formatter"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_logger_adapter_abstractadapter_ce, SL("inTransaction"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_adapter_abstractadapter_ce, SL("queue"), ZEND_ACC_PROTECTED); + phalcon_logger_adapter_abstractadapter_ce->create_object = zephir_init_properties_Phalcon_Logger_Adapter_AbstractAdapter; + + zend_class_implements(phalcon_logger_adapter_abstractadapter_ce, 1, phalcon_logger_adapter_adapterinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, __destruct) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("inTransaction"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_0)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "There is an active transaction", "phalcon/Logger/Adapter/AbstractAdapter.zep", 64); + return; } - ZEPHIR_CALL_METHOD(&task, &dispatcher, "dispatch", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "close", NULL, 0); zephir_check_call_status(); - zephir_read_property(&_35, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_35) != IS_NULL) { - zephir_read_property(&_36$$22, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_37$$22); - ZVAL_STRING(&_37$$22, "console:afterHandleTask"); - ZEPHIR_CALL_METHOD(NULL, &_36$$22, "fire", NULL, 0, &_37$$22, this_ptr, &task); - zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, __serialize) +{ + + ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_logger_exception_ce, "This object cannot be serialized", "phalcon/Logger/Adapter/AbstractAdapter.zep", 75); + return; +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, __unserialize) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *data_param = NULL; + zval data; + + ZVAL_UNDEF(&data); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(data) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &data_param); + zephir_get_arrval(&data, data_param); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "This object cannot be unserialized", "phalcon/Logger/Adapter/AbstractAdapter.zep", 83); + return; +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, add) +{ + zval *item, item_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&item_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &item); + zephir_update_property_array_append(this_ptr, SL("queue"), item); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, begin) +{ + zval __$true, __$false; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("inTransaction"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("inTransaction"), &__$false); } - RETURN_CCTOR(&task); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Cli_Console, setArgument) +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, commit) { + zval item, queue, _0, *_1, _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_6 = NULL; + zephir_fcall_cache_entry *_3 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool str, shift, _0; - zval *arguments_param = NULL, *str_param = NULL, *shift_param = NULL, __$true, arg, pos, args, opts, handleArgs, *_1, _2, _3$$5, _4$$5, _5$$5, _7$$6, _8$$7, _9$$7, _10$$7, _11$$7, _12$$7, _13$$7, _14$$7, _15$$8, _16$$8, _17$$8, _18$$9, _19$$9, _20$$9, _21$$10, _22$$10, _23$$14, _24$$14, _25$$14, _26$$15, _27$$16, _28$$16, _29$$16, _30$$16, _31$$16, _32$$16, _33$$16, _34$$17, _35$$17, _36$$17, _37$$18, _38$$18, _39$$18, _40$$19, _41$$19, _42$$22, _43$$22, _44$$24, _45$$25, _46$$26; - zval arguments; zval *this_ptr = getThis(); - ZVAL_UNDEF(&arguments); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&arg); - ZVAL_UNDEF(&pos); - ZVAL_UNDEF(&args); - ZVAL_UNDEF(&opts); - ZVAL_UNDEF(&handleArgs); + ZVAL_UNDEF(&item); + ZVAL_UNDEF(&queue); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_8$$7); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_10$$7); - ZVAL_UNDEF(&_11$$7); - ZVAL_UNDEF(&_12$$7); - ZVAL_UNDEF(&_13$$7); - ZVAL_UNDEF(&_14$$7); - ZVAL_UNDEF(&_15$$8); - ZVAL_UNDEF(&_16$$8); - ZVAL_UNDEF(&_17$$8); - ZVAL_UNDEF(&_18$$9); - ZVAL_UNDEF(&_19$$9); - ZVAL_UNDEF(&_20$$9); - ZVAL_UNDEF(&_21$$10); - ZVAL_UNDEF(&_22$$10); - ZVAL_UNDEF(&_23$$14); - ZVAL_UNDEF(&_24$$14); - ZVAL_UNDEF(&_25$$14); - ZVAL_UNDEF(&_26$$15); - ZVAL_UNDEF(&_27$$16); - ZVAL_UNDEF(&_28$$16); - ZVAL_UNDEF(&_29$$16); - ZVAL_UNDEF(&_30$$16); - ZVAL_UNDEF(&_31$$16); - ZVAL_UNDEF(&_32$$16); - ZVAL_UNDEF(&_33$$16); - ZVAL_UNDEF(&_34$$17); - ZVAL_UNDEF(&_35$$17); - ZVAL_UNDEF(&_36$$17); - ZVAL_UNDEF(&_37$$18); - ZVAL_UNDEF(&_38$$18); - ZVAL_UNDEF(&_39$$18); - ZVAL_UNDEF(&_40$$19); - ZVAL_UNDEF(&_41$$19); - ZVAL_UNDEF(&_42$$22); - ZVAL_UNDEF(&_43$$22); - ZVAL_UNDEF(&_44$$24); - ZVAL_UNDEF(&_45$$25); - ZVAL_UNDEF(&_46$$26); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 3) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY_OR_NULL(arguments) - Z_PARAM_BOOL(str) - Z_PARAM_BOOL(shift) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 3, &arguments_param, &str_param, &shift_param); - if (!arguments_param) { - ZEPHIR_INIT_VAR(&arguments); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&arguments, arguments_param); - } - if (!str_param) { - str = 1; - } else { - if (UNEXPECTED(Z_TYPE_P(str_param) != IS_TRUE && Z_TYPE_P(str_param) != IS_FALSE)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'str' must be of the type bool")); - RETURN_MM_NULL(); - } - str = (Z_TYPE_P(str_param) == IS_TRUE); - } - if (!shift_param) { - shift = 1; - } else { - if (UNEXPECTED(Z_TYPE_P(shift_param) != IS_TRUE && Z_TYPE_P(shift_param) != IS_FALSE)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'shift' must be of the type bool")); - RETURN_MM_NULL(); - } - shift = (Z_TYPE_P(shift_param) == IS_TRUE); - } - ZEPHIR_INIT_VAR(&args); - array_init(&args); - ZEPHIR_INIT_VAR(&opts); - array_init(&opts); - ZEPHIR_INIT_VAR(&handleArgs); - array_init(&handleArgs); - _0 = shift; - if (_0) { - _0 = ((zephir_fast_count_int(&arguments)) ? 1 : 0); - } - if (_0) { - ZEPHIR_MAKE_REF(&arguments); - ZEPHIR_CALL_FUNCTION(NULL, "array_shift", NULL, 22, &arguments); - ZEPHIR_UNREF(&arguments); - zephir_check_call_status(); - } - zephir_is_iterable(&arguments, 0, "phalcon/Cli/Console.zep", 185); - if (Z_TYPE_P(&arguments) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&arguments), _1) + + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checktransaction", NULL, 68); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("queue"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&queue, &_0); + zephir_is_iterable(&queue, 0, "phalcon/Logger/Adapter/AbstractAdapter.zep", 132); + if (Z_TYPE_P(&queue) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&queue), _1) { - ZEPHIR_INIT_NVAR(&arg); - ZVAL_COPY(&arg, _1); - if (Z_TYPE_P(&arg) == IS_STRING) { - ZEPHIR_INIT_NVAR(&_3$$5); - ZVAL_STRING(&_3$$5, "--"); - ZVAL_LONG(&_4$$5, 2); - ZEPHIR_CALL_FUNCTION(&_5$$5, "strncmp", &_6, 190, &arg, &_3$$5, &_4$$5); - zephir_check_call_status(); - if (ZEPHIR_IS_LONG(&_5$$5, 0)) { - ZEPHIR_INIT_NVAR(&_7$$6); - ZVAL_STRING(&_7$$6, "="); - ZEPHIR_INIT_NVAR(&pos); - zephir_fast_strpos(&pos, &arg, &_7$$6, 0 ); - if (zephir_is_true(&pos)) { - ZEPHIR_INIT_NVAR(&_8$$7); - ZVAL_LONG(&_9$$7, (zephir_get_numberval(&pos) + 1)); - ZEPHIR_INIT_NVAR(&_10$$7); - zephir_substr(&_10$$7, &arg, zephir_get_intval(&_9$$7), 0, ZEPHIR_SUBSTR_NO_LENGTH); - zephir_fast_trim(&_8$$7, &_10$$7, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_11$$7); - ZVAL_LONG(&_12$$7, 2); - ZVAL_LONG(&_13$$7, (zephir_get_numberval(&pos) - 2)); - ZEPHIR_INIT_NVAR(&_14$$7); - zephir_substr(&_14$$7, &arg, 2 , zephir_get_intval(&_13$$7), 0); - zephir_fast_trim(&_11$$7, &_14$$7, NULL , ZEPHIR_TRIM_BOTH); - zephir_array_update_zval(&opts, &_11$$7, &_8$$7, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_INIT_NVAR(&_15$$8); - ZVAL_LONG(&_16$$8, 2); - ZEPHIR_INIT_NVAR(&_17$$8); - zephir_substr(&_17$$8, &arg, 2 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - zephir_fast_trim(&_15$$8, &_17$$8, NULL , ZEPHIR_TRIM_BOTH); - zephir_array_update_zval(&opts, &_15$$8, &__$true, PH_COPY | PH_SEPARATE); - } - } else { - ZEPHIR_INIT_NVAR(&_18$$9); - ZVAL_STRING(&_18$$9, "-"); - ZVAL_LONG(&_19$$9, 1); - ZEPHIR_CALL_FUNCTION(&_20$$9, "strncmp", &_6, 190, &arg, &_18$$9, &_19$$9); - zephir_check_call_status(); - if (ZEPHIR_IS_LONG(&_20$$9, 0)) { - ZVAL_LONG(&_21$$10, 1); - ZEPHIR_INIT_NVAR(&_22$$10); - zephir_substr(&_22$$10, &arg, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - zephir_array_update_zval(&opts, &_22$$10, &__$true, PH_COPY | PH_SEPARATE); - } else { - zephir_array_append(&args, &arg, PH_SEPARATE, "phalcon/Cli/Console.zep", 177); - } - } - } else { - zephir_array_append(&args, &arg, PH_SEPARATE, "phalcon/Cli/Console.zep", 181); - } + ZEPHIR_INIT_NVAR(&item); + ZVAL_COPY(&item, _1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "process", &_3, 0, &item); + zephir_check_call_status(); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &arguments, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &queue, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_2, &arguments, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_2, &queue, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_2)) { break; } - ZEPHIR_CALL_METHOD(&arg, &arguments, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&item, &queue, "current", NULL, 0); zephir_check_call_status(); - if (Z_TYPE_P(&arg) == IS_STRING) { - ZEPHIR_INIT_NVAR(&_23$$14); - ZVAL_STRING(&_23$$14, "--"); - ZVAL_LONG(&_24$$14, 2); - ZEPHIR_CALL_FUNCTION(&_25$$14, "strncmp", &_6, 190, &arg, &_23$$14, &_24$$14); - zephir_check_call_status(); - if (ZEPHIR_IS_LONG(&_25$$14, 0)) { - ZEPHIR_INIT_NVAR(&_26$$15); - ZVAL_STRING(&_26$$15, "="); - ZEPHIR_INIT_NVAR(&pos); - zephir_fast_strpos(&pos, &arg, &_26$$15, 0 ); - if (zephir_is_true(&pos)) { - ZEPHIR_INIT_NVAR(&_27$$16); - ZVAL_LONG(&_28$$16, (zephir_get_numberval(&pos) + 1)); - ZEPHIR_INIT_NVAR(&_29$$16); - zephir_substr(&_29$$16, &arg, zephir_get_intval(&_28$$16), 0, ZEPHIR_SUBSTR_NO_LENGTH); - zephir_fast_trim(&_27$$16, &_29$$16, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_30$$16); - ZVAL_LONG(&_31$$16, 2); - ZVAL_LONG(&_32$$16, (zephir_get_numberval(&pos) - 2)); - ZEPHIR_INIT_NVAR(&_33$$16); - zephir_substr(&_33$$16, &arg, 2 , zephir_get_intval(&_32$$16), 0); - zephir_fast_trim(&_30$$16, &_33$$16, NULL , ZEPHIR_TRIM_BOTH); - zephir_array_update_zval(&opts, &_30$$16, &_27$$16, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_INIT_NVAR(&_34$$17); - ZVAL_LONG(&_35$$17, 2); - ZEPHIR_INIT_NVAR(&_36$$17); - zephir_substr(&_36$$17, &arg, 2 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - zephir_fast_trim(&_34$$17, &_36$$17, NULL , ZEPHIR_TRIM_BOTH); - zephir_array_update_zval(&opts, &_34$$17, &__$true, PH_COPY | PH_SEPARATE); - } - } else { - ZEPHIR_INIT_NVAR(&_37$$18); - ZVAL_STRING(&_37$$18, "-"); - ZVAL_LONG(&_38$$18, 1); - ZEPHIR_CALL_FUNCTION(&_39$$18, "strncmp", &_6, 190, &arg, &_37$$18, &_38$$18); - zephir_check_call_status(); - if (ZEPHIR_IS_LONG(&_39$$18, 0)) { - ZVAL_LONG(&_40$$19, 1); - ZEPHIR_INIT_NVAR(&_41$$19); - zephir_substr(&_41$$19, &arg, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - zephir_array_update_zval(&opts, &_41$$19, &__$true, PH_COPY | PH_SEPARATE); - } else { - zephir_array_append(&args, &arg, PH_SEPARATE, "phalcon/Cli/Console.zep", 177); - } - } - } else { - zephir_array_append(&args, &arg, PH_SEPARATE, "phalcon/Cli/Console.zep", 181); - } - ZEPHIR_CALL_METHOD(NULL, &arguments, "next", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "process", &_3, 0, &item); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &queue, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&arg); - if (str) { - ZEPHIR_INIT_VAR(&_42$$22); - ZEPHIR_CALL_CE_STATIC(&_43$$22, phalcon_cli_router_route_ce, "getdelimiter", NULL, 0); + ZEPHIR_INIT_NVAR(&item); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "resettransaction", NULL, 69); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, getFormatter) +{ + zval _0, _1$$3, _2$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("formatter"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("defaultFormatter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&_1$$3, &_2$$3); zephir_check_call_status(); - zephir_fast_join(&_42$$22, &_43$$22, &args); - zephir_update_property_zval(this_ptr, ZEND_STRL("arguments"), &_42$$22); - } else { - if (zephir_fast_count_int(&args)) { - ZEPHIR_MAKE_REF(&args); - ZEPHIR_CALL_FUNCTION(&_44$$24, "array_shift", NULL, 22, &args); - ZEPHIR_UNREF(&args); - zephir_check_call_status(); - zephir_array_update_string(&handleArgs, SL("task"), &_44$$24, PH_COPY | PH_SEPARATE); - } - if (zephir_fast_count_int(&args)) { - ZEPHIR_MAKE_REF(&args); - ZEPHIR_CALL_FUNCTION(&_45$$25, "array_shift", NULL, 22, &args); - ZEPHIR_UNREF(&args); - zephir_check_call_status(); - zephir_array_update_string(&handleArgs, SL("action"), &_45$$25, PH_COPY | PH_SEPARATE); - } - if (zephir_fast_count_int(&args)) { - ZEPHIR_INIT_VAR(&_46$$26); - zephir_fast_array_merge(&_46$$26, &handleArgs, &args); - ZEPHIR_CPY_WRT(&handleArgs, &_46$$26); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("arguments"), &handleArgs); + zephir_update_property_zval(this_ptr, ZEND_STRL("formatter"), &_1$$3); } - zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &opts); + RETURN_MM_MEMBER(getThis(), "formatter"); +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, inTransaction) +{ + + RETURN_MEMBER(getThis(), "inTransaction"); +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, process) +{ +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, rollback) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checktransaction", NULL, 68); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "resettransaction", NULL, 69); + zephir_check_call_status(); RETURN_THIS(); } -zend_object *zephir_init_properties_Phalcon_Cli_Console(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, setFormatter) { - zval _0, _2, _4, _1$$3, _3$$4, _5$$5; + zval *formatter, formatter_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&formatter_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(formatter, phalcon_logger_formatter_formatterinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &formatter); + zephir_update_property_zval(this_ptr, ZEND_STRL("formatter"), formatter); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, getFormattedItem) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *item, item_sub, formatter; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&item_sub); + ZVAL_UNDEF(&formatter); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &item); + ZEPHIR_CALL_METHOD(&formatter, this_ptr, "getformatter", NULL, 0); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(&formatter, "format", NULL, 0, item); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, checkTransaction) +{ + zval _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("inTransaction"), PH_NOISY_CC | PH_READONLY); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_logger_exception_ce, "There is no active transaction", "phalcon/Logger/Adapter/AbstractAdapter.zep", 213); + return; + } +} + +static PHP_METHOD(Phalcon_Logger_Adapter_AbstractAdapter, resetTransaction) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval __$true, __$false, _0; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("queue"), &_0); + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("inTransaction"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("inTransaction"), &__$false); + } + ZEPHIR_MM_RESTORE(); +} + +zend_object *zephir_init_properties_Phalcon_Logger_Adapter_AbstractAdapter(zend_class_entry *class_type) +{ + zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); @@ -124634,23 +126095,11 @@ zend_object *zephir_init_properties_Phalcon_Cli_Console(zend_class_entry *class_ { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("queue"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("modules"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("modules"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("arguments"), &_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("queue"), &_1$$3); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -124667,383 +126116,434 @@ zend_object *zephir_init_properties_Phalcon_Cli_Console(zend_class_entry *class_ -ZEPHIR_INIT_CLASS(Phalcon_Cli_Dispatcher) +ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_AdapterInterface) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli, Dispatcher, phalcon, cli_dispatcher, phalcon_dispatcher_abstractdispatcher_ce, phalcon_cli_dispatcher_method_entry, 0); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Logger\\Adapter, AdapterInterface, phalcon, logger_adapter_adapterinterface, phalcon_logger_adapter_adapterinterface_method_entry); - zend_declare_property_string(phalcon_cli_dispatcher_ce, SL("defaultHandler"), "main", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_cli_dispatcher_ce, SL("defaultAction"), "main", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_cli_dispatcher_ce, SL("handlerSuffix"), "Task", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_cli_dispatcher_ce, SL("options"), ZEND_ACC_PROTECTED); - phalcon_cli_dispatcher_ce->create_object = zephir_init_properties_Phalcon_Cli_Dispatcher; + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, add); +ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, begin); +ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, close); +ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, commit); +ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, getFormatter); +ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, inTransaction); +ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, process); +ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, rollback); +ZEPHIR_DOC_METHOD(Phalcon_Logger_Adapter_AdapterInterface, setFormatter); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_Noop) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Adapter, Noop, phalcon, logger_adapter_noop, phalcon_logger_adapter_abstractadapter_ce, phalcon_logger_adapter_noop_method_entry, 0); - zend_class_implements(phalcon_cli_dispatcher_ce, 1, phalcon_cli_dispatcherinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Cli_Dispatcher, callActionMethod) +static PHP_METHOD(Phalcon_Logger_Adapter_Noop, close) +{ + + RETURN_BOOL(1); +} + +static PHP_METHOD(Phalcon_Logger_Adapter_Noop, process) +{ + zval *item, item_sub; + + ZVAL_UNDEF(&item_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &item); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_Stream) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Adapter, Stream, phalcon, logger_adapter_stream, phalcon_logger_adapter_abstractadapter_ce, phalcon_logger_adapter_stream_method_entry, 0); + + zend_declare_property_string(phalcon_logger_adapter_stream_ce, SL("mode"), "ab", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_adapter_stream_ce, SL("name"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_logger_adapter_stream_ce, SL("options"), ZEND_ACC_PROTECTED); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Logger_Adapter_Stream, __construct) { - zval _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval actionMethod; - zval *handler, handler_sub, *actionMethod_param = NULL, params, *params_param = NULL, _0, _1, _2; + zval options; + zval *name_param = NULL, *options_param = NULL, mode, _0, _1; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&handler_sub); - ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&mode); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&actionMethod); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_ZVAL(handler) - Z_PARAM_STR(actionMethod) + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(name) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(params) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &handler, &actionMethod_param, ¶ms_param); - zephir_get_strval(&actionMethod, actionMethod_param); - if (!params_param) { - ZEPHIR_INIT_VAR(¶ms); - array_init(¶ms); + zephir_fetch_params(1, 1, 1, &name_param, &options_param); + zephir_get_strval(&name, name_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - ZEPHIR_OBS_COPY_OR_DUP(¶ms, params_param); + zephir_get_arrval(&options, options_param); } - ZEPHIR_CALL_FUNCTION(&_0, "array_values", NULL, 14, ¶ms); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(¶ms, &_0); - ZEPHIR_INIT_VAR(&_1); - zephir_read_property(&_2, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - zephir_fast_array_merge(&_1, ¶ms, &_2); - ZEPHIR_CPY_WRT(¶ms, &_1); - ZEPHIR_INIT_VAR(&_3); - zephir_create_array(&_3, 2, 0); - zephir_array_fast_append(&_3, handler); - zephir_array_fast_append(&_3, &actionMethod); - ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_3, ¶ms); + if (1 == zephir_array_isset_string(&options, SL("mode"))) { + zephir_memory_observe(&mode); + zephir_array_fetch_string(&mode, &options, SL("mode"), PH_NOISY, "phalcon/Logger/Adapter/Stream.zep", 74); + } else { + ZEPHIR_INIT_NVAR(&mode); + ZVAL_STRING(&mode, "ab"); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "r"); + ZEPHIR_CALL_FUNCTION(&_1, "mb_strpos", NULL, 86, &mode, &_0); zephir_check_call_status(); - RETURN_MM(); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_1)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "Adapter cannot be opened in read mode", "phalcon/Logger/Adapter/Stream.zep", 76); + return; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); + zephir_update_property_zval(this_ptr, ZEND_STRL("mode"), &mode); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Cli_Dispatcher, getActiveTask) +static PHP_METHOD(Phalcon_Logger_Adapter_Stream, close) { - RETURN_MEMBER(getThis(), "activeHandler"); + RETURN_BOOL(1); } -static PHP_METHOD(Phalcon_Cli_Dispatcher, getLastTask) +static PHP_METHOD(Phalcon_Logger_Adapter_Stream, getName) { - RETURN_MEMBER(getThis(), "lastHandler"); + RETURN_MEMBER(getThis(), "name"); } -static PHP_METHOD(Phalcon_Cli_Dispatcher, getOption) +static PHP_METHOD(Phalcon_Logger_Adapter_Stream, process) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *option, option_sub, *filters = NULL, filters_sub, *defaultValue = NULL, defaultValue_sub, __$null, options, filter, optionValue, container, _0, _3, _4, _1$$5, _2$$5; + zval *item, item_sub, handler, message, _0, _1, _6, _7, _8, _2$$3, _3$$3, _4$$3, _5$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&option_sub); - ZVAL_UNDEF(&filters_sub); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&filter); - ZVAL_UNDEF(&optionValue); - ZVAL_UNDEF(&container); + ZVAL_UNDEF(&item_sub); + ZVAL_UNDEF(&handler); + ZVAL_UNDEF(&message); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1$$5); - ZVAL_UNDEF(&_2$$5); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ZVAL(option) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(filters) - Z_PARAM_ZVAL_OR_NULL(defaultValue) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &option, &filters, &defaultValue); - if (!filters) { - filters = &filters_sub; - filters = &__$null; - } - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&options, &_0); - zephir_memory_observe(&optionValue); - if (!(zephir_array_isset_fetch(&optionValue, &options, option, 0))) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); - } - if (Z_TYPE_P(filters) == IS_NULL) { - RETURN_CCTOR(&optionValue); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$5); - ZVAL_STRING(&_1$$5, "A dependency injection container is required to access the 'filter' service"); - ZVAL_LONG(&_2$$5, 0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "throwdispatchexception", NULL, 0, &_1$$5, &_2$$5); + zephir_fetch_params(1, 1, 0, &item); + zephir_read_property(&_0, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_1, this_ptr, ZEND_STRL("mode"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&handler, this_ptr, "phpfopen", NULL, 0, &_0, &_1); + zephir_check_call_status(); + if (!(Z_TYPE_P(&handler) == IS_RESOURCE)) { + ZEPHIR_INIT_VAR(&_2$$3); + object_init_ex(&_2$$3, spl_ce_LogicException); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("mode"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_5$$3); + ZEPHIR_CONCAT_SVSVS(&_5$$3, "The file '", &_3$$3, "' cannot be opened with mode '", &_4$$3, "'"); + ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 409, &_5$$3); zephir_check_call_status(); + zephir_throw_exception_debug(&_2$$3, "phalcon/Logger/Adapter/Stream.zep", 119); + ZEPHIR_MM_RESTORE(); + return; } - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, "filter"); - ZEPHIR_CALL_METHOD(&_3, &container, "getshared", NULL, 0, &_4); + ZVAL_LONG(&_6, 2); + ZEPHIR_CALL_FUNCTION(NULL, "flock", NULL, 132, &handler, &_6); zephir_check_call_status(); - ZEPHIR_CPY_WRT(&filter, &_3); - ZEPHIR_RETURN_CALL_METHOD(&filter, "sanitize", NULL, 0, &optionValue, filters); + ZEPHIR_CALL_METHOD(&_7, this_ptr, "getformatteditem", NULL, 0, item); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_INIT_VAR(&_8); + ZEPHIR_GET_CONSTANT(&_8, "PHP_EOL"); + ZEPHIR_INIT_VAR(&message); + ZEPHIR_CONCAT_VV(&message, &_7, &_8); + zephir_fwrite(NULL, &handler, &message); + zephir_fclose(&handler); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Cli_Dispatcher, getOptions) +static PHP_METHOD(Phalcon_Logger_Adapter_Stream, phpFopen) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *filename_param = NULL, *mode_param = NULL; + zval filename, mode; - RETURN_MEMBER(getThis(), "options"); + ZVAL_UNDEF(&filename); + ZVAL_UNDEF(&mode); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(filename) + Z_PARAM_STR(mode) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &filename_param, &mode_param); + zephir_get_strval(&filename, filename_param); + zephir_get_strval(&mode, mode_param); + ZEPHIR_RETURN_CALL_FUNCTION("fopen", NULL, 140, &filename, &mode); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Cli_Dispatcher, getTaskName) -{ - RETURN_MEMBER(getThis(), "handlerName"); -} -static PHP_METHOD(Phalcon_Cli_Dispatcher, getTaskSuffix) -{ - RETURN_MEMBER(getThis(), "handlerSuffix"); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Cli_Dispatcher, hasOption) -{ - zval *option, option_sub, _0; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&option_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(option) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &option); - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - RETURN_BOOL(zephir_array_isset(&_0, option)); -} -static PHP_METHOD(Phalcon_Cli_Dispatcher, setDefaultTask) + + +ZEPHIR_INIT_CLASS(Phalcon_Logger_Adapter_Syslog) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *taskName_param = NULL; - zval taskName; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Logger\\Adapter, Syslog, phalcon, logger_adapter_syslog, phalcon_logger_adapter_abstractadapter_ce, phalcon_logger_adapter_syslog_method_entry, 0); - ZVAL_UNDEF(&taskName); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(taskName) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &taskName_param); - zephir_get_strval(&taskName, taskName_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultHandler"), &taskName); - ZEPHIR_MM_RESTORE(); + zend_declare_property_long(phalcon_logger_adapter_syslog_ce, SL("facility"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_logger_adapter_syslog_ce, SL("name"), "", ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_logger_adapter_syslog_ce, SL("opened"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_logger_adapter_syslog_ce, SL("option"), 0, ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Cli_Dispatcher, setOptions) +static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *options_param = NULL; zval options; + zval *name_param = NULL, *options_param = NULL, facility, option; + zval name; zval *this_ptr = getThis(); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&facility); + ZVAL_UNDEF(&option); ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(1, 1) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(name) + Z_PARAM_OPTIONAL Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &options_param); - zephir_get_arrval(&options, options_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); + zephir_fetch_params(1, 1, 1, &name_param, &options_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + zephir_memory_observe(&facility); + if (!(zephir_array_isset_string_fetch(&facility, &options, SL("facility"), 0))) { + ZEPHIR_INIT_NVAR(&facility); + ZVAL_LONG(&facility, 8); + } + zephir_memory_observe(&option); + if (!(zephir_array_isset_string_fetch(&option, &options, SL("option"), 0))) { + ZEPHIR_INIT_NVAR(&option); + ZVAL_LONG(&option, 4); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); + zephir_update_property_zval(this_ptr, ZEND_STRL("option"), &option); + zephir_update_property_zval(this_ptr, ZEND_STRL("facility"), &facility); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Cli_Dispatcher, setTaskName) +static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, close) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *taskName_param = NULL; - zval taskName; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&taskName); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(taskName) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &taskName_param); - zephir_get_strval(&taskName, taskName_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("handlerName"), &taskName); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Cli_Dispatcher, setTaskSuffix) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *taskSuffix_param = NULL; - zval taskSuffix; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&taskSuffix); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(taskSuffix) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &taskSuffix_param); - zephir_get_strval(&taskSuffix, taskSuffix_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("handlerSuffix"), &taskSuffix); - ZEPHIR_MM_RESTORE(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("opened"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_is_true(&_0))) { + RETURN_MM_BOOL(1); + } + ZEPHIR_RETURN_CALL_FUNCTION("closelog", NULL, 410); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Cli_Dispatcher, handleException) +static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, process) { + zval _6$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *exception, exception_sub, eventsManager, _0, _1$$3, _2$$3; + zval *item, item_sub, __$true, __$false, level, message, result, _0, _1, _2, _9, _3$$3, _4$$3, _5$$3, _7$$3, _8$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&exception_sub); - ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&item_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&level); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_6$$3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(exception, zend_ce_exception) + Z_PARAM_OBJECT_OF_CLASS(item, phalcon_logger_item_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &exception); - zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - if (Z_TYPE_P(&eventsManager) != IS_NULL) { - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "dispatch:beforeException"); - ZEPHIR_CALL_METHOD(&_1$$3, &eventsManager, "fire", NULL, 0, &_2$$3, this_ptr, exception); + zephir_fetch_params(1, 1, 0, &item); + ZEPHIR_CALL_METHOD(&message, this_ptr, "getformatteditem", NULL, 0, item); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_1, this_ptr, ZEND_STRL("option"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_2, this_ptr, ZEND_STRL("facility"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&result, this_ptr, "openlog", NULL, 0, &_0, &_1, &_2); + zephir_check_call_status(); + if (!zephir_is_true(&result)) { + ZEPHIR_INIT_VAR(&_3$$3); + object_init_ex(&_3$$3, spl_ce_LogicException); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + zephir_memory_observe(&_5$$3); + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("facility"), PH_NOISY_CC); + zephir_cast_to_string(&_6$$3, &_5$$3); + ZEPHIR_INIT_VAR(&_7$$3); + ZVAL_STRING(&_7$$3, "Cannot open syslog for name [%s] and facility [%s]"); + ZEPHIR_CALL_FUNCTION(&_8$$3, "sprintf", NULL, 117, &_7$$3, &_4$$3, &_6$$3); zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$3)) { - RETURN_MM_BOOL(0); - } + ZEPHIR_CALL_METHOD(NULL, &_3$$3, "__construct", NULL, 409, &_8$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_3$$3, "phalcon/Logger/Adapter/Syslog.zep", 106); + ZEPHIR_MM_RESTORE(); + return; + } + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("opened"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("opened"), &__$false); } + ZEPHIR_CALL_METHOD(&_9, item, "getlevel", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&level, this_ptr, "logleveltosyslog", NULL, 411, &_9); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(NULL, "syslog", NULL, 412, &level, &message); + zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Cli_Dispatcher, throwDispatchException) +static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, openlog) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long exceptionCode, ZEPHIR_LAST_CALL_STATUS; - zval *message_param = NULL, *exceptionCode_param = NULL, exception, _0, _1; - zval message; - zval *this_ptr = getThis(); + zend_long option, facility, ZEPHIR_LAST_CALL_STATUS; + zval *ident_param = NULL, *option_param = NULL, *facility_param = NULL, _0, _1; + zval ident; - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&exception); + ZVAL_UNDEF(&ident); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(message) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(exceptionCode) + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(ident) + Z_PARAM_LONG(option) + Z_PARAM_LONG(facility) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &message_param, &exceptionCode_param); - zephir_get_strval(&message, message_param); - if (!exceptionCode_param) { - exceptionCode = 0; - } else { - } - ZEPHIR_INIT_VAR(&exception); - object_init_ex(&exception, phalcon_cli_dispatcher_exception_ce); - ZVAL_LONG(&_0, exceptionCode); - ZEPHIR_CALL_METHOD(NULL, &exception, "__construct", NULL, 33, &message, &_0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "handleexception", NULL, 0, &exception); + zephir_fetch_params(1, 3, 0, &ident_param, &option_param, &facility_param); + zephir_get_strval(&ident, ident_param); + ZVAL_LONG(&_0, option); + ZVAL_LONG(&_1, facility); + ZEPHIR_RETURN_CALL_FUNCTION("openlog", NULL, 413, &ident, &_0, &_1); zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_1)) { - RETURN_MM_BOOL(0); - } - zephir_throw_exception_debug(&exception, "phalcon/Cli/Dispatcher.zep", 224); - ZEPHIR_MM_RESTORE(); - return; + RETURN_MM(); } -zend_object *zephir_init_properties_Phalcon_Cli_Dispatcher(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Logger_Adapter_Syslog, logLevelToSyslog) { - zval _0, _2, _4, _6, _8, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7; + zval levels; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_9$$7); - + zval *level_param = NULL, result; + zend_long level; - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("handlerHashes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("handlerHashes"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("camelCaseMap"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("camelCaseMap"), &_5$$5); - } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("activeMethodMap"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("activeMethodMap"), &_7$$6); - } - zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_8) == IS_NULL) { - ZEPHIR_INIT_VAR(&_9$$7); - array_init(&_9$$7); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_9$$7); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&levels); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(level) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &level_param); + ZEPHIR_INIT_VAR(&levels); + zephir_create_array(&levels, 9, 0); + add_index_long(&levels, 2, 1); + add_index_long(&levels, 1, 2); + add_index_long(&levels, 8, 3); + add_index_long(&levels, 7, 7); + add_index_long(&levels, 0, 0); + add_index_long(&levels, 3, 3); + add_index_long(&levels, 6, 6); + add_index_long(&levels, 5, 5); + add_index_long(&levels, 4, 4); + zephir_memory_observe(&result); + if (!(zephir_array_isset_long_fetch(&result, &levels, level, 0))) { + ZEPHIR_INIT_NVAR(&result); + ZVAL_LONG(&result, 3); } + RETURN_CCTOR(&result); } @@ -125056,23 +126556,13 @@ zend_object *zephir_init_properties_Phalcon_Cli_Dispatcher(zend_class_entry *cla -ZEPHIR_INIT_CLASS(Phalcon_Cli_DispatcherInterface) +ZEPHIR_INIT_CLASS(Phalcon_Paginator_Exception) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Cli, DispatcherInterface, phalcon, cli_dispatcherinterface, phalcon_cli_dispatcherinterface_method_entry); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Paginator, Exception, phalcon, paginator_exception, zend_ce_exception, NULL, 0); - zend_class_implements(phalcon_cli_dispatcherinterface_ce, 1, phalcon_dispatcher_dispatcherinterface_ce); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, getActiveTask); -ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, getLastTask); -ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, getOptions); -ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, getTaskName); -ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, getTaskSuffix); -ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, setDefaultTask); -ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, setOptions); -ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, setTaskName); -ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, setTaskSuffix); @@ -125083,868 +126573,484 @@ ZEPHIR_DOC_METHOD(Phalcon_Cli_DispatcherInterface, setTaskSuffix); -ZEPHIR_INIT_CLASS(Phalcon_Cli_Router) +ZEPHIR_INIT_CLASS(Phalcon_Paginator_PaginatorFactory) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli, Router, phalcon, cli_router, phalcon_di_abstractinjectionaware_ce, phalcon_cli_router_method_entry, 0); - - zend_declare_property_string(phalcon_cli_router_ce, SL("action"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_cli_router_ce, SL("defaultAction"), "", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_cli_router_ce, SL("defaultModule"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_cli_router_ce, SL("defaultParams"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_cli_router_ce, SL("defaultTask"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_cli_router_ce, SL("matchedRoute"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_cli_router_ce, SL("matches"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_cli_router_ce, SL("module"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_cli_router_ce, SL("params"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_cli_router_ce, SL("routes"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_cli_router_ce, SL("task"), "", ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_cli_router_ce, SL("wasMatched"), 0, ZEND_ACC_PROTECTED); - phalcon_cli_router_ce->create_object = zephir_init_properties_Phalcon_Cli_Router; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Paginator, PaginatorFactory, phalcon, paginator_paginatorfactory, phalcon_factory_abstractfactory_ce, phalcon_paginator_paginatorfactory_method_entry, 0); return SUCCESS; } -static PHP_METHOD(Phalcon_Cli_Router, __construct) +static PHP_METHOD(Phalcon_Paginator_PaginatorFactory, __construct) { - zval routes, _1$$3, _3$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *defaultRoutes_param = NULL, _0$$3, _2$$3, _4$$3; - zend_bool defaultRoutes; + zval *services_param = NULL; + zval services; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&routes); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&services); ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(defaultRoutes) + Z_PARAM_ARRAY(services) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &defaultRoutes_param); - if (!defaultRoutes_param) { - defaultRoutes = 1; + zephir_fetch_params(1, 0, 1, &services_param); + if (!services_param) { + ZEPHIR_INIT_VAR(&services); + array_init(&services); } else { - } - ZEPHIR_INIT_VAR(&routes); - array_init(&routes); - if (defaultRoutes) { - ZEPHIR_INIT_VAR(&_0$$3); - object_init_ex(&_0$$3, phalcon_cli_router_route_ce); - ZEPHIR_INIT_VAR(&_1$$3); - zephir_create_array(&_1$$3, 1, 0); - add_assoc_long_ex(&_1$$3, SL("task"), 1); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "#^(?::delimiter)?([a-zA-Z0-9\\_\\-]+)[:delimiter]{0,1}$#"); - ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 191, &_2$$3, &_1$$3); - zephir_check_call_status(); - zephir_array_append(&routes, &_0$$3, PH_SEPARATE, "phalcon/Cli/Router.zep", 119); - ZEPHIR_INIT_NVAR(&_2$$3); - object_init_ex(&_2$$3, phalcon_cli_router_route_ce); - ZEPHIR_INIT_VAR(&_3$$3); - zephir_create_array(&_3$$3, 3, 0); - add_assoc_long_ex(&_3$$3, SL("task"), 1); - add_assoc_long_ex(&_3$$3, SL("action"), 2); - add_assoc_long_ex(&_3$$3, SL("params"), 3); - ZEPHIR_INIT_VAR(&_4$$3); - ZVAL_STRING(&_4$$3, "#^(?::delimiter)?([a-zA-Z0-9\\_\\-]+):delimiter([a-zA-Z0-9\\.\\_]+)(:delimiter.*)*$#"); - ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 191, &_4$$3, &_3$$3); - zephir_check_call_status(); - zephir_array_append(&routes, &_2$$3, PH_SEPARATE, "phalcon/Cli/Router.zep", 128); + ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); } - zephir_update_property_zval(this_ptr, ZEND_STRL("routes"), &routes); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); + zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Cli_Router, add) +static PHP_METHOD(Phalcon_Paginator_PaginatorFactory, load) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, route; - zval pattern; + zval *config = NULL, config_sub, name, options, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&route); - bool is_null_true = 1; + ZVAL_UNDEF(&config_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(config) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &config); + ZEPHIR_SEPARATE_PARAM(config); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfig", NULL, 0, config); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(config, &_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "adapter"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfigelement", NULL, 0, config, &_1); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(config, &_0); + zephir_memory_observe(&name); + zephir_array_fetch_string(&name, config, SL("adapter"), PH_NOISY, "phalcon/Paginator/PaginatorFactory.zep", 62); + zephir_memory_observe(&options); + if (!(zephir_array_isset_string_fetch(&options, config, SL("options"), 0))) { + ZEPHIR_INIT_NVAR(&options); + array_init(&options); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "newinstance", NULL, 0, &name, &options); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Paginator_PaginatorFactory, newInstance) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval options, _0; + zval *name_param = NULL, *options_param = NULL, definition; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) + Z_PARAM_STR(name) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); + zephir_fetch_params(1, 1, 1, &name_param, &options_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - ZEPHIR_INIT_VAR(&pattern); + ZEPHIR_INIT_VAR(&name); } - if (!paths) { - paths = &paths_sub; - paths = &__$null; + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - ZEPHIR_INIT_VAR(&route); - object_init_ex(&route, phalcon_cli_router_route_ce); - ZEPHIR_CALL_METHOD(NULL, &route, "__construct", NULL, 191, &pattern, paths); + ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); zephir_check_call_status(); - zephir_update_property_array_append(this_ptr, SL("routes"), &route); - RETURN_CCTOR(&route); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 1, 0); + zephir_array_fast_append(&_0, &options); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(return_value, &definition, &_0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Cli_Router, getActionName) +static PHP_METHOD(Phalcon_Paginator_PaginatorFactory, getExceptionClass) { - RETURN_MEMBER(getThis(), "action"); + RETURN_STRING("Phalcon\\Paginator\\Exception"); } -static PHP_METHOD(Phalcon_Cli_Router, getMatchedRoute) +static PHP_METHOD(Phalcon_Paginator_PaginatorFactory, getServices) { - RETURN_MEMBER(getThis(), "matchedRoute"); + zephir_create_array(return_value, 3, 0); + add_assoc_stringl_ex(return_value, SL("model"), SL("Phalcon\\Paginator\\Adapter\\Model")); + add_assoc_stringl_ex(return_value, SL("nativeArray"), SL("Phalcon\\Paginator\\Adapter\\NativeArray")); + add_assoc_stringl_ex(return_value, SL("queryBuilder"), SL("Phalcon\\Paginator\\Adapter\\QueryBuilder")); + return; } -static PHP_METHOD(Phalcon_Cli_Router, getMatches) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Paginator_Repository) { + ZEPHIR_REGISTER_CLASS(Phalcon\\Paginator, Repository, phalcon, paginator_repository, phalcon_paginator_repository_method_entry, 0); - RETURN_MEMBER(getThis(), "matches"); + zend_declare_property_null(phalcon_paginator_repository_ce, SL("aliases"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_paginator_repository_ce, SL("properties"), ZEND_ACC_PROTECTED); + phalcon_paginator_repository_ce->create_object = zephir_init_properties_Phalcon_Paginator_Repository; + + zend_class_implements(phalcon_paginator_repository_ce, 1, phalcon_paginator_repositoryinterface_ce); + zend_class_implements(phalcon_paginator_repository_ce, 1, php_json_serializable_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Cli_Router, getModuleName) +static PHP_METHOD(Phalcon_Paginator_Repository, __get) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *property_param = NULL, method, _0, _1, _2, _3; + zval property; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "module"); + ZVAL_UNDEF(&property); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(property) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &property_param); + zephir_get_strval(&property, property_param); + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getrealnameproperty", NULL, 0, &property); + zephir_check_call_status(); + zephir_camelize(&_0, &_1, NULL ); + ZEPHIR_INIT_VAR(&method); + ZEPHIR_CONCAT_SV(&method, "get", &_0); + if ((zephir_method_exists(this_ptr, &method) == SUCCESS)) { + ZEPHIR_RETURN_CALL_METHOD_ZVAL(this_ptr, &method, NULL, 0); + zephir_check_call_status(); + RETURN_MM(); + } + ZEPHIR_INIT_VAR(&_2); + zephir_get_class(&_2, this_ptr, 0); + ZEPHIR_INIT_VAR(&_3); + ZEPHIR_CONCAT_SVSV(&_3, "Access to undefined property ", &_2, "::", &property); + ZEPHIR_CALL_FUNCTION(NULL, "trigger_error", NULL, 7, &_3); + zephir_check_call_status(); + RETURN_MM_NULL(); } -static PHP_METHOD(Phalcon_Cli_Router, getParams) +static PHP_METHOD(Phalcon_Paginator_Repository, getAliases) +{ + + RETURN_MEMBER(getThis(), "aliases"); +} + +static PHP_METHOD(Phalcon_Paginator_Repository, getCurrent) { + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getparameters", NULL, 0); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "current"); + ZVAL_LONG(&_1, 0); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getproperty", NULL, 0, &_0, &_1); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Cli_Router, getParameters) +static PHP_METHOD(Phalcon_Paginator_Repository, getFirst) { + zval _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "params"); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "first"); + ZVAL_LONG(&_1, 0); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getproperty", NULL, 0, &_0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Cli_Router, getRouteById) +static PHP_METHOD(Phalcon_Paginator_Repository, getItems) { + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *id, id_sub, route, _0, *_1, _2, _3$$3, _4$$5; zval *this_ptr = getThis(); - ZVAL_UNDEF(&id_sub); - ZVAL_UNDEF(&route); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$5); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(id) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &id); - zephir_read_property(&_0, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_0, 0, "phalcon/Cli/Router.zep", 218); - if (Z_TYPE_P(&_0) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) - { - ZEPHIR_INIT_NVAR(&route); - ZVAL_COPY(&route, _1); - ZEPHIR_CALL_METHOD(&_3$$3, &route, "getrouteid", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_EQUAL(&_3$$3, id)) { - RETURN_CCTOR(&route); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&route, &_0, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$5, &route, "getrouteid", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_EQUAL(&_4$$5, id)) { - RETURN_CCTOR(&route); - } - ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&route); - RETURN_MM_BOOL(0); + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "items"); + ZVAL_NULL(&_1); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getproperty", NULL, 0, &_0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Cli_Router, getRouteByName) +static PHP_METHOD(Phalcon_Paginator_Repository, getLast) { + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, route, _0, *_1, _2, _3$$3, _4$$5; - zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&route); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$5); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_0, 0, "phalcon/Cli/Router.zep", 234); - if (Z_TYPE_P(&_0) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) - { - ZEPHIR_INIT_NVAR(&route); - ZVAL_COPY(&route, _1); - ZEPHIR_CALL_METHOD(&_3$$3, &route, "getname", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_EQUAL(&_3$$3, &name)) { - RETURN_CCTOR(&route); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&route, &_0, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$5, &route, "getname", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_EQUAL(&_4$$5, &name)) { - RETURN_CCTOR(&route); - } - ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&route); - RETURN_MM_BOOL(0); + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "last"); + ZVAL_LONG(&_1, 0); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getproperty", NULL, 0, &_0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Cli_Router, getRoutes) +static PHP_METHOD(Phalcon_Paginator_Repository, getLimit) { + zval _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "routes"); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "limit"); + ZVAL_LONG(&_1, 0); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getproperty", NULL, 0, &_0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Cli_Router, getTaskName) +static PHP_METHOD(Phalcon_Paginator_Repository, getNext) { + zval _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "task"); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "next"); + ZVAL_LONG(&_1, 0); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getproperty", NULL, 0, &_0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Cli_Router, handle) +static PHP_METHOD(Phalcon_Paginator_Repository, getPrevious) { - zval _34$$55; - zend_string *_8$$12, *_21$$32; - zend_ulong _7$$12, _20$$32; - zval _4$$9, _10$$15, _12$$18, _14$$21, _16$$24, _17$$29, _23$$35, _25$$38, _27$$41, _29$$44; - zend_bool _0$$3; + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *arguments = NULL, arguments_sub, __$true, __$false, __$null, moduleName, taskName, actionName, params, route, parts, pattern, routeFound, matches, paths, beforeMatch, converters, converter, part, position, matchPosition, strParams, _1$$3, *_2$$3, _3$$3, *_5$$12, _6$$12, _9$$15, _11$$18, _13$$21, _15$$24, *_18$$32, _19$$32, _22$$35, _24$$38, _26$$41, _28$$44, _30$$46, _31$$46, _32$$46, _33$$46, _35$$55, _36$$56, _37$$58; zval *this_ptr = getThis(); - ZVAL_UNDEF(&arguments_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&moduleName); - ZVAL_UNDEF(&taskName); - ZVAL_UNDEF(&actionName); - ZVAL_UNDEF(¶ms); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&parts); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&routeFound); - ZVAL_UNDEF(&matches); - ZVAL_UNDEF(&paths); - ZVAL_UNDEF(&beforeMatch); - ZVAL_UNDEF(&converters); - ZVAL_UNDEF(&converter); - ZVAL_UNDEF(&part); - ZVAL_UNDEF(&position); - ZVAL_UNDEF(&matchPosition); - ZVAL_UNDEF(&strParams); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_6$$12); - ZVAL_UNDEF(&_9$$15); - ZVAL_UNDEF(&_11$$18); - ZVAL_UNDEF(&_13$$21); - ZVAL_UNDEF(&_15$$24); - ZVAL_UNDEF(&_19$$32); - ZVAL_UNDEF(&_22$$35); - ZVAL_UNDEF(&_24$$38); - ZVAL_UNDEF(&_26$$41); - ZVAL_UNDEF(&_28$$44); - ZVAL_UNDEF(&_30$$46); - ZVAL_UNDEF(&_31$$46); - ZVAL_UNDEF(&_32$$46); - ZVAL_UNDEF(&_33$$46); - ZVAL_UNDEF(&_35$$55); - ZVAL_UNDEF(&_36$$56); - ZVAL_UNDEF(&_37$$58); - ZVAL_UNDEF(&_4$$9); - ZVAL_UNDEF(&_10$$15); - ZVAL_UNDEF(&_12$$18); - ZVAL_UNDEF(&_14$$21); - ZVAL_UNDEF(&_16$$24); - ZVAL_UNDEF(&_17$$29); - ZVAL_UNDEF(&_23$$35); - ZVAL_UNDEF(&_25$$38); - ZVAL_UNDEF(&_27$$41); - ZVAL_UNDEF(&_29$$44); - ZVAL_UNDEF(&_34$$55); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(arguments) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &arguments); - if (!arguments) { - arguments = &arguments_sub; - arguments = &__$null; - } - ZEPHIR_INIT_VAR(&routeFound); - ZVAL_BOOL(&routeFound, 0); - ZEPHIR_INIT_VAR(&parts); - array_init(&parts); - ZEPHIR_INIT_VAR(¶ms); - array_init(¶ms); - ZEPHIR_INIT_VAR(&matches); - ZVAL_NULL(&matches); - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$false); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("matchedRoute"), &__$null); - if (Z_TYPE_P(arguments) != IS_ARRAY) { - _0$$3 = Z_TYPE_P(arguments) != IS_STRING; - if (_0$$3) { - _0$$3 = Z_TYPE_P(arguments) != IS_NULL; - } - if (UNEXPECTED(_0$$3)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_router_exception_ce, "Arguments must be an array or string", "phalcon/Cli/Router.zep", 273); - return; - } - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_1$$3, 0, "phalcon/Cli/Router.zep", 379); - if (Z_TYPE_P(&_1$$3) == IS_ARRAY) { - ZEND_HASH_REVERSE_FOREACH_VAL(Z_ARRVAL_P(&_1$$3), _2$$3) - { - ZEPHIR_INIT_NVAR(&route); - ZVAL_COPY(&route, _2$$3); - ZEPHIR_CALL_METHOD(&pattern, &route, "getcompiledpattern", NULL, 0); - zephir_check_call_status(); - if (zephir_memnstr_str(&pattern, SL("^"), "phalcon/Cli/Router.zep", 282)) { - ZEPHIR_INIT_NVAR(&routeFound); - zephir_preg_match(&routeFound, &pattern, arguments, &matches, 0, 0 , 0 ); - } else { - ZEPHIR_INIT_NVAR(&routeFound); - ZVAL_BOOL(&routeFound, ZEPHIR_IS_EQUAL(&pattern, arguments)); - } - if (zephir_is_true(&routeFound)) { - ZEPHIR_CALL_METHOD(&beforeMatch, &route, "getbeforematch", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&beforeMatch) != IS_NULL) { - if (UNEXPECTED(!(zephir_is_callable(&beforeMatch)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_router_exception_ce, "Before-Match callback is not callable in matched route", "phalcon/Cli/Router.zep", 301); - return; - } - ZEPHIR_INIT_NVAR(&_4$$9); - zephir_create_array(&_4$$9, 3, 0); - zephir_array_fast_append(&_4$$9, arguments); - zephir_array_fast_append(&_4$$9, &route); - zephir_array_fast_append(&_4$$9, this_ptr); - ZEPHIR_INIT_NVAR(&routeFound); - ZEPHIR_CALL_USER_FUNC_ARRAY(&routeFound, &beforeMatch, &_4$$9); - zephir_check_call_status(); - } - } - if (zephir_is_true(&routeFound)) { - ZEPHIR_CALL_METHOD(&paths, &route, "getpaths", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&parts, &paths); - if (Z_TYPE_P(&matches) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(&converters, &route, "getconverters", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&paths, 0, "phalcon/Cli/Router.zep", 366); - if (Z_TYPE_P(&paths) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&paths), _7$$12, _8$$12, _5$$12) - { - ZEPHIR_INIT_NVAR(&part); - if (_8$$12 != NULL) { - ZVAL_STR_COPY(&part, _8$$12); - } else { - ZVAL_LONG(&part, _7$$12); - } - ZEPHIR_INIT_NVAR(&position); - ZVAL_COPY(&position, _5$$12); - ZEPHIR_OBS_NVAR(&matchPosition); - if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_9$$15); - ZEPHIR_INIT_NVAR(&_10$$15); - zephir_create_array(&_10$$15, 1, 0); - zephir_array_fast_append(&_10$$15, &matchPosition); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_9$$15, &converter, &_10$$15); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_9$$15, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); - } - } else { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_11$$18); - ZEPHIR_INIT_NVAR(&_12$$18); - zephir_create_array(&_12$$18, 1, 0); - zephir_array_fast_append(&_12$$18, &position); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_11$$18, &converter, &_12$$18); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_11$$18, PH_COPY | PH_SEPARATE); - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &paths, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_6$$12, &paths, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_6$$12)) { - break; - } - ZEPHIR_CALL_METHOD(&part, &paths, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&position, &paths, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&matchPosition); - if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_13$$21); - ZEPHIR_INIT_NVAR(&_14$$21); - zephir_create_array(&_14$$21, 1, 0); - zephir_array_fast_append(&_14$$21, &matchPosition); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_13$$21, &converter, &_14$$21); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_13$$21, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); - } - } else { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_15$$24); - ZEPHIR_INIT_NVAR(&_16$$24); - zephir_create_array(&_16$$24, 1, 0); - zephir_array_fast_append(&_16$$24, &position); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_15$$24, &converter, &_16$$24); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_15$$24, PH_COPY | PH_SEPARATE); - } - } - ZEPHIR_CALL_METHOD(NULL, &paths, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&position); - ZEPHIR_INIT_NVAR(&part); - zephir_update_property_zval(this_ptr, ZEND_STRL("matches"), &matches); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("matchedRoute"), &route); - break; - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$3, &_1$$3, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&route, &_1$$3, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&pattern, &route, "getcompiledpattern", NULL, 0); - zephir_check_call_status(); - if (zephir_memnstr_str(&pattern, SL("^"), "phalcon/Cli/Router.zep", 282)) { - ZEPHIR_INIT_NVAR(&routeFound); - zephir_preg_match(&routeFound, &pattern, arguments, &matches, 0, 0 , 0 ); - } else { - ZEPHIR_INIT_NVAR(&routeFound); - ZVAL_BOOL(&routeFound, ZEPHIR_IS_EQUAL(&pattern, arguments)); - } - if (zephir_is_true(&routeFound)) { - ZEPHIR_CALL_METHOD(&beforeMatch, &route, "getbeforematch", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&beforeMatch) != IS_NULL) { - if (UNEXPECTED(!(zephir_is_callable(&beforeMatch)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_router_exception_ce, "Before-Match callback is not callable in matched route", "phalcon/Cli/Router.zep", 301); - return; - } - ZEPHIR_INIT_NVAR(&_17$$29); - zephir_create_array(&_17$$29, 3, 0); - zephir_array_fast_append(&_17$$29, arguments); - zephir_array_fast_append(&_17$$29, &route); - zephir_array_fast_append(&_17$$29, this_ptr); - ZEPHIR_INIT_NVAR(&routeFound); - ZEPHIR_CALL_USER_FUNC_ARRAY(&routeFound, &beforeMatch, &_17$$29); - zephir_check_call_status(); - } - } - if (zephir_is_true(&routeFound)) { - ZEPHIR_CALL_METHOD(&paths, &route, "getpaths", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&parts, &paths); - if (Z_TYPE_P(&matches) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(&converters, &route, "getconverters", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&paths, 0, "phalcon/Cli/Router.zep", 366); - if (Z_TYPE_P(&paths) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&paths), _20$$32, _21$$32, _18$$32) - { - ZEPHIR_INIT_NVAR(&part); - if (_21$$32 != NULL) { - ZVAL_STR_COPY(&part, _21$$32); - } else { - ZVAL_LONG(&part, _20$$32); - } - ZEPHIR_INIT_NVAR(&position); - ZVAL_COPY(&position, _18$$32); - ZEPHIR_OBS_NVAR(&matchPosition); - if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_22$$35); - ZEPHIR_INIT_NVAR(&_23$$35); - zephir_create_array(&_23$$35, 1, 0); - zephir_array_fast_append(&_23$$35, &matchPosition); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_22$$35, &converter, &_23$$35); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_22$$35, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); - } - } else { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_24$$38); - ZEPHIR_INIT_NVAR(&_25$$38); - zephir_create_array(&_25$$38, 1, 0); - zephir_array_fast_append(&_25$$38, &position); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_24$$38, &converter, &_25$$38); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_24$$38, PH_COPY | PH_SEPARATE); - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &paths, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_19$$32, &paths, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_19$$32)) { - break; - } - ZEPHIR_CALL_METHOD(&part, &paths, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&position, &paths, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&matchPosition); - if (zephir_array_isset_fetch(&matchPosition, &matches, &position, 0)) { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_26$$41); - ZEPHIR_INIT_NVAR(&_27$$41); - zephir_create_array(&_27$$41, 1, 0); - zephir_array_fast_append(&_27$$41, &matchPosition); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_26$$41, &converter, &_27$$41); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_26$$41, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&parts, &part, &matchPosition, PH_COPY | PH_SEPARATE); - } - } else { - ZEPHIR_OBS_NVAR(&converter); - if (zephir_array_isset_fetch(&converter, &converters, &part, 0)) { - ZEPHIR_INIT_NVAR(&_28$$44); - ZEPHIR_INIT_NVAR(&_29$$44); - zephir_create_array(&_29$$44, 1, 0); - zephir_array_fast_append(&_29$$44, &position); - ZEPHIR_CALL_USER_FUNC_ARRAY(&_28$$44, &converter, &_29$$44); - zephir_check_call_status(); - zephir_array_update_zval(&parts, &part, &_28$$44, PH_COPY | PH_SEPARATE); - } - } - ZEPHIR_CALL_METHOD(NULL, &paths, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&position); - ZEPHIR_INIT_NVAR(&part); - zephir_update_property_zval(this_ptr, ZEND_STRL("matches"), &matches); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("matchedRoute"), &route); - break; - } - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&route); - if (zephir_is_true(&routeFound)) { - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$false); - } - } else { - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("wasMatched"), &__$false); - } - zephir_read_property(&_30$$46, this_ptr, ZEND_STRL("defaultModule"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("module"), &_30$$46); - zephir_read_property(&_31$$46, this_ptr, ZEND_STRL("defaultTask"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("task"), &_31$$46); - zephir_read_property(&_32$$46, this_ptr, ZEND_STRL("defaultAction"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("action"), &_32$$46); - zephir_read_property(&_33$$46, this_ptr, ZEND_STRL("defaultParams"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("params"), &_33$$46); - RETURN_THIS(); - } - } else { - ZEPHIR_CPY_WRT(&parts, arguments); - } - ZEPHIR_INIT_VAR(&moduleName); - ZVAL_NULL(&moduleName); - ZEPHIR_INIT_VAR(&taskName); - ZVAL_NULL(&taskName); - ZEPHIR_INIT_VAR(&actionName); - ZVAL_NULL(&actionName); - ZEPHIR_OBS_NVAR(&moduleName); - if (zephir_array_isset_string_fetch(&moduleName, &parts, SL("module"), 0)) { - zephir_array_unset_string(&parts, SL("module"), PH_SEPARATE); - } else { - ZEPHIR_OBS_NVAR(&moduleName); - zephir_read_property(&moduleName, this_ptr, ZEND_STRL("defaultModule"), PH_NOISY_CC); - } - ZEPHIR_OBS_NVAR(&taskName); - if (zephir_array_isset_string_fetch(&taskName, &parts, SL("task"), 0)) { - zephir_array_unset_string(&parts, SL("task"), PH_SEPARATE); - } else { - ZEPHIR_OBS_NVAR(&taskName); - zephir_read_property(&taskName, this_ptr, ZEND_STRL("defaultTask"), PH_NOISY_CC); - } - ZEPHIR_OBS_NVAR(&actionName); - if (zephir_array_isset_string_fetch(&actionName, &parts, SL("action"), 0)) { - zephir_array_unset_string(&parts, SL("action"), PH_SEPARATE); - } else { - ZEPHIR_OBS_NVAR(&actionName); - zephir_read_property(&actionName, this_ptr, ZEND_STRL("defaultAction"), PH_NOISY_CC); - } - ZEPHIR_OBS_NVAR(¶ms); - if (zephir_array_isset_string_fetch(¶ms, &parts, SL("params"), 0)) { - if (Z_TYPE_P(¶ms) != IS_ARRAY) { - zephir_cast_to_string(&_34$$55, ¶ms); - ZVAL_LONG(&_35$$55, 1); - ZEPHIR_INIT_VAR(&strParams); - zephir_substr(&strParams, &_34$$55, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - if (zephir_is_true(&strParams)) { - ZEPHIR_CALL_CE_STATIC(&_36$$56, phalcon_cli_router_route_ce, "getdelimiter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(¶ms); - zephir_fast_explode(¶ms, &_36$$56, &strParams, LONG_MAX); - } else { - ZEPHIR_INIT_NVAR(¶ms); - array_init(¶ms); - } - } - zephir_array_unset_string(&parts, SL("params"), PH_SEPARATE); - } - if (zephir_fast_count_int(¶ms)) { - ZEPHIR_INIT_VAR(&_37$$58); - zephir_fast_array_merge(&_37$$58, ¶ms, &parts); - ZEPHIR_CPY_WRT(¶ms, &_37$$58); - } else { - ZEPHIR_CPY_WRT(¶ms, &parts); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("module"), &moduleName); - zephir_update_property_zval(this_ptr, ZEND_STRL("task"), &taskName); - zephir_update_property_zval(this_ptr, ZEND_STRL("action"), &actionName); - zephir_update_property_zval(this_ptr, ZEND_STRL("params"), ¶ms); - ZEPHIR_MM_RESTORE(); + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "previous"); + ZVAL_LONG(&_1, 0); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getproperty", NULL, 0, &_0, &_1); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Paginator_Repository, getTotalItems) +{ + zval _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "total_items"); + ZVAL_LONG(&_1, 0); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getproperty", NULL, 0, &_0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Cli_Router, setDefaultAction) +static PHP_METHOD(Phalcon_Paginator_Repository, jsonSerialize) +{ + + RETURN_MEMBER(getThis(), "properties"); +} + +static PHP_METHOD(Phalcon_Paginator_Repository, setAliases) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *actionName_param = NULL; - zval actionName; + zval *aliases_param = NULL; + zval aliases; zval *this_ptr = getThis(); - ZVAL_UNDEF(&actionName); + ZVAL_UNDEF(&aliases); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(actionName) + Z_PARAM_ARRAY(aliases) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &actionName_param); - zephir_get_strval(&actionName, actionName_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultAction"), &actionName); + zephir_fetch_params(1, 1, 0, &aliases_param); + zephir_get_arrval(&aliases, aliases_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("aliases"), &aliases); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Cli_Router, setDefaultModule) +static PHP_METHOD(Phalcon_Paginator_Repository, setProperties) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *moduleName_param = NULL; - zval moduleName; + zval *properties_param = NULL; + zval properties; zval *this_ptr = getThis(); - ZVAL_UNDEF(&moduleName); + ZVAL_UNDEF(&properties); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(moduleName) + Z_PARAM_ARRAY(properties) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &moduleName_param); - zephir_get_strval(&moduleName, moduleName_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultModule"), &moduleName); + zephir_fetch_params(1, 1, 0, &properties_param); + zephir_get_arrval(&properties, properties_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("properties"), &properties); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Cli_Router, setDefaults) +static PHP_METHOD(Phalcon_Paginator_Repository, getProperty) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *defaults_param = NULL, module, task, action, params; - zval defaults; + zval *property_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null, value, _0; + zval property; zval *this_ptr = getThis(); - ZVAL_UNDEF(&defaults); - ZVAL_UNDEF(&module); - ZVAL_UNDEF(&task); - ZVAL_UNDEF(&action); - ZVAL_UNDEF(¶ms); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(defaults) + ZVAL_UNDEF(&property); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(property) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(defaultValue) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &defaults_param); - ZEPHIR_OBS_COPY_OR_DUP(&defaults, defaults_param); - zephir_memory_observe(&module); - if (zephir_array_isset_string_fetch(&module, &defaults, SL("module"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultModule"), &module); - } - zephir_memory_observe(&task); - if (zephir_array_isset_string_fetch(&task, &defaults, SL("task"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultTask"), &task); - } - zephir_memory_observe(&action); - if (zephir_array_isset_string_fetch(&action, &defaults, SL("action"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultAction"), &action); + zephir_fetch_params(1, 1, 1, &property_param, &defaultValue); + zephir_get_strval(&property, property_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; } - zephir_memory_observe(¶ms); - if (zephir_array_isset_string_fetch(¶ms, &defaults, SL("params"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultParams"), ¶ms); + zephir_memory_observe(&value); + zephir_read_property(&_0, this_ptr, ZEND_STRL("properties"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&value, &_0, &property, 0))) { + ZEPHIR_CPY_WRT(&value, defaultValue); } - RETURN_THIS(); + RETURN_CCTOR(&value); } -static PHP_METHOD(Phalcon_Cli_Router, setDefaultTask) +static PHP_METHOD(Phalcon_Paginator_Repository, getRealNameProperty) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *taskName_param = NULL; - zval taskName; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *property_param = NULL, aliases, _0$$3; + zval property; zval *this_ptr = getThis(); - ZVAL_UNDEF(&taskName); + ZVAL_UNDEF(&property); + ZVAL_UNDEF(&aliases); + ZVAL_UNDEF(&_0$$3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(taskName) + Z_PARAM_STR(property) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &taskName_param); - zephir_get_strval(&taskName, taskName_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultTask"), &taskName); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Cli_Router, wasMatched) -{ - - RETURN_MEMBER(getThis(), "wasMatched"); + zephir_fetch_params(1, 1, 0, &property_param); + zephir_get_strval(&property, property_param); + ZEPHIR_CALL_METHOD(&aliases, this_ptr, "getaliases", NULL, 0); + zephir_check_call_status(); + if (zephir_array_isset(&aliases, &property)) { + zephir_array_fetch(&_0$$3, &aliases, &property, PH_NOISY | PH_READONLY, "phalcon/Paginator/Repository.zep", 181); + RETURN_CTOR(&_0$$3); + } + RETURN_CTOR(&property); } -zend_object *zephir_init_properties_Phalcon_Cli_Router(zend_class_entry *class_type) +zend_object *zephir_init_properties_Phalcon_Paginator_Repository(zend_class_entry *class_type) { - zval _0, _2, _4, _6, _1$$3, _3$$4, _5$$5, _7$$6; + zval _0, _2, _1$$3, _3$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); @@ -125953,29 +127059,17 @@ zend_object *zephir_init_properties_Phalcon_Cli_Router(zend_class_entry *class_t { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("routes"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("properties"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("routes"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("properties"), &_1$$3); } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("params"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("aliases"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_2) == IS_NULL) { ZEPHIR_INIT_VAR(&_3$$4); array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("params"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("matches"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("matches"), &_5$$5); - } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("defaultParams"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("defaultParams"), &_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("aliases"), &_3$$4); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -125992,30 +127086,40 @@ zend_object *zephir_init_properties_Phalcon_Cli_Router(zend_class_entry *class_t -ZEPHIR_INIT_CLASS(Phalcon_Cli_RouterInterface) +ZEPHIR_INIT_CLASS(Phalcon_Paginator_RepositoryInterface) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Cli, RouterInterface, phalcon, cli_routerinterface, phalcon_cli_routerinterface_method_entry); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Paginator, RepositoryInterface, phalcon, paginator_repositoryinterface, phalcon_paginator_repositoryinterface_method_entry); + + zephir_declare_class_constant_string(phalcon_paginator_repositoryinterface_ce, SL("PROPERTY_CURRENT_PAGE"), "current"); + + zephir_declare_class_constant_string(phalcon_paginator_repositoryinterface_ce, SL("PROPERTY_FIRST_PAGE"), "first"); + + zephir_declare_class_constant_string(phalcon_paginator_repositoryinterface_ce, SL("PROPERTY_ITEMS"), "items"); + + zephir_declare_class_constant_string(phalcon_paginator_repositoryinterface_ce, SL("PROPERTY_LAST_PAGE"), "last"); + + zephir_declare_class_constant_string(phalcon_paginator_repositoryinterface_ce, SL("PROPERTY_LIMIT"), "limit"); + + zephir_declare_class_constant_string(phalcon_paginator_repositoryinterface_ce, SL("PROPERTY_NEXT_PAGE"), "next"); + + zephir_declare_class_constant_string(phalcon_paginator_repositoryinterface_ce, SL("PROPERTY_PREVIOUS_PAGE"), "previous"); + + zephir_declare_class_constant_string(phalcon_paginator_repositoryinterface_ce, SL("PROPERTY_TOTAL_ITEMS"), "total_items"); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, add); -ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getActionName); -ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getMatchedRoute); -ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getMatches); -ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getModuleName); -ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getParams); -ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getParameters); -ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getRouteById); -ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getRouteByName); -ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getRoutes); -ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, getTaskName); -ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, handle); -ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, setDefaultAction); -ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, setDefaultModule); -ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, setDefaults); -ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, setDefaultTask); -ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, wasMatched); +ZEPHIR_DOC_METHOD(Phalcon_Paginator_RepositoryInterface, getAliases); +ZEPHIR_DOC_METHOD(Phalcon_Paginator_RepositoryInterface, getCurrent); +ZEPHIR_DOC_METHOD(Phalcon_Paginator_RepositoryInterface, getFirst); +ZEPHIR_DOC_METHOD(Phalcon_Paginator_RepositoryInterface, getItems); +ZEPHIR_DOC_METHOD(Phalcon_Paginator_RepositoryInterface, getLast); +ZEPHIR_DOC_METHOD(Phalcon_Paginator_RepositoryInterface, getLimit); +ZEPHIR_DOC_METHOD(Phalcon_Paginator_RepositoryInterface, getNext); +ZEPHIR_DOC_METHOD(Phalcon_Paginator_RepositoryInterface, getPrevious); +ZEPHIR_DOC_METHOD(Phalcon_Paginator_RepositoryInterface, getTotalItems); +ZEPHIR_DOC_METHOD(Phalcon_Paginator_RepositoryInterface, setAliases); +ZEPHIR_DOC_METHOD(Phalcon_Paginator_RepositoryInterface, setProperties); @@ -126026,48 +127130,157 @@ ZEPHIR_DOC_METHOD(Phalcon_Cli_RouterInterface, wasMatched); -ZEPHIR_INIT_CLASS(Phalcon_Cli_Task) +ZEPHIR_INIT_CLASS(Phalcon_Paginator_Adapter_AbstractAdapter) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli, Task, phalcon, cli_task, phalcon_di_injectable_ce, phalcon_cli_task_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Paginator\\Adapter, AbstractAdapter, phalcon, paginator_adapter_abstractadapter, phalcon_paginator_adapter_abstractadapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zend_declare_property_null(phalcon_cli_task_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_cli_task_ce, 1, phalcon_cli_taskinterface_ce); - zend_class_implements(phalcon_cli_task_ce, 1, phalcon_events_eventsawareinterface_ce); + zend_declare_property_null(phalcon_paginator_adapter_abstractadapter_ce, SL("config"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_paginator_adapter_abstractadapter_ce, SL("limitRows"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_paginator_adapter_abstractadapter_ce, SL("page"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_paginator_adapter_abstractadapter_ce, SL("repository"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_paginator_adapter_abstractadapter_ce, 1, phalcon_paginator_adapter_adapterinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Cli_Task, __construct) +static PHP_METHOD(Phalcon_Paginator_Adapter_AbstractAdapter, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *config_param = NULL, _0$$3, _1$$4, _2$$5; + zval config; zval *this_ptr = getThis(); + + ZVAL_UNDEF(&config); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$5); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(config) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("onconstruct")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "onconstruct", NULL, 0); + zephir_fetch_params(1, 1, 0, &config_param); + ZEPHIR_OBS_COPY_OR_DUP(&config, config_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("config"), &config); + if (zephir_array_isset_string(&config, SL("limit"))) { + zephir_array_fetch_string(&_0$$3, &config, SL("limit"), PH_NOISY | PH_READONLY, "phalcon/Paginator/Adapter/AbstractAdapter.zep", 62); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setlimit", NULL, 0, &_0$$3); + zephir_check_call_status(); + } + if (zephir_array_isset_string(&config, SL("page"))) { + zephir_array_fetch_string(&_1$$4, &config, SL("page"), PH_NOISY | PH_READONLY, "phalcon/Paginator/Adapter/AbstractAdapter.zep", 68); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setcurrentpage", NULL, 0, &_1$$4); + zephir_check_call_status(); + } + if (zephir_array_isset_string(&config, SL("repository"))) { + zephir_array_fetch_string(&_2$$5, &config, SL("repository"), PH_NOISY | PH_READONLY, "phalcon/Paginator/Adapter/AbstractAdapter.zep", 74); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setrepository", NULL, 0, &_2$$5); zephir_check_call_status(); } ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Cli_Task, getEventsManager) +static PHP_METHOD(Phalcon_Paginator_Adapter_AbstractAdapter, getLimit) { - RETURN_MEMBER(getThis(), "eventsManager"); + RETURN_MEMBER(getThis(), "limitRows"); } -static PHP_METHOD(Phalcon_Cli_Task, setEventsManager) +static PHP_METHOD(Phalcon_Paginator_Adapter_AbstractAdapter, setCurrentPage) { - zval *eventsManager, eventsManager_sub; + zval *page_param = NULL, _0; + zend_long page; zval *this_ptr = getThis(); - ZVAL_UNDEF(&eventsManager_sub); + ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) + Z_PARAM_LONG(page) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); - zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); + zephir_fetch_params_without_memory_grow(1, 0, &page_param); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, page); + zephir_update_property_zval(this_ptr, ZEND_STRL("page"), &_0); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Paginator_Adapter_AbstractAdapter, setLimit) +{ + zval *limit_param = NULL, _0; + zend_long limit; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(limit) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &limit_param); + if (limit <= 0) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_paginator_exception_ce, "Limit must be greater than zero", "phalcon/Paginator/Adapter/AbstractAdapter.zep", 102); + return; + } + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, limit); + zephir_update_property_zval(this_ptr, ZEND_STRL("limitRows"), &_0); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Paginator_Adapter_AbstractAdapter, setRepository) +{ + zval *repository, repository_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&repository_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(repository, phalcon_paginator_repositoryinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &repository); + zephir_update_property_zval(this_ptr, ZEND_STRL("repository"), repository); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Paginator_Adapter_AbstractAdapter, getRepository) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *properties_param = NULL, _0, _1$$3, _2$$4; + zval properties; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&properties); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY_OR_NULL(properties) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &properties_param); + if (!properties_param) { + ZEPHIR_INIT_VAR(&properties); + } else { + zephir_get_arrval(&properties, properties_param); + } + zephir_memory_observe(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("repository"), PH_NOISY_CC); + if (Z_TYPE_P(&_0) != IS_OBJECT) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_paginator_repository_ce); + if (zephir_has_constructor(&_1$$3)) { + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 0); + zephir_check_call_status(); + } + + zephir_update_property_zval(this_ptr, ZEND_STRL("repository"), &_1$$3); + } + if (!ZEPHIR_IS_NULL(&properties)) { + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("repository"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_2$$4, "setproperties", NULL, 0, &properties); + zephir_check_call_status(); + } + RETURN_MM_MEMBER(getThis(), "repository"); } @@ -126080,13 +127293,17 @@ static PHP_METHOD(Phalcon_Cli_Task, setEventsManager) -ZEPHIR_INIT_CLASS(Phalcon_Cli_TaskInterface) +ZEPHIR_INIT_CLASS(Phalcon_Paginator_Adapter_AdapterInterface) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Cli, TaskInterface, phalcon, cli_taskinterface, NULL); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Paginator\\Adapter, AdapterInterface, phalcon, paginator_adapter_adapterinterface, phalcon_paginator_adapter_adapterinterface_method_entry); return SUCCESS; } +ZEPHIR_DOC_METHOD(Phalcon_Paginator_Adapter_AdapterInterface, getLimit); +ZEPHIR_DOC_METHOD(Phalcon_Paginator_Adapter_AdapterInterface, paginate); +ZEPHIR_DOC_METHOD(Phalcon_Paginator_Adapter_AdapterInterface, setCurrentPage); +ZEPHIR_DOC_METHOD(Phalcon_Paginator_Adapter_AdapterInterface, setLimit); @@ -126097,13 +127314,141 @@ ZEPHIR_INIT_CLASS(Phalcon_Cli_TaskInterface) -ZEPHIR_INIT_CLASS(Phalcon_Cli_Dispatcher_Exception) +ZEPHIR_INIT_CLASS(Phalcon_Paginator_Adapter_Model) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli\\Dispatcher, Exception, phalcon, cli_dispatcher_exception, phalcon_dispatcher_exception_ce, NULL, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Paginator\\Adapter, Model, phalcon, paginator_adapter_model, phalcon_paginator_adapter_abstractadapter_ce, phalcon_paginator_adapter_model_method_entry, 0); return SUCCESS; } +static PHP_METHOD(Phalcon_Paginator_Adapter_Model, paginate) +{ + zval _5, _13, _4$$4, _10$$10; + zval config, modelClass, parameters, rowCountResult, pageItems, _0, _1, _2, _3, _6, _14, _7$$6, _8$$10, _9$$10, _11$$10, _12$$10; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, pageNumber = 0, limit = 0, rowcount = 0, next = 0, totalPages = 0, previous = 0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&config); + ZVAL_UNDEF(&modelClass); + ZVAL_UNDEF(¶meters); + ZVAL_UNDEF(&rowCountResult); + ZVAL_UNDEF(&pageItems); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_8$$10); + ZVAL_UNDEF(&_9$$10); + ZVAL_UNDEF(&_11$$10); + ZVAL_UNDEF(&_12$$10); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_13); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_10$$10); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&pageItems); + array_init(&pageItems); + zephir_memory_observe(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("limitRows"), PH_NOISY_CC); + limit = zephir_get_intval(&_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("config"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&config, &_1); + zephir_memory_observe(&_2); + zephir_read_property(&_2, this_ptr, ZEND_STRL("page"), PH_NOISY_CC); + pageNumber = zephir_get_intval(&_2); + zephir_array_fetch_string(&_3, &config, SL("model"), PH_NOISY | PH_READONLY, "phalcon/Paginator/Adapter/Model.zep", 100); + ZEPHIR_CPY_WRT(&modelClass, &_3); + zephir_memory_observe(¶meters); + if (!(zephir_array_isset_string_fetch(¶meters, &config, SL("parameters"), 0))) { + ZEPHIR_INIT_NVAR(¶meters); + array_init(¶meters); + } + if (UNEXPECTED(Z_TYPE_P(¶meters) != IS_ARRAY)) { + zephir_get_arrval(&_4$$4, ¶meters); + ZEPHIR_CPY_WRT(¶meters, &_4$$4); + } + if (pageNumber <= 0) { + pageNumber = 1; + } + ZEPHIR_INIT_VAR(&_5); + zephir_create_array(&_5, 2, 0); + zephir_array_fast_append(&_5, &modelClass); + ZEPHIR_INIT_VAR(&_6); + ZVAL_STRING(&_6, "count"); + zephir_array_fast_append(&_5, &_6); + ZEPHIR_CALL_FUNCTION(&rowCountResult, "call_user_func", NULL, 188, &_5, ¶meters); + zephir_check_call_status(); + if (Z_TYPE_P(&rowCountResult) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(&_7$$6, &rowCountResult, "count", NULL, 0); + zephir_check_call_status(); + rowcount = zephir_get_intval(&_7$$6); + } else { + rowcount = zephir_get_intval(&rowCountResult); + } + if (zephir_safe_mod_long_long(rowcount, limit) != 0) { + totalPages = (int) ((zephir_safe_div_long_long(rowcount, limit) + (double) (1))); + } else { + totalPages = (int) (zephir_safe_div_long_long(rowcount, limit)); + } + if (rowcount > 0) { + ZEPHIR_INIT_VAR(&_8$$10); + ZVAL_LONG(&_8$$10, limit); + zephir_array_update_string(¶meters, SL("limit"), &_8$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_9$$10); + ZVAL_LONG(&_9$$10, (limit * ((pageNumber - 1)))); + zephir_array_update_string(¶meters, SL("offset"), &_9$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_10$$10); + zephir_create_array(&_10$$10, 2, 0); + zephir_array_fast_append(&_10$$10, &modelClass); + ZEPHIR_INIT_VAR(&_11$$10); + ZVAL_STRING(&_11$$10, "find"); + zephir_array_fast_append(&_10$$10, &_11$$10); + ZEPHIR_CALL_FUNCTION(&_12$$10, "call_user_func", NULL, 188, &_10$$10, ¶meters); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&pageItems, &_12$$10); + } + next = (pageNumber + 1); + if (next > totalPages) { + next = totalPages; + } + if (pageNumber > 1) { + previous = (pageNumber - 1); + } else { + previous = 1; + } + ZEPHIR_INIT_VAR(&_13); + zephir_create_array(&_13, 8, 0); + zephir_array_update_string(&_13, SL("items"), &pageItems, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_6); + ZVAL_LONG(&_6, rowcount); + zephir_array_update_string(&_13, SL("total_items"), &_6, PH_COPY | PH_SEPARATE); + zephir_memory_observe(&_14); + zephir_read_property(&_14, this_ptr, ZEND_STRL("limitRows"), PH_NOISY_CC); + zephir_array_update_string(&_13, SL("limit"), &_14, PH_COPY | PH_SEPARATE); + add_assoc_long_ex(&_13, SL("first"), 1); + ZEPHIR_INIT_NVAR(&_6); + ZVAL_LONG(&_6, previous); + zephir_array_update_string(&_13, SL("previous"), &_6, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_6); + ZVAL_LONG(&_6, pageNumber); + zephir_array_update_string(&_13, SL("current"), &_6, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_6); + ZVAL_LONG(&_6, next); + zephir_array_update_string(&_13, SL("next"), &_6, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_6); + ZVAL_LONG(&_6, totalPages); + zephir_array_update_string(&_13, SL("last"), &_6, PH_COPY | PH_SEPARATE); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrepository", NULL, 0, &_13); + zephir_check_call_status(); + RETURN_MM(); +} + @@ -126114,13 +127459,104 @@ ZEPHIR_INIT_CLASS(Phalcon_Cli_Dispatcher_Exception) -ZEPHIR_INIT_CLASS(Phalcon_Cli_Console_Exception) +ZEPHIR_INIT_CLASS(Phalcon_Paginator_Adapter_NativeArray) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli\\Console, Exception, phalcon, cli_console_exception, phalcon_application_exception_ce, NULL, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Paginator\\Adapter, NativeArray, phalcon, paginator_adapter_nativearray, phalcon_paginator_adapter_abstractadapter_ce, phalcon_paginator_adapter_nativearray_method_entry, 0); return SUCCESS; } +static PHP_METHOD(Phalcon_Paginator_Adapter_NativeArray, paginate) +{ + zval _6; + double roundedTotal = 0; + zval config, items, _0, _1, _2, _3, _4, _5, _7, _8; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, show = 0, pageNumber = 0, totalPages = 0, number = 0, previous = 0, next = 0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&config); + ZVAL_UNDEF(&items); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_6); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("config"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&config, &_0); + zephir_memory_observe(&items); + zephir_array_fetch_string(&items, &config, SL("data"), PH_NOISY, "phalcon/Paginator/Adapter/NativeArray.zep", 54); + if (UNEXPECTED(Z_TYPE_P(&items) != IS_ARRAY)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_paginator_exception_ce, "Invalid data for paginator", "phalcon/Paginator/Adapter/NativeArray.zep", 57); + return; + } + zephir_memory_observe(&_1); + zephir_read_property(&_1, this_ptr, ZEND_STRL("limitRows"), PH_NOISY_CC); + show = zephir_get_intval(&_1); + zephir_memory_observe(&_2); + zephir_read_property(&_2, this_ptr, ZEND_STRL("page"), PH_NOISY_CC); + pageNumber = zephir_get_intval(&_2); + if (pageNumber <= 0) { + pageNumber = 1; + } + number = zephir_fast_count_int(&items); + ZVAL_LONG(&_0, show); + ZEPHIR_CALL_FUNCTION(&_3, "floatval", NULL, 18, &_0); + zephir_check_call_status(); + roundedTotal = (zephir_safe_div_long_zval(number, &_3)); + totalPages = (int) (roundedTotal); + if (totalPages != roundedTotal) { + totalPages++; + } + ZVAL_LONG(&_0, (show * ((pageNumber - 1)))); + ZVAL_LONG(&_4, show); + ZEPHIR_CALL_FUNCTION(&_5, "array_slice", NULL, 501, &items, &_0, &_4); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&items, &_5); + if (pageNumber < totalPages) { + next = (pageNumber + 1); + } else { + next = totalPages; + } + if (pageNumber > 1) { + previous = (pageNumber - 1); + } else { + previous = 1; + } + ZEPHIR_INIT_VAR(&_6); + zephir_create_array(&_6, 8, 0); + zephir_array_update_string(&_6, SL("items"), &items, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_7); + ZVAL_LONG(&_7, number); + zephir_array_update_string(&_6, SL("total_items"), &_7, PH_COPY | PH_SEPARATE); + zephir_memory_observe(&_8); + zephir_read_property(&_8, this_ptr, ZEND_STRL("limitRows"), PH_NOISY_CC); + zephir_array_update_string(&_6, SL("limit"), &_8, PH_COPY | PH_SEPARATE); + add_assoc_long_ex(&_6, SL("first"), 1); + ZEPHIR_INIT_NVAR(&_7); + ZVAL_LONG(&_7, previous); + zephir_array_update_string(&_6, SL("previous"), &_7, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_7); + ZVAL_LONG(&_7, pageNumber); + zephir_array_update_string(&_6, SL("current"), &_7, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_7); + ZVAL_LONG(&_7, next); + zephir_array_update_string(&_6, SL("next"), &_7, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_7); + ZVAL_LONG(&_7, totalPages); + zephir_array_update_string(&_6, SL("last"), &_7, PH_COPY | PH_SEPARATE); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrepository", NULL, 0, &_6); + zephir_check_call_status(); + RETURN_MM(); +} + @@ -126131,13 +127567,334 @@ ZEPHIR_INIT_CLASS(Phalcon_Cli_Console_Exception) -ZEPHIR_INIT_CLASS(Phalcon_Cli_Router_Exception) +ZEPHIR_INIT_CLASS(Phalcon_Paginator_Adapter_QueryBuilder) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cli\\Router, Exception, phalcon, cli_router_exception, zend_ce_exception, NULL, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Paginator\\Adapter, QueryBuilder, phalcon, paginator_adapter_querybuilder, phalcon_paginator_adapter_abstractadapter_ce, phalcon_paginator_adapter_querybuilder_method_entry, 0); + zend_declare_property_null(phalcon_paginator_adapter_querybuilder_ce, SL("builder"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_paginator_adapter_querybuilder_ce, SL("columns"), ZEND_ACC_PROTECTED); return SUCCESS; } +static PHP_METHOD(Phalcon_Paginator_Adapter_QueryBuilder, __construct) +{ + zval _1$$5; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *config_param = NULL, builder, columns, _0$$5; + zval config; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&config); + ZVAL_UNDEF(&builder); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&_0$$5); + ZVAL_UNDEF(&_1$$5); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(config) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &config_param); + zephir_get_arrval(&config, config_param); + if (UNEXPECTED(!(zephir_array_isset_string(&config, SL("limit"))))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_paginator_exception_ce, "Parameter 'limit' is required", "phalcon/Paginator/Adapter/QueryBuilder.zep", 70); + return; + } + zephir_memory_observe(&builder); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&builder, &config, SL("builder"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_paginator_exception_ce, "Parameter 'builder' is required", "phalcon/Paginator/Adapter/QueryBuilder.zep", 74); + return; + } + if (UNEXPECTED(!((zephir_instance_of_ev(&builder, phalcon_mvc_model_query_builder_ce))))) { + ZEPHIR_INIT_VAR(&_0$$5); + object_init_ex(&_0$$5, phalcon_paginator_exception_ce); + ZEPHIR_INIT_VAR(&_1$$5); + ZEPHIR_CONCAT_SS(&_1$$5, "Parameter 'builder' must be an instance ", "of Phalcon\\Mvc\\Model\\Query\\Builder"); + ZEPHIR_CALL_METHOD(NULL, &_0$$5, "__construct", NULL, 33, &_1$$5); + zephir_check_call_status(); + zephir_throw_exception_debug(&_0$$5, "phalcon/Paginator/Adapter/QueryBuilder.zep", 80); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_memory_observe(&columns); + if (zephir_array_isset_string_fetch(&columns, &config, SL("columns"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("columns"), &columns); + } + ZEPHIR_CALL_PARENT(NULL, phalcon_paginator_adapter_querybuilder_ce, getThis(), "__construct", NULL, 0, &config); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setquerybuilder", NULL, 0, &builder); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Paginator_Adapter_QueryBuilder, getCurrentPage) +{ + + RETURN_MEMBER(getThis(), "page"); +} + +static PHP_METHOD(Phalcon_Paginator_Adapter_QueryBuilder, getQueryBuilder) +{ + + RETURN_MEMBER(getThis(), "builder"); +} + +static PHP_METHOD(Phalcon_Paginator_Adapter_QueryBuilder, paginate) +{ + zval _23, _7$$14, _9$$15; + zend_bool hasHaving = 0, hasGroup = 0, _3; + zval originalBuilder, builder, totalBuilder, totalPages, limit, number, query, items, totalQuery, result, row, rowcount, next, sql, columns, db, model, modelClass, dbService, groups, groupColumn, _0, _1, _2, _24, _25, _4$$10, _5$$14, _6$$14, _8$$14, _10$$15, _11$$18, _12$$18, _13$$16, _14$$16, _15$$16, _16$$16, _17$$16, _18$$16, _19$$16, _20$$19, _21$$19, _22$$19; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, previous = 0, numberPage = 0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&originalBuilder); + ZVAL_UNDEF(&builder); + ZVAL_UNDEF(&totalBuilder); + ZVAL_UNDEF(&totalPages); + ZVAL_UNDEF(&limit); + ZVAL_UNDEF(&number); + ZVAL_UNDEF(&query); + ZVAL_UNDEF(&items); + ZVAL_UNDEF(&totalQuery); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&row); + ZVAL_UNDEF(&rowcount); + ZVAL_UNDEF(&next); + ZVAL_UNDEF(&sql); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&db); + ZVAL_UNDEF(&model); + ZVAL_UNDEF(&modelClass); + ZVAL_UNDEF(&dbService); + ZVAL_UNDEF(&groups); + ZVAL_UNDEF(&groupColumn); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_24); + ZVAL_UNDEF(&_25); + ZVAL_UNDEF(&_4$$10); + ZVAL_UNDEF(&_5$$14); + ZVAL_UNDEF(&_6$$14); + ZVAL_UNDEF(&_8$$14); + ZVAL_UNDEF(&_10$$15); + ZVAL_UNDEF(&_11$$18); + ZVAL_UNDEF(&_12$$18); + ZVAL_UNDEF(&_13$$16); + ZVAL_UNDEF(&_14$$16); + ZVAL_UNDEF(&_15$$16); + ZVAL_UNDEF(&_16$$16); + ZVAL_UNDEF(&_17$$16); + ZVAL_UNDEF(&_18$$16); + ZVAL_UNDEF(&_19$$16); + ZVAL_UNDEF(&_20$$19); + ZVAL_UNDEF(&_21$$19); + ZVAL_UNDEF(&_22$$19); + ZVAL_UNDEF(&_23); + ZVAL_UNDEF(&_7$$14); + ZVAL_UNDEF(&_9$$15); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_memory_observe(&originalBuilder); + zephir_read_property(&originalBuilder, this_ptr, ZEND_STRL("builder"), PH_NOISY_CC); + zephir_read_property(&_0, this_ptr, ZEND_STRL("columns"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&columns, &_0); + ZEPHIR_INIT_VAR(&builder); + if (zephir_clone(&builder, &originalBuilder) == FAILURE) { + RETURN_MM(); + } + ZEPHIR_INIT_VAR(&totalBuilder); + if (zephir_clone(&totalBuilder, &builder) == FAILURE) { + RETURN_MM(); + } + zephir_memory_observe(&limit); + zephir_read_property(&limit, this_ptr, ZEND_STRL("limitRows"), PH_NOISY_CC); + zephir_memory_observe(&_1); + zephir_read_property(&_1, this_ptr, ZEND_STRL("page"), PH_NOISY_CC); + numberPage = zephir_get_intval(&_1); + if (!(numberPage)) { + numberPage = 1; + } + ZEPHIR_INIT_VAR(&number); + ZVAL_LONG(&number, (zephir_get_numberval(&limit) * ((numberPage - 1)))); + if (ZEPHIR_LT(&number, &limit)) { + ZEPHIR_CALL_METHOD(NULL, &builder, "limit", NULL, 0, &limit); + zephir_check_call_status(); + } else { + ZEPHIR_CALL_METHOD(NULL, &builder, "limit", NULL, 0, &limit, &number); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(&query, &builder, "getquery", NULL, 0); + zephir_check_call_status(); + if (numberPage == 1) { + previous = 1; + } else { + previous = (numberPage - 1); + } + ZEPHIR_CALL_METHOD(&items, &query, "execute", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_2, &totalBuilder, "gethaving", NULL, 0); + zephir_check_call_status(); + hasHaving = !(ZEPHIR_IS_EMPTY(&_2)); + ZEPHIR_CALL_METHOD(&groups, &totalBuilder, "getgroupby", NULL, 0); + zephir_check_call_status(); + hasGroup = !(ZEPHIR_IS_EMPTY(&groups)); + _3 = hasHaving; + if (_3) { + _3 = !hasGroup; + } + if (_3) { + if (UNEXPECTED(ZEPHIR_IS_EMPTY(&columns))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_paginator_exception_ce, "When having is set there should be columns option provided for which calculate row count", "phalcon/Paginator/Adapter/QueryBuilder.zep", 177); + return; + } + ZEPHIR_CALL_METHOD(NULL, &totalBuilder, "columns", NULL, 0, &columns); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_VAR(&_4$$10); + ZVAL_STRING(&_4$$10, "COUNT(*) [rowcount]"); + ZEPHIR_CALL_METHOD(NULL, &totalBuilder, "columns", NULL, 0, &_4$$10); + zephir_check_call_status(); + } + if (hasGroup) { + if (Z_TYPE_P(&groups) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&groupColumn); + zephir_fast_join_str(&groupColumn, SL(", "), &groups); + } else { + ZEPHIR_CPY_WRT(&groupColumn, &groups); + } + if (!(hasHaving)) { + ZVAL_NULL(&_6$$14); + ZEPHIR_CALL_METHOD(&_5$$14, &totalBuilder, "groupby", NULL, 0, &_6$$14); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_7$$14); + zephir_create_array(&_7$$14, 1, 0); + ZEPHIR_INIT_VAR(&_8$$14); + ZEPHIR_CONCAT_SVS(&_8$$14, "COUNT(DISTINCT ", &groupColumn, ") AS [rowcount]"); + zephir_array_fast_append(&_7$$14, &_8$$14); + ZEPHIR_CALL_METHOD(NULL, &_5$$14, "columns", NULL, 0, &_7$$14); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_VAR(&_9$$15); + zephir_create_array(&_9$$15, 1, 0); + ZEPHIR_INIT_VAR(&_10$$15); + ZEPHIR_CONCAT_SV(&_10$$15, "DISTINCT ", &groupColumn); + zephir_array_fast_append(&_9$$15, &_10$$15); + ZEPHIR_CALL_METHOD(NULL, &totalBuilder, "columns", NULL, 0, &_9$$15); + zephir_check_call_status(); + } + } + ZVAL_NULL(&_0); + ZEPHIR_CALL_METHOD(NULL, &totalBuilder, "orderby", NULL, 0, &_0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&totalQuery, &totalBuilder, "getquery", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&rowcount); + if (hasHaving) { + ZEPHIR_CALL_METHOD(&sql, &totalQuery, "getsql", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&modelClass, &builder, "getmodels", NULL, 0); + zephir_check_call_status(); + if (UNEXPECTED(Z_TYPE_P(&modelClass) == IS_NULL)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_paginator_exception_ce, "Model not defined in builder", "phalcon/Paginator/Adapter/QueryBuilder.zep", 229); + return; + } + if (Z_TYPE_P(&modelClass) == IS_ARRAY) { + ZEPHIR_CALL_FUNCTION(&_11$$18, "array_values", NULL, 14, &modelClass); + zephir_check_call_status(); + zephir_array_fetch_long(&_12$$18, &_11$$18, 0, PH_NOISY | PH_READONLY, "phalcon/Paginator/Adapter/QueryBuilder.zep", 233); + ZEPHIR_CPY_WRT(&modelClass, &_12$$18); + } + ZEPHIR_INIT_VAR(&model); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&model, &modelClass); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&dbService, &model, "getreadconnectionservice", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_13$$16, &totalBuilder, "getdi", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&db, &_13$$16, "get", NULL, 0, &dbService); + zephir_check_call_status(); + zephir_array_fetch_string(&_14$$16, &sql, SL("sql"), PH_NOISY | PH_READONLY, "phalcon/Paginator/Adapter/QueryBuilder.zep", 241); + ZEPHIR_INIT_VAR(&_15$$16); + ZEPHIR_CONCAT_SVS(&_15$$16, "SELECT COUNT(*) as \"rowcount\" FROM (", &_14$$16, ") as T1"); + zephir_array_fetch_string(&_16$$16, &sql, SL("bind"), PH_NOISY | PH_READONLY, "phalcon/Paginator/Adapter/QueryBuilder.zep", 244); + ZVAL_LONG(&_17$$16, 2); + ZEPHIR_CALL_METHOD(&row, &db, "fetchone", NULL, 0, &_15$$16, &_17$$16, &_16$$16); + zephir_check_call_status(); + if (zephir_is_true(&row)) { + zephir_array_fetch_string(&_18$$16, &row, SL("rowcount"), PH_NOISY | PH_READONLY, "phalcon/Paginator/Adapter/QueryBuilder.zep", 246); + ZVAL_LONG(&rowcount, zephir_get_intval(&_18$$16)); + } else { + ZVAL_LONG(&rowcount, 0); + } + ZEPHIR_INIT_VAR(&_19$$16); + div_function(&_19$$16, &rowcount, &limit); + ZVAL_DOUBLE(&_17$$16, zephir_ceil(&_19$$16)); + ZEPHIR_INIT_VAR(&totalPages); + ZVAL_LONG(&totalPages, zephir_get_intval(&_17$$16)); + } else { + ZEPHIR_CALL_METHOD(&result, &totalQuery, "execute", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&row, &result, "getfirst", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&row)) { + zephir_read_property(&_20$$19, &row, ZEND_STRL("rowcount"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&rowcount); + ZVAL_LONG(&rowcount, zephir_get_intval(&_20$$19)); + } else { + ZEPHIR_INIT_NVAR(&rowcount); + ZVAL_LONG(&rowcount, 0); + } + ZEPHIR_INIT_VAR(&_21$$19); + div_function(&_21$$19, &rowcount, &limit); + ZVAL_DOUBLE(&_22$$19, zephir_ceil(&_21$$19)); + ZEPHIR_INIT_NVAR(&totalPages); + ZVAL_LONG(&totalPages, zephir_get_intval(&_22$$19)); + } + if (ZEPHIR_GT_LONG(&totalPages, numberPage)) { + ZEPHIR_INIT_VAR(&next); + ZVAL_LONG(&next, (numberPage + 1)); + } else { + ZEPHIR_CPY_WRT(&next, &totalPages); + } + ZEPHIR_INIT_VAR(&_23); + zephir_create_array(&_23, 8, 0); + zephir_array_update_string(&_23, SL("items"), &items, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_23, SL("total_items"), &rowcount, PH_COPY | PH_SEPARATE); + zephir_memory_observe(&_24); + zephir_read_property(&_24, this_ptr, ZEND_STRL("limitRows"), PH_NOISY_CC); + zephir_array_update_string(&_23, SL("limit"), &_24, PH_COPY | PH_SEPARATE); + add_assoc_long_ex(&_23, SL("first"), 1); + ZEPHIR_INIT_VAR(&_25); + ZVAL_LONG(&_25, previous); + zephir_array_update_string(&_23, SL("previous"), &_25, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_25); + ZVAL_LONG(&_25, numberPage); + zephir_array_update_string(&_23, SL("current"), &_25, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_23, SL("next"), &next, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_23, SL("last"), &totalPages, PH_COPY | PH_SEPARATE); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getrepository", NULL, 0, &_23); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Paginator_Adapter_QueryBuilder, setQueryBuilder) +{ + zval *builder, builder_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&builder_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(builder, phalcon_mvc_model_query_builder_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &builder); + zephir_update_property_zval(this_ptr, ZEND_STRL("builder"), builder); + RETURN_THISW(); +} + @@ -126148,110 +127905,184 @@ ZEPHIR_INIT_CLASS(Phalcon_Cli_Router_Exception) -ZEPHIR_INIT_CLASS(Phalcon_Cli_Router_Route) +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Connection) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Cli\\Router, Route, phalcon, cli_router_route, phalcon_cli_router_route_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Pdo, Connection, phalcon, datamapper_pdo_connection, phalcon_datamapper_pdo_connection_abstractconnection_ce, phalcon_datamapper_pdo_connection_method_entry, 0); - zend_declare_property_null(phalcon_cli_router_route_ce, SL("beforeMatch"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_cli_router_route_ce, SL("compiledPattern"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_cli_router_route_ce, SL("converters"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_cli_router_route_ce, SL("delimiter"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_cli_router_route_ce, SL("delimiterPath"), " ", ZEND_ACC_PROTECTED|ZEND_ACC_STATIC); - zend_declare_property_string(phalcon_cli_router_route_ce, SL("description"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_cli_router_route_ce, SL("routeId"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_cli_router_route_ce, SL("name"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_cli_router_route_ce, SL("paths"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_cli_router_route_ce, SL("pattern"), "", ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_cli_router_route_ce, SL("uniqueId"), 0, ZEND_ACC_PROTECTED|ZEND_ACC_STATIC); - phalcon_cli_router_route_ce->create_object = zephir_init_properties_Phalcon_Cli_Router_Route; - zephir_declare_class_constant_string(phalcon_cli_router_route_ce, SL("DEFAULT_DELIMITER"), " "); + zend_declare_property_null(phalcon_datamapper_pdo_connection_ce, SL("arguments"), ZEND_ACC_PROTECTED); + phalcon_datamapper_pdo_connection_ce->create_object = zephir_init_properties_Phalcon_DataMapper_Pdo_Connection; - zend_class_implements(phalcon_cli_router_route_ce, 1, phalcon_cli_router_routeinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Cli_Router_Route, __construct) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval options, queries, available, _5; + zval *dsn_param = NULL, *username_param = NULL, *password_param = NULL, *options_param = NULL, *queries_param = NULL, *profiler = NULL, profiler_sub, __$true, __$null, parts, _0, _1$$3, _2$$3, _3$$3, _4$$4; + zval dsn, username, password; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&dsn); + ZVAL_UNDEF(&username); + ZVAL_UNDEF(&password); + ZVAL_UNDEF(&profiler_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&parts); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&queries); + ZVAL_UNDEF(&available); + ZVAL_UNDEF(&_5); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 6) + Z_PARAM_STR(dsn) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(username) + Z_PARAM_STR_OR_NULL(password) + Z_PARAM_ARRAY(options) + Z_PARAM_ARRAY(queries) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(profiler, phalcon_datamapper_pdo_profiler_profilerinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 5, &dsn_param, &username_param, &password_param, &options_param, &queries_param, &profiler); + zephir_get_strval(&dsn, dsn_param); + if (!username_param) { + ZEPHIR_INIT_VAR(&username); + } else { + zephir_get_strval(&username, username_param); + } + if (!password_param) { + ZEPHIR_INIT_VAR(&password); + } else { + zephir_get_strval(&password, password_param); + } + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + if (!queries_param) { + ZEPHIR_INIT_VAR(&queries); + array_init(&queries); + } else { + zephir_get_arrval(&queries, queries_param); + } + if (!profiler) { + profiler = &profiler_sub; + ZEPHIR_CPY_WRT(profiler, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(profiler); + } + ZEPHIR_INIT_VAR(&parts); + zephir_fast_explode_str(&parts, SL(":"), &dsn, LONG_MAX); + ZEPHIR_INIT_VAR(&available); + zephir_create_array(&available, 4, 0); + zephir_array_update_string(&available, SL("mysql"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&available, SL("pgsql"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&available, SL("sqlite"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&available, SL("mssql"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_fetch_long(&_0, &parts, 0, PH_READONLY, "phalcon/DataMapper/Pdo/Connection.zep", 65); + if (!(zephir_array_isset(&available, &_0))) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, spl_ce_InvalidArgumentException); + zephir_array_fetch_long(&_2$$3, &parts, 0, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/Connection.zep", 67); + ZEPHIR_INIT_VAR(&_3$$3); + ZEPHIR_CONCAT_SVS(&_3$$3, "Driver not supported [", &_2$$3, "]"); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 200, &_3$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/DataMapper/Pdo/Connection.zep", 68); + ZEPHIR_MM_RESTORE(); + return; + } + if (!(zephir_array_isset_long(&options, 3))) { + ZEPHIR_INIT_VAR(&_4$$4); + ZVAL_LONG(&_4$$4, 2); + zephir_array_update_long(&options, 3, &_4$$4, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + } + ZEPHIR_INIT_VAR(&_5); + zephir_create_array(&_5, 5, 0); + zephir_array_fast_append(&_5, &dsn); + zephir_array_fast_append(&_5, &username); + zephir_array_fast_append(&_5, &password); + zephir_array_fast_append(&_5, &options); + zephir_array_fast_append(&_5, &queries); + zephir_update_property_zval(this_ptr, ZEND_STRL("arguments"), &_5); + if (Z_TYPE_P(profiler) == IS_NULL) { + ZEPHIR_INIT_NVAR(profiler); + object_init_ex(profiler, phalcon_datamapper_pdo_profiler_profiler_ce); + ZEPHIR_CALL_METHOD(NULL, profiler, "__construct", NULL, 201); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setprofiler", NULL, 0, profiler); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection, __debugInfo) { + zval _1, _2, _3, _4, _5; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, routeId, uniqueId, _0, _1; - zval pattern, _2; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&routeId); - ZVAL_UNDEF(&uniqueId); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - paths = &__$null; - } - zephir_memory_observe(&_0); - zephir_read_static_property_ce(&_0, phalcon_cli_router_route_ce, SL("delimiterPath"), PH_NOISY_CC); - zephir_update_property_zval(this_ptr, ZEND_STRL("delimiter"), &_0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "reconfigure", NULL, 0, &pattern, paths); - zephir_check_call_status(); - zephir_memory_observe(&_1); - zephir_read_static_property_ce(&_1, phalcon_cli_router_route_ce, SL("uniqueId"), PH_NOISY_CC); - ZEPHIR_CPY_WRT(&uniqueId, &_1); - ZEPHIR_CPY_WRT(&routeId, &uniqueId); - zephir_cast_to_string(&_2, &routeId); - zephir_update_property_zval(this_ptr, ZEND_STRL("routeId"), &_2); - ZVAL_UNDEF(&_1); - ZVAL_LONG(&_1, (zephir_get_numberval(&uniqueId) + 1)); - zephir_update_static_property_ce(phalcon_cli_router_route_ce, ZEND_STRL("uniqueId"), &_1); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Cli_Router_Route, beforeMatch) -{ - zval *callback, callback_sub; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&callback_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(callback) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &callback); - zephir_update_property_zval(this_ptr, ZEND_STRL("beforeMatch"), callback); - RETURN_THISW(); + zephir_create_array(return_value, 1, 0); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 5, 0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); + zephir_memory_observe(&_2); + zephir_array_fetch_long(&_2, &_1, 0, PH_NOISY, "phalcon/DataMapper/Pdo/Connection.zep", 102); + zephir_array_fast_append(&_0, &_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "****"); + zephir_array_fast_append(&_0, &_3); + ZEPHIR_INIT_NVAR(&_3); + ZVAL_STRING(&_3, "****"); + zephir_array_fast_append(&_0, &_3); + zephir_read_property(&_4, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_OBS_NVAR(&_2); + zephir_array_fetch_long(&_2, &_4, 3, PH_NOISY, "phalcon/DataMapper/Pdo/Connection.zep", 105); + zephir_array_fast_append(&_0, &_2); + zephir_read_property(&_5, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_OBS_NVAR(&_2); + zephir_array_fetch_long(&_2, &_5, 4, PH_NOISY, "phalcon/DataMapper/Pdo/Connection.zep", 107); + zephir_array_fast_append(&_0, &_2); + zephir_array_update_string(return_value, SL("arguments"), &_0, PH_COPY | PH_SEPARATE); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Cli_Router_Route, compilePattern) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection, connect) { - zend_bool _20; - zval map; + zval dsn, options, password, query, queries, username, _0, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, _7$$3, _8$$3, *_9$$3, _10$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_11 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL, idPattern, _0$$3, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, _7$$3, _8$$3, _9$$3, _10$$3, _11$$3, _12$$3, _13$$3, _14$$3, _15$$3, _16$$3, _17$$3, _18$$3, _19$$3; - zval pattern; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&idPattern); - ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&dsn); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&password); + ZVAL_UNDEF(&query); + ZVAL_UNDEF(&queries); + ZVAL_UNDEF(&username); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); @@ -126260,693 +128091,471 @@ static PHP_METHOD(Phalcon_Cli_Router_Route, compilePattern) ZVAL_UNDEF(&_6$$3); ZVAL_UNDEF(&_7$$3); ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_9$$3); ZVAL_UNDEF(&_10$$3); - ZVAL_UNDEF(&_11$$3); - ZVAL_UNDEF(&_12$$3); - ZVAL_UNDEF(&_13$$3); - ZVAL_UNDEF(&_14$$3); - ZVAL_UNDEF(&_15$$3); - ZVAL_UNDEF(&_16$$3); - ZVAL_UNDEF(&_17$$3); - ZVAL_UNDEF(&_18$$3); - ZVAL_UNDEF(&_19$$3); - ZVAL_UNDEF(&map); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(pattern) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &pattern_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (zephir_memnstr_str(&pattern, SL(":"), "phalcon/Cli/Router/Route.zep", 121)) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&idPattern); - ZEPHIR_CONCAT_VS(&idPattern, &_0$$3, "([a-zA-Z0-9\\_\\-]+)"); - ZEPHIR_INIT_VAR(&map); - zephir_create_array(&map, 7, 0); - zephir_memory_observe(&_1$$3); - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC); - zephir_array_update_string(&map, SL(":delimiter"), &_1$$3, PH_COPY | PH_SEPARATE); - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_3$$3); - ZEPHIR_CONCAT_VS(&_3$$3, &_2$$3, ":module"); - zephir_array_update_zval(&map, &_3$$3, &idPattern, PH_COPY); - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_5$$3); - ZEPHIR_CONCAT_VS(&_5$$3, &_4$$3, ":task"); - zephir_array_update_zval(&map, &_5$$3, &idPattern, PH_COPY); - zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_7$$3); - ZEPHIR_CONCAT_VS(&_7$$3, &_6$$3, ":namespace"); - zephir_array_update_zval(&map, &_7$$3, &idPattern, PH_COPY); - zephir_read_property(&_8$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_9$$3); - ZEPHIR_CONCAT_VS(&_9$$3, &_8$$3, ":action"); - zephir_array_update_zval(&map, &_9$$3, &idPattern, PH_COPY); - zephir_read_property(&_10$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_11$$3); - ZEPHIR_CONCAT_VS(&_11$$3, &_10$$3, ":params"); - zephir_read_property(&_12$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_13$$3); - ZEPHIR_CONCAT_SVS(&_13$$3, "(", &_12$$3, ".*)*"); - zephir_array_update_zval(&map, &_11$$3, &_13$$3, PH_COPY); - zephir_read_property(&_14$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_13$$3); - ZEPHIR_CONCAT_VS(&_13$$3, &_14$$3, ":int"); - zephir_read_property(&_15$$3, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_16$$3); - ZEPHIR_CONCAT_VS(&_16$$3, &_15$$3, "([0-9]+)"); - zephir_array_update_zval(&map, &_13$$3, &_16$$3, PH_COPY); - ZEPHIR_INIT_VAR(&_17$$3); - ZEPHIR_INIT_VAR(&_18$$3); - zephir_array_keys(&_18$$3, &map); - ZEPHIR_CALL_FUNCTION(&_19$$3, "array_values", NULL, 14, &map); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_is_true(&_0))) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "connect"); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "start", NULL, 0, &_2$$3); zephir_check_call_status(); - zephir_fast_str_replace(&_17$$3, &_18$$3, &_19$$3, &pattern); - zephir_get_strval(&pattern, &_17$$3); - } - _20 = zephir_memnstr_str(&pattern, SL("("), "phalcon/Cli/Router/Route.zep", 146); - if (!(_20)) { - _20 = zephir_memnstr_str(&pattern, SL("["), "phalcon/Cli/Router/Route.zep", 146); - } - if (_20) { - ZEPHIR_CONCAT_SVS(return_value, "#^", &pattern, "$#"); - RETURN_MM(); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); + zephir_memory_observe(&dsn); + zephir_array_fetch_long(&dsn, &_3$$3, 0, PH_NOISY, "phalcon/DataMapper/Pdo/Connection.zep", 122); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); + zephir_memory_observe(&username); + zephir_array_fetch_long(&username, &_4$$3, 1, PH_NOISY, "phalcon/DataMapper/Pdo/Connection.zep", 123); + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); + zephir_memory_observe(&password); + zephir_array_fetch_long(&password, &_5$$3, 2, PH_NOISY, "phalcon/DataMapper/Pdo/Connection.zep", 124); + zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); + zephir_memory_observe(&options); + zephir_array_fetch_long(&options, &_6$$3, 3, PH_NOISY, "phalcon/DataMapper/Pdo/Connection.zep", 125); + zephir_read_property(&_7$$3, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); + zephir_memory_observe(&queries); + zephir_array_fetch_long(&queries, &_7$$3, 4, PH_NOISY, "phalcon/DataMapper/Pdo/Connection.zep", 126); + ZEPHIR_INIT_NVAR(&_2$$3); + object_init_ex(&_2$$3, php_pdo_get_dbh_ce()); + ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 0, &dsn, &username, &password, &options); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("pdo"), &_2$$3); + zephir_read_property(&_8$$3, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_8$$3, "finish", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&queries, 0, "phalcon/DataMapper/Pdo/Connection.zep", 136); + if (Z_TYPE_P(&queries) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&queries), _9$$3) + { + ZEPHIR_INIT_NVAR(&query); + ZVAL_COPY(&query, _9$$3); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "exec", &_11, 0, &query); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &queries, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_10$$3, &queries, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_10$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&query, &queries, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "exec", &_11, 0, &query); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &queries, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&query); } - RETURN_CTOR(&pattern); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Cli_Router_Route, convert) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection, disconnect) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, *converter, converter_sub; - zval name; + zval __$null, _0, _1, _2; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&converter_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_ZVAL(converter) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &converter); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - zephir_update_property_array(this_ptr, SL("converters"), &name, converter); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Cli_Router_Route, delimiter) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *delimiter_param = NULL; - zval delimiter; - ZVAL_UNDEF(&delimiter); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(delimiter) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &delimiter_param); - if (!delimiter_param) { - ZEPHIR_INIT_VAR(&delimiter); - } else { - if (UNEXPECTED(Z_TYPE_P(delimiter_param) != IS_STRING && Z_TYPE_P(delimiter_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'delimiter' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(delimiter_param) == IS_STRING)) { - zephir_get_strval(&delimiter, delimiter_param); - } else { - ZEPHIR_INIT_VAR(&delimiter); - } - } - zephir_update_static_property_ce(phalcon_cli_router_route_ce, ZEND_STRL("delimiterPath"), &delimiter); + zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "disconnect"); + ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("pdo"), &__$null); + zephir_read_property(&_2, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_2, "finish", NULL, 0); + zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Cli_Router_Route, extractNamedParams) +zend_object *zephir_init_properties_Phalcon_DataMapper_Pdo_Connection(zend_class_entry *class_type) { - long _0, _5$$10, _26$$18; - zend_long cursor = 0, cursorVar = 0, marker = 0, bracketCount, parenthesesCount, foundPattern, intermediate, numberMatches; - zend_bool notValid = 0, _6$$11, _7$$11, _8$$11, _9$$11, _10$$11, _11$$11, _12$$11, _13$$11, _14$$11, _15$$11, _16$$11, _17$$11, _25$$17; - zval matches; - char ch = 0; + zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *pattern_param = NULL, tmp, _1$$10, _2$$10, _3$$10, _18$$15, _19$$15, _20$$15, _22$$15, _23$$15, _28$$27, _29$$27; - zval pattern, route, item, variable, regexp, _4$$10, _21$$15, _24$$15, _27$$25, _30$$28; - zval *this_ptr = getThis(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&route); - ZVAL_UNDEF(&item); - ZVAL_UNDEF(&variable); - ZVAL_UNDEF(®exp); - ZVAL_UNDEF(&_4$$10); - ZVAL_UNDEF(&_21$$15); - ZVAL_UNDEF(&_24$$15); - ZVAL_UNDEF(&_27$$25); - ZVAL_UNDEF(&_30$$28); - ZVAL_UNDEF(&tmp); - ZVAL_UNDEF(&_1$$10); - ZVAL_UNDEF(&_2$$10); - ZVAL_UNDEF(&_3$$10); - ZVAL_UNDEF(&_18$$15); - ZVAL_UNDEF(&_19$$15); - ZVAL_UNDEF(&_20$$15); - ZVAL_UNDEF(&_22$$15); - ZVAL_UNDEF(&_23$$15); - ZVAL_UNDEF(&_28$$27); - ZVAL_UNDEF(&_29$$27); - ZVAL_UNDEF(&matches); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(pattern) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &pattern_param); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - bracketCount = 0; - parenthesesCount = 0; - foundPattern = 0; - intermediate = 0; - numberMatches = 0; - if (zephir_fast_strlen_ev(&pattern) == 0) { - RETURN_MM_BOOL(0); - } - ZEPHIR_INIT_VAR(&matches); - array_init(&matches); - ZEPHIR_INIT_VAR(&route); - for (_0 = 0; _0 < Z_STRLEN_P(&pattern); _0++) { - cursor = _0; - ch = ZEPHIR_STRING_OFFSET(&pattern, _0); - if (parenthesesCount == 0) { - if (ch == '{') { - if (bracketCount == 0) { - marker = (cursor + 1); - intermediate = 0; - notValid = 0; - } - bracketCount++; - } else if (ch == '}') { - bracketCount--; - if (intermediate > 0) { - if (bracketCount == 0) { - numberMatches++; - ZEPHIR_INIT_NVAR(&variable); - ZEPHIR_INIT_NVAR(®exp); - ZVAL_LONG(&_1$$10, marker); - ZVAL_LONG(&_2$$10, (cursor - marker)); - ZEPHIR_INIT_NVAR(&_3$$10); - zephir_substr(&_3$$10, &pattern, zephir_get_intval(&_1$$10), zephir_get_intval(&_2$$10), 0); - zephir_cast_to_string(&_4$$10, &_3$$10); - ZEPHIR_CPY_WRT(&item, &_4$$10); - for (_5$$10 = 0; _5$$10 < Z_STRLEN_P(&item); _5$$10++) { - cursorVar = _5$$10; - ch = ZEPHIR_STRING_OFFSET(&item, _5$$10); - if (ch == '\0') { - break; - } - _6$$11 = cursorVar == 0; - if (_6$$11) { - _7$$11 = ch >= 'a'; - if (_7$$11) { - _7$$11 = ch <= 'z'; - } - _8$$11 = _7$$11; - if (!(_8$$11)) { - _9$$11 = ch >= 'A'; - if (_9$$11) { - _9$$11 = ch <= 'Z'; - } - _8$$11 = _9$$11; - } - _6$$11 = !(_8$$11); - } - if (_6$$11) { - notValid = 1; - break; - } - _10$$11 = ch >= 'a'; - if (_10$$11) { - _10$$11 = ch <= 'z'; - } - _11$$11 = _10$$11; - if (!(_11$$11)) { - _12$$11 = ch >= 'A'; - if (_12$$11) { - _12$$11 = ch <= 'Z'; - } - _11$$11 = _12$$11; - } - _13$$11 = _11$$11; - if (!(_13$$11)) { - _14$$11 = ch >= '0'; - if (_14$$11) { - _14$$11 = ch <= '9'; - } - _13$$11 = _14$$11; - } - _15$$11 = _13$$11; - if (!(_15$$11)) { - _15$$11 = ch == '-'; - } - _16$$11 = _15$$11; - if (!(_16$$11)) { - _16$$11 = ch == '_'; - } - _17$$11 = _16$$11; - if (!(_17$$11)) { - _17$$11 = ch == ':'; - } - if (_17$$11) { - if (ch == ':') { - ZVAL_LONG(&_18$$15, 0); - ZVAL_LONG(&_19$$15, cursorVar); - ZEPHIR_INIT_NVAR(&_20$$15); - zephir_substr(&_20$$15, &item, 0 , zephir_get_intval(&_19$$15), 0); - zephir_cast_to_string(&_21$$15, &_20$$15); - ZEPHIR_CPY_WRT(&variable, &_21$$15); - ZVAL_LONG(&_22$$15, (cursorVar + 1)); - ZEPHIR_INIT_NVAR(&_23$$15); - zephir_substr(&_23$$15, &item, zephir_get_intval(&_22$$15), 0, ZEPHIR_SUBSTR_NO_LENGTH); - zephir_cast_to_string(&_24$$15, &_23$$15); - ZEPHIR_CPY_WRT(®exp, &_24$$15); - break; - } - } else { - notValid = 1; - break; - } - } - if (!(notValid)) { - ZEPHIR_INIT_NVAR(&tmp); - ZVAL_LONG(&tmp, numberMatches); - _25$$17 = zephir_is_true(&variable); - if (_25$$17) { - _25$$17 = zephir_is_true(®exp); - } - if (_25$$17) { - foundPattern = 0; - for (_26$$18 = 0; _26$$18 < Z_STRLEN_P(®exp); _26$$18++) { - ch = ZEPHIR_STRING_OFFSET(®exp, _26$$18); - if (ch == '\0') { - break; - } - if (!(foundPattern)) { - if (ch == '(') { - foundPattern = 1; - } - } else { - if (ch == ')') { - foundPattern = 2; - break; - } - } - } - if (foundPattern != 2) { - ZEPHIR_INIT_NVAR(&_27$$25); - ZEPHIR_CONCAT_SVS(&_27$$25, "(", ®exp, ")"); - zephir_concat_self(&route, &_27$$25); - } else { - zephir_concat_self(&route, ®exp); - } - zephir_array_update_zval(&matches, &variable, &tmp, PH_COPY | PH_SEPARATE); - } else { - zephir_read_property(&_28$$27, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_29$$27); - ZEPHIR_CONCAT_SVS(&_29$$27, "([^", &_28$$27, "]*)"); - zephir_concat_self(&route, &_29$$27); - zephir_array_update_zval(&matches, &item, &tmp, PH_COPY | PH_SEPARATE); - } - } else { - ZEPHIR_INIT_NVAR(&_30$$28); - ZEPHIR_CONCAT_SVS(&_30$$28, "{", &item, "}"); - zephir_concat_self(&route, &_30$$28); - } - continue; - } - } - } - } - if (bracketCount == 0) { - if (ch == '(') { - parenthesesCount++; - } else if (ch == ')') { - parenthesesCount--; - if (parenthesesCount == 0) { - numberMatches++; - } - } - } - if (bracketCount > 0) { - intermediate++; - } else { - zephir_concat_self_char(&route, ch); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("arguments"), &_1$$3); } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } - zephir_create_array(return_value, 2, 0); - zephir_array_fast_append(return_value, &route); - zephir_array_fast_append(return_value, &matches); - RETURN_MM(); } -static PHP_METHOD(Phalcon_Cli_Router_Route, getBeforeMatch) -{ - RETURN_MEMBER(getThis(), "beforeMatch"); -} -static PHP_METHOD(Phalcon_Cli_Router_Route, getCompiledPattern) -{ - RETURN_MEMBER(getThis(), "compiledPattern"); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Cli_Router_Route, getConverters) -{ - RETURN_MEMBER(getThis(), "converters"); -} -static PHP_METHOD(Phalcon_Cli_Router_Route, getDelimiter) -{ - zval _0; - ZVAL_UNDEF(&_0); - zephir_read_static_property_ce(&_0, phalcon_cli_router_route_ce, SL("delimiterPath"), PH_NOISY_CC | PH_READONLY); - RETURN_CTORW(&_0); -} -static PHP_METHOD(Phalcon_Cli_Router_Route, getDescription) +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_ConnectionLocator) { + ZEPHIR_REGISTER_CLASS(Phalcon\\DataMapper\\Pdo, ConnectionLocator, phalcon, datamapper_pdo_connectionlocator, phalcon_datamapper_pdo_connectionlocator_method_entry, 0); - RETURN_MEMBER(getThis(), "description"); -} - -static PHP_METHOD(Phalcon_Cli_Router_Route, getName) -{ + zend_declare_property_null(phalcon_datamapper_pdo_connectionlocator_ce, SL("master"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_datamapper_pdo_connectionlocator_ce, SL("read"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_datamapper_pdo_connectionlocator_ce, SL("write"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_datamapper_pdo_connectionlocator_ce, SL("instances"), ZEND_ACC_PRIVATE); + phalcon_datamapper_pdo_connectionlocator_ce->create_object = zephir_init_properties_Phalcon_DataMapper_Pdo_ConnectionLocator; - RETURN_MEMBER(getThis(), "name"); + zend_class_implements(phalcon_datamapper_pdo_connectionlocator_ce, 1, phalcon_datamapper_pdo_connectionlocatorinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Cli_Router_Route, getPaths) +static PHP_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocator, __construct) { + zend_string *_3, *_8; + zend_ulong _2, _7; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL, *_9 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval read, write; + zval *master, master_sub, *read_param = NULL, *write_param = NULL, name, callableObject, *_0, _1, *_5, _6; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "paths"); + ZVAL_UNDEF(&master_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&callableObject); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&read); + ZVAL_UNDEF(&write); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_OBJECT_OF_CLASS(master, phalcon_datamapper_pdo_connection_connectioninterface_ce) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(read) + Z_PARAM_ARRAY(write) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &master, &read_param, &write_param); + if (!read_param) { + ZEPHIR_INIT_VAR(&read); + array_init(&read); + } else { + zephir_get_arrval(&read, read_param); + } + if (!write_param) { + ZEPHIR_INIT_VAR(&write); + array_init(&write); + } else { + zephir_get_arrval(&write, write_param); + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setmaster", NULL, 0, master); + zephir_check_call_status(); + zephir_is_iterable(&read, 0, "phalcon/DataMapper/Pdo/ConnectionLocator.zep", 74); + if (Z_TYPE_P(&read) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&read), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&name); + if (_3 != NULL) { + ZVAL_STR_COPY(&name, _3); + } else { + ZVAL_LONG(&name, _2); + } + ZEPHIR_INIT_NVAR(&callableObject); + ZVAL_COPY(&callableObject, _0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setread", &_4, 0, &name, &callableObject); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &read, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &read, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&name, &read, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&callableObject, &read, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setread", &_4, 0, &name, &callableObject); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &read, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&callableObject); + ZEPHIR_INIT_NVAR(&name); + zephir_is_iterable(&write, 0, "phalcon/DataMapper/Pdo/ConnectionLocator.zep", 77); + if (Z_TYPE_P(&write) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&write), _7, _8, _5) + { + ZEPHIR_INIT_NVAR(&name); + if (_8 != NULL) { + ZVAL_STR_COPY(&name, _8); + } else { + ZVAL_LONG(&name, _7); + } + ZEPHIR_INIT_NVAR(&callableObject); + ZVAL_COPY(&callableObject, _5); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setwrite", &_9, 0, &name, &callableObject); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &write, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_6, &write, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_6)) { + break; + } + ZEPHIR_CALL_METHOD(&name, &write, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&callableObject, &write, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setwrite", &_9, 0, &name, &callableObject); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &write, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&callableObject); + ZEPHIR_INIT_NVAR(&name); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Cli_Router_Route, getPattern) +static PHP_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocator, getMaster) { - RETURN_MEMBER(getThis(), "pattern"); + RETURN_MEMBER(getThis(), "master"); } -static PHP_METHOD(Phalcon_Cli_Router_Route, getReversedPaths) +static PHP_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocator, getRead) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, _0; + zval name; zval *this_ptr = getThis(); + ZVAL_UNDEF(&name); ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("paths"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_FUNCTION("array_flip", NULL, 100, &_0); + zephir_fetch_params(1, 0, 1, &name_param); + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + ZVAL_STRING(&name, ""); + } else { + zephir_get_strval(&name, name_param); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "read"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getconnection", NULL, 0, &_0, &name); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Cli_Router_Route, getRouteId) -{ - - RETURN_MEMBER(getThis(), "routeId"); -} - -static PHP_METHOD(Phalcon_Cli_Router_Route, reConfigure) +static PHP_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocator, getWrite) { - zend_bool _1$$10; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, _0$$4; - zval *pattern_param = NULL, *paths = NULL, paths_sub, __$null, moduleName, taskName, actionName, parts, routePaths, realClassName, namespaceName, pcrePattern, compiledPattern, extracted, _2$$9, _3$$18, _4$$18, _5$$21, _6$$21, _7$$21; - zval pattern; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, _0; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&paths_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&moduleName); - ZVAL_UNDEF(&taskName); - ZVAL_UNDEF(&actionName); - ZVAL_UNDEF(&parts); - ZVAL_UNDEF(&routePaths); - ZVAL_UNDEF(&realClassName); - ZVAL_UNDEF(&namespaceName); - ZVAL_UNDEF(&pcrePattern); - ZVAL_UNDEF(&compiledPattern); - ZVAL_UNDEF(&extracted); - ZVAL_UNDEF(&_2$$9); - ZVAL_UNDEF(&_3$$18); - ZVAL_UNDEF(&_4$$18); - ZVAL_UNDEF(&_5$$21); - ZVAL_UNDEF(&_6$$21); - ZVAL_UNDEF(&_7$$21); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(pattern) + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(paths) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &pattern_param, &paths); - if (UNEXPECTED(Z_TYPE_P(pattern_param) != IS_STRING && Z_TYPE_P(pattern_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'pattern' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(pattern_param) == IS_STRING)) { - zephir_get_strval(&pattern, pattern_param); - } else { - ZEPHIR_INIT_VAR(&pattern); - } - if (!paths) { - paths = &paths_sub; - ZEPHIR_CPY_WRT(paths, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(paths); - } - if (Z_TYPE_P(paths) == IS_NULL) { - ZEPHIR_INIT_NVAR(paths); - array_init(paths); - } - if (Z_TYPE_P(paths) == IS_STRING) { - ZEPHIR_INIT_VAR(&moduleName); - ZVAL_NULL(&moduleName); - ZEPHIR_INIT_VAR(&taskName); - ZVAL_NULL(&taskName); - ZEPHIR_INIT_VAR(&actionName); - ZVAL_NULL(&actionName); - ZEPHIR_INIT_VAR(&parts); - zephir_fast_explode_str(&parts, SL("::"), paths, LONG_MAX); - do { - _0$$4 = zephir_fast_count_int(&parts); - if (_0$$4 == 3) { - ZEPHIR_OBS_NVAR(&moduleName); - zephir_array_fetch_long(&moduleName, &parts, 0, PH_NOISY, "phalcon/Cli/Router/Route.zep", 417); - ZEPHIR_OBS_NVAR(&taskName); - zephir_array_fetch_long(&taskName, &parts, 1, PH_NOISY, "phalcon/Cli/Router/Route.zep", 418); - ZEPHIR_OBS_NVAR(&actionName); - zephir_array_fetch_long(&actionName, &parts, 2, PH_NOISY, "phalcon/Cli/Router/Route.zep", 419); - break; - } - if (_0$$4 == 2) { - ZEPHIR_OBS_NVAR(&taskName); - zephir_array_fetch_long(&taskName, &parts, 0, PH_NOISY, "phalcon/Cli/Router/Route.zep", 423); - ZEPHIR_OBS_NVAR(&actionName); - zephir_array_fetch_long(&actionName, &parts, 1, PH_NOISY, "phalcon/Cli/Router/Route.zep", 424); - break; - } - if (_0$$4 == 1) { - ZEPHIR_OBS_NVAR(&taskName); - zephir_array_fetch_long(&taskName, &parts, 0, PH_NOISY, "phalcon/Cli/Router/Route.zep", 428); - break; - } - } while(0); - - ZEPHIR_INIT_VAR(&routePaths); - array_init(&routePaths); - if (Z_TYPE_P(&moduleName) != IS_NULL) { - zephir_array_update_string(&routePaths, SL("module"), &moduleName, PH_COPY | PH_SEPARATE); - } - if (Z_TYPE_P(&taskName) != IS_NULL) { - if (zephir_memnstr_str(&taskName, SL("\\"), "phalcon/Cli/Router/Route.zep", 442)) { - ZEPHIR_INIT_VAR(&realClassName); - zephir_get_class_ns(&realClassName, &taskName, 0); - ZEPHIR_INIT_VAR(&namespaceName); - zephir_get_ns_class(&namespaceName, &taskName, 0); - _1$$10 = Z_TYPE_P(&namespaceName) == IS_NULL; - if (!(_1$$10)) { - _1$$10 = Z_TYPE_P(&realClassName) == IS_NULL; - } - if (UNEXPECTED(_1$$10)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_router_exception_ce, "The route contains invalid paths", "phalcon/Cli/Router/Route.zep", 452); - return; - } - if (zephir_is_true(&namespaceName)) { - zephir_array_update_string(&routePaths, SL("namespace"), &namespaceName, PH_COPY | PH_SEPARATE); - } - } else { - ZEPHIR_CPY_WRT(&realClassName, &taskName); - } - ZEPHIR_INIT_VAR(&_2$$9); - zephir_uncamelize(&_2$$9, &realClassName, NULL ); - zephir_array_update_string(&routePaths, SL("task"), &_2$$9, PH_COPY | PH_SEPARATE); - } - if (Z_TYPE_P(&actionName) != IS_NULL) { - zephir_array_update_string(&routePaths, SL("action"), &actionName, PH_COPY | PH_SEPARATE); - } - } else { - ZEPHIR_CPY_WRT(&routePaths, paths); - } - if (UNEXPECTED(Z_TYPE_P(&routePaths) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_router_exception_ce, "The route contains invalid paths", "phalcon/Cli/Router/Route.zep", 476); - return; - } - if (!(zephir_start_with_str(&pattern, SL("#")))) { - if (zephir_memnstr_str(&pattern, SL("{"), "phalcon/Cli/Router/Route.zep", 484)) { - ZEPHIR_CALL_METHOD(&extracted, this_ptr, "extractnamedparams", NULL, 0, &pattern); - zephir_check_call_status(); - zephir_memory_observe(&pcrePattern); - zephir_array_fetch_long(&pcrePattern, &extracted, 0, PH_NOISY, "phalcon/Cli/Router/Route.zep", 489); - ZEPHIR_INIT_VAR(&_3$$18); - zephir_array_fetch_long(&_4$$18, &extracted, 1, PH_NOISY | PH_READONLY, "phalcon/Cli/Router/Route.zep", 490); - zephir_fast_array_merge(&_3$$18, &routePaths, &_4$$18); - ZEPHIR_CPY_WRT(&routePaths, &_3$$18); - } else { - ZEPHIR_CPY_WRT(&pcrePattern, &pattern); - } - ZEPHIR_CALL_METHOD(&compiledPattern, this_ptr, "compilepattern", NULL, 0, &pcrePattern); - zephir_check_call_status(); + zephir_fetch_params(1, 0, 1, &name_param); + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + ZVAL_STRING(&name, ""); } else { - if (zephir_memnstr_str(&pattern, SL(":delimiter"), "phalcon/Cli/Router/Route.zep", 501)) { - ZEPHIR_INIT_VAR(&_5$$21); - zephir_read_property(&_6$$21, this_ptr, ZEND_STRL("delimiter"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_7$$21); - ZVAL_STRING(&_7$$21, ":delimiter"); - zephir_fast_str_replace(&_5$$21, &_7$$21, &_6$$21, &pattern); - zephir_get_strval(&pattern, &_5$$21); - } - ZEPHIR_CPY_WRT(&compiledPattern, &pattern); + zephir_get_strval(&name, name_param); } - zephir_update_property_zval(this_ptr, ZEND_STRL("pattern"), &pattern); - zephir_update_property_zval(this_ptr, ZEND_STRL("compiledPattern"), &compiledPattern); - zephir_update_property_zval(this_ptr, ZEND_STRL("paths"), &routePaths); - ZEPHIR_MM_RESTORE(); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "write"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getconnection", NULL, 0, &_0, &name); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Cli_Router_Route, reset) +static PHP_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocator, setMaster) { - zval _0; + zval *callableObject, callableObject_sub; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, 0); - zephir_update_static_property_ce(phalcon_cli_router_route_ce, ZEND_STRL("uniqueId"), &_0); + ZVAL_UNDEF(&callableObject_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(callableObject, phalcon_datamapper_pdo_connection_connectioninterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &callableObject); + zephir_update_property_zval(this_ptr, ZEND_STRL("master"), callableObject); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Cli_Router_Route, setDescription) +static PHP_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocator, setRead) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *description_param = NULL; - zval description; + zval *name_param = NULL, *callableObject, callableObject_sub; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&description); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(description) + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&callableObject_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_ZVAL(callableObject) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &description_param); - if (UNEXPECTED(Z_TYPE_P(description_param) != IS_STRING && Z_TYPE_P(description_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'description' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(description_param) == IS_STRING)) { - zephir_get_strval(&description, description_param); - } else { - ZEPHIR_INIT_VAR(&description); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("description"), &description); + zephir_fetch_params(1, 2, 0, &name_param, &callableObject); + zephir_get_strval(&name, name_param); + zephir_update_property_array(this_ptr, SL("read"), &name, callableObject); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Cli_Router_Route, setName) +static PHP_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocator, setWrite) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL; + zval *name_param = NULL, *callableObject, callableObject_sub; zval name; zval *this_ptr = getThis(); ZVAL_UNDEF(&name); - ZEND_PARSE_PARAMETERS_START(1, 1) + ZVAL_UNDEF(&callableObject_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_STR(name) + Z_PARAM_ZVAL(callableObject) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 2, 0, &name_param, &callableObject); + zephir_get_strval(&name, name_param); + zephir_update_property_array(this_ptr, SL("write"), &name, callableObject); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocator, getConnection) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *type_param = NULL, *name_param = NULL, collection, instanceName, instances, requested, _0, _1, _6, _2$$5, _3$$5, _4$$6, _5$$6; + zval type, name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&instanceName); + ZVAL_UNDEF(&instances); + ZVAL_UNDEF(&requested); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4$$6); + ZVAL_UNDEF(&_5$$6); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(type) + Z_PARAM_OPTIONAL + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &type_param, &name_param); + zephir_get_strval(&type, type_param); + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + ZVAL_STRING(&name, ""); + } else { + zephir_get_strval(&name, name_param); + } + zephir_memory_observe(&collection); + zephir_read_property_zval(&collection, this_ptr, &type, PH_NOISY_CC); + ZEPHIR_CPY_WRT(&requested, &name); + zephir_read_property(&_0, this_ptr, ZEND_STRL("instances"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&instances, &_0); + if (ZEPHIR_IS_EMPTY(&collection)) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getmaster", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, ""); + if (ZEPHIR_IS_IDENTICAL(&_1, &requested)) { + ZEPHIR_CALL_FUNCTION(&requested, "array_rand", NULL, 202, &collection); + zephir_check_call_status(); } - zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); - RETURN_THIS(); + if (!(zephir_array_isset(&collection, &requested))) { + ZEPHIR_INIT_VAR(&_2$$5); + object_init_ex(&_2$$5, phalcon_datamapper_pdo_exception_connectionnotfound_ce); + ZEPHIR_INIT_VAR(&_3$$5); + ZEPHIR_CONCAT_SVSV(&_3$$5, "Connection not found: ", &type, ":", &requested); + ZEPHIR_CALL_METHOD(NULL, &_2$$5, "__construct", NULL, 33, &_3$$5); + zephir_check_call_status(); + zephir_throw_exception_debug(&_2$$5, "phalcon/DataMapper/Pdo/ConnectionLocator.zep", 206); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_VAR(&instanceName); + ZEPHIR_CONCAT_VSV(&instanceName, &type, "-", &requested); + if (!(zephir_array_isset(&instances, &instanceName))) { + ZEPHIR_INIT_VAR(&_4$$6); + zephir_array_fetch(&_5$$6, &collection, &requested, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/ConnectionLocator.zep", 217); + ZEPHIR_CALL_USER_FUNC(&_4$$6, &_5$$6); + zephir_check_call_status(); + zephir_array_update_zval(&instances, &instanceName, &_4$$6, PH_COPY | PH_SEPARATE); + zephir_update_property_zval(this_ptr, ZEND_STRL("instances"), &instances); + } + zephir_array_fetch(&_6, &instances, &instanceName, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/ConnectionLocator.zep", 221); + RETURN_CTOR(&_6); } -zend_object *zephir_init_properties_Phalcon_Cli_Router_Route(zend_class_entry *class_type) +zend_object *zephir_init_properties_Phalcon_DataMapper_Pdo_ConnectionLocator(zend_class_entry *class_type) { - zval _0, _2, _1$$3, _3$$4; + zval _0, _2, _4, _1$$3, _3$$4, _5$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); @@ -126955,17 +128564,23 @@ zend_object *zephir_init_properties_Phalcon_Cli_Router_Route(zend_class_entry *c { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("paths"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("instances"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("paths"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("instances"), &_1$$3); } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("converters"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("write"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_2) == IS_NULL) { ZEPHIR_INIT_VAR(&_3$$4); array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("converters"), &_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("write"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("read"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("read"), &_5$$5); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -126982,62 +128597,19 @@ zend_object *zephir_init_properties_Phalcon_Cli_Router_Route(zend_class_entry *c -ZEPHIR_INIT_CLASS(Phalcon_Cli_Router_RouteInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Cli\\Router, RouteInterface, phalcon, cli_router_routeinterface, phalcon_cli_router_routeinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, compilePattern); -ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, delimiter); -ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, getCompiledPattern); -ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, getDelimiter); -ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, getDescription); -ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, getName); -ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, getPaths); -ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, getPattern); -ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, getReversedPaths); -ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, getRouteId); -ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, reConfigure); -ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, reset); -ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, setDescription); -ZEPHIR_DOC_METHOD(Phalcon_Cli_Router_RouteInterface, setName); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Image_Enum) +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_ConnectionLocatorInterface) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Image, Enum, phalcon, image_enum, NULL, 0); - - zephir_declare_class_constant_long(phalcon_image_enum_ce, SL("AUTO"), 4); - - zephir_declare_class_constant_long(phalcon_image_enum_ce, SL("HEIGHT"), 3); - - zephir_declare_class_constant_long(phalcon_image_enum_ce, SL("INVERSE"), 5); - - zephir_declare_class_constant_long(phalcon_image_enum_ce, SL("NONE"), 1); - - zephir_declare_class_constant_long(phalcon_image_enum_ce, SL("PRECISE"), 6); - - zephir_declare_class_constant_long(phalcon_image_enum_ce, SL("TENSILE"), 7); - - zephir_declare_class_constant_long(phalcon_image_enum_ce, SL("WIDTH"), 2); - - zephir_declare_class_constant_long(phalcon_image_enum_ce, SL("HORIZONTAL"), 11); - - zephir_declare_class_constant_long(phalcon_image_enum_ce, SL("VERTICAL"), 12); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\DataMapper\\Pdo, ConnectionLocatorInterface, phalcon, datamapper_pdo_connectionlocatorinterface, phalcon_datamapper_pdo_connectionlocatorinterface_method_entry); return SUCCESS; } +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocatorInterface, getMaster); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocatorInterface, getRead); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocatorInterface, getWrite); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocatorInterface, setMaster); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocatorInterface, setRead); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_ConnectionLocatorInterface, setWrite); @@ -127048,1198 +128620,757 @@ ZEPHIR_INIT_CLASS(Phalcon_Image_Enum) -ZEPHIR_INIT_CLASS(Phalcon_Image_Exception) +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Image, Exception, phalcon, image_exception, zend_ce_exception, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - + ZEPHIR_REGISTER_CLASS(Phalcon\\DataMapper\\Pdo\\Profiler, MemoryLogger, phalcon, datamapper_pdo_profiler_memorylogger, phalcon_datamapper_pdo_profiler_memorylogger_method_entry, 0); -ZEPHIR_INIT_CLASS(Phalcon_Image_ImageFactory) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Image, ImageFactory, phalcon, image_imagefactory, phalcon_factory_abstractfactory_ce, phalcon_image_imagefactory_method_entry, 0); + zend_declare_property_null(phalcon_datamapper_pdo_profiler_memorylogger_ce, SL("messages"), ZEND_ACC_PROTECTED); + phalcon_datamapper_pdo_profiler_memorylogger_ce->create_object = zephir_init_properties_Phalcon_DataMapper_Pdo_Profiler_MemoryLogger; + zend_class_implements(phalcon_datamapper_pdo_profiler_memorylogger_ce, 1, phalcon_logger_loggerinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Image_ImageFactory, __construct) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, alert) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *services_param = NULL; - zval services; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&services); - ZEND_PARSE_PARAMETERS_START(0, 1) + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(services) + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &services_param); - if (!services_param) { - ZEPHIR_INIT_VAR(&services); - array_init(&services); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); } else { - ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); + zephir_get_arrval(&context, context_param); } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); + ZVAL_LONG(&_0, 2); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, &_0, &message, &context); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Image_ImageFactory, load) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, critical) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *config = NULL, config_sub, height, file, name, width, _0, _1, _2; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&config_sub); - ZVAL_UNDEF(&height); - ZVAL_UNDEF(&file); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&width); + ZVAL_UNDEF(&message); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(config) + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &config); - ZEPHIR_SEPARATE_PARAM(config); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfig", NULL, 0, config); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(config, &_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "adapter"); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfigelement", NULL, 0, config, &_1); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(config, &_0); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "file"); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfigelement", NULL, 0, config, &_1); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(config, &_0); - zephir_memory_observe(&name); - zephir_array_fetch_string(&name, config, SL("adapter"), PH_NOISY, "phalcon/Image/ImageFactory.zep", 44); - zephir_array_unset_string(config, SL("adapter"), PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "file"); - ZEPHIR_CALL_METHOD(&file, this_ptr, "getarrval", NULL, 408, config, &_1); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "height"); - ZVAL_NULL(&_2); - ZEPHIR_CALL_METHOD(&height, this_ptr, "getarrval", NULL, 408, config, &_1, &_2); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "width"); - ZVAL_NULL(&_2); - ZEPHIR_CALL_METHOD(&width, this_ptr, "getarrval", NULL, 408, config, &_1, &_2); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "newinstance", NULL, 0, &name, &file, &width, &height); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); + } else { + zephir_get_arrval(&context, context_param); + } + ZVAL_LONG(&_0, 1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, &_0, &message, &context); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Image_ImageFactory, newInstance) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, debug) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long width, height, ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, *file_param = NULL, *width_param = NULL, *height_param = NULL, definition, _1; - zval name, file; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&file); - ZVAL_UNDEF(&definition); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&message); ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 4) - Z_PARAM_STR(name) - Z_PARAM_STR(file) + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) Z_PARAM_OPTIONAL - Z_PARAM_LONG_OR_NULL(width, is_null_true) - Z_PARAM_LONG_OR_NULL(height, is_null_true) + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 2, &name_param, &file_param, &width_param, &height_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - if (UNEXPECTED(Z_TYPE_P(file_param) != IS_STRING && Z_TYPE_P(file_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'file' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(file_param) == IS_STRING)) { - zephir_get_strval(&file, file_param); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); } else { - ZEPHIR_INIT_VAR(&file); + zephir_get_arrval(&context, context_param); } - if (!width_param) { - width = 0; - } else { - } - if (!height_param) { - height = 0; - } else { - } - ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 3, 0); - zephir_array_fast_append(&_0, &file); - ZEPHIR_INIT_VAR(&_1); - ZVAL_LONG(&_1, width); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_LONG(&_1, height); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(return_value, &definition, &_0); + ZVAL_LONG(&_0, 7); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, &_0, &message, &context); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Image_ImageFactory, getExceptionClass) -{ - - RETURN_STRING("Phalcon\\Image\\Exception"); -} - -static PHP_METHOD(Phalcon_Image_ImageFactory, getServices) -{ - - zephir_create_array(return_value, 2, 0); - add_assoc_stringl_ex(return_value, SL("gd"), SL("Phalcon\\Image\\Adapter\\Gd")); - add_assoc_stringl_ex(return_value, SL("imagick"), SL("Phalcon\\Image\\Adapter\\Imagick")); - return; -} - -static PHP_METHOD(Phalcon_Image_ImageFactory, getArrVal) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *collection_param = NULL, *index, index_sub, *defaultValue = NULL, defaultValue_sub, __$null, value; - zval collection; - - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&index_sub); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&value); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_ARRAY(collection) - Z_PARAM_ZVAL(index) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &collection_param, &index, &defaultValue); - ZEPHIR_OBS_COPY_OR_DUP(&collection, collection_param); - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; - } - zephir_memory_observe(&value); - if (UNEXPECTED(!(zephir_array_isset_fetch(&value, &collection, index, 0)))) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); - } - RETURN_CCTOR(&value); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Image_Adapter_AbstractAdapter) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Image\\Adapter, AbstractAdapter, phalcon, image_adapter_abstractadapter, phalcon_image_adapter_abstractadapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_image_adapter_abstractadapter_ce, SL("file"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_image_adapter_abstractadapter_ce, SL("height"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_image_adapter_abstractadapter_ce, SL("image"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_image_adapter_abstractadapter_ce, SL("mime"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_image_adapter_abstractadapter_ce, SL("realpath"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_image_adapter_abstractadapter_ce, SL("type"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_image_adapter_abstractadapter_ce, SL("width"), ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_image_adapter_abstractadapter_ce, 1, phalcon_image_adapter_adapterinterface_ce); - return SUCCESS; + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, background) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, emergency) { - zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long opacity, ZEPHIR_LAST_CALL_STATUS; - zval *color_param = NULL, *opacity_param = NULL, colors, _1, _2, _3, _9, _10, _11, _12, _13, _14, _4$$3, _5$$3, _6$$4, _7$$4, _8$$4; - zval color; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&color); - ZVAL_UNDEF(&colors); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_13); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_8$$4); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(color) + Z_PARAM_STR(message) Z_PARAM_OPTIONAL - Z_PARAM_LONG(opacity) + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &color_param, &opacity_param); - zephir_get_strval(&color, color_param); - if (!opacity_param) { - opacity = 100; + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); } else { - } - _0 = zephir_fast_strlen_ev(&color) > 1; - if (_0) { - ZVAL_LONG(&_1, 0); - ZVAL_LONG(&_2, 1); - ZEPHIR_INIT_VAR(&_3); - zephir_substr(&_3, &color, 0 , 1 , 0); - _0 = ZEPHIR_IS_STRING_IDENTICAL(&_3, "#"); - } - if (_0) { - ZVAL_LONG(&_4$$3, 1); - ZEPHIR_INIT_VAR(&_5$$3); - zephir_substr(&_5$$3, &color, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - zephir_get_strval(&color, &_5$$3); - } - if (zephir_fast_strlen_ev(&color) == 3) { - ZEPHIR_INIT_VAR(&_6$$4); - ZVAL_STRING(&_6$$4, "/./"); - ZEPHIR_INIT_VAR(&_7$$4); - ZVAL_STRING(&_7$$4, "$0$0"); - ZEPHIR_CALL_FUNCTION(&_8$$4, "preg_replace", NULL, 41, &_6$$4, &_7$$4, &color); - zephir_check_call_status(); - zephir_get_strval(&color, &_8$$4); + zephir_get_arrval(&context, context_param); } - ZVAL_LONG(&_9, 2); - ZEPHIR_CALL_FUNCTION(&_10, "str_split", NULL, 88, &color, &_9); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_11); - ZVAL_STRING(&_11, "hexdec"); - ZEPHIR_CALL_FUNCTION(&colors, "array_map", NULL, 81, &_11, &_10); - zephir_check_call_status(); - zephir_array_fetch_long(&_12, &colors, 0, PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/AbstractAdapter.zep", 96); - zephir_array_fetch_long(&_13, &colors, 1, PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/AbstractAdapter.zep", 96); - zephir_array_fetch_long(&_14, &colors, 2, PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/AbstractAdapter.zep", 96); - ZVAL_LONG(&_9, opacity); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processbackground", NULL, 0, &_12, &_13, &_14, &_9); + ZVAL_LONG(&_0, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, &_0, &message, &context); zephir_check_call_status(); - RETURN_THIS(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, blur) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, error) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *radius_param = NULL, _0, _1, _2; - zend_long radius, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; zval *this_ptr = getThis(); + ZVAL_UNDEF(&message); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(radius) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &radius_param); - ZVAL_LONG(&_1, radius); - ZVAL_LONG(&_2, 1); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkhighlow", NULL, 0, &_1, &_2); - zephir_check_call_status(); - radius = zephir_get_numberval(&_0); - ZVAL_LONG(&_1, radius); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processblur", NULL, 0, &_1); - zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, crop) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *width_param = NULL, *height_param = NULL, *offsetX_param = NULL, *offsetY_param = NULL, _0$$3, _1$$4, _2$$4, _3$$4, _4$$4, _5$$5, _6$$6, _7$$6, _8$$6, _9$$6, _10, _12, _14, _15, _16, _17, _11$$7, _13$$8; - zend_long width, height, offsetX, offsetY, ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_6$$6); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_8$$6); - ZVAL_UNDEF(&_9$$6); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_15); - ZVAL_UNDEF(&_16); - ZVAL_UNDEF(&_17); - ZVAL_UNDEF(&_11$$7); - ZVAL_UNDEF(&_13$$8); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 4) - Z_PARAM_LONG(width) - Z_PARAM_LONG(height) + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) Z_PARAM_OPTIONAL - Z_PARAM_LONG_OR_NULL(offsetX, is_null_true) - Z_PARAM_LONG_OR_NULL(offsetY, is_null_true) + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 2, &width_param, &height_param, &offsetX_param, &offsetY_param); - if (!offsetX_param) { - offsetX = 0; - } else { - } - if (!offsetY_param) { - offsetY = 0; - } else { - } - if (0 == offsetX) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - offsetX = (long) ((zephir_safe_div_long_long(((zephir_get_numberval(&_0$$3) - width)), 2))); - } else { - ZEPHIR_INIT_VAR(&_1$$4); - if (offsetX < 0) { - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_1$$4); - ZVAL_LONG(&_1$$4, ((zephir_get_numberval(&_2$$4) - width) + offsetX)); - } else { - ZEPHIR_INIT_NVAR(&_1$$4); - ZVAL_LONG(&_1$$4, offsetX); - } - offsetX = zephir_get_numberval(&_1$$4); - ZEPHIR_INIT_VAR(&_3$$4); - zephir_read_property(&_4$$4, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_LT_LONG(&_4$$4, offsetX)) { - ZEPHIR_OBS_NVAR(&_3$$4); - zephir_read_property(&_3$$4, this_ptr, ZEND_STRL("width"), PH_NOISY_CC); - } else { - ZEPHIR_INIT_NVAR(&_3$$4); - ZVAL_LONG(&_3$$4, offsetX); - } - offsetX = zephir_get_numberval(&_3$$4); - } - if (0 == offsetY) { - zephir_read_property(&_5$$5, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - offsetY = (long) ((zephir_safe_div_long_long(((zephir_get_numberval(&_5$$5) - height)), 2))); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); } else { - ZEPHIR_INIT_VAR(&_6$$6); - if (offsetY < 0) { - zephir_read_property(&_7$$6, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_6$$6); - ZVAL_LONG(&_6$$6, ((zephir_get_numberval(&_7$$6) - height) + offsetY)); - } else { - ZEPHIR_INIT_NVAR(&_6$$6); - ZVAL_LONG(&_6$$6, offsetY); - } - offsetY = zephir_get_numberval(&_6$$6); - ZEPHIR_INIT_VAR(&_8$$6); - zephir_read_property(&_9$$6, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_LT_LONG(&_9$$6, offsetY)) { - ZEPHIR_OBS_NVAR(&_8$$6); - zephir_read_property(&_8$$6, this_ptr, ZEND_STRL("height"), PH_NOISY_CC); - } else { - ZEPHIR_INIT_NVAR(&_8$$6); - ZVAL_LONG(&_8$$6, offsetY); - } - offsetY = zephir_get_numberval(&_8$$6); - } - zephir_read_property(&_10, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - if (width > ((zephir_get_numberval(&_10) - offsetX))) { - zephir_read_property(&_11$$7, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - width = (zephir_get_numberval(&_11$$7) - offsetX); - } - zephir_read_property(&_12, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - if (height > ((zephir_get_numberval(&_12) - offsetY))) { - zephir_read_property(&_13$$8, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - height = (zephir_get_numberval(&_13$$8) - offsetY); + zephir_get_arrval(&context, context_param); } - ZVAL_LONG(&_14, width); - ZVAL_LONG(&_15, height); - ZVAL_LONG(&_16, offsetX); - ZVAL_LONG(&_17, offsetY); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processcrop", NULL, 0, &_14, &_15, &_16, &_17); + ZVAL_LONG(&_0, 3); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, &_0, &message, &context); zephir_check_call_status(); - RETURN_THIS(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, flip) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, getAdapter) { - zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *direction_param = NULL, _1; - zend_long direction, ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL; + zval name; - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&name); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(direction) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &direction_param); - _0 = direction != 11; - if (_0) { - _0 = direction != 12; - } - if (_0) { - direction = 11; + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); + object_init_ex(return_value, phalcon_logger_adapter_noop_ce); + if (zephir_has_constructor(return_value)) { + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); + zephir_check_call_status(); } - ZVAL_LONG(&_1, direction); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processflip", NULL, 0, &_1); - zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, getHeight) -{ - - RETURN_MEMBER(getThis(), "height"); -} - -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, getImage) -{ - RETURN_MEMBER(getThis(), "image"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, getMime) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, getAdapters) { - RETURN_MEMBER(getThis(), "mime"); + array_init(return_value); + return; } -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, getRealpath) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, getLogLevel) { - RETURN_MEMBER(getThis(), "realpath"); + RETURN_LONG(8); } -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, getType) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, getMessages) { - RETURN_MEMBER(getThis(), "type"); + RETURN_MEMBER(getThis(), "messages"); } -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, getWidth) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, getName) { - RETURN_MEMBER(getThis(), "width"); + RETURN_STRING("memory logger"); } -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, mask) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, info) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *mask, mask_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&mask_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(mask, phalcon_image_adapter_adapterinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &mask); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processmask", NULL, 0, mask); - zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, pixelate) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *amount_param = NULL, _0; - zend_long amount, ZEPHIR_LAST_CALL_STATUS; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; zval *this_ptr = getThis(); + ZVAL_UNDEF(&message); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(amount) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &amount_param); - if (amount < 2) { - amount = 2; - } - ZVAL_LONG(&_0, amount); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processpixelate", NULL, 0, &_0); - zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, reflection) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool fadeIn, _0; - zval *height_param = NULL, *opacity_param = NULL, *fadeIn_param = NULL, _1, _3, _4, _5, _6, _2$$3; - zend_long height, opacity, ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_2$$3); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_LONG(height) + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) Z_PARAM_OPTIONAL - Z_PARAM_LONG(opacity) - Z_PARAM_BOOL(fadeIn) + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &height_param, &opacity_param, &fadeIn_param); - if (!opacity_param) { - opacity = 100; - } else { - } - if (!fadeIn_param) { - fadeIn = 0; - } else { - } - _0 = height <= 0; - if (!(_0)) { - zephir_read_property(&_1, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - _0 = ZEPHIR_LT_LONG(&_1, height); - } - if (_0) { - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - height = zephir_get_numberval(&_2$$3); - } - ZVAL_LONG(&_4, opacity); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "checkhighlow", NULL, 0, &_4); - zephir_check_call_status(); - opacity = zephir_get_numberval(&_3); - ZVAL_LONG(&_4, height); - ZVAL_LONG(&_5, opacity); - if (fadeIn) { - ZVAL_BOOL(&_6, 1); + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); } else { - ZVAL_BOOL(&_6, 0); + zephir_get_arrval(&context, context_param); } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processreflection", NULL, 0, &_4, &_5, &_6); + ZVAL_LONG(&_0, 6); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, &_0, &message, &context); zephir_check_call_status(); - RETURN_THIS(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, render) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, notice) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long quality, ZEPHIR_LAST_CALL_STATUS; - zval *extension_param = NULL, *quality_param = NULL, _0$$3, _1$$3, _2$$3, _4, _5, _6; - zval extension, _3$$3; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&extension); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(extension) - Z_PARAM_LONG(quality) + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &extension_param, &quality_param); - if (!extension_param) { - ZEPHIR_INIT_VAR(&extension); - } else { - zephir_get_strval(&extension, extension_param); - } - if (!quality_param) { - quality = 100; + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); } else { - } - if (Z_TYPE_P(&extension) == IS_NULL) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_1$$3, 4); - ZEPHIR_CALL_FUNCTION(&_2$$3, "pathinfo", NULL, 89, &_0$$3, &_1$$3); - zephir_check_call_status(); - zephir_cast_to_string(&_3$$3, &_2$$3); - ZEPHIR_CPY_WRT(&extension, &_3$$3); - } - if (1 == ZEPHIR_IS_EMPTY(&extension)) { - ZEPHIR_INIT_NVAR(&extension); - ZVAL_STRING(&extension, "png"); + zephir_get_arrval(&context, context_param); } - ZVAL_LONG(&_5, quality); - ZVAL_LONG(&_6, 1); - ZEPHIR_CALL_METHOD(&_4, this_ptr, "checkhighlow", NULL, 0, &_5, &_6); - zephir_check_call_status(); - quality = zephir_get_numberval(&_4); - ZVAL_LONG(&_5, quality); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "processrender", NULL, 0, &extension, &_5); + ZVAL_LONG(&_0, 5); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, &_0, &message, &context); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, resize) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, warning) { - zend_bool _0$$3; - double ratio = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *width_param = NULL, *height_param = NULL, *master_param = NULL, _20, _21, _22, _23, _24, _25, _26, _27, _1$$10, _2$$10, _3$$10, _4$$11, _5$$11, _6$$11, _7$$12, _8$$12, _9$$13, _10$$13, _11$$14, _12$$14, _13$$14, _14$$15, _15$$15, _16$$16, _17$$16, _18$$17, _19$$17; - zend_long width, height, master, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval context; + zval *message_param = NULL, *context_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_20); - ZVAL_UNDEF(&_21); - ZVAL_UNDEF(&_22); - ZVAL_UNDEF(&_23); - ZVAL_UNDEF(&_24); - ZVAL_UNDEF(&_25); - ZVAL_UNDEF(&_26); - ZVAL_UNDEF(&_27); - ZVAL_UNDEF(&_1$$10); - ZVAL_UNDEF(&_2$$10); - ZVAL_UNDEF(&_3$$10); - ZVAL_UNDEF(&_4$$11); - ZVAL_UNDEF(&_5$$11); - ZVAL_UNDEF(&_6$$11); - ZVAL_UNDEF(&_7$$12); - ZVAL_UNDEF(&_8$$12); - ZVAL_UNDEF(&_9$$13); - ZVAL_UNDEF(&_10$$13); - ZVAL_UNDEF(&_11$$14); - ZVAL_UNDEF(&_12$$14); - ZVAL_UNDEF(&_13$$14); - ZVAL_UNDEF(&_14$$15); - ZVAL_UNDEF(&_15$$15); - ZVAL_UNDEF(&_16$$16); - ZVAL_UNDEF(&_17$$16); - ZVAL_UNDEF(&_18$$17); - ZVAL_UNDEF(&_19$$17); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 3) + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(message) Z_PARAM_OPTIONAL - Z_PARAM_LONG_OR_NULL(width, is_null_true) - Z_PARAM_LONG_OR_NULL(height, is_null_true) - Z_PARAM_LONG(master) + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 3, &width_param, &height_param, &master_param); - if (!width_param) { - width = 0; - } else { - } - if (!height_param) { - height = 0; - } else { - } - if (!master_param) { - master = 4; + zephir_fetch_params(1, 1, 1, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); } else { - } - do { - if (master == 7 || master == 4 || master == 5 || master == 6) { - _0$$3 = 0 == width; - if (!(_0$$3)) { - _0$$3 = 0 == height; - } - if (_0$$3) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width and height must be specified", "phalcon/Image/Adapter/AbstractAdapter.zep", 329); - return; - } - break; - } - if (master == 2) { - if (0 == width) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width must be specified", "phalcon/Image/Adapter/AbstractAdapter.zep", 334); - return; - } - break; - } - if (master == 3) { - if (0 == height) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "height must be specified", "phalcon/Image/Adapter/AbstractAdapter.zep", 339); - return; - } - break; - } - } while(0); - - if (master != 7) { - if (master == 4) { - ZEPHIR_INIT_VAR(&_1$$10); - zephir_read_property(&_2$$10, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_3$$10, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - if ((zephir_safe_div_zval_long(&_2$$10, width)) > (int) (zephir_safe_div_zval_long(&_3$$10, height))) { - ZEPHIR_INIT_NVAR(&_1$$10); - ZVAL_LONG(&_1$$10, 2); - } else { - ZEPHIR_INIT_NVAR(&_1$$10); - ZVAL_LONG(&_1$$10, 3); - } - master = zephir_get_numberval(&_1$$10); - } - if (master == 5) { - ZEPHIR_INIT_VAR(&_4$$11); - zephir_read_property(&_5$$11, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_6$$11, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - if ((zephir_safe_div_zval_long(&_5$$11, width)) > (int) (zephir_safe_div_zval_long(&_6$$11, height))) { - ZEPHIR_INIT_NVAR(&_4$$11); - ZVAL_LONG(&_4$$11, 3); - } else { - ZEPHIR_INIT_NVAR(&_4$$11); - ZVAL_LONG(&_4$$11, 2); - } - master = zephir_get_numberval(&_4$$11); - } - do { - if (master == 2) { - zephir_read_property(&_7$$12, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_8$$12, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - height = (long) (zephir_safe_div_long_zval((zephir_get_numberval(&_7$$12) * width), &_8$$12)); - break; - } - if (master == 3) { - zephir_read_property(&_9$$13, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_10$$13, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - width = (long) (zephir_safe_div_long_zval((zephir_get_numberval(&_9$$13) * height), &_10$$13)); - break; - } - if (master == 6) { - zephir_read_property(&_11$$14, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_12$$14, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_13$$14); - div_function(&_13$$14, &_11$$14, &_12$$14); - ratio = zephir_get_numberval(&_13$$14); - if ((zephir_safe_div_long_long(width, height)) > ratio) { - zephir_read_property(&_14$$15, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_15$$15, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - height = (long) (zephir_safe_div_long_zval((zephir_get_numberval(&_14$$15) * width), &_15$$15)); - } else { - zephir_read_property(&_16$$16, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_17$$16, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - width = (long) (zephir_safe_div_long_zval((zephir_get_numberval(&_16$$16) * height), &_17$$16)); - } - break; - } - if (master == 1) { - ZEPHIR_INIT_VAR(&_18$$17); - if (0 == width) { - ZEPHIR_OBS_NVAR(&_18$$17); - zephir_read_property(&_18$$17, this_ptr, ZEND_STRL("width"), PH_NOISY_CC); - } else { - ZEPHIR_INIT_NVAR(&_18$$17); - ZVAL_LONG(&_18$$17, width); - } - width = zephir_get_numberval(&_18$$17); - ZEPHIR_INIT_VAR(&_19$$17); - if (0 == height) { - ZEPHIR_OBS_NVAR(&_19$$17); - zephir_read_property(&_19$$17, this_ptr, ZEND_STRL("height"), PH_NOISY_CC); - } else { - ZEPHIR_INIT_NVAR(&_19$$17); - ZVAL_LONG(&_19$$17, height); - } - height = zephir_get_numberval(&_19$$17); - break; - } - } while(0); - + zephir_get_arrval(&context, context_param); } - ZEPHIR_INIT_VAR(&_20); - ZVAL_LONG(&_21, width); - zephir_round(&_20, &_21, NULL, NULL); - ZVAL_LONG(&_22, 1); - ZEPHIR_CALL_FUNCTION(&_23, "max", NULL, 90, &_20, &_22); - zephir_check_call_status(); - width = zephir_get_intval(&_23); - ZEPHIR_INIT_VAR(&_24); - ZVAL_LONG(&_22, height); - zephir_round(&_24, &_22, NULL, NULL); - ZVAL_LONG(&_25, 1); - ZEPHIR_CALL_FUNCTION(&_26, "max", NULL, 90, &_24, &_25); - zephir_check_call_status(); - height = zephir_get_intval(&_26); - ZVAL_LONG(&_25, width); - ZVAL_LONG(&_27, height); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processresize", NULL, 0, &_25, &_27); + ZVAL_LONG(&_0, 4); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "log", NULL, 0, &_0, &message, &context); zephir_check_call_status(); - RETURN_THIS(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, rotate) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_MemoryLogger, log) { + zend_string *_3; + zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *degrees_param = NULL, _0; - zend_long degrees, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval context, replace; + zval message; + zval *level, level_sub, *message_param = NULL, *context_param = NULL, key, value, *_0, _1, _6, _4$$3, _5$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(degrees) + ZVAL_UNDEF(&level_sub); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&context); + ZVAL_UNDEF(&replace); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ZVAL(level) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, °rees_param); - if (degrees > 180) { - degrees %= 360; - if (degrees > 180) { - degrees -= 360; - } + zephir_fetch_params(1, 2, 1, &level, &message_param, &context_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); + } else { + zephir_get_arrval(&context, context_param); + } + ZEPHIR_INIT_VAR(&replace); + array_init(&replace); + zephir_is_iterable(&context, 0, "phalcon/DataMapper/Pdo/Profiler/MemoryLogger.zep", 170); + if (Z_TYPE_P(&context) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&context), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&key); + if (_3 != NULL) { + ZVAL_STR_COPY(&key, _3); + } else { + ZVAL_LONG(&key, _2); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0); + ZEPHIR_INIT_NVAR(&_4$$3); + ZEPHIR_CONCAT_SVS(&_4$$3, "{", &key, "}"); + zephir_array_update_zval(&replace, &_4$$3, &value, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); } else { + ZEPHIR_CALL_METHOD(NULL, &context, "rewind", NULL, 0); + zephir_check_call_status(); while (1) { - if (!(degrees < -180)) { + ZEPHIR_CALL_METHOD(&_1, &context, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { break; } - degrees += 360; + ZEPHIR_CALL_METHOD(&key, &context, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &context, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_5$$4); + ZEPHIR_CONCAT_SVS(&_5$$4, "{", &key, "}"); + zephir_array_update_zval(&replace, &_5$$4, &value, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &context, "next", NULL, 0); + zephir_check_call_status(); } } - ZVAL_LONG(&_0, degrees); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processrotate", NULL, 0, &_0); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + ZEPHIR_CALL_FUNCTION(&_6, "strtr", NULL, 5, &message, &replace); zephir_check_call_status(); - RETURN_THIS(); + zephir_update_property_array_append(this_ptr, SL("messages"), &_6); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, save) +zend_object *zephir_init_properties_Phalcon_DataMapper_Pdo_Profiler_MemoryLogger(zend_class_entry *class_type) { + zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long quality, ZEPHIR_LAST_CALL_STATUS; - zval *file_param = NULL, *quality_param = NULL, _0$$3, _2; - zval file, _1$$3; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&file); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_2); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(file) - Z_PARAM_LONG(quality) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &file_param, &quality_param); - if (!file_param) { - ZEPHIR_INIT_VAR(&file); - } else { - zephir_get_strval(&file, file_param); - } - if (!quality_param) { - quality = -1; - } else { + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("messages"), &_1$$3); } - if (Z_TYPE_P(&file) == IS_NULL) { - zephir_memory_observe(&_0$$3); - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("realpath"), PH_NOISY_CC); - zephir_cast_to_string(&_1$$3, &_0$$3); - ZEPHIR_CPY_WRT(&file, &_1$$3); + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } - ZVAL_LONG(&_2, quality); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processsave", NULL, 0, &file, &_2); - zephir_check_call_status(); - RETURN_THIS(); } -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, sharpen) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Profiler_Profiler) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\DataMapper\\Pdo\\Profiler, Profiler, phalcon, datamapper_pdo_profiler_profiler, phalcon_datamapper_pdo_profiler_profiler_method_entry, 0); + + zend_declare_property_bool(phalcon_datamapper_pdo_profiler_profiler_ce, SL("active"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_datamapper_pdo_profiler_profiler_ce, SL("context"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_datamapper_pdo_profiler_profiler_ce, SL("logFormat"), "", ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_datamapper_pdo_profiler_profiler_ce, SL("logLevel"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_datamapper_pdo_profiler_profiler_ce, SL("logger"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_datamapper_pdo_profiler_profiler_ce, SL("encode"), ZEND_ACC_PRIVATE); + phalcon_datamapper_pdo_profiler_profiler_ce->create_object = zephir_init_properties_Phalcon_DataMapper_Pdo_Profiler_Profiler; + + zend_class_implements(phalcon_datamapper_pdo_profiler_profiler_ce, 1, phalcon_datamapper_pdo_profiler_profilerinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *amount_param = NULL, _0, _1, _2; - zend_long amount, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *logger = NULL, logger_sub, __$null, _0, _1; zval *this_ptr = getThis(); + ZVAL_UNDEF(&logger_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(amount) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(logger, phalcon_logger_loggerinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &amount_param); - ZVAL_LONG(&_1, amount); - ZVAL_LONG(&_2, 1); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkhighlow", NULL, 0, &_1, &_2); - zephir_check_call_status(); - amount = zephir_get_numberval(&_0); - ZVAL_LONG(&_1, amount); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processsharpen", NULL, 0, &_1); - zephir_check_call_status(); - RETURN_THIS(); + zephir_fetch_params(1, 0, 1, &logger); + if (!logger) { + logger = &logger_sub; + ZEPHIR_CPY_WRT(logger, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(logger); + } + if (Z_TYPE_P(logger) == IS_NULL) { + ZEPHIR_INIT_NVAR(logger); + object_init_ex(logger, phalcon_datamapper_pdo_profiler_memorylogger_ce); + if (zephir_has_constructor(logger)) { + ZEPHIR_CALL_METHOD(NULL, logger, "__construct", NULL, 0); + zephir_check_call_status(); + } + + } + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "{method} ({duration}s): {statement} {backtrace}"); + zephir_update_property_zval(this_ptr, ZEND_STRL("logFormat"), &_0); + ZVAL_UNDEF(&_1); + ZVAL_LONG(&_1, 7); + zephir_update_property_zval(this_ptr, ZEND_STRL("logLevel"), &_1); + zephir_update_property_zval(this_ptr, ZEND_STRL("logger"), logger); + ZEPHIR_INIT_NVAR(&_0); + object_init_ex(&_0, phalcon_support_helper_json_encode_ce); + if (zephir_has_constructor(&_0)) { + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); + zephir_check_call_status(); + } + + zephir_update_property_zval(this_ptr, ZEND_STRL("encode"), &_0); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, text) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, finish) { - zend_bool _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long opacity, size, ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, *offsetX = NULL, offsetX_sub, *offsetY = NULL, offsetY_sub, *opacity_param = NULL, *color_param = NULL, *size_param = NULL, *fontFile_param = NULL, __$false, colors, _0, _1, _3, _4, _10, _11, _12, _13, _14, _15, _16, _5$$3, _6$$3, _7$$4, _8$$4, _9$$4; - zval text, color, fontFile; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval values; + zval *statement_param = NULL, *values_param = NULL, __$true, ex, finish, _0, _1$$3, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, _7$$3, _8$$3, _9$$3, _10$$3, _11$$3, _12$$3, _13$$3, _14$$3, _15$$3; + zval statement; zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&color); - ZVAL_UNDEF(&fontFile); - ZVAL_UNDEF(&offsetX_sub); - ZVAL_UNDEF(&offsetY_sub); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&colors); + ZVAL_UNDEF(&statement); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&ex); + ZVAL_UNDEF(&finish); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_13); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_15); - ZVAL_UNDEF(&_16); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_5$$3); ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$3); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_11$$3); + ZVAL_UNDEF(&_12$$3); + ZVAL_UNDEF(&_13$$3); + ZVAL_UNDEF(&_14$$3); + ZVAL_UNDEF(&_15$$3); + ZVAL_UNDEF(&values); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 7) - Z_PARAM_STR(text) + ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL(offsetX) - Z_PARAM_ZVAL(offsetY) - Z_PARAM_LONG(opacity) - Z_PARAM_STR(color) - Z_PARAM_LONG(size) - Z_PARAM_STR_OR_NULL(fontFile) + Z_PARAM_STR_OR_NULL(statement) + Z_PARAM_ARRAY(values) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 6, &text_param, &offsetX, &offsetY, &opacity_param, &color_param, &size_param, &fontFile_param); - zephir_get_strval(&text, text_param); - if (!offsetX) { - offsetX = &offsetX_sub; - offsetX = &__$false; - } - if (!offsetY) { - offsetY = &offsetY_sub; - offsetY = &__$false; - } - if (!opacity_param) { - opacity = 100; - } else { - } - if (!color_param) { - ZEPHIR_INIT_VAR(&color); - ZVAL_STRING(&color, "000000"); + zephir_fetch_params(1, 0, 2, &statement_param, &values_param); + if (!statement_param) { + ZEPHIR_INIT_VAR(&statement); } else { - zephir_get_strval(&color, color_param); + zephir_get_strval(&statement, statement_param); } - if (!size_param) { - size = 12; - } else { - } - if (!fontFile_param) { - ZEPHIR_INIT_VAR(&fontFile); + if (!values_param) { + ZEPHIR_INIT_VAR(&values); + array_init(&values); } else { - zephir_get_strval(&fontFile, fontFile_param); - } - ZVAL_LONG(&_1, opacity); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkhighlow", NULL, 0, &_1); - zephir_check_call_status(); - opacity = zephir_get_numberval(&_0); - _2 = zephir_fast_strlen_ev(&color) > 1; - if (_2) { - ZVAL_LONG(&_1, 0); - ZVAL_LONG(&_3, 1); - ZEPHIR_INIT_VAR(&_4); - zephir_substr(&_4, &color, 0 , 1 , 0); - _2 = ZEPHIR_IS_STRING_IDENTICAL(&_4, "#"); + zephir_get_arrval(&values, values_param); } - if (_2) { - ZVAL_LONG(&_5$$3, 1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("active"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(zephir_is_true(&_0))) { + ZEPHIR_INIT_VAR(&ex); + object_init_ex(&ex, phalcon_datamapper_pdo_exception_exception_ce); + ZEPHIR_CALL_METHOD(NULL, &ex, "__construct", NULL, 33); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&finish, "hrtime", NULL, 203, &__$true); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1$$3, &ex, "gettraceasstring", NULL, 204); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "backtrace"); + zephir_update_property_array(this_ptr, SL("context"), &_2$$3, &_1$$3); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("context"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_4$$3, &_3$$3, SL("start"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/Profiler/Profiler.zep", 91); + ZEPHIR_INIT_VAR(&_5$$3); + zephir_sub_function(&_5$$3, &finish, &_4$$3); ZEPHIR_INIT_VAR(&_6$$3); - zephir_substr(&_6$$3, &color, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - zephir_get_strval(&color, &_6$$3); - } - if (zephir_fast_strlen_ev(&color) == 3) { - ZEPHIR_INIT_VAR(&_7$$4); - ZVAL_STRING(&_7$$4, "/./"); - ZEPHIR_INIT_VAR(&_8$$4); - ZVAL_STRING(&_8$$4, "$0$0"); - ZEPHIR_CALL_FUNCTION(&_9$$4, "preg_replace", NULL, 41, &_7$$4, &_8$$4, &color); + ZVAL_STRING(&_6$$3, "duration"); + zephir_update_property_array(this_ptr, SL("context"), &_6$$3, &_5$$3); + ZEPHIR_INIT_VAR(&_7$$3); + ZVAL_STRING(&_7$$3, "finish"); + zephir_update_property_array(this_ptr, SL("context"), &_7$$3, &finish); + ZEPHIR_INIT_VAR(&_8$$3); + ZVAL_STRING(&_8$$3, "statement"); + zephir_update_property_array(this_ptr, SL("context"), &_8$$3, &statement); + ZEPHIR_INIT_NVAR(&_5$$3); + if (ZEPHIR_IS_EMPTY(&values)) { + ZEPHIR_INIT_NVAR(&_5$$3); + ZVAL_STRING(&_5$$3, ""); + } else { + zephir_read_property(&_9$$3, this_ptr, ZEND_STRL("encode"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_5$$3, &_9$$3, "__invoke", NULL, 0, &values); + zephir_check_call_status(); + } + ZEPHIR_INIT_VAR(&_10$$3); + ZVAL_STRING(&_10$$3, "values"); + zephir_update_property_array(this_ptr, SL("context"), &_10$$3, &_5$$3); + zephir_read_property(&_11$$3, this_ptr, ZEND_STRL("logger"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_12$$3, this_ptr, ZEND_STRL("logLevel"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_13$$3, this_ptr, ZEND_STRL("logFormat"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_14$$3, this_ptr, ZEND_STRL("context"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_11$$3, "log", NULL, 0, &_12$$3, &_13$$3, &_14$$3); zephir_check_call_status(); - zephir_get_strval(&color, &_9$$4); + ZEPHIR_INIT_VAR(&_15$$3); + array_init(&_15$$3); + zephir_update_property_zval(this_ptr, ZEND_STRL("context"), &_15$$3); } - ZVAL_LONG(&_10, 2); - ZEPHIR_CALL_FUNCTION(&_11, "str_split", NULL, 88, &color, &_10); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_12); - ZVAL_STRING(&_12, "hexdec"); - ZEPHIR_CALL_FUNCTION(&colors, "array_map", NULL, 81, &_12, &_11); - zephir_check_call_status(); - zephir_array_fetch_long(&_13, &colors, 0, PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/AbstractAdapter.zep", 495); - zephir_array_fetch_long(&_14, &colors, 1, PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/AbstractAdapter.zep", 496); - zephir_array_fetch_long(&_15, &colors, 2, PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/AbstractAdapter.zep", 497); - ZVAL_LONG(&_10, opacity); - ZVAL_LONG(&_16, size); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processtext", NULL, 0, &text, offsetX, offsetY, &_10, &_13, &_14, &_15, &_16, &fontFile); - zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, getLogFormat) +{ + + RETURN_MEMBER(getThis(), "logFormat"); +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, getLogger) +{ + + RETURN_MEMBER(getThis(), "logger"); +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, getLogLevel) +{ + + RETURN_MEMBER(getThis(), "logLevel"); +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, isActive) +{ + + RETURN_MEMBER(getThis(), "active"); +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, setActive) +{ + zval *active_param = NULL, __$true, __$false; + zend_bool active; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(active) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &active_param); + if (active) { + zephir_update_property_zval(this_ptr, ZEND_STRL("active"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("active"), &__$false); + } + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, setLogFormat) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *logFormat_param = NULL; + zval logFormat; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&logFormat); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(logFormat) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &logFormat_param); + zephir_get_strval(&logFormat, logFormat_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("logFormat"), &logFormat); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, watermark) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, setLogLevel) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long offsetX, offsetY, opacity, ZEPHIR_LAST_CALL_STATUS; - zval *watermark, watermark_sub, *offsetX_param = NULL, *offsetY_param = NULL, *opacity_param = NULL, op, x, y, _0, _1, _2, _3, _4; + zval *logLevel_param = NULL; + zval logLevel; zval *this_ptr = getThis(); - ZVAL_UNDEF(&watermark_sub); - ZVAL_UNDEF(&op); - ZVAL_UNDEF(&x); - ZVAL_UNDEF(&y); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_OBJECT_OF_CLASS(watermark, phalcon_image_adapter_adapterinterface_ce) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(offsetX) - Z_PARAM_LONG(offsetY) - Z_PARAM_LONG(opacity) + ZVAL_UNDEF(&logLevel); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(logLevel) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 3, &watermark, &offsetX_param, &offsetY_param, &opacity_param); - if (!offsetX_param) { - offsetX = 0; - } else { - } - if (!offsetY_param) { - offsetY = 0; - } else { - } - if (!opacity_param) { - opacity = 100; - } else { - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_1, watermark, "getwidth", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2); - zephir_sub_function(&_2, &_0, &_1); - ZVAL_LONG(&_0, offsetX); - ZVAL_LONG(&_3, 0); - ZEPHIR_CALL_METHOD(&x, this_ptr, "checkhighlow", NULL, 0, &_0, &_3, &_2); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_1, watermark, "getheight", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_4); - zephir_sub_function(&_4, &_0, &_1); - ZVAL_LONG(&_0, offsetX); - ZVAL_LONG(&_3, 0); - ZEPHIR_CALL_METHOD(&y, this_ptr, "checkhighlow", NULL, 0, &_0, &_3, &_4); - zephir_check_call_status(); - ZVAL_LONG(&_0, opacity); - ZEPHIR_CALL_METHOD(&op, this_ptr, "checkhighlow", NULL, 0, &_0); - zephir_check_call_status(); - ZVAL_LONG(&_0, opacity); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "processwatermark", NULL, 0, watermark, &x, &y, &_0); - zephir_check_call_status(); + zephir_fetch_params(1, 1, 0, &logLevel_param); + zephir_get_strval(&logLevel, logLevel_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("logLevel"), &logLevel); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, checkHighLow) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Profiler_Profiler, start) { + zval _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *value_param = NULL, *min_param = NULL, *max_param = NULL, _0, _1, _2; - zend_long value, min, max, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *method_param = NULL, __$true, _0, _2$$3; + zval method; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&method); + ZVAL_BOOL(&__$true, 1); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_LONG(value) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(min) - Z_PARAM_LONG(max) + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(method) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &value_param, &min_param, &max_param); - if (!min_param) { - min = 0; - } else { - } - if (!max_param) { - max = 100; - } else { + zephir_fetch_params(1, 1, 0, &method_param); + zephir_get_strval(&method, method_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("active"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(zephir_is_true(&_0))) { + ZEPHIR_INIT_VAR(&_1$$3); + zephir_create_array(&_1$$3, 2, 0); + zephir_array_update_string(&_1$$3, SL("method"), &method, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_FUNCTION(&_2$$3, "hrtime", NULL, 203, &__$true); + zephir_check_call_status(); + zephir_array_update_string(&_1$$3, SL("start"), &_2$$3, PH_COPY | PH_SEPARATE); + zephir_update_property_zval(this_ptr, ZEND_STRL("context"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); +} + +zend_object *zephir_init_properties_Phalcon_DataMapper_Pdo_Profiler_Profiler(zend_class_entry *class_type) +{ + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("context"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("context"), &_1$$3); } - ZVAL_LONG(&_0, value); - ZVAL_LONG(&_1, min); - ZEPHIR_CALL_FUNCTION(&_2, "max", NULL, 90, &_0, &_1); - zephir_check_call_status(); - ZVAL_LONG(&_0, max); - ZEPHIR_RETURN_CALL_FUNCTION("min", NULL, 91, &_0, &_2); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } } @@ -128252,27 +129383,22 @@ static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, checkHighLow) -ZEPHIR_INIT_CLASS(Phalcon_Image_Adapter_AdapterInterface) +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Image\\Adapter, AdapterInterface, phalcon, image_adapter_adapterinterface, phalcon_image_adapter_adapterinterface_method_entry); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\DataMapper\\Pdo\\Profiler, ProfilerInterface, phalcon, datamapper_pdo_profiler_profilerinterface, phalcon_datamapper_pdo_profiler_profilerinterface_method_entry); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, background); -ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, blur); -ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, crop); -ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, flip); -ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, mask); -ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, pixelate); -ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, reflection); -ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, render); -ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, resize); -ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, rotate); -ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, save); -ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, sharpen); -ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, text); -ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, watermark); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface, finish); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface, getLogger); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface, getLogFormat); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface, getLogLevel); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface, isActive); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface, setActive); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface, setLogFormat); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface, setLogLevel); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Profiler_ProfilerInterface, start); @@ -128283,3367 +129409,2334 @@ ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, watermark); -ZEPHIR_INIT_CLASS(Phalcon_Image_Adapter_Gd) +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Exception_CannotDisconnect) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Image\\Adapter, Gd, phalcon, image_adapter_gd, phalcon_image_adapter_abstractadapter_ce, phalcon_image_adapter_gd_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Pdo\\Exception, CannotDisconnect, phalcon, datamapper_pdo_exception_cannotdisconnect, phalcon_datamapper_pdo_exception_exception_ce, NULL, 0); return SUCCESS; } -static PHP_METHOD(Phalcon_Image_Adapter_Gd, __construct) -{ - zend_bool _26$$13; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long width, height, ZEPHIR_LAST_CALL_STATUS; - zval *file_param = NULL, *width_param = NULL, *height_param = NULL, __$true, imageInfo, _0, _1$$3, _2$$3, _3$$3, _8$$3, _25$$3, _4$$4, _5$$4, _6$$4, _7$$4, _9$$5, _10$$5, _11$$6, _12$$6, _13$$7, _14$$7, _15$$8, _16$$8, _17$$9, _18$$9, _19$$10, _20$$10, _21$$11, _22$$12, _23$$12, _24$$12, _30$$13, _31$$13, _32$$13, _33$$13, _34$$13, _35$$13, _27$$14, _28$$14, _29$$14; - zval file; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&file); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&imageInfo); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_25$$3); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_9$$5); - ZVAL_UNDEF(&_10$$5); - ZVAL_UNDEF(&_11$$6); - ZVAL_UNDEF(&_12$$6); - ZVAL_UNDEF(&_13$$7); - ZVAL_UNDEF(&_14$$7); - ZVAL_UNDEF(&_15$$8); - ZVAL_UNDEF(&_16$$8); - ZVAL_UNDEF(&_17$$9); - ZVAL_UNDEF(&_18$$9); - ZVAL_UNDEF(&_19$$10); - ZVAL_UNDEF(&_20$$10); - ZVAL_UNDEF(&_21$$11); - ZVAL_UNDEF(&_22$$12); - ZVAL_UNDEF(&_23$$12); - ZVAL_UNDEF(&_24$$12); - ZVAL_UNDEF(&_30$$13); - ZVAL_UNDEF(&_31$$13); - ZVAL_UNDEF(&_32$$13); - ZVAL_UNDEF(&_33$$13); - ZVAL_UNDEF(&_34$$13); - ZVAL_UNDEF(&_35$$13); - ZVAL_UNDEF(&_27$$14); - ZVAL_UNDEF(&_28$$14); - ZVAL_UNDEF(&_29$$14); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(file) - Z_PARAM_OPTIONAL - Z_PARAM_LONG_OR_NULL(width, is_null_true) - Z_PARAM_LONG_OR_NULL(height, is_null_true) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &file_param, &width_param, &height_param); - zephir_get_strval(&file, file_param); - if (!width_param) { - width = 0; - } else { - } - if (!height_param) { - height = 0; - } else { - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "check", NULL, 361); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("file"), &file); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, 0); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); - if (1 == (zephir_file_exists(&_0) == SUCCESS)) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_2$$3, "realpath", NULL, 74, &_1$$3); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("realpath"), &_2$$3); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&imageInfo, "getimagesize", NULL, 311, &_3$$3); - zephir_check_call_status(); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&imageInfo)) { - zephir_array_fetch_long(&_4$$4, &imageInfo, 0, PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/Gd.zep", 42); - zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_4$$4); - zephir_array_fetch_long(&_5$$4, &imageInfo, 1, PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/Gd.zep", 43); - zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_5$$4); - zephir_array_fetch_long(&_6$$4, &imageInfo, 2, PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/Gd.zep", 44); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_6$$4); - zephir_array_fetch_string(&_7$$4, &imageInfo, SL("mime"), PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/Gd.zep", 45); - zephir_update_property_zval(this_ptr, ZEND_STRL("mime"), &_7$$4); - } - zephir_memory_observe(&_8$$3); - zephir_read_property(&_8$$3, this_ptr, ZEND_STRL("type"), PH_NOISY_CC); - do { - if (ZEPHIR_IS_LONG(&_8$$3, 1)) { - zephir_read_property(&_9$$5, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_10$$5, "imagecreatefromgif", NULL, 362, &_9$$5); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &_10$$5); - break; - } - if (ZEPHIR_IS_LONG(&_8$$3, 2) || ZEPHIR_IS_LONG(&_8$$3, 9)) { - zephir_read_property(&_11$$6, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_12$$6, "imagecreatefromjpeg", NULL, 363, &_11$$6); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &_12$$6); - break; - } - if (ZEPHIR_IS_LONG(&_8$$3, 3)) { - zephir_read_property(&_13$$7, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_14$$7, "imagecreatefrompng", NULL, 364, &_13$$7); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &_14$$7); - break; - } - if (ZEPHIR_IS_LONG(&_8$$3, 18)) { - zephir_read_property(&_15$$8, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_16$$8, "imagecreatefromwebp", NULL, 365, &_15$$8); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &_16$$8); - break; - } - if (ZEPHIR_IS_LONG(&_8$$3, 15)) { - zephir_read_property(&_17$$9, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_18$$9, "imagecreatefromwbmp", NULL, 366, &_17$$9); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &_18$$9); - break; - } - if (ZEPHIR_IS_LONG(&_8$$3, 16)) { - zephir_read_property(&_19$$10, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_20$$10, "imagecreatefromxbm", NULL, 367, &_19$$10); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &_20$$10); - break; - } - zephir_read_property(&_21$$11, this_ptr, ZEND_STRL("mime"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_21$$11)) { - ZEPHIR_INIT_VAR(&_22$$12); - object_init_ex(&_22$$12, phalcon_image_exception_ce); - zephir_read_property(&_23$$12, this_ptr, ZEND_STRL("mime"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_24$$12); - ZEPHIR_CONCAT_SVS(&_24$$12, "Installed GD does not support ", &_23$$12, " images"); - ZEPHIR_CALL_METHOD(NULL, &_22$$12, "__construct", NULL, 33, &_24$$12); - zephir_check_call_status(); - zephir_throw_exception_debug(&_22$$12, "phalcon/Image/Adapter/Gd.zep", 78); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Installed GD does not support such images", "phalcon/Image/Adapter/Gd.zep", 83); - return; - } while(0); - zephir_read_property(&_25$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 368, &_25$$3, &__$true); - zephir_check_call_status(); - } else { - _26$$13 = 0 == width; - if (!(_26$$13)) { - _26$$13 = 0 == height; - } - if (_26$$13) { - ZEPHIR_INIT_VAR(&_27$$14); - object_init_ex(&_27$$14, phalcon_image_exception_ce); - zephir_read_property(&_28$$14, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_29$$14); - ZEPHIR_CONCAT_SV(&_29$$14, "Failed to create image from file ", &_28$$14); - ZEPHIR_CALL_METHOD(NULL, &_27$$14, "__construct", NULL, 33, &_29$$14); - zephir_check_call_status(); - zephir_throw_exception_debug(&_27$$14, "phalcon/Image/Adapter/Gd.zep", 91); - ZEPHIR_MM_RESTORE(); - return; - } - ZVAL_LONG(&_30$$13, width); - ZVAL_LONG(&_31$$13, height); - ZEPHIR_CALL_FUNCTION(&_32$$13, "imagecreatetruecolor", NULL, 369, &_30$$13, &_31$$13); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &_32$$13); - zephir_read_property(&_30$$13, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagealphablending", NULL, 370, &_30$$13, &__$true); - zephir_check_call_status(); - zephir_read_property(&_31$$13, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 368, &_31$$13, &__$true); - zephir_check_call_status(); - zephir_read_property(&_33$$13, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("realpath"), &_33$$13); - ZVAL_UNDEF(&_34$$13); - ZVAL_LONG(&_34$$13, width); - zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_34$$13); - ZVAL_UNDEF(&_34$$13); - ZVAL_LONG(&_34$$13, height); - zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_34$$13); - ZVAL_UNDEF(&_34$$13); - ZVAL_LONG(&_34$$13, 3); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_34$$13); - ZEPHIR_INIT_VAR(&_35$$13); - ZEPHIR_INIT_NVAR(&_35$$13); - ZVAL_STRING(&_35$$13, "image/png"); - zephir_update_property_zval(this_ptr, ZEND_STRL("mime"), &_35$$13); - } - ZEPHIR_MM_RESTORE(); -} -static PHP_METHOD(Phalcon_Image_Adapter_Gd, __destruct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$null, image, _0; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); +#ifdef HAVE_CONFIG_H +#endif - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&image); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&image, &_0); - if (Z_TYPE_P(&image) != IS_NULL) { - ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &image); - zephir_check_call_status(); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &__$null); - ZEPHIR_MM_RESTORE(); + + + +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Exception_ConnectionNotFound) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Pdo\\Exception, ConnectionNotFound, phalcon, datamapper_pdo_exception_connectionnotfound, phalcon_datamapper_pdo_exception_exception_ce, NULL, 0); + + return SUCCESS; } -static PHP_METHOD(Phalcon_Image_Adapter_Gd, getVersion) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Exception_Exception) { - zval info, matches, version, _0, _1, _2$$5, _3$$5, _4$$5, _5$$5; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Pdo\\Exception, Exception, phalcon, datamapper_pdo_exception_exception, zend_ce_exception, NULL, 0); - ZVAL_UNDEF(&info); - ZVAL_UNDEF(&matches); - ZVAL_UNDEF(&version); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$5); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + return SUCCESS; +} - if (1 != (zephir_function_exists_ex(ZEND_STRL("gd_info")) == SUCCESS)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "GD is either not installed or not enabled, check your configuration", "phalcon/Image/Adapter/Gd.zep", 134); - return; - } - ZEPHIR_INIT_VAR(&version); - ZVAL_NULL(&version); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "GD_VERSION"); - ZEPHIR_CALL_FUNCTION(&_1, "defined", NULL, 118, &_0); - zephir_check_call_status(); - if (zephir_is_true(&_1)) { - ZEPHIR_INIT_NVAR(&version); - ZEPHIR_GET_CONSTANT(&version, "GD_VERSION"); - } else { - ZEPHIR_CALL_FUNCTION(&info, "gd_info", NULL, 372); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&matches); - ZVAL_NULL(&matches); - zephir_array_fetch_string(&_2$$5, &info, SL("GD Version"), PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/Gd.zep", 148); - ZEPHIR_INIT_VAR(&_3$$5); - ZVAL_STRING(&_3$$5, "/\\d+\\.\\d+(?:\\.\\d+)?/"); - ZEPHIR_INIT_VAR(&_4$$5); - ZEPHIR_INIT_VAR(&_5$$5); - ZVAL_STRING(&_5$$5, "/\\d+\\.\\d+(?:\\.\\d+)?/"); - zephir_preg_match(&_4$$5, &_5$$5, &_2$$5, &matches, 0, 0 , 0 ); - if (zephir_is_true(&_4$$5)) { - ZEPHIR_OBS_NVAR(&version); - zephir_array_fetch_long(&version, &matches, 0, PH_NOISY, "phalcon/Image/Adapter/Gd.zep", 152); - } - } - RETURN_CCTOR(&version); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Connection_AbstractConnection) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\DataMapper\\Pdo\\Connection, AbstractConnection, phalcon, datamapper_pdo_connection_abstractconnection, phalcon_datamapper_pdo_connection_abstractconnection_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + zend_declare_property_null(phalcon_datamapper_pdo_connection_abstractconnection_ce, SL("pdo"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_datamapper_pdo_connection_abstractconnection_ce, SL("profiler"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_datamapper_pdo_connection_abstractconnection_ce, 1, phalcon_datamapper_pdo_connection_connectioninterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Image_Adapter_Gd, processBackground) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, __call) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *red_param = NULL, *green_param = NULL, *blue_param = NULL, *opacity_param = NULL, __$true, background, color, copy, image, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9; - zend_long red, green, blue, opacity, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval arguments, _2; + zval *name, name_sub, *arguments_param = NULL, className, message, _0, _3, _1$$3; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&background); - ZVAL_UNDEF(&color); - ZVAL_UNDEF(©); - ZVAL_UNDEF(&image); + ZVAL_UNDEF(&name_sub); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&message); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_LONG(red) - Z_PARAM_LONG(green) - Z_PARAM_LONG(blue) - Z_PARAM_LONG(opacity) + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&arguments); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(name) + Z_PARAM_ARRAY(arguments) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 0, &red_param, &green_param, &blue_param, &opacity_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_DOUBLE(&_1, ((zephir_safe_div_long_long((opacity * 127), 100)) - (double) (127))); - ZEPHIR_CALL_FUNCTION(&_2, "abs", NULL, 284, &_1); - zephir_check_call_status(); - zephir_round(&_0, &_2, NULL, NULL); - opacity = zephir_get_intval(&_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&image, &_1); - zephir_read_property(&_1, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_3, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&background, this_ptr, "processcreate", NULL, 0, &_1, &_3); - zephir_check_call_status(); - ZVAL_LONG(&_4, red); - ZVAL_LONG(&_5, green); - ZVAL_LONG(&_6, blue); - ZVAL_LONG(&_7, opacity); - ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 373, &background, &_4, &_5, &_6, &_7); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(NULL, "imagealphablending", NULL, 370, &background, &__$true); + zephir_fetch_params(1, 2, 0, &name, &arguments_param); + zephir_get_arrval(&arguments, arguments_param); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); zephir_check_call_status(); - zephir_read_property(&_4, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_5, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_6, 0); - ZVAL_LONG(&_7, 0); - ZVAL_LONG(&_8, 0); - ZVAL_LONG(&_9, 0); - ZEPHIR_CALL_FUNCTION(©, "imagecopy", NULL, 374, &background, &image, &_6, &_7, &_8, &_9, &_4, &_5); + zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + if (!((zephir_method_exists(&_0, name) == SUCCESS))) { + ZEPHIR_INIT_VAR(&className); + zephir_get_class(&className, this_ptr, 0); + ZEPHIR_INIT_VAR(&message); + ZEPHIR_CONCAT_SVSVS(&message, "Class '", &className, "' does not have a method '", name, "'"); + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, spl_ce_BadMethodCallException); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 75, &message); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 59); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_INIT_VAR(&_2); + zephir_create_array(&_2, 2, 0); + zephir_memory_observe(&_3); + zephir_read_property(&_3, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC); + zephir_array_fast_append(&_2, &_3); + zephir_array_fast_append(&_2, name); + ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_2, &arguments); zephir_check_call_status(); - if (!ZEPHIR_IS_FALSE_IDENTICAL(©)) { - ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &image); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &background); - } - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Image_Adapter_Gd, processBlur) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, beginTransaction) { + zval result, _0, _1, _2, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_2 = NULL; - zval *radius_param = NULL, _0$$3, _1$$3; - zend_long radius, ZEPHIR_LAST_CALL_STATUS, counter = 0; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(radius) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &radius_param); - counter = 0; - while (1) { - if (!(counter < radius)) { - break; - } - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_1$$3, 7); - ZEPHIR_CALL_FUNCTION(NULL, "imagefilter", &_2, 375, &_0$$3, &_1$$3); - zephir_check_call_status(); - counter++; - } - ZEPHIR_MM_RESTORE(); + + ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "beginTransaction"); + ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); + zephir_check_call_status(); + zephir_read_property(&_2, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&result, &_2, "begintransaction", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_3, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_3, "finish", NULL, 0); + zephir_check_call_status(); + RETURN_CCTOR(&result); } -static PHP_METHOD(Phalcon_Image_Adapter_Gd, processCreate) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, commit) { + zval result, _0, _1, _2, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *width_param = NULL, *height_param = NULL, __$false, __$true, image, _0, _1; - zend_long width, height, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - ZVAL_BOOL(&__$false, 0); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&image); + ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_LONG(width) - Z_PARAM_LONG(height) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &width_param, &height_param); - ZVAL_LONG(&_0, width); - ZVAL_LONG(&_1, height); - ZEPHIR_CALL_FUNCTION(&image, "imagecreatetruecolor", NULL, 369, &_0, &_1); + + ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(NULL, "imagealphablending", NULL, 370, &image, &__$false); + zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "commit"); + ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 368, &image, &__$true); + zephir_read_property(&_2, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&result, &_2, "commit", NULL, 0); zephir_check_call_status(); - RETURN_CCTOR(&image); + zephir_read_property(&_3, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_3, "finish", NULL, 0); + zephir_check_call_status(); + RETURN_CCTOR(&result); } -static PHP_METHOD(Phalcon_Image_Adapter_Gd, processCrop) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, connect) { - zval rect; +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, disconnect) +{ +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, errorCode) +{ + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *width_param = NULL, *height_param = NULL, *offsetX_param = NULL, *offsetY_param = NULL, image, _0, _1, _2, _3, _4; - zend_long width, height, offsetX, offsetY, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&image); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&rect); - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_LONG(width) - Z_PARAM_LONG(height) - Z_PARAM_LONG(offsetX) - Z_PARAM_LONG(offsetY) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 0, &width_param, &height_param, &offsetX_param, &offsetY_param); - ZEPHIR_INIT_VAR(&rect); - zephir_create_array(&rect, 4, 0); - ZEPHIR_INIT_VAR(&_0); - ZVAL_LONG(&_0, offsetX); - zephir_array_update_string(&rect, SL("x"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_0); - ZVAL_LONG(&_0, offsetY); - zephir_array_update_string(&rect, SL("y"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_0); - ZVAL_LONG(&_0, width); - zephir_array_update_string(&rect, SL("width"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_0); - ZVAL_LONG(&_0, height); - zephir_array_update_string(&rect, SL("height"), &_0, PH_COPY | PH_SEPARATE); - zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&image, "imagecrop", NULL, 376, &_1, &rect); - zephir_check_call_status(); - zephir_read_property(&_2, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &_2); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &image); - ZEPHIR_CALL_FUNCTION(&_3, "imagesx", NULL, 377, &image); + + ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_3); - ZEPHIR_CALL_FUNCTION(&_4, "imagesy", NULL, 378, &image); + zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "errorcode", NULL, 0); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_4); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Image_Adapter_Gd, processFlip) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, errorInfo) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *direction_param = NULL, _0$$3, _1$$3, _2$$4, _3$$4; - zend_long direction, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(direction) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &direction_param); - if (direction == 11) { - zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_1$$3, 1); - ZEPHIR_CALL_FUNCTION(NULL, "imageflip", NULL, 379, &_0$$3, &_1$$3); - zephir_check_call_status(); - } else { - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_3$$4, 2); - ZEPHIR_CALL_FUNCTION(NULL, "imageflip", NULL, 379, &_2$$4, &_3$$4); - zephir_check_call_status(); - } - ZEPHIR_MM_RESTORE(); + + ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "errorinfo", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Image_Adapter_Gd, processMask) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, exec) { - zend_bool _9; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_23 = NULL, *_24 = NULL, *_29 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, alpha = 0, maskHeight = 0, maskWidth = 0, x = 0, y = 0; - zval *mask, mask_sub, __$true, blue, color, index, green, maskImage, newImage, red, tempImage, _0, _1, _2, _3, _4, _5, _6, _7, _8, _10$$3, _11$$3, _12$$3, _13$$3, _14$$3, _15$$3, _16$$3, _17$$3, _18$$3, _19$$3, _20$$4, _21$$5, _22$$5, _27$$5, _28$$5, _25$$6, _26$$6; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *statement_param = NULL, affectedRows, _0, _1, _2, _3; + zval statement; zval *this_ptr = getThis(); - ZVAL_UNDEF(&mask_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&blue); - ZVAL_UNDEF(&color); - ZVAL_UNDEF(&index); - ZVAL_UNDEF(&green); - ZVAL_UNDEF(&maskImage); - ZVAL_UNDEF(&newImage); - ZVAL_UNDEF(&red); - ZVAL_UNDEF(&tempImage); + ZVAL_UNDEF(&statement); + ZVAL_UNDEF(&affectedRows); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_10$$3); - ZVAL_UNDEF(&_11$$3); - ZVAL_UNDEF(&_12$$3); - ZVAL_UNDEF(&_13$$3); - ZVAL_UNDEF(&_14$$3); - ZVAL_UNDEF(&_15$$3); - ZVAL_UNDEF(&_16$$3); - ZVAL_UNDEF(&_17$$3); - ZVAL_UNDEF(&_18$$3); - ZVAL_UNDEF(&_19$$3); - ZVAL_UNDEF(&_20$$4); - ZVAL_UNDEF(&_21$$5); - ZVAL_UNDEF(&_22$$5); - ZVAL_UNDEF(&_27$$5); - ZVAL_UNDEF(&_28$$5); - ZVAL_UNDEF(&_25$$6); - ZVAL_UNDEF(&_26$$6); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(mask, phalcon_image_adapter_adapterinterface_ce) + Z_PARAM_STR(statement) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &mask); - ZEPHIR_CALL_METHOD(&_0, mask, "render", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&maskImage, "imagecreatefromstring", NULL, 380, &_0); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_1, "imagesx", NULL, 377, &maskImage); - zephir_check_call_status(); - maskWidth = zephir_get_intval(&_1); - ZEPHIR_CALL_FUNCTION(&_2, "imagesy", NULL, 378, &maskImage); - zephir_check_call_status(); - maskHeight = zephir_get_intval(&_2); - alpha = 127; - ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 368, &maskImage, &__$true); - zephir_check_call_status(); - zephir_read_property(&_3, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_4, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&newImage, this_ptr, "processcreate", NULL, 0, &_3, &_4); + zephir_fetch_params(1, 1, 0, &statement_param); + zephir_get_strval(&statement, statement_param); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 368, &newImage, &__$true); + zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "exec"); + ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); zephir_check_call_status(); - ZVAL_LONG(&_5, 0); - ZVAL_LONG(&_6, 0); - ZVAL_LONG(&_7, 0); - ZVAL_LONG(&_8, alpha); - ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 373, &newImage, &_5, &_6, &_7, &_8); + zephir_read_property(&_2, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&affectedRows, &_2, "exec", NULL, 0, &statement); zephir_check_call_status(); - ZVAL_LONG(&_5, 0); - ZVAL_LONG(&_6, 0); - ZEPHIR_CALL_FUNCTION(NULL, "imagefill", NULL, 381, &newImage, &_5, &_6, &color); + zephir_read_property(&_3, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_3, "finish", NULL, 0, &statement); zephir_check_call_status(); - zephir_read_property(&_5, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - _9 = !ZEPHIR_IS_LONG_IDENTICAL(&_5, maskWidth); - if (!(_9)) { - zephir_read_property(&_6, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - _9 = !ZEPHIR_IS_LONG_IDENTICAL(&_6, maskHeight); - } - if (_9) { - zephir_read_property(&_10$$3, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_11$$3, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&tempImage, "imagecreatetruecolor", NULL, 369, &_10$$3, &_11$$3); - zephir_check_call_status(); - zephir_read_property(&_12$$3, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_13$$3, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_14$$3, 0); - ZVAL_LONG(&_15$$3, 0); - ZVAL_LONG(&_16$$3, 0); - ZVAL_LONG(&_17$$3, 0); - ZVAL_LONG(&_18$$3, maskWidth); - ZVAL_LONG(&_19$$3, maskHeight); - ZEPHIR_CALL_FUNCTION(NULL, "imagecopyresampled", NULL, 382, &tempImage, &maskImage, &_14$$3, &_15$$3, &_16$$3, &_17$$3, &_12$$3, &_13$$3, &_18$$3, &_19$$3); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &maskImage); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&maskImage, &tempImage); - } - x = 0; - while (1) { - zephir_read_property(&_7, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - if (!(ZEPHIR_GT_LONG(&_7, x))) { - break; - } - y = 0; - while (1) { - zephir_read_property(&_20$$4, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - if (!(ZEPHIR_GT_LONG(&_20$$4, y))) { - break; - } - ZVAL_LONG(&_21$$5, x); - ZVAL_LONG(&_22$$5, y); - ZEPHIR_CALL_FUNCTION(&index, "imagecolorat", &_23, 383, &maskImage, &_21$$5, &_22$$5); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&color, "imagecolorsforindex", &_24, 384, &maskImage, &index); - zephir_check_call_status(); - if (1 == zephir_array_isset_string(&color, SL("red"))) { - zephir_array_fetch_string(&_25$$6, &color, SL("red"), PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/Gd.zep", 348); - ZVAL_DOUBLE(&_26$$6, zephir_safe_div_zval_long(&_25$$6, 2)); - alpha = (127 - zephir_get_intval(&_26$$6)); - } - zephir_read_property(&_21$$5, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_22$$5, x); - ZVAL_LONG(&_27$$5, y); - ZEPHIR_CALL_FUNCTION(&index, "imagecolorat", &_23, 383, &_21$$5, &_22$$5, &_27$$5); - zephir_check_call_status(); - zephir_read_property(&_22$$5, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&color, "imagecolorsforindex", &_24, 384, &_22$$5, &index); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&red); - zephir_array_fetch_string(&red, &color, SL("red"), PH_NOISY, "phalcon/Image/Adapter/Gd.zep", 353); - ZEPHIR_OBS_NVAR(&green); - zephir_array_fetch_string(&green, &color, SL("green"), PH_NOISY, "phalcon/Image/Adapter/Gd.zep", 354); - ZEPHIR_OBS_NVAR(&blue); - zephir_array_fetch_string(&blue, &color, SL("blue"), PH_NOISY, "phalcon/Image/Adapter/Gd.zep", 355); - ZVAL_LONG(&_27$$5, alpha); - ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 373, &newImage, &red, &green, &blue, &_27$$5); - zephir_check_call_status(); - ZVAL_LONG(&_27$$5, x); - ZVAL_LONG(&_28$$5, y); - ZEPHIR_CALL_FUNCTION(NULL, "imagesetpixel", &_29, 385, &newImage, &_27$$5, &_28$$5, &color); - zephir_check_call_status(); - y++; - } - x++; + RETURN_CCTOR(&affectedRows); +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchAffected) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval values; + zval *statement_param = NULL, *values_param = NULL, sth; + zval statement; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&statement); + ZVAL_UNDEF(&sth); + ZVAL_UNDEF(&values); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(statement) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(values) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &statement_param, &values_param); + zephir_get_strval(&statement, statement_param); + if (!values_param) { + ZEPHIR_INIT_VAR(&values); + array_init(&values); + } else { + zephir_get_arrval(&values, values_param); } - zephir_read_property(&_8, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &_8); + ZEPHIR_CALL_METHOD(&sth, this_ptr, "perform", NULL, 0, &statement, &values); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &maskImage); + ZEPHIR_RETURN_CALL_METHOD(&sth, "rowcount", NULL, 0); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &newImage); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Image_Adapter_Gd, processPixelate) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchAll) { - zend_bool _3$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_8 = NULL, *_10 = NULL; - zval *amount_param = NULL, color, x2, y2, _0, _1$$3, _2$$4, _4$$4, _5$$4, _6$$4, _7$$4, _9$$4; - zend_long amount, ZEPHIR_LAST_CALL_STATUS, x = 0, x1 = 0, y = 0, y1 = 0; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval values, _0; + zval *statement_param = NULL, *values_param = NULL, _1; + zval statement; zval *this_ptr = getThis(); - ZVAL_UNDEF(&color); - ZVAL_UNDEF(&x2); - ZVAL_UNDEF(&y2); + ZVAL_UNDEF(&statement); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&values); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_9$$4); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(amount) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(statement) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(values) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &amount_param); - x = 0; - while (1) { - zephir_read_property(&_0, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - if (!(ZEPHIR_GT_LONG(&_0, x))) { - break; - } - y = 0; - while (1) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - if (!(ZEPHIR_GT_LONG(&_1$$3, y))) { - break; - } - x1 = ((x + (zephir_safe_div_long_long(amount, 2)))); - y1 = ((y + (zephir_safe_div_long_long(amount, 2)))); - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - _3$$4 = ZEPHIR_LE_LONG(&_2$$4, x1); - if (!(_3$$4)) { - zephir_read_property(&_4$$4, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - _3$$4 = ZEPHIR_LE_LONG(&_4$$4, y1); - } - if (_3$$4) { - break; - } - zephir_read_property(&_5$$4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_6$$4, x1); - ZVAL_LONG(&_7$$4, y1); - ZEPHIR_CALL_FUNCTION(&color, "imagecolorat", &_8, 383, &_5$$4, &_6$$4, &_7$$4); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&x2); - ZVAL_LONG(&x2, (x + amount)); - ZEPHIR_INIT_NVAR(&y2); - ZVAL_LONG(&y2, (y + amount)); - zephir_read_property(&_6$$4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_7$$4, x); - ZVAL_LONG(&_9$$4, y); - ZEPHIR_CALL_FUNCTION(NULL, "imagefilledrectangle", &_10, 386, &_6$$4, &_7$$4, &_9$$4, &x2, &y2, &color); - zephir_check_call_status(); - y += amount; - } - x += amount; + zephir_fetch_params(1, 1, 1, &statement_param, &values_param); + zephir_get_strval(&statement, statement_param); + if (!values_param) { + ZEPHIR_INIT_VAR(&values); + array_init(&values); + } else { + zephir_get_arrval(&values, values_param); } - ZEPHIR_MM_RESTORE(); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 1, 0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_LONG(&_1, 2); + zephir_array_fast_append(&_0, &_1); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "fetchAll"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "fetchdata", NULL, 0, &_1, &_0, &statement, &values); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Image_Adapter_Gd, processReflection) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchAssoc) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_25 = NULL; - zend_bool fadeIn; - zval *height_param = NULL, *opacity_param = NULL, *fadeIn_param = NULL, line, reflection, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _27, _28, _11$$5, _12$$5, _17$$5, _18$$5, _19$$5, _20$$5, _21$$5, _22$$5, _23$$5, _24$$5, _26$$5, _13$$6, _14$$6, _15$$7, _16$$7; - zend_long height, opacity, ZEPHIR_LAST_CALL_STATUS, destinationY = 0, destinationOpacity = 0, offset = 0, stepping = 0, sourceY = 0; + zephir_fcall_cache_entry *_2 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval values; + zval *statement_param = NULL, *values_param = NULL, data, row, sth, _0, _1$$3, _3$$3; + zval statement; zval *this_ptr = getThis(); - ZVAL_UNDEF(&line); - ZVAL_UNDEF(&reflection); + ZVAL_UNDEF(&statement); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&row); + ZVAL_UNDEF(&sth); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_27); - ZVAL_UNDEF(&_28); - ZVAL_UNDEF(&_11$$5); - ZVAL_UNDEF(&_12$$5); - ZVAL_UNDEF(&_17$$5); - ZVAL_UNDEF(&_18$$5); - ZVAL_UNDEF(&_19$$5); - ZVAL_UNDEF(&_20$$5); - ZVAL_UNDEF(&_21$$5); - ZVAL_UNDEF(&_22$$5); - ZVAL_UNDEF(&_23$$5); - ZVAL_UNDEF(&_24$$5); - ZVAL_UNDEF(&_26$$5); - ZVAL_UNDEF(&_13$$6); - ZVAL_UNDEF(&_14$$6); - ZVAL_UNDEF(&_15$$7); - ZVAL_UNDEF(&_16$$7); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_LONG(height) - Z_PARAM_LONG(opacity) - Z_PARAM_BOOL(fadeIn) + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&values); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(statement) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(values) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &height_param, &opacity_param, &fadeIn_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_DOUBLE(&_1, ((zephir_safe_div_long_long((opacity * 127), 100)) - (double) (127))); - ZEPHIR_CALL_FUNCTION(&_2, "abs", NULL, 284, &_1); - zephir_check_call_status(); - zephir_round(&_0, &_2, NULL, NULL); - opacity = zephir_get_intval(&_0); - if (opacity < 127) { - stepping = (long) (zephir_safe_div_long_long(((127 - opacity)), height)); + zephir_fetch_params(1, 1, 1, &statement_param, &values_param); + zephir_get_strval(&statement, statement_param); + if (!values_param) { + ZEPHIR_INIT_VAR(&values); + array_init(&values); } else { - stepping = (long) (zephir_safe_div_long_long(127, height)); + zephir_get_arrval(&values, values_param); } - zephir_read_property(&_1, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_3, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_4, (zephir_get_numberval(&_3) + height)); - ZEPHIR_CALL_METHOD(&reflection, this_ptr, "processcreate", NULL, 0, &_1, &_4); + ZEPHIR_INIT_VAR(&data); + array_init(&data); + ZEPHIR_CALL_METHOD(&sth, this_ptr, "perform", NULL, 0, &statement, &values); zephir_check_call_status(); - zephir_read_property(&_4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_5, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_6, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_7, 0); - ZVAL_LONG(&_8, 0); - ZVAL_LONG(&_9, 0); - ZVAL_LONG(&_10, 0); - ZEPHIR_CALL_FUNCTION(NULL, "imagecopy", NULL, 374, &reflection, &_4, &_7, &_8, &_9, &_10, &_5, &_6); + ZVAL_LONG(&_0, 2); + ZEPHIR_CALL_METHOD(&row, &sth, "fetch", NULL, 0, &_0); zephir_check_call_status(); - offset = 0; while (1) { - if (!(height >= offset)) { + if (!(zephir_is_true(&row))) { break; } - zephir_read_property(&_11$$5, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - sourceY = ((zephir_get_numberval(&_11$$5) - offset) - 1); - zephir_read_property(&_12$$5, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - destinationY = (zephir_get_numberval(&_12$$5) + offset); - if (fadeIn) { - ZEPHIR_INIT_NVAR(&_13$$6); - ZVAL_LONG(&_14$$6, (opacity + ((stepping * ((height - offset)))))); - zephir_round(&_13$$6, &_14$$6, NULL, NULL); - destinationOpacity = zephir_get_intval(&_13$$6); - } else { - ZEPHIR_INIT_NVAR(&_15$$7); - ZVAL_LONG(&_16$$7, (opacity + ((stepping * offset)))); - zephir_round(&_15$$7, &_16$$7, NULL, NULL); - destinationOpacity = zephir_get_intval(&_15$$7); - } - zephir_read_property(&_17$$5, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_18$$5, 1); - ZEPHIR_CALL_METHOD(&line, this_ptr, "processcreate", NULL, 0, &_17$$5, &_18$$5); - zephir_check_call_status(); - zephir_read_property(&_18$$5, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_19$$5, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_20$$5, 0); - ZVAL_LONG(&_21$$5, 0); - ZVAL_LONG(&_22$$5, 0); - ZVAL_LONG(&_23$$5, sourceY); - ZVAL_LONG(&_24$$5, 1); - ZEPHIR_CALL_FUNCTION(NULL, "imagecopy", NULL, 374, &line, &_18$$5, &_20$$5, &_21$$5, &_22$$5, &_23$$5, &_19$$5, &_24$$5); - zephir_check_call_status(); - ZVAL_LONG(&_20$$5, 4); - ZVAL_LONG(&_21$$5, 0); - ZVAL_LONG(&_22$$5, 0); - ZVAL_LONG(&_23$$5, 0); - ZVAL_LONG(&_24$$5, destinationOpacity); - ZEPHIR_CALL_FUNCTION(NULL, "imagefilter", &_25, 375, &line, &_20$$5, &_21$$5, &_22$$5, &_23$$5, &_24$$5); + ZEPHIR_CALL_FUNCTION(&_1$$3, "current", &_2, 4, &row); zephir_check_call_status(); - zephir_read_property(&_20$$5, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_21$$5, 0); - ZVAL_LONG(&_22$$5, destinationY); - ZVAL_LONG(&_23$$5, 0); - ZVAL_LONG(&_24$$5, 0); - ZVAL_LONG(&_26$$5, 1); - ZEPHIR_CALL_FUNCTION(NULL, "imagecopy", NULL, 374, &reflection, &line, &_21$$5, &_22$$5, &_23$$5, &_24$$5, &_20$$5, &_26$$5); + zephir_array_update_zval(&data, &_1$$3, &row, PH_COPY | PH_SEPARATE); + ZVAL_LONG(&_3$$3, 2); + ZEPHIR_CALL_METHOD(&row, &sth, "fetch", NULL, 0, &_3$$3); zephir_check_call_status(); - offset++; } - zephir_read_property(&_7, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &_7); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &reflection); - ZEPHIR_CALL_FUNCTION(&_27, "imagesx", NULL, 377, &reflection); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_27); - ZEPHIR_CALL_FUNCTION(&_28, "imagesy", NULL, 378, &reflection); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_28); - ZEPHIR_MM_RESTORE(); + RETURN_CCTOR(&data); } -static PHP_METHOD(Phalcon_Image_Adapter_Gd, processRender) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchColumn) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long quality, ZEPHIR_LAST_CALL_STATUS; - zval *extension_param = NULL, *quality_param = NULL, __$null, _0, _1$$3, _2$$4, _3$$4, _4$$5, _5$$6, _6$$7, _7$$8, _8$$9; - zval extension, _9$$9; + zend_long column, ZEPHIR_LAST_CALL_STATUS; + zval values, _0; + zval *statement_param = NULL, *values_param = NULL, *column_param = NULL, _1; + zval statement; zval *this_ptr = getThis(); - ZVAL_UNDEF(&extension); - ZVAL_UNDEF(&_9$$9); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&statement); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&values); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_7$$8); - ZVAL_UNDEF(&_8$$9); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(extension) - Z_PARAM_LONG(quality) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(statement) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(values) + Z_PARAM_LONG(column) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &extension_param, &quality_param); - zephir_get_strval(&extension, extension_param); - ZEPHIR_INIT_VAR(&_0); - zephir_fast_strtolower(&_0, &extension); - zephir_get_strval(&extension, &_0); - ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 387); - zephir_check_call_status(); - do { - if (ZEPHIR_IS_STRING(&extension, "gif")) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagegif", NULL, 388, &_1$$3); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_STRING(&extension, "jpg") || ZEPHIR_IS_STRING(&extension, "jpeg")) { - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_3$$4, quality); - ZEPHIR_CALL_FUNCTION(NULL, "imagejpeg", NULL, 389, &_2$$4, &__$null, &_3$$4); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_STRING(&extension, "png")) { - zephir_read_property(&_4$$5, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagepng", NULL, 390, &_4$$5); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_STRING(&extension, "wbmp")) { - zephir_read_property(&_5$$6, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagewbmp", NULL, 391, &_5$$6); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_STRING(&extension, "webp")) { - zephir_read_property(&_6$$7, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagewebp", NULL, 392, &_6$$7); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_STRING(&extension, "xbm")) { - zephir_read_property(&_7$$8, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagexbm", NULL, 393, &_7$$8, &__$null); - zephir_check_call_status(); - break; + zephir_fetch_params(1, 1, 2, &statement_param, &values_param, &column_param); + zephir_get_strval(&statement, statement_param); + if (!values_param) { + ZEPHIR_INIT_VAR(&values); + array_init(&values); + } else { + zephir_get_arrval(&values, values_param); + } + if (!column_param) { + column = 0; + } else { } - ZEPHIR_INIT_VAR(&_8$$9); - object_init_ex(&_8$$9, phalcon_image_exception_ce); - ZEPHIR_INIT_VAR(&_9$$9); - ZEPHIR_CONCAT_SVS(&_9$$9, "Installed GD does not support '", &extension, "' images"); - ZEPHIR_CALL_METHOD(NULL, &_8$$9, "__construct", NULL, 33, &_9$$9); - zephir_check_call_status(); - zephir_throw_exception_debug(&_8$$9, "phalcon/Image/Adapter/Gd.zep", 552); - ZEPHIR_MM_RESTORE(); - return; - } while(0); - - ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", NULL, 394); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 2, 0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_LONG(&_1, 7); + zephir_array_fast_append(&_0, &_1); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_LONG(&_1, column); + zephir_array_fast_append(&_0, &_1); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "fetchAll"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "fetchdata", NULL, 0, &_1, &_0, &statement, &values); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Image_Adapter_Gd, processResize) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchGroup) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *width_param = NULL, *height_param = NULL, image, _0, _1, _2, _3, _4; - zend_long width, height, ZEPHIR_LAST_CALL_STATUS; + zend_long flags, ZEPHIR_LAST_CALL_STATUS; + zval values, _0; + zval *statement_param = NULL, *values_param = NULL, *flags_param = NULL, _1; + zval statement; zval *this_ptr = getThis(); - ZVAL_UNDEF(&image); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&statement); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_LONG(width) - Z_PARAM_LONG(height) + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(statement) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(values) + Z_PARAM_LONG(flags) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &width_param, &height_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_1, width); - ZVAL_LONG(&_2, height); - ZEPHIR_CALL_FUNCTION(&image, "imagescale", NULL, 395, &_0, &_1, &_2); - zephir_check_call_status(); - zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &_1); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &image); - ZEPHIR_CALL_FUNCTION(&_3, "imagesx", NULL, 377, &image); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_3); - ZEPHIR_CALL_FUNCTION(&_4, "imagesy", NULL, 378, &image); + zephir_fetch_params(1, 1, 2, &statement_param, &values_param, &flags_param); + zephir_get_strval(&statement, statement_param); + if (!values_param) { + ZEPHIR_INIT_VAR(&values); + array_init(&values); + } else { + zephir_get_arrval(&values, values_param); + } + if (!flags_param) { + flags = 2; + } else { + } + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 1, 0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_LONG(&_1, (65536 | flags)); + zephir_array_fast_append(&_0, &_1); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "fetchAll"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "fetchdata", NULL, 0, &_1, &_0, &statement, &values); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_4); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Image_Adapter_Gd, processRotate) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchObject) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *degrees_param = NULL, __$true, copy, height, image, transparent, width, _0, _1, _2, _3, _4, _5, _6, _7, _8$$3; - zend_long degrees, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval values, arguments; + zval *statement_param = NULL, *values_param = NULL, *className_param = NULL, *arguments_param = NULL, sth; + zval statement, className; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(©); - ZVAL_UNDEF(&height); - ZVAL_UNDEF(&image); - ZVAL_UNDEF(&transparent); - ZVAL_UNDEF(&width); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(degrees) + ZVAL_UNDEF(&statement); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&sth); + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&arguments); + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_STR(statement) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(values) + Z_PARAM_STR(className) + Z_PARAM_ARRAY(arguments) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, °rees_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_1, 0); - ZVAL_LONG(&_2, 0); - ZVAL_LONG(&_3, 0); - ZVAL_LONG(&_4, 127); - ZEPHIR_CALL_FUNCTION(&transparent, "imagecolorallocatealpha", NULL, 373, &_0, &_1, &_2, &_3, &_4); - zephir_check_call_status(); - zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_2, (360 - degrees)); - ZEPHIR_CALL_FUNCTION(&image, "imagerotate", NULL, 396, &_1, &_2, &transparent); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 368, &image, &__$true); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&width, "imagesx", NULL, 377, &image); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&height, "imagesy", NULL, 378, &image); + zephir_fetch_params(1, 1, 3, &statement_param, &values_param, &className_param, &arguments_param); + zephir_get_strval(&statement, statement_param); + if (!values_param) { + ZEPHIR_INIT_VAR(&values); + array_init(&values); + } else { + zephir_get_arrval(&values, values_param); + } + if (!className_param) { + ZEPHIR_INIT_VAR(&className); + ZVAL_STRING(&className, "stdClass"); + } else { + zephir_get_strval(&className, className_param); + } + if (!arguments_param) { + ZEPHIR_INIT_VAR(&arguments); + array_init(&arguments); + } else { + zephir_get_arrval(&arguments, arguments_param); + } + ZEPHIR_CALL_METHOD(&sth, this_ptr, "perform", NULL, 0, &statement, &values); zephir_check_call_status(); - zephir_read_property(&_2, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_3, 0); - ZVAL_LONG(&_4, 0); - ZVAL_LONG(&_5, 0); - ZVAL_LONG(&_6, 0); - ZVAL_LONG(&_7, 100); - ZEPHIR_CALL_FUNCTION(©, "imagecopymerge", NULL, 397, &_2, &image, &_3, &_4, &_5, &_6, &width, &height, &_7); + ZEPHIR_RETURN_CALL_METHOD(&sth, "fetchobject", NULL, 0, &className, &arguments); zephir_check_call_status(); - if (!ZEPHIR_IS_FALSE_IDENTICAL(©)) { - zephir_read_property(&_8$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &_8$$3); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &image); - zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &width); - zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &height); - } - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Image_Adapter_Gd, processSave) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchObjects) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long quality, ZEPHIR_LAST_CALL_STATUS; - zval *file_param = NULL, *quality_param = NULL, __$false, extension, _0, _2, _15, _1$$3, _3$$4, _4$$5, _5$$6, _6$$6, _7$$6, _8$$7, _9$$8, _10$$9, _11$$10, _12$$11, _13$$12, _14$$12; - zval file; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval values, arguments; + zval *statement_param = NULL, *values_param = NULL, *className_param = NULL, *arguments_param = NULL, sth, _0; + zval statement, className; zval *this_ptr = getThis(); - ZVAL_UNDEF(&file); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&extension); + ZVAL_UNDEF(&statement); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&sth); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_15); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_6$$6); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_8$$7); - ZVAL_UNDEF(&_9$$8); - ZVAL_UNDEF(&_10$$9); - ZVAL_UNDEF(&_11$$10); - ZVAL_UNDEF(&_12$$11); - ZVAL_UNDEF(&_13$$12); - ZVAL_UNDEF(&_14$$12); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(file) - Z_PARAM_LONG(quality) + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&arguments); + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_STR(statement) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(values) + Z_PARAM_STR(className) + Z_PARAM_ARRAY(arguments) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &file_param, &quality_param); - zephir_get_strval(&file, file_param); - ZVAL_LONG(&_0, 4); - ZEPHIR_CALL_FUNCTION(&extension, "pathinfo", NULL, 89, &file, &_0); - zephir_check_call_status(); - if (1 == ZEPHIR_IS_EMPTY(&extension)) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("type"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&extension, "image_type_to_extension", NULL, 398, &_1$$3, &__$false); - zephir_check_call_status(); + zephir_fetch_params(1, 1, 3, &statement_param, &values_param, &className_param, &arguments_param); + zephir_get_strval(&statement, statement_param); + if (!values_param) { + ZEPHIR_INIT_VAR(&values); + array_init(&values); + } else { + zephir_get_arrval(&values, values_param); } - ZEPHIR_INIT_VAR(&_2); - zephir_fast_strtolower(&_2, &extension); - ZEPHIR_CPY_WRT(&extension, &_2); - do { - if (ZEPHIR_IS_STRING(&extension, "gif")) { - ZVAL_UNDEF(&_3$$4); - ZVAL_LONG(&_3$$4, 1); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_3$$4); - zephir_read_property(&_3$$4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagegif", NULL, 388, &_3$$4, &file); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_STRING(&extension, "jpg") || ZEPHIR_IS_STRING(&extension, "jpeg")) { - ZVAL_UNDEF(&_4$$5); - ZVAL_LONG(&_4$$5, 2); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_4$$5); - if (quality >= 0) { - ZVAL_LONG(&_6$$6, quality); - ZVAL_LONG(&_7$$6, 1); - ZEPHIR_CALL_METHOD(&_5$$6, this_ptr, "checkhighlow", NULL, 0, &_6$$6, &_7$$6); - zephir_check_call_status(); - quality = zephir_get_numberval(&_5$$6); - zephir_read_property(&_6$$6, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_7$$6, quality); - ZEPHIR_CALL_FUNCTION(NULL, "imagejpeg", NULL, 389, &_6$$6, &file, &_7$$6); - zephir_check_call_status(); - } else { - zephir_read_property(&_8$$7, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagejpeg", NULL, 389, &_8$$7, &file); - zephir_check_call_status(); - } - break; - } - if (ZEPHIR_IS_STRING(&extension, "png")) { - ZVAL_UNDEF(&_9$$8); - ZVAL_LONG(&_9$$8, 3); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_9$$8); - zephir_read_property(&_9$$8, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagepng", NULL, 390, &_9$$8, &file); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_STRING(&extension, "wbmp")) { - ZVAL_UNDEF(&_10$$9); - ZVAL_LONG(&_10$$9, 15); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_10$$9); - zephir_read_property(&_10$$9, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagewbmp", NULL, 391, &_10$$9, &file); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_STRING(&extension, "webp")) { - ZVAL_UNDEF(&_11$$10); - ZVAL_LONG(&_11$$10, 18); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_11$$10); - zephir_read_property(&_11$$10, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagewebp", NULL, 392, &_11$$10, &file); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_STRING(&extension, "xbm")) { - ZVAL_UNDEF(&_12$$11); - ZVAL_LONG(&_12$$11, 16); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_12$$11); - zephir_read_property(&_12$$11, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagexbm", NULL, 393, &_12$$11, &file); - zephir_check_call_status(); - break; - } - ZEPHIR_INIT_VAR(&_13$$12); - object_init_ex(&_13$$12, phalcon_image_exception_ce); - ZEPHIR_INIT_VAR(&_14$$12); - ZEPHIR_CONCAT_SVS(&_14$$12, "Installed GD does not support '", &extension, "' images"); - ZEPHIR_CALL_METHOD(NULL, &_13$$12, "__construct", NULL, 33, &_14$$12); - zephir_check_call_status(); - zephir_throw_exception_debug(&_13$$12, "phalcon/Image/Adapter/Gd.zep", 679); - ZEPHIR_MM_RESTORE(); - return; - } while(0); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("type"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_15, "image_type_to_mime_type", NULL, 399, &_0); + if (!className_param) { + ZEPHIR_INIT_VAR(&className); + ZVAL_STRING(&className, "stdClass"); + } else { + zephir_get_strval(&className, className_param); + } + if (!arguments_param) { + ZEPHIR_INIT_VAR(&arguments); + array_init(&arguments); + } else { + zephir_get_arrval(&arguments, arguments_param); + } + ZEPHIR_CALL_METHOD(&sth, this_ptr, "perform", NULL, 0, &statement, &values); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("mime"), &_15); - RETURN_MM_BOOL(1); + ZVAL_LONG(&_0, 8); + ZEPHIR_RETURN_CALL_METHOD(&sth, "fetchall", NULL, 0, &_0, &className, &arguments); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Image_Adapter_Gd, processSharpen) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchOne) { - zval matrix, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *amount_param = NULL, result, _0, _1, _2, _4, _5, _6, _7, _8$$3, _9$$3, _10$$3, _11$$3; - zend_long amount, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval values, _0; + zval *statement_param = NULL, *values_param = NULL, _1; + zval statement; zval *this_ptr = getThis(); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&statement); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_9$$3); - ZVAL_UNDEF(&_10$$3); - ZVAL_UNDEF(&_11$$3); - ZVAL_UNDEF(&matrix); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(amount) + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(statement) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(values) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &amount_param); + zephir_fetch_params(1, 1, 1, &statement_param, &values_param); + zephir_get_strval(&statement, statement_param); + if (!values_param) { + ZEPHIR_INIT_VAR(&values); + array_init(&values); + } else { + zephir_get_arrval(&values, values_param); + } ZEPHIR_INIT_VAR(&_0); - ZVAL_LONG(&_1, (-18 + ((amount * 0.08)))); - ZEPHIR_CALL_FUNCTION(&_2, "abs", NULL, 284, &_1); - zephir_check_call_status(); + zephir_create_array(&_0, 1, 0); + ZEPHIR_INIT_VAR(&_1); ZVAL_LONG(&_1, 2); - zephir_round(&_0, &_2, &_1, NULL); - amount = zephir_get_intval(&_0); - ZEPHIR_INIT_VAR(&matrix); - zephir_create_array(&matrix, 3, 0); - ZEPHIR_INIT_VAR(&_3); - zephir_create_array(&_3, 3, 0); - ZEPHIR_INIT_VAR(&_4); - ZVAL_LONG(&_4, -1); - 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, -1); - zephir_array_fast_append(&_3, &_4); - zephir_array_fast_append(&matrix, &_3); - ZEPHIR_INIT_NVAR(&_3); - zephir_create_array(&_3, 3, 0); - ZEPHIR_INIT_NVAR(&_4); - ZVAL_LONG(&_4, -1); - zephir_array_fast_append(&_3, &_4); - ZEPHIR_INIT_NVAR(&_4); - ZVAL_LONG(&_4, amount); - zephir_array_fast_append(&_3, &_4); - ZEPHIR_INIT_NVAR(&_4); - ZVAL_LONG(&_4, -1); - zephir_array_fast_append(&_3, &_4); - zephir_array_fast_append(&matrix, &_3); - ZEPHIR_INIT_NVAR(&_3); - zephir_create_array(&_3, 3, 0); - ZEPHIR_INIT_NVAR(&_4); - ZVAL_LONG(&_4, -1); - 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, -1); - zephir_array_fast_append(&_3, &_4); - zephir_array_fast_append(&matrix, &_3); - zephir_read_property(&_5, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_6, (amount - 8)); - ZVAL_LONG(&_7, 0); - ZEPHIR_CALL_FUNCTION(&result, "imageconvolution", NULL, 400, &_5, &matrix, &_6, &_7); + zephir_array_fast_append(&_0, &_1); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "fetch"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "fetchdata", NULL, 0, &_1, &_0, &statement, &values); zephir_check_call_status(); - if (ZEPHIR_IS_TRUE_IDENTICAL(&result)) { - zephir_read_property(&_8$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_9$$3, "imagesx", NULL, 377, &_8$$3); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_9$$3); - zephir_read_property(&_10$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_11$$3, "imagesy", NULL, 378, &_10$$3); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_11$$3); - } - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Image_Adapter_Gd, processText) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchPairs) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long opacity, red, green, blue, size, ZEPHIR_LAST_CALL_STATUS, angle = 0, bottomLeftX = 0, bottomLeftY = 0, topRightX = 0, topRightY = 0, _0, _1; - zval *text_param = NULL, *offsetX = NULL, offsetX_sub, *offsetY = NULL, offsetY_sub, *opacity_param = NULL, *red_param = NULL, *green_param = NULL, *blue_param = NULL, *size_param = NULL, *fontFile_param = NULL, color, height, space, width, _2, _3, _4, _5$$3, _6$$3, _11$$3, _12$$3, _19$$3, _20$$3, _21$$3, _7$$5, _8$$5, _9$$5, _10$$5, _13$$6, _14$$6, _15$$6, _16$$7, _17$$7, _18$$7, _22$$8, _23$$8, _30$$8, _31$$8, _32$$8, _33$$8, _24$$9, _25$$9, _26$$9, _27$$10, _28$$10, _29$$10; - zval text, fontFile; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval values, _0; + zval *statement_param = NULL, *values_param = NULL, _1; + zval statement; zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&fontFile); - ZVAL_UNDEF(&offsetX_sub); - ZVAL_UNDEF(&offsetY_sub); - ZVAL_UNDEF(&color); - ZVAL_UNDEF(&height); - ZVAL_UNDEF(&space); - ZVAL_UNDEF(&width); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_11$$3); - ZVAL_UNDEF(&_12$$3); - ZVAL_UNDEF(&_19$$3); - ZVAL_UNDEF(&_20$$3); - ZVAL_UNDEF(&_21$$3); - ZVAL_UNDEF(&_7$$5); - ZVAL_UNDEF(&_8$$5); - ZVAL_UNDEF(&_9$$5); - ZVAL_UNDEF(&_10$$5); - ZVAL_UNDEF(&_13$$6); - ZVAL_UNDEF(&_14$$6); - ZVAL_UNDEF(&_15$$6); - ZVAL_UNDEF(&_16$$7); - ZVAL_UNDEF(&_17$$7); - ZVAL_UNDEF(&_18$$7); - ZVAL_UNDEF(&_22$$8); - ZVAL_UNDEF(&_23$$8); - ZVAL_UNDEF(&_30$$8); - ZVAL_UNDEF(&_31$$8); - ZVAL_UNDEF(&_32$$8); - ZVAL_UNDEF(&_33$$8); - ZVAL_UNDEF(&_24$$9); - ZVAL_UNDEF(&_25$$9); - ZVAL_UNDEF(&_26$$9); - ZVAL_UNDEF(&_27$$10); - ZVAL_UNDEF(&_28$$10); - ZVAL_UNDEF(&_29$$10); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(8, 9) - Z_PARAM_STR(text) - Z_PARAM_ZVAL(offsetX) - Z_PARAM_ZVAL(offsetY) - Z_PARAM_LONG(opacity) - Z_PARAM_LONG(red) - Z_PARAM_LONG(green) - Z_PARAM_LONG(blue) - Z_PARAM_LONG(size) + ZVAL_UNDEF(&statement); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(statement) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(fontFile) + Z_PARAM_ARRAY(values) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 8, 1, &text_param, &offsetX, &offsetY, &opacity_param, &red_param, &green_param, &blue_param, &size_param, &fontFile_param); - zephir_get_strval(&text, text_param); - ZEPHIR_SEPARATE_PARAM(offsetX); - ZEPHIR_SEPARATE_PARAM(offsetY); - if (!fontFile_param) { - ZEPHIR_INIT_VAR(&fontFile); + zephir_fetch_params(1, 1, 1, &statement_param, &values_param); + zephir_get_strval(&statement, statement_param); + if (!values_param) { + ZEPHIR_INIT_VAR(&values); + array_init(&values); } else { - zephir_get_strval(&fontFile, fontFile_param); + zephir_get_arrval(&values, values_param); } - bottomLeftX = 0; - bottomLeftY = 0; - topRightX = 0; - topRightY = 0; - _0 = zephir_get_intval(offsetX); - ZEPHIR_INIT_NVAR(offsetX); - ZVAL_LONG(offsetX, _0); - _1 = zephir_get_intval(offsetY); - ZEPHIR_INIT_NVAR(offsetY); - ZVAL_LONG(offsetY, _1); - ZEPHIR_INIT_VAR(&_2); - ZVAL_DOUBLE(&_3, ((zephir_safe_div_long_long((opacity * 127), 100)) - (double) (127))); - ZEPHIR_CALL_FUNCTION(&_4, "abs", NULL, 284, &_3); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 1, 0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_LONG(&_1, 12); + zephir_array_fast_append(&_0, &_1); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "fetchAll"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "fetchdata", NULL, 0, &_1, &_0, &statement, &values); zephir_check_call_status(); - zephir_round(&_2, &_4, NULL, NULL); - opacity = zephir_get_intval(&_2); - ZEPHIR_INIT_VAR(&width); - if (1 != ZEPHIR_IS_EMPTY(&fontFile)) { - ZVAL_LONG(&_5$$3, size); - ZVAL_LONG(&_6$$3, 0); - ZEPHIR_CALL_FUNCTION(&space, "imagettfbbox", NULL, 401, &_5$$3, &_6$$3, &fontFile, &text); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&space)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Call to imagettfbbox() failed", "phalcon/Image/Adapter/Gd.zep", 758); - return; - } - if (1 == zephir_array_isset_long(&space, 0)) { - zephir_memory_observe(&_7$$5); - zephir_array_fetch_long(&_7$$5, &space, 0, PH_NOISY, "phalcon/Image/Adapter/Gd.zep", 762); - bottomLeftX = zephir_get_intval(&_7$$5); - zephir_memory_observe(&_8$$5); - zephir_array_fetch_long(&_8$$5, &space, 1, PH_NOISY, "phalcon/Image/Adapter/Gd.zep", 763); - bottomLeftY = zephir_get_intval(&_8$$5); - zephir_memory_observe(&_9$$5); - zephir_array_fetch_long(&_9$$5, &space, 4, PH_NOISY, "phalcon/Image/Adapter/Gd.zep", 764); - topRightX = zephir_get_intval(&_9$$5); - zephir_memory_observe(&_10$$5); - zephir_array_fetch_long(&_10$$5, &space, 5, PH_NOISY, "phalcon/Image/Adapter/Gd.zep", 765); - topRightY = zephir_get_intval(&_10$$5); - } - ZVAL_LONG(&_5$$3, (topRightX - bottomLeftX)); - ZEPHIR_CALL_FUNCTION(&_11$$3, "abs", NULL, 284, &_5$$3); - zephir_check_call_status(); - ZVAL_LONG(&width, (zephir_get_numberval(&_11$$3) + 10)); - ZVAL_LONG(&_5$$3, (topRightY - bottomLeftY)); - ZEPHIR_CALL_FUNCTION(&_12$$3, "abs", NULL, 284, &_5$$3); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&height); - ZVAL_LONG(&height, (zephir_get_numberval(&_12$$3) + 10)); - if (ZEPHIR_LT_LONG(offsetX, 0)) { - zephir_read_property(&_13$$6, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_14$$6); - zephir_sub_function(&_14$$6, &_13$$6, &width); - ZEPHIR_INIT_VAR(&_15$$6); - zephir_add_function(&_15$$6, &_14$$6, offsetX); - ZEPHIR_CPY_WRT(offsetX, &_15$$6); - } - if (ZEPHIR_LT_LONG(offsetY, 0)) { - zephir_read_property(&_16$$7, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_17$$7); - zephir_sub_function(&_17$$7, &_16$$7, &height); - ZEPHIR_INIT_VAR(&_18$$7); - zephir_add_function(&_18$$7, &_17$$7, offsetY); - ZEPHIR_CPY_WRT(offsetY, &_18$$7); - } - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_6$$3, red); - ZVAL_LONG(&_19$$3, green); - ZVAL_LONG(&_20$$3, blue); - ZVAL_LONG(&_21$$3, opacity); - ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 373, &_5$$3, &_6$$3, &_19$$3, &_20$$3, &_21$$3); - zephir_check_call_status(); - angle = 0; - zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_19$$3, size); - ZVAL_LONG(&_20$$3, angle); - ZEPHIR_CALL_FUNCTION(NULL, "imagettftext", NULL, 402, &_6$$3, &_19$$3, &_20$$3, offsetX, offsetY, &color, &fontFile, &text); - zephir_check_call_status(); - } else { - ZVAL_LONG(&_22$$8, size); - ZEPHIR_CALL_FUNCTION(&_23$$8, "imagefontwidth", NULL, 403, &_22$$8); - zephir_check_call_status(); - ZVAL_LONG(&width, (zephir_get_numberval(&_23$$8) * zephir_fast_strlen_ev(&text))); - ZVAL_LONG(&_22$$8, size); - ZEPHIR_CALL_FUNCTION(&height, "imagefontheight", NULL, 404, &_22$$8); - zephir_check_call_status(); - if (ZEPHIR_LT_LONG(offsetX, 0)) { - zephir_read_property(&_24$$9, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_25$$9); - zephir_sub_function(&_25$$9, &_24$$9, &width); - ZEPHIR_INIT_VAR(&_26$$9); - zephir_add_function(&_26$$9, &_25$$9, offsetX); - ZEPHIR_CPY_WRT(offsetX, &_26$$9); - } - if (ZEPHIR_LT_LONG(offsetY, 0)) { - zephir_read_property(&_27$$10, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_28$$10); - zephir_sub_function(&_28$$10, &_27$$10, &height); - ZEPHIR_INIT_VAR(&_29$$10); - zephir_add_function(&_29$$10, &_28$$10, offsetY); - ZEPHIR_CPY_WRT(offsetY, &_29$$10); - } - zephir_read_property(&_22$$8, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_30$$8, red); - ZVAL_LONG(&_31$$8, green); - ZVAL_LONG(&_32$$8, blue); - ZVAL_LONG(&_33$$8, opacity); - ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 373, &_22$$8, &_30$$8, &_31$$8, &_32$$8, &_33$$8); - zephir_check_call_status(); - zephir_read_property(&_30$$8, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_31$$8, size); - ZEPHIR_CALL_FUNCTION(NULL, "imagestring", NULL, 405, &_30$$8, &_31$$8, offsetX, offsetY, &text, &color); - zephir_check_call_status(); - } - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Image_Adapter_Gd, processWatermark) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchValue) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long offsetX, offsetY, opacity, ZEPHIR_LAST_CALL_STATUS, height = 0, width = 0; - zval *watermark, watermark_sub, *offsetX_param = NULL, *offsetY_param = NULL, *opacity_param = NULL, __$true, color, copy, overlay, _0, _1, _2, _9, _10, _11, _12, _13, _14, _15, _16, _3$$3, _4$$3, _5$$3, _6$$3, _7$$3, _8$$3; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval values; + zval *statement_param = NULL, *values_param = NULL, sth, _0; + zval statement; zval *this_ptr = getThis(); - ZVAL_UNDEF(&watermark_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&color); - ZVAL_UNDEF(©); - ZVAL_UNDEF(&overlay); + ZVAL_UNDEF(&statement); + ZVAL_UNDEF(&sth); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_13); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_15); - ZVAL_UNDEF(&_16); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_8$$3); - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_OBJECT_OF_CLASS(watermark, phalcon_image_adapter_adapterinterface_ce) - Z_PARAM_LONG(offsetX) - Z_PARAM_LONG(offsetY) - Z_PARAM_LONG(opacity) + ZVAL_UNDEF(&values); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(statement) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(values) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 0, &watermark, &offsetX_param, &offsetY_param, &opacity_param); - ZEPHIR_CALL_METHOD(&_0, watermark, "render", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&overlay, "imagecreatefromstring", NULL, 380, &_0); + zephir_fetch_params(1, 1, 1, &statement_param, &values_param); + zephir_get_strval(&statement, statement_param); + if (!values_param) { + ZEPHIR_INIT_VAR(&values); + array_init(&values); + } else { + zephir_get_arrval(&values, values_param); + } + ZEPHIR_CALL_METHOD(&sth, this_ptr, "perform", NULL, 0, &statement, &values); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 368, &overlay, &__$true); + ZVAL_LONG(&_0, 0); + ZEPHIR_RETURN_CALL_METHOD(&sth, "fetchcolumn", NULL, 0, &_0); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_1, "imagesx", NULL, 377, &overlay); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, getAdapter) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); zephir_check_call_status(); - width = zephir_get_intval(&_1); - ZEPHIR_CALL_FUNCTION(&_2, "imagesy", NULL, 378, &overlay); + RETURN_MM_MEMBER(getThis(), "pdo"); +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, getAttribute) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *attribute_param = NULL, _0, _1; + zend_long attribute, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(attribute) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &attribute_param); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); zephir_check_call_status(); - height = zephir_get_intval(&_2); - if (opacity < 100) { - ZEPHIR_INIT_VAR(&_3$$3); - ZVAL_DOUBLE(&_4$$3, ((zephir_safe_div_long_long((opacity * 127), 100)) - (double) (127))); - ZEPHIR_CALL_FUNCTION(&_5$$3, "abs", NULL, 284, &_4$$3); - zephir_check_call_status(); - zephir_round(&_3$$3, &_5$$3, NULL, NULL); - opacity = zephir_get_intval(&_3$$3); - ZVAL_LONG(&_4$$3, 127); - ZVAL_LONG(&_6$$3, 127); - ZVAL_LONG(&_7$$3, 127); - ZVAL_LONG(&_8$$3, opacity); - ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 373, &overlay, &_4$$3, &_6$$3, &_7$$3, &_8$$3); - zephir_check_call_status(); - ZVAL_LONG(&_4$$3, 3); - ZEPHIR_CALL_FUNCTION(NULL, "imagelayereffect", NULL, 406, &overlay, &_4$$3); - zephir_check_call_status(); - ZVAL_LONG(&_4$$3, 0); - ZVAL_LONG(&_6$$3, 0); - ZVAL_LONG(&_7$$3, width); - ZVAL_LONG(&_8$$3, height); - ZEPHIR_CALL_FUNCTION(NULL, "imagefilledrectangle", NULL, 386, &overlay, &_4$$3, &_6$$3, &_7$$3, &_8$$3, &color); - zephir_check_call_status(); - } - zephir_read_property(&_9, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(NULL, "imagealphablending", NULL, 370, &_9, &__$true); + zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1, attribute); + ZEPHIR_RETURN_CALL_METHOD(&_0, "getattribute", NULL, 0, &_1); zephir_check_call_status(); - zephir_read_property(&_10, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_11, offsetX); - ZVAL_LONG(&_12, offsetY); - ZVAL_LONG(&_13, 0); - ZVAL_LONG(&_14, 0); - ZVAL_LONG(&_15, width); - ZVAL_LONG(&_16, height); - ZEPHIR_CALL_FUNCTION(©, "imagecopy", NULL, 374, &_10, &overlay, &_11, &_12, &_13, &_14, &_15, &_16); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, getAvailableDrivers) +{ + zend_class_entry *_0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + _0 = zephir_fetch_class_str_ex(SL("PDO"), ZEND_FETCH_CLASS_AUTO); + ZEPHIR_RETURN_CALL_CE_STATIC(_0, "getavailabledrivers", NULL, 0); zephir_check_call_status(); - if (ZEPHIR_IS_TRUE_IDENTICAL(©)) { - ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &overlay); - zephir_check_call_status(); - } - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Image_Adapter_Gd, check) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, getDriverName) { - zval version, _0, _1, _2, _3$$3, _4$$3; + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&version); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_CALL_METHOD(&version, this_ptr, "getversion", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "2.0.1"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, ">="); - ZEPHIR_CALL_FUNCTION(&_2, "version_compare", NULL, 134, &version, &_0, &_1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1, 16); + ZEPHIR_RETURN_CALL_METHOD(&_0, "getattribute", NULL, 0, &_1); zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_2)) { - ZEPHIR_INIT_VAR(&_3$$3); - object_init_ex(&_3$$3, phalcon_image_exception_ce); - ZEPHIR_INIT_VAR(&_4$$3); - ZEPHIR_CONCAT_SSV(&_4$$3, "Phalcon\\Image\\Adapter\\GD requires GD ", "version '2.0.1' or greater, you have ", &version); - ZEPHIR_CALL_METHOD(NULL, &_3$$3, "__construct", NULL, 33, &_4$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_3$$3, "phalcon/Image/Adapter/Gd.zep", 898); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, getProfiler) +{ + RETURN_MEMBER(getThis(), "profiler"); +} +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, getQuoteNames) +{ + zval quotes; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *driver_param = NULL, option, _0$$5, _1$$6; + zval driver; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H -#endif + ZVAL_UNDEF(&driver); + ZVAL_UNDEF(&option); + ZVAL_UNDEF(&_0$$5); + ZVAL_UNDEF(&_1$$6); + ZVAL_UNDEF("es); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR(driver) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &driver_param); + if (!driver_param) { + ZEPHIR_INIT_VAR(&driver); + ZVAL_STRING(&driver, ""); + } else { + zephir_get_strval(&driver, driver_param); + } + ZEPHIR_CPY_WRT(&option, &driver); + if (ZEPHIR_IS_EMPTY(&option)) { + ZEPHIR_CALL_METHOD(&option, this_ptr, "getdrivername", NULL, 0); + zephir_check_call_status(); + } + do { + if (ZEPHIR_IS_STRING(&option, "mysql")) { + ZEPHIR_INIT_VAR("es); + zephir_create_array("es, 4, 0); + add_assoc_stringl_ex("es, SL("prefix"), SL("`")); + add_assoc_stringl_ex("es, SL("suffix"), SL("`")); + add_assoc_stringl_ex("es, SL("find"), SL("`")); + add_assoc_stringl_ex("es, SL("replace"), SL("``")); + break; + } + if (ZEPHIR_IS_STRING(&option, "sqlsrv")) { + ZEPHIR_INIT_VAR(&_0$$5); + zephir_create_array(&_0$$5, 4, 0); + add_assoc_stringl_ex(&_0$$5, SL("prefix"), SL("[")); + add_assoc_stringl_ex(&_0$$5, SL("suffix"), SL("]")); + add_assoc_stringl_ex(&_0$$5, SL("find"), SL("]")); + add_assoc_stringl_ex(&_0$$5, SL("replace"), SL("][")); + ZEPHIR_CPY_WRT("es, &_0$$5); + break; + } + ZEPHIR_INIT_VAR(&_1$$6); + zephir_create_array(&_1$$6, 4, 0); + add_assoc_stringl_ex(&_1$$6, SL("prefix"), SL("\"")); + add_assoc_stringl_ex(&_1$$6, SL("suffix"), SL("\"")); + add_assoc_stringl_ex(&_1$$6, SL("find"), SL("\"")); + add_assoc_stringl_ex(&_1$$6, SL("replace"), SL("\"\"")); + ZEPHIR_CPY_WRT("es, &_1$$6); + break; + } while(0); + RETURN_CTOR("es); +} +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, inTransaction) +{ + zval result, _0, _1, _2, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "inTransaction"); + ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); + zephir_check_call_status(); + zephir_read_property(&_2, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&result, &_2, "intransaction", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_3, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_3, "finish", NULL, 0); + zephir_check_call_status(); + RETURN_CCTOR(&result); +} -ZEPHIR_INIT_CLASS(Phalcon_Image_Adapter_Imagick) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, isConnected) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Image\\Adapter, Imagick, phalcon, image_adapter_imagick, phalcon_image_adapter_abstractadapter_ce, phalcon_image_adapter_imagick_method_entry, 0); + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); - zend_declare_property_long(phalcon_image_adapter_imagick_ce, SL("version"), 0, ZEND_ACC_PROTECTED); - return SUCCESS; + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_memory_observe(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC); + RETURN_MM_BOOL(zephir_get_boolval(&_0)); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, __construct) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, lastInsertId) { - zend_bool _22$$7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long width, height, ZEPHIR_LAST_CALL_STATUS; - zval *file_param = NULL, *width_param = NULL, *height_param = NULL, image, _0, _1, _32, _33, _34, _35, _36, _37, _38, _39, _40, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, _10$$3, _11$$3, _15$$3, _16$$3, _17$$3, _18$$3, _7$$4, _8$$4, _9$$4, _12$$5, _13$$5, _14$$5, _19$$6, _20$$6, _21$$6, _26$$7, _27$$7, _28$$7, _29$$7, _30$$7, _31$$7, _23$$8, _24$$8, _25$$8; - zval file; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, result, _0, _1, _2, _3; + zval name, _4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&file); - ZVAL_UNDEF(&image); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_32); - ZVAL_UNDEF(&_33); - ZVAL_UNDEF(&_34); - ZVAL_UNDEF(&_35); - ZVAL_UNDEF(&_36); - ZVAL_UNDEF(&_37); - ZVAL_UNDEF(&_38); - ZVAL_UNDEF(&_39); - ZVAL_UNDEF(&_40); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_10$$3); - ZVAL_UNDEF(&_11$$3); - ZVAL_UNDEF(&_15$$3); - ZVAL_UNDEF(&_16$$3); - ZVAL_UNDEF(&_17$$3); - ZVAL_UNDEF(&_18$$3); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_12$$5); - ZVAL_UNDEF(&_13$$5); - ZVAL_UNDEF(&_14$$5); - ZVAL_UNDEF(&_19$$6); - ZVAL_UNDEF(&_20$$6); - ZVAL_UNDEF(&_21$$6); - ZVAL_UNDEF(&_26$$7); - ZVAL_UNDEF(&_27$$7); - ZVAL_UNDEF(&_28$$7); - ZVAL_UNDEF(&_29$$7); - ZVAL_UNDEF(&_30$$7); - ZVAL_UNDEF(&_31$$7); - ZVAL_UNDEF(&_23$$8); - ZVAL_UNDEF(&_24$$8); - ZVAL_UNDEF(&_25$$8); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(file) + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_LONG_OR_NULL(width, is_null_true) - Z_PARAM_LONG_OR_NULL(height, is_null_true) + Z_PARAM_STR_OR_NULL(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &file_param, &width_param, &height_param); - zephir_get_strval(&file, file_param); - if (!width_param) { - width = 0; + zephir_fetch_params(1, 0, 1, &name_param); + if (!name_param) { + ZEPHIR_INIT_VAR(&name); } else { - } - if (!height_param) { - height = 0; + zephir_get_strval(&name, name_param); + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "lastInsertId"); + ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); + zephir_check_call_status(); + zephir_read_property(&_2, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&result, &_2, "lastinsertid", NULL, 0, &name); + zephir_check_call_status(); + zephir_read_property(&_3, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_3, "finish", NULL, 0); + zephir_check_call_status(); + zephir_cast_to_string(&_4, &result); + RETURN_CTOR(&_4); +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, perform) +{ + zend_string *_5; + zend_ulong _4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_6 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval values; + zval *statement_param = NULL, *values_param = NULL, name, sth, value, _0, _1, *_2, _3, _7; + zval statement; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&statement); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&sth); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&values); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(statement) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(values) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &statement_param, &values_param); + zephir_get_strval(&statement, statement_param); + if (!values_param) { + ZEPHIR_INIT_VAR(&values); + array_init(&values); } else { - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "check", NULL, 407); + zephir_get_arrval(&values, values_param); + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("file"), &file); - ZEPHIR_INIT_VAR(&_0); - object_init_ex(&_0, zephir_get_internal_ce(SL("imagick"))); - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "perform"); + ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); - if (1 == (zephir_file_exists(&_1) == SUCCESS)) { - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&_3$$3, "realpath", NULL, 74, &_2$$3); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("realpath"), &_3$$3); - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("realpath"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_5$$3, &_4$$3, "readimage", NULL, 0, &_6$$3); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_5$$3)) { - ZEPHIR_INIT_VAR(&_7$$4); - object_init_ex(&_7$$4, phalcon_image_exception_ce); - zephir_read_property(&_8$$4, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_9$$4); - ZEPHIR_CONCAT_SVS(&_9$$4, "Imagick::readImage ", &_8$$4, " failed"); - ZEPHIR_CALL_METHOD(NULL, &_7$$4, "__construct", NULL, 33, &_9$$4); - zephir_check_call_status(); - zephir_throw_exception_debug(&_7$$4, "phalcon/Image/Adapter/Imagick.zep", 72); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_read_property(&_10$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_11$$3, &_10$$3, "getimagealphachannel", NULL, 0); - zephir_check_call_status(); - if (!zephir_is_true(&_11$$3)) { - zephir_read_property(&_12$$5, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_13$$5); - ZVAL_STRING(&_13$$5, "Imagick::ALPHACHANNEL_SET"); - ZEPHIR_CALL_FUNCTION(&_14$$5, "constant", NULL, 119, &_13$$5); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_12$$5, "setimagealphachannel", NULL, 0, &_14$$5); + ZEPHIR_CALL_METHOD(&sth, this_ptr, "prepare", NULL, 0, &statement); + zephir_check_call_status(); + zephir_is_iterable(&values, 0, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 579); + if (Z_TYPE_P(&values) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&values), _4, _5, _2) + { + ZEPHIR_INIT_NVAR(&name); + if (_5 != NULL) { + ZVAL_STR_COPY(&name, _5); + } else { + ZVAL_LONG(&name, _4); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _2); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "performbind", &_6, 0, &sth, &name, &value); zephir_check_call_status(); - } - zephir_read_property(&_15$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_16$$3, &_15$$3, "getimagetype", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_16$$3); - zephir_read_property(&_17$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_18$$3, &_17$$3, "getimagetype", NULL, 0); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); zephir_check_call_status(); - if (ZEPHIR_IS_LONG(&_18$$3, 1)) { - zephir_read_property(&_19$$6, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&image, &_19$$6, "coalesceimages", NULL, 0); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &values, "valid", NULL, 0); zephir_check_call_status(); - zephir_read_property(&_20$$6, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_20$$6, "clear", NULL, 0); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&name, &values, "key", NULL, 0); zephir_check_call_status(); - zephir_read_property(&_21$$6, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_21$$6, "destroy", NULL, 0); + ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &image); - } - } else { - _22$$7 = 0 == width; - if (!(_22$$7)) { - _22$$7 = 0 == height; - } - if (_22$$7) { - ZEPHIR_INIT_VAR(&_23$$8); - object_init_ex(&_23$$8, phalcon_image_exception_ce); - zephir_read_property(&_24$$8, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_25$$8); - ZEPHIR_CONCAT_SV(&_25$$8, "Failed to create image from file ", &_24$$8); - ZEPHIR_CALL_METHOD(NULL, &_23$$8, "__construct", NULL, 33, &_25$$8); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "performbind", &_6, 0, &sth, &name, &value); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); zephir_check_call_status(); - zephir_throw_exception_debug(&_23$$8, "phalcon/Image/Adapter/Imagick.zep", 97); - ZEPHIR_MM_RESTORE(); - return; } - zephir_read_property(&_26$$7, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_27$$7); - object_init_ex(&_27$$7, zephir_get_internal_ce(SL("imagickpixel"))); - ZEPHIR_INIT_VAR(&_28$$7); - ZVAL_STRING(&_28$$7, "transparent"); - ZEPHIR_CALL_METHOD(NULL, &_27$$7, "__construct", NULL, 0, &_28$$7); - zephir_check_call_status(); - ZVAL_LONG(&_29$$7, width); - ZVAL_LONG(&_30$$7, height); - ZEPHIR_CALL_METHOD(NULL, &_26$$7, "newimage", NULL, 0, &_29$$7, &_30$$7, &_27$$7); - zephir_check_call_status(); - zephir_read_property(&_29$$7, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_28$$7); - ZVAL_STRING(&_28$$7, "png"); - ZEPHIR_CALL_METHOD(NULL, &_29$$7, "setformat", NULL, 0, &_28$$7); - zephir_check_call_status(); - zephir_read_property(&_30$$7, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_28$$7); - ZVAL_STRING(&_28$$7, "png"); - ZEPHIR_CALL_METHOD(NULL, &_30$$7, "setimageformat", NULL, 0, &_28$$7); - zephir_check_call_status(); - zephir_read_property(&_31$$7, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); - zephir_update_property_zval(this_ptr, ZEND_STRL("realpath"), &_31$$7); } - zephir_read_property(&_32, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_33, &_32, "getimagewidth", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_33); - zephir_read_property(&_34, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_35, &_34, "getimageheight", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_35); - zephir_read_property(&_36, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_37, &_36, "getimagetype", NULL, 0); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&name); + ZEPHIR_CALL_METHOD(NULL, &sth, "execute", NULL, 0); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_37); - zephir_read_property(&_38, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_39, &_38, "getimageformat", NULL, 0); + zephir_read_property(&_7, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_7, "finish", NULL, 0, &statement, &values); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_40); - ZEPHIR_CONCAT_SV(&_40, "image/", &_39); - zephir_update_property_zval(this_ptr, ZEND_STRL("mime"), &_40); - ZEPHIR_MM_RESTORE(); + RETURN_CCTOR(&sth); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, __destruct) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, prepare) { - zval _0, _1$$3, _2$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval options; + zval *statement_param = NULL, *options_param = NULL, sth, _0, _1, _2, _3, _4; + zval statement; zval *this_ptr = getThis(); + ZVAL_UNDEF(&statement); + ZVAL_UNDEF(&sth); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(statement) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_memory_observe(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC); - if (zephir_is_instance_of(&_0, SL("Imagick"))) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "clear", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_2$$3, "destroy", NULL, 0); - zephir_check_call_status(); + zephir_fetch_params(1, 1, 1, &statement_param, &options_param); + zephir_get_strval(&statement, statement_param); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); } - ZEPHIR_MM_RESTORE(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "prepare"); + ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); + zephir_check_call_status(); + zephir_read_property(&_2, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&sth, &_2, "prepare", NULL, 0, &statement, &options); + zephir_check_call_status(); + zephir_read_property(&_3, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_4, &sth, ZEND_STRL("queryString"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_3, "finish", NULL, 0, &_4); + zephir_check_call_status(); + RETURN_CCTOR(&sth); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, liquidRescale) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, query) { + zval _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL; - zval *width_param = NULL, *height_param = NULL, *deltaX_param = NULL, *rigidity_param = NULL, image, result, _0, _8, _9, _1$$3, _2$$3, _3$$3, _4$$3, _6$$3; - zend_long width, height, deltaX, rigidity, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *statement_param = NULL, sth, _0, _1, _3, _4, _5; + zval statement; zval *this_ptr = getThis(); - ZVAL_UNDEF(&image); - ZVAL_UNDEF(&result); + ZVAL_UNDEF(&statement); + ZVAL_UNDEF(&sth); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_6$$3); - ZEND_PARSE_PARAMETERS_START(2, 4) - Z_PARAM_LONG(width) - Z_PARAM_LONG(height) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(deltaX) - Z_PARAM_LONG(rigidity) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(statement) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 2, &width_param, &height_param, &deltaX_param, &rigidity_param); - if (!deltaX_param) { - deltaX = 0; - } else { - } - if (!rigidity_param) { - rigidity = 0; - } else { - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&image, &_0); - ZVAL_LONG(&_0, 0); - ZEPHIR_CALL_METHOD(NULL, &image, "setiteratorindex", NULL, 0, &_0); + zephir_fetch_params(1, 1, 0, &statement_param); + zephir_get_strval(&statement, statement_param); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); zephir_check_call_status(); - while (1) { - if (!(1)) { - break; - } - ZVAL_LONG(&_1$$3, width); - ZVAL_LONG(&_2$$3, height); - ZVAL_LONG(&_3$$3, deltaX); - ZVAL_LONG(&_4$$3, rigidity); - ZEPHIR_CALL_METHOD(&result, &image, "liquidrescaleimage", &_5, 0, &_1$$3, &_2$$3, &_3$$3, &_4$$3); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&result)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::liquidRescale failed", "phalcon/Image/Adapter/Imagick.zep", 165); - return; - } - ZEPHIR_CALL_METHOD(&_6$$3, &image, "nextimage", &_7, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_6$$3)) { - break; - } - } - ZEPHIR_CALL_METHOD(&_8, &image, "getimagewidth", NULL, 0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "query"); + ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_8); - ZEPHIR_CALL_METHOD(&_9, &image, "getimageheight", NULL, 0); + ZEPHIR_INIT_VAR(&_2); + zephir_create_array(&_2, 2, 0); + zephir_memory_observe(&_3); + zephir_read_property(&_3, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC); + zephir_array_fast_append(&_2, &_3); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "query"); + zephir_array_fast_append(&_2, &_1); + ZEPHIR_INIT_NVAR(&_1); + zephir_get_args(&_1); + ZEPHIR_INIT_VAR(&sth); + ZEPHIR_CALL_USER_FUNC_ARRAY(&sth, &_2, &_1); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_9); - RETURN_THIS(); + zephir_read_property(&_4, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_5, &sth, ZEND_STRL("queryString"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_4, "finish", NULL, 0, &_5); + zephir_check_call_status(); + RETURN_CCTOR(&sth); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, setResourceLimit) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, quote) { - zend_bool _0; + zval _0$$3, _7$$4, _11$$5; + zend_string *_6; + zend_ulong _5; + zval elements; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *type_param = NULL, *limit_param = NULL, _1$$3, _2$$3, _3$$3; - zend_long type, limit, ZEPHIR_LAST_CALL_STATUS; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *value, value_sub, *type_param = NULL, element, key, quotes, *_3, _4, _1$$3, _2$$3, _8$$4, _9$$4, _10$$4, _12$$5, _13$$5, _14$$5; zval *this_ptr = getThis(); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&key); + ZVAL_UNDEF("es); + ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZEND_PARSE_PARAMETERS_START(2, 2) + ZVAL_UNDEF(&_8$$4); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&_10$$4); + ZVAL_UNDEF(&_12$$5); + ZVAL_UNDEF(&_13$$5); + ZVAL_UNDEF(&_14$$5); + ZVAL_UNDEF(&elements); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_11$$5); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(value) + Z_PARAM_OPTIONAL Z_PARAM_LONG(type) - Z_PARAM_LONG(limit) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &type_param, &limit_param); - _0 = type >= 0; - if (_0) { - _0 = type <= 6; + zephir_fetch_params(1, 1, 1, &value, &type_param); + if (!type_param) { + type = 2; + } else { + } + ZEPHIR_INIT_VAR(&elements); + array_init(&elements); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&element, value); + ZEPHIR_CALL_METHOD("es, this_ptr, "getquotenames", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&element) != IS_ARRAY) { + zephir_cast_to_string(&_0$$3, &element); + ZEPHIR_CPY_WRT(&element, &_0$$3); + zephir_array_fetch_string(&_1$$3, "es, SL("prefix"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 664); + zephir_array_fetch_string(&_2$$3, "es, SL("suffix"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 664); + ZEPHIR_CONCAT_VVV(return_value, &_1$$3, &element, &_2$$3); + RETURN_MM(); } - if (_0) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_2$$3, type); - ZVAL_LONG(&_3$$3, limit); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "setresourcelimit", NULL, 0, &_2$$3, &_3$$3); - zephir_check_call_status(); + zephir_is_iterable(value, 0, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 673); + if (Z_TYPE_P(value) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(value), _5, _6, _3) + { + ZEPHIR_INIT_NVAR(&key); + if (_6 != NULL) { + ZVAL_STR_COPY(&key, _6); + } else { + ZVAL_LONG(&key, _5); + } + ZEPHIR_INIT_NVAR(&element); + ZVAL_COPY(&element, _3); + zephir_cast_to_string(&_7$$4, &element); + ZEPHIR_CPY_WRT(&element, &_7$$4); + zephir_array_fetch_string(&_8$$4, "es, SL("prefix"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 670); + zephir_array_fetch_string(&_9$$4, "es, SL("suffix"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 670); + ZEPHIR_INIT_NVAR(&_10$$4); + ZEPHIR_CONCAT_VVV(&_10$$4, &_8$$4, &element, &_9$$4); + zephir_array_update_zval(&elements, &key, &_10$$4, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Cannot set the Resource Type for this image", "phalcon/Image/Adapter/Imagick.zep", 201); - return; + ZEPHIR_CALL_METHOD(NULL, value, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_4, value, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_4)) { + break; + } + ZEPHIR_CALL_METHOD(&key, value, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&element, value, "current", NULL, 0); + zephir_check_call_status(); + zephir_cast_to_string(&_11$$5, &element); + ZEPHIR_CPY_WRT(&element, &_11$$5); + zephir_array_fetch_string(&_12$$5, "es, SL("prefix"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 670); + zephir_array_fetch_string(&_13$$5, "es, SL("suffix"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 670); + ZEPHIR_INIT_NVAR(&_14$$5); + ZEPHIR_CONCAT_VVV(&_14$$5, &_12$$5, &element, &_13$$5); + zephir_array_update_zval(&elements, &key, &_14$$5, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, value, "next", NULL, 0); + zephir_check_call_status(); + } } - ZEPHIR_MM_RESTORE(); + ZEPHIR_INIT_NVAR(&element); + ZEPHIR_INIT_NVAR(&key); + zephir_fast_join_str(return_value, SL(", "), &elements); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processBackground) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, rollBack) { + zval result, _0, _1, _2, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_6 = NULL, *_8 = NULL, *_11 = NULL, *_12 = NULL, *_13 = NULL, *_18 = NULL, *_20 = NULL, *_25 = NULL; - zval *red_param = NULL, *green_param = NULL, *blue_param = NULL, *opacity_param = NULL, background, color, pixel1, pixel2, result, _0, _1, _2, _3, _4$$3, _5$$3, _7$$3, _14$$3, _15$$3, _16$$3, _17$$3, _19$$3, _21$$3, _22$$3, _23$$3, _24$$3, _26$$3, _9$$4, _10$$4; - zend_long red, green, blue, opacity = 0, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&background); - ZVAL_UNDEF(&color); - ZVAL_UNDEF(&pixel1); - ZVAL_UNDEF(&pixel2); ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_14$$3); - ZVAL_UNDEF(&_15$$3); - ZVAL_UNDEF(&_16$$3); - ZVAL_UNDEF(&_17$$3); - ZVAL_UNDEF(&_19$$3); - ZVAL_UNDEF(&_21$$3); - ZVAL_UNDEF(&_22$$3); - ZVAL_UNDEF(&_23$$3); - ZVAL_UNDEF(&_24$$3); - ZVAL_UNDEF(&_26$$3); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_10$$4); - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_LONG(red) - Z_PARAM_LONG(green) - Z_PARAM_LONG(blue) - Z_PARAM_LONG(opacity) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 0, &red_param, &green_param, &blue_param, &opacity_param); - opacity /= 100; - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "rgb(%d, %d, %d)"); - ZVAL_LONG(&_1, red); - ZVAL_LONG(&_2, green); - ZVAL_LONG(&_3, blue); - ZEPHIR_CALL_FUNCTION(&color, "sprintf", NULL, 117, &_0, &_1, &_2, &_3); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&pixel1); - object_init_ex(&pixel1, zephir_get_internal_ce(SL("imagickpixel"))); - ZEPHIR_CALL_METHOD(NULL, &pixel1, "__construct", NULL, 0, &color); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&pixel2); - object_init_ex(&pixel2, zephir_get_internal_ce(SL("imagickpixel"))); - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, "transparent"); - ZEPHIR_CALL_METHOD(NULL, &pixel2, "__construct", NULL, 0, &_0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&background); - object_init_ex(&background, zephir_get_internal_ce(SL("imagick"))); - ZEPHIR_CALL_METHOD(NULL, &background, "__construct", NULL, 0); + + ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); zephir_check_call_status(); - zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_2, 0); - ZEPHIR_CALL_METHOD(NULL, &_1, "setiteratorindex", NULL, 0, &_2); + zephir_read_property(&_0, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "rollBack"); + ZEPHIR_CALL_METHOD(NULL, &_0, "start", NULL, 0, &_1); zephir_check_call_status(); - while (1) { - if (!(1)) { - break; - } - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &background, "newimage", &_6, 0, &_4$$3, &_5$$3, &pixel1); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_7$$3, &background, "getimagealphachannel", &_8, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_7$$3)) { - ZEPHIR_INIT_NVAR(&_9$$4); - ZVAL_STRING(&_9$$4, "Imagick::ALPHACHANNEL_SET"); - ZEPHIR_CALL_FUNCTION(&_10$$4, "constant", &_11, 119, &_9$$4); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &background, "setimagealphachannel", &_12, 0, &_10$$4); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(NULL, &background, "setimagebackgroundcolor", &_13, 0, &pixel2); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_14$$3); - ZVAL_STRING(&_14$$3, "Imagick::EVALUATE_MULTIPLY"); - ZEPHIR_CALL_FUNCTION(&_15$$3, "constant", &_11, 119, &_14$$3); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_14$$3); - ZVAL_STRING(&_14$$3, "Imagick::CHANNEL_ALPHA"); - ZEPHIR_CALL_FUNCTION(&_16$$3, "constant", &_11, 119, &_14$$3); - zephir_check_call_status(); - ZVAL_LONG(&_17$$3, opacity); - ZEPHIR_CALL_METHOD(NULL, &background, "evaluateimage", &_18, 0, &_15$$3, &_17$$3, &_16$$3); - zephir_check_call_status(); - zephir_read_property(&_17$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_19$$3, &_17$$3, "getcolorspace", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &background, "setcolorspace", &_20, 0, &_19$$3); - zephir_check_call_status(); - zephir_read_property(&_21$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_14$$3); - ZVAL_STRING(&_14$$3, "Imagick::COMPOSITE_DISSOLVE"); - ZEPHIR_CALL_FUNCTION(&_22$$3, "constant", &_11, 119, &_14$$3); - zephir_check_call_status(); - ZVAL_LONG(&_23$$3, 0); - ZVAL_LONG(&_24$$3, 0); - ZEPHIR_CALL_METHOD(&result, &background, "compositeimage", &_25, 0, &_21$$3, &_22$$3, &_23$$3, &_24$$3); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&result)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::compositeImage failed", "phalcon/Image/Adapter/Imagick.zep", 263); - return; - } - zephir_read_property(&_23$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_26$$3, &_23$$3, "nextimage", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_26$$3)) { - break; - } - } - zephir_read_property(&_2, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_2, "clear", NULL, 0); + zephir_read_property(&_2, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&result, &_2, "rollback", NULL, 0); zephir_check_call_status(); - zephir_read_property(&_3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_3, "destroy", NULL, 0); + zephir_read_property(&_3, this_ptr, ZEND_STRL("profiler"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_3, "finish", NULL, 0); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &background); - ZEPHIR_MM_RESTORE(); + RETURN_CCTOR(&result); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processBlur) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, setAttribute) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *radius_param = NULL, _0, _1, _2$$3, _3$$3, _4$$3, _5$$3; - zend_long radius, ZEPHIR_LAST_CALL_STATUS; + zval *attribute_param = NULL, *value, value_sub, _0, _1; + zend_long attribute, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); + ZVAL_UNDEF(&value_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(radius) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_LONG(attribute) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &radius_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_1, 0); - ZEPHIR_CALL_METHOD(NULL, &_0, "setiteratorindex", NULL, 0, &_1); + zephir_fetch_params(1, 2, 0, &attribute_param, &value); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "connect", NULL, 0); zephir_check_call_status(); - while (1) { - if (!(1)) { - break; - } - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_3$$3, radius); - ZVAL_LONG(&_4$$3, 100); - ZEPHIR_CALL_METHOD(NULL, &_2$$3, "blurimage", NULL, 0, &_3$$3, &_4$$3); - zephir_check_call_status(); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_5$$3, &_3$$3, "nextimage", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_5$$3)) { - break; - } - } - ZEPHIR_MM_RESTORE(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("pdo"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1, attribute); + ZEPHIR_RETURN_CALL_METHOD(&_0, "setattribute", NULL, 0, &_1, value); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processCrop) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, setProfiler) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL, *_6 = NULL, *_8 = NULL; - zval *width_param = NULL, *height_param = NULL, *offsetX_param = NULL, *offsetY_param = NULL, image, _0, _9, _10, _1$$3, _2$$3, _3$$3, _4$$3, _7$$3; - zend_long width, height, offsetX, offsetY, ZEPHIR_LAST_CALL_STATUS; + zval *profiler, profiler_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&image); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&profiler_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(profiler, phalcon_datamapper_pdo_profiler_profilerinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &profiler); + zephir_update_property_zval(this_ptr, ZEND_STRL("profiler"), profiler); +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, performBind) +{ + zend_bool _1$$4; + zval _8, _5$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, _0$$3; + zval *statement, statement_sub, *name, name_sub, *arguments, arguments_sub, key, parameters, type, _7, _9, _2$$4, _3$$7, _4$$7, _6$$8; + + ZVAL_UNDEF(&statement_sub); + ZVAL_UNDEF(&name_sub); + ZVAL_UNDEF(&arguments_sub); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(¶meters); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&_7); ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_7$$3); - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_LONG(width) - Z_PARAM_LONG(height) - Z_PARAM_LONG(offsetX) - Z_PARAM_LONG(offsetY) + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$7); + ZVAL_UNDEF(&_4$$7); + ZVAL_UNDEF(&_6$$8); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_5$$4); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_OBJECT_OF_CLASS(statement, zephir_get_internal_ce(SL("pdostatement"))) + Z_PARAM_ZVAL(name) + Z_PARAM_ZVAL(arguments) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 0, &width_param, &height_param, &offsetX_param, &offsetY_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&image, &_0); - ZVAL_LONG(&_0, 0); - ZEPHIR_CALL_METHOD(NULL, &image, "setiteratorindex", NULL, 0, &_0); - zephir_check_call_status(); - while (1) { - if (!(1)) { - break; + zephir_fetch_params(1, 3, 0, &statement, &name, &arguments); + ZEPHIR_SEPARATE_PARAM(arguments); + ZEPHIR_CPY_WRT(&key, name); + if (Z_TYPE_P(&key) == IS_LONG) { + _0$$3 = (zephir_get_numberval(&key) + 1); + ZEPHIR_INIT_NVAR(&key); + ZVAL_LONG(&key, _0$$3); + } + if (Z_TYPE_P(arguments) == IS_ARRAY) { + if (zephir_array_isset_long(arguments, 1)) { + zephir_memory_observe(&type); + zephir_array_fetch_long(&type, arguments, 1, PH_NOISY, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 743); + } else { + ZEPHIR_INIT_NVAR(&type); + ZVAL_LONG(&type, 2); } - ZVAL_LONG(&_1$$3, width); - ZVAL_LONG(&_2$$3, height); - ZVAL_LONG(&_3$$3, offsetX); - ZVAL_LONG(&_4$$3, offsetY); - ZEPHIR_CALL_METHOD(NULL, &image, "cropimage", &_5, 0, &_1$$3, &_2$$3, &_3$$3, &_4$$3); - zephir_check_call_status(); - ZVAL_LONG(&_1$$3, width); - ZVAL_LONG(&_2$$3, height); - ZVAL_LONG(&_3$$3, 0); - ZVAL_LONG(&_4$$3, 0); - ZEPHIR_CALL_METHOD(NULL, &image, "setimagepage", &_6, 0, &_1$$3, &_2$$3, &_3$$3, &_4$$3); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_7$$3, &image, "nextimage", &_8, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_7$$3)) { - break; + _1$$4 = ZEPHIR_IS_LONG_IDENTICAL(&type, 5); + if (_1$$4) { + zephir_memory_observe(&_2$$4); + zephir_array_fetch_long(&_2$$4, arguments, 0, PH_NOISY, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 748); + _1$$4 = ((Z_TYPE_P(&_2$$4) == IS_TRUE || Z_TYPE_P(&_2$$4) == IS_FALSE) == 1); + } + if (_1$$4) { + ZEPHIR_INIT_VAR(&_3$$7); + zephir_array_fetch_long(&_4$$7, arguments, 0, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Pdo/Connection/AbstractConnection.zep", 749); + if (zephir_is_true(&_4$$7)) { + ZEPHIR_INIT_NVAR(&_3$$7); + ZVAL_STRING(&_3$$7, "1"); + } else { + ZEPHIR_INIT_NVAR(&_3$$7); + ZVAL_STRING(&_3$$7, "0"); + } + zephir_array_update_long(arguments, 0, &_3$$7, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); } + ZEPHIR_INIT_VAR(&_5$$4); + zephir_create_array(&_5$$4, 1, 0); + zephir_array_fast_append(&_5$$4, &key); + ZEPHIR_INIT_VAR(¶meters); + zephir_fast_array_merge(¶meters, &_5$$4, arguments); + } else { + ZEPHIR_INIT_VAR(&_6$$8); + zephir_create_array(&_6$$8, 2, 0); + zephir_array_fast_append(&_6$$8, &key); + zephir_array_fast_append(&_6$$8, arguments); + ZEPHIR_CPY_WRT(¶meters, &_6$$8); } - ZEPHIR_CALL_METHOD(&_9, &image, "getimagewidth", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_9); - ZEPHIR_CALL_METHOD(&_10, &image, "getimageheight", NULL, 0); + ZEPHIR_INIT_VAR(&_7); + ZEPHIR_INIT_VAR(&_8); + zephir_create_array(&_8, 2, 0); + zephir_array_fast_append(&_8, statement); + ZEPHIR_INIT_VAR(&_9); + ZVAL_STRING(&_9, "bindValue"); + zephir_array_fast_append(&_8, &_9); + ZEPHIR_CALL_USER_FUNC_ARRAY(&_7, &_8, ¶meters); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_10); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processFlip) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_AbstractConnection, fetchData) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *direction_param = NULL, method, _0, _1, _2$$3, _3$$3, _4$$3; - zend_long direction, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval arguments, values, _0; + zval *method_param = NULL, *arguments_param = NULL, *statement_param = NULL, *values_param = NULL, result, sth; + zval method, statement; zval *this_ptr = getThis(); ZVAL_UNDEF(&method); + ZVAL_UNDEF(&statement); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&sth); + ZVAL_UNDEF(&arguments); + ZVAL_UNDEF(&values); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(direction) + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_STR(method) + Z_PARAM_ARRAY(arguments) + Z_PARAM_STR(statement) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(values) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &direction_param); - if (direction == 11) { - ZEPHIR_INIT_VAR(&method); - ZVAL_STRING(&method, "flipImage"); + zephir_fetch_params(1, 3, 1, &method_param, &arguments_param, &statement_param, &values_param); + zephir_get_strval(&method, method_param); + zephir_get_arrval(&arguments, arguments_param); + zephir_get_strval(&statement, statement_param); + if (!values_param) { + ZEPHIR_INIT_VAR(&values); + array_init(&values); } else { - ZEPHIR_INIT_NVAR(&method); - ZVAL_STRING(&method, "flopImage"); + zephir_get_arrval(&values, values_param); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_1, 0); - ZEPHIR_CALL_METHOD(NULL, &_0, "setiteratorindex", NULL, 0, &_1); + ZEPHIR_CALL_METHOD(&sth, this_ptr, "perform", NULL, 0, &statement, &values); zephir_check_call_status(); - while (1) { - if (!(1)) { - break; - } - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD_ZVAL(NULL, &_2$$3, &method, NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_4$$3, &_3$$3, "nextimage", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_4$$3)) { - break; - } + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 2, 0); + zephir_array_fast_append(&_0, &sth); + zephir_array_fast_append(&_0, &method); + ZEPHIR_INIT_VAR(&result); + ZEPHIR_CALL_USER_FUNC_ARRAY(&result, &_0, &arguments); + zephir_check_call_status(); + if (Z_TYPE_P(&result) != IS_ARRAY) { + ZEPHIR_INIT_NVAR(&result); + array_init(&result); } - ZEPHIR_MM_RESTORE(); + RETURN_CCTOR(&result); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processMask) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\DataMapper\\Pdo\\Connection, ConnectionInterface, phalcon, datamapper_pdo_connection_connectioninterface, phalcon_datamapper_pdo_connection_connectioninterface_method_entry); + + zend_class_implements(phalcon_datamapper_pdo_connection_connectioninterface_ce, 1, phalcon_datamapper_pdo_connection_pdointerface_ce); + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, connect); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, disconnect); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchAffected); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchAll); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchAssoc); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchColumn); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchGroup); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchObject); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchObjects); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchOne); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchPairs); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, fetchValue); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, getAdapter); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, getProfiler); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, isConnected); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, perform); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_ConnectionInterface, setProfiler); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Connection_Decorated) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Pdo\\Connection, Decorated, phalcon, datamapper_pdo_connection_decorated, phalcon_datamapper_pdo_connection_abstractconnection_ce, phalcon_datamapper_pdo_connection_decorated_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_Decorated, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *image, image_sub, mask, result, _0, _1, _2, _3$$3, _4$$3, _5$$3, _6$$3, _8$$3, _9$$3, _10$$3; + zval *pdo, pdo_sub, *profiler = NULL, profiler_sub, __$null; zval *this_ptr = getThis(); - ZVAL_UNDEF(&image_sub); - ZVAL_UNDEF(&mask); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_9$$3); - ZVAL_UNDEF(&_10$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(image, phalcon_image_adapter_adapterinterface_ce) + ZVAL_UNDEF(&pdo_sub); + ZVAL_UNDEF(&profiler_sub); + ZVAL_NULL(&__$null); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(pdo, php_pdo_get_dbh_ce()) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(profiler, phalcon_datamapper_pdo_profiler_profilerinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &image); - ZEPHIR_INIT_VAR(&mask); - object_init_ex(&mask, zephir_get_internal_ce(SL("imagick"))); - ZEPHIR_CALL_METHOD(NULL, &mask, "__construct", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, image, "render", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &mask, "readimageblob", NULL, 0, &_0); - zephir_check_call_status(); - zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_2, 0); - ZEPHIR_CALL_METHOD(NULL, &_1, "setiteratorindex", NULL, 0, &_2); - zephir_check_call_status(); - while (1) { - if (!(1)) { - break; - } - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_BOOL(&_4$$3, 1); - ZEPHIR_CALL_METHOD(NULL, &_3$$3, "setimagematte", NULL, 0, &_4$$3); - zephir_check_call_status(); - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_5$$3); - ZVAL_STRING(&_5$$3, "Imagick::COMPOSITE_DSTIN"); - ZEPHIR_CALL_FUNCTION(&_6$$3, "constant", &_7, 119, &_5$$3); - zephir_check_call_status(); - ZVAL_LONG(&_8$$3, 0); - ZVAL_LONG(&_9$$3, 0); - ZEPHIR_CALL_METHOD(&result, &_4$$3, "compositeimage", NULL, 0, &mask, &_6$$3, &_8$$3, &_9$$3); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&result)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::compositeImage failed", "phalcon/Image/Adapter/Imagick.zep", 388); - return; - } - zephir_read_property(&_8$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_10$$3, &_8$$3, "nextimage", NULL, 0); + zephir_fetch_params(1, 1, 1, &pdo, &profiler); + if (!profiler) { + profiler = &profiler_sub; + ZEPHIR_CPY_WRT(profiler, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(profiler); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("pdo"), pdo); + if (Z_TYPE_P(profiler) == IS_NULL) { + ZEPHIR_INIT_NVAR(profiler); + object_init_ex(profiler, phalcon_datamapper_pdo_profiler_profiler_ce); + ZEPHIR_CALL_METHOD(NULL, profiler, "__construct", NULL, 201); zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_10$$3)) { - break; - } } - ZEPHIR_CALL_METHOD(NULL, &mask, "clear", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &mask, "destroy", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setprofiler", NULL, 0, profiler); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processPixelate) +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_Decorated, connect) +{ + +} + +static PHP_METHOD(Phalcon_DataMapper_Pdo_Connection_Decorated, disconnect) +{ + + ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_datamapper_pdo_exception_cannotdisconnect_ce, "Cannot disconnect a Decorated connection instance", "phalcon/DataMapper/Pdo/Connection/Decorated.zep", 66); + return; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Pdo_Connection_PdoInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\DataMapper\\Pdo\\Connection, PdoInterface, phalcon, datamapper_pdo_connection_pdointerface, phalcon_datamapper_pdo_connection_pdointerface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, beginTransaction); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, commit); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, errorCode); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, errorInfo); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, exec); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, getAttribute); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, getAvailableDrivers); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, inTransaction); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, lastInsertId); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, prepare); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, query); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, quote); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, rollBack); +ZEPHIR_DOC_METHOD(Phalcon_DataMapper_Pdo_Connection_PdoInterface, setAttribute); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Query_AbstractConditions) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Query, AbstractConditions, phalcon, datamapper_query_abstractconditions, phalcon_datamapper_query_abstractquery_ce, phalcon_datamapper_query_abstractconditions_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, limit) { - double height = 0, width = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *amount_param = NULL, _0, _1, _2, _3, _4$$3, _5$$3, _6$$3, _7$$3, _8$$3, _9$$3; - zend_long amount, ZEPHIR_LAST_CALL_STATUS; + zval *limit_param = NULL, _0, _1; + zend_long limit; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_9$$3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(amount) + Z_PARAM_LONG(limit) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &amount_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - width = (zephir_safe_div_zval_long(&_0, amount)); - zephir_read_property(&_1, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - height = (zephir_safe_div_zval_long(&_1, amount)); - zephir_read_property(&_2, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_3, 0); - ZEPHIR_CALL_METHOD(NULL, &_2, "setiteratorindex", NULL, 0, &_3); - zephir_check_call_status(); - while (1) { - if (!(1)) { - break; - } - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_DOUBLE(&_5$$3, width); - ZVAL_DOUBLE(&_6$$3, height); - ZEPHIR_CALL_METHOD(NULL, &_4$$3, "scaleimage", NULL, 0, &_5$$3, &_6$$3); - zephir_check_call_status(); - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_7$$3, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_5$$3, "scaleimage", NULL, 0, &_6$$3, &_7$$3); - zephir_check_call_status(); - zephir_read_property(&_8$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_9$$3, &_8$$3, "nextimage", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_9$$3)) { - break; - } - } - ZEPHIR_MM_RESTORE(); + zephir_fetch_params(1, 1, 0, &limit_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "LIMIT"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_LONG(&_1, limit); + zephir_update_property_array(this_ptr, SL("store"), &_0, &_1); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processReflection) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, offset) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL, *_11 = NULL, *_13 = NULL, *_14 = NULL, *_20 = NULL, *_23 = NULL, *_26 = NULL, *_33 = NULL, *_36 = NULL, *_38 = NULL, *_41 = NULL, *_46 = NULL, *_53 = NULL; - zend_bool fadeIn, _54$$13; - zval *height_param = NULL, *opacity_param = NULL, *fadeIn_param = NULL, fade, image, pixel, pseudo, reflection, result, _0, _4, _16, _17, _28, _29, _30, _56, _57, _58, _59, _60, _1$$3, _2$$4, _3$$4, _6$$5, _8$$5, _9$$5, _10$$5, _12$$5, _15$$5, _18$$7, _19$$7, _21$$7, _22$$7, _24$$7, _25$$7, _27$$7, _31$$10, _32$$10, _34$$10, _35$$10, _37$$10, _39$$10, _40$$10, _42$$10, _43$$10, _44$$10, _45$$10, _47$$10, _48$$13, _49$$13, _50$$13, _51$$13, _52$$13, _55$$13; - zend_long height, opacity, ZEPHIR_LAST_CALL_STATUS; + zval *offset_param = NULL, _0, _1; + zend_long offset; zval *this_ptr = getThis(); - ZVAL_UNDEF(&fade); - ZVAL_UNDEF(&image); - ZVAL_UNDEF(&pixel); - ZVAL_UNDEF(&pseudo); - ZVAL_UNDEF(&reflection); - ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_16); - ZVAL_UNDEF(&_17); - ZVAL_UNDEF(&_28); - ZVAL_UNDEF(&_29); - ZVAL_UNDEF(&_30); - ZVAL_UNDEF(&_56); - ZVAL_UNDEF(&_57); - ZVAL_UNDEF(&_58); - ZVAL_UNDEF(&_59); - ZVAL_UNDEF(&_60); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_8$$5); - ZVAL_UNDEF(&_9$$5); - ZVAL_UNDEF(&_10$$5); - ZVAL_UNDEF(&_12$$5); - ZVAL_UNDEF(&_15$$5); - ZVAL_UNDEF(&_18$$7); - ZVAL_UNDEF(&_19$$7); - ZVAL_UNDEF(&_21$$7); - ZVAL_UNDEF(&_22$$7); - ZVAL_UNDEF(&_24$$7); - ZVAL_UNDEF(&_25$$7); - ZVAL_UNDEF(&_27$$7); - ZVAL_UNDEF(&_31$$10); - ZVAL_UNDEF(&_32$$10); - ZVAL_UNDEF(&_34$$10); - ZVAL_UNDEF(&_35$$10); - ZVAL_UNDEF(&_37$$10); - ZVAL_UNDEF(&_39$$10); - ZVAL_UNDEF(&_40$$10); - ZVAL_UNDEF(&_42$$10); - ZVAL_UNDEF(&_43$$10); - ZVAL_UNDEF(&_44$$10); - ZVAL_UNDEF(&_45$$10); - ZVAL_UNDEF(&_47$$10); - ZVAL_UNDEF(&_48$$13); - ZVAL_UNDEF(&_49$$13); - ZVAL_UNDEF(&_50$$13); - ZVAL_UNDEF(&_51$$13); - ZVAL_UNDEF(&_52$$13); - ZVAL_UNDEF(&_55$$13); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_LONG(height) - Z_PARAM_LONG(opacity) - Z_PARAM_BOOL(fadeIn) + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(offset) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &height_param, &opacity_param, &fadeIn_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("version"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&reflection); - if (ZEPHIR_GE_LONG(&_0, 30100)) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - if (zephir_clone(&reflection, &_1$$3) == FAILURE) { - RETURN_MM(); - } - } else { - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_3$$4, &_2$$4, "clone", NULL, 0); - zephir_check_call_status(); - if (zephir_clone(&reflection, &_3$$4) == FAILURE) { - RETURN_MM(); - } - } - ZVAL_LONG(&_4, 0); - ZEPHIR_CALL_METHOD(NULL, &reflection, "setiteratorindex", NULL, 0, &_4); - zephir_check_call_status(); - while (1) { - if (!(1)) { - break; - } - ZEPHIR_CALL_METHOD(NULL, &reflection, "flipimage", &_5, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_6$$5, &reflection, "getimagewidth", &_7, 0); - zephir_check_call_status(); - ZVAL_LONG(&_8$$5, height); - ZVAL_LONG(&_9$$5, 0); - ZVAL_LONG(&_10$$5, 0); - ZEPHIR_CALL_METHOD(NULL, &reflection, "cropimage", &_11, 0, &_6$$5, &_8$$5, &_9$$5, &_10$$5); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_12$$5, &reflection, "getimagewidth", &_13, 0); - zephir_check_call_status(); - ZVAL_LONG(&_8$$5, height); - ZVAL_LONG(&_9$$5, 0); - ZVAL_LONG(&_10$$5, 0); - ZEPHIR_CALL_METHOD(NULL, &reflection, "setimagepage", &_14, 0, &_12$$5, &_8$$5, &_9$$5, &_10$$5); - zephir_check_call_status(); - zephir_read_property(&_8$$5, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_15$$5, &_8$$5, "nextimage", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_15$$5)) { - break; - } - } - if (fadeIn) { - ZEPHIR_INIT_VAR(&pseudo); - ZVAL_STRING(&pseudo, "gradient:black-transparent"); - } else { - ZEPHIR_INIT_NVAR(&pseudo); - ZVAL_STRING(&pseudo, "gradient:transparent-black"); - } - ZEPHIR_INIT_VAR(&fade); - object_init_ex(&fade, zephir_get_internal_ce(SL("imagick"))); - ZEPHIR_CALL_METHOD(NULL, &fade, "__construct", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_16, &reflection, "getimagewidth", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_17, &reflection, "getimageheight", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &fade, "newpseudoimage", NULL, 0, &_16, &_17, &pseudo); - zephir_check_call_status(); - opacity /= 100; - ZVAL_LONG(&_4, 0); - ZEPHIR_CALL_METHOD(NULL, &reflection, "setiteratorindex", NULL, 0, &_4); - zephir_check_call_status(); - while (1) { - if (!(1)) { - break; - } - ZEPHIR_INIT_NVAR(&_18$$7); - ZVAL_STRING(&_18$$7, "Imagick::COMPOSITE_DSTOUT"); - ZEPHIR_CALL_FUNCTION(&_19$$7, "constant", &_20, 119, &_18$$7); - zephir_check_call_status(); - ZVAL_LONG(&_21$$7, 0); - ZVAL_LONG(&_22$$7, 0); - ZEPHIR_CALL_METHOD(&result, &reflection, "compositeimage", &_23, 0, &fade, &_19$$7, &_21$$7, &_22$$7); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&result)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::compositeImage failed", "phalcon/Image/Adapter/Imagick.zep", 495); - return; - } - ZEPHIR_INIT_NVAR(&_18$$7); - ZVAL_STRING(&_18$$7, "Imagick::EVALUATE_MULTIPLY"); - ZEPHIR_CALL_FUNCTION(&_24$$7, "constant", &_20, 119, &_18$$7); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_18$$7); - ZVAL_STRING(&_18$$7, "Imagick::CHANNEL_ALPHA"); - ZEPHIR_CALL_FUNCTION(&_25$$7, "constant", &_20, 119, &_18$$7); - zephir_check_call_status(); - ZVAL_LONG(&_21$$7, opacity); - ZEPHIR_CALL_METHOD(NULL, &reflection, "evaluateimage", &_26, 0, &_24$$7, &_21$$7, &_25$$7); - zephir_check_call_status(); - zephir_read_property(&_21$$7, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_27$$7, &_21$$7, "nextimage", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_27$$7)) { - break; - } - } - ZEPHIR_CALL_METHOD(NULL, &fade, "destroy", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&image); - object_init_ex(&image, zephir_get_internal_ce(SL("imagick"))); - ZEPHIR_CALL_METHOD(NULL, &image, "__construct", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&pixel); - object_init_ex(&pixel, zephir_get_internal_ce(SL("imagickpixel"))); - ZEPHIR_CALL_METHOD(NULL, &pixel, "__construct", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_28, &_4, "getimageheight", NULL, 0); - zephir_check_call_status(); - height = (zephir_get_numberval(&_28) + height); - zephir_read_property(&_29, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_30, 0); - ZEPHIR_CALL_METHOD(NULL, &_29, "setiteratorindex", NULL, 0, &_30); - zephir_check_call_status(); - while (1) { - if (!(1)) { - break; - } - zephir_read_property(&_31$$10, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_32$$10, height); - ZEPHIR_CALL_METHOD(NULL, &image, "newimage", &_33, 0, &_31$$10, &_32$$10, &pixel); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_34$$10); - ZVAL_STRING(&_34$$10, "Imagick::ALPHACHANNEL_SET"); - ZEPHIR_CALL_FUNCTION(&_35$$10, "constant", &_20, 119, &_34$$10); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &image, "setimagealphachannel", &_36, 0, &_35$$10); - zephir_check_call_status(); - zephir_read_property(&_32$$10, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_37$$10, &_32$$10, "getcolorspace", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &image, "setcolorspace", &_38, 0, &_37$$10); - zephir_check_call_status(); - zephir_read_property(&_39$$10, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_40$$10, &_39$$10, "getimagedelay", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &image, "setimagedelay", &_41, 0, &_40$$10); - zephir_check_call_status(); - zephir_read_property(&_42$$10, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_34$$10); - ZVAL_STRING(&_34$$10, "Imagick::COMPOSITE_SRC"); - ZEPHIR_CALL_FUNCTION(&_43$$10, "constant", &_20, 119, &_34$$10); - zephir_check_call_status(); - ZVAL_LONG(&_44$$10, 0); - ZVAL_LONG(&_45$$10, 0); - ZEPHIR_CALL_METHOD(&result, &image, "compositeimage", &_46, 0, &_42$$10, &_43$$10, &_44$$10, &_45$$10); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&result)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::compositeImage failed", "phalcon/Image/Adapter/Imagick.zep", 534); - return; - } - zephir_read_property(&_44$$10, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_47$$10, &_44$$10, "nextimage", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_47$$10)) { - break; - } - } - ZVAL_LONG(&_30, 0); - ZEPHIR_CALL_METHOD(NULL, &image, "setiteratorindex", NULL, 0, &_30); - zephir_check_call_status(); - ZVAL_LONG(&_30, 0); - ZEPHIR_CALL_METHOD(NULL, &reflection, "setiteratorindex", NULL, 0, &_30); - zephir_check_call_status(); - while (1) { - if (!(1)) { - break; - } - ZEPHIR_INIT_NVAR(&_48$$13); - ZVAL_STRING(&_48$$13, "Imagick::COMPOSITE_OVER"); - ZEPHIR_CALL_FUNCTION(&_49$$13, "constant", &_20, 119, &_48$$13); - zephir_check_call_status(); - zephir_read_property(&_50$$13, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_51$$13, 0); - ZEPHIR_CALL_METHOD(&result, &image, "compositeimage", &_46, 0, &reflection, &_49$$13, &_51$$13, &_50$$13); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&result)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::compositeImage failed", "phalcon/Image/Adapter/Imagick.zep", 554); - return; - } - ZEPHIR_CALL_METHOD(&_52$$13, &image, "nextimage", &_53, 0); - zephir_check_call_status(); - _54$$13 = !ZEPHIR_IS_TRUE_IDENTICAL(&_52$$13); - if (!(_54$$13)) { - ZEPHIR_CALL_METHOD(&_55$$13, &reflection, "nextimage", NULL, 0); - zephir_check_call_status(); - _54$$13 = !ZEPHIR_IS_TRUE_IDENTICAL(&_55$$13); - } - if (_54$$13) { - break; - } + zephir_fetch_params(1, 1, 0, &offset_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "OFFSET"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_LONG(&_1, offset); + zephir_update_property_array(this_ptr, SL("store"), &_0, &_1); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, andWhere) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _0; + zval condition; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&condition); + ZVAL_UNDEF(&value_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(condition) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(value) + Z_PARAM_LONG(type) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &condition_param, &value, &type_param); + zephir_get_strval(&condition, condition_param); + if (!value) { + value = &value_sub; + value = &__$null; } - ZEPHIR_CALL_METHOD(NULL, &reflection, "destroy", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_30, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_30, "clear", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_56, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_56, "destroy", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &image); - zephir_read_property(&_57, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_58, &_57, "getimagewidth", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_58); - zephir_read_property(&_59, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_60, &_59, "getimageheight", NULL, 0); + if (!type_param) { + type = -1; + } else { + } + ZVAL_LONG(&_0, type); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "where", NULL, 0, &condition, value, &_0); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_60); - ZEPHIR_MM_RESTORE(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processRender) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, appendWhere) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long quality, ZEPHIR_LAST_CALL_STATUS; - zval *extension_param = NULL, *quality_param = NULL, image, _0, _1, _2, _3, _4, _5$$4, _6$$4, _7$$4; - zval extension; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _0, _1; + zval condition; zval *this_ptr = getThis(); - ZVAL_UNDEF(&extension); - ZVAL_UNDEF(&image); + ZVAL_UNDEF(&condition); + ZVAL_UNDEF(&value_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(extension) - Z_PARAM_LONG(quality) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(condition) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(value) + Z_PARAM_LONG(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &extension_param, &quality_param); - zephir_get_strval(&extension, extension_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&image, &_0); - ZEPHIR_CALL_METHOD(NULL, &image, "setformat", NULL, 0, &extension); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &image, "setimageformat", NULL, 0, &extension); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &image, "stripimage", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, &image, "getimagetype", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_1); - ZEPHIR_CALL_METHOD(&_2, &image, "getimageformat", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_3); - ZEPHIR_CONCAT_SV(&_3, "image/", &_2); - zephir_update_property_zval(this_ptr, ZEND_STRL("mime"), &_3); - ZEPHIR_INIT_VAR(&_4); - zephir_fast_strtolower(&_4, &extension); - zephir_get_strval(&extension, &_4); - do { - if (ZEPHIR_IS_STRING(&extension, "gif")) { - ZEPHIR_CALL_METHOD(NULL, &image, "optimizeimagelayers", NULL, 0); - zephir_check_call_status(); - break; - } - if (ZEPHIR_IS_STRING(&extension, "jpg") || ZEPHIR_IS_STRING(&extension, "jpeg")) { - ZEPHIR_INIT_VAR(&_5$$4); - ZVAL_STRING(&_5$$4, "Imagick::COMPRESSION_JPEG"); - ZEPHIR_CALL_FUNCTION(&_6$$4, "constant", NULL, 119, &_5$$4); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &image, "setimagecompression", NULL, 0, &_6$$4); - zephir_check_call_status(); - ZVAL_LONG(&_7$$4, quality); - ZEPHIR_CALL_METHOD(NULL, &image, "setimagecompressionquality", NULL, 0, &_7$$4); - zephir_check_call_status(); + zephir_fetch_params(1, 1, 2, &condition_param, &value, &type_param); + zephir_get_strval(&condition, condition_param); + if (!value) { + value = &value_sub; + value = &__$null; + } + if (!type_param) { + type = -1; + } else { } - } while(0); - - ZEPHIR_RETURN_CALL_METHOD(&image, "getimageblob", NULL, 0); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "WHERE"); + ZVAL_LONG(&_1, type); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendcondition", NULL, 0, &_0, &condition, value, &_1); zephir_check_call_status(); - RETURN_MM(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processResize) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, orderBy) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL, *_5 = NULL; - zval *width_param = NULL, *height_param = NULL, image, _0, _6, _7, _1$$3, _2$$3, _4$$3; - zend_long width, height, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *orderBy, orderBy_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&image); + ZVAL_UNDEF(&orderBy_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$3); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_LONG(width) - Z_PARAM_LONG(height) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(orderBy) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &width_param, &height_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&image, &_0); - ZVAL_LONG(&_0, 0); - ZEPHIR_CALL_METHOD(NULL, &image, "setiteratorindex", NULL, 0, &_0); - zephir_check_call_status(); - while (1) { - if (!(1)) { - break; - } - ZVAL_LONG(&_1$$3, width); - ZVAL_LONG(&_2$$3, height); - ZEPHIR_CALL_METHOD(NULL, &image, "scaleimage", &_3, 0, &_1$$3, &_2$$3); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$3, &image, "nextimage", &_5, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_4$$3)) { - break; - } - } - ZEPHIR_CALL_METHOD(&_6, &image, "getimagewidth", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_6); - ZEPHIR_CALL_METHOD(&_7, &image, "getimageheight", NULL, 0); + zephir_fetch_params(1, 1, 0, &orderBy); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "ORDER"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processvalue", NULL, 0, &_0, orderBy); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_7); - ZEPHIR_MM_RESTORE(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processRotate) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, orWhere) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *degrees_param = NULL, pixel, _0, _1, _9, _10, _11, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, _7$$3, _8$$3; - zend_long degrees, ZEPHIR_LAST_CALL_STATUS; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _0, _1, _2; + zval condition; zval *this_ptr = getThis(); - ZVAL_UNDEF(&pixel); + ZVAL_UNDEF(&condition); + ZVAL_UNDEF(&value_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_8$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(degrees) + ZVAL_UNDEF(&_2); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(condition) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(value) + Z_PARAM_LONG(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, °rees_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_1, 0); - ZEPHIR_CALL_METHOD(NULL, &_0, "setiteratorindex", NULL, 0, &_1); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&pixel); - object_init_ex(&pixel, zephir_get_internal_ce(SL("imagickpixel"))); - ZEPHIR_CALL_METHOD(NULL, &pixel, "__construct", NULL, 0); - zephir_check_call_status(); - while (1) { - if (!(1)) { - break; - } - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_3$$3, degrees); - ZEPHIR_CALL_METHOD(NULL, &_2$$3, "rotateimage", NULL, 0, &pixel, &_3$$3); - zephir_check_call_status(); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_6$$3, 0); - ZVAL_LONG(&_7$$3, 0); - ZEPHIR_CALL_METHOD(NULL, &_3$$3, "setimagepage", NULL, 0, &_4$$3, &_5$$3, &_6$$3, &_7$$3); - zephir_check_call_status(); - zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_8$$3, &_6$$3, "nextimage", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_8$$3)) { - break; - } + zephir_fetch_params(1, 1, 2, &condition_param, &value, &type_param); + zephir_get_strval(&condition, condition_param); + if (!value) { + value = &value_sub; + value = &__$null; } - zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_9, &_1, "getimagewidth", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_9); - zephir_read_property(&_10, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_11, &_10, "getimageheight", NULL, 0); + if (!type_param) { + type = -1; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "WHERE"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "OR "); + ZVAL_LONG(&_2, type); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addcondition", NULL, 0, &_0, &_1, &condition, value, &_2); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_11); - ZEPHIR_MM_RESTORE(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processSave) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, where) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long quality, ZEPHIR_LAST_CALL_STATUS; - zval *file_param = NULL, *quality_param = NULL, extension, fp, _0, _1, _2, _3, _4, _5, _6, _7, _17, _8$$3, _9$$3, _10$$3, _11$$4, _12$$4, _13$$4, _14$$5, _15$$5, _16$$5; - zval file; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _0, _1, _2; + zval condition; zval *this_ptr = getThis(); - ZVAL_UNDEF(&file); - ZVAL_UNDEF(&extension); - ZVAL_UNDEF(&fp); + ZVAL_UNDEF(&condition); + ZVAL_UNDEF(&value_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_17); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_9$$3); - ZVAL_UNDEF(&_10$$3); - ZVAL_UNDEF(&_11$$4); - ZVAL_UNDEF(&_12$$4); - ZVAL_UNDEF(&_13$$4); - ZVAL_UNDEF(&_14$$5); - ZVAL_UNDEF(&_15$$5); - ZVAL_UNDEF(&_16$$5); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(file) - Z_PARAM_LONG(quality) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(condition) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(value) + Z_PARAM_LONG(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &file_param, &quality_param); - zephir_get_strval(&file, file_param); - ZVAL_LONG(&_0, 4); - ZEPHIR_CALL_FUNCTION(&extension, "pathinfo", NULL, 89, &file, &_0); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "setformat", NULL, 0, &extension); - zephir_check_call_status(); - zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_1, "setimageformat", NULL, 0, &extension); - zephir_check_call_status(); - zephir_read_property(&_2, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_3, &_2, "getimagetype", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_3); - zephir_read_property(&_4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_5, &_4, "getimageformat", NULL, 0); + zephir_fetch_params(1, 1, 2, &condition_param, &value, &type_param); + zephir_get_strval(&condition, condition_param); + if (!value) { + value = &value_sub; + value = &__$null; + } + if (!type_param) { + type = -1; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "WHERE"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "AND "); + ZVAL_LONG(&_2, type); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addcondition", NULL, 0, &_0, &_1, &condition, value, &_2); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_6); - ZEPHIR_CONCAT_SV(&_6, "image/", &_5); - zephir_update_property_zval(this_ptr, ZEND_STRL("mime"), &_6); - ZEPHIR_INIT_VAR(&_7); - zephir_fast_strtolower(&_7, &extension); - ZEPHIR_CPY_WRT(&extension, &_7); - do { - if (ZEPHIR_IS_STRING(&extension, "gif")) { - zephir_read_property(&_8$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_8$$3, "optimizeimagelayers", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_9$$3); - ZVAL_STRING(&_9$$3, "w"); - ZEPHIR_CALL_FUNCTION(&fp, "fopen", NULL, 140, &file, &_9$$3); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, whereEquals) +{ + zend_string *_3; + zend_ulong _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *columnsValues_param = NULL, key, value, *_0, _1, _5$$5, _6$$6, _7$$7, _8$$10, _9$$11, _10$$12; + zval columnsValues; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&columnsValues); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_6$$6); + ZVAL_UNDEF(&_7$$7); + ZVAL_UNDEF(&_8$$10); + ZVAL_UNDEF(&_9$$11); + ZVAL_UNDEF(&_10$$12); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(columnsValues) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &columnsValues_param); + zephir_get_arrval(&columnsValues, columnsValues_param); + zephir_is_iterable(&columnsValues, 0, "phalcon/DataMapper/Query/AbstractConditions.zep", 162); + if (Z_TYPE_P(&columnsValues) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&columnsValues), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&key); + if (_3 != NULL) { + ZVAL_STR_COPY(&key, _3); + } else { + ZVAL_LONG(&key, _2); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0); + if (zephir_is_numeric(&key)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "where", &_4, 0, &value); + zephir_check_call_status(); + } else if (Z_TYPE_P(&value) == IS_NULL) { + ZEPHIR_INIT_NVAR(&_5$$5); + ZEPHIR_CONCAT_VS(&_5$$5, &key, " IS NULL"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "where", &_4, 0, &_5$$5); + zephir_check_call_status(); + } else if (Z_TYPE_P(&value) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&_6$$6); + ZEPHIR_CONCAT_VS(&_6$$6, &key, " IN "); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "where", &_4, 0, &_6$$6, &value); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&_7$$7); + ZEPHIR_CONCAT_VS(&_7$$7, &key, " = "); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "where", &_4, 0, &_7$$7, &value); + zephir_check_call_status(); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &columnsValues, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &columnsValues, "valid", NULL, 0); zephir_check_call_status(); - zephir_read_property(&_10$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_10$$3, "writeimagesfile", NULL, 0, &fp); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &columnsValues, "key", NULL, 0); zephir_check_call_status(); - zephir_fclose(&fp); - RETURN_MM_NULL(); - } - if (ZEPHIR_IS_STRING(&extension, "jpg") || ZEPHIR_IS_STRING(&extension, "jpeg")) { - zephir_read_property(&_11$$4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_12$$4); - ZVAL_STRING(&_12$$4, "Imagick::COMPRESSION_JPEG"); - ZEPHIR_CALL_FUNCTION(&_13$$4, "constant", NULL, 119, &_12$$4); + ZEPHIR_CALL_METHOD(&value, &columnsValues, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_11$$4, "setimagecompression", NULL, 0, &_13$$4); + if (zephir_is_numeric(&key)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "where", &_4, 0, &value); + zephir_check_call_status(); + } else if (Z_TYPE_P(&value) == IS_NULL) { + ZEPHIR_INIT_NVAR(&_8$$10); + ZEPHIR_CONCAT_VS(&_8$$10, &key, " IS NULL"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "where", &_4, 0, &_8$$10); + zephir_check_call_status(); + } else if (Z_TYPE_P(&value) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&_9$$11); + ZEPHIR_CONCAT_VS(&_9$$11, &key, " IN "); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "where", &_4, 0, &_9$$11, &value); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&_10$$12); + ZEPHIR_CONCAT_VS(&_10$$12, &key, " = "); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "where", &_4, 0, &_10$$12, &value); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(NULL, &columnsValues, "next", NULL, 0); zephir_check_call_status(); } - } while(0); + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + RETURN_THIS(); +} - if (quality >= 0) { - ZVAL_LONG(&_15$$5, quality); - ZVAL_LONG(&_16$$5, 1); - ZEPHIR_CALL_METHOD(&_14$$5, this_ptr, "checkhighlow", NULL, 0, &_15$$5, &_16$$5); - zephir_check_call_status(); - quality = zephir_get_numberval(&_14$$5); - zephir_read_property(&_15$$5, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_16$$5, quality); - ZEPHIR_CALL_METHOD(NULL, &_15$$5, "setimagecompressionquality", NULL, 0, &_16$$5); +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, addCondition) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *store_param = NULL, *andor_param = NULL, *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _0$$3, _1$$3, _2, _3; + zval store, andor, condition, _4; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&store); + ZVAL_UNDEF(&andor); + ZVAL_UNDEF(&condition); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&value_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(3, 5) + Z_PARAM_STR(store) + Z_PARAM_STR(andor) + Z_PARAM_STR(condition) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(value) + Z_PARAM_LONG(type) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 2, &store_param, &andor_param, &condition_param, &value, &type_param); + zephir_get_strval(&store, store_param); + zephir_get_strval(&andor, andor_param); + zephir_get_strval(&condition, condition_param); + if (!value) { + value = &value_sub; + value = &__$null; + } + if (!type_param) { + type = -1; + } else { + } + if (!(ZEPHIR_IS_EMPTY(value))) { + ZVAL_LONG(&_1$$3, type); + ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "bindinline", NULL, 0, value, &_1$$3); zephir_check_call_status(); + zephir_concat_self(&condition, &_0$$3); } - zephir_read_property(&_17, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_17, "writeimage", NULL, 0, &file); - zephir_check_call_status(); + zephir_read_property(&_2, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_3, &_2, &store, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 185); + if (ZEPHIR_IS_EMPTY(&_3)) { + ZEPHIR_INIT_NVAR(&andor); + } + ZEPHIR_INIT_VAR(&_4); + ZEPHIR_CONCAT_VV(&_4, &andor, &condition); + zephir_update_property_array_multi(this_ptr, SL("store"), &_4, SL("za"), 2, &store); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processSharpen) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, buildBy) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *amount_param = NULL, _0, _1, _2, _3$$3, _4$$3, _5$$3, _6$$3; - zend_long amount, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *type_param = NULL, _0, _1, _2, _3, _4, _5; + zval type; zval *this_ptr = getThis(); + ZVAL_UNDEF(&type); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(amount) + Z_PARAM_STR(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &amount_param); - ZEPHIR_INIT_VAR(&_0); - if (amount < 5) { - ZEPHIR_INIT_NVAR(&_0); - ZVAL_LONG(&_0, 5); - } else { - ZEPHIR_INIT_NVAR(&_0); - ZVAL_LONG(&_0, amount); + zephir_fetch_params(1, 1, 0, &type_param); + zephir_get_strval(&type, type_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_1, &_0, &type, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 201); + if (ZEPHIR_IS_EMPTY(&_1)) { + RETURN_MM_STRING(""); } - amount = zephir_get_numberval(&_0); - amount = (long) (zephir_safe_div_long_long(((amount * 3.0)), 100)); - zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_2, 0); - ZEPHIR_CALL_METHOD(NULL, &_1, "setiteratorindex", NULL, 0, &_2); + zephir_read_property(&_3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_4, &_3, &type, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 206); + ZEPHIR_INIT_VAR(&_5); + ZVAL_STRING(&_5, ","); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "indent", NULL, 0, &_4, &_5); zephir_check_call_status(); - while (1) { - if (!(1)) { - break; - } - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_4$$3, 0); - ZVAL_LONG(&_5$$3, amount); - ZEPHIR_CALL_METHOD(NULL, &_3$$3, "sharpenimage", NULL, 0, &_4$$3, &_5$$3); - zephir_check_call_status(); - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_6$$3, &_4$$3, "nextimage", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_6$$3)) { - break; - } - } - ZEPHIR_MM_RESTORE(); + ZEPHIR_CONCAT_SVSV(return_value, " ", &type, " BY", &_2); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processText) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, buildCondition) { - zend_bool _7$$8, _9$$8, _10$$8, _11$$8, _12$$11, _14$$11, _15$$11, _16$$11; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long opacity, red, green, blue, size, ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, *offsetX = NULL, offsetX_sub, *offsetY = NULL, offsetY_sub, *opacity_param = NULL, *red_param = NULL, *green_param = NULL, *blue_param = NULL, *size_param = NULL, *fontFile_param = NULL, color, draw, gravity, x, y, _0, _1, _2, _3, _4$$4, _5$$5, _6$$7, _8$$8, _13$$11, _17$$12, _18$$14, _19$$14, _20$$14; - zval text, fontFile; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *type_param = NULL, _0, _1, _2, _3, _4; + zval type; zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&fontFile); - ZVAL_UNDEF(&offsetX_sub); - ZVAL_UNDEF(&offsetY_sub); - ZVAL_UNDEF(&color); - ZVAL_UNDEF(&draw); - ZVAL_UNDEF(&gravity); - ZVAL_UNDEF(&x); - ZVAL_UNDEF(&y); + ZVAL_UNDEF(&type); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_8$$8); - ZVAL_UNDEF(&_13$$11); - ZVAL_UNDEF(&_17$$12); - ZVAL_UNDEF(&_18$$14); - ZVAL_UNDEF(&_19$$14); - ZVAL_UNDEF(&_20$$14); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(8, 9) - Z_PARAM_STR(text) - Z_PARAM_ZVAL(offsetX) - Z_PARAM_ZVAL(offsetY) - Z_PARAM_LONG(opacity) - Z_PARAM_LONG(red) - Z_PARAM_LONG(green) - Z_PARAM_LONG(blue) - Z_PARAM_LONG(size) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(fontFile) + ZVAL_UNDEF(&_4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 8, 1, &text_param, &offsetX, &offsetY, &opacity_param, &red_param, &green_param, &blue_param, &size_param, &fontFile_param); - zephir_get_strval(&text, text_param); - ZEPHIR_SEPARATE_PARAM(offsetX); - ZEPHIR_SEPARATE_PARAM(offsetY); - if (!fontFile_param) { - ZEPHIR_INIT_VAR(&fontFile); - } else { - zephir_get_strval(&fontFile, fontFile_param); + zephir_fetch_params(1, 1, 0, &type_param); + zephir_get_strval(&type, type_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_1, &_0, &type, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 218); + if (ZEPHIR_IS_EMPTY(&_1)) { + RETURN_MM_STRING(""); } - opacity = (long) (zephir_safe_div_long_long(opacity, 100)); - ZEPHIR_INIT_VAR(&draw); - object_init_ex(&draw, zephir_get_internal_ce(SL("imagickdraw"))); - ZEPHIR_CALL_METHOD(NULL, &draw, "__construct", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "rgb(%d, %d, %d)"); - ZVAL_LONG(&_1, red); - ZVAL_LONG(&_2, green); - ZVAL_LONG(&_3, blue); - ZEPHIR_CALL_FUNCTION(&color, "sprintf", NULL, 117, &_0, &_1, &_2, &_3); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_0); - object_init_ex(&_0, zephir_get_internal_ce(SL("imagickpixel"))); - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0, &color); + zephir_read_property(&_3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_4, &_3, &type, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 223); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "indent", NULL, 0, &_4); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &draw, "setfillcolor", NULL, 0, &_0); + ZEPHIR_CONCAT_SVV(return_value, " ", &type, &_2); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, buildLimitEarly) +{ + zend_bool _3, _6; + zval _0, _1, _2, _4, _5, _7, _8, _9$$3, _10$$3, _11$$3; + zval limit; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&limit); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9$$3); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_11$$3); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&limit); + zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, &_0, "getdrivername", NULL, 0); zephir_check_call_status(); - if (Z_TYPE_P(&fontFile) != IS_NULL) { - ZEPHIR_CALL_METHOD(NULL, &draw, "setfont", NULL, 0, &fontFile); - zephir_check_call_status(); - } - if (size) { - ZVAL_LONG(&_4$$4, size); - ZEPHIR_CALL_METHOD(NULL, &draw, "setfontsize", NULL, 0, &_4$$4); - zephir_check_call_status(); - } - if (opacity) { - ZVAL_LONG(&_5$$5, opacity); - ZEPHIR_CALL_METHOD(NULL, &draw, "setfillopacity", NULL, 0, &_5$$5); - zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "sqlsrv"); + _3 = ZEPHIR_IS_IDENTICAL(&_2, &_1); + if (_3) { + zephir_read_property(&_4, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_5, &_4, SL("LIMIT"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 237); + _3 = ZEPHIR_GT_LONG(&_5, 0); } - ZEPHIR_INIT_VAR(&gravity); - ZVAL_NULL(&gravity); - if (((Z_TYPE_P(offsetX) == IS_TRUE || Z_TYPE_P(offsetX) == IS_FALSE) == 1)) { - if (((Z_TYPE_P(offsetY) == IS_TRUE || Z_TYPE_P(offsetY) == IS_FALSE) == 1)) { - ZEPHIR_INIT_NVAR(offsetX); - ZVAL_LONG(offsetX, 0); - ZEPHIR_INIT_NVAR(offsetY); - ZVAL_LONG(offsetY, 0); - ZEPHIR_INIT_VAR(&_6$$7); - ZVAL_STRING(&_6$$7, "Imagick::GRAVITY_CENTER"); - ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_6$$7); - zephir_check_call_status(); - } else if (Z_TYPE_P(offsetY) == IS_LONG) { - ZEPHIR_INIT_VAR(&y); - ZVAL_LONG(&y, zephir_get_intval(offsetY)); - _7$$8 = ZEPHIR_IS_TRUE_IDENTICAL(offsetX); - if (_7$$8) { - _7$$8 = ZEPHIR_LT_LONG(&y, 0); - } - if (_7$$8) { - ZEPHIR_INIT_VAR(&_8$$8); - ZVAL_STRING(&_8$$8, "Imagick::GRAVITY_SOUTHEAST"); - ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_8$$8); - zephir_check_call_status(); - } else { - } - _9$$8 = ZEPHIR_IS_TRUE_IDENTICAL(offsetX); - if (_9$$8) { - _9$$8 = ZEPHIR_GE_LONG(&y, 0); - } - if (_9$$8) { - ZEPHIR_INIT_NVAR(&_8$$8); - ZVAL_STRING(&_8$$8, "Imagick::GRAVITY_NORTHEAST"); - ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_8$$8); - zephir_check_call_status(); - } else { - } - _10$$8 = !ZEPHIR_IS_TRUE_IDENTICAL(offsetX); - if (_10$$8) { - _10$$8 = ZEPHIR_LT_LONG(&y, 0); - } - if (_10$$8) { - ZEPHIR_INIT_NVAR(&_8$$8); - ZVAL_STRING(&_8$$8, "Imagick::GRAVITY_SOUTH"); - ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_8$$8); - zephir_check_call_status(); - } else { - } - _11$$8 = !ZEPHIR_IS_TRUE_IDENTICAL(offsetX); - if (_11$$8) { - _11$$8 = ZEPHIR_GE_LONG(&y, 0); - } - if (_11$$8) { - ZEPHIR_INIT_NVAR(&_8$$8); - ZVAL_STRING(&_8$$8, "Imagick::GRAVITY_NORTH"); - ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_8$$8); - zephir_check_call_status(); - } else { - } - ZEPHIR_INIT_NVAR(offsetX); - ZVAL_LONG(offsetX, 0); - if (ZEPHIR_LT_LONG(&y, 0)) { - ZEPHIR_INIT_NVAR(offsetY); - ZVAL_LONG(offsetY, (zephir_get_numberval(&y) * -1)); - } else { - } - } - } else if (Z_TYPE_P(offsetX) == IS_LONG) { - ZEPHIR_INIT_VAR(&x); - ZVAL_LONG(&x, zephir_get_intval(offsetX)); - if (zephir_is_true(offsetX)) { - if (((Z_TYPE_P(offsetY) == IS_TRUE || Z_TYPE_P(offsetY) == IS_FALSE) == 1)) { - _12$$11 = ZEPHIR_IS_TRUE_IDENTICAL(offsetY); - if (_12$$11) { - _12$$11 = ZEPHIR_LT_LONG(&x, 0); - } - if (_12$$11) { - ZEPHIR_INIT_VAR(&_13$$11); - ZVAL_STRING(&_13$$11, "Imagick::GRAVITY_SOUTHEAST"); - ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_13$$11); - zephir_check_call_status(); - } else { - } - _14$$11 = ZEPHIR_IS_TRUE_IDENTICAL(offsetY); - if (_14$$11) { - _14$$11 = ZEPHIR_GE_LONG(&x, 0); - } - if (_14$$11) { - ZEPHIR_INIT_NVAR(&_13$$11); - ZVAL_STRING(&_13$$11, "Imagick::GRAVITY_SOUTH"); - ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_13$$11); - zephir_check_call_status(); - } else { - } - _15$$11 = !ZEPHIR_IS_TRUE_IDENTICAL(offsetY); - if (_15$$11) { - _15$$11 = ZEPHIR_LT_LONG(&x, 0); - } - if (_15$$11) { - ZEPHIR_INIT_NVAR(&_13$$11); - ZVAL_STRING(&_13$$11, "Imagick::GRAVITY_EAST"); - ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_13$$11); - zephir_check_call_status(); - } else { - } - _16$$11 = !ZEPHIR_IS_TRUE_IDENTICAL(offsetY); - if (_16$$11) { - _16$$11 = ZEPHIR_GE_LONG(&x, 0); - } - if (_16$$11) { - ZEPHIR_INIT_NVAR(&_13$$11); - ZVAL_STRING(&_13$$11, "Imagick::GRAVITY_WEST"); - ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_13$$11); - zephir_check_call_status(); - } else { - } - ZEPHIR_INIT_NVAR(offsetY); - ZVAL_LONG(offsetY, 0); - if (ZEPHIR_LT_LONG(&x, 0)) { - ZEPHIR_INIT_NVAR(offsetX); - ZVAL_LONG(offsetX, (zephir_get_numberval(&x) * -1)); - } else { - } - } else if (Z_TYPE_P(offsetY) == IS_LONG) { - ZEPHIR_INIT_NVAR(&y); - ZVAL_LONG(&y, zephir_get_intval(offsetY)); - if (ZEPHIR_LT_LONG(&x, 0)) { - ZEPHIR_INIT_NVAR(offsetX); - ZVAL_LONG(offsetX, (zephir_get_numberval(&x) * -1)); - } else { - ZEPHIR_INIT_NVAR(offsetX); - ZVAL_LONG(offsetX, 0); - } - if (ZEPHIR_LT_LONG(&y, 0)) { - ZEPHIR_INIT_NVAR(offsetY); - ZVAL_LONG(offsetY, (zephir_get_numberval(&y) * -1)); - } else { - } - if (ZEPHIR_LT_LONG(&y, 0)) { - ZEPHIR_INIT_VAR(&_17$$12); - ZVAL_STRING(&_17$$12, "Imagick::GRAVITY_SOUTHEAST"); - ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_17$$12); - zephir_check_call_status(); - } else { - } - if (ZEPHIR_GE_LONG(&y, 0)) { - ZEPHIR_INIT_NVAR(&_17$$12); - ZVAL_STRING(&_17$$12, "Imagick::GRAVITY_NORTHEAST"); - ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_17$$12); - zephir_check_call_status(); - } else { - } - } - } + _6 = _3; + if (_6) { + zephir_read_property(&_7, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_8, &_7, SL("OFFSET"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 239); + _6 = ZEPHIR_IS_LONG_IDENTICAL(&_8, 0); } - if (Z_TYPE_P(&gravity) != IS_NULL) { - ZEPHIR_CALL_METHOD(NULL, &draw, "setgravity", NULL, 0, &gravity); - zephir_check_call_status(); + if (_6) { + zephir_read_property(&_9$$3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_10$$3, &_9$$3, SL("LIMIT"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 240); + ZEPHIR_INIT_VAR(&_11$$3); + ZEPHIR_CONCAT_SV(&_11$$3, " TOP ", &_10$$3); + zephir_get_strval(&limit, &_11$$3); } - zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_2, 0); - ZEPHIR_CALL_METHOD(NULL, &_1, "setiteratorindex", NULL, 0, &_2); + RETURN_CTOR(&limit); +} + +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, buildLimit) +{ + zval method, suffix, _0, _1, _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&suffix); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&suffix, &_0, "getdrivername", NULL, 0); zephir_check_call_status(); - while (1) { - if (!(1)) { - break; - } - zephir_read_property(&_18$$14, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_19$$14, 0); - ZEPHIR_CALL_METHOD(NULL, &_18$$14, "annotateimage", NULL, 0, &draw, offsetX, offsetY, &_19$$14, &text); - zephir_check_call_status(); - zephir_read_property(&_19$$14, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_20$$14, &_19$$14, "nextimage", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_20$$14)) { - break; - } + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "sqlsrv"); + if (!ZEPHIR_IS_IDENTICAL(&_1, &suffix)) { + ZEPHIR_INIT_NVAR(&suffix); + ZVAL_STRING(&suffix, "common"); } - ZEPHIR_CALL_METHOD(NULL, &draw, "destroy", NULL, 0); + ZEPHIR_INIT_VAR(&_2); + zephir_ucfirst(&_2, &suffix); + ZEPHIR_INIT_VAR(&method); + ZEPHIR_CONCAT_SV(&method, "buildLimit", &_2); + ZEPHIR_RETURN_CALL_METHOD_ZVAL(this_ptr, &method, NULL, 0); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processWatermark) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, buildLimitCommon) { + zval _0, _1, _5, _6, _10, _2$$3, _3$$3, _4$$3, _7$$4, _8$$4, _9$$4, _11$$5, _12$$5; + zval limit; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long offsetX, offsetY, opacity, ZEPHIR_LAST_CALL_STATUS; - zval *image, image_sub, *offsetX_param = NULL, *offsetY_param = NULL, *opacity_param = NULL, result, watermark, _0, _1, _2, _3, _4, _5, _6$$3, _7$$3, _8$$3, _9$$3, _10$$3, _11$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&image_sub); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&watermark); + ZVAL_UNDEF(&limit); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$4); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&_11$$5); + ZVAL_UNDEF(&_12$$5); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&limit); + zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_1, &_0, SL("LIMIT"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 275); + if (!ZEPHIR_IS_LONG_IDENTICAL(&_1, 0)) { + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_3$$3, &_2$$3, SL("LIMIT"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 276); + ZEPHIR_INIT_VAR(&_4$$3); + ZEPHIR_CONCAT_SV(&_4$$3, "LIMIT ", &_3$$3); + zephir_concat_self(&limit, &_4$$3); + } + zephir_read_property(&_5, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_6, &_5, SL("OFFSET"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 279); + if (!ZEPHIR_IS_LONG_IDENTICAL(&_6, 0)) { + zephir_read_property(&_7$$4, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_8$$4, &_7$$4, SL("OFFSET"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 280); + ZEPHIR_INIT_VAR(&_9$$4); + ZEPHIR_CONCAT_SV(&_9$$4, " OFFSET ", &_8$$4); + zephir_concat_self(&limit, &_9$$4); + } + ZEPHIR_INIT_VAR(&_10); + ZVAL_STRING(&_10, ""); + if (!ZEPHIR_IS_IDENTICAL(&_10, &limit)) { + ZEPHIR_INIT_VAR(&_11$$5); + zephir_fast_trim(&_11$$5, &limit, NULL , ZEPHIR_TRIM_LEFT); + ZEPHIR_INIT_VAR(&_12$$5); + ZEPHIR_CONCAT_SV(&_12$$5, " ", &_11$$5); + zephir_get_strval(&limit, &_12$$5); + } + RETURN_CTOR(&limit); +} + +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, buildLimitSqlsrv) +{ + zend_bool _2; + zval _0, _1, _3, _4, _5$$3, _6$$3, _7$$3, _8$$3, _9$$3; + zval limit; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&limit); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$3); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&limit); + zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_1, &_0, SL("LIMIT"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 299); + _2 = ZEPHIR_GT_LONG(&_1, 0); + if (_2) { + zephir_read_property(&_3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_4, &_3, SL("OFFSET"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 299); + _2 = ZEPHIR_GT_LONG(&_4, 0); + } + if (_2) { + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_6$$3, &_5$$3, SL("OFFSET"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 300); + zephir_read_property(&_7$$3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_8$$3, &_7$$3, SL("LIMIT"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 301); + ZEPHIR_INIT_VAR(&_9$$3); + ZEPHIR_CONCAT_SVSSVS(&_9$$3, " OFFSET ", &_6$$3, " ROWS", " FETCH NEXT ", &_8$$3, " ROWS ONLY"); + zephir_get_strval(&limit, &_9$$3); + } + RETURN_CTOR(&limit); +} + +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, appendCondition) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *store_param = NULL, *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, key, _2, _3, _5, _6, _7, _8, _9, _10, _0$$3, _1$$3, _4$$4; + zval store, condition; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&store); + ZVAL_UNDEF(&condition); + ZVAL_UNDEF(&value_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&key); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_9$$3); - ZVAL_UNDEF(&_10$$3); - ZVAL_UNDEF(&_11$$3); - ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_OBJECT_OF_CLASS(image, phalcon_image_adapter_adapterinterface_ce) - Z_PARAM_LONG(offsetX) - Z_PARAM_LONG(offsetY) - Z_PARAM_LONG(opacity) + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_4$$4); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_STR(store) + Z_PARAM_STR(condition) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(value) + Z_PARAM_LONG(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 4, 0, &image, &offsetX_param, &offsetY_param, &opacity_param); - opacity = (long) (zephir_safe_div_long_long(opacity, 100)); - ZEPHIR_INIT_VAR(&watermark); - object_init_ex(&watermark, zephir_get_internal_ce(SL("imagick"))); - ZEPHIR_CALL_METHOD(NULL, &watermark, "__construct", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, image, "render", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &watermark, "readimageblob", NULL, 0, &_0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "Imagick::EVALUATE_MULTIPLY"); - ZEPHIR_CALL_FUNCTION(&_2, "constant", NULL, 119, &_1); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "Imagick::CHANNEL_ALPHA"); - ZEPHIR_CALL_FUNCTION(&_3, "constant", NULL, 119, &_1); - zephir_check_call_status(); - ZVAL_LONG(&_4, opacity); - ZEPHIR_CALL_METHOD(NULL, &watermark, "evaluateimage", NULL, 0, &_2, &_4, &_3); - zephir_check_call_status(); - zephir_read_property(&_4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_5, 0); - ZEPHIR_CALL_METHOD(NULL, &_4, "setiteratorindex", NULL, 0, &_5); - zephir_check_call_status(); - while (1) { - if (!(1)) { - break; - } - zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_7$$3); - ZVAL_STRING(&_7$$3, "Imagick::COMPOSITE_OVER"); - ZEPHIR_CALL_FUNCTION(&_8$$3, "constant", NULL, 119, &_7$$3); - zephir_check_call_status(); - ZVAL_LONG(&_9$$3, offsetX); - ZVAL_LONG(&_10$$3, offsetY); - ZEPHIR_CALL_METHOD(&result, &_6$$3, "compositeimage", NULL, 0, &watermark, &_8$$3, &_9$$3, &_10$$3); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&result)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::compositeImage failed", "phalcon/Image/Adapter/Imagick.zep", 893); - return; + zephir_fetch_params(1, 2, 2, &store_param, &condition_param, &value, &type_param); + zephir_get_strval(&store, store_param); + zephir_get_strval(&condition, condition_param); + if (!value) { + value = &value_sub; + value = &__$null; + } + if (!type_param) { + type = -1; + } else { } - zephir_read_property(&_9$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_11$$3, &_9$$3, "nextimage", NULL, 0); + if (!(ZEPHIR_IS_EMPTY(value))) { + ZVAL_LONG(&_1$$3, type); + ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "bindinline", NULL, 0, value, &_1$$3); zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_11$$3)) { - break; - } + zephir_concat_self(&condition, &_0$$3); } - ZEPHIR_CALL_METHOD(NULL, &watermark, "clear", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &watermark, "destroy", NULL, 0); + zephir_read_property(&_2, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_3, &_2, &store, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 327); + if (ZEPHIR_IS_EMPTY(&_3)) { + ZEPHIR_INIT_VAR(&_4$$4); + ZVAL_STRING(&_4$$4, ""); + zephir_update_property_array_multi(this_ptr, SL("store"), &_4$$4, SL("za"), 2, &store); + } + zephir_read_property(&_5, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_6, &_5, &store, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 331); + ZEPHIR_CALL_FUNCTION(&key, "array_key_last", NULL, 40, &_6); zephir_check_call_status(); + zephir_read_property(&_7, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_8, &_7, &store, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 333); + zephir_array_fetch(&_9, &_8, &key, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 333); + ZEPHIR_INIT_VAR(&_10); + ZEPHIR_CONCAT_VV(&_10, &_9, &condition); + zephir_update_property_array_multi(this_ptr, SL("store"), &_10, SL("zz"), 2, &store, &key); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Image_Adapter_Imagick, check) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractConditions, processValue) { - zval _0, _1, _2, _3$$4, _4$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *store_param = NULL, *data = NULL, data_sub, _0$$3, _1$$4, _2$$4, _3$$4; + zval store; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&store); + ZVAL_UNDEF(&data_sub); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$4); ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(store) + Z_PARAM_ZVAL(data) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "imagick"); - if (1 != zephir_class_exists(&_0, 1)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick is not installed, or the extension is not loaded", "phalcon/Image/Adapter/Imagick.zep", 916); - return; + zephir_fetch_params(1, 2, 0, &store_param, &data); + zephir_get_strval(&store, store_param); + ZEPHIR_SEPARATE_PARAM(data); + if (Z_TYPE_P(data) == IS_STRING) { + ZEPHIR_INIT_VAR(&_0$$3); + zephir_create_array(&_0$$3, 1, 0); + zephir_array_fast_append(&_0$$3, data); + ZEPHIR_CPY_WRT(data, &_0$$3); } - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "Imagick::IMAGICK_EXTNUM"); - ZEPHIR_CALL_FUNCTION(&_2, "defined", NULL, 118, &_1); - zephir_check_call_status(); - if (zephir_is_true(&_2)) { - ZEPHIR_INIT_VAR(&_3$$4); - ZVAL_STRING(&_3$$4, "Imagick::IMAGICK_EXTNUM"); - ZEPHIR_CALL_FUNCTION(&_4$$4, "constant", NULL, 119, &_3$$4); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("version"), &_4$$4); + if (Z_TYPE_P(data) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&_1$$4); + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_3$$4, &_2$$4, &store, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractConditions.zep", 350); + zephir_fast_array_merge(&_1$$4, &_3$$4, data); + zephir_update_property_array(this_ptr, SL("store"), &store, &_1$$4); } ZEPHIR_MM_RESTORE(); } @@ -131658,385 +131751,384 @@ static PHP_METHOD(Phalcon_Image_Adapter_Imagick, check) -ZEPHIR_INIT_CLASS(Phalcon_Storage_AdapterFactory) +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Query_AbstractQuery) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage, AdapterFactory, phalcon, storage_adapterfactory, phalcon_factory_abstractfactory_ce, phalcon_storage_adapterfactory_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\DataMapper\\Query, AbstractQuery, phalcon, datamapper_query_abstractquery, phalcon_datamapper_query_abstractquery_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + zend_declare_property_null(phalcon_datamapper_query_abstractquery_ce, SL("bind"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_datamapper_query_abstractquery_ce, SL("connection"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_datamapper_query_abstractquery_ce, SL("store"), ZEND_ACC_PROTECTED); + phalcon_datamapper_query_abstractquery_ce->create_object = zephir_init_properties_Phalcon_DataMapper_Query_AbstractQuery; - zend_declare_property_null(phalcon_storage_adapterfactory_ce, SL("serializerFactory"), ZEND_ACC_PRIVATE); return SUCCESS; } -static PHP_METHOD(Phalcon_Storage_AdapterFactory, __construct) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval services; - zval *factory, factory_sub, *services_param = NULL; + zval *connection, connection_sub, *bind, bind_sub, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&factory_sub); - ZVAL_UNDEF(&services); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_storage_serializerfactory_ce) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(services) + ZVAL_UNDEF(&connection_sub); + ZVAL_UNDEF(&bind_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_datamapper_pdo_connection_ce) + Z_PARAM_OBJECT_OF_CLASS(bind, phalcon_datamapper_query_bind_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &factory, &services_param); - if (!services_param) { - ZEPHIR_INIT_VAR(&services); - array_init(&services); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("serializerFactory"), factory); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); + zephir_fetch_params(1, 2, 0, &connection, &bind); + zephir_update_property_zval(this_ptr, ZEND_STRL("bind"), bind); + zephir_update_property_zval(this_ptr, ZEND_STRL("connection"), connection); + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "UNION"); + zephir_update_property_array(this_ptr, SL("store"), &_1, &_0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "reset", NULL, 0); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_AdapterFactory, newInstance) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, bindInline) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval options, _0; - zval *name_param = NULL, *options_param = NULL, definition, _1; - zval name; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *value, value_sub, *type_param = NULL, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&definition); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&options); + ZVAL_UNDEF(&value_sub); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(name) + Z_PARAM_ZVAL(value) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + Z_PARAM_LONG(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &name_param, &options_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); + zephir_fetch_params(1, 1, 1, &value, &type_param); + if (!type_param) { + type = -1; } else { - ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); - } - ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 2, 0); - zephir_memory_observe(&_1); - zephir_read_property(&_1, this_ptr, ZEND_STRL("serializerFactory"), PH_NOISY_CC); - zephir_array_fast_append(&_0, &_1); - zephir_array_fast_append(&_0, &options); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(return_value, &definition, &_0); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1, type); + ZEPHIR_RETURN_CALL_METHOD(&_0, "bindinline", NULL, 0, value, &_1); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_AdapterFactory, getExceptionClass) -{ - - RETURN_STRING("Phalcon\\Storage\\Exception"); -} - -static PHP_METHOD(Phalcon_Storage_AdapterFactory, getServices) -{ - - zephir_create_array(return_value, 6, 0); - add_assoc_stringl_ex(return_value, SL("apcu"), SL("Phalcon\\Storage\\Adapter\\Apcu")); - add_assoc_stringl_ex(return_value, SL("libmemcached"), SL("Phalcon\\Storage\\Adapter\\Libmemcached")); - add_assoc_stringl_ex(return_value, SL("memory"), SL("Phalcon\\Storage\\Adapter\\Memory")); - add_assoc_stringl_ex(return_value, SL("redis"), SL("Phalcon\\Storage\\Adapter\\Redis")); - add_assoc_stringl_ex(return_value, SL("stream"), SL("Phalcon\\Storage\\Adapter\\Stream")); - add_assoc_stringl_ex(return_value, SL("weak"), SL("Phalcon\\Storage\\Adapter\\Weak")); - return; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Storage_Exception) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage, Exception, phalcon, storage_exception, zend_ce_exception, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Storage_SerializerFactory) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage, SerializerFactory, phalcon, storage_serializerfactory, phalcon_factory_abstractfactory_ce, phalcon_storage_serializerfactory_method_entry, 0); - - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Storage_SerializerFactory, __construct) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, bindValue) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *services_param = NULL; - zval services; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL, *value, value_sub, *type_param = NULL, _0, _1; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&services); - ZEND_PARSE_PARAMETERS_START(0, 1) + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(key) + Z_PARAM_ZVAL(value) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(services) + Z_PARAM_LONG(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &services_param); - if (!services_param) { - ZEPHIR_INIT_VAR(&services); - array_init(&services); + zephir_fetch_params(1, 2, 1, &key_param, &value, &type_param); + zephir_get_strval(&key, key_param); + if (!type_param) { + type = -1; } else { - ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1, type); + ZEPHIR_CALL_METHOD(NULL, &_0, "setvalue", NULL, 0, &key, value, &_1); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_SerializerFactory, newInstance) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, bindValues) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, definition; - zval name; + zval *values_param = NULL, _0; + zval values; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + Z_PARAM_ARRAY(values) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); - zephir_check_call_status(); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(return_value, &definition); + zephir_fetch_params(1, 1, 0, &values_param); + zephir_get_arrval(&values, values_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "setvalues", NULL, 0, &values); zephir_check_call_status(); - RETURN_MM(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_SerializerFactory, getExceptionClass) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, getBindValues) { + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - RETURN_STRING("Phalcon\\Storage\\Exception"); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "toarray", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_SerializerFactory, getServices) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, getStatement) { - - zephir_create_array(return_value, 14, 0); - add_assoc_stringl_ex(return_value, SL("base64"), SL("Phalcon\\Storage\\Serializer\\Base64")); - add_assoc_stringl_ex(return_value, SL("igbinary"), SL("Phalcon\\Storage\\Serializer\\Igbinary")); - add_assoc_stringl_ex(return_value, SL("json"), SL("Phalcon\\Storage\\Serializer\\Json")); - add_assoc_stringl_ex(return_value, SL("memcached_igbinary"), SL("Phalcon\\Storage\\Serializer\\MemcachedIgbinary")); - add_assoc_stringl_ex(return_value, SL("memcached_json"), SL("Phalcon\\Storage\\Serializer\\MemcachedJson")); - add_assoc_stringl_ex(return_value, SL("memcached_php"), SL("Phalcon\\Storage\\Serializer\\MemcachedPhp")); - add_assoc_stringl_ex(return_value, SL("msgpack"), SL("Phalcon\\Storage\\Serializer\\Msgpack")); - add_assoc_stringl_ex(return_value, SL("none"), SL("Phalcon\\Storage\\Serializer\\None")); - add_assoc_stringl_ex(return_value, SL("php"), SL("Phalcon\\Storage\\Serializer\\Php")); - add_assoc_stringl_ex(return_value, SL("redis_igbinary"), SL("Phalcon\\Storage\\Serializer\\RedisIgbinary")); - add_assoc_stringl_ex(return_value, SL("redis_json"), SL("Phalcon\\Storage\\Serializer\\RedisJson")); - add_assoc_stringl_ex(return_value, SL("redis_msgpack"), SL("Phalcon\\Storage\\Serializer\\RedisMsgpack")); - add_assoc_stringl_ex(return_value, SL("redis_none"), SL("Phalcon\\Storage\\Serializer\\RedisNone")); - add_assoc_stringl_ex(return_value, SL("redis_php"), SL("Phalcon\\Storage\\Serializer\\RedisPhp")); - return; } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Storage_Serializer_AbstractSerializer) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, perform) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Storage\\Serializer, AbstractSerializer, phalcon, storage_serializer_abstractserializer, phalcon_storage_serializer_abstractserializer_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + zval _0, _1, _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - zend_declare_property_null(phalcon_storage_serializer_abstractserializer_ce, SL("data"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_storage_serializer_abstractserializer_ce, SL("isSuccess"), 1, ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_storage_serializer_abstractserializer_ce, 1, phalcon_storage_serializer_serializerinterface_ce); - return SUCCESS; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstatement", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "getbindvalues", NULL, 0); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(&_0, "perform", NULL, 0, &_1, &_2); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Serializer_AbstractSerializer, __construct) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, setFlag) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *data = NULL, data_sub, __$null; + zend_bool enable; + zval *flag_param = NULL, *enable_param = NULL, __$true, flags, _0$$4, _1$$4; + zval flag; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data_sub); - ZVAL_NULL(&__$null); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) + ZVAL_UNDEF(&flag); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&flags); + ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&_1$$4); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(flag) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(data) + Z_PARAM_BOOL(enable) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &data); - if (!data) { - data = &data_sub; - data = &__$null; + zephir_fetch_params(1, 1, 1, &flag_param, &enable_param); + zephir_get_strval(&flag, flag_param); + if (!enable_param) { + enable = 1; + } else { + } + if (enable) { + zephir_update_property_array_multi(this_ptr, SL("store"), &__$true, SL("sz"), 3, SL("FLAGS"), &flag); + } else { + zephir_read_property(&_0$$4, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_memory_observe(&flags); + zephir_array_fetch_string(&flags, &_0$$4, SL("FLAGS"), PH_NOISY, "phalcon/DataMapper/Query/AbstractQuery.zep", 144); + zephir_array_unset(&flags, &flag, PH_SEPARATE); + ZEPHIR_INIT_VAR(&_1$$4); + ZVAL_STRING(&_1$$4, "FLAGS"); + zephir_update_property_array(this_ptr, SL("store"), &_1$$4, &flags); } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdata", NULL, 0, data); - zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Serializer_AbstractSerializer, __serialize) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, quoteIdentifier) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, *type_param = NULL, _0, _1; + zval name; zval *this_ptr = getThis(); + ZVAL_UNDEF(&name); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(name) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(type) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_memory_observe(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC); - if (Z_TYPE_P(&_0) == IS_ARRAY) { - RETURN_MM_MEMBER(getThis(), "data"); - } - array_init(return_value); + zephir_fetch_params(1, 1, 1, &name_param, &type_param); + zephir_get_strval(&name, name_param); + if (!type_param) { + type = 2; + } else { + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1, type); + ZEPHIR_RETURN_CALL_METHOD(&_0, "quote", NULL, 0, &name, &_1); + zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Serializer_AbstractSerializer, __unserialize) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, reset) { + zval _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *data_param = NULL; - zval data; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(data) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_13); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_15); + ZVAL_UNDEF(&_16); + ZVAL_UNDEF(&_17); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &data_param); - zephir_get_arrval(&data, data_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("data"), &data); + + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "COLUMNS"); + zephir_update_property_array(this_ptr, SL("store"), &_1, &_0); + ZEPHIR_INIT_VAR(&_2); + array_init(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "FLAGS"); + zephir_update_property_array(this_ptr, SL("store"), &_3, &_2); + ZEPHIR_INIT_VAR(&_4); + array_init(&_4); + ZEPHIR_INIT_VAR(&_5); + ZVAL_STRING(&_5, "FROM"); + zephir_update_property_array(this_ptr, SL("store"), &_5, &_4); + ZEPHIR_INIT_VAR(&_6); + array_init(&_6); + ZEPHIR_INIT_VAR(&_7); + ZVAL_STRING(&_7, "GROUP"); + zephir_update_property_array(this_ptr, SL("store"), &_7, &_6); + ZEPHIR_INIT_VAR(&_8); + array_init(&_8); + ZEPHIR_INIT_VAR(&_9); + ZVAL_STRING(&_9, "HAVING"); + zephir_update_property_array(this_ptr, SL("store"), &_9, &_8); + ZEPHIR_INIT_VAR(&_10); + ZVAL_STRING(&_10, "LIMIT"); + ZEPHIR_INIT_VAR(&_11); + ZVAL_LONG(&_11, 0); + zephir_update_property_array(this_ptr, SL("store"), &_10, &_11); + ZEPHIR_INIT_VAR(&_12); + array_init(&_12); + ZEPHIR_INIT_VAR(&_13); + ZVAL_STRING(&_13, "ORDER"); + zephir_update_property_array(this_ptr, SL("store"), &_13, &_12); + ZEPHIR_INIT_VAR(&_14); + ZVAL_STRING(&_14, "OFFSET"); + ZEPHIR_INIT_VAR(&_15); + ZVAL_LONG(&_15, 0); + zephir_update_property_array(this_ptr, SL("store"), &_14, &_15); + ZEPHIR_INIT_VAR(&_16); + array_init(&_16); + ZEPHIR_INIT_VAR(&_17); + ZVAL_STRING(&_17, "WHERE"); + zephir_update_property_array(this_ptr, SL("store"), &_17, &_16); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Serializer_AbstractSerializer, getData) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, resetColumns) { + zval _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "data"); -} - -static PHP_METHOD(Phalcon_Storage_Serializer_AbstractSerializer, isSuccess) -{ + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - RETURN_MEMBER(getThis(), "isSuccess"); + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "COLUMNS"); + zephir_update_property_array(this_ptr, SL("store"), &_1, &_0); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Serializer_AbstractSerializer, setData) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, resetFrom) { - zval *data, data_sub; + zval _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(data) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &data); - zephir_update_property_zval(this_ptr, ZEND_STRL("data"), data); -} - -static PHP_METHOD(Phalcon_Storage_Serializer_AbstractSerializer, isSerializable) -{ - zend_bool _0, _1; - zval *data, data_sub; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZVAL_UNDEF(&data_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(data) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &data); - _0 = Z_TYPE_P(data) == IS_NULL; - if (!(_0)) { - _0 = 1 == (Z_TYPE_P(data) == IS_TRUE || Z_TYPE_P(data) == IS_FALSE); - } - _1 = _0; - if (!(_1)) { - _1 = 1 == zephir_is_numeric(data); - } - RETURN_BOOL(!(_1)); + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "FROM"); + zephir_update_property_array(this_ptr, SL("store"), &_1, &_0); + ZEPHIR_MM_RESTORE(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Storage_Serializer_Base64) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, resetWhere) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Serializer, Base64, phalcon, storage_serializer_base64, phalcon_storage_serializer_abstractserializer_ce, phalcon_storage_serializer_base64_method_entry, 0); + zval _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "WHERE"); + zephir_update_property_array(this_ptr, SL("store"), &_1, &_0); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Serializer_Base64, serialize) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, resetGroupBy) { zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); @@ -132044,295 +132136,220 @@ static PHP_METHOD(Phalcon_Storage_Serializer_Base64, serialize) ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_memory_observe(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC); - if (Z_TYPE_P(&_0) != IS_STRING) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Data for the serializer must of type string", "phalcon/Storage/Serializer/Base64.zep", 27); - return; - } - zephir_read_property(&_1, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_FUNCTION("base64_encode", NULL, 231, &_1); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "GROUP"); + zephir_update_property_array(this_ptr, SL("store"), &_1, &_0); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Serializer_Base64, unserialize) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, resetHaving) { + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval data_sub, __$true, __$false, result, _0, _1; - zval *data; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(data) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &data); + ZEPHIR_INIT_VAR(&_0); - zephir_gettype(&_0, data); - if (!ZEPHIR_IS_STRING_IDENTICAL(&_0, "string")) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Data for the unserializer must of type string", "phalcon/Storage/Serializer/Base64.zep", 47); - return; - } - ZVAL_BOOL(&_1, 1); - ZEPHIR_CALL_METHOD(&result, this_ptr, "phpbase64decode", NULL, 0, data, &_1); - zephir_check_call_status(); - if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&result))) { - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSuccess"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSuccess"), &__$false); - } - ZEPHIR_INIT_NVAR(&result); - ZVAL_STRING(&result, ""); - } else { - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSuccess"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSuccess"), &__$false); - } - } - zephir_update_property_zval(this_ptr, ZEND_STRL("data"), &result); + array_init(&_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "HAVING"); + zephir_update_property_array(this_ptr, SL("store"), &_1, &_0); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Serializer_Base64, phpBase64Decode) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, resetOrderBy) { + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool strict; - zval *input_param = NULL, *strict_param = NULL, _0; - zval input; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&input); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(input) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(strict) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &input_param, &strict_param); - zephir_get_strval(&input, input_param); - if (!strict_param) { - strict = 0; - } else { - } - ZVAL_BOOL(&_0, (strict ? 1 : 0)); - ZEPHIR_RETURN_CALL_FUNCTION("base64_decode", NULL, 230, &input, &_0); - zephir_check_call_status(); - RETURN_MM(); -} - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Storage_Serializer_Igbinary) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Serializer, Igbinary, phalcon, storage_serializer_igbinary, phalcon_storage_serializer_abstractserializer_ce, phalcon_storage_serializer_igbinary_method_entry, 0); - - return SUCCESS; + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "ORDER"); + zephir_update_property_array(this_ptr, SL("store"), &_1, &_0); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Serializer_Igbinary, serialize) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, resetLimit) { + zval _0, _1, _2, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$true, __$false, result, _0, _1, _2; - zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_1, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "isserializable", NULL, 0, &_1); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - RETURN_MM_MEMBER(getThis(), "data"); - } - zephir_read_property(&_2, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&result, this_ptr, "doserialize", NULL, 0, &_2); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&result) == IS_NULL)) { - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSuccess"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSuccess"), &__$false); - } - ZEPHIR_INIT_NVAR(&result); - ZVAL_STRING(&result, ""); - } else { - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSuccess"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSuccess"), &__$false); - } - } - RETURN_CCTOR(&result); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "LIMIT"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_LONG(&_1, 0); + zephir_update_property_array(this_ptr, SL("store"), &_0, &_1); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "OFFSET"); + ZEPHIR_INIT_VAR(&_3); + ZVAL_LONG(&_3, 0); + zephir_update_property_array(this_ptr, SL("store"), &_2, &_3); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Serializer_Igbinary, unserialize) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, resetFlags) { - zend_bool _8$$4; + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval data_sub, __$false, __$true, result, version, _0, _1$$4, _2$$4, _3$$4, _4$$5, _5$$5, _6$$6, _7$$6; - zval *data; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data_sub); - ZVAL_BOOL(&__$false, 0); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&version); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_6$$6); - ZVAL_UNDEF(&_7$$6); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(data) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &data); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "isserializable", NULL, 0, data); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("data"), data); - } else { - ZEPHIR_CALL_FUNCTION(&version, "phpversion", NULL, 133); - zephir_check_call_status(); - ZEPHIR_GLOBAL(warning).enable = zend_is_true(&__$false); - ZEPHIR_INIT_VAR(&_1$$4); - ZVAL_STRING(&_1$$4, "8.0"); - ZEPHIR_INIT_VAR(&_2$$4); - ZVAL_STRING(&_2$$4, ">="); - ZEPHIR_CALL_FUNCTION(&_3$$4, "version_compare", NULL, 134, &version, &_1$$4, &_2$$4); - zephir_check_call_status(); - if (zephir_is_true(&_3$$4)) { - ZEPHIR_INIT_VAR(&_4$$5); - ZEPHIR_INIT_NVAR(&_4$$5); - zephir_create_closure_ex(&_4$$5, NULL, phalcon_2__closure_ce, SL("__invoke")); - ZVAL_LONG(&_5$$5, 2); - ZEPHIR_CALL_FUNCTION(NULL, "set_error_handler", NULL, 135, &_4$$5, &_5$$5); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_VAR(&_6$$6); - ZEPHIR_INIT_NVAR(&_6$$6); - zephir_create_closure_ex(&_6$$6, NULL, phalcon_3__closure_ce, SL("__invoke")); - ZVAL_LONG(&_7$$6, 2); - ZEPHIR_CALL_FUNCTION(NULL, "set_error_handler", NULL, 135, &_6$$6, &_7$$6); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&result, this_ptr, "dounserialize", NULL, 0, data); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(NULL, "restore_error_handler", NULL, 136); - zephir_check_call_status(); - _8$$4 = ZEPHIR_GLOBAL(warning).enable; - if (!(_8$$4)) { - _8$$4 = ZEPHIR_IS_FALSE_IDENTICAL(&result); - } - if (UNEXPECTED(_8$$4)) { - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSuccess"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSuccess"), &__$false); - } - ZEPHIR_INIT_NVAR(&result); - ZVAL_STRING(&result, ""); - } else { - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSuccess"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSuccess"), &__$false); - } - } - zephir_update_property_zval(this_ptr, ZEND_STRL("data"), &result); - } + + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "FLAGS"); + zephir_update_property_array(this_ptr, SL("store"), &_1, &_0); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Serializer_Igbinary, phpIgbinarySerialize) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, buildFlags) { + zval _0, _1, _2, _3, _4, _5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *value, value_sub; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &value); - ZEPHIR_RETURN_CALL_FUNCTION("igbinary_serialize", NULL, 141, value); - zephir_check_call_status(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_1, &_0, SL("FLAGS"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractQuery.zep", 255); + if (ZEPHIR_IS_EMPTY(&_1)) { + RETURN_MM_STRING(""); + } + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_INIT_VAR(&_3); + zephir_read_property(&_4, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_5, &_4, SL("FLAGS"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractQuery.zep", 259); + zephir_array_keys(&_3, &_5); + zephir_fast_join_str(&_2, SL(" "), &_3); + ZEPHIR_CONCAT_SV(return_value, " ", &_2); RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Serializer_Igbinary, doSerialize) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, buildReturning) { + zval _0, _1, _2, _3, _4, _5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *value, value_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &value); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "phpigbinaryserialize", NULL, 0, value); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_1, &_0, SL("RETURNING"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractQuery.zep", 269); + if (ZEPHIR_IS_EMPTY(&_1)) { + RETURN_MM_STRING(""); + } + zephir_read_property(&_3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_4, &_3, SL("RETURNING"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/AbstractQuery.zep", 273); + ZEPHIR_INIT_VAR(&_5); + ZVAL_STRING(&_5, ","); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "indent", NULL, 0, &_4, &_5); zephir_check_call_status(); + ZEPHIR_CONCAT_SV(return_value, " RETURNING", &_2); RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Serializer_Igbinary, doUnserialize) +static PHP_METHOD(Phalcon_DataMapper_Query_AbstractQuery, indent) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *value, value_sub; + zval glue, _1; + zval *collection_param = NULL, *glue_param = NULL, _0; + zval collection; - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(value) + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&glue); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(collection) + Z_PARAM_OPTIONAL + Z_PARAM_STR(glue) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &value); - ZEPHIR_RETURN_CALL_FUNCTION("igbinary_unserialize", NULL, 142, value); - zephir_check_call_status(); + zephir_fetch_params(1, 1, 1, &collection_param, &glue_param); + zephir_get_arrval(&collection, collection_param); + if (!glue_param) { + ZEPHIR_INIT_VAR(&glue); + ZVAL_STRING(&glue, ""); + } else { + zephir_get_strval(&glue, glue_param); + } + if (ZEPHIR_IS_EMPTY(&collection)) { + RETURN_MM_STRING(""); + } + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_VS(&_1, &glue, " "); + zephir_fast_join(&_0, &_1, &collection); + ZEPHIR_CONCAT_SV(return_value, " ", &_0); RETURN_MM(); } +zend_object *zephir_init_properties_Phalcon_DataMapper_Query_AbstractQuery(zend_class_entry *class_type) +{ + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("store"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } +} + @@ -132343,191 +132360,348 @@ static PHP_METHOD(Phalcon_Storage_Serializer_Igbinary, doUnserialize) -ZEPHIR_INIT_CLASS(Phalcon_Storage_Serializer_Json) +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Query_Bind) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Serializer, Json, phalcon, storage_serializer_json, phalcon_storage_serializer_abstractserializer_ce, phalcon_storage_serializer_json_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\DataMapper\\Query, Bind, phalcon, datamapper_query_bind, phalcon_datamapper_query_bind_method_entry, 0); + + zend_declare_property_long(phalcon_datamapper_query_bind_ce, SL("inlineCount"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_datamapper_query_bind_ce, SL("store"), ZEND_ACC_PROTECTED); + phalcon_datamapper_query_bind_ce->create_object = zephir_init_properties_Phalcon_DataMapper_Query_Bind; - zend_declare_property_null(phalcon_storage_serializer_json_ce, SL("decode"), ZEND_ACC_PRIVATE); - zend_declare_property_null(phalcon_storage_serializer_json_ce, SL("encode"), ZEND_ACC_PRIVATE); return SUCCESS; } -static PHP_METHOD(Phalcon_Storage_Serializer_Json, __construct) +static PHP_METHOD(Phalcon_DataMapper_Query_Bind, bindInline) { + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *data = NULL, data_sub, __$null, _0, _1; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *value, value_sub, *type_param = NULL, key, _3, _4, _5, _1$$3, _2$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(value) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(data) + Z_PARAM_LONG(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &data); - if (!data) { - data = &data_sub; - data = &__$null; + zephir_fetch_params(1, 1, 1, &value, &type_param); + if (!type_param) { + type = -1; + } else { + } + _0 = Z_TYPE_P(value) == IS_OBJECT; + if (_0) { + _0 = zephir_instance_of_ev(value, phalcon_datamapper_query_select_ce); } - ZEPHIR_INIT_VAR(&_0); - object_init_ex(&_0, phalcon_support_helper_json_encode_ce); - if (zephir_has_constructor(&_0)) { - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); + if (_0) { + ZEPHIR_CALL_METHOD(&_1$$3, value, "getstatement", NULL, 0); zephir_check_call_status(); + ZEPHIR_CONCAT_SVS(return_value, "(", &_1$$3, ")"); + RETURN_MM(); } - - zephir_update_property_zval(this_ptr, ZEND_STRL("encode"), &_0); - ZEPHIR_INIT_VAR(&_1); - object_init_ex(&_1, phalcon_support_helper_json_decode_ce); - if (zephir_has_constructor(&_1)) { - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 0); + if (Z_TYPE_P(value) == IS_ARRAY) { + ZVAL_LONG(&_2$$4, type); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "inlinearray", NULL, 0, value, &_2$$4); zephir_check_call_status(); + RETURN_MM(); } - - zephir_update_property_zval(this_ptr, ZEND_STRL("decode"), &_1); - ZEPHIR_CALL_PARENT(NULL, phalcon_storage_serializer_json_ce, getThis(), "__construct", NULL, 0, data); + zephir_read_property(&_3, this_ptr, ZEND_STRL("inlineCount"), PH_NOISY_CC | PH_READONLY); + ZVAL_UNDEF(&_4); + ZVAL_LONG(&_4, (zephir_get_numberval(&_3) + 1)); + zephir_update_property_zval(this_ptr, ZEND_STRL("inlineCount"), &_4); + zephir_read_property(&_4, this_ptr, ZEND_STRL("inlineCount"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&key); + ZEPHIR_CONCAT_SVS(&key, "__", &_4, "__"); + ZVAL_LONG(&_5, type); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setvalue", NULL, 0, &key, value, &_5); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + ZEPHIR_CONCAT_SV(return_value, ":", &key); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Serializer_Json, serialize) +static PHP_METHOD(Phalcon_DataMapper_Query_Bind, remove) { - zval _4$$3; - zend_bool _1; - zval _0, _2, _5, _6, _7, _8, _3$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL, store, _0; + zval key; zval *this_ptr = getThis(); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&store); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(key) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_memory_observe(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC); - _1 = Z_TYPE_P(&_0) == IS_OBJECT; - if (_1) { - zephir_memory_observe(&_2); - zephir_read_property(&_2, this_ptr, ZEND_STRL("data"), PH_NOISY_CC); - _1 = !(zephir_is_instance_of(&_2, SL("JsonSerializable"))); - } - if (_1) { - ZEPHIR_INIT_VAR(&_3$$3); - object_init_ex(&_3$$3, spl_ce_InvalidArgumentException); - ZEPHIR_INIT_VAR(&_4$$3); - ZEPHIR_CONCAT_SS(&_4$$3, "Data for the JSON serializer cannot be of type 'object' ", "without implementing 'JsonSerializable'"); - ZEPHIR_CALL_METHOD(NULL, &_3$$3, "__construct", NULL, 200, &_4$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_3$$3, "phalcon/Storage/Serializer/Json.zep", 54); - ZEPHIR_MM_RESTORE(); - return; - } - zephir_read_property(&_6, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_5, this_ptr, "isserializable", NULL, 0, &_6); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_5)) { - RETURN_MM_MEMBER(getThis(), "data"); - } - zephir_read_property(&_7, this_ptr, ZEND_STRL("encode"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_8, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_METHOD(&_7, "__invoke", NULL, 0, &_8); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&store, &_0); + zephir_array_unset(&store, &key, PH_SEPARATE); + zephir_update_property_zval(this_ptr, ZEND_STRL("store"), &store); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Serializer_Json, unserialize) +static PHP_METHOD(Phalcon_DataMapper_Query_Bind, setValue) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval data_sub, _0, _1$$4, _2$$4; - zval *data; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL, *value, value_sub, *type_param = NULL, localType; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data_sub); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&localType); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(data) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(key) + Z_PARAM_ZVAL(value) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &data); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "isserializable", NULL, 0, data); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("data"), data); + zephir_fetch_params(1, 2, 1, &key_param, &value, &type_param); + zephir_get_strval(&key, key_param); + if (!type_param) { + type = -1; } else { - zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("decode"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_2$$4, &_1$$4, "__invoke", NULL, 0, data); + } + ZEPHIR_INIT_VAR(&localType); + ZVAL_LONG(&localType, type); + if (ZEPHIR_IS_LONG_IDENTICAL(&localType, -1)) { + ZEPHIR_CALL_METHOD(&localType, this_ptr, "gettype", NULL, 0, value); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("data"), &_2$$4); } + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 2, 0); + zephir_array_fast_append(&_0, value); + zephir_array_fast_append(&_0, &localType); + zephir_update_property_array(this_ptr, SL("store"), &key, &_0); ZEPHIR_MM_RESTORE(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Storage_Serializer_MemcachedIgbinary) +static PHP_METHOD(Phalcon_DataMapper_Query_Bind, setValues) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Serializer, MemcachedIgbinary, phalcon, storage_serializer_memcachedigbinary, phalcon_storage_serializer_none_ce, NULL, 0); + zend_string *_3; + zend_ulong _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_5 = NULL; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *values_param = NULL, *type_param = NULL, key, value, *_0, _1, _4$$3, _6$$4; + zval values; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&values); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_6$$4); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(values) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(type) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &values_param, &type_param); + zephir_get_arrval(&values, values_param); + if (!type_param) { + type = -1; + } else { + } + zephir_is_iterable(&values, 0, "phalcon/DataMapper/Query/Bind.zep", 108); + if (Z_TYPE_P(&values) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&values), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&key); + if (_3 != NULL) { + ZVAL_STR_COPY(&key, _3); + } else { + ZVAL_LONG(&key, _2); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0); + ZVAL_LONG(&_4$$3, type); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setvalue", &_5, 0, &key, &value, &_4$$3); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &values, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &values, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &values, "current", NULL, 0); + zephir_check_call_status(); + ZVAL_LONG(&_6$$4, type); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setvalue", &_5, 0, &key, &value, &_6$$4); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + ZEPHIR_MM_RESTORE(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Storage_Serializer_MemcachedJson) +static PHP_METHOD(Phalcon_DataMapper_Query_Bind, toArray) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Serializer, MemcachedJson, phalcon, storage_serializer_memcachedjson, phalcon_storage_serializer_none_ce, NULL, 0); - return SUCCESS; + RETURN_MEMBER(getThis(), "store"); } +static PHP_METHOD(Phalcon_DataMapper_Query_Bind, getType) +{ + zval *value, value_sub; + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &value); + if (Z_TYPE_P(value) == IS_NULL) { + RETURN_LONG(0); + } + if (((Z_TYPE_P(value) == IS_TRUE || Z_TYPE_P(value) == IS_FALSE) == 1)) { + RETURN_LONG(5); + } + if (Z_TYPE_P(value) == IS_LONG) { + RETURN_LONG(1); + } + RETURN_LONG(2); +} +static PHP_METHOD(Phalcon_DataMapper_Query_Bind, inlineArray) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_5 = NULL; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *data_param = NULL, *type_param = NULL, key, value, *_0, _1, _11, _2$$3, _3$$3, _4$$3, _6$$3, _7$$4, _8$$4, _9$$4, _10$$4; + zval data, keys; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H -#endif - - - - + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&keys); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$4); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&_10$$4); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ARRAY(data) + Z_PARAM_LONG(type) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &data_param, &type_param); + zephir_get_arrval(&data, data_param); + ZEPHIR_INIT_VAR(&keys); + array_init(&keys); + zephir_is_iterable(&data, 0, "phalcon/DataMapper/Query/Bind.zep", 167); + if (Z_TYPE_P(&data) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&data), _0) + { + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0); + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("inlineCount"), PH_NOISY_CC | PH_READONLY); + ZVAL_UNDEF(&_3$$3); + ZVAL_LONG(&_3$$3, (zephir_get_numberval(&_2$$3) + 1)); + zephir_update_property_zval(this_ptr, ZEND_STRL("inlineCount"), &_3$$3); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("inlineCount"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&key); + ZEPHIR_CONCAT_SVS(&key, "__", &_3$$3, "__"); + ZVAL_LONG(&_4$$3, type); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setvalue", &_5, 0, &key, &value, &_4$$3); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_6$$3); + ZEPHIR_CONCAT_SV(&_6$$3, ":", &key); + zephir_array_append(&keys, &_6$$3, PH_SEPARATE, "phalcon/DataMapper/Query/Bind.zep", 164); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &data, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_7$$4, this_ptr, ZEND_STRL("inlineCount"), PH_NOISY_CC | PH_READONLY); + ZVAL_UNDEF(&_8$$4); + ZVAL_LONG(&_8$$4, (zephir_get_numberval(&_7$$4) + 1)); + zephir_update_property_zval(this_ptr, ZEND_STRL("inlineCount"), &_8$$4); + zephir_read_property(&_8$$4, this_ptr, ZEND_STRL("inlineCount"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&key); + ZEPHIR_CONCAT_SVS(&key, "__", &_8$$4, "__"); + ZVAL_LONG(&_9$$4, type); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setvalue", &_5, 0, &key, &value, &_9$$4); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_10$$4); + ZEPHIR_CONCAT_SV(&_10$$4, ":", &key); + zephir_array_append(&keys, &_10$$4, PH_SEPARATE, "phalcon/DataMapper/Query/Bind.zep", 164); + ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_VAR(&_11); + zephir_fast_join_str(&_11, SL(", "), &keys); + ZEPHIR_CONCAT_SVS(return_value, "(", &_11, ")"); + RETURN_MM(); +} -ZEPHIR_INIT_CLASS(Phalcon_Storage_Serializer_MemcachedPhp) +zend_object *zephir_init_properties_Phalcon_DataMapper_Query_Bind(zend_class_entry *class_type) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Serializer, MemcachedPhp, phalcon, storage_serializer_memcachedphp, phalcon_storage_serializer_none_ce, NULL, 0); + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + - return SUCCESS; + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("store"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } } @@ -132540,109 +132714,102 @@ ZEPHIR_INIT_CLASS(Phalcon_Storage_Serializer_MemcachedPhp) -ZEPHIR_INIT_CLASS(Phalcon_Storage_Serializer_Msgpack) +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Query_Delete) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Serializer, Msgpack, phalcon, storage_serializer_msgpack, phalcon_storage_serializer_igbinary_ce, phalcon_storage_serializer_msgpack_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Query, Delete, phalcon, datamapper_query_delete, phalcon_datamapper_query_abstractconditions_ce, phalcon_datamapper_query_delete_method_entry, 0); return SUCCESS; } -static PHP_METHOD(Phalcon_Storage_Serializer_Msgpack, doSerialize) +static PHP_METHOD(Phalcon_DataMapper_Query_Delete, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *value, value_sub, _0; + zval *connection, connection_sub, *bind, bind_sub, _0, _1, _2, _3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&connection_sub); + ZVAL_UNDEF(&bind_sub); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(value) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_datamapper_pdo_connection_ce) + Z_PARAM_OBJECT_OF_CLASS(bind, phalcon_datamapper_query_bind_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &value); - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_FUNCTION("msgpack_pack", NULL, 0, &_0); + zephir_fetch_params(1, 2, 0, &connection, &bind); + ZEPHIR_CALL_PARENT(NULL, phalcon_datamapper_query_delete_ce, getThis(), "__construct", NULL, 0, connection, bind); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "FROM"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, ""); + zephir_update_property_array(this_ptr, SL("store"), &_0, &_1); + ZEPHIR_INIT_VAR(&_2); + array_init(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "RETURNING"); + zephir_update_property_array(this_ptr, SL("store"), &_3, &_2); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Serializer_Msgpack, doUnserialize) +static PHP_METHOD(Phalcon_DataMapper_Query_Delete, from) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *value, value_sub; + zval *table_param = NULL, _0; + zval table; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(value) + Z_PARAM_STR(table) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &value); - ZEPHIR_RETURN_CALL_FUNCTION("msgpack_unpack", NULL, 0, value); - zephir_check_call_status(); - RETURN_MM(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Storage_Serializer_None) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Serializer, None, phalcon, storage_serializer_none, phalcon_storage_serializer_abstractserializer_ce, phalcon_storage_serializer_none_method_entry, 0); - - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Storage_Serializer_None, serialize) -{ - - RETURN_MEMBER(getThis(), "data"); + zephir_fetch_params(1, 1, 0, &table_param); + zephir_get_strval(&table, table_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "FROM"); + zephir_update_property_array(this_ptr, SL("store"), &_0, &table); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Serializer_None, unserialize) +static PHP_METHOD(Phalcon_DataMapper_Query_Delete, returning) { - zval data_sub; - zval *data; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *columns_param = NULL, _0, _1, _2, _3; + zval columns; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data_sub); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(data) + Z_PARAM_ARRAY(columns) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &data); - zephir_update_property_zval(this_ptr, ZEND_STRL("data"), data); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Storage_Serializer_Php) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Serializer, Php, phalcon, storage_serializer_php, phalcon_storage_serializer_abstractserializer_ce, phalcon_storage_serializer_php_method_entry, 0); - - return SUCCESS; + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &columns_param); + zephir_get_arrval(&columns, columns_param); + ZEPHIR_INIT_VAR(&_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_2, &_1, SL("RETURNING"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Delete.zep", 63); + zephir_fast_array_merge(&_0, &_2, &columns); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "RETURNING"); + zephir_update_property_array(this_ptr, SL("store"), &_3, &_0); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Serializer_Php, serialize) +static PHP_METHOD(Phalcon_DataMapper_Query_Delete, getStatement) { - zval _0, _1, _2; + zval _0, _1, _2, _3, _4, _5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); @@ -132650,241 +132817,55 @@ static PHP_METHOD(Phalcon_Storage_Serializer_Php, serialize) ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_1, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "isserializable", NULL, 0, &_1); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "buildflags", NULL, 0); zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - RETURN_MM_MEMBER(getThis(), "data"); - } - zephir_read_property(&_2, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_FUNCTION("serialize", NULL, 15, &_2); + zephir_read_property(&_1, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_2, &_1, SL("FROM"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Delete.zep", 78); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "WHERE"); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "buildcondition", NULL, 0, &_4); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "buildreturning", NULL, 0); zephir_check_call_status(); + ZEPHIR_CONCAT_SVSVVV(return_value, "DELETE", &_0, " FROM ", &_2, &_3, &_5); RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Serializer_Php, unserialize) +static PHP_METHOD(Phalcon_DataMapper_Query_Delete, reset) { - zend_bool _8; + zval _0, _1, _2, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval data_sub, __$false, __$true, result, version, _0, _1, _2, _3, _4$$4, _5$$4, _6$$5, _7$$5; - zval *data; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data_sub); - ZVAL_BOOL(&__$false, 0); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&version); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_7$$5); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(data) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &data); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "isserializable", NULL, 0, data); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("data"), data); - RETURN_MM_NULL(); - } - ZEPHIR_CALL_FUNCTION(&version, "phpversion", NULL, 133); + + ZEPHIR_CALL_PARENT(NULL, phalcon_datamapper_query_delete_ce, getThis(), "reset", NULL, 0); zephir_check_call_status(); - ZEPHIR_GLOBAL(warning).enable = zend_is_true(&__$false); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "FROM"); ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "8.0"); + ZVAL_STRING(&_1, ""); + zephir_update_property_array(this_ptr, SL("store"), &_0, &_1); ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, ">="); - ZEPHIR_CALL_FUNCTION(&_3, "version_compare", NULL, 134, &version, &_1, &_2); - zephir_check_call_status(); - if (zephir_is_true(&_3)) { - ZEPHIR_INIT_VAR(&_4$$4); - ZEPHIR_INIT_NVAR(&_4$$4); - zephir_create_closure_ex(&_4$$4, NULL, phalcon_10__closure_ce, SL("__invoke")); - ZVAL_LONG(&_5$$4, 8); - ZEPHIR_CALL_FUNCTION(NULL, "set_error_handler", NULL, 135, &_4$$4, &_5$$4); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_VAR(&_6$$5); - ZEPHIR_INIT_NVAR(&_6$$5); - zephir_create_closure_ex(&_6$$5, NULL, phalcon_11__closure_ce, SL("__invoke")); - ZVAL_LONG(&_7$$5, 8); - ZEPHIR_CALL_FUNCTION(NULL, "set_error_handler", NULL, 135, &_6$$5, &_7$$5); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(&result, this_ptr, "phpunserialize", NULL, 0, data); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(NULL, "restore_error_handler", NULL, 136); - zephir_check_call_status(); - _8 = ZEPHIR_GLOBAL(warning).enable; - if (!(_8)) { - _8 = ZEPHIR_IS_FALSE_IDENTICAL(&result); - } - if (UNEXPECTED(_8)) { - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSuccess"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSuccess"), &__$false); - } - ZEPHIR_INIT_NVAR(&result); - ZVAL_STRING(&result, ""); - } else { - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSuccess"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSuccess"), &__$false); - } - } - zephir_update_property_zval(this_ptr, ZEND_STRL("data"), &result); + array_init(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "RETURNING"); + zephir_update_property_array(this_ptr, SL("store"), &_3, &_2); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Serializer_Php, phpUnserialize) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval *data_param = NULL, *options_param = NULL; - zval data; - - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(data) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &data_param, &options_param); - zephir_get_strval(&data, data_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - ZEPHIR_RETURN_CALL_FUNCTION("unserialize", NULL, 16, &data, &options); - zephir_check_call_status(); - RETURN_MM(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Storage_Serializer_RedisIgbinary) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Serializer, RedisIgbinary, phalcon, storage_serializer_redisigbinary, phalcon_storage_serializer_none_ce, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Storage_Serializer_RedisJson) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Serializer, RedisJson, phalcon, storage_serializer_redisjson, phalcon_storage_serializer_none_ce, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Storage_Serializer_RedisMsgpack) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Serializer, RedisMsgpack, phalcon, storage_serializer_redismsgpack, phalcon_storage_serializer_none_ce, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Storage_Serializer_RedisNone) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Serializer, RedisNone, phalcon, storage_serializer_redisnone, phalcon_storage_serializer_none_ce, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Storage_Serializer_RedisPhp) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Serializer, RedisPhp, phalcon, storage_serializer_redisphp, phalcon_storage_serializer_none_ce, NULL, 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Storage_Serializer_SerializerInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Storage\\Serializer, SerializerInterface, phalcon, storage_serializer_serializerinterface, phalcon_storage_serializer_serializerinterface_method_entry); - - zend_class_implements(phalcon_storage_serializer_serializerinterface_ce, 1, zend_ce_serializable); - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Storage_Serializer_SerializerInterface, getData); -ZEPHIR_DOC_METHOD(Phalcon_Storage_Serializer_SerializerInterface, setData); @@ -132895,560 +132876,600 @@ ZEPHIR_DOC_METHOD(Phalcon_Storage_Serializer_SerializerInterface, setData); -ZEPHIR_INIT_CLASS(Phalcon_Storage_Adapter_AbstractAdapter) +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Query_Insert) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Storage\\Adapter, AbstractAdapter, phalcon, storage_adapter_abstractadapter, phalcon_storage_adapter_abstractadapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_storage_adapter_abstractadapter_ce, SL("adapter"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_storage_adapter_abstractadapter_ce, SL("defaultSerializer"), "php", ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_storage_adapter_abstractadapter_ce, SL("lifetime"), 3600, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_storage_adapter_abstractadapter_ce, SL("options"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_storage_adapter_abstractadapter_ce, SL("prefix"), "ph-memo-", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_storage_adapter_abstractadapter_ce, SL("serializer"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_storage_adapter_abstractadapter_ce, SL("serializerFactory"), ZEND_ACC_PROTECTED); - phalcon_storage_adapter_abstractadapter_ce->create_object = zephir_init_properties_Phalcon_Storage_Adapter_AbstractAdapter; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Query, Insert, phalcon, datamapper_query_insert, phalcon_datamapper_query_abstractquery_ce, phalcon_datamapper_query_insert_method_entry, 0); - zend_class_implements(phalcon_storage_adapter_abstractadapter_ce, 1, phalcon_storage_adapter_adapterinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, __construct) +static PHP_METHOD(Phalcon_DataMapper_Query_Insert, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval *factory, factory_sub, *options_param = NULL, _0, _1, _2, _3, _4, _5, _6, _7$$3; + zval *connection, connection_sub, *bind, bind_sub, _0, _1, _2, _3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&factory_sub); + ZVAL_UNDEF(&connection_sub); + ZVAL_UNDEF(&bind_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_storage_serializerfactory_ce) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_datamapper_pdo_connection_ce) + Z_PARAM_OBJECT_OF_CLASS(bind, phalcon_datamapper_query_bind_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &factory, &options_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("serializerFactory"), factory); + zephir_fetch_params(1, 2, 0, &connection, &bind); + ZEPHIR_CALL_PARENT(NULL, phalcon_datamapper_query_insert_ce, getThis(), "__construct", NULL, 0, connection, bind); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "FROM"); ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "defaultSerializer"); + ZVAL_STRING(&_1, ""); + zephir_update_property_array(this_ptr, SL("store"), &_0, &_1); ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "php"); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getarrval", NULL, 0, &options, &_1, &_2); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_3, "mb_strtolower", NULL, 10, &_0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultSerializer"), &_3); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "lifetime"); - ZVAL_LONG(&_5, 3600); - ZEPHIR_CALL_METHOD(&_4, this_ptr, "getarrval", NULL, 0, &options, &_1, &_5); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("lifetime"), &_4); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "serializer"); - ZVAL_NULL(&_5); - ZEPHIR_CALL_METHOD(&_6, this_ptr, "getarrval", NULL, 0, &options, &_1, &_5); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("serializer"), &_6); - if (zephir_array_isset_string(&options, SL("prefix"))) { - zephir_array_fetch_string(&_7$$3, &options, SL("prefix"), PH_NOISY | PH_READONLY, "phalcon/Storage/Adapter/AbstractAdapter.zep", 99); - zephir_update_property_zval(this_ptr, ZEND_STRL("prefix"), &_7$$3); - } - zephir_array_unset_string(&options, SL("defaultSerializer"), PH_SEPARATE); - zephir_array_unset_string(&options, SL("lifetime"), PH_SEPARATE); - zephir_array_unset_string(&options, SL("serializer"), PH_SEPARATE); - zephir_array_unset_string(&options, SL("prefix"), PH_SEPARATE); - zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); + array_init(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "RETURNING"); + zephir_update_property_array(this_ptr, SL("store"), &_3, &_2); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, clear) -{ -} - -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, decrement) -{ -} - -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, delete) -{ -} - -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, get) +static PHP_METHOD(Phalcon_DataMapper_Query_Insert, column) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null, content, _0; - zval key; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *column_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _1$$3, _2$$3; + zval column, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&content); + ZVAL_UNDEF(&column); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&value_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(key) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(column) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) + Z_PARAM_ZVAL_OR_NULL(value) + Z_PARAM_LONG(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key_param, &defaultValue); - zephir_get_strval(&key, key_param); - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; + zephir_fetch_params(1, 1, 2, &column_param, &value, &type_param); + zephir_get_strval(&column, column_param); + if (!value) { + value = &value_sub; + value = &__$null; } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, 0, &key); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); + if (!type_param) { + type = -1; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_CONCAT_SV(&_0, ":", &column); + zephir_update_property_array_multi(this_ptr, SL("store"), &_0, SL("sz"), 3, SL("COLUMNS"), &column); + if (Z_TYPE_P(value) != IS_NULL) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_2$$3, type); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "setvalue", NULL, 0, &column, value, &_2$$3); + zephir_check_call_status(); } - ZEPHIR_CALL_METHOD(&content, this_ptr, "doget", NULL, 0, &key); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getunserializeddata", NULL, 0, &content, defaultValue); - zephir_check_call_status(); - RETURN_MM(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, getAdapter) +static PHP_METHOD(Phalcon_DataMapper_Query_Insert, columns) { + zend_string *_3; + zend_ulong _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *columns_param = NULL, column, value, *_0, _1; + zval columns; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "adapter"); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&column); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(columns) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &columns_param); + zephir_get_arrval(&columns, columns_param); + zephir_is_iterable(&columns, 0, "phalcon/DataMapper/Query/Insert.zep", 76); + if (Z_TYPE_P(&columns) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&columns), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&column); + if (_3 != NULL) { + ZVAL_STR_COPY(&column, _3); + } else { + ZVAL_LONG(&column, _2); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0); + if (Z_TYPE_P(&column) == IS_LONG) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "column", &_4, 0, &value); + zephir_check_call_status(); + } else { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "column", &_4, 0, &column, &value); + zephir_check_call_status(); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &columns, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&column, &columns, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &columns, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&column) == IS_LONG) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "column", &_4, 0, &value); + zephir_check_call_status(); + } else { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "column", &_4, 0, &column, &value); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&column); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, getDefaultSerializer) +static PHP_METHOD(Phalcon_DataMapper_Query_Insert, into) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *table_param = NULL, _0; + zval table; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "defaultSerializer"); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(table) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &table_param); + zephir_get_strval(&table, table_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "FROM"); + zephir_update_property_array(this_ptr, SL("store"), &_0, &table); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, getKeys) +static PHP_METHOD(Phalcon_DataMapper_Query_Insert, getLastInsertId) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, _0; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &name_param); + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { + zephir_get_strval(&name, name_param); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "lastinsertid", NULL, 0, &name); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, getPrefix) +static PHP_METHOD(Phalcon_DataMapper_Query_Insert, getStatement) { + zval _0, _1, _2, _3, _4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "prefix"); -} + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, has) -{ + ZEPHIR_CALL_METHOD(&_0, this_ptr, "buildflags", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_2, &_1, SL("FROM"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Insert.zep", 113); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "buildcolumns", NULL, 205); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "buildreturning", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CONCAT_SVSVVV(return_value, "INSERT", &_0, " INTO ", &_2, &_3, &_4); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, increment) +static PHP_METHOD(Phalcon_DataMapper_Query_Insert, returning) { -} + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *columns_param = NULL, _0, _1, _2, _3; + zval columns; + zval *this_ptr = getThis(); -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, set) -{ + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(columns) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &columns_param); + zephir_get_arrval(&columns, columns_param); + ZEPHIR_INIT_VAR(&_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_2, &_1, SL("RETURNING"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Insert.zep", 127); + zephir_fast_array_merge(&_0, &_2, &columns); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "RETURNING"); + zephir_update_property_array(this_ptr, SL("store"), &_3, &_0); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, setDefaultSerializer) +static PHP_METHOD(Phalcon_DataMapper_Query_Insert, reset) { + zval _0, _1, _2, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *serializer_param = NULL, _0; - zval serializer; zval *this_ptr = getThis(); - ZVAL_UNDEF(&serializer); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(serializer) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &serializer_param); - zephir_get_strval(&serializer, serializer_param); - ZEPHIR_CALL_FUNCTION(&_0, "mb_strtolower", NULL, 10, &serializer); + + ZEPHIR_CALL_PARENT(NULL, phalcon_datamapper_query_insert_ce, getThis(), "reset", NULL, 0); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultSerializer"), &_0); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "FROM"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, ""); + zephir_update_property_array(this_ptr, SL("store"), &_0, &_1); + ZEPHIR_INIT_VAR(&_2); + array_init(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "RETURNING"); + zephir_update_property_array(this_ptr, SL("store"), &_3, &_2); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, doGet) +static PHP_METHOD(Phalcon_DataMapper_Query_Insert, set) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, _0; - zval key; + zval *column_param = NULL, *value = NULL, value_sub, __$null, _0; + zval column; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&column); + ZVAL_UNDEF(&value_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(column) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - zephir_get_strval(&key, key_param); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getadapter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&_0, "get", NULL, 0, &key); + zephir_fetch_params(1, 1, 1, &column_param, &value); + zephir_get_strval(&column, column_param); + if (!value) { + value = &value_sub; + ZEPHIR_CPY_WRT(value, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(value); + } + if (Z_TYPE_P(value) == IS_NULL) { + ZEPHIR_INIT_NVAR(value); + ZVAL_STRING(value, "NULL"); + } + zephir_update_property_array_multi(this_ptr, SL("store"), value, SL("sz"), 3, SL("COLUMNS"), &column); + zephir_read_property(&_0, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "remove", NULL, 0, &column); zephir_check_call_status(); - RETURN_MM(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, getFilteredKeys) +static PHP_METHOD(Phalcon_DataMapper_Query_Insert, buildColumns) { - zval results; + zend_string *_6; + zend_ulong _5; + zval columns; + zval column, _0, _1, _2, *_3, _4, _10, _11, _12, _13, _14, _15, _16, _17, _7$$3, _9$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_8 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval prefix; - zval *keys = NULL, keys_sub, *prefix_param = NULL, key, pattern, _0, _1, *_2, _3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&keys_sub); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&column); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&prefix); - ZVAL_UNDEF(&results); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(keys) - Z_PARAM_STR(prefix) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_13); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_15); + ZVAL_UNDEF(&_16); + ZVAL_UNDEF(&_17); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&columns); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &keys, &prefix_param); - ZEPHIR_SEPARATE_PARAM(keys); - if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) { - zephir_get_strval(&prefix, prefix_param); - } else { - ZEPHIR_INIT_VAR(&prefix); - } - ZEPHIR_INIT_VAR(&results); - array_init(&results); - zephir_read_property(&_0, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&pattern); - ZEPHIR_CONCAT_VV(&pattern, &_0, &prefix); - ZEPHIR_INIT_VAR(&_1); - if (!(zephir_is_true(keys))) { - ZEPHIR_INIT_NVAR(&_1); - array_init(&_1); - } else { - ZEPHIR_CPY_WRT(&_1, keys); - } - ZEPHIR_CPY_WRT(keys, &_1); - zephir_is_iterable(keys, 0, "phalcon/Storage/Adapter/AbstractAdapter.zep", 267); - if (Z_TYPE_P(keys) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(keys), _2) + + ZEPHIR_INIT_VAR(&columns); + array_init(&columns); + zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_1, &_0, SL("COLUMNS"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Insert.zep", 176); + ZEPHIR_INIT_VAR(&_2); + zephir_is_iterable(&_1, 0, "phalcon/DataMapper/Query/Insert.zep", 180); + if (Z_TYPE_P(&_1) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_1), _5, _6, _3) { - ZEPHIR_INIT_NVAR(&key); - ZVAL_COPY(&key, _2); - if (zephir_start_with(&key, &pattern, NULL)) { - zephir_array_append(&results, &key, PH_SEPARATE, "phalcon/Storage/Adapter/AbstractAdapter.zep", 263); + ZEPHIR_INIT_NVAR(&column); + if (_6 != NULL) { + ZVAL_STR_COPY(&column, _6); + } else { + ZVAL_LONG(&column, _5); } + ZEPHIR_INIT_NVAR(&_2); + ZVAL_COPY(&_2, _3); + ZEPHIR_CALL_METHOD(&_7$$3, this_ptr, "quoteidentifier", &_8, 0, &column); + zephir_check_call_status(); + zephir_array_append(&columns, &_7$$3, PH_SEPARATE, "phalcon/DataMapper/Query/Insert.zep", 177); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, keys, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &_1, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_3, keys, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_4, &_1, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_3)) { + if (!zend_is_true(&_4)) { break; } - ZEPHIR_CALL_METHOD(&key, keys, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&column, &_1, "key", NULL, 0); zephir_check_call_status(); - if (zephir_start_with(&key, &pattern, NULL)) { - zephir_array_append(&results, &key, PH_SEPARATE, "phalcon/Storage/Adapter/AbstractAdapter.zep", 263); - } - ZEPHIR_CALL_METHOD(NULL, keys, "next", NULL, 0); + ZEPHIR_CALL_METHOD(&_2, &_1, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_9$$4, this_ptr, "quoteidentifier", &_8, 0, &column); + zephir_check_call_status(); + zephir_array_append(&columns, &_9$$4, PH_SEPARATE, "phalcon/DataMapper/Query/Insert.zep", 177); + ZEPHIR_CALL_METHOD(NULL, &_1, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&key); - RETURN_CTOR(&results); + ZEPHIR_INIT_NVAR(&_2); + ZEPHIR_INIT_NVAR(&column); + ZEPHIR_INIT_VAR(&_10); + ZEPHIR_INIT_VAR(&_12); + ZVAL_STRING(&_12, ","); + ZEPHIR_CALL_METHOD(&_11, this_ptr, "indent", NULL, 0, &columns, &_12); + zephir_check_call_status(); + zephir_fast_trim(&_10, &_11, NULL , ZEPHIR_TRIM_LEFT); + ZEPHIR_INIT_NVAR(&_12); + zephir_read_property(&_14, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_15, &_14, SL("COLUMNS"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Insert.zep", 183); + ZEPHIR_CALL_FUNCTION(&_16, "array_values", NULL, 14, &_15); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_17); + ZVAL_STRING(&_17, ","); + ZEPHIR_CALL_METHOD(&_13, this_ptr, "indent", NULL, 0, &_16, &_17); + zephir_check_call_status(); + zephir_fast_trim(&_12, &_13, NULL , ZEPHIR_TRIM_LEFT); + ZEPHIR_CONCAT_SVSVS(return_value, " (", &_10, ") VALUES (", &_12, ")"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, getPrefixedKey) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Query_QueryFactory) { - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *key = NULL, key_sub, _1; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS(Phalcon\\DataMapper\\Query, QueryFactory, phalcon, datamapper_query_queryfactory, phalcon_datamapper_query_queryfactory_method_entry, 0); - ZVAL_UNDEF(&key_sub); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(key) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key); - ZEPHIR_SEPARATE_PARAM(key); - zephir_cast_to_string(&_0, key); - ZEPHIR_CPY_WRT(key, &_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CONCAT_VV(return_value, &_1, key); - RETURN_MM(); + zend_declare_property_string(phalcon_datamapper_query_queryfactory_ce, SL("selectClass"), "", ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, getSerializedData) +static PHP_METHOD(Phalcon_DataMapper_Query_QueryFactory, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *content = NULL, content_sub, _0, _1$$3, _2$$3; + zval *selectClass_param = NULL; + zval selectClass; zval *this_ptr = getThis(); - ZVAL_UNDEF(&content_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(content) + ZVAL_UNDEF(&selectClass); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR(selectClass) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &content); - ZEPHIR_SEPARATE_PARAM(content); - zephir_read_property(&_0, this_ptr, ZEND_STRL("serializer"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) != IS_NULL) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("serializer"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "setdata", NULL, 0, content); - zephir_check_call_status(); - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("serializer"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(content, &_2$$3, "serialize", NULL, 0); - zephir_check_call_status(); + zephir_fetch_params(1, 0, 1, &selectClass_param); + if (!selectClass_param) { + ZEPHIR_INIT_VAR(&selectClass); + ZVAL_STRING(&selectClass, ""); + } else { + zephir_get_strval(&selectClass, selectClass_param); } - RETVAL_ZVAL(content, 1, 0); - RETURN_MM(); + if (ZEPHIR_IS_EMPTY(&selectClass)) { + ZEPHIR_INIT_NVAR(&selectClass); + ZVAL_STRING(&selectClass, "Phalcon\\DataMapper\\Query\\Select"); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("selectClass"), &selectClass); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, getTtl) +static PHP_METHOD(Phalcon_DataMapper_Query_QueryFactory, newBind) { - zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *ttl, ttl_sub, dateTime, _1$$4, _2$$4; - - ZVAL_UNDEF(&ttl_sub); - ZVAL_UNDEF(&dateTime); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(ttl) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &ttl); - if (Z_TYPE_P(ttl) == IS_NULL) { - RETURN_MM_MEMBER(getThis(), "lifetime"); - } - _0 = Z_TYPE_P(ttl) == IS_OBJECT; - if (_0) { - _0 = zephir_is_instance_of(ttl, SL("DateInterval")); - } - if (_0) { - ZEPHIR_INIT_VAR(&dateTime); - object_init_ex(&dateTime, php_date_get_date_ce()); - ZEPHIR_INIT_VAR(&_1$$4); - ZVAL_STRING(&_1$$4, "@0"); - ZEPHIR_CALL_METHOD(NULL, &dateTime, "__construct", NULL, 0, &_1$$4); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_2$$4, &dateTime, "add", NULL, 0, ttl); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&_2$$4, "gettimestamp", NULL, 0); + + object_init_ex(return_value, phalcon_datamapper_query_bind_ce); + if (zephir_has_constructor(return_value)) { + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0); zephir_check_call_status(); - RETURN_MM(); } - RETURN_MM_LONG(zephir_get_intval(ttl)); + + RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, getUnserializedData) +static PHP_METHOD(Phalcon_DataMapper_Query_QueryFactory, newDelete) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *content = NULL, content_sub, *defaultValue = NULL, defaultValue_sub, __$null, _0, _1$$3, _2$$3, _3$$3, _4$$3; + zval *connection, connection_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&content_sub); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&connection_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(content) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_datamapper_pdo_connection_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &content, &defaultValue); - ZEPHIR_SEPARATE_PARAM(content); - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("serializer"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) != IS_NULL) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("serializer"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "unserialize", NULL, 0, content); - zephir_check_call_status(); - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("serializer"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_3$$3, &_2$$3, "issuccess", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(!ZEPHIR_IS_TRUE_IDENTICAL(&_3$$3))) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); - } - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("serializer"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(content, &_4$$3, "getdata", NULL, 0); - zephir_check_call_status(); - } - RETVAL_ZVAL(content, 1, 0); + zephir_fetch_params(1, 1, 0, &connection); + object_init_ex(return_value, phalcon_datamapper_query_delete_ce); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "newbind", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 206, connection, &_0); + zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, initSerializer) +static PHP_METHOD(Phalcon_DataMapper_Query_QueryFactory, newInsert) { - zend_bool _1; - zval className, _0, _2, _3$$3, _4$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *connection, connection_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&className); + ZVAL_UNDEF(&connection_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_datamapper_pdo_connection_ce) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_memory_observe(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultSerializer"), PH_NOISY_CC); - _1 = 1 != ZEPHIR_IS_EMPTY(&_0); - if (_1) { - zephir_memory_observe(&_2); - zephir_read_property(&_2, this_ptr, ZEND_STRL("serializer"), PH_NOISY_CC); - _1 = Z_TYPE_P(&_2) != IS_OBJECT; - } - if (_1) { - zephir_memory_observe(&className); - zephir_read_property(&className, this_ptr, ZEND_STRL("defaultSerializer"), PH_NOISY_CC); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("serializerFactory"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_4$$3, &_3$$3, "newinstance", NULL, 0, &className); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("serializer"), &_4$$3); - } - ZEPHIR_MM_RESTORE(); + zephir_fetch_params(1, 1, 0, &connection); + object_init_ex(return_value, phalcon_datamapper_query_insert_ce); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "newbind", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 207, connection, &_0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_AbstractAdapter, getArrVal) +static PHP_METHOD(Phalcon_DataMapper_Query_QueryFactory, newSelect) { + zend_class_entry *_2; + zval selectClass; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval cast; - zval *collection_param = NULL, *index, index_sub, *defaultValue = NULL, defaultValue_sub, *cast_param = NULL, __$null, value; - zval collection; + zval *connection, connection_sub, _0, _1, _3; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&index_sub); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&cast); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 4) - Z_PARAM_ARRAY(collection) - Z_PARAM_ZVAL(index) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) - Z_PARAM_STR_OR_NULL(cast) + ZVAL_UNDEF(&connection_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&selectClass); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_datamapper_pdo_connection_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 2, &collection_param, &index, &defaultValue, &cast_param); - ZEPHIR_OBS_COPY_OR_DUP(&collection, collection_param); - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; - } - if (!cast_param) { - ZEPHIR_INIT_VAR(&cast); - } else { - if (UNEXPECTED(Z_TYPE_P(cast_param) != IS_STRING && Z_TYPE_P(cast_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'cast' must be of the type string")); + zephir_fetch_params(1, 1, 0, &connection); + zephir_read_property(&_0, this_ptr, ZEND_STRL("selectClass"), PH_NOISY_CC | PH_READONLY); + zephir_get_strval(&selectClass, &_0); + zephir_fetch_safe_class(&_1, &selectClass); + _2 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_1), Z_STRLEN_P(&_1), ZEND_FETCH_CLASS_AUTO); + if(!_2) { RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(cast_param) == IS_STRING)) { - zephir_get_strval(&cast, cast_param); - } else { - ZEPHIR_INIT_VAR(&cast); - } - } - zephir_memory_observe(&value); - if (UNEXPECTED(!(zephir_array_isset_fetch(&value, &collection, index, 0)))) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); - } - if (UNEXPECTED(zephir_is_true(&cast))) { - ZEPHIR_MAKE_REF(&value); - ZEPHIR_CALL_FUNCTION(NULL, "settype", NULL, 11, &value, &cast); - ZEPHIR_UNREF(&value); + object_init_ex(return_value, _2); + if (zephir_has_constructor(return_value)) { + ZEPHIR_CALL_METHOD(&_3, this_ptr, "newbind", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0, connection, &_3); zephir_check_call_status(); } - RETURN_CCTOR(&value); + + RETURN_MM(); } -zend_object *zephir_init_properties_Phalcon_Storage_Adapter_AbstractAdapter(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_DataMapper_Query_QueryFactory, newUpdate) { - zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *connection, connection_sub, _0; + zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } + ZVAL_UNDEF(&connection_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_datamapper_pdo_connection_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &connection); + object_init_ex(return_value, phalcon_datamapper_query_update_ce); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "newbind", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 208, connection, &_0); + zephir_check_call_status(); + RETURN_MM(); } @@ -133461,1231 +133482,1397 @@ zend_object *zephir_init_properties_Phalcon_Storage_Adapter_AbstractAdapter(zend -ZEPHIR_INIT_CLASS(Phalcon_Storage_Adapter_AdapterInterface) +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Query_Select) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Storage\\Adapter, AdapterInterface, phalcon, storage_adapter_adapterinterface, phalcon_storage_adapter_adapterinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Storage_Adapter_AdapterInterface, clear); -ZEPHIR_DOC_METHOD(Phalcon_Storage_Adapter_AdapterInterface, decrement); -ZEPHIR_DOC_METHOD(Phalcon_Storage_Adapter_AdapterInterface, delete); -ZEPHIR_DOC_METHOD(Phalcon_Storage_Adapter_AdapterInterface, get); -ZEPHIR_DOC_METHOD(Phalcon_Storage_Adapter_AdapterInterface, getAdapter); -ZEPHIR_DOC_METHOD(Phalcon_Storage_Adapter_AdapterInterface, getKeys); -ZEPHIR_DOC_METHOD(Phalcon_Storage_Adapter_AdapterInterface, getPrefix); -ZEPHIR_DOC_METHOD(Phalcon_Storage_Adapter_AdapterInterface, has); -ZEPHIR_DOC_METHOD(Phalcon_Storage_Adapter_AdapterInterface, increment); -ZEPHIR_DOC_METHOD(Phalcon_Storage_Adapter_AdapterInterface, set); -ZEPHIR_DOC_METHOD(Phalcon_Storage_Adapter_AdapterInterface, setForever); - - - -#ifdef HAVE_CONFIG_H -#endif - + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Query, Select, phalcon, datamapper_query_select, phalcon_datamapper_query_abstractconditions_ce, phalcon_datamapper_query_select_method_entry, 0); + zend_declare_property_string(phalcon_datamapper_query_select_ce, SL("asAlias"), "", ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_datamapper_query_select_ce, SL("forUpdate"), 0, ZEND_ACC_PROTECTED); + zephir_declare_class_constant_string(phalcon_datamapper_query_select_ce, SL("JOIN_INNER"), "INNER"); + zephir_declare_class_constant_string(phalcon_datamapper_query_select_ce, SL("JOIN_LEFT"), "LEFT"); + zephir_declare_class_constant_string(phalcon_datamapper_query_select_ce, SL("JOIN_NATURAL"), "NATURAL"); -ZEPHIR_INIT_CLASS(Phalcon_Storage_Adapter_Apcu) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Adapter, Apcu, phalcon, storage_adapter_apcu, phalcon_storage_adapter_abstractadapter_ce, phalcon_storage_adapter_apcu_method_entry, 0); + zephir_declare_class_constant_string(phalcon_datamapper_query_select_ce, SL("JOIN_RIGHT"), "RIGHT"); - zend_declare_property_string(phalcon_storage_adapter_apcu_ce, SL("prefix"), "ph-apcu-", ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Storage_Adapter_Apcu, __construct) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, __call) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval *factory, factory_sub, *options_param = NULL; + zval params, proxied, _0$$3, _3$$3; + zval *method_param = NULL, *params_param = NULL, __$true, _5, _1$$3, _2$$3, _4$$3; + zval method, _6; zval *this_ptr = getThis(); - ZVAL_UNDEF(&factory_sub); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_storage_serializerfactory_ce) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&_6); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(¶ms); + ZVAL_UNDEF(&proxied); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_3$$3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(method) + Z_PARAM_ARRAY(params) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &factory, &options_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + zephir_fetch_params(1, 2, 0, &method_param, ¶ms_param); + zephir_get_strval(&method, method_param); + zephir_get_arrval(¶ms, params_param); + ZEPHIR_INIT_VAR(&proxied); + zephir_create_array(&proxied, 10, 0); + zephir_array_update_string(&proxied, SL("fetchAffected"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&proxied, SL("fetchAll"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&proxied, SL("fetchAssoc"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&proxied, SL("fetchCol"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&proxied, SL("fetchGroup"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&proxied, SL("fetchObject"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&proxied, SL("fetchObjects"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&proxied, SL("fetchOne"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&proxied, SL("fetchPairs"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&proxied, SL("fetchValue"), &__$true, PH_COPY | PH_SEPARATE); + if (EXPECTED(zephir_array_isset(&proxied, &method))) { + ZEPHIR_INIT_VAR(&_0$$3); + zephir_create_array(&_0$$3, 2, 0); + zephir_memory_observe(&_1$$3); + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC); + zephir_array_fast_append(&_0$$3, &_1$$3); + zephir_array_fast_append(&_0$$3, &method); + ZEPHIR_INIT_VAR(&_2$$3); + ZEPHIR_INIT_VAR(&_3$$3); + zephir_create_array(&_3$$3, 2, 0); + ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "getstatement", NULL, 0); + zephir_check_call_status(); + zephir_array_fast_append(&_3$$3, &_4$$3); + ZEPHIR_CALL_METHOD(&_4$$3, this_ptr, "getbindvalues", NULL, 0); + zephir_check_call_status(); + zephir_array_fast_append(&_3$$3, &_4$$3); + zephir_fast_array_merge(&_2$$3, &_3$$3, ¶ms); + ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_0$$3, &_2$$3); + zephir_check_call_status(); + RETURN_MM(); } - ZEPHIR_CALL_PARENT(NULL, phalcon_storage_adapter_apcu_ce, getThis(), "__construct", NULL, 0, factory, &options); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "initserializer", NULL, 0); + ZEPHIR_INIT_VAR(&_5); + object_init_ex(&_5, spl_ce_BadMethodCallException); + ZEPHIR_INIT_VAR(&_6); + ZEPHIR_CONCAT_SVS(&_6, "Unknown method: [", &method, "]"); + ZEPHIR_CALL_METHOD(NULL, &_5, "__construct", NULL, 75, &_6); zephir_check_call_status(); + zephir_throw_exception_debug(&_5, "phalcon/DataMapper/Query/Select.zep", 83); ZEPHIR_MM_RESTORE(); + return; } -static PHP_METHOD(Phalcon_Storage_Adapter_Apcu, clear) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, andHaving) { - zend_object_iterator *_1; - zend_bool result = 0; - zval item, pattern, apc, _0, _2$$4, _3$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _0; + zval condition; zval *this_ptr = getThis(); - ZVAL_UNDEF(&item); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&apc); + ZVAL_UNDEF(&condition); + ZVAL_UNDEF(&value_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(condition) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(value) + Z_PARAM_LONG(type) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&apc); - ZVAL_NULL(&apc); - zephir_read_property(&_0, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&pattern); - ZEPHIR_CONCAT_SVS(&pattern, "/^", &_0, "/"); - ZEPHIR_CALL_METHOD(&apc, this_ptr, "phpapcuiterator", NULL, 0, &pattern); - zephir_check_call_status(); - result = 1; - if (Z_TYPE_P(&apc) != IS_OBJECT) { - RETURN_MM_BOOL(0); + zephir_fetch_params(1, 1, 2, &condition_param, &value, &type_param); + zephir_get_strval(&condition, condition_param); + if (!value) { + value = &value_sub; + value = &__$null; } - _1 = zephir_get_iterator(&apc); - _1->funcs->rewind(_1); - for (;_1->funcs->valid(_1) == SUCCESS && !EG(exception); _1->funcs->move_forward(_1)) { - { - ZEPHIR_ITERATOR_COPY(&item, _1); - } - zephir_array_fetch_string(&_3$$4, &item, SL("key"), PH_NOISY | PH_READONLY, "phalcon/Storage/Adapter/Apcu.zep", 63); - ZEPHIR_CALL_METHOD(&_2$$4, this_ptr, "phpapcudelete", &_4, 0, &_3$$4); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_2$$4)) { - result = 0; + if (!type_param) { + type = -1; + } else { } - } - zend_iterator_dtor(_1); - RETURN_MM_BOOL(result); + ZVAL_LONG(&_0, type); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "having", NULL, 0, &condition, value, &_0); + zephir_check_call_status(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Apcu, decrement) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, asAlias) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long value, ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value_param = NULL, _0, _1; - zval key; + zval *asAlias_param = NULL; + zval asAlias; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(key) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(value) + ZVAL_UNDEF(&asAlias); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(asAlias) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key_param, &value_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - if (!value_param) { - value = 1; - } else { - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getprefixedkey", NULL, 0, &key); - zephir_check_call_status(); - ZVAL_LONG(&_1, value); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "phpapcudec", NULL, 0, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &asAlias_param); + zephir_get_strval(&asAlias, asAlias_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("asAlias"), &asAlias); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Apcu, delete) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, appendHaving) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, _0, _1; - zval key; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _0, _1; + zval condition; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&condition); + ZVAL_UNDEF(&value_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(condition) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(value) + Z_PARAM_LONG(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 2, &condition_param, &value, &type_param); + zephir_get_strval(&condition, condition_param); + if (!value) { + value = &value_sub; + value = &__$null; } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + if (!type_param) { + type = -1; } else { - ZEPHIR_INIT_VAR(&key); - } - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getprefixedkey", NULL, 0, &key); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "phpapcudelete", NULL, 0, &_1); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "HAVING"); + ZVAL_LONG(&_1, type); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendcondition", NULL, 0, &_0, &condition, value, &_1); zephir_check_call_status(); - RETURN_MM_BOOL(zephir_get_boolval(&_0)); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Apcu, getKeys) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, appendJoin) { - zend_object_iterator *_1; - zval results; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *prefix_param = NULL, item, pattern, apc, _0, _2$$4; - zval prefix; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, end, key, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _0$$3, _1$$3, _2$$3; + zval condition; zval *this_ptr = getThis(); - ZVAL_UNDEF(&prefix); - ZVAL_UNDEF(&item); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&apc); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&results); - ZEND_PARSE_PARAMETERS_START(0, 1) + ZVAL_UNDEF(&condition); + ZVAL_UNDEF(&value_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&end); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(condition) Z_PARAM_OPTIONAL - Z_PARAM_STR(prefix) + Z_PARAM_ZVAL_OR_NULL(value) + Z_PARAM_LONG(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &prefix_param); - if (!prefix_param) { - ZEPHIR_INIT_VAR(&prefix); - ZVAL_STRING(&prefix, ""); - } else { - if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 2, &condition_param, &value, &type_param); + zephir_get_strval(&condition, condition_param); + if (!value) { + value = &value_sub; + value = &__$null; } - if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) { - zephir_get_strval(&prefix, prefix_param); + if (!type_param) { + type = -1; } else { - ZEPHIR_INIT_VAR(&prefix); - } - } - ZEPHIR_INIT_VAR(&apc); - ZVAL_NULL(&apc); - zephir_read_property(&_0, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&pattern); - ZEPHIR_CONCAT_SVVS(&pattern, "/^", &_0, &prefix, "/"); - ZEPHIR_CALL_METHOD(&apc, this_ptr, "phpapcuiterator", NULL, 0, &pattern); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&results); - array_init(&results); - if (Z_TYPE_P(&apc) != IS_OBJECT) { - RETURN_CTOR(&results); - } - _1 = zephir_get_iterator(&apc); - _1->funcs->rewind(_1); - for (;_1->funcs->valid(_1) == SUCCESS && !EG(exception); _1->funcs->move_forward(_1)) { - { - ZEPHIR_ITERATOR_COPY(&item, _1); } - zephir_array_fetch_string(&_2$$4, &item, SL("key"), PH_NOISY | PH_READONLY, "phalcon/Storage/Adapter/Apcu.zep", 117); - zephir_array_append(&results, &_2$$4, PH_SEPARATE, "phalcon/Storage/Adapter/Apcu.zep", 117); + if (!(ZEPHIR_IS_EMPTY(value))) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_2$$3, type); + ZEPHIR_CALL_METHOD(&_1$$3, &_0$$3, "bindinline", NULL, 0, value, &_2$$3); + zephir_check_call_status(); + zephir_concat_self(&condition, &_1$$3); } - zend_iterator_dtor(_1); - RETURN_CTOR(&results); + zephir_read_property(&_3, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_4, &_3, SL("FROM"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 158); + ZEPHIR_CALL_FUNCTION(&end, "array_key_last", NULL, 40, &_4); + zephir_check_call_status(); + zephir_read_property(&_5, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_6, &_5, SL("FROM"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 159); + zephir_array_fetch(&_7, &_6, &end, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 159); + ZEPHIR_CALL_FUNCTION(&key, "array_key_last", NULL, 40, &_7); + zephir_check_call_status(); + zephir_read_property(&_8, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_9, &_8, SL("FROM"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 161); + zephir_array_fetch(&_10, &_9, &end, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 161); + zephir_array_fetch(&_11, &_10, &key, PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 161); + ZEPHIR_INIT_VAR(&_12); + ZEPHIR_CONCAT_VV(&_12, &_11, &condition); + zephir_update_property_array_multi(this_ptr, SL("store"), &_12, SL("szz"), 4, SL("FROM"), &end, &key); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Apcu, has) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, columns) { + zend_string *_3; + zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, result, _0, _1; - zval key; + zval *columns_param = NULL, key, value, *_0, _1, _6, _7, _8, _9, _4$$5, _5$$8; + zval columns, localColumns; zval *this_ptr = getThis(); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&localColumns); ZVAL_UNDEF(&key); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&value); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$8); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + Z_PARAM_ARRAY(columns) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getprefixedkey", NULL, 0, &key); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&result, this_ptr, "phpapcuexists", NULL, 0, &_0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_1); - if (((Z_TYPE_P(&result) == IS_TRUE || Z_TYPE_P(&result) == IS_FALSE) == 1)) { - ZEPHIR_CPY_WRT(&_1, &result); + zephir_fetch_params(1, 1, 0, &columns_param); + zephir_get_arrval(&columns, columns_param); + ZEPHIR_INIT_VAR(&localColumns); + array_init(&localColumns); + zephir_is_iterable(&columns, 0, "phalcon/DataMapper/Query/Select.zep", 187); + if (Z_TYPE_P(&columns) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&columns), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&key); + if (_3 != NULL) { + ZVAL_STR_COPY(&key, _3); + } else { + ZVAL_LONG(&key, _2); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0); + if (Z_TYPE_P(&key) == IS_LONG) { + zephir_array_append(&localColumns, &value, PH_SEPARATE, "phalcon/DataMapper/Query/Select.zep", 181); + } else { + ZEPHIR_INIT_NVAR(&_4$$5); + ZEPHIR_CONCAT_VSV(&_4$$5, &value, " AS ", &key); + zephir_array_append(&localColumns, &_4$$5, PH_SEPARATE, "phalcon/DataMapper/Query/Select.zep", 183); + } + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_INIT_NVAR(&_1); - ZVAL_BOOL(&_1, 0); + ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &columns, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &columns, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &columns, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&key) == IS_LONG) { + zephir_array_append(&localColumns, &value, PH_SEPARATE, "phalcon/DataMapper/Query/Select.zep", 181); + } else { + ZEPHIR_INIT_NVAR(&_5$$8); + ZEPHIR_CONCAT_VSV(&_5$$8, &value, " AS ", &key); + zephir_array_append(&localColumns, &_5$$8, PH_SEPARATE, "phalcon/DataMapper/Query/Select.zep", 183); + } + ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_CCTOR(&_1); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + ZEPHIR_INIT_VAR(&_6); + zephir_read_property(&_7, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_8, &_7, SL("COLUMNS"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 188); + zephir_fast_array_merge(&_6, &_8, &localColumns); + ZEPHIR_INIT_VAR(&_9); + ZVAL_STRING(&_9, "COLUMNS"); + zephir_update_property_array(this_ptr, SL("store"), &_9, &_6); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Apcu, increment) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, distinct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long value, ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value_param = NULL, _0, _1; - zval key; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *enable_param = NULL, _0, _1; + zend_bool enable; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(key) + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_LONG(value) + Z_PARAM_BOOL(enable) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key_param, &value_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - if (!value_param) { - value = 1; + zephir_fetch_params(1, 0, 1, &enable_param); + if (!enable_param) { + enable = 1; } else { } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getprefixedkey", NULL, 0, &key); - zephir_check_call_status(); - ZVAL_LONG(&_1, value); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "phpapcuinc", NULL, 0, &_0, &_1); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "DISTINCT"); + if (enable) { + ZVAL_BOOL(&_1, 1); + } else { + ZVAL_BOOL(&_1, 0); + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setflag", NULL, 0, &_0, &_1); zephir_check_call_status(); - RETURN_MM(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Apcu, set) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, from) { - zend_bool _0; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub, *ttl = NULL, ttl_sub, __$null, result, _1, _2, _3, _4; - zval key; + zval *table_param = NULL; + zval table; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&ttl_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(ttl) + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(table) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &key_param, &value, &ttl); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - if (!ttl) { - ttl = &ttl_sub; - ttl = &__$null; - } - _0 = Z_TYPE_P(ttl) == IS_LONG; - if (_0) { - _0 = ZEPHIR_LT_LONG(ttl, 1); - } - if (_0) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "delete", NULL, 0, &key); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getprefixedkey", NULL, 0, &key); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getserializeddata", NULL, 0, value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "getttl", NULL, 0, ttl); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&result, this_ptr, "phpapcustore", NULL, 0, &_1, &_2, &_3); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_4); - if (((Z_TYPE_P(&result) == IS_TRUE || Z_TYPE_P(&result) == IS_FALSE) == 1)) { - ZEPHIR_CPY_WRT(&_4, &result); - } else { - ZEPHIR_INIT_NVAR(&_4); - ZVAL_BOOL(&_4, 0); - } - RETURN_CCTOR(&_4); + zephir_fetch_params(1, 1, 0, &table_param); + zephir_get_strval(&table, table_param); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 1, 0); + zephir_array_fast_append(&_0, &table); + zephir_update_property_array_multi(this_ptr, SL("store"), &_0, SL("sa"), 3, SL("FROM")); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Apcu, setForever) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, forUpdate) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub, result, _0, _1, _2; - zval key; + zval *enable_param = NULL, __$true, __$false; + zend_bool enable; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(enable) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &key_param, &value); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + zephir_fetch_params_without_memory_grow(0, 1, &enable_param); + if (!enable_param) { + enable = 1; } else { - ZEPHIR_INIT_VAR(&key); - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getprefixedkey", NULL, 0, &key); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getserializeddata", NULL, 0, value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&result, this_ptr, "phpapcustore", NULL, 0, &_0, &_1); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2); - if ((Z_TYPE_P(&result) == IS_TRUE || Z_TYPE_P(&result) == IS_FALSE)) { - ZEPHIR_CPY_WRT(&_2, &result); + } + if (enable) { + zephir_update_property_zval(this_ptr, ZEND_STRL("forUpdate"), &__$true); } else { - ZEPHIR_INIT_NVAR(&_2); - ZVAL_BOOL(&_2, 0); + zephir_update_property_zval(this_ptr, ZEND_STRL("forUpdate"), &__$false); } - RETURN_CCTOR(&_2); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Apcu, doGet) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, getStatement) { + zval _0, _1, _2, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, _0; - zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - zephir_get_strval(&key, key_param); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getprefixedkey", NULL, 0, &key); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "phpapcufetch", NULL, 0, &_0); + + ZEPHIR_INIT_VAR(&_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_2, &_1, SL("UNION"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 242); + zephir_fast_join_str(&_0, SL(""), &_2); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "getcurrentstatement", NULL, 0); zephir_check_call_status(); + ZEPHIR_CONCAT_VV(return_value, &_0, &_3); RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Apcu, phpApcuDec) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, groupBy) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long step, ZEPHIR_LAST_CALL_STATUS; - zval *key, key_sub, *step_param = NULL, _0; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *groupBy, groupBy_sub, _0; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&key_sub); + ZVAL_UNDEF(&groupBy_sub); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(key) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(step) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(groupBy) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key, &step_param); - if (!step_param) { - step = 1; - } else { - } - ZVAL_LONG(&_0, step); - ZEPHIR_RETURN_CALL_FUNCTION("apcu_dec", NULL, 103, key, &_0); + zephir_fetch_params(1, 1, 0, &groupBy); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "GROUP"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processvalue", NULL, 0, &_0, groupBy); zephir_check_call_status(); - RETURN_MM(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Apcu, phpApcuDelete) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, hasColumns) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key, key_sub; + zval _0, _1; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&key_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(key) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key); - ZEPHIR_RETURN_CALL_FUNCTION("apcu_delete", NULL, 104, key); - zephir_check_call_status(); - RETURN_MM(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_1, &_0, SL("COLUMNS"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 266); + RETURN_BOOL(zephir_fast_count_int(&_1) > 0); } -static PHP_METHOD(Phalcon_Storage_Adapter_Apcu, phpApcuExists) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, having) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key, key_sub; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _0, _1, _2; + zval condition; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&key_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(key) + ZVAL_UNDEF(&condition); + ZVAL_UNDEF(&value_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(condition) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(value) + Z_PARAM_LONG(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key); - ZEPHIR_RETURN_CALL_FUNCTION("apcu_exists", NULL, 105, key); + zephir_fetch_params(1, 1, 2, &condition_param, &value, &type_param); + zephir_get_strval(&condition, condition_param); + if (!value) { + value = &value_sub; + value = &__$null; + } + if (!type_param) { + type = -1; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "HAVING"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "AND "); + ZVAL_LONG(&_2, type); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addcondition", NULL, 0, &_0, &_1, &condition, value, &_2); zephir_check_call_status(); - RETURN_MM(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Apcu, phpApcuInc) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, join) { + zend_bool _5, _10; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long step, ZEPHIR_LAST_CALL_STATUS; - zval *key, key_sub, *step_param = NULL, _0; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *join_param = NULL, *table_param = NULL, *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, key, _0, _1, _2, _3, _4, _6, _7, _8, _9, _11, _12, _13, _14, _19, _20, _16$$5, _17$$5, _18$$5; + zval join, table, condition, _21, _15$$4; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&key_sub); + ZVAL_UNDEF(&join); + ZVAL_UNDEF(&table); + ZVAL_UNDEF(&condition); + ZVAL_UNDEF(&_21); + ZVAL_UNDEF(&_15$$4); + ZVAL_UNDEF(&value_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&key); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(key) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_13); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_19); + ZVAL_UNDEF(&_20); + ZVAL_UNDEF(&_16$$5); + ZVAL_UNDEF(&_17$$5); + ZVAL_UNDEF(&_18$$5); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(3, 5) + Z_PARAM_STR(join) + Z_PARAM_STR(table) + Z_PARAM_STR(condition) Z_PARAM_OPTIONAL - Z_PARAM_LONG(step) + Z_PARAM_ZVAL_OR_NULL(value) + Z_PARAM_LONG(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key, &step_param); - if (!step_param) { - step = 1; + zephir_fetch_params(1, 3, 2, &join_param, &table_param, &condition_param, &value, &type_param); + zephir_get_strval(&join, join_param); + zephir_get_strval(&table, table_param); + zephir_get_strval(&condition, condition_param); + if (!value) { + value = &value_sub; + value = &__$null; + } + if (!type_param) { + type = -1; } else { } - ZVAL_LONG(&_0, step); - ZEPHIR_RETURN_CALL_FUNCTION("apcu_inc", NULL, 106, key, &_0); + ZEPHIR_INIT_VAR(&_0); + zephir_fast_trim(&_0, &join, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&join); + zephir_fast_strtoupper(&join, &_0); + ZVAL_LONG(&_1, -4); + ZEPHIR_INIT_VAR(&_2); + zephir_substr(&_2, &join, -4 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + if (!ZEPHIR_IS_STRING_IDENTICAL(&_2, "JOIN")) { + zephir_concat_self_str(&join, " JOIN", sizeof(" JOIN") - 1); + } + ZEPHIR_INIT_VAR(&_3); + zephir_fast_trim(&_3, &condition, NULL , ZEPHIR_TRIM_LEFT); + zephir_get_strval(&condition, &_3); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, ""); + _5 = !ZEPHIR_IS_IDENTICAL(&_4, &condition); + if (_5) { + ZEPHIR_INIT_VAR(&_6); + ZVAL_LONG(&_7, 0); + ZVAL_LONG(&_8, 3); + ZEPHIR_INIT_VAR(&_9); + zephir_substr(&_9, &condition, 0 , 3 , 0); + zephir_fast_strtoupper(&_6, &_9); + _5 = !ZEPHIR_IS_STRING_IDENTICAL(&_6, "ON "); + } + _10 = _5; + if (_10) { + ZEPHIR_INIT_VAR(&_11); + ZVAL_LONG(&_12, 0); + ZVAL_LONG(&_13, 6); + ZEPHIR_INIT_VAR(&_14); + zephir_substr(&_14, &condition, 0 , 6 , 0); + zephir_fast_strtoupper(&_11, &_14); + _10 = !ZEPHIR_IS_STRING_IDENTICAL(&_11, "USING "); + } + if (_10) { + ZEPHIR_INIT_VAR(&_15$$4); + ZEPHIR_CONCAT_SV(&_15$$4, "ON ", &condition); + ZEPHIR_CPY_WRT(&condition, &_15$$4); + } + if (!(ZEPHIR_IS_EMPTY(value))) { + zephir_read_property(&_16$$5, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_18$$5, type); + ZEPHIR_CALL_METHOD(&_17$$5, &_16$$5, "bindinline", NULL, 0, value, &_18$$5); + zephir_check_call_status(); + zephir_concat_self(&condition, &_17$$5); + } + zephir_read_property(&_19, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_20, &_19, SL("FROM"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 327); + ZEPHIR_CALL_FUNCTION(&key, "array_key_last", NULL, 40, &_20); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_INIT_VAR(&_21); + ZEPHIR_CONCAT_VSVSV(&_21, &join, " ", &table, " ", &condition); + zephir_update_property_array_multi(this_ptr, SL("store"), &_21, SL("sza"), 4, SL("FROM"), &key); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Apcu, phpApcuFetch) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, orHaving) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key, key_sub; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *condition_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _0, _1, _2; + zval condition; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&key_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(key) + ZVAL_UNDEF(&condition); + ZVAL_UNDEF(&value_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(condition) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(value) + Z_PARAM_LONG(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key); - ZEPHIR_RETURN_CALL_FUNCTION("apcu_fetch", NULL, 107, key); + zephir_fetch_params(1, 1, 2, &condition_param, &value, &type_param); + zephir_get_strval(&condition, condition_param); + if (!value) { + value = &value_sub; + value = &__$null; + } + if (!type_param) { + type = -1; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "HAVING"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "OR "); + ZVAL_LONG(&_2, type); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addcondition", NULL, 0, &_0, &_1, &condition, value, &_2); zephir_check_call_status(); - RETURN_MM(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Apcu, phpApcuIterator) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, reset) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval __$true, __$false, _0; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *pattern_param = NULL; - zval pattern; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&pattern); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(pattern) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &pattern_param); - zephir_get_strval(&pattern, pattern_param); - object_init_ex(return_value, zephir_get_internal_ce(SL("apcuiterator"))); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 0, &pattern); + + ZEPHIR_CALL_PARENT(NULL, phalcon_datamapper_query_select_ce, getThis(), "reset", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, ""); + zephir_update_property_zval(this_ptr, ZEND_STRL("asAlias"), &_0); + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("forUpdate"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("forUpdate"), &__$false); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Apcu, phpApcuStore) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, subSelect) { + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ttl, ZEPHIR_LAST_CALL_STATUS; - zval *key, key_sub, *payload, payload_sub, *ttl_param = NULL, _0; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&key_sub); - ZVAL_UNDEF(&payload_sub); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_ZVAL(key) - Z_PARAM_ZVAL(payload) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(ttl) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &key, &payload, &ttl_param); - if (!ttl_param) { - ttl = 0; - } else { - } - ZVAL_LONG(&_0, ttl); - ZEPHIR_RETURN_CALL_FUNCTION("apcu_store", NULL, 108, key, payload, &_0); + + object_init_ex(return_value, phalcon_datamapper_query_select_ce); + zephir_read_property(&_0, this_ptr, ZEND_STRL("connection"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_1, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 209, &_0, &_1); zephir_check_call_status(); RETURN_MM(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Storage_Adapter_Libmemcached) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Adapter, Libmemcached, phalcon, storage_adapter_libmemcached, phalcon_storage_adapter_abstractadapter_ce, phalcon_storage_adapter_libmemcached_method_entry, 0); - - zend_declare_property_string(phalcon_storage_adapter_libmemcached_ce, SL("prefix"), "ph-memc-", ZEND_ACC_PROTECTED); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Storage_Adapter_Libmemcached, __construct) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, union) { + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options, _0$$3, _1$$3; - zval *factory, factory_sub, *options_param = NULL; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&factory_sub); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_storage_serializerfactory_ce) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &factory, &options_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - if (!(zephir_array_isset_string(&options, SL("servers")))) { - ZEPHIR_INIT_VAR(&_0$$3); - zephir_create_array(&_0$$3, 1, 0); - ZEPHIR_INIT_VAR(&_1$$3); - zephir_create_array(&_1$$3, 3, 0); - add_assoc_stringl_ex(&_1$$3, SL("host"), SL("127.0.0.1")); - add_assoc_long_ex(&_1$$3, SL("port"), 11211); - add_assoc_long_ex(&_1$$3, SL("weight"), 1); - zephir_array_update_long(&_0$$3, 0, &_1$$3, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_update_string(&options, SL("servers"), &_0$$3, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_PARENT(NULL, phalcon_storage_adapter_libmemcached_ce, getThis(), "__construct", NULL, 0, factory, &options); + + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, " UNION "); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getcurrentstatement", NULL, 0, &_1); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + zephir_update_property_array_multi(this_ptr, SL("store"), &_0, SL("sa"), 3, SL("UNION")); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "reset", NULL, 0); + zephir_check_call_status(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Libmemcached, clear) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, unionAll) { - zval _0; + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getadapter", NULL, 0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, " UNION ALL "); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getcurrentstatement", NULL, 0, &_1); zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&_0, "flush", NULL, 0); + zephir_update_property_array_multi(this_ptr, SL("store"), &_0, SL("sa"), 3, SL("UNION")); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "reset", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Libmemcached, decrement) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, getCurrentStatement) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long value, ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value_param = NULL, _0, _1; - zval key; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *suffix_param = NULL, statement, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13$$4, _14$$4; + zval suffix, forUpdate; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&suffix); + ZVAL_UNDEF(&forUpdate); + ZVAL_UNDEF(&statement); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(key) + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_13$$4); + ZVAL_UNDEF(&_14$$4); + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_LONG(value) + Z_PARAM_STR(suffix) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key_param, &value_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + zephir_fetch_params(1, 0, 1, &suffix_param); + if (!suffix_param) { + ZEPHIR_INIT_VAR(&suffix); + ZVAL_STRING(&suffix, ""); } else { - ZEPHIR_INIT_VAR(&key); + zephir_get_strval(&suffix, suffix_param); } - if (!value_param) { - value = 1; - } else { - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getadapter", NULL, 0); + ZEPHIR_INIT_VAR(&forUpdate); + zephir_read_property(&_0, this_ptr, ZEND_STRL("forUpdate"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_0)) { + ZEPHIR_INIT_NVAR(&forUpdate); + ZVAL_STRING(&forUpdate, " FOR UPDATE"); + } + ZEPHIR_CALL_METHOD(&_1, this_ptr, "buildflags", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "buildlimitearly", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "buildcolumns", NULL, 210); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "buildfrom", NULL, 211); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_6); + ZVAL_STRING(&_6, "WHERE"); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "buildcondition", NULL, 0, &_6); zephir_check_call_status(); - ZVAL_LONG(&_1, value); - ZEPHIR_RETURN_CALL_METHOD(&_0, "decrement", NULL, 0, &key, &_1); + ZEPHIR_INIT_NVAR(&_6); + ZVAL_STRING(&_6, "GROUP"); + ZEPHIR_CALL_METHOD(&_7, this_ptr, "buildby", NULL, 0, &_6); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_6); + ZVAL_STRING(&_6, "HAVING"); + ZEPHIR_CALL_METHOD(&_8, this_ptr, "buildcondition", NULL, 0, &_6); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_6); + ZVAL_STRING(&_6, "ORDER"); + ZEPHIR_CALL_METHOD(&_9, this_ptr, "buildby", NULL, 0, &_6); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_10, this_ptr, "buildlimit", NULL, 0); zephir_check_call_status(); + ZEPHIR_INIT_VAR(&statement); + ZEPHIR_CONCAT_SVVVVVVVVVV(&statement, "SELECT", &_1, &_2, &_3, &_4, &_5, &_7, &_8, &_9, &_10, &forUpdate); + zephir_read_property(&_11, this_ptr, ZEND_STRL("asAlias"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_12); + ZVAL_STRING(&_12, ""); + if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_12, &_11))) { + zephir_read_property(&_13$$4, this_ptr, ZEND_STRL("asAlias"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_14$$4); + ZEPHIR_CONCAT_SVSV(&_14$$4, "(", &statement, ") AS ", &_13$$4); + ZEPHIR_CPY_WRT(&statement, &_14$$4); + } + ZEPHIR_CONCAT_VV(return_value, &statement, &suffix); RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Libmemcached, delete) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, buildColumns) { + zval columns, _0, _3, _1$$3, _2$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, _0, _1; - zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&columns); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "hascolumns", NULL, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&_0))) { + ZEPHIR_INIT_VAR(&columns); + zephir_create_array(&columns, 1, 0); + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "*"); + zephir_array_fast_append(&columns, &_1$$3); } else { - ZEPHIR_INIT_VAR(&key); + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_OBS_NVAR(&columns); + zephir_array_fetch_string(&columns, &_2$$4, SL("COLUMNS"), PH_NOISY, "phalcon/DataMapper/Query/Select.zep", 449); } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getadapter", NULL, 0); - zephir_check_call_status(); - ZVAL_LONG(&_1, 0); - ZEPHIR_RETURN_CALL_METHOD(&_0, "delete", NULL, 0, &key, &_1); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, ","); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "indent", NULL, 0, &columns, &_3); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Libmemcached, getAdapter) +static PHP_METHOD(Phalcon_DataMapper_Query_Select, buildFrom) { + zval from; + zval table, _0, _1, _2, _3, *_4, _5, _14, _15, _6$$4, _8$$4, _10$$4, _11$$5, _12$$5, _13$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$true, client, connection, failover, options, persistentId, sasl, saslUser, saslPass, serverList, servers, _0, _1$$3, _2$$3, _3$$3, _4$$3, _5$$4, _6$$4, _7$$4, _8$$4, _9$$4, _10$$4; + zephir_fcall_cache_entry *_7 = NULL, *_9 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&client); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&failover); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&persistentId); - ZVAL_UNDEF(&sasl); - ZVAL_UNDEF(&saslUser); - ZVAL_UNDEF(&saslPass); - ZVAL_UNDEF(&serverList); - ZVAL_UNDEF(&servers); + ZVAL_UNDEF(&table); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_15); ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_9$$4); ZVAL_UNDEF(&_10$$4); + ZVAL_UNDEF(&_11$$5); + ZVAL_UNDEF(&_12$$5); + ZVAL_UNDEF(&_13$$5); + ZVAL_UNDEF(&from); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_is_true(&_0))) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&options, &_1$$3); - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "persistentId"); - ZEPHIR_INIT_VAR(&_3$$3); - ZVAL_STRING(&_3$$3, "ph-mcid-"); - ZEPHIR_CALL_METHOD(&persistentId, this_ptr, "getarrval", NULL, 0, &options, &_2$$3, &_3$$3); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_2$$3); - array_init(&_2$$3); - ZEPHIR_INIT_NVAR(&_3$$3); - ZVAL_STRING(&_3$$3, "saslAuthData"); - ZEPHIR_CALL_METHOD(&sasl, this_ptr, "getarrval", NULL, 0, &options, &_3$$3, &_2$$3); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&connection); - object_init_ex(&connection, zephir_get_internal_ce(SL("memcached"))); - ZEPHIR_CALL_METHOD(NULL, &connection, "__construct", NULL, 0, &persistentId); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&serverList, &connection, "getserverlist", NULL, 0); - zephir_check_call_status(); - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_4$$3, -1002); - ZEPHIR_CALL_METHOD(NULL, &connection, "setoption", NULL, 0, &_4$$3, &_1$$3); - zephir_check_call_status(); - if (ZEPHIR_IS_EMPTY(&serverList)) { - ZEPHIR_INIT_VAR(&_5$$4); - array_init(&_5$$4); - ZEPHIR_INIT_VAR(&_6$$4); - ZVAL_STRING(&_6$$4, "servers"); - ZEPHIR_CALL_METHOD(&servers, this_ptr, "getarrval", NULL, 0, &options, &_6$$4, &_5$$4); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_6$$4); - array_init(&_6$$4); - ZEPHIR_INIT_VAR(&_7$$4); - ZVAL_STRING(&_7$$4, "client"); - ZEPHIR_CALL_METHOD(&client, this_ptr, "getarrval", NULL, 0, &options, &_7$$4, &_6$$4); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_7$$4); - ZVAL_STRING(&_7$$4, "user"); - ZEPHIR_INIT_VAR(&_8$$4); - ZVAL_STRING(&_8$$4, ""); - ZEPHIR_CALL_METHOD(&saslUser, this_ptr, "getarrval", NULL, 0, &sasl, &_7$$4, &_8$$4); + ZEPHIR_INIT_VAR(&from); + array_init(&from); + zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_1, &_0, SL("FROM"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 465); + if (ZEPHIR_IS_EMPTY(&_1)) { + RETURN_MM_STRING(""); + } + zephir_read_property(&_2, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_3, &_2, SL("FROM"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Select.zep", 469); + zephir_is_iterable(&_3, 0, "phalcon/DataMapper/Query/Select.zep", 473); + if (Z_TYPE_P(&_3) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_3), _4) + { + ZEPHIR_INIT_NVAR(&table); + ZVAL_COPY(&table, _4); + ZEPHIR_MAKE_REF(&table); + ZEPHIR_CALL_FUNCTION(&_6$$4, "array_shift", &_7, 22, &table); + ZEPHIR_UNREF(&table); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_7$$4); - ZVAL_STRING(&_7$$4, "pass"); - ZEPHIR_INIT_NVAR(&_8$$4); - ZVAL_STRING(&_8$$4, ""); - ZEPHIR_CALL_METHOD(&saslPass, this_ptr, "getarrval", NULL, 0, &sasl, &_7$$4, &_8$$4); + ZEPHIR_CALL_METHOD(&_8$$4, this_ptr, "indent", &_9, 0, &table); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&failover); - zephir_create_array(&failover, 5, 0); - add_index_long(&failover, 14, 10); - add_index_long(&failover, 9, 1); - add_index_long(&failover, 21, 2); - zephir_array_update_long(&failover, 35, &__$true, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - add_index_long(&failover, 15, 1); - ZEPHIR_INIT_NVAR(&_7$$4); - zephir_fast_array_merge(&_7$$4, &failover, &client); - ZEPHIR_CPY_WRT(&client, &_7$$4); - ZEPHIR_CALL_METHOD(&_9$$4, this_ptr, "setoptions", NULL, 109, &connection, &client); + ZEPHIR_INIT_NVAR(&_10$$4); + ZEPHIR_CONCAT_VV(&_10$$4, &_6$$4, &_8$$4); + zephir_array_append(&from, &_10$$4, PH_SEPARATE, "phalcon/DataMapper/Query/Select.zep", 470); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_3, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5, &_3, "valid", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_10$$4, &_9$$4, "setservers", NULL, 110, &connection, &servers); + if (!zend_is_true(&_5)) { + break; + } + ZEPHIR_CALL_METHOD(&table, &_3, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_10$$4, "setsasl", NULL, 111, &connection, &saslUser, &saslPass); + ZEPHIR_MAKE_REF(&table); + ZEPHIR_CALL_FUNCTION(&_11$$5, "array_shift", &_7, 22, &table); + ZEPHIR_UNREF(&table); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_12$$5, this_ptr, "indent", &_9, 0, &table); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_13$$5); + ZEPHIR_CONCAT_VV(&_13$$5, &_11$$5, &_12$$5); + zephir_array_append(&from, &_13$$5, PH_SEPARATE, "phalcon/DataMapper/Query/Select.zep", 470); + ZEPHIR_CALL_METHOD(NULL, &_3, "next", NULL, 0); zephir_check_call_status(); } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setserializer", NULL, 112, &connection); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("adapter"), &connection); } - RETURN_MM_MEMBER(getThis(), "adapter"); + ZEPHIR_INIT_NVAR(&table); + ZEPHIR_INIT_VAR(&_15); + ZVAL_STRING(&_15, ","); + ZEPHIR_CALL_METHOD(&_14, this_ptr, "indent", &_9, 0, &from, &_15); + zephir_check_call_status(); + ZEPHIR_CONCAT_SV(return_value, " FROM", &_14); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Libmemcached, getKeys) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_DataMapper_Query_Update) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\DataMapper\\Query, Update, phalcon, datamapper_query_update, phalcon_datamapper_query_abstractconditions_ce, phalcon_datamapper_query_update_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_DataMapper_Query_Update, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *prefix_param = NULL, _0, _1; - zval prefix; + zval *connection, connection_sub, *bind, bind_sub, _0, _1, _2, _3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&prefix); + ZVAL_UNDEF(&connection_sub); + ZVAL_UNDEF(&bind_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(0, 1) + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_OBJECT_OF_CLASS(connection, phalcon_datamapper_pdo_connection_ce) + Z_PARAM_OBJECT_OF_CLASS(bind, phalcon_datamapper_query_bind_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &connection, &bind); + ZEPHIR_CALL_PARENT(NULL, phalcon_datamapper_query_update_ce, getThis(), "__construct", NULL, 0, connection, bind); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "FROM"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, ""); + zephir_update_property_array(this_ptr, SL("store"), &_0, &_1); + ZEPHIR_INIT_VAR(&_2); + array_init(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "RETURNING"); + zephir_update_property_array(this_ptr, SL("store"), &_3, &_2); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_DataMapper_Query_Update, column) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long type, ZEPHIR_LAST_CALL_STATUS; + zval *column_param = NULL, *value = NULL, value_sub, *type_param = NULL, __$null, _1$$3, _2$$3; + zval column, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&column); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&value_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(column) Z_PARAM_OPTIONAL - Z_PARAM_STR(prefix) + Z_PARAM_ZVAL_OR_NULL(value) + Z_PARAM_LONG(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &prefix_param); - if (!prefix_param) { - ZEPHIR_INIT_VAR(&prefix); - ZVAL_STRING(&prefix, ""); - } else { - if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 2, &column_param, &value, &type_param); + zephir_get_strval(&column, column_param); + if (!value) { + value = &value_sub; + value = &__$null; } - if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) { - zephir_get_strval(&prefix, prefix_param); + if (!type_param) { + type = -1; } else { - ZEPHIR_INIT_VAR(&prefix); - } + } + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_CONCAT_SV(&_0, ":", &column); + zephir_update_property_array_multi(this_ptr, SL("store"), &_0, SL("sz"), 3, SL("COLUMNS"), &column); + if (Z_TYPE_P(value) != IS_NULL) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_2$$3, type); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "setvalue", NULL, 0, &column, value, &_2$$3); + zephir_check_call_status(); } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getadapter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, &_0, "getallkeys", NULL, 0); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getfilteredkeys", NULL, 0, &_1, &prefix); - zephir_check_call_status(); - RETURN_MM(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Libmemcached, has) +static PHP_METHOD(Phalcon_DataMapper_Query_Update, columns) { + zend_string *_3; + zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, connection, result, _0; - zval key; + zval *columns_param = NULL, column, value, *_0, _1; + zval columns; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&connection); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&columns); + ZVAL_UNDEF(&column); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + Z_PARAM_ARRAY(columns) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + zephir_fetch_params(1, 1, 0, &columns_param); + zephir_get_arrval(&columns, columns_param); + zephir_is_iterable(&columns, 0, "phalcon/DataMapper/Query/Update.zep", 76); + if (Z_TYPE_P(&columns) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&columns), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&column); + if (_3 != NULL) { + ZVAL_STR_COPY(&column, _3); + } else { + ZVAL_LONG(&column, _2); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0); + if (Z_TYPE_P(&column) == IS_LONG) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "column", &_4, 0, &value); + zephir_check_call_status(); + } else { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "column", &_4, 0, &column, &value); + zephir_check_call_status(); + } + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_INIT_VAR(&key); + ZEPHIR_CALL_METHOD(NULL, &columns, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &columns, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&column, &columns, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &columns, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&column) == IS_LONG) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "column", &_4, 0, &value); + zephir_check_call_status(); + } else { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "column", &_4, 0, &column, &value); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(NULL, &columns, "next", NULL, 0); + zephir_check_call_status(); + } } - ZEPHIR_CALL_METHOD(&connection, this_ptr, "getadapter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&result, &connection, "get", NULL, 0, &key); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, &connection, "getresultcode", NULL, 0); - zephir_check_call_status(); - RETURN_MM_BOOL(!ZEPHIR_IS_LONG_IDENTICAL(&_0, 16)); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&column); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Libmemcached, increment) +static PHP_METHOD(Phalcon_DataMapper_Query_Update, from) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long value, ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value_param = NULL, _0, _1; - zval key; + zval *table_param = NULL, _0; + zval table; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&table); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(key) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(value) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(table) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key_param, &value_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - if (!value_param) { - value = 1; - } else { - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getadapter", NULL, 0); - zephir_check_call_status(); - ZVAL_LONG(&_1, value); - ZEPHIR_RETURN_CALL_METHOD(&_0, "increment", NULL, 0, &key, &_1); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &table_param); + zephir_get_strval(&table, table_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "FROM"); + zephir_update_property_array(this_ptr, SL("store"), &_0, &table); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Libmemcached, set) +static PHP_METHOD(Phalcon_DataMapper_Query_Update, getStatement) { - zend_bool _0; + zval _0, _1, _2, _3, _4, _5, _6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub, *ttl = NULL, ttl_sub, __$null, result, _1, _2, _3, _4; - zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&ttl_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&result); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(ttl) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &key_param, &value, &ttl); - zephir_get_strval(&key, key_param); - if (!ttl) { - ttl = &ttl_sub; - ttl = &__$null; - } - _0 = Z_TYPE_P(ttl) == IS_LONG; - if (_0) { - _0 = ZEPHIR_LT_LONG(ttl, 1); - } - if (_0) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "delete", NULL, 0, &key); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getadapter", NULL, 0); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "buildflags", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getserializeddata", NULL, 0, value); + zephir_read_property(&_1, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_2, &_1, SL("FROM"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Update.zep", 101); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "buildcolumns", NULL, 212); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "getttl", NULL, 0, ttl); + ZEPHIR_INIT_VAR(&_5); + ZVAL_STRING(&_5, "WHERE"); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "buildcondition", NULL, 0, &_5); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&result, &_1, "set", NULL, 0, &key, &_2, &_3); + ZEPHIR_CALL_METHOD(&_6, this_ptr, "buildreturning", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_4); - if (((Z_TYPE_P(&result) == IS_TRUE || Z_TYPE_P(&result) == IS_FALSE) == 1)) { - ZEPHIR_CPY_WRT(&_4, &result); - } else { - ZEPHIR_INIT_NVAR(&_4); - ZVAL_BOOL(&_4, 0); - } - RETURN_CCTOR(&_4); + ZEPHIR_CONCAT_SVSVVVV(return_value, "UPDATE", &_0, " ", &_2, &_3, &_4, &_6); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Libmemcached, setForever) +static PHP_METHOD(Phalcon_DataMapper_Query_Update, hasColumns) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub, result, _0, _1, _2, _3; - zval key; + zval _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &key_param, &value); - zephir_get_strval(&key, key_param); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getadapter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getserializeddata", NULL, 0, value); - zephir_check_call_status(); - ZVAL_LONG(&_2, 0); - ZEPHIR_CALL_METHOD(&result, &_0, "set", NULL, 0, &key, &_1, &_2); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_3); - if (((Z_TYPE_P(&result) == IS_TRUE || Z_TYPE_P(&result) == IS_FALSE) == 1)) { - ZEPHIR_CPY_WRT(&_3, &result); - } else { - ZEPHIR_INIT_NVAR(&_3); - ZVAL_BOOL(&_3, 0); - } - RETURN_CCTOR(&_3); + zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_1, &_0, SL("COLUMNS"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Update.zep", 113); + RETURN_BOOL(zephir_fast_count_int(&_1) > 0); } -static PHP_METHOD(Phalcon_Storage_Adapter_Libmemcached, setOptions) +static PHP_METHOD(Phalcon_DataMapper_Query_Update, returning) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval client; - zval *connection, connection_sub, *client_param = NULL, _0; + zval *columns_param = NULL, _0, _1, _2, _3; + zval columns; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connection_sub); + ZVAL_UNDEF(&columns); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&client); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(connection, zephir_get_internal_ce(SL("memcached"))) - Z_PARAM_ARRAY(client) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(columns) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &connection, &client_param); - zephir_get_arrval(&client, client_param); - ZEPHIR_CALL_METHOD(&_0, connection, "setoptions", NULL, 0, &client); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_storage_exception_ce, "Cannot set Memcached client options", "phalcon/Storage/Adapter/Libmemcached.zep", 253); - return; - } + zephir_fetch_params(1, 1, 0, &columns_param); + zephir_get_arrval(&columns, columns_param); + ZEPHIR_INIT_VAR(&_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_2, &_1, SL("RETURNING"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Update.zep", 126); + zephir_fast_array_merge(&_0, &_2, &columns); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "RETURNING"); + zephir_update_property_array(this_ptr, SL("store"), &_3, &_0); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Libmemcached, setSasl) +static PHP_METHOD(Phalcon_DataMapper_Query_Update, reset) { + zval _0, _1, _2, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval saslUser, saslPass; - zval *connection, connection_sub, *saslUser_param = NULL, *saslPass_param = NULL; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connection_sub); - ZVAL_UNDEF(&saslUser); - ZVAL_UNDEF(&saslPass); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_OBJECT_OF_CLASS(connection, zephir_get_internal_ce(SL("memcached"))) - Z_PARAM_STR(saslUser) - Z_PARAM_STR(saslPass) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &connection, &saslUser_param, &saslPass_param); - zephir_get_strval(&saslUser, saslUser_param); - zephir_get_strval(&saslPass, saslPass_param); - if (1 != ZEPHIR_IS_EMPTY(&saslUser)) { - ZEPHIR_CALL_METHOD(NULL, connection, "setsaslauthdata", NULL, 0, &saslUser, &saslPass); - zephir_check_call_status(); - } - RETURN_THIS(); + + ZEPHIR_CALL_PARENT(NULL, phalcon_datamapper_query_update_ce, getThis(), "reset", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "FROM"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, ""); + zephir_update_property_array(this_ptr, SL("store"), &_0, &_1); + ZEPHIR_INIT_VAR(&_2); + array_init(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "RETURNING"); + zephir_update_property_array(this_ptr, SL("store"), &_3, &_2); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Libmemcached, setSerializer) +static PHP_METHOD(Phalcon_DataMapper_Query_Update, set) { - zval map; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connection, connection_sub, serializer, _0, _1$$3, _2$$3, _3$$3; + zval *column_param = NULL, *value = NULL, value_sub, __$null, _0; + zval column; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connection_sub); - ZVAL_UNDEF(&serializer); + ZVAL_UNDEF(&column); + ZVAL_UNDEF(&value_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&map); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(connection, zephir_get_internal_ce(SL("memcached"))) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(column) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &connection); - ZEPHIR_INIT_VAR(&map); - zephir_create_array(&map, 3, 0); - add_assoc_long_ex(&map, SL("memcached_igbinary"), 2); - add_assoc_long_ex(&map, SL("memcached_json"), 3); - add_assoc_long_ex(&map, SL("memcached_php"), 1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("defaultSerializer"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&serializer); - zephir_fast_strtolower(&serializer, &_0); - if (zephir_array_isset(&map, &serializer)) { - ZEPHIR_INIT_VAR(&_1$$3); - ZEPHIR_INIT_NVAR(&_1$$3); - ZVAL_STRING(&_1$$3, ""); - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultSerializer"), &_1$$3); - zephir_array_fetch(&_2$$3, &map, &serializer, PH_NOISY | PH_READONLY, "phalcon/Storage/Adapter/Libmemcached.zep", 299); - ZVAL_LONG(&_3$$3, -1003); - ZEPHIR_CALL_METHOD(NULL, connection, "setoption", NULL, 0, &_3$$3, &_2$$3); - zephir_check_call_status(); + zephir_fetch_params(1, 1, 1, &column_param, &value); + zephir_get_strval(&column, column_param); + if (!value) { + value = &value_sub; + ZEPHIR_CPY_WRT(value, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(value); } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "initserializer", NULL, 0); + if (Z_TYPE_P(value) == IS_NULL) { + ZEPHIR_INIT_NVAR(value); + ZVAL_STRING(value, "NULL"); + } + zephir_update_property_array_multi(this_ptr, SL("store"), value, SL("sz"), 3, SL("COLUMNS"), &column); + zephir_read_property(&_0, this_ptr, ZEND_STRL("bind"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "remove", NULL, 0, &column); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Libmemcached, setServers) +static PHP_METHOD(Phalcon_DataMapper_Query_Update, buildColumns) { + zend_string *_5; + zend_ulong _4; + zval assignments; + zval column, value, _0, _1, *_2, _3, _11, _12, _6$$3, _8$$3, _9$$4, _10$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_7 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval servers; - zval *connection, connection_sub, *servers_param = NULL, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connection_sub); + ZVAL_UNDEF(&column); + ZVAL_UNDEF(&value); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&servers); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_OBJECT_OF_CLASS(connection, zephir_get_internal_ce(SL("memcached"))) - Z_PARAM_ARRAY(servers) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&_10$$4); + ZVAL_UNDEF(&assignments); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &connection, &servers_param); - zephir_get_arrval(&servers, servers_param); - ZEPHIR_CALL_METHOD(&_0, connection, "addservers", NULL, 0, &servers); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_storage_exception_ce, "Cannot connect to the Memcached server(s)", "phalcon/Storage/Adapter/Libmemcached.zep", 317); - return; + + ZEPHIR_INIT_VAR(&assignments); + array_init(&assignments); + zephir_read_property(&_0, this_ptr, ZEND_STRL("store"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch_string(&_1, &_0, SL("COLUMNS"), PH_NOISY | PH_READONLY, "phalcon/DataMapper/Query/Update.zep", 175); + zephir_is_iterable(&_1, 0, "phalcon/DataMapper/Query/Update.zep", 179); + if (Z_TYPE_P(&_1) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_1), _4, _5, _2) + { + ZEPHIR_INIT_NVAR(&column); + if (_5 != NULL) { + ZVAL_STR_COPY(&column, _5); + } else { + ZVAL_LONG(&column, _4); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _2); + ZEPHIR_CALL_METHOD(&_6$$3, this_ptr, "quoteidentifier", &_7, 0, &column); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_8$$3); + ZEPHIR_CONCAT_VSV(&_8$$3, &_6$$3, " = ", &value); + zephir_array_append(&assignments, &_8$$3, PH_SEPARATE, "phalcon/DataMapper/Query/Update.zep", 176); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_1, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &_1, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&column, &_1, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &_1, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_9$$4, this_ptr, "quoteidentifier", &_7, 0, &column); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_10$$4); + ZEPHIR_CONCAT_VSV(&_10$$4, &_9$$4, " = ", &value); + zephir_array_append(&assignments, &_10$$4, PH_SEPARATE, "phalcon/DataMapper/Query/Update.zep", 176); + ZEPHIR_CALL_METHOD(NULL, &_1, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_THIS(); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&column); + ZEPHIR_INIT_VAR(&_12); + ZVAL_STRING(&_12, ","); + ZEPHIR_CALL_METHOD(&_11, this_ptr, "indent", NULL, 0, &assignments, &_12); + zephir_check_call_status(); + ZEPHIR_CONCAT_SV(return_value, " SET", &_11); + RETURN_MM(); } @@ -134698,554 +134885,492 @@ static PHP_METHOD(Phalcon_Storage_Adapter_Libmemcached, setServers) -ZEPHIR_INIT_CLASS(Phalcon_Storage_Adapter_Memory) +ZEPHIR_INIT_CLASS(Phalcon_Application_AbstractApplication) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Adapter, Memory, phalcon, storage_adapter_memory, phalcon_storage_adapter_abstractadapter_ce, phalcon_storage_adapter_memory_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Application, AbstractApplication, phalcon, application_abstractapplication, phalcon_di_injectable_ce, phalcon_application_abstractapplication_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zend_declare_property_null(phalcon_storage_adapter_memory_ce, SL("data"), ZEND_ACC_PROTECTED); - phalcon_storage_adapter_memory_ce->create_object = zephir_init_properties_Phalcon_Storage_Adapter_Memory; + zend_declare_property_null(phalcon_application_abstractapplication_ce, SL("container"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_application_abstractapplication_ce, SL("defaultModule"), "", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_application_abstractapplication_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_application_abstractapplication_ce, SL("modules"), ZEND_ACC_PROTECTED); + phalcon_application_abstractapplication_ce->create_object = zephir_init_properties_Phalcon_Application_AbstractApplication; + zend_class_implements(phalcon_application_abstractapplication_ce, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Storage_Adapter_Memory, __construct) +static PHP_METHOD(Phalcon_Application_AbstractApplication, __construct) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval *factory, factory_sub, *options_param = NULL; + zval *container = NULL, container_sub, __$null; zval *this_ptr = getThis(); - ZVAL_UNDEF(&factory_sub); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_storage_serializerfactory_ce) + ZVAL_UNDEF(&container_sub); + ZVAL_NULL(&__$null); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(container, phalcon_di_diinterface_ce) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &factory, &options_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + zephir_fetch_params_without_memory_grow(0, 1, &container); + if (!container) { + container = &container_sub; + container = &__$null; + } + if (Z_TYPE_P(container) != IS_NULL) { + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); } - ZEPHIR_CALL_PARENT(NULL, phalcon_storage_adapter_memory_ce, getThis(), "__construct", NULL, 0, factory, &options); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "initserializer", NULL, 0); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Memory, clear) +static PHP_METHOD(Phalcon_Application_AbstractApplication, getDefaultModule) +{ + + RETURN_MEMBER(getThis(), "defaultModule"); +} + +static PHP_METHOD(Phalcon_Application_AbstractApplication, getEventsManager) +{ + + RETURN_MEMBER(getThis(), "eventsManager"); +} + +static PHP_METHOD(Phalcon_Application_AbstractApplication, getModule) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, module, _0, _1$$3; + zval name, _2$$3; zval *this_ptr = getThis(); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&module); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_memory_observe(&module); + zephir_read_property(&_0, this_ptr, ZEND_STRL("modules"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(!(zephir_array_isset_fetch(&module, &_0, &name, 0)))) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_application_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + ZEPHIR_CONCAT_SVS(&_2$$3, "Module '", &name, "' is not registered in the application container"); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Application/AbstractApplication.zep", 83); + ZEPHIR_MM_RESTORE(); + return; + } + RETURN_CCTOR(&module); +} - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("data"), &_0); - RETURN_MM_BOOL(1); +static PHP_METHOD(Phalcon_Application_AbstractApplication, getModules) +{ + + RETURN_MEMBER(getThis(), "modules"); } -static PHP_METHOD(Phalcon_Storage_Adapter_Memory, decrement) +static PHP_METHOD(Phalcon_Application_AbstractApplication, registerModules) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long value, ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value_param = NULL, current, newValue, prefixedKey, result, _0, _1$$3; - zval key; + zend_bool merge; + zval *modules_param = NULL, *merge_param = NULL, _0$$3, _1$$3; + zval modules; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(¤t); - ZVAL_UNDEF(&newValue); - ZVAL_UNDEF(&prefixedKey); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&modules); + ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_1$$3); ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(key) + Z_PARAM_ARRAY(modules) Z_PARAM_OPTIONAL - Z_PARAM_LONG(value) + Z_PARAM_BOOL(merge) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key_param, &value_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - if (!value_param) { - value = 1; + zephir_fetch_params(1, 1, 1, &modules_param, &merge_param); + zephir_get_arrval(&modules, modules_param); + if (!merge_param) { + merge = 0; } else { } - ZEPHIR_CALL_METHOD(&prefixedKey, this_ptr, "getprefixedkey", NULL, 0, &key); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&result); - ZVAL_BOOL(&result, zephir_array_key_exists(&_0, &prefixedKey)); - if (EXPECTED(ZEPHIR_IS_TRUE_IDENTICAL(&result))) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(¤t, &_1$$3, &prefixedKey, PH_NOISY | PH_READONLY, "phalcon/Storage/Adapter/Memory.zep", 72); - ZEPHIR_INIT_VAR(&newValue); - ZVAL_LONG(&newValue, (zephir_get_intval(¤t) - value)); - ZEPHIR_CPY_WRT(&result, &newValue); - zephir_update_property_array(this_ptr, SL("data"), &prefixedKey, &newValue); + if (merge) { + ZEPHIR_INIT_VAR(&_0$$3); + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("modules"), PH_NOISY_CC | PH_READONLY); + zephir_fast_array_merge(&_0$$3, &_1$$3, &modules); + zephir_update_property_zval(this_ptr, ZEND_STRL("modules"), &_0$$3); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("modules"), &modules); } - RETURN_CCTOR(&result); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Memory, delete) +static PHP_METHOD(Phalcon_Application_AbstractApplication, setDefaultModule) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, exists, prefixedKey, _0, _1; - zval key; + zval *defaultModule_param = NULL; + zval defaultModule; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&exists); - ZVAL_UNDEF(&prefixedKey); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&defaultModule); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + Z_PARAM_STR(defaultModule) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + zephir_fetch_params(1, 1, 0, &defaultModule_param); + if (UNEXPECTED(Z_TYPE_P(defaultModule_param) != IS_STRING && Z_TYPE_P(defaultModule_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'defaultModule' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + if (EXPECTED(Z_TYPE_P(defaultModule_param) == IS_STRING)) { + zephir_get_strval(&defaultModule, defaultModule_param); } else { - ZEPHIR_INIT_VAR(&key); + ZEPHIR_INIT_VAR(&defaultModule); } - ZEPHIR_CALL_METHOD(&prefixedKey, this_ptr, "getprefixedkey", NULL, 0, &key); - zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&exists); - ZVAL_BOOL(&exists, zephir_array_key_exists(&_0, &prefixedKey)); - zephir_unset_property_array(this_ptr, ZEND_STRL("data"), &prefixedKey); - zephir_read_property(&_1, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - zephir_array_unset(&_1, &prefixedKey, PH_SEPARATE); - RETURN_CCTOR(&exists); + zephir_update_property_zval(this_ptr, ZEND_STRL("defaultModule"), &defaultModule); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Memory, getKeys) +static PHP_METHOD(Phalcon_Application_AbstractApplication, setEventsManager) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *prefix_param = NULL, _0, _1; - zval prefix; + zval *eventsManager, eventsManager_sub, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&prefix); + ZVAL_UNDEF(&eventsManager_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_STR(prefix) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &prefix_param); - if (!prefix_param) { - ZEPHIR_INIT_VAR(&prefix); - ZVAL_STRING(&prefix, ""); - } else { - zephir_get_strval(&prefix, prefix_param); - } - ZEPHIR_INIT_VAR(&_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - zephir_array_keys(&_0, &_1); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getfilteredkeys", NULL, 0, &_0, &prefix); + zephir_fetch_params(1, 1, 0, &eventsManager); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getdi", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "eventsManager"); + ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &_1, eventsManager); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Memory, has) +zend_object *zephir_init_properties_Phalcon_Application_AbstractApplication(zend_class_entry *class_type) +{ + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("modules"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("modules"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Application_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Application, Exception, phalcon, application_exception, zend_ce_exception, NULL, 0); + + return SUCCESS; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Collection) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Support, Collection, phalcon, support_collection, phalcon_support_collection_method_entry, 0); + + zend_declare_property_null(phalcon_support_collection_ce, SL("data"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_support_collection_ce, SL("insensitive"), 1, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_support_collection_ce, SL("lowerKeys"), ZEND_ACC_PROTECTED); + phalcon_support_collection_ce->create_object = zephir_init_properties_Phalcon_Support_Collection; + + zend_class_implements(phalcon_support_collection_ce, 1, zend_ce_arrayaccess); + zend_class_implements(phalcon_support_collection_ce, 1, phalcon_support_collection_collectioninterface_ce); + zend_class_implements(phalcon_support_collection_ce, 1, zend_ce_countable); + zend_class_implements(phalcon_support_collection_ce, 1, zend_ce_aggregate); + zend_class_implements(phalcon_support_collection_ce, 1, php_json_serializable_ce); + zend_class_implements(phalcon_support_collection_ce, 1, zend_ce_serializable); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Collection, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, prefixedKey, _0; - zval key; + zend_bool insensitive; + zval *data_param = NULL, *insensitive_param = NULL, __$true, __$false; + zval data; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&prefixedKey); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + ZVAL_UNDEF(&data); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(data) + Z_PARAM_BOOL(insensitive) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 0, 2, &data_param, &insensitive_param); + if (!data_param) { + ZEPHIR_INIT_VAR(&data); + array_init(&data); + } else { + zephir_get_arrval(&data, data_param); } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + if (!insensitive_param) { + insensitive = 1; } else { - ZEPHIR_INIT_VAR(&key); + } + if (insensitive) { + zephir_update_property_zval(this_ptr, ZEND_STRL("insensitive"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("insensitive"), &__$false); } - ZEPHIR_CALL_METHOD(&prefixedKey, this_ptr, "getprefixedkey", NULL, 0, &key); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &data); zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - RETURN_MM_BOOL(zephir_array_key_exists(&_0, &prefixedKey)); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Memory, increment) +static PHP_METHOD(Phalcon_Support_Collection, __get) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long value, ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value_param = NULL, current, newValue, prefixedKey, result, _0, _1$$3; - zval key; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *element_param = NULL; + zval element; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(¤t); - ZVAL_UNDEF(&newValue); - ZVAL_UNDEF(&prefixedKey); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(key) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(value) + ZVAL_UNDEF(&element); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(element) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key_param, &value_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - if (!value_param) { - value = 1; - } else { - } - ZEPHIR_CALL_METHOD(&prefixedKey, this_ptr, "getprefixedkey", NULL, 0, &key); + zephir_fetch_params(1, 1, 0, &element_param); + zephir_get_strval(&element, element_param); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0, &element); zephir_check_call_status(); - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&result); - ZVAL_BOOL(&result, zephir_array_key_exists(&_0, &prefixedKey)); - if (EXPECTED(ZEPHIR_IS_TRUE_IDENTICAL(&result))) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(¤t, &_1$$3, &prefixedKey, PH_NOISY | PH_READONLY, "phalcon/Storage/Adapter/Memory.zep", 145); - ZEPHIR_INIT_VAR(&newValue); - ZVAL_LONG(&newValue, (zephir_get_intval(¤t) + value)); - ZEPHIR_CPY_WRT(&result, &newValue); - zephir_update_property_array(this_ptr, SL("data"), &prefixedKey, &newValue); - } - RETURN_CCTOR(&result); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Memory, set) +static PHP_METHOD(Phalcon_Support_Collection, __isset) { - zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub, *ttl = NULL, ttl_sub, __$null, content, prefixedKey; - zval key; + zval *element_param = NULL; + zval element; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&ttl_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&content); - ZVAL_UNDEF(&prefixedKey); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(ttl) + ZVAL_UNDEF(&element); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(element) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &key_param, &value, &ttl); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - if (!ttl) { - ttl = &ttl_sub; - ttl = &__$null; - } - _0 = Z_TYPE_P(ttl) == IS_LONG; - if (_0) { - _0 = ZEPHIR_LT_LONG(ttl, 1); - } - if (_0) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "delete", NULL, 0, &key); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(&content, this_ptr, "getserializeddata", NULL, 0, value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&prefixedKey, this_ptr, "getprefixedkey", NULL, 0, &key); + zephir_fetch_params(1, 1, 0, &element_param); + zephir_get_strval(&element, element_param); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, &element); zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("data"), &prefixedKey, &content); - RETURN_MM_BOOL(1); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Memory, setForever) +static PHP_METHOD(Phalcon_Support_Collection, __set) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub; - zval key; + zval *element_param = NULL, *value, value_sub; + zval element; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&element); ZVAL_UNDEF(&value_sub); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(key) + Z_PARAM_STR(element) Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &key_param, &value); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "set", NULL, 0, &key, value); + zephir_fetch_params(1, 2, 0, &element_param, &value); + zephir_get_strval(&element, element_param); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, 0, &element, value); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Memory, doGet) +static PHP_METHOD(Phalcon_Support_Collection, __unset) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, _0, _1, _2; - zval key; + zval *element_param = NULL; + zval element; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&element); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + Z_PARAM_STR(element) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - zephir_get_strval(&key, key_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getprefixedkey", NULL, 0, &key); + zephir_fetch_params(1, 1, 0, &element_param); + zephir_get_strval(&element, element_param); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "remove", NULL, 0, &element); zephir_check_call_status(); - zephir_array_fetch(&_1, &_0, &_2, PH_NOISY | PH_READONLY, "phalcon/Storage/Adapter/Memory.zep", 206); - RETURN_CTOR(&_1); + ZEPHIR_MM_RESTORE(); } -zend_object *zephir_init_properties_Phalcon_Storage_Adapter_Memory(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Support_Collection, clear) { - zval _0, _2, _1$$3, _3$$4; + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("data"), &_3$$4); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - + zval *this_ptr = getThis(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("data"), &_0); + ZEPHIR_INIT_VAR(&_1); + array_init(&_1); + zephir_update_property_zval(this_ptr, ZEND_STRL("lowerKeys"), &_1); + ZEPHIR_MM_RESTORE(); +} -ZEPHIR_INIT_CLASS(Phalcon_Storage_Adapter_Redis) +static PHP_METHOD(Phalcon_Support_Collection, count) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Adapter, Redis, phalcon, storage_adapter_redis, phalcon_storage_adapter_abstractadapter_ce, phalcon_storage_adapter_redis_method_entry, 0); + zval _0; + zval *this_ptr = getThis(); - zend_declare_property_string(phalcon_storage_adapter_redis_ce, SL("prefix"), "ph-reds-", ZEND_ACC_PROTECTED); - return SUCCESS; + ZVAL_UNDEF(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + RETURN_LONG(zephir_fast_count_int(&_0)); } -static PHP_METHOD(Phalcon_Storage_Adapter_Redis, __construct) +static PHP_METHOD(Phalcon_Support_Collection, get) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval *factory, factory_sub, *options_param = NULL, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14; + zval *element_param = NULL, *defaultValue = NULL, defaultValue_sub, *cast_param = NULL, __$null, key, value, _0, _1, _2, _3; + zval element, cast; zval *this_ptr = getThis(); - ZVAL_UNDEF(&factory_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_13); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_storage_serializerfactory_ce) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &factory, &options_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); - } - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "host"); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "127.0.0.1"); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getarrval", NULL, 0, &options, &_1, &_2); - zephir_check_call_status(); - zephir_array_update_string(&options, SL("host"), &_0, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "port"); - ZVAL_LONG(&_4, 6379); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "int"); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "getarrval", NULL, 0, &options, &_1, &_4, &_2); - zephir_check_call_status(); - zephir_array_update_string(&options, SL("port"), &_3, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "index"); - ZVAL_LONG(&_4, 0); - ZEPHIR_CALL_METHOD(&_5, this_ptr, "getarrval", NULL, 0, &options, &_1, &_4); - zephir_check_call_status(); - zephir_array_update_string(&options, SL("index"), &_5, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "timeout"); - ZVAL_LONG(&_4, 0); - ZEPHIR_CALL_METHOD(&_6, this_ptr, "getarrval", NULL, 0, &options, &_1, &_4); - zephir_check_call_status(); - zephir_array_update_string(&options, SL("timeout"), &_6, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "persistent"); - ZVAL_BOOL(&_4, 0); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "bool"); - ZEPHIR_CALL_METHOD(&_7, this_ptr, "getarrval", NULL, 0, &options, &_1, &_4, &_2); - zephir_check_call_status(); - zephir_array_update_string(&options, SL("persistent"), &_7, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "persistentId"); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, ""); - ZEPHIR_INIT_VAR(&_9); - ZVAL_STRING(&_9, "string"); - ZEPHIR_CALL_METHOD(&_8, this_ptr, "getarrval", NULL, 0, &options, &_1, &_2, &_9); - zephir_check_call_status(); - zephir_array_update_string(&options, SL("persistentId"), &_8, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "auth"); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, ""); - ZEPHIR_CALL_METHOD(&_10, this_ptr, "getarrval", NULL, 0, &options, &_1, &_2); - zephir_check_call_status(); - zephir_array_update_string(&options, SL("auth"), &_10, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "socket"); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, ""); - ZEPHIR_CALL_METHOD(&_11, this_ptr, "getarrval", NULL, 0, &options, &_1, &_2); - zephir_check_call_status(); - zephir_array_update_string(&options, SL("socket"), &_11, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "connectTimeout"); - ZVAL_LONG(&_4, 0); - ZEPHIR_CALL_METHOD(&_12, this_ptr, "getarrval", NULL, 0, &options, &_1, &_4); - zephir_check_call_status(); - zephir_array_update_string(&options, SL("connectTimeout"), &_12, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "retryInterval"); - ZVAL_LONG(&_4, 0); - ZEPHIR_CALL_METHOD(&_13, this_ptr, "getarrval", NULL, 0, &options, &_1, &_4); - zephir_check_call_status(); - zephir_array_update_string(&options, SL("retryInterval"), &_13, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "readTimeout"); - ZVAL_LONG(&_4, 0); - ZEPHIR_CALL_METHOD(&_14, this_ptr, "getarrval", NULL, 0, &options, &_1, &_4); - zephir_check_call_status(); - zephir_array_update_string(&options, SL("readTimeout"), &_14, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_PARENT(NULL, phalcon_storage_adapter_redis_ce, getThis(), "__construct", NULL, 0, factory, &options); + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&cast); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(element) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(defaultValue) + Z_PARAM_STR_OR_NULL(cast) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &element_param, &defaultValue, &cast_param); + zephir_get_strval(&element, element_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } + if (!cast_param) { + ZEPHIR_INIT_VAR(&cast); + } else { + if (UNEXPECTED(Z_TYPE_P(cast_param) != IS_STRING && Z_TYPE_P(cast_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'cast' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(cast_param) == IS_STRING)) { + zephir_get_strval(&cast, cast_param); + } else { + ZEPHIR_INIT_VAR(&cast); + } + } + ZEPHIR_CALL_METHOD(&_0, this_ptr, "processkey", NULL, 0, &element); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + zephir_get_strval(&element, &_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("lowerKeys"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(1 != zephir_array_isset(&_1, &element))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + zephir_read_property(&_2, this_ptr, ZEND_STRL("lowerKeys"), PH_NOISY_CC | PH_READONLY); + zephir_memory_observe(&key); + zephir_array_fetch(&key, &_2, &element, PH_NOISY, "phalcon/Support/Collection.zep", 140); + zephir_read_property(&_3, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + zephir_memory_observe(&value); + zephir_array_fetch(&value, &_3, &key, PH_NOISY, "phalcon/Support/Collection.zep", 141); + if (UNEXPECTED((Z_TYPE_P(&value) == IS_NULL))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + if (UNEXPECTED(zephir_is_true(&cast))) { + ZEPHIR_MAKE_REF(&value); + ZEPHIR_CALL_FUNCTION(NULL, "settype", NULL, 11, &value, &cast); + ZEPHIR_UNREF(&value); + zephir_check_call_status(); + } + RETURN_CCTOR(&value); } -static PHP_METHOD(Phalcon_Storage_Adapter_Redis, clear) +static PHP_METHOD(Phalcon_Support_Collection, getIterator) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; @@ -135256,2195 +135381,2200 @@ static PHP_METHOD(Phalcon_Storage_Adapter_Redis, clear) ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getadapter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&_0, "flushdb", NULL, 0); + object_init_ex(return_value, spl_ce_ArrayIterator); + zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 13, &_0); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Redis, decrement) +static PHP_METHOD(Phalcon_Support_Collection, getKeys) { + zval collection; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long value, ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value_param = NULL, _0, _1; - zval key; + zval *insensitive_param = NULL, _0; + zend_bool insensitive; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(key) + ZVAL_UNDEF(&collection); + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_LONG(value) + Z_PARAM_BOOL(insensitive) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key_param, &value_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - if (!value_param) { - value = 1; + zephir_fetch_params(1, 0, 1, &insensitive_param); + if (!insensitive_param) { + insensitive = 1; } else { } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getadapter", NULL, 0); - zephir_check_call_status(); - ZVAL_LONG(&_1, value); - ZEPHIR_RETURN_CALL_METHOD(&_0, "decrby", NULL, 0, &key, &_1); - zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + if (insensitive == 1) { + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("lowerKeys"), PH_NOISY_CC); + } else { + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC); + } + ZEPHIR_CPY_WRT(&collection, &_0); + zephir_array_keys(return_value, &collection); RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Redis, delete) +static PHP_METHOD(Phalcon_Support_Collection, getValues) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, _0, _1; - zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getadapter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, &_0, "del", NULL, 0, &key); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_FUNCTION("array_values", NULL, 14, &_0); zephir_check_call_status(); - RETURN_MM_BOOL(zephir_get_boolval(&_1)); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Redis, getAdapter) +static PHP_METHOD(Phalcon_Support_Collection, has) { - zval connection, _0, _1$$3, _2$$3, _3$$3, _4$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *element_param = NULL, _0, _1; + zval element; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connection); + ZVAL_UNDEF(&element); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(element) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&connection); - object_init_ex(&connection, zephir_get_internal_ce(SL("redis"))); - ZEPHIR_CALL_METHOD(NULL, &connection, "__construct", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "checkconnect", NULL, 113, &connection); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_2$$3, &_1$$3, "checkauth", NULL, 114, &connection); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_2$$3, "checkindex", NULL, 115, &connection); - zephir_check_call_status(); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_4$$3, 2); - ZEPHIR_CALL_METHOD(NULL, &connection, "setoption", NULL, 0, &_4$$3, &_3$$3); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setserializer", NULL, 116, &connection); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("adapter"), &connection); - } - RETURN_MM_MEMBER(getThis(), "adapter"); + zephir_fetch_params(1, 1, 0, &element_param); + zephir_get_strval(&element, element_param); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "processkey", NULL, 0, &element); + zephir_check_call_status(); + zephir_get_strval(&element, &_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("lowerKeys"), PH_NOISY_CC | PH_READONLY); + RETURN_MM_BOOL(zephir_array_isset(&_1, &element)); } -static PHP_METHOD(Phalcon_Storage_Adapter_Redis, getKeys) +static PHP_METHOD(Phalcon_Support_Collection, init) { + zend_string *_3; + zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *prefix_param = NULL, _0, _1, _2; - zval prefix; + zval *data_param = NULL, key, value, *_0, _1; + zval data; zval *this_ptr = getThis(); - ZVAL_UNDEF(&prefix); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_STR(prefix) + Z_PARAM_ARRAY(data) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &prefix_param); - if (!prefix_param) { - ZEPHIR_INIT_VAR(&prefix); - ZVAL_STRING(&prefix, ""); + zephir_fetch_params(1, 0, 1, &data_param); + if (!data_param) { + ZEPHIR_INIT_VAR(&data); + array_init(&data); } else { - if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be of the type string")); - RETURN_MM_NULL(); + zephir_get_arrval(&data, data_param); } - if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) { - zephir_get_strval(&prefix, prefix_param); + zephir_is_iterable(&data, 0, "phalcon/Support/Collection.zep", 206); + if (Z_TYPE_P(&data) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&key); + if (_3 != NULL) { + ZVAL_STR_COPY(&key, _3); + } else { + ZVAL_LONG(&key, _2); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdata", &_4, 0, &key, &value); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_INIT_VAR(&prefix); - } + ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &data, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &data, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdata", &_4, 0, &key, &value); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); + zephir_check_call_status(); + } } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getadapter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "*"); - ZEPHIR_CALL_METHOD(&_1, &_0, "keys", NULL, 0, &_2); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getfilteredkeys", NULL, 0, &_1, &prefix); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Redis, has) +static PHP_METHOD(Phalcon_Support_Collection, jsonSerialize) { + zend_bool _5$$3, _7$$6; + zend_string *_4; + zend_ulong _3; + zval records; + zval key, value, _0, *_1, _2, _6$$4, _8$$7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, _0, _1; - zval key; zval *this_ptr = getThis(); ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_8$$7); + ZVAL_UNDEF(&records); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + + ZEPHIR_INIT_VAR(&records); + array_init(&records); + zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_0, 0, "phalcon/Support/Collection.zep", 227); + if (Z_TYPE_P(&_0) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_0), _3, _4, _1) + { + ZEPHIR_INIT_NVAR(&key); + if (_4 != NULL) { + ZVAL_STR_COPY(&key, _4); + } else { + ZVAL_LONG(&key, _3); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _1); + _5$$3 = Z_TYPE_P(&value) == IS_OBJECT; + if (_5$$3) { + _5$$3 = (zephir_method_exists_ex(&value, ZEND_STRL("jsonserialize")) == SUCCESS); + } + if (_5$$3) { + ZEPHIR_CALL_METHOD(&_6$$4, &value, "jsonserialize", NULL, 0); + zephir_check_call_status(); + zephir_array_update_zval(&records, &key, &_6$$4, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&records, &key, &value, PH_COPY | PH_SEPARATE); + } + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_INIT_VAR(&key); + ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &_0, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &_0, "current", NULL, 0); + zephir_check_call_status(); + _7$$6 = Z_TYPE_P(&value) == IS_OBJECT; + if (_7$$6) { + _7$$6 = (zephir_method_exists_ex(&value, ZEND_STRL("jsonserialize")) == SUCCESS); + } + if (_7$$6) { + ZEPHIR_CALL_METHOD(&_8$$7, &value, "jsonserialize", NULL, 0); + zephir_check_call_status(); + zephir_array_update_zval(&records, &key, &_8$$7, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&records, &key, &value, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); + zephir_check_call_status(); + } } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getadapter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, &_0, "exists", NULL, 0, &key); - zephir_check_call_status(); - RETURN_MM_BOOL(zephir_get_boolval(&_1)); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + RETURN_CTOR(&records); } -static PHP_METHOD(Phalcon_Storage_Adapter_Redis, increment) +static PHP_METHOD(Phalcon_Support_Collection, offsetExists) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long value, ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value_param = NULL, _0, _1; - zval key; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval element_sub; + zval *element = NULL; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&element_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(key) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(value) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(element) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key_param, &value_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - if (!value_param) { - value = 1; - } else { - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getadapter", NULL, 0); - zephir_check_call_status(); - ZVAL_LONG(&_1, value); - ZEPHIR_RETURN_CALL_METHOD(&_0, "incrby", NULL, 0, &key, &_1); + zephir_fetch_params(1, 1, 0, &element); + zephir_cast_to_string(&_0, element); + ZEPHIR_CPY_WRT(element, &_0); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, element); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Redis, set) +static PHP_METHOD(Phalcon_Support_Collection, offsetGet) { - zend_bool _0; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub, *ttl = NULL, ttl_sub, __$null, result, _1, _2, _3, _4; - zval key; + zval element_sub; + zval *element = NULL; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&ttl_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(ttl) + ZVAL_UNDEF(&element_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(element) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &key_param, &value, &ttl); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - if (!ttl) { - ttl = &ttl_sub; - ttl = &__$null; - } - _0 = Z_TYPE_P(ttl) == IS_LONG; - if (_0) { - _0 = ZEPHIR_LT_LONG(ttl, 1); - } - if (_0) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "delete", NULL, 0, &key); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getadapter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getserializeddata", NULL, 0, value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "getttl", NULL, 0, ttl); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&result, &_1, "set", NULL, 0, &key, &_2, &_3); + zephir_fetch_params(1, 1, 0, &element); + zephir_cast_to_string(&_0, element); + ZEPHIR_CPY_WRT(element, &_0); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0, element); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_4); - if (((Z_TYPE_P(&result) == IS_TRUE || Z_TYPE_P(&result) == IS_FALSE) == 1)) { - ZEPHIR_CPY_WRT(&_4, &result); - } else { - ZEPHIR_INIT_NVAR(&_4); - ZVAL_BOOL(&_4, 0); - } - RETURN_CCTOR(&_4); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Redis, setForever) +static PHP_METHOD(Phalcon_Support_Collection, offsetSet) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub, result, _0, _1, _2; - zval key; + zval offset_sub, value_sub; + zval *offset = NULL, *value; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&offset_sub); ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(key) + Z_PARAM_ZVAL(offset) Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &key_param, &value); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getadapter", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getserializeddata", NULL, 0, value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&result, &_0, "set", NULL, 0, &key, &_1); + zephir_fetch_params(1, 2, 0, &offset, &value); + zephir_cast_to_string(&_0, offset); + ZEPHIR_CPY_WRT(offset, &_0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, 0, offset, value); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2); - if (((Z_TYPE_P(&result) == IS_TRUE || Z_TYPE_P(&result) == IS_FALSE) == 1)) { - ZEPHIR_CPY_WRT(&_2, &result); - } else { - ZEPHIR_INIT_NVAR(&_2); - ZVAL_BOOL(&_2, 0); - } - RETURN_CCTOR(&_2); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Redis, checkAuth) +static PHP_METHOD(Phalcon_Support_Collection, offsetUnset) { - zend_bool error = 0, _1$$3; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connection, connection_sub, auth, _0, _3, _4, _2$$3; + zval element_sub; + zval *element = NULL; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connection_sub); - ZVAL_UNDEF(&auth); + ZVAL_UNDEF(&element_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_2$$3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(connection, zephir_get_internal_ce(SL("redis"))) + Z_PARAM_ZVAL(element) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &connection); - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&auth); - zephir_array_fetch_string(&auth, &_0, SL("auth"), PH_NOISY, "phalcon/Storage/Adapter/Redis.zep", 243); - - /* try_start_1: */ - - _1$$3 = 1 != ZEPHIR_IS_EMPTY(&auth); - if (_1$$3) { - ZEPHIR_CALL_METHOD(&_2$$3, connection, "auth", NULL, 0, &auth); - zephir_check_call_status_or_jump(try_end_1); - _1$$3 = !ZEPHIR_IS_TRUE_IDENTICAL(&_2$$3); - } - error = _1$$3; - - try_end_1: - - if (EG(exception)) { - ZEPHIR_INIT_VAR(&_3); - ZVAL_OBJ(&_3, EG(exception)); - Z_ADDREF_P(&_3); - ZEPHIR_INIT_VAR(&_4); - if (zephir_is_instance_of(&_3, SL("Exception"))) { - zend_clear_exception(); - ZEPHIR_CPY_WRT(&_4, &_3); - error = 1; - } - } - if (error) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_storage_exception_ce, "Failed to authenticate with the Redis server", "phalcon/Storage/Adapter/Redis.zep", 254); - return; - } - RETURN_THIS(); + zephir_fetch_params(1, 1, 0, &element); + zephir_cast_to_string(&_0, element); + ZEPHIR_CPY_WRT(element, &_0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "remove", NULL, 0, element); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Redis, checkConnect) +static PHP_METHOD(Phalcon_Support_Collection, remove) { + zval lowerKeys, data; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connection, connection_sub, host, method, options, parameter, persistentId, port, retryInterval, readTimeout, result, timeout, _0, _1, _2$$4, _3$$4, _4$$5, _5$$5, _6$$5; + zval *element_param = NULL, key, _0, _1$$3, _2$$3, _3$$3; + zval element; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connection_sub); - ZVAL_UNDEF(&host); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(¶meter); - ZVAL_UNDEF(&persistentId); - ZVAL_UNDEF(&port); - ZVAL_UNDEF(&retryInterval); - ZVAL_UNDEF(&readTimeout); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&timeout); + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&key); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&lowerKeys); + ZVAL_UNDEF(&data); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(connection, zephir_get_internal_ce(SL("redis"))) + Z_PARAM_STR(element) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &connection); - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&options, &_0); - zephir_memory_observe(&host); - zephir_array_fetch_string(&host, &options, SL("host"), PH_NOISY, "phalcon/Storage/Adapter/Redis.zep", 272); - zephir_memory_observe(&port); - zephir_array_fetch_string(&port, &options, SL("port"), PH_NOISY, "phalcon/Storage/Adapter/Redis.zep", 273); - zephir_memory_observe(&timeout); - zephir_array_fetch_string(&timeout, &options, SL("timeout"), PH_NOISY, "phalcon/Storage/Adapter/Redis.zep", 274); - zephir_memory_observe(&retryInterval); - zephir_array_fetch_string(&retryInterval, &options, SL("retryInterval"), PH_NOISY, "phalcon/Storage/Adapter/Redis.zep", 275); - zephir_memory_observe(&readTimeout); - zephir_array_fetch_string(&readTimeout, &options, SL("readTimeout"), PH_NOISY, "phalcon/Storage/Adapter/Redis.zep", 276); - zephir_array_fetch_string(&_1, &options, SL("persistent"), PH_NOISY | PH_READONLY, "phalcon/Storage/Adapter/Redis.zep", 278); - ZEPHIR_INIT_VAR(&method); - ZEPHIR_INIT_VAR(¶meter); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_1)) { - ZVAL_STRING(&method, "connect"); - ZVAL_NULL(¶meter); - } else { - ZVAL_STRING(&method, "pconnect"); - zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&persistentId); - zephir_array_fetch_string(&persistentId, &_2$$4, SL("persistentId"), PH_NOISY, "phalcon/Storage/Adapter/Redis.zep", 283); - if (!(ZEPHIR_IS_EMPTY(&persistentId))) { - ZEPHIR_CPY_WRT(¶meter, &persistentId); - } else { - zephir_array_fetch_string(&_3$$4, &options, SL("index"), PH_NOISY | PH_READONLY, "phalcon/Storage/Adapter/Redis.zep", 284); - ZEPHIR_CONCAT_SV(¶meter, "persistentId", &_3$$4); - } - } - ZEPHIR_CALL_METHOD_ZVAL(&result, connection, &method, NULL, 0, &host, &port, &timeout, ¶meter, &retryInterval, &readTimeout); + zephir_fetch_params(1, 1, 0, &element_param); + zephir_get_strval(&element, element_param); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, 0, &element); zephir_check_call_status(); - if (!(zephir_is_true(&result))) { - ZEPHIR_INIT_VAR(&_4$$5); - object_init_ex(&_4$$5, phalcon_storage_exception_ce); - ZEPHIR_INIT_VAR(&_5$$5); - ZVAL_STRING(&_5$$5, "Could not connect to the Redisd server [%s:%s]"); - ZEPHIR_CALL_FUNCTION(&_6$$5, "sprintf", NULL, 117, &_5$$5, &host, &port); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_4$$5, "__construct", NULL, 33, &_6$$5); + if (UNEXPECTED(zephir_is_true(&_0))) { + ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "processkey", NULL, 0, &element); zephir_check_call_status(); - zephir_throw_exception_debug(&_4$$5, "phalcon/Storage/Adapter/Redis.zep", 303); - ZEPHIR_MM_RESTORE(); - return; + zephir_get_strval(&element, &_1$$3); + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&data, &_2$$3); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("lowerKeys"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&lowerKeys, &_3$$3); + zephir_array_fetch(&key, &lowerKeys, &element, PH_NOISY | PH_READONLY, "phalcon/Support/Collection.zep", 286); + zephir_array_unset(&lowerKeys, &element, PH_SEPARATE); + zephir_array_unset(&data, &key, PH_SEPARATE); + zephir_update_property_zval(this_ptr, ZEND_STRL("data"), &data); + zephir_update_property_zval(this_ptr, ZEND_STRL("lowerKeys"), &lowerKeys); } - RETURN_THIS(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Redis, checkIndex) +static PHP_METHOD(Phalcon_Support_Collection, set) { - zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connection, connection_sub, index, _0, _2; + zval *element_param = NULL, *value, value_sub; + zval element; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connection_sub); - ZVAL_UNDEF(&index); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(connection, zephir_get_internal_ce(SL("redis"))) + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(element) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &connection); - zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&index); - zephir_array_fetch_string(&index, &_0, SL("index"), PH_NOISY, "phalcon/Storage/Adapter/Redis.zep", 319); - _1 = ZEPHIR_GT_LONG(&index, 0); - if (_1) { - ZEPHIR_CALL_METHOD(&_2, connection, "select", NULL, 0, &index); - zephir_check_call_status(); - _1 = !ZEPHIR_IS_TRUE_IDENTICAL(&_2); - } - if (_1) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_storage_exception_ce, "Redis server selected database failed", "phalcon/Storage/Adapter/Redis.zep", 324); - return; - } - RETURN_THIS(); + zephir_fetch_params(1, 2, 0, &element_param, &value); + zephir_get_strval(&element, element_param); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdata", NULL, 0, &element, value); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Redis, setSerializer) +static PHP_METHOD(Phalcon_Support_Collection, serialize) { - zval map; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *connection, connection_sub, serializer, _0, _1, _4, _7, _10, _2$$3, _3$$3, _5$$4, _6$$4, _8$$5, _9$$5, _11$$6, _12$$6, _13$$6; zval *this_ptr = getThis(); - ZVAL_UNDEF(&connection_sub); - ZVAL_UNDEF(&serializer); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_8$$5); - ZVAL_UNDEF(&_9$$5); - ZVAL_UNDEF(&_11$$6); - ZVAL_UNDEF(&_12$$6); - ZVAL_UNDEF(&_13$$6); - ZVAL_UNDEF(&map); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(connection, zephir_get_internal_ce(SL("redis"))) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &connection); - ZEPHIR_INIT_VAR(&map); - zephir_create_array(&map, 2, 0); - add_assoc_long_ex(&map, SL("redis_none"), 0); - add_assoc_long_ex(&map, SL("redis_php"), 1); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "\\Redis::SERIALIZER_IGBINARY"); - ZEPHIR_CALL_FUNCTION(&_1, "defined", NULL, 118, &_0); - zephir_check_call_status(); - if (zephir_is_true(&_1)) { - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "\\Redis::SERIALIZER_IGBINARY"); - ZEPHIR_CALL_FUNCTION(&_3$$3, "constant", NULL, 119, &_2$$3); - zephir_check_call_status(); - zephir_array_update_string(&map, SL("redis_igbinary"), &_3$$3, PH_COPY | PH_SEPARATE); - } - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, "\\Redis::SERIALIZER_MSGPACK"); - ZEPHIR_CALL_FUNCTION(&_4, "defined", NULL, 118, &_0); - zephir_check_call_status(); - if (zephir_is_true(&_4)) { - ZEPHIR_INIT_VAR(&_5$$4); - ZVAL_STRING(&_5$$4, "\\Redis::SERIALIZER_MSGPACK"); - ZEPHIR_CALL_FUNCTION(&_6$$4, "constant", NULL, 119, &_5$$4); - zephir_check_call_status(); - zephir_array_update_string(&map, SL("redis_msgpack"), &_6$$4, PH_COPY | PH_SEPARATE); - } - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, "\\Redis::SERIALIZER_JSON"); - ZEPHIR_CALL_FUNCTION(&_7, "defined", NULL, 118, &_0); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "toarray", NULL, 0); zephir_check_call_status(); - if (zephir_is_true(&_7)) { - ZEPHIR_INIT_VAR(&_8$$5); - ZVAL_STRING(&_8$$5, "\\Redis::SERIALIZER_JSON"); - ZEPHIR_CALL_FUNCTION(&_9$$5, "constant", NULL, 119, &_8$$5); - zephir_check_call_status(); - zephir_array_update_string(&map, SL("redis_json"), &_9$$5, PH_COPY | PH_SEPARATE); - } - zephir_read_property(&_10, this_ptr, ZEND_STRL("defaultSerializer"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&serializer); - zephir_fast_strtolower(&serializer, &_10); - if (1 == zephir_array_isset(&map, &serializer)) { - ZEPHIR_INIT_VAR(&_11$$6); - ZEPHIR_INIT_NVAR(&_11$$6); - ZVAL_STRING(&_11$$6, ""); - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultSerializer"), &_11$$6); - zephir_array_fetch(&_12$$6, &map, &serializer, PH_NOISY | PH_READONLY, "phalcon/Storage/Adapter/Redis.zep", 366); - ZVAL_LONG(&_13$$6, 1); - ZEPHIR_CALL_METHOD(NULL, connection, "setoption", NULL, 0, &_13$$6, &_12$$6); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "initserializer", NULL, 0); + ZEPHIR_RETURN_CALL_FUNCTION("serialize", NULL, 15, &_0); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Storage_Adapter_Stream) +static PHP_METHOD(Phalcon_Support_Collection, toArray) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Adapter, Stream, phalcon, storage_adapter_stream, phalcon_storage_adapter_abstractadapter_ce, phalcon_storage_adapter_stream_method_entry, 0); - zend_declare_property_string(phalcon_storage_adapter_stream_ce, SL("prefix"), "ph-strm", ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_storage_adapter_stream_ce, SL("storageDir"), "", ZEND_ACC_PROTECTED); - return SUCCESS; + RETURN_MEMBER(getThis(), "data"); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, __construct) +static PHP_METHOD(Phalcon_Support_Collection, toJson) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval options; - zval *factory, factory_sub, *options_param = NULL, storageDir, _0, _1, _2; + zval *options_param = NULL, result, _0, _1; + zend_long options, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&factory_sub); - ZVAL_UNDEF(&storageDir); + ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&options); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_storage_serializerfactory_ce) + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + Z_PARAM_LONG(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &factory, &options_param); + zephir_fetch_params(1, 0, 1, &options_param); if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); + options = 4194383; } else { - ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "storageDir"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, ""); - ZEPHIR_CALL_METHOD(&storageDir, this_ptr, "getarrval", NULL, 0, &options, &_0, &_1); + } + ZEPHIR_CALL_METHOD(&_0, this_ptr, "jsonserialize", NULL, 0); zephir_check_call_status(); - if (ZEPHIR_IS_EMPTY(&storageDir)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_storage_exception_ce, "The 'storageDir' must be specified in the options", "phalcon/Storage/Adapter/Stream.zep", 60); - return; - } - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getdirseparator", NULL, 120, &storageDir); + ZVAL_LONG(&_1, options); + ZEPHIR_CALL_METHOD(&result, this_ptr, "phpjsonencode", NULL, 0, &_0, &_1); zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("storageDir"), &_2); - ZEPHIR_CALL_PARENT(NULL, phalcon_storage_adapter_stream_ce, getThis(), "__construct", NULL, 0, factory, &options); + if (ZEPHIR_IS_FALSE_IDENTICAL(&result)) { + ZEPHIR_INIT_NVAR(&result); + ZVAL_STRING(&result, ""); + } + RETURN_CCTOR(&result); +} + +static PHP_METHOD(Phalcon_Support_Collection, unserialize) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *data_param = NULL, unserialized; + zval data; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&unserialized); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(data) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &data_param); + zephir_get_strval(&data, data_param); + ZEPHIR_CALL_FUNCTION(&unserialized, "unserialize", NULL, 16, &data); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "initserializer", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &unserialized); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, clear) +static PHP_METHOD(Phalcon_Support_Collection, __serialize) { - zend_bool result = 0, _4$$3, _9$$5; - zval directory, iterator, file, _0, *_1, _2, _3$$3, _5$$3, _6$$3, _8$$5, _10$$5, _11$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - - ZVAL_UNDEF(&directory); - ZVAL_UNDEF(&iterator); - ZVAL_UNDEF(&file); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_8$$5); - ZVAL_UNDEF(&_10$$5); - ZVAL_UNDEF(&_11$$5); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - result = 1; - zephir_read_property(&_0, this_ptr, ZEND_STRL("storageDir"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&directory, this_ptr, "getdirseparator", NULL, 120, &_0); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "toarray", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&iterator, this_ptr, "getiterator", NULL, 121, &directory); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Support_Collection, __unserialize) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *data_param = NULL; + zval data; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&data); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(data) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &data_param); + zephir_get_arrval(&data, data_param); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &data); zephir_check_call_status(); - zephir_is_iterable(&iterator, 0, "phalcon/Storage/Adapter/Stream.zep", 91); - if (Z_TYPE_P(&iterator) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&iterator), _1) - { - ZEPHIR_INIT_NVAR(&file); - ZVAL_COPY(&file, _1); - ZEPHIR_CALL_METHOD(&_3$$3, &file, "isfile", NULL, 0); - zephir_check_call_status(); - _4$$3 = ZEPHIR_IS_TRUE_IDENTICAL(&_3$$3); - if (_4$$3) { - ZEPHIR_CALL_METHOD(&_6$$3, &file, "getpathname", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_5$$3, this_ptr, "phpunlink", &_7, 0, &_6$$3); - zephir_check_call_status(); - _4$$3 = !ZEPHIR_IS_TRUE_IDENTICAL(&_5$$3); - } - if (UNEXPECTED(_4$$3)) { - result = 0; - } - } ZEND_HASH_FOREACH_END(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Support_Collection, setData) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *element_param = NULL, *value, value_sub, key; + zval element; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&key); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(element) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &element_param, &value); + zephir_get_strval(&element, element_param); + ZEPHIR_CALL_METHOD(&key, this_ptr, "processkey", NULL, 0, &element); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("data"), &element, value); + zephir_update_property_array(this_ptr, SL("lowerKeys"), &key, &element); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Support_Collection, phpJsonEncode) +{ + zend_long flags, depth; + zval *value, value_sub, *flags_param = NULL, *depth_param = NULL, _0, _1; + + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ZVAL(value) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(flags) + Z_PARAM_LONG(depth) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 2, &value, &flags_param, &depth_param); + if (!flags_param) { + flags = 0; } else { - ZEPHIR_CALL_METHOD(NULL, &iterator, "rewind", NULL, 0); + } + if (!depth_param) { + depth = 512; + } else { + } + ZVAL_LONG(&_0, flags); + ZVAL_LONG(&_1, depth); + zephir_json_encode(return_value, value, zephir_get_intval(&_0) ); + return; +} + +static PHP_METHOD(Phalcon_Support_Collection, processKey) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *element_param = NULL, _0; + zval element; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(element) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &element_param); + zephir_get_strval(&element, element_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("insensitive"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(zephir_is_true(&_0))) { + ZEPHIR_RETURN_CALL_FUNCTION("mb_strtolower", NULL, 10, &element); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &iterator, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&file, &iterator, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_8$$5, &file, "isfile", NULL, 0); - zephir_check_call_status(); - _9$$5 = ZEPHIR_IS_TRUE_IDENTICAL(&_8$$5); - if (_9$$5) { - ZEPHIR_CALL_METHOD(&_11$$5, &file, "getpathname", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_10$$5, this_ptr, "phpunlink", &_7, 0, &_11$$5); - zephir_check_call_status(); - _9$$5 = !ZEPHIR_IS_TRUE_IDENTICAL(&_10$$5); - } - if (UNEXPECTED(_9$$5)) { - result = 0; - } - ZEPHIR_CALL_METHOD(NULL, &iterator, "next", NULL, 0); - zephir_check_call_status(); + RETURN_MM(); + } + RETURN_CTOR(&element); +} + +zend_object *zephir_init_properties_Phalcon_Support_Collection(zend_class_entry *class_type) +{ + zval _0, _2, _1$$3, _3$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("lowerKeys"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("lowerKeys"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("data"), &_3$$4); } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } - ZEPHIR_INIT_NVAR(&file); - RETURN_MM_BOOL(result); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, decrement) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Debug) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Support, Debug, phalcon, support_debug, phalcon_support_debug_method_entry, 0); + + zend_declare_property_null(phalcon_support_debug_ce, SL("blacklist"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_support_debug_ce, SL("data"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_support_debug_ce, SL("hideDocumentRoot"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_support_debug_ce, SL("isActive"), 0, ZEND_ACC_PROTECTED|ZEND_ACC_STATIC); + zend_declare_property_bool(phalcon_support_debug_ce, SL("showBackTrace"), 1, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_support_debug_ce, SL("showFileFragment"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_support_debug_ce, SL("showFiles"), 1, ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_support_debug_ce, SL("uri"), "https://assets.phalcon.io/debug/5.0.x/", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_support_debug_ce, SL("version"), ZEND_ACC_PRIVATE); + phalcon_support_debug_ce->create_object = zephir_init_properties_Phalcon_Support_Debug; + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Debug, __construct) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long value, ZEPHIR_LAST_CALL_STATUS, _1; - zval *key_param = NULL, *value_param = NULL, data, result, _0; - zval key; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(key) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(value) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key_param, &value_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - if (!value_param) { - value = 1; - } else { - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, 0, &key); - zephir_check_call_status(); - if (UNEXPECTED(!ZEPHIR_IS_TRUE_IDENTICAL(&_0))) { - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(&data, this_ptr, "get", NULL, 0, &key); - zephir_check_call_status(); - _1 = (zephir_get_intval(&data) - value); - ZEPHIR_INIT_NVAR(&data); - ZVAL_LONG(&data, _1); - ZEPHIR_CALL_METHOD(&result, this_ptr, "set", NULL, 0, &key, &data); - zephir_check_call_status(); - if (EXPECTED(!ZEPHIR_IS_FALSE_IDENTICAL(&result))) { - ZEPHIR_CPY_WRT(&result, &data); + + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, phalcon_support_version_ce); + if (zephir_has_constructor(&_0)) { + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); + zephir_check_call_status(); } - RETURN_CCTOR(&result); + + zephir_update_property_zval(this_ptr, ZEND_STRL("version"), &_0); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, delete) +static PHP_METHOD(Phalcon_Support_Debug, clearVars) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, filepath, _0; - zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&filepath); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, 0, &key); - zephir_check_call_status(); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(&filepath, this_ptr, "getfilepath", NULL, 122, &key); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_FUNCTION("unlink", NULL, 123, &filepath); - zephir_check_call_status(); - RETURN_MM(); + + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("data"), &_0); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, get) +static PHP_METHOD(Phalcon_Support_Debug, debugVar) { - zend_bool _0; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null, content, filepath, payload, _1, _2; - zval key; + zval *varz, varz_sub, _1, _2; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&content); - ZVAL_UNDEF(&filepath); - ZVAL_UNDEF(&payload); + ZVAL_UNDEF(&varz_sub); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(key) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(varz) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key_param, &defaultValue); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; - } - ZEPHIR_CALL_METHOD(&filepath, this_ptr, "getfilepath", NULL, 122, &key); - zephir_check_call_status(); - if (1 != (zephir_file_exists(&filepath) == SUCCESS)) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(&payload, this_ptr, "getpayload", NULL, 124, &filepath); + zephir_fetch_params(1, 1, 0, &varz); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 3, 0); + zephir_array_fast_append(&_0, varz); + ZEPHIR_CALL_FUNCTION(&_1, "debug_backtrace", NULL, 0); zephir_check_call_status(); - _0 = ZEPHIR_IS_EMPTY(&payload); - if (!(_0)) { - ZEPHIR_CALL_METHOD(&_1, this_ptr, "isexpired", NULL, 125, &payload); - zephir_check_call_status(); - _0 = zephir_is_true(&_1); - } - if (_0) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); - } + zephir_array_fast_append(&_0, &_1); ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "content"); - ZEPHIR_CALL_METHOD(&content, this_ptr, "getarrval", NULL, 0, &payload, &_2); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getunserializeddata", NULL, 0, &content, defaultValue); - zephir_check_call_status(); - RETURN_MM(); + zephir_time(&_2); + zephir_array_fast_append(&_0, &_2); + zephir_update_property_array_append(this_ptr, SL("data"), &_0); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, getKeys) +static PHP_METHOD(Phalcon_Support_Debug, getCssSources) { - zval files; + zval uri, sources, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *prefix_param = NULL, directory, file, iterator, _0, *_1, _2, _3$$4, _4$$5, _5$$5, _6$$5, _7$$6, _8$$7, _9$$7, _10$$7; - zval prefix; zval *this_ptr = getThis(); - ZVAL_UNDEF(&prefix); - ZVAL_UNDEF(&directory); - ZVAL_UNDEF(&file); - ZVAL_UNDEF(&iterator); + ZVAL_UNDEF(&uri); + ZVAL_UNDEF(&sources); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_8$$7); - ZVAL_UNDEF(&_9$$7); - ZVAL_UNDEF(&_10$$7); - ZVAL_UNDEF(&files); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_STR(prefix) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &prefix_param); - if (!prefix_param) { - ZEPHIR_INIT_VAR(&prefix); - ZVAL_STRING(&prefix, ""); - } else { - if (UNEXPECTED(Z_TYPE_P(prefix_param) != IS_STRING && Z_TYPE_P(prefix_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'prefix' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(prefix_param) == IS_STRING)) { - zephir_get_strval(&prefix, prefix_param); - } else { - ZEPHIR_INIT_VAR(&prefix); - } - } - ZEPHIR_INIT_VAR(&files); - array_init(&files); - ZEPHIR_CALL_METHOD(&directory, this_ptr, "getdir", NULL, 126); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "phpfileexists", NULL, 0, &directory); - zephir_check_call_status(); - if (UNEXPECTED(!ZEPHIR_IS_TRUE_IDENTICAL(&_0))) { - array_init(return_value); - RETURN_MM(); - } - ZEPHIR_CALL_METHOD(&iterator, this_ptr, "getiterator", NULL, 121, &directory); - zephir_check_call_status(); - zephir_is_iterable(&iterator, 0, "phalcon/Storage/Adapter/Stream.zep", 197); - if (Z_TYPE_P(&iterator) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&iterator), _1) - { - ZEPHIR_INIT_NVAR(&file); - ZVAL_COPY(&file, _1); - ZEPHIR_CALL_METHOD(&_3$$4, &file, "isfile", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_3$$4)) { - zephir_read_property(&_4$$5, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_5$$5, &file, "getfilename", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_6$$5); - ZEPHIR_CONCAT_VV(&_6$$5, &_4$$5, &_5$$5); - zephir_array_append(&files, &_6$$5, PH_SEPARATE, "phalcon/Storage/Adapter/Stream.zep", 193); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &iterator, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &iterator, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&file, &iterator, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_7$$6, &file, "isfile", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_7$$6)) { - zephir_read_property(&_8$$7, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_9$$7, &file, "getfilename", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_10$$7); - ZEPHIR_CONCAT_VV(&_10$$7, &_8$$7, &_9$$7); - zephir_array_append(&files, &_10$$7, PH_SEPARATE, "phalcon/Storage/Adapter/Stream.zep", 193); - } - ZEPHIR_CALL_METHOD(NULL, &iterator, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&file); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getfilteredkeys", NULL, 0, &files, &prefix); - zephir_check_call_status(); - RETURN_MM(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("uri"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&uri, &_0); + ZEPHIR_INIT_VAR(&sources); + ZEPHIR_CONCAT_SVSSVSSVS(&sources, "", "", ""); + RETURN_CCTOR(&sources); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, has) +static PHP_METHOD(Phalcon_Support_Debug, getJsSources) { + zval uri, sources, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, payload, filepath, _0, _1; - zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&payload); - ZVAL_UNDEF(&filepath); + ZVAL_UNDEF(&uri); + ZVAL_UNDEF(&sources); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - ZEPHIR_CALL_METHOD(&filepath, this_ptr, "getfilepath", NULL, 122, &key); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "phpfileexists", NULL, 0, &filepath); - zephir_check_call_status(); - if (UNEXPECTED(!ZEPHIR_IS_TRUE_IDENTICAL(&_0))) { - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(&payload, this_ptr, "getpayload", NULL, 124, &filepath); - zephir_check_call_status(); - if (UNEXPECTED(ZEPHIR_IS_EMPTY(&payload))) { - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(&_1, this_ptr, "isexpired", NULL, 125, &payload); - zephir_check_call_status(); - RETURN_MM_BOOL(!zephir_is_true(&_1)); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("uri"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&uri, &_0); + ZEPHIR_INIT_VAR(&sources); + ZEPHIR_CONCAT_SVSSVSSVSSVSSVS(&sources, "", "", "", "", ""); + RETURN_CCTOR(&sources); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, increment) +static PHP_METHOD(Phalcon_Support_Debug, getVersion) { + zval link, _0, _1, _2, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long value, ZEPHIR_LAST_CALL_STATUS, _1; - zval *key_param = NULL, *value_param = NULL, data, result, _0; - zval key; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&result); + ZVAL_UNDEF(&link); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(key) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(value) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key_param, &value_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - if (!value_param) { - value = 1; - } else { - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, 0, &key); - zephir_check_call_status(); - if (UNEXPECTED(!ZEPHIR_IS_TRUE_IDENTICAL(&_0))) { - RETURN_MM_BOOL(0); - } - ZEPHIR_CALL_METHOD(&data, this_ptr, "get", NULL, 0, &key); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("version"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_2, 0); + ZEPHIR_CALL_METHOD(&_1, &_0, "getpart", NULL, 0, &_2); zephir_check_call_status(); - _1 = (zephir_get_intval(&data) + value); - ZEPHIR_INIT_NVAR(&data); - ZVAL_LONG(&data, _1); - ZEPHIR_CALL_METHOD(&result, this_ptr, "set", NULL, 0, &key, &data); + ZEPHIR_INIT_VAR(&link); + ZEPHIR_CONCAT_SVS(&link, "https://docs.phalcon.io/", &_1, ".0/en/"); + zephir_read_property(&_2, this_ptr, ZEND_STRL("version"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_3, &_2, "get", NULL, 0); zephir_check_call_status(); - if (EXPECTED(!ZEPHIR_IS_FALSE_IDENTICAL(&result))) { - ZEPHIR_CPY_WRT(&result, &data); - } - RETURN_CCTOR(&result); + ZEPHIR_CONCAT_SSVSVS(return_value, "
Phalcon Framework ", "", &_3, "
"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, set) +static PHP_METHOD(Phalcon_Support_Debug, halt) +{ + + ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_support_debug_exception_ce, "Halted request", "phalcon/Support/Debug.zep", 169); + return; +} + +static PHP_METHOD(Phalcon_Support_Debug, listen) { - zend_bool _0; - zval payload; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub, *ttl = NULL, ttl_sub, __$null, _1, _2; - zval key; + zval *exceptions_param = NULL, *lowSeverity_param = NULL; + zend_bool exceptions, lowSeverity; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&ttl_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&payload); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(ttl) + Z_PARAM_BOOL(exceptions) + Z_PARAM_BOOL(lowSeverity) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &key_param, &value, &ttl); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + zephir_fetch_params(1, 0, 2, &exceptions_param, &lowSeverity_param); + if (!exceptions_param) { + exceptions = 1; } else { - ZEPHIR_INIT_VAR(&key); - } - if (!ttl) { - ttl = &ttl_sub; - ttl = &__$null; - } - _0 = Z_TYPE_P(ttl) == IS_LONG; - if (_0) { - _0 = ZEPHIR_LT_LONG(ttl, 1); + } + if (!lowSeverity_param) { + lowSeverity = 0; + } else { + } + if (exceptions) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "listenexceptions", NULL, 0); + zephir_check_call_status(); } - if (_0) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "delete", NULL, 0, &key); + if (lowSeverity) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "listenlowseverity", NULL, 0); zephir_check_call_status(); - RETURN_MM(); } - ZEPHIR_INIT_VAR(&payload); - zephir_create_array(&payload, 3, 0); - ZEPHIR_INIT_VAR(&_1); - zephir_time(&_1); - zephir_array_update_string(&payload, SL("created"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getttl", NULL, 0, ttl); - zephir_check_call_status(); - zephir_array_update_string(&payload, SL("ttl"), &_2, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getserializeddata", NULL, 0, value); - zephir_check_call_status(); - zephir_array_update_string(&payload, SL("content"), &_2, PH_COPY | PH_SEPARATE); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "storepayload", NULL, 127, &payload, &key); - zephir_check_call_status(); - RETURN_MM(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, setForever) +static PHP_METHOD(Phalcon_Support_Debug, listenExceptions) { - zval payload; + zval _1; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub, _0, _1; - zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&payload); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &key_param, &value); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - ZEPHIR_INIT_VAR(&payload); - zephir_create_array(&payload, 3, 0); + ZEPHIR_INIT_VAR(&_0); - zephir_time(&_0); - zephir_array_update_string(&payload, SL("created"), &_0, PH_COPY | PH_SEPARATE); - add_assoc_stringl_ex(&payload, SL("ttl"), SL("forever")); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getserializeddata", NULL, 0, value); - zephir_check_call_status(); - zephir_array_update_string(&payload, SL("content"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "storepayload", NULL, 127, &payload, &key); + zephir_create_array(&_0, 2, 0); + zephir_array_fast_append(&_0, this_ptr); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "onUncaughtException"); + zephir_array_fast_append(&_0, &_1); + ZEPHIR_CALL_FUNCTION(NULL, "set_exception_handler", NULL, 0, &_0); zephir_check_call_status(); - RETURN_MM(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, getDir) +static PHP_METHOD(Phalcon_Support_Debug, listenLowSeverity) { + zval _1; + zval _0, _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, dirFromFile, dirPrefix, _0, _1, _2, _3, _4; - zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&dirFromFile); - ZVAL_UNDEF(&dirPrefix); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_STR(key) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &key_param); - if (!key_param) { - ZEPHIR_INIT_VAR(&key); - ZVAL_STRING(&key, ""); - } else { - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("storageDir"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_1, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VV(&_2, &_0, &_1); - ZEPHIR_CALL_METHOD(&dirPrefix, this_ptr, "getdirseparator", NULL, 120, &_2); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "getkeywithoutprefix", NULL, 128, &key); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&dirFromFile, this_ptr, "getdirfromfile", NULL, 129, &_3); + + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 2, 0); + zephir_array_fast_append(&_0, this_ptr); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "onUncaughtLowSeverity"); + zephir_array_fast_append(&_0, &_1); + ZEPHIR_CALL_FUNCTION(NULL, "set_error_handler", NULL, 135, &_0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_4); - ZEPHIR_CONCAT_VV(&_4, &dirPrefix, &dirFromFile); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getdirseparator", NULL, 120, &_4); + ZEPHIR_INIT_VAR(&_2); + zephir_create_array(&_2, 2, 0); + zephir_array_fast_append(&_2, this_ptr); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "onUncaughtException"); + zephir_array_fast_append(&_2, &_1); + ZEPHIR_CALL_FUNCTION(NULL, "set_exception_handler", NULL, 0, &_2); zephir_check_call_status(); - RETURN_MM(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, getFilepath) +static PHP_METHOD(Phalcon_Support_Debug, onUncaughtException) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, _0, _1; - zval key; + zval *exception, exception_sub, __$true, __$false, obLevel, _0, _2, _1$$4; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&exception_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&obLevel); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_1$$4); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + Z_PARAM_OBJECT_OF_CLASS(exception, zend_ce_throwable) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - zephir_get_strval(&key, key_param); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getdir", NULL, 126, &key); + zephir_fetch_params(1, 1, 0, &exception); + ZEPHIR_CALL_FUNCTION(&obLevel, "ob_get_level", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getkeywithoutprefix", NULL, 128, &key); + if (ZEPHIR_GT_LONG(&obLevel, 0)) { + ZEPHIR_CALL_FUNCTION(NULL, "ob_end_clean", NULL, 489); + zephir_check_call_status(); + } + zephir_read_static_property_ce(&_0, phalcon_support_debug_ce, SL("isActive"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_0)) { + ZEPHIR_CALL_METHOD(&_1$$4, exception, "getmessage", NULL, 0); + zephir_check_call_status(); + zend_print_zval(&_1$$4, 0); + RETURN_MM_NULL(); + } + zephir_update_static_property_ce(phalcon_support_debug_ce, ZEND_STRL("isActive"), &__$true); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "renderhtml", NULL, 0, exception); zephir_check_call_status(); - ZEPHIR_CONCAT_VV(return_value, &_0, &_1); - RETURN_MM(); + zend_print_zval(&_2, 0); + zephir_update_static_property_ce(phalcon_support_debug_ce, ZEND_STRL("isActive"), &__$false); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, getKeyWithoutPrefix) +static PHP_METHOD(Phalcon_Support_Debug, onUncaughtLowSeverity) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *key_param = NULL, _0, _1$$3, _2$$3; - zval key; - zval *this_ptr = getThis(); + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *severity, severity_sub, *message, message_sub, *file, file_sub, *line, line_sub, *context, context_sub, _0, _1, _2$$3, _3$$3; - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&severity_sub); + ZVAL_UNDEF(&message_sub); + ZVAL_UNDEF(&file_sub); + ZVAL_UNDEF(&line_sub); + ZVAL_UNDEF(&context_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + ZVAL_UNDEF(&_3$$3); + ZEND_PARSE_PARAMETERS_START(5, 5) + Z_PARAM_ZVAL(severity) + Z_PARAM_ZVAL(message) + Z_PARAM_ZVAL(file) + Z_PARAM_ZVAL(line) + Z_PARAM_ZVAL(context) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - zephir_get_strval(&key, key_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); - if (zephir_start_with(&key, &_0, NULL)) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_2$$3, zephir_fast_strlen_ev(&_1$$3)); - zephir_substr(return_value, &key, zephir_get_intval(&_2$$3), 0, ZEPHIR_SUBSTR_NO_LENGTH); - RETURN_MM(); + zephir_fetch_params(1, 5, 0, &severity, &message, &file, &line, &context); + ZEPHIR_CALL_FUNCTION(&_0, "error_reporting", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1); + zephir_bitwise_and_function(&_1, &_0, severity); + if (UNEXPECTED(zephir_is_true(&_1))) { + ZEPHIR_INIT_VAR(&_2$$3); + object_init_ex(&_2$$3, zend_ce_error_exception); + ZVAL_LONG(&_3$$3, 0); + ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 0, message, &_3$$3, severity, file, line); + zephir_check_call_status(); + zephir_throw_exception_debug(&_2$$3, "phalcon/Support/Debug.zep", 268); + ZEPHIR_MM_RESTORE(); + return; } - RETURN_CTOR(&key); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, getIterator) +static PHP_METHOD(Phalcon_Support_Debug, renderHtml) { + zend_string *_12$$3, *_23$$3, *_39$$3, *_52$$3, *_61$$21; + zend_ulong _11$$3, _22$$3, _38$$3, _51$$3, _60$$21; + zval _7$$3, _16$$3, _33$$3, _47$$3, _57$$21; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_14 = NULL, *_27 = NULL, *_42 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *dir_param = NULL, _0, _1; - zval dir; + zval *exception, exception_sub, _REQUEST, __$true, _SERVER, blacklist, className, dataVar, dataVars, escapedMessage, html, keyFile, keyRequest, keyServer, keyVar, n, showBackTrace, traceItem, value, _0, _1, _2, _3, _4, _5, _6, _68, _69, _8$$3, *_9$$3, _10$$3, _17$$3, _18$$3, _19$$3, *_20$$3, _21$$3, _34$$3, _35$$3, *_36$$3, _37$$3, _48$$3, *_49$$3, _50$$3, _55$$3, _56$$3, _13$$5, _15$$6, _24$$7, _25$$9, _26$$10, _28$$10, _29$$11, _30$$13, _31$$14, _32$$14, _40$$15, _41$$16, _43$$16, _44$$17, _45$$18, _46$$18, _53$$19, _54$$20, *_58$$21, _59$$21, _62$$22, _63$$22, _64$$22, _65$$23, _66$$23, _67$$23; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&dir); + ZVAL_UNDEF(&exception_sub); + ZVAL_UNDEF(&_REQUEST); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&_SERVER); + ZVAL_UNDEF(&blacklist); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&dataVar); + ZVAL_UNDEF(&dataVars); + ZVAL_UNDEF(&escapedMessage); + ZVAL_UNDEF(&html); + ZVAL_UNDEF(&keyFile); + ZVAL_UNDEF(&keyRequest); + ZVAL_UNDEF(&keyServer); + ZVAL_UNDEF(&keyVar); + ZVAL_UNDEF(&n); + ZVAL_UNDEF(&showBackTrace); + ZVAL_UNDEF(&traceItem); + ZVAL_UNDEF(&value); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_68); + ZVAL_UNDEF(&_69); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_17$$3); + ZVAL_UNDEF(&_18$$3); + ZVAL_UNDEF(&_19$$3); + ZVAL_UNDEF(&_21$$3); + ZVAL_UNDEF(&_34$$3); + ZVAL_UNDEF(&_35$$3); + ZVAL_UNDEF(&_37$$3); + ZVAL_UNDEF(&_48$$3); + ZVAL_UNDEF(&_50$$3); + ZVAL_UNDEF(&_55$$3); + ZVAL_UNDEF(&_56$$3); + ZVAL_UNDEF(&_13$$5); + ZVAL_UNDEF(&_15$$6); + ZVAL_UNDEF(&_24$$7); + ZVAL_UNDEF(&_25$$9); + ZVAL_UNDEF(&_26$$10); + ZVAL_UNDEF(&_28$$10); + ZVAL_UNDEF(&_29$$11); + ZVAL_UNDEF(&_30$$13); + ZVAL_UNDEF(&_31$$14); + ZVAL_UNDEF(&_32$$14); + ZVAL_UNDEF(&_40$$15); + ZVAL_UNDEF(&_41$$16); + ZVAL_UNDEF(&_43$$16); + ZVAL_UNDEF(&_44$$17); + ZVAL_UNDEF(&_45$$18); + ZVAL_UNDEF(&_46$$18); + ZVAL_UNDEF(&_53$$19); + ZVAL_UNDEF(&_54$$20); + ZVAL_UNDEF(&_59$$21); + ZVAL_UNDEF(&_62$$22); + ZVAL_UNDEF(&_63$$22); + ZVAL_UNDEF(&_64$$22); + ZVAL_UNDEF(&_65$$23); + ZVAL_UNDEF(&_66$$23); + ZVAL_UNDEF(&_67$$23); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_16$$3); + ZVAL_UNDEF(&_33$$3); + ZVAL_UNDEF(&_47$$3); + ZVAL_UNDEF(&_57$$21); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(dir) + Z_PARAM_OBJECT_OF_CLASS(exception, zend_ce_throwable) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &dir_param); - if (UNEXPECTED(Z_TYPE_P(dir_param) != IS_STRING && Z_TYPE_P(dir_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'dir' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(dir_param) == IS_STRING)) { - zephir_get_strval(&dir, dir_param); - } else { - ZEPHIR_INIT_VAR(&dir); - } - object_init_ex(return_value, spl_ce_RecursiveIteratorIterator); - ZEPHIR_INIT_VAR(&_0); - object_init_ex(&_0, spl_ce_RecursiveDirectoryIterator); - ZVAL_LONG(&_1, 4096); - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 130, &dir, &_1); + zephir_get_global(&_SERVER, SL("_SERVER")); + zephir_get_global(&_REQUEST, SL("_REQUEST")); + zephir_fetch_params(1, 1, 0, &exception); + ZEPHIR_INIT_VAR(&className); + zephir_get_class(&className, exception, 0); + ZEPHIR_CALL_METHOD(&_0, exception, "getmessage", NULL, 0); zephir_check_call_status(); - ZVAL_LONG(&_1, 2); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 131, &_0, &_1); + ZEPHIR_CALL_METHOD(&escapedMessage, this_ptr, "escapestring", NULL, 0, &_0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getcsssources", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&html); + ZEPHIR_CONCAT_SSVSVSVS(&html, "", "", &className, ": ", &escapedMessage, "", &_1, ""); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "getversion", NULL, 0); + zephir_check_call_status(); + zephir_concat_self(&html, &_2); + ZEPHIR_CALL_METHOD(&_3, exception, "getfile", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4, exception, "getline", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_5); + ZEPHIR_CONCAT_SSSVSVSSVSVSS(&_5, "
", "
", "

", &className, ": ", &escapedMessage, "

", "", &_3, " (", &_4, ")", "
"); + zephir_concat_self(&html, &_5); + zephir_read_property(&_6, this_ptr, ZEND_STRL("showBackTrace"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&showBackTrace, &_6); + if (zephir_is_true(&showBackTrace)) { + zephir_memory_observe(&dataVars); + zephir_read_property(&dataVars, this_ptr, ZEND_STRL("data"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(&_7$$3); + ZEPHIR_CONCAT_SSSSSS(&_7$$3, "
")); + zephir_concat_self_str(&html, SL("
")); + ZEPHIR_CALL_METHOD(&_8$$3, exception, "gettrace", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&_8$$3, 0, "phalcon/Support/Debug.zep", 355); + if (Z_TYPE_P(&_8$$3) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_8$$3), _11$$3, _12$$3, _9$$3) + { + ZEPHIR_INIT_NVAR(&n); + if (_12$$3 != NULL) { + ZVAL_STR_COPY(&n, _12$$3); + } else { + ZVAL_LONG(&n, _11$$3); + } + ZEPHIR_INIT_NVAR(&traceItem); + ZVAL_COPY(&traceItem, _9$$3); + ZEPHIR_CALL_METHOD(&_13$$5, this_ptr, "showtraceitem", &_14, 0, &n, &traceItem); + zephir_check_call_status(); + zephir_concat_self(&html, &_13$$5); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_8$$3, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_10$$3, &_8$$3, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_10$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&n, &_8$$3, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&traceItem, &_8$$3, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_15$$6, this_ptr, "showtraceitem", &_14, 0, &n, &traceItem); + zephir_check_call_status(); + zephir_concat_self(&html, &_15$$6); + ZEPHIR_CALL_METHOD(NULL, &_8$$3, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&traceItem); + ZEPHIR_INIT_NVAR(&n); + zephir_concat_self_str(&html, SL("
")); + ZEPHIR_INIT_VAR(&_16$$3); + ZEPHIR_CONCAT_SSS(&_16$$3, "
", "", ""); + zephir_concat_self(&html, &_16$$3); + zephir_read_property(&_17$$3, this_ptr, ZEND_STRL("blacklist"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_18$$3); + array_init(&_18$$3); + ZEPHIR_INIT_VAR(&_19$$3); + ZVAL_STRING(&_19$$3, "request"); + ZEPHIR_CALL_METHOD(&blacklist, this_ptr, "getarrval", NULL, 0, &_17$$3, &_19$$3, &_18$$3); + zephir_check_call_status(); + zephir_is_iterable(&_REQUEST, 0, "phalcon/Support/Debug.zep", 379); + if (Z_TYPE_P(&_REQUEST) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_REQUEST), _22$$3, _23$$3, _20$$3) + { + ZEPHIR_INIT_NVAR(&keyRequest); + if (_23$$3 != NULL) { + ZVAL_STR_COPY(&keyRequest, _23$$3); + } else { + ZVAL_LONG(&keyRequest, _22$$3); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _20$$3); + ZEPHIR_INIT_NVAR(&_24$$7); + zephir_fast_strtolower(&_24$$7, &keyRequest); + if (1 != zephir_array_isset(&blacklist, &_24$$7)) { + if (Z_TYPE_P(&value) != IS_ARRAY) { + ZEPHIR_INIT_NVAR(&_25$$9); + ZEPHIR_CONCAT_SVSVS(&_25$$9, ""); + zephir_concat_self(&html, &_25$$9); + } else { + ZEPHIR_CALL_FUNCTION(&_26$$10, "print_r", &_27, 0, &value, &__$true); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_28$$10); + ZEPHIR_CONCAT_SVSVS(&_28$$10, ""); + zephir_concat_self(&html, &_28$$10); + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_REQUEST, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_21$$3, &_REQUEST, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_21$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&keyRequest, &_REQUEST, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &_REQUEST, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_29$$11); + zephir_fast_strtolower(&_29$$11, &keyRequest); + if (1 != zephir_array_isset(&blacklist, &_29$$11)) { + if (Z_TYPE_P(&value) != IS_ARRAY) { + ZEPHIR_INIT_NVAR(&_30$$13); + ZEPHIR_CONCAT_SVSVS(&_30$$13, ""); + zephir_concat_self(&html, &_30$$13); + } else { + ZEPHIR_CALL_FUNCTION(&_31$$14, "print_r", &_27, 0, &value, &__$true); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_32$$14); + ZEPHIR_CONCAT_SVSVS(&_32$$14, ""); + zephir_concat_self(&html, &_32$$14); + } + } + ZEPHIR_CALL_METHOD(NULL, &_REQUEST, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&keyRequest); + zephir_concat_self_str(&html, SL("
KeyValue
", &keyRequest, "", &value, "
", &keyRequest, "", &_26$$10, "
", &keyRequest, "", &value, "
", &keyRequest, "", &_31$$14, "
")); + ZEPHIR_INIT_VAR(&_33$$3); + ZEPHIR_CONCAT_SSS(&_33$$3, "
", "", ""); + zephir_concat_self(&html, &_33$$3); + zephir_read_property(&_34$$3, this_ptr, ZEND_STRL("blacklist"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_19$$3); + array_init(&_19$$3); + ZEPHIR_INIT_VAR(&_35$$3); + ZVAL_STRING(&_35$$3, "server"); + ZEPHIR_CALL_METHOD(&blacklist, this_ptr, "getarrval", NULL, 0, &_34$$3, &_35$$3, &_19$$3); + zephir_check_call_status(); + zephir_is_iterable(&_SERVER, 0, "phalcon/Support/Debug.zep", 397); + if (Z_TYPE_P(&_SERVER) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_SERVER), _38$$3, _39$$3, _36$$3) + { + ZEPHIR_INIT_NVAR(&keyServer); + if (_39$$3 != NULL) { + ZVAL_STR_COPY(&keyServer, _39$$3); + } else { + ZVAL_LONG(&keyServer, _38$$3); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _36$$3); + ZEPHIR_INIT_NVAR(&_40$$15); + zephir_fast_strtolower(&_40$$15, &keyServer); + if (1 != zephir_array_isset(&blacklist, &_40$$15)) { + ZEPHIR_CALL_METHOD(&_41$$16, this_ptr, "getvardump", &_42, 0, &value); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_43$$16); + ZEPHIR_CONCAT_SVSVS(&_43$$16, ""); + zephir_concat_self(&html, &_43$$16); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_SERVER, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_37$$3, &_SERVER, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_37$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&keyServer, &_SERVER, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &_SERVER, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_44$$17); + zephir_fast_strtolower(&_44$$17, &keyServer); + if (1 != zephir_array_isset(&blacklist, &_44$$17)) { + ZEPHIR_CALL_METHOD(&_45$$18, this_ptr, "getvardump", &_42, 0, &value); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_46$$18); + ZEPHIR_CONCAT_SVSVS(&_46$$18, ""); + zephir_concat_self(&html, &_46$$18); + } + ZEPHIR_CALL_METHOD(NULL, &_SERVER, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&keyServer); + zephir_concat_self_str(&html, SL("
KeyValue
", &keyServer, "", &_41$$16, "
", &keyServer, "", &_45$$18, "
")); + ZEPHIR_INIT_VAR(&_47$$3); + ZEPHIR_CONCAT_SSS(&_47$$3, "
", "", ""); + zephir_concat_self(&html, &_47$$3); + ZEPHIR_CALL_FUNCTION(&_48$$3, "get_included_files", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&_48$$3, 0, "phalcon/Support/Debug.zep", 410); + if (Z_TYPE_P(&_48$$3) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_48$$3), _51$$3, _52$$3, _49$$3) + { + ZEPHIR_INIT_NVAR(&keyFile); + if (_52$$3 != NULL) { + ZVAL_STR_COPY(&keyFile, _52$$3); + } else { + ZVAL_LONG(&keyFile, _51$$3); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _49$$3); + ZEPHIR_INIT_NVAR(&_53$$19); + ZEPHIR_CONCAT_SVSVS(&_53$$19, ""); + zephir_concat_self(&html, &_53$$19); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_48$$3, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_50$$3, &_48$$3, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_50$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&keyFile, &_48$$3, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &_48$$3, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_54$$20); + ZEPHIR_CONCAT_SVSVS(&_54$$20, ""); + zephir_concat_self(&html, &_54$$20); + ZEPHIR_CALL_METHOD(NULL, &_48$$3, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&keyFile); + zephir_concat_self_str(&html, SL("
#Path
", &keyFile, "", &value, "
", &keyFile, "", &value, "
")); + ZEPHIR_CALL_FUNCTION(&_55$$3, "memory_get_usage", NULL, 0, &__$true); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_56$$3); + ZEPHIR_CONCAT_SSSVSS(&_56$$3, "
", "", "", "
Memory
Usage", &_55$$3, "
"); + zephir_concat_self(&html, &_56$$3); + if (!(ZEPHIR_IS_EMPTY(&dataVars))) { + ZEPHIR_INIT_VAR(&_57$$21); + ZEPHIR_CONCAT_SSS(&_57$$21, "
", "", ""); + zephir_concat_self(&html, &_57$$21); + zephir_is_iterable(&dataVars, 0, "phalcon/Support/Debug.zep", 435); + if (Z_TYPE_P(&dataVars) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&dataVars), _60$$21, _61$$21, _58$$21) + { + ZEPHIR_INIT_NVAR(&keyVar); + if (_61$$21 != NULL) { + ZVAL_STR_COPY(&keyVar, _61$$21); + } else { + ZVAL_LONG(&keyVar, _60$$21); + } + ZEPHIR_INIT_NVAR(&dataVar); + ZVAL_COPY(&dataVar, _58$$21); + zephir_array_fetch_long(&_63$$22, &dataVar, 0, PH_NOISY | PH_READONLY, "phalcon/Support/Debug.zep", 432); + ZEPHIR_CALL_METHOD(&_62$$22, this_ptr, "getvardump", &_42, 0, &_63$$22); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_64$$22); + ZEPHIR_CONCAT_SVSVS(&_64$$22, ""); + zephir_concat_self(&html, &_64$$22); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &dataVars, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_59$$21, &dataVars, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_59$$21)) { + break; + } + ZEPHIR_CALL_METHOD(&keyVar, &dataVars, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&dataVar, &dataVars, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_fetch_long(&_66$$23, &dataVar, 0, PH_NOISY | PH_READONLY, "phalcon/Support/Debug.zep", 432); + ZEPHIR_CALL_METHOD(&_65$$23, this_ptr, "getvardump", &_42, 0, &_66$$23); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_67$$23); + ZEPHIR_CONCAT_SVSVS(&_67$$23, ""); + zephir_concat_self(&html, &_67$$23); + ZEPHIR_CALL_METHOD(NULL, &dataVars, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&dataVar); + ZEPHIR_INIT_NVAR(&keyVar); + zephir_concat_self_str(&html, SL("
KeyValue
", &keyVar, "", &_62$$22, "
", &keyVar, "", &_65$$23, "
")); + } + zephir_concat_self_str(&html, SL("
")); + } + ZEPHIR_CALL_METHOD(&_68, this_ptr, "getjssources", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_INIT_VAR(&_69); + ZEPHIR_CONCAT_VS(&_69, &_68, "
"); + zephir_concat_self(&html, &_69); + RETURN_CCTOR(&html); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, getPayload) +static PHP_METHOD(Phalcon_Support_Debug, setBlacklist) { - zend_bool _10; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *filepath_param = NULL, __$false, payload, pointer, version, _0, _1, _2, _3, _4, _9, _5$$6, _6$$6, _7$$7, _8$$7; - zval filepath; + zval *blacklist_param = NULL, area, result, subArray, value, _0, _1, *_2, _3, _6, *_7, _8, _4$$3, _5$$4, _9$$5, _10$$6; + zval blacklist; zval *this_ptr = getThis(); - ZVAL_UNDEF(&filepath); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&payload); - ZVAL_UNDEF(&pointer); - ZVAL_UNDEF(&version); + ZVAL_UNDEF(&blacklist); + ZVAL_UNDEF(&area); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&subArray); + ZVAL_UNDEF(&value); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_6$$6); - ZVAL_UNDEF(&_7$$7); - ZVAL_UNDEF(&_8$$7); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_10$$6); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(filepath) + Z_PARAM_ARRAY(blacklist) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &filepath_param); - zephir_get_strval(&filepath, filepath_param); - ZEPHIR_INIT_VAR(&payload); - ZVAL_BOOL(&payload, 0); + zephir_fetch_params(1, 1, 0, &blacklist_param); + zephir_get_arrval(&blacklist, blacklist_param); ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "r"); - ZEPHIR_CALL_METHOD(&pointer, this_ptr, "phpfopen", NULL, 0, &filepath, &_0); - zephir_check_call_status(); - if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&pointer))) { - array_init(return_value); - RETURN_MM(); - } - ZVAL_LONG(&_1, 1); - ZEPHIR_CALL_FUNCTION(&_2, "flock", NULL, 132, &pointer, &_1); + array_init(&_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "request"); + ZEPHIR_CALL_METHOD(&area, this_ptr, "getarrval", NULL, 0, &blacklist, &_1, &_0); zephir_check_call_status(); - if (EXPECTED(ZEPHIR_IS_TRUE_IDENTICAL(&_2))) { - ZEPHIR_CALL_METHOD(&payload, this_ptr, "phpfilegetcontents", NULL, 0, &filepath); + ZEPHIR_INIT_VAR(&subArray); + array_init(&subArray); + ZEPHIR_INIT_VAR(&result); + array_init(&result); + zephir_is_iterable(&area, 0, "phalcon/Support/Debug.zep", 467); + if (Z_TYPE_P(&area) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&area), _2) + { + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _2); + ZEPHIR_INIT_NVAR(&_4$$3); + zephir_fast_strtolower(&_4$$3, &value); + ZEPHIR_CPY_WRT(&value, &_4$$3); + ZEPHIR_INIT_NVAR(&_4$$3); + ZVAL_LONG(&_4$$3, 1); + zephir_array_update_zval(&subArray, &value, &_4$$3, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &area, "rewind", NULL, 0); zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &area, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&value, &area, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_5$$4); + zephir_fast_strtolower(&_5$$4, &value); + ZEPHIR_CPY_WRT(&value, &_5$$4); + ZEPHIR_INIT_NVAR(&_5$$4); + ZVAL_LONG(&_5$$4, 1); + zephir_array_update_zval(&subArray, &value, &_5$$4, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &area, "next", NULL, 0); + zephir_check_call_status(); + } } - zephir_fclose(&pointer); - if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&payload))) { - array_init(return_value); - RETURN_MM(); - } - ZEPHIR_CALL_FUNCTION(&version, "phpversion", NULL, 133); - zephir_check_call_status(); - ZEPHIR_GLOBAL(warning).enable = zend_is_true(&__$false); - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, "8.0"); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, ">="); - ZEPHIR_CALL_FUNCTION(&_4, "version_compare", NULL, 134, &version, &_0, &_3); + ZEPHIR_INIT_NVAR(&value); + zephir_array_update_string(&result, SL("request"), &subArray, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + array_init(&_1); + ZEPHIR_INIT_VAR(&_6); + ZVAL_STRING(&_6, "server"); + ZEPHIR_CALL_METHOD(&area, this_ptr, "getarrval", NULL, 0, &blacklist, &_6, &_1); zephir_check_call_status(); - if (zephir_is_true(&_4)) { - ZEPHIR_INIT_VAR(&_5$$6); - ZEPHIR_INIT_NVAR(&_5$$6); - zephir_create_closure_ex(&_5$$6, NULL, phalcon_0__closure_ce, SL("__invoke")); - ZVAL_LONG(&_6$$6, 8); - ZEPHIR_CALL_FUNCTION(NULL, "set_error_handler", NULL, 135, &_5$$6, &_6$$6); - zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&subArray); + array_init(&subArray); + zephir_is_iterable(&area, 0, "phalcon/Support/Debug.zep", 476); + if (Z_TYPE_P(&area) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&area), _7) + { + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _7); + ZEPHIR_INIT_NVAR(&_9$$5); + zephir_fast_strtolower(&_9$$5, &value); + ZEPHIR_CPY_WRT(&value, &_9$$5); + ZEPHIR_INIT_NVAR(&_9$$5); + ZVAL_LONG(&_9$$5, 1); + zephir_array_update_zval(&subArray, &value, &_9$$5, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_INIT_VAR(&_7$$7); - ZEPHIR_INIT_NVAR(&_7$$7); - zephir_create_closure_ex(&_7$$7, NULL, phalcon_1__closure_ce, SL("__invoke")); - ZVAL_LONG(&_8$$7, 8); - ZEPHIR_CALL_FUNCTION(NULL, "set_error_handler", NULL, 135, &_7$$7, &_8$$7); + ZEPHIR_CALL_METHOD(NULL, &area, "rewind", NULL, 0); zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_8, &area, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_8)) { + break; + } + ZEPHIR_CALL_METHOD(&value, &area, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_10$$6); + zephir_fast_strtolower(&_10$$6, &value); + ZEPHIR_CPY_WRT(&value, &_10$$6); + ZEPHIR_INIT_NVAR(&_10$$6); + ZVAL_LONG(&_10$$6, 1); + zephir_array_update_zval(&subArray, &value, &_10$$6, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &area, "next", NULL, 0); + zephir_check_call_status(); + } } - ZEPHIR_CALL_FUNCTION(&_9, "unserialize", NULL, 16, &payload); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&payload, &_9); - ZEPHIR_CALL_FUNCTION(NULL, "restore_error_handler", NULL, 136); - zephir_check_call_status(); - _10 = ZEPHIR_GLOBAL(warning).enable; - if (!(_10)) { - _10 = Z_TYPE_P(&payload) != IS_ARRAY; - } - if (UNEXPECTED(_10)) { - array_init(return_value); - RETURN_MM(); - } - RETURN_CCTOR(&payload); + ZEPHIR_INIT_NVAR(&value); + zephir_array_update_string(&result, SL("server"), &subArray, PH_COPY | PH_SEPARATE); + zephir_update_property_zval(this_ptr, ZEND_STRL("blacklist"), &result); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, isExpired) +static PHP_METHOD(Phalcon_Support_Debug, setShowBackTrace) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *payload_param = NULL, created, ttl, _0, _1, _2, _3, _4; - zval payload; + zval *showBackTrace_param = NULL, __$true, __$false; + zend_bool showBackTrace; zval *this_ptr = getThis(); - ZVAL_UNDEF(&payload); - ZVAL_UNDEF(&created); - ZVAL_UNDEF(&ttl); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(payload) + Z_PARAM_BOOL(showBackTrace) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &payload_param); - ZEPHIR_OBS_COPY_OR_DUP(&payload, payload_param); - ZEPHIR_INIT_VAR(&_0); - zephir_time(&_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "created"); - ZEPHIR_CALL_METHOD(&created, this_ptr, "getarrval", NULL, 0, &payload, &_1, &_0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "ttl"); - ZVAL_LONG(&_2, 3600); - ZEPHIR_CALL_METHOD(&ttl, this_ptr, "getarrval", NULL, 0, &payload, &_1, &_2); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "forever"); - if (ZEPHIR_IS_IDENTICAL(&_3, &ttl)) { - RETURN_MM_BOOL(0); + zephir_fetch_params_without_memory_grow(1, 0, &showBackTrace_param); + if (showBackTrace) { + zephir_update_property_zval(this_ptr, ZEND_STRL("showBackTrace"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("showBackTrace"), &__$false); } - ZEPHIR_INIT_VAR(&_4); - zephir_add_function(&_4, &created, &ttl); - ZEPHIR_INIT_NVAR(&_1); - zephir_time(&_1); - RETURN_MM_BOOL(ZEPHIR_LT(&_4, &_1)); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, storePayload) +static PHP_METHOD(Phalcon_Support_Debug, setShowFileFragment) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval key; - zval payload, *payload_param = NULL, *key_param = NULL, __$true, directory, _0, _2, _3, _4, _1$$3; + zval *showFileFragment_param = NULL, __$true, __$false; + zend_bool showFileFragment; zval *this_ptr = getThis(); - ZVAL_UNDEF(&payload); ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&directory); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&key); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ARRAY(payload) - Z_PARAM_STR(key) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &payload_param, &key_param); - zephir_get_arrval(&payload, payload_param); - zephir_get_strval(&key, key_param); - ZEPHIR_CALL_FUNCTION(&_0, "serialize", NULL, 15, &payload); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&payload, &_0); - ZEPHIR_CALL_METHOD(&directory, this_ptr, "getdir", NULL, 126, &key); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_0, "is_dir", NULL, 137, &directory); - zephir_check_call_status(); - if (!(zephir_is_true(&_0))) { - ZVAL_LONG(&_1$$3, 0777); - ZEPHIR_CALL_FUNCTION(NULL, "mkdir", NULL, 138, &directory, &_1$$3, &__$true); - zephir_check_call_status(); - } - ZEPHIR_INIT_VAR(&_3); - ZEPHIR_CONCAT_VV(&_3, &directory, &key); - ZVAL_LONG(&_4, 2); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "phpfileputcontents", NULL, 0, &_3, &payload, &_4); - zephir_check_call_status(); - RETURN_MM_BOOL(!ZEPHIR_IS_FALSE_IDENTICAL(&_2)); -} - -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, phpFileExists) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *filename_param = NULL; - zval filename; - - ZVAL_UNDEF(&filename); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(filename) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &filename_param); - zephir_get_strval(&filename, filename_param); - RETURN_MM_BOOL((zephir_file_exists(&filename) == SUCCESS)); -} - -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, phpFileGetContents) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *filename_param = NULL; - zval filename; - - ZVAL_UNDEF(&filename); + ZVAL_BOOL(&__$false, 0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(filename) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &filename_param); - zephir_get_strval(&filename, filename_param); - zephir_file_get_contents(return_value, &filename); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, phpFilePutContents) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long flags, ZEPHIR_LAST_CALL_STATUS; - zval *filename_param = NULL, *data, data_sub, *flags_param = NULL, *context = NULL, context_sub, __$null, _0; - zval filename; - - ZVAL_UNDEF(&filename); - ZVAL_UNDEF(&data_sub); - ZVAL_UNDEF(&context_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 4) - Z_PARAM_STR(filename) - Z_PARAM_ZVAL(data) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(flags) - Z_PARAM_ZVAL_OR_NULL(context) + Z_PARAM_BOOL(showFileFragment) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 2, &filename_param, &data, &flags_param, &context); - zephir_get_strval(&filename, filename_param); - if (!flags_param) { - flags = 0; + zephir_fetch_params_without_memory_grow(1, 0, &showFileFragment_param); + if (showFileFragment) { + zephir_update_property_zval(this_ptr, ZEND_STRL("showFileFragment"), &__$true); } else { - } - if (!context) { - context = &context_sub; - context = &__$null; + zephir_update_property_zval(this_ptr, ZEND_STRL("showFileFragment"), &__$false); } - ZVAL_LONG(&_0, flags); - ZEPHIR_RETURN_CALL_FUNCTION("file_put_contents", NULL, 139, &filename, data, &_0, context); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, phpFopen) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *filename_param = NULL, *mode_param = NULL; - zval filename, mode; - - ZVAL_UNDEF(&filename); - ZVAL_UNDEF(&mode); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(filename) - Z_PARAM_STR(mode) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &filename_param, &mode_param); - zephir_get_strval(&filename, filename_param); - zephir_get_strval(&mode, mode_param); - ZEPHIR_RETURN_CALL_FUNCTION("fopen", NULL, 140, &filename, &mode); - zephir_check_call_status(); - RETURN_MM(); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, phpUnlink) +static PHP_METHOD(Phalcon_Support_Debug, setShowFiles) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *filename_param = NULL; - zval filename; + zval *showFiles_param = NULL, __$true, __$false; + zend_bool showFiles; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&filename); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(filename) + Z_PARAM_BOOL(showFiles) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &filename_param); - zephir_get_strval(&filename, filename_param); - ZEPHIR_RETURN_CALL_FUNCTION("unlink", NULL, 123, &filename); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params_without_memory_grow(1, 0, &showFiles_param); + if (showFiles) { + zephir_update_property_zval(this_ptr, ZEND_STRL("showFiles"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("showFiles"), &__$false); + } + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, getDirFromFile) +static PHP_METHOD(Phalcon_Support_Debug, setUri) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *file_param = NULL, name, start, _0, _1, _7, _8, _9, _2$$3, _3$$3, _4$$3, _5$$4, _6$$4; - zval file; + zval *uri_param = NULL; + zval uri; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&file); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&start); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&uri); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(file) + Z_PARAM_STR(uri) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &file_param); - if (UNEXPECTED(Z_TYPE_P(file_param) != IS_STRING && Z_TYPE_P(file_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'file' must be of the type string")); + zephir_fetch_params(1, 1, 0, &uri_param); + if (UNEXPECTED(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 of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(file_param) == IS_STRING)) { - zephir_get_strval(&file, file_param); + if (EXPECTED(Z_TYPE_P(uri_param) == IS_STRING)) { + zephir_get_strval(&uri, uri_param); } else { - ZEPHIR_INIT_VAR(&file); - } - ZVAL_LONG(&_0, 8); - ZEPHIR_CALL_FUNCTION(&name, "pathinfo", NULL, 89, &file, &_0); - zephir_check_call_status(); - ZVAL_LONG(&_0, 0); - ZVAL_LONG(&_1, -2); - ZEPHIR_INIT_VAR(&start); - zephir_substr(&start, &name, 0 , -2 , 0); - if (!(ZEPHIR_IS_EMPTY(&start))) { - ZEPHIR_INIT_VAR(&_2$$3); - ZEPHIR_INIT_VAR(&_3$$3); - ZVAL_STRING(&_3$$3, "."); - ZEPHIR_INIT_VAR(&_4$$3); - ZVAL_STRING(&_4$$3, "-"); - zephir_fast_str_replace(&_2$$3, &_3$$3, &_4$$3, &start); - ZEPHIR_CPY_WRT(&start, &_2$$3); - } - if (!(zephir_is_true(&start))) { - ZVAL_LONG(&_5$$4, 0); - ZVAL_LONG(&_6$$4, 1); - ZEPHIR_INIT_NVAR(&start); - zephir_substr(&start, &name, 0 , 1 , 0); + ZEPHIR_INIT_VAR(&uri); } - ZEPHIR_INIT_VAR(&_7); - ZVAL_LONG(&_8, 2); - ZEPHIR_CALL_FUNCTION(&_9, "str_split", NULL, 88, &start, &_8); - zephir_check_call_status(); - zephir_fast_join_str(&_7, SL("/"), &_9); - ZEPHIR_CONCAT_VS(return_value, &_7, "/"); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("uri"), &uri); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Stream, getDirSeparator) +static PHP_METHOD(Phalcon_Support_Debug, escapeString) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *directory_param = NULL, _0, _1; - zval directory; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *value_param = NULL, _0, _1, _2, _3, _4; + zval value; - ZVAL_UNDEF(&directory); + ZVAL_UNDEF(&value); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(directory) + Z_PARAM_STR(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &directory_param); - if (UNEXPECTED(Z_TYPE_P(directory_param) != IS_STRING && Z_TYPE_P(directory_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'directory' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(directory_param) == IS_STRING)) { - zephir_get_strval(&directory, directory_param); - } else { - ZEPHIR_INIT_VAR(&directory); - } + zephir_fetch_params(1, 1, 0, &value_param); + zephir_get_strval(&value, value_param); ZEPHIR_INIT_VAR(&_0); ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "/"); - zephir_fast_trim(&_0, &directory, &_1, ZEPHIR_TRIM_RIGHT); - ZEPHIR_CONCAT_VS(return_value, &_0, "/"); + ZVAL_STRING(&_1, "\n"); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "\\n"); + zephir_fast_str_replace(&_0, &_1, &_2, &value); + ZVAL_LONG(&_3, 2); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "utf-8"); + ZEPHIR_RETURN_CALL_FUNCTION("htmlentities", NULL, 0, &_0, &_3, &_4); + zephir_check_call_status(); RETURN_MM(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Storage_Adapter_Weak) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Storage\\Adapter, Weak, phalcon, storage_adapter_weak, phalcon_storage_adapter_abstractadapter_ce, phalcon_storage_adapter_weak_method_entry, 0); - - zend_declare_property_null(phalcon_storage_adapter_weak_ce, SL("fetching"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_storage_adapter_weak_ce, SL("weakList"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_storage_adapter_weak_ce, SL("options"), ZEND_ACC_PROTECTED); - phalcon_storage_adapter_weak_ce->create_object = zephir_init_properties_Phalcon_Storage_Adapter_Weak; - - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Storage_Adapter_Weak, __construct) +static PHP_METHOD(Phalcon_Support_Debug, getArrayDump) { + zend_string *_4; + zend_ulong _3; + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval options; - zval *factory, factory_sub, *options_param = NULL, _0; + zephir_fcall_cache_entry *_5 = NULL, *_8 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *argument_param = NULL, *n = NULL, n_sub, numberArguments, dump, varDump, k, v, *_1, _2, _6$$8, _7$$8, _9$$9, _10$$5, _11$$15, _12$$15, _13$$16, _14$$12; + zval argument; zval *this_ptr = getThis(); - ZVAL_UNDEF(&factory_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&options); + ZVAL_UNDEF(&argument); + ZVAL_UNDEF(&n_sub); + ZVAL_UNDEF(&numberArguments); + ZVAL_UNDEF(&dump); + ZVAL_UNDEF(&varDump); + ZVAL_UNDEF(&k); + ZVAL_UNDEF(&v); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_6$$8); + ZVAL_UNDEF(&_7$$8); + ZVAL_UNDEF(&_9$$9); + ZVAL_UNDEF(&_10$$5); + ZVAL_UNDEF(&_11$$15); + ZVAL_UNDEF(&_12$$15); + ZVAL_UNDEF(&_13$$16); + ZVAL_UNDEF(&_14$$12); ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_storage_serializerfactory_ce) + Z_PARAM_ARRAY(argument) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + Z_PARAM_ZVAL(n) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &factory, &options_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + zephir_fetch_params(1, 1, 1, &argument_param, &n); + ZEPHIR_OBS_COPY_OR_DUP(&argument, argument_param); + if (!n) { + n = &n_sub; + ZEPHIR_INIT_VAR(n); + ZVAL_LONG(n, 0); } - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, "none"); - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultSerializer"), &_0); - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, ""); - zephir_update_property_zval(this_ptr, ZEND_STRL("prefix"), &_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Storage_Adapter_Weak, clear) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("weakList"), &_0); - RETURN_MM_BOOL(1); -} - -static PHP_METHOD(Phalcon_Storage_Adapter_Weak, decrement) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long value; - zval *key_param = NULL, *value_param = NULL; - zval key; - - ZVAL_UNDEF(&key); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(key) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key_param, &value_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); + ZEPHIR_INIT_VAR(&numberArguments); + ZVAL_LONG(&numberArguments, zephir_fast_count_int(&argument)); + _0 = ZEPHIR_GE_LONG(n, 3); + if (!(_0)) { + _0 = ZEPHIR_IS_LONG(&numberArguments, 0); + } + if (_0) { RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); + if (ZEPHIR_GE_LONG(&numberArguments, 10)) { + RETURN_CCTOR(&numberArguments); } - if (!value_param) { - value = 1; + ZEPHIR_INIT_VAR(&dump); + array_init(&dump); + zephir_is_iterable(&argument, 0, "phalcon/Support/Debug.zep", 587); + if (Z_TYPE_P(&argument) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&argument), _3, _4, _1) + { + ZEPHIR_INIT_NVAR(&k); + if (_4 != NULL) { + ZVAL_STR_COPY(&k, _4); + } else { + ZVAL_LONG(&k, _3); + } + ZEPHIR_INIT_NVAR(&v); + ZVAL_COPY(&v, _1); + if (ZEPHIR_IS_STRING(&v, "")) { + ZEPHIR_INIT_NVAR(&varDump); + ZVAL_STRING(&varDump, "(empty string)"); + } else if (zephir_is_scalar(&v)) { + ZEPHIR_CALL_METHOD(&varDump, this_ptr, "escapestring", &_5, 0, &v); + zephir_check_call_status(); + } else if (Z_TYPE_P(&v) == IS_ARRAY) { + ZVAL_LONG(&_7$$8, (zephir_get_numberval(n) + 1)); + ZEPHIR_CALL_METHOD(&_6$$8, this_ptr, "getarraydump", &_8, 0, &v, &_7$$8); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&varDump); + ZEPHIR_CONCAT_SVS(&varDump, "Array(", &_6$$8, ")"); + } else if (Z_TYPE_P(&v) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_9$$9); + zephir_get_class(&_9$$9, &v, 0); + ZEPHIR_INIT_NVAR(&varDump); + ZEPHIR_CONCAT_SVS(&varDump, "Object(", &_9$$9, ")"); + } else if (Z_TYPE_P(&v) == IS_NULL) { + ZEPHIR_INIT_NVAR(&varDump); + ZVAL_STRING(&varDump, "null"); + } else { + ZEPHIR_CPY_WRT(&varDump, &v); + } + ZEPHIR_INIT_NVAR(&_10$$5); + ZEPHIR_CONCAT_SVSV(&_10$$5, "[", &k, "] => ", &varDump); + zephir_array_append(&dump, &_10$$5, PH_SEPARATE, "phalcon/Support/Debug.zep", 584); + } ZEND_HASH_FOREACH_END(); } else { + ZEPHIR_CALL_METHOD(NULL, &argument, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &argument, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&k, &argument, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&v, &argument, "current", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_STRING(&v, "")) { + ZEPHIR_INIT_NVAR(&varDump); + ZVAL_STRING(&varDump, "(empty string)"); + } else if (zephir_is_scalar(&v)) { + ZEPHIR_CALL_METHOD(&varDump, this_ptr, "escapestring", &_5, 0, &v); + zephir_check_call_status(); + } else if (Z_TYPE_P(&v) == IS_ARRAY) { + ZVAL_LONG(&_12$$15, (zephir_get_numberval(n) + 1)); + ZEPHIR_CALL_METHOD(&_11$$15, this_ptr, "getarraydump", &_8, 0, &v, &_12$$15); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&varDump); + ZEPHIR_CONCAT_SVS(&varDump, "Array(", &_11$$15, ")"); + } else if (Z_TYPE_P(&v) == IS_OBJECT) { + ZEPHIR_INIT_NVAR(&_13$$16); + zephir_get_class(&_13$$16, &v, 0); + ZEPHIR_INIT_NVAR(&varDump); + ZEPHIR_CONCAT_SVS(&varDump, "Object(", &_13$$16, ")"); + } else if (Z_TYPE_P(&v) == IS_NULL) { + ZEPHIR_INIT_NVAR(&varDump); + ZVAL_STRING(&varDump, "null"); + } else { + ZEPHIR_CPY_WRT(&varDump, &v); + } + ZEPHIR_INIT_NVAR(&_14$$12); + ZEPHIR_CONCAT_SVSV(&_14$$12, "[", &k, "] => ", &varDump); + zephir_array_append(&dump, &_14$$12, PH_SEPARATE, "phalcon/Support/Debug.zep", 584); + ZEPHIR_CALL_METHOD(NULL, &argument, "next", NULL, 0); + zephir_check_call_status(); } - RETURN_MM_BOOL(0); + } + ZEPHIR_INIT_NVAR(&v); + ZEPHIR_INIT_NVAR(&k); + zephir_fast_join_str(return_value, SL(", "), &dump); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Weak, delete) +static PHP_METHOD(Phalcon_Support_Debug, getVarDump) { - zend_bool exists = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *key_param = NULL, _0, _1, _2; - zval key; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *variable, variable_sub, className, dumpedObject, _0$$8, _1$$10; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&variable_sub); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&dumpedObject); + ZVAL_UNDEF(&_0$$8); + ZVAL_UNDEF(&_1$$10); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + Z_PARAM_ZVAL(variable) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 0, &variable); + if (ZEPHIR_IS_TRUE_IDENTICAL(variable)) { + RETURN_MM_STRING("true"); } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); + if (ZEPHIR_IS_FALSE_IDENTICAL(variable)) { + RETURN_MM_STRING("false"); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("fetching"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_IDENTICAL(&key, &_0)) { - RETURN_MM_BOOL(0); + if (Z_TYPE_P(variable) == IS_STRING) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "escapestring", NULL, 0, variable); + zephir_check_call_status(); + RETURN_MM(); } - zephir_read_property(&_1, this_ptr, ZEND_STRL("weakList"), PH_NOISY_CC | PH_READONLY); - exists = zephir_array_isset(&_1, &key); - zephir_unset_property_array(this_ptr, ZEND_STRL("weakList"), &key); - zephir_read_property(&_2, this_ptr, ZEND_STRL("weakList"), PH_NOISY_CC | PH_READONLY); - zephir_array_unset(&_2, &key, PH_SEPARATE); - RETURN_MM_BOOL(exists); + if (zephir_is_scalar(variable)) { + RETVAL_ZVAL(variable, 1, 0); + RETURN_MM(); + } + if (Z_TYPE_P(variable) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&className); + zephir_get_class(&className, variable, 0); + if ((zephir_method_exists_ex(variable, ZEND_STRL("dump")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(&dumpedObject, variable, "dump", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0$$8, this_ptr, "getarraydump", NULL, 0, &dumpedObject); + zephir_check_call_status(); + ZEPHIR_CONCAT_SVSVS(return_value, "Object(", &className, ": ", &_0$$8, ")"); + RETURN_MM(); + } else { + ZEPHIR_CONCAT_SVS(return_value, "Object(", &className, ")"); + RETURN_MM(); + } + } + if (Z_TYPE_P(variable) == IS_ARRAY) { + ZEPHIR_CALL_METHOD(&_1$$10, this_ptr, "getarraydump", NULL, 0, variable); + zephir_check_call_status(); + ZEPHIR_CONCAT_SVS(return_value, "Array(", &_1$$10, ")"); + RETURN_MM(); + } + if (Z_TYPE_P(variable) == IS_NULL) { + RETURN_MM_STRING("null"); + } + zephir_gettype(return_value, variable); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Storage_Adapter_Weak, getKeys) +static PHP_METHOD(Phalcon_Support_Debug, showTraceItem) { - zval results; + zend_bool _45$$25; + zval _1, _31$$17; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *prefix_param = NULL, keys, key, _0, _1, *_2$$3, _3$$3; - zval prefix; + zephir_fcall_cache_entry *_24 = NULL, *_52 = NULL; + zval trace; + zval *n_param = NULL, *trace_param = NULL, className, prepareInternalClass, preparedFunctionName, html, classReflection, prepareUriClass, functionName, functionReflection, traceArgs, arguments, argument, filez, line, showFiles, lines, numberLines, showFileFragment, firstLine, lastLine, linePosition, currentLine, classNameWithLink, functionNameWithLink, parts, _0, _20, _2$$3, _3$$3, _4$$3, _5$$3, _15$$3, _16$$3, _6$$4, _7$$4, _8$$4, _9$$4, _10$$4, _11$$5, _12$$6, _13$$6, _14$$6, _17$$10, _18$$11, _19$$11, *_21$$14, _22$$14, _28$$14, _29$$14, _23$$15, _25$$15, _26$$16, _27$$16, _30$$17, _32$$17, _33$$17, _34$$18, _35$$19, _36$$24, _37$$27, _38$$27, _39$$27, _40$$27, _41$$27, _42$$28, _43$$28, _44$$28, _46$$30, _47$$30, _48$$30, _49$$30, _50$$30, _51$$30; + zend_long n, ZEPHIR_LAST_CALL_STATUS, i = 0, beforeLine$$19, afterLine$$19; zval *this_ptr = getThis(); - ZVAL_UNDEF(&prefix); - ZVAL_UNDEF(&keys); - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&prepareInternalClass); + ZVAL_UNDEF(&preparedFunctionName); + ZVAL_UNDEF(&html); + ZVAL_UNDEF(&classReflection); + ZVAL_UNDEF(&prepareUriClass); + ZVAL_UNDEF(&functionName); + ZVAL_UNDEF(&functionReflection); + ZVAL_UNDEF(&traceArgs); + ZVAL_UNDEF(&arguments); + ZVAL_UNDEF(&argument); + ZVAL_UNDEF(&filez); + ZVAL_UNDEF(&line); + ZVAL_UNDEF(&showFiles); + ZVAL_UNDEF(&lines); + ZVAL_UNDEF(&numberLines); + ZVAL_UNDEF(&showFileFragment); + ZVAL_UNDEF(&firstLine); + ZVAL_UNDEF(&lastLine); + ZVAL_UNDEF(&linePosition); + ZVAL_UNDEF(¤tLine); + ZVAL_UNDEF(&classNameWithLink); + ZVAL_UNDEF(&functionNameWithLink); + ZVAL_UNDEF(&parts); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_20); + ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&results); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_STR(prefix) + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_15$$3); + ZVAL_UNDEF(&_16$$3); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$4); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&_10$$4); + ZVAL_UNDEF(&_11$$5); + ZVAL_UNDEF(&_12$$6); + ZVAL_UNDEF(&_13$$6); + ZVAL_UNDEF(&_14$$6); + ZVAL_UNDEF(&_17$$10); + ZVAL_UNDEF(&_18$$11); + ZVAL_UNDEF(&_19$$11); + ZVAL_UNDEF(&_22$$14); + ZVAL_UNDEF(&_28$$14); + ZVAL_UNDEF(&_29$$14); + ZVAL_UNDEF(&_23$$15); + ZVAL_UNDEF(&_25$$15); + ZVAL_UNDEF(&_26$$16); + ZVAL_UNDEF(&_27$$16); + ZVAL_UNDEF(&_30$$17); + ZVAL_UNDEF(&_32$$17); + ZVAL_UNDEF(&_33$$17); + ZVAL_UNDEF(&_34$$18); + ZVAL_UNDEF(&_35$$19); + ZVAL_UNDEF(&_36$$24); + ZVAL_UNDEF(&_37$$27); + ZVAL_UNDEF(&_38$$27); + ZVAL_UNDEF(&_39$$27); + ZVAL_UNDEF(&_40$$27); + ZVAL_UNDEF(&_41$$27); + ZVAL_UNDEF(&_42$$28); + ZVAL_UNDEF(&_43$$28); + ZVAL_UNDEF(&_44$$28); + ZVAL_UNDEF(&_46$$30); + ZVAL_UNDEF(&_47$$30); + ZVAL_UNDEF(&_48$$30); + ZVAL_UNDEF(&_49$$30); + ZVAL_UNDEF(&_50$$30); + ZVAL_UNDEF(&_51$$30); + ZVAL_UNDEF(&trace); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_31$$17); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_LONG(n) + Z_PARAM_ARRAY(trace) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &prefix_param); - if (!prefix_param) { - ZEPHIR_INIT_VAR(&prefix); - ZVAL_STRING(&prefix, ""); + zephir_fetch_params(1, 2, 0, &n_param, &trace_param); + ZEPHIR_OBS_COPY_OR_DUP(&trace, trace_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_LONG(&_0, n); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_SVS(&_1, "#", &_0, ""); + ZEPHIR_CPY_WRT(&html, &_1); + zephir_memory_observe(&className); + if (zephir_array_isset_string_fetch(&className, &trace, SL("class"), 0)) { + ZEPHIR_INIT_VAR(&_2$$3); + ZEPHIR_INIT_VAR(&_3$$3); + ZVAL_STRING(&_3$$3, "/^Phalcon/"); + ZEPHIR_INIT_VAR(&_4$$3); + ZEPHIR_INIT_VAR(&_5$$3); + ZVAL_STRING(&_5$$3, "/^Phalcon/"); + zephir_preg_match(&_4$$3, &_5$$3, &className, &_2$$3, 0, 0 , 0 ); + if (zephir_is_true(&_4$$3)) { + ZEPHIR_INIT_VAR(&parts); + zephir_fast_explode_str(&parts, SL("\\"), &className, LONG_MAX); + zephir_array_fetch_long(&_6$$4, &parts, 0, PH_NOISY | PH_READONLY, "phalcon/Support/Debug.zep", 700); + zephir_array_fetch_long(&_7$$4, &parts, 1, PH_NOISY | PH_READONLY, "phalcon/Support/Debug.zep", 700); + ZEPHIR_INIT_VAR(&prepareUriClass); + ZEPHIR_CONCAT_VSV(&prepareUriClass, &_6$$4, "_", &_7$$4); + zephir_read_property(&_8$$4, this_ptr, ZEND_STRL("version"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_10$$4, 0); + ZEPHIR_CALL_METHOD(&_9$$4, &_8$$4, "getpart", NULL, 0, &_10$$4); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&classNameWithLink); + ZEPHIR_CONCAT_SVSVSVS(&classNameWithLink, "", &className, ""); + } else { + ZEPHIR_INIT_VAR(&classReflection); + object_init_ex(&classReflection, zephir_get_internal_ce(SL("reflectionclass"))); + ZEPHIR_CALL_METHOD(NULL, &classReflection, "__construct", NULL, 154, &className); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_11$$5, &classReflection, "isinternal", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_11$$5)) { + ZEPHIR_INIT_VAR(&_12$$6); + zephir_fast_strtolower(&_12$$6, &className); + ZEPHIR_INIT_VAR(&_13$$6); + ZVAL_STRING(&_13$$6, "_"); + ZEPHIR_INIT_VAR(&_14$$6); + ZVAL_STRING(&_14$$6, "-"); + ZEPHIR_INIT_VAR(&prepareInternalClass); + zephir_fast_str_replace(&prepareInternalClass, &_13$$6, &_14$$6, &_12$$6); + ZEPHIR_INIT_NVAR(&classNameWithLink); + ZEPHIR_CONCAT_SVSVS(&classNameWithLink, "", &className, ""); + } else { + ZEPHIR_CPY_WRT(&classNameWithLink, &className); + } + } + ZEPHIR_INIT_VAR(&_15$$3); + ZEPHIR_CONCAT_SVS(&_15$$3, "", &classNameWithLink, ""); + zephir_concat_self(&html, &_15$$3); + zephir_array_fetch_string(&_16$$3, &trace, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Support/Debug.zep", 739); + zephir_concat_self(&html, &_16$$3); + } + zephir_memory_observe(&functionName); + zephir_array_fetch_string(&functionName, &trace, SL("function"), PH_NOISY, "phalcon/Support/Debug.zep", 745); + if (zephir_array_isset_string(&trace, SL("class"))) { + ZEPHIR_CPY_WRT(&functionNameWithLink, &functionName); } else { - zephir_get_strval(&prefix, prefix_param); + if ((zephir_function_exists(&functionName) == SUCCESS)) { + ZEPHIR_INIT_VAR(&functionReflection); + object_init_ex(&functionReflection, zephir_get_internal_ce(SL("reflectionfunction"))); + ZEPHIR_CALL_METHOD(NULL, &functionReflection, "__construct", NULL, 151, &functionName); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_17$$10, &functionReflection, "isinternal", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_17$$10)) { + ZEPHIR_INIT_VAR(&_18$$11); + ZVAL_STRING(&_18$$11, "_"); + ZEPHIR_INIT_VAR(&_19$$11); + ZVAL_STRING(&_19$$11, "-"); + ZEPHIR_INIT_VAR(&preparedFunctionName); + zephir_fast_str_replace(&preparedFunctionName, &_18$$11, &_19$$11, &functionName); + ZEPHIR_INIT_NVAR(&functionNameWithLink); + ZEPHIR_CONCAT_SVSVS(&functionNameWithLink, "", &functionName, ""); + } else { + ZEPHIR_CPY_WRT(&functionNameWithLink, &functionName); + } + } else { + ZEPHIR_CPY_WRT(&functionNameWithLink, &functionName); + } } - zephir_read_property(&_0, this_ptr, ZEND_STRL("weakList"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&keys); - zephir_array_keys(&keys, &_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, ""); - if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_1, &prefix))) { - ZEPHIR_INIT_VAR(&results); - array_init(&results); - zephir_is_iterable(&keys, 0, "phalcon/Storage/Adapter/Weak.zep", 116); - if (Z_TYPE_P(&keys) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&keys), _2$$3) + ZEPHIR_INIT_VAR(&_20); + ZEPHIR_CONCAT_SVS(&_20, "", &functionNameWithLink, ""); + zephir_concat_self(&html, &_20); + zephir_memory_observe(&traceArgs); + if (zephir_array_isset_string_fetch(&traceArgs, &trace, SL("args"), 0)) { + ZEPHIR_INIT_VAR(&arguments); + array_init(&arguments); + zephir_is_iterable(&traceArgs, 0, "phalcon/Support/Debug.zep", 800); + if (Z_TYPE_P(&traceArgs) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&traceArgs), _21$$14) { - ZEPHIR_INIT_NVAR(&key); - ZVAL_COPY(&key, _2$$3); - if (zephir_start_with(&key, &prefix, NULL)) { - zephir_array_append(&results, &key, PH_SEPARATE, "phalcon/Storage/Adapter/Weak.zep", 113); - } + ZEPHIR_INIT_NVAR(&argument); + ZVAL_COPY(&argument, _21$$14); + ZEPHIR_CALL_METHOD(&_23$$15, this_ptr, "getvardump", &_24, 0, &argument); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_25$$15); + ZEPHIR_CONCAT_SVS(&_25$$15, "", &_23$$15, ""); + zephir_array_append(&arguments, &_25$$15, PH_SEPARATE, "phalcon/Support/Debug.zep", 794); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &keys, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &traceArgs, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_22$$14, &traceArgs, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_22$$14)) { + break; + } + ZEPHIR_CALL_METHOD(&argument, &traceArgs, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_26$$16, this_ptr, "getvardump", &_24, 0, &argument); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_27$$16); + ZEPHIR_CONCAT_SVS(&_27$$16, "", &_26$$16, ""); + zephir_array_append(&arguments, &_27$$16, PH_SEPARATE, "phalcon/Support/Debug.zep", 794); + ZEPHIR_CALL_METHOD(NULL, &traceArgs, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&argument); + ZEPHIR_INIT_VAR(&_28$$14); + zephir_fast_join_str(&_28$$14, SL(", "), &arguments); + ZEPHIR_INIT_VAR(&_29$$14); + ZEPHIR_CONCAT_SVS(&_29$$14, "(", &_28$$14, ")"); + zephir_concat_self(&html, &_29$$14); + } + zephir_memory_observe(&filez); + if (zephir_array_isset_string_fetch(&filez, &trace, SL("file"), 0)) { + zephir_memory_observe(&_30$$17); + zephir_array_fetch_string(&_30$$17, &trace, SL("line"), PH_NOISY, "phalcon/Support/Debug.zep", 808); + zephir_cast_to_string(&_31$$17, &_30$$17); + ZEPHIR_CPY_WRT(&line, &_31$$17); + ZEPHIR_INIT_VAR(&_32$$17); + ZEPHIR_CONCAT_SVSVS(&_32$$17, "
", &filez, " (", &line, ")
"); + zephir_concat_self(&html, &_32$$17); + zephir_read_property(&_33$$17, this_ptr, ZEND_STRL("showFiles"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&showFiles, &_33$$17); + if (zephir_is_true(&showFiles)) { + ZEPHIR_CALL_FUNCTION(&lines, "file", NULL, 0, &filez); zephir_check_call_status(); + ZEPHIR_INIT_VAR(&numberLines); + ZVAL_LONG(&numberLines, zephir_fast_count_int(&lines)); + zephir_read_property(&_34$$18, this_ptr, ZEND_STRL("showFileFragment"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&showFileFragment, &_34$$18); + if (zephir_is_true(&showFileFragment)) { + beforeLine$$19 = (zephir_get_numberval(&line) - 7); + if (beforeLine$$19 < 1) { + ZEPHIR_INIT_VAR(&firstLine); + ZVAL_LONG(&firstLine, 1); + } else { + ZEPHIR_INIT_NVAR(&firstLine); + ZVAL_LONG(&firstLine, beforeLine$$19); + } + afterLine$$19 = (zephir_get_numberval(&line) + 5); + if (ZEPHIR_LT_LONG(&numberLines, afterLine$$19)) { + ZEPHIR_CPY_WRT(&lastLine, &numberLines); + } else { + ZEPHIR_INIT_NVAR(&lastLine); + ZVAL_LONG(&lastLine, afterLine$$19); + } + ZEPHIR_INIT_VAR(&_35$$19); + ZEPHIR_CONCAT_SVSVSVS(&_35$$19, "
");
+				zephir_concat_self(&html, &_35$$19);
+			} else {
+				ZEPHIR_INIT_NVAR(&firstLine);
+				ZVAL_LONG(&firstLine, 1);
+				ZEPHIR_CPY_WRT(&lastLine, &numberLines);
+				ZEPHIR_INIT_VAR(&_36$$24);
+				ZEPHIR_CONCAT_SVSVS(&_36$$24, "
");
+				zephir_concat_self(&html, &_36$$24);
+			}
+			i = zephir_get_numberval(&firstLine);
 			while (1) {
-				ZEPHIR_CALL_METHOD(&_3$$3, &keys, "valid", NULL, 0);
-				zephir_check_call_status();
-				if (!zend_is_true(&_3$$3)) {
+				if (!(ZEPHIR_GE_LONG(&lastLine, i))) {
 					break;
 				}
-				ZEPHIR_CALL_METHOD(&key, &keys, "current", NULL, 0);
-				zephir_check_call_status();
-					if (zephir_start_with(&key, &prefix, NULL)) {
-						zephir_array_append(&results, &key, PH_SEPARATE, "phalcon/Storage/Adapter/Weak.zep", 113);
+				ZEPHIR_INIT_NVAR(&linePosition);
+				ZVAL_LONG(&linePosition, (i - 1));
+				ZEPHIR_OBS_NVAR(¤tLine);
+				zephir_array_fetch(¤tLine, &lines, &linePosition, PH_NOISY, "phalcon/Support/Debug.zep", 881);
+				if (zephir_is_true(&showFileFragment)) {
+					if (ZEPHIR_IS_LONG(&firstLine, i)) {
+						ZEPHIR_INIT_NVAR(&_37$$27);
+						ZEPHIR_INIT_NVAR(&_38$$27);
+						zephir_fast_trim(&_38$$27, ¤tLine, NULL , ZEPHIR_TRIM_RIGHT);
+						ZEPHIR_INIT_NVAR(&_39$$27);
+						ZVAL_STRING(&_39$$27, "#\\*\\/#");
+						ZEPHIR_INIT_NVAR(&_40$$27);
+						ZEPHIR_INIT_NVAR(&_41$$27);
+						ZVAL_STRING(&_41$$27, "#\\*\\/#");
+						zephir_preg_match(&_40$$27, &_41$$27, &_38$$27, &_37$$27, 0, 0 , 0 );
+						if (zephir_is_true(&_40$$27)) {
+							ZEPHIR_INIT_NVAR(&_42$$28);
+							ZEPHIR_INIT_NVAR(&_43$$28);
+							ZVAL_STRING(&_43$$28, "* /");
+							ZEPHIR_INIT_NVAR(&_44$$28);
+							ZVAL_STRING(&_44$$28, " ");
+							zephir_fast_str_replace(&_42$$28, &_43$$28, &_44$$28, ¤tLine);
+							ZEPHIR_CPY_WRT(¤tLine, &_42$$28);
+						}
 					}
-				ZEPHIR_CALL_METHOD(NULL, &keys, "next", NULL, 0);
-				zephir_check_call_status();
+				}
+				_45$$25 = ZEPHIR_IS_STRING(¤tLine, "\n");
+				if (!(_45$$25)) {
+					_45$$25 = ZEPHIR_IS_STRING(¤tLine, "\r\n");
+				}
+				if (_45$$25) {
+					zephir_concat_self_str(&html, SL(" \n"));
+				} else {
+					ZEPHIR_INIT_NVAR(&_46$$30);
+					ZEPHIR_INIT_NVAR(&_47$$30);
+					ZVAL_STRING(&_47$$30, "\t");
+					ZEPHIR_INIT_NVAR(&_48$$30);
+					ZVAL_STRING(&_48$$30, "  ");
+					zephir_fast_str_replace(&_46$$30, &_47$$30, &_48$$30, ¤tLine);
+					ZVAL_LONG(&_49$$30, 2);
+					ZEPHIR_INIT_NVAR(&_50$$30);
+					ZVAL_STRING(&_50$$30, "UTF-8");
+					ZEPHIR_CALL_FUNCTION(&_51$$30, "htmlentities", &_52, 0, &_46$$30, &_49$$30, &_50$$30);
+					zephir_check_call_status();
+					zephir_concat_self(&html, &_51$$30);
+				}
+				i++;
 			}
+			zephir_concat_self_str(&html, SL("
")); } - ZEPHIR_INIT_NVAR(&key); - RETURN_CTOR(&results); - } - RETURN_CCTOR(&keys); -} - -static PHP_METHOD(Phalcon_Storage_Adapter_Weak, increment) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long value; - zval *key_param = NULL, *value_param = NULL; - zval key; - - ZVAL_UNDEF(&key); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(key) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key_param, &value_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - if (!value_param) { - value = 1; - } else { - } - RETURN_MM_BOOL(0); + zephir_concat_self_str(&html, SL("")); + RETURN_CCTOR(&html); } -static PHP_METHOD(Phalcon_Storage_Adapter_Weak, get) +static PHP_METHOD(Phalcon_Support_Debug, getArrVal) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null, value, wr, _0, _1; - zval key; - zval *this_ptr = getThis(); + zval *collection_param = NULL, *index, index_sub, *defaultValue = NULL, defaultValue_sub, __$null, value; + zval collection; - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&index_sub); ZVAL_UNDEF(&defaultValue_sub); ZVAL_NULL(&__$null); ZVAL_UNDEF(&value); - ZVAL_UNDEF(&wr); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(key) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ARRAY(collection) + Z_PARAM_ZVAL(index) Z_PARAM_OPTIONAL Z_PARAM_ZVAL_OR_NULL(defaultValue) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &key_param, &defaultValue); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } + zephir_fetch_params(1, 2, 1, &collection_param, &index, &defaultValue); + ZEPHIR_OBS_COPY_OR_DUP(&collection, collection_param); if (!defaultValue) { defaultValue = &defaultValue_sub; defaultValue = &__$null; } - zephir_update_property_zval(this_ptr, ZEND_STRL("fetching"), &key); - zephir_read_property(&_0, this_ptr, ZEND_STRL("weakList"), PH_NOISY_CC | PH_READONLY); - if (0 == zephir_array_isset(&_0, &key)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("fetching"), &__$null); + zephir_memory_observe(&value); + if (UNEXPECTED(!(zephir_array_isset_fetch(&value, &collection, index, 0)))) { RETVAL_ZVAL(defaultValue, 1, 0); RETURN_MM(); } - zephir_read_property(&_1, this_ptr, ZEND_STRL("weakList"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&wr); - zephir_array_fetch(&wr, &_1, &key, PH_NOISY, "phalcon/Storage/Adapter/Weak.zep", 156); - ZEPHIR_CALL_METHOD(&value, &wr, "get", NULL, 0); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("fetching"), &__$null); - if (Z_TYPE_P(&value) == IS_NULL) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "delete", NULL, 0, &key); - zephir_check_call_status(); - } RETURN_CCTOR(&value); } -static PHP_METHOD(Phalcon_Storage_Adapter_Weak, has) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *key_param = NULL, _0; - zval key; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("weakList"), PH_NOISY_CC | PH_READONLY); - RETURN_MM_BOOL(zephir_array_isset(&_0, &key)); -} - -static PHP_METHOD(Phalcon_Storage_Adapter_Weak, set) -{ - zend_class_entry *_2$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub, *ttl = NULL, ttl_sub, __$null, _0, _1$$4; - zval key; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&ttl_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(ttl) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &key_param, &value, &ttl); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - if (!ttl) { - ttl = &ttl_sub; - ttl = &__$null; - } - if (Z_TYPE_P(value) != IS_OBJECT) { - RETURN_MM_BOOL(0); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("weakList"), PH_NOISY_CC | PH_READONLY); - if (0 == zephir_array_isset(&_0, &key)) { - _2$$4 = zephir_fetch_class_str_ex(SL("WeakReference"), ZEND_FETCH_CLASS_AUTO); - ZEPHIR_CALL_CE_STATIC(&_1$$4, _2$$4, "create", NULL, 0, value); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("weakList"), &key, &_1$$4); - } - RETURN_MM_BOOL(1); -} - -static PHP_METHOD(Phalcon_Storage_Adapter_Weak, setForever) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *value, value_sub; - zval key; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(key) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &key_param, &value); - zephir_get_strval(&key, key_param); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "set", NULL, 0, &key, value); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Storage_Adapter_Weak, setDefaultSerializer) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *serializer_param = NULL; - zval serializer; - - ZVAL_UNDEF(&serializer); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(serializer) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &serializer_param); - zephir_get_strval(&serializer, serializer_param); -} - -zend_object *zephir_init_properties_Phalcon_Storage_Adapter_Weak(zend_class_entry *class_type) +zend_object *zephir_init_properties_Phalcon_Support_Debug(zend_class_entry *class_type) { - zval _0, _2, _1$$3, _3$$4; + zval _3$$4; + zval _0, _2, _1$$3, _4$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_4$$4); ZVAL_UNDEF(&_3$$4); @@ -137454,17 +137584,23 @@ zend_object *zephir_init_properties_Phalcon_Storage_Adapter_Weak(zend_class_entr { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("data"), &_1$$3); } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("weakList"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("blacklist"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_2) == IS_NULL) { ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("weakList"), &_3$$4); + zephir_create_array(&_3$$4, 2, 0); + ZEPHIR_INIT_VAR(&_4$$4); + array_init(&_4$$4); + zephir_array_update_string(&_3$$4, SL("request"), &_4$$4, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_4$$4); + array_init(&_4$$4); + zephir_array_update_string(&_3$$4, SL("server"), &_4$$4, PH_COPY | PH_SEPARATE); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("blacklist"), &_3$$4); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -137481,378 +137617,198 @@ zend_object *zephir_init_properties_Phalcon_Storage_Adapter_Weak(zend_class_entr -ZEPHIR_INIT_CLASS(Phalcon_Annotations_Annotation) +ZEPHIR_INIT_CLASS(Phalcon_Support_Exception) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Annotations, Annotation, phalcon, annotations_annotation, phalcon_annotations_annotation_method_entry, 0); - - zend_declare_property_null(phalcon_annotations_annotation_ce, SL("arguments"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_annotations_annotation_ce, SL("exprArguments"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_annotations_annotation_ce, SL("name"), ZEND_ACC_PROTECTED); - phalcon_annotations_annotation_ce->create_object = zephir_init_properties_Phalcon_Annotations_Annotation; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support, Exception, phalcon, support_exception, zend_ce_exception, NULL, 0); return SUCCESS; } -static PHP_METHOD(Phalcon_Annotations_Annotation, __construct) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *reflectionData_param = NULL, name, exprArguments, argument, resolvedArgument, _0$$3, *_1$$4, _2$$4, _3$$5, _5$$8; - zval reflectionData, arguments; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&reflectionData); - ZVAL_UNDEF(&arguments); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&exprArguments); - ZVAL_UNDEF(&argument); - ZVAL_UNDEF(&resolvedArgument); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_5$$8); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(reflectionData) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &reflectionData_param); - ZEPHIR_OBS_COPY_OR_DUP(&reflectionData, reflectionData_param); - zephir_memory_observe(&name); - if (zephir_array_isset_string_fetch(&name, &reflectionData, SL("name"), 0)) { - zephir_array_fetch_string(&_0$$3, &reflectionData, SL("name"), PH_NOISY | PH_READONLY, "phalcon/Annotations/Annotation.zep", 48); - zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &_0$$3); - } - zephir_memory_observe(&exprArguments); - if (zephir_array_isset_string_fetch(&exprArguments, &reflectionData, SL("arguments"), 0)) { - ZEPHIR_INIT_VAR(&arguments); - array_init(&arguments); - zephir_is_iterable(&exprArguments, 0, "phalcon/Annotations/Annotation.zep", 69); - if (Z_TYPE_P(&exprArguments) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&exprArguments), _1$$4) - { - ZEPHIR_INIT_NVAR(&argument); - ZVAL_COPY(&argument, _1$$4); - zephir_array_fetch_string(&_3$$5, &argument, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/Annotations/Annotation.zep", 60); - ZEPHIR_CALL_METHOD(&resolvedArgument, this_ptr, "getexpression", &_4, 0, &_3$$5); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&name); - if (zephir_array_isset_string_fetch(&name, &argument, SL("name"), 0)) { - zephir_array_update_zval(&arguments, &name, &resolvedArgument, PH_COPY | PH_SEPARATE); - } else { - zephir_array_append(&arguments, &resolvedArgument, PH_SEPARATE, "phalcon/Annotations/Annotation.zep", 65); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &exprArguments, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2$$4, &exprArguments, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2$$4)) { - break; - } - ZEPHIR_CALL_METHOD(&argument, &exprArguments, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_fetch_string(&_5$$8, &argument, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/Annotations/Annotation.zep", 60); - ZEPHIR_CALL_METHOD(&resolvedArgument, this_ptr, "getexpression", &_4, 0, &_5$$8); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&name); - if (zephir_array_isset_string_fetch(&name, &argument, SL("name"), 0)) { - zephir_array_update_zval(&arguments, &name, &resolvedArgument, PH_COPY | PH_SEPARATE); - } else { - zephir_array_append(&arguments, &resolvedArgument, PH_SEPARATE, "phalcon/Annotations/Annotation.zep", 65); - } - ZEPHIR_CALL_METHOD(NULL, &exprArguments, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&argument); - zephir_update_property_zval(this_ptr, ZEND_STRL("arguments"), &arguments); - zephir_update_property_zval(this_ptr, ZEND_STRL("exprArguments"), &exprArguments); - } - ZEPHIR_MM_RESTORE(); -} -static PHP_METHOD(Phalcon_Annotations_Annotation, getArgument) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *position, position_sub, argument, _0; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&position_sub); - ZVAL_UNDEF(&argument); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(position) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &position); - zephir_memory_observe(&argument); - zephir_read_property(&_0, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&argument, &_0, position, 0)) { - RETURN_CCTOR(&argument); - } - RETURN_MM_NULL(); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Annotations_Annotation, getArguments) -{ - RETURN_MEMBER(getThis(), "arguments"); -} -static PHP_METHOD(Phalcon_Annotations_Annotation, getExprArguments) + + +ZEPHIR_INIT_CLASS(Phalcon_Support_HelperFactory) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support, HelperFactory, phalcon, support_helperfactory, phalcon_factory_abstractfactory_ce, phalcon_support_helperfactory_method_entry, 0); - RETURN_MEMBER(getThis(), "exprArguments"); + return SUCCESS; } -static PHP_METHOD(Phalcon_Annotations_Annotation, getExpression) +static PHP_METHOD(Phalcon_Support_HelperFactory, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *expr_param = NULL, value, item, resolvedItem, arrayValue, name, type, _0$$7, *_1$$7, _2$$7, _3$$8, _5$$11, _6$$15, _7$$15; - zval expr; + zval *services_param = NULL; + zval services; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expr); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&item); - ZVAL_UNDEF(&resolvedItem); - ZVAL_UNDEF(&arrayValue); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&_0$$7); - ZVAL_UNDEF(&_2$$7); - ZVAL_UNDEF(&_3$$8); - ZVAL_UNDEF(&_5$$11); - ZVAL_UNDEF(&_6$$15); - ZVAL_UNDEF(&_7$$15); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(expr) + ZVAL_UNDEF(&services); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(services) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &expr_param); - ZEPHIR_OBS_COPY_OR_DUP(&expr, expr_param); - zephir_memory_observe(&type); - zephir_array_fetch_string(&type, &expr, SL("type"), PH_NOISY, "phalcon/Annotations/Annotation.zep", 111); - do { - if (ZEPHIR_IS_LONG(&type, 301) || ZEPHIR_IS_LONG(&type, 302) || ZEPHIR_IS_LONG(&type, 303) || ZEPHIR_IS_LONG(&type, 307)) { - zephir_memory_observe(&value); - zephir_array_fetch_string(&value, &expr, SL("value"), PH_NOISY, "phalcon/Annotations/Annotation.zep", 118); - break; - } - if (ZEPHIR_IS_LONG(&type, 304)) { - ZEPHIR_INIT_NVAR(&value); - ZVAL_NULL(&value); - break; - } - if (ZEPHIR_IS_LONG(&type, 305)) { - ZEPHIR_INIT_NVAR(&value); - ZVAL_BOOL(&value, 0); - break; - } - if (ZEPHIR_IS_LONG(&type, 306)) { - ZEPHIR_INIT_NVAR(&value); - ZVAL_BOOL(&value, 1); - break; - } - if (ZEPHIR_IS_LONG(&type, 308)) { - ZEPHIR_INIT_VAR(&arrayValue); - array_init(&arrayValue); - zephir_array_fetch_string(&_0$$7, &expr, SL("items"), PH_NOISY | PH_READONLY, "phalcon/Annotations/Annotation.zep", 136); - zephir_is_iterable(&_0$$7, 0, "phalcon/Annotations/Annotation.zep", 148); - if (Z_TYPE_P(&_0$$7) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0$$7), _1$$7) - { - ZEPHIR_INIT_NVAR(&item); - ZVAL_COPY(&item, _1$$7); - zephir_array_fetch_string(&_3$$8, &item, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/Annotations/Annotation.zep", 139); - ZEPHIR_CALL_METHOD(&resolvedItem, this_ptr, "getexpression", &_4, 157, &_3$$8); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&name); - if (zephir_array_isset_string_fetch(&name, &item, SL("name"), 0)) { - zephir_array_update_zval(&arrayValue, &name, &resolvedItem, PH_COPY | PH_SEPARATE); - } else { - zephir_array_append(&arrayValue, &resolvedItem, PH_SEPARATE, "phalcon/Annotations/Annotation.zep", 144); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_0$$7, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2$$7, &_0$$7, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2$$7)) { - break; - } - ZEPHIR_CALL_METHOD(&item, &_0$$7, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_fetch_string(&_5$$11, &item, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/Annotations/Annotation.zep", 139); - ZEPHIR_CALL_METHOD(&resolvedItem, this_ptr, "getexpression", &_4, 157, &_5$$11); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&name); - if (zephir_array_isset_string_fetch(&name, &item, SL("name"), 0)) { - zephir_array_update_zval(&arrayValue, &name, &resolvedItem, PH_COPY | PH_SEPARATE); - } else { - zephir_array_append(&arrayValue, &resolvedItem, PH_SEPARATE, "phalcon/Annotations/Annotation.zep", 144); - } - ZEPHIR_CALL_METHOD(NULL, &_0$$7, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&item); - RETURN_CCTOR(&arrayValue); - } - if (ZEPHIR_IS_LONG(&type, 300)) { - object_init_ex(return_value, phalcon_annotations_annotation_ce); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 158, &expr); - zephir_check_call_status(); - RETURN_MM(); - } - ZEPHIR_INIT_VAR(&_6$$15); - object_init_ex(&_6$$15, phalcon_annotations_exception_ce); - ZEPHIR_INIT_VAR(&_7$$15); - ZEPHIR_CONCAT_SVS(&_7$$15, "The expression ", &type, " is unknown"); - ZEPHIR_CALL_METHOD(NULL, &_6$$15, "__construct", NULL, 33, &_7$$15); - zephir_check_call_status(); - zephir_throw_exception_debug(&_6$$15, "phalcon/Annotations/Annotation.zep", 154); - ZEPHIR_MM_RESTORE(); - return; - } while(0); - - RETURN_CCTOR(&value); -} - -static PHP_METHOD(Phalcon_Annotations_Annotation, getName) -{ - - RETURN_MEMBER(getThis(), "name"); + zephir_fetch_params(1, 0, 1, &services_param); + if (!services_param) { + ZEPHIR_INIT_VAR(&services); + array_init(&services); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Annotations_Annotation, getNamedArgument) +static PHP_METHOD(Phalcon_Support_HelperFactory, __call) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, argument, _0; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval arguments, _0; + zval *name_param = NULL, *arguments_param = NULL, helper, _1; zval name; zval *this_ptr = getThis(); ZVAL_UNDEF(&name); - ZVAL_UNDEF(&argument); + ZVAL_UNDEF(&helper); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&arguments); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) + ZEND_PARSE_PARAMETERS_START(2, 2) Z_PARAM_STR(name) + Z_PARAM_ARRAY(arguments) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - zephir_memory_observe(&argument); - zephir_read_property(&_0, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&argument, &_0, &name, 0)) { - RETURN_CCTOR(&argument); - } - RETURN_MM_NULL(); + zephir_fetch_params(1, 2, 0, &name_param, &arguments_param); + zephir_get_strval(&name, name_param); + zephir_get_arrval(&arguments, arguments_param); + ZEPHIR_CALL_METHOD(&helper, this_ptr, "newinstance", NULL, 0, &name); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 2, 0); + zephir_array_fast_append(&_0, &helper); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "__invoke"); + zephir_array_fast_append(&_0, &_1); + ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_0, &arguments); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Annotations_Annotation, getNamedParameter) +static PHP_METHOD(Phalcon_Support_HelperFactory, newInstance) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL; + zval *name_param = NULL, _0, _3, _4, _1$$3, _2$$3; zval name; zval *this_ptr = getThis(); ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); + zephir_get_strval(&name, name_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); + if (1 != zephir_array_isset(&_0, &name)) { + ZEPHIR_INIT_VAR(&_1$$3); + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "getservice", NULL, 0, &name); + zephir_check_call_status(); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance(&_1$$3, &_2$$3); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("services"), &name, &_1$$3); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getnamedargument", NULL, 0, &name); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Annotations_Annotation, hasArgument) -{ - zval *position, position_sub, _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&position_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(position) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &position); - zephir_read_property(&_0, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); - RETURN_BOOL(zephir_array_isset(&_0, position)); + zephir_read_property(&_3, this_ptr, ZEND_STRL("services"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_4, &_3, &name, PH_NOISY | PH_READONLY, "phalcon/Support/HelperFactory.zep", 118); + RETURN_CTOR(&_4); } -static PHP_METHOD(Phalcon_Annotations_Annotation, numberArguments) +static PHP_METHOD(Phalcon_Support_HelperFactory, getExceptionClass) { - zval _0; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); - RETURN_LONG(zephir_fast_count_int(&_0)); + RETURN_STRING("Phalcon\\Support\\Exception"); } -zend_object *zephir_init_properties_Phalcon_Annotations_Annotation(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Support_HelperFactory, getServices) { - zval _0, _2, _1$$3, _3$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("exprArguments"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("exprArguments"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("arguments"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("arguments"), &_3$$4); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } + zephir_create_array(return_value, 59, 0); + add_assoc_stringl_ex(return_value, SL("blacklist"), SL("Phalcon\\Support\\Helper\\Arr\\Blacklist")); + add_assoc_stringl_ex(return_value, SL("chunk"), SL("Phalcon\\Support\\Helper\\Arr\\Chunk")); + add_assoc_stringl_ex(return_value, SL("filter"), SL("Phalcon\\Support\\Helper\\Arr\\Filter")); + add_assoc_stringl_ex(return_value, SL("first"), SL("Phalcon\\Support\\Helper\\Arr\\First")); + add_assoc_stringl_ex(return_value, SL("firstKey"), SL("Phalcon\\Support\\Helper\\Arr\\FirstKey")); + add_assoc_stringl_ex(return_value, SL("flatten"), SL("Phalcon\\Support\\Helper\\Arr\\Flatten")); + add_assoc_stringl_ex(return_value, SL("get"), SL("Phalcon\\Support\\Helper\\Arr\\Get")); + add_assoc_stringl_ex(return_value, SL("group"), SL("Phalcon\\Support\\Helper\\Arr\\Group")); + add_assoc_stringl_ex(return_value, SL("has"), SL("Phalcon\\Support\\Helper\\Arr\\Has")); + add_assoc_stringl_ex(return_value, SL("isUnique"), SL("Phalcon\\Support\\Helper\\Arr\\IsUnique")); + add_assoc_stringl_ex(return_value, SL("last"), SL("Phalcon\\Support\\Helper\\Arr\\Last")); + add_assoc_stringl_ex(return_value, SL("lastKey"), SL("Phalcon\\Support\\Helper\\Arr\\LastKey")); + add_assoc_stringl_ex(return_value, SL("order"), SL("Phalcon\\Support\\Helper\\Arr\\Order")); + add_assoc_stringl_ex(return_value, SL("pluck"), SL("Phalcon\\Support\\Helper\\Arr\\Pluck")); + add_assoc_stringl_ex(return_value, SL("set"), SL("Phalcon\\Support\\Helper\\Arr\\Set")); + add_assoc_stringl_ex(return_value, SL("sliceLeft"), SL("Phalcon\\Support\\Helper\\Arr\\SliceLeft")); + add_assoc_stringl_ex(return_value, SL("sliceRight"), SL("Phalcon\\Support\\Helper\\Arr\\SliceRight")); + add_assoc_stringl_ex(return_value, SL("split"), SL("Phalcon\\Support\\Helper\\Arr\\Split")); + add_assoc_stringl_ex(return_value, SL("toObject"), SL("Phalcon\\Support\\Helper\\Arr\\ToObject")); + add_assoc_stringl_ex(return_value, SL("validateAll"), SL("Phalcon\\Support\\Helper\\Arr\\ValidateAll")); + add_assoc_stringl_ex(return_value, SL("validateAny"), SL("Phalcon\\Support\\Helper\\Arr\\ValidateAny")); + add_assoc_stringl_ex(return_value, SL("whitelist"), SL("Phalcon\\Support\\Helper\\Arr\\Whitelist")); + add_assoc_stringl_ex(return_value, SL("basename"), SL("Phalcon\\Support\\Helper\\File\\Basename")); + add_assoc_stringl_ex(return_value, SL("decode"), SL("Phalcon\\Support\\Helper\\Json\\Decode")); + add_assoc_stringl_ex(return_value, SL("encode"), SL("Phalcon\\Support\\Helper\\Json\\Encode")); + add_assoc_stringl_ex(return_value, SL("isBetween"), SL("Phalcon\\Support\\Helper\\Number\\IsBetween")); + add_assoc_stringl_ex(return_value, SL("camelize"), SL("Phalcon\\Support\\Helper\\Str\\Camelize")); + add_assoc_stringl_ex(return_value, SL("concat"), SL("Phalcon\\Support\\Helper\\Str\\Concat")); + add_assoc_stringl_ex(return_value, SL("countVowels"), SL("Phalcon\\Support\\Helper\\Str\\CountVowels")); + add_assoc_stringl_ex(return_value, SL("decapitalize"), SL("Phalcon\\Support\\Helper\\Str\\Decapitalize")); + add_assoc_stringl_ex(return_value, SL("decrement"), SL("Phalcon\\Support\\Helper\\Str\\Decrement")); + add_assoc_stringl_ex(return_value, SL("dirFromFile"), SL("Phalcon\\Support\\Helper\\Str\\DirFromFile")); + add_assoc_stringl_ex(return_value, SL("dirSeparator"), SL("Phalcon\\Support\\Helper\\Str\\DirSeparator")); + add_assoc_stringl_ex(return_value, SL("dynamic"), SL("Phalcon\\Support\\Helper\\Str\\Dynamic")); + add_assoc_stringl_ex(return_value, SL("endsWith"), SL("Phalcon\\Support\\Helper\\Str\\EndsWith")); + add_assoc_stringl_ex(return_value, SL("firstBetween"), SL("Phalcon\\Support\\Helper\\Str\\FirstBetween")); + add_assoc_stringl_ex(return_value, SL("friendly"), SL("Phalcon\\Support\\Helper\\Str\\Friendly")); + add_assoc_stringl_ex(return_value, SL("humanize"), SL("Phalcon\\Support\\Helper\\Str\\Humanize")); + add_assoc_stringl_ex(return_value, SL("includes"), SL("Phalcon\\Support\\Helper\\Str\\Includes")); + add_assoc_stringl_ex(return_value, SL("increment"), SL("Phalcon\\Support\\Helper\\Str\\Increment")); + add_assoc_stringl_ex(return_value, SL("interpolate"), SL("Phalcon\\Support\\Helper\\Str\\Interpolate")); + add_assoc_stringl_ex(return_value, SL("isAnagram"), SL("Phalcon\\Support\\Helper\\Str\\IsAnagram")); + add_assoc_stringl_ex(return_value, SL("isLower"), SL("Phalcon\\Support\\Helper\\Str\\IsLower")); + add_assoc_stringl_ex(return_value, SL("isPalindrome"), SL("Phalcon\\Support\\Helper\\Str\\IsPalindrome")); + add_assoc_stringl_ex(return_value, SL("isUpper"), SL("Phalcon\\Support\\Helper\\Str\\IsUpper")); + add_assoc_stringl_ex(return_value, SL("kebabCase"), SL("Phalcon\\Support\\Helper\\Str\\KebabCase")); + add_assoc_stringl_ex(return_value, SL("len"), SL("Phalcon\\Support\\Helper\\Str\\Len")); + add_assoc_stringl_ex(return_value, SL("lower"), SL("Phalcon\\Support\\Helper\\Str\\Lower")); + add_assoc_stringl_ex(return_value, SL("pascalCase"), SL("Phalcon\\Support\\Helper\\Str\\PascalCase")); + add_assoc_stringl_ex(return_value, SL("prefix"), SL("Phalcon\\Support\\Helper\\Str\\Prefix")); + add_assoc_stringl_ex(return_value, SL("random"), SL("Phalcon\\Support\\Helper\\Str\\Random")); + add_assoc_stringl_ex(return_value, SL("reduceSlashes"), SL("Phalcon\\Support\\Helper\\Str\\ReduceSlashes")); + add_assoc_stringl_ex(return_value, SL("snakeCase"), SL("Phalcon\\Support\\Helper\\Str\\SnakeCase")); + add_assoc_stringl_ex(return_value, SL("startsWith"), SL("Phalcon\\Support\\Helper\\Str\\StartsWith")); + add_assoc_stringl_ex(return_value, SL("suffix"), SL("Phalcon\\Support\\Helper\\Str\\Suffix")); + add_assoc_stringl_ex(return_value, SL("ucwords"), SL("Phalcon\\Support\\Helper\\Str\\Ucwords")); + add_assoc_stringl_ex(return_value, SL("uncamelize"), SL("Phalcon\\Support\\Helper\\Str\\Uncamelize")); + add_assoc_stringl_ex(return_value, SL("underscore"), SL("Phalcon\\Support\\Helper\\Str\\Underscore")); + add_assoc_stringl_ex(return_value, SL("upper"), SL("Phalcon\\Support\\Helper\\Str\\Upper")); + return; } @@ -137865,1882 +137821,2028 @@ zend_object *zephir_init_properties_Phalcon_Annotations_Annotation(zend_class_en -ZEPHIR_INIT_CLASS(Phalcon_Annotations_AnnotationsFactory) +ZEPHIR_INIT_CLASS(Phalcon_Support_Registry) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Annotations, AnnotationsFactory, phalcon, annotations_annotationsfactory, phalcon_factory_abstractfactory_ce, phalcon_annotations_annotationsfactory_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support, Registry, phalcon, support_registry, phalcon_support_collection_ce, phalcon_support_registry_method_entry, ZEND_ACC_FINAL_CLASS); return SUCCESS; } -static PHP_METHOD(Phalcon_Annotations_AnnotationsFactory, __construct) +static PHP_METHOD(Phalcon_Support_Registry, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *services_param = NULL; - zval services; - zval *this_ptr = getThis(); + zval *data_param = NULL; + zval data; - ZVAL_UNDEF(&services); + ZVAL_UNDEF(&data); ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(services) + Z_PARAM_ARRAY(data) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &services_param); - if (!services_param) { - ZEPHIR_INIT_VAR(&services); - array_init(&services); + zephir_fetch_params(1, 0, 1, &data_param); + if (!data_param) { + ZEPHIR_INIT_VAR(&data); + array_init(&data); } else { - ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); + ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); + ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "__construct", NULL, 0, &data); zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Annotations_AnnotationsFactory, load) +static PHP_METHOD(Phalcon_Support_Registry, __get) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *config = NULL, config_sub, name, options, _0, _1, _2, _3; - zval *this_ptr = getThis(); + zval *element_param = NULL; + zval element; - ZVAL_UNDEF(&config_sub); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&element); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(config) + Z_PARAM_STR(element) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &config); - ZEPHIR_SEPARATE_PARAM(config); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfig", NULL, 0, config); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(config, &_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "adapter"); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfigelement", NULL, 0, config, &_1); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(config, &_0); - zephir_memory_observe(&name); - zephir_array_fetch_string(&name, config, SL("adapter"), PH_NOISY, "phalcon/Annotations/AnnotationsFactory.zep", 48); - zephir_array_unset_string(config, SL("adapter"), PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - object_init_ex(&_1, phalcon_support_helper_arr_get_ce); - if (zephir_has_constructor(&_1)) { - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 0); - zephir_check_call_status(); + zephir_fetch_params(1, 1, 0, &element_param); + if (UNEXPECTED(Z_TYPE_P(element_param) != IS_STRING && Z_TYPE_P(element_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'element' must be of the type string")); + RETURN_MM_NULL(); } - - ZEPHIR_INIT_VAR(&_2); - array_init(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "options"); - ZEPHIR_CALL_METHOD(&options, &_1, "__invoke", NULL, 159, config, &_3, &_2); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "newinstance", NULL, 0, &name, &options); + if (EXPECTED(Z_TYPE_P(element_param) == IS_STRING)) { + zephir_get_strval(&element, element_param); + } else { + ZEPHIR_INIT_VAR(&element); + } + ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "get", NULL, 0, &element); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Annotations_AnnotationsFactory, newInstance) +static PHP_METHOD(Phalcon_Support_Registry, __isset) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval options, _0; - zval *name_param = NULL, *options_param = NULL, definition; - zval name; - zval *this_ptr = getThis(); + zval *element_param = NULL; + zval element; - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&definition); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(name) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZVAL_UNDEF(&element); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(element) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &name_param, &options_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + zephir_fetch_params(1, 1, 0, &element_param); + if (UNEXPECTED(Z_TYPE_P(element_param) != IS_STRING && Z_TYPE_P(element_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'element' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); + if (EXPECTED(Z_TYPE_P(element_param) == IS_STRING)) { + zephir_get_strval(&element, element_param); } else { - ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + ZEPHIR_INIT_VAR(&element); } - ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 1, 0); - zephir_array_fast_append(&_0, &options); - ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(return_value, &definition, &_0); + ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "has", NULL, 0, &element); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Annotations_AnnotationsFactory, getExceptionClass) -{ - - RETURN_STRING("Phalcon\\Annotations\\Exception"); -} - -static PHP_METHOD(Phalcon_Annotations_AnnotationsFactory, getServices) -{ - - zephir_create_array(return_value, 3, 0); - add_assoc_stringl_ex(return_value, SL("apcu"), SL("Phalcon\\Annotations\\Adapter\\Apcu")); - add_assoc_stringl_ex(return_value, SL("memory"), SL("Phalcon\\Annotations\\Adapter\\Memory")); - add_assoc_stringl_ex(return_value, SL("stream"), SL("Phalcon\\Annotations\\Adapter\\Stream")); - return; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Annotations_Collection) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Annotations, Collection, phalcon, annotations_collection, phalcon_annotations_collection_method_entry, 0); - - zend_declare_property_null(phalcon_annotations_collection_ce, SL("annotations"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_annotations_collection_ce, SL("position"), 0, ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_annotations_collection_ce, 1, zend_ce_iterator); - zend_class_implements(phalcon_annotations_collection_ce, 1, zend_ce_countable); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Annotations_Collection, __construct) +static PHP_METHOD(Phalcon_Support_Registry, __set) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *reflectionData_param = NULL, annotations, annotationData, *_0, _1, _2$$3, _4$$4; - zval reflectionData; - zval *this_ptr = getThis(); + zval *element_param = NULL, *value, value_sub; + zval element; - ZVAL_UNDEF(&reflectionData); - ZVAL_UNDEF(&annotations); - ZVAL_UNDEF(&annotationData); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$4); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(reflectionData) + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(element) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &reflectionData_param); - if (!reflectionData_param) { - ZEPHIR_INIT_VAR(&reflectionData); - array_init(&reflectionData); - } else { - zephir_get_arrval(&reflectionData, reflectionData_param); + zephir_fetch_params(1, 2, 0, &element_param, &value); + if (UNEXPECTED(Z_TYPE_P(element_param) != IS_STRING && Z_TYPE_P(element_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'element' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_INIT_VAR(&annotations); - array_init(&annotations); - zephir_is_iterable(&reflectionData, 0, "phalcon/Annotations/Collection.zep", 58); - if (Z_TYPE_P(&reflectionData) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&reflectionData), _0) - { - ZEPHIR_INIT_NVAR(&annotationData); - ZVAL_COPY(&annotationData, _0); - ZEPHIR_INIT_NVAR(&_2$$3); - object_init_ex(&_2$$3, phalcon_annotations_annotation_ce); - ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", &_3, 158, &annotationData); - zephir_check_call_status(); - zephir_array_append(&annotations, &_2$$3, PH_SEPARATE, "phalcon/Annotations/Collection.zep", 55); - } ZEND_HASH_FOREACH_END(); + if (EXPECTED(Z_TYPE_P(element_param) == IS_STRING)) { + zephir_get_strval(&element, element_param); } else { - ZEPHIR_CALL_METHOD(NULL, &reflectionData, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &reflectionData, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&annotationData, &reflectionData, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_4$$4); - object_init_ex(&_4$$4, phalcon_annotations_annotation_ce); - ZEPHIR_CALL_METHOD(NULL, &_4$$4, "__construct", &_3, 158, &annotationData); - zephir_check_call_status(); - zephir_array_append(&annotations, &_4$$4, PH_SEPARATE, "phalcon/Annotations/Collection.zep", 55); - ZEPHIR_CALL_METHOD(NULL, &reflectionData, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&element); } - ZEPHIR_INIT_NVAR(&annotationData); - zephir_update_property_zval(this_ptr, ZEND_STRL("annotations"), &annotations); + ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "set", NULL, 0, &element, value); + zephir_check_call_status(); ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Annotations_Collection, count) +static PHP_METHOD(Phalcon_Support_Registry, __unset) { - zval _0; - zval *this_ptr = getThis(); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *element_param = NULL; + zval element; - ZVAL_UNDEF(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("annotations"), PH_NOISY_CC | PH_READONLY); - RETURN_LONG(zephir_fast_count_int(&_0)); + ZVAL_UNDEF(&element); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(element) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &element_param); + if (UNEXPECTED(Z_TYPE_P(element_param) != IS_STRING && Z_TYPE_P(element_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'element' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(element_param) == IS_STRING)) { + zephir_get_strval(&element, element_param); + } else { + ZEPHIR_INIT_VAR(&element); + } + ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "remove", NULL, 0, &element); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Annotations_Collection, current) +static PHP_METHOD(Phalcon_Support_Registry, clear) { - zval annotation, _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&annotation); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + zend_long ZEPHIR_LAST_CALL_STATUS; ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_memory_observe(&annotation); - zephir_read_property(&_0, this_ptr, ZEND_STRL("annotations"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_1, this_ptr, ZEND_STRL("position"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&annotation, &_0, &_1, 0))) { - RETURN_MM_BOOL(0); - } - RETURN_CCTOR(&annotation); + ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "clear", NULL, 0); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Annotations_Collection, get) +static PHP_METHOD(Phalcon_Support_Registry, count) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, annotation, annotations, _0, *_1, _2, _5, _3$$3, _4$$5; - zval name, _6; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&annotation); - ZVAL_UNDEF(&annotations); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$5); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - zephir_get_strval(&name, name_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("annotations"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&annotations, &_0); - zephir_is_iterable(&annotations, 0, "phalcon/Annotations/Collection.zep", 98); - if (Z_TYPE_P(&annotations) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&annotations), _1) - { - ZEPHIR_INIT_NVAR(&annotation); - ZVAL_COPY(&annotation, _1); - ZEPHIR_CALL_METHOD(&_3$$3, &annotation, "getname", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_EQUAL(&name, &_3$$3)) { - RETURN_CCTOR(&annotation); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &annotations, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &annotations, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&annotation, &annotations, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$5, &annotation, "getname", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_EQUAL(&name, &_4$$5)) { - RETURN_CCTOR(&annotation); - } - ZEPHIR_CALL_METHOD(NULL, &annotations, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&annotation); - ZEPHIR_INIT_VAR(&_5); - object_init_ex(&_5, phalcon_annotations_exception_ce); - ZEPHIR_INIT_VAR(&_6); - ZEPHIR_CONCAT_SVS(&_6, "Collection doesn't have an annotation called '", &name, "'"); - ZEPHIR_CALL_METHOD(NULL, &_5, "__construct", NULL, 33, &_6); + + ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "count", NULL, 0); zephir_check_call_status(); - zephir_throw_exception_debug(&_5, "phalcon/Annotations/Collection.zep", 100); - ZEPHIR_MM_RESTORE(); - return; + RETURN_MM(); } -static PHP_METHOD(Phalcon_Annotations_Collection, getAll) +static PHP_METHOD(Phalcon_Support_Registry, get) { - zval found; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, annotations, annotation, _0, *_1, _2, _3$$3, _4$$5; - zval name; - zval *this_ptr = getThis(); + zval *element_param = NULL, *defaultValue = NULL, defaultValue_sub, *cast_param = NULL, __$null; + zval element, cast; - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&annotations); - ZVAL_UNDEF(&annotation); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&found); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&cast); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(element) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(defaultValue) + Z_PARAM_STR_OR_NULL(cast) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - zephir_get_strval(&name, name_param); - ZEPHIR_INIT_VAR(&found); - array_init(&found); - zephir_read_property(&_0, this_ptr, ZEND_STRL("annotations"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&annotations, &_0); - zephir_is_iterable(&annotations, 0, "phalcon/Annotations/Collection.zep", 120); - if (Z_TYPE_P(&annotations) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&annotations), _1) - { - ZEPHIR_INIT_NVAR(&annotation); - ZVAL_COPY(&annotation, _1); - ZEPHIR_CALL_METHOD(&_3$$3, &annotation, "getname", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_EQUAL(&name, &_3$$3)) { - zephir_array_append(&found, &annotation, PH_SEPARATE, "phalcon/Annotations/Collection.zep", 116); - } - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 1, 2, &element_param, &defaultValue, &cast_param); + if (UNEXPECTED(Z_TYPE_P(element_param) != IS_STRING && Z_TYPE_P(element_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'element' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(element_param) == IS_STRING)) { + zephir_get_strval(&element, element_param); } else { - ZEPHIR_CALL_METHOD(NULL, &annotations, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &annotations, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&annotation, &annotations, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$5, &annotation, "getname", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_EQUAL(&name, &_4$$5)) { - zephir_array_append(&found, &annotation, PH_SEPARATE, "phalcon/Annotations/Collection.zep", 116); - } - ZEPHIR_CALL_METHOD(NULL, &annotations, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&element); } - ZEPHIR_INIT_NVAR(&annotation); - RETURN_CTOR(&found); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } + if (!cast_param) { + ZEPHIR_INIT_VAR(&cast); + } else { + if (UNEXPECTED(Z_TYPE_P(cast_param) != IS_STRING && Z_TYPE_P(cast_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'cast' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(cast_param) == IS_STRING)) { + zephir_get_strval(&cast, cast_param); + } else { + ZEPHIR_INIT_VAR(&cast); + } + } + ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "get", NULL, 0, &element, defaultValue, &cast); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Annotations_Collection, getAnnotations) +static PHP_METHOD(Phalcon_Support_Registry, getIterator) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - RETURN_MEMBER(getThis(), "annotations"); + ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "getiterator", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Annotations_Collection, has) +static PHP_METHOD(Phalcon_Support_Registry, has) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, annotations, annotation, _0, *_1, _2, _3$$3, _4$$5; - zval name; - zval *this_ptr = getThis(); + zval *element_param = NULL; + zval element; - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&annotations); - ZVAL_UNDEF(&annotation); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&element); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + Z_PARAM_STR(element) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - zephir_get_strval(&name, name_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("annotations"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&annotations, &_0); - zephir_is_iterable(&annotations, 0, "phalcon/Annotations/Collection.zep", 146); - if (Z_TYPE_P(&annotations) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&annotations), _1) - { - ZEPHIR_INIT_NVAR(&annotation); - ZVAL_COPY(&annotation, _1); - ZEPHIR_CALL_METHOD(&_3$$3, &annotation, "getname", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_EQUAL(&name, &_3$$3)) { - RETURN_MM_BOOL(1); - } - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 1, 0, &element_param); + if (UNEXPECTED(Z_TYPE_P(element_param) != IS_STRING && Z_TYPE_P(element_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'element' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(element_param) == IS_STRING)) { + zephir_get_strval(&element, element_param); } else { - ZEPHIR_CALL_METHOD(NULL, &annotations, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &annotations, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&annotation, &annotations, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$5, &annotation, "getname", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_IS_EQUAL(&name, &_4$$5)) { - RETURN_MM_BOOL(1); - } - ZEPHIR_CALL_METHOD(NULL, &annotations, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&element); } - ZEPHIR_INIT_NVAR(&annotation); - RETURN_MM_BOOL(0); + ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "has", NULL, 0, &element); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Annotations_Collection, key) +static PHP_METHOD(Phalcon_Support_Registry, init) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *data_param = NULL; + zval data; - RETURN_MEMBER(getThis(), "position"); -} - -static PHP_METHOD(Phalcon_Annotations_Collection, next) -{ - zval *this_ptr = getThis(); - RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("position"))); + ZVAL_UNDEF(&data); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(data) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &data_param); + if (!data_param) { + ZEPHIR_INIT_VAR(&data); + array_init(&data); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); + } + ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "init", NULL, 0, &data); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Annotations_Collection, rewind) +static PHP_METHOD(Phalcon_Support_Registry, jsonSerialize) { - zval _0; - zval *this_ptr = getThis(); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_0); - ZVAL_LONG(&_0, 0); - zephir_update_property_zval(this_ptr, ZEND_STRL("position"), &_0); + ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "jsonserialize", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Annotations_Collection, valid) +static PHP_METHOD(Phalcon_Support_Registry, offsetExists) { - zval _0, _1; - zval *this_ptr = getThis(); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *element, element_sub; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - zephir_read_property(&_0, this_ptr, ZEND_STRL("annotations"), PH_NOISY_CC | PH_READONLY); - zephir_read_property(&_1, this_ptr, ZEND_STRL("position"), PH_NOISY_CC | PH_READONLY); - RETURN_BOOL(zephir_array_isset(&_0, &_1)); + ZVAL_UNDEF(&element_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(element) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &element); + ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "has", NULL, 0, element); + zephir_check_call_status(); + RETURN_MM(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Annotations_Exception) +static PHP_METHOD(Phalcon_Support_Registry, offsetGet) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Annotations, Exception, phalcon, annotations_exception, zend_ce_exception, NULL, 0); - - return SUCCESS; -} - - - -/* Driver template for the LEMON parser generator. -** The author disclaims copyright to this source code. -*/ -/* First off, code is include which follows the "include" declaration -** in the input file. */ -// 18 "parser.php.lemon" - - -// 12 "parser.php.c" -/* Next is all token values, in a form suitable for use by makeheaders. -** This section will be null unless lemon is run with the -m switch. -*/ -/* Make sure the INTERFACE macro is defined. -*/ -#ifndef INTERFACE -# define INTERFACE 1 -#endif -/* The next thing included is series of defines which control -** various aspects of the generated parser. -** AACODETYPE is the data type used for storing terminal -** and nonterminal numbers. "unsigned char" is -** used if there are fewer than 250 terminals -** and nonterminals. "int" is used otherwise. -** AANOCODE is a number of type AACODETYPE which corresponds -** to no legal terminal or nonterminal number. This -** number is used to fill in empty slots of the hash -** table. -** AAFALLBACK If defined, this indicates that one or more tokens -** have fall-back values which should be used if the -** original value of the token will not parse. -** AAACTIONTYPE is the data type used for storing terminal -** and nonterminal numbers. "unsigned char" is -** used if there are fewer than 250 rules and -** states combined. "int" is used otherwise. -** phannot_TOKENTYPE is the data type used for minor tokens given -** directly to the parser from the tokenizer. -** AAMINORTYPE is the data type used for all minor tokens. -** This is typically a union of many types, one of -** which is phannot_TOKENTYPE. The entry in the union -** for base tokens is called "aa0". -** AASTACKDEPTH is the maximum depth of the parser's stack. -** phannot_ARG_SDECL A static variable declaration for the %extra_argument -** phannot_ARG_PDECL A parameter declaration for the %extra_argument -** phannot_ARG_STORE Code to store %extra_argument into aapParser -** phannot_ARG_FETCH Code to extract %extra_argument from aapParser -** AANSTATE the combined number of states. -** AANRULE the number of rules in the grammar -** AAERRORSYMBOL is the code number of the error symbol. If not -** defined, then do no error processing. -*/ -#define AACODETYPE unsigned char -#define AANOCODE 28 -#define AAACTIONTYPE unsigned char -#define phannot_TOKENTYPE phannot_parser_token* -typedef union { - phannot_TOKENTYPE aa0; - zval aa8; - int aa55; -} AAMINORTYPE; -#define AASTACKDEPTH 100 -#define phannot_ARG_SDECL phannot_parser_status *status; -#define phannot_ARG_PDECL ,phannot_parser_status *status -#define phannot_ARG_FETCH phannot_parser_status *status = aapParser->status -#define phannot_ARG_STORE aapParser->status = status -#define AANSTATE 40 -#define AANRULE 25 -#define AAERRORSYMBOL 18 -#define AAERRSYMDT aa55 -#define AA_NO_ACTION (AANSTATE+AANRULE+2) -#define AA_ACCEPT_ACTION (AANSTATE+AANRULE+1) -#define AA_ERROR_ACTION (AANSTATE+AANRULE) - -/* Next are that tables used to determine what action to take based on the -** current state and lookahead token. These tables are used to implement -** functions that take a state number and lookahead value and return an -** action integer. -** -** Suppose the action integer is N. Then the action is determined as -** follows -** -** 0 <= N < AANSTATE Shift N. That is, push the lookahead -** token onto the stack and goto state N. -** -** AANSTATE <= N < AANSTATE+AANRULE Reduce by rule N-AANSTATE. -** -** N == AANSTATE+AANRULE A syntax error has occurred. -** -** N == AANSTATE+AANRULE+1 The parser accepts its input. -** -** N == AANSTATE+AANRULE+2 No such action. Denotes unused -** slots in the aa_action[] table. -** -** The action table is constructed as a single large table named aa_action[]. -** Given state S and lookahead X, the action is computed as -** -** aa_action[ aa_shift_ofst[S] + X ] -** -** If the index value aa_shift_ofst[S]+X is out of range or if the value -** aa_lookahead[aa_shift_ofst[S]+X] is not equal to X or if aa_shift_ofst[S] -** is equal to AA_SHIFT_USE_DFLT, it means that the action is not in the table -** and that aa_default[S] should be used instead. -** -** The formula above is for computing the action when the lookahead is -** a terminal symbol. If the lookahead is a non-terminal (as occurs after -** a reduce action) then the aa_reduce_ofst[] array is used in place of -** the aa_shift_ofst[] array and AA_REDUCE_USE_DFLT is used in place of -** AA_SHIFT_USE_DFLT. -** -** The following are the tables generated in this section: -** -** aa_action[] A single table containing all actions. -** aa_lookahead[] A table containing the lookahead for each entry in -** aa_action. Used to detect hash collisions. -** aa_shift_ofst[] For each state, the offset into aa_action for -** shifting terminals. -** aa_reduce_ofst[] For each state, the offset into aa_action for -** shifting non-terminals after a reduce. -** aa_default[] Default action for each state. -*/ -static AAACTIONTYPE aa_action[] = { - /* 0 */ 4, 28, 15, 38, 12, 14, 16, 18, 20, 21, - /* 10 */ 22, 23, 24, 4, 31, 4, 28, 15, 40, 12, - /* 20 */ 30, 16, 18, 20, 21, 22, 23, 24, 3, 31, - /* 30 */ 4, 17, 15, 6, 19, 35, 16, 18, 20, 21, - /* 40 */ 22, 23, 24, 5, 31, 15, 7, 27, 11, 16, - /* 50 */ 54, 54, 15, 25, 27, 11, 16, 15, 32, 27, - /* 60 */ 11, 16, 66, 1, 2, 39, 41, 15, 4, 10, - /* 70 */ 11, 16, 15, 9, 9, 37, 16, 8, 13, 36, - /* 80 */ 9, 29, 34, 54, 54, 54, 54, 54, 26, 54, - /* 90 */ 54, 54, 54, 54, 54, 54, 33, -}; -static AACODETYPE aa_lookahead[] = { - /* 0 */ 2, 3, 22, 5, 6, 25, 26, 9, 10, 11, - /* 10 */ 12, 13, 14, 2, 16, 2, 3, 22, 0, 6, - /* 20 */ 25, 26, 9, 10, 11, 12, 13, 14, 22, 16, - /* 30 */ 2, 3, 22, 4, 6, 25, 26, 9, 10, 11, - /* 40 */ 12, 13, 14, 3, 16, 22, 23, 24, 25, 26, - /* 50 */ 27, 27, 22, 23, 24, 25, 26, 22, 23, 24, - /* 60 */ 25, 26, 19, 20, 21, 22, 0, 22, 2, 24, - /* 70 */ 25, 26, 22, 1, 1, 25, 26, 5, 7, 8, - /* 80 */ 1, 7, 8, 27, 27, 27, 27, 27, 15, 27, - /* 90 */ 27, 27, 27, 27, 27, 27, 17, -}; -#define AA_SHIFT_USE_DFLT (-3) -static signed char aa_shift_ofst[] = { - /* 0 */ 11, 18, 66, -3, 40, 29, -2, 72, -3, 13, - /* 10 */ -3, -3, 71, 28, -3, -3, -3, -3, -3, -3, - /* 20 */ -3, -3, -3, -3, 13, 73, -3, -3, 74, 28, - /* 30 */ -3, 13, 79, -3, 28, -3, 28, -3, -3, -3, -}; -#define AA_REDUCE_USE_DFLT (-21) -static signed char aa_reduce_ofst[] = { - /* 0 */ 43, -21, 6, -21, -21, -21, 23, -21, -21, 45, - /* 10 */ -21, -21, -21, -20, -21, -21, -21, -21, -21, -21, - /* 20 */ -21, -21, -21, -21, 30, -21, -21, -21, -21, -5, - /* 30 */ -21, 35, -21, -21, 10, -21, 50, -21, -21, -21, -}; -static AAACTIONTYPE aa_default[] = { - /* 0 */ 65, 65, 65, 42, 65, 46, 65, 65, 44, 65, - /* 10 */ 47, 49, 58, 65, 50, 54, 55, 56, 57, 58, - /* 20 */ 59, 60, 61, 62, 65, 65, 63, 48, 56, 65, - /* 30 */ 52, 65, 65, 64, 65, 53, 65, 51, 45, 43, -}; -#define AA_SZ_ACTTAB (sizeof(aa_action)/sizeof(aa_action[0])) - -/* The next table maps tokens into fallback tokens. If a construct -** like the following: -** -** %fallback ID X Y Z. -** -** appears in the grammer, then ID becomes a fallback token for X, Y, -** and Z. Whenever one of the tokens X, Y, or Z is input to the parser -** but it does not parse, the type of the token is changed to ID and -** the parse is retried before an error is thrown. -*/ -#ifdef AAFALLBACK -static const AACODETYPE aaFallback[] = { -}; -#endif /* AAFALLBACK */ - -/* The following structure represents a single element of the -** parser's stack. Information stored includes: -** -** + The state number for the parser at this level of the stack. -** -** + The value of the token stored at this level of the stack. -** (In other words, the "major" token.) -** -** + The semantic value stored at this level of the stack. This is -** the information used by the action routines in the grammar. -** It is sometimes called the "minor" token. -*/ -struct aaStackEntry { - int stateno; /* The state-number */ - int major; /* The major token value. This is the code - ** number for the token at this stack level */ - AAMINORTYPE minor; /* The user-supplied minor token value. This - ** is the value of the token */ -}; -typedef struct aaStackEntry aaStackEntry; - -/* The state of the parser is completely contained in an instance of -** the following structure */ -struct aaParser { - int aaidx; /* Index of top element in stack */ - int aaerrcnt; /* Shifts left before out of the error */ - phannot_ARG_SDECL /* A place to hold %extra_argument */ - aaStackEntry aastack[AASTACKDEPTH]; /* The parser's stack */ -}; -typedef struct aaParser aaParser; - -#ifndef NDEBUG -static FILE *aaTraceFILE = 0; -static char *aaTracePrompt = 0; -#endif /* NDEBUG */ - -#ifndef NDEBUG -static void phannot_Trace(FILE *TraceFILE, char *zTracePrompt){ - aaTraceFILE = TraceFILE; - aaTracePrompt = zTracePrompt; - if( aaTraceFILE==0 ) aaTracePrompt = 0; - else if( aaTracePrompt==0 ) aaTraceFILE = 0; -} -#endif /* NDEBUG */ - -#ifndef NDEBUG -/* For tracing shifts, the names of all terminals and nonterminals -** are required. The following table supplies these names */ -static const char *aaTokenName[] = { - "$", "COMMA", "AT", "IDENTIFIER", - "PARENTHESES_OPEN", "PARENTHESES_CLOSE", "STRING", "EQUALS", - "COLON", "INTEGER", "DOUBLE", "NULL", - "FALSE", "TRUE", "BRACKET_OPEN", "BRACKET_CLOSE", - "SBRACKET_OPEN", "SBRACKET_CLOSE", "error", "program", - "annotation_language", "annotation_list", "annotation", "argument_list", - "argument_item", "expr", "array", -}; -#endif /* NDEBUG */ - -#ifndef NDEBUG -/* For tracing reduce actions, the names of all rules are required. -*/ -static const char *aaRuleName[] = { - /* 0 */ "program ::= annotation_language", - /* 1 */ "annotation_language ::= annotation_list", - /* 2 */ "annotation_list ::= annotation_list annotation", - /* 3 */ "annotation_list ::= annotation", - /* 4 */ "annotation ::= AT IDENTIFIER PARENTHESES_OPEN argument_list PARENTHESES_CLOSE", - /* 5 */ "annotation ::= AT IDENTIFIER PARENTHESES_OPEN PARENTHESES_CLOSE", - /* 6 */ "annotation ::= AT IDENTIFIER", - /* 7 */ "argument_list ::= argument_list COMMA argument_item", - /* 8 */ "argument_list ::= argument_item", - /* 9 */ "argument_item ::= expr", - /* 10 */ "argument_item ::= STRING EQUALS expr", - /* 11 */ "argument_item ::= STRING COLON expr", - /* 12 */ "argument_item ::= IDENTIFIER EQUALS expr", - /* 13 */ "argument_item ::= IDENTIFIER COLON expr", - /* 14 */ "expr ::= annotation", - /* 15 */ "expr ::= array", - /* 16 */ "expr ::= IDENTIFIER", - /* 17 */ "expr ::= INTEGER", - /* 18 */ "expr ::= STRING", - /* 19 */ "expr ::= DOUBLE", - /* 20 */ "expr ::= NULL", - /* 21 */ "expr ::= FALSE", - /* 22 */ "expr ::= TRUE", - /* 23 */ "array ::= BRACKET_OPEN argument_list BRACKET_CLOSE", - /* 24 */ "array ::= SBRACKET_OPEN argument_list SBRACKET_CLOSE", -}; -#endif /* NDEBUG */ - -const char *phannot_TokenName(int tokenType){ -#ifndef NDEBUG - if( tokenType>0 && tokenType<(sizeof(aaTokenName)/sizeof(aaTokenName[0])) ){ - return aaTokenName[tokenType]; - }else{ - return "Unknown"; - } -#else - return ""; -#endif -} + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval element_sub; + zval *element; -void *phannot_Alloc(void *(*mallocProc)(size_t)){ - aaParser *pParser; - pParser = (aaParser*)(*mallocProc)( (size_t)sizeof(aaParser) ); - if( pParser ){ - pParser->aaidx = -1; - } - return pParser; + ZVAL_UNDEF(&element_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(element) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &element); + ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "get", NULL, 0, element); + zephir_check_call_status(); + RETURN_MM(); } -/* The following function deletes the value associated with a -** symbol. The symbol can be either a terminal or nonterminal. -** "aamajor" is the symbol code, and "aapminor" is a pointer to -** the value. -*/ -static void aa_destructor(AACODETYPE aamajor, AAMINORTYPE *aapminor){ - switch( aamajor ){ - /* Here is inserted the actions which take place when a - ** terminal or non-terminal is destroyed. This can happen - ** when the symbol is popped from the stack during a - ** reduce or during error processing or when a parser is - ** being destroyed before it is finished parsing. - ** - ** Note: during a reduce, the only symbols destroyed are those - ** which appear on the RHS of the rule, but which are not used - ** inside the C code. - */ - case 1: - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - case 13: - case 14: - case 15: - case 16: - case 17: -// 67 "parser.php.lemon" -{ - if ((aapminor->aa0)) { - if ((aapminor->aa0)->free_flag) { - efree((aapminor->aa0)->token); - } - efree((aapminor->aa0)); - } -} -// 380 "parser.php.c" - break; - case 20: - case 21: - case 22: - case 23: - case 24: - case 25: -// 80 "parser.php.lemon" +static PHP_METHOD(Phalcon_Support_Registry, offsetSet) { - zval_ptr_dtor(&(aapminor->aa8)); -} -// 392 "parser.php.c" - break; - default: break; /* If no destructor action specified: do nothing */ - } -} - -static int aa_pop_parser_stack(aaParser *pParser){ - AACODETYPE aamajor; - aaStackEntry *aatos = &pParser->aastack[pParser->aaidx]; - - if( pParser->aaidx<0 ) return 0; -#ifndef NDEBUG - if( aaTraceFILE && pParser->aaidx>=0 ){ - fprintf(aaTraceFILE,"%sPopping %s\n", - aaTracePrompt, - aaTokenName[aatos->major]); - } -#endif - aamajor = aatos->major; - aa_destructor( aamajor, &aatos->minor); - pParser->aaidx--; - return aamajor; -} + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *offset, offset_sub, *value, value_sub; -static void phannot_Free( - void *p, /* The parser to be deleted */ - void (*freeProc)(void*) /* Function used to reclaim memory */ -){ - aaParser *pParser = (aaParser*)p; - if( pParser==0 ) return; - while( pParser->aaidx>=0 ) aa_pop_parser_stack(pParser); - (*freeProc)((void*)pParser); + ZVAL_UNDEF(&offset_sub); + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(offset) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &offset, &value); + ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "set", NULL, 0, offset, value); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static int aa_find_shift_action( - aaParser *pParser, /* The parser */ - int iLookAhead /* The look-ahead token */ -){ - int i; - int stateno = pParser->aastack[pParser->aaidx].stateno; +static PHP_METHOD(Phalcon_Support_Registry, offsetUnset) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *element, element_sub; - /* if( pParser->aaidx<0 ) return AA_NO_ACTION; */ - i = aa_shift_ofst[stateno]; - if( i==AA_SHIFT_USE_DFLT ){ - return aa_default[stateno]; - } - if( iLookAhead==AANOCODE ){ - return AA_NO_ACTION; - } - i += iLookAhead; - if( i<0 || i>=AA_SZ_ACTTAB || aa_lookahead[i]!=iLookAhead ){ -#ifdef AAFALLBACK - int iFallback; /* Fallback token */ - if( iLookAhead %s\n", - aaTracePrompt, aaTokenName[iLookAhead], aaTokenName[iFallback]); - } -#endif - return aa_find_shift_action(pParser, iFallback); - } -#endif - return aa_default[stateno]; - }else{ - return aa_action[i]; - } + ZVAL_UNDEF(&element_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(element) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &element); + ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "remove", NULL, 0, element); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static int aa_find_reduce_action( - aaParser *pParser, /* The parser */ - int iLookAhead /* The look-ahead token */ -){ - int i; - int stateno = pParser->aastack[pParser->aaidx].stateno; - - i = aa_reduce_ofst[stateno]; - if( i==AA_REDUCE_USE_DFLT ){ - return aa_default[stateno]; - } - if( iLookAhead==AANOCODE ){ - return AA_NO_ACTION; - } - i += iLookAhead; - if( i<0 || i>=AA_SZ_ACTTAB || aa_lookahead[i]!=iLookAhead ){ - return aa_default[stateno]; - }else{ - return aa_action[i]; - } -} +static PHP_METHOD(Phalcon_Support_Registry, remove) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *element_param = NULL; + zval element; -static void aa_shift( - aaParser *aapParser, /* The parser to be shifted */ - int aaNewState, /* The new state to shift in */ - int aaMajor, /* The major token to shift in */ - AAMINORTYPE *aapMinor /* Pointer ot the minor token to shift in */ -){ - aaStackEntry *aatos; - aapParser->aaidx++; - if( aapParser->aaidx>=AASTACKDEPTH ){ - phannot_ARG_FETCH; - aapParser->aaidx--; -#ifndef NDEBUG - if( aaTraceFILE ){ - fprintf(aaTraceFILE,"%sStack Overflow!\n",aaTracePrompt); - } -#endif - while( aapParser->aaidx>=0 ) aa_pop_parser_stack(aapParser); - /* Here code is inserted which will execute if the parser - ** stack every overflows */ - phannot_ARG_STORE; /* Suppress warning about unused %extra_argument var */ - return; - } - aatos = &aapParser->aastack[aapParser->aaidx]; - aatos->stateno = aaNewState; - aatos->major = aaMajor; - aatos->minor = *aapMinor; -#ifndef NDEBUG - if( aaTraceFILE && aapParser->aaidx>0 ){ - int i; - fprintf(aaTraceFILE,"%sShift %d\n",aaTracePrompt,aaNewState); - fprintf(aaTraceFILE,"%sStack:",aaTracePrompt); - for(i=1; i<=aapParser->aaidx; i++) - fprintf(aaTraceFILE," %s",aaTokenName[aapParser->aastack[i].major]); - fprintf(aaTraceFILE,"\n"); - } -#endif + ZVAL_UNDEF(&element); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(element) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &element_param); + if (UNEXPECTED(Z_TYPE_P(element_param) != IS_STRING && Z_TYPE_P(element_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'element' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(element_param) == IS_STRING)) { + zephir_get_strval(&element, element_param); + } else { + ZEPHIR_INIT_VAR(&element); + } + ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "remove", NULL, 0, &element); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -/* The following table contains information about every rule that -** is used during the reduce. -*/ -static struct { - AACODETYPE lhs; /* Symbol on the left-hand side of the rule */ - unsigned char nrhs; /* Number of right-hand side symbols in the rule */ -} aaRuleInfo[] = { - { 19, 1 }, - { 20, 1 }, - { 21, 2 }, - { 21, 1 }, - { 22, 5 }, - { 22, 4 }, - { 22, 2 }, - { 23, 3 }, - { 23, 1 }, - { 24, 1 }, - { 24, 3 }, - { 24, 3 }, - { 24, 3 }, - { 24, 3 }, - { 25, 1 }, - { 25, 1 }, - { 25, 1 }, - { 25, 1 }, - { 25, 1 }, - { 25, 1 }, - { 25, 1 }, - { 25, 1 }, - { 25, 1 }, - { 26, 3 }, - { 26, 3 }, -}; - -static void aa_accept(aaParser*); /* Forward Declaration */ - -static void aa_reduce( - aaParser *aapParser, /* The parser */ - int aaruleno /* Number of the rule by which to reduce */ -){ - int aagoto; /* The next state */ - int aaact; /* The next action */ - AAMINORTYPE aagotominor; /* The LHS of the rule reduced */ - aaStackEntry *aamsp; /* The top of the parser's stack */ - int aasize; /* Amount to pop the stack */ - phannot_ARG_FETCH; - aamsp = &aapParser->aastack[aapParser->aaidx]; -#ifndef NDEBUG - if( aaTraceFILE && aaruleno>=0 - && aaruleno - ** { ... } // User supplied code - ** // - ** break; - */ - case 0: -// 76 "parser.php.lemon" -{ - ZVAL_ZVAL(&status->ret, &aamsp[0].minor.aa8, 1, 1); -} -// 634 "parser.php.c" - break; - case 1: - case 14: - case 15: -// 84 "parser.php.lemon" -{ - aagotominor.aa8 = aamsp[0].minor.aa8; -} -// 643 "parser.php.c" - break; - case 2: -// 92 "parser.php.lemon" -{ - phannot_ret_zval_list(&aagotominor.aa8, &aamsp[-1].minor.aa8, &aamsp[0].minor.aa8); -} -// 650 "parser.php.c" - break; - case 3: - case 8: -// 96 "parser.php.lemon" -{ - phannot_ret_zval_list(&aagotominor.aa8, NULL, &aamsp[0].minor.aa8); -} -// 658 "parser.php.c" - break; - case 4: -// 104 "parser.php.lemon" -{ - phannot_ret_annotation(&aagotominor.aa8, aamsp[-3].minor.aa0, &aamsp[-1].minor.aa8, status->scanner_state); - aa_destructor(2,&aamsp[-4].minor); - aa_destructor(4,&aamsp[-2].minor); - aa_destructor(5,&aamsp[0].minor); -} -// 668 "parser.php.c" - break; - case 5: -// 108 "parser.php.lemon" -{ - phannot_ret_annotation(&aagotominor.aa8, aamsp[-2].minor.aa0, NULL, status->scanner_state); - aa_destructor(2,&aamsp[-3].minor); - aa_destructor(4,&aamsp[-1].minor); - aa_destructor(5,&aamsp[0].minor); -} -// 678 "parser.php.c" - break; - case 6: -// 112 "parser.php.lemon" -{ - phannot_ret_annotation(&aagotominor.aa8, aamsp[0].minor.aa0, NULL, status->scanner_state); - aa_destructor(2,&aamsp[-1].minor); -} -// 686 "parser.php.c" - break; - case 7: -// 120 "parser.php.lemon" -{ - phannot_ret_zval_list(&aagotominor.aa8, &aamsp[-2].minor.aa8, &aamsp[0].minor.aa8); - aa_destructor(1,&aamsp[-1].minor); -} -// 694 "parser.php.c" - break; - case 9: -// 132 "parser.php.lemon" -{ - phannot_ret_named_item(&aagotominor.aa8, NULL, &aamsp[0].minor.aa8); -} -// 701 "parser.php.c" - break; - case 10: - case 12: -// 136 "parser.php.lemon" +static PHP_METHOD(Phalcon_Support_Registry, serialize) { - phannot_ret_named_item(&aagotominor.aa8, aamsp[-2].minor.aa0, &aamsp[0].minor.aa8); - aa_destructor(7,&aamsp[-1].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "serialize", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -// 710 "parser.php.c" - break; - case 11: - case 13: -// 140 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Support_Registry, set) { - phannot_ret_named_item(&aagotominor.aa8, aamsp[-2].minor.aa0, &aamsp[0].minor.aa8); - aa_destructor(8,&aamsp[-1].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *element_param = NULL, *value, value_sub; + zval element; + + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(element) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &element_param, &value); + if (UNEXPECTED(Z_TYPE_P(element_param) != IS_STRING && Z_TYPE_P(element_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'element' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(element_param) == IS_STRING)) { + zephir_get_strval(&element, element_param); + } else { + ZEPHIR_INIT_VAR(&element); + } + ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "set", NULL, 0, &element, value); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -// 719 "parser.php.c" - break; - case 16: -// 164 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Support_Registry, toArray) { - phannot_ret_literal_zval(&aagotominor.aa8, PHANNOT_T_IDENTIFIER, aamsp[0].minor.aa0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "toarray", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -// 726 "parser.php.c" - break; - case 17: -// 168 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Support_Registry, toJson) { - phannot_ret_literal_zval(&aagotominor.aa8, PHANNOT_T_INTEGER, aamsp[0].minor.aa0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *options_param = NULL, _0; + zend_long options, ZEPHIR_LAST_CALL_STATUS; + + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(options) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &options_param); + if (!options_param) { + options = 79; + } else { + } + ZVAL_LONG(&_0, options); + ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "tojson", NULL, 0, &_0); + zephir_check_call_status(); + RETURN_MM(); } -// 733 "parser.php.c" - break; - case 18: -// 172 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Support_Registry, unserialize) { - phannot_ret_literal_zval(&aagotominor.aa8, PHANNOT_T_STRING, aamsp[0].minor.aa0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *data_param = NULL; + zval data; + + ZVAL_UNDEF(&data); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(data) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &data_param); + zephir_get_strval(&data, data_param); + ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "unserialize", NULL, 0, &data); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -// 740 "parser.php.c" - break; - case 19: -// 176 "parser.php.lemon" + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Version) { - phannot_ret_literal_zval(&aagotominor.aa8, PHANNOT_T_DOUBLE, aamsp[0].minor.aa0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Support, Version, phalcon, support_version, phalcon_support_version_method_entry, 0); + + zephir_declare_class_constant_long(phalcon_support_version_ce, SL("VERSION_MAJOR"), 0); + + zephir_declare_class_constant_long(phalcon_support_version_ce, SL("VERSION_MEDIUM"), 1); + + zephir_declare_class_constant_long(phalcon_support_version_ce, SL("VERSION_MINOR"), 2); + + zephir_declare_class_constant_long(phalcon_support_version_ce, SL("VERSION_SPECIAL"), 3); + + zephir_declare_class_constant_long(phalcon_support_version_ce, SL("VERSION_SPECIAL_NUMBER"), 4); + + return SUCCESS; } -// 747 "parser.php.c" - break; - case 20: -// 180 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Support_Version, getVersion) { - phannot_ret_literal_zval(&aagotominor.aa8, PHANNOT_T_NULL, NULL); - aa_destructor(11,&aamsp[0].minor); + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_create_array(return_value, 5, 0); + ZEPHIR_INIT_VAR(&_0); + ZVAL_LONG(&_0, 5); + zephir_array_fast_append(return_value, &_0); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_LONG(&_0, 8); + zephir_array_fast_append(return_value, &_0); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_LONG(&_0, 0); + zephir_array_fast_append(return_value, &_0); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_LONG(&_0, 4); + zephir_array_fast_append(return_value, &_0); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_LONG(&_0, 0); + zephir_array_fast_append(return_value, &_0); + RETURN_MM(); } -// 755 "parser.php.c" - break; - case 21: -// 184 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Support_Version, getSpecial) { - phannot_ret_literal_zval(&aagotominor.aa8, PHANNOT_T_FALSE, NULL); - aa_destructor(12,&aamsp[0].minor); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *special_param = NULL, suffix; + zend_long special; + + ZVAL_UNDEF(&suffix); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(special) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &special_param); + do { + if (special == 1) { + ZEPHIR_INIT_VAR(&suffix); + ZVAL_STRING(&suffix, "alpha"); + break; + } + if (special == 2) { + ZEPHIR_INIT_NVAR(&suffix); + ZVAL_STRING(&suffix, "beta"); + break; + } + if (special == 3) { + ZEPHIR_INIT_NVAR(&suffix); + ZVAL_STRING(&suffix, "RC"); + break; + } + ZEPHIR_INIT_NVAR(&suffix); + ZVAL_STRING(&suffix, ""); + break; + } while(0); + + RETURN_CCTOR(&suffix); } -// 763 "parser.php.c" - break; - case 22: -// 188 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Support_Version, get) { - phannot_ret_literal_zval(&aagotominor.aa8, PHANNOT_T_TRUE, NULL); - aa_destructor(13,&aamsp[0].minor); + zval result; + zval version, major, medium, minor, special, specialNumber, suffix, _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&version); + ZVAL_UNDEF(&major); + ZVAL_UNDEF(&medium); + ZVAL_UNDEF(&minor); + ZVAL_UNDEF(&special); + ZVAL_UNDEF(&specialNumber); + ZVAL_UNDEF(&suffix); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&result); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_CALL_METHOD(&version, this_ptr, "getversion", NULL, 0); + zephir_check_call_status(); + zephir_memory_observe(&major); + zephir_array_fetch_long(&major, &version, 0, PH_NOISY, "phalcon/Support/Version.zep", 122); + zephir_memory_observe(&medium); + zephir_array_fetch_long(&medium, &version, 1, PH_NOISY, "phalcon/Support/Version.zep", 123); + zephir_memory_observe(&minor); + zephir_array_fetch_long(&minor, &version, 2, PH_NOISY, "phalcon/Support/Version.zep", 124); + zephir_memory_observe(&special); + zephir_array_fetch_long(&special, &version, 3, PH_NOISY, "phalcon/Support/Version.zep", 125); + zephir_memory_observe(&specialNumber); + zephir_array_fetch_long(&specialNumber, &version, 4, PH_NOISY, "phalcon/Support/Version.zep", 126); + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_CONCAT_VSVSV(&_0, &major, ".", &medium, ".", &minor); + zephir_get_strval(&result, &_0); + ZEPHIR_CALL_METHOD(&suffix, this_ptr, "getspecial", NULL, 0, &special); + zephir_check_call_status(); + if (!ZEPHIR_IS_STRING(&suffix, "")) { + zephir_concat_self(&result, &suffix); + if (!ZEPHIR_IS_LONG(&specialNumber, 0)) { + zephir_concat_self(&result, &specialNumber); + } + } + RETURN_CTOR(&result); } -// 771 "parser.php.c" - break; - case 23: -// 192 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Support_Version, getId) { - phannot_ret_array(&aagotominor.aa8, &aamsp[-1].minor.aa8); - aa_destructor(14,&aamsp[-2].minor); - aa_destructor(15,&aamsp[0].minor); + zval version, major, medium, minor, special, specialNumber, _0, _1, _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&version); + ZVAL_UNDEF(&major); + ZVAL_UNDEF(&medium); + ZVAL_UNDEF(&minor); + ZVAL_UNDEF(&special); + ZVAL_UNDEF(&specialNumber); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_CALL_METHOD(&version, this_ptr, "getversion", NULL, 0); + zephir_check_call_status(); + zephir_memory_observe(&major); + zephir_array_fetch_long(&major, &version, 0, PH_NOISY, "phalcon/Support/Version.zep", 160); + zephir_memory_observe(&medium); + zephir_array_fetch_long(&medium, &version, 1, PH_NOISY, "phalcon/Support/Version.zep", 161); + zephir_memory_observe(&minor); + zephir_array_fetch_long(&minor, &version, 2, PH_NOISY, "phalcon/Support/Version.zep", 162); + zephir_memory_observe(&special); + zephir_array_fetch_long(&special, &version, 3, PH_NOISY, "phalcon/Support/Version.zep", 163); + zephir_memory_observe(&specialNumber); + zephir_array_fetch_long(&specialNumber, &version, 4, PH_NOISY, "phalcon/Support/Version.zep", 164); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "%02s"); + ZEPHIR_CALL_FUNCTION(&_1, "sprintf", NULL, 117, &_0, &medium); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "%02s"); + ZEPHIR_CALL_FUNCTION(&_2, "sprintf", NULL, 117, &_0, &minor); + zephir_check_call_status(); + ZEPHIR_CONCAT_VVVVV(return_value, &major, &_1, &_2, &special, &specialNumber); + RETURN_MM(); } -// 780 "parser.php.c" - break; - case 24: -// 196 "parser.php.lemon" + +static PHP_METHOD(Phalcon_Support_Version, getPart) { - phannot_ret_array(&aagotominor.aa8, &aamsp[-1].minor.aa8); - aa_destructor(16,&aamsp[-2].minor); - aa_destructor(17,&aamsp[0].minor); -} -// 789 "parser.php.c" - break; - }; - aagoto = aaRuleInfo[aaruleno].lhs; - aasize = aaRuleInfo[aaruleno].nrhs; - aapParser->aaidx -= aasize; - aaact = aa_find_reduce_action(aapParser,aagoto); - if( aaact < AANSTATE ){ - aa_shift(aapParser,aaact,aagoto,&aagotominor); - }else if( aaact == AANSTATE + AANRULE + 1 ){ - aa_accept(aapParser); - } + zval _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *part_param = NULL, version, _0$$3, _2$$4; + zend_long part, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&version); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(part) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &part_param); + ZEPHIR_CALL_METHOD(&version, this_ptr, "getversion", NULL, 0); + zephir_check_call_status(); + do { + if (part == 0 || part == 1 || part == 2 || part == 4) { + zephir_memory_observe(&_0$$3); + zephir_array_fetch_long(&_0$$3, &version, part, PH_NOISY, "phalcon/Support/Version.zep", 192); + zephir_cast_to_string(&_1$$3, &_0$$3); + RETURN_CTOR(&_1$$3); + } + if (part == 3) { + zephir_array_fetch_long(&_2$$4, &version, 3, PH_NOISY | PH_READONLY, "phalcon/Support/Version.zep", 195); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getspecial", NULL, 0, &_2$$4); + zephir_check_call_status(); + RETURN_MM(); + } + } while(0); + + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static void aa_parse_failed( - aaParser *aapParser /* The parser */ -){ - phannot_ARG_FETCH; -#ifndef NDEBUG - if( aaTraceFILE ){ - fprintf(aaTraceFILE,"%sFail!\n",aaTracePrompt); - } + + + +#ifdef HAVE_CONFIG_H #endif - while( aapParser->aaidx>=0 ) aa_pop_parser_stack(aapParser); - /* Here code is inserted which will be executed whenever the - ** parser fails */ - phannot_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} -static void aa_syntax_error( - aaParser *aapParser, /* The parser */ - int aamajor, /* The major type of the error token */ - AAMINORTYPE aaminor /* The minor type of the error token */ -){ - phannot_ARG_FETCH; -#define ATOKEN (aaminor.aa0) -// 22 "parser.php.lemon" - if (status->scanner_state->start_length) { - char *token_name = NULL; - const phannot_token_names *tokens = phannot_tokens; - int active_token = status->scanner_state->active_token; - unsigned int near_length = status->scanner_state->start_length; - if (active_token) { - do { - if (tokens->code == active_token) { - token_name = tokens->name; - break; - } - ++tokens; - } while (tokens[0].code != 0); - } - if (!token_name) { - token_name = "UNKNOWN"; - } - if (near_length > 0) { - if (status->token->value) { - spprintf(&status->syntax_error, 0, "Syntax error, unexpected token %s(%s), near to '%s' in %s on line %d", token_name, status->token->value, status->scanner_state->start, status->scanner_state->active_file, status->scanner_state->active_line); - } else { - spprintf(&status->syntax_error, 0, "Syntax error, unexpected token %s, near to '%s' in %s on line %d", token_name, status->scanner_state->start, status->scanner_state->active_file, status->scanner_state->active_line); - } - } else { - if (active_token != PHANNOT_T_IGNORE) { - if (status->token->value) { - spprintf(&status->syntax_error, 0, "Syntax error, unexpected token %s(%s), at the end of docblock in %s on line %d", token_name, status->token->value, status->scanner_state->active_file, status->scanner_state->active_line); - } else { - spprintf(&status->syntax_error, 0, "Syntax error, unexpected token %s, at the end of docblock in %s on line %d", token_name, status->scanner_state->active_file, status->scanner_state->active_line); - } - } else { - spprintf(&status->syntax_error, 0, "Syntax error, unexpected EOF, at the end of docblock in %s on line %d", status->scanner_state->active_file, status->scanner_state->active_line); - } - } - } else { - spprintf(&status->syntax_error, 0, "Syntax error, unexpected EOF in %s", status->scanner_state->active_file); - } +ZEPHIR_INIT_CLASS(Phalcon_Support_Debug_Dump) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Debug, Dump, phalcon, support_debug_dump, phalcon_support_debug_dump_method_entry, 0); - status->status = PHANNOT_PARSING_FAILED; + zend_declare_property_bool(phalcon_support_debug_dump_ce, SL("detailed"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_support_debug_dump_ce, SL("methods"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_support_debug_dump_ce, SL("styles"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_support_debug_dump_ce, SL("encode"), ZEND_ACC_PRIVATE); + phalcon_support_debug_dump_ce->create_object = zephir_init_properties_Phalcon_Support_Debug_Dump; -// 876 "parser.php.c" - phannot_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ + return SUCCESS; } -static void aa_accept( - aaParser *aapParser /* The parser */ -){ - phannot_ARG_FETCH; -#ifndef NDEBUG - if( aaTraceFILE ){ - fprintf(aaTraceFILE,"%sAccept!\n",aaTracePrompt); - } -#endif - while( aapParser->aaidx>=0 ) aa_pop_parser_stack(aapParser); - /* Here code is inserted which will be executed whenever the - ** parser accepts */ - phannot_ARG_STORE; /* Suppress warning about unused %extra_argument variable */ -} +static PHP_METHOD(Phalcon_Support_Debug_Dump, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool detailed; + zval *styles_param = NULL, *detailed_param = NULL, __$true, __$false, _0; + zval styles; + zval *this_ptr = getThis(); -/* The main parser program. -** The first argument is a pointer to a structure obtained from -** "phannot_Alloc" which describes the current state of the parser. -** The second argument is the major token number. The third is -** the minor token. The fourth optional argument is whatever the -** user wants (and specified in the grammar) and is available for -** use by the action routines. -** -** Inputs: -**
    -**
  • A pointer to the parser (an opaque structure.) -**
  • The major token number. -**
  • The minor token number. -**
  • An option argument of a grammar-specified type. -**
-** -** Outputs: -** None. -*/ -static void phannot_( - void *aap, /* The parser */ - int aamajor, /* The major token code number */ - phannot_TOKENTYPE aaminor /* The value for the token */ - phannot_ARG_PDECL /* Optional %extra_argument parameter */ -){ - AAMINORTYPE aaminorunion; - int aaact; /* The parser action. */ - int aaendofinput; /* True if we are at the end of input */ - int aaerrorhit = 0; /* True if aamajor has invoked an error */ - aaParser *aapParser; /* The parser */ + ZVAL_UNDEF(&styles); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(styles) + Z_PARAM_BOOL(detailed) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 2, &styles_param, &detailed_param); + if (!styles_param) { + ZEPHIR_INIT_VAR(&styles); + array_init(&styles); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&styles, styles_param); + } + if (!detailed_param) { + detailed = 0; + } else { + } + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, phalcon_support_helper_json_encode_ce); + if (zephir_has_constructor(&_0)) { + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); + zephir_check_call_status(); + } - /* (re)initialize the parser, if necessary */ - aapParser = (aaParser*)aap; - if( aapParser->aaidx<0 ){ - if( aamajor==0 ) return; - aapParser->aaidx = 0; - aapParser->aaerrcnt = -1; - aapParser->aastack[0].stateno = 0; - aapParser->aastack[0].major = 0; - } - aaminorunion.aa0 = aaminor; - aaendofinput = (aamajor==0); - phannot_ARG_STORE; + zephir_update_property_zval(this_ptr, ZEND_STRL("encode"), &_0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setstyles", NULL, 0, &styles); + zephir_check_call_status(); + if (detailed) { + zephir_update_property_zval(this_ptr, ZEND_STRL("detailed"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("detailed"), &__$false); + } + ZEPHIR_MM_RESTORE(); +} -#ifndef NDEBUG - if( aaTraceFILE ){ - fprintf(aaTraceFILE,"%sInput %s\n",aaTracePrompt,aaTokenName[aamajor]); - } -#endif +static PHP_METHOD(Phalcon_Support_Debug_Dump, all) +{ + zval _1; + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - do{ - aaact = aa_find_shift_action(aapParser,aamajor); - if( aaactaaerrcnt--; - if( aaendofinput && aapParser->aaidx>=0 ){ - aamajor = 0; - }else{ - aamajor = AANOCODE; - } - }else if( aaact < AANSTATE + AANRULE ){ - aa_reduce(aapParser,aaact-AANSTATE); - }else if( aaact == AA_ERROR_ACTION ){ - int aamx; -#ifndef NDEBUG - if( aaTraceFILE ){ - fprintf(aaTraceFILE,"%sSyntax Error!\n",aaTracePrompt); - } -#endif -#ifdef AAERRORSYMBOL - /* A syntax error has occurred. - ** The response to an error depends upon whether or not the - ** grammar defines an error token "ERROR". - ** - ** This is what we do if the grammar does define ERROR: - ** - ** * Call the %syntax_error function. - ** - ** * Begin popping the stack until we enter a state where - ** it is legal to shift the error symbol, then shift - ** the error symbol. - ** - ** * Set the error count to three. - ** - ** * Begin accepting and shifting new tokens. No new error - ** processing will occur until three tokens have been - ** shifted successfully. - ** - */ - if( aapParser->aaerrcnt<0 ){ - aa_syntax_error(aapParser,aamajor,aaminorunion); - } - aamx = aapParser->aastack[aapParser->aaidx].major; - if( aamx==AAERRORSYMBOL || aaerrorhit ){ -#ifndef NDEBUG - if( aaTraceFILE ){ - fprintf(aaTraceFILE,"%sDiscard input token %s\n", - aaTracePrompt,aaTokenName[aamajor]); - } -#endif - aa_destructor(aamajor,&aaminorunion); - aamajor = AANOCODE; - }else{ - while( - aapParser->aaidx >= 0 && - aamx != AAERRORSYMBOL && - (aaact = aa_find_shift_action(aapParser,AAERRORSYMBOL)) >= AANSTATE - ){ - aa_pop_parser_stack(aapParser); - } - if( aapParser->aaidx < 0 || aamajor==0 ){ - aa_destructor(aamajor,&aaminorunion); - aa_parse_failed(aapParser); - aamajor = AANOCODE; - }else if( aamx!=AAERRORSYMBOL ){ - AAMINORTYPE u2; - u2.AAERRSYMDT = 0; - aa_shift(aapParser,aaact,AAERRORSYMBOL,&u2); - } - } - aapParser->aaerrcnt = 3; - aaerrorhit = 1; -#else /* AAERRORSYMBOL is not defined */ - /* This is what we do if the grammar does not define ERROR: - ** - ** * Report an error message, and throw away the input token. - ** - ** * If the input token is $, then fail the parse. - ** - ** As before, subsequent error messages are suppressed until - ** three input tokens have been successfully shifted. - */ - if( aapParser->aaerrcnt<=0 ){ - aa_syntax_error(aapParser,aamajor,aaminorunion); - } - aapParser->aaerrcnt = 3; - aa_destructor(aamajor,&aaminorunion); - if( aaendofinput ){ - aa_parse_failed(aapParser); - } - aamajor = AANOCODE; -#endif - }else{ - aa_accept(aapParser); - aamajor = AANOCODE; - } - }while( aamajor!=AANOCODE && aapParser->aaidx>=0 ); - return; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 2, 0); + zephir_array_fast_append(&_0, this_ptr); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "variables"); + zephir_array_fast_append(&_0, &_1); + ZEPHIR_INIT_NVAR(&_1); + zephir_get_args(&_1); + ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -/* base.c - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the - * LICENSE.txt file that was distributed with this source code. - */ -const phannot_token_names phannot_tokens[] = +static PHP_METHOD(Phalcon_Support_Debug_Dump, getDetailed) { - { "INTEGER", PHANNOT_T_INTEGER }, - { "DOUBLE", PHANNOT_T_DOUBLE }, - { "STRING", PHANNOT_T_STRING }, - { "IDENTIFIER", PHANNOT_T_IDENTIFIER }, - { "@", PHANNOT_T_AT }, - { ",", PHANNOT_T_COMMA }, - { "=", PHANNOT_T_EQUALS }, - { ":", PHANNOT_T_COLON }, - { "(", PHANNOT_T_PARENTHESES_OPEN }, - { ")", PHANNOT_T_PARENTHESES_CLOSE }, - { "{", PHANNOT_T_BRACKET_OPEN }, - { "}", PHANNOT_T_BRACKET_CLOSE }, - { "[", PHANNOT_T_SBRACKET_OPEN }, - { "]", PHANNOT_T_SBRACKET_CLOSE }, - { "ARBITRARY TEXT", PHANNOT_T_ARBITRARY_TEXT }, - { NULL, 0 } -}; -static void *phannot_wrapper_alloc(size_t bytes){ - return emalloc(bytes); + RETURN_MEMBER(getThis(), "detailed"); } -static void phannot_wrapper_free(void *pointer){ - efree(pointer); -} +static PHP_METHOD(Phalcon_Support_Debug_Dump, setDetailed) +{ + zval *detailed_param = NULL, __$true, __$false; + zend_bool detailed; + zval *this_ptr = getThis(); -static void phannot_parse_with_token(void* phannot_parser, int opcode, int parsercode, phannot_scanner_token *token, phannot_parser_status *parser_status){ + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(detailed) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &detailed_param); + if (detailed) { + zephir_update_property_zval(this_ptr, ZEND_STRL("detailed"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("detailed"), &__$false); + } +} - phannot_parser_token *pToken; +static PHP_METHOD(Phalcon_Support_Debug_Dump, one) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval name; + zval *variable, variable_sub, *name_param = NULL; + zval *this_ptr = getThis(); - pToken = emalloc(sizeof(phannot_parser_token)); - pToken->opcode = opcode; - pToken->token = token->value; - pToken->token_len = token->len; - pToken->free_flag = 1; + ZVAL_UNDEF(&variable_sub); + ZVAL_UNDEF(&name); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(variable) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &variable, &name_param); + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { + zephir_get_strval(&name, name_param); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "variable", NULL, 0, variable, &name); + zephir_check_call_status(); + RETURN_MM(); +} - phannot_(phannot_parser, parsercode, pToken, parser_status); +static PHP_METHOD(Phalcon_Support_Debug_Dump, setStyles) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *styles_param = NULL, defaultStyles, _0; + zval styles; + zval *this_ptr = getThis(); - token->value = NULL; - token->len = 0; + ZVAL_UNDEF(&styles); + ZVAL_UNDEF(&defaultStyles); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(styles) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &styles_param); + if (!styles_param) { + ZEPHIR_INIT_VAR(&styles); + array_init(&styles); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&styles, styles_param); + } + ZEPHIR_INIT_VAR(&defaultStyles); + zephir_create_array(&defaultStyles, 11, 0); + add_assoc_stringl_ex(&defaultStyles, SL("pre"), SL("background-color:#f3f3f3; font-size:11px; padding:10px; border:1px solid #ccc; text-align:left; color:#333")); + add_assoc_stringl_ex(&defaultStyles, SL("arr"), SL("color:red")); + add_assoc_stringl_ex(&defaultStyles, SL("bool"), SL("color:green")); + add_assoc_stringl_ex(&defaultStyles, SL("float"), SL("color:fuchsia")); + add_assoc_stringl_ex(&defaultStyles, SL("int"), SL("color:blue")); + add_assoc_stringl_ex(&defaultStyles, SL("null"), SL("color:black")); + add_assoc_stringl_ex(&defaultStyles, SL("num"), SL("color:navy")); + add_assoc_stringl_ex(&defaultStyles, SL("obj"), SL("color:purple")); + add_assoc_stringl_ex(&defaultStyles, SL("other"), SL("color:maroon")); + add_assoc_stringl_ex(&defaultStyles, SL("res"), SL("color:lime")); + add_assoc_stringl_ex(&defaultStyles, SL("str"), SL("color:teal")); + ZEPHIR_INIT_VAR(&_0); + zephir_fast_array_merge(&_0, &defaultStyles, &styles); + zephir_update_property_zval(this_ptr, ZEND_STRL("styles"), &_0); + RETURN_MM_MEMBER(getThis(), "styles"); } -static void phannot_scanner_error_msg(phannot_parser_status *parser_status, char **error_msg){ +static PHP_METHOD(Phalcon_Support_Debug_Dump, toJson) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *variable, variable_sub, _0, _1; + zval *this_ptr = getThis(); - phannot_scanner_state *state = parser_status->scanner_state; + ZVAL_UNDEF(&variable_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(variable) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &variable); + zephir_read_property(&_0, this_ptr, ZEND_STRL("encode"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1, ((128 | 64) | 256)); + ZEPHIR_RETURN_CALL_METHOD(&_0, "__invoke", NULL, 0, variable, &_1); + zephir_check_call_status(); + RETURN_MM(); +} - if (state->start) { - if (state->start_length > 16) { - spprintf(error_msg, 0, "Scanning error before '%.16s...' in %s on line %d", state->start, state->active_file, state->active_line); - } else { - spprintf(error_msg, 0, "Scanning error before '%s' in %s on line %d", state->start, state->active_file, state->active_line); - } +static PHP_METHOD(Phalcon_Support_Debug_Dump, variable) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval name; + zval *variable, variable_sub, *name_param = NULL, _1, _2; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&variable_sub); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(variable) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &variable, &name_param); + if (!name_param) { + ZEPHIR_INIT_VAR(&name); } else { - spprintf(error_msg, 0, "Scanning error near to EOF in %s", state->active_file); + zephir_get_strval(&name, name_param); } + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 2, 0); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "pre"); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", NULL, 0, &_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, 0, variable, &name); + zephir_check_call_status(); + zephir_array_update_string(&_0, SL(":output"), &_1, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "
:output
"); + ZEPHIR_RETURN_CALL_FUNCTION("strtr", NULL, 5, &_2, &_0); + zephir_check_call_status(); + RETURN_MM(); } -static int phannot_parse_annotations(zval *result, zval *comment, zval *file_path, zval *line) { +static PHP_METHOD(Phalcon_Support_Debug_Dump, variables) +{ + zend_string *_4; + zend_ulong _3; + zval output; + zval key, value, _0, *_1, _2, _5$$3, _6$$3, _8$$4, _9$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_7 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - char *comment_str; - int comment_len; - char *file_path_str; - int line_num; + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_8$$4); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&output); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - char *error_msg = NULL; + ZEPHIR_INIT_VAR(&output); + ZEPHIR_INIT_VAR(&_0); + zephir_get_args(&_0); + zephir_is_iterable(&_0, 0, "phalcon/Support/Debug/Dump.zep", 198); + if (Z_TYPE_P(&_0) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_0), _3, _4, _1) + { + ZEPHIR_INIT_NVAR(&key); + if (_4 != NULL) { + ZVAL_STR_COPY(&key, _4); + } else { + ZVAL_LONG(&key, _3); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _1); + ZEPHIR_INIT_NVAR(&_6$$3); + ZEPHIR_CONCAT_SV(&_6$$3, "var ", &key); + ZEPHIR_CALL_METHOD(&_5$$3, this_ptr, "one", &_7, 0, &value, &_6$$3); + zephir_check_call_status(); + zephir_concat_self(&output, &_5$$3); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &_0, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &_0, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_9$$4); + ZEPHIR_CONCAT_SV(&_9$$4, "var ", &key); + ZEPHIR_CALL_METHOD(&_8$$4, this_ptr, "one", &_7, 0, &value, &_9$$4); + zephir_check_call_status(); + zephir_concat_self(&output, &_8$$4); + ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + RETURN_CTOR(&output); +} - ZVAL_NULL(result); +static PHP_METHOD(Phalcon_Support_Debug_Dump, getStyle) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *type_param = NULL, style, _0; + zval type; + zval *this_ptr = getThis(); - if (Z_TYPE_P(comment) == IS_STRING) { - comment_str = Z_STRVAL_P(comment); - comment_len = Z_STRLEN_P(comment); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&style); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(type) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &type_param); + if (UNEXPECTED(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(type_param) == IS_STRING)) { + zephir_get_strval(&type, type_param); } else { - comment_str = ""; - comment_len = 0; + ZEPHIR_INIT_VAR(&type); + } + zephir_memory_observe(&style); + zephir_read_property(&_0, this_ptr, ZEND_STRL("styles"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&style, &_0, &type, 0))) { + RETURN_MM_STRING("color:gray"); } + RETURN_CCTOR(&style); +} - if (Z_TYPE_P(file_path) == IS_STRING) { - file_path_str = Z_STRVAL_P(file_path); +static PHP_METHOD(Phalcon_Support_Debug_Dump, output) +{ + zend_class_entry *_74$$16, *_91$$17; + zend_bool _15$$5, _16$$5, _17$$5, _27$$7, _28$$7, _29$$7, _42$$9; + zend_string *_7$$4, *_50$$12; + zend_ulong _6$$4, _49$$12; + zval _166, _1$$4, _11$$5, _23$$7, _34$$9, _105$$9, _38$$10, _53$$13, _61$$14, _79$$16, _95$$17, _116$$21, _122$$22, _129$$24, _135$$25, _144$$26, _148$$27, _151$$28, _154$$29, _159$$30, _163$$31; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_10 = NULL, *_19 = NULL, *_71 = NULL, *_72 = NULL, *_75 = NULL, *_77 = NULL, *_85 = NULL, *_88 = NULL, *_89 = NULL, *_93 = NULL, *_101 = NULL; + zend_long tab, ZEPHIR_LAST_CALL_STATUS; + zval name, _0$$3; + zval *variable, variable_sub, *name_param = NULL, *tab_param = NULL, key, value, output, space, type, attr, _147, _167, _168, _2$$4, _3$$4, *_4$$4, _5$$4, _32$$4, _33$$4, _8$$5, _9$$5, _12$$5, _13$$5, _14$$5, _18$$5, _20$$5, _21$$7, _22$$7, _24$$7, _25$$7, _26$$7, _30$$7, _31$$7, _35$$9, _36$$9, _37$$9, _41$$9, _103$$9, _104$$9, _106$$9, _107$$9, _142$$9, _143$$9, _39$$10, _40$$10, _43$$11, _44$$11, _45$$11, _46$$12, *_47$$12, _48$$12, _51$$13, _52$$13, _54$$13, _55$$13, _56$$13, _57$$13, _58$$13, _59$$14, _60$$14, _62$$14, _63$$14, _64$$14, _65$$14, _66$$14, reflect$$15, props$$15, property$$15, _67$$15, *_68$$15, _69$$15, _70$$16, _73$$16, _76$$16, _78$$16, _80$$16, _81$$16, _82$$16, _83$$16, _84$$16, _86$$16, _87$$17, _90$$17, _92$$17, _94$$17, _96$$17, _97$$17, _98$$17, _99$$17, _100$$17, _102$$17, _108$$18, _109$$18, _110$$18, *_111$$19, _112$$19, _139$$19, _140$$19, _141$$19, _113$$20, _114$$21, _115$$21, _117$$21, _118$$21, _119$$21, _120$$22, _121$$22, _123$$22, _124$$22, _125$$22, _126$$23, _127$$24, _128$$24, _130$$24, _131$$24, _132$$24, _133$$25, _134$$25, _136$$25, _137$$25, _138$$25, _145$$26, _146$$26, _149$$27, _150$$27, _152$$28, _153$$28, _155$$29, _156$$29, _157$$29, _158$$29, _160$$30, _161$$30, _162$$30, _164$$31, _165$$31; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&variable_sub); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&output); + ZVAL_UNDEF(&space); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&attr); + ZVAL_UNDEF(&_147); + ZVAL_UNDEF(&_167); + ZVAL_UNDEF(&_168); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_32$$4); + ZVAL_UNDEF(&_33$$4); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_12$$5); + ZVAL_UNDEF(&_13$$5); + ZVAL_UNDEF(&_14$$5); + ZVAL_UNDEF(&_18$$5); + ZVAL_UNDEF(&_20$$5); + ZVAL_UNDEF(&_21$$7); + ZVAL_UNDEF(&_22$$7); + ZVAL_UNDEF(&_24$$7); + ZVAL_UNDEF(&_25$$7); + ZVAL_UNDEF(&_26$$7); + ZVAL_UNDEF(&_30$$7); + ZVAL_UNDEF(&_31$$7); + ZVAL_UNDEF(&_35$$9); + ZVAL_UNDEF(&_36$$9); + ZVAL_UNDEF(&_37$$9); + ZVAL_UNDEF(&_41$$9); + ZVAL_UNDEF(&_103$$9); + ZVAL_UNDEF(&_104$$9); + ZVAL_UNDEF(&_106$$9); + ZVAL_UNDEF(&_107$$9); + ZVAL_UNDEF(&_142$$9); + ZVAL_UNDEF(&_143$$9); + ZVAL_UNDEF(&_39$$10); + ZVAL_UNDEF(&_40$$10); + ZVAL_UNDEF(&_43$$11); + ZVAL_UNDEF(&_44$$11); + ZVAL_UNDEF(&_45$$11); + ZVAL_UNDEF(&_46$$12); + ZVAL_UNDEF(&_48$$12); + ZVAL_UNDEF(&_51$$13); + ZVAL_UNDEF(&_52$$13); + ZVAL_UNDEF(&_54$$13); + ZVAL_UNDEF(&_55$$13); + ZVAL_UNDEF(&_56$$13); + ZVAL_UNDEF(&_57$$13); + ZVAL_UNDEF(&_58$$13); + ZVAL_UNDEF(&_59$$14); + ZVAL_UNDEF(&_60$$14); + ZVAL_UNDEF(&_62$$14); + ZVAL_UNDEF(&_63$$14); + ZVAL_UNDEF(&_64$$14); + ZVAL_UNDEF(&_65$$14); + ZVAL_UNDEF(&_66$$14); + ZVAL_UNDEF(&reflect$$15); + ZVAL_UNDEF(&props$$15); + ZVAL_UNDEF(&property$$15); + ZVAL_UNDEF(&_67$$15); + ZVAL_UNDEF(&_69$$15); + ZVAL_UNDEF(&_70$$16); + ZVAL_UNDEF(&_73$$16); + ZVAL_UNDEF(&_76$$16); + ZVAL_UNDEF(&_78$$16); + ZVAL_UNDEF(&_80$$16); + ZVAL_UNDEF(&_81$$16); + ZVAL_UNDEF(&_82$$16); + ZVAL_UNDEF(&_83$$16); + ZVAL_UNDEF(&_84$$16); + ZVAL_UNDEF(&_86$$16); + ZVAL_UNDEF(&_87$$17); + ZVAL_UNDEF(&_90$$17); + ZVAL_UNDEF(&_92$$17); + ZVAL_UNDEF(&_94$$17); + ZVAL_UNDEF(&_96$$17); + ZVAL_UNDEF(&_97$$17); + ZVAL_UNDEF(&_98$$17); + ZVAL_UNDEF(&_99$$17); + ZVAL_UNDEF(&_100$$17); + ZVAL_UNDEF(&_102$$17); + ZVAL_UNDEF(&_108$$18); + ZVAL_UNDEF(&_109$$18); + ZVAL_UNDEF(&_110$$18); + ZVAL_UNDEF(&_112$$19); + ZVAL_UNDEF(&_139$$19); + ZVAL_UNDEF(&_140$$19); + ZVAL_UNDEF(&_141$$19); + ZVAL_UNDEF(&_113$$20); + ZVAL_UNDEF(&_114$$21); + ZVAL_UNDEF(&_115$$21); + ZVAL_UNDEF(&_117$$21); + ZVAL_UNDEF(&_118$$21); + ZVAL_UNDEF(&_119$$21); + ZVAL_UNDEF(&_120$$22); + ZVAL_UNDEF(&_121$$22); + ZVAL_UNDEF(&_123$$22); + ZVAL_UNDEF(&_124$$22); + ZVAL_UNDEF(&_125$$22); + ZVAL_UNDEF(&_126$$23); + ZVAL_UNDEF(&_127$$24); + ZVAL_UNDEF(&_128$$24); + ZVAL_UNDEF(&_130$$24); + ZVAL_UNDEF(&_131$$24); + ZVAL_UNDEF(&_132$$24); + ZVAL_UNDEF(&_133$$25); + ZVAL_UNDEF(&_134$$25); + ZVAL_UNDEF(&_136$$25); + ZVAL_UNDEF(&_137$$25); + ZVAL_UNDEF(&_138$$25); + ZVAL_UNDEF(&_145$$26); + ZVAL_UNDEF(&_146$$26); + ZVAL_UNDEF(&_149$$27); + ZVAL_UNDEF(&_150$$27); + ZVAL_UNDEF(&_152$$28); + ZVAL_UNDEF(&_153$$28); + ZVAL_UNDEF(&_155$$29); + ZVAL_UNDEF(&_156$$29); + ZVAL_UNDEF(&_157$$29); + ZVAL_UNDEF(&_158$$29); + ZVAL_UNDEF(&_160$$30); + ZVAL_UNDEF(&_161$$30); + ZVAL_UNDEF(&_162$$30); + ZVAL_UNDEF(&_164$$31); + ZVAL_UNDEF(&_165$$31); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_166); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_11$$5); + ZVAL_UNDEF(&_23$$7); + ZVAL_UNDEF(&_34$$9); + ZVAL_UNDEF(&_105$$9); + ZVAL_UNDEF(&_38$$10); + ZVAL_UNDEF(&_53$$13); + ZVAL_UNDEF(&_61$$14); + ZVAL_UNDEF(&_79$$16); + ZVAL_UNDEF(&_95$$17); + ZVAL_UNDEF(&_116$$21); + ZVAL_UNDEF(&_122$$22); + ZVAL_UNDEF(&_129$$24); + ZVAL_UNDEF(&_135$$25); + ZVAL_UNDEF(&_144$$26); + ZVAL_UNDEF(&_148$$27); + ZVAL_UNDEF(&_151$$28); + ZVAL_UNDEF(&_154$$29); + ZVAL_UNDEF(&_159$$30); + ZVAL_UNDEF(&_163$$31); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ZVAL(variable) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + Z_PARAM_LONG(tab) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &variable, &name_param, &tab_param); + if (!name_param) { + ZEPHIR_INIT_VAR(&name); } else { - file_path_str = "eval"; + zephir_get_strval(&name, name_param); } - - if (Z_TYPE_P(line) == IS_LONG) { - line_num = Z_LVAL_P(line); + if (!tab_param) { + tab = 1; } else { - line_num = 0; + } + ZEPHIR_INIT_VAR(&space); + ZVAL_STRING(&space, " "); + ZEPHIR_INIT_VAR(&output); + ZVAL_STRING(&output, ""); + if (!(ZEPHIR_IS_EMPTY(&name))) { + ZEPHIR_INIT_VAR(&_0$$3); + ZEPHIR_CONCAT_VS(&_0$$3, &name, " "); + ZEPHIR_CPY_WRT(&output, &_0$$3); } - - if (phannot_internal_parse_annotations(&result, comment_str, comment_len, file_path_str, line_num, &error_msg) == FAILURE) { - if (likely(error_msg != NULL)) { - zephir_throw_exception_string(phalcon_annotations_exception_ce, error_msg, strlen(error_msg)); - efree(error_msg); + if (Z_TYPE_P(variable) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&_1$$4); + zephir_create_array(&_1$$4, 2, 0); + ZEPHIR_INIT_VAR(&_3$$4); + ZVAL_STRING(&_3$$4, "arr"); + ZEPHIR_CALL_METHOD(&_2$$4, this_ptr, "getstyle", NULL, 0, &_3$$4); + zephir_check_call_status(); + zephir_array_update_string(&_1$$4, SL(":style"), &_2$$4, PH_COPY | PH_SEPARATE); + add_assoc_long_ex(&_1$$4, SL(":count"), zephir_fast_count_int(variable)); + ZEPHIR_INIT_NVAR(&_3$$4); + ZVAL_STRING(&_3$$4, "Array (:count) (\n"); + ZEPHIR_CALL_FUNCTION(&_2$$4, "strtr", NULL, 5, &_3$$4, &_1$$4); + zephir_check_call_status(); + zephir_concat_self(&output, &_2$$4); + zephir_is_iterable(variable, 0, "phalcon/Support/Debug/Dump.zep", 248); + if (Z_TYPE_P(variable) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(variable), _6$$4, _7$$4, _4$$4) + { + ZEPHIR_INIT_NVAR(&key); + if (_7$$4 != NULL) { + ZVAL_STR_COPY(&key, _7$$4); + } else { + ZVAL_LONG(&key, _6$$4); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _4$$4); + ZVAL_LONG(&_8$$5, tab); + ZEPHIR_CALL_FUNCTION(&_9$$5, "str_repeat", &_10, 1, &space, &_8$$5); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_11$$5); + zephir_create_array(&_11$$5, 2, 0); + ZEPHIR_INIT_NVAR(&_13$$5); + ZVAL_STRING(&_13$$5, "arr"); + ZEPHIR_CALL_METHOD(&_12$$5, this_ptr, "getstyle", NULL, 0, &_13$$5); + zephir_check_call_status(); + zephir_array_update_string(&_11$$5, SL(":style"), &_12$$5, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_11$$5, SL(":key"), &key, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_13$$5); + ZVAL_STRING(&_13$$5, "[:key] => "); + ZEPHIR_CALL_FUNCTION(&_12$$5, "strtr", NULL, 5, &_13$$5, &_11$$5); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_14$$5); + ZEPHIR_CONCAT_VV(&_14$$5, &_9$$5, &_12$$5); + zephir_concat_self(&output, &_14$$5); + _15$$5 = tab == 1; + if (_15$$5) { + _15$$5 = !ZEPHIR_IS_STRING(&name, ""); + } + _16$$5 = _15$$5; + if (_16$$5) { + _16$$5 = !(Z_TYPE_P(&key) == IS_LONG); + } + _17$$5 = _16$$5; + if (_17$$5) { + _17$$5 = ZEPHIR_IS_EQUAL(&name, &key); + } + if (_17$$5) { + continue; + } + ZEPHIR_INIT_NVAR(&_13$$5); + ZVAL_STRING(&_13$$5, ""); + ZVAL_LONG(&_8$$5, (tab + 1)); + ZEPHIR_CALL_METHOD(&_18$$5, this_ptr, "output", &_19, 0, &value, &_13$$5, &_8$$5); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_20$$5); + ZEPHIR_CONCAT_VS(&_20$$5, &_18$$5, "\n"); + zephir_concat_self(&output, &_20$$5); + } ZEND_HASH_FOREACH_END(); } else { - zephir_throw_exception_string(phalcon_annotations_exception_ce, SL("There was an error parsing annotation")); + ZEPHIR_CALL_METHOD(NULL, variable, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5$$4, variable, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5$$4)) { + break; + } + ZEPHIR_CALL_METHOD(&key, variable, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, variable, "current", NULL, 0); + zephir_check_call_status(); + ZVAL_LONG(&_21$$7, tab); + ZEPHIR_CALL_FUNCTION(&_22$$7, "str_repeat", &_10, 1, &space, &_21$$7); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_23$$7); + zephir_create_array(&_23$$7, 2, 0); + ZEPHIR_INIT_NVAR(&_25$$7); + ZVAL_STRING(&_25$$7, "arr"); + ZEPHIR_CALL_METHOD(&_24$$7, this_ptr, "getstyle", NULL, 0, &_25$$7); + zephir_check_call_status(); + zephir_array_update_string(&_23$$7, SL(":style"), &_24$$7, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_23$$7, SL(":key"), &key, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_25$$7); + ZVAL_STRING(&_25$$7, "[:key] => "); + ZEPHIR_CALL_FUNCTION(&_24$$7, "strtr", NULL, 5, &_25$$7, &_23$$7); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_26$$7); + ZEPHIR_CONCAT_VV(&_26$$7, &_22$$7, &_24$$7); + zephir_concat_self(&output, &_26$$7); + _27$$7 = tab == 1; + if (_27$$7) { + _27$$7 = !ZEPHIR_IS_STRING(&name, ""); + } + _28$$7 = _27$$7; + if (_28$$7) { + _28$$7 = !(Z_TYPE_P(&key) == IS_LONG); + } + _29$$7 = _28$$7; + if (_29$$7) { + _29$$7 = ZEPHIR_IS_EQUAL(&name, &key); + } + if (_29$$7) { + continue; + } + ZEPHIR_INIT_NVAR(&_25$$7); + ZVAL_STRING(&_25$$7, ""); + ZVAL_LONG(&_21$$7, (tab + 1)); + ZEPHIR_CALL_METHOD(&_30$$7, this_ptr, "output", &_19, 0, &value, &_25$$7, &_21$$7); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_31$$7); + ZEPHIR_CONCAT_VS(&_31$$7, &_30$$7, "\n"); + zephir_concat_self(&output, &_31$$7); + ZEPHIR_CALL_METHOD(NULL, variable, "next", NULL, 0); + zephir_check_call_status(); + } } - - return FAILURE; + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + ZVAL_LONG(&_32$$4, (tab - 1)); + ZEPHIR_CALL_FUNCTION(&_33$$4, "str_repeat", &_10, 1, &space, &_32$$4); + zephir_check_call_status(); + ZEPHIR_CONCAT_VVS(return_value, &output, &_33$$4, ")"); + RETURN_MM(); } - - return SUCCESS; -} - -static void phannot_remove_comment_separators(char **ret, int *ret_len, const char *comment, int length, int *start_lines) -{ - char ch; - int start_mode = 1, j, i, open_parentheses; - smart_str processed_str = {0}; - - (*start_lines) = 0; - - for (i = 0; i < length; i++) { - - ch = comment[i]; - - if (start_mode) { - if (ch == ' ' || ch == '*' || ch == '/' || ch == '\t' || ch == 11) { - continue; - } - start_mode = 0; + if (Z_TYPE_P(variable) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_34$$9); + zephir_create_array(&_34$$9, 2, 0); + ZEPHIR_INIT_VAR(&_36$$9); + ZVAL_STRING(&_36$$9, "obj"); + ZEPHIR_CALL_METHOD(&_35$$9, this_ptr, "getstyle", NULL, 0, &_36$$9); + zephir_check_call_status(); + zephir_array_update_string(&_34$$9, SL(":style"), &_35$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_36$$9); + zephir_get_class(&_36$$9, variable, 0); + zephir_array_update_string(&_34$$9, SL(":class"), &_36$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_36$$9); + ZVAL_STRING(&_36$$9, "Object :class"); + ZEPHIR_CALL_FUNCTION(&_35$$9, "strtr", NULL, 5, &_36$$9, &_34$$9); + zephir_check_call_status(); + zephir_concat_self(&output, &_35$$9); + ZEPHIR_CALL_FUNCTION(&_37$$9, "get_parent_class", NULL, 0, variable); + zephir_check_call_status(); + if (zephir_is_true(&_37$$9)) { + ZEPHIR_INIT_VAR(&_38$$10); + zephir_create_array(&_38$$10, 2, 0); + ZEPHIR_INIT_VAR(&_40$$10); + ZVAL_STRING(&_40$$10, "obj"); + ZEPHIR_CALL_METHOD(&_39$$10, this_ptr, "getstyle", NULL, 0, &_40$$10); + zephir_check_call_status(); + zephir_array_update_string(&_38$$10, SL(":style"), &_39$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_FUNCTION(&_39$$10, "get_parent_class", NULL, 0, variable); + zephir_check_call_status(); + zephir_array_update_string(&_38$$10, SL(":parent"), &_39$$10, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_40$$10); + ZVAL_STRING(&_40$$10, " extends :parent"); + ZEPHIR_CALL_FUNCTION(&_39$$10, "strtr", NULL, 5, &_40$$10, &_38$$10); + zephir_check_call_status(); + zephir_concat_self(&output, &_39$$10); } - - if (ch == '@') { - - smart_str_appendc(&processed_str, ch); - i++; - - open_parentheses = 0; - for (j = i; j < length; j++) { - - ch = comment[j]; - - if (start_mode) { - if (ch == ' ' || ch == '*' || ch == '/' || ch == '\t' || ch == 11) { - continue; + zephir_concat_self_str(&output, SL(" (\n")); + zephir_read_property(&_41$$9, this_ptr, ZEND_STRL("detailed"), PH_NOISY_CC | PH_READONLY); + _42$$9 = !zephir_is_true(&_41$$9); + if (!(_42$$9)) { + _42$$9 = zephir_is_instance_of(variable, SL("stdClass")); + } + if (zephir_instance_of_ev(variable, phalcon_di_di_ce)) { + ZVAL_LONG(&_43$$11, tab); + ZEPHIR_CALL_FUNCTION(&_44$$11, "str_repeat", &_10, 1, &space, &_43$$11); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_45$$11); + ZEPHIR_CONCAT_VS(&_45$$11, &_44$$11, "[skipped]\n"); + zephir_concat_self(&output, &_45$$11); + } else if (_42$$9) { + ZEPHIR_CALL_FUNCTION(&_46$$12, "get_object_vars", NULL, 426, variable); + zephir_check_call_status(); + zephir_is_iterable(&_46$$12, 0, "phalcon/Support/Debug/Dump.zep", 280); + if (Z_TYPE_P(&_46$$12) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_46$$12), _49$$12, _50$$12, _47$$12) + { + ZEPHIR_INIT_NVAR(&key); + if (_50$$12 != NULL) { + ZVAL_STR_COPY(&key, _50$$12); + } else { + ZVAL_LONG(&key, _49$$12); } - start_mode = 0; - } - - if (open_parentheses == 0) { - - if (isalnum(ch) || '_' == ch || '\\' == ch) { - smart_str_appendc(&processed_str, ch); - continue; + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _47$$12); + ZVAL_LONG(&_51$$13, tab); + ZEPHIR_CALL_FUNCTION(&_52$$13, "str_repeat", &_10, 1, &space, &_51$$13); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_53$$13); + zephir_create_array(&_53$$13, 3, 0); + ZEPHIR_INIT_NVAR(&_55$$13); + ZVAL_STRING(&_55$$13, "obj"); + ZEPHIR_CALL_METHOD(&_54$$13, this_ptr, "getstyle", NULL, 0, &_55$$13); + zephir_check_call_status(); + zephir_array_update_string(&_53$$13, SL(":style"), &_54$$13, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_53$$13, SL(":key"), &key, PH_COPY | PH_SEPARATE); + add_assoc_stringl_ex(&_53$$13, SL(":type"), SL("public")); + ZEPHIR_INIT_NVAR(&_55$$13); + ZVAL_STRING(&_55$$13, "->:key (:type) = "); + ZEPHIR_CALL_FUNCTION(&_54$$13, "strtr", NULL, 5, &_55$$13, &_53$$13); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_56$$13); + ZEPHIR_CONCAT_VV(&_56$$13, &_52$$13, &_54$$13); + zephir_concat_self(&output, &_56$$13); + ZEPHIR_INIT_NVAR(&_55$$13); + ZVAL_STRING(&_55$$13, ""); + ZVAL_LONG(&_51$$13, (tab + 1)); + ZEPHIR_CALL_METHOD(&_57$$13, this_ptr, "output", &_19, 0, &value, &_55$$13, &_51$$13); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_58$$13); + ZEPHIR_CONCAT_VS(&_58$$13, &_57$$13, "\n"); + zephir_concat_self(&output, &_58$$13); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_46$$12, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_48$$12, &_46$$12, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_48$$12)) { + break; } - - if (ch == '(') { - smart_str_appendc(&processed_str, ch); - open_parentheses++; - continue; + ZEPHIR_CALL_METHOD(&key, &_46$$12, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &_46$$12, "current", NULL, 0); + zephir_check_call_status(); + ZVAL_LONG(&_59$$14, tab); + ZEPHIR_CALL_FUNCTION(&_60$$14, "str_repeat", &_10, 1, &space, &_59$$14); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_61$$14); + zephir_create_array(&_61$$14, 3, 0); + ZEPHIR_INIT_NVAR(&_63$$14); + ZVAL_STRING(&_63$$14, "obj"); + ZEPHIR_CALL_METHOD(&_62$$14, this_ptr, "getstyle", NULL, 0, &_63$$14); + zephir_check_call_status(); + zephir_array_update_string(&_61$$14, SL(":style"), &_62$$14, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_61$$14, SL(":key"), &key, PH_COPY | PH_SEPARATE); + add_assoc_stringl_ex(&_61$$14, SL(":type"), SL("public")); + ZEPHIR_INIT_NVAR(&_63$$14); + ZVAL_STRING(&_63$$14, "->:key (:type) = "); + ZEPHIR_CALL_FUNCTION(&_62$$14, "strtr", NULL, 5, &_63$$14, &_61$$14); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_64$$14); + ZEPHIR_CONCAT_VV(&_64$$14, &_60$$14, &_62$$14); + zephir_concat_self(&output, &_64$$14); + ZEPHIR_INIT_NVAR(&_63$$14); + ZVAL_STRING(&_63$$14, ""); + ZVAL_LONG(&_59$$14, (tab + 1)); + ZEPHIR_CALL_METHOD(&_65$$14, this_ptr, "output", &_19, 0, &value, &_63$$14, &_59$$14); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_66$$14); + ZEPHIR_CONCAT_VS(&_66$$14, &_65$$14, "\n"); + zephir_concat_self(&output, &_66$$14); + ZEPHIR_CALL_METHOD(NULL, &_46$$12, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + } else { + ZEPHIR_INIT_VAR(&reflect$$15); + object_init_ex(&reflect$$15, zephir_get_internal_ce(SL("reflectionclass"))); + ZEPHIR_CALL_METHOD(NULL, &reflect$$15, "__construct", NULL, 154, variable); + zephir_check_call_status(); + ZVAL_LONG(&_67$$15, ((1 | 2) | 4)); + ZEPHIR_CALL_METHOD(&props$$15, &reflect$$15, "getproperties", NULL, 165, &_67$$15); + zephir_check_call_status(); + zephir_is_iterable(&props$$15, 0, "phalcon/Support/Debug/Dump.zep", 306); + if (Z_TYPE_P(&props$$15) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&props$$15), _68$$15) + { + ZEPHIR_INIT_NVAR(&property$$15); + ZVAL_COPY(&property$$15, _68$$15); + ZVAL_BOOL(&_70$$16, 1); + ZEPHIR_CALL_METHOD(NULL, &property$$15, "setaccessible", &_71, 0, &_70$$16); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&key, &property$$15, "getname", &_72, 0); + zephir_check_call_status(); + _74$$16 = zephir_fetch_class_str_ex(SL("Reflection"), ZEND_FETCH_CLASS_AUTO); + ZEPHIR_CALL_METHOD(&_76$$16, &property$$15, "getmodifiers", &_77, 0); + zephir_check_call_status(); + ZEPHIR_CALL_CE_STATIC(&_73$$16, _74$$16, "getmodifiernames", &_75, 0, &_76$$16); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&type); + zephir_fast_join_str(&type, SL(" "), &_73$$16); + ZVAL_LONG(&_70$$16, tab); + ZEPHIR_CALL_FUNCTION(&_78$$16, "str_repeat", &_10, 1, &space, &_70$$16); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_79$$16); + zephir_create_array(&_79$$16, 3, 0); + ZEPHIR_INIT_NVAR(&_81$$16); + ZVAL_STRING(&_81$$16, "obj"); + ZEPHIR_CALL_METHOD(&_80$$16, this_ptr, "getstyle", NULL, 0, &_81$$16); + zephir_check_call_status(); + zephir_array_update_string(&_79$$16, SL(":style"), &_80$$16, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_79$$16, SL(":key"), &key, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_79$$16, SL(":type"), &type, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_81$$16); + ZVAL_STRING(&_81$$16, "->:key (:type) = "); + ZEPHIR_CALL_FUNCTION(&_80$$16, "strtr", NULL, 5, &_81$$16, &_79$$16); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_82$$16); + ZEPHIR_CONCAT_VV(&_82$$16, &_78$$16, &_80$$16); + zephir_concat_self(&output, &_82$$16); + ZEPHIR_CALL_METHOD(&_84$$16, &property$$15, "getvalue", &_85, 0, variable); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_81$$16); + ZVAL_STRING(&_81$$16, ""); + ZVAL_LONG(&_70$$16, (tab + 1)); + ZEPHIR_CALL_METHOD(&_83$$16, this_ptr, "output", &_19, 0, &_84$$16, &_81$$16, &_70$$16); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_86$$16); + ZEPHIR_CONCAT_VS(&_86$$16, &_83$$16, "\n"); + zephir_concat_self(&output, &_86$$16); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &props$$15, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_69$$15, &props$$15, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_69$$15)) { + break; } - - } else { - - smart_str_appendc(&processed_str, ch); - - if (ch == '(') { - open_parentheses++; + ZEPHIR_CALL_METHOD(&property$$15, &props$$15, "current", NULL, 0); + zephir_check_call_status(); + ZVAL_BOOL(&_87$$17, 1); + ZEPHIR_CALL_METHOD(NULL, &property$$15, "setaccessible", &_88, 0, &_87$$17); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&key, &property$$15, "getname", &_89, 0); + zephir_check_call_status(); + _91$$17 = zephir_fetch_class_str_ex(SL("Reflection"), ZEND_FETCH_CLASS_AUTO); + ZEPHIR_CALL_METHOD(&_92$$17, &property$$15, "getmodifiers", &_93, 0); + zephir_check_call_status(); + ZEPHIR_CALL_CE_STATIC(&_90$$17, _91$$17, "getmodifiernames", &_75, 0, &_92$$17); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&type); + zephir_fast_join_str(&type, SL(" "), &_90$$17); + ZVAL_LONG(&_87$$17, tab); + ZEPHIR_CALL_FUNCTION(&_94$$17, "str_repeat", &_10, 1, &space, &_87$$17); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_95$$17); + zephir_create_array(&_95$$17, 3, 0); + ZEPHIR_INIT_NVAR(&_97$$17); + ZVAL_STRING(&_97$$17, "obj"); + ZEPHIR_CALL_METHOD(&_96$$17, this_ptr, "getstyle", NULL, 0, &_97$$17); + zephir_check_call_status(); + zephir_array_update_string(&_95$$17, SL(":style"), &_96$$17, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_95$$17, SL(":key"), &key, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_95$$17, SL(":type"), &type, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_97$$17); + ZVAL_STRING(&_97$$17, "->:key (:type) = "); + ZEPHIR_CALL_FUNCTION(&_96$$17, "strtr", NULL, 5, &_97$$17, &_95$$17); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_98$$17); + ZEPHIR_CONCAT_VV(&_98$$17, &_94$$17, &_96$$17); + zephir_concat_self(&output, &_98$$17); + ZEPHIR_CALL_METHOD(&_100$$17, &property$$15, "getvalue", &_101, 0, variable); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_97$$17); + ZVAL_STRING(&_97$$17, ""); + ZVAL_LONG(&_87$$17, (tab + 1)); + ZEPHIR_CALL_METHOD(&_99$$17, this_ptr, "output", &_19, 0, &_100$$17, &_97$$17, &_87$$17); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_102$$17); + ZEPHIR_CONCAT_VS(&_102$$17, &_99$$17, "\n"); + zephir_concat_self(&output, &_102$$17); + ZEPHIR_CALL_METHOD(NULL, &props$$15, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&property$$15); + } + ZEPHIR_CALL_FUNCTION(&attr, "get_class_methods", NULL, 0, variable); + zephir_check_call_status(); + ZVAL_LONG(&_103$$9, tab); + ZEPHIR_CALL_FUNCTION(&_104$$9, "str_repeat", &_10, 1, &space, &_103$$9); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_105$$9); + zephir_create_array(&_105$$9, 3, 0); + ZEPHIR_INIT_NVAR(&_36$$9); + ZVAL_STRING(&_36$$9, "obj"); + ZEPHIR_CALL_METHOD(&_106$$9, this_ptr, "getstyle", NULL, 0, &_36$$9); + zephir_check_call_status(); + zephir_array_update_string(&_105$$9, SL(":style"), &_106$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_36$$9); + zephir_get_class(&_36$$9, variable, 0); + zephir_array_update_string(&_105$$9, SL(":class"), &_36$$9, PH_COPY | PH_SEPARATE); + add_assoc_long_ex(&_105$$9, SL(":count"), zephir_fast_count_int(&attr)); + ZEPHIR_INIT_NVAR(&_36$$9); + ZVAL_STRING(&_36$$9, ":class methods: (:count) (\n"); + ZEPHIR_CALL_FUNCTION(&_106$$9, "strtr", NULL, 5, &_36$$9, &_105$$9); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_107$$9); + ZEPHIR_CONCAT_VV(&_107$$9, &_104$$9, &_106$$9); + zephir_concat_self(&output, &_107$$9); + ZEPHIR_INIT_NVAR(&_36$$9); + zephir_get_class(&_36$$9, variable, 0); + zephir_read_property(&_103$$9, this_ptr, ZEND_STRL("methods"), PH_NOISY_CC | PH_READONLY); + if (zephir_fast_in_array(&_36$$9, &_103$$9)) { + ZVAL_LONG(&_108$$18, tab); + ZEPHIR_CALL_FUNCTION(&_109$$18, "str_repeat", &_10, 1, &space, &_108$$18); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_110$$18); + ZEPHIR_CONCAT_VS(&_110$$18, &_109$$18, "[already listed]\n"); + zephir_concat_self(&output, &_110$$18); + } else { + zephir_is_iterable(&attr, 0, "phalcon/Support/Debug/Dump.zep", 324); + if (Z_TYPE_P(&attr) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attr), _111$$19) + { + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _111$$19); + ZEPHIR_INIT_NVAR(&_113$$20); + zephir_get_class(&_113$$20, variable, 0); + zephir_update_property_array_append(this_ptr, SL("methods"), &_113$$20); + if (ZEPHIR_IS_STRING(&value, "__construct")) { + ZVAL_LONG(&_114$$21, (tab + 1)); + ZEPHIR_CALL_FUNCTION(&_115$$21, "str_repeat", &_10, 1, &space, &_114$$21); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_116$$21); + zephir_create_array(&_116$$21, 2, 0); + ZEPHIR_INIT_NVAR(&_118$$21); + ZVAL_STRING(&_118$$21, "obj"); + ZEPHIR_CALL_METHOD(&_117$$21, this_ptr, "getstyle", NULL, 0, &_118$$21); + zephir_check_call_status(); + zephir_array_update_string(&_116$$21, SL(":style"), &_117$$21, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_116$$21, SL(":method"), &value, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_118$$21); + ZVAL_STRING(&_118$$21, "->:method(); [constructor]\n"); + ZEPHIR_CALL_FUNCTION(&_117$$21, "strtr", NULL, 5, &_118$$21, &_116$$21); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_119$$21); + ZEPHIR_CONCAT_VV(&_119$$21, &_115$$21, &_117$$21); + zephir_concat_self(&output, &_119$$21); } else { - if (ch == ')') { - open_parentheses--; - } else { - if (ch == '\n') { - (*start_lines)++; - start_mode = 1; - } - } + ZVAL_LONG(&_120$$22, (tab + 1)); + ZEPHIR_CALL_FUNCTION(&_121$$22, "str_repeat", &_10, 1, &space, &_120$$22); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_122$$22); + zephir_create_array(&_122$$22, 2, 0); + ZEPHIR_INIT_NVAR(&_124$$22); + ZVAL_STRING(&_124$$22, "obj"); + ZEPHIR_CALL_METHOD(&_123$$22, this_ptr, "getstyle", NULL, 0, &_124$$22); + zephir_check_call_status(); + zephir_array_update_string(&_122$$22, SL(":style"), &_123$$22, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_122$$22, SL(":method"), &value, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_124$$22); + ZVAL_STRING(&_124$$22, "->:method();\n"); + ZEPHIR_CALL_FUNCTION(&_123$$22, "strtr", NULL, 5, &_124$$22, &_122$$22); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_125$$22); + ZEPHIR_CONCAT_VV(&_125$$22, &_121$$22, &_123$$22); + zephir_concat_self(&output, &_125$$22); } - - if (open_parentheses > 0) { - continue; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &attr, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_112$$19, &attr, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_112$$19)) { + break; } + ZEPHIR_CALL_METHOD(&value, &attr, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_126$$23); + zephir_get_class(&_126$$23, variable, 0); + zephir_update_property_array_append(this_ptr, SL("methods"), &_126$$23); + if (ZEPHIR_IS_STRING(&value, "__construct")) { + ZVAL_LONG(&_127$$24, (tab + 1)); + ZEPHIR_CALL_FUNCTION(&_128$$24, "str_repeat", &_10, 1, &space, &_127$$24); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_129$$24); + zephir_create_array(&_129$$24, 2, 0); + ZEPHIR_INIT_NVAR(&_131$$24); + ZVAL_STRING(&_131$$24, "obj"); + ZEPHIR_CALL_METHOD(&_130$$24, this_ptr, "getstyle", NULL, 0, &_131$$24); + zephir_check_call_status(); + zephir_array_update_string(&_129$$24, SL(":style"), &_130$$24, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_129$$24, SL(":method"), &value, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_131$$24); + ZVAL_STRING(&_131$$24, "->:method(); [constructor]\n"); + ZEPHIR_CALL_FUNCTION(&_130$$24, "strtr", NULL, 5, &_131$$24, &_129$$24); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_132$$24); + ZEPHIR_CONCAT_VV(&_132$$24, &_128$$24, &_130$$24); + zephir_concat_self(&output, &_132$$24); + } else { + ZVAL_LONG(&_133$$25, (tab + 1)); + ZEPHIR_CALL_FUNCTION(&_134$$25, "str_repeat", &_10, 1, &space, &_133$$25); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_135$$25); + zephir_create_array(&_135$$25, 2, 0); + ZEPHIR_INIT_NVAR(&_137$$25); + ZVAL_STRING(&_137$$25, "obj"); + ZEPHIR_CALL_METHOD(&_136$$25, this_ptr, "getstyle", NULL, 0, &_137$$25); + zephir_check_call_status(); + zephir_array_update_string(&_135$$25, SL(":style"), &_136$$25, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_135$$25, SL(":method"), &value, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_137$$25); + ZVAL_STRING(&_137$$25, "->:method();\n"); + ZEPHIR_CALL_FUNCTION(&_136$$25, "strtr", NULL, 5, &_137$$25, &_135$$25); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_138$$25); + ZEPHIR_CONCAT_VV(&_138$$25, &_134$$25, &_136$$25); + zephir_concat_self(&output, &_138$$25); + } + ZEPHIR_CALL_METHOD(NULL, &attr, "next", NULL, 0); + zephir_check_call_status(); } - - i = j; - smart_str_appendc(&processed_str, ' '); - break; } + ZEPHIR_INIT_NVAR(&value); + ZVAL_LONG(&_139$$19, tab); + ZEPHIR_CALL_FUNCTION(&_140$$19, "str_repeat", &_10, 1, &space, &_139$$19); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_141$$19); + ZEPHIR_CONCAT_VS(&_141$$19, &_140$$19, ")\n"); + zephir_concat_self(&output, &_141$$19); } - - if (ch == '\n') { - (*start_lines)++; - start_mode = 1; - } + ZVAL_LONG(&_142$$9, (tab - 1)); + ZEPHIR_CALL_FUNCTION(&_143$$9, "str_repeat", &_10, 1, &space, &_142$$9); + zephir_check_call_status(); + ZEPHIR_CONCAT_VVS(return_value, &output, &_143$$9, ")"); + RETURN_MM(); } - - smart_str_0(&processed_str); - - if (processed_str.s) { - *ret = estrndup(ZSTR_VAL(processed_str.s), ZSTR_LEN(processed_str.s)); - *ret_len = ZSTR_LEN(processed_str.s); - smart_str_free(&processed_str); - } else { - *ret = NULL; - *ret_len = 0; + if (Z_TYPE_P(variable) == IS_LONG) { + ZEPHIR_INIT_VAR(&_144$$26); + zephir_create_array(&_144$$26, 2, 0); + ZEPHIR_INIT_VAR(&_146$$26); + ZVAL_STRING(&_146$$26, "int"); + ZEPHIR_CALL_METHOD(&_145$$26, this_ptr, "getstyle", NULL, 0, &_146$$26); + zephir_check_call_status(); + zephir_array_update_string(&_144$$26, SL(":style"), &_145$$26, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_144$$26, SL(":var"), variable, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_146$$26); + ZVAL_STRING(&_146$$26, "Integer (:var)"); + ZEPHIR_CALL_FUNCTION(&_145$$26, "strtr", NULL, 5, &_146$$26, &_144$$26); + zephir_check_call_status(); + ZEPHIR_CONCAT_VV(return_value, &output, &_145$$26); + RETURN_MM(); } -} - -static int phannot_internal_parse_annotations(zval **result, const char *comment, int comment_len, const char *file_path, int line, char **error_msg) -{ - phannot_scanner_state *state; - phannot_scanner_token token; - int start_lines; - int scanner_status, status = SUCCESS; - phannot_parser_status *parser_status = NULL; - void* phannot_parser; - char *processed_comment; - int processed_comment_len; - - *error_msg = NULL; - - if (UNEXPECTED(!comment)) { - ZVAL_BOOL(*result, 0); - spprintf(error_msg, 0, "Empty annotation"); - return FAILURE; + ZEPHIR_CALL_FUNCTION(&_147, "is_float", NULL, 214, variable); + zephir_check_call_status(); + if (zephir_is_true(&_147)) { + ZEPHIR_INIT_VAR(&_148$$27); + zephir_create_array(&_148$$27, 2, 0); + ZEPHIR_INIT_VAR(&_150$$27); + ZVAL_STRING(&_150$$27, "float"); + ZEPHIR_CALL_METHOD(&_149$$27, this_ptr, "getstyle", NULL, 0, &_150$$27); + zephir_check_call_status(); + zephir_array_update_string(&_148$$27, SL(":style"), &_149$$27, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_148$$27, SL(":var"), variable, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_150$$27); + ZVAL_STRING(&_150$$27, "Float (:var)"); + ZEPHIR_CALL_FUNCTION(&_149$$27, "strtr", NULL, 5, &_150$$27, &_148$$27); + zephir_check_call_status(); + ZEPHIR_CONCAT_VV(return_value, &output, &_149$$27); + RETURN_MM(); } - - if (comment_len < 2) { - ZVAL_BOOL(*result, 0); - return SUCCESS; + if (zephir_is_numeric(variable)) { + ZEPHIR_INIT_VAR(&_151$$28); + zephir_create_array(&_151$$28, 3, 0); + ZEPHIR_INIT_VAR(&_153$$28); + ZVAL_STRING(&_153$$28, "num"); + ZEPHIR_CALL_METHOD(&_152$$28, this_ptr, "getstyle", NULL, 0, &_153$$28); + zephir_check_call_status(); + zephir_array_update_string(&_151$$28, SL(":style"), &_152$$28, PH_COPY | PH_SEPARATE); + add_assoc_long_ex(&_151$$28, SL(":length"), zephir_fast_strlen_ev(variable)); + zephir_array_update_string(&_151$$28, SL(":var"), variable, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_153$$28); + ZVAL_STRING(&_153$$28, "Numeric string (:length) \":var\""); + ZEPHIR_CALL_FUNCTION(&_152$$28, "strtr", NULL, 5, &_153$$28, &_151$$28); + zephir_check_call_status(); + ZEPHIR_CONCAT_VV(return_value, &output, &_152$$28); + RETURN_MM(); } - - phannot_remove_comment_separators(&processed_comment, &processed_comment_len, comment, comment_len, &start_lines); - - if (processed_comment_len < 2) { - ZVAL_BOOL(*result, 0); - if (processed_comment) { - efree(processed_comment); + if (Z_TYPE_P(variable) == IS_STRING) { + ZEPHIR_INIT_VAR(&_154$$29); + zephir_create_array(&_154$$29, 3, 0); + ZEPHIR_INIT_VAR(&_156$$29); + ZVAL_STRING(&_156$$29, "str"); + ZEPHIR_CALL_METHOD(&_155$$29, this_ptr, "getstyle", NULL, 0, &_156$$29); + zephir_check_call_status(); + zephir_array_update_string(&_154$$29, SL(":style"), &_155$$29, PH_COPY | PH_SEPARATE); + add_assoc_long_ex(&_154$$29, SL(":length"), zephir_fast_strlen_ev(variable)); + ZVAL_LONG(&_157$$29, 4); + ZEPHIR_INIT_NVAR(&_156$$29); + ZVAL_STRING(&_156$$29, "utf-8"); + ZEPHIR_CALL_FUNCTION(&_155$$29, "htmlentities", NULL, 0, variable, &_157$$29, &_156$$29); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_158$$29, "nl2br", NULL, 0, &_155$$29); + zephir_check_call_status(); + zephir_array_update_string(&_154$$29, SL(":var"), &_158$$29, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_156$$29); + ZVAL_STRING(&_156$$29, "String (:length) \":var\""); + ZEPHIR_CALL_FUNCTION(&_158$$29, "strtr", NULL, 5, &_156$$29, &_154$$29); + zephir_check_call_status(); + ZEPHIR_CONCAT_VV(return_value, &output, &_158$$29); + RETURN_MM(); + } + if ((Z_TYPE_P(variable) == IS_TRUE || Z_TYPE_P(variable) == IS_FALSE)) { + ZEPHIR_INIT_VAR(&_159$$30); + zephir_create_array(&_159$$30, 2, 0); + ZEPHIR_INIT_VAR(&_161$$30); + ZVAL_STRING(&_161$$30, "bool"); + ZEPHIR_CALL_METHOD(&_160$$30, this_ptr, "getstyle", NULL, 0, &_161$$30); + zephir_check_call_status(); + zephir_array_update_string(&_159$$30, SL(":style"), &_160$$30, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_162$$30); + if (zephir_is_true(variable)) { + ZEPHIR_INIT_NVAR(&_162$$30); + ZVAL_STRING(&_162$$30, "TRUE"); + } else { + ZEPHIR_INIT_NVAR(&_162$$30); + ZVAL_STRING(&_162$$30, "FALSE"); } - - return SUCCESS; + zephir_array_update_string(&_159$$30, SL(":var"), &_162$$30, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_161$$30); + ZVAL_STRING(&_161$$30, "Boolean (:var)"); + ZEPHIR_CALL_FUNCTION(&_160$$30, "strtr", NULL, 5, &_161$$30, &_159$$30); + zephir_check_call_status(); + ZEPHIR_CONCAT_VV(return_value, &output, &_160$$30); + RETURN_MM(); } - - phannot_parser = phannot_Alloc(phannot_wrapper_alloc); - if (unlikely(!phannot_parser)) { - ZVAL_BOOL(*result, 0); - return FAILURE; + if (Z_TYPE_P(variable) == IS_NULL) { + ZEPHIR_INIT_VAR(&_163$$31); + zephir_create_array(&_163$$31, 1, 0); + ZEPHIR_INIT_VAR(&_165$$31); + ZVAL_STRING(&_165$$31, "null"); + ZEPHIR_CALL_METHOD(&_164$$31, this_ptr, "getstyle", NULL, 0, &_165$$31); + zephir_check_call_status(); + zephir_array_update_string(&_163$$31, SL(":style"), &_164$$31, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_165$$31); + ZVAL_STRING(&_165$$31, "NULL"); + ZEPHIR_CALL_FUNCTION(&_164$$31, "strtr", NULL, 5, &_165$$31, &_163$$31); + zephir_check_call_status(); + ZEPHIR_CONCAT_VV(return_value, &output, &_164$$31); + RETURN_MM(); } + ZEPHIR_INIT_VAR(&_166); + zephir_create_array(&_166, 2, 0); + ZEPHIR_INIT_VAR(&_168); + ZVAL_STRING(&_168, "other"); + ZEPHIR_CALL_METHOD(&_167, this_ptr, "getstyle", NULL, 0, &_168); + zephir_check_call_status(); + zephir_array_update_string(&_166, SL(":style"), &_167, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_166, SL(":var"), variable, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_168); + ZVAL_STRING(&_168, "(:var)"); + ZEPHIR_CALL_FUNCTION(&_167, "strtr", NULL, 5, &_168, &_166); + zephir_check_call_status(); + ZEPHIR_CONCAT_VV(return_value, &output, &_167); + RETURN_MM(); +} - parser_status = emalloc(sizeof(phannot_parser_status) + sizeof(phannot_scanner_state)); - state = (phannot_scanner_state*)((char*)parser_status + sizeof(phannot_parser_status)); - - parser_status->status = PHANNOT_PARSING_OK; - parser_status->scanner_state = state; - parser_status->token = &token; - parser_status->syntax_error = NULL; - - state->active_token = 0; - state->start = processed_comment; - state->start_length = 0; - state->mode = PHANNOT_MODE_RAW; - state->active_file = file_path; - - token.value = NULL; - token.len = 0; +zend_object *zephir_init_properties_Phalcon_Support_Debug_Dump(zend_class_entry *class_type) +{ + zval _0, _2, _1$$3, _3$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + - if (line) { - state->active_line = line - start_lines; - } else { - state->active_line = 1; + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("styles"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("styles"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("methods"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("methods"), &_3$$4); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } +} - state->end = state->start; - - while(0 <= (scanner_status = phannot_get_token(state, &token))) { - - state->active_token = token.opcode; - - state->start_length = processed_comment + processed_comment_len - state->start; - - switch (token.opcode) { - - case PHANNOT_T_IGNORE: - break; - - case PHANNOT_T_AT: - phannot_(phannot_parser, PHANNOT_AT, NULL, parser_status); - break; - case PHANNOT_T_COMMA: - phannot_(phannot_parser, PHANNOT_COMMA, NULL, parser_status); - break; - case PHANNOT_T_EQUALS: - phannot_(phannot_parser, PHANNOT_EQUALS, NULL, parser_status); - break; - case PHANNOT_T_COLON: - phannot_(phannot_parser, PHANNOT_COLON, NULL, parser_status); - break; - - case PHANNOT_T_PARENTHESES_OPEN: - phannot_(phannot_parser, PHANNOT_PARENTHESES_OPEN, NULL, parser_status); - break; - case PHANNOT_T_PARENTHESES_CLOSE: - phannot_(phannot_parser, PHANNOT_PARENTHESES_CLOSE, NULL, parser_status); - break; - case PHANNOT_T_BRACKET_OPEN: - phannot_(phannot_parser, PHANNOT_BRACKET_OPEN, NULL, parser_status); - break; - case PHANNOT_T_BRACKET_CLOSE: - phannot_(phannot_parser, PHANNOT_BRACKET_CLOSE, NULL, parser_status); - break; - case PHANNOT_T_SBRACKET_OPEN: - phannot_(phannot_parser, PHANNOT_SBRACKET_OPEN, NULL, parser_status); - break; - case PHANNOT_T_SBRACKET_CLOSE: - phannot_(phannot_parser, PHANNOT_SBRACKET_CLOSE, NULL, parser_status); - break; - case PHANNOT_T_NULL: - phannot_(phannot_parser, PHANNOT_NULL, NULL, parser_status); - break; - case PHANNOT_T_TRUE: - phannot_(phannot_parser, PHANNOT_TRUE, NULL, parser_status); - break; - case PHANNOT_T_FALSE: - phannot_(phannot_parser, PHANNOT_FALSE, NULL, parser_status); - break; +#ifdef HAVE_CONFIG_H +#endif - case PHANNOT_T_INTEGER: - phannot_parse_with_token(phannot_parser, PHANNOT_T_INTEGER, PHANNOT_INTEGER, &token, parser_status); - break; - case PHANNOT_T_DOUBLE: - phannot_parse_with_token(phannot_parser, PHANNOT_T_DOUBLE, PHANNOT_DOUBLE, &token, parser_status); - break; - case PHANNOT_T_STRING: - phannot_parse_with_token(phannot_parser, PHANNOT_T_STRING, PHANNOT_STRING, &token, parser_status); - break; - case PHANNOT_T_IDENTIFIER: - phannot_parse_with_token(phannot_parser, PHANNOT_T_IDENTIFIER, PHANNOT_IDENTIFIER, &token, parser_status); - break; - /*case PHANNOT_T_ARBITRARY_TEXT: - phannot_parse_with_token(phannot_parser, PHANNOT_T_ARBITRARY_TEXT, PHANNOT_ARBITRARY_TEXT, &token, parser_status); - break;*/ - default: - parser_status->status = PHANNOT_PARSING_FAILED; - if (!*error_msg) { - spprintf(error_msg, 0, "Scanner: unknown opcode %d on in %s line %d", token.opcode, state->active_file, state->active_line); - } - break; - } - if (parser_status->status != PHANNOT_PARSING_OK) { - status = FAILURE; - break; - } - state->end = state->start; - } - if (status != FAILURE) { - switch (scanner_status) { +ZEPHIR_INIT_CLASS(Phalcon_Support_Debug_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Debug, Exception, phalcon, support_debug_exception, zend_ce_exception, NULL, 0); - case PHANNOT_SCANNER_RETCODE_ERR: - case PHANNOT_SCANNER_RETCODE_IMPOSSIBLE: - if (!*error_msg) { - phannot_scanner_error_msg(parser_status, error_msg); - } - status = FAILURE; - break; + return SUCCESS; +} - default: - phannot_(phannot_parser, 0, NULL, parser_status); - } - } - state->active_token = 0; - state->start = NULL; - if (parser_status->status != PHANNOT_PARSING_OK) { - status = FAILURE; - if (parser_status->syntax_error) { - if (!*error_msg) { - *error_msg = parser_status->syntax_error; - } else { - efree(parser_status->syntax_error); - } - } - } - phannot_Free(phannot_parser, phannot_wrapper_free); +#ifdef HAVE_CONFIG_H +#endif - if (status != FAILURE) { - if (parser_status->status == PHANNOT_PARSING_OK) { - ZVAL_ZVAL(*result, &parser_status->ret, 1, 1); - } - } - efree(processed_comment); - efree(parser_status); - return status; + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper, Exception, phalcon, support_helper_exception, zend_ce_exception, NULL, 0); + + return SUCCESS; } + #ifdef HAVE_CONFIG_H #endif @@ -139748,322 +139850,205 @@ static int phannot_internal_parse_annotations(zval **result, const char *comment -ZEPHIR_INIT_CLASS(Phalcon_Annotations_Reader) +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Json_Decode) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Annotations, Reader, phalcon, annotations_reader, phalcon_annotations_reader_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Json, Decode, phalcon, support_helper_json_decode, phalcon_support_helper_json_decode_method_entry, 0); - zend_class_implements(phalcon_annotations_reader_ce, 1, phalcon_annotations_readerinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Annotations_Reader, parse) +static PHP_METHOD(Phalcon_Support_Helper_Json_Decode, __invoke) { - zval annotations; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, line = 0; - zval *className_param = NULL, reflection, comment, arrayKeys, classAnnotations, properties, property, annotationsProperties, propertyAnnotations, methods, method, annotationsMethods, methodAnnotations, constants, constant, anotationsConstants, constantAnnotations, constantReflection, _0$$3, _1$$3, *_2$$5, _3$$5, _5$$7, _6$$7, _7$$10, _8$$10, *_9$$13, _10$$13, _11$$15, _12$$15, _13$$16, _14$$18, _15$$18, _16$$19, *_17$$21, _18$$21, _19$$23, _20$$23, _21$$24, _22$$26, _23$$26, _24$$27; - zval className; + zend_long depth, options, ZEPHIR_LAST_CALL_STATUS; + zend_bool associative; + zval *data_param = NULL, *associative_param = NULL, *depth_param = NULL, *options_param = NULL, __$null, decoded, error, message, _0, _1, _2, _3$$3, _4$$3; + zval data; - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&reflection); - ZVAL_UNDEF(&comment); - ZVAL_UNDEF(&arrayKeys); - ZVAL_UNDEF(&classAnnotations); - ZVAL_UNDEF(&properties); - ZVAL_UNDEF(&property); - ZVAL_UNDEF(&annotationsProperties); - ZVAL_UNDEF(&propertyAnnotations); - ZVAL_UNDEF(&methods); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&annotationsMethods); - ZVAL_UNDEF(&methodAnnotations); - ZVAL_UNDEF(&constants); - ZVAL_UNDEF(&constant); - ZVAL_UNDEF(&anotationsConstants); - ZVAL_UNDEF(&constantAnnotations); - ZVAL_UNDEF(&constantReflection); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_5$$7); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_7$$10); - ZVAL_UNDEF(&_8$$10); - ZVAL_UNDEF(&_10$$13); - ZVAL_UNDEF(&_11$$15); - ZVAL_UNDEF(&_12$$15); - ZVAL_UNDEF(&_13$$16); - ZVAL_UNDEF(&_14$$18); - ZVAL_UNDEF(&_15$$18); - ZVAL_UNDEF(&_16$$19); - ZVAL_UNDEF(&_18$$21); - ZVAL_UNDEF(&_19$$23); - ZVAL_UNDEF(&_20$$23); - ZVAL_UNDEF(&_21$$24); - ZVAL_UNDEF(&_22$$26); - ZVAL_UNDEF(&_23$$26); - ZVAL_UNDEF(&_24$$27); - ZVAL_UNDEF(&annotations); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(className) + ZVAL_UNDEF(&data); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&decoded); + ZVAL_UNDEF(&error); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_STR(data) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(associative) + Z_PARAM_LONG(depth) + Z_PARAM_LONG(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &className_param); - zephir_get_strval(&className, className_param); - ZEPHIR_INIT_VAR(&annotations); - array_init(&annotations); - ZEPHIR_INIT_VAR(&reflection); - object_init_ex(&reflection, zephir_get_internal_ce(SL("reflectionclass"))); - ZEPHIR_CALL_METHOD(NULL, &reflection, "__construct", NULL, 154, &className); + zephir_fetch_params(1, 1, 3, &data_param, &associative_param, &depth_param, &options_param); + zephir_get_strval(&data, data_param); + if (!associative_param) { + associative = 0; + } else { + } + if (!depth_param) { + depth = 512; + } else { + } + if (!options_param) { + options = 79; + } else { + } + ZEPHIR_INIT_VAR(&decoded); + zephir_json_encode(&decoded, &__$null, 0 ); + ZVAL_BOOL(&_0, (associative ? 1 : 0)); + ZVAL_LONG(&_1, depth); + ZVAL_LONG(&_2, options); + ZEPHIR_INIT_NVAR(&decoded); + zephir_json_decode(&decoded, &data, zephir_get_intval(&_0) ); + ZEPHIR_CALL_FUNCTION(&error, "json_last_error", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&comment, &reflection, "getdoccomment", NULL, 160); + ZEPHIR_CALL_FUNCTION(&message, "json_last_error_msg", NULL, 0); zephir_check_call_status(); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&comment)) { - ZEPHIR_INIT_VAR(&classAnnotations); - ZEPHIR_CALL_METHOD(&_0$$3, &reflection, "getfilename", NULL, 161); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1$$3, &reflection, "getstartline", NULL, 162); - zephir_check_call_status(); - ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(&classAnnotations, &comment, &_0$$3, &_1$$3); + if (!ZEPHIR_IS_LONG_IDENTICAL(&error, 0)) { + ZEPHIR_INIT_VAR(&_3$$3); + zephir_json_encode(&_3$$3, &__$null, 0 ); + ZEPHIR_INIT_VAR(&_4$$3); + object_init_ex(&_4$$3, spl_ce_InvalidArgumentException); + ZEPHIR_CALL_METHOD(NULL, &_4$$3, "__construct", NULL, 200, &message, &error); zephir_check_call_status(); - if (Z_TYPE_P(&classAnnotations) == IS_ARRAY) { - zephir_array_update_string(&annotations, SL("class"), &classAnnotations, PH_COPY | PH_SEPARATE); - } + zephir_throw_exception_debug(&_4$$3, "phalcon/Support/Helper/Json/Decode.zep", 64); + ZEPHIR_MM_RESTORE(); + return; } - ZEPHIR_CALL_METHOD(&constants, &reflection, "getconstants", NULL, 163); - zephir_check_call_status(); - if (zephir_fast_count_int(&constants)) { - line = 1; - ZEPHIR_INIT_VAR(&arrayKeys); - zephir_array_keys(&arrayKeys, &constants); - ZEPHIR_INIT_VAR(&anotationsConstants); - array_init(&anotationsConstants); - zephir_is_iterable(&arrayKeys, 0, "phalcon/Annotations/Reader.zep", 92); - if (Z_TYPE_P(&arrayKeys) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&arrayKeys), _2$$5) - { - ZEPHIR_INIT_NVAR(&constant); - ZVAL_COPY(&constant, _2$$5); - ZEPHIR_CALL_METHOD(&constantReflection, &reflection, "getreflectionconstant", &_4, 164, &constant); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&comment, &constantReflection, "getdoccomment", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&comment)) { - ZEPHIR_INIT_NVAR(&constantAnnotations); - ZEPHIR_CALL_METHOD(&_5$$7, &reflection, "getfilename", NULL, 161); - zephir_check_call_status(); - ZVAL_LONG(&_6$$7, line); - ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(&constantAnnotations, &comment, &_5$$7, &_6$$7); - zephir_check_call_status(); - if (Z_TYPE_P(&constantAnnotations) == IS_ARRAY) { - zephir_array_update_zval(&anotationsConstants, &constant, &constantAnnotations, PH_COPY | PH_SEPARATE); - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &arrayKeys, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$5, &arrayKeys, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$5)) { - break; - } - ZEPHIR_CALL_METHOD(&constant, &arrayKeys, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&constantReflection, &reflection, "getreflectionconstant", &_4, 164, &constant); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&comment, &constantReflection, "getdoccomment", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&comment)) { - ZEPHIR_INIT_NVAR(&constantAnnotations); - ZEPHIR_CALL_METHOD(&_7$$10, &reflection, "getfilename", NULL, 161); - zephir_check_call_status(); - ZVAL_LONG(&_8$$10, line); - ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(&constantAnnotations, &comment, &_7$$10, &_8$$10); - zephir_check_call_status(); - if (Z_TYPE_P(&constantAnnotations) == IS_ARRAY) { - zephir_array_update_zval(&anotationsConstants, &constant, &constantAnnotations, PH_COPY | PH_SEPARATE); - } - } - ZEPHIR_CALL_METHOD(NULL, &arrayKeys, "next", NULL, 0); - zephir_check_call_status(); - } + RETURN_CCTOR(&decoded); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Json_Encode) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Json, Encode, phalcon, support_helper_json_encode, phalcon_support_helper_json_encode_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Json_Encode, __invoke) +{ + zval _4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long options, depth, ZEPHIR_LAST_CALL_STATUS; + zval *data, data_sub, *options_param = NULL, *depth_param = NULL, __$null, encoded, error, message, _0, _1, _2$$3, _3$$3; + + ZVAL_UNDEF(&data_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&encoded); + ZVAL_UNDEF(&error); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ZVAL(data) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(options) + Z_PARAM_LONG(depth) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &data, &options_param, &depth_param); + if (!options_param) { + options = 79; + } else { } - ZEPHIR_INIT_NVAR(&constant); - if (zephir_fast_count_int(&anotationsConstants)) { - zephir_array_update_string(&annotations, SL("constants"), &anotationsConstants, PH_COPY | PH_SEPARATE); + if (!depth_param) { + depth = 512; + } else { } - } - ZEPHIR_CALL_METHOD(&properties, &reflection, "getproperties", NULL, 165); + ZEPHIR_INIT_VAR(&encoded); + zephir_json_encode(&encoded, &__$null, 0 ); + ZVAL_LONG(&_0, options); + ZVAL_LONG(&_1, depth); + ZEPHIR_INIT_NVAR(&encoded); + zephir_json_encode(&encoded, data, zephir_get_intval(&_0) ); + ZEPHIR_CALL_FUNCTION(&error, "json_last_error", NULL, 0); zephir_check_call_status(); - if (zephir_fast_count_int(&properties)) { - line = 1; - ZEPHIR_INIT_VAR(&annotationsProperties); - array_init(&annotationsProperties); - zephir_is_iterable(&properties, 0, "phalcon/Annotations/Reader.zep", 130); - if (Z_TYPE_P(&properties) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&properties), _9$$13) - { - ZEPHIR_INIT_NVAR(&property); - ZVAL_COPY(&property, _9$$13); - ZEPHIR_CALL_METHOD(&comment, &property, "getdoccomment", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&comment)) { - ZEPHIR_INIT_NVAR(&propertyAnnotations); - ZEPHIR_CALL_METHOD(&_11$$15, &reflection, "getfilename", NULL, 161); - zephir_check_call_status(); - ZVAL_LONG(&_12$$15, line); - ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(&propertyAnnotations, &comment, &_11$$15, &_12$$15); - zephir_check_call_status(); - if (Z_TYPE_P(&propertyAnnotations) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&_13$$16); - zephir_read_property(&_13$$16, &property, ZEND_STRL("name"), PH_NOISY_CC); - zephir_array_update_zval(&annotationsProperties, &_13$$16, &propertyAnnotations, PH_COPY | PH_SEPARATE); - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &properties, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_10$$13, &properties, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_10$$13)) { - break; - } - ZEPHIR_CALL_METHOD(&property, &properties, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&comment, &property, "getdoccomment", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&comment)) { - ZEPHIR_INIT_NVAR(&propertyAnnotations); - ZEPHIR_CALL_METHOD(&_14$$18, &reflection, "getfilename", NULL, 161); - zephir_check_call_status(); - ZVAL_LONG(&_15$$18, line); - ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(&propertyAnnotations, &comment, &_14$$18, &_15$$18); - zephir_check_call_status(); - if (Z_TYPE_P(&propertyAnnotations) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&_16$$19); - zephir_read_property(&_16$$19, &property, ZEND_STRL("name"), PH_NOISY_CC); - zephir_array_update_zval(&annotationsProperties, &_16$$19, &propertyAnnotations, PH_COPY | PH_SEPARATE); - } - } - ZEPHIR_CALL_METHOD(NULL, &properties, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&property); - if (zephir_fast_count_int(&annotationsProperties)) { - zephir_array_update_string(&annotations, SL("properties"), &annotationsProperties, PH_COPY | PH_SEPARATE); - } - } - ZEPHIR_CALL_METHOD(&methods, &reflection, "getmethods", NULL, 166); + ZEPHIR_CALL_FUNCTION(&message, "json_last_error_msg", NULL, 0); zephir_check_call_status(); - if (0 == ZEPHIR_IS_EMPTY(&methods)) { - ZEPHIR_INIT_VAR(&annotationsMethods); - array_init(&annotationsMethods); - zephir_is_iterable(&methods, 0, "phalcon/Annotations/Reader.zep", 164); - if (Z_TYPE_P(&methods) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&methods), _17$$21) - { - ZEPHIR_INIT_NVAR(&method); - ZVAL_COPY(&method, _17$$21); - ZEPHIR_CALL_METHOD(&comment, &method, "getdoccomment", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&comment)) { - ZEPHIR_INIT_NVAR(&methodAnnotations); - ZEPHIR_CALL_METHOD(&_19$$23, &method, "getfilename", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_20$$23, &method, "getstartline", NULL, 0); - zephir_check_call_status(); - ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(&methodAnnotations, &comment, &_19$$23, &_20$$23); - zephir_check_call_status(); - if (Z_TYPE_P(&methodAnnotations) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&_21$$24); - zephir_read_property(&_21$$24, &method, ZEND_STRL("name"), PH_NOISY_CC); - zephir_array_update_zval(&annotationsMethods, &_21$$24, &methodAnnotations, PH_COPY | PH_SEPARATE); - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &methods, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_18$$21, &methods, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_18$$21)) { - break; - } - ZEPHIR_CALL_METHOD(&method, &methods, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&comment, &method, "getdoccomment", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&comment)) { - ZEPHIR_INIT_NVAR(&methodAnnotations); - ZEPHIR_CALL_METHOD(&_22$$26, &method, "getfilename", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_23$$26, &method, "getstartline", NULL, 0); - zephir_check_call_status(); - ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(&methodAnnotations, &comment, &_22$$26, &_23$$26); - zephir_check_call_status(); - if (Z_TYPE_P(&methodAnnotations) == IS_ARRAY) { - ZEPHIR_OBS_NVAR(&_24$$27); - zephir_read_property(&_24$$27, &method, ZEND_STRL("name"), PH_NOISY_CC); - zephir_array_update_zval(&annotationsMethods, &_24$$27, &methodAnnotations, PH_COPY | PH_SEPARATE); - } - } - ZEPHIR_CALL_METHOD(NULL, &methods, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&method); - if (zephir_fast_count_int(&annotationsMethods)) { - zephir_array_update_string(&annotations, SL("methods"), &annotationsMethods, PH_COPY | PH_SEPARATE); - } + if (!ZEPHIR_IS_LONG_IDENTICAL(&error, 0)) { + ZEPHIR_INIT_VAR(&_2$$3); + zephir_json_encode(&_2$$3, &__$null, 0 ); + ZEPHIR_INIT_VAR(&_3$$3); + object_init_ex(&_3$$3, spl_ce_InvalidArgumentException); + ZEPHIR_CALL_METHOD(NULL, &_3$$3, "__construct", NULL, 200, &message, &error); + zephir_check_call_status(); + zephir_throw_exception_debug(&_3$$3, "phalcon/Support/Helper/Json/Encode.zep", 64); + ZEPHIR_MM_RESTORE(); + return; } - RETURN_CTOR(&annotations); + zephir_cast_to_string(&_4, &encoded); + RETURN_CTOR(&_4); } -static PHP_METHOD(Phalcon_Annotations_Reader, parseDocBlock) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_AbstractArr) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, AbstractArr, phalcon, support_helper_arr_abstractarr, phalcon_support_helper_arr_abstractarr_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Arr_AbstractArr, toFilter) { + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *docBlock_param = NULL, *file = NULL, file_sub, *line = NULL, line_sub, __$null; - zval docBlock; + zval *collection_param = NULL, *method = NULL, method_sub, __$null; + zval collection; - ZVAL_UNDEF(&docBlock); - ZVAL_UNDEF(&file_sub); - ZVAL_UNDEF(&line_sub); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&method_sub); ZVAL_NULL(&__$null); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(docBlock) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(collection) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(file) - Z_PARAM_ZVAL_OR_NULL(line) + Z_PARAM_ZVAL_OR_NULL(method) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &docBlock_param, &file, &line); - zephir_get_strval(&docBlock, docBlock_param); - if (!file) { - file = &file_sub; - ZEPHIR_CPY_WRT(file, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(file); + zephir_fetch_params(1, 1, 1, &collection_param, &method); + zephir_get_arrval(&collection, collection_param); + if (!method) { + method = &method_sub; + method = &__$null; } - if (!line) { - line = &line_sub; - line = &__$null; + _0 = !zephir_is_true(method); + if (!(_0)) { + _0 = !(zephir_is_callable(method)); } - if (Z_TYPE_P(file) != IS_STRING) { - ZEPHIR_INIT_NVAR(file); - ZVAL_STRING(file, "eval code"); + if (_0) { + RETURN_CTOR(&collection); } - ZEPHIR_LAST_CALL_STATUS = phannot_parse_annotations(return_value, &docBlock, file, line); + ZEPHIR_RETURN_CALL_FUNCTION("array_filter", NULL, 17, &collection, method); zephir_check_call_status(); RETURN_MM(); } @@ -140078,15 +140063,47 @@ static PHP_METHOD(Phalcon_Annotations_Reader, parseDocBlock) -ZEPHIR_INIT_CLASS(Phalcon_Annotations_ReaderInterface) +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Blacklist) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Annotations, ReaderInterface, phalcon, annotations_readerinterface, phalcon_annotations_readerinterface_method_entry); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Arr, Blacklist, phalcon, support_helper_arr_blacklist, phalcon_support_helper_arr_abstractarr_ce, phalcon_support_helper_arr_blacklist_method_entry, 0); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Annotations_ReaderInterface, parse); -ZEPHIR_DOC_METHOD(Phalcon_Annotations_ReaderInterface, parseDocBlock); +static PHP_METHOD(Phalcon_Support_Helper_Arr_Blacklist, __invoke) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *collection_param = NULL, *blackList_param = NULL, blackListed, _0, _1; + zval collection, blackList; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&blackList); + ZVAL_UNDEF(&blackListed); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ARRAY(collection) + Z_PARAM_ARRAY(blackList) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &collection_param, &blackList_param); + zephir_get_arrval(&collection, collection_param); + zephir_get_arrval(&blackList, blackList_param); + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_INIT_NVAR(&_0); + zephir_create_closure_ex(&_0, NULL, phalcon_12__closure_ce, SL("__invoke")); + ZEPHIR_CALL_METHOD(&blackListed, this_ptr, "tofilter", NULL, 0, &blackList, &_0); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_1, "array_flip", NULL, 100, &blackListed); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_FUNCTION("array_diff_key", NULL, 99, &collection, &_1); + zephir_check_call_status(); + RETURN_MM(); +} + @@ -140097,1235 +140114,474 @@ ZEPHIR_DOC_METHOD(Phalcon_Annotations_ReaderInterface, parseDocBlock); -ZEPHIR_INIT_CLASS(Phalcon_Annotations_Reflection) +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Chunk) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Annotations, Reflection, phalcon, annotations_reflection, phalcon_annotations_reflection_method_entry, 0); - - zend_declare_property_null(phalcon_annotations_reflection_ce, SL("classAnnotations"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_annotations_reflection_ce, SL("constantAnnotations"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_annotations_reflection_ce, SL("propertyAnnotations"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_annotations_reflection_ce, SL("methodAnnotations"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_annotations_reflection_ce, SL("reflectionData"), ZEND_ACC_PROTECTED); - phalcon_annotations_reflection_ce->create_object = zephir_init_properties_Phalcon_Annotations_Reflection; + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, Chunk, phalcon, support_helper_arr_chunk, phalcon_support_helper_arr_chunk_method_entry, 0); return SUCCESS; } -static PHP_METHOD(Phalcon_Annotations_Reflection, __construct) +static PHP_METHOD(Phalcon_Support_Helper_Arr_Chunk, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *reflectionData_param = NULL; - zval reflectionData; - zval *this_ptr = getThis(); + zend_bool preserveKeys; + zend_long size, ZEPHIR_LAST_CALL_STATUS; + zval *collection_param = NULL, *size_param = NULL, *preserveKeys_param = NULL, _0, _1; + zval collection; - ZVAL_UNDEF(&reflectionData); - ZEND_PARSE_PARAMETERS_START(0, 1) + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ARRAY(collection) + Z_PARAM_LONG(size) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(reflectionData) + Z_PARAM_BOOL(preserveKeys) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &reflectionData_param); - if (!reflectionData_param) { - ZEPHIR_INIT_VAR(&reflectionData); - array_init(&reflectionData); + zephir_fetch_params(1, 2, 1, &collection_param, &size_param, &preserveKeys_param); + zephir_get_arrval(&collection, collection_param); + if (!preserveKeys_param) { + preserveKeys = 0; } else { - zephir_get_arrval(&reflectionData, reflectionData_param); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("reflectionData"), &reflectionData); - ZEPHIR_MM_RESTORE(); + } + ZVAL_LONG(&_0, size); + ZVAL_BOOL(&_1, (preserveKeys ? 1 : 0)); + ZEPHIR_RETURN_CALL_FUNCTION("array_chunk", NULL, 0, &collection, &_0, &_1); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Annotations_Reflection, getClassAnnotations) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Filter) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Arr, Filter, phalcon, support_helper_arr_filter, phalcon_support_helper_arr_abstractarr_ce, phalcon_support_helper_arr_filter_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Arr_Filter, __invoke) { - zval reflectionClass, _0, _1$$3, _2$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *collection_param = NULL, *method = NULL, method_sub, __$null; + zval collection; zval *this_ptr = getThis(); - ZVAL_UNDEF(&reflectionClass); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&method_sub); + ZVAL_NULL(&__$null); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(collection) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(method) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("classAnnotations"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - zephir_memory_observe(&reflectionClass); - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("reflectionData"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_string_fetch(&reflectionClass, &_1$$3, SL("class"), 0)) { - ZEPHIR_INIT_VAR(&_2$$4); - object_init_ex(&_2$$4, phalcon_annotations_collection_ce); - ZEPHIR_CALL_METHOD(NULL, &_2$$4, "__construct", NULL, 38, &reflectionClass); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("classAnnotations"), &_2$$4); - } + zephir_fetch_params(1, 1, 1, &collection_param, &method); + zephir_get_arrval(&collection, collection_param); + if (!method) { + method = &method_sub; + method = &__$null; } - RETURN_MM_MEMBER(getThis(), "classAnnotations"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "tofilter", NULL, 0, &collection, method); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Annotations_Reflection, getConstantsAnnotations) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_First) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Arr, First, phalcon, support_helper_arr_first, phalcon_support_helper_arr_abstractarr_ce, phalcon_support_helper_arr_first_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Arr_First, __invoke) { - zend_string *_5$$4; - zend_ulong _4$$4; - zend_bool _1$$3; - zval reflectionConstants, constant, reflectionConstant, _0, *_2$$4, _3$$4, _6$$5, _8$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *collection_param = NULL, *method = NULL, method_sub, __$null, filtered; + zval collection; zval *this_ptr = getThis(); - ZVAL_UNDEF(&reflectionConstants); - ZVAL_UNDEF(&constant); - ZVAL_UNDEF(&reflectionConstant); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&method_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&filtered); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(collection) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(method) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_memory_observe(&reflectionConstants); - zephir_read_property(&_0, this_ptr, ZEND_STRL("reflectionData"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_string_fetch(&reflectionConstants, &_0, SL("constants"), 0)) { - _1$$3 = Z_TYPE_P(&reflectionConstants) == IS_ARRAY; - if (_1$$3) { - _1$$3 = zephir_fast_count_int(&reflectionConstants) > 0; - } - if (_1$$3) { - zephir_is_iterable(&reflectionConstants, 0, "phalcon/Annotations/Reflection.zep", 97); - if (Z_TYPE_P(&reflectionConstants) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&reflectionConstants), _4$$4, _5$$4, _2$$4) - { - ZEPHIR_INIT_NVAR(&constant); - if (_5$$4 != NULL) { - ZVAL_STR_COPY(&constant, _5$$4); - } else { - ZVAL_LONG(&constant, _4$$4); - } - ZEPHIR_INIT_NVAR(&reflectionConstant); - ZVAL_COPY(&reflectionConstant, _2$$4); - ZEPHIR_INIT_NVAR(&_6$$5); - object_init_ex(&_6$$5, phalcon_annotations_collection_ce); - ZEPHIR_CALL_METHOD(NULL, &_6$$5, "__construct", &_7, 38, &reflectionConstant); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("constantAnnotations"), &constant, &_6$$5); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &reflectionConstants, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$4, &reflectionConstants, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$4)) { - break; - } - ZEPHIR_CALL_METHOD(&constant, &reflectionConstants, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&reflectionConstant, &reflectionConstants, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_8$$6); - object_init_ex(&_8$$6, phalcon_annotations_collection_ce); - ZEPHIR_CALL_METHOD(NULL, &_8$$6, "__construct", &_7, 38, &reflectionConstant); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("constantAnnotations"), &constant, &_8$$6); - ZEPHIR_CALL_METHOD(NULL, &reflectionConstants, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&reflectionConstant); - ZEPHIR_INIT_NVAR(&constant); - } + zephir_fetch_params(1, 1, 1, &collection_param, &method); + zephir_get_arrval(&collection, collection_param); + if (!method) { + method = &method_sub; + method = &__$null; } - RETURN_MM_MEMBER(getThis(), "constantAnnotations"); + ZEPHIR_CALL_METHOD(&filtered, this_ptr, "tofilter", NULL, 0, &collection, method); + zephir_check_call_status(); + ZEPHIR_MAKE_REF(&filtered); + ZEPHIR_RETURN_CALL_FUNCTION("reset", NULL, 477, &filtered); + ZEPHIR_UNREF(&filtered); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Annotations_Reflection, getPropertiesAnnotations) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_FirstKey) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Arr, FirstKey, phalcon, support_helper_arr_firstkey, phalcon_support_helper_arr_abstractarr_ce, phalcon_support_helper_arr_firstkey_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Arr_FirstKey, __invoke) { - zend_string *_5$$4; - zend_ulong _4$$4; - zend_bool _1$$3; - zval reflectionProperties, property, reflectionProperty, _0, *_2$$4, _3$$4, _6$$5, _8$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *collection_param = NULL, *method = NULL, method_sub, __$null, filtered; + zval collection; zval *this_ptr = getThis(); - ZVAL_UNDEF(&reflectionProperties); - ZVAL_UNDEF(&property); - ZVAL_UNDEF(&reflectionProperty); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&method_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&filtered); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(collection) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(method) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_memory_observe(&reflectionProperties); - zephir_read_property(&_0, this_ptr, ZEND_STRL("reflectionData"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_string_fetch(&reflectionProperties, &_0, SL("properties"), 0)) { - _1$$3 = Z_TYPE_P(&reflectionProperties) == IS_ARRAY; - if (_1$$3) { - _1$$3 = zephir_fast_count_int(&reflectionProperties) > 0; - } - if (_1$$3) { - zephir_is_iterable(&reflectionProperties, 0, "phalcon/Annotations/Reflection.zep", 119); - if (Z_TYPE_P(&reflectionProperties) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&reflectionProperties), _4$$4, _5$$4, _2$$4) - { - ZEPHIR_INIT_NVAR(&property); - if (_5$$4 != NULL) { - ZVAL_STR_COPY(&property, _5$$4); - } else { - ZVAL_LONG(&property, _4$$4); - } - ZEPHIR_INIT_NVAR(&reflectionProperty); - ZVAL_COPY(&reflectionProperty, _2$$4); - ZEPHIR_INIT_NVAR(&_6$$5); - object_init_ex(&_6$$5, phalcon_annotations_collection_ce); - ZEPHIR_CALL_METHOD(NULL, &_6$$5, "__construct", &_7, 38, &reflectionProperty); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("propertyAnnotations"), &property, &_6$$5); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &reflectionProperties, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$4, &reflectionProperties, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$4)) { - break; - } - ZEPHIR_CALL_METHOD(&property, &reflectionProperties, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&reflectionProperty, &reflectionProperties, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_8$$6); - object_init_ex(&_8$$6, phalcon_annotations_collection_ce); - ZEPHIR_CALL_METHOD(NULL, &_8$$6, "__construct", &_7, 38, &reflectionProperty); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("propertyAnnotations"), &property, &_8$$6); - ZEPHIR_CALL_METHOD(NULL, &reflectionProperties, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&reflectionProperty); - ZEPHIR_INIT_NVAR(&property); - } + zephir_fetch_params(1, 1, 1, &collection_param, &method); + zephir_get_arrval(&collection, collection_param); + if (!method) { + method = &method_sub; + method = &__$null; } - RETURN_MM_MEMBER(getThis(), "propertyAnnotations"); + ZEPHIR_CALL_METHOD(&filtered, this_ptr, "tofilter", NULL, 0, &collection, method); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_FUNCTION("array_key_first", NULL, 0, &filtered); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Annotations_Reflection, getMethodsAnnotations) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Flatten) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, Flatten, phalcon, support_helper_arr_flatten, phalcon_support_helper_arr_flatten_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Arr_Flatten, __invoke) { - zend_string *_5$$4; - zend_ulong _4$$4; - zend_bool _1$$3; - zval reflectionMethods, methodName, reflectionMethod, _0, *_2$$4, _3$$4, _6$$5, _8$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL; + zephir_fcall_cache_entry *_3 = NULL, *_5 = NULL, *_7 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool deep; + zval *collection_param = NULL, *deep_param = NULL, data, item, *_0, _1, _2$$3, _4$$3, _6$$3, _8$$4, _9$$4, _10$$4; + zval collection; zval *this_ptr = getThis(); - ZVAL_UNDEF(&reflectionMethods); - ZVAL_UNDEF(&methodName); - ZVAL_UNDEF(&reflectionMethod); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&item); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_8$$4); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&_10$$4); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(collection) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(deep) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_memory_observe(&reflectionMethods); - zephir_read_property(&_0, this_ptr, ZEND_STRL("reflectionData"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_string_fetch(&reflectionMethods, &_0, SL("methods"), 0)) { - _1$$3 = Z_TYPE_P(&reflectionMethods) == IS_ARRAY; - if (_1$$3) { - _1$$3 = zephir_fast_count_int(&reflectionMethods) > 0; + zephir_fetch_params(1, 1, 1, &collection_param, &deep_param); + zephir_get_arrval(&collection, collection_param); + if (!deep_param) { + deep = 0; + } else { } - if (_1$$3) { - zephir_is_iterable(&reflectionMethods, 0, "phalcon/Annotations/Reflection.zep", 141); - if (Z_TYPE_P(&reflectionMethods) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&reflectionMethods), _4$$4, _5$$4, _2$$4) - { - ZEPHIR_INIT_NVAR(&methodName); - if (_5$$4 != NULL) { - ZVAL_STR_COPY(&methodName, _5$$4); - } else { - ZVAL_LONG(&methodName, _4$$4); - } - ZEPHIR_INIT_NVAR(&reflectionMethod); - ZVAL_COPY(&reflectionMethod, _2$$4); - ZEPHIR_INIT_NVAR(&_6$$5); - object_init_ex(&_6$$5, phalcon_annotations_collection_ce); - ZEPHIR_CALL_METHOD(NULL, &_6$$5, "__construct", &_7, 38, &reflectionMethod); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("methodAnnotations"), &methodName, &_6$$5); - } ZEND_HASH_FOREACH_END(); + ZEPHIR_INIT_VAR(&data); + array_init(&data); + zephir_is_iterable(&collection, 0, "phalcon/Support/Helper/Arr/Flatten.zep", 37); + if (Z_TYPE_P(&collection) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&collection), _0) + { + ZEPHIR_INIT_NVAR(&item); + ZVAL_COPY(&item, _0); + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "processnotarray", &_3, 0, &data, &item); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&data, &_2$$3); + if (deep) { + ZVAL_BOOL(&_4$$3, 1); } else { - ZEPHIR_CALL_METHOD(NULL, &reflectionMethods, "rewind", NULL, 0); + ZVAL_BOOL(&_4$$3, 0); + } + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "processarraydeep", &_5, 0, &data, &item, &_4$$3); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&data, &_2$$3); + if (deep) { + ZVAL_BOOL(&_6$$3, 1); + } else { + ZVAL_BOOL(&_6$$3, 0); + } + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "processarray", &_7, 0, &data, &item, &_6$$3); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&data, &_2$$3); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &collection, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &collection, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&item, &collection, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_8$$4, this_ptr, "processnotarray", &_3, 0, &data, &item); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$4, &reflectionMethods, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$4)) { - break; - } - ZEPHIR_CALL_METHOD(&methodName, &reflectionMethods, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&reflectionMethod, &reflectionMethods, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_8$$6); - object_init_ex(&_8$$6, phalcon_annotations_collection_ce); - ZEPHIR_CALL_METHOD(NULL, &_8$$6, "__construct", &_7, 38, &reflectionMethod); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("methodAnnotations"), &methodName, &_8$$6); - ZEPHIR_CALL_METHOD(NULL, &reflectionMethods, "next", NULL, 0); - zephir_check_call_status(); + ZEPHIR_CPY_WRT(&data, &_8$$4); + if (deep) { + ZVAL_BOOL(&_9$$4, 1); + } else { + ZVAL_BOOL(&_9$$4, 0); + } + ZEPHIR_CALL_METHOD(&_8$$4, this_ptr, "processarraydeep", &_5, 0, &data, &item, &_9$$4); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&data, &_8$$4); + if (deep) { + ZVAL_BOOL(&_10$$4, 1); + } else { + ZVAL_BOOL(&_10$$4, 0); } - } - ZEPHIR_INIT_NVAR(&reflectionMethod); - ZEPHIR_INIT_NVAR(&methodName); + ZEPHIR_CALL_METHOD(&_8$$4, this_ptr, "processarray", &_7, 0, &data, &item, &_10$$4); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&data, &_8$$4); + ZEPHIR_CALL_METHOD(NULL, &collection, "next", NULL, 0); + zephir_check_call_status(); } } - RETURN_MM_MEMBER(getThis(), "methodAnnotations"); + ZEPHIR_INIT_NVAR(&item); + RETURN_CCTOR(&data); } -static PHP_METHOD(Phalcon_Annotations_Reflection, getReflectionData) +static PHP_METHOD(Phalcon_Support_Helper_Arr_Flatten, processNotArray) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *data_param = NULL, *item, item_sub; + zval data; - RETURN_MEMBER(getThis(), "reflectionData"); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&item_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ARRAY(data) + Z_PARAM_ZVAL(item) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &data_param, &item); + zephir_get_arrval(&data, data_param); + if (Z_TYPE_P(item) != IS_ARRAY) { + zephir_array_append(&data, item, PH_SEPARATE, "phalcon/Support/Helper/Arr/Flatten.zep", 49); + } + RETURN_CTOR(&data); } -zend_object *zephir_init_properties_Phalcon_Annotations_Reflection(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Support_Helper_Arr_Flatten, processArray) { - zval _0, _2, _4, _6, _1$$3, _3$$4, _5$$5, _7$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_7$$6); - + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool deep, _0; + zval *data_param = NULL, *item, item_sub, *deep_param = NULL, _1$$3, _2$$3; + zval data; - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("reflectionData"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("reflectionData"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("methodAnnotations"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("methodAnnotations"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("propertyAnnotations"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("propertyAnnotations"), &_5$$5); - } - zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("constantAnnotations"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_6) == IS_NULL) { - ZEPHIR_INIT_VAR(&_7$$6); - array_init(&_7$$6); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("constantAnnotations"), &_7$$6); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&item_sub); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ARRAY(data) + Z_PARAM_ZVAL(item) + Z_PARAM_BOOL(deep) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 0, &data_param, &item, &deep_param); + zephir_get_arrval(&data, data_param); + _0 = Z_TYPE_P(item) == IS_ARRAY; + if (_0) { + _0 = !deep; + } + if (_0) { + ZEPHIR_INIT_VAR(&_1$$3); + ZEPHIR_CALL_FUNCTION(&_2$$3, "array_values", NULL, 14, item); + zephir_check_call_status(); + zephir_fast_array_merge(&_1$$3, &data, &_2$$3); + ZEPHIR_CPY_WRT(&data, &_1$$3); } + RETURN_CTOR(&data); } +static PHP_METHOD(Phalcon_Support_Helper_Arr_Flatten, processArrayDeep) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool deep, _0; + zval *data_param = NULL, *item, item_sub, *deep_param = NULL, _1$$3, _2$$3, _3$$3; + zval data; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&item_sub); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ARRAY(data) + Z_PARAM_ZVAL(item) + Z_PARAM_BOOL(deep) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 0, &data_param, &item, &deep_param); + zephir_get_arrval(&data, data_param); + _0 = Z_TYPE_P(item) == IS_ARRAY; + if (_0) { + _0 = deep; + } + if (_0) { + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_BOOL(&_3$$3, 1); + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "__invoke", NULL, 0, item, &_3$$3); + zephir_check_call_status(); + zephir_fast_array_merge(&_1$$3, &data, &_2$$3); + ZEPHIR_CPY_WRT(&data, &_1$$3); + } + RETURN_CTOR(&data); +} -/* Generated by re2c 1.1.1 */ -/* scanner.re - * This file is part of the Phalcon Framework. - * - * (c) Phalcon Team - * - * For the full copyright and license information, please view the - * LICENSE.txt file that was distributed with this source code. - */ - - - -#define AACTYPE unsigned char -#define AACURSOR (s->start) -#define AALIMIT (s->end) -#define AAMARKER q - -static int phannot_get_token(phannot_scanner_state *s, phannot_scanner_token *token) { - char next, *q = AACURSOR, *start = AACURSOR; - int status = PHANNOT_SCANNER_RETCODE_IMPOSSIBLE; - while (PHANNOT_SCANNER_RETCODE_IMPOSSIBLE == status) { - if (s->mode == PHANNOT_MODE_RAW) { +#ifdef HAVE_CONFIG_H +#endif - if (*AACURSOR == '\n') { - s->active_line++; - } - next = *(AACURSOR+1); - if (*AACURSOR == '\0' || *AACURSOR == '@') { - if ((next >= 'A' && next <= 'Z') || (next >= 'a' && next <= 'z')) { - s->mode = PHANNOT_MODE_ANNOTATION; - continue; - } - } - ++AACURSOR; - token->opcode = PHANNOT_T_IGNORE; - return 0; - } else { +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Get) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, Get, phalcon, support_helper_arr_get, phalcon_support_helper_arr_get_method_entry, 0); - - { - AACTYPE aach; - unsigned int aaaccept = 0; - aach = *AACURSOR; - switch (aach) { - case 0x00: goto aa2; - case '\t': - case '\r': - case ' ': goto aa6; - case '\n': goto aa9; - case '"': goto aa11; - case '\'': goto aa12; - case '(': goto aa13; - case ')': goto aa15; - case ',': goto aa17; - case '-': goto aa19; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto aa20; - case ':': goto aa23; - case '=': goto aa25; - case '@': goto aa27; - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto aa29; - case 'F': - case 'f': goto aa32; - case 'N': - case 'n': goto aa33; - case 'T': - case 't': goto aa34; - case '[': goto aa35; - case '\\': goto aa37; - case ']': goto aa38; - case '{': goto aa40; - case '}': goto aa42; - default: goto aa4; - } -aa2: - ++AACURSOR; - { - status = PHANNOT_SCANNER_RETCODE_EOF; - break; - } -aa4: - ++AACURSOR; -aa5: - { - status = PHANNOT_SCANNER_RETCODE_ERR; - break; - } -aa6: - aach = *++AACURSOR; - switch (aach) { - case '\t': - case '\r': - case ' ': goto aa6; - default: goto aa8; - } -aa8: - { - token->opcode = PHANNOT_T_IGNORE; - return 0; - } -aa9: - ++AACURSOR; - { - s->active_line++; - token->opcode = PHANNOT_T_IGNORE; - return 0; - } -aa11: - aaaccept = 0; - aach = *(AAMARKER = ++AACURSOR); - if (aach <= 0x00) goto aa5; - goto aa45; -aa12: - aaaccept = 0; - aach = *(AAMARKER = ++AACURSOR); - if (aach <= 0x00) goto aa5; - goto aa51; -aa13: - ++AACURSOR; - { - token->opcode = PHANNOT_T_PARENTHESES_OPEN; - return 0; - } -aa15: - ++AACURSOR; - { - token->opcode = PHANNOT_T_PARENTHESES_CLOSE; - return 0; - } -aa17: - ++AACURSOR; - { - token->opcode = PHANNOT_T_COMMA; - return 0; - } -aa19: - aach = *++AACURSOR; - switch (aach) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto aa20; - default: goto aa5; - } -aa20: - aaaccept = 1; - aach = *(AAMARKER = ++AACURSOR); - switch (aach) { - case '.': goto aa53; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto aa20; - default: goto aa22; - } -aa22: - { - token->opcode = PHANNOT_T_INTEGER; - token->value = estrndup(start, AACURSOR - start); - token->len = AACURSOR - start; - q = AACURSOR; - return 0; - } -aa23: - ++AACURSOR; - { - token->opcode = PHANNOT_T_COLON; - return 0; - } -aa25: - ++AACURSOR; - { - token->opcode = PHANNOT_T_EQUALS; - return 0; - } -aa27: - ++AACURSOR; - { - token->opcode = PHANNOT_T_AT; - return 0; - } -aa29: - aaaccept = 2; - aach = *(AAMARKER = ++AACURSOR); -aa30: - switch (aach) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto aa29; - case '\\': goto aa54; - default: goto aa31; - } -aa31: - { - token->opcode = PHANNOT_T_IDENTIFIER; - token->value = estrndup(start, AACURSOR - start); - token->len = AACURSOR - start; - q = AACURSOR; - return 0; - } -aa32: - aaaccept = 2; - aach = *(AAMARKER = ++AACURSOR); - switch (aach) { - case 'A': - case 'a': goto aa55; - default: goto aa30; - } -aa33: - aaaccept = 2; - aach = *(AAMARKER = ++AACURSOR); - switch (aach) { - case 'U': - case 'u': goto aa56; - default: goto aa30; - } -aa34: - aaaccept = 2; - aach = *(AAMARKER = ++AACURSOR); - switch (aach) { - case 'R': - case 'r': goto aa57; - default: goto aa30; - } -aa35: - ++AACURSOR; - { - token->opcode = PHANNOT_T_SBRACKET_OPEN; - return 0; - } -aa37: - aach = *++AACURSOR; - switch (aach) { - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto aa29; - default: goto aa5; - } -aa38: - ++AACURSOR; - { - token->opcode = PHANNOT_T_SBRACKET_CLOSE; - return 0; - } -aa40: - ++AACURSOR; - { - token->opcode = PHANNOT_T_BRACKET_OPEN; - return 0; - } -aa42: - ++AACURSOR; - { - token->opcode = PHANNOT_T_BRACKET_CLOSE; - return 0; - } -aa44: - aach = *++AACURSOR; -aa45: - switch (aach) { - case 0x00: goto aa46; - case '"': goto aa47; - case '\\': goto aa49; - default: goto aa44; - } -aa46: - AACURSOR = AAMARKER; - switch (aaaccept) { - case 0: goto aa5; - case 1: goto aa22; - case 2: goto aa31; - case 3: goto aa66; - case 4: goto aa68; - default: goto aa70; - } -aa47: - ++AACURSOR; - { - token->opcode = PHANNOT_T_STRING; - token->value = estrndup(q, AACURSOR - q - 1); - token->len = AACURSOR - q - 1; - q = AACURSOR; - return 0; - } -aa49: - aach = *++AACURSOR; - switch (aach) { - case '\n': goto aa46; - default: goto aa44; - } -aa50: - aach = *++AACURSOR; -aa51: - switch (aach) { - case 0x00: goto aa46; - case '\'': goto aa47; - case '\\': goto aa52; - default: goto aa50; - } -aa52: - aach = *++AACURSOR; - switch (aach) { - case '\n': goto aa46; - default: goto aa50; - } -aa53: - aach = *++AACURSOR; - switch (aach) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto aa58; - default: goto aa46; - } -aa54: - aach = *++AACURSOR; - switch (aach) { - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto aa29; - default: goto aa46; - } -aa55: - aaaccept = 2; - aach = *(AAMARKER = ++AACURSOR); - switch (aach) { - case 'L': - case 'l': goto aa61; - default: goto aa30; - } -aa56: - aaaccept = 2; - aach = *(AAMARKER = ++AACURSOR); - switch (aach) { - case 'L': - case 'l': goto aa62; - default: goto aa30; - } -aa57: - aaaccept = 2; - aach = *(AAMARKER = ++AACURSOR); - switch (aach) { - case 'U': - case 'u': goto aa63; - default: goto aa30; - } -aa58: - aach = *++AACURSOR; - switch (aach) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': goto aa58; - default: goto aa60; - } -aa60: - { - token->opcode = PHANNOT_T_DOUBLE; - token->value = estrndup(start, AACURSOR - start); - token->len = AACURSOR - start; - q = AACURSOR; - return 0; - } -aa61: - aaaccept = 2; - aach = *(AAMARKER = ++AACURSOR); - switch (aach) { - case 'S': - case 's': goto aa64; - default: goto aa30; - } -aa62: - aaaccept = 2; - aach = *(AAMARKER = ++AACURSOR); - switch (aach) { - case 'L': - case 'l': goto aa65; - default: goto aa30; - } -aa63: - aaaccept = 2; - aach = *(AAMARKER = ++AACURSOR); - switch (aach) { - case 'E': - case 'e': goto aa67; - default: goto aa30; - } -aa64: - aaaccept = 2; - aach = *(AAMARKER = ++AACURSOR); - switch (aach) { - case 'E': - case 'e': goto aa69; - default: goto aa30; - } -aa65: - aaaccept = 3; - aach = *(AAMARKER = ++AACURSOR); - switch (aach) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto aa29; - case '\\': goto aa54; - default: goto aa66; - } -aa66: - { - token->opcode = PHANNOT_T_NULL; - return 0; - } -aa67: - aaaccept = 4; - aach = *(AAMARKER = ++AACURSOR); - switch (aach) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto aa29; - case '\\': goto aa54; - default: goto aa68; - } -aa68: - { - token->opcode = PHANNOT_T_TRUE; - return 0; - } -aa69: - aaaccept = 5; - aach = *(AAMARKER = ++AACURSOR); - switch (aach) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F': - case 'G': - case 'H': - case 'I': - case 'J': - case 'K': - case 'L': - case 'M': - case 'N': - case 'O': - case 'P': - case 'Q': - case 'R': - case 'S': - case 'T': - case 'U': - case 'V': - case 'W': - case 'X': - case 'Y': - case 'Z': - case '_': - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - case 'h': - case 'i': - case 'j': - case 'k': - case 'l': - case 'm': - case 'n': - case 'o': - case 'p': - case 'q': - case 'r': - case 's': - case 't': - case 'u': - case 'v': - case 'w': - case 'x': - case 'y': - case 'z': goto aa29; - case '\\': goto aa54; - default: goto aa70; - } -aa70: - { - token->opcode = PHANNOT_T_FALSE; - return 0; - } - } + return SUCCESS; +} +static PHP_METHOD(Phalcon_Support_Helper_Arr_Get, __invoke) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval cast; + zval *collection_param = NULL, *index, index_sub, *defaultValue = NULL, defaultValue_sub, *cast_param = NULL, __$null, value; + zval collection; - } + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&cast); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_ARRAY(collection) + Z_PARAM_ZVAL(index) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(defaultValue) + Z_PARAM_STR_OR_NULL(cast) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 2, &collection_param, &index, &defaultValue, &cast_param); + zephir_get_arrval(&collection, collection_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; } - - return status; + if (!cast_param) { + ZEPHIR_INIT_VAR(&cast); + } else { + zephir_get_strval(&cast, cast_param); + } + ZEPHIR_CPY_WRT(&value, defaultValue); + if (1 == zephir_array_isset(&collection, index)) { + ZEPHIR_OBS_NVAR(&value); + zephir_array_fetch(&value, &collection, index, PH_NOISY, "phalcon/Support/Helper/Arr/Get.zep", 38); + } + if (!(ZEPHIR_IS_EMPTY(&cast))) { + ZEPHIR_MAKE_REF(&value); + ZEPHIR_CALL_FUNCTION(NULL, "settype", NULL, 11, &value, &cast); + ZEPHIR_UNREF(&value); + zephir_check_call_status(); + } + RETURN_CCTOR(&value); } + #ifdef HAVE_CONFIG_H #endif @@ -141333,358 +140589,561 @@ static int phannot_get_token(phannot_scanner_state *s, phannot_scanner_token *to -ZEPHIR_INIT_CLASS(Phalcon_Annotations_Adapter_AbstractAdapter) +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Group) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Annotations\\Adapter, AbstractAdapter, phalcon, annotations_adapter_abstractadapter, phalcon_annotations_adapter_abstractadapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_null(phalcon_annotations_adapter_abstractadapter_ce, SL("annotations"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_annotations_adapter_abstractadapter_ce, SL("reader"), ZEND_ACC_PROTECTED); - phalcon_annotations_adapter_abstractadapter_ce->create_object = zephir_init_properties_Phalcon_Annotations_Adapter_AbstractAdapter; + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, Group, phalcon, support_helper_arr_group, phalcon_support_helper_arr_group_method_entry, 0); - zend_class_implements(phalcon_annotations_adapter_abstractadapter_ce, 1, phalcon_annotations_adapter_adapterinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Annotations_Adapter_AbstractAdapter, get) +static PHP_METHOD(Phalcon_Support_Helper_Arr_Group, __invoke) { - zend_bool _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL, *_5 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *className, className_sub, classAnnotations, parsedAnnotations, realClassName, reader, _0, _1$$5, _2$$5; + zval *collection_param = NULL, *method, method_sub, element, filtered, *_0, _1, _2$$3, _6$$4; + zval collection; zval *this_ptr = getThis(); - ZVAL_UNDEF(&className_sub); - ZVAL_UNDEF(&classAnnotations); - ZVAL_UNDEF(&parsedAnnotations); - ZVAL_UNDEF(&realClassName); - ZVAL_UNDEF(&reader); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$5); - ZVAL_UNDEF(&_2$$5); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(className) + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&method_sub); + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&filtered); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_6$$4); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ARRAY(collection) + Z_PARAM_ZVAL(method) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &className); - if (Z_TYPE_P(className) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&realClassName); - zephir_get_class(&realClassName, className, 0); + zephir_fetch_params(1, 2, 0, &collection_param, &method); + zephir_get_arrval(&collection, collection_param); + ZEPHIR_INIT_VAR(&filtered); + array_init(&filtered); + zephir_is_iterable(&collection, 0, "phalcon/Support/Helper/Arr/Group.zep", 36); + if (Z_TYPE_P(&collection) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&collection), _0) + { + ZEPHIR_INIT_NVAR(&element); + ZVAL_COPY(&element, _0); + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "processcallable", &_3, 0, &filtered, method, &element); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&filtered, &_2$$3); + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "processobject", &_4, 0, &filtered, method, &element); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&filtered, &_2$$3); + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "processother", &_5, 0, &filtered, method, &element); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&filtered, &_2$$3); + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CPY_WRT(&realClassName, className); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("annotations"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset(&_0, &realClassName)) { - zephir_read_property(&_1$$5, this_ptr, ZEND_STRL("annotations"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_2$$5, &_1$$5, &realClassName, PH_NOISY | PH_READONLY, "phalcon/Annotations/Adapter/AbstractAdapter.zep", 51); - RETURN_CTOR(&_2$$5); - } - ZEPHIR_CALL_METHOD(&classAnnotations, this_ptr, "read", NULL, 0, &realClassName); - zephir_check_call_status(); - _3 = Z_TYPE_P(&classAnnotations) == IS_NULL; - if (!(_3)) { - _3 = ZEPHIR_IS_FALSE_IDENTICAL(&classAnnotations); - } - if (_3) { - ZEPHIR_CALL_METHOD(&reader, this_ptr, "getreader", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&parsedAnnotations, &reader, "parse", NULL, 0, &realClassName); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&classAnnotations); - object_init_ex(&classAnnotations, phalcon_annotations_reflection_ce); - ZEPHIR_CALL_METHOD(NULL, &classAnnotations, "__construct", NULL, 37, &parsedAnnotations); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("annotations"), &realClassName, &classAnnotations); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "write", NULL, 0, &realClassName, &classAnnotations); + ZEPHIR_CALL_METHOD(NULL, &collection, "rewind", NULL, 0); zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &collection, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&element, &collection, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_6$$4, this_ptr, "processcallable", &_3, 0, &filtered, method, &element); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&filtered, &_6$$4); + ZEPHIR_CALL_METHOD(&_6$$4, this_ptr, "processobject", &_4, 0, &filtered, method, &element); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&filtered, &_6$$4); + ZEPHIR_CALL_METHOD(&_6$$4, this_ptr, "processother", &_5, 0, &filtered, method, &element); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&filtered, &_6$$4); + ZEPHIR_CALL_METHOD(NULL, &collection, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_CCTOR(&classAnnotations); + ZEPHIR_INIT_NVAR(&element); + RETURN_CCTOR(&filtered); } -static PHP_METHOD(Phalcon_Annotations_Adapter_AbstractAdapter, getConstant) +static PHP_METHOD(Phalcon_Support_Helper_Arr_Group, isCallable) +{ + zend_bool _0, _1; + zval *method, method_sub; + + ZVAL_UNDEF(&method_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(method) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &method); + _0 = zephir_is_callable(method); + if (!(_0)) { + _1 = Z_TYPE_P(method) == IS_STRING; + if (_1) { + _1 = 1 == (zephir_function_exists(method) == SUCCESS); + } + _0 = _1; + } + RETURN_BOOL(_0); +} + +static PHP_METHOD(Phalcon_Support_Helper_Arr_Group, processCallable) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *className_param = NULL, *constantName_param = NULL, constants, constant; - zval className, constantName; + zval *filtered_param = NULL, *method, method_sub, *element, element_sub, key, output, _0; + zval filtered; zval *this_ptr = getThis(); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&constantName); - ZVAL_UNDEF(&constants); - ZVAL_UNDEF(&constant); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(className) - Z_PARAM_STR(constantName) + ZVAL_UNDEF(&filtered); + ZVAL_UNDEF(&method_sub); + ZVAL_UNDEF(&element_sub); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&output); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ARRAY(filtered) + Z_PARAM_ZVAL(method) + Z_PARAM_ZVAL(element) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &className_param, &constantName_param); - zephir_get_strval(&className, className_param); - zephir_get_strval(&constantName, constantName_param); - ZEPHIR_CALL_METHOD(&constants, this_ptr, "getconstants", NULL, 0, &className); + zephir_fetch_params(1, 3, 0, &filtered_param, &method, &element); + zephir_get_arrval(&filtered, filtered_param); + ZEPHIR_CPY_WRT(&output, &filtered); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "iscallable", NULL, 0, method); zephir_check_call_status(); - if (!(zephir_array_isset_fetch(&constant, &constants, &constantName, 1))) { - object_init_ex(return_value, phalcon_annotations_collection_ce); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 38); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_CALL_FUNCTION(&key, "call_user_func", NULL, 188, method, element); zephir_check_call_status(); - RETURN_MM(); + zephir_array_update_multi(&output, element, SL("za"), 2, &key); } - RETURN_CTOR(&constant); + RETURN_CCTOR(&output); } -static PHP_METHOD(Phalcon_Annotations_Adapter_AbstractAdapter, getConstants) +static PHP_METHOD(Phalcon_Support_Helper_Arr_Group, processObject) { + zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *className_param = NULL, classAnnotations; - zval className; + zval *filtered_param = NULL, *method, method_sub, *element, element_sub, output, _0, key$$3; + zval filtered; zval *this_ptr = getThis(); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&classAnnotations); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(className) + ZVAL_UNDEF(&filtered); + ZVAL_UNDEF(&method_sub); + ZVAL_UNDEF(&element_sub); + ZVAL_UNDEF(&output); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&key$$3); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ARRAY(filtered) + Z_PARAM_ZVAL(method) + Z_PARAM_ZVAL(element) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &className_param); - zephir_get_strval(&className, className_param); - ZEPHIR_CALL_METHOD(&classAnnotations, this_ptr, "get", NULL, 0, &className); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&classAnnotations, "getconstantsannotations", NULL, 0); + zephir_fetch_params(1, 3, 0, &filtered_param, &method, &element); + zephir_get_arrval(&filtered, filtered_param); + ZEPHIR_CPY_WRT(&output, &filtered); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "iscallable", NULL, 0, method); zephir_check_call_status(); - RETURN_MM(); + _1 = !ZEPHIR_IS_TRUE_IDENTICAL(&_0); + if (_1) { + _1 = Z_TYPE_P(element) == IS_OBJECT; + } + if (_1) { + zephir_memory_observe(&key$$3); + zephir_read_property_zval(&key$$3, element, method, PH_NOISY_CC); + zephir_array_update_multi(&output, element, SL("za"), 2, &key$$3); + } + RETURN_CCTOR(&output); } -static PHP_METHOD(Phalcon_Annotations_Adapter_AbstractAdapter, getProperty) +static PHP_METHOD(Phalcon_Support_Helper_Arr_Group, processOther) { + zend_bool _1, _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *className_param = NULL, *propertyName_param = NULL, classAnnotations, properties, property; - zval className, propertyName; + zval *filtered_param = NULL, *method, method_sub, *element, element_sub, output, _0, key$$3; + zval filtered; zval *this_ptr = getThis(); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&propertyName); - ZVAL_UNDEF(&classAnnotations); - ZVAL_UNDEF(&properties); - ZVAL_UNDEF(&property); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(className) - Z_PARAM_STR(propertyName) + ZVAL_UNDEF(&filtered); + ZVAL_UNDEF(&method_sub); + ZVAL_UNDEF(&element_sub); + ZVAL_UNDEF(&output); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&key$$3); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ARRAY(filtered) + Z_PARAM_ZVAL(method) + Z_PARAM_ZVAL(element) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &className_param, &propertyName_param); - zephir_get_strval(&className, className_param); - zephir_get_strval(&propertyName, propertyName_param); - ZEPHIR_CALL_METHOD(&classAnnotations, this_ptr, "get", NULL, 0, &className); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&properties, &classAnnotations, "getpropertiesannotations", NULL, 0); + zephir_fetch_params(1, 3, 0, &filtered_param, &method, &element); + zephir_get_arrval(&filtered, filtered_param); + ZEPHIR_CPY_WRT(&output, &filtered); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "iscallable", NULL, 0, method); zephir_check_call_status(); - if (!(zephir_array_isset_fetch(&property, &properties, &propertyName, 1))) { - object_init_ex(return_value, phalcon_annotations_collection_ce); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 38); - zephir_check_call_status(); - RETURN_MM(); + _1 = !ZEPHIR_IS_TRUE_IDENTICAL(&_0); + if (_1) { + _1 = Z_TYPE_P(element) != IS_OBJECT; } - RETURN_CTOR(&property); + _2 = _1; + if (_2) { + _2 = 1 == zephir_array_isset(element, method); + } + if (_2) { + zephir_memory_observe(&key$$3); + zephir_array_fetch(&key$$3, element, method, PH_NOISY, "phalcon/Support/Helper/Arr/Group.zep", 116); + zephir_array_update_multi(&output, element, SL("za"), 2, &key$$3); + } + RETURN_CCTOR(&output); } -static PHP_METHOD(Phalcon_Annotations_Adapter_AbstractAdapter, getProperties) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Has) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, Has, phalcon, support_helper_arr_has, phalcon_support_helper_arr_has_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Arr_Has, __invoke) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *collection_param = NULL, *index, index_sub; + zval collection; + + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&index_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ARRAY(collection) + Z_PARAM_ZVAL(index) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &collection_param, &index); + zephir_get_arrval(&collection, collection_param); + RETURN_MM_BOOL(zephir_array_key_exists(&collection, index)); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_IsUnique) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, IsUnique, phalcon, support_helper_arr_isunique, phalcon_support_helper_arr_isunique_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Arr_IsUnique, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *className_param = NULL, classAnnotations; - zval className; - zval *this_ptr = getThis(); + zval *collection_param = NULL, _0; + zval collection; - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&classAnnotations); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(className) + Z_PARAM_ARRAY(collection) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &className_param); - zephir_get_strval(&className, className_param); - ZEPHIR_CALL_METHOD(&classAnnotations, this_ptr, "get", NULL, 0, &className); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&classAnnotations, "getpropertiesannotations", NULL, 0); + zephir_fetch_params(1, 1, 0, &collection_param); + zephir_get_arrval(&collection, collection_param); + ZEPHIR_CALL_FUNCTION(&_0, "array_unique", NULL, 180, &collection); zephir_check_call_status(); - RETURN_MM(); + RETURN_MM_BOOL(zephir_fast_count_int(&collection) == zephir_fast_count_int(&_0)); } -static PHP_METHOD(Phalcon_Annotations_Adapter_AbstractAdapter, getMethod) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Last) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Arr, Last, phalcon, support_helper_arr_last, phalcon_support_helper_arr_abstractarr_ce, phalcon_support_helper_arr_last_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Arr_Last, __invoke) { - zend_string *_3$$3; - zend_ulong _2$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *className_param = NULL, *methodName_param = NULL, classAnnotations, methods, method, methodKey, *_0$$3, _1$$3, _4$$4, _6$$6; - zval className, methodName; + zval *collection_param = NULL, *method = NULL, method_sub, __$null, filtered; + zval collection; zval *this_ptr = getThis(); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&methodName); - ZVAL_UNDEF(&classAnnotations); - ZVAL_UNDEF(&methods); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&methodKey); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_6$$6); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(className) - Z_PARAM_STR(methodName) + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&method_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&filtered); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(collection) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(method) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &className_param, &methodName_param); - zephir_get_strval(&className, className_param); - zephir_get_strval(&methodName, methodName_param); - ZEPHIR_CALL_METHOD(&classAnnotations, this_ptr, "get", NULL, 0, &className); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&methods, &classAnnotations, "getmethodsannotations", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&methods) == IS_ARRAY) { - zephir_is_iterable(&methods, 0, "phalcon/Annotations/Adapter/AbstractAdapter.zep", 167); - if (Z_TYPE_P(&methods) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&methods), _2$$3, _3$$3, _0$$3) - { - ZEPHIR_INIT_NVAR(&methodKey); - if (_3$$3 != NULL) { - ZVAL_STR_COPY(&methodKey, _3$$3); - } else { - ZVAL_LONG(&methodKey, _2$$3); - } - ZEPHIR_INIT_NVAR(&method); - ZVAL_COPY(&method, _0$$3); - ZEPHIR_CALL_FUNCTION(&_4$$4, "strcasecmp", &_5, 39, &methodKey, &methodName); - zephir_check_call_status(); - if (!(zephir_is_true(&_4$$4))) { - RETURN_CCTOR(&method); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &methods, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1$$3, &methods, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&methodKey, &methods, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&method, &methods, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_6$$6, "strcasecmp", &_5, 39, &methodKey, &methodName); - zephir_check_call_status(); - if (!(zephir_is_true(&_6$$6))) { - RETURN_CCTOR(&method); - } - ZEPHIR_CALL_METHOD(NULL, &methods, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&method); - ZEPHIR_INIT_NVAR(&methodKey); + zephir_fetch_params(1, 1, 1, &collection_param, &method); + zephir_get_arrval(&collection, collection_param); + if (!method) { + method = &method_sub; + method = &__$null; } - object_init_ex(return_value, phalcon_annotations_collection_ce); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 38); + ZEPHIR_CALL_METHOD(&filtered, this_ptr, "tofilter", NULL, 0, &collection, method); + zephir_check_call_status(); + ZEPHIR_MAKE_REF(&filtered); + ZEPHIR_RETURN_CALL_FUNCTION("end", NULL, 320, &filtered); + ZEPHIR_UNREF(&filtered); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Annotations_Adapter_AbstractAdapter, getMethods) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_LastKey) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Arr, LastKey, phalcon, support_helper_arr_lastkey, phalcon_support_helper_arr_abstractarr_ce, phalcon_support_helper_arr_lastkey_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Arr_LastKey, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *className_param = NULL, classAnnotations; - zval className; + zval *collection_param = NULL, *method = NULL, method_sub, __$null, filtered; + zval collection; zval *this_ptr = getThis(); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&classAnnotations); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(className) + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&method_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&filtered); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(collection) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(method) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &className_param); - zephir_get_strval(&className, className_param); - ZEPHIR_CALL_METHOD(&classAnnotations, this_ptr, "get", NULL, 0, &className); + zephir_fetch_params(1, 1, 1, &collection_param, &method); + zephir_get_arrval(&collection, collection_param); + if (!method) { + method = &method_sub; + method = &__$null; + } + ZEPHIR_CALL_METHOD(&filtered, this_ptr, "tofilter", NULL, 0, &collection, method); zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&classAnnotations, "getmethodsannotations", NULL, 0); + ZEPHIR_RETURN_CALL_FUNCTION("array_key_last", NULL, 40, &filtered); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Annotations_Adapter_AbstractAdapter, getReader) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Order) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, Order, phalcon, support_helper_arr_order, phalcon_support_helper_arr_order_method_entry, 0); + + zephir_declare_class_constant_long(phalcon_support_helper_arr_order_ce, SL("ORDER_ASC"), 1); + + zephir_declare_class_constant_long(phalcon_support_helper_arr_order_ce, SL("ORDER_DESC"), 2); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Arr_Order, __invoke) { - zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL; + zend_long order, flags, ZEPHIR_LAST_CALL_STATUS; + zval *collection_param = NULL, *attribute, attribute_sub, *order_param = NULL, *flags_param = NULL, item, sorted, *_0, _1, _2$$3, _5$$4, _6$$5, _7$$6; + zval collection; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&attribute_sub); + ZVAL_UNDEF(&item); + ZVAL_UNDEF(&sorted); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_7$$6); + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_ARRAY(collection) + Z_PARAM_ZVAL(attribute) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(order) + Z_PARAM_LONG(flags) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("reader"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - object_init_ex(&_1$$3, phalcon_annotations_reader_ce); - if (zephir_has_constructor(&_1$$3)) { - ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 0); + zephir_fetch_params(1, 2, 2, &collection_param, &attribute, &order_param, &flags_param); + zephir_get_arrval(&collection, collection_param); + if (!order_param) { + order = 1; + } else { + } + if (!flags_param) { + flags = 0; + } else { + } + ZEPHIR_INIT_VAR(&sorted); + array_init(&sorted); + zephir_is_iterable(&collection, 0, "phalcon/Support/Helper/Arr/Order.zep", 45); + if (Z_TYPE_P(&collection) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&collection), _0) + { + ZEPHIR_INIT_NVAR(&item); + ZVAL_COPY(&item, _0); + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "checkobject", &_3, 0, &sorted, attribute, &item); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&sorted, &_2$$3); + ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "checknonobject", &_4, 0, &sorted, attribute, &item); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&sorted, &_2$$3); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &collection, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &collection, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&item, &collection, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5$$4, this_ptr, "checkobject", &_3, 0, &sorted, attribute, &item); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&sorted, &_5$$4); + ZEPHIR_CALL_METHOD(&_5$$4, this_ptr, "checknonobject", &_4, 0, &sorted, attribute, &item); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&sorted, &_5$$4); + ZEPHIR_CALL_METHOD(NULL, &collection, "next", NULL, 0); zephir_check_call_status(); } - - zephir_update_property_zval(this_ptr, ZEND_STRL("reader"), &_1$$3); } - RETURN_MM_MEMBER(getThis(), "reader"); + ZEPHIR_INIT_NVAR(&item); + if (1 == order) { + ZVAL_LONG(&_6$$5, flags); + ZEPHIR_MAKE_REF(&sorted); + ZEPHIR_CALL_FUNCTION(NULL, "ksort", NULL, 0, &sorted, &_6$$5); + ZEPHIR_UNREF(&sorted); + zephir_check_call_status(); + } else { + ZVAL_LONG(&_7$$6, flags); + ZEPHIR_MAKE_REF(&sorted); + ZEPHIR_CALL_FUNCTION(NULL, "krsort", NULL, 0, &sorted, &_7$$6); + ZEPHIR_UNREF(&sorted); + zephir_check_call_status(); + } + ZEPHIR_RETURN_CALL_FUNCTION("array_values", NULL, 14, &sorted); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Annotations_Adapter_AbstractAdapter, setReader) +static PHP_METHOD(Phalcon_Support_Helper_Arr_Order, checkObject) { - zval *reader, reader_sub; - zval *this_ptr = getThis(); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *sorted_param = NULL, *attribute, attribute_sub, *item, item_sub, key; + zval sorted; - ZVAL_UNDEF(&reader_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(reader, phalcon_annotations_readerinterface_ce) + ZVAL_UNDEF(&sorted); + ZVAL_UNDEF(&attribute_sub); + ZVAL_UNDEF(&item_sub); + ZVAL_UNDEF(&key); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ARRAY(sorted) + Z_PARAM_ZVAL(attribute) + Z_PARAM_ZVAL(item) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &reader); - zephir_update_property_zval(this_ptr, ZEND_STRL("reader"), reader); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 0, &sorted_param, &attribute, &item); + zephir_get_arrval(&sorted, sorted_param); + if (Z_TYPE_P(item) == IS_OBJECT) { + zephir_memory_observe(&key); + zephir_read_property_zval(&key, item, attribute, PH_NOISY_CC); + zephir_array_update_zval(&sorted, &key, item, PH_COPY | PH_SEPARATE); + } + RETURN_CTOR(&sorted); } -zend_object *zephir_init_properties_Phalcon_Annotations_Adapter_AbstractAdapter(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Support_Helper_Arr_Order, checkNonObject) { - zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - + zval *sorted_param = NULL, *attribute, attribute_sub, *item, item_sub, key; + zval sorted; - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("annotations"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("annotations"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + ZVAL_UNDEF(&sorted); + ZVAL_UNDEF(&attribute_sub); + ZVAL_UNDEF(&item_sub); + ZVAL_UNDEF(&key); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ARRAY(sorted) + Z_PARAM_ZVAL(attribute) + Z_PARAM_ZVAL(item) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 0, &sorted_param, &attribute, &item); + zephir_get_arrval(&sorted, sorted_param); + if (Z_TYPE_P(item) != IS_OBJECT) { + zephir_memory_observe(&key); + zephir_array_fetch(&key, item, attribute, PH_NOISY, "phalcon/Support/Helper/Arr/Order.zep", 85); + zephir_array_update_zval(&sorted, &key, item, PH_COPY | PH_SEPARATE); } + RETURN_CTOR(&sorted); } @@ -141697,22 +141156,100 @@ zend_object *zephir_init_properties_Phalcon_Annotations_Adapter_AbstractAdapter( -ZEPHIR_INIT_CLASS(Phalcon_Annotations_Adapter_AdapterInterface) +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Pluck) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Annotations\\Adapter, AdapterInterface, phalcon, annotations_adapter_adapterinterface, phalcon_annotations_adapter_adapterinterface_method_entry); + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, Pluck, phalcon, support_helper_arr_pluck, phalcon_support_helper_arr_pluck_method_entry, 0); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, get); -ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, getConstant); -ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, getConstants); -ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, getProperty); -ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, getProperties); -ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, getMethod); -ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, getMethods); -ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, getReader); -ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, setReader); +static PHP_METHOD(Phalcon_Support_Helper_Arr_Pluck, __invoke) +{ + zend_bool _2$$3, _3$$3, _6$$6, _7$$6; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval element; + zval *collection_param = NULL, *element_param = NULL, item, *_0, _1, _4$$4, _5$$5, _8$$7, _9$$8; + zval collection, filtered; + + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&filtered); + ZVAL_UNDEF(&item); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_8$$7); + ZVAL_UNDEF(&_9$$8); + ZVAL_UNDEF(&element); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ARRAY(collection) + Z_PARAM_STR(element) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &collection_param, &element_param); + zephir_get_arrval(&collection, collection_param); + zephir_get_strval(&element, element_param); + ZEPHIR_INIT_VAR(&filtered); + array_init(&filtered); + zephir_is_iterable(&collection, 0, "phalcon/Support/Helper/Arr/Pluck.zep", 39); + if (Z_TYPE_P(&collection) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&collection), _0) + { + ZEPHIR_INIT_NVAR(&item); + ZVAL_COPY(&item, _0); + _2$$3 = Z_TYPE_P(&item) == IS_OBJECT; + if (_2$$3) { + _2$$3 = zephir_isset_property_zval(&item, &element); + } + _3$$3 = Z_TYPE_P(&item) == IS_ARRAY; + if (_3$$3) { + _3$$3 = zephir_array_isset(&item, &element); + } + if (_2$$3) { + ZEPHIR_OBS_NVAR(&_4$$4); + zephir_read_property_zval(&_4$$4, &item, &element, PH_NOISY_CC); + zephir_array_append(&filtered, &_4$$4, PH_SEPARATE, "phalcon/Support/Helper/Arr/Pluck.zep", 33); + } else if (_3$$3) { + zephir_array_fetch(&_5$$5, &item, &element, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Arr/Pluck.zep", 35); + zephir_array_append(&filtered, &_5$$5, PH_SEPARATE, "phalcon/Support/Helper/Arr/Pluck.zep", 35); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &collection, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &collection, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&item, &collection, "current", NULL, 0); + zephir_check_call_status(); + _6$$6 = Z_TYPE_P(&item) == IS_OBJECT; + if (_6$$6) { + _6$$6 = zephir_isset_property_zval(&item, &element); + } + _7$$6 = Z_TYPE_P(&item) == IS_ARRAY; + if (_7$$6) { + _7$$6 = zephir_array_isset(&item, &element); + } + if (_6$$6) { + ZEPHIR_OBS_NVAR(&_8$$7); + zephir_read_property_zval(&_8$$7, &item, &element, PH_NOISY_CC); + zephir_array_append(&filtered, &_8$$7, PH_SEPARATE, "phalcon/Support/Helper/Arr/Pluck.zep", 33); + } else if (_7$$6) { + zephir_array_fetch(&_9$$8, &item, &element, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Arr/Pluck.zep", 35); + zephir_array_append(&filtered, &_9$$8, PH_SEPARATE, "phalcon/Support/Helper/Arr/Pluck.zep", 35); + } + ZEPHIR_CALL_METHOD(NULL, &collection, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&item); + RETURN_CTOR(&filtered); +} + @@ -141723,123 +141260,184 @@ ZEPHIR_DOC_METHOD(Phalcon_Annotations_Adapter_AdapterInterface, setReader); -ZEPHIR_INIT_CLASS(Phalcon_Annotations_Adapter_Apcu) +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Set) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Annotations\\Adapter, Apcu, phalcon, annotations_adapter_apcu, phalcon_annotations_adapter_abstractadapter_ce, phalcon_annotations_adapter_apcu_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, Set, phalcon, support_helper_arr_set, phalcon_support_helper_arr_set_method_entry, 0); - zend_declare_property_string(phalcon_annotations_adapter_apcu_ce, SL("prefix"), "", ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_annotations_adapter_apcu_ce, SL("ttl"), 172800, ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Annotations_Adapter_Apcu, __construct) +static PHP_METHOD(Phalcon_Support_Helper_Arr_Set, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *options_param = NULL, prefix, ttl; - zval options; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *collection_param = NULL, *value, value_sub, *index = NULL, index_sub, __$null, source; + zval collection; zval *this_ptr = getThis(); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&prefix); - ZVAL_UNDEF(&ttl); - ZEND_PARSE_PARAMETERS_START(0, 1) + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&index_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&source); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ARRAY(collection) + Z_PARAM_ZVAL(value) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + Z_PARAM_ZVAL_OR_NULL(index) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &options_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); + zephir_fetch_params(1, 2, 1, &collection_param, &value, &index); + zephir_get_arrval(&collection, collection_param); + if (!index) { + index = &index_sub; + index = &__$null; } - zephir_memory_observe(&prefix); - if (zephir_array_isset_string_fetch(&prefix, &options, SL("prefix"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("prefix"), &prefix); + ZEPHIR_CALL_METHOD(&source, this_ptr, "checknull", NULL, 0, &collection, value, index); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checknotnull", NULL, 0, &source, value, index); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Support_Helper_Arr_Set, checkNull) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *collection_param = NULL, *value, value_sub, *index, index_sub; + zval collection; + + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&index_sub); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ARRAY(collection) + Z_PARAM_ZVAL(value) + Z_PARAM_ZVAL(index) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 0, &collection_param, &value, &index); + zephir_get_arrval(&collection, collection_param); + if (Z_TYPE_P(index) == IS_NULL) { + zephir_array_append(&collection, value, PH_SEPARATE, "phalcon/Support/Helper/Arr/Set.zep", 47); } - zephir_memory_observe(&ttl); - if (zephir_array_isset_string_fetch(&ttl, &options, SL("lifetime"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("ttl"), &ttl); + RETURN_CTOR(&collection); +} + +static PHP_METHOD(Phalcon_Support_Helper_Arr_Set, checkNotNull) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *collection_param = NULL, *value, value_sub, *index, index_sub; + zval collection; + + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&index_sub); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ARRAY(collection) + Z_PARAM_ZVAL(value) + Z_PARAM_ZVAL(index) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 3, 0, &collection_param, &value, &index); + zephir_get_arrval(&collection, collection_param); + if (Z_TYPE_P(index) != IS_NULL) { + zephir_array_update_zval(&collection, index, value, PH_COPY | PH_SEPARATE); } - ZEPHIR_MM_RESTORE(); + RETURN_CTOR(&collection); } -static PHP_METHOD(Phalcon_Annotations_Adapter_Apcu, read) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_SliceLeft) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, SliceLeft, phalcon, support_helper_arr_sliceleft, phalcon_support_helper_arr_sliceleft_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Arr_SliceLeft, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, _0, _1, _2; - zval key; - zval *this_ptr = getThis(); + zend_long elements, ZEPHIR_LAST_CALL_STATUS; + zval *collection_param = NULL, *elements_param = NULL, _0, _1; + zval collection; - ZVAL_UNDEF(&key); + ZVAL_UNDEF(&collection); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(collection) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(elements) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + zephir_fetch_params(1, 1, 1, &collection_param, &elements_param); + zephir_get_arrval(&collection, collection_param); + if (!elements_param) { + elements = 1; } else { - ZEPHIR_INIT_VAR(&key); - } - ZEPHIR_INIT_VAR(&_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_SVV(&_2, "_PHAN", &_1, &key); - zephir_fast_strtolower(&_0, &_2); - ZEPHIR_RETURN_CALL_FUNCTION("apcu_fetch", NULL, 107, &_0); + } + ZVAL_LONG(&_0, 0); + ZVAL_LONG(&_1, elements); + ZEPHIR_RETURN_CALL_FUNCTION("array_slice", NULL, 501, &collection, &_0, &_1); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Annotations_Adapter_Apcu, write) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_SliceRight) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, SliceRight, phalcon, support_helper_arr_sliceright, phalcon_support_helper_arr_sliceright_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Arr_SliceRight, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *data, data_sub, _0, _1, _2, _3; - zval key; - zval *this_ptr = getThis(); + zend_long elements, ZEPHIR_LAST_CALL_STATUS; + zval *collection_param = NULL, *elements_param = NULL, _0; + zval collection; - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&data_sub); + ZVAL_UNDEF(&collection); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(key) - Z_PARAM_OBJECT_OF_CLASS(data, phalcon_annotations_reflection_ce) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(collection) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(elements) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &key_param, &data); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); + zephir_fetch_params(1, 1, 1, &collection_param, &elements_param); + zephir_get_arrval(&collection, collection_param); + if (!elements_param) { + elements = 1; } else { - ZEPHIR_INIT_VAR(&key); - } - ZEPHIR_INIT_VAR(&_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("prefix"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_SVV(&_2, "_PHAN", &_1, &key); - zephir_fast_strtolower(&_0, &_2); - zephir_read_property(&_3, this_ptr, ZEND_STRL("ttl"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_FUNCTION("apcu_store", NULL, 108, &_0, data, &_3); + } + ZVAL_LONG(&_0, elements); + ZEPHIR_RETURN_CALL_FUNCTION("array_slice", NULL, 501, &collection, &_0); zephir_check_call_status(); RETURN_MM(); } @@ -141854,80 +141452,38 @@ static PHP_METHOD(Phalcon_Annotations_Adapter_Apcu, write) -ZEPHIR_INIT_CLASS(Phalcon_Annotations_Adapter_Memory) +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Split) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Annotations\\Adapter, Memory, phalcon, annotations_adapter_memory, phalcon_annotations_adapter_abstractadapter_ce, phalcon_annotations_adapter_memory_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, Split, phalcon, support_helper_arr_split, phalcon_support_helper_arr_split_method_entry, 0); - zend_declare_property_null(phalcon_annotations_adapter_memory_ce, SL("data"), ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Annotations_Adapter_Memory, read) +static PHP_METHOD(Phalcon_Support_Helper_Arr_Split, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *key_param = NULL, data, _0, _1; - zval key; - zval *this_ptr = getThis(); + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *collection_param = NULL, _0, _1; + zval collection; - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&collection); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - zephir_memory_observe(&data); - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - zephir_fast_strtolower(&_1, &key); - if (!(zephir_array_isset_fetch(&data, &_0, &_1, 0))) { - RETURN_MM_BOOL(0); - } - RETURN_CCTOR(&data); -} - -static PHP_METHOD(Phalcon_Annotations_Adapter_Memory, write) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *key_param = NULL, *data, data_sub, lowercasedKey; - zval key; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&data_sub); - ZVAL_UNDEF(&lowercasedKey); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(key) - Z_PARAM_OBJECT_OF_CLASS(data, phalcon_annotations_reflection_ce) + Z_PARAM_ARRAY(collection) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &key_param, &data); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - ZEPHIR_INIT_VAR(&lowercasedKey); - zephir_fast_strtolower(&lowercasedKey, &key); - zephir_update_property_array(this_ptr, SL("data"), &lowercasedKey, data); - ZEPHIR_MM_RESTORE(); + zephir_fetch_params(1, 1, 0, &collection_param); + zephir_get_arrval(&collection, collection_param); + zephir_create_array(return_value, 2, 0); + ZEPHIR_INIT_VAR(&_0); + zephir_array_keys(&_0, &collection); + zephir_array_fast_append(return_value, &_0); + ZEPHIR_CALL_FUNCTION(&_1, "array_values", NULL, 14, &collection); + zephir_check_call_status(); + zephir_array_fast_append(return_value, &_1); + RETURN_MM(); } @@ -141940,177 +141496,70 @@ static PHP_METHOD(Phalcon_Annotations_Adapter_Memory, write) -ZEPHIR_INIT_CLASS(Phalcon_Annotations_Adapter_Stream) +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_ToObject) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Annotations\\Adapter, Stream, phalcon, annotations_adapter_stream, phalcon_annotations_adapter_abstractadapter_ce, phalcon_annotations_adapter_stream_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, ToObject, phalcon, support_helper_arr_toobject, phalcon_support_helper_arr_toobject_method_entry, 0); - zend_declare_property_string(phalcon_annotations_adapter_stream_ce, SL("annotationsDir"), "./", ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Annotations_Adapter_Stream, __construct) +static PHP_METHOD(Phalcon_Support_Helper_Arr_ToObject, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *options_param = NULL, annotationsDir; - zval options; - zval *this_ptr = getThis(); + zval *collection_param = NULL; + zval collection; - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&annotationsDir); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(options) + ZVAL_UNDEF(&collection); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(collection) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &options_param); - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - zephir_memory_observe(&annotationsDir); - if (zephir_array_isset_string_fetch(&annotationsDir, &options, SL("annotationsDir"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("annotationsDir"), &annotationsDir); - } - ZEPHIR_MM_RESTORE(); + zephir_fetch_params(1, 1, 0, &collection_param); + zephir_get_arrval(&collection, collection_param); + zephir_convert_to_object(&collection); + RETURN_CTOR(&collection); } -static PHP_METHOD(Phalcon_Annotations_Adapter_Stream, read) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_ValidateAll) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, __$false, contents, version, _0, _1, _2, _3, _4, _5, _6, _11, _7$$5, _8$$5, _9$$6, _10$$6; - zval key, path; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Arr, ValidateAll, phalcon, support_helper_arr_validateall, phalcon_support_helper_arr_abstractarr_ce, phalcon_support_helper_arr_validateall_method_entry, 0); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&path); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&contents); - ZVAL_UNDEF(&version); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_7$$5); - ZVAL_UNDEF(&_8$$5); - ZVAL_UNDEF(&_9$$6); - ZVAL_UNDEF(&_10$$6); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(key) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &key_param); - zephir_get_strval(&key, key_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("annotationsDir"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "_"); - zephir_prepare_virtual_path(&_1, &key, &_2); - ZEPHIR_INIT_VAR(&_3); - ZEPHIR_CONCAT_VVS(&_3, &_0, &_1, ".php"); - zephir_get_strval(&path, &_3); - if (!((zephir_file_exists(&path) == SUCCESS))) { - RETURN_MM_BOOL(0); - } - ZEPHIR_INIT_VAR(&contents); - zephir_file_get_contents(&contents, &path); - if (UNEXPECTED(ZEPHIR_IS_EMPTY(&contents))) { - RETURN_MM_BOOL(0); - } - ZEPHIR_GLOBAL(warning).enable = zend_is_true(&__$false); - ZEPHIR_CALL_FUNCTION(&version, "phpversion", NULL, 133); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, "8.0"); - ZEPHIR_INIT_VAR(&_5); - ZVAL_STRING(&_5, ">="); - ZEPHIR_CALL_FUNCTION(&_6, "version_compare", NULL, 134, &version, &_4, &_5); - zephir_check_call_status(); - if (zephir_is_true(&_6)) { - ZEPHIR_INIT_VAR(&_7$$5); - ZEPHIR_INIT_NVAR(&_7$$5); - zephir_create_closure_ex(&_7$$5, NULL, phalcon_4__closure_ce, SL("__invoke")); - ZVAL_LONG(&_8$$5, 2); - ZEPHIR_CALL_FUNCTION(NULL, "set_error_handler", NULL, 135, &_7$$5, &_8$$5); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_VAR(&_9$$6); - ZEPHIR_INIT_NVAR(&_9$$6); - zephir_create_closure_ex(&_9$$6, NULL, phalcon_5__closure_ce, SL("__invoke")); - ZVAL_LONG(&_10$$6, 2); - ZEPHIR_CALL_FUNCTION(NULL, "set_error_handler", NULL, 135, &_9$$6, &_10$$6); - zephir_check_call_status(); - } - ZEPHIR_CALL_FUNCTION(&_11, "unserialize", NULL, 16, &contents); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&contents, &_11); - ZEPHIR_CALL_FUNCTION(NULL, "restore_error_handler", NULL, 136); - zephir_check_call_status(); - if (UNEXPECTED(ZEPHIR_GLOBAL(warning).enable)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_RuntimeException, "Cannot read annotation data", "phalcon/Annotations/Adapter/Stream.zep", 102); - return; - } - RETURN_CCTOR(&contents); + return SUCCESS; } -static PHP_METHOD(Phalcon_Annotations_Adapter_Stream, write) +static PHP_METHOD(Phalcon_Support_Helper_Arr_ValidateAll, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *key_param = NULL, *data, data_sub, code, _0, _1, _2, _3, _4; - zval key, path; + zval *collection_param = NULL, *method, method_sub, _0; + zval collection; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&path); - ZVAL_UNDEF(&data_sub); - ZVAL_UNDEF(&code); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&method_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(key) - Z_PARAM_OBJECT_OF_CLASS(data, phalcon_annotations_reflection_ce) + Z_PARAM_ARRAY(collection) + Z_PARAM_ZVAL(method) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &key_param, &data); - if (UNEXPECTED(Z_TYPE_P(key_param) != IS_STRING && Z_TYPE_P(key_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'key' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { - zephir_get_strval(&key, key_param); - } else { - ZEPHIR_INIT_VAR(&key); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("annotationsDir"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_1); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "_"); - zephir_prepare_virtual_path(&_1, &key, &_2); - ZEPHIR_INIT_VAR(&_3); - ZEPHIR_CONCAT_VVS(&_3, &_0, &_1, ".php"); - zephir_get_strval(&path, &_3); - ZEPHIR_CALL_FUNCTION(&code, "serialize", NULL, 15, data); + zephir_fetch_params(1, 2, 0, &collection_param, &method); + zephir_get_arrval(&collection, collection_param); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "tofilter", NULL, 0, &collection, method); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_4); - zephir_file_put_contents(&_4, &path, &code); - if (UNEXPECTED(ZEPHIR_IS_FALSE_IDENTICAL(&_4))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_annotations_exception_ce, "Annotations directory cannot be written", "phalcon/Annotations/Adapter/Stream.zep", 123); - return; - } - ZEPHIR_MM_RESTORE(); + RETURN_MM_BOOL(zephir_fast_count_int(&_0) == zephir_fast_count_int(&collection)); } @@ -142123,713 +141572,443 @@ static PHP_METHOD(Phalcon_Annotations_Adapter_Stream, write) -ZEPHIR_INIT_CLASS(Phalcon_Flash_AbstractFlash) +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_ValidateAny) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Flash, AbstractFlash, phalcon, flash_abstractflash, phalcon_di_abstractinjectionaware_ce, phalcon_flash_abstractflash_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - - zend_declare_property_bool(phalcon_flash_abstractflash_ce, SL("autoescape"), 1, ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_flash_abstractflash_ce, SL("automaticHtml"), 1, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_flash_abstractflash_ce, SL("cssClasses"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_flash_abstractflash_ce, SL("cssIconClasses"), ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_flash_abstractflash_ce, SL("customTemplate"), "", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_flash_abstractflash_ce, SL("escaperService"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_flash_abstractflash_ce, SL("implicitFlush"), 1, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_flash_abstractflash_ce, SL("interpolator"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_flash_abstractflash_ce, SL("messages"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_flash_abstractflash_ce, SL("sessionService"), ZEND_ACC_PROTECTED); - phalcon_flash_abstractflash_ce->create_object = zephir_init_properties_Phalcon_Flash_AbstractFlash; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Arr, ValidateAny, phalcon, support_helper_arr_validateany, phalcon_support_helper_arr_abstractarr_ce, phalcon_support_helper_arr_validateany_method_entry, 0); - zend_class_implements(phalcon_flash_abstractflash_ce, 1, phalcon_flash_flashinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Flash_AbstractFlash, __construct) +static PHP_METHOD(Phalcon_Support_Helper_Arr_ValidateAny, __invoke) { - zval _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *escaper = NULL, escaper_sub, *session = NULL, session_sub, __$null, _0; + zval *collection_param = NULL, *method, method_sub, _0; + zval collection; zval *this_ptr = getThis(); - ZVAL_UNDEF(&escaper_sub); - ZVAL_UNDEF(&session_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&method_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(escaper, phalcon_html_escaper_escaperinterface_ce) - Z_PARAM_OBJECT_OF_CLASS_OR_NULL(session, phalcon_session_managerinterface_ce) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ARRAY(collection) + Z_PARAM_ZVAL(method) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &escaper, &session); - if (!escaper) { - escaper = &escaper_sub; - escaper = &__$null; - } - if (!session) { - session = &session_sub; - session = &__$null; - } - zephir_update_property_zval(this_ptr, ZEND_STRL("escaperService"), escaper); - zephir_update_property_zval(this_ptr, ZEND_STRL("sessionService"), session); - ZEPHIR_INIT_VAR(&_0); - object_init_ex(&_0, phalcon_support_helper_str_interpolate_ce); - if (zephir_has_constructor(&_0)) { - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); - zephir_check_call_status(); - } - - zephir_update_property_zval(this_ptr, ZEND_STRL("interpolator"), &_0); - ZEPHIR_INIT_VAR(&_1); - zephir_create_array(&_1, 4, 0); - add_assoc_stringl_ex(&_1, SL("error"), SL("errorMessage")); - add_assoc_stringl_ex(&_1, SL("notice"), SL("noticeMessage")); - add_assoc_stringl_ex(&_1, SL("success"), SL("successMessage")); - add_assoc_stringl_ex(&_1, SL("warning"), SL("warningMessage")); - zephir_update_property_zval(this_ptr, ZEND_STRL("cssClasses"), &_1); - ZEPHIR_MM_RESTORE(); + zephir_fetch_params(1, 2, 0, &collection_param, &method); + zephir_get_arrval(&collection, collection_param); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "tofilter", NULL, 0, &collection, method); + zephir_check_call_status(); + RETURN_MM_BOOL(zephir_fast_count_int(&_0) > 0); } -static PHP_METHOD(Phalcon_Flash_AbstractFlash, clear) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), &_0); - ZEPHIR_MM_RESTORE(); + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Whitelist) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Arr, Whitelist, phalcon, support_helper_arr_whitelist, phalcon_support_helper_arr_abstractarr_ce, phalcon_support_helper_arr_whitelist_method_entry, 0); + + return SUCCESS; } -static PHP_METHOD(Phalcon_Flash_AbstractFlash, error) +static PHP_METHOD(Phalcon_Support_Helper_Arr_Whitelist, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *message_param = NULL, _0; - zval message; + zval *collection_param = NULL, *whiteList_param = NULL, filtered, _0, _1; + zval collection, whiteList; zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&whiteList); + ZVAL_UNDEF(&filtered); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(message) + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ARRAY(collection) + Z_PARAM_ARRAY(whiteList) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &message_param); - zephir_get_strval(&message, message_param); + zephir_fetch_params(1, 2, 0, &collection_param, &whiteList_param); + zephir_get_arrval(&collection, collection_param); + zephir_get_arrval(&whiteList, whiteList_param); ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "error"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "message", NULL, 0, &_0, &message); + ZEPHIR_INIT_NVAR(&_0); + zephir_create_closure_ex(&_0, NULL, phalcon_13__closure_ce, SL("__invoke")); + ZEPHIR_CALL_METHOD(&filtered, this_ptr, "tofilter", NULL, 0, &whiteList, &_0); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_1, "array_flip", NULL, 100, &filtered); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_FUNCTION("array_intersect_key", NULL, 2, &collection, &_1); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Flash_AbstractFlash, getAutoescape) -{ - RETURN_MEMBER(getThis(), "autoescape"); -} -static PHP_METHOD(Phalcon_Flash_AbstractFlash, getAutomaticHtml) -{ - RETURN_MEMBER(getThis(), "automaticHtml"); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Flash_AbstractFlash, getCssClasses) -{ - RETURN_MEMBER(getThis(), "cssClasses"); -} -static PHP_METHOD(Phalcon_Flash_AbstractFlash, getCssIconClasses) -{ - RETURN_MEMBER(getThis(), "cssIconClasses"); -} -static PHP_METHOD(Phalcon_Flash_AbstractFlash, getCustomTemplate) +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_File_Basename) { + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\File, Basename, phalcon, support_helper_file_basename, phalcon_support_helper_file_basename_method_entry, 0); - RETURN_MEMBER(getThis(), "customTemplate"); + return SUCCESS; } -static PHP_METHOD(Phalcon_Flash_AbstractFlash, getEscaperService) +static PHP_METHOD(Phalcon_Support_Helper_File_Basename, __invoke) { - zend_bool _2; - zval _0, _1, _3, _4, _5, _6$$4, _7$$4, _8$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + zval *uri_param = NULL, *suffix_param = NULL, fileName, matches, _0, _1, _2, _3, _4, _5, _6$$3, _7$$3, _8$$3, _9$$3; + zval uri, suffix; + ZVAL_UNDEF(&uri); + ZVAL_UNDEF(&suffix); + ZVAL_UNDEF(&fileName); + ZVAL_UNDEF(&matches); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_8$$4); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("escaperService"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) != IS_NULL) { - RETURN_MM_MEMBER(getThis(), "escaperService"); - } - zephir_read_property(&_1, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - _2 = Z_TYPE_P(&_1) != IS_NULL; - if (_2) { - zephir_read_property(&_3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_5); - ZVAL_STRING(&_5, "escaper"); - ZEPHIR_CALL_METHOD(&_4, &_3, "has", NULL, 0, &_5); - zephir_check_call_status(); - _2 = ZEPHIR_IS_TRUE_IDENTICAL(&_4); - } - if (_2) { - zephir_read_property(&_6$$4, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_8$$4); - ZVAL_STRING(&_8$$4, "escaper"); - ZEPHIR_CALL_METHOD(&_7$$4, &_6$$4, "getshared", NULL, 0, &_8$$4); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("escaperService"), &_7$$4); - RETURN_MM_MEMBER(getThis(), "escaperService"); - } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_flash_exception_ce, "A dependency injection container is required to access the 'escaper' service", "phalcon/Flash/AbstractFlash.zep", 194); - return; -} - -static PHP_METHOD(Phalcon_Flash_AbstractFlash, notice) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *message_param = NULL, _0; - zval message; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(message) + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(uri) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(suffix) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &message_param); - zephir_get_strval(&message, message_param); + zephir_fetch_params(1, 1, 1, &uri_param, &suffix_param); + zephir_get_strval(&uri, uri_param); + if (!suffix_param) { + ZEPHIR_INIT_VAR(&suffix); + } else { + zephir_get_strval(&suffix, suffix_param); + } ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "notice"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "message", NULL, 0, &_0, &message); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "/"); + zephir_fast_trim(&_0, &uri, &_1, ZEPHIR_TRIM_RIGHT); + zephir_get_strval(&uri, &_0); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "/"); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "@"); + ZEPHIR_CALL_FUNCTION(&_4, "preg_quote", NULL, 351, &_2, &_3); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Flash_AbstractFlash, setAutoescape) -{ - zval *autoescape_param = NULL, __$true, __$false; - zend_bool autoescape; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(autoescape) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &autoescape_param); - if (autoescape) { - zephir_update_property_zval(this_ptr, ZEND_STRL("autoescape"), &__$true); + ZEPHIR_INIT_VAR(&_5); + ZEPHIR_CONCAT_SVS(&_5, "@[^", &_4, "]+$@"); + ZEPHIR_INIT_NVAR(&_2); + zephir_preg_match(&_2, &_5, &uri, &matches, 0, 0 , 0 ); + if (zephir_is_true(&_2)) { + zephir_memory_observe(&fileName); + zephir_array_fetch_long(&fileName, &matches, 0, PH_NOISY, "phalcon/Support/Helper/File/Basename.zep", 39); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("autoescape"), &__$false); + ZEPHIR_INIT_NVAR(&fileName); + ZVAL_STRING(&fileName, ""); } - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Flash_AbstractFlash, setAutomaticHtml) -{ - zval *automaticHtml_param = NULL, __$true, __$false; - zend_bool automaticHtml; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(automaticHtml) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &automaticHtml_param); - if (automaticHtml) { - zephir_update_property_zval(this_ptr, ZEND_STRL("automaticHtml"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("automaticHtml"), &__$false); + if (1 != ZEPHIR_IS_EMPTY(&suffix)) { + ZEPHIR_INIT_VAR(&_6$$3); + ZVAL_STRING(&_6$$3, "@"); + ZEPHIR_CALL_FUNCTION(&_7$$3, "preg_quote", NULL, 351, &suffix, &_6$$3); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_8$$3); + ZEPHIR_CONCAT_SVS(&_8$$3, "@", &_7$$3, "$@"); + ZEPHIR_INIT_NVAR(&_6$$3); + ZVAL_STRING(&_6$$3, ""); + ZEPHIR_CALL_FUNCTION(&_9$$3, "preg_replace", NULL, 41, &_8$$3, &_6$$3, &fileName); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&fileName, &_9$$3); } - RETURN_THISW(); + RETURN_CCTOR(&fileName); } -static PHP_METHOD(Phalcon_Flash_AbstractFlash, setCssClasses) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *cssClasses_param = NULL; - zval cssClasses; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&cssClasses); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(cssClasses) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &cssClasses_param); - ZEPHIR_OBS_COPY_OR_DUP(&cssClasses, cssClasses_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("cssClasses"), &cssClasses); - RETURN_THIS(); -} -static PHP_METHOD(Phalcon_Flash_AbstractFlash, setCssIconClasses) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *cssIconClasses_param = NULL; - zval cssIconClasses; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&cssIconClasses); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(cssIconClasses) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &cssIconClasses_param); - ZEPHIR_OBS_COPY_OR_DUP(&cssIconClasses, cssIconClasses_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("cssIconClasses"), &cssIconClasses); - RETURN_THIS(); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Flash_AbstractFlash, setCustomTemplate) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *customTemplate_param = NULL; - zval customTemplate; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&customTemplate); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(customTemplate) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &customTemplate_param); - if (UNEXPECTED(Z_TYPE_P(customTemplate_param) != IS_STRING && Z_TYPE_P(customTemplate_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'customTemplate' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(customTemplate_param) == IS_STRING)) { - zephir_get_strval(&customTemplate, customTemplate_param); - } else { - ZEPHIR_INIT_VAR(&customTemplate); - } - zephir_update_property_zval(this_ptr, ZEND_STRL("customTemplate"), &customTemplate); - RETURN_THIS(); -} -static PHP_METHOD(Phalcon_Flash_AbstractFlash, setEscaperService) -{ - zval *escaperService, escaperService_sub; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&escaperService_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(escaperService, phalcon_html_escaper_escaperinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &escaperService); - zephir_update_property_zval(this_ptr, ZEND_STRL("escaperService"), escaperService); - RETURN_THISW(); -} -static PHP_METHOD(Phalcon_Flash_AbstractFlash, setImplicitFlush) +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_AbstractStr) { - zval *implicitFlush_param = NULL, __$true, __$false; - zend_bool implicitFlush; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, AbstractStr, phalcon, support_helper_str_abstractstr, phalcon_support_helper_str_abstractstr_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(implicitFlush) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &implicitFlush_param); - if (implicitFlush) { - zephir_update_property_zval(this_ptr, ZEND_STRL("implicitFlush"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("implicitFlush"), &__$false); - } - RETURN_THISW(); + return SUCCESS; } -static PHP_METHOD(Phalcon_Flash_AbstractFlash, success) +static PHP_METHOD(Phalcon_Support_Helper_Str_AbstractStr, toEndsWith) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *message_param = NULL, _0; - zval message; - zval *this_ptr = getThis(); + zend_bool ignoreCase; + zval *haystack_param = NULL, *needle_param = NULL, *ignoreCase_param = NULL, child, parent, _0; + zval haystack, needle; - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&haystack); + ZVAL_UNDEF(&needle); + ZVAL_UNDEF(&child); + ZVAL_UNDEF(&parent); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(message) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(haystack) + Z_PARAM_STR(needle) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(ignoreCase) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &message_param); - zephir_get_strval(&message, message_param); + zephir_fetch_params(1, 2, 1, &haystack_param, &needle_param, &ignoreCase_param); + zephir_get_strval(&haystack, haystack_param); + zephir_get_strval(&needle, needle_param); + if (!ignoreCase_param) { + ignoreCase = 1; + } else { + } ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "success"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "message", NULL, 0, &_0, &message); - zephir_check_call_status(); - RETURN_MM(); + ZVAL_STRING(&_0, ""); + if (ZEPHIR_IS_IDENTICAL(&_0, &haystack)) { + RETURN_MM_BOOL(0); + } + if (EXPECTED(ignoreCase)) { + ZEPHIR_CALL_FUNCTION(&child, "mb_strtolower", NULL, 10, &needle); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&parent, "mb_strtolower", NULL, 10, &haystack); + zephir_check_call_status(); + } else { + ZEPHIR_CPY_WRT(&child, &needle); + ZEPHIR_CPY_WRT(&parent, &haystack); + } + RETURN_MM_BOOL(zephir_end_with(&parent, &child, NULL)); } -static PHP_METHOD(Phalcon_Flash_AbstractFlash, outputMessage) +static PHP_METHOD(Phalcon_Support_Helper_Str_AbstractStr, toInterpolate) { - zend_bool _0; + zend_string *_3; + zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL, *_5 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *type_param = NULL, *message = NULL, message_sub, content, html, item, prepared, *_2, _3, _1$$4, _6$$5, _7$$8; - zval type; - zval *this_ptr = getThis(); + zval context; + zval *input_param = NULL, *context_param = NULL, *left_param = NULL, *right_param = NULL, key, replace, value, *_0, _1, _4$$4, _5$$5; + zval input, left, right; - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&message_sub); - ZVAL_UNDEF(&content); - ZVAL_UNDEF(&html); - ZVAL_UNDEF(&item); - ZVAL_UNDEF(&prepared); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_7$$8); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(type) - Z_PARAM_ZVAL(message) + ZVAL_UNDEF(&input); + ZVAL_UNDEF(&left); + ZVAL_UNDEF(&right); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&replace); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&context); + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_STR(input) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) + Z_PARAM_STR(left) + Z_PARAM_STR(right) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &type_param, &message); - zephir_get_strval(&type, type_param); - ZEPHIR_SEPARATE_PARAM(message); - ZEPHIR_INIT_VAR(&content); - ZVAL_STRING(&content, ""); - _0 = Z_TYPE_P(message) != IS_ARRAY; - if (_0) { - _0 = Z_TYPE_P(message) != IS_STRING; + zephir_fetch_params(1, 1, 3, &input_param, &context_param, &left_param, &right_param); + zephir_get_strval(&input, input_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); + } else { + zephir_get_arrval(&context, context_param); } - if (_0) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_flash_exception_ce, "The message must be an array or a string", "phalcon/Flash/AbstractFlash.zep", 334); - return; + if (!left_param) { + ZEPHIR_INIT_VAR(&left); + ZVAL_STRING(&left, "%"); + } else { + zephir_get_strval(&left, left_param); } - if (Z_TYPE_P(message) != IS_ARRAY) { - ZEPHIR_INIT_VAR(&_1$$4); - zephir_create_array(&_1$$4, 1, 0); - zephir_array_fast_append(&_1$$4, message); - ZEPHIR_CPY_WRT(message, &_1$$4); + if (!right_param) { + ZEPHIR_INIT_VAR(&right); + ZVAL_STRING(&right, "%"); + } else { + zephir_get_strval(&right, right_param); } - zephir_is_iterable(message, 0, "phalcon/Flash/AbstractFlash.zep", 360); - if (Z_TYPE_P(message) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(message), _2) + if (ZEPHIR_IS_EMPTY(&context)) { + RETURN_CTOR(&input); + } + ZEPHIR_INIT_VAR(&replace); + array_init(&replace); + zephir_is_iterable(&context, 0, "phalcon/Support/Helper/Str/AbstractStr.zep", 82); + if (Z_TYPE_P(&context) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&context), _2, _3, _0) { - ZEPHIR_INIT_NVAR(&item); - ZVAL_COPY(&item, _2); - ZEPHIR_CALL_METHOD(&prepared, this_ptr, "prepareescapedmessage", &_4, 82, &item); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&html, this_ptr, "preparehtmlmessage", &_5, 83, &type, &prepared); - zephir_check_call_status(); - zephir_read_property(&_6$$5, this_ptr, ZEND_STRL("implicitFlush"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_6$$5)) { - zend_print_zval(&html, 0); + ZEPHIR_INIT_NVAR(&key); + if (_3 != NULL) { + ZVAL_STR_COPY(&key, _3); } else { - zephir_concat_self(&content, &html); - zephir_update_property_array_append(this_ptr, SL("messages"), &html); + ZVAL_LONG(&key, _2); } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0); + ZEPHIR_INIT_NVAR(&_4$$4); + ZEPHIR_CONCAT_VVV(&_4$$4, &left, &key, &right); + zephir_array_update_zval(&replace, &_4$$4, &value, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, message, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &context, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_3, message, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_1, &context, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_3)) { + if (!zend_is_true(&_1)) { break; } - ZEPHIR_CALL_METHOD(&item, message, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&key, &context, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&prepared, this_ptr, "prepareescapedmessage", &_4, 82, &item); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&html, this_ptr, "preparehtmlmessage", &_5, 83, &type, &prepared); - zephir_check_call_status(); - zephir_read_property(&_7$$8, this_ptr, ZEND_STRL("implicitFlush"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_7$$8)) { - zend_print_zval(&html, 0); - } else { - zephir_concat_self(&content, &html); - zephir_update_property_array_append(this_ptr, SL("messages"), &html); - } - ZEPHIR_CALL_METHOD(NULL, message, "next", NULL, 0); + ZEPHIR_CALL_METHOD(&value, &context, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_5$$5); + ZEPHIR_CONCAT_VVV(&_5$$5, &left, &key, &right); + zephir_array_update_zval(&replace, &_5$$5, &value, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &context, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&item); - RETURN_CCTOR(&content); -} - -static PHP_METHOD(Phalcon_Flash_AbstractFlash, warning) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *message_param = NULL, _0; - zval message; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(message) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &message_param); - zephir_get_strval(&message, message_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "warning"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "message", NULL, 0, &_0, &message); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Flash_AbstractFlash, getTemplate) -{ - zval _4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *cssClassses_param = NULL, *cssIconClasses_param = NULL, _0, _1, _2, _3; - zval cssClassses, cssIconClasses, divString, iconString, template; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&cssClassses); - ZVAL_UNDEF(&cssIconClasses); - ZVAL_UNDEF(&divString); - ZVAL_UNDEF(&iconString); - ZVAL_UNDEF(&template); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(cssClassses) - Z_PARAM_STR(cssIconClasses) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &cssClassses_param, &cssIconClasses_param); - zephir_get_strval(&cssClassses, cssClassses_param); - zephir_get_strval(&cssIconClasses, cssIconClasses_param); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_GET_CONSTANT(&_0, "PHP_EOL"); - ZEPHIR_INIT_VAR(&_1); - ZEPHIR_CONCAT_SV(&_1, "%iconString%%message%
", &_0); - zephir_get_strval(&template, &_1); - ZEPHIR_INIT_VAR(&divString); - ZEPHIR_INIT_VAR(&iconString); - zephir_read_property(&_2, this_ptr, ZEND_STRL("customTemplate"), PH_NOISY_CC | PH_READONLY); - if (!(ZEPHIR_IS_EMPTY(&_2))) { - RETURN_MM_MEMBER(getThis(), "customTemplate"); - } - if (!(ZEPHIR_IS_EMPTY(&cssClassses))) { - ZEPHIR_INIT_NVAR(&divString); - ZVAL_STRING(&divString, " class=\"%cssClass%\""); - if (!(ZEPHIR_IS_EMPTY(&cssIconClasses))) { - ZEPHIR_INIT_NVAR(&iconString); - ZVAL_STRING(&iconString, " "); - } - } - zephir_read_property(&_3, this_ptr, ZEND_STRL("interpolator"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_4); - zephir_create_array(&_4, 2, 0); - zephir_array_update_string(&_4, SL("divString"), &divString, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_4, SL("iconString"), &iconString, PH_COPY | PH_SEPARATE); - ZEPHIR_RETURN_CALL_METHOD(&_3, "__invoke", NULL, 0, &template, &_4); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + ZEPHIR_RETURN_CALL_FUNCTION("strtr", NULL, 5, &input, &replace); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Flash_AbstractFlash, prepareEscapedMessage) +static PHP_METHOD(Phalcon_Support_Helper_Str_AbstractStr, toLower) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *message_param = NULL, escaper, _0; - zval message; - zval *this_ptr = getThis(); + zval *text_param = NULL, *encoding_param = NULL, _0; + zval text, encoding; - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&escaper); + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&encoding); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(message) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(text) + Z_PARAM_OPTIONAL + Z_PARAM_STR(encoding) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &message_param); - zephir_get_strval(&message, message_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("autoescape"), PH_NOISY_CC | PH_READONLY); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - RETURN_CTOR(&message); + zephir_fetch_params(1, 1, 1, &text_param, &encoding_param); + zephir_get_strval(&text, text_param); + if (!encoding_param) { + ZEPHIR_INIT_VAR(&encoding); + ZVAL_STRING(&encoding, "UTF-8"); + } else { + zephir_get_strval(&encoding, encoding_param); } - ZEPHIR_CALL_METHOD(&escaper, this_ptr, "getescaperservice", NULL, 0); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&escaper, "escapehtml", NULL, 0, &message); + ZVAL_LONG(&_0, 1); + ZEPHIR_RETURN_CALL_FUNCTION("mb_convert_case", NULL, 12, &text, &_0, &encoding); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Flash_AbstractFlash, prepareHtmlMessage) +static PHP_METHOD(Phalcon_Support_Helper_Str_AbstractStr, toStartsWith) { - zval _5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *type_param = NULL, *message_param = NULL, cssClasses, cssIconClasses, _0, _1, _2, _3, _4; - zval type, message; - zval *this_ptr = getThis(); + zend_bool ignoreCase; + zval *haystack_param = NULL, *needle_param = NULL, *ignoreCase_param = NULL, child, parent, _0; + zval haystack, needle; - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&cssClasses); - ZVAL_UNDEF(&cssIconClasses); + ZVAL_UNDEF(&haystack); + ZVAL_UNDEF(&needle); + ZVAL_UNDEF(&child); + ZVAL_UNDEF(&parent); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(type) - Z_PARAM_STR(message) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &type_param, &message_param); - zephir_get_strval(&type, type_param); - zephir_get_strval(&message, message_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("automaticHtml"), PH_NOISY_CC | PH_READONLY); - if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - RETURN_CTOR(&message); - } - zephir_read_property(&_1, this_ptr, ZEND_STRL("cssClasses"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&cssClasses, this_ptr, "checkclasses", NULL, 84, &_1, &type); - zephir_check_call_status(); - zephir_read_property(&_2, this_ptr, ZEND_STRL("cssIconClasses"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&cssIconClasses, this_ptr, "checkclasses", NULL, 84, &_2, &type); - zephir_check_call_status(); - zephir_read_property(&_3, this_ptr, ZEND_STRL("interpolator"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_4, this_ptr, "gettemplate", NULL, 85, &cssClasses, &cssIconClasses); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_5); - zephir_create_array(&_5, 3, 0); - zephir_array_update_string(&_5, SL("cssClass"), &cssClasses, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_5, SL("cssIconClass"), &cssIconClasses, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_5, SL("message"), &message, PH_COPY | PH_SEPARATE); - ZEPHIR_RETURN_CALL_METHOD(&_3, "__invoke", NULL, 0, &_4, &_5); - zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Flash_AbstractFlash, checkClasses) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval type; - zval *collection_param = NULL, *type_param = NULL, content, _0$$5, _1$$4; - zval collection; - - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&content); - ZVAL_UNDEF(&_0$$5); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&type); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ARRAY(collection) - Z_PARAM_STR(type) + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(haystack) + Z_PARAM_STR(needle) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(ignoreCase) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &collection_param, &type_param); - zephir_get_arrval(&collection, collection_param); - zephir_get_strval(&type, type_param); - ZEPHIR_INIT_VAR(&content); - ZVAL_STRING(&content, ""); - if (zephir_array_isset(&collection, &type)) { - ZEPHIR_OBS_NVAR(&content); - zephir_array_fetch(&content, &collection, &type, PH_NOISY, "phalcon/Flash/AbstractFlash.zep", 484); - } - if (1 != ZEPHIR_IS_EMPTY(&content)) { - if (Z_TYPE_P(&content) != IS_ARRAY) { - ZEPHIR_INIT_VAR(&_0$$5); - zephir_create_array(&_0$$5, 1, 0); - zephir_array_fast_append(&_0$$5, &content); - ZEPHIR_CPY_WRT(&content, &_0$$5); + zephir_fetch_params(1, 2, 1, &haystack_param, &needle_param, &ignoreCase_param); + zephir_get_strval(&haystack, haystack_param); + zephir_get_strval(&needle, needle_param); + if (!ignoreCase_param) { + ignoreCase = 1; + } else { } - ZEPHIR_INIT_VAR(&_1$$4); - zephir_fast_join_str(&_1$$4, SL(" "), &content); - ZEPHIR_CPY_WRT(&content, &_1$$4); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, ""); + if (ZEPHIR_IS_IDENTICAL(&_0, &haystack)) { + RETURN_MM_BOOL(0); } - RETURN_CCTOR(&content); + if (EXPECTED(ignoreCase)) { + ZEPHIR_CALL_FUNCTION(&child, "mb_strtolower", NULL, 10, &needle); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&parent, "mb_strtolower", NULL, 10, &haystack); + zephir_check_call_status(); + } else { + ZEPHIR_CPY_WRT(&child, &needle); + ZEPHIR_CPY_WRT(&parent, &haystack); + } + RETURN_MM_BOOL(zephir_start_with(&parent, &child, NULL)); } -zend_object *zephir_init_properties_Phalcon_Flash_AbstractFlash(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Support_Helper_Str_AbstractStr, toUpper) { - zval _0, _2, _4, _1$$3, _3$$4, _5$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *text_param = NULL, *encoding_param = NULL, _0; + zval text, encoding; - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("messages"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("cssIconClasses"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("cssIconClasses"), &_3$$4); - } - zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("cssClasses"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_4) == IS_NULL) { - ZEPHIR_INIT_VAR(&_5$$5); - array_init(&_5$$5); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("cssClasses"), &_5$$5); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&encoding); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(text) + Z_PARAM_OPTIONAL + Z_PARAM_STR(encoding) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &text_param, &encoding_param); + zephir_get_strval(&text, text_param); + if (!encoding_param) { + ZEPHIR_INIT_VAR(&encoding); + ZVAL_STRING(&encoding, "UTF-8"); + } else { + zephir_get_strval(&encoding, encoding_param); } + ZVAL_LONG(&_0, 0); + ZEPHIR_RETURN_CALL_FUNCTION("mb_convert_case", NULL, 12, &text, &_0, &encoding); + zephir_check_call_status(); + RETURN_MM(); } @@ -142842,89 +142021,162 @@ zend_object *zephir_init_properties_Phalcon_Flash_AbstractFlash(zend_class_entry -ZEPHIR_INIT_CLASS(Phalcon_Flash_Direct) +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Camelize) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Flash, Direct, phalcon, flash_direct, phalcon_flash_abstractflash_ce, phalcon_flash_direct_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, Camelize, phalcon, support_helper_str_camelize, phalcon_support_helper_str_pascalcase_ce, phalcon_support_helper_str_camelize_method_entry, 0); return SUCCESS; } -static PHP_METHOD(Phalcon_Flash_Direct, message) +static PHP_METHOD(Phalcon_Support_Helper_Str_Camelize, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *type_param = NULL, *message, message_sub; - zval type; - zval *this_ptr = getThis(); + zend_bool lowerFirst; + zval *text_param = NULL, *delimiters_param = NULL, *lowerFirst_param = NULL, result, _0$$3; + zval text, delimiters; - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&message_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(type) - Z_PARAM_ZVAL(message) + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&delimiters); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&_0$$3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(text) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(delimiters) + Z_PARAM_BOOL(lowerFirst) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &type_param, &message); - zephir_get_strval(&type, type_param); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "outputmessage", NULL, 0, &type, message); + zephir_fetch_params(1, 1, 2, &text_param, &delimiters_param, &lowerFirst_param); + zephir_get_strval(&text, text_param); + if (!delimiters_param) { + ZEPHIR_INIT_VAR(&delimiters); + } else { + zephir_get_strval(&delimiters, delimiters_param); + } + if (!lowerFirst_param) { + lowerFirst = 0; + } else { + } + ZEPHIR_CALL_PARENT(&result, phalcon_support_helper_str_camelize_ce, getThis(), "__invoke", NULL, 0, &text, &delimiters); zephir_check_call_status(); - RETURN_MM(); + if (lowerFirst == 1) { + ZEPHIR_CALL_FUNCTION(&_0$$3, "lcfirst", NULL, 76, &result); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&result, &_0$$3); + } + RETURN_CCTOR(&result); } -static PHP_METHOD(Phalcon_Flash_Direct, output) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Concat) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, Concat, phalcon, support_helper_str_concat, phalcon_support_helper_str_abstractstr_ce, phalcon_support_helper_str_concat_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Str_Concat, __invoke) { + zval argument, arguments, delimiter, data, first, last, prefix, suffix, _0, _1, *_2, _3, _6, _4$$6, _5$$7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *remove_param = NULL, message, _0, *_1, _2; - zend_bool remove; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&argument); + ZVAL_UNDEF(&arguments); + ZVAL_UNDEF(&delimiter); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&first); + ZVAL_UNDEF(&last); + ZVAL_UNDEF(&prefix); + ZVAL_UNDEF(&suffix); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(remove) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_4$$6); + ZVAL_UNDEF(&_5$$7); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &remove_param); - if (!remove_param) { - remove = 1; - } else { - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_0, 0, "phalcon/Flash/Direct.zep", 45); - if (Z_TYPE_P(&_0) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) + + ZEPHIR_INIT_VAR(&arguments); + zephir_get_args(&arguments); + if (UNEXPECTED(zephir_fast_count_int(&arguments) < 3)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_support_helper_exception_ce, "concat needs at least three parameters", "phalcon/Support/Helper/Str/Concat.zep", 37); + return; + } + ZEPHIR_MAKE_REF(&arguments); + ZEPHIR_CALL_FUNCTION(&delimiter, "reset", NULL, 477, &arguments); + ZEPHIR_UNREF(&arguments); + zephir_check_call_status(); + ZVAL_LONG(&_0, 1); + ZEPHIR_CALL_FUNCTION(&_1, "array_slice", NULL, 501, &arguments, &_0); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&arguments, &_1); + ZEPHIR_MAKE_REF(&arguments); + ZEPHIR_CALL_FUNCTION(&first, "reset", NULL, 477, &arguments); + ZEPHIR_UNREF(&arguments); + zephir_check_call_status(); + ZEPHIR_MAKE_REF(&arguments); + ZEPHIR_CALL_FUNCTION(&last, "end", NULL, 320, &arguments); + ZEPHIR_UNREF(&arguments); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&prefix); + ZVAL_STRING(&prefix, ""); + ZEPHIR_INIT_VAR(&suffix); + ZVAL_STRING(&suffix, ""); + ZEPHIR_INIT_VAR(&data); + array_init(&data); + if (zephir_start_with(&first, &delimiter, NULL)) { + ZEPHIR_CPY_WRT(&prefix, &delimiter); + } + if (zephir_end_with(&last, &delimiter, NULL)) { + ZEPHIR_CPY_WRT(&suffix, &delimiter); + } + zephir_is_iterable(&arguments, 0, "phalcon/Support/Helper/Str/Concat.zep", 61); + if (Z_TYPE_P(&arguments) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&arguments), _2) { - ZEPHIR_INIT_NVAR(&message); - ZVAL_COPY(&message, _1); - zend_print_zval(&message, 0); + ZEPHIR_INIT_NVAR(&argument); + ZVAL_COPY(&argument, _2); + ZEPHIR_INIT_NVAR(&_4$$6); + zephir_fast_trim(&_4$$6, &argument, &delimiter, ZEPHIR_TRIM_BOTH); + zephir_array_append(&data, &_4$$6, PH_SEPARATE, "phalcon/Support/Helper/Str/Concat.zep", 58); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &arguments, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_3, &arguments, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_2)) { + if (!zend_is_true(&_3)) { break; } - ZEPHIR_CALL_METHOD(&message, &_0, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&argument, &arguments, "current", NULL, 0); zephir_check_call_status(); - zend_print_zval(&message, 0); - ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); + ZEPHIR_INIT_NVAR(&_5$$7); + zephir_fast_trim(&_5$$7, &argument, &delimiter, ZEPHIR_TRIM_BOTH); + zephir_array_append(&data, &_5$$7, PH_SEPARATE, "phalcon/Support/Helper/Str/Concat.zep", 58); + ZEPHIR_CALL_METHOD(NULL, &arguments, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&message); - if (remove) { - ZEPHIR_CALL_PARENT(NULL, phalcon_flash_direct_ce, getThis(), "clear", NULL, 0); - zephir_check_call_status(); - } - ZEPHIR_MM_RESTORE(); + ZEPHIR_INIT_NVAR(&argument); + ZEPHIR_INIT_VAR(&_6); + zephir_fast_join(&_6, &delimiter, &data); + ZEPHIR_CONCAT_VVV(return_value, &prefix, &_6, &suffix); + RETURN_MM(); } @@ -142937,35 +142189,42 @@ static PHP_METHOD(Phalcon_Flash_Direct, output) -ZEPHIR_INIT_CLASS(Phalcon_Flash_Exception) +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_CountVowels) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Flash, Exception, phalcon, flash_exception, zend_ce_exception, NULL, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, CountVowels, phalcon, support_helper_str_countvowels, phalcon_support_helper_str_countvowels_method_entry, 0); return SUCCESS; } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Flash_FlashInterface) +static PHP_METHOD(Phalcon_Support_Helper_Str_CountVowels, __invoke) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Flash, FlashInterface, phalcon, flash_flashinterface, phalcon_flash_flashinterface_method_entry); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *text_param = NULL, matches, _0, _1, _2, _3; + zval text; - return SUCCESS; + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&matches); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(text) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &text_param); + zephir_get_strval(&text, text_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "/[aeiouy]/i"); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "/[aeiouy]/i"); + zephir_preg_match(&_1, &_2, &text, &matches, 1, 0 , 0 ); + zephir_array_fetch_long(&_3, &matches, 0, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/CountVowels.zep", 30); + RETURN_MM_LONG(zephir_fast_count_int(&_3)); } -ZEPHIR_DOC_METHOD(Phalcon_Flash_FlashInterface, error); -ZEPHIR_DOC_METHOD(Phalcon_Flash_FlashInterface, message); -ZEPHIR_DOC_METHOD(Phalcon_Flash_FlashInterface, notice); -ZEPHIR_DOC_METHOD(Phalcon_Flash_FlashInterface, success); -ZEPHIR_DOC_METHOD(Phalcon_Flash_FlashInterface, warning); @@ -142976,350 +142235,245 @@ ZEPHIR_DOC_METHOD(Phalcon_Flash_FlashInterface, warning); -ZEPHIR_INIT_CLASS(Phalcon_Flash_Session) +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Decapitalize) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Flash, Session, phalcon, flash_session, phalcon_flash_abstractflash_ce, phalcon_flash_session_method_entry, 0); - - zephir_declare_class_constant_string(phalcon_flash_session_ce, SL("SESSION_KEY"), "_flashMessages"); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, Decapitalize, phalcon, support_helper_str_decapitalize, phalcon_support_helper_str_abstractstr_ce, phalcon_support_helper_str_decapitalize_method_entry, 0); return SUCCESS; } -static PHP_METHOD(Phalcon_Flash_Session, clear) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZVAL_BOOL(&_0, 1); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "getsessionmessages", NULL, 0, &_0); - zephir_check_call_status(); - ZEPHIR_CALL_PARENT(NULL, phalcon_flash_session_ce, getThis(), "clear", NULL, 0); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Flash_Session, getMessages) +static PHP_METHOD(Phalcon_Support_Helper_Str_Decapitalize, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool remove; - zval *type = NULL, type_sub, *remove_param = NULL, __$null, _0; + zend_bool upperRest; + zval *text_param = NULL, *upperRest_param = NULL, *encoding_param = NULL, substr, suffix, _0, _1, _2, _3; + zval text, encoding; zval *this_ptr = getThis(); - ZVAL_UNDEF(&type_sub); - ZVAL_NULL(&__$null); + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&encoding); + ZVAL_UNDEF(&substr); + ZVAL_UNDEF(&suffix); ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(text) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(type) - Z_PARAM_BOOL(remove) + Z_PARAM_BOOL(upperRest) + Z_PARAM_STR(encoding) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &type, &remove_param); - if (!type) { - type = &type_sub; - type = &__$null; - } - if (!remove_param) { - remove = 1; + zephir_fetch_params(1, 1, 2, &text_param, &upperRest_param, &encoding_param); + zephir_get_strval(&text, text_param); + if (!upperRest_param) { + upperRest = 0; } else { } - if (remove) { - ZVAL_BOOL(&_0, 1); + if (!encoding_param) { + ZEPHIR_INIT_VAR(&encoding); + ZVAL_STRING(&encoding, "UTF-8"); } else { - ZVAL_BOOL(&_0, 0); + zephir_get_strval(&encoding, encoding_param); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsessionmessages", NULL, 0, &_0, type); + ZVAL_LONG(&_0, 1); + ZEPHIR_CALL_FUNCTION(&substr, "mb_substr", NULL, 228, &text, &_0); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Flash_Session, has) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *type_param = NULL, messages, _0; - zval type; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&messages); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(type) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &type_param); - if (!type_param) { - ZEPHIR_INIT_VAR(&type); + if (upperRest) { + ZEPHIR_CALL_METHOD(&suffix, this_ptr, "toupper", NULL, 0, &substr, &encoding); + zephir_check_call_status(); } else { - zephir_get_strval(&type, type_param); + ZEPHIR_CPY_WRT(&suffix, &substr); } - ZVAL_BOOL(&_0, 0); - ZEPHIR_CALL_METHOD(&messages, this_ptr, "getsessionmessages", NULL, 0, &_0); + ZVAL_LONG(&_0, 0); + ZVAL_LONG(&_2, 1); + ZEPHIR_CALL_FUNCTION(&_3, "mb_substr", NULL, 228, &text, &_0, &_2); zephir_check_call_status(); - if (!(!(ZEPHIR_IS_EMPTY(&type)))) { - RETURN_MM_BOOL((1 != ZEPHIR_IS_EMPTY(&messages))); - } - RETURN_MM_BOOL(zephir_array_isset(&messages, &type)); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "tolower", NULL, 0, &_3, &encoding); + zephir_check_call_status(); + ZEPHIR_CONCAT_VV(return_value, &_1, &suffix); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Flash_Session, message) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Decrement) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *type_param = NULL, *message, message_sub, messages, _0, _1$$3; - zval type; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, Decrement, phalcon, support_helper_str_decrement, phalcon_support_helper_str_decrement_method_entry, 0); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&message_sub); - ZVAL_UNDEF(&messages); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(type) - Z_PARAM_ZVAL(message) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &type_param, &message); - zephir_get_strval(&type, type_param); - ZVAL_BOOL(&_0, 0); - ZEPHIR_CALL_METHOD(&messages, this_ptr, "getsessionmessages", NULL, 0, &_0); - zephir_check_call_status(); - if (1 != zephir_array_isset(&messages, &type)) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_array_update_zval(&messages, &type, &_1$$3, PH_COPY | PH_SEPARATE); - } - zephir_array_update_multi(&messages, message, SL("za"), 2, &type); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setsessionmessages", NULL, 0, &messages); - zephir_check_call_status(); - RETURN_MM_NULL(); + return SUCCESS; } -static PHP_METHOD(Phalcon_Flash_Session, output) +static PHP_METHOD(Phalcon_Support_Helper_Str_Decrement, __invoke) { - zend_string *_4; - zend_ulong _3; + zend_long number = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *remove_param = NULL, message, messages, type, _0, *_1, _2; - zend_bool remove; - zval *this_ptr = getThis(); + zval *text_param = NULL, *separator_param = NULL, parts, _0, _3, _4, _1$$3, _2$$4; + zval text, separator; - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&messages); - ZVAL_UNDEF(&type); + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&separator); + ZVAL_UNDEF(&parts); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(0, 1) + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(text) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(remove) + Z_PARAM_STR(separator) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &remove_param); - if (!remove_param) { - remove = 1; - } else { - } - if (remove) { - ZVAL_BOOL(&_0, 1); + zephir_fetch_params(1, 1, 1, &text_param, &separator_param); + zephir_get_strval(&text, text_param); + if (!separator_param) { + ZEPHIR_INIT_VAR(&separator); + ZVAL_STRING(&separator, "_"); } else { - ZVAL_BOOL(&_0, 0); + zephir_get_strval(&separator, separator_param); } - ZEPHIR_CALL_METHOD(&messages, this_ptr, "getsessionmessages", NULL, 0, &_0); - zephir_check_call_status(); - zephir_is_iterable(&messages, 0, "phalcon/Flash/Session.zep", 117); - if (Z_TYPE_P(&messages) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&messages), _3, _4, _1) - { - ZEPHIR_INIT_NVAR(&type); - if (_4 != NULL) { - ZVAL_STR_COPY(&type, _4); - } else { - ZVAL_LONG(&type, _3); - } - ZEPHIR_INIT_NVAR(&message); - ZVAL_COPY(&message, _1); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "outputmessage", &_5, 0, &type, &message); - zephir_check_call_status(); - } ZEND_HASH_FOREACH_END(); + number = 0; + ZEPHIR_INIT_VAR(&parts); + zephir_fast_explode(&parts, &separator, &text, LONG_MAX); + ZEPHIR_INIT_VAR(&_0); + if (Z_TYPE_P(&parts) != IS_ARRAY) { + ZEPHIR_INIT_NVAR(&_0); + array_init(&_0); } else { - ZEPHIR_CALL_METHOD(NULL, &messages, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &messages, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&type, &messages, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&message, &messages, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "outputmessage", &_5, 0, &type, &message); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &messages, "next", NULL, 0); - zephir_check_call_status(); + ZEPHIR_CPY_WRT(&_0, &parts); + } + ZEPHIR_CPY_WRT(&parts, &_0); + if (1 == zephir_array_isset_long(&parts, 1)) { + zephir_memory_observe(&_1$$3); + zephir_array_fetch_long(&_1$$3, &parts, 1, PH_NOISY, "phalcon/Support/Helper/Str/Decrement.zep", 36); + number = zephir_get_intval(&_1$$3); + number--; + if (number <= 0) { + zephir_array_fetch_long(&_2$$4, &parts, 0, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Decrement.zep", 39); + RETURN_CTOR(&_2$$4); } } - ZEPHIR_INIT_NVAR(&message); - ZEPHIR_INIT_NVAR(&type); - ZEPHIR_CALL_PARENT(NULL, phalcon_flash_session_ce, getThis(), "clear", NULL, 0); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + zephir_array_fetch_long(&_3, &parts, 0, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Decrement.zep", 43); + ZEPHIR_INIT_VAR(&_4); + ZVAL_LONG(&_4, number); + ZEPHIR_CONCAT_VVV(return_value, &_3, &separator, &_4); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Flash_Session, getSessionMessages) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_DirFromFile) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, DirFromFile, phalcon, support_helper_str_dirfromfile, phalcon_support_helper_str_dirfromfile_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Str_DirFromFile, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval type; - zval *remove_param = NULL, *type_param = NULL, session, messages, returnMessages, _0, _1$$6, _2$$7; - zend_bool remove; - zval *this_ptr = getThis(); + zval *file_param = NULL, name, start, _0, _1, _4, _5, _2$$3, _3$$3; + zval file; - ZVAL_UNDEF(&session); - ZVAL_UNDEF(&messages); - ZVAL_UNDEF(&returnMessages); + ZVAL_UNDEF(&file); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&start); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$6); - ZVAL_UNDEF(&_2$$7); - ZVAL_UNDEF(&type); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_BOOL(remove) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(type) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(file) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &remove_param, &type_param); - if (!type_param) { - ZEPHIR_INIT_VAR(&type); - } else { - zephir_get_strval(&type, type_param); - } - ZEPHIR_CALL_METHOD(&session, this_ptr, "getsessionservice", NULL, 0); + zephir_fetch_params(1, 1, 0, &file_param); + zephir_get_strval(&file, file_param); + ZVAL_LONG(&_0, 8); + ZEPHIR_CALL_FUNCTION(&name, "pathinfo", NULL, 89, &file, &_0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "_flashMessages"); - ZEPHIR_CALL_METHOD(&messages, &session, "get", NULL, 0, &_0); + ZVAL_LONG(&_0, 0); + ZVAL_LONG(&_1, -2); + ZEPHIR_CALL_FUNCTION(&start, "mb_substr", NULL, 228, &name, &_0, &_1); zephir_check_call_status(); - if (Z_TYPE_P(&messages) != IS_ARRAY) { - ZEPHIR_INIT_NVAR(&messages); - array_init(&messages); - } - if (1 != ZEPHIR_IS_EMPTY(&type)) { - zephir_memory_observe(&returnMessages); - if (zephir_array_isset_fetch(&returnMessages, &messages, &type, 0)) { - if (remove) { - zephir_array_unset(&messages, &type, PH_SEPARATE); - ZEPHIR_INIT_VAR(&_1$$6); - ZVAL_STRING(&_1$$6, "_flashMessages"); - ZEPHIR_CALL_METHOD(NULL, &session, "set", NULL, 0, &_1$$6, &messages); - zephir_check_call_status(); - } - RETURN_CCTOR(&returnMessages); - } - array_init(return_value); - RETURN_MM(); - } - if (remove) { - ZEPHIR_INIT_VAR(&_2$$7); - ZVAL_STRING(&_2$$7, "_flashMessages"); - ZEPHIR_CALL_METHOD(NULL, &session, "remove", NULL, 0, &_2$$7); + if (!zephir_is_true(&start)) { + ZVAL_LONG(&_2$$3, 0); + ZVAL_LONG(&_3$$3, 1); + ZEPHIR_CALL_FUNCTION(&start, "mb_substr", NULL, 228, &name, &_2$$3, &_3$$3); zephir_check_call_status(); } - RETURN_CCTOR(&messages); + ZEPHIR_INIT_VAR(&_4); + ZVAL_LONG(&_0, 2); + ZEPHIR_CALL_FUNCTION(&_5, "mb_str_split", NULL, 0, &start, &_0); + zephir_check_call_status(); + zephir_fast_join_str(&_4, SL("/"), &_5); + ZEPHIR_CONCAT_VS(return_value, &_4, "/"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Flash_Session, setSessionMessages) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_DirSeparator) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *messages_param = NULL, session, _0; - zval messages; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, DirSeparator, phalcon, support_helper_str_dirseparator, phalcon_support_helper_str_dirseparator_method_entry, 0); - ZVAL_UNDEF(&messages); - ZVAL_UNDEF(&session); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(messages) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &messages_param); - ZEPHIR_OBS_COPY_OR_DUP(&messages, messages_param); - ZEPHIR_CALL_METHOD(&session, this_ptr, "getsessionservice", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "_flashMessages"); - ZEPHIR_CALL_METHOD(NULL, &session, "set", NULL, 0, &_0, &messages); - zephir_check_call_status(); - RETURN_CTOR(&messages); + return SUCCESS; } -static PHP_METHOD(Phalcon_Flash_Session, getSessionService) +static PHP_METHOD(Phalcon_Support_Helper_Str_DirSeparator, __invoke) { - zend_bool _2; - zval _0, _1, _3, _4, _5, _6$$4, _7$$4, _8$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + zval *directory_param = NULL, _0, _1; + zval directory; + ZVAL_UNDEF(&directory); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_8$$4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(directory) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("sessionService"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) != IS_NULL) { - RETURN_MM_MEMBER(getThis(), "sessionService"); - } - zephir_read_property(&_1, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - _2 = Z_TYPE_P(&_1) != IS_NULL; - if (_2) { - zephir_read_property(&_3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_5); - ZVAL_STRING(&_5, "session"); - ZEPHIR_CALL_METHOD(&_4, &_3, "has", NULL, 0, &_5); - zephir_check_call_status(); - _2 = ZEPHIR_IS_TRUE_IDENTICAL(&_4); - } - if (_2) { - zephir_read_property(&_6$$4, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_8$$4); - ZVAL_STRING(&_8$$4, "session"); - ZEPHIR_CALL_METHOD(&_7$$4, &_6$$4, "getshared", NULL, 0, &_8$$4); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("sessionService"), &_7$$4); - RETURN_MM_MEMBER(getThis(), "sessionService"); - } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_flash_exception_ce, "A dependency injection container is required to access the 'session' service", "phalcon/Flash/Session.zep", 205); - return; + zephir_fetch_params(1, 1, 0, &directory_param); + zephir_get_strval(&directory, directory_param); + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "/"); + zephir_fast_trim(&_0, &directory, &_1, ZEPHIR_TRIM_RIGHT); + ZEPHIR_CONCAT_VS(return_value, &_0, "/"); + RETURN_MM(); } @@ -143332,886 +142486,862 @@ static PHP_METHOD(Phalcon_Flash_Session, getSessionService) -ZEPHIR_INIT_CLASS(Phalcon_Support_Collection) +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Dynamic) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support, Collection, phalcon, support_collection, phalcon_support_collection_method_entry, 0); - - zend_declare_property_null(phalcon_support_collection_ce, SL("data"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_support_collection_ce, SL("insensitive"), 1, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_support_collection_ce, SL("lowerKeys"), ZEND_ACC_PROTECTED); - phalcon_support_collection_ce->create_object = zephir_init_properties_Phalcon_Support_Collection; + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, Dynamic, phalcon, support_helper_str_dynamic, phalcon_support_helper_str_dynamic_method_entry, 0); - zend_class_implements(phalcon_support_collection_ce, 1, zend_ce_arrayaccess); - zend_class_implements(phalcon_support_collection_ce, 1, phalcon_support_collection_collectioninterface_ce); - zend_class_implements(phalcon_support_collection_ce, 1, zend_ce_countable); - zend_class_implements(phalcon_support_collection_ce, 1, zend_ce_aggregate); - zend_class_implements(phalcon_support_collection_ce, 1, php_json_serializable_ce); - zend_class_implements(phalcon_support_collection_ce, 1, zend_ce_serializable); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Collection, __construct) +static PHP_METHOD(Phalcon_Support_Helper_Str_Dynamic, __invoke) { + zend_bool _8$$6, _17$$8; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_11 = NULL, *_16 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool insensitive; - zval *data_param = NULL, *insensitive_param = NULL, __$true, __$false; - zval data; - zval *this_ptr = getThis(); + zval *text_param = NULL, *leftDelimiter_param = NULL, *rightDelimiter_param = NULL, *separator_param = NULL, ldS, rdS, matches, match, words, word, sub, _0, _1, _4, _5, _2$$3, *_6$$5, _7$$5, _9$$6, _10$$6, _12$$6, _13$$6, _14$$6, _15$$6, _18$$8, _19$$8, _20$$8, _21$$8, _22$$8, _23$$8; + zval text, leftDelimiter, rightDelimiter, separator, pattern, _3$$3; - ZVAL_UNDEF(&data); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(0, 2) + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&leftDelimiter); + ZVAL_UNDEF(&rightDelimiter); + ZVAL_UNDEF(&separator); + ZVAL_UNDEF(&pattern); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&ldS); + ZVAL_UNDEF(&rdS); + ZVAL_UNDEF(&matches); + ZVAL_UNDEF(&match); + ZVAL_UNDEF(&words); + ZVAL_UNDEF(&word); + ZVAL_UNDEF(&sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_9$$6); + ZVAL_UNDEF(&_10$$6); + ZVAL_UNDEF(&_12$$6); + ZVAL_UNDEF(&_13$$6); + ZVAL_UNDEF(&_14$$6); + ZVAL_UNDEF(&_15$$6); + ZVAL_UNDEF(&_18$$8); + ZVAL_UNDEF(&_19$$8); + ZVAL_UNDEF(&_20$$8); + ZVAL_UNDEF(&_21$$8); + ZVAL_UNDEF(&_22$$8); + ZVAL_UNDEF(&_23$$8); + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_STR(text) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(data) - Z_PARAM_BOOL(insensitive) + Z_PARAM_STR(leftDelimiter) + Z_PARAM_STR(rightDelimiter) + Z_PARAM_STR(separator) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &data_param, &insensitive_param); - if (!data_param) { - ZEPHIR_INIT_VAR(&data); - array_init(&data); + zephir_fetch_params(1, 1, 3, &text_param, &leftDelimiter_param, &rightDelimiter_param, &separator_param); + zephir_get_strval(&text, text_param); + if (!leftDelimiter_param) { + ZEPHIR_INIT_VAR(&leftDelimiter); + ZVAL_STRING(&leftDelimiter, "{"); } else { - zephir_get_arrval(&data, data_param); + zephir_get_strval(&leftDelimiter, leftDelimiter_param); } - if (!insensitive_param) { - insensitive = 1; + if (!rightDelimiter_param) { + ZEPHIR_INIT_VAR(&rightDelimiter); + ZVAL_STRING(&rightDelimiter, "}"); } else { - } - if (insensitive) { - zephir_update_property_zval(this_ptr, ZEND_STRL("insensitive"), &__$true); + zephir_get_strval(&rightDelimiter, rightDelimiter_param); + } + if (!separator_param) { + ZEPHIR_INIT_VAR(&separator); + ZVAL_STRING(&separator, "|"); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("insensitive"), &__$false); + zephir_get_strval(&separator, separator_param); } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &data); + ZEPHIR_CALL_FUNCTION(&_0, "substr_count", NULL, 0, &text, &leftDelimiter); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + ZEPHIR_CALL_FUNCTION(&_1, "substr_count", NULL, 0, &text, &rightDelimiter); + zephir_check_call_status(); + if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { + ZEPHIR_INIT_VAR(&_2$$3); + object_init_ex(&_2$$3, spl_ce_RuntimeException); + ZEPHIR_INIT_VAR(&_3$$3); + ZEPHIR_CONCAT_SVS(&_3$$3, "Syntax error in string '", &text, "'"); + ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 0, &_3$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_2$$3, "phalcon/Support/Helper/Str/Dynamic.zep", 43); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_FUNCTION(&ldS, "preg_quote", NULL, 351, &leftDelimiter); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&rdS, "preg_quote", NULL, 351, &rightDelimiter); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4); + ZEPHIR_CONCAT_SVSVVSVS(&_4, "/", &ldS, "([^", &ldS, &rdS, "]+)", &rdS, "/"); + zephir_get_strval(&pattern, &_4); + ZEPHIR_INIT_VAR(&matches); + array_init(&matches); + ZEPHIR_INIT_VAR(&_5); + zephir_preg_match(&_5, &pattern, &text, &matches, 1, 2 , 0 ); + if (!(zephir_is_true(&_5))) { + RETURN_CTOR(&text); + } + if (Z_TYPE_P(&matches) == IS_ARRAY) { + zephir_is_iterable(&matches, 0, "phalcon/Support/Helper/Str/Dynamic.zep", 66); + if (Z_TYPE_P(&matches) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&matches), _6$$5) + { + ZEPHIR_INIT_NVAR(&match); + ZVAL_COPY(&match, _6$$5); + _8$$6 = !(zephir_array_isset_long(&match, 0)); + if (!(_8$$6)) { + _8$$6 = !(zephir_array_isset_long(&match, 1)); + } + if (_8$$6) { + continue; + } + zephir_array_fetch_long(&_9$$6, &match, 1, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Dynamic.zep", 61); + ZEPHIR_INIT_NVAR(&words); + zephir_fast_explode(&words, &separator, &_9$$6, LONG_MAX); + ZEPHIR_OBS_NVAR(&word); + ZEPHIR_CALL_FUNCTION(&_10$$6, "array_rand", &_11, 202, &words); + zephir_check_call_status(); + zephir_array_fetch(&word, &words, &_10$$6, PH_NOISY, "phalcon/Support/Helper/Str/Dynamic.zep", 62); + zephir_array_fetch_long(&_12$$6, &match, 0, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Dynamic.zep", 63); + ZEPHIR_CALL_FUNCTION(&sub, "preg_quote", NULL, 351, &_12$$6, &separator); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_13$$6); + ZEPHIR_CONCAT_SVS(&_13$$6, "/", &sub, "/"); + ZVAL_LONG(&_14$$6, 1); + ZEPHIR_CALL_FUNCTION(&_15$$6, "preg_replace", &_16, 41, &_13$$6, &word, &text, &_14$$6); + zephir_check_call_status(); + zephir_get_strval(&text, &_15$$6); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &matches, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_7$$5, &matches, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_7$$5)) { + break; + } + ZEPHIR_CALL_METHOD(&match, &matches, "current", NULL, 0); + zephir_check_call_status(); + _17$$8 = !(zephir_array_isset_long(&match, 0)); + if (!(_17$$8)) { + _17$$8 = !(zephir_array_isset_long(&match, 1)); + } + if (_17$$8) { + continue; + } + zephir_array_fetch_long(&_18$$8, &match, 1, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Dynamic.zep", 61); + ZEPHIR_INIT_NVAR(&words); + zephir_fast_explode(&words, &separator, &_18$$8, LONG_MAX); + ZEPHIR_OBS_NVAR(&word); + ZEPHIR_CALL_FUNCTION(&_19$$8, "array_rand", &_11, 202, &words); + zephir_check_call_status(); + zephir_array_fetch(&word, &words, &_19$$8, PH_NOISY, "phalcon/Support/Helper/Str/Dynamic.zep", 62); + zephir_array_fetch_long(&_20$$8, &match, 0, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Dynamic.zep", 63); + ZEPHIR_CALL_FUNCTION(&sub, "preg_quote", NULL, 351, &_20$$8, &separator); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_21$$8); + ZEPHIR_CONCAT_SVS(&_21$$8, "/", &sub, "/"); + ZVAL_LONG(&_22$$8, 1); + ZEPHIR_CALL_FUNCTION(&_23$$8, "preg_replace", &_16, 41, &_21$$8, &word, &text, &_22$$8); + zephir_check_call_status(); + zephir_get_strval(&text, &_23$$8); + ZEPHIR_CALL_METHOD(NULL, &matches, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&match); + } + RETURN_CTOR(&text); } -static PHP_METHOD(Phalcon_Support_Collection, __get) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *element_param = NULL; - zval element; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&element); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(element) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &element_param); - zephir_get_strval(&element, element_param); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0, &element); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Support_Collection, __isset) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *element_param = NULL; - zval element; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&element); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(element) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &element_param); - zephir_get_strval(&element, element_param); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, &element); - zephir_check_call_status(); - RETURN_MM(); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Support_Collection, __set) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *element_param = NULL, *value, value_sub; - zval element; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(element) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &element_param, &value); - zephir_get_strval(&element, element_param); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, 0, &element, value); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_EndsWith) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, EndsWith, phalcon, support_helper_str_endswith, phalcon_support_helper_str_abstractstr_ce, phalcon_support_helper_str_endswith_method_entry, 0); + + return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Collection, __unset) +static PHP_METHOD(Phalcon_Support_Helper_Str_EndsWith, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *element_param = NULL; - zval element; + zend_bool ignoreCase; + zval *haystack_param = NULL, *needle_param = NULL, *ignoreCase_param = NULL, _0; + zval haystack, needle; zval *this_ptr = getThis(); - ZVAL_UNDEF(&element); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(element) + ZVAL_UNDEF(&haystack); + ZVAL_UNDEF(&needle); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(haystack) + Z_PARAM_STR(needle) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(ignoreCase) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &element_param); - zephir_get_strval(&element, element_param); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "remove", NULL, 0, &element); + zephir_fetch_params(1, 2, 1, &haystack_param, &needle_param, &ignoreCase_param); + zephir_get_strval(&haystack, haystack_param); + zephir_get_strval(&needle, needle_param); + if (!ignoreCase_param) { + ignoreCase = 1; + } else { + } + if (ignoreCase) { + ZVAL_BOOL(&_0, 1); + } else { + ZVAL_BOOL(&_0, 0); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "toendswith", NULL, 0, &haystack, &needle, &_0); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Collection, clear) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_FirstBetween) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, FirstBetween, phalcon, support_helper_str_firstbetween, phalcon_support_helper_str_firstbetween_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Str_FirstBetween, __invoke) { - zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *text_param = NULL, *start_param = NULL, *end_param = NULL, __$true, result, _0, _1; + zval text, start, end, _2; + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&start); + ZVAL_UNDEF(&end); + ZVAL_UNDEF(&_2); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_STR(text) + Z_PARAM_STR(start) + Z_PARAM_STR(end) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - + zephir_fetch_params(1, 3, 0, &text_param, &start_param, &end_param); + zephir_get_strval(&text, text_param); + zephir_get_strval(&start, start_param); + zephir_get_strval(&end, end_param); + ZEPHIR_CALL_FUNCTION(&result, "mb_strstr", NULL, 0, &text, &start); + zephir_check_call_status(); ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("data"), &_0); - ZEPHIR_INIT_VAR(&_1); - array_init(&_1); - zephir_update_property_zval(this_ptr, ZEND_STRL("lowerKeys"), &_1); - ZEPHIR_MM_RESTORE(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&result)) { + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, ""); + } else { + ZEPHIR_CPY_WRT(&_0, &result); + } + ZEPHIR_CPY_WRT(&result, &_0); + ZEPHIR_CALL_FUNCTION(&_1, "mb_strstr", NULL, 0, &result, &end, &__$true); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&result, &_1); + ZEPHIR_INIT_NVAR(&_0); + if (ZEPHIR_IS_FALSE_IDENTICAL(&result)) { + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, ""); + } else { + ZEPHIR_CPY_WRT(&_0, &result); + } + ZEPHIR_CPY_WRT(&result, &_0); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_CONCAT_VV(&_2, &start, &end); + zephir_fast_trim(return_value, &result, &_2, ZEPHIR_TRIM_BOTH); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Collection, count) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Friendly) { - zval _0; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, Friendly, phalcon, support_helper_str_friendly, phalcon_support_helper_str_abstractstr_ce, phalcon_support_helper_str_friendly_method_entry, 0); - ZVAL_UNDEF(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - RETURN_LONG(zephir_fast_count_int(&_0)); + return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Collection, get) +static PHP_METHOD(Phalcon_Support_Helper_Str_Friendly, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *element_param = NULL, *defaultValue = NULL, defaultValue_sub, *cast_param = NULL, __$null, key, value, _0, _1, _2, _3; - zval element, cast; + zend_bool lowercase; + zval *text_param = NULL, *separator_param = NULL, *lowercase_param = NULL, *replace = NULL, replace_sub, __$null, friendly, matrix, _1, _2, _3, _4, _5, _7, _0$$3, _6$$5; + zval text, separator; zval *this_ptr = getThis(); - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&cast); - ZVAL_UNDEF(&defaultValue_sub); + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&separator); + ZVAL_UNDEF(&replace_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&friendly); + ZVAL_UNDEF(&matrix); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_6$$5); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(element) + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_STR(text) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) - Z_PARAM_STR_OR_NULL(cast) + Z_PARAM_STR(separator) + Z_PARAM_BOOL(lowercase) + Z_PARAM_ZVAL_OR_NULL(replace) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &element_param, &defaultValue, &cast_param); - zephir_get_strval(&element, element_param); - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; + zephir_fetch_params(1, 1, 3, &text_param, &separator_param, &lowercase_param, &replace); + if (UNEXPECTED(Z_TYPE_P(text_param) != IS_STRING && Z_TYPE_P(text_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'text' must be of the type string")); + RETURN_MM_NULL(); } - if (!cast_param) { - ZEPHIR_INIT_VAR(&cast); + if (EXPECTED(Z_TYPE_P(text_param) == IS_STRING)) { + zephir_get_strval(&text, text_param); } else { - if (UNEXPECTED(Z_TYPE_P(cast_param) != IS_STRING && Z_TYPE_P(cast_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'cast' must be of the type string")); - RETURN_MM_NULL(); + ZEPHIR_INIT_VAR(&text); } - if (EXPECTED(Z_TYPE_P(cast_param) == IS_STRING)) { - zephir_get_strval(&cast, cast_param); + if (!separator_param) { + ZEPHIR_INIT_VAR(&separator); + ZVAL_STRING(&separator, "-"); } else { - ZEPHIR_INIT_VAR(&cast); + if (UNEXPECTED(Z_TYPE_P(separator_param) != IS_STRING && Z_TYPE_P(separator_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'separator' must be of the type string")); + RETURN_MM_NULL(); } + if (EXPECTED(Z_TYPE_P(separator_param) == IS_STRING)) { + zephir_get_strval(&separator, separator_param); + } else { + ZEPHIR_INIT_VAR(&separator); } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "processkey", NULL, 0, &element); - zephir_check_call_status(); - zephir_get_strval(&element, &_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("lowerKeys"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(1 != zephir_array_isset(&_1, &element))) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); } - zephir_read_property(&_2, this_ptr, ZEND_STRL("lowerKeys"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&key); - zephir_array_fetch(&key, &_2, &element, PH_NOISY, "phalcon/Support/Collection.zep", 140); - zephir_read_property(&_3, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - zephir_memory_observe(&value); - zephir_array_fetch(&value, &_3, &key, PH_NOISY, "phalcon/Support/Collection.zep", 141); - if (UNEXPECTED((Z_TYPE_P(&value) == IS_NULL))) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); + if (!lowercase_param) { + lowercase = 1; + } else { + } + if (!replace) { + replace = &replace_sub; + ZEPHIR_CPY_WRT(replace, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(replace); } - if (UNEXPECTED(zephir_is_true(&cast))) { - ZEPHIR_MAKE_REF(&value); - ZEPHIR_CALL_FUNCTION(NULL, "settype", NULL, 11, &value, &cast); - ZEPHIR_UNREF(&value); + if (zephir_is_true(replace)) { + ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "checkreplace", NULL, 0, replace); zephir_check_call_status(); + ZEPHIR_CPY_WRT(replace, &_0$$3); + } else { + ZEPHIR_INIT_NVAR(replace); + array_init(replace); } - RETURN_CCTOR(&value); -} - -static PHP_METHOD(Phalcon_Support_Collection, getIterator) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - object_init_ex(return_value, spl_ce_ArrayIterator); - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 13, &_0); + ZEPHIR_CALL_METHOD(&matrix, this_ptr, "getmatrix", NULL, 0, replace); zephir_check_call_status(); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Support_Collection, getKeys) -{ - zval collection; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *insensitive_param = NULL, _0; - zend_bool insensitive; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&collection); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(insensitive) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &insensitive_param); - if (!insensitive_param) { - insensitive = 1; - } else { - } - ZEPHIR_INIT_VAR(&_0); - if (insensitive == 1) { - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("lowerKeys"), PH_NOISY_CC); - } else { - ZEPHIR_OBS_NVAR(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_INIT_VAR(&_2); + zephir_array_keys(&_2, &matrix); + ZEPHIR_CALL_FUNCTION(&_3, "array_values", NULL, 14, &matrix); + zephir_check_call_status(); + zephir_fast_str_replace(&_1, &_2, &_3, &text); + zephir_get_strval(&text, &_1); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "/[^a-zA-Z0-9\\/_|+ -]/"); + ZEPHIR_INIT_VAR(&_5); + ZVAL_STRING(&_5, ""); + ZEPHIR_CALL_FUNCTION(&friendly, "preg_replace", NULL, 41, &_4, &_5, &text); + zephir_check_call_status(); + if (lowercase) { + ZEPHIR_INIT_VAR(&_6$$5); + zephir_fast_strtolower(&_6$$5, &friendly); + ZEPHIR_CPY_WRT(&friendly, &_6$$5); } - ZEPHIR_CPY_WRT(&collection, &_0); - zephir_array_keys(return_value, &collection); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Support_Collection, getValues) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_FUNCTION("array_values", NULL, 14, &_0); + ZEPHIR_INIT_NVAR(&_4); + ZVAL_STRING(&_4, "/[\\/_|+ -]+/"); + ZEPHIR_CALL_FUNCTION(&_7, "preg_replace", NULL, 41, &_4, &separator, &friendly); zephir_check_call_status(); + ZEPHIR_CPY_WRT(&friendly, &_7); + zephir_fast_trim(return_value, &friendly, &separator, ZEPHIR_TRIM_BOTH); RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Collection, has) +static PHP_METHOD(Phalcon_Support_Helper_Str_Friendly, checkReplace) { + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *element_param = NULL, _0, _1; - zval element; - zval *this_ptr = getThis(); + zval *replace = NULL, replace_sub, _1$$4; - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&replace_sub); + ZVAL_UNDEF(&_1$$4); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(element) + Z_PARAM_ZVAL(replace) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &element_param); - zephir_get_strval(&element, element_param); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "processkey", NULL, 0, &element); - zephir_check_call_status(); - zephir_get_strval(&element, &_0); - zephir_read_property(&_1, this_ptr, ZEND_STRL("lowerKeys"), PH_NOISY_CC | PH_READONLY); - RETURN_MM_BOOL(zephir_array_isset(&_1, &element)); + zephir_fetch_params(1, 1, 0, &replace); + ZEPHIR_SEPARATE_PARAM(replace); + _0 = Z_TYPE_P(replace) != IS_ARRAY; + if (_0) { + _0 = Z_TYPE_P(replace) != IS_STRING; + } + if (_0) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_support_helper_exception_ce, "Parameter replace must be an array or a string", "phalcon/Support/Helper/Str/Friendly.zep", 74); + return; + } + if (Z_TYPE_P(replace) == IS_STRING) { + ZEPHIR_INIT_VAR(&_1$$4); + zephir_create_array(&_1$$4, 1, 0); + zephir_array_fast_append(&_1$$4, replace); + ZEPHIR_CPY_WRT(replace, &_1$$4); + } + RETVAL_ZVAL(replace, 1, 0); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Collection, init) +static PHP_METHOD(Phalcon_Support_Helper_Str_Friendly, getMatrix) { - zend_string *_3; - zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *data_param = NULL, key, value, *_0, _1; - zval data; - zval *this_ptr = getThis(); + zval *replace_param = NULL, item, *_0, _1, _2$$3, _3$$4; + zval replace, matrix; - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); + ZVAL_UNDEF(&replace); + ZVAL_UNDEF(&matrix); + ZVAL_UNDEF(&item); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(data) + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(replace) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &data_param); - if (!data_param) { - ZEPHIR_INIT_VAR(&data); - array_init(&data); - } else { - zephir_get_arrval(&data, data_param); - } - zephir_is_iterable(&data, 0, "phalcon/Support/Collection.zep", 206); - if (Z_TYPE_P(&data) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _2, _3, _0) + zephir_fetch_params(1, 1, 0, &replace_param); + zephir_get_arrval(&replace, replace_param); + ZEPHIR_INIT_VAR(&matrix); + zephir_create_array(&matrix, 79, 0); + add_assoc_stringl_ex(&matrix, SL("Š"), SL("S")); + add_assoc_stringl_ex(&matrix, SL("š"), SL("s")); + add_assoc_stringl_ex(&matrix, SL("Đ"), SL("Dj")); + add_assoc_stringl_ex(&matrix, SL("Ð"), SL("Dj")); + add_assoc_stringl_ex(&matrix, SL("đ"), SL("dj")); + add_assoc_stringl_ex(&matrix, SL("Ž"), SL("Z")); + add_assoc_stringl_ex(&matrix, SL("ž"), SL("z")); + add_assoc_stringl_ex(&matrix, SL("Č"), SL("C")); + add_assoc_stringl_ex(&matrix, SL("č"), SL("c")); + add_assoc_stringl_ex(&matrix, SL("Ć"), SL("C")); + add_assoc_stringl_ex(&matrix, SL("ć"), SL("c")); + add_assoc_stringl_ex(&matrix, SL("À"), SL("A")); + add_assoc_stringl_ex(&matrix, SL("Á"), SL("A")); + add_assoc_stringl_ex(&matrix, SL("Â"), SL("A")); + add_assoc_stringl_ex(&matrix, SL("Ã"), SL("A")); + add_assoc_stringl_ex(&matrix, SL("Ä"), SL("A")); + add_assoc_stringl_ex(&matrix, SL("Å"), SL("A")); + add_assoc_stringl_ex(&matrix, SL("Æ"), SL("A")); + add_assoc_stringl_ex(&matrix, SL("Ç"), SL("C")); + add_assoc_stringl_ex(&matrix, SL("È"), SL("E")); + add_assoc_stringl_ex(&matrix, SL("É"), SL("E")); + add_assoc_stringl_ex(&matrix, SL("Ê"), SL("E")); + add_assoc_stringl_ex(&matrix, SL("Ë"), SL("E")); + add_assoc_stringl_ex(&matrix, SL("Ì"), SL("I")); + add_assoc_stringl_ex(&matrix, SL("Í"), SL("I")); + add_assoc_stringl_ex(&matrix, SL("Î"), SL("I")); + add_assoc_stringl_ex(&matrix, SL("Ï"), SL("I")); + add_assoc_stringl_ex(&matrix, SL("Ñ"), SL("N")); + add_assoc_stringl_ex(&matrix, SL("Ò"), SL("O")); + add_assoc_stringl_ex(&matrix, SL("Ó"), SL("O")); + add_assoc_stringl_ex(&matrix, SL("Ô"), SL("O")); + add_assoc_stringl_ex(&matrix, SL("Õ"), SL("O")); + add_assoc_stringl_ex(&matrix, SL("Ö"), SL("O")); + add_assoc_stringl_ex(&matrix, SL("Ø"), SL("O")); + add_assoc_stringl_ex(&matrix, SL("Ù"), SL("U")); + add_assoc_stringl_ex(&matrix, SL("Ú"), SL("U")); + add_assoc_stringl_ex(&matrix, SL("Û"), SL("U")); + add_assoc_stringl_ex(&matrix, SL("Ü"), SL("U")); + add_assoc_stringl_ex(&matrix, SL("Ý"), SL("Y")); + add_assoc_stringl_ex(&matrix, SL("Þ"), SL("B")); + add_assoc_stringl_ex(&matrix, SL("ß"), SL("Ss")); + add_assoc_stringl_ex(&matrix, SL("à"), SL("a")); + add_assoc_stringl_ex(&matrix, SL("á"), SL("a")); + add_assoc_stringl_ex(&matrix, SL("â"), SL("a")); + add_assoc_stringl_ex(&matrix, SL("ã"), SL("a")); + add_assoc_stringl_ex(&matrix, SL("ä"), SL("a")); + add_assoc_stringl_ex(&matrix, SL("å"), SL("a")); + add_assoc_stringl_ex(&matrix, SL("æ"), SL("a")); + add_assoc_stringl_ex(&matrix, SL("ç"), SL("c")); + add_assoc_stringl_ex(&matrix, SL("è"), SL("e")); + add_assoc_stringl_ex(&matrix, SL("é"), SL("e")); + add_assoc_stringl_ex(&matrix, SL("ê"), SL("e")); + add_assoc_stringl_ex(&matrix, SL("ë"), SL("e")); + add_assoc_stringl_ex(&matrix, SL("ì"), SL("i")); + add_assoc_stringl_ex(&matrix, SL("í"), SL("i")); + add_assoc_stringl_ex(&matrix, SL("î"), SL("i")); + add_assoc_stringl_ex(&matrix, SL("ï"), SL("i")); + add_assoc_stringl_ex(&matrix, SL("ð"), SL("o")); + add_assoc_stringl_ex(&matrix, SL("ñ"), SL("n")); + add_assoc_stringl_ex(&matrix, SL("ò"), SL("o")); + add_assoc_stringl_ex(&matrix, SL("ó"), SL("o")); + add_assoc_stringl_ex(&matrix, SL("ô"), SL("o")); + add_assoc_stringl_ex(&matrix, SL("õ"), SL("o")); + add_assoc_stringl_ex(&matrix, SL("ö"), SL("o")); + add_assoc_stringl_ex(&matrix, SL("ø"), SL("o")); + add_assoc_stringl_ex(&matrix, SL("ù"), SL("u")); + add_assoc_stringl_ex(&matrix, SL("ú"), SL("u")); + add_assoc_stringl_ex(&matrix, SL("û"), SL("u")); + add_assoc_stringl_ex(&matrix, SL("ý"), SL("y")); + add_assoc_stringl_ex(&matrix, SL("þ"), SL("b")); + add_assoc_stringl_ex(&matrix, SL("ÿ"), SL("y")); + add_assoc_stringl_ex(&matrix, SL("Ŕ"), SL("R")); + add_assoc_stringl_ex(&matrix, SL("ŕ"), SL("r")); + add_assoc_stringl_ex(&matrix, SL("ē"), SL("e")); + add_assoc_stringl_ex(&matrix, SL("'"), SL("")); + add_assoc_stringl_ex(&matrix, SL("&"), SL(" and ")); + add_assoc_stringl_ex(&matrix, SL("\r\n"), SL(" ")); + add_assoc_stringl_ex(&matrix, SL("\n"), SL(" ")); + zephir_is_iterable(&replace, 0, "phalcon/Support/Helper/Str/Friendly.zep", 122); + if (Z_TYPE_P(&replace) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&replace), _0) { - ZEPHIR_INIT_NVAR(&key); - if (_3 != NULL) { - ZVAL_STR_COPY(&key, _3); - } else { - ZVAL_LONG(&key, _2); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdata", &_4, 0, &key, &value); - zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&item); + ZVAL_COPY(&item, _0); + ZEPHIR_INIT_NVAR(&_2$$3); + ZVAL_STRING(&_2$$3, " "); + zephir_array_update_zval(&matrix, &item, &_2$$3, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &replace, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_1, &data, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_1, &replace, "valid", NULL, 0); zephir_check_call_status(); if (!zend_is_true(&_1)) { break; } - ZEPHIR_CALL_METHOD(&key, &data, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&item, &replace, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdata", &_4, 0, &key, &value); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); + ZEPHIR_INIT_NVAR(&_3$$4); + ZVAL_STRING(&_3$$4, " "); + zephir_array_update_zval(&matrix, &item, &_3$$4, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &replace, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - ZEPHIR_MM_RESTORE(); + ZEPHIR_INIT_NVAR(&item); + RETURN_CTOR(&matrix); } -static PHP_METHOD(Phalcon_Support_Collection, jsonSerialize) -{ - zend_bool _5$$3, _7$$6; - zend_string *_4; - zend_ulong _3; - zval records; - zval key, value, _0, *_1, _2, _6$$4, _8$$7; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_8$$7); - ZVAL_UNDEF(&records); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_INIT_VAR(&records); - array_init(&records); - zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_0, 0, "phalcon/Support/Collection.zep", 227); - if (Z_TYPE_P(&_0) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_0), _3, _4, _1) - { - ZEPHIR_INIT_NVAR(&key); - if (_4 != NULL) { - ZVAL_STR_COPY(&key, _4); - } else { - ZVAL_LONG(&key, _3); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _1); - _5$$3 = Z_TYPE_P(&value) == IS_OBJECT; - if (_5$$3) { - _5$$3 = (zephir_method_exists_ex(&value, ZEND_STRL("jsonserialize")) == SUCCESS); - } - if (_5$$3) { - ZEPHIR_CALL_METHOD(&_6$$4, &value, "jsonserialize", NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&records, &key, &_6$$4, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&records, &key, &value, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &_0, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &_0, "current", NULL, 0); - zephir_check_call_status(); - _7$$6 = Z_TYPE_P(&value) == IS_OBJECT; - if (_7$$6) { - _7$$6 = (zephir_method_exists_ex(&value, ZEND_STRL("jsonserialize")) == SUCCESS); - } - if (_7$$6) { - ZEPHIR_CALL_METHOD(&_8$$7, &value, "jsonserialize", NULL, 0); - zephir_check_call_status(); - zephir_array_update_zval(&records, &key, &_8$$7, PH_COPY | PH_SEPARATE); - } else { - zephir_array_update_zval(&records, &key, &value, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - RETURN_CTOR(&records); -} -static PHP_METHOD(Phalcon_Support_Collection, offsetExists) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval element_sub; - zval *element = NULL; - zval *this_ptr = getThis(); +#ifdef HAVE_CONFIG_H +#endif - ZVAL_UNDEF(&element_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(element) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &element); - zephir_cast_to_string(&_0, element); - ZEPHIR_CPY_WRT(element, &_0); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "has", NULL, 0, element); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Support_Collection, offsetGet) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval element_sub; - zval *element = NULL; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&element_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(element) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &element); - zephir_cast_to_string(&_0, element); - ZEPHIR_CPY_WRT(element, &_0); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0, element); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Support_Collection, offsetSet) + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Humanize) { - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval offset_sub, value_sub; - zval *offset = NULL, *value; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, Humanize, phalcon, support_helper_str_humanize, phalcon_support_helper_str_humanize_method_entry, 0); - ZVAL_UNDEF(&offset_sub); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(offset) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &offset, &value); - zephir_cast_to_string(&_0, offset); - ZEPHIR_CPY_WRT(offset, &_0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "set", NULL, 0, offset, value); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Collection, offsetUnset) +static PHP_METHOD(Phalcon_Support_Helper_Str_Humanize, __invoke) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval element_sub; - zval *element = NULL; - zval *this_ptr = getThis(); + zval *text_param = NULL, result, _0, _1, _2; + zval text; - ZVAL_UNDEF(&element_sub); + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(element) + Z_PARAM_STR(text) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &element); - zephir_cast_to_string(&_0, element); - ZEPHIR_CPY_WRT(element, &_0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "remove", NULL, 0, element); + zephir_fetch_params(1, 1, 0, &text_param); + zephir_get_strval(&text, text_param); + ZEPHIR_INIT_VAR(&_0); + zephir_fast_trim(&_0, &text, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "#[_-]+#"); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, " "); + ZEPHIR_CALL_FUNCTION(&result, "preg_replace", NULL, 41, &_1, &_2, &_0); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + ZEPHIR_INIT_NVAR(&_1); + if (Z_TYPE_P(&result) == IS_NULL) { + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, ""); + } else { + ZEPHIR_CPY_WRT(&_1, &result); + } + RETURN_CCTOR(&_1); } -static PHP_METHOD(Phalcon_Support_Collection, remove) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Includes) { - zval lowerKeys, data; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *element_param = NULL, key, _0, _1$$3, _2$$3, _3$$3; - zval element; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, Includes, phalcon, support_helper_str_includes, phalcon_support_helper_str_includes_method_entry, 0); - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&lowerKeys); - ZVAL_UNDEF(&data); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(element) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &element_param); - zephir_get_strval(&element, element_param); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, 0, &element); - zephir_check_call_status(); - if (UNEXPECTED(zephir_is_true(&_0))) { - ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "processkey", NULL, 0, &element); - zephir_check_call_status(); - zephir_get_strval(&element, &_1$$3); - zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&data, &_2$$3); - zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("lowerKeys"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&lowerKeys, &_3$$3); - zephir_array_fetch(&key, &lowerKeys, &element, PH_NOISY | PH_READONLY, "phalcon/Support/Collection.zep", 286); - zephir_array_unset(&lowerKeys, &element, PH_SEPARATE); - zephir_array_unset(&data, &key, PH_SEPARATE); - zephir_update_property_zval(this_ptr, ZEND_STRL("data"), &data); - zephir_update_property_zval(this_ptr, ZEND_STRL("lowerKeys"), &lowerKeys); - } - ZEPHIR_MM_RESTORE(); + return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Collection, set) +static PHP_METHOD(Phalcon_Support_Helper_Str_Includes, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *element_param = NULL, *value, value_sub; - zval element; - zval *this_ptr = getThis(); + zval *haystack_param = NULL, *needle_param = NULL, _0; + zval haystack, needle; - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&haystack); + ZVAL_UNDEF(&needle); + ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(element) - Z_PARAM_ZVAL(value) + Z_PARAM_STR(haystack) + Z_PARAM_STR(needle) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &element_param, &value); - zephir_get_strval(&element, element_param); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setdata", NULL, 0, &element, value); + zephir_fetch_params(1, 2, 0, &haystack_param, &needle_param); + zephir_get_strval(&haystack, haystack_param); + zephir_get_strval(&needle, needle_param); + ZEPHIR_CALL_FUNCTION(&_0, "mb_strpos", NULL, 86, &haystack, &needle); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM_BOOL(!ZEPHIR_IS_FALSE_IDENTICAL(&_0)); } -static PHP_METHOD(Phalcon_Support_Collection, serialize) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "toarray", NULL, 0); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_FUNCTION("serialize", NULL, 15, &_0); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Support_Collection, toArray) +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Increment) { + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, Increment, phalcon, support_helper_str_increment, phalcon_support_helper_str_increment_method_entry, 0); - RETURN_MEMBER(getThis(), "data"); + return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Collection, toJson) +static PHP_METHOD(Phalcon_Support_Helper_Str_Increment, __invoke) { + zend_long number = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *options_param = NULL, result, _0, _1; - zend_long options, ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + zval *text_param = NULL, *separator_param = NULL, parts, _1, _2, _0$$3; + zval text, separator; - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&separator); + ZVAL_UNDEF(&parts); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(0, 1) + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_0$$3); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(text) Z_PARAM_OPTIONAL - Z_PARAM_LONG(options) + Z_PARAM_STR(separator) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &options_param); - if (!options_param) { - options = 4194383; + zephir_fetch_params(1, 1, 1, &text_param, &separator_param); + zephir_get_strval(&text, text_param); + if (!separator_param) { + ZEPHIR_INIT_VAR(&separator); + ZVAL_STRING(&separator, "_"); } else { - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "jsonserialize", NULL, 0); - zephir_check_call_status(); - ZVAL_LONG(&_1, options); - ZEPHIR_CALL_METHOD(&result, this_ptr, "phpjsonencode", NULL, 0, &_0, &_1); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&result)) { - ZEPHIR_INIT_NVAR(&result); - ZVAL_STRING(&result, ""); + zephir_get_strval(&separator, separator_param); } - RETURN_CCTOR(&result); + ZEPHIR_INIT_VAR(&parts); + zephir_fast_explode(&parts, &separator, &text, LONG_MAX); + number = 1; + if (1 == zephir_array_isset_long(&parts, 1)) { + zephir_memory_observe(&_0$$3); + zephir_array_fetch_long(&_0$$3, &parts, 1, PH_NOISY, "phalcon/Support/Helper/Str/Increment.zep", 35); + number = (zephir_get_intval(&_0$$3) + 1); + } + zephir_array_fetch_long(&_1, &parts, 0, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Increment.zep", 38); + ZEPHIR_INIT_VAR(&_2); + ZVAL_LONG(&_2, number); + ZEPHIR_CONCAT_VVV(return_value, &_1, &separator, &_2); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Collection, unserialize) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *data_param = NULL, unserialized; - zval data; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&unserialized); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(data) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &data_param); - zephir_get_strval(&data, data_param); - ZEPHIR_CALL_FUNCTION(&unserialized, "unserialize", NULL, 16, &data); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &unserialized); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} -static PHP_METHOD(Phalcon_Support_Collection, __serialize) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "toarray", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Support_Collection, __unserialize) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *data_param = NULL; - zval data; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&data); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(data) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &data_param); - zephir_get_arrval(&data, data_param); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &data); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} -static PHP_METHOD(Phalcon_Support_Collection, setData) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *element_param = NULL, *value, value_sub, key; - zval element; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&key); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(element) - Z_PARAM_ZVAL(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &element_param, &value); - zephir_get_strval(&element, element_param); - ZEPHIR_CALL_METHOD(&key, this_ptr, "processkey", NULL, 0, &element); - zephir_check_call_status(); - zephir_update_property_array(this_ptr, SL("data"), &element, value); - zephir_update_property_array(this_ptr, SL("lowerKeys"), &key, &element); - ZEPHIR_MM_RESTORE(); -} -static PHP_METHOD(Phalcon_Support_Collection, phpJsonEncode) +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Interpolate) { - zend_long flags, depth; - zval *value, value_sub, *flags_param = NULL, *depth_param = NULL, _0, _1; + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, Interpolate, phalcon, support_helper_str_interpolate, phalcon_support_helper_str_interpolate_method_entry, 0); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ZVAL(value) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(flags) - Z_PARAM_LONG(depth) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 2, &value, &flags_param, &depth_param); - if (!flags_param) { - flags = 0; - } else { - } - if (!depth_param) { - depth = 512; - } else { - } - ZVAL_LONG(&_0, flags); - ZVAL_LONG(&_1, depth); - zephir_json_encode(return_value, value, zephir_get_intval(&_0) ); - return; + return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Collection, processKey) +static PHP_METHOD(Phalcon_Support_Helper_Str_Interpolate, __invoke) { + zend_string *_3$$3; + zend_ulong _2$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *element_param = NULL, _0; - zval element; - zval *this_ptr = getThis(); + zval context, replace; + zval *message_param = NULL, *context_param = NULL, *leftToken_param = NULL, *rightToken_param = NULL, key, value, *_0$$3, _1$$3, _4$$4, _5$$5; + zval message, leftToken, rightToken; - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(element) + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&leftToken); + ZVAL_UNDEF(&rightToken); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&context); + ZVAL_UNDEF(&replace); + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_STR(message) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(context) + Z_PARAM_STR(leftToken) + Z_PARAM_STR(rightToken) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &element_param); - zephir_get_strval(&element, element_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("insensitive"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(zephir_is_true(&_0))) { - ZEPHIR_RETURN_CALL_FUNCTION("mb_strtolower", NULL, 10, &element); + zephir_fetch_params(1, 1, 3, &message_param, &context_param, &leftToken_param, &rightToken_param); + zephir_get_strval(&message, message_param); + if (!context_param) { + ZEPHIR_INIT_VAR(&context); + array_init(&context); + } else { + zephir_get_arrval(&context, context_param); + } + if (!leftToken_param) { + ZEPHIR_INIT_VAR(&leftToken); + ZVAL_STRING(&leftToken, "%"); + } else { + zephir_get_strval(&leftToken, leftToken_param); + } + if (!rightToken_param) { + ZEPHIR_INIT_VAR(&rightToken); + ZVAL_STRING(&rightToken, "%"); + } else { + zephir_get_strval(&rightToken, rightToken_param); + } + if (!(ZEPHIR_IS_EMPTY(&context))) { + ZEPHIR_INIT_VAR(&replace); + array_init(&replace); + zephir_is_iterable(&context, 0, "phalcon/Support/Helper/Str/Interpolate.zep", 41); + if (Z_TYPE_P(&context) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&context), _2$$3, _3$$3, _0$$3) + { + ZEPHIR_INIT_NVAR(&key); + if (_3$$3 != NULL) { + ZVAL_STR_COPY(&key, _3$$3); + } else { + ZVAL_LONG(&key, _2$$3); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0$$3); + ZEPHIR_INIT_NVAR(&_4$$4); + ZEPHIR_CONCAT_VVV(&_4$$4, &leftToken, &key, &rightToken); + zephir_array_update_zval(&replace, &_4$$4, &value, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &context, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1$$3, &context, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &context, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &context, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_5$$5); + ZEPHIR_CONCAT_VVV(&_5$$5, &leftToken, &key, &rightToken); + zephir_array_update_zval(&replace, &_5$$5, &value, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &context, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + ZEPHIR_RETURN_CALL_FUNCTION("strtr", NULL, 5, &message, &replace); zephir_check_call_status(); RETURN_MM(); } - RETURN_CTOR(&element); -} - -zend_object *zephir_init_properties_Phalcon_Support_Collection(zend_class_entry *class_type) -{ - zval _0, _2, _1$$3, _3$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$4); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("lowerKeys"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("lowerKeys"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("data"), &_3$$4); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); - } + RETURN_CTOR(&message); } @@ -144224,1596 +143354,771 @@ zend_object *zephir_init_properties_Phalcon_Support_Collection(zend_class_entry -ZEPHIR_INIT_CLASS(Phalcon_Support_Debug) +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_IsAnagram) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support, Debug, phalcon, support_debug, phalcon_support_debug_method_entry, 0); - - zend_declare_property_null(phalcon_support_debug_ce, SL("blacklist"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_support_debug_ce, SL("data"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_support_debug_ce, SL("hideDocumentRoot"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_support_debug_ce, SL("isActive"), 0, ZEND_ACC_PROTECTED|ZEND_ACC_STATIC); - zend_declare_property_bool(phalcon_support_debug_ce, SL("showBackTrace"), 1, ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_support_debug_ce, SL("showFileFragment"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_support_debug_ce, SL("showFiles"), 1, ZEND_ACC_PROTECTED); - zend_declare_property_string(phalcon_support_debug_ce, SL("uri"), "https://assets.phalcon.io/debug/5.0.x/", ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_support_debug_ce, SL("version"), ZEND_ACC_PRIVATE); - phalcon_support_debug_ce->create_object = zephir_init_properties_Phalcon_Support_Debug; + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, IsAnagram, phalcon, support_helper_str_isanagram, phalcon_support_helper_str_isanagram_method_entry, 0); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Debug, __construct) +static PHP_METHOD(Phalcon_Support_Helper_Str_IsAnagram, __invoke) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - object_init_ex(&_0, phalcon_support_version_ce); - if (zephir_has_constructor(&_0)) { - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); - zephir_check_call_status(); - } - - zephir_update_property_zval(this_ptr, ZEND_STRL("version"), &_0); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Support_Debug, clearVars) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); + zval *first_param = NULL, *second_param = NULL, _0, _1, _2; + zval first, second; + ZVAL_UNDEF(&first); + ZVAL_UNDEF(&second); ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("data"), &_0); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Support_Debug, debugVar) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *varz, varz_sub, _1, _2; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&varz_sub); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(varz) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(first) + Z_PARAM_STR(second) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &varz); - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 3, 0); - zephir_array_fast_append(&_0, varz); - ZEPHIR_CALL_FUNCTION(&_1, "debug_backtrace", NULL, 0); + zephir_fetch_params(1, 2, 0, &first_param, &second_param); + zephir_get_strval(&first, first_param); + zephir_get_strval(&second, second_param); + ZVAL_LONG(&_0, 1); + ZEPHIR_CALL_FUNCTION(&_1, "count_chars", NULL, 0, &first, &_0); zephir_check_call_status(); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_INIT_VAR(&_2); - zephir_time(&_2); - zephir_array_fast_append(&_0, &_2); - zephir_update_property_array_append(this_ptr, SL("data"), &_0); - RETURN_THIS(); + ZVAL_LONG(&_0, 1); + ZEPHIR_CALL_FUNCTION(&_2, "count_chars", NULL, 0, &second, &_0); + zephir_check_call_status(); + RETURN_MM_BOOL(ZEPHIR_IS_IDENTICAL(&_1, &_2)); } -static PHP_METHOD(Phalcon_Support_Debug, getCssSources) -{ - zval uri, sources, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&uri); - ZVAL_UNDEF(&sources); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("uri"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&uri, &_0); - ZEPHIR_INIT_VAR(&sources); - ZEPHIR_CONCAT_SVSSVSSVS(&sources, "", "", ""); - RETURN_CCTOR(&sources); -} -static PHP_METHOD(Phalcon_Support_Debug, getJsSources) -{ - zval uri, sources, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&uri); - ZVAL_UNDEF(&sources); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); +#ifdef HAVE_CONFIG_H +#endif - zephir_read_property(&_0, this_ptr, ZEND_STRL("uri"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&uri, &_0); - ZEPHIR_INIT_VAR(&sources); - ZEPHIR_CONCAT_SVSSVSSVSSVSSVS(&sources, "", "", "", "", ""); - RETURN_CCTOR(&sources); -} -static PHP_METHOD(Phalcon_Support_Debug, getVersion) -{ - zval link, _0, _1, _2, _3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&link); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("version"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_2, 0); - ZEPHIR_CALL_METHOD(&_1, &_0, "getpart", NULL, 0, &_2); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&link); - ZEPHIR_CONCAT_SVS(&link, "https://docs.phalcon.io/", &_1, ".0/en/"); - zephir_read_property(&_2, this_ptr, ZEND_STRL("version"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(&_3, &_2, "get", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CONCAT_SSVSVS(return_value, "
Phalcon Framework ", "", &_3, "
"); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Support_Debug, halt) +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_IsLower) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, IsLower, phalcon, support_helper_str_islower, phalcon_support_helper_str_abstractstr_ce, phalcon_support_helper_str_islower_method_entry, 0); - ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_support_debug_exception_ce, "Halted request", "phalcon/Support/Debug.zep", 169); - return; + return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Debug, listen) +static PHP_METHOD(Phalcon_Support_Helper_Str_IsLower, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *exceptions_param = NULL, *lowSeverity_param = NULL; - zend_bool exceptions, lowSeverity; + zval *text_param = NULL, *encoding_param = NULL, _0; + zval text, encoding; zval *this_ptr = getThis(); - ZEND_PARSE_PARAMETERS_START(0, 2) + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&encoding); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(text) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(exceptions) - Z_PARAM_BOOL(lowSeverity) + Z_PARAM_STR(encoding) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &exceptions_param, &lowSeverity_param); - if (!exceptions_param) { - exceptions = 1; - } else { - } - if (!lowSeverity_param) { - lowSeverity = 0; + zephir_fetch_params(1, 1, 1, &text_param, &encoding_param); + zephir_get_strval(&text, text_param); + if (!encoding_param) { + ZEPHIR_INIT_VAR(&encoding); + ZVAL_STRING(&encoding, "UTF-8"); } else { - } - if (exceptions) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "listenexceptions", NULL, 0); - zephir_check_call_status(); - } - if (lowSeverity) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "listenlowseverity", NULL, 0); - zephir_check_call_status(); + zephir_get_strval(&encoding, encoding_param); } - RETURN_THIS(); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "tolower", NULL, 0, &text, &encoding); + zephir_check_call_status(); + RETURN_MM_BOOL(ZEPHIR_IS_IDENTICAL(&text, &_0)); } -static PHP_METHOD(Phalcon_Support_Debug, listenExceptions) -{ - zval _1; - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 2, 0); - zephir_array_fast_append(&_0, this_ptr); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "onUncaughtException"); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_CALL_FUNCTION(NULL, "set_exception_handler", NULL, 0, &_0); - zephir_check_call_status(); - RETURN_THIS(); -} -static PHP_METHOD(Phalcon_Support_Debug, listenLowSeverity) -{ - zval _1; - zval _0, _2; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); +#ifdef HAVE_CONFIG_H +#endif - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 2, 0); - zephir_array_fast_append(&_0, this_ptr); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "onUncaughtLowSeverity"); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_CALL_FUNCTION(NULL, "set_error_handler", NULL, 135, &_0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2); - zephir_create_array(&_2, 2, 0); - zephir_array_fast_append(&_2, this_ptr); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "onUncaughtException"); - zephir_array_fast_append(&_2, &_1); - ZEPHIR_CALL_FUNCTION(NULL, "set_exception_handler", NULL, 0, &_2); - zephir_check_call_status(); - RETURN_THIS(); + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_IsPalindrome) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, IsPalindrome, phalcon, support_helper_str_ispalindrome, phalcon_support_helper_str_ispalindrome_method_entry, 0); + + return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Debug, onUncaughtException) +static PHP_METHOD(Phalcon_Support_Helper_Str_IsPalindrome, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *exception, exception_sub, __$true, __$false, obLevel, _0, _2, _1$$4; - zval *this_ptr = getThis(); + zval *text_param = NULL, _0; + zval text; - ZVAL_UNDEF(&exception_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&obLevel); + ZVAL_UNDEF(&text); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_1$$4); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(exception, zend_ce_throwable) + Z_PARAM_STR(text) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &exception); - ZEPHIR_CALL_FUNCTION(&obLevel, "ob_get_level", NULL, 0); - zephir_check_call_status(); - if (ZEPHIR_GT_LONG(&obLevel, 0)) { - ZEPHIR_CALL_FUNCTION(NULL, "ob_end_clean", NULL, 489); - zephir_check_call_status(); - } - zephir_read_static_property_ce(&_0, phalcon_support_debug_ce, SL("isActive"), PH_NOISY_CC | PH_READONLY); - if (zephir_is_true(&_0)) { - ZEPHIR_CALL_METHOD(&_1$$4, exception, "getmessage", NULL, 0); - zephir_check_call_status(); - zend_print_zval(&_1$$4, 0); - RETURN_MM_NULL(); - } - zephir_update_static_property_ce(phalcon_support_debug_ce, ZEND_STRL("isActive"), &__$true); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "renderhtml", NULL, 0, exception); + zephir_fetch_params(1, 1, 0, &text_param); + zephir_get_strval(&text, text_param); + ZEPHIR_CALL_FUNCTION(&_0, "strrev", NULL, 0, &text); zephir_check_call_status(); - zend_print_zval(&_2, 0); - zephir_update_static_property_ce(phalcon_support_debug_ce, ZEND_STRL("isActive"), &__$false); - RETURN_MM_BOOL(1); + RETURN_MM_BOOL(ZEPHIR_IS_IDENTICAL(&_0, &text)); } -static PHP_METHOD(Phalcon_Support_Debug, onUncaughtLowSeverity) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_IsUpper) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *severity, severity_sub, *message, message_sub, *file, file_sub, *line, line_sub, *context, context_sub, _0, _1, _2$$3, _3$$3; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, IsUpper, phalcon, support_helper_str_isupper, phalcon_support_helper_str_abstractstr_ce, phalcon_support_helper_str_isupper_method_entry, 0); - ZVAL_UNDEF(&severity_sub); - ZVAL_UNDEF(&message_sub); - ZVAL_UNDEF(&file_sub); - ZVAL_UNDEF(&line_sub); - ZVAL_UNDEF(&context_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZEND_PARSE_PARAMETERS_START(5, 5) - Z_PARAM_ZVAL(severity) - Z_PARAM_ZVAL(message) - Z_PARAM_ZVAL(file) - Z_PARAM_ZVAL(line) - Z_PARAM_ZVAL(context) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 5, 0, &severity, &message, &file, &line, &context); - ZEPHIR_CALL_FUNCTION(&_0, "error_reporting", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_1); - zephir_bitwise_and_function(&_1, &_0, severity); - if (UNEXPECTED(zephir_is_true(&_1))) { - ZEPHIR_INIT_VAR(&_2$$3); - object_init_ex(&_2$$3, zend_ce_error_exception); - ZVAL_LONG(&_3$$3, 0); - ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 0, message, &_3$$3, severity, file, line); - zephir_check_call_status(); - zephir_throw_exception_debug(&_2$$3, "phalcon/Support/Debug.zep", 268); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_MM_RESTORE(); + return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Debug, renderHtml) +static PHP_METHOD(Phalcon_Support_Helper_Str_IsUpper, __invoke) { - zend_string *_12$$3, *_23$$3, *_39$$3, *_52$$3, *_61$$21; - zend_ulong _11$$3, _22$$3, _38$$3, _51$$3, _60$$21; - zval _7$$3, _16$$3, _33$$3, _47$$3, _57$$21; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_14 = NULL, *_27 = NULL, *_42 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *exception, exception_sub, _REQUEST, __$true, _SERVER, blacklist, className, dataVar, dataVars, escapedMessage, html, keyFile, keyRequest, keyServer, keyVar, n, showBackTrace, traceItem, value, _0, _1, _2, _3, _4, _5, _6, _68, _69, _8$$3, *_9$$3, _10$$3, _17$$3, _18$$3, _19$$3, *_20$$3, _21$$3, _34$$3, _35$$3, *_36$$3, _37$$3, _48$$3, *_49$$3, _50$$3, _55$$3, _56$$3, _13$$5, _15$$6, _24$$7, _25$$9, _26$$10, _28$$10, _29$$11, _30$$13, _31$$14, _32$$14, _40$$15, _41$$16, _43$$16, _44$$17, _45$$18, _46$$18, _53$$19, _54$$20, *_58$$21, _59$$21, _62$$22, _63$$22, _64$$22, _65$$23, _66$$23, _67$$23; + zval *text_param = NULL, *encoding_param = NULL, _0; + zval text, encoding; zval *this_ptr = getThis(); - ZVAL_UNDEF(&exception_sub); - ZVAL_UNDEF(&_REQUEST); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&_SERVER); - ZVAL_UNDEF(&blacklist); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&dataVar); - ZVAL_UNDEF(&dataVars); - ZVAL_UNDEF(&escapedMessage); - ZVAL_UNDEF(&html); - ZVAL_UNDEF(&keyFile); - ZVAL_UNDEF(&keyRequest); - ZVAL_UNDEF(&keyServer); - ZVAL_UNDEF(&keyVar); - ZVAL_UNDEF(&n); - ZVAL_UNDEF(&showBackTrace); - ZVAL_UNDEF(&traceItem); - ZVAL_UNDEF(&value); + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&encoding); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_68); - ZVAL_UNDEF(&_69); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_10$$3); - ZVAL_UNDEF(&_17$$3); - ZVAL_UNDEF(&_18$$3); - ZVAL_UNDEF(&_19$$3); - ZVAL_UNDEF(&_21$$3); - ZVAL_UNDEF(&_34$$3); - ZVAL_UNDEF(&_35$$3); - ZVAL_UNDEF(&_37$$3); - ZVAL_UNDEF(&_48$$3); - ZVAL_UNDEF(&_50$$3); - ZVAL_UNDEF(&_55$$3); - ZVAL_UNDEF(&_56$$3); - ZVAL_UNDEF(&_13$$5); - ZVAL_UNDEF(&_15$$6); - ZVAL_UNDEF(&_24$$7); - ZVAL_UNDEF(&_25$$9); - ZVAL_UNDEF(&_26$$10); - ZVAL_UNDEF(&_28$$10); - ZVAL_UNDEF(&_29$$11); - ZVAL_UNDEF(&_30$$13); - ZVAL_UNDEF(&_31$$14); - ZVAL_UNDEF(&_32$$14); - ZVAL_UNDEF(&_40$$15); - ZVAL_UNDEF(&_41$$16); - ZVAL_UNDEF(&_43$$16); - ZVAL_UNDEF(&_44$$17); - ZVAL_UNDEF(&_45$$18); - ZVAL_UNDEF(&_46$$18); - ZVAL_UNDEF(&_53$$19); - ZVAL_UNDEF(&_54$$20); - ZVAL_UNDEF(&_59$$21); - ZVAL_UNDEF(&_62$$22); - ZVAL_UNDEF(&_63$$22); - ZVAL_UNDEF(&_64$$22); - ZVAL_UNDEF(&_65$$23); - ZVAL_UNDEF(&_66$$23); - ZVAL_UNDEF(&_67$$23); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_16$$3); - ZVAL_UNDEF(&_33$$3); - ZVAL_UNDEF(&_47$$3); - ZVAL_UNDEF(&_57$$21); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(exception, zend_ce_throwable) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(text) + Z_PARAM_OPTIONAL + Z_PARAM_STR(encoding) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_get_global(&_SERVER, SL("_SERVER")); - zephir_get_global(&_REQUEST, SL("_REQUEST")); - zephir_fetch_params(1, 1, 0, &exception); - ZEPHIR_INIT_VAR(&className); - zephir_get_class(&className, exception, 0); - ZEPHIR_CALL_METHOD(&_0, exception, "getmessage", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&escapedMessage, this_ptr, "escapestring", NULL, 0, &_0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getcsssources", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&html); - ZEPHIR_CONCAT_SSVSVSVS(&html, "", "", &className, ": ", &escapedMessage, "", &_1, ""); - ZEPHIR_CALL_METHOD(&_2, this_ptr, "getversion", NULL, 0); - zephir_check_call_status(); - zephir_concat_self(&html, &_2); - ZEPHIR_CALL_METHOD(&_3, exception, "getfile", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4, exception, "getline", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_5); - ZEPHIR_CONCAT_SSSVSVSSVSVSS(&_5, "
", "
", "

", &className, ": ", &escapedMessage, "

", "", &_3, " (", &_4, ")", "
"); - zephir_concat_self(&html, &_5); - zephir_read_property(&_6, this_ptr, ZEND_STRL("showBackTrace"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&showBackTrace, &_6); - if (zephir_is_true(&showBackTrace)) { - zephir_memory_observe(&dataVars); - zephir_read_property(&dataVars, this_ptr, ZEND_STRL("data"), PH_NOISY_CC); - ZEPHIR_INIT_VAR(&_7$$3); - ZEPHIR_CONCAT_SSSSSS(&_7$$3, "
")); - zephir_concat_self_str(&html, SL("
")); - ZEPHIR_CALL_METHOD(&_8$$3, exception, "gettrace", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&_8$$3, 0, "phalcon/Support/Debug.zep", 355); - if (Z_TYPE_P(&_8$$3) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_8$$3), _11$$3, _12$$3, _9$$3) - { - ZEPHIR_INIT_NVAR(&n); - if (_12$$3 != NULL) { - ZVAL_STR_COPY(&n, _12$$3); - } else { - ZVAL_LONG(&n, _11$$3); - } - ZEPHIR_INIT_NVAR(&traceItem); - ZVAL_COPY(&traceItem, _9$$3); - ZEPHIR_CALL_METHOD(&_13$$5, this_ptr, "showtraceitem", &_14, 0, &n, &traceItem); - zephir_check_call_status(); - zephir_concat_self(&html, &_13$$5); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_8$$3, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_10$$3, &_8$$3, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_10$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&n, &_8$$3, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&traceItem, &_8$$3, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_15$$6, this_ptr, "showtraceitem", &_14, 0, &n, &traceItem); - zephir_check_call_status(); - zephir_concat_self(&html, &_15$$6); - ZEPHIR_CALL_METHOD(NULL, &_8$$3, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&traceItem); - ZEPHIR_INIT_NVAR(&n); - zephir_concat_self_str(&html, SL("
")); - ZEPHIR_INIT_VAR(&_16$$3); - ZEPHIR_CONCAT_SSS(&_16$$3, "
", "", ""); - zephir_concat_self(&html, &_16$$3); - zephir_read_property(&_17$$3, this_ptr, ZEND_STRL("blacklist"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_18$$3); - array_init(&_18$$3); - ZEPHIR_INIT_VAR(&_19$$3); - ZVAL_STRING(&_19$$3, "request"); - ZEPHIR_CALL_METHOD(&blacklist, this_ptr, "getarrval", NULL, 0, &_17$$3, &_19$$3, &_18$$3); - zephir_check_call_status(); - zephir_is_iterable(&_REQUEST, 0, "phalcon/Support/Debug.zep", 379); - if (Z_TYPE_P(&_REQUEST) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_REQUEST), _22$$3, _23$$3, _20$$3) - { - ZEPHIR_INIT_NVAR(&keyRequest); - if (_23$$3 != NULL) { - ZVAL_STR_COPY(&keyRequest, _23$$3); - } else { - ZVAL_LONG(&keyRequest, _22$$3); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _20$$3); - ZEPHIR_INIT_NVAR(&_24$$7); - zephir_fast_strtolower(&_24$$7, &keyRequest); - if (1 != zephir_array_isset(&blacklist, &_24$$7)) { - if (Z_TYPE_P(&value) != IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_25$$9); - ZEPHIR_CONCAT_SVSVS(&_25$$9, ""); - zephir_concat_self(&html, &_25$$9); - } else { - ZEPHIR_CALL_FUNCTION(&_26$$10, "print_r", &_27, 0, &value, &__$true); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_28$$10); - ZEPHIR_CONCAT_SVSVS(&_28$$10, ""); - zephir_concat_self(&html, &_28$$10); - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_REQUEST, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_21$$3, &_REQUEST, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_21$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&keyRequest, &_REQUEST, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &_REQUEST, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_29$$11); - zephir_fast_strtolower(&_29$$11, &keyRequest); - if (1 != zephir_array_isset(&blacklist, &_29$$11)) { - if (Z_TYPE_P(&value) != IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_30$$13); - ZEPHIR_CONCAT_SVSVS(&_30$$13, ""); - zephir_concat_self(&html, &_30$$13); - } else { - ZEPHIR_CALL_FUNCTION(&_31$$14, "print_r", &_27, 0, &value, &__$true); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_32$$14); - ZEPHIR_CONCAT_SVSVS(&_32$$14, ""); - zephir_concat_self(&html, &_32$$14); - } - } - ZEPHIR_CALL_METHOD(NULL, &_REQUEST, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&keyRequest); - zephir_concat_self_str(&html, SL("
KeyValue
", &keyRequest, "", &value, "
", &keyRequest, "", &_26$$10, "
", &keyRequest, "", &value, "
", &keyRequest, "", &_31$$14, "
")); - ZEPHIR_INIT_VAR(&_33$$3); - ZEPHIR_CONCAT_SSS(&_33$$3, "
", "", ""); - zephir_concat_self(&html, &_33$$3); - zephir_read_property(&_34$$3, this_ptr, ZEND_STRL("blacklist"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_NVAR(&_19$$3); - array_init(&_19$$3); - ZEPHIR_INIT_VAR(&_35$$3); - ZVAL_STRING(&_35$$3, "server"); - ZEPHIR_CALL_METHOD(&blacklist, this_ptr, "getarrval", NULL, 0, &_34$$3, &_35$$3, &_19$$3); - zephir_check_call_status(); - zephir_is_iterable(&_SERVER, 0, "phalcon/Support/Debug.zep", 397); - if (Z_TYPE_P(&_SERVER) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_SERVER), _38$$3, _39$$3, _36$$3) - { - ZEPHIR_INIT_NVAR(&keyServer); - if (_39$$3 != NULL) { - ZVAL_STR_COPY(&keyServer, _39$$3); - } else { - ZVAL_LONG(&keyServer, _38$$3); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _36$$3); - ZEPHIR_INIT_NVAR(&_40$$15); - zephir_fast_strtolower(&_40$$15, &keyServer); - if (1 != zephir_array_isset(&blacklist, &_40$$15)) { - ZEPHIR_CALL_METHOD(&_41$$16, this_ptr, "getvardump", &_42, 0, &value); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_43$$16); - ZEPHIR_CONCAT_SVSVS(&_43$$16, ""); - zephir_concat_self(&html, &_43$$16); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_SERVER, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_37$$3, &_SERVER, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_37$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&keyServer, &_SERVER, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &_SERVER, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_44$$17); - zephir_fast_strtolower(&_44$$17, &keyServer); - if (1 != zephir_array_isset(&blacklist, &_44$$17)) { - ZEPHIR_CALL_METHOD(&_45$$18, this_ptr, "getvardump", &_42, 0, &value); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_46$$18); - ZEPHIR_CONCAT_SVSVS(&_46$$18, ""); - zephir_concat_self(&html, &_46$$18); - } - ZEPHIR_CALL_METHOD(NULL, &_SERVER, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&keyServer); - zephir_concat_self_str(&html, SL("
KeyValue
", &keyServer, "", &_41$$16, "
", &keyServer, "", &_45$$18, "
")); - ZEPHIR_INIT_VAR(&_47$$3); - ZEPHIR_CONCAT_SSS(&_47$$3, "
", "", ""); - zephir_concat_self(&html, &_47$$3); - ZEPHIR_CALL_FUNCTION(&_48$$3, "get_included_files", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&_48$$3, 0, "phalcon/Support/Debug.zep", 410); - if (Z_TYPE_P(&_48$$3) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_48$$3), _51$$3, _52$$3, _49$$3) - { - ZEPHIR_INIT_NVAR(&keyFile); - if (_52$$3 != NULL) { - ZVAL_STR_COPY(&keyFile, _52$$3); - } else { - ZVAL_LONG(&keyFile, _51$$3); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _49$$3); - ZEPHIR_INIT_NVAR(&_53$$19); - ZEPHIR_CONCAT_SVSVS(&_53$$19, ""); - zephir_concat_self(&html, &_53$$19); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_48$$3, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_50$$3, &_48$$3, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_50$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&keyFile, &_48$$3, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &_48$$3, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_54$$20); - ZEPHIR_CONCAT_SVSVS(&_54$$20, ""); - zephir_concat_self(&html, &_54$$20); - ZEPHIR_CALL_METHOD(NULL, &_48$$3, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&keyFile); - zephir_concat_self_str(&html, SL("
#Path
", &keyFile, "", &value, "
", &keyFile, "", &value, "
")); - ZEPHIR_CALL_FUNCTION(&_55$$3, "memory_get_usage", NULL, 0, &__$true); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_56$$3); - ZEPHIR_CONCAT_SSSVSS(&_56$$3, "
", "", "", "
Memory
Usage", &_55$$3, "
"); - zephir_concat_self(&html, &_56$$3); - if (!(ZEPHIR_IS_EMPTY(&dataVars))) { - ZEPHIR_INIT_VAR(&_57$$21); - ZEPHIR_CONCAT_SSS(&_57$$21, "
", "", ""); - zephir_concat_self(&html, &_57$$21); - zephir_is_iterable(&dataVars, 0, "phalcon/Support/Debug.zep", 435); - if (Z_TYPE_P(&dataVars) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&dataVars), _60$$21, _61$$21, _58$$21) - { - ZEPHIR_INIT_NVAR(&keyVar); - if (_61$$21 != NULL) { - ZVAL_STR_COPY(&keyVar, _61$$21); - } else { - ZVAL_LONG(&keyVar, _60$$21); - } - ZEPHIR_INIT_NVAR(&dataVar); - ZVAL_COPY(&dataVar, _58$$21); - zephir_array_fetch_long(&_63$$22, &dataVar, 0, PH_NOISY | PH_READONLY, "phalcon/Support/Debug.zep", 432); - ZEPHIR_CALL_METHOD(&_62$$22, this_ptr, "getvardump", &_42, 0, &_63$$22); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_64$$22); - ZEPHIR_CONCAT_SVSVS(&_64$$22, ""); - zephir_concat_self(&html, &_64$$22); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &dataVars, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_59$$21, &dataVars, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_59$$21)) { - break; - } - ZEPHIR_CALL_METHOD(&keyVar, &dataVars, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&dataVar, &dataVars, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_fetch_long(&_66$$23, &dataVar, 0, PH_NOISY | PH_READONLY, "phalcon/Support/Debug.zep", 432); - ZEPHIR_CALL_METHOD(&_65$$23, this_ptr, "getvardump", &_42, 0, &_66$$23); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_67$$23); - ZEPHIR_CONCAT_SVSVS(&_67$$23, ""); - zephir_concat_self(&html, &_67$$23); - ZEPHIR_CALL_METHOD(NULL, &dataVars, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&dataVar); - ZEPHIR_INIT_NVAR(&keyVar); - zephir_concat_self_str(&html, SL("
KeyValue
", &keyVar, "", &_62$$22, "
", &keyVar, "", &_65$$23, "
")); - } - zephir_concat_self_str(&html, SL("
")); + zephir_fetch_params(1, 1, 1, &text_param, &encoding_param); + zephir_get_strval(&text, text_param); + if (!encoding_param) { + ZEPHIR_INIT_VAR(&encoding); + ZVAL_STRING(&encoding, "UTF-8"); + } else { + zephir_get_strval(&encoding, encoding_param); } - ZEPHIR_CALL_METHOD(&_68, this_ptr, "getjssources", NULL, 0); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "toupper", NULL, 0, &text, &encoding); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_69); - ZEPHIR_CONCAT_VS(&_69, &_68, "
"); - zephir_concat_self(&html, &_69); - RETURN_CCTOR(&html); + RETURN_MM_BOOL(ZEPHIR_IS_IDENTICAL(&text, &_0)); } -static PHP_METHOD(Phalcon_Support_Debug, setBlacklist) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_KebabCase) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, KebabCase, phalcon, support_helper_str_kebabcase, phalcon_support_helper_str_pascalcase_ce, phalcon_support_helper_str_kebabcase_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Str_KebabCase, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *blacklist_param = NULL, area, result, subArray, value, _0, _1, *_2, _3, _6, *_7, _8, _4$$3, _5$$4, _9$$5, _10$$6; - zval blacklist; + zval *text_param = NULL, *delimiters_param = NULL, output; + zval text, delimiters; zval *this_ptr = getThis(); - ZVAL_UNDEF(&blacklist); - ZVAL_UNDEF(&area); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&subArray); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_9$$5); - ZVAL_UNDEF(&_10$$6); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(blacklist) + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&delimiters); + ZVAL_UNDEF(&output); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(text) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(delimiters) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &blacklist_param); - zephir_get_arrval(&blacklist, blacklist_param); - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "request"); - ZEPHIR_CALL_METHOD(&area, this_ptr, "getarrval", NULL, 0, &blacklist, &_1, &_0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&subArray); - array_init(&subArray); - ZEPHIR_INIT_VAR(&result); - array_init(&result); - zephir_is_iterable(&area, 0, "phalcon/Support/Debug.zep", 467); - if (Z_TYPE_P(&area) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&area), _2) - { - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _2); - ZEPHIR_INIT_NVAR(&_4$$3); - zephir_fast_strtolower(&_4$$3, &value); - ZEPHIR_CPY_WRT(&value, &_4$$3); - ZEPHIR_INIT_NVAR(&_4$$3); - ZVAL_LONG(&_4$$3, 1); - zephir_array_update_zval(&subArray, &value, &_4$$3, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 1, 1, &text_param, &delimiters_param); + zephir_get_strval(&text, text_param); + if (!delimiters_param) { + ZEPHIR_INIT_VAR(&delimiters); } else { - ZEPHIR_CALL_METHOD(NULL, &area, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &area, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3)) { - break; - } - ZEPHIR_CALL_METHOD(&value, &area, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_5$$4); - zephir_fast_strtolower(&_5$$4, &value); - ZEPHIR_CPY_WRT(&value, &_5$$4); - ZEPHIR_INIT_NVAR(&_5$$4); - ZVAL_LONG(&_5$$4, 1); - zephir_array_update_zval(&subArray, &value, &_5$$4, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &area, "next", NULL, 0); - zephir_check_call_status(); - } + zephir_get_strval(&delimiters, delimiters_param); } - ZEPHIR_INIT_NVAR(&value); - zephir_array_update_string(&result, SL("request"), &subArray, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_1); - array_init(&_1); - ZEPHIR_INIT_VAR(&_6); - ZVAL_STRING(&_6, "server"); - ZEPHIR_CALL_METHOD(&area, this_ptr, "getarrval", NULL, 0, &blacklist, &_6, &_1); + ZEPHIR_CALL_METHOD(&output, this_ptr, "processarray", NULL, 0, &text, &delimiters); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&subArray); - array_init(&subArray); - zephir_is_iterable(&area, 0, "phalcon/Support/Debug.zep", 476); - if (Z_TYPE_P(&area) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&area), _7) - { - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _7); - ZEPHIR_INIT_NVAR(&_9$$5); - zephir_fast_strtolower(&_9$$5, &value); - ZEPHIR_CPY_WRT(&value, &_9$$5); - ZEPHIR_INIT_NVAR(&_9$$5); - ZVAL_LONG(&_9$$5, 1); - zephir_array_update_zval(&subArray, &value, &_9$$5, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &area, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_8, &area, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_8)) { - break; - } - ZEPHIR_CALL_METHOD(&value, &area, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_10$$6); - zephir_fast_strtolower(&_10$$6, &value); - ZEPHIR_CPY_WRT(&value, &_10$$6); - ZEPHIR_INIT_NVAR(&_10$$6); - ZVAL_LONG(&_10$$6, 1); - zephir_array_update_zval(&subArray, &value, &_10$$6, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &area, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - zephir_array_update_string(&result, SL("server"), &subArray, PH_COPY | PH_SEPARATE); - zephir_update_property_zval(this_ptr, ZEND_STRL("blacklist"), &result); - RETURN_THIS(); + zephir_fast_join_str(return_value, SL("-"), &output); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Debug, setShowBackTrace) -{ - zval *showBackTrace_param = NULL, __$true, __$false; - zend_bool showBackTrace; - zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(showBackTrace) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &showBackTrace_param); - if (showBackTrace) { - zephir_update_property_zval(this_ptr, ZEND_STRL("showBackTrace"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("showBackTrace"), &__$false); - } - RETURN_THISW(); -} -static PHP_METHOD(Phalcon_Support_Debug, setShowFileFragment) -{ - zval *showFileFragment_param = NULL, __$true, __$false; - zend_bool showFileFragment; - zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(showFileFragment) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &showFileFragment_param); - if (showFileFragment) { - zephir_update_property_zval(this_ptr, ZEND_STRL("showFileFragment"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("showFileFragment"), &__$false); - } - RETURN_THISW(); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Support_Debug, setShowFiles) -{ - zval *showFiles_param = NULL, __$true, __$false; - zend_bool showFiles; - zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(showFiles) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &showFiles_param); - if (showFiles) { - zephir_update_property_zval(this_ptr, ZEND_STRL("showFiles"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("showFiles"), &__$false); - } - RETURN_THISW(); + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Len) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, Len, phalcon, support_helper_str_len, phalcon_support_helper_str_len_method_entry, 0); + + return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Debug, setUri) +static PHP_METHOD(Phalcon_Support_Helper_Str_Len, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *uri_param = NULL; - zval uri; - zval *this_ptr = getThis(); + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *text_param = NULL, *encoding_param = NULL; + zval text, encoding; - ZVAL_UNDEF(&uri); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(uri) + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&encoding); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(text) + Z_PARAM_OPTIONAL + Z_PARAM_STR(encoding) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &uri_param); - if (UNEXPECTED(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 of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(uri_param) == IS_STRING)) { - zephir_get_strval(&uri, uri_param); + zephir_fetch_params(1, 1, 1, &text_param, &encoding_param); + zephir_get_strval(&text, text_param); + if (!encoding_param) { + ZEPHIR_INIT_VAR(&encoding); + ZVAL_STRING(&encoding, "UTF-8"); } else { - ZEPHIR_INIT_VAR(&uri); + zephir_get_strval(&encoding, encoding_param); } - zephir_update_property_zval(this_ptr, ZEND_STRL("uri"), &uri); - RETURN_THIS(); + ZEPHIR_RETURN_CALL_FUNCTION("mb_strlen", NULL, 234, &text, &encoding); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Debug, escapeString) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Lower) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, Lower, phalcon, support_helper_str_lower, phalcon_support_helper_str_abstractstr_ce, phalcon_support_helper_str_lower_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Str_Lower, __invoke) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *value_param = NULL, _0, _1, _2, _3, _4; - zval value; + zval *text_param = NULL, *encoding_param = NULL; + zval text, encoding; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(value) + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&encoding); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(text) + Z_PARAM_OPTIONAL + Z_PARAM_STR(encoding) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &value_param); - zephir_get_strval(&value, value_param); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "\n"); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "\\n"); - zephir_fast_str_replace(&_0, &_1, &_2, &value); - ZVAL_LONG(&_3, 2); - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, "utf-8"); - ZEPHIR_RETURN_CALL_FUNCTION("htmlentities", NULL, 0, &_0, &_3, &_4); + zephir_fetch_params(1, 1, 1, &text_param, &encoding_param); + zephir_get_strval(&text, text_param); + if (!encoding_param) { + ZEPHIR_INIT_VAR(&encoding); + ZVAL_STRING(&encoding, "UTF-8"); + } else { + zephir_get_strval(&encoding, encoding_param); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "tolower", NULL, 0, &text, &encoding); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Debug, getArrayDump) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_PascalCase) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, PascalCase, phalcon, support_helper_str_pascalcase, phalcon_support_helper_str_pascalcase_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Str_PascalCase, __invoke) { - zend_string *_4; - zend_ulong _3; - zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL, *_8 = NULL; + zephir_fcall_cache_entry *_4 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *argument_param = NULL, *n = NULL, n_sub, numberArguments, dump, varDump, k, v, *_1, _2, _6$$8, _7$$8, _9$$9, _10$$5, _11$$15, _12$$15, _13$$16, _14$$12; - zval argument; + zval *text_param = NULL, *delimiters_param = NULL, exploded, output, element, *_0, _1, _2$$3, _3$$3, _5$$3, _6$$4, _7$$4, _8$$4; + zval text, delimiters; zval *this_ptr = getThis(); - ZVAL_UNDEF(&argument); - ZVAL_UNDEF(&n_sub); - ZVAL_UNDEF(&numberArguments); - ZVAL_UNDEF(&dump); - ZVAL_UNDEF(&varDump); - ZVAL_UNDEF(&k); - ZVAL_UNDEF(&v); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_6$$8); - ZVAL_UNDEF(&_7$$8); - ZVAL_UNDEF(&_9$$9); - ZVAL_UNDEF(&_10$$5); - ZVAL_UNDEF(&_11$$15); - ZVAL_UNDEF(&_12$$15); - ZVAL_UNDEF(&_13$$16); - ZVAL_UNDEF(&_14$$12); + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&delimiters); + ZVAL_UNDEF(&exploded); + ZVAL_UNDEF(&output); + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$4); + bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(argument) + Z_PARAM_STR(text) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL(n) + Z_PARAM_STR_OR_NULL(delimiters) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &argument_param, &n); - ZEPHIR_OBS_COPY_OR_DUP(&argument, argument_param); - if (!n) { - n = &n_sub; - ZEPHIR_INIT_VAR(n); - ZVAL_LONG(n, 0); - } - ZEPHIR_INIT_VAR(&numberArguments); - ZVAL_LONG(&numberArguments, zephir_fast_count_int(&argument)); - _0 = ZEPHIR_GE_LONG(n, 3); - if (!(_0)) { - _0 = ZEPHIR_IS_LONG(&numberArguments, 0); - } - if (_0) { - RETURN_MM_NULL(); - } - if (ZEPHIR_GE_LONG(&numberArguments, 10)) { - RETURN_CCTOR(&numberArguments); + zephir_fetch_params(1, 1, 1, &text_param, &delimiters_param); + zephir_get_strval(&text, text_param); + if (!delimiters_param) { + ZEPHIR_INIT_VAR(&delimiters); + } else { + zephir_get_strval(&delimiters, delimiters_param); } - ZEPHIR_INIT_VAR(&dump); - array_init(&dump); - zephir_is_iterable(&argument, 0, "phalcon/Support/Debug.zep", 587); - if (Z_TYPE_P(&argument) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&argument), _3, _4, _1) + ZEPHIR_CALL_METHOD(&exploded, this_ptr, "processarray", NULL, 0, &text, &delimiters); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&output); + ZVAL_STRING(&output, ""); + zephir_is_iterable(&exploded, 0, "phalcon/Support/Helper/Str/PascalCase.zep", 37); + if (Z_TYPE_P(&exploded) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&exploded), _0) { - ZEPHIR_INIT_NVAR(&k); - if (_4 != NULL) { - ZVAL_STR_COPY(&k, _4); - } else { - ZVAL_LONG(&k, _3); - } - ZEPHIR_INIT_NVAR(&v); - ZVAL_COPY(&v, _1); - if (ZEPHIR_IS_STRING(&v, "")) { - ZEPHIR_INIT_NVAR(&varDump); - ZVAL_STRING(&varDump, "(empty string)"); - } else if (zephir_is_scalar(&v)) { - ZEPHIR_CALL_METHOD(&varDump, this_ptr, "escapestring", &_5, 0, &v); - zephir_check_call_status(); - } else if (Z_TYPE_P(&v) == IS_ARRAY) { - ZVAL_LONG(&_7$$8, (zephir_get_numberval(n) + 1)); - ZEPHIR_CALL_METHOD(&_6$$8, this_ptr, "getarraydump", &_8, 0, &v, &_7$$8); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&varDump); - ZEPHIR_CONCAT_SVS(&varDump, "Array(", &_6$$8, ")"); - } else if (Z_TYPE_P(&v) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_9$$9); - zephir_get_class(&_9$$9, &v, 0); - ZEPHIR_INIT_NVAR(&varDump); - ZEPHIR_CONCAT_SVS(&varDump, "Object(", &_9$$9, ")"); - } else if (Z_TYPE_P(&v) == IS_NULL) { - ZEPHIR_INIT_NVAR(&varDump); - ZVAL_STRING(&varDump, "null"); - } else { - ZEPHIR_CPY_WRT(&varDump, &v); - } - ZEPHIR_INIT_NVAR(&_10$$5); - ZEPHIR_CONCAT_SVSV(&_10$$5, "[", &k, "] => ", &varDump); - zephir_array_append(&dump, &_10$$5, PH_SEPARATE, "phalcon/Support/Debug.zep", 584); + ZEPHIR_INIT_NVAR(&element); + ZVAL_COPY(&element, _0); + ZEPHIR_INIT_NVAR(&_2$$3); + ZEPHIR_CALL_FUNCTION(&_3$$3, "mb_strtolower", &_4, 10, &element); + zephir_check_call_status(); + zephir_ucfirst(&_2$$3, &_3$$3); + ZEPHIR_INIT_NVAR(&_5$$3); + ZEPHIR_CONCAT_VV(&_5$$3, &output, &_2$$3); + ZEPHIR_CPY_WRT(&output, &_5$$3); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &argument, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &exploded, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_2, &argument, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_1, &exploded, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_2)) { + if (!zend_is_true(&_1)) { break; } - ZEPHIR_CALL_METHOD(&k, &argument, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&v, &argument, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&element, &exploded, "current", NULL, 0); zephir_check_call_status(); - if (ZEPHIR_IS_STRING(&v, "")) { - ZEPHIR_INIT_NVAR(&varDump); - ZVAL_STRING(&varDump, "(empty string)"); - } else if (zephir_is_scalar(&v)) { - ZEPHIR_CALL_METHOD(&varDump, this_ptr, "escapestring", &_5, 0, &v); - zephir_check_call_status(); - } else if (Z_TYPE_P(&v) == IS_ARRAY) { - ZVAL_LONG(&_12$$15, (zephir_get_numberval(n) + 1)); - ZEPHIR_CALL_METHOD(&_11$$15, this_ptr, "getarraydump", &_8, 0, &v, &_12$$15); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&varDump); - ZEPHIR_CONCAT_SVS(&varDump, "Array(", &_11$$15, ")"); - } else if (Z_TYPE_P(&v) == IS_OBJECT) { - ZEPHIR_INIT_NVAR(&_13$$16); - zephir_get_class(&_13$$16, &v, 0); - ZEPHIR_INIT_NVAR(&varDump); - ZEPHIR_CONCAT_SVS(&varDump, "Object(", &_13$$16, ")"); - } else if (Z_TYPE_P(&v) == IS_NULL) { - ZEPHIR_INIT_NVAR(&varDump); - ZVAL_STRING(&varDump, "null"); - } else { - ZEPHIR_CPY_WRT(&varDump, &v); - } - ZEPHIR_INIT_NVAR(&_14$$12); - ZEPHIR_CONCAT_SVSV(&_14$$12, "[", &k, "] => ", &varDump); - zephir_array_append(&dump, &_14$$12, PH_SEPARATE, "phalcon/Support/Debug.zep", 584); - ZEPHIR_CALL_METHOD(NULL, &argument, "next", NULL, 0); + ZEPHIR_INIT_NVAR(&_6$$4); + ZEPHIR_CALL_FUNCTION(&_7$$4, "mb_strtolower", &_4, 10, &element); + zephir_check_call_status(); + zephir_ucfirst(&_6$$4, &_7$$4); + ZEPHIR_INIT_NVAR(&_8$$4); + ZEPHIR_CONCAT_VV(&_8$$4, &output, &_6$$4); + ZEPHIR_CPY_WRT(&output, &_8$$4); + ZEPHIR_CALL_METHOD(NULL, &exploded, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&v); - ZEPHIR_INIT_NVAR(&k); - zephir_fast_join_str(return_value, SL(", "), &dump); - RETURN_MM(); + ZEPHIR_INIT_NVAR(&element); + RETURN_CCTOR(&output); } -static PHP_METHOD(Phalcon_Support_Debug, getVarDump) +static PHP_METHOD(Phalcon_Support_Helper_Str_PascalCase, processArray) { + zval _6$$4, _8$$4; + zend_bool _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *variable, variable_sub, className, dumpedObject, _0$$8, _1$$10; - zval *this_ptr = getThis(); + zval *text_param = NULL, *delimiters_param = NULL, result, _0, _1, _3, _4, _11, _12, _13, _5$$4, _7$$4; + zval text, delimiters, _10, _9$$4; - ZVAL_UNDEF(&variable_sub); - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&dumpedObject); - ZVAL_UNDEF(&_0$$8); - ZVAL_UNDEF(&_1$$10); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(variable) + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&delimiters); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_13); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_8$$4); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(text) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(delimiters) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &variable); - if (ZEPHIR_IS_TRUE_IDENTICAL(variable)) { - RETURN_MM_STRING("true"); - } - if (ZEPHIR_IS_FALSE_IDENTICAL(variable)) { - RETURN_MM_STRING("false"); - } - if (Z_TYPE_P(variable) == IS_STRING) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "escapestring", NULL, 0, variable); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 1, 1, &text_param, &delimiters_param); + zephir_get_strval(&text, text_param); + if (!delimiters_param) { + ZEPHIR_INIT_VAR(&delimiters); + } else { + zephir_get_strval(&delimiters, delimiters_param); } - if (zephir_is_scalar(variable)) { - RETVAL_ZVAL(variable, 1, 0); - RETURN_MM(); + if (ZEPHIR_IS_NULL(&delimiters)) { + ZEPHIR_INIT_NVAR(&delimiters); + ZVAL_STRING(&delimiters, "-_"); } - if (Z_TYPE_P(variable) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&className); - zephir_get_class(&className, variable, 0); - if ((zephir_method_exists_ex(variable, ZEND_STRL("dump")) == SUCCESS)) { - ZEPHIR_CALL_METHOD(&dumpedObject, variable, "dump", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_0$$8, this_ptr, "getarraydump", NULL, 0, &dumpedObject); - zephir_check_call_status(); - ZEPHIR_CONCAT_SVSVS(return_value, "Object(", &className, ": ", &_0$$8, ")"); - RETURN_MM(); - } else { - ZEPHIR_CONCAT_SVS(return_value, "Object(", &className, ")"); - RETURN_MM(); - } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "\\-"); + ZEPHIR_INIT_VAR(&_1); + zephir_fast_strpos(&_1, &delimiters, &_0, 0 ); + _2 = !ZEPHIR_IS_FALSE_IDENTICAL(&_1); + if (!(_2)) { + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "-"); + ZEPHIR_INIT_VAR(&_4); + zephir_fast_strpos(&_4, &delimiters, &_3, 0 ); + _2 = !ZEPHIR_IS_FALSE_IDENTICAL(&_4); } - if (Z_TYPE_P(variable) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(&_1$$10, this_ptr, "getarraydump", NULL, 0, variable); - zephir_check_call_status(); - ZEPHIR_CONCAT_SVS(return_value, "Array(", &_1$$10, ")"); - RETURN_MM(); + if (_2) { + ZEPHIR_INIT_VAR(&_5$$4); + ZEPHIR_INIT_VAR(&_6$$4); + zephir_create_array(&_6$$4, 2, 0); + ZEPHIR_INIT_VAR(&_7$$4); + ZVAL_STRING(&_7$$4, "\\-"); + zephir_array_fast_append(&_6$$4, &_7$$4); + ZEPHIR_INIT_NVAR(&_7$$4); + ZVAL_STRING(&_7$$4, "-"); + zephir_array_fast_append(&_6$$4, &_7$$4); + ZEPHIR_INIT_VAR(&_8$$4); + zephir_create_array(&_8$$4, 2, 0); + ZEPHIR_INIT_NVAR(&_7$$4); + ZVAL_STRING(&_7$$4, ""); + zephir_array_fast_append(&_8$$4, &_7$$4); + ZEPHIR_INIT_NVAR(&_7$$4); + ZVAL_STRING(&_7$$4, ""); + zephir_array_fast_append(&_8$$4, &_7$$4); + zephir_fast_str_replace(&_5$$4, &_6$$4, &_8$$4, &delimiters); + zephir_get_strval(&delimiters, &_5$$4); + ZEPHIR_INIT_VAR(&_9$$4); + ZEPHIR_CONCAT_SV(&_9$$4, "-", &delimiters); + ZEPHIR_CPY_WRT(&delimiters, &_9$$4); } - if (Z_TYPE_P(variable) == IS_NULL) { - RETURN_MM_STRING("null"); + ZEPHIR_INIT_VAR(&_10); + ZEPHIR_CONCAT_SVS(&_10, "/[", &delimiters, "]+/"); + ZVAL_LONG(&_11, -1); + ZVAL_LONG(&_12, (2 | 1)); + ZEPHIR_CALL_FUNCTION(&result, "preg_split", NULL, 70, &_10, &text, &_11, &_12); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_13); + if (ZEPHIR_IS_FALSE_IDENTICAL(&result)) { + ZEPHIR_INIT_NVAR(&_13); + array_init(&_13); + } else { + ZEPHIR_CPY_WRT(&_13, &result); } - zephir_gettype(return_value, variable); + RETURN_CCTOR(&_13); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Prefix) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, Prefix, phalcon, support_helper_str_prefix, phalcon_support_helper_str_prefix_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Str_Prefix, __invoke) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval prefix, _0; + zval *text, text_sub, *prefix_param = NULL; + + ZVAL_UNDEF(&text_sub); + ZVAL_UNDEF(&prefix); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(text) + Z_PARAM_STR(prefix) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &text, &prefix_param); + zephir_get_strval(&prefix, prefix_param); + zephir_cast_to_string(&_0, text); + ZEPHIR_CONCAT_VV(return_value, &prefix, &_0); RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Debug, showTraceItem) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Random) { - zend_bool _45$$25; - zval _1, _31$$17; + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, Random, phalcon, support_helper_str_random, phalcon_support_helper_str_random_method_entry, 0); + + zephir_declare_class_constant_long(phalcon_support_helper_str_random_ce, SL("RANDOM_ALNUM"), 0); + + zephir_declare_class_constant_long(phalcon_support_helper_str_random_ce, SL("RANDOM_ALPHA"), 1); + + zephir_declare_class_constant_long(phalcon_support_helper_str_random_ce, SL("RANDOM_DISTINCT"), 5); + + zephir_declare_class_constant_long(phalcon_support_helper_str_random_ce, SL("RANDOM_HEXDEC"), 2); + + zephir_declare_class_constant_long(phalcon_support_helper_str_random_ce, SL("RANDOM_NOZERO"), 4); + + zephir_declare_class_constant_long(phalcon_support_helper_str_random_ce, SL("RANDOM_NUMERIC"), 3); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Helper_Str_Random, __invoke) +{ + zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_24 = NULL, *_52 = NULL; - zval trace; - zval *n_param = NULL, *trace_param = NULL, className, prepareInternalClass, preparedFunctionName, html, classReflection, prepareUriClass, functionName, functionReflection, traceArgs, arguments, argument, filez, line, showFiles, lines, numberLines, showFileFragment, firstLine, lastLine, linePosition, currentLine, classNameWithLink, functionNameWithLink, parts, _0, _20, _2$$3, _3$$3, _4$$3, _5$$3, _15$$3, _16$$3, _6$$4, _7$$4, _8$$4, _9$$4, _10$$4, _11$$5, _12$$6, _13$$6, _14$$6, _17$$10, _18$$11, _19$$11, *_21$$14, _22$$14, _28$$14, _29$$14, _23$$15, _25$$15, _26$$16, _27$$16, _30$$17, _32$$17, _33$$17, _34$$18, _35$$19, _36$$24, _37$$27, _38$$27, _39$$27, _40$$27, _41$$27, _42$$28, _43$$28, _44$$28, _46$$30, _47$$30, _48$$30, _49$$30, _50$$30, _51$$30; - zend_long n, ZEPHIR_LAST_CALL_STATUS, i = 0, beforeLine$$19, afterLine$$19; - zval *this_ptr = getThis(); + zephir_fcall_cache_entry *_20 = NULL; + zval *type_param = NULL, *length_param = NULL, end, pools, text, _0, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16$$3, _17$$3, _18$$3, _19$$3; + zend_long type, length, ZEPHIR_LAST_CALL_STATUS; - ZVAL_UNDEF(&className); - ZVAL_UNDEF(&prepareInternalClass); - ZVAL_UNDEF(&preparedFunctionName); - ZVAL_UNDEF(&html); - ZVAL_UNDEF(&classReflection); - ZVAL_UNDEF(&prepareUriClass); - ZVAL_UNDEF(&functionName); - ZVAL_UNDEF(&functionReflection); - ZVAL_UNDEF(&traceArgs); - ZVAL_UNDEF(&arguments); - ZVAL_UNDEF(&argument); - ZVAL_UNDEF(&filez); - ZVAL_UNDEF(&line); - ZVAL_UNDEF(&showFiles); - ZVAL_UNDEF(&lines); - ZVAL_UNDEF(&numberLines); - ZVAL_UNDEF(&showFileFragment); - ZVAL_UNDEF(&firstLine); - ZVAL_UNDEF(&lastLine); - ZVAL_UNDEF(&linePosition); - ZVAL_UNDEF(¤tLine); - ZVAL_UNDEF(&classNameWithLink); - ZVAL_UNDEF(&functionNameWithLink); - ZVAL_UNDEF(&parts); + ZVAL_UNDEF(&end); + ZVAL_UNDEF(&pools); + ZVAL_UNDEF(&text); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_20); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_15$$3); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_13); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_15); ZVAL_UNDEF(&_16$$3); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_10$$4); - ZVAL_UNDEF(&_11$$5); - ZVAL_UNDEF(&_12$$6); - ZVAL_UNDEF(&_13$$6); - ZVAL_UNDEF(&_14$$6); - ZVAL_UNDEF(&_17$$10); - ZVAL_UNDEF(&_18$$11); - ZVAL_UNDEF(&_19$$11); - ZVAL_UNDEF(&_22$$14); - ZVAL_UNDEF(&_28$$14); - ZVAL_UNDEF(&_29$$14); - ZVAL_UNDEF(&_23$$15); - ZVAL_UNDEF(&_25$$15); - ZVAL_UNDEF(&_26$$16); - ZVAL_UNDEF(&_27$$16); - ZVAL_UNDEF(&_30$$17); - ZVAL_UNDEF(&_32$$17); - ZVAL_UNDEF(&_33$$17); - ZVAL_UNDEF(&_34$$18); - ZVAL_UNDEF(&_35$$19); - ZVAL_UNDEF(&_36$$24); - ZVAL_UNDEF(&_37$$27); - ZVAL_UNDEF(&_38$$27); - ZVAL_UNDEF(&_39$$27); - ZVAL_UNDEF(&_40$$27); - ZVAL_UNDEF(&_41$$27); - ZVAL_UNDEF(&_42$$28); - ZVAL_UNDEF(&_43$$28); - ZVAL_UNDEF(&_44$$28); - ZVAL_UNDEF(&_46$$30); - ZVAL_UNDEF(&_47$$30); - ZVAL_UNDEF(&_48$$30); - ZVAL_UNDEF(&_49$$30); - ZVAL_UNDEF(&_50$$30); - ZVAL_UNDEF(&_51$$30); - ZVAL_UNDEF(&trace); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_31$$17); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_LONG(n) - Z_PARAM_ARRAY(trace) + ZVAL_UNDEF(&_17$$3); + ZVAL_UNDEF(&_18$$3); + ZVAL_UNDEF(&_19$$3); + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(type) + Z_PARAM_LONG(length) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &n_param, &trace_param); - ZEPHIR_OBS_COPY_OR_DUP(&trace, trace_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_LONG(&_0, n); - ZEPHIR_INIT_VAR(&_1); - ZEPHIR_CONCAT_SVS(&_1, "#", &_0, ""); - ZEPHIR_CPY_WRT(&html, &_1); - zephir_memory_observe(&className); - if (zephir_array_isset_string_fetch(&className, &trace, SL("class"), 0)) { - ZEPHIR_INIT_VAR(&_2$$3); - ZEPHIR_INIT_VAR(&_3$$3); - ZVAL_STRING(&_3$$3, "/^Phalcon/"); - ZEPHIR_INIT_VAR(&_4$$3); - ZEPHIR_INIT_VAR(&_5$$3); - ZVAL_STRING(&_5$$3, "/^Phalcon/"); - zephir_preg_match(&_4$$3, &_5$$3, &className, &_2$$3, 0, 0 , 0 ); - if (zephir_is_true(&_4$$3)) { - ZEPHIR_INIT_VAR(&parts); - zephir_fast_explode_str(&parts, SL("\\"), &className, LONG_MAX); - zephir_array_fetch_long(&_6$$4, &parts, 0, PH_NOISY | PH_READONLY, "phalcon/Support/Debug.zep", 700); - zephir_array_fetch_long(&_7$$4, &parts, 1, PH_NOISY | PH_READONLY, "phalcon/Support/Debug.zep", 700); - ZEPHIR_INIT_VAR(&prepareUriClass); - ZEPHIR_CONCAT_VSV(&prepareUriClass, &_6$$4, "_", &_7$$4); - zephir_read_property(&_8$$4, this_ptr, ZEND_STRL("version"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_10$$4, 0); - ZEPHIR_CALL_METHOD(&_9$$4, &_8$$4, "getpart", NULL, 0, &_10$$4); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&classNameWithLink); - ZEPHIR_CONCAT_SVSVSVS(&classNameWithLink, "", &className, ""); - } else { - ZEPHIR_INIT_VAR(&classReflection); - object_init_ex(&classReflection, zephir_get_internal_ce(SL("reflectionclass"))); - ZEPHIR_CALL_METHOD(NULL, &classReflection, "__construct", NULL, 154, &className); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_11$$5, &classReflection, "isinternal", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&_11$$5)) { - ZEPHIR_INIT_VAR(&_12$$6); - zephir_fast_strtolower(&_12$$6, &className); - ZEPHIR_INIT_VAR(&_13$$6); - ZVAL_STRING(&_13$$6, "_"); - ZEPHIR_INIT_VAR(&_14$$6); - ZVAL_STRING(&_14$$6, "-"); - ZEPHIR_INIT_VAR(&prepareInternalClass); - zephir_fast_str_replace(&prepareInternalClass, &_13$$6, &_14$$6, &_12$$6); - ZEPHIR_INIT_NVAR(&classNameWithLink); - ZEPHIR_CONCAT_SVSVS(&classNameWithLink, "", &className, ""); - } else { - ZEPHIR_CPY_WRT(&classNameWithLink, &className); - } + zephir_fetch_params(1, 0, 2, &type_param, &length_param); + if (!type_param) { + type = 0; + } else { } - ZEPHIR_INIT_VAR(&_15$$3); - ZEPHIR_CONCAT_SVS(&_15$$3, "", &classNameWithLink, ""); - zephir_concat_self(&html, &_15$$3); - zephir_array_fetch_string(&_16$$3, &trace, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Support/Debug.zep", 739); - zephir_concat_self(&html, &_16$$3); - } - zephir_memory_observe(&functionName); - zephir_array_fetch_string(&functionName, &trace, SL("function"), PH_NOISY, "phalcon/Support/Debug.zep", 745); - if (zephir_array_isset_string(&trace, SL("class"))) { - ZEPHIR_CPY_WRT(&functionNameWithLink, &functionName); + if (!length_param) { + length = 8; } else { - if ((zephir_function_exists(&functionName) == SUCCESS)) { - ZEPHIR_INIT_VAR(&functionReflection); - object_init_ex(&functionReflection, zephir_get_internal_ce(SL("reflectionfunction"))); - ZEPHIR_CALL_METHOD(NULL, &functionReflection, "__construct", NULL, 151, &functionName); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_17$$10, &functionReflection, "isinternal", NULL, 0); - zephir_check_call_status(); - if (zephir_is_true(&_17$$10)) { - ZEPHIR_INIT_VAR(&_18$$11); - ZVAL_STRING(&_18$$11, "_"); - ZEPHIR_INIT_VAR(&_19$$11); - ZVAL_STRING(&_19$$11, "-"); - ZEPHIR_INIT_VAR(&preparedFunctionName); - zephir_fast_str_replace(&preparedFunctionName, &_18$$11, &_19$$11, &functionName); - ZEPHIR_INIT_NVAR(&functionNameWithLink); - ZEPHIR_CONCAT_SVSVS(&functionNameWithLink, "", &functionName, ""); - } else { - ZEPHIR_CPY_WRT(&functionNameWithLink, &functionName); - } - } else { - ZEPHIR_CPY_WRT(&functionNameWithLink, &functionName); } + ZEPHIR_INIT_VAR(&text); + ZVAL_STRING(&text, ""); + ZEPHIR_INIT_VAR(&_0); + _1 = type < 0; + if (!(_1)) { + _1 = type > 5; } - ZEPHIR_INIT_VAR(&_20); - ZEPHIR_CONCAT_SVS(&_20, "", &functionNameWithLink, ""); - zephir_concat_self(&html, &_20); - zephir_memory_observe(&traceArgs); - if (zephir_array_isset_string_fetch(&traceArgs, &trace, SL("args"), 0)) { - ZEPHIR_INIT_VAR(&arguments); - array_init(&arguments); - zephir_is_iterable(&traceArgs, 0, "phalcon/Support/Debug.zep", 800); - if (Z_TYPE_P(&traceArgs) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&traceArgs), _21$$14) - { - ZEPHIR_INIT_NVAR(&argument); - ZVAL_COPY(&argument, _21$$14); - ZEPHIR_CALL_METHOD(&_23$$15, this_ptr, "getvardump", &_24, 0, &argument); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_25$$15); - ZEPHIR_CONCAT_SVS(&_25$$15, "", &_23$$15, ""); - zephir_array_append(&arguments, &_25$$15, PH_SEPARATE, "phalcon/Support/Debug.zep", 794); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &traceArgs, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_22$$14, &traceArgs, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_22$$14)) { - break; - } - ZEPHIR_CALL_METHOD(&argument, &traceArgs, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_26$$16, this_ptr, "getvardump", &_24, 0, &argument); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_27$$16); - ZEPHIR_CONCAT_SVS(&_27$$16, "", &_26$$16, ""); - zephir_array_append(&arguments, &_27$$16, PH_SEPARATE, "phalcon/Support/Debug.zep", 794); - ZEPHIR_CALL_METHOD(NULL, &traceArgs, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&argument); - ZEPHIR_INIT_VAR(&_28$$14); - zephir_fast_join_str(&_28$$14, SL(", "), &arguments); - ZEPHIR_INIT_VAR(&_29$$14); - ZEPHIR_CONCAT_SVS(&_29$$14, "(", &_28$$14, ")"); - zephir_concat_self(&html, &_29$$14); + if (_1) { + ZEPHIR_INIT_NVAR(&_0); + ZVAL_LONG(&_0, 0); + } else { + ZEPHIR_INIT_NVAR(&_0); + ZVAL_LONG(&_0, type); } - zephir_memory_observe(&filez); - if (zephir_array_isset_string_fetch(&filez, &trace, SL("file"), 0)) { - zephir_memory_observe(&_30$$17); - zephir_array_fetch_string(&_30$$17, &trace, SL("line"), PH_NOISY, "phalcon/Support/Debug.zep", 808); - zephir_cast_to_string(&_31$$17, &_30$$17); - ZEPHIR_CPY_WRT(&line, &_31$$17); - ZEPHIR_INIT_VAR(&_32$$17); - ZEPHIR_CONCAT_SVSVS(&_32$$17, "
", &filez, " (", &line, ")
"); - zephir_concat_self(&html, &_32$$17); - zephir_read_property(&_33$$17, this_ptr, ZEND_STRL("showFiles"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&showFiles, &_33$$17); - if (zephir_is_true(&showFiles)) { - ZEPHIR_CALL_FUNCTION(&lines, "file", NULL, 0, &filez); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&numberLines); - ZVAL_LONG(&numberLines, zephir_fast_count_int(&lines)); - zephir_read_property(&_34$$18, this_ptr, ZEND_STRL("showFileFragment"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&showFileFragment, &_34$$18); - if (zephir_is_true(&showFileFragment)) { - beforeLine$$19 = (zephir_get_numberval(&line) - 7); - if (beforeLine$$19 < 1) { - ZEPHIR_INIT_VAR(&firstLine); - ZVAL_LONG(&firstLine, 1); - } else { - ZEPHIR_INIT_NVAR(&firstLine); - ZVAL_LONG(&firstLine, beforeLine$$19); - } - afterLine$$19 = (zephir_get_numberval(&line) + 5); - if (ZEPHIR_LT_LONG(&numberLines, afterLine$$19)) { - ZEPHIR_CPY_WRT(&lastLine, &numberLines); - } else { - ZEPHIR_INIT_NVAR(&lastLine); - ZVAL_LONG(&lastLine, afterLine$$19); - } - ZEPHIR_INIT_VAR(&_35$$19); - ZEPHIR_CONCAT_SVSVSVS(&_35$$19, "
");
-				zephir_concat_self(&html, &_35$$19);
-			} else {
-				ZEPHIR_INIT_NVAR(&firstLine);
-				ZVAL_LONG(&firstLine, 1);
-				ZEPHIR_CPY_WRT(&lastLine, &numberLines);
-				ZEPHIR_INIT_VAR(&_36$$24);
-				ZEPHIR_CONCAT_SVSVS(&_36$$24, "
");
-				zephir_concat_self(&html, &_36$$24);
-			}
-			i = zephir_get_numberval(&firstLine);
-			while (1) {
-				if (!(ZEPHIR_GE_LONG(&lastLine, i))) {
-					break;
-				}
-				ZEPHIR_INIT_NVAR(&linePosition);
-				ZVAL_LONG(&linePosition, (i - 1));
-				ZEPHIR_OBS_NVAR(¤tLine);
-				zephir_array_fetch(¤tLine, &lines, &linePosition, PH_NOISY, "phalcon/Support/Debug.zep", 881);
-				if (zephir_is_true(&showFileFragment)) {
-					if (ZEPHIR_IS_LONG(&firstLine, i)) {
-						ZEPHIR_INIT_NVAR(&_37$$27);
-						ZEPHIR_INIT_NVAR(&_38$$27);
-						zephir_fast_trim(&_38$$27, ¤tLine, NULL , ZEPHIR_TRIM_RIGHT);
-						ZEPHIR_INIT_NVAR(&_39$$27);
-						ZVAL_STRING(&_39$$27, "#\\*\\/#");
-						ZEPHIR_INIT_NVAR(&_40$$27);
-						ZEPHIR_INIT_NVAR(&_41$$27);
-						ZVAL_STRING(&_41$$27, "#\\*\\/#");
-						zephir_preg_match(&_40$$27, &_41$$27, &_38$$27, &_37$$27, 0, 0 , 0 );
-						if (zephir_is_true(&_40$$27)) {
-							ZEPHIR_INIT_NVAR(&_42$$28);
-							ZEPHIR_INIT_NVAR(&_43$$28);
-							ZVAL_STRING(&_43$$28, "* /");
-							ZEPHIR_INIT_NVAR(&_44$$28);
-							ZVAL_STRING(&_44$$28, " ");
-							zephir_fast_str_replace(&_42$$28, &_43$$28, &_44$$28, ¤tLine);
-							ZEPHIR_CPY_WRT(¤tLine, &_42$$28);
-						}
-					}
-				}
-				_45$$25 = ZEPHIR_IS_STRING(¤tLine, "\n");
-				if (!(_45$$25)) {
-					_45$$25 = ZEPHIR_IS_STRING(¤tLine, "\r\n");
-				}
-				if (_45$$25) {
-					zephir_concat_self_str(&html, SL(" \n"));
-				} else {
-					ZEPHIR_INIT_NVAR(&_46$$30);
-					ZEPHIR_INIT_NVAR(&_47$$30);
-					ZVAL_STRING(&_47$$30, "\t");
-					ZEPHIR_INIT_NVAR(&_48$$30);
-					ZVAL_STRING(&_48$$30, "  ");
-					zephir_fast_str_replace(&_46$$30, &_47$$30, &_48$$30, ¤tLine);
-					ZVAL_LONG(&_49$$30, 2);
-					ZEPHIR_INIT_NVAR(&_50$$30);
-					ZVAL_STRING(&_50$$30, "UTF-8");
-					ZEPHIR_CALL_FUNCTION(&_51$$30, "htmlentities", &_52, 0, &_46$$30, &_49$$30, &_50$$30);
-					zephir_check_call_status();
-					zephir_concat_self(&html, &_51$$30);
-				}
-				i++;
-			}
-			zephir_concat_self_str(&html, SL("
")); + type = zephir_get_numberval(&_0); + ZEPHIR_INIT_VAR(&pools); + zephir_create_array(&pools, 6, 0); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "a"); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "z"); + ZEPHIR_CALL_FUNCTION(&_5, "range", NULL, 314, &_3, &_4); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_3); + ZVAL_STRING(&_3, "A"); + ZEPHIR_INIT_NVAR(&_4); + ZVAL_STRING(&_4, "Z"); + ZEPHIR_CALL_FUNCTION(&_6, "range", NULL, 314, &_3, &_4); + zephir_check_call_status(); + zephir_fast_array_merge(&_2, &_5, &_6); + zephir_array_update_long(&pools, 1, &_2, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_LONG(&_7, 0); + ZVAL_LONG(&_8, 9); + ZEPHIR_CALL_FUNCTION(&_9, "range", NULL, 314, &_7, &_8); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_3); + ZVAL_STRING(&_3, "a"); + ZEPHIR_INIT_NVAR(&_4); + ZVAL_STRING(&_4, "f"); + ZEPHIR_CALL_FUNCTION(&_10, "range", NULL, 314, &_3, &_4); + zephir_check_call_status(); + zephir_fast_array_merge(&_2, &_9, &_10); + zephir_array_update_long(&pools, 2, &_2, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); + ZVAL_LONG(&_7, 0); + ZVAL_LONG(&_8, 9); + ZEPHIR_CALL_FUNCTION(&_11, "range", NULL, 314, &_7, &_8); + zephir_check_call_status(); + zephir_array_update_long(&pools, 3, &_11, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); + ZVAL_LONG(&_7, 1); + ZVAL_LONG(&_8, 9); + ZEPHIR_CALL_FUNCTION(&_11, "range", NULL, 314, &_7, &_8); + zephir_check_call_status(); + zephir_array_update_long(&pools, 4, &_11, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "2345679ACDEFHJKLMNPRSTUVWXYZ"); + ZEPHIR_CALL_FUNCTION(&_11, "str_split", NULL, 88, &_2); + zephir_check_call_status(); + zephir_array_update_long(&pools, 5, &_11, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); + ZVAL_LONG(&_7, 0); + ZVAL_LONG(&_8, 9); + ZEPHIR_CALL_FUNCTION(&_11, "range", NULL, 314, &_7, &_8); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "a"); + ZEPHIR_INIT_NVAR(&_3); + ZVAL_STRING(&_3, "z"); + ZEPHIR_CALL_FUNCTION(&_12, "range", NULL, 314, &_2, &_3); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "A"); + ZEPHIR_INIT_NVAR(&_3); + ZVAL_STRING(&_3, "Z"); + ZEPHIR_CALL_FUNCTION(&_13, "range", NULL, 314, &_2, &_3); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_14, "array_merge", NULL, 330, &_11, &_12, &_13); + zephir_check_call_status(); + zephir_array_update_long(&pools, 0, &_14, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); + zephir_array_fetch_long(&_15, &pools, type, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Random.zep", 66); + ZEPHIR_INIT_VAR(&end); + ZVAL_LONG(&end, (zephir_fast_count_int(&_15) - 1)); + while (1) { + if (!(zephir_fast_strlen_ev(&text) < length)) { + break; } + zephir_array_fetch_long(&_16$$3, &pools, type, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Random.zep", 69); + ZVAL_LONG(&_18$$3, 0); + ZEPHIR_CALL_FUNCTION(&_19$$3, "mt_rand", &_20, 0, &_18$$3, &end); + zephir_check_call_status(); + zephir_array_fetch(&_17$$3, &_16$$3, &_19$$3, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Random.zep", 69); + zephir_concat_self(&text, &_17$$3); } - zephir_concat_self_str(&html, SL("")); - RETURN_CCTOR(&html); + RETURN_CCTOR(&text); } -static PHP_METHOD(Phalcon_Support_Debug, getArrVal) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_ReduceSlashes) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *collection_param = NULL, *index, index_sub, *defaultValue = NULL, defaultValue_sub, __$null, value; - zval collection; + ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, ReduceSlashes, phalcon, support_helper_str_reduceslashes, phalcon_support_helper_str_reduceslashes_method_entry, 0); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&index_sub); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&value); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_ARRAY(collection) - Z_PARAM_ZVAL(index) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &collection_param, &index, &defaultValue); - ZEPHIR_OBS_COPY_OR_DUP(&collection, collection_param); - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; - } - zephir_memory_observe(&value); - if (UNEXPECTED(!(zephir_array_isset_fetch(&value, &collection, index, 0)))) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); - } - RETURN_CCTOR(&value); + return SUCCESS; } -zend_object *zephir_init_properties_Phalcon_Support_Debug(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Support_Helper_Str_ReduceSlashes, __invoke) { - zval _3$$4; - zval _0, _2, _1$$3, _4$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_3$$4); - + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *text_param = NULL, result, _0, _1; + zval text; - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("data"), &_1$$3); - } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("blacklist"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_2) == IS_NULL) { - ZEPHIR_INIT_VAR(&_3$$4); - zephir_create_array(&_3$$4, 2, 0); - ZEPHIR_INIT_VAR(&_4$$4); - array_init(&_4$$4); - zephir_array_update_string(&_3$$4, SL("request"), &_4$$4, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_4$$4); - array_init(&_4$$4); - zephir_array_update_string(&_3$$4, SL("server"), &_4$$4, PH_COPY | PH_SEPARATE); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("blacklist"), &_3$$4); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(text) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &text_param); + zephir_get_strval(&text, text_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "#(?= start; + if (_0) { + _0 = value <= end; + } + RETURN_BOOL(_0); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Collection_CollectionInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Support\\Collection, CollectionInterface, phalcon, support_collection_collectioninterface, phalcon_support_collection_collectioninterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, __get); +ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, __isset); +ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, __set); +ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, __unset); +ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, clear); +ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, get); +ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, getKeys); +ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, getValues); +ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, has); +ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, init); +ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, remove); +ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, set); +ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, toArray); +ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, toJson); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Collection_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Collection, Exception, phalcon, support_collection_exception, zend_ce_exception, NULL, 0); + + return SUCCESS; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Support_Collection_ReadOnlyCollection) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Collection, ReadOnlyCollection, phalcon, support_collection_readonlycollection, phalcon_support_collection_ce, phalcon_support_collection_readonlycollection_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Support_Collection_ReadOnlyCollection, remove) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; zval *element_param = NULL; zval element; @@ -146105,24 +144584,14 @@ static PHP_METHOD(Phalcon_Support_Registry, __isset) ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); zephir_fetch_params(1, 1, 0, &element_param); - if (UNEXPECTED(Z_TYPE_P(element_param) != IS_STRING && Z_TYPE_P(element_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'element' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(element_param) == IS_STRING)) { - zephir_get_strval(&element, element_param); - } else { - ZEPHIR_INIT_VAR(&element); - } - ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "has", NULL, 0, &element); - zephir_check_call_status(); - RETURN_MM(); + zephir_get_strval(&element, element_param); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_support_collection_exception_ce, "The object is read only", "phalcon/Support/Collection/ReadOnlyCollection.zep", 25); + return; } -static PHP_METHOD(Phalcon_Support_Registry, __set) +static PHP_METHOD(Phalcon_Support_Collection_ReadOnlyCollection, set) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; zval *element_param = NULL, *value, value_sub; zval element; @@ -146135,403 +144604,341 @@ static PHP_METHOD(Phalcon_Support_Registry, __set) ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); zephir_fetch_params(1, 2, 0, &element_param, &value); - if (UNEXPECTED(Z_TYPE_P(element_param) != IS_STRING && Z_TYPE_P(element_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'element' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(element_param) == IS_STRING)) { - zephir_get_strval(&element, element_param); - } else { - ZEPHIR_INIT_VAR(&element); - } - ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "set", NULL, 0, &element, value); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + zephir_get_strval(&element, element_param); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_support_collection_exception_ce, "The object is read only", "phalcon/Support/Collection/ReadOnlyCollection.zep", 33); + return; } -static PHP_METHOD(Phalcon_Support_Registry, __unset) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *element_param = NULL; - zval element; - ZVAL_UNDEF(&element); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(element) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &element_param); - if (UNEXPECTED(Z_TYPE_P(element_param) != IS_STRING && Z_TYPE_P(element_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'element' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(element_param) == IS_STRING)) { - zephir_get_strval(&element, element_param); - } else { - ZEPHIR_INIT_VAR(&element); - } - ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "remove", NULL, 0, &element); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); -} -static PHP_METHOD(Phalcon_Support_Registry, clear) + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Messages_Exception) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Messages, Exception, phalcon, messages_exception, zend_ce_exception, NULL, 0); - ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "clear", NULL, 0); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Registry, count) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Messages_Message) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + ZEPHIR_REGISTER_CLASS(Phalcon\\Messages, Message, phalcon, messages_message, phalcon_messages_message_method_entry, 0); - ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "count", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + zend_declare_property_null(phalcon_messages_message_ce, SL("code"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_messages_message_ce, SL("field"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_messages_message_ce, SL("message"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_messages_message_ce, SL("type"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_messages_message_ce, SL("metaData"), ZEND_ACC_PROTECTED); + phalcon_messages_message_ce->create_object = zephir_init_properties_Phalcon_Messages_Message; + + zend_class_implements(phalcon_messages_message_ce, 1, phalcon_messages_messageinterface_ce); + zend_class_implements(phalcon_messages_message_ce, 1, php_json_serializable_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Registry, get) +static PHP_METHOD(Phalcon_Messages_Message, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *element_param = NULL, *defaultValue = NULL, defaultValue_sub, *cast_param = NULL, __$null; - zval element, cast; + zval metaData; + zend_long code; + zval *message_param = NULL, *field = NULL, field_sub, *type_param = NULL, *code_param = NULL, *metaData_param = NULL, _0; + zval message, type; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&cast); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(element) + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&field_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&metaData); + ZEND_PARSE_PARAMETERS_START(1, 5) + Z_PARAM_STR(message) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) - Z_PARAM_STR_OR_NULL(cast) + Z_PARAM_ZVAL(field) + Z_PARAM_STR(type) + Z_PARAM_LONG(code) + Z_PARAM_ARRAY(metaData) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &element_param, &defaultValue, &cast_param); - if (UNEXPECTED(Z_TYPE_P(element_param) != IS_STRING && Z_TYPE_P(element_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'element' must be of the type string")); + zephir_fetch_params(1, 1, 4, &message_param, &field, &type_param, &code_param, &metaData_param); + if (UNEXPECTED(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(element_param) == IS_STRING)) { - zephir_get_strval(&element, element_param); + if (EXPECTED(Z_TYPE_P(message_param) == IS_STRING)) { + zephir_get_strval(&message, message_param); } else { - ZEPHIR_INIT_VAR(&element); + ZEPHIR_INIT_VAR(&message); } - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; + if (!field) { + field = &field_sub; + ZEPHIR_INIT_VAR(field); + ZVAL_STRING(field, ""); } - if (!cast_param) { - ZEPHIR_INIT_VAR(&cast); + if (!type_param) { + ZEPHIR_INIT_VAR(&type); + ZVAL_STRING(&type, ""); } else { - if (UNEXPECTED(Z_TYPE_P(cast_param) != IS_STRING && Z_TYPE_P(cast_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'cast' must be of the type string")); - RETURN_MM_NULL(); + zephir_get_strval(&type, type_param); } - if (EXPECTED(Z_TYPE_P(cast_param) == IS_STRING)) { - zephir_get_strval(&cast, cast_param); + if (!code_param) { + code = 0; } else { - ZEPHIR_INIT_VAR(&cast); - } + } + if (!metaData_param) { + ZEPHIR_INIT_VAR(&metaData); + array_init(&metaData); + } else { + zephir_get_arrval(&metaData, metaData_param); } - ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "get", NULL, 0, &element, defaultValue, &cast); - zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("message"), &message); + zephir_update_property_zval(this_ptr, ZEND_STRL("field"), field); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &type); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, code); + zephir_update_property_zval(this_ptr, ZEND_STRL("code"), &_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("metaData"), &metaData); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Support_Registry, getIterator) +static PHP_METHOD(Phalcon_Messages_Message, __toString) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "getiterator", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MEMBER(getThis(), "message"); } -static PHP_METHOD(Phalcon_Support_Registry, has) +static PHP_METHOD(Phalcon_Messages_Message, getCode) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *element_param = NULL; - zval element; - ZVAL_UNDEF(&element); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(element) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &element_param); - if (UNEXPECTED(Z_TYPE_P(element_param) != IS_STRING && Z_TYPE_P(element_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'element' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(element_param) == IS_STRING)) { - zephir_get_strval(&element, element_param); - } else { - ZEPHIR_INIT_VAR(&element); - } - ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "has", NULL, 0, &element); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MEMBER(getThis(), "code"); } -static PHP_METHOD(Phalcon_Support_Registry, init) +static PHP_METHOD(Phalcon_Messages_Message, getField) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *data_param = NULL; - zval data; - ZVAL_UNDEF(&data); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(data) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &data_param); - if (!data_param) { - ZEPHIR_INIT_VAR(&data); - array_init(&data); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); - } - ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "init", NULL, 0, &data); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MEMBER(getThis(), "field"); } -static PHP_METHOD(Phalcon_Support_Registry, jsonSerialize) +static PHP_METHOD(Phalcon_Messages_Message, getMessage) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "jsonserialize", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MEMBER(getThis(), "message"); } -static PHP_METHOD(Phalcon_Support_Registry, offsetExists) +static PHP_METHOD(Phalcon_Messages_Message, getType) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *element, element_sub; - ZVAL_UNDEF(&element_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(element) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &element); - ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "has", NULL, 0, element); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MEMBER(getThis(), "type"); } -static PHP_METHOD(Phalcon_Support_Registry, offsetGet) +static PHP_METHOD(Phalcon_Messages_Message, getMetaData) +{ + + RETURN_MEMBER(getThis(), "metaData"); +} + +static PHP_METHOD(Phalcon_Messages_Message, jsonSerialize) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval element_sub; - zval *element; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&element_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(element) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &element); - ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "get", NULL, 0, element); - zephir_check_call_status(); + + zephir_create_array(return_value, 5, 0); + zephir_memory_observe(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("field"), PH_NOISY_CC); + zephir_array_update_string(return_value, SL("field"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("message"), PH_NOISY_CC); + zephir_array_update_string(return_value, SL("message"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("type"), PH_NOISY_CC); + zephir_array_update_string(return_value, SL("type"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("code"), PH_NOISY_CC); + zephir_array_update_string(return_value, SL("code"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC); + zephir_array_update_string(return_value, SL("metaData"), &_0, PH_COPY | PH_SEPARATE); RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Registry, offsetSet) +static PHP_METHOD(Phalcon_Messages_Message, setCode) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *offset, offset_sub, *value, value_sub; + zval *code_param = NULL, _0; + zend_long code; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&offset_sub); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(offset) - Z_PARAM_ZVAL(value) + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(code) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &offset, &value); - ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "set", NULL, 0, offset, value); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + zephir_fetch_params_without_memory_grow(1, 0, &code_param); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, code); + zephir_update_property_zval(this_ptr, ZEND_STRL("code"), &_0); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Support_Registry, offsetUnset) +static PHP_METHOD(Phalcon_Messages_Message, setField) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *element, element_sub; + zval *field, field_sub; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&element_sub); + ZVAL_UNDEF(&field_sub); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(element) + Z_PARAM_ZVAL(field) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &element); - ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "remove", NULL, 0, element); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + zephir_fetch_params_without_memory_grow(1, 0, &field); + zephir_update_property_zval(this_ptr, ZEND_STRL("field"), field); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Support_Registry, remove) +static PHP_METHOD(Phalcon_Messages_Message, setMessage) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *element_param = NULL; - zval element; + zval *message_param = NULL; + zval message; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&element); + ZVAL_UNDEF(&message); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(element) + Z_PARAM_STR(message) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &element_param); - if (UNEXPECTED(Z_TYPE_P(element_param) != IS_STRING && Z_TYPE_P(element_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'element' must be of the type string")); + zephir_fetch_params(1, 1, 0, &message_param); + if (UNEXPECTED(Z_TYPE_P(message_param) != IS_STRING && Z_TYPE_P(message_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'message' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(element_param) == IS_STRING)) { - zephir_get_strval(&element, element_param); + if (EXPECTED(Z_TYPE_P(message_param) == IS_STRING)) { + zephir_get_strval(&message, message_param); } else { - ZEPHIR_INIT_VAR(&element); + ZEPHIR_INIT_VAR(&message); } - ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "remove", NULL, 0, &element); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + zephir_update_property_zval(this_ptr, ZEND_STRL("message"), &message); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Support_Registry, serialize) +static PHP_METHOD(Phalcon_Messages_Message, setMetaData) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *metaData_param = NULL; + zval metaData; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&metaData); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(metaData) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "serialize", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &metaData_param); + ZEPHIR_OBS_COPY_OR_DUP(&metaData, metaData_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("metaData"), &metaData); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Support_Registry, set) +static PHP_METHOD(Phalcon_Messages_Message, setType) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *element_param = NULL, *value, value_sub; - zval element; + zval *type_param = NULL; + zval type; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&element); - ZVAL_UNDEF(&value_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(element) - Z_PARAM_ZVAL(value) + ZVAL_UNDEF(&type); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(type) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &element_param, &value); - if (UNEXPECTED(Z_TYPE_P(element_param) != IS_STRING && Z_TYPE_P(element_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'element' must be of the type string")); + zephir_fetch_params(1, 1, 0, &type_param); + if (UNEXPECTED(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(element_param) == IS_STRING)) { - zephir_get_strval(&element, element_param); + if (EXPECTED(Z_TYPE_P(type_param) == IS_STRING)) { + zephir_get_strval(&type, type_param); } else { - ZEPHIR_INIT_VAR(&element); + ZEPHIR_INIT_VAR(&type); } - ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "set", NULL, 0, &element, value); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &type); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Support_Registry, toArray) +zend_object *zephir_init_properties_Phalcon_Messages_Message(zend_class_entry *class_type) { + zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + - ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "toarray", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("metaData"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("metaData"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } } -static PHP_METHOD(Phalcon_Support_Registry, toJson) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *options_param = NULL, _0; - zend_long options, ZEPHIR_LAST_CALL_STATUS; - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(options) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &options_param); - if (!options_param) { - options = 79; - } else { - } - ZVAL_LONG(&_0, options); - ZEPHIR_RETURN_CALL_PARENT(phalcon_support_registry_ce, getThis(), "tojson", NULL, 0, &_0); - zephir_check_call_status(); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Support_Registry, unserialize) + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Messages_MessageInterface) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *data_param = NULL; - zval data; + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Messages, MessageInterface, phalcon, messages_messageinterface, phalcon_messages_messageinterface_method_entry); - ZVAL_UNDEF(&data); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(data) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &data_param); - zephir_get_strval(&data, data_param); - ZEPHIR_CALL_PARENT(NULL, phalcon_support_registry_ce, getThis(), "unserialize", NULL, 0, &data); - zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + return SUCCESS; } +ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, __toString); +ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, getCode); +ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, getField); +ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, getMessage); +ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, getMetaData); +ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, getType); +ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, setCode); +ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, setField); +ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, setMessage); +ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, setMetaData); +ZEPHIR_DOC_METHOD(Phalcon_Messages_MessageInterface, setType); @@ -146542,318 +144949,423 @@ static PHP_METHOD(Phalcon_Support_Registry, unserialize) -ZEPHIR_INIT_CLASS(Phalcon_Support_Version) +ZEPHIR_INIT_CLASS(Phalcon_Messages_Messages) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support, Version, phalcon, support_version, phalcon_support_version_method_entry, 0); - - zephir_declare_class_constant_long(phalcon_support_version_ce, SL("VERSION_MAJOR"), 0); - - zephir_declare_class_constant_long(phalcon_support_version_ce, SL("VERSION_MEDIUM"), 1); - - zephir_declare_class_constant_long(phalcon_support_version_ce, SL("VERSION_MINOR"), 2); - - zephir_declare_class_constant_long(phalcon_support_version_ce, SL("VERSION_SPECIAL"), 3); - - zephir_declare_class_constant_long(phalcon_support_version_ce, SL("VERSION_SPECIAL_NUMBER"), 4); + ZEPHIR_REGISTER_CLASS(Phalcon\\Messages, Messages, phalcon, messages_messages, phalcon_messages_messages_method_entry, 0); + zend_declare_property_long(phalcon_messages_messages_ce, SL("position"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_messages_messages_ce, SL("messages"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_messages_messages_ce, 1, zend_ce_arrayaccess); + zend_class_implements(phalcon_messages_messages_ce, 1, zend_ce_countable); + zend_class_implements(phalcon_messages_messages_ce, 1, zend_ce_iterator); + zend_class_implements(phalcon_messages_messages_ce, 1, php_json_serializable_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Version, getVersion) +static PHP_METHOD(Phalcon_Messages_Messages, __construct) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *messages_param = NULL; + zval messages; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&messages); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(messages) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &messages_param); + if (!messages_param) { + ZEPHIR_INIT_VAR(&messages); + array_init(&messages); + } else { + zephir_get_arrval(&messages, messages_param); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), &messages); + ZEPHIR_MM_RESTORE(); +} - zephir_create_array(return_value, 5, 0); - ZEPHIR_INIT_VAR(&_0); - ZVAL_LONG(&_0, 5); - zephir_array_fast_append(return_value, &_0); - ZEPHIR_INIT_NVAR(&_0); - ZVAL_LONG(&_0, 7); - zephir_array_fast_append(return_value, &_0); - ZEPHIR_INIT_NVAR(&_0); - ZVAL_LONG(&_0, 0); - zephir_array_fast_append(return_value, &_0); - ZEPHIR_INIT_NVAR(&_0); - ZVAL_LONG(&_0, 4); - zephir_array_fast_append(return_value, &_0); - ZEPHIR_INIT_NVAR(&_0); - ZVAL_LONG(&_0, 0); - zephir_array_fast_append(return_value, &_0); - RETURN_MM(); +static PHP_METHOD(Phalcon_Messages_Messages, appendMessage) +{ + zval *message, message_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&message_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(message, phalcon_messages_messageinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &message); + zephir_update_property_array_append(this_ptr, SL("messages"), message); } -static PHP_METHOD(Phalcon_Support_Version, getSpecial) +static PHP_METHOD(Phalcon_Messages_Messages, appendMessages) { + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *special_param = NULL, suffix; - zend_long special; + zephir_fcall_cache_entry *_2 = NULL, *_3 = NULL, *_4 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *messages, messages_sub, currentMessages, finalMessages, message, _1$$7; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&suffix); + ZVAL_UNDEF(&messages_sub); + ZVAL_UNDEF(¤tMessages); + ZVAL_UNDEF(&finalMessages); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_1$$7); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(special) + Z_PARAM_ZVAL(messages) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &special_param); - do { - if (special == 1) { - ZEPHIR_INIT_VAR(&suffix); - ZVAL_STRING(&suffix, "alpha"); - break; - } - if (special == 2) { - ZEPHIR_INIT_NVAR(&suffix); - ZVAL_STRING(&suffix, "beta"); - break; + zephir_fetch_params(1, 1, 0, &messages); + _0 = Z_TYPE_P(messages) != IS_ARRAY; + if (_0) { + _0 = Z_TYPE_P(messages) != IS_OBJECT; + } + if (_0) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_messages_exception_ce, "The messages must be iterable", "phalcon/Messages/Messages.zep", 69); + return; + } + zephir_memory_observe(¤tMessages); + zephir_read_property(¤tMessages, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC); + if (Z_TYPE_P(messages) == IS_ARRAY) { + if (Z_TYPE_P(¤tMessages) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&finalMessages); + zephir_fast_array_merge(&finalMessages, ¤tMessages, messages); + } else { + ZEPHIR_CPY_WRT(&finalMessages, messages); } - if (special == 3) { - ZEPHIR_INIT_NVAR(&suffix); - ZVAL_STRING(&suffix, "RC"); - break; + zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), &finalMessages); + } else { + ZEPHIR_CALL_METHOD(NULL, messages, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1$$7, messages, "valid", NULL, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&_1$$7))) { + break; + } + ZEPHIR_CALL_METHOD(&message, messages, "current", &_2, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "appendmessage", &_3, 0, &message); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, messages, "next", &_4, 0); + zephir_check_call_status(); } - ZEPHIR_INIT_NVAR(&suffix); - ZVAL_STRING(&suffix, ""); - break; - } while(0); - - RETURN_CCTOR(&suffix); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Support_Version, get) +static PHP_METHOD(Phalcon_Messages_Messages, count) { - zval result; - zval version, major, medium, minor, special, specialNumber, suffix, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&version); - ZVAL_UNDEF(&major); - ZVAL_UNDEF(&medium); - ZVAL_UNDEF(&minor); - ZVAL_UNDEF(&special); - ZVAL_UNDEF(&specialNumber); - ZVAL_UNDEF(&suffix); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&result); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&version, this_ptr, "getversion", NULL, 0); - zephir_check_call_status(); - zephir_memory_observe(&major); - zephir_array_fetch_long(&major, &version, 0, PH_NOISY, "phalcon/Support/Version.zep", 122); - zephir_memory_observe(&medium); - zephir_array_fetch_long(&medium, &version, 1, PH_NOISY, "phalcon/Support/Version.zep", 123); - zephir_memory_observe(&minor); - zephir_array_fetch_long(&minor, &version, 2, PH_NOISY, "phalcon/Support/Version.zep", 124); - zephir_memory_observe(&special); - zephir_array_fetch_long(&special, &version, 3, PH_NOISY, "phalcon/Support/Version.zep", 125); - zephir_memory_observe(&specialNumber); - zephir_array_fetch_long(&specialNumber, &version, 4, PH_NOISY, "phalcon/Support/Version.zep", 126); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_CONCAT_VSVSV(&_0, &major, ".", &medium, ".", &minor); - zephir_get_strval(&result, &_0); - ZEPHIR_CALL_METHOD(&suffix, this_ptr, "getspecial", NULL, 0, &special); - zephir_check_call_status(); - if (!ZEPHIR_IS_STRING(&suffix, "")) { - zephir_concat_self(&result, &suffix); - if (!ZEPHIR_IS_LONG(&specialNumber, 0)) { - zephir_concat_self(&result, &specialNumber); - } - } - RETURN_CTOR(&result); + zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + RETURN_LONG(zephir_fast_count_int(&_0)); } -static PHP_METHOD(Phalcon_Support_Version, getId) +static PHP_METHOD(Phalcon_Messages_Messages, current) { - zval version, major, medium, minor, special, specialNumber, _0, _1, _2; + zval _0, _1, _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&version); - ZVAL_UNDEF(&major); - ZVAL_UNDEF(&medium); - ZVAL_UNDEF(&minor); - ZVAL_UNDEF(&special); - ZVAL_UNDEF(&specialNumber); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_CALL_METHOD(&version, this_ptr, "getversion", NULL, 0); - zephir_check_call_status(); - zephir_memory_observe(&major); - zephir_array_fetch_long(&major, &version, 0, PH_NOISY, "phalcon/Support/Version.zep", 160); - zephir_memory_observe(&medium); - zephir_array_fetch_long(&medium, &version, 1, PH_NOISY, "phalcon/Support/Version.zep", 161); - zephir_memory_observe(&minor); - zephir_array_fetch_long(&minor, &version, 2, PH_NOISY, "phalcon/Support/Version.zep", 162); - zephir_memory_observe(&special); - zephir_array_fetch_long(&special, &version, 3, PH_NOISY, "phalcon/Support/Version.zep", 163); - zephir_memory_observe(&specialNumber); - zephir_array_fetch_long(&specialNumber, &version, 4, PH_NOISY, "phalcon/Support/Version.zep", 164); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "%02s"); - ZEPHIR_CALL_FUNCTION(&_1, "sprintf", NULL, 117, &_0, &medium); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, "%02s"); - ZEPHIR_CALL_FUNCTION(&_2, "sprintf", NULL, 117, &_0, &minor); - zephir_check_call_status(); - ZEPHIR_CONCAT_VVVVV(return_value, &major, &_1, &_2, &special, &specialNumber); - RETURN_MM(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + zephir_memory_observe(&_2); + zephir_read_property(&_2, this_ptr, ZEND_STRL("position"), PH_NOISY_CC); + zephir_array_fetch(&_1, &_0, &_2, PH_NOISY | PH_READONLY, "phalcon/Messages/Messages.zep", 117); + RETURN_CTOR(&_1); } -static PHP_METHOD(Phalcon_Support_Version, getPart) +static PHP_METHOD(Phalcon_Messages_Messages, filter) { - zval _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *part_param = NULL, version, _0$$3, _2$$4; - zend_long part, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *fieldName_param = NULL, filtered, messages, message, _0, *_1$$3, _2$$3, _3$$5, _4$$8; + zval fieldName; zval *this_ptr = getThis(); - ZVAL_UNDEF(&version); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&fieldName); + ZVAL_UNDEF(&filtered); + ZVAL_UNDEF(&messages); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4$$8); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(part) + Z_PARAM_STR(fieldName) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &part_param); - ZEPHIR_CALL_METHOD(&version, this_ptr, "getversion", NULL, 0); - zephir_check_call_status(); - do { - if (part == 0 || part == 1 || part == 2 || part == 4) { - zephir_memory_observe(&_0$$3); - zephir_array_fetch_long(&_0$$3, &version, part, PH_NOISY, "phalcon/Support/Version.zep", 192); - zephir_cast_to_string(&_1$$3, &_0$$3); - RETURN_CTOR(&_1$$3); - } - if (part == 3) { - zephir_array_fetch_long(&_2$$4, &version, 3, PH_NOISY | PH_READONLY, "phalcon/Support/Version.zep", 195); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getspecial", NULL, 0, &_2$$4); + zephir_fetch_params(1, 1, 0, &fieldName_param); + if (UNEXPECTED(Z_TYPE_P(fieldName_param) != IS_STRING && Z_TYPE_P(fieldName_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'fieldName' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(fieldName_param) == IS_STRING)) { + zephir_get_strval(&fieldName, fieldName_param); + } else { + ZEPHIR_INIT_VAR(&fieldName); + } + ZEPHIR_INIT_VAR(&filtered); + array_init(&filtered); + zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&messages, &_0); + if (Z_TYPE_P(&messages) == IS_ARRAY) { + zephir_is_iterable(&messages, 0, "phalcon/Messages/Messages.zep", 145); + if (Z_TYPE_P(&messages) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&messages), _1$$3) + { + ZEPHIR_INIT_NVAR(&message); + ZVAL_COPY(&message, _1$$3); + if ((zephir_method_exists_ex(&message, ZEND_STRL("getfield")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(&_3$$5, &message, "getfield", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_EQUAL(&fieldName, &_3$$5)) { + zephir_array_append(&filtered, &message, PH_SEPARATE, "phalcon/Messages/Messages.zep", 141); + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &messages, "rewind", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + while (1) { + ZEPHIR_CALL_METHOD(&_2$$3, &messages, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&message, &messages, "current", NULL, 0); + zephir_check_call_status(); + if ((zephir_method_exists_ex(&message, ZEND_STRL("getfield")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(&_4$$8, &message, "getfield", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_EQUAL(&fieldName, &_4$$8)) { + zephir_array_append(&filtered, &message, PH_SEPARATE, "phalcon/Messages/Messages.zep", 141); + } + } + ZEPHIR_CALL_METHOD(NULL, &messages, "next", NULL, 0); + zephir_check_call_status(); + } } - } while(0); - - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "get", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_INIT_NVAR(&message); + } + RETURN_CCTOR(&filtered); } +static PHP_METHOD(Phalcon_Messages_Messages, jsonSerialize) +{ + zend_bool _3$$3, _5$$6; + zval records; + zval message, _0, *_1, _2, _4$$4, _6$$7; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&records); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + ZEPHIR_INIT_VAR(&records); + array_init(&records); + zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_0, 0, "phalcon/Messages/Messages.zep", 174); + if (Z_TYPE_P(&_0) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) + { + ZEPHIR_INIT_NVAR(&message); + ZVAL_COPY(&message, _1); + _3$$3 = Z_TYPE_P(&message) == IS_OBJECT; + if (_3$$3) { + _3$$3 = (zephir_method_exists_ex(&message, ZEND_STRL("jsonserialize")) == SUCCESS); + } + if (_3$$3) { + ZEPHIR_CALL_METHOD(&_4$$4, &message, "jsonserialize", NULL, 0); + zephir_check_call_status(); + zephir_array_append(&records, &_4$$4, PH_SEPARATE, "phalcon/Messages/Messages.zep", 168); + } else { + zephir_array_append(&records, &message, PH_SEPARATE, "phalcon/Messages/Messages.zep", 170); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&message, &_0, "current", NULL, 0); + zephir_check_call_status(); + _5$$6 = Z_TYPE_P(&message) == IS_OBJECT; + if (_5$$6) { + _5$$6 = (zephir_method_exists_ex(&message, ZEND_STRL("jsonserialize")) == SUCCESS); + } + if (_5$$6) { + ZEPHIR_CALL_METHOD(&_6$$7, &message, "jsonserialize", NULL, 0); + zephir_check_call_status(); + zephir_array_append(&records, &_6$$7, PH_SEPARATE, "phalcon/Messages/Messages.zep", 168); + } else { + zephir_array_append(&records, &message, PH_SEPARATE, "phalcon/Messages/Messages.zep", 170); + } + ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&message); + RETURN_CTOR(&records); +} -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Collection_CollectionInterface) +static PHP_METHOD(Phalcon_Messages_Messages, key) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Support\\Collection, CollectionInterface, phalcon, support_collection_collectioninterface, phalcon_support_collection_collectioninterface_method_entry); - return SUCCESS; + RETURN_MEMBER(getThis(), "position"); } -ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, __get); -ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, __isset); -ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, __set); -ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, __unset); -ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, clear); -ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, get); -ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, getKeys); -ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, getValues); -ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, has); -ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, init); -ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, remove); -ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, set); -ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, toArray); -ZEPHIR_DOC_METHOD(Phalcon_Support_Collection_CollectionInterface, toJson); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Collection_Exception) +static PHP_METHOD(Phalcon_Messages_Messages, next) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Collection, Exception, phalcon, support_collection_exception, zend_ce_exception, NULL, 0); - - return SUCCESS; + zval *this_ptr = getThis(); + RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("position"))); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Collection_ReadOnlyCollection) +static PHP_METHOD(Phalcon_Messages_Messages, offsetExists) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Collection, ReadOnlyCollection, phalcon, support_collection_readonlycollection, phalcon_support_collection_ce, phalcon_support_collection_readonlycollection_method_entry, 0); + zval index_sub, _0; + zval *index; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(index) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &index); + zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + RETURN_BOOL(zephir_array_isset(&_0, index)); } -static PHP_METHOD(Phalcon_Support_Collection_ReadOnlyCollection, remove) +static PHP_METHOD(Phalcon_Messages_Messages, offsetGet) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *element_param = NULL; - zval element; + zval index_sub, message, returnValue, _0; + zval *index; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&element); + ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&returnValue); + ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(element) + Z_PARAM_ZVAL(index) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &element_param); - zephir_get_strval(&element, element_param); - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_support_collection_exception_ce, "The object is read only", "phalcon/Support/Collection/ReadOnlyCollection.zep", 25); - return; + zephir_fetch_params(1, 1, 0, &index); + ZEPHIR_INIT_VAR(&returnValue); + ZVAL_NULL(&returnValue); + zephir_memory_observe(&message); + zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&message, &_0, index, 0)) { + ZEPHIR_CPY_WRT(&returnValue, &message); + } + RETURN_CCTOR(&returnValue); } -static PHP_METHOD(Phalcon_Support_Collection_ReadOnlyCollection, set) +static PHP_METHOD(Phalcon_Messages_Messages, offsetSet) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *element_param = NULL, *value, value_sub; - zval element; + zval offset_sub, value_sub, _0; + zval *offset, *value; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&element); + ZVAL_UNDEF(&offset_sub); ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(element) + Z_PARAM_ZVAL(offset) Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &element_param, &value); - zephir_get_strval(&element, element_param); - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_support_collection_exception_ce, "The object is read only", "phalcon/Support/Collection/ReadOnlyCollection.zep", 33); - return; + zephir_fetch_params(1, 2, 0, &offset, &value); + ZEPHIR_INIT_VAR(&_0); + zephir_gettype(&_0, value); + if (!ZEPHIR_IS_STRING_IDENTICAL(&_0, "object")) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_messages_exception_ce, "The message must be an object", "phalcon/Messages/Messages.zep", 241); + return; + } + zephir_update_property_array(this_ptr, SL("messages"), offset, value); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Messages_Messages, offsetUnset) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval index_sub, _0, _1$$3, _2$$3; + zval *index; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(index) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &index); + zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset(&_0, index)) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_2$$3, 1); + ZEPHIR_MAKE_REF(&_1$$3); + ZEPHIR_CALL_FUNCTION(NULL, "array_splice", NULL, 415, &_1$$3, index, &_2$$3); + ZEPHIR_UNREF(&_1$$3); + zephir_check_call_status(); + } + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Messages_Messages, rewind) +{ + zval _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, 0); + zephir_update_property_zval(this_ptr, ZEND_STRL("position"), &_0); +} + +static PHP_METHOD(Phalcon_Messages_Messages, valid) +{ + zval _0, _1; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_1, this_ptr, ZEND_STRL("position"), PH_NOISY_CC | PH_READONLY); + RETURN_BOOL(zephir_array_isset(&_0, &_1)); } @@ -146866,9 +145378,9 @@ static PHP_METHOD(Phalcon_Support_Collection_ReadOnlyCollection, set) -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Exception) +ZEPHIR_INIT_CLASS(Phalcon_Forms_Exception) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper, Exception, phalcon, support_helper_exception, zend_ce_exception, NULL, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms, Exception, phalcon, forms_exception, zend_ce_exception, NULL, 0); return SUCCESS; } @@ -146883,1483 +145395,1744 @@ ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Exception) -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_File_Basename) +ZEPHIR_INIT_CLASS(Phalcon_Forms_Form) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\File, Basename, phalcon, support_helper_file_basename, phalcon_support_helper_file_basename_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms, Form, phalcon, forms_form, phalcon_di_injectable_ce, phalcon_forms_form_method_entry, 0); + + zend_declare_property_null(phalcon_forms_form_ce, SL("attributes"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_form_ce, SL("data"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_form_ce, SL("filteredData"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_form_ce, SL("elements"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_form_ce, SL("elementsIndexed"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_form_ce, SL("entity"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_form_ce, SL("messages"), ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_forms_form_ce, SL("position"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_form_ce, SL("options"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_form_ce, SL("tagFactory"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_form_ce, SL("validation"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_form_ce, SL("whitelist"), ZEND_ACC_PROTECTED); + phalcon_forms_form_ce->create_object = zephir_init_properties_Phalcon_Forms_Form; + zend_class_implements(phalcon_forms_form_ce, 1, zend_ce_countable); + zend_class_implements(phalcon_forms_form_ce, 1, zend_ce_iterator); + zend_class_implements(phalcon_forms_form_ce, 1, phalcon_html_attributes_attributesinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Helper_File_Basename, __invoke) +static PHP_METHOD(Phalcon_Forms_Form, __construct) { + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *uri_param = NULL, *suffix_param = NULL, fileName, matches, _0, _1, _2, _3, _4, _5, _6$$3, _7$$3, _8$$3, _9$$3; - zval uri, suffix; + zval userOptions; + zval *entity = NULL, entity_sub, *userOptions_param = NULL, __$null, _1; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&uri); - ZVAL_UNDEF(&suffix); - ZVAL_UNDEF(&fileName); - ZVAL_UNDEF(&matches); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&entity_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_9$$3); + ZVAL_UNDEF(&userOptions); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(uri) + ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(suffix) + Z_PARAM_ZVAL_OR_NULL(entity) + Z_PARAM_ARRAY(userOptions) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &uri_param, &suffix_param); - zephir_get_strval(&uri, uri_param); - if (!suffix_param) { - ZEPHIR_INIT_VAR(&suffix); + zephir_fetch_params(1, 0, 2, &entity, &userOptions_param); + if (!entity) { + entity = &entity_sub; + entity = &__$null; + } + if (!userOptions_param) { + ZEPHIR_INIT_VAR(&userOptions); + array_init(&userOptions); } else { - zephir_get_strval(&suffix, suffix_param); + zephir_get_arrval(&userOptions, userOptions_param); } - ZEPHIR_INIT_VAR(&_0); + _0 = Z_TYPE_P(entity) != IS_NULL; + if (_0) { + _0 = Z_TYPE_P(entity) != IS_OBJECT; + } + if (UNEXPECTED(_0)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_forms_exception_ce, "The base entity is not valid", "phalcon/Forms/Form.zep", 98); + return; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("entity"), entity); + zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &userOptions); ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "/"); - zephir_fast_trim(&_0, &uri, &_1, ZEPHIR_TRIM_RIGHT); - zephir_get_strval(&uri, &_0); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "/"); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "@"); - ZEPHIR_CALL_FUNCTION(&_4, "preg_quote", NULL, 351, &_2, &_3); + object_init_ex(&_1, phalcon_html_attributes_ce); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 23); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_5); - ZEPHIR_CONCAT_SVS(&_5, "@[^", &_4, "]+$@"); - ZEPHIR_INIT_NVAR(&_2); - zephir_preg_match(&_2, &_5, &uri, &matches, 0, 0 , 0 ); - if (zephir_is_true(&_2)) { - zephir_memory_observe(&fileName); - zephir_array_fetch_long(&fileName, &matches, 0, PH_NOISY, "phalcon/Support/Helper/File/Basename.zep", 39); - } else { - ZEPHIR_INIT_NVAR(&fileName); - ZVAL_STRING(&fileName, ""); - } - if (1 != ZEPHIR_IS_EMPTY(&suffix)) { - ZEPHIR_INIT_VAR(&_6$$3); - ZVAL_STRING(&_6$$3, "@"); - ZEPHIR_CALL_FUNCTION(&_7$$3, "preg_quote", NULL, 351, &suffix, &_6$$3); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_8$$3); - ZEPHIR_CONCAT_SVS(&_8$$3, "@", &_7$$3, "$@"); - ZEPHIR_INIT_NVAR(&_6$$3); - ZVAL_STRING(&_6$$3, ""); - ZEPHIR_CALL_FUNCTION(&_9$$3, "preg_replace", NULL, 41, &_8$$3, &_6$$3, &fileName); + zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &_1); + if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("initialize")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "initialize", NULL, 0, entity, &userOptions); zephir_check_call_status(); - ZEPHIR_CPY_WRT(&fileName, &_9$$3); } - RETURN_CCTOR(&fileName); + ZEPHIR_MM_RESTORE(); } +static PHP_METHOD(Phalcon_Forms_Form, add) +{ + zend_string *_9$$5; + zend_ulong _8$$5; + zval elements; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool type, _0, _3; + zval position; + zval *element, element_sub, *position_param = NULL, *type_param = NULL, name, key, value, _1, _4, _2$$3, _5$$5, *_6$$5, _7$$5; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&element_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&position); + ZVAL_UNDEF(&elements); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_OBJECT_OF_CLASS(element, phalcon_forms_element_elementinterface_ce) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(position) + Z_PARAM_BOOL_OR_NULL(type, is_null_true) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &element, &position_param, &type_param); + if (!position_param) { + ZEPHIR_INIT_VAR(&position); + } else { + zephir_get_strval(&position, position_param); + } + if (!type_param) { + type = 0; + } else { + } + ZEPHIR_CALL_METHOD(&name, element, "getname", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, element, "setform", NULL, 0, this_ptr); + zephir_check_call_status(); + _0 = (zephir_method_exists_ex(element, ZEND_STRL("settagfactory")) == SUCCESS); + if (_0) { + zephir_read_property(&_1, this_ptr, ZEND_STRL("tagFactory"), PH_NOISY_CC | PH_READONLY); + _0 = Z_TYPE_P(&_1) != IS_NULL; + } + if (_0) { + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("tagFactory"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, element, "settagfactory", NULL, 0, &_2$$3); + zephir_check_call_status(); + } + _3 = ZEPHIR_IS_NULL(&position); + if (!(_3)) { + zephir_read_property(&_4, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + _3 = ZEPHIR_IS_EMPTY(&_4); + } + if (_3) { + zephir_update_property_array(this_ptr, SL("elements"), &name, element); + } else { + ZEPHIR_INIT_VAR(&elements); + array_init(&elements); + zephir_read_property(&_5$$5, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_5$$5, 0, "phalcon/Forms/Form.zep", 176); + if (Z_TYPE_P(&_5$$5) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_5$$5), _8$$5, _9$$5, _6$$5) + { + ZEPHIR_INIT_NVAR(&key); + if (_9$$5 != NULL) { + ZVAL_STR_COPY(&key, _9$$5); + } else { + ZVAL_LONG(&key, _8$$5); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _6$$5); + if (ZEPHIR_IS_EQUAL(&key, &position)) { + if (type) { + zephir_array_update_zval(&elements, &name, element, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&elements, &key, &value, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&elements, &key, &value, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&elements, &name, element, PH_COPY | PH_SEPARATE); + } + } else { + zephir_array_update_zval(&elements, &key, &value, PH_COPY | PH_SEPARATE); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_5$$5, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_7$$5, &_5$$5, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_7$$5)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &_5$$5, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &_5$$5, "current", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_EQUAL(&key, &position)) { + if (type) { + zephir_array_update_zval(&elements, &name, element, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&elements, &key, &value, PH_COPY | PH_SEPARATE); + } else { + zephir_array_update_zval(&elements, &key, &value, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&elements, &name, element, PH_COPY | PH_SEPARATE); + } + } else { + zephir_array_update_zval(&elements, &key, &value, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, &_5$$5, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + zephir_update_property_zval(this_ptr, ZEND_STRL("elements"), &elements); + } + RETURN_THIS(); +} - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_AbstractArr) +static PHP_METHOD(Phalcon_Forms_Form, bind) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, AbstractArr, phalcon, support_helper_arr_abstractarr, phalcon_support_helper_arr_abstractarr_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + zend_bool _7$$5, _16$$15; + zend_string *_5; + zend_ulong _4; + zval method; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_8 = NULL, *_14 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *data_param = NULL, *entity = NULL, entity_sub, *whitelist_param = NULL, __$null, filter, key, value, element, filters, container, filteredValue, _0, *_2, _3, _1$$4, _6$$5, _9$$9, _10$$9, _11$$11, _12$$11, _13$$11, _15$$15, _17$$19, _18$$19, _19$$21, _20$$21, _21$$21; + zval data, whitelist, assignData, filteredData; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&whitelist); + ZVAL_UNDEF(&assignData); + ZVAL_UNDEF(&filteredData); + ZVAL_UNDEF(&entity_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&filter); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&filters); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&filteredValue); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_9$$9); + ZVAL_UNDEF(&_10$$9); + ZVAL_UNDEF(&_11$$11); + ZVAL_UNDEF(&_12$$11); + ZVAL_UNDEF(&_13$$11); + ZVAL_UNDEF(&_15$$15); + ZVAL_UNDEF(&_17$$19); + ZVAL_UNDEF(&_18$$19); + ZVAL_UNDEF(&_19$$21); + ZVAL_UNDEF(&_20$$21); + ZVAL_UNDEF(&_21$$21); + ZVAL_UNDEF(&method); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ARRAY(data) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(entity) + Z_PARAM_ARRAY(whitelist) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &data_param, &entity, &whitelist_param); + ZEPHIR_OBS_COPY_OR_DUP(&data, data_param); + if (!entity) { + entity = &entity_sub; + ZEPHIR_CPY_WRT(entity, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(entity); + } + if (!whitelist_param) { + ZEPHIR_INIT_VAR(&whitelist); + array_init(&whitelist); + } else { + zephir_get_arrval(&whitelist, whitelist_param); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(ZEPHIR_IS_EMPTY(&_0))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_forms_exception_ce, "There are no elements in the form", "phalcon/Forms/Form.zep", 195); + return; + } + if (ZEPHIR_IS_EMPTY(&whitelist)) { + zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("whitelist"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&whitelist, &_1$$4); + } + ZEPHIR_INIT_VAR(&filter); + ZVAL_NULL(&filter); + ZEPHIR_INIT_VAR(&assignData); + array_init(&assignData); + ZEPHIR_INIT_VAR(&filteredData); + array_init(&filteredData); + zephir_is_iterable(&data, 0, "phalcon/Forms/Form.zep", 269); + if (Z_TYPE_P(&data) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _4, _5, _2) + { + ZEPHIR_INIT_NVAR(&key); + if (_5 != NULL) { + ZVAL_STR_COPY(&key, _5); + } else { + ZVAL_LONG(&key, _4); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _2); + ZEPHIR_OBS_NVAR(&element); + zephir_read_property(&_6$$5, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&element, &_6$$5, &key, 0))) { + continue; + } + _7$$5 = !(ZEPHIR_IS_EMPTY(&whitelist)); + if (_7$$5) { + _7$$5 = !(zephir_fast_in_array(&key, &whitelist)); + } + if (_7$$5) { + continue; + } + ZEPHIR_CALL_METHOD(&filters, &element, "getfilters", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&filters)) { + if (Z_TYPE_P(&filter) != IS_OBJECT) { + ZEPHIR_CALL_METHOD(&container, this_ptr, "getdi", &_8, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_10$$9); + ZVAL_STRING(&_10$$9, "filter"); + ZEPHIR_CALL_METHOD(&_9$$9, &container, "getshared", NULL, 0, &_10$$9); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&filter, &_9$$9); + } + ZEPHIR_CALL_METHOD(&filteredValue, &filter, "sanitize", NULL, 0, &value, &filters); + zephir_check_call_status(); + } else { + ZEPHIR_CPY_WRT(&filteredValue, &value); + } + zephir_array_update_zval(&assignData, &key, &value, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&filteredData, &key, &filteredValue, PH_COPY | PH_SEPARATE); + if (Z_TYPE_P(entity) != IS_NULL) { + ZEPHIR_INIT_NVAR(&_11$$11); + zephir_camelize(&_11$$11, &key, NULL ); + ZEPHIR_INIT_NVAR(&_12$$11); + ZEPHIR_CONCAT_SV(&_12$$11, "set", &_11$$11); + zephir_get_strval(&method, &_12$$11); + if ((zephir_method_exists(entity, &method) == SUCCESS)) { + ZEPHIR_CALL_METHOD_ZVAL(NULL, entity, &method, NULL, 0, &filteredValue); + zephir_check_call_status(); + continue; + } + if (!(ZEPHIR_GLOBAL(form).strict_entity_property_check)) { + zephir_update_property_zval_zval(entity, &key, &filteredValue); + continue; + } + ZEPHIR_CALL_FUNCTION(&_13$$11, "property_exists", &_14, 290, entity, &key); + zephir_check_call_status(); + if (zephir_is_true(&_13$$11)) { + zephir_update_property_zval_zval(entity, &key, &filteredValue); + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &data, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&key, &data, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&element); + zephir_read_property(&_15$$15, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&element, &_15$$15, &key, 0))) { + continue; + } + _16$$15 = !(ZEPHIR_IS_EMPTY(&whitelist)); + if (_16$$15) { + _16$$15 = !(zephir_fast_in_array(&key, &whitelist)); + } + if (_16$$15) { + continue; + } + ZEPHIR_CALL_METHOD(&filters, &element, "getfilters", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&filters)) { + if (Z_TYPE_P(&filter) != IS_OBJECT) { + ZEPHIR_CALL_METHOD(&container, this_ptr, "getdi", &_8, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_18$$19); + ZVAL_STRING(&_18$$19, "filter"); + ZEPHIR_CALL_METHOD(&_17$$19, &container, "getshared", NULL, 0, &_18$$19); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&filter, &_17$$19); + } + ZEPHIR_CALL_METHOD(&filteredValue, &filter, "sanitize", NULL, 0, &value, &filters); + zephir_check_call_status(); + } else { + ZEPHIR_CPY_WRT(&filteredValue, &value); + } + zephir_array_update_zval(&assignData, &key, &value, PH_COPY | PH_SEPARATE); + zephir_array_update_zval(&filteredData, &key, &filteredValue, PH_COPY | PH_SEPARATE); + if (Z_TYPE_P(entity) != IS_NULL) { + ZEPHIR_INIT_NVAR(&_19$$21); + zephir_camelize(&_19$$21, &key, NULL ); + ZEPHIR_INIT_NVAR(&_20$$21); + ZEPHIR_CONCAT_SV(&_20$$21, "set", &_19$$21); + zephir_get_strval(&method, &_20$$21); + if ((zephir_method_exists(entity, &method) == SUCCESS)) { + ZEPHIR_CALL_METHOD_ZVAL(NULL, entity, &method, NULL, 0, &filteredValue); + zephir_check_call_status(); + continue; + } + if (!(ZEPHIR_GLOBAL(form).strict_entity_property_check)) { + zephir_update_property_zval_zval(entity, &key, &filteredValue); + continue; + } + ZEPHIR_CALL_FUNCTION(&_21$$21, "property_exists", &_14, 290, entity, &key); + zephir_check_call_status(); + if (zephir_is_true(&_21$$21)) { + zephir_update_property_zval_zval(entity, &key, &filteredValue); + } + } + ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + zephir_update_property_zval(this_ptr, ZEND_STRL("data"), &assignData); + zephir_update_property_zval(this_ptr, ZEND_STRL("filteredData"), &filteredData); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_AbstractArr, toFilter) +static PHP_METHOD(Phalcon_Forms_Form, clear) { - zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, *method = NULL, method_sub, __$null; - zval collection; + zval *fields = NULL, fields_sub, __$null, elements, element, data, field, _0, *_1$$3, _2$$3, _3$$4, _4$$4, _5$$5, _6$$5, _7$$7, *_8$$6, _9$$6, _10$$10, _11$$10, _12$$13, _13$$13; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&method_sub); + ZVAL_UNDEF(&fields_sub); ZVAL_NULL(&__$null); + ZVAL_UNDEF(&elements); + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&field); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_7$$7); + ZVAL_UNDEF(&_9$$6); + ZVAL_UNDEF(&_10$$10); + ZVAL_UNDEF(&_11$$10); + ZVAL_UNDEF(&_12$$13); + ZVAL_UNDEF(&_13$$13); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(collection) + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(method) + Z_PARAM_ZVAL_OR_NULL(fields) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &collection_param, &method); - zephir_get_arrval(&collection, collection_param); - if (!method) { - method = &method_sub; - method = &__$null; - } - _0 = !zephir_is_true(method); - if (!(_0)) { - _0 = !(zephir_is_callable(method)); + zephir_fetch_params(1, 0, 1, &fields); + if (!fields) { + fields = &fields_sub; + ZEPHIR_CPY_WRT(fields, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(fields); } - if (_0) { - RETURN_CTOR(&collection); + zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&data, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&elements, &_0); + if (Z_TYPE_P(fields) == IS_NULL) { + ZEPHIR_INIT_NVAR(&data); + array_init(&data); + zephir_is_iterable(&elements, 0, "phalcon/Forms/Form.zep", 298); + if (Z_TYPE_P(&elements) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&elements), _1$$3) + { + ZEPHIR_INIT_NVAR(&element); + ZVAL_COPY(&element, _1$$3); + ZEPHIR_CALL_METHOD(&_3$$4, &element, "getdefault", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4$$4, &element, "getname", NULL, 0); + zephir_check_call_status(); + zephir_array_update_zval(&data, &_4$$4, &_3$$4, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &elements, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2$$3, &elements, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&element, &elements, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5$$5, &element, "getdefault", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_6$$5, &element, "getname", NULL, 0); + zephir_check_call_status(); + zephir_array_update_zval(&data, &_6$$5, &_5$$5, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &elements, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&element); + } else { + if (Z_TYPE_P(fields) != IS_ARRAY) { + ZEPHIR_INIT_VAR(&_7$$7); + zephir_create_array(&_7$$7, 1, 0); + zephir_array_fast_append(&_7$$7, fields); + ZEPHIR_CPY_WRT(fields, &_7$$7); + } + zephir_is_iterable(fields, 0, "phalcon/Forms/Form.zep", 312); + if (Z_TYPE_P(fields) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(fields), _8$$6) + { + ZEPHIR_INIT_NVAR(&field); + ZVAL_COPY(&field, _8$$6); + if (zephir_array_isset(&data, &field)) { + zephir_array_unset(&data, &field, PH_SEPARATE); + } + ZEPHIR_OBS_NVAR(&element); + if (zephir_array_isset_fetch(&element, &elements, &field, 0)) { + ZEPHIR_CALL_METHOD(&_10$$10, &element, "getdefault", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_11$$10, &element, "getname", NULL, 0); + zephir_check_call_status(); + zephir_array_update_zval(&data, &_11$$10, &_10$$10, PH_COPY | PH_SEPARATE); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, fields, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_9$$6, fields, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_9$$6)) { + break; + } + ZEPHIR_CALL_METHOD(&field, fields, "current", NULL, 0); + zephir_check_call_status(); + if (zephir_array_isset(&data, &field)) { + zephir_array_unset(&data, &field, PH_SEPARATE); + } + ZEPHIR_OBS_NVAR(&element); + if (zephir_array_isset_fetch(&element, &elements, &field, 0)) { + ZEPHIR_CALL_METHOD(&_12$$13, &element, "getdefault", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_13$$13, &element, "getname", NULL, 0); + zephir_check_call_status(); + zephir_array_update_zval(&data, &_13$$13, &_12$$13, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, fields, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&field); } - ZEPHIR_RETURN_CALL_FUNCTION("array_filter", NULL, 17, &collection, method); - zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("data"), &data); + RETURN_THIS(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Blacklist) +static PHP_METHOD(Phalcon_Forms_Form, count) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Arr, Blacklist, phalcon, support_helper_arr_blacklist, phalcon_support_helper_arr_abstractarr_ce, phalcon_support_helper_arr_blacklist_method_entry, 0); + zval _0; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + RETURN_LONG(zephir_fast_count_int(&_0)); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_Blacklist, __invoke) +static PHP_METHOD(Phalcon_Forms_Form, current) { + zval element, _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, *blackList_param = NULL, blackListed, _0, _1; - zval collection, blackList; zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&blackList); - ZVAL_UNDEF(&blackListed); + ZVAL_UNDEF(&element); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ARRAY(collection) - Z_PARAM_ARRAY(blackList) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &collection_param, &blackList_param); - zephir_get_arrval(&collection, collection_param); - zephir_get_arrval(&blackList, blackList_param); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_INIT_NVAR(&_0); - zephir_create_closure_ex(&_0, NULL, phalcon_12__closure_ce, SL("__invoke")); - ZEPHIR_CALL_METHOD(&blackListed, this_ptr, "tofilter", NULL, 0, &blackList, &_0); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_1, "array_flip", NULL, 100, &blackListed); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_FUNCTION("array_diff_key", NULL, 99, &collection, &_1); - zephir_check_call_status(); - RETURN_MM(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Chunk) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, Chunk, phalcon, support_helper_arr_chunk, phalcon_support_helper_arr_chunk_method_entry, 0); - - return SUCCESS; + zephir_memory_observe(&element); + zephir_read_property(&_0, this_ptr, ZEND_STRL("elementsIndexed"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_1, this_ptr, ZEND_STRL("position"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&element, &_0, &_1, 0))) { + RETURN_MM_BOOL(0); + } + RETURN_CCTOR(&element); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_Chunk, __invoke) +static PHP_METHOD(Phalcon_Forms_Form, get) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_bool preserveKeys; - zend_long size, ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, *size_param = NULL, *preserveKeys_param = NULL, _0, _1; - zval collection; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, element, _0, _1$$3; + zval name, _2$$3; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&element); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_ARRAY(collection) - Z_PARAM_LONG(size) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(preserveKeys) + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &collection_param, &size_param, &preserveKeys_param); - zephir_get_arrval(&collection, collection_param); - if (!preserveKeys_param) { - preserveKeys = 0; + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - } - ZVAL_LONG(&_0, size); - ZVAL_BOOL(&_1, (preserveKeys ? 1 : 0)); - ZEPHIR_RETURN_CALL_FUNCTION("array_chunk", NULL, 0, &collection, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Filter) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Arr, Filter, phalcon, support_helper_arr_filter, phalcon_support_helper_arr_abstractarr_ce, phalcon_support_helper_arr_filter_method_entry, 0); - - return SUCCESS; + ZEPHIR_INIT_VAR(&name); + } + zephir_memory_observe(&element); + zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(!(zephir_array_isset_fetch(&element, &_0, &name, 0)))) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_forms_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + ZEPHIR_CONCAT_SVS(&_2$$3, "Element with ID=", &name, " is not part of the form"); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Forms/Form.zep", 351); + ZEPHIR_MM_RESTORE(); + return; + } + RETURN_CCTOR(&element); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_Filter, __invoke) +static PHP_METHOD(Phalcon_Forms_Form, getAction) { + zval _3; + zval _0, _1, _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, *method = NULL, method_sub, __$null; - zval collection; zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&method_sub); - ZVAL_NULL(&__$null); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(collection) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(method) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &collection_param, &method); - zephir_get_arrval(&collection, collection_param); - if (!method) { - method = &method_sub; - method = &__$null; - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "tofilter", NULL, 0, &collection, method); - zephir_check_call_status(); - RETURN_MM(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_First) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Arr, First, phalcon, support_helper_arr_first, phalcon_support_helper_arr_abstractarr_ce, phalcon_support_helper_arr_first_method_entry, 0); - return SUCCESS; + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getattributes", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "action"); + ZEPHIR_CALL_METHOD(&_1, &_0, "get", NULL, 0, &_2); + zephir_check_call_status(); + zephir_cast_to_string(&_3, &_1); + RETURN_CTOR(&_3); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_First, __invoke) +static PHP_METHOD(Phalcon_Forms_Form, getAttributes) { + zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, *method = NULL, method_sub, __$null, filtered; - zval collection; zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&method_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&filtered); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(collection) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(method) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &collection_param, &method); - zephir_get_arrval(&collection, collection_param); - if (!method) { - method = &method_sub; - method = &__$null; + + zephir_read_property(&_0, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(Z_TYPE_P(&_0) == IS_NULL)) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_html_attributes_ce); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 23); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &_1$$3); } - ZEPHIR_CALL_METHOD(&filtered, this_ptr, "tofilter", NULL, 0, &collection, method); - zephir_check_call_status(); - ZEPHIR_MAKE_REF(&filtered); - ZEPHIR_RETURN_CALL_FUNCTION("reset", NULL, 477, &filtered); - ZEPHIR_UNREF(&filtered); - zephir_check_call_status(); - RETURN_MM(); + RETURN_MM_MEMBER(getThis(), "attributes"); } +static PHP_METHOD(Phalcon_Forms_Form, getElements) +{ + RETURN_MEMBER(getThis(), "elements"); +} - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_FirstKey) +static PHP_METHOD(Phalcon_Forms_Form, getEntity) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Arr, FirstKey, phalcon, support_helper_arr_firstkey, phalcon_support_helper_arr_abstractarr_ce, phalcon_support_helper_arr_firstkey_method_entry, 0); - return SUCCESS; + RETURN_MEMBER(getThis(), "entity"); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_FirstKey, __invoke) +static PHP_METHOD(Phalcon_Forms_Form, getFilteredValue) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, *method = NULL, method_sub, __$null, filtered; - zval collection; + zval *name_param = NULL, filteredData, value, _0; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&method_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&filtered); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(collection) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(method) + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&filteredData); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &collection_param, &method); - zephir_get_arrval(&collection, collection_param); - if (!method) { - method = &method_sub; - method = &__$null; + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_CALL_METHOD(&filtered, this_ptr, "tofilter", NULL, 0, &collection, method); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_FUNCTION("array_key_first", NULL, 0, &filtered); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("filteredData"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&filteredData, &_0); + if (Z_TYPE_P(&filteredData) == IS_ARRAY) { + zephir_memory_observe(&value); + if (zephir_array_isset_fetch(&value, &filteredData, &name, 0)) { + RETURN_CCTOR(&value); + } + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getvalue", NULL, 0, &name); zephir_check_call_status(); RETURN_MM(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Flatten) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, Flatten, phalcon, support_helper_arr_flatten, phalcon_support_helper_arr_flatten_method_entry, 0); - - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Support_Helper_Arr_Flatten, __invoke) +static PHP_METHOD(Phalcon_Forms_Form, getLabel) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL, *_5 = NULL, *_7 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool deep; - zval *collection_param = NULL, *deep_param = NULL, data, item, *_0, _1, _2$$3, _4$$3, _6$$3, _8$$4, _9$$4, _10$$4; - zval collection; + zval *name_param = NULL, element, label, _0, _1$$3; + zval name, _2$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&item); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&name); ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_10$$4); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(collection) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(deep) + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&label); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &collection_param, &deep_param); - zephir_get_arrval(&collection, collection_param); - if (!deep_param) { - deep = 0; - } else { - } - ZEPHIR_INIT_VAR(&data); - array_init(&data); - zephir_is_iterable(&collection, 0, "phalcon/Support/Helper/Arr/Flatten.zep", 37); - if (Z_TYPE_P(&collection) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&collection), _0) - { - ZEPHIR_INIT_NVAR(&item); - ZVAL_COPY(&item, _0); - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "processnotarray", &_3, 0, &data, &item); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&data, &_2$$3); - if (deep) { - ZVAL_BOOL(&_4$$3, 1); - } else { - ZVAL_BOOL(&_4$$3, 0); - } - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "processarraydeep", &_5, 0, &data, &item, &_4$$3); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&data, &_2$$3); - if (deep) { - ZVAL_BOOL(&_6$$3, 1); - } else { - ZVAL_BOOL(&_6$$3, 0); - } - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "processarray", &_7, 0, &data, &item, &_6$$3); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&data, &_2$$3); - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - ZEPHIR_CALL_METHOD(NULL, &collection, "rewind", NULL, 0); + ZEPHIR_INIT_VAR(&name); + } + zephir_memory_observe(&element); + zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(!(zephir_array_isset_fetch(&element, &_0, &name, 0)))) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_forms_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + ZEPHIR_CONCAT_SVS(&_2$$3, "Element with ID=", &name, " is not part of the form"); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &collection, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&item, &collection, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_8$$4, this_ptr, "processnotarray", &_3, 0, &data, &item); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&data, &_8$$4); - if (deep) { - ZVAL_BOOL(&_9$$4, 1); - } else { - ZVAL_BOOL(&_9$$4, 0); - } - ZEPHIR_CALL_METHOD(&_8$$4, this_ptr, "processarraydeep", &_5, 0, &data, &item, &_9$$4); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&data, &_8$$4); - if (deep) { - ZVAL_BOOL(&_10$$4, 1); - } else { - ZVAL_BOOL(&_10$$4, 0); - } - ZEPHIR_CALL_METHOD(&_8$$4, this_ptr, "processarray", &_7, 0, &data, &item, &_10$$4); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&data, &_8$$4); - ZEPHIR_CALL_METHOD(NULL, &collection, "next", NULL, 0); - zephir_check_call_status(); - } + zephir_throw_exception_debug(&_1$$3, "phalcon/Forms/Form.zep", 426); + ZEPHIR_MM_RESTORE(); + return; } - ZEPHIR_INIT_NVAR(&item); - RETURN_CCTOR(&data); -} - -static PHP_METHOD(Phalcon_Support_Helper_Arr_Flatten, processNotArray) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *data_param = NULL, *item, item_sub; - zval data; - - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&item_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ARRAY(data) - Z_PARAM_ZVAL(item) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &data_param, &item); - zephir_get_arrval(&data, data_param); - if (Z_TYPE_P(item) != IS_ARRAY) { - zephir_array_append(&data, item, PH_SEPARATE, "phalcon/Support/Helper/Arr/Flatten.zep", 49); + ZEPHIR_CALL_METHOD(&label, &element, "getlabel", NULL, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&label))) { + RETURN_CTOR(&name); } - RETURN_CTOR(&data); + RETURN_CCTOR(&label); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_Flatten, processArray) +static PHP_METHOD(Phalcon_Forms_Form, getMessages) { + zend_bool _1; + zval messages, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool deep, _0; - zval *data_param = NULL, *item, item_sub, *deep_param = NULL, _1$$3, _2$$3; - zval data; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&item_sub); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ARRAY(data) - Z_PARAM_ZVAL(item) - Z_PARAM_BOOL(deep) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&messages); + ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &data_param, &item, &deep_param); - zephir_get_arrval(&data, data_param); - _0 = Z_TYPE_P(item) == IS_ARRAY; - if (_0) { - _0 = !deep; + + zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&messages, &_0); + _1 = Z_TYPE_P(&messages) == IS_OBJECT; + if (_1) { + _1 = zephir_instance_of_ev(&messages, phalcon_messages_messages_ce); } - if (_0) { - ZEPHIR_INIT_VAR(&_1$$3); - ZEPHIR_CALL_FUNCTION(&_2$$3, "array_values", NULL, 14, item); + if (!(_1)) { + object_init_ex(return_value, phalcon_messages_messages_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 8); zephir_check_call_status(); - zephir_fast_array_merge(&_1$$3, &data, &_2$$3); - ZEPHIR_CPY_WRT(&data, &_1$$3); + RETURN_MM(); } - RETURN_CTOR(&data); + RETURN_CCTOR(&messages); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_Flatten, processArrayDeep) +static PHP_METHOD(Phalcon_Forms_Form, getMessagesFor) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool deep, _0; - zval *data_param = NULL, *item, item_sub, *deep_param = NULL, _1$$3, _2$$3, _3$$3; - zval data; + zval *name_param = NULL, _0, _1; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&item_sub); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ARRAY(data) - Z_PARAM_ZVAL(item) - Z_PARAM_BOOL(deep) + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &data_param, &item, &deep_param); - zephir_get_arrval(&data, data_param); - _0 = Z_TYPE_P(item) == IS_ARRAY; - if (_0) { - _0 = deep; + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); } - if (_0) { - ZEPHIR_INIT_VAR(&_1$$3); - ZVAL_BOOL(&_3$$3, 1); - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "__invoke", NULL, 0, item, &_3$$3); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + ZEPHIR_CALL_METHOD(&_0, this_ptr, "has", NULL, 0, &name); + zephir_check_call_status(); + if (!(zephir_is_true(&_0))) { + object_init_ex(return_value, phalcon_messages_messages_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 8); zephir_check_call_status(); - zephir_fast_array_merge(&_1$$3, &data, &_2$$3); - ZEPHIR_CPY_WRT(&data, &_1$$3); + RETURN_MM(); } - RETURN_CTOR(&data); + ZEPHIR_CALL_METHOD(&_1, this_ptr, "get", NULL, 0, &name); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(&_1, "getmessages", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Get) +static PHP_METHOD(Phalcon_Forms_Form, getTagFactory) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, Get, phalcon, support_helper_arr_get, phalcon_support_helper_arr_get_method_entry, 0); - return SUCCESS; + RETURN_MEMBER(getThis(), "tagFactory"); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_Get, __invoke) +static PHP_METHOD(Phalcon_Forms_Form, getUserOption) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval cast; - zval *collection_param = NULL, *index, index_sub, *defaultValue = NULL, defaultValue_sub, *cast_param = NULL, __$null, value; - zval collection; + zval *option_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null, value, _0; + zval option; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(&option); ZVAL_UNDEF(&defaultValue_sub); ZVAL_NULL(&__$null); ZVAL_UNDEF(&value); - ZVAL_UNDEF(&cast); + ZVAL_UNDEF(&_0); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 4) - Z_PARAM_ARRAY(collection) - Z_PARAM_ZVAL(index) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(option) Z_PARAM_OPTIONAL Z_PARAM_ZVAL_OR_NULL(defaultValue) - Z_PARAM_STR_OR_NULL(cast) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 2, &collection_param, &index, &defaultValue, &cast_param); - zephir_get_arrval(&collection, collection_param); + zephir_fetch_params(1, 1, 1, &option_param, &defaultValue); + zephir_get_strval(&option, option_param); if (!defaultValue) { defaultValue = &defaultValue_sub; defaultValue = &__$null; } - if (!cast_param) { - ZEPHIR_INIT_VAR(&cast); - } else { - zephir_get_strval(&cast, cast_param); - } - ZEPHIR_CPY_WRT(&value, defaultValue); - if (1 == zephir_array_isset(&collection, index)) { - ZEPHIR_OBS_NVAR(&value); - zephir_array_fetch(&value, &collection, index, PH_NOISY, "phalcon/Support/Helper/Arr/Get.zep", 38); - } - if (!(ZEPHIR_IS_EMPTY(&cast))) { - ZEPHIR_MAKE_REF(&value); - ZEPHIR_CALL_FUNCTION(NULL, "settype", NULL, 11, &value, &cast); - ZEPHIR_UNREF(&value); - zephir_check_call_status(); + zephir_memory_observe(&value); + zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&value, &_0, &option, 0))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); } RETURN_CCTOR(&value); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Group) +static PHP_METHOD(Phalcon_Forms_Form, getUserOptions) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, Group, phalcon, support_helper_arr_group, phalcon_support_helper_arr_group_method_entry, 0); - return SUCCESS; + RETURN_MEMBER(getThis(), "options"); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_Group, __invoke) +static PHP_METHOD(Phalcon_Forms_Form, getValue) { + zval forbidden; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL, *_5 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, *method, method_sub, element, filtered, *_0, _1, _2$$3, _6$$4; - zval collection; + zval *name_param = NULL, __$true, entity, value, data, internalEntity, element, _0, _3, _4, _1$$4, _2$$4; + zval name, method; zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&method_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&method); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&entity); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&internalEntity); ZVAL_UNDEF(&element); - ZVAL_UNDEF(&filtered); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_6$$4); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ARRAY(collection) - Z_PARAM_ZVAL(method) + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&forbidden); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &collection_param, &method); - zephir_get_arrval(&collection, collection_param); - ZEPHIR_INIT_VAR(&filtered); - array_init(&filtered); - zephir_is_iterable(&collection, 0, "phalcon/Support/Helper/Arr/Group.zep", 36); - if (Z_TYPE_P(&collection) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&collection), _0) - { - ZEPHIR_INIT_NVAR(&element); - ZVAL_COPY(&element, _0); - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "processcallable", &_3, 0, &filtered, method, &element); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&filtered, &_2$$3); - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "processobject", &_4, 0, &filtered, method, &element); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&filtered, &_2$$3); - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "processother", &_5, 0, &filtered, method, &element); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&filtered, &_2$$3); - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - ZEPHIR_CALL_METHOD(NULL, &collection, "rewind", NULL, 0); + ZEPHIR_INIT_VAR(&name); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("entity"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&entity, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&data, &_0); + if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("getcustomvalue")) == SUCCESS)) { + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getcustomvalue", NULL, 0, &name, &entity, &data); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &collection, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&element, &collection, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_6$$4, this_ptr, "processcallable", &_3, 0, &filtered, method, &element); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&filtered, &_6$$4); - ZEPHIR_CALL_METHOD(&_6$$4, this_ptr, "processobject", &_4, 0, &filtered, method, &element); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&filtered, &_6$$4); - ZEPHIR_CALL_METHOD(&_6$$4, this_ptr, "processother", &_5, 0, &filtered, method, &element); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&filtered, &_6$$4); - ZEPHIR_CALL_METHOD(NULL, &collection, "next", NULL, 0); + RETURN_MM(); + } + if (Z_TYPE_P(&entity) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_1$$4); + zephir_camelize(&_1$$4, &name, NULL ); + ZEPHIR_INIT_VAR(&_2$$4); + ZEPHIR_CONCAT_SV(&_2$$4, "get", &_1$$4); + zephir_get_strval(&method, &_2$$4); + if ((zephir_method_exists(&entity, &method) == SUCCESS)) { + ZEPHIR_RETURN_CALL_METHOD_ZVAL(&entity, &method, NULL, 0); zephir_check_call_status(); + RETURN_MM(); } - } - ZEPHIR_INIT_NVAR(&element); - RETURN_CCTOR(&filtered); -} - -static PHP_METHOD(Phalcon_Support_Helper_Arr_Group, isCallable) -{ - zend_bool _0, _1; - zval *method, method_sub; - - ZVAL_UNDEF(&method_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(method) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &method); - _0 = zephir_is_callable(method); - if (!(_0)) { - _1 = Z_TYPE_P(method) == IS_STRING; - if (_1) { - _1 = 1 == (zephir_function_exists(method) == SUCCESS); + zephir_memory_observe(&value); + if (zephir_fetch_property_zval(&value, &entity, &name, PH_SILENT_CC)) { + RETURN_CCTOR(&value); } - _0 = _1; } - RETURN_BOOL(_0); -} - -static PHP_METHOD(Phalcon_Support_Helper_Arr_Group, processCallable) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *filtered_param = NULL, *method, method_sub, *element, element_sub, key, output, _0; - zval filtered; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&filtered); - ZVAL_UNDEF(&method_sub); - ZVAL_UNDEF(&element_sub); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&output); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ARRAY(filtered) - Z_PARAM_ZVAL(method) - Z_PARAM_ZVAL(element) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &filtered_param, &method, &element); - zephir_get_arrval(&filtered, filtered_param); - ZEPHIR_CPY_WRT(&output, &filtered); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "iscallable", NULL, 0, method); - zephir_check_call_status(); - if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { - ZEPHIR_CALL_FUNCTION(&key, "call_user_func", NULL, 188, method, element); - zephir_check_call_status(); - zephir_array_update_multi(&output, element, SL("za"), 2, &key); - } - RETURN_CCTOR(&output); -} - -static PHP_METHOD(Phalcon_Support_Helper_Arr_Group, processObject) -{ - zend_bool _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *filtered_param = NULL, *method, method_sub, *element, element_sub, output, _0, key$$3; - zval filtered; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&filtered); - ZVAL_UNDEF(&method_sub); - ZVAL_UNDEF(&element_sub); - ZVAL_UNDEF(&output); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&key$$3); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ARRAY(filtered) - Z_PARAM_ZVAL(method) - Z_PARAM_ZVAL(element) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &filtered_param, &method, &element); - zephir_get_arrval(&filtered, filtered_param); - ZEPHIR_CPY_WRT(&output, &filtered); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "iscallable", NULL, 0, method); - zephir_check_call_status(); - _1 = !ZEPHIR_IS_TRUE_IDENTICAL(&_0); - if (_1) { - _1 = Z_TYPE_P(element) == IS_OBJECT; - } - if (_1) { - zephir_memory_observe(&key$$3); - zephir_read_property_zval(&key$$3, element, method, PH_NOISY_CC); - zephir_array_update_multi(&output, element, SL("za"), 2, &key$$3); + if (Z_TYPE_P(&data) == IS_ARRAY) { + ZEPHIR_OBS_NVAR(&value); + if (zephir_array_isset_fetch(&value, &data, &name, 0)) { + RETURN_CCTOR(&value); + } } - RETURN_CCTOR(&output); -} - -static PHP_METHOD(Phalcon_Support_Helper_Arr_Group, processOther) -{ - zend_bool _1, _2; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *filtered_param = NULL, *method, method_sub, *element, element_sub, output, _0, key$$3; - zval filtered; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&filtered); - ZVAL_UNDEF(&method_sub); - ZVAL_UNDEF(&element_sub); - ZVAL_UNDEF(&output); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&key$$3); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ARRAY(filtered) - Z_PARAM_ZVAL(method) - Z_PARAM_ZVAL(element) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &filtered_param, &method, &element); - zephir_get_arrval(&filtered, filtered_param); - ZEPHIR_CPY_WRT(&output, &filtered); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "iscallable", NULL, 0, method); - zephir_check_call_status(); - _1 = !ZEPHIR_IS_TRUE_IDENTICAL(&_0); - if (_1) { - _1 = Z_TYPE_P(element) != IS_OBJECT; + ZEPHIR_INIT_VAR(&forbidden); + zephir_create_array(&forbidden, 14, 0); + zephir_array_update_string(&forbidden, SL("attributes"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&forbidden, SL("validation"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&forbidden, SL("action"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&forbidden, SL("useroption"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&forbidden, SL("useroptions"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&forbidden, SL("entity"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&forbidden, SL("elements"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&forbidden, SL("messages"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&forbidden, SL("messagesfor"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&forbidden, SL("label"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&forbidden, SL("value"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&forbidden, SL("di"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&forbidden, SL("tagFactory"), &__$true, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&forbidden, SL("eventsmanager"), &__$true, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&internalEntity); + zephir_fast_strtolower(&internalEntity, &name); + if (zephir_array_isset(&forbidden, &internalEntity)) { + RETURN_MM_NULL(); } - _2 = _1; - if (_2) { - _2 = 1 == zephir_array_isset(element, method); + ZEPHIR_INIT_VAR(&_3); + zephir_camelize(&_3, &name, NULL ); + ZEPHIR_INIT_VAR(&_4); + ZEPHIR_CONCAT_SV(&_4, "get", &_3); + zephir_get_strval(&method, &_4); + if ((zephir_method_exists(this_ptr, &method) == SUCCESS)) { + ZEPHIR_RETURN_CALL_METHOD_ZVAL(this_ptr, &method, NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } - if (_2) { - zephir_memory_observe(&key$$3); - zephir_array_fetch(&key$$3, element, method, PH_NOISY, "phalcon/Support/Helper/Arr/Group.zep", 116); - zephir_array_update_multi(&output, element, SL("za"), 2, &key$$3); + zephir_memory_observe(&element); + zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&element, &_0, &name, 0)) { + ZEPHIR_RETURN_CALL_METHOD(&element, "getdefault", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } - RETURN_CCTOR(&output); + RETURN_MM_NULL(); } +static PHP_METHOD(Phalcon_Forms_Form, getValidation) +{ + RETURN_MEMBER(getThis(), "validation"); +} - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Has) +static PHP_METHOD(Phalcon_Forms_Form, getWhitelist) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, Has, phalcon, support_helper_arr_has, phalcon_support_helper_arr_has_method_entry, 0); - return SUCCESS; + RETURN_MEMBER(getThis(), "whitelist"); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_Has, __invoke) +static PHP_METHOD(Phalcon_Forms_Form, has) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *collection_param = NULL, *index, index_sub; - zval collection; + zval *name_param = NULL, _0; + zval name; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&index_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ARRAY(collection) - Z_PARAM_ZVAL(index) + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &collection_param, &index); - zephir_get_arrval(&collection, collection_param); - RETURN_MM_BOOL(zephir_array_key_exists(&collection, index)); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_IsUnique) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, IsUnique, phalcon, support_helper_arr_isunique, phalcon_support_helper_arr_isunique_method_entry, 0); - - return SUCCESS; + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + RETURN_MM_BOOL(zephir_array_isset(&_0, &name)); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_IsUnique, __invoke) +static PHP_METHOD(Phalcon_Forms_Form, hasMessagesFor) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, _0; - zval collection; + zval *name_param = NULL, _0, _1; + zval name; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&name); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(collection) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &collection_param); - zephir_get_arrval(&collection, collection_param); - ZEPHIR_CALL_FUNCTION(&_0, "array_unique", NULL, 180, &collection); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmessagesfor", NULL, 0, &name); zephir_check_call_status(); - RETURN_MM_BOOL(zephir_fast_count_int(&collection) == zephir_fast_count_int(&_0)); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Last) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Arr, Last, phalcon, support_helper_arr_last, phalcon_support_helper_arr_abstractarr_ce, phalcon_support_helper_arr_last_method_entry, 0); - - return SUCCESS; + ZEPHIR_CALL_METHOD(&_1, &_0, "count", NULL, 0); + zephir_check_call_status(); + RETURN_MM_BOOL(ZEPHIR_GT_LONG(&_1, 0)); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_Last, __invoke) +static PHP_METHOD(Phalcon_Forms_Form, isValid) { + zend_object_iterator *_18$$20; + zend_bool validationStatus = 0, _3, _7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_13 = NULL, *_14 = NULL, *_21 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, *method = NULL, method_sub, __$null, filtered; - zval collection; + zval whitelist; + zval *data = NULL, data_sub, *entity = NULL, entity_sub, *whitelist_param = NULL, __$null, messages, element, validators, name, filters, validator, validation, elementMessage, _0, _4, _8, *_9, _10, _17, _1$$4, _2$$5, _5$$6, _6$$7, *_11$$10, _12$$10, *_15$$15, _16$$15, _19$$21, _20$$21; zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&method_sub); + ZVAL_UNDEF(&data_sub); + ZVAL_UNDEF(&entity_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&filtered); + ZVAL_UNDEF(&messages); + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&validators); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&filters); + ZVAL_UNDEF(&validator); + ZVAL_UNDEF(&validation); + ZVAL_UNDEF(&elementMessage); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_17); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_12$$10); + ZVAL_UNDEF(&_16$$15); + ZVAL_UNDEF(&_19$$21); + ZVAL_UNDEF(&_20$$21); + ZVAL_UNDEF(&whitelist); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(collection) + ZEND_PARSE_PARAMETERS_START(0, 3) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(method) + Z_PARAM_ZVAL_OR_NULL(data) + Z_PARAM_ZVAL_OR_NULL(entity) + Z_PARAM_ARRAY(whitelist) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &collection_param, &method); - zephir_get_arrval(&collection, collection_param); - if (!method) { - method = &method_sub; - method = &__$null; + zephir_fetch_params(1, 0, 3, &data, &entity, &whitelist_param); + if (!data) { + data = &data_sub; + ZEPHIR_CPY_WRT(data, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(data); } - ZEPHIR_CALL_METHOD(&filtered, this_ptr, "tofilter", NULL, 0, &collection, method); + if (!entity) { + entity = &entity_sub; + ZEPHIR_CPY_WRT(entity, &__$null); + } else { + ZEPHIR_SEPARATE_PARAM(entity); + } + if (!whitelist_param) { + ZEPHIR_INIT_VAR(&whitelist); + array_init(&whitelist); + } else { + zephir_get_arrval(&whitelist, whitelist_param); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_EMPTY(&_0)) { + RETURN_MM_BOOL(1); + } + if (ZEPHIR_IS_EMPTY(&whitelist)) { + zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("whitelist"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&whitelist, &_1$$4); + } + if (Z_TYPE_P(data) != IS_ARRAY) { + zephir_read_property(&_2$$5, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(data, &_2$$5); + } + _3 = Z_TYPE_P(entity) != IS_OBJECT; + if (_3) { + zephir_memory_observe(&_4); + zephir_read_property(&_4, this_ptr, ZEND_STRL("entity"), PH_NOISY_CC); + _3 = Z_TYPE_P(&_4) == IS_OBJECT; + } + if (_3) { + zephir_read_property(&_5$$6, this_ptr, ZEND_STRL("entity"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(entity, &_5$$6); + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "bind", NULL, 0, data, entity, &whitelist); zephir_check_call_status(); - ZEPHIR_MAKE_REF(&filtered); - ZEPHIR_RETURN_CALL_FUNCTION("end", NULL, 320, &filtered); - ZEPHIR_UNREF(&filtered); + if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("beforevalidation")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(&_6$$7, this_ptr, "beforevalidation", NULL, 0, data, entity); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_6$$7)) { + RETURN_MM_BOOL(0); + } + } + validationStatus = 1; + ZEPHIR_CALL_METHOD(&validation, this_ptr, "getvalidation", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + _7 = Z_TYPE_P(&validation) != IS_OBJECT; + if (!(_7)) { + _7 = !((zephir_instance_of_ev(&validation, phalcon_filter_validation_validationinterface_ce))); + } + if (_7) { + ZEPHIR_INIT_NVAR(&validation); + object_init_ex(&validation, phalcon_filter_validation_ce); + ZEPHIR_CALL_METHOD(NULL, &validation, "__construct", NULL, 315); + zephir_check_call_status(); + } + zephir_read_property(&_8, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_8, 0, "phalcon/Forms/Form.zep", 722); + if (Z_TYPE_P(&_8) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_8), _9) + { + ZEPHIR_INIT_NVAR(&element); + ZVAL_COPY(&element, _9); + ZEPHIR_CALL_METHOD(&validators, &element, "getvalidators", NULL, 0); + zephir_check_call_status(); + if (zephir_fast_count_int(&validators) == 0) { + continue; + } + ZEPHIR_CALL_METHOD(&name, &element, "getname", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&validators, 0, "phalcon/Forms/Form.zep", 709); + if (Z_TYPE_P(&validators) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&validators), _11$$10) + { + ZEPHIR_INIT_NVAR(&validator); + ZVAL_COPY(&validator, _11$$10); + ZEPHIR_CALL_METHOD(NULL, &validation, "add", &_13, 316, &name, &validator); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &validators, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_12$$10, &validators, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_12$$10)) { + break; + } + ZEPHIR_CALL_METHOD(&validator, &validators, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &validation, "add", &_13, 316, &name, &validator); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &validators, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&validator); + ZEPHIR_CALL_METHOD(&filters, &element, "getfilters", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&filters) == IS_ARRAY) { + ZEPHIR_CALL_METHOD(NULL, &validation, "setfilters", &_14, 317, &name, &filters); + zephir_check_call_status(); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_8, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_10, &_8, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_10)) { + break; + } + ZEPHIR_CALL_METHOD(&element, &_8, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&validators, &element, "getvalidators", NULL, 0); + zephir_check_call_status(); + if (zephir_fast_count_int(&validators) == 0) { + continue; + } + ZEPHIR_CALL_METHOD(&name, &element, "getname", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&validators, 0, "phalcon/Forms/Form.zep", 709); + if (Z_TYPE_P(&validators) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&validators), _15$$15) + { + ZEPHIR_INIT_NVAR(&validator); + ZVAL_COPY(&validator, _15$$15); + ZEPHIR_CALL_METHOD(NULL, &validation, "add", &_13, 316, &name, &validator); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &validators, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_16$$15, &validators, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_16$$15)) { + break; + } + ZEPHIR_CALL_METHOD(&validator, &validators, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &validation, "add", &_13, 316, &name, &validator); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &validators, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&validator); + ZEPHIR_CALL_METHOD(&filters, &element, "getfilters", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&filters) == IS_ARRAY) { + ZEPHIR_CALL_METHOD(NULL, &validation, "setfilters", &_14, 317, &name, &filters); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(NULL, &_8, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&element); + ZEPHIR_CALL_METHOD(&messages, &validation, "validate", NULL, 318, data, entity); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_17, &messages, "count", NULL, 0); + zephir_check_call_status(); + if (zephir_is_true(&_17)) { + _18$$20 = zephir_get_iterator(&messages); + _18$$20->funcs->rewind(_18$$20); + for (;_18$$20->funcs->valid(_18$$20) == SUCCESS && !EG(exception); _18$$20->funcs->move_forward(_18$$20)) { + { + ZEPHIR_ITERATOR_COPY(&elementMessage, _18$$20); + } + ZEPHIR_CALL_METHOD(&_20$$21, &elementMessage, "getfield", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_19$$21, this_ptr, "get", &_21, 0, &_20$$21); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_19$$21, "appendmessage", NULL, 0, &elementMessage); + zephir_check_call_status(); + } + zend_iterator_dtor(_18$$20); + ZEPHIR_CALL_METHOD(NULL, &messages, "rewind", NULL, 0); + zephir_check_call_status(); + validationStatus = 0; + } + if (!(validationStatus)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), &messages); + } + if ((zephir_method_exists_ex(this_ptr, ZEND_STRL("aftervalidation")) == SUCCESS)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "aftervalidation", NULL, 0, &messages); + zephir_check_call_status(); + } + RETURN_MM_BOOL(validationStatus); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_LastKey) +static PHP_METHOD(Phalcon_Forms_Form, key) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Arr, LastKey, phalcon, support_helper_arr_lastkey, phalcon_support_helper_arr_abstractarr_ce, phalcon_support_helper_arr_lastkey_method_entry, 0); - return SUCCESS; + RETURN_MEMBER(getThis(), "position"); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_LastKey, __invoke) +static PHP_METHOD(Phalcon_Forms_Form, label) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, *method = NULL, method_sub, __$null, filtered; - zval collection; + zval attributes; + zval *name_param = NULL, *attributes_param = NULL, element, _0, _1$$3; + zval name, _2$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&method_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&filtered); - bool is_null_true = 1; + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&attributes); ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(collection) + Z_PARAM_STR(name) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(method) + Z_PARAM_ARRAY(attributes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &collection_param, &method); - zephir_get_arrval(&collection, collection_param); - if (!method) { - method = &method_sub; - method = &__$null; + zephir_fetch_params(1, 1, 1, &name_param, &attributes_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_CALL_METHOD(&filtered, this_ptr, "tofilter", NULL, 0, &collection, method); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_FUNCTION("array_key_last", NULL, 40, &filtered); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + zephir_memory_observe(&element); + zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(!(zephir_array_isset_fetch(&element, &_0, &name, 0)))) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_forms_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + ZEPHIR_CONCAT_SVS(&_2$$3, "Element with ID=", &name, " is not part of the form"); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Forms/Form.zep", 772); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_RETURN_CALL_METHOD(&element, "label", NULL, 0, &attributes); zephir_check_call_status(); RETURN_MM(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Order) +static PHP_METHOD(Phalcon_Forms_Form, next) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, Order, phalcon, support_helper_arr_order, phalcon_support_helper_arr_order_method_entry, 0); - - zephir_declare_class_constant_long(phalcon_support_helper_arr_order_ce, SL("ORDER_ASC"), 1); - - zephir_declare_class_constant_long(phalcon_support_helper_arr_order_ce, SL("ORDER_DESC"), 2); - - return SUCCESS; + zval *this_ptr = getThis(); + RETURN_ON_FAILURE(zephir_property_incr(this_ptr, SL("position"))); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_Order, __invoke) +static PHP_METHOD(Phalcon_Forms_Form, render) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL, *_4 = NULL; - zend_long order, flags, ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, *attribute, attribute_sub, *order_param = NULL, *flags_param = NULL, item, sorted, *_0, _1, _2$$3, _5$$4, _6$$5, _7$$6; - zval collection; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval attributes; + zval *name_param = NULL, *attributes_param = NULL, element, _0, _1$$3; + zval name, _2$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&attribute_sub); - ZVAL_UNDEF(&item); - ZVAL_UNDEF(&sorted); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&name); ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_7$$6); - ZEND_PARSE_PARAMETERS_START(2, 4) - Z_PARAM_ARRAY(collection) - Z_PARAM_ZVAL(attribute) + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&attributes); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(name) Z_PARAM_OPTIONAL - Z_PARAM_LONG(order) - Z_PARAM_LONG(flags) + Z_PARAM_ARRAY(attributes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 2, &collection_param, &attribute, &order_param, &flags_param); - zephir_get_arrval(&collection, collection_param); - if (!order_param) { - order = 1; - } else { - } - if (!flags_param) { - flags = 0; - } else { - } - ZEPHIR_INIT_VAR(&sorted); - array_init(&sorted); - zephir_is_iterable(&collection, 0, "phalcon/Support/Helper/Arr/Order.zep", 45); - if (Z_TYPE_P(&collection) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&collection), _0) - { - ZEPHIR_INIT_NVAR(&item); - ZVAL_COPY(&item, _0); - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "checkobject", &_3, 0, &sorted, attribute, &item); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&sorted, &_2$$3); - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "checknonobject", &_4, 0, &sorted, attribute, &item); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&sorted, &_2$$3); - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 1, 1, &name_param, &attributes_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - ZEPHIR_CALL_METHOD(NULL, &collection, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &collection, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&item, &collection, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_5$$4, this_ptr, "checkobject", &_3, 0, &sorted, attribute, &item); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&sorted, &_5$$4); - ZEPHIR_CALL_METHOD(&_5$$4, this_ptr, "checknonobject", &_4, 0, &sorted, attribute, &item); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&sorted, &_5$$4); - ZEPHIR_CALL_METHOD(NULL, &collection, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&name); } - ZEPHIR_INIT_NVAR(&item); - if (1 == order) { - ZVAL_LONG(&_6$$5, flags); - ZEPHIR_MAKE_REF(&sorted); - ZEPHIR_CALL_FUNCTION(NULL, "ksort", NULL, 0, &sorted, &_6$$5); - ZEPHIR_UNREF(&sorted); - zephir_check_call_status(); + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); } else { - ZVAL_LONG(&_7$$6, flags); - ZEPHIR_MAKE_REF(&sorted); - ZEPHIR_CALL_FUNCTION(NULL, "krsort", NULL, 0, &sorted, &_7$$6); - ZEPHIR_UNREF(&sorted); + zephir_get_arrval(&attributes, attributes_param); + } + zephir_memory_observe(&element); + zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(!(zephir_array_isset_fetch(&element, &_0, &name, 0)))) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_forms_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + ZEPHIR_CONCAT_SVS(&_2$$3, "Element with ID=", &name, " is not part of the form"); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3); zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Forms/Form.zep", 796); + ZEPHIR_MM_RESTORE(); + return; } - ZEPHIR_RETURN_CALL_FUNCTION("array_values", NULL, 14, &sorted); + ZEPHIR_RETURN_CALL_METHOD(&element, "render", NULL, 0, &attributes); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_Order, checkObject) +static PHP_METHOD(Phalcon_Forms_Form, remove) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *sorted_param = NULL, *attribute, attribute_sub, *item, item_sub, key; - zval sorted; + zval *name_param = NULL, __$null, _0, _1$$3; + zval name; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&sorted); - ZVAL_UNDEF(&attribute_sub); - ZVAL_UNDEF(&item_sub); - ZVAL_UNDEF(&key); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ARRAY(sorted) - Z_PARAM_ZVAL(attribute) - Z_PARAM_ZVAL(item) + ZVAL_UNDEF(&name); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &sorted_param, &attribute, &item); - zephir_get_arrval(&sorted, sorted_param); - if (Z_TYPE_P(item) == IS_OBJECT) { - zephir_memory_observe(&key); - zephir_read_property_zval(&key, item, attribute, PH_NOISY_CC); - zephir_array_update_zval(&sorted, &key, item, PH_COPY | PH_SEPARATE); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); } - RETURN_CTOR(&sorted); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset(&_0, &name)) { + zephir_unset_property_array(this_ptr, ZEND_STRL("elements"), &name); + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + zephir_array_unset(&_1$$3, &name, PH_SEPARATE); + RETURN_MM_BOOL(1); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("elementsIndexed"), &__$null); + RETURN_MM_BOOL(0); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_Order, checkNonObject) +static PHP_METHOD(Phalcon_Forms_Form, rewind) { + zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *sorted_param = NULL, *attribute, attribute_sub, *item, item_sub, key; - zval sorted; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&sorted); - ZVAL_UNDEF(&attribute_sub); - ZVAL_UNDEF(&item_sub); - ZVAL_UNDEF(&key); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ARRAY(sorted) - Z_PARAM_ZVAL(attribute) - Z_PARAM_ZVAL(item) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &sorted_param, &attribute, &item); - zephir_get_arrval(&sorted, sorted_param); - if (Z_TYPE_P(item) != IS_OBJECT) { - zephir_memory_observe(&key); - zephir_array_fetch(&key, item, attribute, PH_NOISY, "phalcon/Support/Helper/Arr/Order.zep", 85); - zephir_array_update_zval(&sorted, &key, item, PH_COPY | PH_SEPARATE); - } - RETURN_CTOR(&sorted); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Pluck) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, Pluck, phalcon, support_helper_arr_pluck, phalcon_support_helper_arr_pluck_method_entry, 0); - - return SUCCESS; + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, 0); + zephir_update_property_zval(this_ptr, ZEND_STRL("position"), &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&_1, "array_values", NULL, 14, &_0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("elementsIndexed"), &_1); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_Pluck, __invoke) +static PHP_METHOD(Phalcon_Forms_Form, setAction) { - zend_bool _2$$3, _3$$3, _6$$6, _7$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval element; - zval *collection_param = NULL, *element_param = NULL, item, *_0, _1, _4$$4, _5$$5, _8$$7, _9$$8; - zval collection, filtered; + zval *action_param = NULL, _0, _1; + zval action; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&filtered); - ZVAL_UNDEF(&item); + ZVAL_UNDEF(&action); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_8$$7); - ZVAL_UNDEF(&_9$$8); - ZVAL_UNDEF(&element); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ARRAY(collection) - Z_PARAM_STR(element) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(action) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &collection_param, &element_param); - zephir_get_arrval(&collection, collection_param); - zephir_get_strval(&element, element_param); - ZEPHIR_INIT_VAR(&filtered); - array_init(&filtered); - zephir_is_iterable(&collection, 0, "phalcon/Support/Helper/Arr/Pluck.zep", 39); - if (Z_TYPE_P(&collection) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&collection), _0) - { - ZEPHIR_INIT_NVAR(&item); - ZVAL_COPY(&item, _0); - _2$$3 = Z_TYPE_P(&item) == IS_OBJECT; - if (_2$$3) { - _2$$3 = zephir_isset_property_zval(&item, &element); - } - _3$$3 = Z_TYPE_P(&item) == IS_ARRAY; - if (_3$$3) { - _3$$3 = zephir_array_isset(&item, &element); - } - if (_2$$3) { - ZEPHIR_OBS_NVAR(&_4$$4); - zephir_read_property_zval(&_4$$4, &item, &element, PH_NOISY_CC); - zephir_array_append(&filtered, &_4$$4, PH_SEPARATE, "phalcon/Support/Helper/Arr/Pluck.zep", 33); - } else if (_3$$3) { - zephir_array_fetch(&_5$$5, &item, &element, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Arr/Pluck.zep", 35); - zephir_array_append(&filtered, &_5$$5, PH_SEPARATE, "phalcon/Support/Helper/Arr/Pluck.zep", 35); - } - } ZEND_HASH_FOREACH_END(); + zephir_fetch_params(1, 1, 0, &action_param); + if (UNEXPECTED(Z_TYPE_P(action_param) != IS_STRING && Z_TYPE_P(action_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'action' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(action_param) == IS_STRING)) { + zephir_get_strval(&action, action_param); } else { - ZEPHIR_CALL_METHOD(NULL, &collection, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &collection, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&item, &collection, "current", NULL, 0); - zephir_check_call_status(); - _6$$6 = Z_TYPE_P(&item) == IS_OBJECT; - if (_6$$6) { - _6$$6 = zephir_isset_property_zval(&item, &element); - } - _7$$6 = Z_TYPE_P(&item) == IS_ARRAY; - if (_7$$6) { - _7$$6 = zephir_array_isset(&item, &element); - } - if (_6$$6) { - ZEPHIR_OBS_NVAR(&_8$$7); - zephir_read_property_zval(&_8$$7, &item, &element, PH_NOISY_CC); - zephir_array_append(&filtered, &_8$$7, PH_SEPARATE, "phalcon/Support/Helper/Arr/Pluck.zep", 33); - } else if (_7$$6) { - zephir_array_fetch(&_9$$8, &item, &element, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Arr/Pluck.zep", 35); - zephir_array_append(&filtered, &_9$$8, PH_SEPARATE, "phalcon/Support/Helper/Arr/Pluck.zep", 35); - } - ZEPHIR_CALL_METHOD(NULL, &collection, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&action); } - ZEPHIR_INIT_NVAR(&item); - RETURN_CTOR(&filtered); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getattributes", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "action"); + ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &_1, &action); + zephir_check_call_status(); + RETURN_THIS(); } +static PHP_METHOD(Phalcon_Forms_Form, setAttributes) +{ + zval *attributes, attributes_sub; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&attributes_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(attributes, phalcon_html_attributes_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &attributes); + zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), attributes); + RETURN_THISW(); +} +static PHP_METHOD(Phalcon_Forms_Form, setEntity) +{ + zval *entity, entity_sub; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H -#endif - - + ZVAL_UNDEF(&entity_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(entity) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &entity); + zephir_update_property_zval(this_ptr, ZEND_STRL("entity"), entity); + RETURN_THISW(); +} +static PHP_METHOD(Phalcon_Forms_Form, setTagFactory) +{ + zval *tagFactory, tagFactory_sub; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&tagFactory_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(tagFactory, phalcon_html_tagfactory_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &tagFactory); + zephir_update_property_zval(this_ptr, ZEND_STRL("tagFactory"), tagFactory); + RETURN_THISW(); +} -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Set) +static PHP_METHOD(Phalcon_Forms_Form, setValidation) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, Set, phalcon, support_helper_arr_set, phalcon_support_helper_arr_set_method_entry, 0); + zval *validation, validation_sub; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&validation_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(validation, phalcon_filter_validation_validationinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &validation); + zephir_update_property_zval(this_ptr, ZEND_STRL("validation"), validation); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_Set, __invoke) +static PHP_METHOD(Phalcon_Forms_Form, setWhitelist) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, *value, value_sub, *index = NULL, index_sub, __$null, source; - zval collection; + zval *whitelist_param = NULL; + zval whitelist; zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&index_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&source); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_ARRAY(collection) - Z_PARAM_ZVAL(value) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(index) + ZVAL_UNDEF(&whitelist); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(whitelist) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &collection_param, &value, &index); - zephir_get_arrval(&collection, collection_param); - if (!index) { - index = &index_sub; - index = &__$null; - } - ZEPHIR_CALL_METHOD(&source, this_ptr, "checknull", NULL, 0, &collection, value, index); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "checknotnull", NULL, 0, &source, value, index); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &whitelist_param); + zephir_get_arrval(&whitelist, whitelist_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("whitelist"), &whitelist); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_Set, checkNull) +static PHP_METHOD(Phalcon_Forms_Form, setUserOption) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *collection_param = NULL, *value, value_sub, *index, index_sub; - zval collection; + zval *option_param = NULL, *value, value_sub; + zval option; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&option); ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&index_sub); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ARRAY(collection) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(option) Z_PARAM_ZVAL(value) - Z_PARAM_ZVAL(index) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &collection_param, &value, &index); - zephir_get_arrval(&collection, collection_param); - if (Z_TYPE_P(index) == IS_NULL) { - zephir_array_append(&collection, value, PH_SEPARATE, "phalcon/Support/Helper/Arr/Set.zep", 47); - } - RETURN_CTOR(&collection); + zephir_fetch_params(1, 2, 0, &option_param, &value); + zephir_get_strval(&option, option_param); + zephir_update_property_array(this_ptr, SL("options"), &option, value); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_Set, checkNotNull) +static PHP_METHOD(Phalcon_Forms_Form, setUserOptions) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *collection_param = NULL, *value, value_sub, *index, index_sub; - zval collection; + zval *options_param = NULL; + zval options; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&index_sub); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ARRAY(collection) - Z_PARAM_ZVAL(value) - Z_PARAM_ZVAL(index) + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &collection_param, &value, &index); - zephir_get_arrval(&collection, collection_param); - if (Z_TYPE_P(index) != IS_NULL) { - zephir_array_update_zval(&collection, index, value, PH_COPY | PH_SEPARATE); - } - RETURN_CTOR(&collection); + zephir_fetch_params(1, 1, 0, &options_param); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); + RETURN_THIS(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_SliceLeft) +static PHP_METHOD(Phalcon_Forms_Form, valid) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, SliceLeft, phalcon, support_helper_arr_sliceleft, phalcon_support_helper_arr_sliceleft_method_entry, 0); + zval _0, _1; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + zephir_read_property(&_0, this_ptr, ZEND_STRL("elementsIndexed"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_1, this_ptr, ZEND_STRL("position"), PH_NOISY_CC | PH_READONLY); + RETURN_BOOL(zephir_array_isset(&_0, &_1)); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_SliceLeft, __invoke) +zend_object *zephir_init_properties_Phalcon_Forms_Form(zend_class_entry *class_type) { + zval _0, _2, _4, _6, _8, _10, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long elements, ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, *elements_param = NULL, _0, _1; - zval collection; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_9$$7); + ZVAL_UNDEF(&_11$$8); + - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(collection) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(elements) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &collection_param, &elements_param); - zephir_get_arrval(&collection, collection_param); - if (!elements_param) { - elements = 1; - } else { + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("whitelist"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("whitelist"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("elementsIndexed"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("elementsIndexed"), &_5$$5); + } + zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("elements"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_6) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$6); + array_init(&_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("elements"), &_7$$6); + } + zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("filteredData"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_8) == IS_NULL) { + ZEPHIR_INIT_VAR(&_9$$7); + array_init(&_9$$7); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("filteredData"), &_9$$7); + } + zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("data"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_10) == IS_NULL) { + ZEPHIR_INIT_VAR(&_11$$8); + array_init(&_11$$8); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("data"), &_11$$8); } - ZVAL_LONG(&_0, 0); - ZVAL_LONG(&_1, elements); - ZEPHIR_RETURN_CALL_FUNCTION("array_slice", NULL, 501, &collection, &_0, &_1); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } } @@ -148372,118 +147145,150 @@ static PHP_METHOD(Phalcon_Support_Helper_Arr_SliceLeft, __invoke) -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_SliceRight) +ZEPHIR_INIT_CLASS(Phalcon_Forms_Manager) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, SliceRight, phalcon, support_helper_arr_sliceright, phalcon_support_helper_arr_sliceright_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Forms, Manager, phalcon, forms_manager, phalcon_forms_manager_method_entry, 0); + + zend_declare_property_null(phalcon_forms_manager_ce, SL("forms"), ZEND_ACC_PROTECTED); + phalcon_forms_manager_ce->create_object = zephir_init_properties_Phalcon_Forms_Manager; return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Helper_Arr_SliceRight, __invoke) +static PHP_METHOD(Phalcon_Forms_Manager, create) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long elements, ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, *elements_param = NULL, _0; - zval collection; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, *entity = NULL, entity_sub, __$null, form; + zval name; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&entity_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&form); + bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(collection) + Z_PARAM_STR(name) Z_PARAM_OPTIONAL - Z_PARAM_LONG(elements) + Z_PARAM_ZVAL_OR_NULL(entity) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &collection_param, &elements_param); - zephir_get_arrval(&collection, collection_param); - if (!elements_param) { - elements = 1; - } else { - } - ZVAL_LONG(&_0, elements); - ZEPHIR_RETURN_CALL_FUNCTION("array_slice", NULL, 501, &collection, &_0); + zephir_fetch_params(1, 1, 1, &name_param, &entity); + zephir_get_strval(&name, name_param); + if (!entity) { + entity = &entity_sub; + entity = &__$null; + } + ZEPHIR_INIT_VAR(&form); + object_init_ex(&form, phalcon_forms_form_ce); + ZEPHIR_CALL_METHOD(NULL, &form, "__construct", NULL, 319, entity); zephir_check_call_status(); - RETURN_MM(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Split) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, Split, phalcon, support_helper_arr_split, phalcon_support_helper_arr_split_method_entry, 0); - - return SUCCESS; + zephir_update_property_array(this_ptr, SL("forms"), &name, &form); + RETURN_CCTOR(&form); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_Split, __invoke) +static PHP_METHOD(Phalcon_Forms_Manager, get) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, _0, _1; - zval collection; + zval *name_param = NULL, form, _0, _1$$3; + zval name, _2$$3; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&form); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_1$$3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(collection) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &collection_param); - zephir_get_arrval(&collection, collection_param); - zephir_create_array(return_value, 2, 0); - ZEPHIR_INIT_VAR(&_0); - zephir_array_keys(&_0, &collection); - zephir_array_fast_append(return_value, &_0); - ZEPHIR_CALL_FUNCTION(&_1, "array_values", NULL, 14, &collection); - zephir_check_call_status(); - zephir_array_fast_append(return_value, &_1); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); + zephir_memory_observe(&form); + zephir_read_property(&_0, this_ptr, ZEND_STRL("forms"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(!(zephir_array_isset_fetch(&form, &_0, &name, 0)))) { + ZEPHIR_INIT_VAR(&_1$$3); + object_init_ex(&_1$$3, phalcon_forms_exception_ce); + ZEPHIR_INIT_VAR(&_2$$3); + ZEPHIR_CONCAT_SVS(&_2$$3, "There is no form with name='", &name, "'"); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 33, &_2$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Forms/Manager.zep", 46); + ZEPHIR_MM_RESTORE(); + return; + } + RETURN_CCTOR(&form); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_ToObject) +static PHP_METHOD(Phalcon_Forms_Manager, has) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Arr, ToObject, phalcon, support_helper_arr_toobject, phalcon_support_helper_arr_toobject_method_entry, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *name_param = NULL, _0; + zval name; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("forms"), PH_NOISY_CC | PH_READONLY); + RETURN_MM_BOOL(zephir_array_isset(&_0, &name)); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_ToObject, __invoke) +static PHP_METHOD(Phalcon_Forms_Manager, set) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *collection_param = NULL; - zval collection; + zval *name_param = NULL, *form, form_sub; + zval name; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(collection) + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&form_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_OBJECT_OF_CLASS(form, phalcon_forms_form_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &collection_param); - zephir_get_arrval(&collection, collection_param); - zephir_convert_to_object(&collection); - RETURN_CTOR(&collection); + zephir_fetch_params(1, 2, 0, &name_param, &form); + zephir_get_strval(&name, name_param); + zephir_update_property_array(this_ptr, SL("forms"), &name, form); + RETURN_THIS(); +} + +zend_object *zephir_init_properties_Phalcon_Forms_Manager(zend_class_entry *class_type) +{ + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("forms"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("forms"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); + } } @@ -148496,756 +147301,872 @@ static PHP_METHOD(Phalcon_Support_Helper_Arr_ToObject, __invoke) -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_ValidateAll) +ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_AbstractElement) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Arr, ValidateAll, phalcon, support_helper_arr_validateall, phalcon_support_helper_arr_abstractarr_ce, phalcon_support_helper_arr_validateall_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Forms\\Element, AbstractElement, phalcon, forms_element_abstractelement, phalcon_forms_element_abstractelement_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + + zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("attributes"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("filters"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("form"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("label"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_forms_element_abstractelement_ce, SL("method"), "inputText", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("messages"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("name"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("options"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("tagFactory"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("validators"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_forms_element_abstractelement_ce, SL("value"), ZEND_ACC_PROTECTED); + phalcon_forms_element_abstractelement_ce->create_object = zephir_init_properties_Phalcon_Forms_Element_AbstractElement; + zend_class_implements(phalcon_forms_element_abstractelement_ce, 1, phalcon_forms_element_elementinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Helper_Arr_ValidateAll, __invoke) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, *method, method_sub, _0; - zval collection; + zval attributes; + zval *name_param = NULL, *attributes_param = NULL, _0, _1; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&method_sub); + ZVAL_UNDEF(&name); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ARRAY(collection) - Z_PARAM_ZVAL(method) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&attributes); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(name) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(attributes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &collection_param, &method); - zephir_get_arrval(&collection, collection_param); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "tofilter", NULL, 0, &collection, method); + zephir_fetch_params(1, 1, 1, &name_param, &attributes_param); + zephir_get_strval(&name, name_param); + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + ZEPHIR_INIT_VAR(&_0); + zephir_fast_trim(&_0, &name, NULL , ZEPHIR_TRIM_BOTH); + zephir_get_strval(&name, &_0); + if (UNEXPECTED(ZEPHIR_IS_EMPTY(&name))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Form element name is required", "phalcon/Forms/Element/AbstractElement.zep", 97); + return; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); + zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &attributes); + ZEPHIR_INIT_VAR(&_1); + object_init_ex(&_1, phalcon_messages_messages_ce); + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 8); zephir_check_call_status(); - RETURN_MM_BOOL(zephir_fast_count_int(&_0) == zephir_fast_count_int(&collection)); + zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), &_1); + ZEPHIR_MM_RESTORE(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_ValidateAny) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, __toString) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Arr, ValidateAny, phalcon, support_helper_arr_validateany, phalcon_support_helper_arr_abstractarr_ce, phalcon_support_helper_arr_validateany_method_entry, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - return SUCCESS; + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "render", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_ValidateAny, __invoke) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, addFilter) { + zval _1$$5, _2$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, *method, method_sub, _0; - zval collection; + zval *filter_param = NULL, filters, _0; + zval filter; zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&method_sub); + ZVAL_UNDEF(&filter); + ZVAL_UNDEF(&filters); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ARRAY(collection) - Z_PARAM_ZVAL(method) + ZVAL_UNDEF(&_1$$5); + ZVAL_UNDEF(&_2$$6); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(filter) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &collection_param, &method); - zephir_get_arrval(&collection, collection_param); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "tofilter", NULL, 0, &collection, method); - zephir_check_call_status(); - RETURN_MM_BOOL(zephir_fast_count_int(&_0) > 0); + zephir_fetch_params(1, 1, 0, &filter_param); + zephir_get_strval(&filter, filter_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("filters"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&filters, &_0); + if (Z_TYPE_P(&filters) == IS_ARRAY) { + zephir_update_property_array_append(this_ptr, SL("filters"), &filter); + } else { + if (Z_TYPE_P(&filters) == IS_STRING) { + ZEPHIR_INIT_VAR(&_1$$5); + zephir_create_array(&_1$$5, 2, 0); + zephir_array_fast_append(&_1$$5, &filters); + zephir_array_fast_append(&_1$$5, &filter); + zephir_update_property_zval(this_ptr, ZEND_STRL("filters"), &_1$$5); + } else { + ZEPHIR_INIT_VAR(&_2$$6); + zephir_create_array(&_2$$6, 1, 0); + zephir_array_fast_append(&_2$$6, &filter); + zephir_update_property_zval(this_ptr, ZEND_STRL("filters"), &_2$$6); + } + } + RETURN_THIS(); } +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, addValidator) +{ + zval *validator, validator_sub; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&validator_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(validator, phalcon_filter_validation_validatorinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &validator); + zephir_update_property_array_append(this_ptr, SL("validators"), validator); + RETURN_THISW(); +} - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Arr_Whitelist) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, addValidators) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Arr, Whitelist, phalcon, support_helper_arr_whitelist, phalcon_support_helper_arr_abstractarr_ce, phalcon_support_helper_arr_whitelist_method_entry, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_3 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool merge; + zval *validators_param = NULL, *merge_param = NULL, validator, *_1, _2, _0$$3; + zval validators; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&validators); + ZVAL_UNDEF(&validator); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_0$$3); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(validators) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(merge) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &validators_param, &merge_param); + ZEPHIR_OBS_COPY_OR_DUP(&validators, validators_param); + if (!merge_param) { + merge = 1; + } else { + } + if (UNEXPECTED(!merge)) { + ZEPHIR_INIT_VAR(&_0$$3); + array_init(&_0$$3); + zephir_update_property_zval(this_ptr, ZEND_STRL("validators"), &_0$$3); + } + zephir_is_iterable(&validators, 0, "phalcon/Forms/Element/AbstractElement.zep", 163); + if (Z_TYPE_P(&validators) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&validators), _1) + { + ZEPHIR_INIT_NVAR(&validator); + ZVAL_COPY(&validator, _1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addvalidator", &_3, 0, &validator); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &validators, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &validators, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&validator, &validators, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addvalidator", &_3, 0, &validator); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &validators, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&validator); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Support_Helper_Arr_Whitelist, __invoke) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, appendMessage) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *collection_param = NULL, *whiteList_param = NULL, filtered, _0, _1; - zval collection, whiteList; + zval *message, message_sub, _0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&whiteList); - ZVAL_UNDEF(&filtered); + ZVAL_UNDEF(&message_sub); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ARRAY(collection) - Z_PARAM_ARRAY(whiteList) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(message, phalcon_messages_messageinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &collection_param, &whiteList_param); - zephir_get_arrval(&collection, collection_param); - zephir_get_arrval(&whiteList, whiteList_param); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_INIT_NVAR(&_0); - zephir_create_closure_ex(&_0, NULL, phalcon_13__closure_ce, SL("__invoke")); - ZEPHIR_CALL_METHOD(&filtered, this_ptr, "tofilter", NULL, 0, &whiteList, &_0); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_1, "array_flip", NULL, 100, &filtered); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_FUNCTION("array_intersect_key", NULL, 2, &collection, &_1); + zephir_fetch_params(1, 1, 0, &message); + zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "appendmessage", NULL, 0, message); zephir_check_call_status(); - RETURN_MM(); + RETURN_THIS(); } +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, clear) +{ + zval form, _0, name; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&form); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&name); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_read_property(&_0, this_ptr, ZEND_STRL("form"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&form, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&name, &_0); + if (Z_TYPE_P(&form) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(NULL, &form, "clear", NULL, 0, &name); + zephir_check_call_status(); + } + RETURN_THIS(); +} -#ifdef HAVE_CONFIG_H -#endif +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getAttribute) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *attribute_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null, attributes, value, _0; + zval attribute; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(attribute) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(defaultValue) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &attribute_param, &defaultValue); + zephir_get_strval(&attribute, attribute_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&attributes, &_0); + zephir_memory_observe(&value); + if (!(zephir_array_isset_fetch(&value, &attributes, &attribute, 0))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + RETURN_CCTOR(&value); +} +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getAttributes) +{ + zval attributes, _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_read_property(&_0, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&attributes, &_0); + RETURN_CCTOR(&attributes); +} -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Number_IsBetween) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getDefault) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Number, IsBetween, phalcon, support_helper_number_isbetween, phalcon_support_helper_number_isbetween_method_entry, 0); - return SUCCESS; + RETURN_MEMBER(getThis(), "value"); } -static PHP_METHOD(Phalcon_Support_Helper_Number_IsBetween, __invoke) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getFilters) { - zend_bool _0; - zval *value_param = NULL, *start_param = NULL, *end_param = NULL; - zend_long value, start, end; - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_LONG(value) - Z_PARAM_LONG(start) - Z_PARAM_LONG(end) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(3, 0, &value_param, &start_param, &end_param); - _0 = value >= start; - if (_0) { - _0 = value <= end; - } - RETURN_BOOL(_0); + RETURN_MEMBER(getThis(), "filters"); } +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getForm) +{ + RETURN_MEMBER(getThis(), "form"); +} +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getLabel) +{ -#ifdef HAVE_CONFIG_H -#endif + RETURN_MEMBER(getThis(), "label"); +} +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getMessages) +{ + RETURN_MEMBER(getThis(), "messages"); +} +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getName) +{ + RETURN_MEMBER(getThis(), "name"); +} -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Json_Decode) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getTagFactory) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Json, Decode, phalcon, support_helper_json_decode, phalcon_support_helper_json_decode_method_entry, 0); - return SUCCESS; + RETURN_MEMBER(getThis(), "tagFactory"); } -static PHP_METHOD(Phalcon_Support_Helper_Json_Decode, __invoke) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getUserOption) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long depth, options, ZEPHIR_LAST_CALL_STATUS; - zend_bool associative; - zval *data_param = NULL, *associative_param = NULL, *depth_param = NULL, *options_param = NULL, __$null, decoded, error, message, _0, _1, _2, _3$$3, _4$$3; - zval data; + zval *option_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null, value, _0; + zval option; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&option); + ZVAL_UNDEF(&defaultValue_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&decoded); - ZVAL_UNDEF(&error); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&value); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$3); - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_STR(data) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(option) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(associative) - Z_PARAM_LONG(depth) - Z_PARAM_LONG(options) + Z_PARAM_ZVAL_OR_NULL(defaultValue) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 3, &data_param, &associative_param, &depth_param, &options_param); - zephir_get_strval(&data, data_param); - if (!associative_param) { - associative = 0; - } else { - } - if (!depth_param) { - depth = 512; - } else { - } - if (!options_param) { - options = 79; - } else { - } - ZEPHIR_INIT_VAR(&decoded); - zephir_json_encode(&decoded, &__$null, 0 ); - ZVAL_BOOL(&_0, (associative ? 1 : 0)); - ZVAL_LONG(&_1, depth); - ZVAL_LONG(&_2, options); - ZEPHIR_INIT_NVAR(&decoded); - zephir_json_decode(&decoded, &data, zephir_get_intval(&_0) ); - ZEPHIR_CALL_FUNCTION(&error, "json_last_error", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&message, "json_last_error_msg", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_LONG_IDENTICAL(&error, 0)) { - ZEPHIR_INIT_VAR(&_3$$3); - zephir_json_encode(&_3$$3, &__$null, 0 ); - ZEPHIR_INIT_VAR(&_4$$3); - object_init_ex(&_4$$3, spl_ce_InvalidArgumentException); - ZEPHIR_CALL_METHOD(NULL, &_4$$3, "__construct", NULL, 200, &message, &error); - zephir_check_call_status(); - zephir_throw_exception_debug(&_4$$3, "phalcon/Support/Helper/Json/Decode.zep", 64); - ZEPHIR_MM_RESTORE(); - return; + zephir_fetch_params(1, 1, 1, &option_param, &defaultValue); + zephir_get_strval(&option, option_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; } - RETURN_CCTOR(&decoded); + zephir_memory_observe(&value); + zephir_read_property(&_0, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&value, &_0, &option, 0))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + RETURN_CCTOR(&value); } +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getUserOptions) +{ + RETURN_MEMBER(getThis(), "options"); +} - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Json_Encode) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getValidators) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Json, Encode, phalcon, support_helper_json_encode, phalcon_support_helper_json_encode_method_entry, 0); - return SUCCESS; + RETURN_MEMBER(getThis(), "validators"); } -static PHP_METHOD(Phalcon_Support_Helper_Json_Encode, __invoke) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getValue) { - zval _4; + zval name, _0, form, value, _1$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long options, depth, ZEPHIR_LAST_CALL_STATUS; - zval *data, data_sub, *options_param = NULL, *depth_param = NULL, __$null, encoded, error, message, _0, _1, _2$$3, _3$$3; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&data_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&encoded); - ZVAL_UNDEF(&error); - ZVAL_UNDEF(&message); + ZVAL_UNDEF(&name); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ZVAL(data) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(options) - Z_PARAM_LONG(depth) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&form); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_1$$4); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &data, &options_param, &depth_param); - if (!options_param) { - options = 79; - } else { - } - if (!depth_param) { - depth = 512; - } else { - } - ZEPHIR_INIT_VAR(&encoded); - zephir_json_encode(&encoded, &__$null, 0 ); - ZVAL_LONG(&_0, options); - ZVAL_LONG(&_1, depth); - ZEPHIR_INIT_NVAR(&encoded); - zephir_json_encode(&encoded, data, zephir_get_intval(&_0) ); - ZEPHIR_CALL_FUNCTION(&error, "json_last_error", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&message, "json_last_error_msg", NULL, 0); - zephir_check_call_status(); - if (!ZEPHIR_IS_LONG_IDENTICAL(&error, 0)) { - ZEPHIR_INIT_VAR(&_2$$3); - zephir_json_encode(&_2$$3, &__$null, 0 ); - ZEPHIR_INIT_VAR(&_3$$3); - object_init_ex(&_3$$3, spl_ce_InvalidArgumentException); - ZEPHIR_CALL_METHOD(NULL, &_3$$3, "__construct", NULL, 200, &message, &error); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&name, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("form"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&form, &_0); + ZEPHIR_INIT_VAR(&value); + ZVAL_NULL(&value); + if (Z_TYPE_P(&form) == IS_OBJECT) { + ZEPHIR_RETURN_CALL_METHOD(&form, "getvalue", NULL, 0, &name); zephir_check_call_status(); - zephir_throw_exception_debug(&_3$$3, "phalcon/Support/Helper/Json/Encode.zep", 64); - ZEPHIR_MM_RESTORE(); - return; + RETURN_MM(); } - zephir_cast_to_string(&_4, &encoded); - RETURN_CTOR(&_4); + if (Z_TYPE_P(&value) == IS_NULL) { + zephir_read_property(&_1$$4, this_ptr, ZEND_STRL("value"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&value, &_1$$4); + } + RETURN_CCTOR(&value); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_AbstractStr) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, hasMessages) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, AbstractStr, phalcon, support_helper_str_abstractstr, phalcon_support_helper_str_abstractstr_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + zval _0; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + RETURN_BOOL(zephir_fast_count_int(&_0) > 0); } -static PHP_METHOD(Phalcon_Support_Helper_Str_AbstractStr, toEndsWith) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, label) { + zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool ignoreCase; - zval *haystack_param = NULL, *needle_param = NULL, *ignoreCase_param = NULL, child, parent, _0; - zval haystack, needle; + zval *attributes_param = NULL, code, internalAttributes, labelName, name, tagFactory, _0$$3; + zval attributes; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&haystack); - ZVAL_UNDEF(&needle); - ZVAL_UNDEF(&child); - ZVAL_UNDEF(&parent); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(haystack) - Z_PARAM_STR(needle) + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&code); + ZVAL_UNDEF(&internalAttributes); + ZVAL_UNDEF(&labelName); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&tagFactory); + ZVAL_UNDEF(&_0$$3); + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(ignoreCase) + Z_PARAM_ARRAY(attributes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &haystack_param, &needle_param, &ignoreCase_param); - zephir_get_strval(&haystack, haystack_param); - zephir_get_strval(&needle, needle_param); - if (!ignoreCase_param) { - ignoreCase = 1; + zephir_fetch_params(1, 0, 1, &attributes_param); + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, ""); - if (ZEPHIR_IS_IDENTICAL(&_0, &haystack)) { - RETURN_MM_BOOL(0); + zephir_get_arrval(&attributes, attributes_param); } - if (EXPECTED(ignoreCase)) { - ZEPHIR_CALL_FUNCTION(&child, "mb_strtolower", NULL, 10, &needle); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&parent, "mb_strtolower", NULL, 10, &haystack); - zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&child, &needle); - ZEPHIR_CPY_WRT(&parent, &haystack); + ZEPHIR_CALL_METHOD(&tagFactory, this_ptr, "getlocaltagfactory", NULL, 0); + zephir_check_call_status(); + zephir_memory_observe(&internalAttributes); + zephir_read_property(&internalAttributes, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC); + zephir_memory_observe(&name); + if (!(zephir_array_isset_string_fetch(&name, &internalAttributes, SL("id"), 0))) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&name, &_0$$3); } - RETURN_MM_BOOL(zephir_end_with(&parent, &child, NULL)); + if (!(zephir_array_isset_string(&attributes, SL("for")))) { + zephir_array_update_string(&attributes, SL("for"), &name, PH_COPY | PH_SEPARATE); + } + zephir_memory_observe(&labelName); + zephir_read_property(&labelName, this_ptr, ZEND_STRL("label"), PH_NOISY_CC); + _1 = zephir_is_true(&labelName); + if (!(_1)) { + _1 = zephir_is_numeric(&labelName); + } + if (!(_1)) { + ZEPHIR_CPY_WRT(&labelName, &name); + } + ZEPHIR_CALL_METHOD(&code, &tagFactory, "label", NULL, 0, &labelName, &attributes); + zephir_check_call_status(); + RETURN_CCTOR(&code); } -static PHP_METHOD(Phalcon_Support_Helper_Str_AbstractStr, toInterpolate) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, render) { - zend_string *_3; - zend_ulong _2; + zval _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval context; - zval *input_param = NULL, *context_param = NULL, *left_param = NULL, *right_param = NULL, key, replace, value, *_0, _1, _4$$4, _5$$5; - zval input, left, right; + zval *attributes_param = NULL, helper, merged, method, name, result, tagFactory, value, _0; + zval attributes; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&input); - ZVAL_UNDEF(&left); - ZVAL_UNDEF(&right); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&replace); + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&helper); + ZVAL_UNDEF(&merged); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&tagFactory); ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&context); - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_STR(input) + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) - Z_PARAM_STR(left) - Z_PARAM_STR(right) + Z_PARAM_ARRAY(attributes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 3, &input_param, &context_param, &left_param, &right_param); - zephir_get_strval(&input, input_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); - } else { - zephir_get_arrval(&context, context_param); - } - if (!left_param) { - ZEPHIR_INIT_VAR(&left); - ZVAL_STRING(&left, "%"); - } else { - zephir_get_strval(&left, left_param); - } - if (!right_param) { - ZEPHIR_INIT_VAR(&right); - ZVAL_STRING(&right, "%"); + zephir_fetch_params(1, 0, 1, &attributes_param); + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); } else { - zephir_get_strval(&right, right_param); - } - if (ZEPHIR_IS_EMPTY(&context)) { - RETURN_CTOR(&input); + zephir_get_arrval(&attributes, attributes_param); } - ZEPHIR_INIT_VAR(&replace); - array_init(&replace); - zephir_is_iterable(&context, 0, "phalcon/Support/Helper/Str/AbstractStr.zep", 82); - if (Z_TYPE_P(&context) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&context), _2, _3, _0) - { - ZEPHIR_INIT_NVAR(&key); - if (_3 != NULL) { - ZVAL_STR_COPY(&key, _3); - } else { - ZVAL_LONG(&key, _2); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0); - ZEPHIR_INIT_NVAR(&_4$$4); - ZEPHIR_CONCAT_VVV(&_4$$4, &left, &key, &right); - zephir_array_update_zval(&replace, &_4$$4, &value, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &context, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &context, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &context, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &context, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_5$$5); - ZEPHIR_CONCAT_VVV(&_5$$5, &left, &key, &right); - zephir_array_update_zval(&replace, &_5$$5, &value, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &context, "next", NULL, 0); - zephir_check_call_status(); - } + zephir_read_property(&_0, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&name, &_0); + ZEPHIR_CALL_METHOD(&value, this_ptr, "getvalue", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("method"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&method, &_0); + ZEPHIR_CALL_METHOD(&tagFactory, this_ptr, "getlocaltagfactory", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&helper, &tagFactory, "newinstance", NULL, 0, &method); + zephir_check_call_status(); + if (zephir_array_isset_string(&attributes, SL("value"))) { + ZEPHIR_OBS_NVAR(&value); + zephir_array_fetch_string(&value, &attributes, SL("value"), PH_NOISY, "phalcon/Forms/Element/AbstractElement.zep", 391); + zephir_array_unset_string(&attributes, SL("value"), PH_SEPARATE); } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - ZEPHIR_RETURN_CALL_FUNCTION("strtr", NULL, 5, &input, &replace); + zephir_read_property(&_0, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&merged); + zephir_fast_array_merge(&merged, &_0, &attributes); + ZEPHIR_CALL_METHOD(&result, &helper, "__invoke", NULL, 0, &name, &value, &merged); zephir_check_call_status(); - RETURN_MM(); + zephir_cast_to_string(&_1, &result); + RETURN_CTOR(&_1); } -static PHP_METHOD(Phalcon_Support_Helper_Str_AbstractStr, toLower) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setAttribute) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, *encoding_param = NULL, _0; - zval text, encoding; + zval *attribute_param = NULL, *value, value_sub; + zval attribute; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&encoding); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(text) - Z_PARAM_OPTIONAL - Z_PARAM_STR(encoding) + ZVAL_UNDEF(&attribute); + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(attribute) + Z_PARAM_ZVAL(value) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &text_param, &encoding_param); - zephir_get_strval(&text, text_param); - if (!encoding_param) { - ZEPHIR_INIT_VAR(&encoding); - ZVAL_STRING(&encoding, "UTF-8"); - } else { - zephir_get_strval(&encoding, encoding_param); - } - ZVAL_LONG(&_0, 1); - ZEPHIR_RETURN_CALL_FUNCTION("mb_convert_case", NULL, 12, &text, &_0, &encoding); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 2, 0, &attribute_param, &value); + zephir_get_strval(&attribute, attribute_param); + zephir_update_property_array(this_ptr, SL("attributes"), &attribute, value); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Support_Helper_Str_AbstractStr, toStartsWith) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setAttributes) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool ignoreCase; - zval *haystack_param = NULL, *needle_param = NULL, *ignoreCase_param = NULL, child, parent, _0; - zval haystack, needle; + zval *attributes_param = NULL; + zval attributes; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&haystack); - ZVAL_UNDEF(&needle); - ZVAL_UNDEF(&child); - ZVAL_UNDEF(&parent); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(haystack) - Z_PARAM_STR(needle) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(ignoreCase) + ZVAL_UNDEF(&attributes); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(attributes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &haystack_param, &needle_param, &ignoreCase_param); - zephir_get_strval(&haystack, haystack_param); - zephir_get_strval(&needle, needle_param); - if (!ignoreCase_param) { - ignoreCase = 1; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, ""); - if (ZEPHIR_IS_IDENTICAL(&_0, &haystack)) { - RETURN_MM_BOOL(0); - } - if (EXPECTED(ignoreCase)) { - ZEPHIR_CALL_FUNCTION(&child, "mb_strtolower", NULL, 10, &needle); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&parent, "mb_strtolower", NULL, 10, &haystack); - zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&child, &needle); - ZEPHIR_CPY_WRT(&parent, &haystack); - } - RETURN_MM_BOOL(zephir_start_with(&parent, &child, NULL)); + zephir_fetch_params(1, 1, 0, &attributes_param); + ZEPHIR_OBS_COPY_OR_DUP(&attributes, attributes_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("attributes"), &attributes); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setDefault) +{ + zval *value, value_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &value); + zephir_update_property_zval(this_ptr, ZEND_STRL("value"), value); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Support_Helper_Str_AbstractStr, toUpper) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setFilters) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, *encoding_param = NULL, _0; - zval text, encoding; + zend_bool _0; + zval *filters, filters_sub; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&encoding); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(text) - Z_PARAM_OPTIONAL - Z_PARAM_STR(encoding) + ZVAL_UNDEF(&filters_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(filters) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &text_param, &encoding_param); - zephir_get_strval(&text, text_param); - if (!encoding_param) { - ZEPHIR_INIT_VAR(&encoding); - ZVAL_STRING(&encoding, "UTF-8"); - } else { - zephir_get_strval(&encoding, encoding_param); + zephir_fetch_params_without_memory_grow(1, 0, &filters); + _0 = Z_TYPE_P(filters) != IS_STRING; + if (_0) { + _0 = Z_TYPE_P(filters) != IS_ARRAY; } - ZVAL_LONG(&_0, 0); - ZEPHIR_RETURN_CALL_FUNCTION("mb_convert_case", NULL, 12, &text, &_0, &encoding); - zephir_check_call_status(); - RETURN_MM(); + if (UNEXPECTED(_0)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STRW(phalcon_forms_exception_ce, "The filter needs to be an array or string", "phalcon/Forms/Element/AbstractElement.zep", 440); + return; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("filters"), filters); + RETURN_THISW(); } +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setForm) +{ + zval *form, form_sub; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&form_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(form, phalcon_forms_form_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &form); + zephir_update_property_zval(this_ptr, ZEND_STRL("form"), form); + RETURN_THISW(); +} +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setLabel) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *label_param = NULL; + zval label; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H -#endif - - - - + ZVAL_UNDEF(&label); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(label) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &label_param); + zephir_get_strval(&label, label_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("label"), &label); + RETURN_THIS(); +} -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Camelize) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setMessages) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, Camelize, phalcon, support_helper_str_camelize, phalcon_support_helper_str_pascalcase_ce, phalcon_support_helper_str_camelize_method_entry, 0); + zval *messages, messages_sub; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&messages_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(messages, phalcon_messages_messages_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &messages); + zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), messages); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Support_Helper_Str_Camelize, __invoke) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setName) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool lowerFirst; - zval *text_param = NULL, *delimiters_param = NULL, *lowerFirst_param = NULL, result, _0$$3; - zval text, delimiters; + zval *name_param = NULL; + zval name; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&delimiters); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0$$3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(text) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(delimiters) - Z_PARAM_BOOL(lowerFirst) + ZVAL_UNDEF(&name); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &text_param, &delimiters_param, &lowerFirst_param); - zephir_get_strval(&text, text_param); - if (!delimiters_param) { - ZEPHIR_INIT_VAR(&delimiters); - } else { - zephir_get_strval(&delimiters, delimiters_param); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); } - if (!lowerFirst_param) { - lowerFirst = 0; + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - } - ZEPHIR_CALL_PARENT(&result, phalcon_support_helper_str_camelize_ce, getThis(), "__invoke", NULL, 0, &text, &delimiters); - zephir_check_call_status(); - if (lowerFirst == 1) { - ZEPHIR_CALL_FUNCTION(&_0$$3, "lcfirst", NULL, 76, &result); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&result, &_0$$3); + ZEPHIR_INIT_VAR(&name); } - RETURN_CCTOR(&result); + zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); + RETURN_THIS(); } +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setTagFactory) +{ + zval *tagFactory, tagFactory_sub; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&tagFactory_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(tagFactory, phalcon_html_tagfactory_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &tagFactory); + zephir_update_property_zval(this_ptr, ZEND_STRL("tagFactory"), tagFactory); + RETURN_THISW(); +} +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setUserOption) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *option_param = NULL, *value, value_sub; + zval option; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H -#endif - - - - + ZVAL_UNDEF(&option); + ZVAL_UNDEF(&value_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(option) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &option_param, &value); + zephir_get_strval(&option, option_param); + zephir_update_property_array(this_ptr, SL("options"), &option, value); + RETURN_THIS(); +} -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Concat) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, setUserOptions) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, Concat, phalcon, support_helper_str_concat, phalcon_support_helper_str_abstractstr_ce, phalcon_support_helper_str_concat_method_entry, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *options_param = NULL; + zval options; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&options); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(options) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &options_param); + zephir_get_arrval(&options, options_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("options"), &options); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Support_Helper_Str_Concat, __invoke) +static PHP_METHOD(Phalcon_Forms_Element_AbstractElement, getLocalTagFactory) { - zval argument, arguments, delimiter, data, first, last, prefix, suffix, _0, _1, *_2, _3, _6, _4$$6, _5$$7; + zval container, escaper, tagFactory, _0, _1$$3, _2$$4, _3$$5, _4$$5, _5$$6, _6$$7, _7$$7, _8$$8; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&argument); - ZVAL_UNDEF(&arguments); - ZVAL_UNDEF(&delimiter); - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&first); - ZVAL_UNDEF(&last); - ZVAL_UNDEF(&prefix); - ZVAL_UNDEF(&suffix); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&escaper); + ZVAL_UNDEF(&tagFactory); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_4$$6); - ZVAL_UNDEF(&_5$$7); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_7$$7); + ZVAL_UNDEF(&_8$$8); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_INIT_VAR(&arguments); - zephir_get_args(&arguments); - if (UNEXPECTED(zephir_fast_count_int(&arguments) < 3)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_support_helper_exception_ce, "concat needs at least three parameters", "phalcon/Support/Helper/Str/Concat.zep", 37); - return; - } - ZEPHIR_MAKE_REF(&arguments); - ZEPHIR_CALL_FUNCTION(&delimiter, "reset", NULL, 477, &arguments); - ZEPHIR_UNREF(&arguments); - zephir_check_call_status(); - ZVAL_LONG(&_0, 1); - ZEPHIR_CALL_FUNCTION(&_1, "array_slice", NULL, 501, &arguments, &_0); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&arguments, &_1); - ZEPHIR_MAKE_REF(&arguments); - ZEPHIR_CALL_FUNCTION(&first, "reset", NULL, 477, &arguments); - ZEPHIR_UNREF(&arguments); - zephir_check_call_status(); - ZEPHIR_MAKE_REF(&arguments); - ZEPHIR_CALL_FUNCTION(&last, "end", NULL, 320, &arguments); - ZEPHIR_UNREF(&arguments); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&prefix); - ZVAL_STRING(&prefix, ""); - ZEPHIR_INIT_VAR(&suffix); - ZVAL_STRING(&suffix, ""); - ZEPHIR_INIT_VAR(&data); - array_init(&data); - if (zephir_start_with(&first, &delimiter, NULL)) { - ZEPHIR_CPY_WRT(&prefix, &delimiter); - } - if (zephir_end_with(&last, &delimiter, NULL)) { - ZEPHIR_CPY_WRT(&suffix, &delimiter); - } - zephir_is_iterable(&arguments, 0, "phalcon/Support/Helper/Str/Concat.zep", 61); - if (Z_TYPE_P(&arguments) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&arguments), _2) - { - ZEPHIR_INIT_NVAR(&argument); - ZVAL_COPY(&argument, _2); - ZEPHIR_INIT_NVAR(&_4$$6); - zephir_fast_trim(&_4$$6, &argument, &delimiter, ZEPHIR_TRIM_BOTH); - zephir_array_append(&data, &_4$$6, PH_SEPARATE, "phalcon/Support/Helper/Str/Concat.zep", 58); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &arguments, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &arguments, "valid", NULL, 0); + ZEPHIR_INIT_VAR(&tagFactory); + ZVAL_NULL(&tagFactory); + zephir_read_property(&_0, this_ptr, ZEND_STRL("tagFactory"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(ZEPHIR_IS_EMPTY(&_0))) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("form"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_1$$3) != IS_NULL) { + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("form"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&tagFactory, &_2$$4, "gettagfactory", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_3)) { - break; + } + if (Z_TYPE_P(&tagFactory) == IS_NULL) { + ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4$$5); + ZVAL_STRING(&_4$$5, "tag"); + ZEPHIR_CALL_METHOD(&_3$$5, &container, "has", NULL, 0, &_4$$5); + zephir_check_call_status(); + if (EXPECTED(ZEPHIR_IS_TRUE_IDENTICAL(&_3$$5))) { + ZEPHIR_INIT_VAR(&_5$$6); + ZVAL_STRING(&_5$$6, "tag"); + ZEPHIR_CALL_METHOD(&tagFactory, &container, "getshared", NULL, 0, &_5$$6); + zephir_check_call_status(); } - ZEPHIR_CALL_METHOD(&argument, &arguments, "current", NULL, 0); + } + if (Z_TYPE_P(&tagFactory) == IS_NULL) { + ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_5$$7); - zephir_fast_trim(&_5$$7, &argument, &delimiter, ZEPHIR_TRIM_BOTH); - zephir_array_append(&data, &_5$$7, PH_SEPARATE, "phalcon/Support/Helper/Str/Concat.zep", 58); - ZEPHIR_CALL_METHOD(NULL, &arguments, "next", NULL, 0); + ZEPHIR_INIT_VAR(&_7$$7); + ZVAL_STRING(&_7$$7, "escaper"); + ZEPHIR_CALL_METHOD(&_6$$7, &container, "has", NULL, 0, &_7$$7); + zephir_check_call_status(); + if (EXPECTED(ZEPHIR_IS_TRUE_IDENTICAL(&_6$$7))) { + ZEPHIR_INIT_VAR(&_8$$8); + ZVAL_STRING(&_8$$8, "escaper"); + ZEPHIR_CALL_METHOD(&escaper, &container, "getshared", NULL, 0, &_8$$8); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&escaper); + object_init_ex(&escaper, phalcon_html_escaper_ce); + if (zephir_has_constructor(&escaper)) { + ZEPHIR_CALL_METHOD(NULL, &escaper, "__construct", NULL, 0); + zephir_check_call_status(); + } + + } + ZEPHIR_INIT_NVAR(&tagFactory); + object_init_ex(&tagFactory, phalcon_html_tagfactory_ce); + ZEPHIR_CALL_METHOD(NULL, &tagFactory, "__construct", NULL, 9, &escaper); zephir_check_call_status(); } + zephir_update_property_zval(this_ptr, ZEND_STRL("tagFactory"), &tagFactory); + } + RETURN_MM_MEMBER(getThis(), "tagFactory"); +} + +zend_object *zephir_init_properties_Phalcon_Forms_Element_AbstractElement(zend_class_entry *class_type) +{ + zval _0, _2, _4, _6, _1$$3, _3$$4, _5$$5, _7$$6; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("validators"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("validators"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("options"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("options"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("filters"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("filters"), &_5$$5); + } + zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_6) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$6); + array_init(&_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("attributes"), &_7$$6); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } - ZEPHIR_INIT_NVAR(&argument); - ZEPHIR_INIT_VAR(&_6); - zephir_fast_join(&_6, &delimiter, &data); - ZEPHIR_CONCAT_VVV(return_value, &prefix, &_6, &suffix); - RETURN_MM(); } @@ -149258,42 +148179,14 @@ static PHP_METHOD(Phalcon_Support_Helper_Str_Concat, __invoke) -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_CountVowels) +ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Check) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, CountVowels, phalcon, support_helper_str_countvowels, phalcon_support_helper_str_countvowels_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Check, phalcon, forms_element_check, phalcon_forms_element_abstractelement_ce, NULL, 0); + zend_declare_property_string(phalcon_forms_element_check_ce, SL("method"), "inputCheckbox", ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Helper_Str_CountVowels, __invoke) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *text_param = NULL, matches, _0, _1, _2, _3; - zval text; - - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&matches); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(text) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &text_param); - zephir_get_strval(&text, text_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "/[aeiouy]/i"); - ZEPHIR_INIT_VAR(&_1); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "/[aeiouy]/i"); - zephir_preg_match(&_1, &_2, &text, &matches, 1, 0 , 0 ); - zephir_array_fetch_long(&_3, &matches, 0, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/CountVowels.zep", 30); - RETURN_MM_LONG(zephir_fast_count_int(&_3)); -} - @@ -149304,69 +148197,61 @@ static PHP_METHOD(Phalcon_Support_Helper_Str_CountVowels, __invoke) -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Decapitalize) +ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Date) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, Decapitalize, phalcon, support_helper_str_decapitalize, phalcon_support_helper_str_abstractstr_ce, phalcon_support_helper_str_decapitalize_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Date, phalcon, forms_element_date, phalcon_forms_element_abstractelement_ce, NULL, 0); + zend_declare_property_string(phalcon_forms_element_date_ce, SL("method"), "inputDate", ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Helper_Str_Decapitalize, __invoke) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_ElementInterface) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool upperRest; - zval *text_param = NULL, *upperRest_param = NULL, *encoding_param = NULL, substr, suffix, _0, _1, _2, _3; - zval text, encoding; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Forms\\Element, ElementInterface, phalcon, forms_element_elementinterface, phalcon_forms_element_elementinterface_method_entry); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&encoding); - ZVAL_UNDEF(&substr); - ZVAL_UNDEF(&suffix); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(text) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(upperRest) - Z_PARAM_STR(encoding) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &text_param, &upperRest_param, &encoding_param); - zephir_get_strval(&text, text_param); - if (!upperRest_param) { - upperRest = 0; - } else { - } - if (!encoding_param) { - ZEPHIR_INIT_VAR(&encoding); - ZVAL_STRING(&encoding, "UTF-8"); - } else { - zephir_get_strval(&encoding, encoding_param); - } - ZVAL_LONG(&_0, 1); - ZEPHIR_CALL_FUNCTION(&substr, "mb_substr", NULL, 228, &text, &_0); - zephir_check_call_status(); - if (upperRest) { - ZEPHIR_CALL_METHOD(&suffix, this_ptr, "toupper", NULL, 0, &substr, &encoding); - zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&suffix, &substr); - } - ZVAL_LONG(&_0, 0); - ZVAL_LONG(&_2, 1); - ZEPHIR_CALL_FUNCTION(&_3, "mb_substr", NULL, 228, &text, &_0, &_2); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "tolower", NULL, 0, &_3, &encoding); - zephir_check_call_status(); - ZEPHIR_CONCAT_VV(return_value, &_1, &suffix); - RETURN_MM(); + return SUCCESS; } +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, addFilter); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, addValidator); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, addValidators); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, appendMessage); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, clear); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getAttribute); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getAttributes); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getDefault); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getFilters); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getForm); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getLabel); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getMessages); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getName); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getUserOption); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getUserOptions); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getValidators); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, getValue); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, hasMessages); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, label); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, render); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setAttribute); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setAttributes); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setDefault); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setFilters); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setForm); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setLabel); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setMessages); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setName); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setUserOption); +ZEPHIR_DOC_METHOD(Phalcon_Forms_Element_ElementInterface, setUserOptions); @@ -149377,69 +148262,30 @@ static PHP_METHOD(Phalcon_Support_Helper_Str_Decapitalize, __invoke) -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Decrement) +ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Email) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, Decrement, phalcon, support_helper_str_decrement, phalcon_support_helper_str_decrement_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Email, phalcon, forms_element_email, phalcon_forms_element_abstractelement_ce, NULL, 0); + zend_declare_property_string(phalcon_forms_element_email_ce, SL("method"), "inputEmail", ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Helper_Str_Decrement, __invoke) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_File) { - zend_long number = 0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *text_param = NULL, *separator_param = NULL, parts, _0, _3, _4, _1$$3, _2$$4; - zval text, separator; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, File, phalcon, forms_element_file, phalcon_forms_element_abstractelement_ce, NULL, 0); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&separator); - ZVAL_UNDEF(&parts); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(text) - Z_PARAM_OPTIONAL - Z_PARAM_STR(separator) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &text_param, &separator_param); - zephir_get_strval(&text, text_param); - if (!separator_param) { - ZEPHIR_INIT_VAR(&separator); - ZVAL_STRING(&separator, "_"); - } else { - zephir_get_strval(&separator, separator_param); - } - number = 0; - ZEPHIR_INIT_VAR(&parts); - zephir_fast_explode(&parts, &separator, &text, LONG_MAX); - ZEPHIR_INIT_VAR(&_0); - if (Z_TYPE_P(&parts) != IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_0); - array_init(&_0); - } else { - ZEPHIR_CPY_WRT(&_0, &parts); - } - ZEPHIR_CPY_WRT(&parts, &_0); - if (1 == zephir_array_isset_long(&parts, 1)) { - zephir_memory_observe(&_1$$3); - zephir_array_fetch_long(&_1$$3, &parts, 1, PH_NOISY, "phalcon/Support/Helper/Str/Decrement.zep", 36); - number = zephir_get_intval(&_1$$3); - number--; - if (number <= 0) { - zephir_array_fetch_long(&_2$$4, &parts, 0, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Decrement.zep", 39); - RETURN_CTOR(&_2$$4); - } - } - zephir_array_fetch_long(&_3, &parts, 0, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Decrement.zep", 43); - ZEPHIR_INIT_VAR(&_4); - ZVAL_LONG(&_4, number); - ZEPHIR_CONCAT_VVV(return_value, &_3, &separator, &_4); - RETURN_MM(); + zend_declare_property_string(phalcon_forms_element_file_ce, SL("method"), "inputFile", ZEND_ACC_PROTECTED); + return SUCCESS; } @@ -149452,56 +148298,30 @@ static PHP_METHOD(Phalcon_Support_Helper_Str_Decrement, __invoke) -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_DirFromFile) +ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Hidden) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, DirFromFile, phalcon, support_helper_str_dirfromfile, phalcon_support_helper_str_dirfromfile_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Hidden, phalcon, forms_element_hidden, phalcon_forms_element_abstractelement_ce, NULL, 0); + zend_declare_property_string(phalcon_forms_element_hidden_ce, SL("method"), "inputHidden", ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Helper_Str_DirFromFile, __invoke) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Numeric) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *file_param = NULL, name, start, _0, _1, _4, _5, _2$$3, _3$$3; - zval file; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Numeric, phalcon, forms_element_numeric, phalcon_forms_element_abstractelement_ce, NULL, 0); - ZVAL_UNDEF(&file); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&start); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(file) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &file_param); - zephir_get_strval(&file, file_param); - ZVAL_LONG(&_0, 8); - ZEPHIR_CALL_FUNCTION(&name, "pathinfo", NULL, 89, &file, &_0); - zephir_check_call_status(); - ZVAL_LONG(&_0, 0); - ZVAL_LONG(&_1, -2); - ZEPHIR_CALL_FUNCTION(&start, "mb_substr", NULL, 228, &name, &_0, &_1); - zephir_check_call_status(); - if (!zephir_is_true(&start)) { - ZVAL_LONG(&_2$$3, 0); - ZVAL_LONG(&_3$$3, 1); - ZEPHIR_CALL_FUNCTION(&start, "mb_substr", NULL, 228, &name, &_2$$3, &_3$$3); - zephir_check_call_status(); - } - ZEPHIR_INIT_VAR(&_4); - ZVAL_LONG(&_0, 2); - ZEPHIR_CALL_FUNCTION(&_5, "mb_str_split", NULL, 0, &start, &_0); - zephir_check_call_status(); - zephir_fast_join_str(&_4, SL("/"), &_5); - ZEPHIR_CONCAT_VS(return_value, &_4, "/"); - RETURN_MM(); + zend_declare_property_string(phalcon_forms_element_numeric_ce, SL("method"), "inputNumeric", ZEND_ACC_PROTECTED); + return SUCCESS; } @@ -149514,35 +148334,30 @@ static PHP_METHOD(Phalcon_Support_Helper_Str_DirFromFile, __invoke) -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_DirSeparator) +ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Password) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, DirSeparator, phalcon, support_helper_str_dirseparator, phalcon_support_helper_str_dirseparator_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Password, phalcon, forms_element_password, phalcon_forms_element_abstractelement_ce, NULL, 0); + zend_declare_property_string(phalcon_forms_element_password_ce, SL("method"), "inputPassword", ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Helper_Str_DirSeparator, __invoke) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Radio) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *directory_param = NULL, _0, _1; - zval directory; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Radio, phalcon, forms_element_radio, phalcon_forms_element_abstractelement_ce, NULL, 0); - ZVAL_UNDEF(&directory); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(directory) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &directory_param); - zephir_get_strval(&directory, directory_param); - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "/"); - zephir_fast_trim(&_0, &directory, &_1, ZEPHIR_TRIM_RIGHT); - ZEPHIR_CONCAT_VS(return_value, &_0, "/"); - RETURN_MM(); + zend_declare_property_string(phalcon_forms_element_radio_ce, SL("method"), "inputRadio", ZEND_ACC_PROTECTED); + return SUCCESS; } @@ -149555,237 +148370,224 @@ static PHP_METHOD(Phalcon_Support_Helper_Str_DirSeparator, __invoke) -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Dynamic) +ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Select) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, Dynamic, phalcon, support_helper_str_dynamic, phalcon_support_helper_str_dynamic_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Select, phalcon, forms_element_select, phalcon_forms_element_abstractelement_ce, phalcon_forms_element_select_method_entry, 0); + zend_declare_property_null(phalcon_forms_element_select_ce, SL("optionsValues"), ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Helper_Str_Dynamic, __invoke) +static PHP_METHOD(Phalcon_Forms_Element_Select, __construct) { - zend_bool _8$$6, _17$$8; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_11 = NULL, *_16 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, *leftDelimiter_param = NULL, *rightDelimiter_param = NULL, *separator_param = NULL, ldS, rdS, matches, match, words, word, sub, _0, _1, _4, _5, _2$$3, *_6$$5, _7$$5, _9$$6, _10$$6, _12$$6, _13$$6, _14$$6, _15$$6, _18$$8, _19$$8, _20$$8, _21$$8, _22$$8, _23$$8; - zval text, leftDelimiter, rightDelimiter, separator, pattern, _3$$3; + zval attributes; + zval *name_param = NULL, *options = NULL, options_sub, *attributes_param = NULL, __$null; + zval name; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&leftDelimiter); - ZVAL_UNDEF(&rightDelimiter); - ZVAL_UNDEF(&separator); - ZVAL_UNDEF(&pattern); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&ldS); - ZVAL_UNDEF(&rdS); - ZVAL_UNDEF(&matches); - ZVAL_UNDEF(&match); - ZVAL_UNDEF(&words); - ZVAL_UNDEF(&word); - ZVAL_UNDEF(&sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_7$$5); - ZVAL_UNDEF(&_9$$6); - ZVAL_UNDEF(&_10$$6); - ZVAL_UNDEF(&_12$$6); - ZVAL_UNDEF(&_13$$6); - ZVAL_UNDEF(&_14$$6); - ZVAL_UNDEF(&_15$$6); - ZVAL_UNDEF(&_18$$8); - ZVAL_UNDEF(&_19$$8); - ZVAL_UNDEF(&_20$$8); - ZVAL_UNDEF(&_21$$8); - ZVAL_UNDEF(&_22$$8); - ZVAL_UNDEF(&_23$$8); - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_STR(text) + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&options_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&attributes); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(name) Z_PARAM_OPTIONAL - Z_PARAM_STR(leftDelimiter) - Z_PARAM_STR(rightDelimiter) - Z_PARAM_STR(separator) + Z_PARAM_ZVAL_OR_NULL(options) + Z_PARAM_ARRAY(attributes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 3, &text_param, &leftDelimiter_param, &rightDelimiter_param, &separator_param); - zephir_get_strval(&text, text_param); - if (!leftDelimiter_param) { - ZEPHIR_INIT_VAR(&leftDelimiter); - ZVAL_STRING(&leftDelimiter, "{"); - } else { - zephir_get_strval(&leftDelimiter, leftDelimiter_param); - } - if (!rightDelimiter_param) { - ZEPHIR_INIT_VAR(&rightDelimiter); - ZVAL_STRING(&rightDelimiter, "}"); - } else { - zephir_get_strval(&rightDelimiter, rightDelimiter_param); + zephir_fetch_params(1, 1, 2, &name_param, &options, &attributes_param); + zephir_get_strval(&name, name_param); + if (!options) { + options = &options_sub; + options = &__$null; } - if (!separator_param) { - ZEPHIR_INIT_VAR(&separator); - ZVAL_STRING(&separator, "|"); + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); } else { - zephir_get_strval(&separator, separator_param); - } - ZEPHIR_CALL_FUNCTION(&_0, "substr_count", NULL, 0, &text, &leftDelimiter); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_1, "substr_count", NULL, 0, &text, &rightDelimiter); - zephir_check_call_status(); - if (UNEXPECTED(!ZEPHIR_IS_IDENTICAL(&_0, &_1))) { - ZEPHIR_INIT_VAR(&_2$$3); - object_init_ex(&_2$$3, spl_ce_RuntimeException); - ZEPHIR_INIT_VAR(&_3$$3); - ZEPHIR_CONCAT_SVS(&_3$$3, "Syntax error in string '", &text, "'"); - ZEPHIR_CALL_METHOD(NULL, &_2$$3, "__construct", NULL, 0, &_3$$3); - zephir_check_call_status(); - zephir_throw_exception_debug(&_2$$3, "phalcon/Support/Helper/Str/Dynamic.zep", 43); - ZEPHIR_MM_RESTORE(); - return; + zephir_get_arrval(&attributes, attributes_param); } - ZEPHIR_CALL_FUNCTION(&ldS, "preg_quote", NULL, 351, &leftDelimiter); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&rdS, "preg_quote", NULL, 351, &rightDelimiter); + zephir_update_property_zval(this_ptr, ZEND_STRL("optionsValues"), options); + ZEPHIR_CALL_PARENT(NULL, phalcon_forms_element_select_ce, getThis(), "__construct", NULL, 0, &name, &attributes); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_4); - ZEPHIR_CONCAT_SVSVVSVS(&_4, "/", &ldS, "([^", &ldS, &rdS, "]+)", &rdS, "/"); - zephir_get_strval(&pattern, &_4); - ZEPHIR_INIT_VAR(&matches); - array_init(&matches); - ZEPHIR_INIT_VAR(&_5); - zephir_preg_match(&_5, &pattern, &text, &matches, 1, 2 , 0 ); - if (!(zephir_is_true(&_5))) { - RETURN_CTOR(&text); - } - if (Z_TYPE_P(&matches) == IS_ARRAY) { - zephir_is_iterable(&matches, 0, "phalcon/Support/Helper/Str/Dynamic.zep", 66); - if (Z_TYPE_P(&matches) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&matches), _6$$5) + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Forms_Element_Select, addOption) +{ + zend_string *_3$$3; + zend_ulong _2$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *option, option_sub, key, value, *_0$$3, _1$$3; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&option_sub); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(option) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &option); + if (Z_TYPE_P(option) == IS_ARRAY) { + zephir_is_iterable(option, 0, "phalcon/Forms/Element/Select.zep", 51); + if (Z_TYPE_P(option) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(option), _2$$3, _3$$3, _0$$3) { - ZEPHIR_INIT_NVAR(&match); - ZVAL_COPY(&match, _6$$5); - _8$$6 = !(zephir_array_isset_long(&match, 0)); - if (!(_8$$6)) { - _8$$6 = !(zephir_array_isset_long(&match, 1)); - } - if (_8$$6) { - continue; + ZEPHIR_INIT_NVAR(&key); + if (_3$$3 != NULL) { + ZVAL_STR_COPY(&key, _3$$3); + } else { + ZVAL_LONG(&key, _2$$3); } - zephir_array_fetch_long(&_9$$6, &match, 1, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Dynamic.zep", 61); - ZEPHIR_INIT_NVAR(&words); - zephir_fast_explode(&words, &separator, &_9$$6, LONG_MAX); - ZEPHIR_OBS_NVAR(&word); - ZEPHIR_CALL_FUNCTION(&_10$$6, "array_rand", &_11, 202, &words); - zephir_check_call_status(); - zephir_array_fetch(&word, &words, &_10$$6, PH_NOISY, "phalcon/Support/Helper/Str/Dynamic.zep", 62); - zephir_array_fetch_long(&_12$$6, &match, 0, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Dynamic.zep", 63); - ZEPHIR_CALL_FUNCTION(&sub, "preg_quote", NULL, 351, &_12$$6, &separator); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_13$$6); - ZEPHIR_CONCAT_SVS(&_13$$6, "/", &sub, "/"); - ZVAL_LONG(&_14$$6, 1); - ZEPHIR_CALL_FUNCTION(&_15$$6, "preg_replace", &_16, 41, &_13$$6, &word, &text, &_14$$6); - zephir_check_call_status(); - zephir_get_strval(&text, &_15$$6); + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0$$3); + zephir_update_property_array(this_ptr, SL("optionsValues"), &key, &value); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &matches, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, option, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_7$$5, &matches, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_1$$3, option, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_7$$5)) { + if (!zend_is_true(&_1$$3)) { break; } - ZEPHIR_CALL_METHOD(&match, &matches, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&key, option, "key", NULL, 0); zephir_check_call_status(); - _17$$8 = !(zephir_array_isset_long(&match, 0)); - if (!(_17$$8)) { - _17$$8 = !(zephir_array_isset_long(&match, 1)); - } - if (_17$$8) { - continue; - } - zephir_array_fetch_long(&_18$$8, &match, 1, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Dynamic.zep", 61); - ZEPHIR_INIT_NVAR(&words); - zephir_fast_explode(&words, &separator, &_18$$8, LONG_MAX); - ZEPHIR_OBS_NVAR(&word); - ZEPHIR_CALL_FUNCTION(&_19$$8, "array_rand", &_11, 202, &words); - zephir_check_call_status(); - zephir_array_fetch(&word, &words, &_19$$8, PH_NOISY, "phalcon/Support/Helper/Str/Dynamic.zep", 62); - zephir_array_fetch_long(&_20$$8, &match, 0, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Dynamic.zep", 63); - ZEPHIR_CALL_FUNCTION(&sub, "preg_quote", NULL, 351, &_20$$8, &separator); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_21$$8); - ZEPHIR_CONCAT_SVS(&_21$$8, "/", &sub, "/"); - ZVAL_LONG(&_22$$8, 1); - ZEPHIR_CALL_FUNCTION(&_23$$8, "preg_replace", &_16, 41, &_21$$8, &word, &text, &_22$$8); - zephir_check_call_status(); - zephir_get_strval(&text, &_23$$8); - ZEPHIR_CALL_METHOD(NULL, &matches, "next", NULL, 0); + ZEPHIR_CALL_METHOD(&value, option, "current", NULL, 0); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("optionsValues"), &key, &value); + ZEPHIR_CALL_METHOD(NULL, option, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&match); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + } else { + zephir_update_property_array_append(this_ptr, SL("optionsValues"), option); } - RETURN_CTOR(&text); + RETURN_THIS(); } +static PHP_METHOD(Phalcon_Forms_Element_Select, getOptions) +{ + RETURN_MEMBER(getThis(), "optionsValues"); +} +static PHP_METHOD(Phalcon_Forms_Element_Select, render) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *attributes_param = NULL, _0, _1; + zval attributes; + zval *this_ptr = getThis(); -#ifdef HAVE_CONFIG_H -#endif - - - - + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(attributes) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &attributes_param); + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); + } else { + zephir_get_arrval(&attributes, attributes_param); + } + ZEPHIR_CALL_METHOD(&_0, this_ptr, "prepareattributes", NULL, 0, &attributes); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("optionsValues"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_CE_STATIC(phalcon_tag_select_ce, "selectfield", NULL, 0, &_0, &_1); + zephir_check_call_status(); + RETURN_MM(); +} -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_EndsWith) +static PHP_METHOD(Phalcon_Forms_Element_Select, setOptions) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, EndsWith, phalcon, support_helper_str_endswith, phalcon_support_helper_str_abstractstr_ce, phalcon_support_helper_str_endswith_method_entry, 0); + zval *options, options_sub; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&options_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(options) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &options); + zephir_update_property_zval(this_ptr, ZEND_STRL("optionsValues"), options); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Support_Helper_Str_EndsWith, __invoke) +static PHP_METHOD(Phalcon_Forms_Element_Select, prepareAttributes) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool ignoreCase; - zval *haystack_param = NULL, *needle_param = NULL, *ignoreCase_param = NULL, _0; - zval haystack, needle; + zval *attributes_param = NULL, value, name, mergedAttributes, defaultAttributes, _0; + zval attributes; zval *this_ptr = getThis(); - ZVAL_UNDEF(&haystack); - ZVAL_UNDEF(&needle); + ZVAL_UNDEF(&attributes); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&mergedAttributes); + ZVAL_UNDEF(&defaultAttributes); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(haystack) - Z_PARAM_STR(needle) + ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL - Z_PARAM_BOOL(ignoreCase) + Z_PARAM_ARRAY(attributes) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &haystack_param, &needle_param, &ignoreCase_param); - zephir_get_strval(&haystack, haystack_param); - zephir_get_strval(&needle, needle_param); - if (!ignoreCase_param) { - ignoreCase = 1; - } else { - } - if (ignoreCase) { - ZVAL_BOOL(&_0, 1); + zephir_fetch_params(1, 0, 1, &attributes_param); + if (!attributes_param) { + ZEPHIR_INIT_VAR(&attributes); + array_init(&attributes); } else { - ZVAL_BOOL(&_0, 0); + zephir_get_arrval(&attributes, attributes_param); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "toendswith", NULL, 0, &haystack, &needle, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("name"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&name, &_0); + zephir_array_update_long(&attributes, 0, &name, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + zephir_memory_observe(&defaultAttributes); + zephir_read_property(&defaultAttributes, this_ptr, ZEND_STRL("attributes"), PH_NOISY_CC); + ZEPHIR_INIT_VAR(&mergedAttributes); + zephir_fast_array_merge(&mergedAttributes, &defaultAttributes, &attributes); + ZEPHIR_CALL_METHOD(&value, this_ptr, "getvalue", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + if (Z_TYPE_P(&value) != IS_NULL) { + zephir_array_update_string(&mergedAttributes, SL("value"), &value, PH_COPY | PH_SEPARATE); + } + RETURN_CCTOR(&mergedAttributes); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Submit) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Submit, phalcon, forms_element_submit, phalcon_forms_element_abstractelement_ce, NULL, 0); + + zend_declare_property_string(phalcon_forms_element_submit_ce, SL("method"), "inputSubmit", ZEND_ACC_PROTECTED); + return SUCCESS; } @@ -149798,64 +148600,29 @@ static PHP_METHOD(Phalcon_Support_Helper_Str_EndsWith, __invoke) -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_FirstBetween) +ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_Text) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, FirstBetween, phalcon, support_helper_str_firstbetween, phalcon_support_helper_str_firstbetween_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, Text, phalcon, forms_element_text, phalcon_forms_element_abstractelement_ce, NULL, 0); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Helper_Str_FirstBetween, __invoke) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Forms_Element_TextArea) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, *start_param = NULL, *end_param = NULL, __$true, result, _0, _1; - zval text, start, end, _2; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Forms\\Element, TextArea, phalcon, forms_element_textarea, phalcon_forms_element_abstractelement_ce, NULL, 0); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&start); - ZVAL_UNDEF(&end); - ZVAL_UNDEF(&_2); - ZVAL_BOOL(&__$true, 1); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_STR(text) - Z_PARAM_STR(start) - Z_PARAM_STR(end) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &text_param, &start_param, &end_param); - zephir_get_strval(&text, text_param); - zephir_get_strval(&start, start_param); - zephir_get_strval(&end, end_param); - ZEPHIR_CALL_FUNCTION(&result, "mb_strstr", NULL, 0, &text, &start); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - if (ZEPHIR_IS_FALSE_IDENTICAL(&result)) { - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, ""); - } else { - ZEPHIR_CPY_WRT(&_0, &result); - } - ZEPHIR_CPY_WRT(&result, &_0); - ZEPHIR_CALL_FUNCTION(&_1, "mb_strstr", NULL, 0, &result, &end, &__$true); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&result, &_1); - ZEPHIR_INIT_NVAR(&_0); - if (ZEPHIR_IS_FALSE_IDENTICAL(&result)) { - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, ""); - } else { - ZEPHIR_CPY_WRT(&_0, &result); - } - ZEPHIR_CPY_WRT(&result, &_0); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_VV(&_2, &start, &end); - zephir_fast_trim(return_value, &result, &_2, ZEPHIR_TRIM_BOTH); - RETURN_MM(); + zend_declare_property_string(phalcon_forms_element_textarea_ce, SL("method"), "inputTextarea", ZEND_ACC_PROTECTED); + return SUCCESS; } @@ -149868,596 +148635,604 @@ static PHP_METHOD(Phalcon_Support_Helper_Str_FirstBetween, __invoke) -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Friendly) +ZEPHIR_INIT_CLASS(Phalcon_Cache_AbstractCache) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, Friendly, phalcon, support_helper_str_friendly, phalcon_support_helper_str_abstractstr_ce, phalcon_support_helper_str_friendly_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Cache, AbstractCache, phalcon, cache_abstractcache, phalcon_cache_abstractcache_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + zend_declare_property_null(phalcon_cache_abstractcache_ce, SL("adapter"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_cache_abstractcache_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_cache_abstractcache_ce, 1, phalcon_cache_cacheinterface_ce); + zend_class_implements(phalcon_cache_abstractcache_ce, 1, phalcon_events_eventsawareinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Helper_Str_Friendly, __invoke) +static PHP_METHOD(Phalcon_Cache_AbstractCache, __construct) +{ + zval *adapter, adapter_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&adapter_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(adapter, phalcon_cache_adapter_adapterinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &adapter); + zephir_update_property_zval(this_ptr, ZEND_STRL("adapter"), adapter); +} + +static PHP_METHOD(Phalcon_Cache_AbstractCache, getAdapter) +{ + + RETURN_MEMBER(getThis(), "adapter"); +} + +static PHP_METHOD(Phalcon_Cache_AbstractCache, setEventsManager) { + zval *eventsManager, eventsManager_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&eventsManager_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); + zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); +} + +static PHP_METHOD(Phalcon_Cache_AbstractCache, getEventsManager) +{ + + RETURN_MEMBER(getThis(), "eventsManager"); +} + +static PHP_METHOD(Phalcon_Cache_AbstractCache, checkKey) +{ + zend_class_entry *_6$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool lowercase; - zval *text_param = NULL, *separator_param = NULL, *lowercase_param = NULL, *replace = NULL, replace_sub, __$null, friendly, matrix, _1, _2, _3, _4, _5, _7, _0$$3, _6$$5; - zval text, separator; + zval *key_param = NULL, exception, _0, _1, _2, _3, _4$$3, _5$$3, _7$$3; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&separator); - ZVAL_UNDEF(&replace_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&friendly); - ZVAL_UNDEF(&matrix); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&exception); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_6$$5); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_STR(text) - Z_PARAM_OPTIONAL - Z_PARAM_STR(separator) - Z_PARAM_BOOL(lowercase) - Z_PARAM_ZVAL_OR_NULL(replace) + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_7$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 3, &text_param, &separator_param, &lowercase_param, &replace); - if (UNEXPECTED(Z_TYPE_P(text_param) != IS_STRING && Z_TYPE_P(text_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'text' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(text_param) == IS_STRING)) { - zephir_get_strval(&text, text_param); - } else { - ZEPHIR_INIT_VAR(&text); - } - if (!separator_param) { - ZEPHIR_INIT_VAR(&separator); - ZVAL_STRING(&separator, "-"); - } else { - if (UNEXPECTED(Z_TYPE_P(separator_param) != IS_STRING && Z_TYPE_P(separator_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'separator' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(separator_param) == IS_STRING)) { - zephir_get_strval(&separator, separator_param); - } else { - ZEPHIR_INIT_VAR(&separator); - } - } - if (!lowercase_param) { - lowercase = 1; - } else { - } - if (!replace) { - replace = &replace_sub; - ZEPHIR_CPY_WRT(replace, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(replace); - } - if (zephir_is_true(replace)) { - ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "checkreplace", NULL, 0, replace); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(replace, &_0$$3); - } else { - ZEPHIR_INIT_NVAR(replace); - array_init(replace); - } - ZEPHIR_CALL_METHOD(&matrix, this_ptr, "getmatrix", NULL, 0, replace); - zephir_check_call_status(); + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); + ZEPHIR_INIT_VAR(&_0); ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "/[^A-Za-z0-9-_.]/"); ZEPHIR_INIT_VAR(&_2); - zephir_array_keys(&_2, &matrix); - ZEPHIR_CALL_FUNCTION(&_3, "array_values", NULL, 14, &matrix); - zephir_check_call_status(); - zephir_fast_str_replace(&_1, &_2, &_3, &text); - zephir_get_strval(&text, &_1); - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, "/[^a-zA-Z0-9\\/_|+ -]/"); - ZEPHIR_INIT_VAR(&_5); - ZVAL_STRING(&_5, ""); - ZEPHIR_CALL_FUNCTION(&friendly, "preg_replace", NULL, 41, &_4, &_5, &text); - zephir_check_call_status(); - if (lowercase) { - ZEPHIR_INIT_VAR(&_6$$5); - zephir_fast_strtolower(&_6$$5, &friendly); - ZEPHIR_CPY_WRT(&friendly, &_6$$5); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "/[^A-Za-z0-9-_.]/"); + zephir_preg_match(&_2, &_3, &key, &_0, 0, 0 , 0 ); + if (zephir_is_true(&_2)) { + ZEPHIR_CALL_METHOD(&exception, this_ptr, "getexceptionclass", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4$$3); + zephir_fetch_safe_class(&_5$$3, &exception); + _6$$3 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_5$$3), Z_STRLEN_P(&_5$$3), ZEND_FETCH_CLASS_AUTO); + if(!_6$$3) { + RETURN_MM_NULL(); + } + object_init_ex(&_4$$3, _6$$3); + ZEPHIR_INIT_VAR(&_7$$3); + ZVAL_STRING(&_7$$3, "The key contains invalid characters"); + ZEPHIR_CALL_METHOD(NULL, &_4$$3, "__construct", NULL, 0, &_7$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_4$$3, "phalcon/Cache/AbstractCache.zep", 90); + ZEPHIR_MM_RESTORE(); + return; } - ZEPHIR_INIT_NVAR(&_4); - ZVAL_STRING(&_4, "/[\\/_|+ -]+/"); - ZEPHIR_CALL_FUNCTION(&_7, "preg_replace", NULL, 41, &_4, &separator, &friendly); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&friendly, &_7); - zephir_fast_trim(return_value, &friendly, &separator, ZEPHIR_TRIM_BOTH); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Support_Helper_Str_Friendly, checkReplace) +static PHP_METHOD(Phalcon_Cache_AbstractCache, checkKeys) { + zend_class_entry *_3$$3; zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *replace = NULL, replace_sub, _1$$4; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *keys, keys_sub, exception, _1$$3, _2$$3, _4$$3; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&replace_sub); - ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&keys_sub); + ZVAL_UNDEF(&exception); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_4$$3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(replace) + Z_PARAM_ZVAL(keys) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &replace); - ZEPHIR_SEPARATE_PARAM(replace); - _0 = Z_TYPE_P(replace) != IS_ARRAY; - if (_0) { - _0 = Z_TYPE_P(replace) != IS_STRING; + zephir_fetch_params(1, 1, 0, &keys); + _0 = Z_TYPE_P(keys) == IS_ARRAY; + if (!(_0)) { + _0 = zephir_zval_is_traversable(keys); } - if (_0) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_support_helper_exception_ce, "Parameter replace must be an array or a string", "phalcon/Support/Helper/Str/Friendly.zep", 74); + if (!(_0)) { + ZEPHIR_CALL_METHOD(&exception, this_ptr, "getexceptionclass", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1$$3); + zephir_fetch_safe_class(&_2$$3, &exception); + _3$$3 = zephir_fetch_class_str_ex(Z_STRVAL_P(&_2$$3), Z_STRLEN_P(&_2$$3), ZEND_FETCH_CLASS_AUTO); + if(!_3$$3) { + RETURN_MM_NULL(); + } + object_init_ex(&_1$$3, _3$$3); + ZEPHIR_INIT_VAR(&_4$$3); + ZVAL_STRING(&_4$$3, "The keys need to be an array or instance of Traversable"); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "__construct", NULL, 0, &_4$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_1$$3, "phalcon/Cache/AbstractCache.zep", 109); + ZEPHIR_MM_RESTORE(); return; } - if (Z_TYPE_P(replace) == IS_STRING) { - ZEPHIR_INIT_VAR(&_1$$4); - zephir_create_array(&_1$$4, 1, 0); - zephir_array_fast_append(&_1$$4, replace); - ZEPHIR_CPY_WRT(replace, &_1$$4); - } - RETVAL_ZVAL(replace, 1, 0); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Cache_AbstractCache, doClear) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_METHOD(&_0, "clear", NULL, 0); + zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Helper_Str_Friendly, getMatrix) +static PHP_METHOD(Phalcon_Cache_AbstractCache, doDelete) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *replace_param = NULL, item, *_0, _1, _2$$3, _3$$4; - zval replace, matrix; + zval *key_param = NULL, result, _0, _1; + zval key; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&replace); - ZVAL_UNDEF(&matrix); - ZVAL_UNDEF(&item); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$4); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(replace) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &replace_param); - zephir_get_arrval(&replace, replace_param); - ZEPHIR_INIT_VAR(&matrix); - zephir_create_array(&matrix, 79, 0); - add_assoc_stringl_ex(&matrix, SL("Š"), SL("S")); - add_assoc_stringl_ex(&matrix, SL("š"), SL("s")); - add_assoc_stringl_ex(&matrix, SL("Đ"), SL("Dj")); - add_assoc_stringl_ex(&matrix, SL("Ð"), SL("Dj")); - add_assoc_stringl_ex(&matrix, SL("đ"), SL("dj")); - add_assoc_stringl_ex(&matrix, SL("Ž"), SL("Z")); - add_assoc_stringl_ex(&matrix, SL("ž"), SL("z")); - add_assoc_stringl_ex(&matrix, SL("Č"), SL("C")); - add_assoc_stringl_ex(&matrix, SL("č"), SL("c")); - add_assoc_stringl_ex(&matrix, SL("Ć"), SL("C")); - add_assoc_stringl_ex(&matrix, SL("ć"), SL("c")); - add_assoc_stringl_ex(&matrix, SL("À"), SL("A")); - add_assoc_stringl_ex(&matrix, SL("Á"), SL("A")); - add_assoc_stringl_ex(&matrix, SL("Â"), SL("A")); - add_assoc_stringl_ex(&matrix, SL("Ã"), SL("A")); - add_assoc_stringl_ex(&matrix, SL("Ä"), SL("A")); - add_assoc_stringl_ex(&matrix, SL("Å"), SL("A")); - add_assoc_stringl_ex(&matrix, SL("Æ"), SL("A")); - add_assoc_stringl_ex(&matrix, SL("Ç"), SL("C")); - add_assoc_stringl_ex(&matrix, SL("È"), SL("E")); - add_assoc_stringl_ex(&matrix, SL("É"), SL("E")); - add_assoc_stringl_ex(&matrix, SL("Ê"), SL("E")); - add_assoc_stringl_ex(&matrix, SL("Ë"), SL("E")); - add_assoc_stringl_ex(&matrix, SL("Ì"), SL("I")); - add_assoc_stringl_ex(&matrix, SL("Í"), SL("I")); - add_assoc_stringl_ex(&matrix, SL("Î"), SL("I")); - add_assoc_stringl_ex(&matrix, SL("Ï"), SL("I")); - add_assoc_stringl_ex(&matrix, SL("Ñ"), SL("N")); - add_assoc_stringl_ex(&matrix, SL("Ò"), SL("O")); - add_assoc_stringl_ex(&matrix, SL("Ó"), SL("O")); - add_assoc_stringl_ex(&matrix, SL("Ô"), SL("O")); - add_assoc_stringl_ex(&matrix, SL("Õ"), SL("O")); - add_assoc_stringl_ex(&matrix, SL("Ö"), SL("O")); - add_assoc_stringl_ex(&matrix, SL("Ø"), SL("O")); - add_assoc_stringl_ex(&matrix, SL("Ù"), SL("U")); - add_assoc_stringl_ex(&matrix, SL("Ú"), SL("U")); - add_assoc_stringl_ex(&matrix, SL("Û"), SL("U")); - add_assoc_stringl_ex(&matrix, SL("Ü"), SL("U")); - add_assoc_stringl_ex(&matrix, SL("Ý"), SL("Y")); - add_assoc_stringl_ex(&matrix, SL("Þ"), SL("B")); - add_assoc_stringl_ex(&matrix, SL("ß"), SL("Ss")); - add_assoc_stringl_ex(&matrix, SL("à"), SL("a")); - add_assoc_stringl_ex(&matrix, SL("á"), SL("a")); - add_assoc_stringl_ex(&matrix, SL("â"), SL("a")); - add_assoc_stringl_ex(&matrix, SL("ã"), SL("a")); - add_assoc_stringl_ex(&matrix, SL("ä"), SL("a")); - add_assoc_stringl_ex(&matrix, SL("å"), SL("a")); - add_assoc_stringl_ex(&matrix, SL("æ"), SL("a")); - add_assoc_stringl_ex(&matrix, SL("ç"), SL("c")); - add_assoc_stringl_ex(&matrix, SL("è"), SL("e")); - add_assoc_stringl_ex(&matrix, SL("é"), SL("e")); - add_assoc_stringl_ex(&matrix, SL("ê"), SL("e")); - add_assoc_stringl_ex(&matrix, SL("ë"), SL("e")); - add_assoc_stringl_ex(&matrix, SL("ì"), SL("i")); - add_assoc_stringl_ex(&matrix, SL("í"), SL("i")); - add_assoc_stringl_ex(&matrix, SL("î"), SL("i")); - add_assoc_stringl_ex(&matrix, SL("ï"), SL("i")); - add_assoc_stringl_ex(&matrix, SL("ð"), SL("o")); - add_assoc_stringl_ex(&matrix, SL("ñ"), SL("n")); - add_assoc_stringl_ex(&matrix, SL("ò"), SL("o")); - add_assoc_stringl_ex(&matrix, SL("ó"), SL("o")); - add_assoc_stringl_ex(&matrix, SL("ô"), SL("o")); - add_assoc_stringl_ex(&matrix, SL("õ"), SL("o")); - add_assoc_stringl_ex(&matrix, SL("ö"), SL("o")); - add_assoc_stringl_ex(&matrix, SL("ø"), SL("o")); - add_assoc_stringl_ex(&matrix, SL("ù"), SL("u")); - add_assoc_stringl_ex(&matrix, SL("ú"), SL("u")); - add_assoc_stringl_ex(&matrix, SL("û"), SL("u")); - add_assoc_stringl_ex(&matrix, SL("ý"), SL("y")); - add_assoc_stringl_ex(&matrix, SL("þ"), SL("b")); - add_assoc_stringl_ex(&matrix, SL("ÿ"), SL("y")); - add_assoc_stringl_ex(&matrix, SL("Ŕ"), SL("R")); - add_assoc_stringl_ex(&matrix, SL("ŕ"), SL("r")); - add_assoc_stringl_ex(&matrix, SL("ē"), SL("e")); - add_assoc_stringl_ex(&matrix, SL("'"), SL("")); - add_assoc_stringl_ex(&matrix, SL("&"), SL(" and ")); - add_assoc_stringl_ex(&matrix, SL("\r\n"), SL(" ")); - add_assoc_stringl_ex(&matrix, SL("\n"), SL(" ")); - zephir_is_iterable(&replace, 0, "phalcon/Support/Helper/Str/Friendly.zep", 122); - if (Z_TYPE_P(&replace) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&replace), _0) + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "cache:beforeDelete"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fire", NULL, 0, &_0, &key); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkey", NULL, 0, &key); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&result, &_1, "delete", NULL, 0, &key); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "cache:afterDelete"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fire", NULL, 0, &_0, &key); + zephir_check_call_status(); + RETURN_CCTOR(&result); +} + +static PHP_METHOD(Phalcon_Cache_AbstractCache, doDeleteMultiple) +{ + zend_bool result = 0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *keys, keys_sub, key, _0, *_1, _2, _3$$3, _4$$3, _5$$5, _6$$5; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&keys_sub); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_6$$5); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(keys) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &keys); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkeys", NULL, 0, keys); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "cache:beforeDeleteMultiple"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fire", NULL, 0, &_0, keys); + zephir_check_call_status(); + result = 1; + zephir_is_iterable(keys, 0, "phalcon/Cache/AbstractCache.zep", 167); + if (Z_TYPE_P(keys) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(keys), _1) { - ZEPHIR_INIT_NVAR(&item); - ZVAL_COPY(&item, _0); - ZEPHIR_INIT_NVAR(&_2$$3); - ZVAL_STRING(&_2$$3, " "); - zephir_array_update_zval(&matrix, &item, &_2$$3, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&key); + ZVAL_COPY(&key, _1); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_4$$3, &_3$$3, "delete", NULL, 0, &key); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_4$$3)) { + result = 0; + } } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &replace, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, keys, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_1, &replace, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_2, keys, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_1)) { + if (!zend_is_true(&_2)) { break; } - ZEPHIR_CALL_METHOD(&item, &replace, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&key, keys, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_3$$4); - ZVAL_STRING(&_3$$4, " "); - zephir_array_update_zval(&matrix, &item, &_3$$4, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &replace, "next", NULL, 0); + zephir_read_property(&_5$$5, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_6$$5, &_5$$5, "delete", NULL, 0, &key); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_6$$5)) { + result = 0; + } + ZEPHIR_CALL_METHOD(NULL, keys, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&item); - RETURN_CTOR(&matrix); + ZEPHIR_INIT_NVAR(&key); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "cache:afterDeleteMultiple"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fire", NULL, 0, &_0, keys); + zephir_check_call_status(); + RETURN_MM_BOOL(result); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Humanize) +static PHP_METHOD(Phalcon_Cache_AbstractCache, doGet) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, Humanize, phalcon, support_helper_str_humanize, phalcon_support_helper_str_humanize_method_entry, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null, result, _0, _1; + zval key; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(key) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(defaultValue) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &key_param, &defaultValue); + zephir_get_strval(&key, key_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkey", NULL, 0, &key); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "cache:beforeGet"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fire", NULL, 0, &_0, &key); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&result, &_1, "get", NULL, 0, &key, defaultValue); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "cache:afterGet"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fire", NULL, 0, &_0, &key); + zephir_check_call_status(); + RETURN_CCTOR(&result); } -static PHP_METHOD(Phalcon_Support_Helper_Str_Humanize, __invoke) +static PHP_METHOD(Phalcon_Cache_AbstractCache, doGetMultiple) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, result, _0, _1, _2; - zval text; + zval *keys, keys_sub, *defaultValue = NULL, defaultValue_sub, __$null, element, results, _0, *_1, _2, _3$$3, _5$$4; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&result); + ZVAL_UNDEF(&keys_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&element); + ZVAL_UNDEF(&results); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(text) + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_5$$4); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(keys) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(defaultValue) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &text_param); - zephir_get_strval(&text, text_param); + zephir_fetch_params(1, 1, 1, &keys, &defaultValue); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkeys", NULL, 0, keys); + zephir_check_call_status(); ZEPHIR_INIT_VAR(&_0); - zephir_fast_trim(&_0, &text, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "#[_-]+#"); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, " "); - ZEPHIR_CALL_FUNCTION(&result, "preg_replace", NULL, 41, &_1, &_2, &_0); + ZVAL_STRING(&_0, "cache:beforeGetMultiple"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fire", NULL, 0, &_0, keys); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_1); - if (Z_TYPE_P(&result) == IS_NULL) { - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, ""); + ZEPHIR_INIT_VAR(&results); + array_init(&results); + zephir_is_iterable(keys, 0, "phalcon/Cache/AbstractCache.zep", 215); + if (Z_TYPE_P(keys) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(keys), _1) + { + ZEPHIR_INIT_NVAR(&element); + ZVAL_COPY(&element, _1); + ZEPHIR_CALL_METHOD(&_3$$3, this_ptr, "get", &_4, 0, &element, defaultValue); + zephir_check_call_status(); + zephir_array_update_zval(&results, &element, &_3$$3, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CPY_WRT(&_1, &result); + ZEPHIR_CALL_METHOD(NULL, keys, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, keys, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&element, keys, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_5$$4, this_ptr, "get", &_6, 0, &element, defaultValue); + zephir_check_call_status(); + zephir_array_update_zval(&results, &element, &_5$$4, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, keys, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_CCTOR(&_1); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Includes) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, Includes, phalcon, support_helper_str_includes, phalcon_support_helper_str_includes_method_entry, 0); - - return SUCCESS; + ZEPHIR_INIT_NVAR(&element); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "cache:afterGetMultiple"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fire", NULL, 0, &_0, keys); + zephir_check_call_status(); + RETURN_CCTOR(&results); } -static PHP_METHOD(Phalcon_Support_Helper_Str_Includes, __invoke) +static PHP_METHOD(Phalcon_Cache_AbstractCache, doHas) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *haystack_param = NULL, *needle_param = NULL, _0; - zval haystack, needle; + zval *key_param = NULL, result, _0, _1; + zval key; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&haystack); - ZVAL_UNDEF(&needle); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(haystack) - Z_PARAM_STR(needle) + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &haystack_param, &needle_param); - zephir_get_strval(&haystack, haystack_param); - zephir_get_strval(&needle, needle_param); - ZEPHIR_CALL_FUNCTION(&_0, "mb_strpos", NULL, 86, &haystack, &needle); + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkey", NULL, 0, &key); zephir_check_call_status(); - RETURN_MM_BOOL(!ZEPHIR_IS_FALSE_IDENTICAL(&_0)); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Increment) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, Increment, phalcon, support_helper_str_increment, phalcon_support_helper_str_increment_method_entry, 0); - - return SUCCESS; + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "cache:beforeHas"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fire", NULL, 0, &_0, &key); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&result, &_1, "has", NULL, 0, &key); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "cache:afterHas"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fire", NULL, 0, &_0, &key); + zephir_check_call_status(); + RETURN_CCTOR(&result); } -static PHP_METHOD(Phalcon_Support_Helper_Str_Increment, __invoke) +static PHP_METHOD(Phalcon_Cache_AbstractCache, doSet) { - zend_long number = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *text_param = NULL, *separator_param = NULL, parts, _1, _2, _0$$3; - zval text, separator; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL, *value, value_sub, *ttl = NULL, ttl_sub, __$null, result, _0, _1; + zval key; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&separator); - ZVAL_UNDEF(&parts); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&ttl_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_0$$3); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(text) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(key) + Z_PARAM_ZVAL(value) Z_PARAM_OPTIONAL - Z_PARAM_STR(separator) + Z_PARAM_ZVAL_OR_NULL(ttl) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &text_param, &separator_param); - zephir_get_strval(&text, text_param); - if (!separator_param) { - ZEPHIR_INIT_VAR(&separator); - ZVAL_STRING(&separator, "_"); - } else { - zephir_get_strval(&separator, separator_param); - } - ZEPHIR_INIT_VAR(&parts); - zephir_fast_explode(&parts, &separator, &text, LONG_MAX); - number = 1; - if (1 == zephir_array_isset_long(&parts, 1)) { - zephir_memory_observe(&_0$$3); - zephir_array_fetch_long(&_0$$3, &parts, 1, PH_NOISY, "phalcon/Support/Helper/Str/Increment.zep", 35); - number = (zephir_get_intval(&_0$$3) + 1); + zephir_fetch_params(1, 2, 1, &key_param, &value, &ttl); + zephir_get_strval(&key, key_param); + if (!ttl) { + ttl = &ttl_sub; + ttl = &__$null; } - zephir_array_fetch_long(&_1, &parts, 0, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Increment.zep", 38); - ZEPHIR_INIT_VAR(&_2); - ZVAL_LONG(&_2, number); - ZEPHIR_CONCAT_VVV(return_value, &_1, &separator, &_2); - RETURN_MM(); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Interpolate) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, Interpolate, phalcon, support_helper_str_interpolate, phalcon_support_helper_str_interpolate_method_entry, 0); - - return SUCCESS; + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkey", NULL, 0, &key); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "cache:beforeSet"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fire", NULL, 0, &_0, &key); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("adapter"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&result, &_1, "set", NULL, 0, &key, value, ttl); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "cache:afterSet"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fire", NULL, 0, &_0, &key); + zephir_check_call_status(); + RETURN_CCTOR(&result); } -static PHP_METHOD(Phalcon_Support_Helper_Str_Interpolate, __invoke) +static PHP_METHOD(Phalcon_Cache_AbstractCache, doSetMultiple) { - zend_string *_3$$3; - zend_ulong _2$$3; + zend_string *_5; + zend_ulong _4; + zend_bool result = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_7 = NULL, *_9 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval context, replace; - zval *message_param = NULL, *context_param = NULL, *leftToken_param = NULL, *rightToken_param = NULL, key, value, *_0$$3, _1$$3, _4$$4, _5$$5; - zval message, leftToken, rightToken; + zval *values, values_sub, *ttl = NULL, ttl_sub, __$null, key, value, _0, _1, *_2, _3, _10, _6$$3, _8$$5; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&leftToken); - ZVAL_UNDEF(&rightToken); + ZVAL_UNDEF(&values_sub); + ZVAL_UNDEF(&ttl_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&key); ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&context); - ZVAL_UNDEF(&replace); - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_STR(message) + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_8$$5); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(values) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(context) - Z_PARAM_STR(leftToken) - Z_PARAM_STR(rightToken) + Z_PARAM_ZVAL_OR_NULL(ttl) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 3, &message_param, &context_param, &leftToken_param, &rightToken_param); - zephir_get_strval(&message, message_param); - if (!context_param) { - ZEPHIR_INIT_VAR(&context); - array_init(&context); - } else { - zephir_get_arrval(&context, context_param); - } - if (!leftToken_param) { - ZEPHIR_INIT_VAR(&leftToken); - ZVAL_STRING(&leftToken, "%"); - } else { - zephir_get_strval(&leftToken, leftToken_param); + zephir_fetch_params(1, 1, 1, &values, &ttl); + if (!ttl) { + ttl = &ttl_sub; + ttl = &__$null; } - if (!rightToken_param) { - ZEPHIR_INIT_VAR(&rightToken); - ZVAL_STRING(&rightToken, "%"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "checkkeys", NULL, 0, values); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + zephir_array_keys(&_0, values); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "cache:beforeSetMultiple"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fire", NULL, 0, &_1, &_0); + zephir_check_call_status(); + result = 1; + zephir_is_iterable(values, 0, "phalcon/Cache/AbstractCache.zep", 296); + if (Z_TYPE_P(values) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(values), _4, _5, _2) + { + ZEPHIR_INIT_NVAR(&key); + if (_5 != NULL) { + ZVAL_STR_COPY(&key, _5); + } else { + ZVAL_LONG(&key, _4); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _2); + ZEPHIR_CALL_METHOD(&_6$$3, this_ptr, "set", &_7, 0, &key, &value, ttl); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_6$$3)) { + result = 0; + } + } ZEND_HASH_FOREACH_END(); } else { - zephir_get_strval(&rightToken, rightToken_param); - } - if (!(ZEPHIR_IS_EMPTY(&context))) { - ZEPHIR_INIT_VAR(&replace); - array_init(&replace); - zephir_is_iterable(&context, 0, "phalcon/Support/Helper/Str/Interpolate.zep", 41); - if (Z_TYPE_P(&context) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&context), _2$$3, _3$$3, _0$$3) - { - ZEPHIR_INIT_NVAR(&key); - if (_3$$3 != NULL) { - ZVAL_STR_COPY(&key, _3$$3); - } else { - ZVAL_LONG(&key, _2$$3); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0$$3); - ZEPHIR_INIT_NVAR(&_4$$4); - ZEPHIR_CONCAT_VVV(&_4$$4, &leftToken, &key, &rightToken); - zephir_array_update_zval(&replace, &_4$$4, &value, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &context, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, values, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, values, "valid", NULL, 0); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1$$3, &context, "valid", NULL, 0); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&key, values, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, values, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_8$$5, this_ptr, "set", &_9, 0, &key, &value, ttl); zephir_check_call_status(); - if (!zend_is_true(&_1$$3)) { - break; + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_8$$5)) { + result = 0; } - ZEPHIR_CALL_METHOD(&key, &context, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &context, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_5$$5); - ZEPHIR_CONCAT_VVV(&_5$$5, &leftToken, &key, &rightToken); - zephir_array_update_zval(&replace, &_5$$5, &value, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &context, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_CALL_METHOD(NULL, values, "next", NULL, 0); + zephir_check_call_status(); } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - ZEPHIR_RETURN_CALL_FUNCTION("strtr", NULL, 5, &message, &replace); - zephir_check_call_status(); - RETURN_MM(); } - RETURN_CTOR(&message); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_IsAnagram) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, IsAnagram, phalcon, support_helper_str_isanagram, phalcon_support_helper_str_isanagram_method_entry, 0); - - return SUCCESS; + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&key); + ZEPHIR_INIT_NVAR(&_1); + zephir_array_keys(&_1, values); + ZEPHIR_INIT_VAR(&_10); + ZVAL_STRING(&_10, "cache:afterSetMultiple"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "fire", NULL, 0, &_10, &_1); + zephir_check_call_status(); + RETURN_MM_BOOL(result); } -static PHP_METHOD(Phalcon_Support_Helper_Str_IsAnagram, __invoke) +static PHP_METHOD(Phalcon_Cache_AbstractCache, fire) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *first_param = NULL, *second_param = NULL, _0, _1, _2; - zval first, second; + zval *eventName_param = NULL, *keys, keys_sub, _0, _1, _2; + zval eventName; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&first); - ZVAL_UNDEF(&second); + ZVAL_UNDEF(&eventName); + ZVAL_UNDEF(&keys_sub); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(first) - Z_PARAM_STR(second) + Z_PARAM_STR(eventName) + Z_PARAM_ZVAL(keys) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &first_param, &second_param); - zephir_get_strval(&first, first_param); - zephir_get_strval(&second, second_param); - ZVAL_LONG(&_0, 1); - ZEPHIR_CALL_FUNCTION(&_1, "count_chars", NULL, 0, &first, &_0); - zephir_check_call_status(); - ZVAL_LONG(&_0, 1); - ZEPHIR_CALL_FUNCTION(&_2, "count_chars", NULL, 0, &second, &_0); + zephir_fetch_params(1, 2, 0, &eventName_param, &keys); + zephir_get_strval(&eventName, eventName_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + RETURN_MM_NULL(); + } + zephir_read_property(&_1, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZVAL_BOOL(&_2, 0); + ZEPHIR_CALL_METHOD(NULL, &_1, "fire", NULL, 0, &eventName, this_ptr, keys, &_2); zephir_check_call_status(); - RETURN_MM_BOOL(ZEPHIR_IS_IDENTICAL(&_1, &_2)); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Cache_AbstractCache, getExceptionClass) +{ } @@ -150470,42 +149245,111 @@ static PHP_METHOD(Phalcon_Support_Helper_Str_IsAnagram, __invoke) -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_IsLower) +ZEPHIR_INIT_CLASS(Phalcon_Cache_AdapterFactory) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, IsLower, phalcon, support_helper_str_islower, phalcon_support_helper_str_abstractstr_ce, phalcon_support_helper_str_islower_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache, AdapterFactory, phalcon, cache_adapterfactory, phalcon_factory_abstractfactory_ce, phalcon_cache_adapterfactory_method_entry, 0); + zend_declare_property_null(phalcon_cache_adapterfactory_ce, SL("serializerFactory"), ZEND_ACC_PRIVATE); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Helper_Str_IsLower, __invoke) +static PHP_METHOD(Phalcon_Cache_AdapterFactory, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, *encoding_param = NULL, _0; - zval text, encoding; + zval services; + zval *factory, factory_sub, *services_param = NULL; zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&encoding); + ZVAL_UNDEF(&factory_sub); + ZVAL_UNDEF(&services); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_storage_serializerfactory_ce) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(services) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &factory, &services_param); + if (!services_param) { + ZEPHIR_INIT_VAR(&services); + array_init(&services); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("serializerFactory"), factory); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Cache_AdapterFactory, newInstance) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval options, _0; + zval *name_param = NULL, *options_param = NULL, definition, _1; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&options); ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(text) + Z_PARAM_STR(name) Z_PARAM_OPTIONAL - Z_PARAM_STR(encoding) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &text_param, &encoding_param); - zephir_get_strval(&text, text_param); - if (!encoding_param) { - ZEPHIR_INIT_VAR(&encoding); - ZVAL_STRING(&encoding, "UTF-8"); + zephir_fetch_params(1, 1, 1, &name_param, &options_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - zephir_get_strval(&encoding, encoding_param); + ZEPHIR_INIT_VAR(&name); } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "tolower", NULL, 0, &text, &encoding); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); + } + ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); zephir_check_call_status(); - RETURN_MM_BOOL(ZEPHIR_IS_IDENTICAL(&text, &_0)); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 2, 0); + zephir_memory_observe(&_1); + zephir_read_property(&_1, this_ptr, ZEND_STRL("serializerFactory"), PH_NOISY_CC); + zephir_array_fast_append(&_0, &_1); + zephir_array_fast_append(&_0, &options); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(return_value, &definition, &_0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Cache_AdapterFactory, getExceptionClass) +{ + + RETURN_STRING("Phalcon\\Cache\\Exception\\Exception"); +} + +static PHP_METHOD(Phalcon_Cache_AdapterFactory, getServices) +{ + + zephir_create_array(return_value, 6, 0); + add_assoc_stringl_ex(return_value, SL("apcu"), SL("Phalcon\\Cache\\Adapter\\Apcu")); + add_assoc_stringl_ex(return_value, SL("libmemcached"), SL("Phalcon\\Cache\\Adapter\\Libmemcached")); + add_assoc_stringl_ex(return_value, SL("memory"), SL("Phalcon\\Cache\\Adapter\\Memory")); + add_assoc_stringl_ex(return_value, SL("redis"), SL("Phalcon\\Cache\\Adapter\\Redis")); + add_assoc_stringl_ex(return_value, SL("stream"), SL("Phalcon\\Cache\\Adapter\\Stream")); + add_assoc_stringl_ex(return_value, SL("weak"), SL("Phalcon\\Cache\\Adapter\\Weak")); + return; } @@ -150518,224 +149362,211 @@ static PHP_METHOD(Phalcon_Support_Helper_Str_IsLower, __invoke) -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_IsPalindrome) +ZEPHIR_INIT_CLASS(Phalcon_Cache_Cache) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, IsPalindrome, phalcon, support_helper_str_ispalindrome, phalcon_support_helper_str_ispalindrome_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache, Cache, phalcon, cache_cache, phalcon_cache_abstractcache_ce, phalcon_cache_cache_method_entry, 0); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Helper_Str_IsPalindrome, __invoke) +static PHP_METHOD(Phalcon_Cache_Cache, clear) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, _0; - zval text; + zval *this_ptr = getThis(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&_0); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "doclear", NULL, 0); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Cache_Cache, delete) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL; + zval key; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&key); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(text) + Z_PARAM_STR(key) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &text_param); - zephir_get_strval(&text, text_param); - ZEPHIR_CALL_FUNCTION(&_0, "strrev", NULL, 0, &text); + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dodelete", NULL, 0, &key); zephir_check_call_status(); - RETURN_MM_BOOL(ZEPHIR_IS_IDENTICAL(&_0, &text)); + RETURN_MM(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_IsUpper) +static PHP_METHOD(Phalcon_Cache_Cache, deleteMultiple) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, IsUpper, phalcon, support_helper_str_isupper, phalcon_support_helper_str_abstractstr_ce, phalcon_support_helper_str_isupper_method_entry, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *keys, keys_sub; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&keys_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(keys) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &keys); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dodeletemultiple", NULL, 0, keys); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Helper_Str_IsUpper, __invoke) +static PHP_METHOD(Phalcon_Cache_Cache, get) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, *encoding_param = NULL, _0; - zval text, encoding; + zval *key_param = NULL, *defaultValue = NULL, defaultValue_sub, __$null; + zval key; zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&encoding); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(text) + Z_PARAM_STR(key) Z_PARAM_OPTIONAL - Z_PARAM_STR(encoding) + Z_PARAM_ZVAL_OR_NULL(defaultValue) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &text_param, &encoding_param); - zephir_get_strval(&text, text_param); - if (!encoding_param) { - ZEPHIR_INIT_VAR(&encoding); - ZVAL_STRING(&encoding, "UTF-8"); - } else { - zephir_get_strval(&encoding, encoding_param); + zephir_fetch_params(1, 1, 1, &key_param, &defaultValue); + zephir_get_strval(&key, key_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "toupper", NULL, 0, &text, &encoding); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "doget", NULL, 0, &key, defaultValue); zephir_check_call_status(); - RETURN_MM_BOOL(ZEPHIR_IS_IDENTICAL(&text, &_0)); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_KebabCase) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, KebabCase, phalcon, support_helper_str_kebabcase, phalcon_support_helper_str_pascalcase_ce, phalcon_support_helper_str_kebabcase_method_entry, 0); - - return SUCCESS; + RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Helper_Str_KebabCase, __invoke) +static PHP_METHOD(Phalcon_Cache_Cache, getMultiple) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, *delimiters_param = NULL, output; - zval text, delimiters; + zval *keys, keys_sub, *defaultValue = NULL, defaultValue_sub, __$null; zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&delimiters); - ZVAL_UNDEF(&output); + ZVAL_UNDEF(&keys_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(text) + Z_PARAM_ZVAL(keys) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(delimiters) + Z_PARAM_ZVAL_OR_NULL(defaultValue) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &text_param, &delimiters_param); - zephir_get_strval(&text, text_param); - if (!delimiters_param) { - ZEPHIR_INIT_VAR(&delimiters); - } else { - zephir_get_strval(&delimiters, delimiters_param); + zephir_fetch_params(1, 1, 1, &keys, &defaultValue); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; } - ZEPHIR_CALL_METHOD(&output, this_ptr, "processarray", NULL, 0, &text, &delimiters); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dogetmultiple", NULL, 0, keys, defaultValue); zephir_check_call_status(); - zephir_fast_join_str(return_value, SL("-"), &output); RETURN_MM(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Len) +static PHP_METHOD(Phalcon_Cache_Cache, has) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, Len, phalcon, support_helper_str_len, phalcon_support_helper_str_len_method_entry, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *key_param = NULL; + zval key; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&key); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(key) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &key_param); + zephir_get_strval(&key, key_param); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dohas", NULL, 0, &key); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Helper_Str_Len, __invoke) +static PHP_METHOD(Phalcon_Cache_Cache, set) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, *encoding_param = NULL; - zval text, encoding; + zval *key_param = NULL, *value, value_sub, *ttl = NULL, ttl_sub, __$null; + zval key; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&encoding); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(text) + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&ttl_sub); + ZVAL_NULL(&__$null); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(key) + Z_PARAM_ZVAL(value) Z_PARAM_OPTIONAL - Z_PARAM_STR(encoding) + Z_PARAM_ZVAL_OR_NULL(ttl) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &text_param, &encoding_param); - zephir_get_strval(&text, text_param); - if (!encoding_param) { - ZEPHIR_INIT_VAR(&encoding); - ZVAL_STRING(&encoding, "UTF-8"); - } else { - zephir_get_strval(&encoding, encoding_param); + zephir_fetch_params(1, 2, 1, &key_param, &value, &ttl); + zephir_get_strval(&key, key_param); + if (!ttl) { + ttl = &ttl_sub; + ttl = &__$null; } - ZEPHIR_RETURN_CALL_FUNCTION("mb_strlen", NULL, 234, &text, &encoding); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "doset", NULL, 0, &key, value, ttl); zephir_check_call_status(); RETURN_MM(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Lower) -{ - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, Lower, phalcon, support_helper_str_lower, phalcon_support_helper_str_abstractstr_ce, phalcon_support_helper_str_lower_method_entry, 0); - - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Support_Helper_Str_Lower, __invoke) +static PHP_METHOD(Phalcon_Cache_Cache, setMultiple) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, *encoding_param = NULL; - zval text, encoding; + zval *values, values_sub, *ttl = NULL, ttl_sub, __$null; zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&encoding); + ZVAL_UNDEF(&values_sub); + ZVAL_UNDEF(&ttl_sub); + ZVAL_NULL(&__$null); + bool is_null_true = 1; ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(text) + Z_PARAM_ZVAL(values) Z_PARAM_OPTIONAL - Z_PARAM_STR(encoding) + Z_PARAM_ZVAL_OR_NULL(ttl) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &text_param, &encoding_param); - zephir_get_strval(&text, text_param); - if (!encoding_param) { - ZEPHIR_INIT_VAR(&encoding); - ZVAL_STRING(&encoding, "UTF-8"); - } else { - zephir_get_strval(&encoding, encoding_param); + zephir_fetch_params(1, 1, 1, &values, &ttl); + if (!ttl) { + ttl = &ttl_sub; + ttl = &__$null; } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "tolower", NULL, 0, &text, &encoding); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "dosetmultiple", NULL, 0, values, ttl); zephir_check_call_status(); RETURN_MM(); } +static PHP_METHOD(Phalcon_Cache_Cache, getExceptionClass) +{ + + RETURN_STRING("Phalcon\\Cache\\Exception\\InvalidArgumentException"); +} + @@ -150746,187 +149577,115 @@ static PHP_METHOD(Phalcon_Support_Helper_Str_Lower, __invoke) -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_PascalCase) +ZEPHIR_INIT_CLASS(Phalcon_Cache_CacheFactory) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, PascalCase, phalcon, support_helper_str_pascalcase, phalcon_support_helper_str_pascalcase_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache, CacheFactory, phalcon, cache_cachefactory, phalcon_factory_abstractconfigfactory_ce, phalcon_cache_cachefactory_method_entry, 0); + zend_declare_property_null(phalcon_cache_cachefactory_ce, SL("adapterFactory"), ZEND_ACC_PROTECTED); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Helper_Str_PascalCase, __invoke) +static PHP_METHOD(Phalcon_Cache_CacheFactory, __construct) +{ + zval *factory, factory_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&factory_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(factory, phalcon_cache_adapterfactory_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &factory); + zephir_update_property_zval(this_ptr, ZEND_STRL("adapterFactory"), factory); +} + +static PHP_METHOD(Phalcon_Cache_CacheFactory, load) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, *delimiters_param = NULL, exploded, output, element, *_0, _1, _2$$3, _3$$3, _5$$3, _6$$4, _7$$4, _8$$4; - zval text, delimiters; + zval *config = NULL, config_sub, name, options, _0, _1; zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&delimiters); - ZVAL_UNDEF(&exploded); - ZVAL_UNDEF(&output); - ZVAL_UNDEF(&element); + ZVAL_UNDEF(&config_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_8$$4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(text) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(delimiters) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(config) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &text_param, &delimiters_param); - zephir_get_strval(&text, text_param); - if (!delimiters_param) { - ZEPHIR_INIT_VAR(&delimiters); - } else { - zephir_get_strval(&delimiters, delimiters_param); - } - ZEPHIR_CALL_METHOD(&exploded, this_ptr, "processarray", NULL, 0, &text, &delimiters); + zephir_fetch_params(1, 1, 0, &config); + ZEPHIR_SEPARATE_PARAM(config); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfig", NULL, 0, config); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&output); - ZVAL_STRING(&output, ""); - zephir_is_iterable(&exploded, 0, "phalcon/Support/Helper/Str/PascalCase.zep", 37); - if (Z_TYPE_P(&exploded) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&exploded), _0) - { - ZEPHIR_INIT_NVAR(&element); - ZVAL_COPY(&element, _0); - ZEPHIR_INIT_NVAR(&_2$$3); - ZEPHIR_CALL_FUNCTION(&_3$$3, "mb_strtolower", &_4, 10, &element); - zephir_check_call_status(); - zephir_ucfirst(&_2$$3, &_3$$3); - ZEPHIR_INIT_NVAR(&_5$$3); - ZEPHIR_CONCAT_VV(&_5$$3, &output, &_2$$3); - ZEPHIR_CPY_WRT(&output, &_5$$3); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &exploded, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &exploded, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&element, &exploded, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_6$$4); - ZEPHIR_CALL_FUNCTION(&_7$$4, "mb_strtolower", &_4, 10, &element); - zephir_check_call_status(); - zephir_ucfirst(&_6$$4, &_7$$4); - ZEPHIR_INIT_NVAR(&_8$$4); - ZEPHIR_CONCAT_VV(&_8$$4, &output, &_6$$4); - ZEPHIR_CPY_WRT(&output, &_8$$4); - ZEPHIR_CALL_METHOD(NULL, &exploded, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_CPY_WRT(config, &_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "adapter"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfigelement", NULL, 0, config, &_1); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(config, &_0); + zephir_memory_observe(&name); + zephir_array_fetch_string(&name, config, SL("adapter"), PH_NOISY, "phalcon/Cache/CacheFactory.zep", 73); + zephir_memory_observe(&options); + if (!(zephir_array_isset_string_fetch(&options, config, SL("options"), 0))) { + ZEPHIR_INIT_NVAR(&options); + array_init(&options); } - ZEPHIR_INIT_NVAR(&element); - RETURN_CCTOR(&output); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "newinstance", NULL, 0, &name, &options); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Helper_Str_PascalCase, processArray) +static PHP_METHOD(Phalcon_Cache_CacheFactory, newInstance) { - zval _6$$4, _8$$4; - zend_bool _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, *delimiters_param = NULL, result, _0, _1, _3, _4, _11, _12, _13, _5$$4, _7$$4; - zval text, delimiters, _10, _9$$4; + zval options; + zval *name_param = NULL, *options_param = NULL, adapter, _0; + zval name; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&delimiters); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&result); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&adapter); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_13); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_8$$4); - bool is_null_true = 1; + ZVAL_UNDEF(&options); ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(text) + Z_PARAM_STR(name) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(delimiters) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &text_param, &delimiters_param); - zephir_get_strval(&text, text_param); - if (!delimiters_param) { - ZEPHIR_INIT_VAR(&delimiters); - } else { - zephir_get_strval(&delimiters, delimiters_param); - } - if (ZEPHIR_IS_NULL(&delimiters)) { - ZEPHIR_INIT_NVAR(&delimiters); - ZVAL_STRING(&delimiters, "-_"); - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "\\-"); - ZEPHIR_INIT_VAR(&_1); - zephir_fast_strpos(&_1, &delimiters, &_0, 0 ); - _2 = !ZEPHIR_IS_FALSE_IDENTICAL(&_1); - if (!(_2)) { - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "-"); - ZEPHIR_INIT_VAR(&_4); - zephir_fast_strpos(&_4, &delimiters, &_3, 0 ); - _2 = !ZEPHIR_IS_FALSE_IDENTICAL(&_4); + zephir_fetch_params(1, 1, 1, &name_param, &options_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); } - if (_2) { - ZEPHIR_INIT_VAR(&_5$$4); - ZEPHIR_INIT_VAR(&_6$$4); - zephir_create_array(&_6$$4, 2, 0); - ZEPHIR_INIT_VAR(&_7$$4); - ZVAL_STRING(&_7$$4, "\\-"); - zephir_array_fast_append(&_6$$4, &_7$$4); - ZEPHIR_INIT_NVAR(&_7$$4); - ZVAL_STRING(&_7$$4, "-"); - zephir_array_fast_append(&_6$$4, &_7$$4); - ZEPHIR_INIT_VAR(&_8$$4); - zephir_create_array(&_8$$4, 2, 0); - ZEPHIR_INIT_NVAR(&_7$$4); - ZVAL_STRING(&_7$$4, ""); - zephir_array_fast_append(&_8$$4, &_7$$4); - ZEPHIR_INIT_NVAR(&_7$$4); - ZVAL_STRING(&_7$$4, ""); - zephir_array_fast_append(&_8$$4, &_7$$4); - zephir_fast_str_replace(&_5$$4, &_6$$4, &_8$$4, &delimiters); - zephir_get_strval(&delimiters, &_5$$4); - ZEPHIR_INIT_VAR(&_9$$4); - ZEPHIR_CONCAT_SV(&_9$$4, "-", &delimiters); - ZEPHIR_CPY_WRT(&delimiters, &_9$$4); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); } - ZEPHIR_INIT_VAR(&_10); - ZEPHIR_CONCAT_SVS(&_10, "/[", &delimiters, "]+/"); - ZVAL_LONG(&_11, -1); - ZVAL_LONG(&_12, (2 | 1)); - ZEPHIR_CALL_FUNCTION(&result, "preg_split", NULL, 70, &_10, &text, &_11, &_12); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_13); - if (ZEPHIR_IS_FALSE_IDENTICAL(&result)) { - ZEPHIR_INIT_NVAR(&_13); - array_init(&_13); + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); } else { - ZEPHIR_CPY_WRT(&_13, &result); + ZEPHIR_OBS_COPY_OR_DUP(&options, options_param); } - RETURN_CCTOR(&_13); + zephir_read_property(&_0, this_ptr, ZEND_STRL("adapterFactory"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&adapter, &_0, "newinstance", NULL, 0, &name, &options); + zephir_check_call_status(); + object_init_ex(return_value, phalcon_cache_cache_ce); + ZEPHIR_CALL_METHOD(NULL, return_value, "__construct", NULL, 189, &adapter); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Cache_CacheFactory, getExceptionClass) +{ + + RETURN_STRING("Phalcon\\Cache\\Exception\\Exception"); } @@ -150939,35 +149698,21 @@ static PHP_METHOD(Phalcon_Support_Helper_Str_PascalCase, processArray) -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Prefix) +ZEPHIR_INIT_CLASS(Phalcon_Cache_CacheInterface) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, Prefix, phalcon, support_helper_str_prefix, phalcon_support_helper_str_prefix_method_entry, 0); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Cache, CacheInterface, phalcon, cache_cacheinterface, phalcon_cache_cacheinterface_method_entry); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Helper_Str_Prefix, __invoke) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval prefix, _0; - zval *text, text_sub, *prefix_param = NULL; - - ZVAL_UNDEF(&text_sub); - ZVAL_UNDEF(&prefix); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(text) - Z_PARAM_STR(prefix) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &text, &prefix_param); - zephir_get_strval(&prefix, prefix_param); - zephir_cast_to_string(&_0, text); - ZEPHIR_CONCAT_VV(return_value, &prefix, &_0); - RETURN_MM(); -} - +ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, clear); +ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, delete); +ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, deleteMultiple); +ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, get); +ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, getMultiple); +ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, has); +ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, set); +ZEPHIR_DOC_METHOD(Phalcon_Cache_CacheInterface, setMultiple); @@ -150978,165 +149723,28 @@ static PHP_METHOD(Phalcon_Support_Helper_Str_Prefix, __invoke) -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Random) +ZEPHIR_INIT_CLASS(Phalcon_Cache_Exception_Exception) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, Random, phalcon, support_helper_str_random, phalcon_support_helper_str_random_method_entry, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Exception, Exception, phalcon, cache_exception_exception, zend_ce_exception, NULL, 0); - zephir_declare_class_constant_long(phalcon_support_helper_str_random_ce, SL("RANDOM_ALNUM"), 0); + return SUCCESS; +} - zephir_declare_class_constant_long(phalcon_support_helper_str_random_ce, SL("RANDOM_ALPHA"), 1); - zephir_declare_class_constant_long(phalcon_support_helper_str_random_ce, SL("RANDOM_DISTINCT"), 5); - zephir_declare_class_constant_long(phalcon_support_helper_str_random_ce, SL("RANDOM_HEXDEC"), 2); - zephir_declare_class_constant_long(phalcon_support_helper_str_random_ce, SL("RANDOM_NOZERO"), 4); +#ifdef HAVE_CONFIG_H +#endif - zephir_declare_class_constant_long(phalcon_support_helper_str_random_ce, SL("RANDOM_NUMERIC"), 3); - return SUCCESS; -} -static PHP_METHOD(Phalcon_Support_Helper_Str_Random, __invoke) + + +ZEPHIR_INIT_CLASS(Phalcon_Cache_Exception_InvalidArgumentException) { - zend_bool _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_20 = NULL; - zval *type_param = NULL, *length_param = NULL, end, pools, text, _0, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16$$3, _17$$3, _18$$3, _19$$3; - zend_long type, length, ZEPHIR_LAST_CALL_STATUS; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Cache\\Exception, InvalidArgumentException, phalcon, cache_exception_invalidargumentexception, zend_ce_exception, NULL, 0); - ZVAL_UNDEF(&end); - ZVAL_UNDEF(&pools); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_13); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_15); - ZVAL_UNDEF(&_16$$3); - ZVAL_UNDEF(&_17$$3); - ZVAL_UNDEF(&_18$$3); - ZVAL_UNDEF(&_19$$3); - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_LONG(type) - Z_PARAM_LONG(length) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &type_param, &length_param); - if (!type_param) { - type = 0; - } else { - } - if (!length_param) { - length = 8; - } else { - } - ZEPHIR_INIT_VAR(&text); - ZVAL_STRING(&text, ""); - ZEPHIR_INIT_VAR(&_0); - _1 = type < 0; - if (!(_1)) { - _1 = type > 5; - } - if (_1) { - ZEPHIR_INIT_NVAR(&_0); - ZVAL_LONG(&_0, 0); - } else { - ZEPHIR_INIT_NVAR(&_0); - ZVAL_LONG(&_0, type); - } - type = zephir_get_numberval(&_0); - ZEPHIR_INIT_VAR(&pools); - zephir_create_array(&pools, 6, 0); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "a"); - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, "z"); - ZEPHIR_CALL_FUNCTION(&_5, "range", NULL, 314, &_3, &_4); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_3); - ZVAL_STRING(&_3, "A"); - ZEPHIR_INIT_NVAR(&_4); - ZVAL_STRING(&_4, "Z"); - ZEPHIR_CALL_FUNCTION(&_6, "range", NULL, 314, &_3, &_4); - zephir_check_call_status(); - zephir_fast_array_merge(&_2, &_5, &_6); - zephir_array_update_long(&pools, 1, &_2, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_LONG(&_7, 0); - ZVAL_LONG(&_8, 9); - ZEPHIR_CALL_FUNCTION(&_9, "range", NULL, 314, &_7, &_8); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_3); - ZVAL_STRING(&_3, "a"); - ZEPHIR_INIT_NVAR(&_4); - ZVAL_STRING(&_4, "f"); - ZEPHIR_CALL_FUNCTION(&_10, "range", NULL, 314, &_3, &_4); - zephir_check_call_status(); - zephir_fast_array_merge(&_2, &_9, &_10); - zephir_array_update_long(&pools, 2, &_2, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - ZVAL_LONG(&_7, 0); - ZVAL_LONG(&_8, 9); - ZEPHIR_CALL_FUNCTION(&_11, "range", NULL, 314, &_7, &_8); - zephir_check_call_status(); - zephir_array_update_long(&pools, 3, &_11, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - ZVAL_LONG(&_7, 1); - ZVAL_LONG(&_8, 9); - ZEPHIR_CALL_FUNCTION(&_11, "range", NULL, 314, &_7, &_8); - zephir_check_call_status(); - zephir_array_update_long(&pools, 4, &_11, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "2345679ACDEFHJKLMNPRSTUVWXYZ"); - ZEPHIR_CALL_FUNCTION(&_11, "str_split", NULL, 88, &_2); - zephir_check_call_status(); - zephir_array_update_long(&pools, 5, &_11, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - ZVAL_LONG(&_7, 0); - ZVAL_LONG(&_8, 9); - ZEPHIR_CALL_FUNCTION(&_11, "range", NULL, 314, &_7, &_8); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "a"); - ZEPHIR_INIT_NVAR(&_3); - ZVAL_STRING(&_3, "z"); - ZEPHIR_CALL_FUNCTION(&_12, "range", NULL, 314, &_2, &_3); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "A"); - ZEPHIR_INIT_NVAR(&_3); - ZVAL_STRING(&_3, "Z"); - ZEPHIR_CALL_FUNCTION(&_13, "range", NULL, 314, &_2, &_3); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_14, "array_merge", NULL, 330, &_11, &_12, &_13); - zephir_check_call_status(); - zephir_array_update_long(&pools, 0, &_14, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); - zephir_array_fetch_long(&_15, &pools, type, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Random.zep", 66); - ZEPHIR_INIT_VAR(&end); - ZVAL_LONG(&end, (zephir_fast_count_int(&_15) - 1)); - while (1) { - if (!(zephir_fast_strlen_ev(&text) < length)) { - break; - } - zephir_array_fetch_long(&_16$$3, &pools, type, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Random.zep", 69); - ZVAL_LONG(&_18$$3, 0); - ZEPHIR_CALL_FUNCTION(&_19$$3, "mt_rand", &_20, 0, &_18$$3, &end); - zephir_check_call_status(); - zephir_array_fetch(&_17$$3, &_16$$3, &_19$$3, PH_NOISY | PH_READONLY, "phalcon/Support/Helper/Str/Random.zep", 69); - zephir_concat_self(&text, &_17$$3); - } - RETURN_CCTOR(&text); + return SUCCESS; } @@ -151149,47 +149757,14 @@ static PHP_METHOD(Phalcon_Support_Helper_Str_Random, __invoke) -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_ReduceSlashes) +ZEPHIR_INIT_CLASS(Phalcon_Cache_Adapter_AdapterInterface) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Helper\\Str, ReduceSlashes, phalcon, support_helper_str_reduceslashes, phalcon_support_helper_str_reduceslashes_method_entry, 0); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Cache\\Adapter, AdapterInterface, phalcon, cache_adapter_adapterinterface, NULL); + zend_class_implements(phalcon_cache_adapter_adapterinterface_ce, 1, phalcon_storage_adapter_adapterinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Helper_Str_ReduceSlashes, __invoke) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, result, _0, _1; - zval text; - - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(text) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &text_param); - zephir_get_strval(&text, text_param); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "#(?create_object = zephir_init_properties_Phalcon_Flash_AbstractFlash; + zend_class_implements(phalcon_flash_abstractflash_ce, 1, phalcon_flash_flashinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Support_Helper_Str_Underscore, __invoke) +static PHP_METHOD(Phalcon_Flash_AbstractFlash, __construct) { + zval _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, result, _0, _1, _2; - zval text; + zval *escaper = NULL, escaper_sub, *session = NULL, session_sub, __$null, _0; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&result); + ZVAL_UNDEF(&escaper_sub); + ZVAL_UNDEF(&session_sub); + ZVAL_NULL(&__$null); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(text) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(escaper, phalcon_html_escaper_escaperinterface_ce) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(session, phalcon_session_managerinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &text_param); - zephir_get_strval(&text, text_param); + zephir_fetch_params(1, 0, 2, &escaper, &session); + if (!escaper) { + escaper = &escaper_sub; + escaper = &__$null; + } + if (!session) { + session = &session_sub; + session = &__$null; + } + zephir_update_property_zval(this_ptr, ZEND_STRL("escaperService"), escaper); + zephir_update_property_zval(this_ptr, ZEND_STRL("sessionService"), session); ZEPHIR_INIT_VAR(&_0); - zephir_fast_trim(&_0, &text, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "#\\s+#"); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "_"); - ZEPHIR_CALL_FUNCTION(&result, "preg_replace", NULL, 41, &_1, &_2, &_0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_1); - if (Z_TYPE_P(&result) == IS_NULL) { - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, ""); - } else { - ZEPHIR_CPY_WRT(&_1, &result); + object_init_ex(&_0, phalcon_support_helper_str_interpolate_ce); + if (zephir_has_constructor(&_0)) { + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); + zephir_check_call_status(); } - RETURN_CCTOR(&_1); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - + zephir_update_property_zval(this_ptr, ZEND_STRL("interpolator"), &_0); + ZEPHIR_INIT_VAR(&_1); + zephir_create_array(&_1, 4, 0); + add_assoc_stringl_ex(&_1, SL("error"), SL("errorMessage")); + add_assoc_stringl_ex(&_1, SL("notice"), SL("noticeMessage")); + add_assoc_stringl_ex(&_1, SL("success"), SL("successMessage")); + add_assoc_stringl_ex(&_1, SL("warning"), SL("warningMessage")); + zephir_update_property_zval(this_ptr, ZEND_STRL("cssClasses"), &_1); + ZEPHIR_MM_RESTORE(); +} -ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Str_Upper) +static PHP_METHOD(Phalcon_Flash_AbstractFlash, clear) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Helper\\Str, Upper, phalcon, support_helper_str_upper, phalcon_support_helper_str_abstractstr_ce, phalcon_support_helper_str_upper_method_entry, 0); + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("messages"), &_0); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Support_Helper_Str_Upper, __invoke) +static PHP_METHOD(Phalcon_Flash_AbstractFlash, error) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *text_param = NULL, *encoding_param = NULL; - zval text, encoding; + zval *message_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&text); - ZVAL_UNDEF(&encoding); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(text) - Z_PARAM_OPTIONAL - Z_PARAM_STR(encoding) + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(message) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &text_param, &encoding_param); - zephir_get_strval(&text, text_param); - if (!encoding_param) { - ZEPHIR_INIT_VAR(&encoding); - ZVAL_STRING(&encoding, "UTF-8"); - } else { - zephir_get_strval(&encoding, encoding_param); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "toupper", NULL, 0, &text, &encoding); + zephir_fetch_params(1, 1, 0, &message_param); + zephir_get_strval(&message, message_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "error"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "message", NULL, 0, &_0, &message); zephir_check_call_status(); RETURN_MM(); } +static PHP_METHOD(Phalcon_Flash_AbstractFlash, getAutoescape) +{ + RETURN_MEMBER(getThis(), "autoescape"); +} +static PHP_METHOD(Phalcon_Flash_AbstractFlash, getAutomaticHtml) +{ -#ifdef HAVE_CONFIG_H -#endif + RETURN_MEMBER(getThis(), "automaticHtml"); +} +static PHP_METHOD(Phalcon_Flash_AbstractFlash, getCssClasses) +{ + RETURN_MEMBER(getThis(), "cssClasses"); +} +static PHP_METHOD(Phalcon_Flash_AbstractFlash, getCssIconClasses) +{ + RETURN_MEMBER(getThis(), "cssIconClasses"); +} -ZEPHIR_INIT_CLASS(Phalcon_Support_Debug_Dump) +static PHP_METHOD(Phalcon_Flash_AbstractFlash, getCustomTemplate) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Support\\Debug, Dump, phalcon, support_debug_dump, phalcon_support_debug_dump_method_entry, 0); - - zend_declare_property_bool(phalcon_support_debug_dump_ce, SL("detailed"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_support_debug_dump_ce, SL("methods"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_support_debug_dump_ce, SL("styles"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_support_debug_dump_ce, SL("encode"), ZEND_ACC_PRIVATE); - phalcon_support_debug_dump_ce->create_object = zephir_init_properties_Phalcon_Support_Debug_Dump; - return SUCCESS; + RETURN_MEMBER(getThis(), "customTemplate"); } -static PHP_METHOD(Phalcon_Support_Debug_Dump, __construct) +static PHP_METHOD(Phalcon_Flash_AbstractFlash, getEscaperService) { + zend_bool _2; + zval _0, _1, _3, _4, _5, _6$$4, _7$$4, _8$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool detailed; - zval *styles_param = NULL, *detailed_param = NULL, __$true, __$false, _0; - zval styles; zval *this_ptr = getThis(); - ZVAL_UNDEF(&styles); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(styles) - Z_PARAM_BOOL(detailed) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$4); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &styles_param, &detailed_param); - if (!styles_param) { - ZEPHIR_INIT_VAR(&styles); - array_init(&styles); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&styles, styles_param); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("escaperService"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) != IS_NULL) { + RETURN_MM_MEMBER(getThis(), "escaperService"); } - if (!detailed_param) { - detailed = 0; - } else { - } - ZEPHIR_INIT_VAR(&_0); - object_init_ex(&_0, phalcon_support_helper_json_encode_ce); - if (zephir_has_constructor(&_0)) { - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + _2 = Z_TYPE_P(&_1) != IS_NULL; + if (_2) { + zephir_read_property(&_3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_5); + ZVAL_STRING(&_5, "escaper"); + ZEPHIR_CALL_METHOD(&_4, &_3, "has", NULL, 0, &_5); zephir_check_call_status(); + _2 = ZEPHIR_IS_TRUE_IDENTICAL(&_4); } - - zephir_update_property_zval(this_ptr, ZEND_STRL("encode"), &_0); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setstyles", NULL, 0, &styles); - zephir_check_call_status(); - if (detailed) { - zephir_update_property_zval(this_ptr, ZEND_STRL("detailed"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("detailed"), &__$false); + if (_2) { + zephir_read_property(&_6$$4, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_8$$4); + ZVAL_STRING(&_8$$4, "escaper"); + ZEPHIR_CALL_METHOD(&_7$$4, &_6$$4, "getshared", NULL, 0, &_8$$4); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("escaperService"), &_7$$4); + RETURN_MM_MEMBER(getThis(), "escaperService"); } - ZEPHIR_MM_RESTORE(); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_flash_exception_ce, "A dependency injection container is required to access the 'escaper' service", "phalcon/Flash/AbstractFlash.zep", 194); + return; } -static PHP_METHOD(Phalcon_Support_Debug_Dump, all) +static PHP_METHOD(Phalcon_Flash_AbstractFlash, notice) { - zval _1; - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *message_param = NULL, _0; + zval message; zval *this_ptr = getThis(); + ZVAL_UNDEF(&message); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(message) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - + zephir_fetch_params(1, 1, 0, &message_param); + zephir_get_strval(&message, message_param); ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 2, 0); - zephir_array_fast_append(&_0, this_ptr); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "variables"); - zephir_array_fast_append(&_0, &_1); - ZEPHIR_INIT_NVAR(&_1); - zephir_get_args(&_1); - ZEPHIR_CALL_USER_FUNC_ARRAY(return_value, &_0, &_1); + ZVAL_STRING(&_0, "notice"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "message", NULL, 0, &_0, &message); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Debug_Dump, getDetailed) -{ - - RETURN_MEMBER(getThis(), "detailed"); -} - -static PHP_METHOD(Phalcon_Support_Debug_Dump, setDetailed) +static PHP_METHOD(Phalcon_Flash_AbstractFlash, setAutoescape) { - zval *detailed_param = NULL, __$true, __$false; - zend_bool detailed; + zval *autoescape_param = NULL, __$true, __$false; + zend_bool autoescape; zval *this_ptr = getThis(); ZVAL_BOOL(&__$true, 1); ZVAL_BOOL(&__$false, 0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(detailed) + Z_PARAM_BOOL(autoescape) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &detailed_param); - if (detailed) { - zephir_update_property_zval(this_ptr, ZEND_STRL("detailed"), &__$true); + zephir_fetch_params_without_memory_grow(1, 0, &autoescape_param); + if (autoescape) { + zephir_update_property_zval(this_ptr, ZEND_STRL("autoescape"), &__$true); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("detailed"), &__$false); + zephir_update_property_zval(this_ptr, ZEND_STRL("autoescape"), &__$false); } + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Support_Debug_Dump, one) +static PHP_METHOD(Phalcon_Flash_AbstractFlash, setAutomaticHtml) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval name; - zval *variable, variable_sub, *name_param = NULL; + zval *automaticHtml_param = NULL, __$true, __$false; + zend_bool automaticHtml; zval *this_ptr = getThis(); - ZVAL_UNDEF(&variable_sub); - ZVAL_UNDEF(&name); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(variable) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(automaticHtml) ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &variable, &name_param); - if (!name_param) { - ZEPHIR_INIT_VAR(&name); + zephir_fetch_params_without_memory_grow(1, 0, &automaticHtml_param); + if (automaticHtml) { + zephir_update_property_zval(this_ptr, ZEND_STRL("automaticHtml"), &__$true); } else { - zephir_get_strval(&name, name_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("automaticHtml"), &__$false); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "variable", NULL, 0, variable, &name); - zephir_check_call_status(); - RETURN_MM(); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Support_Debug_Dump, setStyles) +static PHP_METHOD(Phalcon_Flash_AbstractFlash, setCssClasses) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *styles_param = NULL, defaultStyles, _0; - zval styles; + zval *cssClasses_param = NULL; + zval cssClasses; zval *this_ptr = getThis(); - ZVAL_UNDEF(&styles); - ZVAL_UNDEF(&defaultStyles); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(styles) + ZVAL_UNDEF(&cssClasses); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(cssClasses) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &styles_param); - if (!styles_param) { - ZEPHIR_INIT_VAR(&styles); - array_init(&styles); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&styles, styles_param); - } - ZEPHIR_INIT_VAR(&defaultStyles); - zephir_create_array(&defaultStyles, 11, 0); - add_assoc_stringl_ex(&defaultStyles, SL("pre"), SL("background-color:#f3f3f3; font-size:11px; padding:10px; border:1px solid #ccc; text-align:left; color:#333")); - add_assoc_stringl_ex(&defaultStyles, SL("arr"), SL("color:red")); - add_assoc_stringl_ex(&defaultStyles, SL("bool"), SL("color:green")); - add_assoc_stringl_ex(&defaultStyles, SL("float"), SL("color:fuchsia")); - add_assoc_stringl_ex(&defaultStyles, SL("int"), SL("color:blue")); - add_assoc_stringl_ex(&defaultStyles, SL("null"), SL("color:black")); - add_assoc_stringl_ex(&defaultStyles, SL("num"), SL("color:navy")); - add_assoc_stringl_ex(&defaultStyles, SL("obj"), SL("color:purple")); - add_assoc_stringl_ex(&defaultStyles, SL("other"), SL("color:maroon")); - add_assoc_stringl_ex(&defaultStyles, SL("res"), SL("color:lime")); - add_assoc_stringl_ex(&defaultStyles, SL("str"), SL("color:teal")); - ZEPHIR_INIT_VAR(&_0); - zephir_fast_array_merge(&_0, &defaultStyles, &styles); - zephir_update_property_zval(this_ptr, ZEND_STRL("styles"), &_0); - RETURN_MM_MEMBER(getThis(), "styles"); + zephir_fetch_params(1, 1, 0, &cssClasses_param); + ZEPHIR_OBS_COPY_OR_DUP(&cssClasses, cssClasses_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("cssClasses"), &cssClasses); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Support_Debug_Dump, toJson) +static PHP_METHOD(Phalcon_Flash_AbstractFlash, setCssIconClasses) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *variable, variable_sub, _0, _1; + zval *cssIconClasses_param = NULL; + zval cssIconClasses; zval *this_ptr = getThis(); - ZVAL_UNDEF(&variable_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&cssIconClasses); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(variable) + Z_PARAM_ARRAY(cssIconClasses) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &variable); - zephir_read_property(&_0, this_ptr, ZEND_STRL("encode"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_1, ((128 | 64) | 256)); - ZEPHIR_RETURN_CALL_METHOD(&_0, "__invoke", NULL, 0, variable, &_1); - zephir_check_call_status(); - RETURN_MM(); + zephir_fetch_params(1, 1, 0, &cssIconClasses_param); + ZEPHIR_OBS_COPY_OR_DUP(&cssIconClasses, cssIconClasses_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("cssIconClasses"), &cssIconClasses); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Support_Debug_Dump, variable) +static PHP_METHOD(Phalcon_Flash_AbstractFlash, setCustomTemplate) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval name; - zval *variable, variable_sub, *name_param = NULL, _1, _2; + zval *customTemplate_param = NULL; + zval customTemplate; zval *this_ptr = getThis(); - ZVAL_UNDEF(&variable_sub); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_0); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(variable) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) + ZVAL_UNDEF(&customTemplate); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(customTemplate) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &variable, &name_param); - if (!name_param) { - ZEPHIR_INIT_VAR(&name); + zephir_fetch_params(1, 1, 0, &customTemplate_param); + if (UNEXPECTED(Z_TYPE_P(customTemplate_param) != IS_STRING && Z_TYPE_P(customTemplate_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'customTemplate' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(customTemplate_param) == IS_STRING)) { + zephir_get_strval(&customTemplate, customTemplate_param); } else { - zephir_get_strval(&name, name_param); + ZEPHIR_INIT_VAR(&customTemplate); } - ZEPHIR_INIT_VAR(&_0); - zephir_create_array(&_0, 2, 0); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "pre"); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getstyle", NULL, 0, &_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, 0, variable, &name); - zephir_check_call_status(); - zephir_array_update_string(&_0, SL(":output"), &_1, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_2); - ZVAL_STRING(&_2, "
:output
"); - ZEPHIR_RETURN_CALL_FUNCTION("strtr", NULL, 5, &_2, &_0); - zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("customTemplate"), &customTemplate); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Support_Debug_Dump, variables) +static PHP_METHOD(Phalcon_Flash_AbstractFlash, setEscaperService) { - zend_string *_4; - zend_ulong _3; - zval output; - zval key, value, _0, *_1, _2, _5$$3, _6$$3, _8$$4, _9$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_7 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *escaperService, escaperService_sub; zval *this_ptr = getThis(); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&output); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + ZVAL_UNDEF(&escaperService_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(escaperService, phalcon_html_escaper_escaperinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &escaperService); + zephir_update_property_zval(this_ptr, ZEND_STRL("escaperService"), escaperService); + RETURN_THISW(); +} - ZEPHIR_INIT_VAR(&output); - ZEPHIR_INIT_VAR(&_0); - zephir_get_args(&_0); - zephir_is_iterable(&_0, 0, "phalcon/Support/Debug/Dump.zep", 198); - if (Z_TYPE_P(&_0) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_0), _3, _4, _1) - { - ZEPHIR_INIT_NVAR(&key); - if (_4 != NULL) { - ZVAL_STR_COPY(&key, _4); - } else { - ZVAL_LONG(&key, _3); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _1); - ZEPHIR_INIT_NVAR(&_6$$3); - ZEPHIR_CONCAT_SV(&_6$$3, "var ", &key); - ZEPHIR_CALL_METHOD(&_5$$3, this_ptr, "one", &_7, 0, &value, &_6$$3); - zephir_check_call_status(); - zephir_concat_self(&output, &_5$$3); - } ZEND_HASH_FOREACH_END(); +static PHP_METHOD(Phalcon_Flash_AbstractFlash, setImplicitFlush) +{ + zval *implicitFlush_param = NULL, __$true, __$false; + zend_bool implicitFlush; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(implicitFlush) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &implicitFlush_param); + if (implicitFlush) { + zephir_update_property_zval(this_ptr, ZEND_STRL("implicitFlush"), &__$true); } else { - ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_2)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &_0, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &_0, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_9$$4); - ZEPHIR_CONCAT_SV(&_9$$4, "var ", &key); - ZEPHIR_CALL_METHOD(&_8$$4, this_ptr, "one", &_7, 0, &value, &_9$$4); - zephir_check_call_status(); - zephir_concat_self(&output, &_8$$4); - ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); - zephir_check_call_status(); - } + zephir_update_property_zval(this_ptr, ZEND_STRL("implicitFlush"), &__$false); } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - RETURN_CTOR(&output); + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Support_Debug_Dump, getStyle) +static PHP_METHOD(Phalcon_Flash_AbstractFlash, success) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *type_param = NULL, style, _0; - zval type; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *message_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&style); + ZVAL_UNDEF(&message); ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(type) + Z_PARAM_STR(message) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &type_param); - if (UNEXPECTED(Z_TYPE_P(type_param) != IS_STRING && Z_TYPE_P(type_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'type' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(type_param) == IS_STRING)) { - zephir_get_strval(&type, type_param); - } else { - ZEPHIR_INIT_VAR(&type); - } - zephir_memory_observe(&style); - zephir_read_property(&_0, this_ptr, ZEND_STRL("styles"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&style, &_0, &type, 0))) { - RETURN_MM_STRING("color:gray"); - } - RETURN_CCTOR(&style); + zephir_fetch_params(1, 1, 0, &message_param); + zephir_get_strval(&message, message_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "success"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "message", NULL, 0, &_0, &message); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Support_Debug_Dump, output) +static PHP_METHOD(Phalcon_Flash_AbstractFlash, outputMessage) { - zend_class_entry *_74$$16, *_91$$17; - zend_bool _15$$5, _16$$5, _17$$5, _27$$7, _28$$7, _29$$7, _42$$9; - zend_string *_7$$4, *_50$$12; - zend_ulong _6$$4, _49$$12; - zval _166, _1$$4, _11$$5, _23$$7, _34$$9, _105$$9, _38$$10, _53$$13, _61$$14, _79$$16, _95$$17, _116$$21, _122$$22, _129$$24, _135$$25, _144$$26, _148$$27, _151$$28, _154$$29, _159$$30, _163$$31; + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_10 = NULL, *_19 = NULL, *_71 = NULL, *_72 = NULL, *_75 = NULL, *_77 = NULL, *_85 = NULL, *_88 = NULL, *_89 = NULL, *_93 = NULL, *_101 = NULL; - zend_long tab, ZEPHIR_LAST_CALL_STATUS; - zval name, _0$$3; - zval *variable, variable_sub, *name_param = NULL, *tab_param = NULL, key, value, output, space, type, attr, _147, _167, _168, _2$$4, _3$$4, *_4$$4, _5$$4, _32$$4, _33$$4, _8$$5, _9$$5, _12$$5, _13$$5, _14$$5, _18$$5, _20$$5, _21$$7, _22$$7, _24$$7, _25$$7, _26$$7, _30$$7, _31$$7, _35$$9, _36$$9, _37$$9, _41$$9, _103$$9, _104$$9, _106$$9, _107$$9, _142$$9, _143$$9, _39$$10, _40$$10, _43$$11, _44$$11, _45$$11, _46$$12, *_47$$12, _48$$12, _51$$13, _52$$13, _54$$13, _55$$13, _56$$13, _57$$13, _58$$13, _59$$14, _60$$14, _62$$14, _63$$14, _64$$14, _65$$14, _66$$14, reflect$$15, props$$15, property$$15, _67$$15, *_68$$15, _69$$15, _70$$16, _73$$16, _76$$16, _78$$16, _80$$16, _81$$16, _82$$16, _83$$16, _84$$16, _86$$16, _87$$17, _90$$17, _92$$17, _94$$17, _96$$17, _97$$17, _98$$17, _99$$17, _100$$17, _102$$17, _108$$18, _109$$18, _110$$18, *_111$$19, _112$$19, _139$$19, _140$$19, _141$$19, _113$$20, _114$$21, _115$$21, _117$$21, _118$$21, _119$$21, _120$$22, _121$$22, _123$$22, _124$$22, _125$$22, _126$$23, _127$$24, _128$$24, _130$$24, _131$$24, _132$$24, _133$$25, _134$$25, _136$$25, _137$$25, _138$$25, _145$$26, _146$$26, _149$$27, _150$$27, _152$$28, _153$$28, _155$$29, _156$$29, _157$$29, _158$$29, _160$$30, _161$$30, _162$$30, _164$$31, _165$$31; + zephir_fcall_cache_entry *_4 = NULL, *_5 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *type_param = NULL, *message = NULL, message_sub, content, html, item, prepared, *_2, _3, _1$$4, _6$$5, _7$$8; + zval type; zval *this_ptr = getThis(); - ZVAL_UNDEF(&variable_sub); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&output); - ZVAL_UNDEF(&space); ZVAL_UNDEF(&type); - ZVAL_UNDEF(&attr); - ZVAL_UNDEF(&_147); - ZVAL_UNDEF(&_167); - ZVAL_UNDEF(&_168); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_32$$4); - ZVAL_UNDEF(&_33$$4); - ZVAL_UNDEF(&_8$$5); - ZVAL_UNDEF(&_9$$5); - ZVAL_UNDEF(&_12$$5); - ZVAL_UNDEF(&_13$$5); - ZVAL_UNDEF(&_14$$5); - ZVAL_UNDEF(&_18$$5); - ZVAL_UNDEF(&_20$$5); - ZVAL_UNDEF(&_21$$7); - ZVAL_UNDEF(&_22$$7); - ZVAL_UNDEF(&_24$$7); - ZVAL_UNDEF(&_25$$7); - ZVAL_UNDEF(&_26$$7); - ZVAL_UNDEF(&_30$$7); - ZVAL_UNDEF(&_31$$7); - ZVAL_UNDEF(&_35$$9); - ZVAL_UNDEF(&_36$$9); - ZVAL_UNDEF(&_37$$9); - ZVAL_UNDEF(&_41$$9); - ZVAL_UNDEF(&_103$$9); - ZVAL_UNDEF(&_104$$9); - ZVAL_UNDEF(&_106$$9); - ZVAL_UNDEF(&_107$$9); - ZVAL_UNDEF(&_142$$9); - ZVAL_UNDEF(&_143$$9); - ZVAL_UNDEF(&_39$$10); - ZVAL_UNDEF(&_40$$10); - ZVAL_UNDEF(&_43$$11); - ZVAL_UNDEF(&_44$$11); - ZVAL_UNDEF(&_45$$11); - ZVAL_UNDEF(&_46$$12); - ZVAL_UNDEF(&_48$$12); - ZVAL_UNDEF(&_51$$13); - ZVAL_UNDEF(&_52$$13); - ZVAL_UNDEF(&_54$$13); - ZVAL_UNDEF(&_55$$13); - ZVAL_UNDEF(&_56$$13); - ZVAL_UNDEF(&_57$$13); - ZVAL_UNDEF(&_58$$13); - ZVAL_UNDEF(&_59$$14); - ZVAL_UNDEF(&_60$$14); - ZVAL_UNDEF(&_62$$14); - ZVAL_UNDEF(&_63$$14); - ZVAL_UNDEF(&_64$$14); - ZVAL_UNDEF(&_65$$14); - ZVAL_UNDEF(&_66$$14); - ZVAL_UNDEF(&reflect$$15); - ZVAL_UNDEF(&props$$15); - ZVAL_UNDEF(&property$$15); - ZVAL_UNDEF(&_67$$15); - ZVAL_UNDEF(&_69$$15); - ZVAL_UNDEF(&_70$$16); - ZVAL_UNDEF(&_73$$16); - ZVAL_UNDEF(&_76$$16); - ZVAL_UNDEF(&_78$$16); - ZVAL_UNDEF(&_80$$16); - ZVAL_UNDEF(&_81$$16); - ZVAL_UNDEF(&_82$$16); - ZVAL_UNDEF(&_83$$16); - ZVAL_UNDEF(&_84$$16); - ZVAL_UNDEF(&_86$$16); - ZVAL_UNDEF(&_87$$17); - ZVAL_UNDEF(&_90$$17); - ZVAL_UNDEF(&_92$$17); - ZVAL_UNDEF(&_94$$17); - ZVAL_UNDEF(&_96$$17); - ZVAL_UNDEF(&_97$$17); - ZVAL_UNDEF(&_98$$17); - ZVAL_UNDEF(&_99$$17); - ZVAL_UNDEF(&_100$$17); - ZVAL_UNDEF(&_102$$17); - ZVAL_UNDEF(&_108$$18); - ZVAL_UNDEF(&_109$$18); - ZVAL_UNDEF(&_110$$18); - ZVAL_UNDEF(&_112$$19); - ZVAL_UNDEF(&_139$$19); - ZVAL_UNDEF(&_140$$19); - ZVAL_UNDEF(&_141$$19); - ZVAL_UNDEF(&_113$$20); - ZVAL_UNDEF(&_114$$21); - ZVAL_UNDEF(&_115$$21); - ZVAL_UNDEF(&_117$$21); - ZVAL_UNDEF(&_118$$21); - ZVAL_UNDEF(&_119$$21); - ZVAL_UNDEF(&_120$$22); - ZVAL_UNDEF(&_121$$22); - ZVAL_UNDEF(&_123$$22); - ZVAL_UNDEF(&_124$$22); - ZVAL_UNDEF(&_125$$22); - ZVAL_UNDEF(&_126$$23); - ZVAL_UNDEF(&_127$$24); - ZVAL_UNDEF(&_128$$24); - ZVAL_UNDEF(&_130$$24); - ZVAL_UNDEF(&_131$$24); - ZVAL_UNDEF(&_132$$24); - ZVAL_UNDEF(&_133$$25); - ZVAL_UNDEF(&_134$$25); - ZVAL_UNDEF(&_136$$25); - ZVAL_UNDEF(&_137$$25); - ZVAL_UNDEF(&_138$$25); - ZVAL_UNDEF(&_145$$26); - ZVAL_UNDEF(&_146$$26); - ZVAL_UNDEF(&_149$$27); - ZVAL_UNDEF(&_150$$27); - ZVAL_UNDEF(&_152$$28); - ZVAL_UNDEF(&_153$$28); - ZVAL_UNDEF(&_155$$29); - ZVAL_UNDEF(&_156$$29); - ZVAL_UNDEF(&_157$$29); - ZVAL_UNDEF(&_158$$29); - ZVAL_UNDEF(&_160$$30); - ZVAL_UNDEF(&_161$$30); - ZVAL_UNDEF(&_162$$30); - ZVAL_UNDEF(&_164$$31); - ZVAL_UNDEF(&_165$$31); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_166); + ZVAL_UNDEF(&message_sub); + ZVAL_UNDEF(&content); + ZVAL_UNDEF(&html); + ZVAL_UNDEF(&item); + ZVAL_UNDEF(&prepared); + ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_11$$5); - ZVAL_UNDEF(&_23$$7); - ZVAL_UNDEF(&_34$$9); - ZVAL_UNDEF(&_105$$9); - ZVAL_UNDEF(&_38$$10); - ZVAL_UNDEF(&_53$$13); - ZVAL_UNDEF(&_61$$14); - ZVAL_UNDEF(&_79$$16); - ZVAL_UNDEF(&_95$$17); - ZVAL_UNDEF(&_116$$21); - ZVAL_UNDEF(&_122$$22); - ZVAL_UNDEF(&_129$$24); - ZVAL_UNDEF(&_135$$25); - ZVAL_UNDEF(&_144$$26); - ZVAL_UNDEF(&_148$$27); - ZVAL_UNDEF(&_151$$28); - ZVAL_UNDEF(&_154$$29); - ZVAL_UNDEF(&_159$$30); - ZVAL_UNDEF(&_163$$31); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ZVAL(variable) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) - Z_PARAM_LONG(tab) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &variable, &name_param, &tab_param); - if (!name_param) { - ZEPHIR_INIT_VAR(&name); - } else { - zephir_get_strval(&name, name_param); - } - if (!tab_param) { - tab = 1; - } else { - } - ZEPHIR_INIT_VAR(&space); - ZVAL_STRING(&space, " "); - ZEPHIR_INIT_VAR(&output); - ZVAL_STRING(&output, ""); - if (!(ZEPHIR_IS_EMPTY(&name))) { - ZEPHIR_INIT_VAR(&_0$$3); - ZEPHIR_CONCAT_VS(&_0$$3, &name, " "); - ZEPHIR_CPY_WRT(&output, &_0$$3); - } - if (Z_TYPE_P(variable) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_1$$4); - zephir_create_array(&_1$$4, 2, 0); - ZEPHIR_INIT_VAR(&_3$$4); - ZVAL_STRING(&_3$$4, "arr"); - ZEPHIR_CALL_METHOD(&_2$$4, this_ptr, "getstyle", NULL, 0, &_3$$4); - zephir_check_call_status(); - zephir_array_update_string(&_1$$4, SL(":style"), &_2$$4, PH_COPY | PH_SEPARATE); - add_assoc_long_ex(&_1$$4, SL(":count"), zephir_fast_count_int(variable)); - ZEPHIR_INIT_NVAR(&_3$$4); - ZVAL_STRING(&_3$$4, "Array (:count) (\n"); - ZEPHIR_CALL_FUNCTION(&_2$$4, "strtr", NULL, 5, &_3$$4, &_1$$4); - zephir_check_call_status(); - zephir_concat_self(&output, &_2$$4); - zephir_is_iterable(variable, 0, "phalcon/Support/Debug/Dump.zep", 248); - if (Z_TYPE_P(variable) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(variable), _6$$4, _7$$4, _4$$4) - { - ZEPHIR_INIT_NVAR(&key); - if (_7$$4 != NULL) { - ZVAL_STR_COPY(&key, _7$$4); - } else { - ZVAL_LONG(&key, _6$$4); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _4$$4); - ZVAL_LONG(&_8$$5, tab); - ZEPHIR_CALL_FUNCTION(&_9$$5, "str_repeat", &_10, 1, &space, &_8$$5); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_11$$5); - zephir_create_array(&_11$$5, 2, 0); - ZEPHIR_INIT_NVAR(&_13$$5); - ZVAL_STRING(&_13$$5, "arr"); - ZEPHIR_CALL_METHOD(&_12$$5, this_ptr, "getstyle", NULL, 0, &_13$$5); - zephir_check_call_status(); - zephir_array_update_string(&_11$$5, SL(":style"), &_12$$5, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_11$$5, SL(":key"), &key, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_13$$5); - ZVAL_STRING(&_13$$5, "[:key] => "); - ZEPHIR_CALL_FUNCTION(&_12$$5, "strtr", NULL, 5, &_13$$5, &_11$$5); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_14$$5); - ZEPHIR_CONCAT_VV(&_14$$5, &_9$$5, &_12$$5); - zephir_concat_self(&output, &_14$$5); - _15$$5 = tab == 1; - if (_15$$5) { - _15$$5 = !ZEPHIR_IS_STRING(&name, ""); - } - _16$$5 = _15$$5; - if (_16$$5) { - _16$$5 = !(Z_TYPE_P(&key) == IS_LONG); - } - _17$$5 = _16$$5; - if (_17$$5) { - _17$$5 = ZEPHIR_IS_EQUAL(&name, &key); - } - if (_17$$5) { - continue; - } - ZEPHIR_INIT_NVAR(&_13$$5); - ZVAL_STRING(&_13$$5, ""); - ZVAL_LONG(&_8$$5, (tab + 1)); - ZEPHIR_CALL_METHOD(&_18$$5, this_ptr, "output", &_19, 0, &value, &_13$$5, &_8$$5); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_20$$5); - ZEPHIR_CONCAT_VS(&_20$$5, &_18$$5, "\n"); - zephir_concat_self(&output, &_20$$5); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, variable, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5$$4, variable, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5$$4)) { - break; - } - ZEPHIR_CALL_METHOD(&key, variable, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, variable, "current", NULL, 0); - zephir_check_call_status(); - ZVAL_LONG(&_21$$7, tab); - ZEPHIR_CALL_FUNCTION(&_22$$7, "str_repeat", &_10, 1, &space, &_21$$7); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_23$$7); - zephir_create_array(&_23$$7, 2, 0); - ZEPHIR_INIT_NVAR(&_25$$7); - ZVAL_STRING(&_25$$7, "arr"); - ZEPHIR_CALL_METHOD(&_24$$7, this_ptr, "getstyle", NULL, 0, &_25$$7); - zephir_check_call_status(); - zephir_array_update_string(&_23$$7, SL(":style"), &_24$$7, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_23$$7, SL(":key"), &key, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_25$$7); - ZVAL_STRING(&_25$$7, "[:key] => "); - ZEPHIR_CALL_FUNCTION(&_24$$7, "strtr", NULL, 5, &_25$$7, &_23$$7); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_26$$7); - ZEPHIR_CONCAT_VV(&_26$$7, &_22$$7, &_24$$7); - zephir_concat_self(&output, &_26$$7); - _27$$7 = tab == 1; - if (_27$$7) { - _27$$7 = !ZEPHIR_IS_STRING(&name, ""); - } - _28$$7 = _27$$7; - if (_28$$7) { - _28$$7 = !(Z_TYPE_P(&key) == IS_LONG); - } - _29$$7 = _28$$7; - if (_29$$7) { - _29$$7 = ZEPHIR_IS_EQUAL(&name, &key); - } - if (_29$$7) { - continue; - } - ZEPHIR_INIT_NVAR(&_25$$7); - ZVAL_STRING(&_25$$7, ""); - ZVAL_LONG(&_21$$7, (tab + 1)); - ZEPHIR_CALL_METHOD(&_30$$7, this_ptr, "output", &_19, 0, &value, &_25$$7, &_21$$7); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_31$$7); - ZEPHIR_CONCAT_VS(&_31$$7, &_30$$7, "\n"); - zephir_concat_self(&output, &_31$$7); - ZEPHIR_CALL_METHOD(NULL, variable, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - ZVAL_LONG(&_32$$4, (tab - 1)); - ZEPHIR_CALL_FUNCTION(&_33$$4, "str_repeat", &_10, 1, &space, &_32$$4); - zephir_check_call_status(); - ZEPHIR_CONCAT_VVS(return_value, &output, &_33$$4, ")"); - RETURN_MM(); - } - if (Z_TYPE_P(variable) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_34$$9); - zephir_create_array(&_34$$9, 2, 0); - ZEPHIR_INIT_VAR(&_36$$9); - ZVAL_STRING(&_36$$9, "obj"); - ZEPHIR_CALL_METHOD(&_35$$9, this_ptr, "getstyle", NULL, 0, &_36$$9); - zephir_check_call_status(); - zephir_array_update_string(&_34$$9, SL(":style"), &_35$$9, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_36$$9); - zephir_get_class(&_36$$9, variable, 0); - zephir_array_update_string(&_34$$9, SL(":class"), &_36$$9, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_36$$9); - ZVAL_STRING(&_36$$9, "Object :class"); - ZEPHIR_CALL_FUNCTION(&_35$$9, "strtr", NULL, 5, &_36$$9, &_34$$9); - zephir_check_call_status(); - zephir_concat_self(&output, &_35$$9); - ZEPHIR_CALL_FUNCTION(&_37$$9, "get_parent_class", NULL, 0, variable); - zephir_check_call_status(); - if (zephir_is_true(&_37$$9)) { - ZEPHIR_INIT_VAR(&_38$$10); - zephir_create_array(&_38$$10, 2, 0); - ZEPHIR_INIT_VAR(&_40$$10); - ZVAL_STRING(&_40$$10, "obj"); - ZEPHIR_CALL_METHOD(&_39$$10, this_ptr, "getstyle", NULL, 0, &_40$$10); - zephir_check_call_status(); - zephir_array_update_string(&_38$$10, SL(":style"), &_39$$10, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_FUNCTION(&_39$$10, "get_parent_class", NULL, 0, variable); - zephir_check_call_status(); - zephir_array_update_string(&_38$$10, SL(":parent"), &_39$$10, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_40$$10); - ZVAL_STRING(&_40$$10, " extends :parent"); - ZEPHIR_CALL_FUNCTION(&_39$$10, "strtr", NULL, 5, &_40$$10, &_38$$10); - zephir_check_call_status(); - zephir_concat_self(&output, &_39$$10); - } - zephir_concat_self_str(&output, SL(" (\n")); - zephir_read_property(&_41$$9, this_ptr, ZEND_STRL("detailed"), PH_NOISY_CC | PH_READONLY); - _42$$9 = !zephir_is_true(&_41$$9); - if (!(_42$$9)) { - _42$$9 = zephir_is_instance_of(variable, SL("stdClass")); - } - if (zephir_instance_of_ev(variable, phalcon_di_di_ce)) { - ZVAL_LONG(&_43$$11, tab); - ZEPHIR_CALL_FUNCTION(&_44$$11, "str_repeat", &_10, 1, &space, &_43$$11); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_45$$11); - ZEPHIR_CONCAT_VS(&_45$$11, &_44$$11, "[skipped]\n"); - zephir_concat_self(&output, &_45$$11); - } else if (_42$$9) { - ZEPHIR_CALL_FUNCTION(&_46$$12, "get_object_vars", NULL, 426, variable); - zephir_check_call_status(); - zephir_is_iterable(&_46$$12, 0, "phalcon/Support/Debug/Dump.zep", 280); - if (Z_TYPE_P(&_46$$12) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_46$$12), _49$$12, _50$$12, _47$$12) - { - ZEPHIR_INIT_NVAR(&key); - if (_50$$12 != NULL) { - ZVAL_STR_COPY(&key, _50$$12); - } else { - ZVAL_LONG(&key, _49$$12); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _47$$12); - ZVAL_LONG(&_51$$13, tab); - ZEPHIR_CALL_FUNCTION(&_52$$13, "str_repeat", &_10, 1, &space, &_51$$13); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_53$$13); - zephir_create_array(&_53$$13, 3, 0); - ZEPHIR_INIT_NVAR(&_55$$13); - ZVAL_STRING(&_55$$13, "obj"); - ZEPHIR_CALL_METHOD(&_54$$13, this_ptr, "getstyle", NULL, 0, &_55$$13); - zephir_check_call_status(); - zephir_array_update_string(&_53$$13, SL(":style"), &_54$$13, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_53$$13, SL(":key"), &key, PH_COPY | PH_SEPARATE); - add_assoc_stringl_ex(&_53$$13, SL(":type"), SL("public")); - ZEPHIR_INIT_NVAR(&_55$$13); - ZVAL_STRING(&_55$$13, "->:key (:type) = "); - ZEPHIR_CALL_FUNCTION(&_54$$13, "strtr", NULL, 5, &_55$$13, &_53$$13); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_56$$13); - ZEPHIR_CONCAT_VV(&_56$$13, &_52$$13, &_54$$13); - zephir_concat_self(&output, &_56$$13); - ZEPHIR_INIT_NVAR(&_55$$13); - ZVAL_STRING(&_55$$13, ""); - ZVAL_LONG(&_51$$13, (tab + 1)); - ZEPHIR_CALL_METHOD(&_57$$13, this_ptr, "output", &_19, 0, &value, &_55$$13, &_51$$13); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_58$$13); - ZEPHIR_CONCAT_VS(&_58$$13, &_57$$13, "\n"); - zephir_concat_self(&output, &_58$$13); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_46$$12, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_48$$12, &_46$$12, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_48$$12)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &_46$$12, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &_46$$12, "current", NULL, 0); - zephir_check_call_status(); - ZVAL_LONG(&_59$$14, tab); - ZEPHIR_CALL_FUNCTION(&_60$$14, "str_repeat", &_10, 1, &space, &_59$$14); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_61$$14); - zephir_create_array(&_61$$14, 3, 0); - ZEPHIR_INIT_NVAR(&_63$$14); - ZVAL_STRING(&_63$$14, "obj"); - ZEPHIR_CALL_METHOD(&_62$$14, this_ptr, "getstyle", NULL, 0, &_63$$14); - zephir_check_call_status(); - zephir_array_update_string(&_61$$14, SL(":style"), &_62$$14, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_61$$14, SL(":key"), &key, PH_COPY | PH_SEPARATE); - add_assoc_stringl_ex(&_61$$14, SL(":type"), SL("public")); - ZEPHIR_INIT_NVAR(&_63$$14); - ZVAL_STRING(&_63$$14, "->:key (:type) = "); - ZEPHIR_CALL_FUNCTION(&_62$$14, "strtr", NULL, 5, &_63$$14, &_61$$14); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_64$$14); - ZEPHIR_CONCAT_VV(&_64$$14, &_60$$14, &_62$$14); - zephir_concat_self(&output, &_64$$14); - ZEPHIR_INIT_NVAR(&_63$$14); - ZVAL_STRING(&_63$$14, ""); - ZVAL_LONG(&_59$$14, (tab + 1)); - ZEPHIR_CALL_METHOD(&_65$$14, this_ptr, "output", &_19, 0, &value, &_63$$14, &_59$$14); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_66$$14); - ZEPHIR_CONCAT_VS(&_66$$14, &_65$$14, "\n"); - zephir_concat_self(&output, &_66$$14); - ZEPHIR_CALL_METHOD(NULL, &_46$$12, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&key); - } else { - ZEPHIR_INIT_VAR(&reflect$$15); - object_init_ex(&reflect$$15, zephir_get_internal_ce(SL("reflectionclass"))); - ZEPHIR_CALL_METHOD(NULL, &reflect$$15, "__construct", NULL, 154, variable); - zephir_check_call_status(); - ZVAL_LONG(&_67$$15, ((1 | 2) | 4)); - ZEPHIR_CALL_METHOD(&props$$15, &reflect$$15, "getproperties", NULL, 165, &_67$$15); - zephir_check_call_status(); - zephir_is_iterable(&props$$15, 0, "phalcon/Support/Debug/Dump.zep", 306); - if (Z_TYPE_P(&props$$15) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&props$$15), _68$$15) - { - ZEPHIR_INIT_NVAR(&property$$15); - ZVAL_COPY(&property$$15, _68$$15); - ZVAL_BOOL(&_70$$16, 1); - ZEPHIR_CALL_METHOD(NULL, &property$$15, "setaccessible", &_71, 0, &_70$$16); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&key, &property$$15, "getname", &_72, 0); - zephir_check_call_status(); - _74$$16 = zephir_fetch_class_str_ex(SL("Reflection"), ZEND_FETCH_CLASS_AUTO); - ZEPHIR_CALL_METHOD(&_76$$16, &property$$15, "getmodifiers", &_77, 0); - zephir_check_call_status(); - ZEPHIR_CALL_CE_STATIC(&_73$$16, _74$$16, "getmodifiernames", &_75, 0, &_76$$16); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&type); - zephir_fast_join_str(&type, SL(" "), &_73$$16); - ZVAL_LONG(&_70$$16, tab); - ZEPHIR_CALL_FUNCTION(&_78$$16, "str_repeat", &_10, 1, &space, &_70$$16); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_79$$16); - zephir_create_array(&_79$$16, 3, 0); - ZEPHIR_INIT_NVAR(&_81$$16); - ZVAL_STRING(&_81$$16, "obj"); - ZEPHIR_CALL_METHOD(&_80$$16, this_ptr, "getstyle", NULL, 0, &_81$$16); - zephir_check_call_status(); - zephir_array_update_string(&_79$$16, SL(":style"), &_80$$16, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_79$$16, SL(":key"), &key, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_79$$16, SL(":type"), &type, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_81$$16); - ZVAL_STRING(&_81$$16, "->:key (:type) = "); - ZEPHIR_CALL_FUNCTION(&_80$$16, "strtr", NULL, 5, &_81$$16, &_79$$16); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_82$$16); - ZEPHIR_CONCAT_VV(&_82$$16, &_78$$16, &_80$$16); - zephir_concat_self(&output, &_82$$16); - ZEPHIR_CALL_METHOD(&_84$$16, &property$$15, "getvalue", &_85, 0, variable); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_81$$16); - ZVAL_STRING(&_81$$16, ""); - ZVAL_LONG(&_70$$16, (tab + 1)); - ZEPHIR_CALL_METHOD(&_83$$16, this_ptr, "output", &_19, 0, &_84$$16, &_81$$16, &_70$$16); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_86$$16); - ZEPHIR_CONCAT_VS(&_86$$16, &_83$$16, "\n"); - zephir_concat_self(&output, &_86$$16); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &props$$15, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_69$$15, &props$$15, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_69$$15)) { - break; - } - ZEPHIR_CALL_METHOD(&property$$15, &props$$15, "current", NULL, 0); - zephir_check_call_status(); - ZVAL_BOOL(&_87$$17, 1); - ZEPHIR_CALL_METHOD(NULL, &property$$15, "setaccessible", &_88, 0, &_87$$17); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&key, &property$$15, "getname", &_89, 0); - zephir_check_call_status(); - _91$$17 = zephir_fetch_class_str_ex(SL("Reflection"), ZEND_FETCH_CLASS_AUTO); - ZEPHIR_CALL_METHOD(&_92$$17, &property$$15, "getmodifiers", &_93, 0); - zephir_check_call_status(); - ZEPHIR_CALL_CE_STATIC(&_90$$17, _91$$17, "getmodifiernames", &_75, 0, &_92$$17); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&type); - zephir_fast_join_str(&type, SL(" "), &_90$$17); - ZVAL_LONG(&_87$$17, tab); - ZEPHIR_CALL_FUNCTION(&_94$$17, "str_repeat", &_10, 1, &space, &_87$$17); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_95$$17); - zephir_create_array(&_95$$17, 3, 0); - ZEPHIR_INIT_NVAR(&_97$$17); - ZVAL_STRING(&_97$$17, "obj"); - ZEPHIR_CALL_METHOD(&_96$$17, this_ptr, "getstyle", NULL, 0, &_97$$17); - zephir_check_call_status(); - zephir_array_update_string(&_95$$17, SL(":style"), &_96$$17, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_95$$17, SL(":key"), &key, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_95$$17, SL(":type"), &type, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_97$$17); - ZVAL_STRING(&_97$$17, "->:key (:type) = "); - ZEPHIR_CALL_FUNCTION(&_96$$17, "strtr", NULL, 5, &_97$$17, &_95$$17); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_98$$17); - ZEPHIR_CONCAT_VV(&_98$$17, &_94$$17, &_96$$17); - zephir_concat_self(&output, &_98$$17); - ZEPHIR_CALL_METHOD(&_100$$17, &property$$15, "getvalue", &_101, 0, variable); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_97$$17); - ZVAL_STRING(&_97$$17, ""); - ZVAL_LONG(&_87$$17, (tab + 1)); - ZEPHIR_CALL_METHOD(&_99$$17, this_ptr, "output", &_19, 0, &_100$$17, &_97$$17, &_87$$17); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_102$$17); - ZEPHIR_CONCAT_VS(&_102$$17, &_99$$17, "\n"); - zephir_concat_self(&output, &_102$$17); - ZEPHIR_CALL_METHOD(NULL, &props$$15, "next", NULL, 0); - zephir_check_call_status(); - } + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_7$$8); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(type) + Z_PARAM_ZVAL(message) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &type_param, &message); + zephir_get_strval(&type, type_param); + ZEPHIR_SEPARATE_PARAM(message); + ZEPHIR_INIT_VAR(&content); + ZVAL_STRING(&content, ""); + _0 = Z_TYPE_P(message) != IS_ARRAY; + if (_0) { + _0 = Z_TYPE_P(message) != IS_STRING; + } + if (_0) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_flash_exception_ce, "The message must be an array or a string", "phalcon/Flash/AbstractFlash.zep", 334); + return; + } + if (Z_TYPE_P(message) != IS_ARRAY) { + ZEPHIR_INIT_VAR(&_1$$4); + zephir_create_array(&_1$$4, 1, 0); + zephir_array_fast_append(&_1$$4, message); + ZEPHIR_CPY_WRT(message, &_1$$4); + } + zephir_is_iterable(message, 0, "phalcon/Flash/AbstractFlash.zep", 360); + if (Z_TYPE_P(message) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(message), _2) + { + ZEPHIR_INIT_NVAR(&item); + ZVAL_COPY(&item, _2); + ZEPHIR_CALL_METHOD(&prepared, this_ptr, "prepareescapedmessage", &_4, 82, &item); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&html, this_ptr, "preparehtmlmessage", &_5, 83, &type, &prepared); + zephir_check_call_status(); + zephir_read_property(&_6$$5, this_ptr, ZEND_STRL("implicitFlush"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_6$$5)) { + zend_print_zval(&html, 0); + } else { + zephir_concat_self(&content, &html); + zephir_update_property_array_append(this_ptr, SL("messages"), &html); } - ZEPHIR_INIT_NVAR(&property$$15); - } - ZEPHIR_CALL_FUNCTION(&attr, "get_class_methods", NULL, 0, variable); - zephir_check_call_status(); - ZVAL_LONG(&_103$$9, tab); - ZEPHIR_CALL_FUNCTION(&_104$$9, "str_repeat", &_10, 1, &space, &_103$$9); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_105$$9); - zephir_create_array(&_105$$9, 3, 0); - ZEPHIR_INIT_NVAR(&_36$$9); - ZVAL_STRING(&_36$$9, "obj"); - ZEPHIR_CALL_METHOD(&_106$$9, this_ptr, "getstyle", NULL, 0, &_36$$9); - zephir_check_call_status(); - zephir_array_update_string(&_105$$9, SL(":style"), &_106$$9, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_36$$9); - zephir_get_class(&_36$$9, variable, 0); - zephir_array_update_string(&_105$$9, SL(":class"), &_36$$9, PH_COPY | PH_SEPARATE); - add_assoc_long_ex(&_105$$9, SL(":count"), zephir_fast_count_int(&attr)); - ZEPHIR_INIT_NVAR(&_36$$9); - ZVAL_STRING(&_36$$9, ":class methods: (:count) (\n"); - ZEPHIR_CALL_FUNCTION(&_106$$9, "strtr", NULL, 5, &_36$$9, &_105$$9); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, message, "rewind", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_107$$9); - ZEPHIR_CONCAT_VV(&_107$$9, &_104$$9, &_106$$9); - zephir_concat_self(&output, &_107$$9); - ZEPHIR_INIT_NVAR(&_36$$9); - zephir_get_class(&_36$$9, variable, 0); - zephir_read_property(&_103$$9, this_ptr, ZEND_STRL("methods"), PH_NOISY_CC | PH_READONLY); - if (zephir_fast_in_array(&_36$$9, &_103$$9)) { - ZVAL_LONG(&_108$$18, tab); - ZEPHIR_CALL_FUNCTION(&_109$$18, "str_repeat", &_10, 1, &space, &_108$$18); + while (1) { + ZEPHIR_CALL_METHOD(&_3, message, "valid", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_110$$18); - ZEPHIR_CONCAT_VS(&_110$$18, &_109$$18, "[already listed]\n"); - zephir_concat_self(&output, &_110$$18); - } else { - zephir_is_iterable(&attr, 0, "phalcon/Support/Debug/Dump.zep", 324); - if (Z_TYPE_P(&attr) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&attr), _111$$19) - { - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _111$$19); - ZEPHIR_INIT_NVAR(&_113$$20); - zephir_get_class(&_113$$20, variable, 0); - zephir_update_property_array_append(this_ptr, SL("methods"), &_113$$20); - if (ZEPHIR_IS_STRING(&value, "__construct")) { - ZVAL_LONG(&_114$$21, (tab + 1)); - ZEPHIR_CALL_FUNCTION(&_115$$21, "str_repeat", &_10, 1, &space, &_114$$21); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_116$$21); - zephir_create_array(&_116$$21, 2, 0); - ZEPHIR_INIT_NVAR(&_118$$21); - ZVAL_STRING(&_118$$21, "obj"); - ZEPHIR_CALL_METHOD(&_117$$21, this_ptr, "getstyle", NULL, 0, &_118$$21); - zephir_check_call_status(); - zephir_array_update_string(&_116$$21, SL(":style"), &_117$$21, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_116$$21, SL(":method"), &value, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_118$$21); - ZVAL_STRING(&_118$$21, "->:method(); [constructor]\n"); - ZEPHIR_CALL_FUNCTION(&_117$$21, "strtr", NULL, 5, &_118$$21, &_116$$21); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_119$$21); - ZEPHIR_CONCAT_VV(&_119$$21, &_115$$21, &_117$$21); - zephir_concat_self(&output, &_119$$21); - } else { - ZVAL_LONG(&_120$$22, (tab + 1)); - ZEPHIR_CALL_FUNCTION(&_121$$22, "str_repeat", &_10, 1, &space, &_120$$22); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_122$$22); - zephir_create_array(&_122$$22, 2, 0); - ZEPHIR_INIT_NVAR(&_124$$22); - ZVAL_STRING(&_124$$22, "obj"); - ZEPHIR_CALL_METHOD(&_123$$22, this_ptr, "getstyle", NULL, 0, &_124$$22); - zephir_check_call_status(); - zephir_array_update_string(&_122$$22, SL(":style"), &_123$$22, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_122$$22, SL(":method"), &value, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_124$$22); - ZVAL_STRING(&_124$$22, "->:method();\n"); - ZEPHIR_CALL_FUNCTION(&_123$$22, "strtr", NULL, 5, &_124$$22, &_122$$22); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_125$$22); - ZEPHIR_CONCAT_VV(&_125$$22, &_121$$22, &_123$$22); - zephir_concat_self(&output, &_125$$22); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &attr, "rewind", NULL, 0); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&item, message, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&prepared, this_ptr, "prepareescapedmessage", &_4, 82, &item); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_112$$19, &attr, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_112$$19)) { - break; - } - ZEPHIR_CALL_METHOD(&value, &attr, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_126$$23); - zephir_get_class(&_126$$23, variable, 0); - zephir_update_property_array_append(this_ptr, SL("methods"), &_126$$23); - if (ZEPHIR_IS_STRING(&value, "__construct")) { - ZVAL_LONG(&_127$$24, (tab + 1)); - ZEPHIR_CALL_FUNCTION(&_128$$24, "str_repeat", &_10, 1, &space, &_127$$24); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_129$$24); - zephir_create_array(&_129$$24, 2, 0); - ZEPHIR_INIT_NVAR(&_131$$24); - ZVAL_STRING(&_131$$24, "obj"); - ZEPHIR_CALL_METHOD(&_130$$24, this_ptr, "getstyle", NULL, 0, &_131$$24); - zephir_check_call_status(); - zephir_array_update_string(&_129$$24, SL(":style"), &_130$$24, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_129$$24, SL(":method"), &value, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_131$$24); - ZVAL_STRING(&_131$$24, "->:method(); [constructor]\n"); - ZEPHIR_CALL_FUNCTION(&_130$$24, "strtr", NULL, 5, &_131$$24, &_129$$24); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_132$$24); - ZEPHIR_CONCAT_VV(&_132$$24, &_128$$24, &_130$$24); - zephir_concat_self(&output, &_132$$24); - } else { - ZVAL_LONG(&_133$$25, (tab + 1)); - ZEPHIR_CALL_FUNCTION(&_134$$25, "str_repeat", &_10, 1, &space, &_133$$25); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_135$$25); - zephir_create_array(&_135$$25, 2, 0); - ZEPHIR_INIT_NVAR(&_137$$25); - ZVAL_STRING(&_137$$25, "obj"); - ZEPHIR_CALL_METHOD(&_136$$25, this_ptr, "getstyle", NULL, 0, &_137$$25); - zephir_check_call_status(); - zephir_array_update_string(&_135$$25, SL(":style"), &_136$$25, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_135$$25, SL(":method"), &value, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_137$$25); - ZVAL_STRING(&_137$$25, "->:method();\n"); - ZEPHIR_CALL_FUNCTION(&_136$$25, "strtr", NULL, 5, &_137$$25, &_135$$25); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_138$$25); - ZEPHIR_CONCAT_VV(&_138$$25, &_134$$25, &_136$$25); - zephir_concat_self(&output, &_138$$25); - } - ZEPHIR_CALL_METHOD(NULL, &attr, "next", NULL, 0); - zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&html, this_ptr, "preparehtmlmessage", &_5, 83, &type, &prepared); + zephir_check_call_status(); + zephir_read_property(&_7$$8, this_ptr, ZEND_STRL("implicitFlush"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_7$$8)) { + zend_print_zval(&html, 0); + } else { + zephir_concat_self(&content, &html); + zephir_update_property_array_append(this_ptr, SL("messages"), &html); } - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_LONG(&_139$$19, tab); - ZEPHIR_CALL_FUNCTION(&_140$$19, "str_repeat", &_10, 1, &space, &_139$$19); + ZEPHIR_CALL_METHOD(NULL, message, "next", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_141$$19); - ZEPHIR_CONCAT_VS(&_141$$19, &_140$$19, ")\n"); - zephir_concat_self(&output, &_141$$19); } - ZVAL_LONG(&_142$$9, (tab - 1)); - ZEPHIR_CALL_FUNCTION(&_143$$9, "str_repeat", &_10, 1, &space, &_142$$9); - zephir_check_call_status(); - ZEPHIR_CONCAT_VVS(return_value, &output, &_143$$9, ")"); - RETURN_MM(); - } - if (Z_TYPE_P(variable) == IS_LONG) { - ZEPHIR_INIT_VAR(&_144$$26); - zephir_create_array(&_144$$26, 2, 0); - ZEPHIR_INIT_VAR(&_146$$26); - ZVAL_STRING(&_146$$26, "int"); - ZEPHIR_CALL_METHOD(&_145$$26, this_ptr, "getstyle", NULL, 0, &_146$$26); - zephir_check_call_status(); - zephir_array_update_string(&_144$$26, SL(":style"), &_145$$26, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_144$$26, SL(":var"), variable, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_146$$26); - ZVAL_STRING(&_146$$26, "Integer (:var)"); - ZEPHIR_CALL_FUNCTION(&_145$$26, "strtr", NULL, 5, &_146$$26, &_144$$26); - zephir_check_call_status(); - ZEPHIR_CONCAT_VV(return_value, &output, &_145$$26); - RETURN_MM(); } - ZEPHIR_CALL_FUNCTION(&_147, "is_float", NULL, 214, variable); + ZEPHIR_INIT_NVAR(&item); + RETURN_CCTOR(&content); +} + +static PHP_METHOD(Phalcon_Flash_AbstractFlash, warning) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *message_param = NULL, _0; + zval message; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(message) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &message_param); + zephir_get_strval(&message, message_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "warning"); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "message", NULL, 0, &_0, &message); zephir_check_call_status(); - if (zephir_is_true(&_147)) { - ZEPHIR_INIT_VAR(&_148$$27); - zephir_create_array(&_148$$27, 2, 0); - ZEPHIR_INIT_VAR(&_150$$27); - ZVAL_STRING(&_150$$27, "float"); - ZEPHIR_CALL_METHOD(&_149$$27, this_ptr, "getstyle", NULL, 0, &_150$$27); - zephir_check_call_status(); - zephir_array_update_string(&_148$$27, SL(":style"), &_149$$27, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_148$$27, SL(":var"), variable, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_150$$27); - ZVAL_STRING(&_150$$27, "Float (:var)"); - ZEPHIR_CALL_FUNCTION(&_149$$27, "strtr", NULL, 5, &_150$$27, &_148$$27); - zephir_check_call_status(); - ZEPHIR_CONCAT_VV(return_value, &output, &_149$$27); - RETURN_MM(); - } - if (zephir_is_numeric(variable)) { - ZEPHIR_INIT_VAR(&_151$$28); - zephir_create_array(&_151$$28, 3, 0); - ZEPHIR_INIT_VAR(&_153$$28); - ZVAL_STRING(&_153$$28, "num"); - ZEPHIR_CALL_METHOD(&_152$$28, this_ptr, "getstyle", NULL, 0, &_153$$28); - zephir_check_call_status(); - zephir_array_update_string(&_151$$28, SL(":style"), &_152$$28, PH_COPY | PH_SEPARATE); - add_assoc_long_ex(&_151$$28, SL(":length"), zephir_fast_strlen_ev(variable)); - zephir_array_update_string(&_151$$28, SL(":var"), variable, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_153$$28); - ZVAL_STRING(&_153$$28, "Numeric string (:length) \":var\""); - ZEPHIR_CALL_FUNCTION(&_152$$28, "strtr", NULL, 5, &_153$$28, &_151$$28); - zephir_check_call_status(); - ZEPHIR_CONCAT_VV(return_value, &output, &_152$$28); - RETURN_MM(); - } - if (Z_TYPE_P(variable) == IS_STRING) { - ZEPHIR_INIT_VAR(&_154$$29); - zephir_create_array(&_154$$29, 3, 0); - ZEPHIR_INIT_VAR(&_156$$29); - ZVAL_STRING(&_156$$29, "str"); - ZEPHIR_CALL_METHOD(&_155$$29, this_ptr, "getstyle", NULL, 0, &_156$$29); - zephir_check_call_status(); - zephir_array_update_string(&_154$$29, SL(":style"), &_155$$29, PH_COPY | PH_SEPARATE); - add_assoc_long_ex(&_154$$29, SL(":length"), zephir_fast_strlen_ev(variable)); - ZVAL_LONG(&_157$$29, 4); - ZEPHIR_INIT_NVAR(&_156$$29); - ZVAL_STRING(&_156$$29, "utf-8"); - ZEPHIR_CALL_FUNCTION(&_155$$29, "htmlentities", NULL, 0, variable, &_157$$29, &_156$$29); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&_158$$29, "nl2br", NULL, 0, &_155$$29); - zephir_check_call_status(); - zephir_array_update_string(&_154$$29, SL(":var"), &_158$$29, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_156$$29); - ZVAL_STRING(&_156$$29, "String (:length) \":var\""); - ZEPHIR_CALL_FUNCTION(&_158$$29, "strtr", NULL, 5, &_156$$29, &_154$$29); - zephir_check_call_status(); - ZEPHIR_CONCAT_VV(return_value, &output, &_158$$29); - RETURN_MM(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Flash_AbstractFlash, getTemplate) +{ + zval _4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *cssClassses_param = NULL, *cssIconClasses_param = NULL, _0, _1, _2, _3; + zval cssClassses, cssIconClasses, divString, iconString, template; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&cssClassses); + ZVAL_UNDEF(&cssIconClasses); + ZVAL_UNDEF(&divString); + ZVAL_UNDEF(&iconString); + ZVAL_UNDEF(&template); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(cssClassses) + Z_PARAM_STR(cssIconClasses) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &cssClassses_param, &cssIconClasses_param); + zephir_get_strval(&cssClassses, cssClassses_param); + zephir_get_strval(&cssIconClasses, cssIconClasses_param); + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_GET_CONSTANT(&_0, "PHP_EOL"); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_SV(&_1, "%iconString%%message%
", &_0); + zephir_get_strval(&template, &_1); + ZEPHIR_INIT_VAR(&divString); + ZEPHIR_INIT_VAR(&iconString); + zephir_read_property(&_2, this_ptr, ZEND_STRL("customTemplate"), PH_NOISY_CC | PH_READONLY); + if (!(ZEPHIR_IS_EMPTY(&_2))) { + RETURN_MM_MEMBER(getThis(), "customTemplate"); } - if ((Z_TYPE_P(variable) == IS_TRUE || Z_TYPE_P(variable) == IS_FALSE)) { - ZEPHIR_INIT_VAR(&_159$$30); - zephir_create_array(&_159$$30, 2, 0); - ZEPHIR_INIT_VAR(&_161$$30); - ZVAL_STRING(&_161$$30, "bool"); - ZEPHIR_CALL_METHOD(&_160$$30, this_ptr, "getstyle", NULL, 0, &_161$$30); - zephir_check_call_status(); - zephir_array_update_string(&_159$$30, SL(":style"), &_160$$30, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_162$$30); - if (zephir_is_true(variable)) { - ZEPHIR_INIT_NVAR(&_162$$30); - ZVAL_STRING(&_162$$30, "TRUE"); - } else { - ZEPHIR_INIT_NVAR(&_162$$30); - ZVAL_STRING(&_162$$30, "FALSE"); + if (!(ZEPHIR_IS_EMPTY(&cssClassses))) { + ZEPHIR_INIT_NVAR(&divString); + ZVAL_STRING(&divString, " class=\"%cssClass%\""); + if (!(ZEPHIR_IS_EMPTY(&cssIconClasses))) { + ZEPHIR_INIT_NVAR(&iconString); + ZVAL_STRING(&iconString, " "); } - zephir_array_update_string(&_159$$30, SL(":var"), &_162$$30, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_161$$30); - ZVAL_STRING(&_161$$30, "Boolean (:var)"); - ZEPHIR_CALL_FUNCTION(&_160$$30, "strtr", NULL, 5, &_161$$30, &_159$$30); - zephir_check_call_status(); - ZEPHIR_CONCAT_VV(return_value, &output, &_160$$30); - RETURN_MM(); } - if (Z_TYPE_P(variable) == IS_NULL) { - ZEPHIR_INIT_VAR(&_163$$31); - zephir_create_array(&_163$$31, 1, 0); - ZEPHIR_INIT_VAR(&_165$$31); - ZVAL_STRING(&_165$$31, "null"); - ZEPHIR_CALL_METHOD(&_164$$31, this_ptr, "getstyle", NULL, 0, &_165$$31); - zephir_check_call_status(); - zephir_array_update_string(&_163$$31, SL(":style"), &_164$$31, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_165$$31); - ZVAL_STRING(&_165$$31, "NULL"); - ZEPHIR_CALL_FUNCTION(&_164$$31, "strtr", NULL, 5, &_165$$31, &_163$$31); - zephir_check_call_status(); - ZEPHIR_CONCAT_VV(return_value, &output, &_164$$31); - RETURN_MM(); + zephir_read_property(&_3, this_ptr, ZEND_STRL("interpolator"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_4); + zephir_create_array(&_4, 2, 0); + zephir_array_update_string(&_4, SL("divString"), &divString, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_4, SL("iconString"), &iconString, PH_COPY | PH_SEPARATE); + ZEPHIR_RETURN_CALL_METHOD(&_3, "__invoke", NULL, 0, &template, &_4); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Flash_AbstractFlash, prepareEscapedMessage) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *message_param = NULL, escaper, _0; + zval message; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&escaper); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(message) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &message_param); + zephir_get_strval(&message, message_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("autoescape"), PH_NOISY_CC | PH_READONLY); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + RETURN_CTOR(&message); } - ZEPHIR_INIT_VAR(&_166); - zephir_create_array(&_166, 2, 0); - ZEPHIR_INIT_VAR(&_168); - ZVAL_STRING(&_168, "other"); - ZEPHIR_CALL_METHOD(&_167, this_ptr, "getstyle", NULL, 0, &_168); + ZEPHIR_CALL_METHOD(&escaper, this_ptr, "getescaperservice", NULL, 0); zephir_check_call_status(); - zephir_array_update_string(&_166, SL(":style"), &_167, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_166, SL(":var"), variable, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_168); - ZVAL_STRING(&_168, "(:var)"); - ZEPHIR_CALL_FUNCTION(&_167, "strtr", NULL, 5, &_168, &_166); + ZEPHIR_RETURN_CALL_METHOD(&escaper, "escapehtml", NULL, 0, &message); zephir_check_call_status(); - ZEPHIR_CONCAT_VV(return_value, &output, &_167); RETURN_MM(); } -zend_object *zephir_init_properties_Phalcon_Support_Debug_Dump(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Flash_AbstractFlash, prepareHtmlMessage) { - zval _0, _2, _1$$3, _3$$4; + zval _5; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *type_param = NULL, *message_param = NULL, cssClasses, cssIconClasses, _0, _1, _2, _3, _4; + zval type, message; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&cssClasses); + ZVAL_UNDEF(&cssIconClasses); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(type) + Z_PARAM_STR(message) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &type_param, &message_param); + zephir_get_strval(&type, type_param); + zephir_get_strval(&message, message_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("automaticHtml"), PH_NOISY_CC | PH_READONLY); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + RETURN_CTOR(&message); + } + zephir_read_property(&_1, this_ptr, ZEND_STRL("cssClasses"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&cssClasses, this_ptr, "checkclasses", NULL, 84, &_1, &type); + zephir_check_call_status(); + zephir_read_property(&_2, this_ptr, ZEND_STRL("cssIconClasses"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&cssIconClasses, this_ptr, "checkclasses", NULL, 84, &_2, &type); + zephir_check_call_status(); + zephir_read_property(&_3, this_ptr, ZEND_STRL("interpolator"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "gettemplate", NULL, 85, &cssClasses, &cssIconClasses); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_5); + zephir_create_array(&_5, 3, 0); + zephir_array_update_string(&_5, SL("cssClass"), &cssClasses, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_5, SL("cssIconClass"), &cssIconClasses, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_5, SL("message"), &message, PH_COPY | PH_SEPARATE); + ZEPHIR_RETURN_CALL_METHOD(&_3, "__invoke", NULL, 0, &_4, &_5); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Flash_AbstractFlash, checkClasses) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval type; + zval *collection_param = NULL, *type_param = NULL, content, _0$$5, _1$$4; + zval collection; + + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&content); + ZVAL_UNDEF(&_0$$5); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&type); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ARRAY(collection) + Z_PARAM_STR(type) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &collection_param, &type_param); + zephir_get_arrval(&collection, collection_param); + zephir_get_strval(&type, type_param); + ZEPHIR_INIT_VAR(&content); + ZVAL_STRING(&content, ""); + if (zephir_array_isset(&collection, &type)) { + ZEPHIR_OBS_NVAR(&content); + zephir_array_fetch(&content, &collection, &type, PH_NOISY, "phalcon/Flash/AbstractFlash.zep", 484); + } + if (1 != ZEPHIR_IS_EMPTY(&content)) { + if (Z_TYPE_P(&content) != IS_ARRAY) { + ZEPHIR_INIT_VAR(&_0$$5); + zephir_create_array(&_0$$5, 1, 0); + zephir_array_fast_append(&_0$$5, &content); + ZEPHIR_CPY_WRT(&content, &_0$$5); + } + ZEPHIR_INIT_VAR(&_1$$4); + zephir_fast_join_str(&_1$$4, SL(" "), &content); + ZEPHIR_CPY_WRT(&content, &_1$$4); + } + RETURN_CCTOR(&content); +} + +zend_object *zephir_init_properties_Phalcon_Flash_AbstractFlash(zend_class_entry *class_type) +{ + zval _0, _2, _4, _1$$3, _3$$4, _5$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); @@ -152784,17 +150575,23 @@ zend_object *zephir_init_properties_Phalcon_Support_Debug_Dump(zend_class_entry { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("styles"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("styles"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("messages"), &_1$$3); } - zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("methods"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("cssIconClasses"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_2) == IS_NULL) { ZEPHIR_INIT_VAR(&_3$$4); array_init(&_3$$4); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("methods"), &_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("cssIconClasses"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("cssClasses"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("cssClasses"), &_5$$5); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -152811,13 +150608,486 @@ zend_object *zephir_init_properties_Phalcon_Support_Debug_Dump(zend_class_entry -ZEPHIR_INIT_CLASS(Phalcon_Support_Debug_Exception) +ZEPHIR_INIT_CLASS(Phalcon_Flash_Direct) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Support\\Debug, Exception, phalcon, support_debug_exception, zend_ce_exception, NULL, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Flash, Direct, phalcon, flash_direct, phalcon_flash_abstractflash_ce, phalcon_flash_direct_method_entry, 0); + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Flash_Direct, message) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *type_param = NULL, *message, message_sub; + zval type; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&message_sub); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(type) + Z_PARAM_ZVAL(message) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &type_param, &message); + zephir_get_strval(&type, type_param); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "outputmessage", NULL, 0, &type, message); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Flash_Direct, output) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *remove_param = NULL, message, _0, *_1, _2; + zend_bool remove; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(remove) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &remove_param); + if (!remove_param) { + remove = 1; + } else { + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("messages"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_0, 0, "phalcon/Flash/Direct.zep", 45); + if (Z_TYPE_P(&_0) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_0), _1) + { + ZEPHIR_INIT_NVAR(&message); + ZVAL_COPY(&message, _1); + zend_print_zval(&message, 0); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_0, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &_0, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&message, &_0, "current", NULL, 0); + zephir_check_call_status(); + zend_print_zval(&message, 0); + ZEPHIR_CALL_METHOD(NULL, &_0, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&message); + if (remove) { + ZEPHIR_CALL_PARENT(NULL, phalcon_flash_direct_ce, getThis(), "clear", NULL, 0); + zephir_check_call_status(); + } + ZEPHIR_MM_RESTORE(); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Flash_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Flash, Exception, phalcon, flash_exception, zend_ce_exception, NULL, 0); + + return SUCCESS; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Flash_FlashInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Flash, FlashInterface, phalcon, flash_flashinterface, phalcon_flash_flashinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Flash_FlashInterface, error); +ZEPHIR_DOC_METHOD(Phalcon_Flash_FlashInterface, message); +ZEPHIR_DOC_METHOD(Phalcon_Flash_FlashInterface, notice); +ZEPHIR_DOC_METHOD(Phalcon_Flash_FlashInterface, success); +ZEPHIR_DOC_METHOD(Phalcon_Flash_FlashInterface, warning); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Flash_Session) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Flash, Session, phalcon, flash_session, phalcon_flash_abstractflash_ce, phalcon_flash_session_method_entry, 0); + + zephir_declare_class_constant_string(phalcon_flash_session_ce, SL("SESSION_KEY"), "_flashMessages"); return SUCCESS; } +static PHP_METHOD(Phalcon_Flash_Session, clear) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZVAL_BOOL(&_0, 1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "getsessionmessages", NULL, 0, &_0); + zephir_check_call_status(); + ZEPHIR_CALL_PARENT(NULL, phalcon_flash_session_ce, getThis(), "clear", NULL, 0); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Flash_Session, getMessages) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool remove; + zval *type = NULL, type_sub, *remove_param = NULL, __$null, _0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&type_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(type) + Z_PARAM_BOOL(remove) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 2, &type, &remove_param); + if (!type) { + type = &type_sub; + type = &__$null; + } + if (!remove_param) { + remove = 1; + } else { + } + if (remove) { + ZVAL_BOOL(&_0, 1); + } else { + ZVAL_BOOL(&_0, 0); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsessionmessages", NULL, 0, &_0, type); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Flash_Session, has) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *type_param = NULL, messages, _0; + zval type; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&messages); + ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(type) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &type_param); + if (!type_param) { + ZEPHIR_INIT_VAR(&type); + } else { + zephir_get_strval(&type, type_param); + } + ZVAL_BOOL(&_0, 0); + ZEPHIR_CALL_METHOD(&messages, this_ptr, "getsessionmessages", NULL, 0, &_0); + zephir_check_call_status(); + if (!(!(ZEPHIR_IS_EMPTY(&type)))) { + RETURN_MM_BOOL((1 != ZEPHIR_IS_EMPTY(&messages))); + } + RETURN_MM_BOOL(zephir_array_isset(&messages, &type)); +} + +static PHP_METHOD(Phalcon_Flash_Session, message) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *type_param = NULL, *message, message_sub, messages, _0, _1$$3; + zval type; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&message_sub); + ZVAL_UNDEF(&messages); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(type) + Z_PARAM_ZVAL(message) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &type_param, &message); + zephir_get_strval(&type, type_param); + ZVAL_BOOL(&_0, 0); + ZEPHIR_CALL_METHOD(&messages, this_ptr, "getsessionmessages", NULL, 0, &_0); + zephir_check_call_status(); + if (1 != zephir_array_isset(&messages, &type)) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_array_update_zval(&messages, &type, &_1$$3, PH_COPY | PH_SEPARATE); + } + zephir_array_update_multi(&messages, message, SL("za"), 2, &type); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setsessionmessages", NULL, 0, &messages); + zephir_check_call_status(); + RETURN_MM_NULL(); +} + +static PHP_METHOD(Phalcon_Flash_Session, output) +{ + zend_string *_4; + zend_ulong _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_5 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *remove_param = NULL, message, messages, type, _0, *_1, _2; + zend_bool remove; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&messages); + ZVAL_UNDEF(&type); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(remove) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &remove_param); + if (!remove_param) { + remove = 1; + } else { + } + if (remove) { + ZVAL_BOOL(&_0, 1); + } else { + ZVAL_BOOL(&_0, 0); + } + ZEPHIR_CALL_METHOD(&messages, this_ptr, "getsessionmessages", NULL, 0, &_0); + zephir_check_call_status(); + zephir_is_iterable(&messages, 0, "phalcon/Flash/Session.zep", 117); + if (Z_TYPE_P(&messages) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&messages), _3, _4, _1) + { + ZEPHIR_INIT_NVAR(&type); + if (_4 != NULL) { + ZVAL_STR_COPY(&type, _4); + } else { + ZVAL_LONG(&type, _3); + } + ZEPHIR_INIT_NVAR(&message); + ZVAL_COPY(&message, _1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "outputmessage", &_5, 0, &type, &message); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &messages, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &messages, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&type, &messages, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&message, &messages, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "outputmessage", &_5, 0, &type, &message); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &messages, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&message); + ZEPHIR_INIT_NVAR(&type); + ZEPHIR_CALL_PARENT(NULL, phalcon_flash_session_ce, getThis(), "clear", NULL, 0); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Flash_Session, getSessionMessages) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval type; + zval *remove_param = NULL, *type_param = NULL, session, messages, returnMessages, _0, _1$$6, _2$$7; + zend_bool remove; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&session); + ZVAL_UNDEF(&messages); + ZVAL_UNDEF(&returnMessages); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$6); + ZVAL_UNDEF(&_2$$7); + ZVAL_UNDEF(&type); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_BOOL(remove) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(type) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &remove_param, &type_param); + if (!type_param) { + ZEPHIR_INIT_VAR(&type); + } else { + zephir_get_strval(&type, type_param); + } + ZEPHIR_CALL_METHOD(&session, this_ptr, "getsessionservice", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "_flashMessages"); + ZEPHIR_CALL_METHOD(&messages, &session, "get", NULL, 0, &_0); + zephir_check_call_status(); + if (Z_TYPE_P(&messages) != IS_ARRAY) { + ZEPHIR_INIT_NVAR(&messages); + array_init(&messages); + } + if (1 != ZEPHIR_IS_EMPTY(&type)) { + zephir_memory_observe(&returnMessages); + if (zephir_array_isset_fetch(&returnMessages, &messages, &type, 0)) { + if (remove) { + zephir_array_unset(&messages, &type, PH_SEPARATE); + ZEPHIR_INIT_VAR(&_1$$6); + ZVAL_STRING(&_1$$6, "_flashMessages"); + ZEPHIR_CALL_METHOD(NULL, &session, "set", NULL, 0, &_1$$6, &messages); + zephir_check_call_status(); + } + RETURN_CCTOR(&returnMessages); + } + array_init(return_value); + RETURN_MM(); + } + if (remove) { + ZEPHIR_INIT_VAR(&_2$$7); + ZVAL_STRING(&_2$$7, "_flashMessages"); + ZEPHIR_CALL_METHOD(NULL, &session, "remove", NULL, 0, &_2$$7); + zephir_check_call_status(); + } + RETURN_CCTOR(&messages); +} + +static PHP_METHOD(Phalcon_Flash_Session, setSessionMessages) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *messages_param = NULL, session, _0; + zval messages; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&messages); + ZVAL_UNDEF(&session); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ARRAY(messages) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &messages_param); + ZEPHIR_OBS_COPY_OR_DUP(&messages, messages_param); + ZEPHIR_CALL_METHOD(&session, this_ptr, "getsessionservice", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "_flashMessages"); + ZEPHIR_CALL_METHOD(NULL, &session, "set", NULL, 0, &_0, &messages); + zephir_check_call_status(); + RETURN_CTOR(&messages); +} + +static PHP_METHOD(Phalcon_Flash_Session, getSessionService) +{ + zend_bool _2; + zval _0, _1, _3, _4, _5, _6$$4, _7$$4, _8$$4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$4); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("sessionService"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) != IS_NULL) { + RETURN_MM_MEMBER(getThis(), "sessionService"); + } + zephir_read_property(&_1, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + _2 = Z_TYPE_P(&_1) != IS_NULL; + if (_2) { + zephir_read_property(&_3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_5); + ZVAL_STRING(&_5, "session"); + ZEPHIR_CALL_METHOD(&_4, &_3, "has", NULL, 0, &_5); + zephir_check_call_status(); + _2 = ZEPHIR_IS_TRUE_IDENTICAL(&_4); + } + if (_2) { + zephir_read_property(&_6$$4, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_8$$4); + ZVAL_STRING(&_8$$4, "session"); + ZEPHIR_CALL_METHOD(&_7$$4, &_6$$4, "getshared", NULL, 0, &_8$$4); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("sessionService"), &_7$$4); + RETURN_MM_MEMBER(getThis(), "sessionService"); + } + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_flash_exception_ce, "A dependency injection container is required to access the 'session' service", "phalcon/Flash/Session.zep", 205); + return; +} + @@ -155827,342 +154097,1006 @@ static PHP_METHOD(Phalcon_Http_Request, getUploadedFiles) ZEPHIR_CALL_METHOD(NULL, &superFiles, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_1$$3, &superFiles, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_1$$3, &superFiles, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&prefix, &superFiles, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&input, &superFiles, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&_35$$18); + zephir_array_fetch_string(&_35$$18, &input, SL("name"), PH_NOISY, "phalcon/Http/Request.zep", 887); + if (Z_TYPE_P(&_35$$18) == IS_ARRAY) { + zephir_array_fetch_string(&_36$$19, &input, SL("name"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 889); + zephir_array_fetch_string(&_37$$19, &input, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 890); + zephir_array_fetch_string(&_38$$19, &input, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 891); + zephir_array_fetch_string(&_39$$19, &input, SL("size"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 892); + zephir_array_fetch_string(&_40$$19, &input, SL("error"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 893); + ZEPHIR_CALL_METHOD(&smoothInput, this_ptr, "smoothfiles", &_10, 342, &_36$$19, &_37$$19, &_38$$19, &_39$$19, &_40$$19, &prefix); + zephir_check_call_status(); + zephir_is_iterable(&smoothInput, 0, "phalcon/Http/Request.zep", 920); + if (Z_TYPE_P(&smoothInput) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&smoothInput), _41$$19) + { + ZEPHIR_INIT_NVAR(&file); + ZVAL_COPY(&file, _41$$19); + _43$$20 = onlySuccessful == 0; + if (!(_43$$20)) { + zephir_array_fetch_string(&_44$$20, &file, SL("error"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 898); + _43$$20 = ZEPHIR_IS_LONG(&_44$$20, 0); + } + if (_43$$20) { + ZEPHIR_INIT_NVAR(&_45$$21); + zephir_create_array(&_45$$21, 5, 0); + ZEPHIR_OBS_NVAR(&_46$$21); + zephir_array_fetch_string(&_46$$21, &file, SL("name"), PH_NOISY, "phalcon/Http/Request.zep", 900); + zephir_array_update_string(&_45$$21, SL("name"), &_46$$21, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_46$$21); + zephir_array_fetch_string(&_46$$21, &file, SL("type"), PH_NOISY, "phalcon/Http/Request.zep", 901); + zephir_array_update_string(&_45$$21, SL("type"), &_46$$21, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_46$$21); + zephir_array_fetch_string(&_46$$21, &file, SL("tmp_name"), PH_NOISY, "phalcon/Http/Request.zep", 902); + zephir_array_update_string(&_45$$21, SL("tmp_name"), &_46$$21, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_46$$21); + zephir_array_fetch_string(&_46$$21, &file, SL("size"), PH_NOISY, "phalcon/Http/Request.zep", 903); + zephir_array_update_string(&_45$$21, SL("size"), &_46$$21, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_46$$21); + zephir_array_fetch_string(&_46$$21, &file, SL("error"), PH_NOISY, "phalcon/Http/Request.zep", 905); + zephir_array_update_string(&_45$$21, SL("error"), &_46$$21, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&dataFile, &_45$$21); + if (namedKeys == 1) { + ZEPHIR_INIT_NVAR(&_47$$22); + object_init_ex(&_47$$22, phalcon_http_request_file_ce); + zephir_array_fetch_string(&_48$$22, &file, SL("key"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 911); + ZEPHIR_CALL_METHOD(NULL, &_47$$22, "__construct", &_18, 343, &dataFile, &_48$$22); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&_49$$22); + zephir_array_fetch_string(&_49$$22, &file, SL("key"), PH_NOISY, "phalcon/Http/Request.zep", 908); + zephir_array_update_zval(&files, &_49$$22, &_47$$22, PH_COPY | PH_SEPARATE); + } else { + ZEPHIR_INIT_NVAR(&_50$$23); + object_init_ex(&_50$$23, phalcon_http_request_file_ce); + zephir_array_fetch_string(&_51$$23, &file, SL("key"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 916); + ZEPHIR_CALL_METHOD(NULL, &_50$$23, "__construct", &_18, 343, &dataFile, &_51$$23); + zephir_check_call_status(); + zephir_array_append(&files, &_50$$23, PH_SEPARATE, "phalcon/Http/Request.zep", 916); + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &smoothInput, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_42$$19, &smoothInput, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_42$$19)) { + break; + } + ZEPHIR_CALL_METHOD(&file, &smoothInput, "current", NULL, 0); + zephir_check_call_status(); + _52$$24 = onlySuccessful == 0; + if (!(_52$$24)) { + zephir_array_fetch_string(&_53$$24, &file, SL("error"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 898); + _52$$24 = ZEPHIR_IS_LONG(&_53$$24, 0); + } + if (_52$$24) { + ZEPHIR_INIT_NVAR(&_54$$25); + zephir_create_array(&_54$$25, 5, 0); + ZEPHIR_OBS_NVAR(&_55$$25); + zephir_array_fetch_string(&_55$$25, &file, SL("name"), PH_NOISY, "phalcon/Http/Request.zep", 900); + zephir_array_update_string(&_54$$25, SL("name"), &_55$$25, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_55$$25); + zephir_array_fetch_string(&_55$$25, &file, SL("type"), PH_NOISY, "phalcon/Http/Request.zep", 901); + zephir_array_update_string(&_54$$25, SL("type"), &_55$$25, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_55$$25); + zephir_array_fetch_string(&_55$$25, &file, SL("tmp_name"), PH_NOISY, "phalcon/Http/Request.zep", 902); + zephir_array_update_string(&_54$$25, SL("tmp_name"), &_55$$25, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_55$$25); + zephir_array_fetch_string(&_55$$25, &file, SL("size"), PH_NOISY, "phalcon/Http/Request.zep", 903); + zephir_array_update_string(&_54$$25, SL("size"), &_55$$25, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_55$$25); + zephir_array_fetch_string(&_55$$25, &file, SL("error"), PH_NOISY, "phalcon/Http/Request.zep", 905); + zephir_array_update_string(&_54$$25, SL("error"), &_55$$25, PH_COPY | PH_SEPARATE); + ZEPHIR_CPY_WRT(&dataFile, &_54$$25); + if (namedKeys == 1) { + ZEPHIR_INIT_NVAR(&_56$$26); + object_init_ex(&_56$$26, phalcon_http_request_file_ce); + zephir_array_fetch_string(&_57$$26, &file, SL("key"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 911); + ZEPHIR_CALL_METHOD(NULL, &_56$$26, "__construct", &_18, 343, &dataFile, &_57$$26); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&_58$$26); + zephir_array_fetch_string(&_58$$26, &file, SL("key"), PH_NOISY, "phalcon/Http/Request.zep", 908); + zephir_array_update_zval(&files, &_58$$26, &_56$$26, PH_COPY | PH_SEPARATE); + } else { + ZEPHIR_INIT_NVAR(&_59$$27); + object_init_ex(&_59$$27, phalcon_http_request_file_ce); + zephir_array_fetch_string(&_60$$27, &file, SL("key"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 916); + ZEPHIR_CALL_METHOD(NULL, &_59$$27, "__construct", &_18, 343, &dataFile, &_60$$27); + zephir_check_call_status(); + zephir_array_append(&files, &_59$$27, PH_SEPARATE, "phalcon/Http/Request.zep", 916); + } + } + ZEPHIR_CALL_METHOD(NULL, &smoothInput, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&file); + } else { + _61$$28 = onlySuccessful == 0; + if (!(_61$$28)) { + zephir_array_fetch_string(&_62$$28, &input, SL("error"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 921); + _61$$28 = ZEPHIR_IS_LONG(&_62$$28, 0); + } + if (_61$$28) { + if (namedKeys == 1) { + ZEPHIR_INIT_NVAR(&_63$$30); + object_init_ex(&_63$$30, phalcon_http_request_file_ce); + ZEPHIR_CALL_METHOD(NULL, &_63$$30, "__construct", &_18, 343, &input, &prefix); + zephir_check_call_status(); + zephir_array_update_zval(&files, &prefix, &_63$$30, PH_COPY | PH_SEPARATE); + } else { + ZEPHIR_INIT_NVAR(&_64$$31); + object_init_ex(&_64$$31, phalcon_http_request_file_ce); + ZEPHIR_CALL_METHOD(NULL, &_64$$31, "__construct", &_18, 343, &input, &prefix); + zephir_check_call_status(); + zephir_array_append(&files, &_64$$31, PH_SEPARATE, "phalcon/Http/Request.zep", 925); + } + } + } + ZEPHIR_CALL_METHOD(NULL, &superFiles, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&input); + ZEPHIR_INIT_NVAR(&prefix); + } + RETURN_CTOR(&files); +} + +static PHP_METHOD(Phalcon_Http_Request, getURI) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *onlyPath_param = NULL, requestURI, _0, _1$$4, _2$$4, _3$$4; + zend_bool onlyPath; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&requestURI); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(onlyPath) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &onlyPath_param); + if (!onlyPath_param) { + onlyPath = 0; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "REQUEST_URI"); + ZEPHIR_CALL_METHOD(&requestURI, this_ptr, "getserver", NULL, 0, &_0); + zephir_check_call_status(); + if (Z_TYPE_P(&requestURI) == IS_NULL) { + RETURN_MM_STRING(""); + } + if (onlyPath) { + ZEPHIR_INIT_VAR(&_1$$4); + ZEPHIR_INIT_VAR(&_2$$4); + ZVAL_STRING(&_2$$4, "?"); + zephir_fast_explode(&_1$$4, &_2$$4, &requestURI, LONG_MAX); + zephir_array_fetch_long(&_3$$4, &_1$$4, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 959); + ZEPHIR_CPY_WRT(&requestURI, &_3$$4); + } + RETURN_CCTOR(&requestURI); +} + +static PHP_METHOD(Phalcon_Http_Request, getUserAgent) +{ + zval userAgent, _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&userAgent); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "HTTP_USER_AGENT"); + ZEPHIR_CALL_METHOD(&userAgent, this_ptr, "getserver", NULL, 0, &_0); + zephir_check_call_status(); + if (Z_TYPE_P(&userAgent) == IS_NULL) { + RETURN_MM_STRING(""); + } + RETURN_CCTOR(&userAgent); +} + +static PHP_METHOD(Phalcon_Http_Request, has) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *name_param = NULL, _REQUEST; + zval name; + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_REQUEST); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_get_global(&_REQUEST, SL("_REQUEST")); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + RETURN_MM_BOOL(zephir_array_isset(&_REQUEST, &name)); +} + +static PHP_METHOD(Phalcon_Http_Request, hasFiles) +{ + zval _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZVAL_BOOL(&_1, 1); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "numfiles", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_MM_BOOL(ZEPHIR_GT_LONG(&_0, 0)); +} + +static PHP_METHOD(Phalcon_Http_Request, hasHeader) +{ + zend_bool _4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *header_param = NULL, name, _0, _1, _2, _3, _5, _6; + zval header; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&header); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(header) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &header_param); + if (UNEXPECTED(Z_TYPE_P(header_param) != IS_STRING && Z_TYPE_P(header_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'header' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(header_param) == IS_STRING)) { + zephir_get_strval(&header, header_param); + } else { + ZEPHIR_INIT_VAR(&header); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "-"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "_"); + ZEPHIR_CALL_FUNCTION(&_2, "strtr", NULL, 5, &header, &_0, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&name); + zephir_fast_strtoupper(&name, &_2); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "hasserver", NULL, 335, &name); + zephir_check_call_status(); + _4 = zephir_is_true(&_3); + if (!(_4)) { + ZEPHIR_INIT_VAR(&_6); + ZEPHIR_CONCAT_SV(&_6, "HTTP_", &name); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "hasserver", NULL, 335, &_6); + zephir_check_call_status(); + _4 = zephir_is_true(&_5); + } + RETURN_MM_BOOL(_4); +} + +static PHP_METHOD(Phalcon_Http_Request, hasPatch) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, patch; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&patch); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + ZEPHIR_CALL_METHOD(&patch, this_ptr, "getpatch", NULL, 0); + zephir_check_call_status(); + RETURN_MM_BOOL(zephir_array_isset(&patch, &name)); +} + +static PHP_METHOD(Phalcon_Http_Request, hasPost) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *name_param = NULL, _POST; + zval name; + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_POST); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_get_global(&_POST, SL("_POST")); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + RETURN_MM_BOOL(zephir_array_isset(&_POST, &name)); +} + +static PHP_METHOD(Phalcon_Http_Request, hasPut) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, put; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&put); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + ZEPHIR_CALL_METHOD(&put, this_ptr, "getput", NULL, 0); + zephir_check_call_status(); + RETURN_MM_BOOL(zephir_array_isset(&put, &name)); +} + +static PHP_METHOD(Phalcon_Http_Request, hasQuery) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *name_param = NULL, _GET; + zval name; + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_GET); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_get_global(&_GET, SL("_GET")); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + RETURN_MM_BOOL(zephir_array_isset(&_GET, &name)); +} + +static PHP_METHOD(Phalcon_Http_Request, hasServer) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, server; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&server); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + ZEPHIR_CALL_METHOD(&server, this_ptr, "getserverarray", NULL, 337); + zephir_check_call_status(); + RETURN_MM_BOOL(zephir_array_isset(&server, &name)); +} + +static PHP_METHOD(Phalcon_Http_Request, isAjax) +{ + zend_bool _2; + zval _0, _1, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "HTTP_X_REQUESTED_WITH"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "hasserver", NULL, 335, &_1); + zephir_check_call_status(); + _2 = zephir_is_true(&_0); + if (_2) { + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "HTTP_X_REQUESTED_WITH"); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "getserver", NULL, 0, &_1); + zephir_check_call_status(); + _2 = ZEPHIR_IS_STRING_IDENTICAL(&_3, "XMLHttpRequest"); + } + RETURN_MM_BOOL(_2); +} + +static PHP_METHOD(Phalcon_Http_Request, isConnect) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); + zephir_check_call_status(); + RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "CONNECT")); +} + +static PHP_METHOD(Phalcon_Http_Request, isDelete) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); + zephir_check_call_status(); + RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "DELETE")); +} + +static PHP_METHOD(Phalcon_Http_Request, isGet) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); + zephir_check_call_status(); + RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "GET")); +} + +static PHP_METHOD(Phalcon_Http_Request, isHead) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); + zephir_check_call_status(); + RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "HEAD")); +} + +static PHP_METHOD(Phalcon_Http_Request, isMethod) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_8 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool strict, _0$$3; + zval *methods, methods_sub, *strict_param = NULL, httpMethod, method, _1$$3, _2$$4, _3$$4, *_4$$5, _5$$5, _6$$6, _7$$6, _9$$8, _10$$8; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&methods_sub); + ZVAL_UNDEF(&httpMethod); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_6$$6); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_9$$8); + ZVAL_UNDEF(&_10$$8); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(methods) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(strict) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &methods, &strict_param); + if (!strict_param) { + strict = 0; + } else { + } + ZEPHIR_CALL_METHOD(&httpMethod, this_ptr, "getmethod", NULL, 344); + zephir_check_call_status(); + if (Z_TYPE_P(methods) == IS_STRING) { + _0$$3 = strict; + if (_0$$3) { + ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "isvalidhttpmethod", NULL, 0, methods); + zephir_check_call_status(); + _0$$3 = !zephir_is_true(&_1$$3); + } + if (UNEXPECTED(_0$$3)) { + ZEPHIR_INIT_VAR(&_2$$4); + object_init_ex(&_2$$4, phalcon_http_request_exception_ce); + ZEPHIR_INIT_VAR(&_3$$4); + ZEPHIR_CONCAT_SV(&_3$$4, "Invalid HTTP method: ", methods); + ZEPHIR_CALL_METHOD(NULL, &_2$$4, "__construct", NULL, 33, &_3$$4); + zephir_check_call_status(); + zephir_throw_exception_debug(&_2$$4, "phalcon/Http/Request.zep", 1117); + ZEPHIR_MM_RESTORE(); + return; + } + RETURN_MM_BOOL(ZEPHIR_IS_EQUAL(methods, &httpMethod)); + } + if (Z_TYPE_P(methods) == IS_ARRAY) { + zephir_is_iterable(methods, 0, "phalcon/Http/Request.zep", 1130); + if (Z_TYPE_P(methods) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(methods), _4$$5) + { + ZEPHIR_INIT_NVAR(&method); + ZVAL_COPY(&method, _4$$5); + if (strict) { + ZVAL_BOOL(&_7$$6, 1); + } else { + ZVAL_BOOL(&_7$$6, 0); + } + ZEPHIR_CALL_METHOD(&_6$$6, this_ptr, "ismethod", &_8, 345, &method, &_7$$6); + zephir_check_call_status(); + if (zephir_is_true(&_6$$6)) { + RETURN_MM_BOOL(1); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, methods, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5$$5, methods, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_1$$3)) { + if (!zend_is_true(&_5$$5)) { break; } - ZEPHIR_CALL_METHOD(&prefix, &superFiles, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&input, &superFiles, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&method, methods, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&_35$$18); - zephir_array_fetch_string(&_35$$18, &input, SL("name"), PH_NOISY, "phalcon/Http/Request.zep", 887); - if (Z_TYPE_P(&_35$$18) == IS_ARRAY) { - zephir_array_fetch_string(&_36$$19, &input, SL("name"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 889); - zephir_array_fetch_string(&_37$$19, &input, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 890); - zephir_array_fetch_string(&_38$$19, &input, SL("tmp_name"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 891); - zephir_array_fetch_string(&_39$$19, &input, SL("size"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 892); - zephir_array_fetch_string(&_40$$19, &input, SL("error"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 893); - ZEPHIR_CALL_METHOD(&smoothInput, this_ptr, "smoothfiles", &_10, 342, &_36$$19, &_37$$19, &_38$$19, &_39$$19, &_40$$19, &prefix); - zephir_check_call_status(); - zephir_is_iterable(&smoothInput, 0, "phalcon/Http/Request.zep", 920); - if (Z_TYPE_P(&smoothInput) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&smoothInput), _41$$19) - { - ZEPHIR_INIT_NVAR(&file); - ZVAL_COPY(&file, _41$$19); - _43$$20 = onlySuccessful == 0; - if (!(_43$$20)) { - zephir_array_fetch_string(&_44$$20, &file, SL("error"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 898); - _43$$20 = ZEPHIR_IS_LONG(&_44$$20, 0); - } - if (_43$$20) { - ZEPHIR_INIT_NVAR(&_45$$21); - zephir_create_array(&_45$$21, 5, 0); - ZEPHIR_OBS_NVAR(&_46$$21); - zephir_array_fetch_string(&_46$$21, &file, SL("name"), PH_NOISY, "phalcon/Http/Request.zep", 900); - zephir_array_update_string(&_45$$21, SL("name"), &_46$$21, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_46$$21); - zephir_array_fetch_string(&_46$$21, &file, SL("type"), PH_NOISY, "phalcon/Http/Request.zep", 901); - zephir_array_update_string(&_45$$21, SL("type"), &_46$$21, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_46$$21); - zephir_array_fetch_string(&_46$$21, &file, SL("tmp_name"), PH_NOISY, "phalcon/Http/Request.zep", 902); - zephir_array_update_string(&_45$$21, SL("tmp_name"), &_46$$21, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_46$$21); - zephir_array_fetch_string(&_46$$21, &file, SL("size"), PH_NOISY, "phalcon/Http/Request.zep", 903); - zephir_array_update_string(&_45$$21, SL("size"), &_46$$21, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_46$$21); - zephir_array_fetch_string(&_46$$21, &file, SL("error"), PH_NOISY, "phalcon/Http/Request.zep", 905); - zephir_array_update_string(&_45$$21, SL("error"), &_46$$21, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&dataFile, &_45$$21); - if (namedKeys == 1) { - ZEPHIR_INIT_NVAR(&_47$$22); - object_init_ex(&_47$$22, phalcon_http_request_file_ce); - zephir_array_fetch_string(&_48$$22, &file, SL("key"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 911); - ZEPHIR_CALL_METHOD(NULL, &_47$$22, "__construct", &_18, 343, &dataFile, &_48$$22); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&_49$$22); - zephir_array_fetch_string(&_49$$22, &file, SL("key"), PH_NOISY, "phalcon/Http/Request.zep", 908); - zephir_array_update_zval(&files, &_49$$22, &_47$$22, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_INIT_NVAR(&_50$$23); - object_init_ex(&_50$$23, phalcon_http_request_file_ce); - zephir_array_fetch_string(&_51$$23, &file, SL("key"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 916); - ZEPHIR_CALL_METHOD(NULL, &_50$$23, "__construct", &_18, 343, &dataFile, &_51$$23); - zephir_check_call_status(); - zephir_array_append(&files, &_50$$23, PH_SEPARATE, "phalcon/Http/Request.zep", 916); - } - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &smoothInput, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_42$$19, &smoothInput, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_42$$19)) { - break; - } - ZEPHIR_CALL_METHOD(&file, &smoothInput, "current", NULL, 0); - zephir_check_call_status(); - _52$$24 = onlySuccessful == 0; - if (!(_52$$24)) { - zephir_array_fetch_string(&_53$$24, &file, SL("error"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 898); - _52$$24 = ZEPHIR_IS_LONG(&_53$$24, 0); - } - if (_52$$24) { - ZEPHIR_INIT_NVAR(&_54$$25); - zephir_create_array(&_54$$25, 5, 0); - ZEPHIR_OBS_NVAR(&_55$$25); - zephir_array_fetch_string(&_55$$25, &file, SL("name"), PH_NOISY, "phalcon/Http/Request.zep", 900); - zephir_array_update_string(&_54$$25, SL("name"), &_55$$25, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_55$$25); - zephir_array_fetch_string(&_55$$25, &file, SL("type"), PH_NOISY, "phalcon/Http/Request.zep", 901); - zephir_array_update_string(&_54$$25, SL("type"), &_55$$25, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_55$$25); - zephir_array_fetch_string(&_55$$25, &file, SL("tmp_name"), PH_NOISY, "phalcon/Http/Request.zep", 902); - zephir_array_update_string(&_54$$25, SL("tmp_name"), &_55$$25, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_55$$25); - zephir_array_fetch_string(&_55$$25, &file, SL("size"), PH_NOISY, "phalcon/Http/Request.zep", 903); - zephir_array_update_string(&_54$$25, SL("size"), &_55$$25, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_55$$25); - zephir_array_fetch_string(&_55$$25, &file, SL("error"), PH_NOISY, "phalcon/Http/Request.zep", 905); - zephir_array_update_string(&_54$$25, SL("error"), &_55$$25, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&dataFile, &_54$$25); - if (namedKeys == 1) { - ZEPHIR_INIT_NVAR(&_56$$26); - object_init_ex(&_56$$26, phalcon_http_request_file_ce); - zephir_array_fetch_string(&_57$$26, &file, SL("key"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 911); - ZEPHIR_CALL_METHOD(NULL, &_56$$26, "__construct", &_18, 343, &dataFile, &_57$$26); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&_58$$26); - zephir_array_fetch_string(&_58$$26, &file, SL("key"), PH_NOISY, "phalcon/Http/Request.zep", 908); - zephir_array_update_zval(&files, &_58$$26, &_56$$26, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_INIT_NVAR(&_59$$27); - object_init_ex(&_59$$27, phalcon_http_request_file_ce); - zephir_array_fetch_string(&_60$$27, &file, SL("key"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 916); - ZEPHIR_CALL_METHOD(NULL, &_59$$27, "__construct", &_18, 343, &dataFile, &_60$$27); - zephir_check_call_status(); - zephir_array_append(&files, &_59$$27, PH_SEPARATE, "phalcon/Http/Request.zep", 916); - } - } - ZEPHIR_CALL_METHOD(NULL, &smoothInput, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&file); + if (strict) { + ZVAL_BOOL(&_10$$8, 1); } else { - _61$$28 = onlySuccessful == 0; - if (!(_61$$28)) { - zephir_array_fetch_string(&_62$$28, &input, SL("error"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 921); - _61$$28 = ZEPHIR_IS_LONG(&_62$$28, 0); - } - if (_61$$28) { - if (namedKeys == 1) { - ZEPHIR_INIT_NVAR(&_63$$30); - object_init_ex(&_63$$30, phalcon_http_request_file_ce); - ZEPHIR_CALL_METHOD(NULL, &_63$$30, "__construct", &_18, 343, &input, &prefix); - zephir_check_call_status(); - zephir_array_update_zval(&files, &prefix, &_63$$30, PH_COPY | PH_SEPARATE); - } else { - ZEPHIR_INIT_NVAR(&_64$$31); - object_init_ex(&_64$$31, phalcon_http_request_file_ce); - ZEPHIR_CALL_METHOD(NULL, &_64$$31, "__construct", &_18, 343, &input, &prefix); - zephir_check_call_status(); - zephir_array_append(&files, &_64$$31, PH_SEPARATE, "phalcon/Http/Request.zep", 925); - } - } + ZVAL_BOOL(&_10$$8, 0); } - ZEPHIR_CALL_METHOD(NULL, &superFiles, "next", NULL, 0); + ZEPHIR_CALL_METHOD(&_9$$8, this_ptr, "ismethod", &_8, 345, &method, &_10$$8); + zephir_check_call_status(); + if (zephir_is_true(&_9$$8)) { + RETURN_MM_BOOL(1); + } + ZEPHIR_CALL_METHOD(NULL, methods, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&input); - ZEPHIR_INIT_NVAR(&prefix); + ZEPHIR_INIT_NVAR(&method); + RETURN_MM_BOOL(0); } - RETURN_CTOR(&files); + if (UNEXPECTED(strict)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_request_exception_ce, "Invalid HTTP method: non-string", "phalcon/Http/Request.zep", 1134); + return; + } + RETURN_MM_BOOL(0); } -static PHP_METHOD(Phalcon_Http_Request, getURI) +static PHP_METHOD(Phalcon_Http_Request, isOptions) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *onlyPath_param = NULL, requestURI, _0, _1$$4, _2$$4, _3$$4; - zend_bool onlyPath; zval *this_ptr = getThis(); - ZVAL_UNDEF(&requestURI); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(onlyPath) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &onlyPath_param); - if (!onlyPath_param) { - onlyPath = 0; - } else { - } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "REQUEST_URI"); - ZEPHIR_CALL_METHOD(&requestURI, this_ptr, "getserver", NULL, 0, &_0); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); zephir_check_call_status(); - if (Z_TYPE_P(&requestURI) == IS_NULL) { - RETURN_MM_STRING(""); - } - if (onlyPath) { - ZEPHIR_INIT_VAR(&_1$$4); - ZEPHIR_INIT_VAR(&_2$$4); - ZVAL_STRING(&_2$$4, "?"); - zephir_fast_explode(&_1$$4, &_2$$4, &requestURI, LONG_MAX); - zephir_array_fetch_long(&_3$$4, &_1$$4, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 959); - ZEPHIR_CPY_WRT(&requestURI, &_3$$4); - } - RETURN_CCTOR(&requestURI); + RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "OPTIONS")); } -static PHP_METHOD(Phalcon_Http_Request, getUserAgent) +static PHP_METHOD(Phalcon_Http_Request, isPatch) { - zval userAgent, _0; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&userAgent); ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "HTTP_USER_AGENT"); - ZEPHIR_CALL_METHOD(&userAgent, this_ptr, "getserver", NULL, 0, &_0); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); zephir_check_call_status(); - if (Z_TYPE_P(&userAgent) == IS_NULL) { - RETURN_MM_STRING(""); - } - RETURN_CCTOR(&userAgent); + RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "PATCH")); } -static PHP_METHOD(Phalcon_Http_Request, has) +static PHP_METHOD(Phalcon_Http_Request, isPost) { + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, _REQUEST; - zval name; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_REQUEST); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_get_global(&_REQUEST, SL("_REQUEST")); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - RETURN_MM_BOOL(zephir_array_isset(&_REQUEST, &name)); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); + zephir_check_call_status(); + RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "POST")); } -static PHP_METHOD(Phalcon_Http_Request, hasFiles) +static PHP_METHOD(Phalcon_Http_Request, isPut) { - zval _0, _1; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZVAL_BOOL(&_1, 1); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "numfiles", NULL, 0, &_1); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); zephir_check_call_status(); - RETURN_MM_BOOL(ZEPHIR_GT_LONG(&_0, 0)); + RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "PUT")); } -static PHP_METHOD(Phalcon_Http_Request, hasHeader) +static PHP_METHOD(Phalcon_Http_Request, isPurge) { - zend_bool _4; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *header_param = NULL, name, _0, _1, _2, _3, _5, _6; - zval header; zval *this_ptr = getThis(); - ZVAL_UNDEF(&header); - ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); + zephir_check_call_status(); + RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "PURGE")); +} + +static PHP_METHOD(Phalcon_Http_Request, isSecure) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getscheme", NULL, 0); + zephir_check_call_status(); + RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "https")); +} + +static PHP_METHOD(Phalcon_Http_Request, isStrictHostCheck) +{ + + RETURN_MEMBER(getThis(), "strictHostCheck"); +} + +static PHP_METHOD(Phalcon_Http_Request, isSoap) +{ + zval contentType, _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&contentType); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "HTTP_SOAPACTION"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "hasserver", NULL, 335, &_1); + zephir_check_call_status(); + if (zephir_is_true(&_0)) { + RETURN_MM_BOOL(1); + } + ZEPHIR_CALL_METHOD(&contentType, this_ptr, "getcontenttype", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_EMPTY(&contentType)) { + RETURN_MM_BOOL(0); + } + RETURN_MM_BOOL(zephir_memnstr_str(&contentType, SL("application/soap+xml"), "phalcon/Http/Request.zep", 1219)); +} + +static PHP_METHOD(Phalcon_Http_Request, isTrace) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); + zephir_check_call_status(); + RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "TRACE")); +} + +static PHP_METHOD(Phalcon_Http_Request, isValidHttpMethod) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *method_param = NULL, _0; + zval method; + + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(header) + Z_PARAM_STR(method) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &header_param); - if (UNEXPECTED(Z_TYPE_P(header_param) != IS_STRING && Z_TYPE_P(header_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'header' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(header_param) == IS_STRING)) { - zephir_get_strval(&header, header_param); + zephir_fetch_params(1, 1, 0, &method_param); + zephir_get_strval(&method, method_param); + ZEPHIR_INIT_VAR(&_0); + zephir_fast_strtoupper(&_0, &method); + do { + if (ZEPHIR_IS_STRING(&_0, "CONNECT") || ZEPHIR_IS_STRING(&_0, "DELETE") || ZEPHIR_IS_STRING(&_0, "GET") || ZEPHIR_IS_STRING(&_0, "HEAD") || ZEPHIR_IS_STRING(&_0, "OPTIONS") || ZEPHIR_IS_STRING(&_0, "PATCH") || ZEPHIR_IS_STRING(&_0, "POST") || ZEPHIR_IS_STRING(&_0, "PURGE") || ZEPHIR_IS_STRING(&_0, "PUT") || ZEPHIR_IS_STRING(&_0, "TRACE")) { + RETURN_MM_BOOL(1); + } + } while(0); + + RETURN_MM_BOOL(0); +} + +static PHP_METHOD(Phalcon_Http_Request, numFiles) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_5 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, numberFiles; + zval *onlySuccessful_param = NULL, _FILES, files, file, error, *_0, _1, _3$$8, _4$$8, _7$$13, _8$$13; + zend_bool onlySuccessful, _2$$6, _6$$11; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_FILES); + ZVAL_UNDEF(&files); + ZVAL_UNDEF(&file); + ZVAL_UNDEF(&error); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3$$8); + ZVAL_UNDEF(&_4$$8); + ZVAL_UNDEF(&_7$$13); + ZVAL_UNDEF(&_8$$13); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(onlySuccessful) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_get_global(&_FILES, SL("_FILES")); + zephir_fetch_params(1, 0, 1, &onlySuccessful_param); + if (!onlySuccessful_param) { + onlySuccessful = 0; } else { - ZEPHIR_INIT_VAR(&header); + } + numberFiles = 0; + ZEPHIR_CPY_WRT(&files, &_FILES); + if (Z_TYPE_P(&files) != IS_ARRAY) { + RETURN_MM_LONG(0); } - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "-"); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "_"); - ZEPHIR_CALL_FUNCTION(&_2, "strtr", NULL, 5, &header, &_0, &_1); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&name); - zephir_fast_strtoupper(&name, &_2); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "hasserver", NULL, 335, &name); - zephir_check_call_status(); - _4 = zephir_is_true(&_3); - if (!(_4)) { - ZEPHIR_INIT_VAR(&_6); - ZEPHIR_CONCAT_SV(&_6, "HTTP_", &name); - ZEPHIR_CALL_METHOD(&_5, this_ptr, "hasserver", NULL, 335, &_6); + zephir_is_iterable(&files, 0, "phalcon/Http/Request.zep", 1284); + if (Z_TYPE_P(&files) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&files), _0) + { + ZEPHIR_INIT_NVAR(&file); + ZVAL_COPY(&file, _0); + ZEPHIR_OBS_NVAR(&error); + if (zephir_array_isset_string_fetch(&error, &file, SL("error"), 0)) { + if (Z_TYPE_P(&error) != IS_ARRAY) { + _2$$6 = !zephir_is_true(&error); + if (!(_2$$6)) { + _2$$6 = !onlySuccessful; + } + if (_2$$6) { + numberFiles++; + } + } + if (Z_TYPE_P(&error) == IS_ARRAY) { + if (onlySuccessful) { + ZVAL_BOOL(&_4$$8, 1); + } else { + ZVAL_BOOL(&_4$$8, 0); + } + ZEPHIR_CALL_METHOD(&_3$$8, this_ptr, "hasfilehelper", &_5, 346, &error, &_4$$8); + zephir_check_call_status(); + numberFiles += zephir_get_numberval(&_3$$8); + } + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &files, "rewind", NULL, 0); zephir_check_call_status(); - _4 = zephir_is_true(&_5); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &files, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&file, &files, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&error); + if (zephir_array_isset_string_fetch(&error, &file, SL("error"), 0)) { + if (Z_TYPE_P(&error) != IS_ARRAY) { + _6$$11 = !zephir_is_true(&error); + if (!(_6$$11)) { + _6$$11 = !onlySuccessful; + } + if (_6$$11) { + numberFiles++; + } + } + if (Z_TYPE_P(&error) == IS_ARRAY) { + if (onlySuccessful) { + ZVAL_BOOL(&_8$$13, 1); + } else { + ZVAL_BOOL(&_8$$13, 0); + } + ZEPHIR_CALL_METHOD(&_7$$13, this_ptr, "hasfilehelper", &_5, 346, &error, &_8$$13); + zephir_check_call_status(); + numberFiles += zephir_get_numberval(&_7$$13); + } + } + ZEPHIR_CALL_METHOD(NULL, &files, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_MM_BOOL(_4); + ZEPHIR_INIT_NVAR(&file); + RETURN_MM_LONG(numberFiles); } -static PHP_METHOD(Phalcon_Http_Request, hasPatch) +static PHP_METHOD(Phalcon_Http_Request, setHttpMethodParameterOverride) +{ + zval *override_param = NULL, __$true, __$false; + zend_bool override; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(override) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &override_param); + if (override) { + zephir_update_property_zval(this_ptr, ZEND_STRL("httpMethodParameterOverride"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("httpMethodParameterOverride"), &__$false); + } + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Http_Request, setParameterFilters) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_5 = NULL, *_9 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, patch; - zval name; + zval filters, scope; + zval *name_param = NULL, *filters_param = NULL, *scope_param = NULL, filterService, sanitizer, localScope, scopeMethod, *_2, _3, *_13, _14, _0$$3, _4$$4, _6$$5, _7$$5, _8$$6, _10$$7, _11$$7, _12$$8, _15$$10, _16$$11; + zval name, _1$$3; zval *this_ptr = getThis(); ZVAL_UNDEF(&name); - ZVAL_UNDEF(&patch); - ZEND_PARSE_PARAMETERS_START(1, 1) + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&filterService); + ZVAL_UNDEF(&sanitizer); + ZVAL_UNDEF(&localScope); + ZVAL_UNDEF(&scopeMethod); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&_10$$7); + ZVAL_UNDEF(&_11$$7); + ZVAL_UNDEF(&_12$$8); + ZVAL_UNDEF(&_15$$10); + ZVAL_UNDEF(&_16$$11); + ZVAL_UNDEF(&filters); + ZVAL_UNDEF(&scope); + ZEND_PARSE_PARAMETERS_START(1, 3) Z_PARAM_STR(name) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(filters) + Z_PARAM_ARRAY(scope) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); + zephir_fetch_params(1, 1, 2, &name_param, &filters_param, &scope_param); if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); RETURN_MM_NULL(); @@ -156172,26 +155106,181 @@ static PHP_METHOD(Phalcon_Http_Request, hasPatch) } else { ZEPHIR_INIT_VAR(&name); } - ZEPHIR_CALL_METHOD(&patch, this_ptr, "getpatch", NULL, 0); + if (!filters_param) { + ZEPHIR_INIT_VAR(&filters); + array_init(&filters); + } else { + zephir_get_arrval(&filters, filters_param); + } + if (!scope_param) { + ZEPHIR_INIT_VAR(&scope); + array_init(&scope); + } else { + zephir_get_arrval(&scope, scope_param); + } + if (UNEXPECTED(zephir_fast_count_int(&filters) < 1)) { + ZEPHIR_INIT_VAR(&_0$$3); + object_init_ex(&_0$$3, phalcon_http_request_exception_ce); + ZEPHIR_INIT_VAR(&_1$$3); + ZEPHIR_CONCAT_SVS(&_1$$3, "Filters have not been defined for '", &name, "'"); + ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 33, &_1$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_0$$3, "phalcon/Http/Request.zep", 1315); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(&filterService, this_ptr, "getfilterservice", NULL, 347); zephir_check_call_status(); - RETURN_MM_BOOL(zephir_array_isset(&patch, &name)); + zephir_is_iterable(&filters, 0, "phalcon/Http/Request.zep", 1328); + if (Z_TYPE_P(&filters) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&filters), _2) + { + ZEPHIR_INIT_NVAR(&sanitizer); + ZVAL_COPY(&sanitizer, _2); + ZEPHIR_CALL_METHOD(&_4$$4, &filterService, "has", &_5, 0, &sanitizer); + zephir_check_call_status(); + if (UNEXPECTED(!ZEPHIR_IS_TRUE_IDENTICAL(&_4$$4))) { + ZEPHIR_INIT_NVAR(&_6$$5); + object_init_ex(&_6$$5, phalcon_http_request_exception_ce); + ZEPHIR_INIT_NVAR(&_7$$5); + ZEPHIR_CONCAT_SVS(&_7$$5, "Sanitizer '", &sanitizer, "' does not exist in the filter locator"); + ZEPHIR_CALL_METHOD(NULL, &_6$$5, "__construct", NULL, 33, &_7$$5); + zephir_check_call_status(); + zephir_throw_exception_debug(&_6$$5, "phalcon/Http/Request.zep", 1324); + ZEPHIR_MM_RESTORE(); + return; + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &filters, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, &filters, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&sanitizer, &filters, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_8$$6, &filterService, "has", &_9, 0, &sanitizer); + zephir_check_call_status(); + if (UNEXPECTED(!ZEPHIR_IS_TRUE_IDENTICAL(&_8$$6))) { + ZEPHIR_INIT_NVAR(&_10$$7); + object_init_ex(&_10$$7, phalcon_http_request_exception_ce); + ZEPHIR_INIT_NVAR(&_11$$7); + ZEPHIR_CONCAT_SVS(&_11$$7, "Sanitizer '", &sanitizer, "' does not exist in the filter locator"); + ZEPHIR_CALL_METHOD(NULL, &_10$$7, "__construct", NULL, 33, &_11$$7); + zephir_check_call_status(); + zephir_throw_exception_debug(&_10$$7, "phalcon/Http/Request.zep", 1324); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_CALL_METHOD(NULL, &filters, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&sanitizer); + if (zephir_fast_count_int(&scope) < 1) { + ZEPHIR_INIT_VAR(&localScope); + zephir_create_array(&localScope, 4, 0); + ZEPHIR_INIT_VAR(&_12$$8); + ZVAL_STRING(&_12$$8, "GET"); + zephir_array_fast_append(&localScope, &_12$$8); + ZEPHIR_INIT_NVAR(&_12$$8); + ZVAL_STRING(&_12$$8, "PATCH"); + zephir_array_fast_append(&localScope, &_12$$8); + ZEPHIR_INIT_NVAR(&_12$$8); + ZVAL_STRING(&_12$$8, "POST"); + zephir_array_fast_append(&localScope, &_12$$8); + ZEPHIR_INIT_NVAR(&_12$$8); + ZVAL_STRING(&_12$$8, "PUT"); + zephir_array_fast_append(&localScope, &_12$$8); + } else { + ZEPHIR_CPY_WRT(&localScope, &scope); + } + zephir_is_iterable(&localScope, 0, "phalcon/Http/Request.zep", 1343); + if (Z_TYPE_P(&localScope) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&localScope), _13) + { + ZEPHIR_INIT_NVAR(&scopeMethod); + ZVAL_COPY(&scopeMethod, _13); + ZEPHIR_INIT_NVAR(&_15$$10); + zephir_fast_strtoupper(&_15$$10, &scopeMethod); + zephir_update_property_array_multi(this_ptr, SL("queryFilters"), &filters, SL("zz"), 2, &_15$$10, &name); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &localScope, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_14, &localScope, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_14)) { + break; + } + ZEPHIR_CALL_METHOD(&scopeMethod, &localScope, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_16$$11); + zephir_fast_strtoupper(&_16$$11, &scopeMethod); + zephir_update_property_array_multi(this_ptr, SL("queryFilters"), &filters, SL("zz"), 2, &_16$$11, &name); + ZEPHIR_CALL_METHOD(NULL, &localScope, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&scopeMethod); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Request, hasPost) +static PHP_METHOD(Phalcon_Http_Request, setStrictHostCheck) +{ + zval *flag_param = NULL, __$true, __$false; + zend_bool flag; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(flag) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(0, 1, &flag_param); + if (!flag_param) { + flag = 1; + } else { + } + if (flag) { + zephir_update_property_zval(this_ptr, ZEND_STRL("strictHostCheck"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("strictHostCheck"), &__$false); + } + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Http_Request, getBestQuality) { + double quality = 0, acceptQuality = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, _POST; + zend_long ZEPHIR_LAST_CALL_STATUS, i = 0; zval name; + zval *qualityParts_param = NULL, *name_param = NULL, selectedName, accept, *_0, _1, _2$$4, _3$$5, _4$$8, _5$$9; + zval qualityParts; + ZVAL_UNDEF(&qualityParts); + ZVAL_UNDEF(&selectedName); + ZVAL_UNDEF(&accept); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4$$8); + ZVAL_UNDEF(&_5$$9); ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_POST); - ZEND_PARSE_PARAMETERS_START(1, 1) + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ARRAY(qualityParts) Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_get_global(&_POST, SL("_POST")); - zephir_fetch_params(1, 1, 0, &name_param); + zephir_fetch_params(1, 2, 0, &qualityParts_param, &name_param); + zephir_get_arrval(&qualityParts, qualityParts_param); if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); RETURN_MM_NULL(); @@ -156201,25 +155290,106 @@ static PHP_METHOD(Phalcon_Http_Request, hasPost) } else { ZEPHIR_INIT_VAR(&name); } - RETURN_MM_BOOL(zephir_array_isset(&_POST, &name)); + i = 0; + quality = (0.0); + ZEPHIR_INIT_VAR(&selectedName); + ZVAL_STRING(&selectedName, ""); + zephir_is_iterable(&qualityParts, 0, "phalcon/Http/Request.zep", 1386); + if (Z_TYPE_P(&qualityParts) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&qualityParts), _0) + { + ZEPHIR_INIT_NVAR(&accept); + ZVAL_COPY(&accept, _0); + if (i == 0) { + ZEPHIR_OBS_NVAR(&_2$$4); + zephir_array_fetch_string(&_2$$4, &accept, SL("quality"), PH_NOISY, "phalcon/Http/Request.zep", 1372); + quality = (zephir_get_doubleval(&_2$$4)); + ZEPHIR_OBS_NVAR(&selectedName); + zephir_array_fetch(&selectedName, &accept, &name, PH_NOISY, "phalcon/Http/Request.zep", 1373); + } else { + ZEPHIR_OBS_NVAR(&_3$$5); + zephir_array_fetch_string(&_3$$5, &accept, SL("quality"), PH_NOISY, "phalcon/Http/Request.zep", 1375); + acceptQuality = (zephir_get_doubleval(&_3$$5)); + if (acceptQuality > quality) { + quality = acceptQuality; + ZEPHIR_OBS_NVAR(&selectedName); + zephir_array_fetch(&selectedName, &accept, &name, PH_NOISY, "phalcon/Http/Request.zep", 1379); + } + } + i++; + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &qualityParts, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &qualityParts, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&accept, &qualityParts, "current", NULL, 0); + zephir_check_call_status(); + if (i == 0) { + ZEPHIR_OBS_NVAR(&_4$$8); + zephir_array_fetch_string(&_4$$8, &accept, SL("quality"), PH_NOISY, "phalcon/Http/Request.zep", 1372); + quality = (zephir_get_doubleval(&_4$$8)); + ZEPHIR_OBS_NVAR(&selectedName); + zephir_array_fetch(&selectedName, &accept, &name, PH_NOISY, "phalcon/Http/Request.zep", 1373); + } else { + ZEPHIR_OBS_NVAR(&_5$$9); + zephir_array_fetch_string(&_5$$9, &accept, SL("quality"), PH_NOISY, "phalcon/Http/Request.zep", 1375); + acceptQuality = (zephir_get_doubleval(&_5$$9)); + if (acceptQuality > quality) { + quality = acceptQuality; + ZEPHIR_OBS_NVAR(&selectedName); + zephir_array_fetch(&selectedName, &accept, &name, PH_NOISY, "phalcon/Http/Request.zep", 1379); + } + } + i++; + ZEPHIR_CALL_METHOD(NULL, &qualityParts, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&accept); + RETURN_CCTOR(&selectedName); } -static PHP_METHOD(Phalcon_Http_Request, hasPut) +static PHP_METHOD(Phalcon_Http_Request, getHelper) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, put; + zend_bool notAllowEmpty, noRecursive, _0, _1; zval name; + zval *source_param = NULL, *name_param = NULL, *filters = NULL, filters_sub, *defaultValue = NULL, defaultValue_sub, *notAllowEmpty_param = NULL, *noRecursive_param = NULL, __$null, value, filterService, _2$$6, _3$$6; + zval source; zval *this_ptr = getThis(); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&filters_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&filterService); + ZVAL_UNDEF(&_2$$6); + ZVAL_UNDEF(&_3$$6); ZVAL_UNDEF(&name); - ZVAL_UNDEF(&put); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 6) + Z_PARAM_ARRAY(source) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + Z_PARAM_ZVAL_OR_NULL(filters) + Z_PARAM_ZVAL_OR_NULL(defaultValue) + Z_PARAM_BOOL(notAllowEmpty) + Z_PARAM_BOOL(noRecursive) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); + zephir_fetch_params(1, 1, 5, &source_param, &name_param, &filters, &defaultValue, ¬AllowEmpty_param, &noRecursive_param); + zephir_get_arrval(&source, source_param); + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); RETURN_MM_NULL(); @@ -156229,54 +155399,234 @@ static PHP_METHOD(Phalcon_Http_Request, hasPut) } else { ZEPHIR_INIT_VAR(&name); } - ZEPHIR_CALL_METHOD(&put, this_ptr, "getput", NULL, 0); - zephir_check_call_status(); - RETURN_MM_BOOL(zephir_array_isset(&put, &name)); + } + if (!filters) { + filters = &filters_sub; + filters = &__$null; + } + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } + if (!notAllowEmpty_param) { + notAllowEmpty = 0; + } else { + } + if (!noRecursive_param) { + noRecursive = 0; + } else { + } + if (ZEPHIR_IS_NULL(&name)) { + RETURN_CTOR(&source); + } + zephir_memory_observe(&value); + if (!(zephir_array_isset_fetch(&value, &source, &name, 0))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + _0 = !(zephir_is_numeric(&value)); + if (_0) { + _0 = ZEPHIR_IS_EMPTY(&value); + } + _1 = _0; + if (_1) { + _1 = notAllowEmpty; + } + if (_1) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + if (Z_TYPE_P(filters) != IS_NULL) { + ZEPHIR_CALL_METHOD(&filterService, this_ptr, "getfilterservice", NULL, 347); + zephir_check_call_status(); + if (noRecursive) { + ZVAL_BOOL(&_3$$6, 1); + } else { + ZVAL_BOOL(&_3$$6, 0); + } + ZEPHIR_CALL_METHOD(&_2$$6, &filterService, "sanitize", NULL, 0, &value, filters, &_3$$6); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&value, &_2$$6); + if (ZEPHIR_IS_FALSE_IDENTICAL(&value)) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + } + RETURN_CCTOR(&value); } -static PHP_METHOD(Phalcon_Http_Request, hasQuery) +static PHP_METHOD(Phalcon_Http_Request, hasFileHelper) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, _GET; - zval name; + zephir_fcall_cache_entry *_5 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, numberFiles; + zend_bool onlySuccessful, _2$$5, _6$$9; + zval *data, data_sub, *onlySuccessful_param = NULL, value, *_0, _1, _3$$7, _4$$7, _7$$11, _8$$11; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_GET); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + ZVAL_UNDEF(&data_sub); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3$$7); + ZVAL_UNDEF(&_4$$7); + ZVAL_UNDEF(&_7$$11); + ZVAL_UNDEF(&_8$$11); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(data) + Z_PARAM_BOOL(onlySuccessful) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_get_global(&_GET, SL("_GET")); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 2, 0, &data, &onlySuccessful_param); + numberFiles = 0; + if (Z_TYPE_P(data) != IS_ARRAY) { + RETURN_MM_LONG(1); } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + zephir_is_iterable(data, 0, "phalcon/Http/Request.zep", 1455); + if (Z_TYPE_P(data) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(data), _0) + { + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0); + if (Z_TYPE_P(&value) != IS_ARRAY) { + _2$$5 = !zephir_is_true(&value); + if (!(_2$$5)) { + _2$$5 = !onlySuccessful; + } + if (_2$$5) { + numberFiles++; + } + } + if (Z_TYPE_P(&value) == IS_ARRAY) { + if (onlySuccessful) { + ZVAL_BOOL(&_4$$7, 1); + } else { + ZVAL_BOOL(&_4$$7, 0); + } + ZEPHIR_CALL_METHOD(&_3$$7, this_ptr, "hasfilehelper", &_5, 346, &value, &_4$$7); + zephir_check_call_status(); + numberFiles += zephir_get_numberval(&_3$$7); + } + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_INIT_VAR(&name); + ZEPHIR_CALL_METHOD(NULL, data, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, data, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&value, data, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&value) != IS_ARRAY) { + _6$$9 = !zephir_is_true(&value); + if (!(_6$$9)) { + _6$$9 = !onlySuccessful; + } + if (_6$$9) { + numberFiles++; + } + } + if (Z_TYPE_P(&value) == IS_ARRAY) { + if (onlySuccessful) { + ZVAL_BOOL(&_8$$11, 1); + } else { + ZVAL_BOOL(&_8$$11, 0); + } + ZEPHIR_CALL_METHOD(&_7$$11, this_ptr, "hasfilehelper", &_5, 346, &value, &_8$$11); + zephir_check_call_status(); + numberFiles += zephir_get_numberval(&_7$$11); + } + ZEPHIR_CALL_METHOD(NULL, data, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_MM_BOOL(zephir_array_isset(&_GET, &name)); + ZEPHIR_INIT_NVAR(&value); + RETURN_MM_LONG(numberFiles); } -static PHP_METHOD(Phalcon_Http_Request, hasServer) +static PHP_METHOD(Phalcon_Http_Request, getQualityHeader) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, server; - zval name; + zval *serverIndex_param = NULL, *name_param = NULL, headerPart, headerParts, headerSplit, part, parts, returnedParts, serverValue, split, _0, _1, _2, _3, *_4, _5, _6$$3, _7$$3, _8$$3, _9$$3, *_10$$3, _11$$3, _12$$4, _13$$4, _14$$5, _15$$6, _16$$6, _17$$7, _18$$7, _19$$8, _20$$9, _21$$9, _22$$10, _23$$11, _24$$11, _25$$12, _26$$12, _27$$13, _28$$14, _29$$14, _30$$14, _31$$14, *_32$$14, _33$$14, _34$$15, _35$$15, _36$$16, _37$$17, _38$$17, _39$$18, _40$$18, _41$$19, _42$$20, _43$$20, _44$$21, _45$$22, _46$$22, _47$$23, _48$$23, _49$$24; + zval serverIndex, name; zval *this_ptr = getThis(); + ZVAL_UNDEF(&serverIndex); ZVAL_UNDEF(&name); - ZVAL_UNDEF(&server); - ZEND_PARSE_PARAMETERS_START(1, 1) + ZVAL_UNDEF(&headerPart); + ZVAL_UNDEF(&headerParts); + ZVAL_UNDEF(&headerSplit); + ZVAL_UNDEF(&part); + ZVAL_UNDEF(&parts); + ZVAL_UNDEF(&returnedParts); + ZVAL_UNDEF(&serverValue); + ZVAL_UNDEF(&split); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$3); + ZVAL_UNDEF(&_11$$3); + ZVAL_UNDEF(&_12$$4); + ZVAL_UNDEF(&_13$$4); + ZVAL_UNDEF(&_14$$5); + ZVAL_UNDEF(&_15$$6); + ZVAL_UNDEF(&_16$$6); + ZVAL_UNDEF(&_17$$7); + ZVAL_UNDEF(&_18$$7); + ZVAL_UNDEF(&_19$$8); + ZVAL_UNDEF(&_20$$9); + ZVAL_UNDEF(&_21$$9); + ZVAL_UNDEF(&_22$$10); + ZVAL_UNDEF(&_23$$11); + ZVAL_UNDEF(&_24$$11); + ZVAL_UNDEF(&_25$$12); + ZVAL_UNDEF(&_26$$12); + ZVAL_UNDEF(&_27$$13); + ZVAL_UNDEF(&_28$$14); + ZVAL_UNDEF(&_29$$14); + ZVAL_UNDEF(&_30$$14); + ZVAL_UNDEF(&_31$$14); + ZVAL_UNDEF(&_33$$14); + ZVAL_UNDEF(&_34$$15); + ZVAL_UNDEF(&_35$$15); + ZVAL_UNDEF(&_36$$16); + ZVAL_UNDEF(&_37$$17); + ZVAL_UNDEF(&_38$$17); + ZVAL_UNDEF(&_39$$18); + ZVAL_UNDEF(&_40$$18); + ZVAL_UNDEF(&_41$$19); + ZVAL_UNDEF(&_42$$20); + ZVAL_UNDEF(&_43$$20); + ZVAL_UNDEF(&_44$$21); + ZVAL_UNDEF(&_45$$22); + ZVAL_UNDEF(&_46$$22); + ZVAL_UNDEF(&_47$$23); + ZVAL_UNDEF(&_48$$23); + ZVAL_UNDEF(&_49$$24); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(serverIndex) Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); + zephir_fetch_params(1, 2, 0, &serverIndex_param, &name_param); + if (UNEXPECTED(Z_TYPE_P(serverIndex_param) != IS_STRING && Z_TYPE_P(serverIndex_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'serverIndex' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(serverIndex_param) == IS_STRING)) { + zephir_get_strval(&serverIndex, serverIndex_param); + } else { + ZEPHIR_INIT_VAR(&serverIndex); + } if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); RETURN_MM_NULL(); @@ -156286,2761 +155636,3208 @@ static PHP_METHOD(Phalcon_Http_Request, hasServer) } else { ZEPHIR_INIT_VAR(&name); } - ZEPHIR_CALL_METHOD(&server, this_ptr, "getserverarray", NULL, 337); + ZEPHIR_INIT_VAR(&returnedParts); + array_init(&returnedParts); + ZEPHIR_CALL_METHOD(&serverValue, this_ptr, "getserver", NULL, 0, &serverIndex); zephir_check_call_status(); - RETURN_MM_BOOL(zephir_array_isset(&server, &name)); -} - -static PHP_METHOD(Phalcon_Http_Request, isAjax) -{ - zend_bool _2; - zval _0, _1, _3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - + ZEPHIR_INIT_VAR(&_0); + if (Z_TYPE_P(&serverValue) == IS_NULL) { + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, ""); + } else { + ZEPHIR_CPY_WRT(&_0, &serverValue); + } + ZEPHIR_CPY_WRT(&serverValue, &_0); ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "HTTP_X_REQUESTED_WITH"); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "hasserver", NULL, 335, &_1); + ZVAL_STRING(&_1, "/,\\s*/"); + ZVAL_LONG(&_2, -1); + ZVAL_LONG(&_3, 1); + ZEPHIR_CALL_FUNCTION(&parts, "preg_split", NULL, 70, &_1, &serverValue, &_2, &_3); zephir_check_call_status(); - _2 = zephir_is_true(&_0); - if (_2) { - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "HTTP_X_REQUESTED_WITH"); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "getserver", NULL, 0, &_1); + zephir_is_iterable(&parts, 0, "phalcon/Http/Request.zep", 1499); + if (Z_TYPE_P(&parts) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&parts), _4) + { + ZEPHIR_INIT_NVAR(&part); + ZVAL_COPY(&part, _4); + ZEPHIR_INIT_NVAR(&headerParts); + array_init(&headerParts); + ZEPHIR_INIT_NVAR(&_6$$3); + zephir_fast_trim(&_6$$3, &part, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_7$$3); + ZVAL_STRING(&_7$$3, "/\\s*;\\s*/"); + ZVAL_LONG(&_8$$3, -1); + ZVAL_LONG(&_9$$3, 1); + ZEPHIR_CALL_FUNCTION(&headerSplit, "preg_split", NULL, 70, &_7$$3, &_6$$3, &_8$$3, &_9$$3); + zephir_check_call_status(); + zephir_is_iterable(&headerSplit, 0, "phalcon/Http/Request.zep", 1496); + if (Z_TYPE_P(&headerSplit) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&headerSplit), _10$$3) + { + ZEPHIR_INIT_NVAR(&headerPart); + ZVAL_COPY(&headerPart, _10$$3); + ZEPHIR_INIT_NVAR(&_12$$4); + ZVAL_STRING(&_12$$4, "="); + ZEPHIR_INIT_NVAR(&_13$$4); + zephir_fast_strpos(&_13$$4, &headerPart, &_12$$4, 0 ); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_13$$4)) { + ZEPHIR_INIT_NVAR(&split); + zephir_fast_explode_str(&split, SL("="), &headerPart, 2 ); + zephir_array_fetch_long(&_14$$5, &split, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1485); + if (ZEPHIR_IS_STRING_IDENTICAL(&_14$$5, "q")) { + ZEPHIR_OBS_NVAR(&_15$$6); + zephir_array_fetch_long(&_15$$6, &split, 1, PH_NOISY, "phalcon/Http/Request.zep", 1486); + ZEPHIR_INIT_NVAR(&_16$$6); + ZVAL_DOUBLE(&_16$$6, zephir_get_doubleval(&_15$$6)); + zephir_array_update_string(&headerParts, SL("quality"), &_16$$6, PH_COPY | PH_SEPARATE); + } else { + zephir_array_fetch_long(&_17$$7, &split, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1488); + ZEPHIR_OBS_NVAR(&_18$$7); + zephir_array_fetch_long(&_18$$7, &split, 0, PH_NOISY, "phalcon/Http/Request.zep", 1488); + zephir_array_update_zval(&headerParts, &_18$$7, &_17$$7, PH_COPY | PH_SEPARATE); + } + } else { + zephir_array_update_zval(&headerParts, &name, &headerPart, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_19$$8); + ZVAL_DOUBLE(&_19$$8, 1.0); + zephir_array_update_string(&headerParts, SL("quality"), &_19$$8, PH_COPY | PH_SEPARATE); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &headerSplit, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_11$$3, &headerSplit, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_11$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&headerPart, &headerSplit, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_20$$9); + ZVAL_STRING(&_20$$9, "="); + ZEPHIR_INIT_NVAR(&_21$$9); + zephir_fast_strpos(&_21$$9, &headerPart, &_20$$9, 0 ); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_21$$9)) { + ZEPHIR_INIT_NVAR(&split); + zephir_fast_explode_str(&split, SL("="), &headerPart, 2 ); + zephir_array_fetch_long(&_22$$10, &split, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1485); + if (ZEPHIR_IS_STRING_IDENTICAL(&_22$$10, "q")) { + ZEPHIR_OBS_NVAR(&_23$$11); + zephir_array_fetch_long(&_23$$11, &split, 1, PH_NOISY, "phalcon/Http/Request.zep", 1486); + ZEPHIR_INIT_NVAR(&_24$$11); + ZVAL_DOUBLE(&_24$$11, zephir_get_doubleval(&_23$$11)); + zephir_array_update_string(&headerParts, SL("quality"), &_24$$11, PH_COPY | PH_SEPARATE); + } else { + zephir_array_fetch_long(&_25$$12, &split, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1488); + ZEPHIR_OBS_NVAR(&_26$$12); + zephir_array_fetch_long(&_26$$12, &split, 0, PH_NOISY, "phalcon/Http/Request.zep", 1488); + zephir_array_update_zval(&headerParts, &_26$$12, &_25$$12, PH_COPY | PH_SEPARATE); + } + } else { + zephir_array_update_zval(&headerParts, &name, &headerPart, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_27$$13); + ZVAL_DOUBLE(&_27$$13, 1.0); + zephir_array_update_string(&headerParts, SL("quality"), &_27$$13, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, &headerSplit, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&headerPart); + zephir_array_append(&returnedParts, &headerParts, PH_SEPARATE, "phalcon/Http/Request.zep", 1496); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &parts, "rewind", NULL, 0); zephir_check_call_status(); - _2 = ZEPHIR_IS_STRING_IDENTICAL(&_3, "XMLHttpRequest"); + while (1) { + ZEPHIR_CALL_METHOD(&_5, &parts, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5)) { + break; + } + ZEPHIR_CALL_METHOD(&part, &parts, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&headerParts); + array_init(&headerParts); + ZEPHIR_INIT_NVAR(&_28$$14); + zephir_fast_trim(&_28$$14, &part, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_29$$14); + ZVAL_STRING(&_29$$14, "/\\s*;\\s*/"); + ZVAL_LONG(&_30$$14, -1); + ZVAL_LONG(&_31$$14, 1); + ZEPHIR_CALL_FUNCTION(&headerSplit, "preg_split", NULL, 70, &_29$$14, &_28$$14, &_30$$14, &_31$$14); + zephir_check_call_status(); + zephir_is_iterable(&headerSplit, 0, "phalcon/Http/Request.zep", 1496); + if (Z_TYPE_P(&headerSplit) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&headerSplit), _32$$14) + { + ZEPHIR_INIT_NVAR(&headerPart); + ZVAL_COPY(&headerPart, _32$$14); + ZEPHIR_INIT_NVAR(&_34$$15); + ZVAL_STRING(&_34$$15, "="); + ZEPHIR_INIT_NVAR(&_35$$15); + zephir_fast_strpos(&_35$$15, &headerPart, &_34$$15, 0 ); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_35$$15)) { + ZEPHIR_INIT_NVAR(&split); + zephir_fast_explode_str(&split, SL("="), &headerPart, 2 ); + zephir_array_fetch_long(&_36$$16, &split, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1485); + if (ZEPHIR_IS_STRING_IDENTICAL(&_36$$16, "q")) { + ZEPHIR_OBS_NVAR(&_37$$17); + zephir_array_fetch_long(&_37$$17, &split, 1, PH_NOISY, "phalcon/Http/Request.zep", 1486); + ZEPHIR_INIT_NVAR(&_38$$17); + ZVAL_DOUBLE(&_38$$17, zephir_get_doubleval(&_37$$17)); + zephir_array_update_string(&headerParts, SL("quality"), &_38$$17, PH_COPY | PH_SEPARATE); + } else { + zephir_array_fetch_long(&_39$$18, &split, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1488); + ZEPHIR_OBS_NVAR(&_40$$18); + zephir_array_fetch_long(&_40$$18, &split, 0, PH_NOISY, "phalcon/Http/Request.zep", 1488); + zephir_array_update_zval(&headerParts, &_40$$18, &_39$$18, PH_COPY | PH_SEPARATE); + } + } else { + zephir_array_update_zval(&headerParts, &name, &headerPart, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_41$$19); + ZVAL_DOUBLE(&_41$$19, 1.0); + zephir_array_update_string(&headerParts, SL("quality"), &_41$$19, PH_COPY | PH_SEPARATE); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &headerSplit, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_33$$14, &headerSplit, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_33$$14)) { + break; + } + ZEPHIR_CALL_METHOD(&headerPart, &headerSplit, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_42$$20); + ZVAL_STRING(&_42$$20, "="); + ZEPHIR_INIT_NVAR(&_43$$20); + zephir_fast_strpos(&_43$$20, &headerPart, &_42$$20, 0 ); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_43$$20)) { + ZEPHIR_INIT_NVAR(&split); + zephir_fast_explode_str(&split, SL("="), &headerPart, 2 ); + zephir_array_fetch_long(&_44$$21, &split, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1485); + if (ZEPHIR_IS_STRING_IDENTICAL(&_44$$21, "q")) { + ZEPHIR_OBS_NVAR(&_45$$22); + zephir_array_fetch_long(&_45$$22, &split, 1, PH_NOISY, "phalcon/Http/Request.zep", 1486); + ZEPHIR_INIT_NVAR(&_46$$22); + ZVAL_DOUBLE(&_46$$22, zephir_get_doubleval(&_45$$22)); + zephir_array_update_string(&headerParts, SL("quality"), &_46$$22, PH_COPY | PH_SEPARATE); + } else { + zephir_array_fetch_long(&_47$$23, &split, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1488); + ZEPHIR_OBS_NVAR(&_48$$23); + zephir_array_fetch_long(&_48$$23, &split, 0, PH_NOISY, "phalcon/Http/Request.zep", 1488); + zephir_array_update_zval(&headerParts, &_48$$23, &_47$$23, PH_COPY | PH_SEPARATE); + } + } else { + zephir_array_update_zval(&headerParts, &name, &headerPart, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_49$$24); + ZVAL_DOUBLE(&_49$$24, 1.0); + zephir_array_update_string(&headerParts, SL("quality"), &_49$$24, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, &headerSplit, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&headerPart); + zephir_array_append(&returnedParts, &headerParts, PH_SEPARATE, "phalcon/Http/Request.zep", 1496); + ZEPHIR_CALL_METHOD(NULL, &parts, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_MM_BOOL(_2); -} - -static PHP_METHOD(Phalcon_Http_Request, isConnect) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); - zephir_check_call_status(); - RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "CONNECT")); -} - -static PHP_METHOD(Phalcon_Http_Request, isDelete) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); - zephir_check_call_status(); - RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "DELETE")); -} - -static PHP_METHOD(Phalcon_Http_Request, isGet) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); - zephir_check_call_status(); - RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "GET")); + ZEPHIR_INIT_NVAR(&part); + RETURN_CCTOR(&returnedParts); } -static PHP_METHOD(Phalcon_Http_Request, isHead) +static PHP_METHOD(Phalcon_Http_Request, resolveAuthorizationHeaders) { - zval _0; + zend_bool _4, _9, _35, _22$$11; + zval headers, _5$$5, _36$$19; + zval resolved, eventsManager, hasEventsManager, container, exploded, digest, authHeader, server, _0, _8, _10, _1$$3, _2$$4, _3$$4, _6$$5, _7$$6, _11$$7, _12$$7, _13$$7, _14$$8, _15$$8, _16$$8, _17$$9, _18$$10, _19$$11, _20$$11, _21$$11, _23$$11, _24$$11, _25$$12, _26$$12, _27$$12, _28$$13, _29$$13, _30$$17, _31$$17, _32$$17, _33$$17, _34$$17, _37$$19, _38$$20; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); + ZVAL_UNDEF(&resolved); + ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&hasEventsManager); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&exploded); + ZVAL_UNDEF(&digest); + ZVAL_UNDEF(&authHeader); + ZVAL_UNDEF(&server); ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); - zephir_check_call_status(); - RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "HEAD")); -} - -static PHP_METHOD(Phalcon_Http_Request, isMethod) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_8 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool strict, _0$$3; - zval *methods, methods_sub, *strict_param = NULL, httpMethod, method, _1$$3, _2$$4, _3$$4, *_4$$5, _5$$5, _6$$6, _7$$6, _9$$8, _10$$8; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&methods_sub); - ZVAL_UNDEF(&httpMethod); - ZVAL_UNDEF(&method); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_2$$4); ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_6$$6); + ZVAL_UNDEF(&_6$$5); ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_9$$8); - ZVAL_UNDEF(&_10$$8); - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(methods) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(strict) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_11$$7); + ZVAL_UNDEF(&_12$$7); + ZVAL_UNDEF(&_13$$7); + ZVAL_UNDEF(&_14$$8); + ZVAL_UNDEF(&_15$$8); + ZVAL_UNDEF(&_16$$8); + ZVAL_UNDEF(&_17$$9); + ZVAL_UNDEF(&_18$$10); + ZVAL_UNDEF(&_19$$11); + ZVAL_UNDEF(&_20$$11); + ZVAL_UNDEF(&_21$$11); + ZVAL_UNDEF(&_23$$11); + ZVAL_UNDEF(&_24$$11); + ZVAL_UNDEF(&_25$$12); + ZVAL_UNDEF(&_26$$12); + ZVAL_UNDEF(&_27$$12); + ZVAL_UNDEF(&_28$$13); + ZVAL_UNDEF(&_29$$13); + ZVAL_UNDEF(&_30$$17); + ZVAL_UNDEF(&_31$$17); + ZVAL_UNDEF(&_32$$17); + ZVAL_UNDEF(&_33$$17); + ZVAL_UNDEF(&_34$$17); + ZVAL_UNDEF(&_37$$19); + ZVAL_UNDEF(&_38$$20); + ZVAL_UNDEF(&headers); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_36$$19); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &methods, &strict_param); - if (!strict_param) { - strict = 0; - } else { - } - ZEPHIR_CALL_METHOD(&httpMethod, this_ptr, "getmethod", NULL, 344); + + ZEPHIR_INIT_VAR(&authHeader); + ZVAL_NULL(&authHeader); + ZEPHIR_INIT_VAR(&headers); + array_init(&headers); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getdi", NULL, 0); zephir_check_call_status(); - if (Z_TYPE_P(methods) == IS_STRING) { - _0$$3 = strict; - if (_0$$3) { - ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "isvalidhttpmethod", NULL, 0, methods); - zephir_check_call_status(); - _0$$3 = !zephir_is_true(&_1$$3); - } - if (UNEXPECTED(_0$$3)) { - ZEPHIR_INIT_VAR(&_2$$4); - object_init_ex(&_2$$4, phalcon_http_request_exception_ce); + ZEPHIR_CPY_WRT(&container, &_0); + ZEPHIR_CALL_METHOD(&server, this_ptr, "getserverarray", NULL, 337); + zephir_check_call_status(); + if (Z_TYPE_P(&container) != IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "eventsManager"); + ZEPHIR_CALL_METHOD(&hasEventsManager, &container, "has", NULL, 0, &_1$$3); + zephir_check_call_status(); + if (zephir_is_true(&hasEventsManager)) { ZEPHIR_INIT_VAR(&_3$$4); - ZEPHIR_CONCAT_SV(&_3$$4, "Invalid HTTP method: ", methods); - ZEPHIR_CALL_METHOD(NULL, &_2$$4, "__construct", NULL, 33, &_3$$4); + ZVAL_STRING(&_3$$4, "eventsManager"); + ZEPHIR_CALL_METHOD(&_2$$4, &container, "getshared", NULL, 0, &_3$$4); zephir_check_call_status(); - zephir_throw_exception_debug(&_2$$4, "phalcon/Http/Request.zep", 1117); - ZEPHIR_MM_RESTORE(); - return; + ZEPHIR_CPY_WRT(&eventsManager, &_2$$4); } - RETURN_MM_BOOL(ZEPHIR_IS_EQUAL(methods, &httpMethod)); } - if (Z_TYPE_P(methods) == IS_ARRAY) { - zephir_is_iterable(methods, 0, "phalcon/Http/Request.zep", 1130); - if (Z_TYPE_P(methods) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(methods), _4$$5) - { - ZEPHIR_INIT_NVAR(&method); - ZVAL_COPY(&method, _4$$5); - if (strict) { - ZVAL_BOOL(&_7$$6, 1); - } else { - ZVAL_BOOL(&_7$$6, 0); - } - ZEPHIR_CALL_METHOD(&_6$$6, this_ptr, "ismethod", &_8, 345, &method, &_7$$6); + _4 = zephir_is_true(&hasEventsManager); + if (_4) { + _4 = Z_TYPE_P(&eventsManager) == IS_OBJECT; + } + if (_4) { + ZEPHIR_INIT_VAR(&_5$$5); + zephir_create_array(&_5$$5, 1, 0); + zephir_array_update_string(&_5$$5, SL("server"), &server, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_6$$5); + ZVAL_STRING(&_6$$5, "request:beforeAuthorizationResolve"); + ZEPHIR_CALL_METHOD(&resolved, &eventsManager, "fire", NULL, 0, &_6$$5, this_ptr, &_5$$5); + zephir_check_call_status(); + if (Z_TYPE_P(&resolved) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&_7$$6); + zephir_fast_array_merge(&_7$$6, &headers, &resolved); + ZEPHIR_CPY_WRT(&headers, &_7$$6); + } + } + ZEPHIR_INIT_VAR(&_8); + ZVAL_STRING(&_8, "PHP_AUTH_USER"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "hasserver", NULL, 335, &_8); + zephir_check_call_status(); + _9 = zephir_is_true(&_0); + if (_9) { + ZEPHIR_INIT_NVAR(&_8); + ZVAL_STRING(&_8, "PHP_AUTH_PW"); + ZEPHIR_CALL_METHOD(&_10, this_ptr, "hasserver", NULL, 335, &_8); + zephir_check_call_status(); + _9 = zephir_is_true(&_10); + } + if (_9) { + ZEPHIR_INIT_VAR(&_12$$7); + ZVAL_STRING(&_12$$7, "PHP_AUTH_USER"); + ZEPHIR_CALL_METHOD(&_11$$7, this_ptr, "getserver", NULL, 0, &_12$$7); + zephir_check_call_status(); + zephir_array_update_string(&headers, SL("Php-Auth-User"), &_11$$7, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_12$$7); + ZVAL_STRING(&_12$$7, "PHP_AUTH_PW"); + ZEPHIR_CALL_METHOD(&_13$$7, this_ptr, "getserver", NULL, 0, &_12$$7); + zephir_check_call_status(); + zephir_array_update_string(&headers, SL("Php-Auth-Pw"), &_13$$7, PH_COPY | PH_SEPARATE); + } else { + ZEPHIR_INIT_VAR(&_15$$8); + ZVAL_STRING(&_15$$8, "HTTP_AUTHORIZATION"); + ZEPHIR_CALL_METHOD(&_14$$8, this_ptr, "hasserver", NULL, 335, &_15$$8); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_15$$8); + ZVAL_STRING(&_15$$8, "REDIRECT_HTTP_AUTHORIZATION"); + ZEPHIR_CALL_METHOD(&_16$$8, this_ptr, "hasserver", NULL, 335, &_15$$8); + zephir_check_call_status(); + if (zephir_is_true(&_14$$8)) { + ZEPHIR_INIT_VAR(&_17$$9); + ZVAL_STRING(&_17$$9, "HTTP_AUTHORIZATION"); + ZEPHIR_CALL_METHOD(&authHeader, this_ptr, "getserver", NULL, 0, &_17$$9); + zephir_check_call_status(); + } else if (zephir_is_true(&_16$$8)) { + ZEPHIR_INIT_VAR(&_18$$10); + ZVAL_STRING(&_18$$10, "REDIRECT_HTTP_AUTHORIZATION"); + ZEPHIR_CALL_METHOD(&authHeader, this_ptr, "getserver", NULL, 0, &_18$$10); + zephir_check_call_status(); + } + if (zephir_is_true(&authHeader)) { + ZEPHIR_INIT_VAR(&_19$$11); + ZVAL_STRING(&_19$$11, "basic "); + ZEPHIR_CALL_FUNCTION(&_20$$11, "stripos", NULL, 348, &authHeader, &_19$$11); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_19$$11); + ZVAL_STRING(&_19$$11, "digest "); + ZEPHIR_CALL_FUNCTION(&_21$$11, "stripos", NULL, 348, &authHeader, &_19$$11); + zephir_check_call_status(); + _22$$11 = ZEPHIR_IS_LONG_IDENTICAL(&_21$$11, 0); + if (_22$$11) { + ZEPHIR_INIT_NVAR(&_19$$11); + ZVAL_STRING(&_19$$11, "PHP_AUTH_DIGEST"); + ZEPHIR_CALL_METHOD(&_23$$11, this_ptr, "hasserver", NULL, 335, &_19$$11); zephir_check_call_status(); - if (zephir_is_true(&_6$$6)) { - RETURN_MM_BOOL(1); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, methods, "rewind", NULL, 0); + _22$$11 = !zephir_is_true(&_23$$11); + } + ZEPHIR_INIT_NVAR(&_19$$11); + ZVAL_STRING(&_19$$11, "bearer "); + ZEPHIR_CALL_FUNCTION(&_24$$11, "stripos", NULL, 348, &authHeader, &_19$$11); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5$$5, methods, "valid", NULL, 0); + if (ZEPHIR_IS_LONG_IDENTICAL(&_20$$11, 0)) { + ZVAL_LONG(&_25$$12, 6); + ZEPHIR_INIT_VAR(&_26$$12); + zephir_substr(&_26$$12, &authHeader, 6 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + ZEPHIR_CALL_FUNCTION(&_27$$12, "base64_decode", NULL, 230, &_26$$12); zephir_check_call_status(); - if (!zend_is_true(&_5$$5)) { - break; + ZEPHIR_INIT_VAR(&exploded); + zephir_fast_explode_str(&exploded, SL(":"), &_27$$12, 2 ); + if (zephir_fast_count_int(&exploded) == 2) { + zephir_array_fetch_long(&_28$$13, &exploded, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1558); + zephir_array_update_string(&headers, SL("Php-Auth-User"), &_28$$13, PH_COPY | PH_SEPARATE); + zephir_array_fetch_long(&_29$$13, &exploded, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1559); + zephir_array_update_string(&headers, SL("Php-Auth-Pw"), &_29$$13, PH_COPY | PH_SEPARATE); } - ZEPHIR_CALL_METHOD(&method, methods, "current", NULL, 0); - zephir_check_call_status(); - if (strict) { - ZVAL_BOOL(&_10$$8, 1); - } else { - ZVAL_BOOL(&_10$$8, 0); - } - ZEPHIR_CALL_METHOD(&_9$$8, this_ptr, "ismethod", &_8, 345, &method, &_10$$8); - zephir_check_call_status(); - if (zephir_is_true(&_9$$8)) { - RETURN_MM_BOOL(1); - } - ZEPHIR_CALL_METHOD(NULL, methods, "next", NULL, 0); - zephir_check_call_status(); + } else if (_22$$11) { + zephir_array_update_string(&headers, SL("Php-Auth-Digest"), &authHeader, PH_COPY | PH_SEPARATE); + } else if (ZEPHIR_IS_LONG_IDENTICAL(&_24$$11, 0)) { + zephir_array_update_string(&headers, SL("Authorization"), &authHeader, PH_COPY | PH_SEPARATE); } } - ZEPHIR_INIT_NVAR(&method); - RETURN_MM_BOOL(0); } - if (UNEXPECTED(strict)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_request_exception_ce, "Invalid HTTP method: non-string", "phalcon/Http/Request.zep", 1134); - return; + if (!(zephir_array_isset_string(&headers, SL("Authorization")))) { + zephir_memory_observe(&digest); + if (zephir_array_isset_string(&headers, SL("Php-Auth-User"))) { + zephir_array_fetch_string(&_30$$17, &headers, SL("Php-Auth-User"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1571); + zephir_array_fetch_string(&_31$$17, &headers, SL("Php-Auth-Pw"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1571); + ZEPHIR_INIT_VAR(&_32$$17); + ZEPHIR_CONCAT_VSV(&_32$$17, &_30$$17, ":", &_31$$17); + ZEPHIR_CALL_FUNCTION(&_33$$17, "base64_encode", NULL, 231, &_32$$17); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_34$$17); + ZEPHIR_CONCAT_SV(&_34$$17, "Basic ", &_33$$17); + zephir_array_update_string(&headers, SL("Authorization"), &_34$$17, PH_COPY | PH_SEPARATE); + } else if (zephir_array_isset_string_fetch(&digest, &headers, SL("Php-Auth-Digest"), 0)) { + zephir_array_update_string(&headers, SL("Authorization"), &digest, PH_COPY | PH_SEPARATE); + } } - RETURN_MM_BOOL(0); -} - -static PHP_METHOD(Phalcon_Http_Request, isOptions) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); - zephir_check_call_status(); - RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "OPTIONS")); + _35 = zephir_is_true(&hasEventsManager); + if (_35) { + _35 = Z_TYPE_P(&eventsManager) == IS_OBJECT; + } + if (_35) { + ZEPHIR_INIT_VAR(&_36$$19); + zephir_create_array(&_36$$19, 2, 0); + zephir_array_update_string(&_36$$19, SL("headers"), &headers, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_36$$19, SL("server"), &server, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_VAR(&_37$$19); + ZVAL_STRING(&_37$$19, "request:afterAuthorizationResolve"); + ZEPHIR_CALL_METHOD(&resolved, &eventsManager, "fire", NULL, 0, &_37$$19, this_ptr, &_36$$19); + zephir_check_call_status(); + if (Z_TYPE_P(&resolved) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&_38$$20); + zephir_fast_array_merge(&_38$$20, &headers, &resolved); + ZEPHIR_CPY_WRT(&headers, &_38$$20); + } + } + RETURN_CTOR(&headers); } -static PHP_METHOD(Phalcon_Http_Request, isPatch) +static PHP_METHOD(Phalcon_Http_Request, smoothFiles) { - zval _0; + zend_string *_3; + zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_11 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval prefix; + zval *names_param = NULL, *types_param = NULL, *tmp_names_param = NULL, *sizes_param = NULL, *errors_param = NULL, *prefix_param = NULL, idx, name, file, files, parentFiles, p, *_0, _1, _5$$4, _6$$5, _7$$5, _8$$5, _9$$5, _10$$5, *_12$$5, _13$$5, _15$$9, _16$$10, _17$$10, _18$$10, _19$$10, _20$$10, *_21$$10, _22$$10; + zval names, types, tmp_names, sizes, errors, _4$$4, _14$$9; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&names); + ZVAL_UNDEF(&types); + ZVAL_UNDEF(&tmp_names); + ZVAL_UNDEF(&sizes); + ZVAL_UNDEF(&errors); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_14$$9); + ZVAL_UNDEF(&idx); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&file); + ZVAL_UNDEF(&files); + ZVAL_UNDEF(&parentFiles); + ZVAL_UNDEF(&p); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_10$$5); + ZVAL_UNDEF(&_13$$5); + ZVAL_UNDEF(&_15$$9); + ZVAL_UNDEF(&_16$$10); + ZVAL_UNDEF(&_17$$10); + ZVAL_UNDEF(&_18$$10); + ZVAL_UNDEF(&_19$$10); + ZVAL_UNDEF(&_20$$10); + ZVAL_UNDEF(&_22$$10); + ZVAL_UNDEF(&prefix); + ZEND_PARSE_PARAMETERS_START(6, 6) + Z_PARAM_ARRAY(names) + Z_PARAM_ARRAY(types) + Z_PARAM_ARRAY(tmp_names) + Z_PARAM_ARRAY(sizes) + Z_PARAM_ARRAY(errors) + Z_PARAM_STR(prefix) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); - zephir_check_call_status(); - RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "PATCH")); + zephir_fetch_params(1, 6, 0, &names_param, &types_param, &tmp_names_param, &sizes_param, &errors_param, &prefix_param); + ZEPHIR_OBS_COPY_OR_DUP(&names, names_param); + ZEPHIR_OBS_COPY_OR_DUP(&types, types_param); + ZEPHIR_OBS_COPY_OR_DUP(&tmp_names, tmp_names_param); + ZEPHIR_OBS_COPY_OR_DUP(&sizes, sizes_param); + ZEPHIR_OBS_COPY_OR_DUP(&errors, errors_param); + zephir_get_strval(&prefix, prefix_param); + ZEPHIR_INIT_VAR(&files); + array_init(&files); + zephir_is_iterable(&names, 0, "phalcon/Http/Request.zep", 1635); + if (Z_TYPE_P(&names) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&names), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&idx); + if (_3 != NULL) { + ZVAL_STR_COPY(&idx, _3); + } else { + ZVAL_LONG(&idx, _2); + } + ZEPHIR_INIT_NVAR(&name); + ZVAL_COPY(&name, _0); + ZEPHIR_INIT_NVAR(&p); + ZEPHIR_CONCAT_VSV(&p, &prefix, ".", &idx); + if (Z_TYPE_P(&name) == IS_STRING) { + ZEPHIR_INIT_NVAR(&_4$$4); + zephir_create_array(&_4$$4, 6, 0); + zephir_array_update_string(&_4$$4, SL("name"), &name, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_5$$4); + zephir_array_fetch(&_5$$4, &types, &idx, PH_NOISY, "phalcon/Http/Request.zep", 1611); + zephir_array_update_string(&_4$$4, SL("type"), &_5$$4, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_5$$4); + zephir_array_fetch(&_5$$4, &tmp_names, &idx, PH_NOISY, "phalcon/Http/Request.zep", 1612); + zephir_array_update_string(&_4$$4, SL("tmp_name"), &_5$$4, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_5$$4); + zephir_array_fetch(&_5$$4, &sizes, &idx, PH_NOISY, "phalcon/Http/Request.zep", 1613); + zephir_array_update_string(&_4$$4, SL("size"), &_5$$4, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_5$$4); + zephir_array_fetch(&_5$$4, &errors, &idx, PH_NOISY, "phalcon/Http/Request.zep", 1614); + zephir_array_update_string(&_4$$4, SL("error"), &_5$$4, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_4$$4, SL("key"), &p, PH_COPY | PH_SEPARATE); + zephir_array_append(&files, &_4$$4, PH_SEPARATE, "phalcon/Http/Request.zep", 1616); + } + if (Z_TYPE_P(&name) == IS_ARRAY) { + zephir_array_fetch(&_6$$5, &names, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1621); + zephir_array_fetch(&_7$$5, &types, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1622); + zephir_array_fetch(&_8$$5, &tmp_names, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1623); + zephir_array_fetch(&_9$$5, &sizes, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1624); + zephir_array_fetch(&_10$$5, &errors, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1625); + ZEPHIR_CALL_METHOD(&parentFiles, this_ptr, "smoothfiles", &_11, 342, &_6$$5, &_7$$5, &_8$$5, &_9$$5, &_10$$5, &p); + zephir_check_call_status(); + zephir_is_iterable(&parentFiles, 0, "phalcon/Http/Request.zep", 1632); + if (Z_TYPE_P(&parentFiles) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&parentFiles), _12$$5) + { + ZEPHIR_INIT_NVAR(&file); + ZVAL_COPY(&file, _12$$5); + zephir_array_append(&files, &file, PH_SEPARATE, "phalcon/Http/Request.zep", 1630); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &parentFiles, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_13$$5, &parentFiles, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_13$$5)) { + break; + } + ZEPHIR_CALL_METHOD(&file, &parentFiles, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_append(&files, &file, PH_SEPARATE, "phalcon/Http/Request.zep", 1630); + ZEPHIR_CALL_METHOD(NULL, &parentFiles, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&file); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &names, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &names, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; + } + ZEPHIR_CALL_METHOD(&idx, &names, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&name, &names, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&p); + ZEPHIR_CONCAT_VSV(&p, &prefix, ".", &idx); + if (Z_TYPE_P(&name) == IS_STRING) { + ZEPHIR_INIT_NVAR(&_14$$9); + zephir_create_array(&_14$$9, 6, 0); + zephir_array_update_string(&_14$$9, SL("name"), &name, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_15$$9); + zephir_array_fetch(&_15$$9, &types, &idx, PH_NOISY, "phalcon/Http/Request.zep", 1611); + zephir_array_update_string(&_14$$9, SL("type"), &_15$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_15$$9); + zephir_array_fetch(&_15$$9, &tmp_names, &idx, PH_NOISY, "phalcon/Http/Request.zep", 1612); + zephir_array_update_string(&_14$$9, SL("tmp_name"), &_15$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_15$$9); + zephir_array_fetch(&_15$$9, &sizes, &idx, PH_NOISY, "phalcon/Http/Request.zep", 1613); + zephir_array_update_string(&_14$$9, SL("size"), &_15$$9, PH_COPY | PH_SEPARATE); + ZEPHIR_OBS_NVAR(&_15$$9); + zephir_array_fetch(&_15$$9, &errors, &idx, PH_NOISY, "phalcon/Http/Request.zep", 1614); + zephir_array_update_string(&_14$$9, SL("error"), &_15$$9, PH_COPY | PH_SEPARATE); + zephir_array_update_string(&_14$$9, SL("key"), &p, PH_COPY | PH_SEPARATE); + zephir_array_append(&files, &_14$$9, PH_SEPARATE, "phalcon/Http/Request.zep", 1616); + } + if (Z_TYPE_P(&name) == IS_ARRAY) { + zephir_array_fetch(&_16$$10, &names, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1621); + zephir_array_fetch(&_17$$10, &types, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1622); + zephir_array_fetch(&_18$$10, &tmp_names, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1623); + zephir_array_fetch(&_19$$10, &sizes, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1624); + zephir_array_fetch(&_20$$10, &errors, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1625); + ZEPHIR_CALL_METHOD(&parentFiles, this_ptr, "smoothfiles", &_11, 342, &_16$$10, &_17$$10, &_18$$10, &_19$$10, &_20$$10, &p); + zephir_check_call_status(); + zephir_is_iterable(&parentFiles, 0, "phalcon/Http/Request.zep", 1632); + if (Z_TYPE_P(&parentFiles) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&parentFiles), _21$$10) + { + ZEPHIR_INIT_NVAR(&file); + ZVAL_COPY(&file, _21$$10); + zephir_array_append(&files, &file, PH_SEPARATE, "phalcon/Http/Request.zep", 1630); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &parentFiles, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_22$$10, &parentFiles, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_22$$10)) { + break; + } + ZEPHIR_CALL_METHOD(&file, &parentFiles, "current", NULL, 0); + zephir_check_call_status(); + zephir_array_append(&files, &file, PH_SEPARATE, "phalcon/Http/Request.zep", 1630); + ZEPHIR_CALL_METHOD(NULL, &parentFiles, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&file); + } + ZEPHIR_CALL_METHOD(NULL, &names, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&name); + ZEPHIR_INIT_NVAR(&idx); + RETURN_CCTOR(&files); } -static PHP_METHOD(Phalcon_Http_Request, isPost) +static PHP_METHOD(Phalcon_Http_Request, getFilterService) { - zval _0; + zval container, filterService, _0, _1$$3, _2$$3, _3$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&filterService); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); - zephir_check_call_status(); - RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "POST")); + zephir_read_property(&_0, this_ptr, ZEND_STRL("filterService"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&filterService, &_0); + if (Z_TYPE_P(&filterService) != IS_OBJECT) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_1$$3); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_request_exception_ce, "A dependency injection container is required to access the 'filter' service", "phalcon/Http/Request.zep", 1653); + return; + } + ZEPHIR_INIT_VAR(&_3$$3); + ZVAL_STRING(&_3$$3, "filter"); + ZEPHIR_CALL_METHOD(&_2$$3, &container, "getshared", NULL, 0, &_3$$3); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&filterService, &_2$$3); + zephir_update_property_zval(this_ptr, ZEND_STRL("filterService"), &filterService); + } + RETURN_MM_MEMBER(getThis(), "filterService"); } -static PHP_METHOD(Phalcon_Http_Request, isPut) +static PHP_METHOD(Phalcon_Http_Request, getServerArray) { - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + zval _SERVER; - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + ZVAL_UNDEF(&_SERVER); + zephir_get_global(&_SERVER, SL("_SERVER")); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); - zephir_check_call_status(); - RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "PUT")); + if (zephir_is_true(&_SERVER)) { + RETVAL_ZVAL(&_SERVER, 1, 0); + return; + } + array_init(return_value); + return; } -static PHP_METHOD(Phalcon_Http_Request, isPurge) +static PHP_METHOD(Phalcon_Http_Request, getFilteredData) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool notAllowEmpty, noRecursive; + zval *methodKey_param = NULL, *method_param = NULL, *name_param = NULL, *defaultValue = NULL, defaultValue_sub, *notAllowEmpty_param = NULL, *noRecursive_param = NULL, __$null, filters, _0, _1, _2, _3; + zval methodKey, method, name; zval *this_ptr = getThis(); + ZVAL_UNDEF(&methodKey); + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&filters); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 6) + Z_PARAM_STR(methodKey) + Z_PARAM_STR(method) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + Z_PARAM_ZVAL_OR_NULL(defaultValue) + Z_PARAM_BOOL(notAllowEmpty) + Z_PARAM_BOOL(noRecursive) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); + zephir_fetch_params(1, 2, 4, &methodKey_param, &method_param, &name_param, &defaultValue, ¬AllowEmpty_param, &noRecursive_param); + zephir_get_strval(&methodKey, methodKey_param); + zephir_get_strval(&method, method_param); + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { + zephir_get_strval(&name, name_param); + } + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } + if (!notAllowEmpty_param) { + notAllowEmpty = 0; + } else { + } + if (!noRecursive_param) { + noRecursive = 0; + } else { + } + zephir_memory_observe(&filters); + zephir_read_property(&_0, this_ptr, ZEND_STRL("queryFilters"), PH_NOISY_CC | PH_READONLY); + zephir_array_fetch(&_1, &_0, &methodKey, PH_READONLY, "phalcon/Http/Request.zep", 1685); + if (!(zephir_array_isset_fetch(&filters, &_1, &name, 0))) { + ZEPHIR_INIT_NVAR(&filters); + array_init(&filters); + } + if (notAllowEmpty) { + ZVAL_BOOL(&_2, 1); + } else { + ZVAL_BOOL(&_2, 0); + } + if (noRecursive) { + ZVAL_BOOL(&_3, 1); + } else { + ZVAL_BOOL(&_3, 0); + } + ZEPHIR_RETURN_CALL_METHOD_ZVAL(this_ptr, &method, NULL, 0, &name, &filters, defaultValue, &_2, &_3); zephir_check_call_status(); - RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "PURGE")); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Http_Request, isSecure) +static PHP_METHOD(Phalcon_Http_Request, getPatchPut) { - zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool notAllowEmpty, noRecursive, _0$$3, _3$$3; + zval *collection_param = NULL, *name_param = NULL, *filters = NULL, filters_sub, *defaultValue = NULL, defaultValue_sub, *notAllowEmpty_param = NULL, *noRecursive_param = NULL, __$null, cached, contentType, _10, _11, _1$$3, _2$$3, _4$$3, _5$$4, _6$$4, _8$$4, _7$$5, _9$$8; + zval collection, name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&filters_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&cached); + ZVAL_UNDEF(&contentType); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_8$$4); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_9$$8); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 6) + Z_PARAM_STR(collection) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(name) + Z_PARAM_ZVAL_OR_NULL(filters) + Z_PARAM_ZVAL_OR_NULL(defaultValue) + Z_PARAM_BOOL(notAllowEmpty) + Z_PARAM_BOOL(noRecursive) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getscheme", NULL, 0); + zephir_fetch_params(1, 1, 5, &collection_param, &name_param, &filters, &defaultValue, ¬AllowEmpty_param, &noRecursive_param); + zephir_get_strval(&collection, collection_param); + if (!name_param) { + ZEPHIR_INIT_VAR(&name); + } else { + zephir_get_strval(&name, name_param); + } + if (!filters) { + filters = &filters_sub; + filters = &__$null; + } + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } + if (!notAllowEmpty_param) { + notAllowEmpty = 0; + } else { + } + if (!noRecursive_param) { + noRecursive = 0; + } else { + } + zephir_memory_observe(&cached); + zephir_read_property_zval(&cached, this_ptr, &collection, PH_NOISY_CC); + if (Z_TYPE_P(&cached) == IS_NULL) { + ZEPHIR_CALL_METHOD(&contentType, this_ptr, "getcontenttype", NULL, 0); + zephir_check_call_status(); + _0$$3 = Z_TYPE_P(&contentType) == IS_STRING; + if (_0$$3) { + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "json"); + ZEPHIR_CALL_FUNCTION(&_2$$3, "stripos", NULL, 348, &contentType, &_1$$3); + zephir_check_call_status(); + _3$$3 = !ZEPHIR_IS_FALSE(&_2$$3); + if (!(_3$$3)) { + ZEPHIR_INIT_NVAR(&_1$$3); + ZVAL_STRING(&_1$$3, "multipart/form-data"); + ZEPHIR_CALL_FUNCTION(&_4$$3, "stripos", NULL, 348, &contentType, &_1$$3); + zephir_check_call_status(); + _3$$3 = !ZEPHIR_IS_FALSE_IDENTICAL(&_4$$3); + } + _0$$3 = _3$$3; + } + if (_0$$3) { + ZEPHIR_INIT_VAR(&_5$$4); + ZVAL_STRING(&_5$$4, "json"); + ZEPHIR_CALL_FUNCTION(&_6$$4, "stripos", NULL, 348, &contentType, &_5$$4); + zephir_check_call_status(); + if (!ZEPHIR_IS_FALSE(&_6$$4)) { + ZVAL_BOOL(&_7$$5, 1); + ZEPHIR_CALL_METHOD(&cached, this_ptr, "getjsonrawbody", NULL, 0, &_7$$5); + zephir_check_call_status(); + } + ZEPHIR_INIT_NVAR(&_5$$4); + ZVAL_STRING(&_5$$4, "multipart/form-data"); + ZEPHIR_CALL_FUNCTION(&_8$$4, "stripos", NULL, 348, &contentType, &_5$$4); + zephir_check_call_status(); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_8$$4)) { + ZEPHIR_CALL_METHOD(&cached, this_ptr, "getformdata", NULL, 349); + zephir_check_call_status(); + } + if (Z_TYPE_P(&cached) != IS_ARRAY) { + ZEPHIR_INIT_NVAR(&cached); + array_init(&cached); + } + } else { + ZEPHIR_INIT_NVAR(&cached); + array_init(&cached); + ZEPHIR_CALL_METHOD(&_9$$8, this_ptr, "getrawbody", NULL, 0); + zephir_check_call_status(); + ZEPHIR_MAKE_REF(&cached); + ZEPHIR_CALL_FUNCTION(NULL, "parse_str", NULL, 350, &_9$$8, &cached); + ZEPHIR_UNREF(&cached); + zephir_check_call_status(); + } + zephir_update_property_zval_zval(this_ptr, &collection, &cached); + } + if (notAllowEmpty) { + ZVAL_BOOL(&_10, 1); + } else { + ZVAL_BOOL(&_10, 0); + } + if (noRecursive) { + ZVAL_BOOL(&_11, 1); + } else { + ZVAL_BOOL(&_11, 0); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "gethelper", NULL, 333, &cached, &name, filters, defaultValue, &_10, &_11); zephir_check_call_status(); - RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "https")); -} - -static PHP_METHOD(Phalcon_Http_Request, isStrictHostCheck) -{ - - RETURN_MEMBER(getThis(), "strictHostCheck"); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Http_Request, isSoap) +static PHP_METHOD(Phalcon_Http_Request, getFormData) { - zval contentType, _0, _1; + zval dataset, headers$$3, headers$$25; + zval boundary, matches, _0, _1, _2, _3, bodyParts, _4, _5, _6, _7, bodyPart, *_8, _9, splited$$3, _10$$3, _11$$3, headerParts$$3, headerPart$$3, _12$$3, _13$$3, *_14$$3, _15$$3, _67$$3, _68$$3, _69$$3, _16$$5, _17$$5, exploded$$5, headerName$$5, headerValue$$5, _18$$5, _19$$5, _20$$5, _21$$5, _22$$5, explodedHeader$$7, part$$7, *_23$$7, _24$$7, _25$$8, _26$$8, _27$$8, explodedPart$$9, namePart$$9, valuePart$$9, _29$$9, _30$$9, _31$$9, _32$$9, _33$$9, _34$$11, _35$$11, _36$$11, explodedPart$$12, namePart$$12, valuePart$$12, _37$$12, _38$$12, _39$$12, _40$$12, _41$$12, _42$$15, _43$$15, exploded$$15, headerName$$15, headerValue$$15, _44$$15, _45$$15, _46$$15, _47$$15, _48$$15, explodedHeader$$17, part$$17, *_49$$17, _50$$17, _51$$18, _52$$18, _53$$18, explodedPart$$19, namePart$$19, valuePart$$19, _54$$19, _55$$19, _56$$19, _57$$19, _58$$19, _59$$21, _60$$21, _61$$21, explodedPart$$22, namePart$$22, valuePart$$22, _62$$22, _63$$22, _64$$22, _65$$22, _66$$22, splited$$25, _70$$25, _71$$25, headerParts$$25, headerPart$$25, _72$$25, _73$$25, *_74$$25, _75$$25, _126$$25, _127$$25, _128$$25, _76$$27, _77$$27, exploded$$27, headerName$$27, headerValue$$27, _78$$27, _79$$27, _80$$27, _81$$27, _82$$27, explodedHeader$$29, part$$29, *_83$$29, _84$$29, _85$$30, _86$$30, _87$$30, explodedPart$$31, namePart$$31, valuePart$$31, _88$$31, _89$$31, _90$$31, _91$$31, _92$$31, _93$$33, _94$$33, _95$$33, explodedPart$$34, namePart$$34, valuePart$$34, _96$$34, _97$$34, _98$$34, _99$$34, _100$$34, _101$$37, _102$$37, exploded$$37, headerName$$37, headerValue$$37, _103$$37, _104$$37, _105$$37, _106$$37, _107$$37, explodedHeader$$39, part$$39, *_108$$39, _109$$39, _110$$40, _111$$40, _112$$40, explodedPart$$41, namePart$$41, valuePart$$41, _113$$41, _114$$41, _115$$41, _116$$41, _117$$41, _118$$43, _119$$43, _120$$43, explodedPart$$44, namePart$$44, valuePart$$44, _121$$44, _122$$44, _123$$44, _124$$44, _125$$44; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_28 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&contentType); + ZVAL_UNDEF(&boundary); + ZVAL_UNDEF(&matches); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&bodyParts); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&bodyPart); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&splited$$3); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_11$$3); + ZVAL_UNDEF(&headerParts$$3); + ZVAL_UNDEF(&headerPart$$3); + ZVAL_UNDEF(&_12$$3); + ZVAL_UNDEF(&_13$$3); + ZVAL_UNDEF(&_15$$3); + ZVAL_UNDEF(&_67$$3); + ZVAL_UNDEF(&_68$$3); + ZVAL_UNDEF(&_69$$3); + ZVAL_UNDEF(&_16$$5); + ZVAL_UNDEF(&_17$$5); + ZVAL_UNDEF(&exploded$$5); + ZVAL_UNDEF(&headerName$$5); + ZVAL_UNDEF(&headerValue$$5); + ZVAL_UNDEF(&_18$$5); + ZVAL_UNDEF(&_19$$5); + ZVAL_UNDEF(&_20$$5); + ZVAL_UNDEF(&_21$$5); + ZVAL_UNDEF(&_22$$5); + ZVAL_UNDEF(&explodedHeader$$7); + ZVAL_UNDEF(&part$$7); + ZVAL_UNDEF(&_24$$7); + ZVAL_UNDEF(&_25$$8); + ZVAL_UNDEF(&_26$$8); + ZVAL_UNDEF(&_27$$8); + ZVAL_UNDEF(&explodedPart$$9); + ZVAL_UNDEF(&namePart$$9); + ZVAL_UNDEF(&valuePart$$9); + ZVAL_UNDEF(&_29$$9); + ZVAL_UNDEF(&_30$$9); + ZVAL_UNDEF(&_31$$9); + ZVAL_UNDEF(&_32$$9); + ZVAL_UNDEF(&_33$$9); + ZVAL_UNDEF(&_34$$11); + ZVAL_UNDEF(&_35$$11); + ZVAL_UNDEF(&_36$$11); + ZVAL_UNDEF(&explodedPart$$12); + ZVAL_UNDEF(&namePart$$12); + ZVAL_UNDEF(&valuePart$$12); + ZVAL_UNDEF(&_37$$12); + ZVAL_UNDEF(&_38$$12); + ZVAL_UNDEF(&_39$$12); + ZVAL_UNDEF(&_40$$12); + ZVAL_UNDEF(&_41$$12); + ZVAL_UNDEF(&_42$$15); + ZVAL_UNDEF(&_43$$15); + ZVAL_UNDEF(&exploded$$15); + ZVAL_UNDEF(&headerName$$15); + ZVAL_UNDEF(&headerValue$$15); + ZVAL_UNDEF(&_44$$15); + ZVAL_UNDEF(&_45$$15); + ZVAL_UNDEF(&_46$$15); + ZVAL_UNDEF(&_47$$15); + ZVAL_UNDEF(&_48$$15); + ZVAL_UNDEF(&explodedHeader$$17); + ZVAL_UNDEF(&part$$17); + ZVAL_UNDEF(&_50$$17); + ZVAL_UNDEF(&_51$$18); + ZVAL_UNDEF(&_52$$18); + ZVAL_UNDEF(&_53$$18); + ZVAL_UNDEF(&explodedPart$$19); + ZVAL_UNDEF(&namePart$$19); + ZVAL_UNDEF(&valuePart$$19); + ZVAL_UNDEF(&_54$$19); + ZVAL_UNDEF(&_55$$19); + ZVAL_UNDEF(&_56$$19); + ZVAL_UNDEF(&_57$$19); + ZVAL_UNDEF(&_58$$19); + ZVAL_UNDEF(&_59$$21); + ZVAL_UNDEF(&_60$$21); + ZVAL_UNDEF(&_61$$21); + ZVAL_UNDEF(&explodedPart$$22); + ZVAL_UNDEF(&namePart$$22); + ZVAL_UNDEF(&valuePart$$22); + ZVAL_UNDEF(&_62$$22); + ZVAL_UNDEF(&_63$$22); + ZVAL_UNDEF(&_64$$22); + ZVAL_UNDEF(&_65$$22); + ZVAL_UNDEF(&_66$$22); + ZVAL_UNDEF(&splited$$25); + ZVAL_UNDEF(&_70$$25); + ZVAL_UNDEF(&_71$$25); + ZVAL_UNDEF(&headerParts$$25); + ZVAL_UNDEF(&headerPart$$25); + ZVAL_UNDEF(&_72$$25); + ZVAL_UNDEF(&_73$$25); + ZVAL_UNDEF(&_75$$25); + ZVAL_UNDEF(&_126$$25); + ZVAL_UNDEF(&_127$$25); + ZVAL_UNDEF(&_128$$25); + ZVAL_UNDEF(&_76$$27); + ZVAL_UNDEF(&_77$$27); + ZVAL_UNDEF(&exploded$$27); + ZVAL_UNDEF(&headerName$$27); + ZVAL_UNDEF(&headerValue$$27); + ZVAL_UNDEF(&_78$$27); + ZVAL_UNDEF(&_79$$27); + ZVAL_UNDEF(&_80$$27); + ZVAL_UNDEF(&_81$$27); + ZVAL_UNDEF(&_82$$27); + ZVAL_UNDEF(&explodedHeader$$29); + ZVAL_UNDEF(&part$$29); + ZVAL_UNDEF(&_84$$29); + ZVAL_UNDEF(&_85$$30); + ZVAL_UNDEF(&_86$$30); + ZVAL_UNDEF(&_87$$30); + ZVAL_UNDEF(&explodedPart$$31); + ZVAL_UNDEF(&namePart$$31); + ZVAL_UNDEF(&valuePart$$31); + ZVAL_UNDEF(&_88$$31); + ZVAL_UNDEF(&_89$$31); + ZVAL_UNDEF(&_90$$31); + ZVAL_UNDEF(&_91$$31); + ZVAL_UNDEF(&_92$$31); + ZVAL_UNDEF(&_93$$33); + ZVAL_UNDEF(&_94$$33); + ZVAL_UNDEF(&_95$$33); + ZVAL_UNDEF(&explodedPart$$34); + ZVAL_UNDEF(&namePart$$34); + ZVAL_UNDEF(&valuePart$$34); + ZVAL_UNDEF(&_96$$34); + ZVAL_UNDEF(&_97$$34); + ZVAL_UNDEF(&_98$$34); + ZVAL_UNDEF(&_99$$34); + ZVAL_UNDEF(&_100$$34); + ZVAL_UNDEF(&_101$$37); + ZVAL_UNDEF(&_102$$37); + ZVAL_UNDEF(&exploded$$37); + ZVAL_UNDEF(&headerName$$37); + ZVAL_UNDEF(&headerValue$$37); + ZVAL_UNDEF(&_103$$37); + ZVAL_UNDEF(&_104$$37); + ZVAL_UNDEF(&_105$$37); + ZVAL_UNDEF(&_106$$37); + ZVAL_UNDEF(&_107$$37); + ZVAL_UNDEF(&explodedHeader$$39); + ZVAL_UNDEF(&part$$39); + ZVAL_UNDEF(&_109$$39); + ZVAL_UNDEF(&_110$$40); + ZVAL_UNDEF(&_111$$40); + ZVAL_UNDEF(&_112$$40); + ZVAL_UNDEF(&explodedPart$$41); + ZVAL_UNDEF(&namePart$$41); + ZVAL_UNDEF(&valuePart$$41); + ZVAL_UNDEF(&_113$$41); + ZVAL_UNDEF(&_114$$41); + ZVAL_UNDEF(&_115$$41); + ZVAL_UNDEF(&_116$$41); + ZVAL_UNDEF(&_117$$41); + ZVAL_UNDEF(&_118$$43); + ZVAL_UNDEF(&_119$$43); + ZVAL_UNDEF(&_120$$43); + ZVAL_UNDEF(&explodedPart$$44); + ZVAL_UNDEF(&namePart$$44); + ZVAL_UNDEF(&valuePart$$44); + ZVAL_UNDEF(&_121$$44); + ZVAL_UNDEF(&_122$$44); + ZVAL_UNDEF(&_123$$44); + ZVAL_UNDEF(&_124$$44); + ZVAL_UNDEF(&_125$$44); + ZVAL_UNDEF(&dataset); + ZVAL_UNDEF(&headers$$3); + ZVAL_UNDEF(&headers$$25); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getcontenttype", NULL, 0); + zephir_check_call_status(); ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "HTTP_SOAPACTION"); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "hasserver", NULL, 335, &_1); + ZVAL_STRING(&_1, "/boundary=(.*)$/is"); + ZEPHIR_INIT_VAR(&_2); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "/boundary=(.*)$/is"); + zephir_preg_match(&_2, &_3, &_0, &matches, 0, 0 , 0 ); + zephir_memory_observe(&boundary); + zephir_array_fetch_long(&boundary, &matches, 1, PH_NOISY, "phalcon/Http/Request.zep", 1771); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "/"); + ZEPHIR_CALL_FUNCTION(&_5, "preg_quote", NULL, 351, &boundary, &_4); zephir_check_call_status(); - if (zephir_is_true(&_0)) { - RETURN_MM_BOOL(1); - } - ZEPHIR_CALL_METHOD(&contentType, this_ptr, "getcontenttype", NULL, 0); + ZEPHIR_INIT_VAR(&_6); + ZEPHIR_CONCAT_SVS(&_6, "/\\R?-+", &_5, "/s"); + ZEPHIR_CALL_METHOD(&_7, this_ptr, "getrawbody", NULL, 0); zephir_check_call_status(); - if (ZEPHIR_IS_EMPTY(&contentType)) { - RETURN_MM_BOOL(0); - } - RETURN_MM_BOOL(zephir_memnstr_str(&contentType, SL("application/soap+xml"), "phalcon/Http/Request.zep", 1219)); -} - -static PHP_METHOD(Phalcon_Http_Request, isTrace) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getmethod", NULL, 344); + ZEPHIR_CALL_FUNCTION(&bodyParts, "preg_split", NULL, 70, &_6, &_7); zephir_check_call_status(); - RETURN_MM_BOOL(ZEPHIR_IS_STRING_IDENTICAL(&_0, "TRACE")); -} - -static PHP_METHOD(Phalcon_Http_Request, isValidHttpMethod) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *method_param = NULL, _0; - zval method; - - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(method) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &method_param); - zephir_get_strval(&method, method_param); - ZEPHIR_INIT_VAR(&_0); - zephir_fast_strtoupper(&_0, &method); - do { - if (ZEPHIR_IS_STRING(&_0, "CONNECT") || ZEPHIR_IS_STRING(&_0, "DELETE") || ZEPHIR_IS_STRING(&_0, "GET") || ZEPHIR_IS_STRING(&_0, "HEAD") || ZEPHIR_IS_STRING(&_0, "OPTIONS") || ZEPHIR_IS_STRING(&_0, "PATCH") || ZEPHIR_IS_STRING(&_0, "POST") || ZEPHIR_IS_STRING(&_0, "PURGE") || ZEPHIR_IS_STRING(&_0, "PUT") || ZEPHIR_IS_STRING(&_0, "TRACE")) { - RETURN_MM_BOOL(1); - } - } while(0); - - RETURN_MM_BOOL(0); -} - -static PHP_METHOD(Phalcon_Http_Request, numFiles) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, numberFiles; - zval *onlySuccessful_param = NULL, _FILES, files, file, error, *_0, _1, _3$$8, _4$$8, _7$$13, _8$$13; - zend_bool onlySuccessful, _2$$6, _6$$11; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_FILES); - ZVAL_UNDEF(&files); - ZVAL_UNDEF(&file); - ZVAL_UNDEF(&error); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3$$8); - ZVAL_UNDEF(&_4$$8); - ZVAL_UNDEF(&_7$$13); - ZVAL_UNDEF(&_8$$13); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(onlySuccessful) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_get_global(&_FILES, SL("_FILES")); - zephir_fetch_params(1, 0, 1, &onlySuccessful_param); - if (!onlySuccessful_param) { - onlySuccessful = 0; - } else { - } - numberFiles = 0; - ZEPHIR_CPY_WRT(&files, &_FILES); - if (Z_TYPE_P(&files) != IS_ARRAY) { - RETURN_MM_LONG(0); - } - zephir_is_iterable(&files, 0, "phalcon/Http/Request.zep", 1284); - if (Z_TYPE_P(&files) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&files), _0) + ZEPHIR_MAKE_REF(&bodyParts); + ZEPHIR_CALL_FUNCTION(NULL, "array_pop", NULL, 352, &bodyParts); + ZEPHIR_UNREF(&bodyParts); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&dataset); + array_init(&dataset); + zephir_is_iterable(&bodyParts, 0, "phalcon/Http/Request.zep", 1832); + if (Z_TYPE_P(&bodyParts) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&bodyParts), _8) { - ZEPHIR_INIT_NVAR(&file); - ZVAL_COPY(&file, _0); - ZEPHIR_OBS_NVAR(&error); - if (zephir_array_isset_string_fetch(&error, &file, SL("error"), 0)) { - if (Z_TYPE_P(&error) != IS_ARRAY) { - _2$$6 = !zephir_is_true(&error); - if (!(_2$$6)) { - _2$$6 = !onlySuccessful; - } - if (_2$$6) { - numberFiles++; + ZEPHIR_INIT_NVAR(&bodyPart); + ZVAL_COPY(&bodyPart, _8); + if (ZEPHIR_IS_EMPTY(&bodyPart)) { + continue; + } + ZEPHIR_INIT_NVAR(&_10$$3); + ZVAL_STRING(&_10$$3, "/\\R\\R/"); + ZVAL_LONG(&_11$$3, 2); + ZEPHIR_CALL_FUNCTION(&splited$$3, "preg_split", NULL, 70, &_10$$3, &bodyPart, &_11$$3); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&headers$$3); + array_init(&headers$$3); + zephir_array_fetch_long(&_12$$3, &splited$$3, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1793); + ZEPHIR_INIT_NVAR(&_10$$3); + ZVAL_STRING(&_10$$3, "/\\R/s"); + ZVAL_LONG(&_11$$3, -1); + ZVAL_LONG(&_13$$3, 1); + ZEPHIR_CALL_FUNCTION(&headerParts$$3, "preg_split", NULL, 70, &_10$$3, &_12$$3, &_11$$3, &_13$$3); + zephir_check_call_status(); + zephir_is_iterable(&headerParts$$3, 0, "phalcon/Http/Request.zep", 1829); + if (Z_TYPE_P(&headerParts$$3) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&headerParts$$3), _14$$3) + { + ZEPHIR_INIT_NVAR(&headerPart$$3); + ZVAL_COPY(&headerPart$$3, _14$$3); + ZEPHIR_INIT_NVAR(&_16$$5); + ZVAL_STRING(&_16$$5, ":"); + ZEPHIR_INIT_NVAR(&_17$$5); + zephir_fast_strpos(&_17$$5, &headerPart$$3, &_16$$5, 0 ); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_17$$5)) { + continue; } - } - if (Z_TYPE_P(&error) == IS_ARRAY) { - if (onlySuccessful) { - ZVAL_BOOL(&_4$$8, 1); + ZEPHIR_INIT_NVAR(&exploded$$5); + zephir_fast_explode_str(&exploded$$5, SL(":"), &headerPart$$3, 2 ); + ZEPHIR_INIT_NVAR(&_18$$5); + zephir_array_fetch_long(&_19$$5, &exploded$$5, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1803); + zephir_fast_trim(&_18$$5, &_19$$5, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&headerName$$5); + zephir_fast_strtolower(&headerName$$5, &_18$$5); + zephir_array_fetch_long(&_20$$5, &exploded$$5, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1804); + ZEPHIR_INIT_NVAR(&headerValue$$5); + zephir_fast_trim(&headerValue$$5, &_20$$5, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_21$$5); + ZVAL_STRING(&_21$$5, ";"); + ZEPHIR_INIT_NVAR(&_22$$5); + zephir_fast_strpos(&_22$$5, &headerValue$$5, &_21$$5, 0 ); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_22$$5)) { + ZEPHIR_INIT_NVAR(&explodedHeader$$7); + zephir_fast_explode_str(&explodedHeader$$7, SL(";"), &headerValue$$5, LONG_MAX); + zephir_is_iterable(&explodedHeader$$7, 0, "phalcon/Http/Request.zep", 1824); + if (Z_TYPE_P(&explodedHeader$$7) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&explodedHeader$$7), _23$$7) + { + ZEPHIR_INIT_NVAR(&part$$7); + ZVAL_COPY(&part$$7, _23$$7); + ZEPHIR_INIT_NVAR(&_25$$8); + zephir_fast_trim(&_25$$8, &part$$7, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_26$$8); + ZVAL_STRING(&_26$$8, "/\"/"); + ZEPHIR_INIT_NVAR(&_27$$8); + ZVAL_STRING(&_27$$8, ""); + ZEPHIR_CALL_FUNCTION(&part$$7, "preg_replace", &_28, 41, &_26$$8, &_27$$8, &_25$$8); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_26$$8); + ZVAL_STRING(&_26$$8, "="); + ZEPHIR_INIT_NVAR(&_27$$8); + zephir_fast_strpos(&_27$$8, &part$$7, &_26$$8, 0 ); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_27$$8)) { + ZEPHIR_INIT_NVAR(&explodedPart$$9); + zephir_fast_explode_str(&explodedPart$$9, SL("="), &part$$7, 2 ); + ZEPHIR_INIT_NVAR(&_29$$9); + zephir_array_fetch_long(&_30$$9, &explodedPart$$9, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1816); + zephir_fast_trim(&_29$$9, &_30$$9, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&namePart$$9); + zephir_fast_strtolower(&namePart$$9, &_29$$9); + ZEPHIR_INIT_NVAR(&_31$$9); + zephir_array_fetch_long(&_32$$9, &explodedPart$$9, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1817); + zephir_fast_trim(&_31$$9, &_32$$9, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_33$$9); + ZVAL_STRING(&_33$$9, "\""); + ZEPHIR_INIT_NVAR(&valuePart$$9); + zephir_fast_trim(&valuePart$$9, &_31$$9, &_33$$9, ZEPHIR_TRIM_BOTH); + zephir_array_update_multi(&headers$$3, &valuePart$$9, SL("zz"), 2, &headerName$$5, &namePart$$9); + } else { + zephir_array_update_multi(&headers$$3, &part$$7, SL("za"), 2, &headerName$$5); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &explodedHeader$$7, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_24$$7, &explodedHeader$$7, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_24$$7)) { + break; + } + ZEPHIR_CALL_METHOD(&part$$7, &explodedHeader$$7, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_34$$11); + zephir_fast_trim(&_34$$11, &part$$7, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_35$$11); + ZVAL_STRING(&_35$$11, "/\"/"); + ZEPHIR_INIT_NVAR(&_36$$11); + ZVAL_STRING(&_36$$11, ""); + ZEPHIR_CALL_FUNCTION(&part$$7, "preg_replace", &_28, 41, &_35$$11, &_36$$11, &_34$$11); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_35$$11); + ZVAL_STRING(&_35$$11, "="); + ZEPHIR_INIT_NVAR(&_36$$11); + zephir_fast_strpos(&_36$$11, &part$$7, &_35$$11, 0 ); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_36$$11)) { + ZEPHIR_INIT_NVAR(&explodedPart$$12); + zephir_fast_explode_str(&explodedPart$$12, SL("="), &part$$7, 2 ); + ZEPHIR_INIT_NVAR(&_37$$12); + zephir_array_fetch_long(&_38$$12, &explodedPart$$12, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1816); + zephir_fast_trim(&_37$$12, &_38$$12, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&namePart$$12); + zephir_fast_strtolower(&namePart$$12, &_37$$12); + ZEPHIR_INIT_NVAR(&_39$$12); + zephir_array_fetch_long(&_40$$12, &explodedPart$$12, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1817); + zephir_fast_trim(&_39$$12, &_40$$12, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_41$$12); + ZVAL_STRING(&_41$$12, "\""); + ZEPHIR_INIT_NVAR(&valuePart$$12); + zephir_fast_trim(&valuePart$$12, &_39$$12, &_41$$12, ZEPHIR_TRIM_BOTH); + zephir_array_update_multi(&headers$$3, &valuePart$$12, SL("zz"), 2, &headerName$$5, &namePart$$12); + } else { + zephir_array_update_multi(&headers$$3, &part$$7, SL("za"), 2, &headerName$$5); + } + ZEPHIR_CALL_METHOD(NULL, &explodedHeader$$7, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&part$$7); } else { - ZVAL_BOOL(&_4$$8, 0); + zephir_array_update_zval(&headers$$3, &headerName$$5, &headerValue$$5, PH_COPY | PH_SEPARATE); } - ZEPHIR_CALL_METHOD(&_3$$8, this_ptr, "hasfilehelper", &_5, 346, &error, &_4$$8); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &headerParts$$3, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_15$$3, &headerParts$$3, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_15$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&headerPart$$3, &headerParts$$3, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_42$$15); + ZVAL_STRING(&_42$$15, ":"); + ZEPHIR_INIT_NVAR(&_43$$15); + zephir_fast_strpos(&_43$$15, &headerPart$$3, &_42$$15, 0 ); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_43$$15)) { + continue; + } + ZEPHIR_INIT_NVAR(&exploded$$15); + zephir_fast_explode_str(&exploded$$15, SL(":"), &headerPart$$3, 2 ); + ZEPHIR_INIT_NVAR(&_44$$15); + zephir_array_fetch_long(&_45$$15, &exploded$$15, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1803); + zephir_fast_trim(&_44$$15, &_45$$15, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&headerName$$15); + zephir_fast_strtolower(&headerName$$15, &_44$$15); + zephir_array_fetch_long(&_46$$15, &exploded$$15, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1804); + ZEPHIR_INIT_NVAR(&headerValue$$15); + zephir_fast_trim(&headerValue$$15, &_46$$15, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_47$$15); + ZVAL_STRING(&_47$$15, ";"); + ZEPHIR_INIT_NVAR(&_48$$15); + zephir_fast_strpos(&_48$$15, &headerValue$$15, &_47$$15, 0 ); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_48$$15)) { + ZEPHIR_INIT_NVAR(&explodedHeader$$17); + zephir_fast_explode_str(&explodedHeader$$17, SL(";"), &headerValue$$15, LONG_MAX); + zephir_is_iterable(&explodedHeader$$17, 0, "phalcon/Http/Request.zep", 1824); + if (Z_TYPE_P(&explodedHeader$$17) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&explodedHeader$$17), _49$$17) + { + ZEPHIR_INIT_NVAR(&part$$17); + ZVAL_COPY(&part$$17, _49$$17); + ZEPHIR_INIT_NVAR(&_51$$18); + zephir_fast_trim(&_51$$18, &part$$17, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_52$$18); + ZVAL_STRING(&_52$$18, "/\"/"); + ZEPHIR_INIT_NVAR(&_53$$18); + ZVAL_STRING(&_53$$18, ""); + ZEPHIR_CALL_FUNCTION(&part$$17, "preg_replace", &_28, 41, &_52$$18, &_53$$18, &_51$$18); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_52$$18); + ZVAL_STRING(&_52$$18, "="); + ZEPHIR_INIT_NVAR(&_53$$18); + zephir_fast_strpos(&_53$$18, &part$$17, &_52$$18, 0 ); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_53$$18)) { + ZEPHIR_INIT_NVAR(&explodedPart$$19); + zephir_fast_explode_str(&explodedPart$$19, SL("="), &part$$17, 2 ); + ZEPHIR_INIT_NVAR(&_54$$19); + zephir_array_fetch_long(&_55$$19, &explodedPart$$19, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1816); + zephir_fast_trim(&_54$$19, &_55$$19, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&namePart$$19); + zephir_fast_strtolower(&namePart$$19, &_54$$19); + ZEPHIR_INIT_NVAR(&_56$$19); + zephir_array_fetch_long(&_57$$19, &explodedPart$$19, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1817); + zephir_fast_trim(&_56$$19, &_57$$19, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_58$$19); + ZVAL_STRING(&_58$$19, "\""); + ZEPHIR_INIT_NVAR(&valuePart$$19); + zephir_fast_trim(&valuePart$$19, &_56$$19, &_58$$19, ZEPHIR_TRIM_BOTH); + zephir_array_update_multi(&headers$$3, &valuePart$$19, SL("zz"), 2, &headerName$$15, &namePart$$19); + } else { + zephir_array_update_multi(&headers$$3, &part$$17, SL("za"), 2, &headerName$$15); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &explodedHeader$$17, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_50$$17, &explodedHeader$$17, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_50$$17)) { + break; + } + ZEPHIR_CALL_METHOD(&part$$17, &explodedHeader$$17, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_59$$21); + zephir_fast_trim(&_59$$21, &part$$17, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_60$$21); + ZVAL_STRING(&_60$$21, "/\"/"); + ZEPHIR_INIT_NVAR(&_61$$21); + ZVAL_STRING(&_61$$21, ""); + ZEPHIR_CALL_FUNCTION(&part$$17, "preg_replace", &_28, 41, &_60$$21, &_61$$21, &_59$$21); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_60$$21); + ZVAL_STRING(&_60$$21, "="); + ZEPHIR_INIT_NVAR(&_61$$21); + zephir_fast_strpos(&_61$$21, &part$$17, &_60$$21, 0 ); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_61$$21)) { + ZEPHIR_INIT_NVAR(&explodedPart$$22); + zephir_fast_explode_str(&explodedPart$$22, SL("="), &part$$17, 2 ); + ZEPHIR_INIT_NVAR(&_62$$22); + zephir_array_fetch_long(&_63$$22, &explodedPart$$22, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1816); + zephir_fast_trim(&_62$$22, &_63$$22, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&namePart$$22); + zephir_fast_strtolower(&namePart$$22, &_62$$22); + ZEPHIR_INIT_NVAR(&_64$$22); + zephir_array_fetch_long(&_65$$22, &explodedPart$$22, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1817); + zephir_fast_trim(&_64$$22, &_65$$22, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_66$$22); + ZVAL_STRING(&_66$$22, "\""); + ZEPHIR_INIT_NVAR(&valuePart$$22); + zephir_fast_trim(&valuePart$$22, &_64$$22, &_66$$22, ZEPHIR_TRIM_BOTH); + zephir_array_update_multi(&headers$$3, &valuePart$$22, SL("zz"), 2, &headerName$$15, &namePart$$22); + } else { + zephir_array_update_multi(&headers$$3, &part$$17, SL("za"), 2, &headerName$$15); + } + ZEPHIR_CALL_METHOD(NULL, &explodedHeader$$17, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&part$$17); + } else { + zephir_array_update_zval(&headers$$3, &headerName$$15, &headerValue$$15, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, &headerParts$$3, "next", NULL, 0); zephir_check_call_status(); - numberFiles += zephir_get_numberval(&_3$$8); } } + ZEPHIR_INIT_NVAR(&headerPart$$3); + zephir_array_fetch_long(&_67$$3, &splited$$3, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1829); + zephir_array_fetch_string(&_68$$3, &headers$$3, SL("content-disposition"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1829); + ZEPHIR_OBS_NVAR(&_69$$3); + zephir_array_fetch_string(&_69$$3, &_68$$3, SL("name"), PH_NOISY, "phalcon/Http/Request.zep", 1829); + zephir_array_update_zval(&dataset, &_69$$3, &_67$$3, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &files, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &bodyParts, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_1, &files, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_9, &bodyParts, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_1)) { + if (!zend_is_true(&_9)) { break; } - ZEPHIR_CALL_METHOD(&file, &files, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&bodyPart, &bodyParts, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&error); - if (zephir_array_isset_string_fetch(&error, &file, SL("error"), 0)) { - if (Z_TYPE_P(&error) != IS_ARRAY) { - _6$$11 = !zephir_is_true(&error); - if (!(_6$$11)) { - _6$$11 = !onlySuccessful; - } - if (_6$$11) { - numberFiles++; + if (ZEPHIR_IS_EMPTY(&bodyPart)) { + continue; + } + ZEPHIR_INIT_NVAR(&_70$$25); + ZVAL_STRING(&_70$$25, "/\\R\\R/"); + ZVAL_LONG(&_71$$25, 2); + ZEPHIR_CALL_FUNCTION(&splited$$25, "preg_split", NULL, 70, &_70$$25, &bodyPart, &_71$$25); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&headers$$25); + array_init(&headers$$25); + zephir_array_fetch_long(&_72$$25, &splited$$25, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1793); + ZEPHIR_INIT_NVAR(&_70$$25); + ZVAL_STRING(&_70$$25, "/\\R/s"); + ZVAL_LONG(&_71$$25, -1); + ZVAL_LONG(&_73$$25, 1); + ZEPHIR_CALL_FUNCTION(&headerParts$$25, "preg_split", NULL, 70, &_70$$25, &_72$$25, &_71$$25, &_73$$25); + zephir_check_call_status(); + zephir_is_iterable(&headerParts$$25, 0, "phalcon/Http/Request.zep", 1829); + if (Z_TYPE_P(&headerParts$$25) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&headerParts$$25), _74$$25) + { + ZEPHIR_INIT_NVAR(&headerPart$$25); + ZVAL_COPY(&headerPart$$25, _74$$25); + ZEPHIR_INIT_NVAR(&_76$$27); + ZVAL_STRING(&_76$$27, ":"); + ZEPHIR_INIT_NVAR(&_77$$27); + zephir_fast_strpos(&_77$$27, &headerPart$$25, &_76$$27, 0 ); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_77$$27)) { + continue; } - } - if (Z_TYPE_P(&error) == IS_ARRAY) { - if (onlySuccessful) { - ZVAL_BOOL(&_8$$13, 1); + ZEPHIR_INIT_NVAR(&exploded$$27); + zephir_fast_explode_str(&exploded$$27, SL(":"), &headerPart$$25, 2 ); + ZEPHIR_INIT_NVAR(&_78$$27); + zephir_array_fetch_long(&_79$$27, &exploded$$27, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1803); + zephir_fast_trim(&_78$$27, &_79$$27, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&headerName$$27); + zephir_fast_strtolower(&headerName$$27, &_78$$27); + zephir_array_fetch_long(&_80$$27, &exploded$$27, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1804); + ZEPHIR_INIT_NVAR(&headerValue$$27); + zephir_fast_trim(&headerValue$$27, &_80$$27, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_81$$27); + ZVAL_STRING(&_81$$27, ";"); + ZEPHIR_INIT_NVAR(&_82$$27); + zephir_fast_strpos(&_82$$27, &headerValue$$27, &_81$$27, 0 ); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_82$$27)) { + ZEPHIR_INIT_NVAR(&explodedHeader$$29); + zephir_fast_explode_str(&explodedHeader$$29, SL(";"), &headerValue$$27, LONG_MAX); + zephir_is_iterable(&explodedHeader$$29, 0, "phalcon/Http/Request.zep", 1824); + if (Z_TYPE_P(&explodedHeader$$29) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&explodedHeader$$29), _83$$29) + { + ZEPHIR_INIT_NVAR(&part$$29); + ZVAL_COPY(&part$$29, _83$$29); + ZEPHIR_INIT_NVAR(&_85$$30); + zephir_fast_trim(&_85$$30, &part$$29, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_86$$30); + ZVAL_STRING(&_86$$30, "/\"/"); + ZEPHIR_INIT_NVAR(&_87$$30); + ZVAL_STRING(&_87$$30, ""); + ZEPHIR_CALL_FUNCTION(&part$$29, "preg_replace", &_28, 41, &_86$$30, &_87$$30, &_85$$30); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_86$$30); + ZVAL_STRING(&_86$$30, "="); + ZEPHIR_INIT_NVAR(&_87$$30); + zephir_fast_strpos(&_87$$30, &part$$29, &_86$$30, 0 ); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_87$$30)) { + ZEPHIR_INIT_NVAR(&explodedPart$$31); + zephir_fast_explode_str(&explodedPart$$31, SL("="), &part$$29, 2 ); + ZEPHIR_INIT_NVAR(&_88$$31); + zephir_array_fetch_long(&_89$$31, &explodedPart$$31, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1816); + zephir_fast_trim(&_88$$31, &_89$$31, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&namePart$$31); + zephir_fast_strtolower(&namePart$$31, &_88$$31); + ZEPHIR_INIT_NVAR(&_90$$31); + zephir_array_fetch_long(&_91$$31, &explodedPart$$31, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1817); + zephir_fast_trim(&_90$$31, &_91$$31, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_92$$31); + ZVAL_STRING(&_92$$31, "\""); + ZEPHIR_INIT_NVAR(&valuePart$$31); + zephir_fast_trim(&valuePart$$31, &_90$$31, &_92$$31, ZEPHIR_TRIM_BOTH); + zephir_array_update_multi(&headers$$25, &valuePart$$31, SL("zz"), 2, &headerName$$27, &namePart$$31); + } else { + zephir_array_update_multi(&headers$$25, &part$$29, SL("za"), 2, &headerName$$27); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &explodedHeader$$29, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_84$$29, &explodedHeader$$29, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_84$$29)) { + break; + } + ZEPHIR_CALL_METHOD(&part$$29, &explodedHeader$$29, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_93$$33); + zephir_fast_trim(&_93$$33, &part$$29, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_94$$33); + ZVAL_STRING(&_94$$33, "/\"/"); + ZEPHIR_INIT_NVAR(&_95$$33); + ZVAL_STRING(&_95$$33, ""); + ZEPHIR_CALL_FUNCTION(&part$$29, "preg_replace", &_28, 41, &_94$$33, &_95$$33, &_93$$33); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_94$$33); + ZVAL_STRING(&_94$$33, "="); + ZEPHIR_INIT_NVAR(&_95$$33); + zephir_fast_strpos(&_95$$33, &part$$29, &_94$$33, 0 ); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_95$$33)) { + ZEPHIR_INIT_NVAR(&explodedPart$$34); + zephir_fast_explode_str(&explodedPart$$34, SL("="), &part$$29, 2 ); + ZEPHIR_INIT_NVAR(&_96$$34); + zephir_array_fetch_long(&_97$$34, &explodedPart$$34, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1816); + zephir_fast_trim(&_96$$34, &_97$$34, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&namePart$$34); + zephir_fast_strtolower(&namePart$$34, &_96$$34); + ZEPHIR_INIT_NVAR(&_98$$34); + zephir_array_fetch_long(&_99$$34, &explodedPart$$34, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1817); + zephir_fast_trim(&_98$$34, &_99$$34, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_100$$34); + ZVAL_STRING(&_100$$34, "\""); + ZEPHIR_INIT_NVAR(&valuePart$$34); + zephir_fast_trim(&valuePart$$34, &_98$$34, &_100$$34, ZEPHIR_TRIM_BOTH); + zephir_array_update_multi(&headers$$25, &valuePart$$34, SL("zz"), 2, &headerName$$27, &namePart$$34); + } else { + zephir_array_update_multi(&headers$$25, &part$$29, SL("za"), 2, &headerName$$27); + } + ZEPHIR_CALL_METHOD(NULL, &explodedHeader$$29, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&part$$29); } else { - ZVAL_BOOL(&_8$$13, 0); + zephir_array_update_zval(&headers$$25, &headerName$$27, &headerValue$$27, PH_COPY | PH_SEPARATE); } - ZEPHIR_CALL_METHOD(&_7$$13, this_ptr, "hasfilehelper", &_5, 346, &error, &_8$$13); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &headerParts$$25, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_75$$25, &headerParts$$25, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_75$$25)) { + break; + } + ZEPHIR_CALL_METHOD(&headerPart$$25, &headerParts$$25, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_101$$37); + ZVAL_STRING(&_101$$37, ":"); + ZEPHIR_INIT_NVAR(&_102$$37); + zephir_fast_strpos(&_102$$37, &headerPart$$25, &_101$$37, 0 ); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_102$$37)) { + continue; + } + ZEPHIR_INIT_NVAR(&exploded$$37); + zephir_fast_explode_str(&exploded$$37, SL(":"), &headerPart$$25, 2 ); + ZEPHIR_INIT_NVAR(&_103$$37); + zephir_array_fetch_long(&_104$$37, &exploded$$37, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1803); + zephir_fast_trim(&_103$$37, &_104$$37, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&headerName$$37); + zephir_fast_strtolower(&headerName$$37, &_103$$37); + zephir_array_fetch_long(&_105$$37, &exploded$$37, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1804); + ZEPHIR_INIT_NVAR(&headerValue$$37); + zephir_fast_trim(&headerValue$$37, &_105$$37, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_106$$37); + ZVAL_STRING(&_106$$37, ";"); + ZEPHIR_INIT_NVAR(&_107$$37); + zephir_fast_strpos(&_107$$37, &headerValue$$37, &_106$$37, 0 ); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_107$$37)) { + ZEPHIR_INIT_NVAR(&explodedHeader$$39); + zephir_fast_explode_str(&explodedHeader$$39, SL(";"), &headerValue$$37, LONG_MAX); + zephir_is_iterable(&explodedHeader$$39, 0, "phalcon/Http/Request.zep", 1824); + if (Z_TYPE_P(&explodedHeader$$39) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&explodedHeader$$39), _108$$39) + { + ZEPHIR_INIT_NVAR(&part$$39); + ZVAL_COPY(&part$$39, _108$$39); + ZEPHIR_INIT_NVAR(&_110$$40); + zephir_fast_trim(&_110$$40, &part$$39, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_111$$40); + ZVAL_STRING(&_111$$40, "/\"/"); + ZEPHIR_INIT_NVAR(&_112$$40); + ZVAL_STRING(&_112$$40, ""); + ZEPHIR_CALL_FUNCTION(&part$$39, "preg_replace", &_28, 41, &_111$$40, &_112$$40, &_110$$40); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_111$$40); + ZVAL_STRING(&_111$$40, "="); + ZEPHIR_INIT_NVAR(&_112$$40); + zephir_fast_strpos(&_112$$40, &part$$39, &_111$$40, 0 ); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_112$$40)) { + ZEPHIR_INIT_NVAR(&explodedPart$$41); + zephir_fast_explode_str(&explodedPart$$41, SL("="), &part$$39, 2 ); + ZEPHIR_INIT_NVAR(&_113$$41); + zephir_array_fetch_long(&_114$$41, &explodedPart$$41, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1816); + zephir_fast_trim(&_113$$41, &_114$$41, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&namePart$$41); + zephir_fast_strtolower(&namePart$$41, &_113$$41); + ZEPHIR_INIT_NVAR(&_115$$41); + zephir_array_fetch_long(&_116$$41, &explodedPart$$41, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1817); + zephir_fast_trim(&_115$$41, &_116$$41, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_117$$41); + ZVAL_STRING(&_117$$41, "\""); + ZEPHIR_INIT_NVAR(&valuePart$$41); + zephir_fast_trim(&valuePart$$41, &_115$$41, &_117$$41, ZEPHIR_TRIM_BOTH); + zephir_array_update_multi(&headers$$25, &valuePart$$41, SL("zz"), 2, &headerName$$37, &namePart$$41); + } else { + zephir_array_update_multi(&headers$$25, &part$$39, SL("za"), 2, &headerName$$37); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &explodedHeader$$39, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_109$$39, &explodedHeader$$39, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_109$$39)) { + break; + } + ZEPHIR_CALL_METHOD(&part$$39, &explodedHeader$$39, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_118$$43); + zephir_fast_trim(&_118$$43, &part$$39, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_119$$43); + ZVAL_STRING(&_119$$43, "/\"/"); + ZEPHIR_INIT_NVAR(&_120$$43); + ZVAL_STRING(&_120$$43, ""); + ZEPHIR_CALL_FUNCTION(&part$$39, "preg_replace", &_28, 41, &_119$$43, &_120$$43, &_118$$43); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_119$$43); + ZVAL_STRING(&_119$$43, "="); + ZEPHIR_INIT_NVAR(&_120$$43); + zephir_fast_strpos(&_120$$43, &part$$39, &_119$$43, 0 ); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_120$$43)) { + ZEPHIR_INIT_NVAR(&explodedPart$$44); + zephir_fast_explode_str(&explodedPart$$44, SL("="), &part$$39, 2 ); + ZEPHIR_INIT_NVAR(&_121$$44); + zephir_array_fetch_long(&_122$$44, &explodedPart$$44, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1816); + zephir_fast_trim(&_121$$44, &_122$$44, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&namePart$$44); + zephir_fast_strtolower(&namePart$$44, &_121$$44); + ZEPHIR_INIT_NVAR(&_123$$44); + zephir_array_fetch_long(&_124$$44, &explodedPart$$44, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1817); + zephir_fast_trim(&_123$$44, &_124$$44, NULL , ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_NVAR(&_125$$44); + ZVAL_STRING(&_125$$44, "\""); + ZEPHIR_INIT_NVAR(&valuePart$$44); + zephir_fast_trim(&valuePart$$44, &_123$$44, &_125$$44, ZEPHIR_TRIM_BOTH); + zephir_array_update_multi(&headers$$25, &valuePart$$44, SL("zz"), 2, &headerName$$37, &namePart$$44); + } else { + zephir_array_update_multi(&headers$$25, &part$$39, SL("za"), 2, &headerName$$37); + } + ZEPHIR_CALL_METHOD(NULL, &explodedHeader$$39, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&part$$39); + } else { + zephir_array_update_zval(&headers$$25, &headerName$$37, &headerValue$$37, PH_COPY | PH_SEPARATE); + } + ZEPHIR_CALL_METHOD(NULL, &headerParts$$25, "next", NULL, 0); zephir_check_call_status(); - numberFiles += zephir_get_numberval(&_7$$13); } } - ZEPHIR_CALL_METHOD(NULL, &files, "next", NULL, 0); + ZEPHIR_INIT_NVAR(&headerPart$$25); + zephir_array_fetch_long(&_126$$25, &splited$$25, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1829); + zephir_array_fetch_string(&_127$$25, &headers$$25, SL("content-disposition"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1829); + ZEPHIR_OBS_NVAR(&_128$$25); + zephir_array_fetch_string(&_128$$25, &_127$$25, SL("name"), PH_NOISY, "phalcon/Http/Request.zep", 1829); + zephir_array_update_zval(&dataset, &_128$$25, &_126$$25, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, &bodyParts, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&file); - RETURN_MM_LONG(numberFiles); + ZEPHIR_INIT_NVAR(&bodyPart); + RETURN_CTOR(&dataset); } -static PHP_METHOD(Phalcon_Http_Request, setHttpMethodParameterOverride) +zend_object *zephir_init_properties_Phalcon_Http_Request(zend_class_entry *class_type) { - zval *override_param = NULL, __$true, __$false; - zend_bool override; - zval *this_ptr = getThis(); + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(override) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &override_param); - if (override) { - zephir_update_property_zval(this_ptr, ZEND_STRL("httpMethodParameterOverride"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("httpMethodParameterOverride"), &__$false); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("queryFilters"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("queryFilters"), &_1$$3); + } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } - RETURN_THISW(); } -static PHP_METHOD(Phalcon_Http_Request, setParameterFilters) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Http_RequestInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http, RequestInterface, phalcon, http_requestinterface, phalcon_http_requestinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, get); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getAcceptableContent); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getBasicAuth); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getBestAccept); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getBestCharset); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getBestLanguage); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getClientAddress); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getClientCharsets); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getContentType); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getDigestAuth); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getHeader); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getHeaders); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getHttpHost); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getHTTPReferer); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getJsonRawBody); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getLanguages); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getMethod); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getPort); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getURI); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getPost); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getPut); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getQuery); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getRawBody); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getScheme); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getServer); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getServerAddress); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getServerName); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getUploadedFiles); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getUserAgent); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, has); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, hasFiles); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, hasHeader); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, hasQuery); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, hasPost); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, hasPut); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, hasServer); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isAjax); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isConnect); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isDelete); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isGet); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isHead); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isMethod); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isOptions); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isPost); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isPurge); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isPut); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isSecure); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isSoap); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isTrace); +ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, numFiles); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Http_Response) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Http, Response, phalcon, http_response, phalcon_http_response_method_entry, 0); + + zend_declare_property_null(phalcon_http_response_ce, SL("container"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_http_response_ce, SL("content"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_http_response_ce, SL("cookies"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_http_response_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_http_response_ce, SL("file"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_http_response_ce, SL("headers"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_http_response_ce, SL("sent"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_http_response_ce, SL("statusCodes"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_http_response_ce, SL("encode"), ZEND_ACC_PRIVATE); + phalcon_http_response_ce->create_object = zephir_init_properties_Phalcon_Http_Response; + + zend_class_implements(phalcon_http_response_ce, 1, phalcon_http_responseinterface_ce); + zend_class_implements(phalcon_http_response_ce, 1, phalcon_di_injectionawareinterface_ce); + zend_class_implements(phalcon_http_response_ce, 1, phalcon_events_eventsawareinterface_ce); + zend_class_implements(phalcon_http_response_ce, 1, phalcon_http_message_responsestatuscodeinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Http_Response, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL, *_9 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval filters, scope; - zval *name_param = NULL, *filters_param = NULL, *scope_param = NULL, filterService, sanitizer, localScope, scopeMethod, *_2, _3, *_13, _14, _0$$3, _4$$4, _6$$5, _7$$5, _8$$6, _10$$7, _11$$7, _12$$8, _15$$10, _16$$11; - zval name, _1$$3; + zval *content_param = NULL, *code = NULL, code_sub, *status = NULL, status_sub, __$null, _0, _1; + zval content; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&filterService); - ZVAL_UNDEF(&sanitizer); - ZVAL_UNDEF(&localScope); - ZVAL_UNDEF(&scopeMethod); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_14); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_7$$5); - ZVAL_UNDEF(&_8$$6); - ZVAL_UNDEF(&_10$$7); - ZVAL_UNDEF(&_11$$7); - ZVAL_UNDEF(&_12$$8); - ZVAL_UNDEF(&_15$$10); - ZVAL_UNDEF(&_16$$11); - ZVAL_UNDEF(&filters); - ZVAL_UNDEF(&scope); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(name) + ZVAL_UNDEF(&content); + ZVAL_UNDEF(&code_sub); + ZVAL_UNDEF(&status_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 3) Z_PARAM_OPTIONAL - Z_PARAM_ARRAY(filters) - Z_PARAM_ARRAY(scope) + Z_PARAM_STR_OR_NULL(content) + Z_PARAM_ZVAL_OR_NULL(code) + Z_PARAM_ZVAL_OR_NULL(status) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &name_param, &filters_param, &scope_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + zephir_fetch_params(1, 0, 3, &content_param, &code, &status); + if (!content_param) { + ZEPHIR_INIT_VAR(&content); + } else { + if (UNEXPECTED(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 of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + if (EXPECTED(Z_TYPE_P(content_param) == IS_STRING)) { + zephir_get_strval(&content, content_param); } else { - ZEPHIR_INIT_VAR(&name); + ZEPHIR_INIT_VAR(&content); } - if (!filters_param) { - ZEPHIR_INIT_VAR(&filters); - array_init(&filters); - } else { - zephir_get_arrval(&filters, filters_param); } - if (!scope_param) { - ZEPHIR_INIT_VAR(&scope); - array_init(&scope); - } else { - zephir_get_arrval(&scope, scope_param); + if (!code) { + code = &code_sub; + code = &__$null; } - if (UNEXPECTED(zephir_fast_count_int(&filters) < 1)) { - ZEPHIR_INIT_VAR(&_0$$3); - object_init_ex(&_0$$3, phalcon_http_request_exception_ce); - ZEPHIR_INIT_VAR(&_1$$3); - ZEPHIR_CONCAT_SVS(&_1$$3, "Filters have not been defined for '", &name, "'"); - ZEPHIR_CALL_METHOD(NULL, &_0$$3, "__construct", NULL, 33, &_1$$3); + if (!status) { + status = &status_sub; + status = &__$null; + } + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, phalcon_http_response_headers_ce); + if (zephir_has_constructor(&_0)) { + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); zephir_check_call_status(); - zephir_throw_exception_debug(&_0$$3, "phalcon/Http/Request.zep", 1315); - ZEPHIR_MM_RESTORE(); - return; } - ZEPHIR_CALL_METHOD(&filterService, this_ptr, "getfilterservice", NULL, 347); - zephir_check_call_status(); - zephir_is_iterable(&filters, 0, "phalcon/Http/Request.zep", 1328); - if (Z_TYPE_P(&filters) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&filters), _2) - { - ZEPHIR_INIT_NVAR(&sanitizer); - ZVAL_COPY(&sanitizer, _2); - ZEPHIR_CALL_METHOD(&_4$$4, &filterService, "has", &_5, 0, &sanitizer); - zephir_check_call_status(); - if (UNEXPECTED(!ZEPHIR_IS_TRUE_IDENTICAL(&_4$$4))) { - ZEPHIR_INIT_NVAR(&_6$$5); - object_init_ex(&_6$$5, phalcon_http_request_exception_ce); - ZEPHIR_INIT_NVAR(&_7$$5); - ZEPHIR_CONCAT_SVS(&_7$$5, "Sanitizer '", &sanitizer, "' does not exist in the filter locator"); - ZEPHIR_CALL_METHOD(NULL, &_6$$5, "__construct", NULL, 33, &_7$$5); - zephir_check_call_status(); - zephir_throw_exception_debug(&_6$$5, "phalcon/Http/Request.zep", 1324); - ZEPHIR_MM_RESTORE(); - return; - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &filters, "rewind", NULL, 0); + + zephir_update_property_zval(this_ptr, ZEND_STRL("headers"), &_0); + ZEPHIR_INIT_VAR(&_1); + object_init_ex(&_1, phalcon_support_helper_json_encode_ce); + if (zephir_has_constructor(&_1)) { + ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 0); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3, &filters, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3)) { - break; - } - ZEPHIR_CALL_METHOD(&sanitizer, &filters, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_8$$6, &filterService, "has", &_9, 0, &sanitizer); - zephir_check_call_status(); - if (UNEXPECTED(!ZEPHIR_IS_TRUE_IDENTICAL(&_8$$6))) { - ZEPHIR_INIT_NVAR(&_10$$7); - object_init_ex(&_10$$7, phalcon_http_request_exception_ce); - ZEPHIR_INIT_NVAR(&_11$$7); - ZEPHIR_CONCAT_SVS(&_11$$7, "Sanitizer '", &sanitizer, "' does not exist in the filter locator"); - ZEPHIR_CALL_METHOD(NULL, &_10$$7, "__construct", NULL, 33, &_11$$7); - zephir_check_call_status(); - zephir_throw_exception_debug(&_10$$7, "phalcon/Http/Request.zep", 1324); - ZEPHIR_MM_RESTORE(); - return; - } - ZEPHIR_CALL_METHOD(NULL, &filters, "next", NULL, 0); - zephir_check_call_status(); - } } - ZEPHIR_INIT_NVAR(&sanitizer); - if (zephir_fast_count_int(&scope) < 1) { - ZEPHIR_INIT_VAR(&localScope); - zephir_create_array(&localScope, 4, 0); - ZEPHIR_INIT_VAR(&_12$$8); - ZVAL_STRING(&_12$$8, "GET"); - zephir_array_fast_append(&localScope, &_12$$8); - ZEPHIR_INIT_NVAR(&_12$$8); - ZVAL_STRING(&_12$$8, "PATCH"); - zephir_array_fast_append(&localScope, &_12$$8); - ZEPHIR_INIT_NVAR(&_12$$8); - ZVAL_STRING(&_12$$8, "POST"); - zephir_array_fast_append(&localScope, &_12$$8); - ZEPHIR_INIT_NVAR(&_12$$8); - ZVAL_STRING(&_12$$8, "PUT"); - zephir_array_fast_append(&localScope, &_12$$8); - } else { - ZEPHIR_CPY_WRT(&localScope, &scope); + + zephir_update_property_zval(this_ptr, ZEND_STRL("encode"), &_1); + if (!ZEPHIR_IS_NULL(&content)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setcontent", NULL, 0, &content); + zephir_check_call_status(); } - zephir_is_iterable(&localScope, 0, "phalcon/Http/Request.zep", 1343); - if (Z_TYPE_P(&localScope) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&localScope), _13) - { - ZEPHIR_INIT_NVAR(&scopeMethod); - ZVAL_COPY(&scopeMethod, _13); - ZEPHIR_INIT_NVAR(&_15$$10); - zephir_fast_strtoupper(&_15$$10, &scopeMethod); - zephir_update_property_array_multi(this_ptr, SL("queryFilters"), &filters, SL("zz"), 2, &_15$$10, &name); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &localScope, "rewind", NULL, 0); + if (Z_TYPE_P(code) != IS_NULL) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setstatuscode", NULL, 0, code, status); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_14, &localScope, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_14)) { - break; - } - ZEPHIR_CALL_METHOD(&scopeMethod, &localScope, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_16$$11); - zephir_fast_strtoupper(&_16$$11, &scopeMethod); - zephir_update_property_array_multi(this_ptr, SL("queryFilters"), &filters, SL("zz"), 2, &_16$$11, &name); - ZEPHIR_CALL_METHOD(NULL, &localScope, "next", NULL, 0); - zephir_check_call_status(); - } } - ZEPHIR_INIT_NVAR(&scopeMethod); - RETURN_THIS(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Http_Request, setStrictHostCheck) +static PHP_METHOD(Phalcon_Http_Response, appendContent) { - zval *flag_param = NULL, __$true, __$false; - zend_bool flag; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *content, content_sub, _0, _1; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(flag) + ZVAL_UNDEF(&content_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(content) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(0, 1, &flag_param); - if (!flag_param) { - flag = 1; - } else { - } - if (flag) { - zephir_update_property_zval(this_ptr, ZEND_STRL("strictHostCheck"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("strictHostCheck"), &__$false); - } - RETURN_THISW(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &content); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "getcontent", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_VV(&_1, &_0, content); + zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &_1); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Request, getBestQuality) +static PHP_METHOD(Phalcon_Http_Response, getContent) { - double quality = 0, acceptQuality = 0; + zval _1; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, i = 0; - zval name; - zval *qualityParts_param = NULL, *name_param = NULL, selectedName, accept, *_0, _1, _2$$4, _3$$5, _4$$8, _5$$9; - zval qualityParts; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&qualityParts); - ZVAL_UNDEF(&selectedName); - ZVAL_UNDEF(&accept); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$5); - ZVAL_UNDEF(&_4$$8); - ZVAL_UNDEF(&_5$$9); - ZVAL_UNDEF(&name); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ARRAY(qualityParts) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &qualityParts_param, &name_param); - zephir_get_arrval(&qualityParts, qualityParts_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - i = 0; - quality = (0.0); - ZEPHIR_INIT_VAR(&selectedName); - ZVAL_STRING(&selectedName, ""); - zephir_is_iterable(&qualityParts, 0, "phalcon/Http/Request.zep", 1386); - if (Z_TYPE_P(&qualityParts) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&qualityParts), _0) - { - ZEPHIR_INIT_NVAR(&accept); - ZVAL_COPY(&accept, _0); - if (i == 0) { - ZEPHIR_OBS_NVAR(&_2$$4); - zephir_array_fetch_string(&_2$$4, &accept, SL("quality"), PH_NOISY, "phalcon/Http/Request.zep", 1372); - quality = (zephir_get_doubleval(&_2$$4)); - ZEPHIR_OBS_NVAR(&selectedName); - zephir_array_fetch(&selectedName, &accept, &name, PH_NOISY, "phalcon/Http/Request.zep", 1373); - } else { - ZEPHIR_OBS_NVAR(&_3$$5); - zephir_array_fetch_string(&_3$$5, &accept, SL("quality"), PH_NOISY, "phalcon/Http/Request.zep", 1375); - acceptQuality = (zephir_get_doubleval(&_3$$5)); - if (acceptQuality > quality) { - quality = acceptQuality; - ZEPHIR_OBS_NVAR(&selectedName); - zephir_array_fetch(&selectedName, &accept, &name, PH_NOISY, "phalcon/Http/Request.zep", 1379); - } - } - i++; - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &qualityParts, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &qualityParts, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&accept, &qualityParts, "current", NULL, 0); - zephir_check_call_status(); - if (i == 0) { - ZEPHIR_OBS_NVAR(&_4$$8); - zephir_array_fetch_string(&_4$$8, &accept, SL("quality"), PH_NOISY, "phalcon/Http/Request.zep", 1372); - quality = (zephir_get_doubleval(&_4$$8)); - ZEPHIR_OBS_NVAR(&selectedName); - zephir_array_fetch(&selectedName, &accept, &name, PH_NOISY, "phalcon/Http/Request.zep", 1373); - } else { - ZEPHIR_OBS_NVAR(&_5$$9); - zephir_array_fetch_string(&_5$$9, &accept, SL("quality"), PH_NOISY, "phalcon/Http/Request.zep", 1375); - acceptQuality = (zephir_get_doubleval(&_5$$9)); - if (acceptQuality > quality) { - quality = acceptQuality; - ZEPHIR_OBS_NVAR(&selectedName); - zephir_array_fetch(&selectedName, &accept, &name, PH_NOISY, "phalcon/Http/Request.zep", 1379); - } - } - i++; - ZEPHIR_CALL_METHOD(NULL, &qualityParts, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&accept); - RETURN_CCTOR(&selectedName); + + zephir_memory_observe(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("content"), PH_NOISY_CC); + zephir_cast_to_string(&_1, &_0); + RETURN_CTOR(&_1); } -static PHP_METHOD(Phalcon_Http_Request, getHelper) +static PHP_METHOD(Phalcon_Http_Response, getCookies) { + + RETURN_MEMBER(getThis(), "cookies"); +} + +static PHP_METHOD(Phalcon_Http_Response, getDI) +{ + zval container, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool notAllowEmpty, noRecursive, _0, _1; - zval name; - zval *source_param = NULL, *name_param = NULL, *filters = NULL, filters_sub, *defaultValue = NULL, defaultValue_sub, *notAllowEmpty_param = NULL, *noRecursive_param = NULL, __$null, value, filterService, _2$$6, _3$$6; - zval source; zval *this_ptr = getThis(); - ZVAL_UNDEF(&source); - ZVAL_UNDEF(&filters_sub); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&filterService); - ZVAL_UNDEF(&_2$$6); - ZVAL_UNDEF(&_3$$6); - ZVAL_UNDEF(&name); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 6) - Z_PARAM_ARRAY(source) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) - Z_PARAM_ZVAL_OR_NULL(filters) - Z_PARAM_ZVAL_OR_NULL(defaultValue) - Z_PARAM_BOOL(notAllowEmpty) - Z_PARAM_BOOL(noRecursive) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 5, &source_param, &name_param, &filters, &defaultValue, ¬AllowEmpty_param, &noRecursive_param); - zephir_get_arrval(&source, source_param); - if (!name_param) { - ZEPHIR_INIT_VAR(&name); - } else { - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - } - if (!filters) { - filters = &filters_sub; - filters = &__$null; - } - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; - } - if (!notAllowEmpty_param) { - notAllowEmpty = 0; - } else { - } - if (!noRecursive_param) { - noRecursive = 0; - } else { - } - if (ZEPHIR_IS_NULL(&name)) { - RETURN_CTOR(&source); - } - zephir_memory_observe(&value); - if (!(zephir_array_isset_fetch(&value, &source, &name, 0))) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); - } - _0 = !(zephir_is_numeric(&value)); - if (_0) { - _0 = ZEPHIR_IS_EMPTY(&value); - } - _1 = _0; - if (_1) { - _1 = notAllowEmpty; - } - if (_1) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); - } - if (Z_TYPE_P(filters) != IS_NULL) { - ZEPHIR_CALL_METHOD(&filterService, this_ptr, "getfilterservice", NULL, 347); - zephir_check_call_status(); - if (noRecursive) { - ZVAL_BOOL(&_3$$6, 1); - } else { - ZVAL_BOOL(&_3$$6, 0); - } - ZEPHIR_CALL_METHOD(&_2$$6, &filterService, "sanitize", NULL, 0, &value, filters, &_3$$6); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_0); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); zephir_check_call_status(); - ZEPHIR_CPY_WRT(&value, &_2$$6); - if (ZEPHIR_IS_FALSE_IDENTICAL(&value)) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_response_exception_ce, "A dependency injection container is required to access the 'url' service", "phalcon/Http/Response.zep", 153); + return; } + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &container); } - RETURN_CCTOR(&value); + RETURN_CCTOR(&container); } -static PHP_METHOD(Phalcon_Http_Request, hasFileHelper) +static PHP_METHOD(Phalcon_Http_Response, getEventsManager) +{ + + RETURN_MEMBER(getThis(), "eventsManager"); +} + +static PHP_METHOD(Phalcon_Http_Response, getHeaders) +{ + + RETURN_MEMBER(getThis(), "headers"); +} + +static PHP_METHOD(Phalcon_Http_Response, getReasonPhrase) { + zval statusReasonPhrase, _0, _1, _2, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, numberFiles; - zend_bool onlySuccessful, _2$$5, _6$$9; - zval *data, data_sub, *onlySuccessful_param = NULL, value, *_0, _1, _3$$7, _4$$7, _7$$11, _8$$11; + zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&data_sub); - ZVAL_UNDEF(&value); + ZVAL_UNDEF(&statusReasonPhrase); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3$$7); - ZVAL_UNDEF(&_4$$7); - ZVAL_UNDEF(&_7$$11); - ZVAL_UNDEF(&_8$$11); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_ZVAL(data) - Z_PARAM_BOOL(onlySuccessful) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &data, &onlySuccessful_param); - numberFiles = 0; - if (Z_TYPE_P(data) != IS_ARRAY) { - RETURN_MM_LONG(1); - } - zephir_is_iterable(data, 0, "phalcon/Http/Request.zep", 1455); - if (Z_TYPE_P(data) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(data), _0) - { - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0); - if (Z_TYPE_P(&value) != IS_ARRAY) { - _2$$5 = !zephir_is_true(&value); - if (!(_2$$5)) { - _2$$5 = !onlySuccessful; - } - if (_2$$5) { - numberFiles++; - } - } - if (Z_TYPE_P(&value) == IS_ARRAY) { - if (onlySuccessful) { - ZVAL_BOOL(&_4$$7, 1); - } else { - ZVAL_BOOL(&_4$$7, 0); - } - ZEPHIR_CALL_METHOD(&_3$$7, this_ptr, "hasfilehelper", &_5, 346, &value, &_4$$7); - zephir_check_call_status(); - numberFiles += zephir_get_numberval(&_3$$7); - } - } ZEND_HASH_FOREACH_END(); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "Status"); + ZEPHIR_CALL_METHOD(&_1, &_0, "get", NULL, 0, &_2); + zephir_check_call_status(); + ZVAL_LONG(&_3, 4); + ZEPHIR_INIT_VAR(&statusReasonPhrase); + zephir_substr(&statusReasonPhrase, &_1, 4 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + ZEPHIR_INIT_NVAR(&_2); + if (zephir_is_true(&statusReasonPhrase)) { + ZEPHIR_CPY_WRT(&_2, &statusReasonPhrase); } else { - ZEPHIR_CALL_METHOD(NULL, data, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, data, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&value, data, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&value) != IS_ARRAY) { - _6$$9 = !zephir_is_true(&value); - if (!(_6$$9)) { - _6$$9 = !onlySuccessful; - } - if (_6$$9) { - numberFiles++; - } - } - if (Z_TYPE_P(&value) == IS_ARRAY) { - if (onlySuccessful) { - ZVAL_BOOL(&_8$$11, 1); - } else { - ZVAL_BOOL(&_8$$11, 0); - } - ZEPHIR_CALL_METHOD(&_7$$11, this_ptr, "hasfilehelper", &_5, 346, &value, &_8$$11); - zephir_check_call_status(); - numberFiles += zephir_get_numberval(&_7$$11); - } - ZEPHIR_CALL_METHOD(NULL, data, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_NVAR(&_2); + ZVAL_NULL(&_2); } - ZEPHIR_INIT_NVAR(&value); - RETURN_MM_LONG(numberFiles); + RETURN_CCTOR(&_2); } -static PHP_METHOD(Phalcon_Http_Request, getQualityHeader) +static PHP_METHOD(Phalcon_Http_Response, getStatusCode) { + zval statusCode, _0, _1, _2, _3, _4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *serverIndex_param = NULL, *name_param = NULL, headerPart, headerParts, headerSplit, part, parts, returnedParts, serverValue, split, _0, _1, _2, _3, *_4, _5, _6$$3, _7$$3, _8$$3, _9$$3, *_10$$3, _11$$3, _12$$4, _13$$4, _14$$5, _15$$6, _16$$6, _17$$7, _18$$7, _19$$8, _20$$9, _21$$9, _22$$10, _23$$11, _24$$11, _25$$12, _26$$12, _27$$13, _28$$14, _29$$14, _30$$14, _31$$14, *_32$$14, _33$$14, _34$$15, _35$$15, _36$$16, _37$$17, _38$$17, _39$$18, _40$$18, _41$$19, _42$$20, _43$$20, _44$$21, _45$$22, _46$$22, _47$$23, _48$$23, _49$$24; - zval serverIndex, name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&serverIndex); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&headerPart); - ZVAL_UNDEF(&headerParts); - ZVAL_UNDEF(&headerSplit); - ZVAL_UNDEF(&part); - ZVAL_UNDEF(&parts); - ZVAL_UNDEF(&returnedParts); - ZVAL_UNDEF(&serverValue); - ZVAL_UNDEF(&split); + ZVAL_UNDEF(&statusCode); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_9$$3); - ZVAL_UNDEF(&_11$$3); - ZVAL_UNDEF(&_12$$4); - ZVAL_UNDEF(&_13$$4); - ZVAL_UNDEF(&_14$$5); - ZVAL_UNDEF(&_15$$6); - ZVAL_UNDEF(&_16$$6); - ZVAL_UNDEF(&_17$$7); - ZVAL_UNDEF(&_18$$7); - ZVAL_UNDEF(&_19$$8); - ZVAL_UNDEF(&_20$$9); - ZVAL_UNDEF(&_21$$9); - ZVAL_UNDEF(&_22$$10); - ZVAL_UNDEF(&_23$$11); - ZVAL_UNDEF(&_24$$11); - ZVAL_UNDEF(&_25$$12); - ZVAL_UNDEF(&_26$$12); - ZVAL_UNDEF(&_27$$13); - ZVAL_UNDEF(&_28$$14); - ZVAL_UNDEF(&_29$$14); - ZVAL_UNDEF(&_30$$14); - ZVAL_UNDEF(&_31$$14); - ZVAL_UNDEF(&_33$$14); - ZVAL_UNDEF(&_34$$15); - ZVAL_UNDEF(&_35$$15); - ZVAL_UNDEF(&_36$$16); - ZVAL_UNDEF(&_37$$17); - ZVAL_UNDEF(&_38$$17); - ZVAL_UNDEF(&_39$$18); - ZVAL_UNDEF(&_40$$18); - ZVAL_UNDEF(&_41$$19); - ZVAL_UNDEF(&_42$$20); - ZVAL_UNDEF(&_43$$20); - ZVAL_UNDEF(&_44$$21); - ZVAL_UNDEF(&_45$$22); - ZVAL_UNDEF(&_46$$22); - ZVAL_UNDEF(&_47$$23); - ZVAL_UNDEF(&_48$$23); - ZVAL_UNDEF(&_49$$24); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(serverIndex) + ZVAL_UNDEF(&_4); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "Status"); + ZEPHIR_CALL_METHOD(&_1, &_0, "get", NULL, 0, &_2); + zephir_check_call_status(); + ZVAL_LONG(&_3, 0); + ZVAL_LONG(&_4, 3); + ZEPHIR_INIT_VAR(&statusCode); + zephir_substr(&statusCode, &_1, 0 , 3 , 0); + ZEPHIR_INIT_NVAR(&_2); + if (zephir_is_true(&statusCode)) { + ZEPHIR_INIT_NVAR(&_2); + ZVAL_LONG(&_2, zephir_get_intval(&statusCode)); + } else { + ZEPHIR_INIT_NVAR(&_2); + ZVAL_NULL(&_2); + } + RETURN_CCTOR(&_2); +} + +static PHP_METHOD(Phalcon_Http_Response, hasHeader) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, headers; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&headers); + ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &serverIndex_param, &name_param); - if (UNEXPECTED(Z_TYPE_P(serverIndex_param) != IS_STRING && Z_TYPE_P(serverIndex_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'serverIndex' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(serverIndex_param) == IS_STRING)) { - zephir_get_strval(&serverIndex, serverIndex_param); + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); + ZEPHIR_CALL_METHOD(&headers, this_ptr, "getheaders", NULL, 0); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(&headers, "has", NULL, 0, &name); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Http_Response, isSent) +{ + + RETURN_MEMBER(getThis(), "sent"); +} + +static PHP_METHOD(Phalcon_Http_Response, redirect) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long statusCode, ZEPHIR_LAST_CALL_STATUS; + zend_bool externalRedirect, _11, _0$$5; + zval *location = NULL, location_sub, *externalRedirect_param = NULL, *statusCode_param = NULL, __$null, header, url, container, matched, view, _8, _9, _12, _1$$5, _2$$5, _3$$6, _4$$6, _5$$6, _6$$10, _7$$10, _10$$11; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&location_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&header); + ZVAL_UNDEF(&url); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&matched); + ZVAL_UNDEF(&view); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_1$$5); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_3$$6); + ZVAL_UNDEF(&_4$$6); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_6$$10); + ZVAL_UNDEF(&_7$$10); + ZVAL_UNDEF(&_10$$11); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 3) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(location) + Z_PARAM_BOOL(externalRedirect) + Z_PARAM_LONG(statusCode) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 3, &location, &externalRedirect_param, &statusCode_param); + if (!location) { + location = &location_sub; + ZEPHIR_CPY_WRT(location, &__$null); } else { - ZEPHIR_INIT_VAR(&serverIndex); - } - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); + ZEPHIR_SEPARATE_PARAM(location); } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + if (!externalRedirect_param) { + externalRedirect = 0; } else { - ZEPHIR_INIT_VAR(&name); - } - ZEPHIR_INIT_VAR(&returnedParts); - array_init(&returnedParts); - ZEPHIR_CALL_METHOD(&serverValue, this_ptr, "getserver", NULL, 0, &serverIndex); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_0); - if (Z_TYPE_P(&serverValue) == IS_NULL) { - ZEPHIR_INIT_NVAR(&_0); - ZVAL_STRING(&_0, ""); + } + if (!statusCode_param) { + statusCode = 302; } else { - ZEPHIR_CPY_WRT(&_0, &serverValue); + } + if (!(zephir_is_true(location))) { + ZEPHIR_INIT_NVAR(location); + ZVAL_STRING(location, ""); } - ZEPHIR_CPY_WRT(&serverValue, &_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "/,\\s*/"); - ZVAL_LONG(&_2, -1); - ZVAL_LONG(&_3, 1); - ZEPHIR_CALL_FUNCTION(&parts, "preg_split", NULL, 70, &_1, &serverValue, &_2, &_3); - zephir_check_call_status(); - zephir_is_iterable(&parts, 0, "phalcon/Http/Request.zep", 1499); - if (Z_TYPE_P(&parts) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&parts), _4) - { - ZEPHIR_INIT_NVAR(&part); - ZVAL_COPY(&part, _4); - ZEPHIR_INIT_NVAR(&headerParts); - array_init(&headerParts); - ZEPHIR_INIT_NVAR(&_6$$3); - zephir_fast_trim(&_6$$3, &part, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_7$$3); - ZVAL_STRING(&_7$$3, "/\\s*;\\s*/"); - ZVAL_LONG(&_8$$3, -1); - ZVAL_LONG(&_9$$3, 1); - ZEPHIR_CALL_FUNCTION(&headerSplit, "preg_split", NULL, 70, &_7$$3, &_6$$3, &_8$$3, &_9$$3); + if (externalRedirect) { + ZEPHIR_CPY_WRT(&header, location); + } else { + _0$$5 = Z_TYPE_P(location) == IS_STRING; + if (_0$$5) { + ZEPHIR_INIT_VAR(&_1$$5); + ZVAL_STRING(&_1$$5, "://"); + ZEPHIR_CALL_FUNCTION(&_2$$5, "strstr", NULL, 355, location, &_1$$5); zephir_check_call_status(); - zephir_is_iterable(&headerSplit, 0, "phalcon/Http/Request.zep", 1496); - if (Z_TYPE_P(&headerSplit) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&headerSplit), _10$$3) - { - ZEPHIR_INIT_NVAR(&headerPart); - ZVAL_COPY(&headerPart, _10$$3); - ZEPHIR_INIT_NVAR(&_12$$4); - ZVAL_STRING(&_12$$4, "="); - ZEPHIR_INIT_NVAR(&_13$$4); - zephir_fast_strpos(&_13$$4, &headerPart, &_12$$4, 0 ); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_13$$4)) { - ZEPHIR_INIT_NVAR(&split); - zephir_fast_explode_str(&split, SL("="), &headerPart, 2 ); - zephir_array_fetch_long(&_14$$5, &split, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1485); - if (ZEPHIR_IS_STRING_IDENTICAL(&_14$$5, "q")) { - ZEPHIR_OBS_NVAR(&_15$$6); - zephir_array_fetch_long(&_15$$6, &split, 1, PH_NOISY, "phalcon/Http/Request.zep", 1486); - ZEPHIR_INIT_NVAR(&_16$$6); - ZVAL_DOUBLE(&_16$$6, zephir_get_doubleval(&_15$$6)); - zephir_array_update_string(&headerParts, SL("quality"), &_16$$6, PH_COPY | PH_SEPARATE); - } else { - zephir_array_fetch_long(&_17$$7, &split, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1488); - ZEPHIR_OBS_NVAR(&_18$$7); - zephir_array_fetch_long(&_18$$7, &split, 0, PH_NOISY, "phalcon/Http/Request.zep", 1488); - zephir_array_update_zval(&headerParts, &_18$$7, &_17$$7, PH_COPY | PH_SEPARATE); - } - } else { - zephir_array_update_zval(&headerParts, &name, &headerPart, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_19$$8); - ZVAL_DOUBLE(&_19$$8, 1.0); - zephir_array_update_string(&headerParts, SL("quality"), &_19$$8, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); + _0$$5 = zephir_is_true(&_2$$5); + } + if (_0$$5) { + ZEPHIR_INIT_VAR(&_3$$6); + ZEPHIR_INIT_VAR(&_4$$6); + ZVAL_STRING(&_4$$6, "/^[^:\\/?#]++:/"); + ZEPHIR_INIT_VAR(&_5$$6); + ZVAL_STRING(&_5$$6, "/^[^:\\/?#]++:/"); + ZEPHIR_INIT_VAR(&matched); + zephir_preg_match(&matched, &_5$$6, location, &_3$$6, 0, 0 , 0 ); + if (zephir_is_true(&matched)) { + ZEPHIR_CPY_WRT(&header, location); } else { - ZEPHIR_CALL_METHOD(NULL, &headerSplit, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_11$$3, &headerSplit, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_11$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&headerPart, &headerSplit, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_20$$9); - ZVAL_STRING(&_20$$9, "="); - ZEPHIR_INIT_NVAR(&_21$$9); - zephir_fast_strpos(&_21$$9, &headerPart, &_20$$9, 0 ); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_21$$9)) { - ZEPHIR_INIT_NVAR(&split); - zephir_fast_explode_str(&split, SL("="), &headerPart, 2 ); - zephir_array_fetch_long(&_22$$10, &split, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1485); - if (ZEPHIR_IS_STRING_IDENTICAL(&_22$$10, "q")) { - ZEPHIR_OBS_NVAR(&_23$$11); - zephir_array_fetch_long(&_23$$11, &split, 1, PH_NOISY, "phalcon/Http/Request.zep", 1486); - ZEPHIR_INIT_NVAR(&_24$$11); - ZVAL_DOUBLE(&_24$$11, zephir_get_doubleval(&_23$$11)); - zephir_array_update_string(&headerParts, SL("quality"), &_24$$11, PH_COPY | PH_SEPARATE); - } else { - zephir_array_fetch_long(&_25$$12, &split, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1488); - ZEPHIR_OBS_NVAR(&_26$$12); - zephir_array_fetch_long(&_26$$12, &split, 0, PH_NOISY, "phalcon/Http/Request.zep", 1488); - zephir_array_update_zval(&headerParts, &_26$$12, &_25$$12, PH_COPY | PH_SEPARATE); - } - } else { - zephir_array_update_zval(&headerParts, &name, &headerPart, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_27$$13); - ZVAL_DOUBLE(&_27$$13, 1.0); - zephir_array_update_string(&headerParts, SL("quality"), &_27$$13, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &headerSplit, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_NVAR(&header); + ZVAL_NULL(&header); } - ZEPHIR_INIT_NVAR(&headerPart); - zephir_array_append(&returnedParts, &headerParts, PH_SEPARATE, "phalcon/Http/Request.zep", 1496); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &parts, "rewind", NULL, 0); + } else { + ZEPHIR_INIT_NVAR(&header); + ZVAL_NULL(&header); + } + } + ZEPHIR_CALL_METHOD(&container, this_ptr, "getdi", NULL, 0); + zephir_check_call_status(); + if (!(zephir_is_true(&header))) { + ZEPHIR_INIT_VAR(&_7$$10); + ZVAL_STRING(&_7$$10, "url"); + ZEPHIR_CALL_METHOD(&_6$$10, &container, "getshared", NULL, 0, &_7$$10); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5, &parts, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5)) { - break; - } - ZEPHIR_CALL_METHOD(&part, &parts, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&headerParts); - array_init(&headerParts); - ZEPHIR_INIT_NVAR(&_28$$14); - zephir_fast_trim(&_28$$14, &part, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_29$$14); - ZVAL_STRING(&_29$$14, "/\\s*;\\s*/"); - ZVAL_LONG(&_30$$14, -1); - ZVAL_LONG(&_31$$14, 1); - ZEPHIR_CALL_FUNCTION(&headerSplit, "preg_split", NULL, 70, &_29$$14, &_28$$14, &_30$$14, &_31$$14); - zephir_check_call_status(); - zephir_is_iterable(&headerSplit, 0, "phalcon/Http/Request.zep", 1496); - if (Z_TYPE_P(&headerSplit) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&headerSplit), _32$$14) - { - ZEPHIR_INIT_NVAR(&headerPart); - ZVAL_COPY(&headerPart, _32$$14); - ZEPHIR_INIT_NVAR(&_34$$15); - ZVAL_STRING(&_34$$15, "="); - ZEPHIR_INIT_NVAR(&_35$$15); - zephir_fast_strpos(&_35$$15, &headerPart, &_34$$15, 0 ); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_35$$15)) { - ZEPHIR_INIT_NVAR(&split); - zephir_fast_explode_str(&split, SL("="), &headerPart, 2 ); - zephir_array_fetch_long(&_36$$16, &split, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1485); - if (ZEPHIR_IS_STRING_IDENTICAL(&_36$$16, "q")) { - ZEPHIR_OBS_NVAR(&_37$$17); - zephir_array_fetch_long(&_37$$17, &split, 1, PH_NOISY, "phalcon/Http/Request.zep", 1486); - ZEPHIR_INIT_NVAR(&_38$$17); - ZVAL_DOUBLE(&_38$$17, zephir_get_doubleval(&_37$$17)); - zephir_array_update_string(&headerParts, SL("quality"), &_38$$17, PH_COPY | PH_SEPARATE); - } else { - zephir_array_fetch_long(&_39$$18, &split, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1488); - ZEPHIR_OBS_NVAR(&_40$$18); - zephir_array_fetch_long(&_40$$18, &split, 0, PH_NOISY, "phalcon/Http/Request.zep", 1488); - zephir_array_update_zval(&headerParts, &_40$$18, &_39$$18, PH_COPY | PH_SEPARATE); - } - } else { - zephir_array_update_zval(&headerParts, &name, &headerPart, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_41$$19); - ZVAL_DOUBLE(&_41$$19, 1.0); - zephir_array_update_string(&headerParts, SL("quality"), &_41$$19, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &headerSplit, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_33$$14, &headerSplit, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_33$$14)) { - break; - } - ZEPHIR_CALL_METHOD(&headerPart, &headerSplit, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_42$$20); - ZVAL_STRING(&_42$$20, "="); - ZEPHIR_INIT_NVAR(&_43$$20); - zephir_fast_strpos(&_43$$20, &headerPart, &_42$$20, 0 ); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_43$$20)) { - ZEPHIR_INIT_NVAR(&split); - zephir_fast_explode_str(&split, SL("="), &headerPart, 2 ); - zephir_array_fetch_long(&_44$$21, &split, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1485); - if (ZEPHIR_IS_STRING_IDENTICAL(&_44$$21, "q")) { - ZEPHIR_OBS_NVAR(&_45$$22); - zephir_array_fetch_long(&_45$$22, &split, 1, PH_NOISY, "phalcon/Http/Request.zep", 1486); - ZEPHIR_INIT_NVAR(&_46$$22); - ZVAL_DOUBLE(&_46$$22, zephir_get_doubleval(&_45$$22)); - zephir_array_update_string(&headerParts, SL("quality"), &_46$$22, PH_COPY | PH_SEPARATE); - } else { - zephir_array_fetch_long(&_47$$23, &split, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1488); - ZEPHIR_OBS_NVAR(&_48$$23); - zephir_array_fetch_long(&_48$$23, &split, 0, PH_NOISY, "phalcon/Http/Request.zep", 1488); - zephir_array_update_zval(&headerParts, &_48$$23, &_47$$23, PH_COPY | PH_SEPARATE); - } - } else { - zephir_array_update_zval(&headerParts, &name, &headerPart, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_49$$24); - ZVAL_DOUBLE(&_49$$24, 1.0); - zephir_array_update_string(&headerParts, SL("quality"), &_49$$24, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &headerSplit, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&headerPart); - zephir_array_append(&returnedParts, &headerParts, PH_SEPARATE, "phalcon/Http/Request.zep", 1496); - ZEPHIR_CALL_METHOD(NULL, &parts, "next", NULL, 0); + ZEPHIR_CPY_WRT(&url, &_6$$10); + ZEPHIR_CALL_METHOD(&header, &url, "get", NULL, 0, location); + zephir_check_call_status(); + } + ZEPHIR_INIT_VAR(&_9); + ZVAL_STRING(&_9, "view"); + ZEPHIR_CALL_METHOD(&_8, &container, "has", NULL, 0, &_9); + zephir_check_call_status(); + if (zephir_is_true(&_8)) { + ZEPHIR_INIT_VAR(&_10$$11); + ZVAL_STRING(&_10$$11, "view"); + ZEPHIR_CALL_METHOD(&view, &container, "getshared", NULL, 0, &_10$$11); + zephir_check_call_status(); + if (zephir_instance_of_ev(&view, phalcon_mvc_viewinterface_ce)) { + ZEPHIR_CALL_METHOD(NULL, &view, "disable", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&part); - RETURN_CCTOR(&returnedParts); + _11 = statusCode < 300; + if (!(_11)) { + _11 = statusCode > 308; + } + if (_11) { + statusCode = 302; + } + ZVAL_LONG(&_12, statusCode); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setstatuscode", NULL, 0, &_12); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_9); + ZVAL_STRING(&_9, "Location"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, &_9, &header); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Http_Response, removeHeader) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, _0; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "remove", NULL, 0, &name); + zephir_check_call_status(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Request, resolveAuthorizationHeaders) +static PHP_METHOD(Phalcon_Http_Response, resetHeaders) { - zend_bool _4, _9, _35, _22$$11; - zval headers, _5$$5, _36$$19; - zval resolved, eventsManager, hasEventsManager, container, exploded, digest, authHeader, server, _0, _8, _10, _1$$3, _2$$4, _3$$4, _6$$5, _7$$6, _11$$7, _12$$7, _13$$7, _14$$8, _15$$8, _16$$8, _17$$9, _18$$10, _19$$11, _20$$11, _21$$11, _23$$11, _24$$11, _25$$12, _26$$12, _27$$12, _28$$13, _29$$13, _30$$17, _31$$17, _32$$17, _33$$17, _34$$17, _37$$19, _38$$20; + zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&resolved); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&hasEventsManager); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&exploded); - ZVAL_UNDEF(&digest); - ZVAL_UNDEF(&authHeader); - ZVAL_UNDEF(&server); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_7$$6); - ZVAL_UNDEF(&_11$$7); - ZVAL_UNDEF(&_12$$7); - ZVAL_UNDEF(&_13$$7); - ZVAL_UNDEF(&_14$$8); - ZVAL_UNDEF(&_15$$8); - ZVAL_UNDEF(&_16$$8); - ZVAL_UNDEF(&_17$$9); - ZVAL_UNDEF(&_18$$10); - ZVAL_UNDEF(&_19$$11); - ZVAL_UNDEF(&_20$$11); - ZVAL_UNDEF(&_21$$11); - ZVAL_UNDEF(&_23$$11); - ZVAL_UNDEF(&_24$$11); - ZVAL_UNDEF(&_25$$12); - ZVAL_UNDEF(&_26$$12); - ZVAL_UNDEF(&_27$$12); - ZVAL_UNDEF(&_28$$13); - ZVAL_UNDEF(&_29$$13); - ZVAL_UNDEF(&_30$$17); - ZVAL_UNDEF(&_31$$17); - ZVAL_UNDEF(&_32$$17); - ZVAL_UNDEF(&_33$$17); - ZVAL_UNDEF(&_34$$17); - ZVAL_UNDEF(&_37$$19); - ZVAL_UNDEF(&_38$$20); - ZVAL_UNDEF(&headers); - ZVAL_UNDEF(&_5$$5); - ZVAL_UNDEF(&_36$$19); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_INIT_VAR(&authHeader); - ZVAL_NULL(&authHeader); - ZEPHIR_INIT_VAR(&headers); - array_init(&headers); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getdi", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&container, &_0); - ZEPHIR_CALL_METHOD(&server, this_ptr, "getserverarray", NULL, 337); + zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "reset", NULL, 0); zephir_check_call_status(); - if (Z_TYPE_P(&container) != IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - ZVAL_STRING(&_1$$3, "eventsManager"); - ZEPHIR_CALL_METHOD(&hasEventsManager, &container, "has", NULL, 0, &_1$$3); - zephir_check_call_status(); - if (zephir_is_true(&hasEventsManager)) { - ZEPHIR_INIT_VAR(&_3$$4); - ZVAL_STRING(&_3$$4, "eventsManager"); - ZEPHIR_CALL_METHOD(&_2$$4, &container, "getshared", NULL, 0, &_3$$4); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&eventsManager, &_2$$4); - } - } - _4 = zephir_is_true(&hasEventsManager); - if (_4) { - _4 = Z_TYPE_P(&eventsManager) == IS_OBJECT; - } - if (_4) { - ZEPHIR_INIT_VAR(&_5$$5); - zephir_create_array(&_5$$5, 1, 0); - zephir_array_update_string(&_5$$5, SL("server"), &server, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_6$$5); - ZVAL_STRING(&_6$$5, "request:beforeAuthorizationResolve"); - ZEPHIR_CALL_METHOD(&resolved, &eventsManager, "fire", NULL, 0, &_6$$5, this_ptr, &_5$$5); - zephir_check_call_status(); - if (Z_TYPE_P(&resolved) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_7$$6); - zephir_fast_array_merge(&_7$$6, &headers, &resolved); - ZEPHIR_CPY_WRT(&headers, &_7$$6); - } + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Http_Response, send) +{ + zend_bool _3$$5; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval __$true, __$false, content, file, _0, _1, _2$$5; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&content); + ZVAL_UNDEF(&file); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$5); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("sent"), PH_NOISY_CC | PH_READONLY); + if (UNEXPECTED(zephir_is_true(&_0))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_response_exception_ce, "Response was already sent", "phalcon/Http/Response.zep", 343); + return; } - ZEPHIR_INIT_VAR(&_8); - ZVAL_STRING(&_8, "PHP_AUTH_USER"); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "hasserver", NULL, 335, &_8); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "sendheaders", NULL, 0); zephir_check_call_status(); - _9 = zephir_is_true(&_0); - if (_9) { - ZEPHIR_INIT_NVAR(&_8); - ZVAL_STRING(&_8, "PHP_AUTH_PW"); - ZEPHIR_CALL_METHOD(&_10, this_ptr, "hasserver", NULL, 335, &_8); - zephir_check_call_status(); - _9 = zephir_is_true(&_10); - } - if (_9) { - ZEPHIR_INIT_VAR(&_12$$7); - ZVAL_STRING(&_12$$7, "PHP_AUTH_USER"); - ZEPHIR_CALL_METHOD(&_11$$7, this_ptr, "getserver", NULL, 0, &_12$$7); - zephir_check_call_status(); - zephir_array_update_string(&headers, SL("Php-Auth-User"), &_11$$7, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_NVAR(&_12$$7); - ZVAL_STRING(&_12$$7, "PHP_AUTH_PW"); - ZEPHIR_CALL_METHOD(&_13$$7, this_ptr, "getserver", NULL, 0, &_12$$7); - zephir_check_call_status(); - zephir_array_update_string(&headers, SL("Php-Auth-Pw"), &_13$$7, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "sendcookies", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("content"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&content, &_1); + if (Z_TYPE_P(&content) != IS_NULL) { + zend_print_zval(&content, 0); } else { - ZEPHIR_INIT_VAR(&_15$$8); - ZVAL_STRING(&_15$$8, "HTTP_AUTHORIZATION"); - ZEPHIR_CALL_METHOD(&_14$$8, this_ptr, "hasserver", NULL, 335, &_15$$8); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_15$$8); - ZVAL_STRING(&_15$$8, "REDIRECT_HTTP_AUTHORIZATION"); - ZEPHIR_CALL_METHOD(&_16$$8, this_ptr, "hasserver", NULL, 335, &_15$$8); - zephir_check_call_status(); - if (zephir_is_true(&_14$$8)) { - ZEPHIR_INIT_VAR(&_17$$9); - ZVAL_STRING(&_17$$9, "HTTP_AUTHORIZATION"); - ZEPHIR_CALL_METHOD(&authHeader, this_ptr, "getserver", NULL, 0, &_17$$9); - zephir_check_call_status(); - } else if (zephir_is_true(&_16$$8)) { - ZEPHIR_INIT_VAR(&_18$$10); - ZVAL_STRING(&_18$$10, "REDIRECT_HTTP_AUTHORIZATION"); - ZEPHIR_CALL_METHOD(&authHeader, this_ptr, "getserver", NULL, 0, &_18$$10); - zephir_check_call_status(); - } - if (zephir_is_true(&authHeader)) { - ZEPHIR_INIT_VAR(&_19$$11); - ZVAL_STRING(&_19$$11, "basic "); - ZEPHIR_CALL_FUNCTION(&_20$$11, "stripos", NULL, 348, &authHeader, &_19$$11); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_19$$11); - ZVAL_STRING(&_19$$11, "digest "); - ZEPHIR_CALL_FUNCTION(&_21$$11, "stripos", NULL, 348, &authHeader, &_19$$11); - zephir_check_call_status(); - _22$$11 = ZEPHIR_IS_LONG_IDENTICAL(&_21$$11, 0); - if (_22$$11) { - ZEPHIR_INIT_NVAR(&_19$$11); - ZVAL_STRING(&_19$$11, "PHP_AUTH_DIGEST"); - ZEPHIR_CALL_METHOD(&_23$$11, this_ptr, "hasserver", NULL, 335, &_19$$11); - zephir_check_call_status(); - _22$$11 = !zephir_is_true(&_23$$11); - } - ZEPHIR_INIT_NVAR(&_19$$11); - ZVAL_STRING(&_19$$11, "bearer "); - ZEPHIR_CALL_FUNCTION(&_24$$11, "stripos", NULL, 348, &authHeader, &_19$$11); - zephir_check_call_status(); - if (ZEPHIR_IS_LONG_IDENTICAL(&_20$$11, 0)) { - ZVAL_LONG(&_25$$12, 6); - ZEPHIR_INIT_VAR(&_26$$12); - zephir_substr(&_26$$12, &authHeader, 6 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - ZEPHIR_CALL_FUNCTION(&_27$$12, "base64_decode", NULL, 230, &_26$$12); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&exploded); - zephir_fast_explode_str(&exploded, SL(":"), &_27$$12, 2 ); - if (zephir_fast_count_int(&exploded) == 2) { - zephir_array_fetch_long(&_28$$13, &exploded, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1558); - zephir_array_update_string(&headers, SL("Php-Auth-User"), &_28$$13, PH_COPY | PH_SEPARATE); - zephir_array_fetch_long(&_29$$13, &exploded, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1559); - zephir_array_update_string(&headers, SL("Php-Auth-Pw"), &_29$$13, PH_COPY | PH_SEPARATE); - } - } else if (_22$$11) { - zephir_array_update_string(&headers, SL("Php-Auth-Digest"), &authHeader, PH_COPY | PH_SEPARATE); - } else if (ZEPHIR_IS_LONG_IDENTICAL(&_24$$11, 0)) { - zephir_array_update_string(&headers, SL("Authorization"), &authHeader, PH_COPY | PH_SEPARATE); - } + zephir_read_property(&_2$$5, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&file, &_2$$5); + _3$$5 = Z_TYPE_P(&file) == IS_STRING; + if (_3$$5) { + _3$$5 = ((zephir_fast_strlen_ev(&file)) ? 1 : 0); } - } - if (!(zephir_array_isset_string(&headers, SL("Authorization")))) { - zephir_memory_observe(&digest); - if (zephir_array_isset_string(&headers, SL("Php-Auth-User"))) { - zephir_array_fetch_string(&_30$$17, &headers, SL("Php-Auth-User"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1571); - zephir_array_fetch_string(&_31$$17, &headers, SL("Php-Auth-Pw"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1571); - ZEPHIR_INIT_VAR(&_32$$17); - ZEPHIR_CONCAT_VSV(&_32$$17, &_30$$17, ":", &_31$$17); - ZEPHIR_CALL_FUNCTION(&_33$$17, "base64_encode", NULL, 231, &_32$$17); + if (_3$$5) { + ZEPHIR_CALL_FUNCTION(NULL, "readfile", NULL, 356, &file); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_34$$17); - ZEPHIR_CONCAT_SV(&_34$$17, "Basic ", &_33$$17); - zephir_array_update_string(&headers, SL("Authorization"), &_34$$17, PH_COPY | PH_SEPARATE); - } else if (zephir_array_isset_string_fetch(&digest, &headers, SL("Php-Auth-Digest"), 0)) { - zephir_array_update_string(&headers, SL("Authorization"), &digest, PH_COPY | PH_SEPARATE); } } - _35 = zephir_is_true(&hasEventsManager); - if (_35) { - _35 = Z_TYPE_P(&eventsManager) == IS_OBJECT; - } - if (_35) { - ZEPHIR_INIT_VAR(&_36$$19); - zephir_create_array(&_36$$19, 2, 0); - zephir_array_update_string(&_36$$19, SL("headers"), &headers, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_36$$19, SL("server"), &server, PH_COPY | PH_SEPARATE); - ZEPHIR_INIT_VAR(&_37$$19); - ZVAL_STRING(&_37$$19, "request:afterAuthorizationResolve"); - ZEPHIR_CALL_METHOD(&resolved, &eventsManager, "fire", NULL, 0, &_37$$19, this_ptr, &_36$$19); - zephir_check_call_status(); - if (Z_TYPE_P(&resolved) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_38$$20); - zephir_fast_array_merge(&_38$$20, &headers, &resolved); - ZEPHIR_CPY_WRT(&headers, &_38$$20); - } + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("sent"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("sent"), &__$false); } - RETURN_CTOR(&headers); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Request, smoothFiles) +static PHP_METHOD(Phalcon_Http_Response, sendCookies) { - zend_string *_3; - zend_ulong _2; + zval cookies, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_11 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval prefix; - zval *names_param = NULL, *types_param = NULL, *tmp_names_param = NULL, *sizes_param = NULL, *errors_param = NULL, *prefix_param = NULL, idx, name, file, files, parentFiles, p, *_0, _1, _5$$4, _6$$5, _7$$5, _8$$5, _9$$5, _10$$5, *_12$$5, _13$$5, _15$$9, _16$$10, _17$$10, _18$$10, _19$$10, _20$$10, *_21$$10, _22$$10; - zval names, types, tmp_names, sizes, errors, _4$$4, _14$$9; zval *this_ptr = getThis(); - ZVAL_UNDEF(&names); - ZVAL_UNDEF(&types); - ZVAL_UNDEF(&tmp_names); - ZVAL_UNDEF(&sizes); - ZVAL_UNDEF(&errors); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_14$$9); - ZVAL_UNDEF(&idx); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&file); - ZVAL_UNDEF(&files); - ZVAL_UNDEF(&parentFiles); - ZVAL_UNDEF(&p); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_7$$5); - ZVAL_UNDEF(&_8$$5); - ZVAL_UNDEF(&_9$$5); - ZVAL_UNDEF(&_10$$5); - ZVAL_UNDEF(&_13$$5); - ZVAL_UNDEF(&_15$$9); - ZVAL_UNDEF(&_16$$10); - ZVAL_UNDEF(&_17$$10); - ZVAL_UNDEF(&_18$$10); - ZVAL_UNDEF(&_19$$10); - ZVAL_UNDEF(&_20$$10); - ZVAL_UNDEF(&_22$$10); - ZVAL_UNDEF(&prefix); - ZEND_PARSE_PARAMETERS_START(6, 6) - Z_PARAM_ARRAY(names) - Z_PARAM_ARRAY(types) - Z_PARAM_ARRAY(tmp_names) - Z_PARAM_ARRAY(sizes) - Z_PARAM_ARRAY(errors) - Z_PARAM_STR(prefix) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&cookies); + ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 6, 0, &names_param, &types_param, &tmp_names_param, &sizes_param, &errors_param, &prefix_param); - ZEPHIR_OBS_COPY_OR_DUP(&names, names_param); - ZEPHIR_OBS_COPY_OR_DUP(&types, types_param); - ZEPHIR_OBS_COPY_OR_DUP(&tmp_names, tmp_names_param); - ZEPHIR_OBS_COPY_OR_DUP(&sizes, sizes_param); - ZEPHIR_OBS_COPY_OR_DUP(&errors, errors_param); - zephir_get_strval(&prefix, prefix_param); - ZEPHIR_INIT_VAR(&files); - array_init(&files); - zephir_is_iterable(&names, 0, "phalcon/Http/Request.zep", 1635); - if (Z_TYPE_P(&names) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&names), _2, _3, _0) - { - ZEPHIR_INIT_NVAR(&idx); - if (_3 != NULL) { - ZVAL_STR_COPY(&idx, _3); - } else { - ZVAL_LONG(&idx, _2); - } - ZEPHIR_INIT_NVAR(&name); - ZVAL_COPY(&name, _0); - ZEPHIR_INIT_NVAR(&p); - ZEPHIR_CONCAT_VSV(&p, &prefix, ".", &idx); - if (Z_TYPE_P(&name) == IS_STRING) { - ZEPHIR_INIT_NVAR(&_4$$4); - zephir_create_array(&_4$$4, 6, 0); - zephir_array_update_string(&_4$$4, SL("name"), &name, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_5$$4); - zephir_array_fetch(&_5$$4, &types, &idx, PH_NOISY, "phalcon/Http/Request.zep", 1611); - zephir_array_update_string(&_4$$4, SL("type"), &_5$$4, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_5$$4); - zephir_array_fetch(&_5$$4, &tmp_names, &idx, PH_NOISY, "phalcon/Http/Request.zep", 1612); - zephir_array_update_string(&_4$$4, SL("tmp_name"), &_5$$4, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_5$$4); - zephir_array_fetch(&_5$$4, &sizes, &idx, PH_NOISY, "phalcon/Http/Request.zep", 1613); - zephir_array_update_string(&_4$$4, SL("size"), &_5$$4, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_5$$4); - zephir_array_fetch(&_5$$4, &errors, &idx, PH_NOISY, "phalcon/Http/Request.zep", 1614); - zephir_array_update_string(&_4$$4, SL("error"), &_5$$4, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_4$$4, SL("key"), &p, PH_COPY | PH_SEPARATE); - zephir_array_append(&files, &_4$$4, PH_SEPARATE, "phalcon/Http/Request.zep", 1616); - } - if (Z_TYPE_P(&name) == IS_ARRAY) { - zephir_array_fetch(&_6$$5, &names, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1621); - zephir_array_fetch(&_7$$5, &types, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1622); - zephir_array_fetch(&_8$$5, &tmp_names, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1623); - zephir_array_fetch(&_9$$5, &sizes, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1624); - zephir_array_fetch(&_10$$5, &errors, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1625); - ZEPHIR_CALL_METHOD(&parentFiles, this_ptr, "smoothfiles", &_11, 342, &_6$$5, &_7$$5, &_8$$5, &_9$$5, &_10$$5, &p); - zephir_check_call_status(); - zephir_is_iterable(&parentFiles, 0, "phalcon/Http/Request.zep", 1632); - if (Z_TYPE_P(&parentFiles) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&parentFiles), _12$$5) - { - ZEPHIR_INIT_NVAR(&file); - ZVAL_COPY(&file, _12$$5); - zephir_array_append(&files, &file, PH_SEPARATE, "phalcon/Http/Request.zep", 1630); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &parentFiles, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_13$$5, &parentFiles, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_13$$5)) { - break; - } - ZEPHIR_CALL_METHOD(&file, &parentFiles, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_append(&files, &file, PH_SEPARATE, "phalcon/Http/Request.zep", 1630); - ZEPHIR_CALL_METHOD(NULL, &parentFiles, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&file); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &names, "rewind", NULL, 0); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("cookies"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&cookies, &_0); + if (Z_TYPE_P(&cookies) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(NULL, &cookies, "send", NULL, 0); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, &names, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&idx, &names, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&name, &names, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&p); - ZEPHIR_CONCAT_VSV(&p, &prefix, ".", &idx); - if (Z_TYPE_P(&name) == IS_STRING) { - ZEPHIR_INIT_NVAR(&_14$$9); - zephir_create_array(&_14$$9, 6, 0); - zephir_array_update_string(&_14$$9, SL("name"), &name, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_15$$9); - zephir_array_fetch(&_15$$9, &types, &idx, PH_NOISY, "phalcon/Http/Request.zep", 1611); - zephir_array_update_string(&_14$$9, SL("type"), &_15$$9, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_15$$9); - zephir_array_fetch(&_15$$9, &tmp_names, &idx, PH_NOISY, "phalcon/Http/Request.zep", 1612); - zephir_array_update_string(&_14$$9, SL("tmp_name"), &_15$$9, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_15$$9); - zephir_array_fetch(&_15$$9, &sizes, &idx, PH_NOISY, "phalcon/Http/Request.zep", 1613); - zephir_array_update_string(&_14$$9, SL("size"), &_15$$9, PH_COPY | PH_SEPARATE); - ZEPHIR_OBS_NVAR(&_15$$9); - zephir_array_fetch(&_15$$9, &errors, &idx, PH_NOISY, "phalcon/Http/Request.zep", 1614); - zephir_array_update_string(&_14$$9, SL("error"), &_15$$9, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_14$$9, SL("key"), &p, PH_COPY | PH_SEPARATE); - zephir_array_append(&files, &_14$$9, PH_SEPARATE, "phalcon/Http/Request.zep", 1616); - } - if (Z_TYPE_P(&name) == IS_ARRAY) { - zephir_array_fetch(&_16$$10, &names, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1621); - zephir_array_fetch(&_17$$10, &types, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1622); - zephir_array_fetch(&_18$$10, &tmp_names, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1623); - zephir_array_fetch(&_19$$10, &sizes, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1624); - zephir_array_fetch(&_20$$10, &errors, &idx, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1625); - ZEPHIR_CALL_METHOD(&parentFiles, this_ptr, "smoothfiles", &_11, 342, &_16$$10, &_17$$10, &_18$$10, &_19$$10, &_20$$10, &p); - zephir_check_call_status(); - zephir_is_iterable(&parentFiles, 0, "phalcon/Http/Request.zep", 1632); - if (Z_TYPE_P(&parentFiles) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&parentFiles), _21$$10) - { - ZEPHIR_INIT_NVAR(&file); - ZVAL_COPY(&file, _21$$10); - zephir_array_append(&files, &file, PH_SEPARATE, "phalcon/Http/Request.zep", 1630); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &parentFiles, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_22$$10, &parentFiles, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_22$$10)) { - break; - } - ZEPHIR_CALL_METHOD(&file, &parentFiles, "current", NULL, 0); - zephir_check_call_status(); - zephir_array_append(&files, &file, PH_SEPARATE, "phalcon/Http/Request.zep", 1630); - ZEPHIR_CALL_METHOD(NULL, &parentFiles, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&file); - } - ZEPHIR_CALL_METHOD(NULL, &names, "next", NULL, 0); - zephir_check_call_status(); - } } - ZEPHIR_INIT_NVAR(&name); - ZEPHIR_INIT_NVAR(&idx); - RETURN_CCTOR(&files); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Request, getFilterService) +static PHP_METHOD(Phalcon_Http_Response, sendHeaders) { - zval container, filterService, _0, _1$$3, _2$$3, _3$$3; + zend_bool _3; + zval eventsManager, headers, result, _0, _1$$3, _2$$3, _4$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&filterService); + ZVAL_UNDEF(&eventsManager); + ZVAL_UNDEF(&headers); + ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$5); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("filterService"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&filterService, &_0); - if (Z_TYPE_P(&filterService) != IS_OBJECT) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_1$$3); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_request_exception_ce, "A dependency injection container is required to access the 'filter' service", "phalcon/Http/Request.zep", 1653); - return; + zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&headers, &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&eventsManager, &_0); + if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "response:beforeSendHeaders"); + ZEPHIR_CALL_METHOD(&_1$$3, &eventsManager, "fire", NULL, 0, &_2$$3, this_ptr); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$3)) { + RETURN_MM_BOOL(0); } - ZEPHIR_INIT_VAR(&_3$$3); - ZVAL_STRING(&_3$$3, "filter"); - ZEPHIR_CALL_METHOD(&_2$$3, &container, "getshared", NULL, 0, &_3$$3); + } + ZEPHIR_CALL_METHOD(&result, &headers, "send", NULL, 0); + zephir_check_call_status(); + _3 = ZEPHIR_IS_TRUE_IDENTICAL(&result); + if (_3) { + _3 = Z_TYPE_P(&eventsManager) == IS_OBJECT; + } + if (_3) { + ZEPHIR_INIT_VAR(&_4$$5); + ZVAL_STRING(&_4$$5, "response:afterSendHeaders"); + ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_4$$5, this_ptr); zephir_check_call_status(); - ZEPHIR_CPY_WRT(&filterService, &_2$$3); - zephir_update_property_zval(this_ptr, ZEND_STRL("filterService"), &filterService); } - RETURN_MM_MEMBER(getThis(), "filterService"); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Request, getServerArray) +static PHP_METHOD(Phalcon_Http_Response, setCache) { - zval _SERVER; - - ZVAL_UNDEF(&_SERVER); - zephir_get_global(&_SERVER, SL("_SERVER")); + zval _1, _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *minutes_param = NULL, date, _0, _2, _4; + zend_long minutes, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - if (zephir_is_true(&_SERVER)) { - RETVAL_ZVAL(&_SERVER, 1, 0); - return; + ZVAL_UNDEF(&date); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(minutes) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &minutes_param); + if (UNEXPECTED(Z_TYPE_P(minutes_param) != IS_LONG)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'minutes' must be of the type int")); + RETURN_MM_NULL(); } - array_init(return_value); - return; + minutes = Z_LVAL_P(minutes_param); + ZEPHIR_INIT_VAR(&date); + object_init_ex(&date, php_date_get_date_ce()); + ZEPHIR_CALL_METHOD(NULL, &date, "__construct", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + ZVAL_LONG(&_0, minutes); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_SVS(&_1, "+", &_0, " minutes"); + ZEPHIR_CALL_METHOD(NULL, &date, "modify", NULL, 0, &_1); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setexpires", NULL, 0, &date); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_2); + ZVAL_LONG(&_2, ((minutes * 60))); + ZEPHIR_INIT_VAR(&_3); + ZEPHIR_CONCAT_SV(&_3, "max-age=", &_2); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "Cache-Control"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, &_4, &_3); + zephir_check_call_status(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Request, getFilteredData) +static PHP_METHOD(Phalcon_Http_Response, setContent) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *content_param = NULL; + zval content; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&content); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(content) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &content_param); + zephir_get_strval(&content, content_param); + zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &content); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Http_Response, setContentLength) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *contentLength_param = NULL, _0, _1; + zend_long contentLength, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(contentLength) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &contentLength_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "Content-Length"); + ZVAL_LONG(&_1, contentLength); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, &_0, &_1); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Http_Response, setContentType) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool notAllowEmpty, noRecursive; - zval *methodKey_param = NULL, *method_param = NULL, *name_param = NULL, *defaultValue = NULL, defaultValue_sub, *notAllowEmpty_param = NULL, *noRecursive_param = NULL, __$null, filters, _0, _1, _2, _3; - zval methodKey, method, name; + zval *contentType_param = NULL, *charset = NULL, charset_sub, __$null, _0$$3, _1; + zval contentType; zval *this_ptr = getThis(); - ZVAL_UNDEF(&methodKey); - ZVAL_UNDEF(&method); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&defaultValue_sub); + ZVAL_UNDEF(&contentType); + ZVAL_UNDEF(&charset_sub); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&filters); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_0$$3); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 6) - Z_PARAM_STR(methodKey) - Z_PARAM_STR(method) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(contentType) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) - Z_PARAM_ZVAL_OR_NULL(defaultValue) - Z_PARAM_BOOL(notAllowEmpty) - Z_PARAM_BOOL(noRecursive) + Z_PARAM_ZVAL_OR_NULL(charset) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 4, &methodKey_param, &method_param, &name_param, &defaultValue, ¬AllowEmpty_param, &noRecursive_param); - zephir_get_strval(&methodKey, methodKey_param); - zephir_get_strval(&method, method_param); - if (!name_param) { - ZEPHIR_INIT_VAR(&name); - } else { - zephir_get_strval(&name, name_param); - } - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; - } - if (!notAllowEmpty_param) { - notAllowEmpty = 0; - } else { - } - if (!noRecursive_param) { - noRecursive = 0; - } else { - } - zephir_memory_observe(&filters); - zephir_read_property(&_0, this_ptr, ZEND_STRL("queryFilters"), PH_NOISY_CC | PH_READONLY); - zephir_array_fetch(&_1, &_0, &methodKey, PH_READONLY, "phalcon/Http/Request.zep", 1685); - if (!(zephir_array_isset_fetch(&filters, &_1, &name, 0))) { - ZEPHIR_INIT_NVAR(&filters); - array_init(&filters); + zephir_fetch_params(1, 1, 1, &contentType_param, &charset); + zephir_get_strval(&contentType, contentType_param); + if (!charset) { + charset = &charset_sub; + charset = &__$null; } - if (notAllowEmpty) { - ZVAL_BOOL(&_2, 1); - } else { - ZVAL_BOOL(&_2, 0); + if (Z_TYPE_P(charset) != IS_NULL) { + ZEPHIR_INIT_VAR(&_0$$3); + ZEPHIR_CONCAT_SV(&_0$$3, "; charset=", charset); + zephir_concat_self(&contentType, &_0$$3); } - if (noRecursive) { - ZVAL_BOOL(&_3, 1); - } else { - ZVAL_BOOL(&_3, 0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "Content-Type"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, &_1, &contentType); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Http_Response, setCookies) +{ + zval *cookies, cookies_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&cookies_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(cookies, phalcon_http_response_cookiesinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &cookies); + zephir_update_property_zval(this_ptr, ZEND_STRL("cookies"), cookies); + RETURN_THISW(); +} + +static PHP_METHOD(Phalcon_Http_Response, setDI) +{ + zval *container, container_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&container_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &container); + zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); +} + +static PHP_METHOD(Phalcon_Http_Response, setEtag) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *etag_param = NULL, _0; + zval etag; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&etag); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(etag) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &etag_param); + zephir_get_strval(&etag, etag_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "Etag"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, &_0, &etag); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Http_Response, setExpires) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *datetime, datetime_sub, date, _0, _1, _2, _3; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&datetime_sub); + ZVAL_UNDEF(&date); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(datetime, php_date_get_date_ce()) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &datetime); + ZEPHIR_INIT_VAR(&date); + if (zephir_clone(&date, datetime) == FAILURE) { + RETURN_MM(); } - ZEPHIR_RETURN_CALL_METHOD_ZVAL(this_ptr, &method, NULL, 0, &name, &filters, defaultValue, &_2, &_3); + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, php_date_get_timezone_ce()); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "UTC"); + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0, &_1); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_CALL_METHOD(NULL, &date, "settimezone", NULL, 0, &_0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "D, d M Y H:i:s"); + ZEPHIR_CALL_METHOD(&_2, &date, "format", NULL, 0, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3); + ZEPHIR_CONCAT_VS(&_3, &_2, " GMT"); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "Expires"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, &_1, &_3); + zephir_check_call_status(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Request, getPatchPut) +static PHP_METHOD(Phalcon_Http_Response, setEventsManager) +{ + zval *eventsManager, eventsManager_sub; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&eventsManager_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); + zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); +} + +static PHP_METHOD(Phalcon_Http_Response, setFileToSend) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zend_bool notAllowEmpty, noRecursive, _0$$3, _3$$3; - zval *collection_param = NULL, *name_param = NULL, *filters = NULL, filters_sub, *defaultValue = NULL, defaultValue_sub, *notAllowEmpty_param = NULL, *noRecursive_param = NULL, __$null, cached, contentType, _10, _11, _1$$3, _2$$3, _4$$3, _5$$4, _6$$4, _8$$4, _7$$5, _9$$8; - zval collection, name; + zval *filePath_param = NULL, *attachmentName = NULL, attachmentName_sub, *attachment = NULL, attachment_sub, __$true, __$null, basePath, basePathEncoding, _0$$6, _1$$5, _2$$7, _3$$7, _4$$7, _5$$8, _6$$8, _7$$8; + zval filePath; zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&filters_sub); - ZVAL_UNDEF(&defaultValue_sub); + ZVAL_UNDEF(&filePath); + ZVAL_UNDEF(&attachmentName_sub); + ZVAL_UNDEF(&attachment_sub); + ZVAL_BOOL(&__$true, 1); ZVAL_NULL(&__$null); - ZVAL_UNDEF(&cached); - ZVAL_UNDEF(&contentType); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_7$$5); - ZVAL_UNDEF(&_9$$8); + ZVAL_UNDEF(&basePath); + ZVAL_UNDEF(&basePathEncoding); + ZVAL_UNDEF(&_0$$6); + ZVAL_UNDEF(&_1$$5); + ZVAL_UNDEF(&_2$$7); + ZVAL_UNDEF(&_3$$7); + ZVAL_UNDEF(&_4$$7); + ZVAL_UNDEF(&_5$$8); + ZVAL_UNDEF(&_6$$8); + ZVAL_UNDEF(&_7$$8); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 6) - Z_PARAM_STR(collection) + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(filePath) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(name) - Z_PARAM_ZVAL_OR_NULL(filters) - Z_PARAM_ZVAL_OR_NULL(defaultValue) - Z_PARAM_BOOL(notAllowEmpty) - Z_PARAM_BOOL(noRecursive) + Z_PARAM_ZVAL_OR_NULL(attachmentName) + Z_PARAM_ZVAL(attachment) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 5, &collection_param, &name_param, &filters, &defaultValue, ¬AllowEmpty_param, &noRecursive_param); - zephir_get_strval(&collection, collection_param); - if (!name_param) { - ZEPHIR_INIT_VAR(&name); - } else { - zephir_get_strval(&name, name_param); - } - if (!filters) { - filters = &filters_sub; - filters = &__$null; + zephir_fetch_params(1, 1, 2, &filePath_param, &attachmentName, &attachment); + zephir_get_strval(&filePath, filePath_param); + if (!attachmentName) { + attachmentName = &attachmentName_sub; + attachmentName = &__$null; } - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; + if (!attachment) { + attachment = &attachment_sub; + attachment = &__$true; } - if (!notAllowEmpty_param) { - notAllowEmpty = 0; - } else { - } - if (!noRecursive_param) { - noRecursive = 0; + ZEPHIR_INIT_VAR(&basePathEncoding); + ZVAL_STRING(&basePathEncoding, "ASCII"); + if (Z_TYPE_P(attachmentName) != IS_STRING) { + ZEPHIR_CALL_METHOD(&basePath, this_ptr, "getbasename", NULL, 357, &filePath); + zephir_check_call_status(); } else { + ZEPHIR_CPY_WRT(&basePath, attachmentName); + } + if (zephir_is_true(attachment)) { + if ((zephir_function_exists_ex(ZEND_STRL("mb_detect_encoding")) == SUCCESS)) { + ZEPHIR_CALL_FUNCTION(&_0$$6, "mb_detect_order", NULL, 358); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&basePathEncoding, "mb_detect_encoding", NULL, 323, &basePath, &_0$$6, &__$true); + zephir_check_call_status(); } - zephir_memory_observe(&cached); - zephir_read_property_zval(&cached, this_ptr, &collection, PH_NOISY_CC); - if (Z_TYPE_P(&cached) == IS_NULL) { - ZEPHIR_CALL_METHOD(&contentType, this_ptr, "getcontenttype", NULL, 0); + ZEPHIR_INIT_VAR(&_1$$5); + ZVAL_STRING(&_1$$5, "Content-Description: File Transfer"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setrawheader", NULL, 0, &_1$$5); zephir_check_call_status(); - _0$$3 = Z_TYPE_P(&contentType) == IS_STRING; - if (_0$$3) { - ZEPHIR_INIT_VAR(&_1$$3); - ZVAL_STRING(&_1$$3, "json"); - ZEPHIR_CALL_FUNCTION(&_2$$3, "stripos", NULL, 348, &contentType, &_1$$3); + ZEPHIR_INIT_NVAR(&_1$$5); + ZVAL_STRING(&_1$$5, "Content-Type: application/octet-stream"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setrawheader", NULL, 0, &_1$$5); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_1$$5); + ZVAL_STRING(&_1$$5, "Content-Transfer-Encoding: binary"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setrawheader", NULL, 0, &_1$$5); + zephir_check_call_status(); + if (!ZEPHIR_IS_STRING(&basePathEncoding, "ASCII")) { + ZEPHIR_CALL_FUNCTION(&_2$$7, "rawurlencode", NULL, 327, &basePath); zephir_check_call_status(); - _3$$3 = !ZEPHIR_IS_FALSE(&_2$$3); - if (!(_3$$3)) { - ZEPHIR_INIT_NVAR(&_1$$3); - ZVAL_STRING(&_1$$3, "multipart/form-data"); - ZEPHIR_CALL_FUNCTION(&_4$$3, "stripos", NULL, 348, &contentType, &_1$$3); - zephir_check_call_status(); - _3$$3 = !ZEPHIR_IS_FALSE_IDENTICAL(&_4$$3); - } - _0$$3 = _3$$3; - } - if (_0$$3) { - ZEPHIR_INIT_VAR(&_5$$4); - ZVAL_STRING(&_5$$4, "json"); - ZEPHIR_CALL_FUNCTION(&_6$$4, "stripos", NULL, 348, &contentType, &_5$$4); + ZEPHIR_CPY_WRT(&basePath, &_2$$7); + ZEPHIR_INIT_VAR(&_3$$7); + zephir_fast_strtolower(&_3$$7, &basePathEncoding); + ZEPHIR_INIT_VAR(&_4$$7); + ZEPHIR_CONCAT_SVSVSV(&_4$$7, "Content-Disposition: attachment; filename=", &basePath, "; filename*=", &_3$$7, "''", &basePath); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setrawheader", NULL, 0, &_4$$7); zephir_check_call_status(); - if (!ZEPHIR_IS_FALSE(&_6$$4)) { - ZVAL_BOOL(&_7$$5, 1); - ZEPHIR_CALL_METHOD(&cached, this_ptr, "getjsonrawbody", NULL, 0, &_7$$5); - zephir_check_call_status(); - } - ZEPHIR_INIT_NVAR(&_5$$4); - ZVAL_STRING(&_5$$4, "multipart/form-data"); - ZEPHIR_CALL_FUNCTION(&_8$$4, "stripos", NULL, 348, &contentType, &_5$$4); + } else { + ZEPHIR_INIT_VAR(&_5$$8); + ZVAL_STRING(&_5$$8, "\15\17\\\""); + ZEPHIR_CALL_FUNCTION(&_6$$8, "addcslashes", NULL, 215, &basePath, &_5$$8); zephir_check_call_status(); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_8$$4)) { - ZEPHIR_CALL_METHOD(&cached, this_ptr, "getformdata", NULL, 349); - zephir_check_call_status(); + ZEPHIR_CPY_WRT(&basePath, &_6$$8); + ZEPHIR_INIT_VAR(&_7$$8); + ZEPHIR_CONCAT_SVS(&_7$$8, "Content-Disposition: attachment; filename=\"", &basePath, "\""); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setrawheader", NULL, 0, &_7$$8); + zephir_check_call_status(); + } + } + zephir_update_property_zval(this_ptr, ZEND_STRL("file"), &filePath); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Http_Response, setHeader) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, *value, value_sub, _0; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_ZVAL(value) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &name_param, &value); + zephir_get_strval(&name, name_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &name, value); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Http_Response, setHeaders) +{ + zend_string *_3; + zend_ulong _2; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *headers, headers_sub, data, name, value, *_0, _1, _4$$3, _5$$4; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&headers_sub); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(headers, phalcon_http_response_headersinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &headers); + ZEPHIR_CALL_METHOD(&data, headers, "toarray", NULL, 0); + zephir_check_call_status(); + zephir_is_iterable(&data, 0, "phalcon/Http/Response.zep", 628); + if (Z_TYPE_P(&data) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&name); + if (_3 != NULL) { + ZVAL_STR_COPY(&name, _3); + } else { + ZVAL_LONG(&name, _2); } - if (Z_TYPE_P(&cached) != IS_ARRAY) { - ZEPHIR_INIT_NVAR(&cached); - array_init(&cached); + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _0); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_4$$3, "set", NULL, 0, &name, &value); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_1, &data, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_1)) { + break; } - } else { - ZEPHIR_INIT_NVAR(&cached); - array_init(&cached); - ZEPHIR_CALL_METHOD(&_9$$8, this_ptr, "getrawbody", NULL, 0); + ZEPHIR_CALL_METHOD(&name, &data, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_MAKE_REF(&cached); - ZEPHIR_CALL_FUNCTION(NULL, "parse_str", NULL, 350, &_9$$8, &cached); - ZEPHIR_UNREF(&cached); + ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_5$$4, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_5$$4, "set", NULL, 0, &name, &value); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); zephir_check_call_status(); } - zephir_update_property_zval_zval(this_ptr, &collection, &cached); } - if (notAllowEmpty) { - ZVAL_BOOL(&_10, 1); + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&name); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Http_Response, setJsonContent) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long jsonOptions, depth, ZEPHIR_LAST_CALL_STATUS; + zval *content, content_sub, *jsonOptions_param = NULL, *depth_param = NULL, _0, _1, _2, _3, _4; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&content_sub); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_ZVAL(content) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(jsonOptions) + Z_PARAM_LONG(depth) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &content, &jsonOptions_param, &depth_param); + if (!jsonOptions_param) { + jsonOptions = 0; } else { - ZVAL_BOOL(&_10, 0); - } - if (noRecursive) { - ZVAL_BOOL(&_11, 1); + } + if (!depth_param) { + depth = 512; } else { - ZVAL_BOOL(&_11, 0); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "gethelper", NULL, 333, &cached, &name, filters, defaultValue, &_10, &_11); + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "application/json"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setcontenttype", NULL, 0, &_0); zephir_check_call_status(); - RETURN_MM(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("encode"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_3, jsonOptions); + ZVAL_LONG(&_4, depth); + ZEPHIR_CALL_METHOD(&_2, &_1, "__invoke", NULL, 0, content, &_3, &_4); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setcontent", NULL, 0, &_2); + zephir_check_call_status(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Request, getFormData) +static PHP_METHOD(Phalcon_Http_Response, setLastModified) { - zval dataset, headers$$3, headers$$25; - zval boundary, matches, _0, _1, _2, _3, bodyParts, _4, _5, _6, _7, bodyPart, *_8, _9, splited$$3, _10$$3, _11$$3, headerParts$$3, headerPart$$3, _12$$3, _13$$3, *_14$$3, _15$$3, _67$$3, _68$$3, _69$$3, _16$$5, _17$$5, exploded$$5, headerName$$5, headerValue$$5, _18$$5, _19$$5, _20$$5, _21$$5, _22$$5, explodedHeader$$7, part$$7, *_23$$7, _24$$7, _25$$8, _26$$8, _27$$8, explodedPart$$9, namePart$$9, valuePart$$9, _29$$9, _30$$9, _31$$9, _32$$9, _33$$9, _34$$11, _35$$11, _36$$11, explodedPart$$12, namePart$$12, valuePart$$12, _37$$12, _38$$12, _39$$12, _40$$12, _41$$12, _42$$15, _43$$15, exploded$$15, headerName$$15, headerValue$$15, _44$$15, _45$$15, _46$$15, _47$$15, _48$$15, explodedHeader$$17, part$$17, *_49$$17, _50$$17, _51$$18, _52$$18, _53$$18, explodedPart$$19, namePart$$19, valuePart$$19, _54$$19, _55$$19, _56$$19, _57$$19, _58$$19, _59$$21, _60$$21, _61$$21, explodedPart$$22, namePart$$22, valuePart$$22, _62$$22, _63$$22, _64$$22, _65$$22, _66$$22, splited$$25, _70$$25, _71$$25, headerParts$$25, headerPart$$25, _72$$25, _73$$25, *_74$$25, _75$$25, _126$$25, _127$$25, _128$$25, _76$$27, _77$$27, exploded$$27, headerName$$27, headerValue$$27, _78$$27, _79$$27, _80$$27, _81$$27, _82$$27, explodedHeader$$29, part$$29, *_83$$29, _84$$29, _85$$30, _86$$30, _87$$30, explodedPart$$31, namePart$$31, valuePart$$31, _88$$31, _89$$31, _90$$31, _91$$31, _92$$31, _93$$33, _94$$33, _95$$33, explodedPart$$34, namePart$$34, valuePart$$34, _96$$34, _97$$34, _98$$34, _99$$34, _100$$34, _101$$37, _102$$37, exploded$$37, headerName$$37, headerValue$$37, _103$$37, _104$$37, _105$$37, _106$$37, _107$$37, explodedHeader$$39, part$$39, *_108$$39, _109$$39, _110$$40, _111$$40, _112$$40, explodedPart$$41, namePart$$41, valuePart$$41, _113$$41, _114$$41, _115$$41, _116$$41, _117$$41, _118$$43, _119$$43, _120$$43, explodedPart$$44, namePart$$44, valuePart$$44, _121$$44, _122$$44, _123$$44, _124$$44, _125$$44; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_28 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zval *datetime, datetime_sub, date, _0, _1, _2, _3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&boundary); - ZVAL_UNDEF(&matches); + ZVAL_UNDEF(&datetime_sub); + ZVAL_UNDEF(&date); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&bodyParts); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&bodyPart); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&splited$$3); - ZVAL_UNDEF(&_10$$3); - ZVAL_UNDEF(&_11$$3); - ZVAL_UNDEF(&headerParts$$3); - ZVAL_UNDEF(&headerPart$$3); - ZVAL_UNDEF(&_12$$3); - ZVAL_UNDEF(&_13$$3); - ZVAL_UNDEF(&_15$$3); - ZVAL_UNDEF(&_67$$3); - ZVAL_UNDEF(&_68$$3); - ZVAL_UNDEF(&_69$$3); - ZVAL_UNDEF(&_16$$5); - ZVAL_UNDEF(&_17$$5); - ZVAL_UNDEF(&exploded$$5); - ZVAL_UNDEF(&headerName$$5); - ZVAL_UNDEF(&headerValue$$5); - ZVAL_UNDEF(&_18$$5); - ZVAL_UNDEF(&_19$$5); - ZVAL_UNDEF(&_20$$5); - ZVAL_UNDEF(&_21$$5); - ZVAL_UNDEF(&_22$$5); - ZVAL_UNDEF(&explodedHeader$$7); - ZVAL_UNDEF(&part$$7); - ZVAL_UNDEF(&_24$$7); - ZVAL_UNDEF(&_25$$8); - ZVAL_UNDEF(&_26$$8); - ZVAL_UNDEF(&_27$$8); - ZVAL_UNDEF(&explodedPart$$9); - ZVAL_UNDEF(&namePart$$9); - ZVAL_UNDEF(&valuePart$$9); - ZVAL_UNDEF(&_29$$9); - ZVAL_UNDEF(&_30$$9); - ZVAL_UNDEF(&_31$$9); - ZVAL_UNDEF(&_32$$9); - ZVAL_UNDEF(&_33$$9); - ZVAL_UNDEF(&_34$$11); - ZVAL_UNDEF(&_35$$11); - ZVAL_UNDEF(&_36$$11); - ZVAL_UNDEF(&explodedPart$$12); - ZVAL_UNDEF(&namePart$$12); - ZVAL_UNDEF(&valuePart$$12); - ZVAL_UNDEF(&_37$$12); - ZVAL_UNDEF(&_38$$12); - ZVAL_UNDEF(&_39$$12); - ZVAL_UNDEF(&_40$$12); - ZVAL_UNDEF(&_41$$12); - ZVAL_UNDEF(&_42$$15); - ZVAL_UNDEF(&_43$$15); - ZVAL_UNDEF(&exploded$$15); - ZVAL_UNDEF(&headerName$$15); - ZVAL_UNDEF(&headerValue$$15); - ZVAL_UNDEF(&_44$$15); - ZVAL_UNDEF(&_45$$15); - ZVAL_UNDEF(&_46$$15); - ZVAL_UNDEF(&_47$$15); - ZVAL_UNDEF(&_48$$15); - ZVAL_UNDEF(&explodedHeader$$17); - ZVAL_UNDEF(&part$$17); - ZVAL_UNDEF(&_50$$17); - ZVAL_UNDEF(&_51$$18); - ZVAL_UNDEF(&_52$$18); - ZVAL_UNDEF(&_53$$18); - ZVAL_UNDEF(&explodedPart$$19); - ZVAL_UNDEF(&namePart$$19); - ZVAL_UNDEF(&valuePart$$19); - ZVAL_UNDEF(&_54$$19); - ZVAL_UNDEF(&_55$$19); - ZVAL_UNDEF(&_56$$19); - ZVAL_UNDEF(&_57$$19); - ZVAL_UNDEF(&_58$$19); - ZVAL_UNDEF(&_59$$21); - ZVAL_UNDEF(&_60$$21); - ZVAL_UNDEF(&_61$$21); - ZVAL_UNDEF(&explodedPart$$22); - ZVAL_UNDEF(&namePart$$22); - ZVAL_UNDEF(&valuePart$$22); - ZVAL_UNDEF(&_62$$22); - ZVAL_UNDEF(&_63$$22); - ZVAL_UNDEF(&_64$$22); - ZVAL_UNDEF(&_65$$22); - ZVAL_UNDEF(&_66$$22); - ZVAL_UNDEF(&splited$$25); - ZVAL_UNDEF(&_70$$25); - ZVAL_UNDEF(&_71$$25); - ZVAL_UNDEF(&headerParts$$25); - ZVAL_UNDEF(&headerPart$$25); - ZVAL_UNDEF(&_72$$25); - ZVAL_UNDEF(&_73$$25); - ZVAL_UNDEF(&_75$$25); - ZVAL_UNDEF(&_126$$25); - ZVAL_UNDEF(&_127$$25); - ZVAL_UNDEF(&_128$$25); - ZVAL_UNDEF(&_76$$27); - ZVAL_UNDEF(&_77$$27); - ZVAL_UNDEF(&exploded$$27); - ZVAL_UNDEF(&headerName$$27); - ZVAL_UNDEF(&headerValue$$27); - ZVAL_UNDEF(&_78$$27); - ZVAL_UNDEF(&_79$$27); - ZVAL_UNDEF(&_80$$27); - ZVAL_UNDEF(&_81$$27); - ZVAL_UNDEF(&_82$$27); - ZVAL_UNDEF(&explodedHeader$$29); - ZVAL_UNDEF(&part$$29); - ZVAL_UNDEF(&_84$$29); - ZVAL_UNDEF(&_85$$30); - ZVAL_UNDEF(&_86$$30); - ZVAL_UNDEF(&_87$$30); - ZVAL_UNDEF(&explodedPart$$31); - ZVAL_UNDEF(&namePart$$31); - ZVAL_UNDEF(&valuePart$$31); - ZVAL_UNDEF(&_88$$31); - ZVAL_UNDEF(&_89$$31); - ZVAL_UNDEF(&_90$$31); - ZVAL_UNDEF(&_91$$31); - ZVAL_UNDEF(&_92$$31); - ZVAL_UNDEF(&_93$$33); - ZVAL_UNDEF(&_94$$33); - ZVAL_UNDEF(&_95$$33); - ZVAL_UNDEF(&explodedPart$$34); - ZVAL_UNDEF(&namePart$$34); - ZVAL_UNDEF(&valuePart$$34); - ZVAL_UNDEF(&_96$$34); - ZVAL_UNDEF(&_97$$34); - ZVAL_UNDEF(&_98$$34); - ZVAL_UNDEF(&_99$$34); - ZVAL_UNDEF(&_100$$34); - ZVAL_UNDEF(&_101$$37); - ZVAL_UNDEF(&_102$$37); - ZVAL_UNDEF(&exploded$$37); - ZVAL_UNDEF(&headerName$$37); - ZVAL_UNDEF(&headerValue$$37); - ZVAL_UNDEF(&_103$$37); - ZVAL_UNDEF(&_104$$37); - ZVAL_UNDEF(&_105$$37); - ZVAL_UNDEF(&_106$$37); - ZVAL_UNDEF(&_107$$37); - ZVAL_UNDEF(&explodedHeader$$39); - ZVAL_UNDEF(&part$$39); - ZVAL_UNDEF(&_109$$39); - ZVAL_UNDEF(&_110$$40); - ZVAL_UNDEF(&_111$$40); - ZVAL_UNDEF(&_112$$40); - ZVAL_UNDEF(&explodedPart$$41); - ZVAL_UNDEF(&namePart$$41); - ZVAL_UNDEF(&valuePart$$41); - ZVAL_UNDEF(&_113$$41); - ZVAL_UNDEF(&_114$$41); - ZVAL_UNDEF(&_115$$41); - ZVAL_UNDEF(&_116$$41); - ZVAL_UNDEF(&_117$$41); - ZVAL_UNDEF(&_118$$43); - ZVAL_UNDEF(&_119$$43); - ZVAL_UNDEF(&_120$$43); - ZVAL_UNDEF(&explodedPart$$44); - ZVAL_UNDEF(&namePart$$44); - ZVAL_UNDEF(&valuePart$$44); - ZVAL_UNDEF(&_121$$44); - ZVAL_UNDEF(&_122$$44); - ZVAL_UNDEF(&_123$$44); - ZVAL_UNDEF(&_124$$44); - ZVAL_UNDEF(&_125$$44); - ZVAL_UNDEF(&dataset); - ZVAL_UNDEF(&headers$$3); - ZVAL_UNDEF(&headers$$25); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(datetime, php_date_get_date_ce()) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getcontenttype", NULL, 0); - zephir_check_call_status(); + zephir_fetch_params(1, 1, 0, &datetime); + ZEPHIR_INIT_VAR(&date); + if (zephir_clone(&date, datetime) == FAILURE) { + RETURN_MM(); + } + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, php_date_get_timezone_ce()); ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "/boundary=(.*)$/is"); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "/boundary=(.*)$/is"); - zephir_preg_match(&_2, &_3, &_0, &matches, 0, 0 , 0 ); - zephir_memory_observe(&boundary); - zephir_array_fetch_long(&boundary, &matches, 1, PH_NOISY, "phalcon/Http/Request.zep", 1771); - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, "/"); - ZEPHIR_CALL_FUNCTION(&_5, "preg_quote", NULL, 351, &boundary, &_4); + ZVAL_STRING(&_1, "UTC"); + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0, &_1); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_6); - ZEPHIR_CONCAT_SVS(&_6, "/\\R?-+", &_5, "/s"); - ZEPHIR_CALL_METHOD(&_7, this_ptr, "getrawbody", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &date, "settimezone", NULL, 0, &_0); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&bodyParts, "preg_split", NULL, 70, &_6, &_7); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "D, d M Y H:i:s"); + ZEPHIR_CALL_METHOD(&_2, &date, "format", NULL, 0, &_1); zephir_check_call_status(); - ZEPHIR_MAKE_REF(&bodyParts); - ZEPHIR_CALL_FUNCTION(NULL, "array_pop", NULL, 352, &bodyParts); - ZEPHIR_UNREF(&bodyParts); + ZEPHIR_INIT_VAR(&_3); + ZEPHIR_CONCAT_VS(&_3, &_2, " GMT"); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "Last-Modified"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, &_1, &_3); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&dataset); - array_init(&dataset); - zephir_is_iterable(&bodyParts, 0, "phalcon/Http/Request.zep", 1832); - if (Z_TYPE_P(&bodyParts) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&bodyParts), _8) + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Http_Response, setNotModified) +{ + zval _0, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZVAL_LONG(&_0, 304); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "Not modified"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setstatuscode", NULL, 0, &_0, &_1); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Http_Response, setStatusCode) +{ + zend_bool _6$$3, _11$$5; + zend_string *_5; + zend_ulong _4; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_9 = NULL; + zval message, _17, _20; + zval *code_param = NULL, *message_param = NULL, currentHeadersRaw, key, statusCodes, defaultMessage, _0, _1, *_2, _3, _15, _16, _18, _19, _21, _7$$3, _8$$3, _10$$4, _12$$5, _13$$5, _14$$6; + zend_long code, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(¤tHeadersRaw); + ZVAL_UNDEF(&key); + ZVAL_UNDEF(&statusCodes); + ZVAL_UNDEF(&defaultMessage); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_15); + ZVAL_UNDEF(&_16); + ZVAL_UNDEF(&_18); + ZVAL_UNDEF(&_19); + ZVAL_UNDEF(&_21); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_10$$4); + ZVAL_UNDEF(&_12$$5); + ZVAL_UNDEF(&_13$$5); + ZVAL_UNDEF(&_14$$6); + ZVAL_UNDEF(&message); + ZVAL_UNDEF(&_17); + ZVAL_UNDEF(&_20); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_LONG(code) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(message) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &code_param, &message_param); + if (!message_param) { + ZEPHIR_INIT_VAR(&message); + } else { + zephir_get_strval(&message, message_param); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(¤tHeadersRaw, &_0, "toarray", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1); + zephir_is_iterable(¤tHeadersRaw, 0, "phalcon/Http/Response.zep", 717); + if (Z_TYPE_P(¤tHeadersRaw) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(¤tHeadersRaw), _4, _5, _2) { - ZEPHIR_INIT_NVAR(&bodyPart); - ZVAL_COPY(&bodyPart, _8); - if (ZEPHIR_IS_EMPTY(&bodyPart)) { - continue; - } - ZEPHIR_INIT_NVAR(&_10$$3); - ZVAL_STRING(&_10$$3, "/\\R\\R/"); - ZVAL_LONG(&_11$$3, 2); - ZEPHIR_CALL_FUNCTION(&splited$$3, "preg_split", NULL, 70, &_10$$3, &bodyPart, &_11$$3); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&headers$$3); - array_init(&headers$$3); - zephir_array_fetch_long(&_12$$3, &splited$$3, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1793); - ZEPHIR_INIT_NVAR(&_10$$3); - ZVAL_STRING(&_10$$3, "/\\R/s"); - ZVAL_LONG(&_11$$3, -1); - ZVAL_LONG(&_13$$3, 1); - ZEPHIR_CALL_FUNCTION(&headerParts$$3, "preg_split", NULL, 70, &_10$$3, &_12$$3, &_11$$3, &_13$$3); - zephir_check_call_status(); - zephir_is_iterable(&headerParts$$3, 0, "phalcon/Http/Request.zep", 1829); - if (Z_TYPE_P(&headerParts$$3) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&headerParts$$3), _14$$3) - { - ZEPHIR_INIT_NVAR(&headerPart$$3); - ZVAL_COPY(&headerPart$$3, _14$$3); - ZEPHIR_INIT_NVAR(&_16$$5); - ZVAL_STRING(&_16$$5, ":"); - ZEPHIR_INIT_NVAR(&_17$$5); - zephir_fast_strpos(&_17$$5, &headerPart$$3, &_16$$5, 0 ); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_17$$5)) { - continue; - } - ZEPHIR_INIT_NVAR(&exploded$$5); - zephir_fast_explode_str(&exploded$$5, SL(":"), &headerPart$$3, 2 ); - ZEPHIR_INIT_NVAR(&_18$$5); - zephir_array_fetch_long(&_19$$5, &exploded$$5, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1803); - zephir_fast_trim(&_18$$5, &_19$$5, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&headerName$$5); - zephir_fast_strtolower(&headerName$$5, &_18$$5); - zephir_array_fetch_long(&_20$$5, &exploded$$5, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1804); - ZEPHIR_INIT_NVAR(&headerValue$$5); - zephir_fast_trim(&headerValue$$5, &_20$$5, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_21$$5); - ZVAL_STRING(&_21$$5, ";"); - ZEPHIR_INIT_NVAR(&_22$$5); - zephir_fast_strpos(&_22$$5, &headerValue$$5, &_21$$5, 0 ); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_22$$5)) { - ZEPHIR_INIT_NVAR(&explodedHeader$$7); - zephir_fast_explode_str(&explodedHeader$$7, SL(";"), &headerValue$$5, LONG_MAX); - zephir_is_iterable(&explodedHeader$$7, 0, "phalcon/Http/Request.zep", 1824); - if (Z_TYPE_P(&explodedHeader$$7) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&explodedHeader$$7), _23$$7) - { - ZEPHIR_INIT_NVAR(&part$$7); - ZVAL_COPY(&part$$7, _23$$7); - ZEPHIR_INIT_NVAR(&_25$$8); - zephir_fast_trim(&_25$$8, &part$$7, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_26$$8); - ZVAL_STRING(&_26$$8, "/\"/"); - ZEPHIR_INIT_NVAR(&_27$$8); - ZVAL_STRING(&_27$$8, ""); - ZEPHIR_CALL_FUNCTION(&part$$7, "preg_replace", &_28, 41, &_26$$8, &_27$$8, &_25$$8); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_26$$8); - ZVAL_STRING(&_26$$8, "="); - ZEPHIR_INIT_NVAR(&_27$$8); - zephir_fast_strpos(&_27$$8, &part$$7, &_26$$8, 0 ); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_27$$8)) { - ZEPHIR_INIT_NVAR(&explodedPart$$9); - zephir_fast_explode_str(&explodedPart$$9, SL("="), &part$$7, 2 ); - ZEPHIR_INIT_NVAR(&_29$$9); - zephir_array_fetch_long(&_30$$9, &explodedPart$$9, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1816); - zephir_fast_trim(&_29$$9, &_30$$9, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&namePart$$9); - zephir_fast_strtolower(&namePart$$9, &_29$$9); - ZEPHIR_INIT_NVAR(&_31$$9); - zephir_array_fetch_long(&_32$$9, &explodedPart$$9, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1817); - zephir_fast_trim(&_31$$9, &_32$$9, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_33$$9); - ZVAL_STRING(&_33$$9, "\""); - ZEPHIR_INIT_NVAR(&valuePart$$9); - zephir_fast_trim(&valuePart$$9, &_31$$9, &_33$$9, ZEPHIR_TRIM_BOTH); - zephir_array_update_multi(&headers$$3, &valuePart$$9, SL("zz"), 2, &headerName$$5, &namePart$$9); - } else { - zephir_array_update_multi(&headers$$3, &part$$7, SL("za"), 2, &headerName$$5); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &explodedHeader$$7, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_24$$7, &explodedHeader$$7, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_24$$7)) { - break; - } - ZEPHIR_CALL_METHOD(&part$$7, &explodedHeader$$7, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_34$$11); - zephir_fast_trim(&_34$$11, &part$$7, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_35$$11); - ZVAL_STRING(&_35$$11, "/\"/"); - ZEPHIR_INIT_NVAR(&_36$$11); - ZVAL_STRING(&_36$$11, ""); - ZEPHIR_CALL_FUNCTION(&part$$7, "preg_replace", &_28, 41, &_35$$11, &_36$$11, &_34$$11); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_35$$11); - ZVAL_STRING(&_35$$11, "="); - ZEPHIR_INIT_NVAR(&_36$$11); - zephir_fast_strpos(&_36$$11, &part$$7, &_35$$11, 0 ); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_36$$11)) { - ZEPHIR_INIT_NVAR(&explodedPart$$12); - zephir_fast_explode_str(&explodedPart$$12, SL("="), &part$$7, 2 ); - ZEPHIR_INIT_NVAR(&_37$$12); - zephir_array_fetch_long(&_38$$12, &explodedPart$$12, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1816); - zephir_fast_trim(&_37$$12, &_38$$12, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&namePart$$12); - zephir_fast_strtolower(&namePart$$12, &_37$$12); - ZEPHIR_INIT_NVAR(&_39$$12); - zephir_array_fetch_long(&_40$$12, &explodedPart$$12, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1817); - zephir_fast_trim(&_39$$12, &_40$$12, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_41$$12); - ZVAL_STRING(&_41$$12, "\""); - ZEPHIR_INIT_NVAR(&valuePart$$12); - zephir_fast_trim(&valuePart$$12, &_39$$12, &_41$$12, ZEPHIR_TRIM_BOTH); - zephir_array_update_multi(&headers$$3, &valuePart$$12, SL("zz"), 2, &headerName$$5, &namePart$$12); - } else { - zephir_array_update_multi(&headers$$3, &part$$7, SL("za"), 2, &headerName$$5); - } - ZEPHIR_CALL_METHOD(NULL, &explodedHeader$$7, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&part$$7); - } else { - zephir_array_update_zval(&headers$$3, &headerName$$5, &headerValue$$5, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); + ZEPHIR_INIT_NVAR(&key); + if (_5 != NULL) { + ZVAL_STR_COPY(&key, _5); } else { - ZEPHIR_CALL_METHOD(NULL, &headerParts$$3, "rewind", NULL, 0); + ZVAL_LONG(&key, _4); + } + ZEPHIR_INIT_NVAR(&_1); + ZVAL_COPY(&_1, _2); + _6$$3 = Z_TYPE_P(&key) == IS_STRING; + if (_6$$3) { + ZEPHIR_INIT_NVAR(&_7$$3); + ZVAL_STRING(&_7$$3, "HTTP/"); + ZEPHIR_CALL_FUNCTION(&_8$$3, "strstr", &_9, 355, &key, &_7$$3); + zephir_check_call_status(); + _6$$3 = zephir_is_true(&_8$$3); + } + if (_6$$3) { + zephir_read_property(&_10$$4, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_10$$4, "remove", NULL, 0, &key); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_15$$3, &headerParts$$3, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_15$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&headerPart$$3, &headerParts$$3, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_42$$15); - ZVAL_STRING(&_42$$15, ":"); - ZEPHIR_INIT_NVAR(&_43$$15); - zephir_fast_strpos(&_43$$15, &headerPart$$3, &_42$$15, 0 ); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_43$$15)) { - continue; - } - ZEPHIR_INIT_NVAR(&exploded$$15); - zephir_fast_explode_str(&exploded$$15, SL(":"), &headerPart$$3, 2 ); - ZEPHIR_INIT_NVAR(&_44$$15); - zephir_array_fetch_long(&_45$$15, &exploded$$15, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1803); - zephir_fast_trim(&_44$$15, &_45$$15, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&headerName$$15); - zephir_fast_strtolower(&headerName$$15, &_44$$15); - zephir_array_fetch_long(&_46$$15, &exploded$$15, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1804); - ZEPHIR_INIT_NVAR(&headerValue$$15); - zephir_fast_trim(&headerValue$$15, &_46$$15, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_47$$15); - ZVAL_STRING(&_47$$15, ";"); - ZEPHIR_INIT_NVAR(&_48$$15); - zephir_fast_strpos(&_48$$15, &headerValue$$15, &_47$$15, 0 ); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_48$$15)) { - ZEPHIR_INIT_NVAR(&explodedHeader$$17); - zephir_fast_explode_str(&explodedHeader$$17, SL(";"), &headerValue$$15, LONG_MAX); - zephir_is_iterable(&explodedHeader$$17, 0, "phalcon/Http/Request.zep", 1824); - if (Z_TYPE_P(&explodedHeader$$17) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&explodedHeader$$17), _49$$17) - { - ZEPHIR_INIT_NVAR(&part$$17); - ZVAL_COPY(&part$$17, _49$$17); - ZEPHIR_INIT_NVAR(&_51$$18); - zephir_fast_trim(&_51$$18, &part$$17, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_52$$18); - ZVAL_STRING(&_52$$18, "/\"/"); - ZEPHIR_INIT_NVAR(&_53$$18); - ZVAL_STRING(&_53$$18, ""); - ZEPHIR_CALL_FUNCTION(&part$$17, "preg_replace", &_28, 41, &_52$$18, &_53$$18, &_51$$18); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_52$$18); - ZVAL_STRING(&_52$$18, "="); - ZEPHIR_INIT_NVAR(&_53$$18); - zephir_fast_strpos(&_53$$18, &part$$17, &_52$$18, 0 ); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_53$$18)) { - ZEPHIR_INIT_NVAR(&explodedPart$$19); - zephir_fast_explode_str(&explodedPart$$19, SL("="), &part$$17, 2 ); - ZEPHIR_INIT_NVAR(&_54$$19); - zephir_array_fetch_long(&_55$$19, &explodedPart$$19, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1816); - zephir_fast_trim(&_54$$19, &_55$$19, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&namePart$$19); - zephir_fast_strtolower(&namePart$$19, &_54$$19); - ZEPHIR_INIT_NVAR(&_56$$19); - zephir_array_fetch_long(&_57$$19, &explodedPart$$19, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1817); - zephir_fast_trim(&_56$$19, &_57$$19, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_58$$19); - ZVAL_STRING(&_58$$19, "\""); - ZEPHIR_INIT_NVAR(&valuePart$$19); - zephir_fast_trim(&valuePart$$19, &_56$$19, &_58$$19, ZEPHIR_TRIM_BOTH); - zephir_array_update_multi(&headers$$3, &valuePart$$19, SL("zz"), 2, &headerName$$15, &namePart$$19); - } else { - zephir_array_update_multi(&headers$$3, &part$$17, SL("za"), 2, &headerName$$15); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &explodedHeader$$17, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_50$$17, &explodedHeader$$17, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_50$$17)) { - break; - } - ZEPHIR_CALL_METHOD(&part$$17, &explodedHeader$$17, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_59$$21); - zephir_fast_trim(&_59$$21, &part$$17, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_60$$21); - ZVAL_STRING(&_60$$21, "/\"/"); - ZEPHIR_INIT_NVAR(&_61$$21); - ZVAL_STRING(&_61$$21, ""); - ZEPHIR_CALL_FUNCTION(&part$$17, "preg_replace", &_28, 41, &_60$$21, &_61$$21, &_59$$21); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_60$$21); - ZVAL_STRING(&_60$$21, "="); - ZEPHIR_INIT_NVAR(&_61$$21); - zephir_fast_strpos(&_61$$21, &part$$17, &_60$$21, 0 ); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_61$$21)) { - ZEPHIR_INIT_NVAR(&explodedPart$$22); - zephir_fast_explode_str(&explodedPart$$22, SL("="), &part$$17, 2 ); - ZEPHIR_INIT_NVAR(&_62$$22); - zephir_array_fetch_long(&_63$$22, &explodedPart$$22, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1816); - zephir_fast_trim(&_62$$22, &_63$$22, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&namePart$$22); - zephir_fast_strtolower(&namePart$$22, &_62$$22); - ZEPHIR_INIT_NVAR(&_64$$22); - zephir_array_fetch_long(&_65$$22, &explodedPart$$22, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1817); - zephir_fast_trim(&_64$$22, &_65$$22, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_66$$22); - ZVAL_STRING(&_66$$22, "\""); - ZEPHIR_INIT_NVAR(&valuePart$$22); - zephir_fast_trim(&valuePart$$22, &_64$$22, &_66$$22, ZEPHIR_TRIM_BOTH); - zephir_array_update_multi(&headers$$3, &valuePart$$22, SL("zz"), 2, &headerName$$15, &namePart$$22); - } else { - zephir_array_update_multi(&headers$$3, &part$$17, SL("za"), 2, &headerName$$15); - } - ZEPHIR_CALL_METHOD(NULL, &explodedHeader$$17, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&part$$17); - } else { - zephir_array_update_zval(&headers$$3, &headerName$$15, &headerValue$$15, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &headerParts$$3, "next", NULL, 0); - zephir_check_call_status(); - } } - ZEPHIR_INIT_NVAR(&headerPart$$3); - zephir_array_fetch_long(&_67$$3, &splited$$3, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1829); - zephir_array_fetch_string(&_68$$3, &headers$$3, SL("content-disposition"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1829); - ZEPHIR_OBS_NVAR(&_69$$3); - zephir_array_fetch_string(&_69$$3, &_68$$3, SL("name"), PH_NOISY, "phalcon/Http/Request.zep", 1829); - zephir_array_update_zval(&dataset, &_69$$3, &_67$$3, PH_COPY | PH_SEPARATE); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &bodyParts, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, ¤tHeadersRaw, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_9, &bodyParts, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_3, ¤tHeadersRaw, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_9)) { + if (!zend_is_true(&_3)) { break; } - ZEPHIR_CALL_METHOD(&bodyPart, &bodyParts, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&key, ¤tHeadersRaw, "key", NULL, 0); zephir_check_call_status(); - if (ZEPHIR_IS_EMPTY(&bodyPart)) { - continue; + ZEPHIR_CALL_METHOD(&_1, ¤tHeadersRaw, "current", NULL, 0); + zephir_check_call_status(); + _11$$5 = Z_TYPE_P(&key) == IS_STRING; + if (_11$$5) { + ZEPHIR_INIT_NVAR(&_12$$5); + ZVAL_STRING(&_12$$5, "HTTP/"); + ZEPHIR_CALL_FUNCTION(&_13$$5, "strstr", &_9, 355, &key, &_12$$5); + zephir_check_call_status(); + _11$$5 = zephir_is_true(&_13$$5); } - ZEPHIR_INIT_NVAR(&_70$$25); - ZVAL_STRING(&_70$$25, "/\\R\\R/"); - ZVAL_LONG(&_71$$25, 2); - ZEPHIR_CALL_FUNCTION(&splited$$25, "preg_split", NULL, 70, &_70$$25, &bodyPart, &_71$$25); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&headers$$25); - array_init(&headers$$25); - zephir_array_fetch_long(&_72$$25, &splited$$25, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1793); - ZEPHIR_INIT_NVAR(&_70$$25); - ZVAL_STRING(&_70$$25, "/\\R/s"); - ZVAL_LONG(&_71$$25, -1); - ZVAL_LONG(&_73$$25, 1); - ZEPHIR_CALL_FUNCTION(&headerParts$$25, "preg_split", NULL, 70, &_70$$25, &_72$$25, &_71$$25, &_73$$25); - zephir_check_call_status(); - zephir_is_iterable(&headerParts$$25, 0, "phalcon/Http/Request.zep", 1829); - if (Z_TYPE_P(&headerParts$$25) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&headerParts$$25), _74$$25) - { - ZEPHIR_INIT_NVAR(&headerPart$$25); - ZVAL_COPY(&headerPart$$25, _74$$25); - ZEPHIR_INIT_NVAR(&_76$$27); - ZVAL_STRING(&_76$$27, ":"); - ZEPHIR_INIT_NVAR(&_77$$27); - zephir_fast_strpos(&_77$$27, &headerPart$$25, &_76$$27, 0 ); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_77$$27)) { - continue; - } - ZEPHIR_INIT_NVAR(&exploded$$27); - zephir_fast_explode_str(&exploded$$27, SL(":"), &headerPart$$25, 2 ); - ZEPHIR_INIT_NVAR(&_78$$27); - zephir_array_fetch_long(&_79$$27, &exploded$$27, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1803); - zephir_fast_trim(&_78$$27, &_79$$27, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&headerName$$27); - zephir_fast_strtolower(&headerName$$27, &_78$$27); - zephir_array_fetch_long(&_80$$27, &exploded$$27, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1804); - ZEPHIR_INIT_NVAR(&headerValue$$27); - zephir_fast_trim(&headerValue$$27, &_80$$27, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_81$$27); - ZVAL_STRING(&_81$$27, ";"); - ZEPHIR_INIT_NVAR(&_82$$27); - zephir_fast_strpos(&_82$$27, &headerValue$$27, &_81$$27, 0 ); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_82$$27)) { - ZEPHIR_INIT_NVAR(&explodedHeader$$29); - zephir_fast_explode_str(&explodedHeader$$29, SL(";"), &headerValue$$27, LONG_MAX); - zephir_is_iterable(&explodedHeader$$29, 0, "phalcon/Http/Request.zep", 1824); - if (Z_TYPE_P(&explodedHeader$$29) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&explodedHeader$$29), _83$$29) - { - ZEPHIR_INIT_NVAR(&part$$29); - ZVAL_COPY(&part$$29, _83$$29); - ZEPHIR_INIT_NVAR(&_85$$30); - zephir_fast_trim(&_85$$30, &part$$29, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_86$$30); - ZVAL_STRING(&_86$$30, "/\"/"); - ZEPHIR_INIT_NVAR(&_87$$30); - ZVAL_STRING(&_87$$30, ""); - ZEPHIR_CALL_FUNCTION(&part$$29, "preg_replace", &_28, 41, &_86$$30, &_87$$30, &_85$$30); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_86$$30); - ZVAL_STRING(&_86$$30, "="); - ZEPHIR_INIT_NVAR(&_87$$30); - zephir_fast_strpos(&_87$$30, &part$$29, &_86$$30, 0 ); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_87$$30)) { - ZEPHIR_INIT_NVAR(&explodedPart$$31); - zephir_fast_explode_str(&explodedPart$$31, SL("="), &part$$29, 2 ); - ZEPHIR_INIT_NVAR(&_88$$31); - zephir_array_fetch_long(&_89$$31, &explodedPart$$31, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1816); - zephir_fast_trim(&_88$$31, &_89$$31, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&namePart$$31); - zephir_fast_strtolower(&namePart$$31, &_88$$31); - ZEPHIR_INIT_NVAR(&_90$$31); - zephir_array_fetch_long(&_91$$31, &explodedPart$$31, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1817); - zephir_fast_trim(&_90$$31, &_91$$31, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_92$$31); - ZVAL_STRING(&_92$$31, "\""); - ZEPHIR_INIT_NVAR(&valuePart$$31); - zephir_fast_trim(&valuePart$$31, &_90$$31, &_92$$31, ZEPHIR_TRIM_BOTH); - zephir_array_update_multi(&headers$$25, &valuePart$$31, SL("zz"), 2, &headerName$$27, &namePart$$31); - } else { - zephir_array_update_multi(&headers$$25, &part$$29, SL("za"), 2, &headerName$$27); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &explodedHeader$$29, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_84$$29, &explodedHeader$$29, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_84$$29)) { - break; - } - ZEPHIR_CALL_METHOD(&part$$29, &explodedHeader$$29, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_93$$33); - zephir_fast_trim(&_93$$33, &part$$29, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_94$$33); - ZVAL_STRING(&_94$$33, "/\"/"); - ZEPHIR_INIT_NVAR(&_95$$33); - ZVAL_STRING(&_95$$33, ""); - ZEPHIR_CALL_FUNCTION(&part$$29, "preg_replace", &_28, 41, &_94$$33, &_95$$33, &_93$$33); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_94$$33); - ZVAL_STRING(&_94$$33, "="); - ZEPHIR_INIT_NVAR(&_95$$33); - zephir_fast_strpos(&_95$$33, &part$$29, &_94$$33, 0 ); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_95$$33)) { - ZEPHIR_INIT_NVAR(&explodedPart$$34); - zephir_fast_explode_str(&explodedPart$$34, SL("="), &part$$29, 2 ); - ZEPHIR_INIT_NVAR(&_96$$34); - zephir_array_fetch_long(&_97$$34, &explodedPart$$34, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1816); - zephir_fast_trim(&_96$$34, &_97$$34, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&namePart$$34); - zephir_fast_strtolower(&namePart$$34, &_96$$34); - ZEPHIR_INIT_NVAR(&_98$$34); - zephir_array_fetch_long(&_99$$34, &explodedPart$$34, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1817); - zephir_fast_trim(&_98$$34, &_99$$34, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_100$$34); - ZVAL_STRING(&_100$$34, "\""); - ZEPHIR_INIT_NVAR(&valuePart$$34); - zephir_fast_trim(&valuePart$$34, &_98$$34, &_100$$34, ZEPHIR_TRIM_BOTH); - zephir_array_update_multi(&headers$$25, &valuePart$$34, SL("zz"), 2, &headerName$$27, &namePart$$34); - } else { - zephir_array_update_multi(&headers$$25, &part$$29, SL("za"), 2, &headerName$$27); - } - ZEPHIR_CALL_METHOD(NULL, &explodedHeader$$29, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&part$$29); - } else { - zephir_array_update_zval(&headers$$25, &headerName$$27, &headerValue$$27, PH_COPY | PH_SEPARATE); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &headerParts$$25, "rewind", NULL, 0); + if (_11$$5) { + zephir_read_property(&_14$$6, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_14$$6, "remove", NULL, 0, &key); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_75$$25, &headerParts$$25, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_75$$25)) { - break; - } - ZEPHIR_CALL_METHOD(&headerPart$$25, &headerParts$$25, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_101$$37); - ZVAL_STRING(&_101$$37, ":"); - ZEPHIR_INIT_NVAR(&_102$$37); - zephir_fast_strpos(&_102$$37, &headerPart$$25, &_101$$37, 0 ); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_102$$37)) { - continue; - } - ZEPHIR_INIT_NVAR(&exploded$$37); - zephir_fast_explode_str(&exploded$$37, SL(":"), &headerPart$$25, 2 ); - ZEPHIR_INIT_NVAR(&_103$$37); - zephir_array_fetch_long(&_104$$37, &exploded$$37, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1803); - zephir_fast_trim(&_103$$37, &_104$$37, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&headerName$$37); - zephir_fast_strtolower(&headerName$$37, &_103$$37); - zephir_array_fetch_long(&_105$$37, &exploded$$37, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1804); - ZEPHIR_INIT_NVAR(&headerValue$$37); - zephir_fast_trim(&headerValue$$37, &_105$$37, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_106$$37); - ZVAL_STRING(&_106$$37, ";"); - ZEPHIR_INIT_NVAR(&_107$$37); - zephir_fast_strpos(&_107$$37, &headerValue$$37, &_106$$37, 0 ); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_107$$37)) { - ZEPHIR_INIT_NVAR(&explodedHeader$$39); - zephir_fast_explode_str(&explodedHeader$$39, SL(";"), &headerValue$$37, LONG_MAX); - zephir_is_iterable(&explodedHeader$$39, 0, "phalcon/Http/Request.zep", 1824); - if (Z_TYPE_P(&explodedHeader$$39) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&explodedHeader$$39), _108$$39) - { - ZEPHIR_INIT_NVAR(&part$$39); - ZVAL_COPY(&part$$39, _108$$39); - ZEPHIR_INIT_NVAR(&_110$$40); - zephir_fast_trim(&_110$$40, &part$$39, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_111$$40); - ZVAL_STRING(&_111$$40, "/\"/"); - ZEPHIR_INIT_NVAR(&_112$$40); - ZVAL_STRING(&_112$$40, ""); - ZEPHIR_CALL_FUNCTION(&part$$39, "preg_replace", &_28, 41, &_111$$40, &_112$$40, &_110$$40); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_111$$40); - ZVAL_STRING(&_111$$40, "="); - ZEPHIR_INIT_NVAR(&_112$$40); - zephir_fast_strpos(&_112$$40, &part$$39, &_111$$40, 0 ); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_112$$40)) { - ZEPHIR_INIT_NVAR(&explodedPart$$41); - zephir_fast_explode_str(&explodedPart$$41, SL("="), &part$$39, 2 ); - ZEPHIR_INIT_NVAR(&_113$$41); - zephir_array_fetch_long(&_114$$41, &explodedPart$$41, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1816); - zephir_fast_trim(&_113$$41, &_114$$41, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&namePart$$41); - zephir_fast_strtolower(&namePart$$41, &_113$$41); - ZEPHIR_INIT_NVAR(&_115$$41); - zephir_array_fetch_long(&_116$$41, &explodedPart$$41, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1817); - zephir_fast_trim(&_115$$41, &_116$$41, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_117$$41); - ZVAL_STRING(&_117$$41, "\""); - ZEPHIR_INIT_NVAR(&valuePart$$41); - zephir_fast_trim(&valuePart$$41, &_115$$41, &_117$$41, ZEPHIR_TRIM_BOTH); - zephir_array_update_multi(&headers$$25, &valuePart$$41, SL("zz"), 2, &headerName$$37, &namePart$$41); - } else { - zephir_array_update_multi(&headers$$25, &part$$39, SL("za"), 2, &headerName$$37); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &explodedHeader$$39, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_109$$39, &explodedHeader$$39, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_109$$39)) { - break; - } - ZEPHIR_CALL_METHOD(&part$$39, &explodedHeader$$39, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_118$$43); - zephir_fast_trim(&_118$$43, &part$$39, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_119$$43); - ZVAL_STRING(&_119$$43, "/\"/"); - ZEPHIR_INIT_NVAR(&_120$$43); - ZVAL_STRING(&_120$$43, ""); - ZEPHIR_CALL_FUNCTION(&part$$39, "preg_replace", &_28, 41, &_119$$43, &_120$$43, &_118$$43); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_119$$43); - ZVAL_STRING(&_119$$43, "="); - ZEPHIR_INIT_NVAR(&_120$$43); - zephir_fast_strpos(&_120$$43, &part$$39, &_119$$43, 0 ); - if (!ZEPHIR_IS_FALSE_IDENTICAL(&_120$$43)) { - ZEPHIR_INIT_NVAR(&explodedPart$$44); - zephir_fast_explode_str(&explodedPart$$44, SL("="), &part$$39, 2 ); - ZEPHIR_INIT_NVAR(&_121$$44); - zephir_array_fetch_long(&_122$$44, &explodedPart$$44, 0, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1816); - zephir_fast_trim(&_121$$44, &_122$$44, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&namePart$$44); - zephir_fast_strtolower(&namePart$$44, &_121$$44); - ZEPHIR_INIT_NVAR(&_123$$44); - zephir_array_fetch_long(&_124$$44, &explodedPart$$44, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1817); - zephir_fast_trim(&_123$$44, &_124$$44, NULL , ZEPHIR_TRIM_BOTH); - ZEPHIR_INIT_NVAR(&_125$$44); - ZVAL_STRING(&_125$$44, "\""); - ZEPHIR_INIT_NVAR(&valuePart$$44); - zephir_fast_trim(&valuePart$$44, &_123$$44, &_125$$44, ZEPHIR_TRIM_BOTH); - zephir_array_update_multi(&headers$$25, &valuePart$$44, SL("zz"), 2, &headerName$$37, &namePart$$44); - } else { - zephir_array_update_multi(&headers$$25, &part$$39, SL("za"), 2, &headerName$$37); - } - ZEPHIR_CALL_METHOD(NULL, &explodedHeader$$39, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&part$$39); - } else { - zephir_array_update_zval(&headers$$25, &headerName$$37, &headerValue$$37, PH_COPY | PH_SEPARATE); - } - ZEPHIR_CALL_METHOD(NULL, &headerParts$$25, "next", NULL, 0); - zephir_check_call_status(); - } } - ZEPHIR_INIT_NVAR(&headerPart$$25); - zephir_array_fetch_long(&_126$$25, &splited$$25, 1, PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1829); - zephir_array_fetch_string(&_127$$25, &headers$$25, SL("content-disposition"), PH_NOISY | PH_READONLY, "phalcon/Http/Request.zep", 1829); - ZEPHIR_OBS_NVAR(&_128$$25); - zephir_array_fetch_string(&_128$$25, &_127$$25, SL("name"), PH_NOISY, "phalcon/Http/Request.zep", 1829); - zephir_array_update_zval(&dataset, &_128$$25, &_126$$25, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &bodyParts, "next", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, ¤tHeadersRaw, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&bodyPart); - RETURN_CTOR(&dataset); + ZEPHIR_INIT_NVAR(&_1); + ZEPHIR_INIT_NVAR(&key); + if (ZEPHIR_IS_NULL(&message)) { + ZEPHIR_INIT_VAR(&statusCodes); + zephir_create_array(&statusCodes, 89, 0); + add_index_stringl(&statusCodes, 100, SL("Continue")); + add_index_stringl(&statusCodes, 101, SL("Switching Protocols")); + add_index_stringl(&statusCodes, 102, SL("Processing")); + add_index_stringl(&statusCodes, 103, SL("Early Hints")); + add_index_stringl(&statusCodes, 200, SL("OK")); + add_index_stringl(&statusCodes, 201, SL("Created")); + add_index_stringl(&statusCodes, 202, SL("Accepted")); + add_index_stringl(&statusCodes, 203, SL("Non-Authoritative Information")); + add_index_stringl(&statusCodes, 204, SL("No Content")); + add_index_stringl(&statusCodes, 205, SL("Reset Content")); + add_index_stringl(&statusCodes, 206, SL("Partial Content")); + add_index_stringl(&statusCodes, 207, SL("Multi-status")); + add_index_stringl(&statusCodes, 208, SL("Already Reported")); + add_index_stringl(&statusCodes, 226, SL("IM Used")); + add_index_stringl(&statusCodes, 300, SL("Multiple Choices")); + add_index_stringl(&statusCodes, 301, SL("Moved Permanently")); + add_index_stringl(&statusCodes, 302, SL("Found")); + add_index_stringl(&statusCodes, 303, SL("See Other")); + add_index_stringl(&statusCodes, 304, SL("Not Modified")); + add_index_stringl(&statusCodes, 305, SL("Use Proxy")); + add_index_stringl(&statusCodes, 306, SL("Switch Proxy")); + add_index_stringl(&statusCodes, 307, SL("Temporary Redirect")); + add_index_stringl(&statusCodes, 308, SL("Permanent Redirect")); + add_index_stringl(&statusCodes, 400, SL("Bad Request")); + add_index_stringl(&statusCodes, 401, SL("Unauthorized")); + add_index_stringl(&statusCodes, 402, SL("Payment Required")); + add_index_stringl(&statusCodes, 403, SL("Forbidden")); + add_index_stringl(&statusCodes, 404, SL("Not Found")); + add_index_stringl(&statusCodes, 405, SL("Method Not Allowed")); + add_index_stringl(&statusCodes, 406, SL("Not Acceptable")); + add_index_stringl(&statusCodes, 407, SL("Proxy Authentication Required")); + add_index_stringl(&statusCodes, 408, SL("Request Time-out")); + add_index_stringl(&statusCodes, 409, SL("Conflict")); + add_index_stringl(&statusCodes, 410, SL("Gone")); + add_index_stringl(&statusCodes, 411, SL("Length Required")); + add_index_stringl(&statusCodes, 412, SL("Precondition Failed")); + add_index_stringl(&statusCodes, 413, SL("Request Entity Too Large")); + add_index_stringl(&statusCodes, 414, SL("Request-URI Too Large")); + add_index_stringl(&statusCodes, 415, SL("Unsupported Media Type")); + add_index_stringl(&statusCodes, 416, SL("Requested range not satisfiable")); + add_index_stringl(&statusCodes, 417, SL("Expectation Failed")); + add_index_stringl(&statusCodes, 418, SL("I'm a teapot")); + add_index_stringl(&statusCodes, 421, SL("Misdirected Request")); + add_index_stringl(&statusCodes, 422, SL("Unprocessable Entity")); + add_index_stringl(&statusCodes, 423, SL("Locked")); + add_index_stringl(&statusCodes, 424, SL("Failed Dependency")); + add_index_stringl(&statusCodes, 425, SL("Unordered Collection")); + add_index_stringl(&statusCodes, 426, SL("Upgrade Required")); + add_index_stringl(&statusCodes, 428, SL("Precondition Required")); + add_index_stringl(&statusCodes, 429, SL("Too Many Requests")); + add_index_stringl(&statusCodes, 431, SL("Request Header Fields Too Large")); + add_index_stringl(&statusCodes, 451, SL("Unavailable For Legal Reasons")); + add_index_stringl(&statusCodes, 500, SL("Internal Server Error")); + add_index_stringl(&statusCodes, 501, SL("Not Implemented")); + add_index_stringl(&statusCodes, 502, SL("Bad Gateway")); + add_index_stringl(&statusCodes, 503, SL("Service Unavailable")); + add_index_stringl(&statusCodes, 504, SL("Gateway Time-out")); + add_index_stringl(&statusCodes, 505, SL("HTTP Version not supported")); + add_index_stringl(&statusCodes, 506, SL("Variant Also Negotiates")); + add_index_stringl(&statusCodes, 507, SL("Insufficient Storage")); + add_index_stringl(&statusCodes, 508, SL("Loop Detected")); + add_index_stringl(&statusCodes, 510, SL("Not Extended")); + add_index_stringl(&statusCodes, 511, SL("Network Authentication Required")); + add_index_stringl(&statusCodes, 218, SL("This is fine")); + add_index_stringl(&statusCodes, 419, SL("Page Expired")); + add_index_stringl(&statusCodes, 420, SL("Method Failure")); + add_index_stringl(&statusCodes, 440, SL("Login Time-out")); + add_index_stringl(&statusCodes, 444, SL("No Response")); + add_index_stringl(&statusCodes, 449, SL("Retry With")); + add_index_stringl(&statusCodes, 450, SL("Blocked by Windows Parental Controls (Microsoft)")); + add_index_stringl(&statusCodes, 494, SL("Request header too large")); + add_index_stringl(&statusCodes, 495, SL("SSL Certificate Error")); + add_index_stringl(&statusCodes, 496, SL("SSL Certificate Required")); + add_index_stringl(&statusCodes, 497, SL("HTTP Request Sent to HTTPS Port")); + add_index_stringl(&statusCodes, 498, SL("Invalid Token (Esri)")); + add_index_stringl(&statusCodes, 499, SL("Client Closed Request")); + add_index_stringl(&statusCodes, 509, SL("Bandwidth Limit Exceeded")); + add_index_stringl(&statusCodes, 520, SL("Unknown Error")); + add_index_stringl(&statusCodes, 521, SL("Web Server Is Down")); + add_index_stringl(&statusCodes, 522, SL("Connection Timed Out")); + add_index_stringl(&statusCodes, 523, SL("Origin Is Unreachable")); + add_index_stringl(&statusCodes, 524, SL("A Timeout Occurred")); + add_index_stringl(&statusCodes, 525, SL("SSL Handshake Failed")); + add_index_stringl(&statusCodes, 526, SL("Invalid SSL Certificate")); + add_index_stringl(&statusCodes, 527, SL("Railgun Error")); + add_index_stringl(&statusCodes, 530, SL("Origin DNS Error")); + add_index_stringl(&statusCodes, 598, SL("Network read timeout error")); + add_index_stringl(&statusCodes, 599, SL("Network Connect Timeout Error")); + if (UNEXPECTED(!(zephir_array_isset_long(&statusCodes, code)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_response_exception_ce, "Non-standard statuscode given without a message", "phalcon/Http/Response.zep", 824); + return; + } + zephir_memory_observe(&defaultMessage); + zephir_array_fetch_long(&defaultMessage, &statusCodes, code, PH_NOISY, "phalcon/Http/Response.zep", 827); + zephir_get_strval(&message, &defaultMessage); + } + zephir_read_property(&_15, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_16); + ZVAL_LONG(&_16, code); + ZEPHIR_INIT_VAR(&_17); + ZEPHIR_CONCAT_SVSV(&_17, "HTTP/1.1 ", &_16, " ", &message); + ZEPHIR_CALL_METHOD(NULL, &_15, "setraw", NULL, 0, &_17); + zephir_check_call_status(); + zephir_read_property(&_18, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_19); + ZVAL_LONG(&_19, code); + ZEPHIR_INIT_VAR(&_20); + ZEPHIR_CONCAT_VSV(&_20, &_19, " ", &message); + ZEPHIR_INIT_VAR(&_21); + ZVAL_STRING(&_21, "Status"); + ZEPHIR_CALL_METHOD(NULL, &_18, "set", NULL, 0, &_21, &_20); + zephir_check_call_status(); + RETURN_THIS(); } -zend_object *zephir_init_properties_Phalcon_Http_Request(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Http_Response, setRawHeader) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *header_param = NULL, _0; + zval header; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&header); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(header) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &header_param); + zephir_get_strval(&header, header_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "setraw", NULL, 0, &header); + zephir_check_call_status(); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Http_Response, getBasename) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *uri_param = NULL, *suffix = NULL, suffix_sub, __$null, filename, matches, _0, _1, _2, _3, _4, _5, _6$$3, _7$$3, _8$$3, _9$$3; + zval uri; + + ZVAL_UNDEF(&uri); + ZVAL_UNDEF(&suffix_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&filename); + ZVAL_UNDEF(&matches); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$3); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(uri) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(suffix) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &uri_param, &suffix); + if (UNEXPECTED(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 of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(uri_param) == IS_STRING)) { + zephir_get_strval(&uri, uri_param); + } else { + ZEPHIR_INIT_VAR(&uri); + } + if (!suffix) { + suffix = &suffix_sub; + suffix = &__$null; + } + ZEPHIR_INIT_VAR(&_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "/"); + zephir_fast_trim(&_0, &uri, &_1, ZEPHIR_TRIM_RIGHT); + zephir_get_strval(&uri, &_0); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "/"); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "@"); + ZEPHIR_CALL_FUNCTION(&_4, "preg_quote", NULL, 351, &_2, &_3); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_5); + ZEPHIR_CONCAT_SVS(&_5, "@[^", &_4, "]+$@"); + ZEPHIR_INIT_NVAR(&_2); + zephir_preg_match(&_2, &_5, &uri, &matches, 0, 0 , 0 ); + if (zephir_is_true(&_2)) { + zephir_memory_observe(&filename); + zephir_array_fetch_long(&filename, &matches, 0, PH_NOISY, "phalcon/Http/Response.zep", 867); + } else { + ZEPHIR_INIT_NVAR(&filename); + ZVAL_STRING(&filename, ""); + } + if (zephir_is_true(suffix)) { + ZEPHIR_INIT_VAR(&_6$$3); + ZVAL_STRING(&_6$$3, "@"); + ZEPHIR_CALL_FUNCTION(&_7$$3, "preg_quote", NULL, 351, suffix, &_6$$3); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_8$$3); + ZEPHIR_CONCAT_SVS(&_8$$3, "@", &_7$$3, "$@"); + ZEPHIR_INIT_NVAR(&_6$$3); + ZVAL_STRING(&_6$$3, ""); + ZEPHIR_CALL_FUNCTION(&_9$$3, "preg_replace", NULL, 41, &_8$$3, &_6$$3, &filename); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&filename, &_9$$3); + } + RETURN_CCTOR(&filename); +} + +zend_object *zephir_init_properties_Phalcon_Http_Response(zend_class_entry *class_type) { zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; @@ -159054,11 +158851,11 @@ zend_object *zephir_init_properties_Phalcon_Http_Request(zend_class_entry *class { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("queryFilters"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("statusCodes"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("queryFilters"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("statusCodes"), &_1$$3); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -159075,63 +158872,617 @@ zend_object *zephir_init_properties_Phalcon_Http_Request(zend_class_entry *class -ZEPHIR_INIT_CLASS(Phalcon_Http_RequestInterface) +ZEPHIR_INIT_CLASS(Phalcon_Http_ResponseInterface) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http, RequestInterface, phalcon, http_requestinterface, phalcon_http_requestinterface_method_entry); + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http, ResponseInterface, phalcon, http_responseinterface, phalcon_http_responseinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, appendContent); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, getContent); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, getStatusCode); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, getHeaders); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, hasHeader); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, isSent); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, redirect); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, resetHeaders); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setContent); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setContentLength); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setContentType); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setExpires); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setFileToSend); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setHeader); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setJsonContent); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setNotModified); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setRawHeader); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setStatusCode); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, send); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, sendCookies); +ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, sendHeaders); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Http_Message_RequestMethodInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http\\Message, RequestMethodInterface, phalcon, http_message_requestmethodinterface, NULL); + + zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_CONNECT"), "CONNECT"); + + zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_DELETE"), "DELETE"); + + zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_GET"), "GET"); + + zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_HEAD"), "HEAD"); + + zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_OPTIONS"), "OPTIONS"); + + zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_PATCH"), "PATCH"); + + zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_POST"), "POST"); + + zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_PURGE"), "PURGE"); + + zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_PUT"), "PUT"); + + zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_TRACE"), "TRACE"); + + return SUCCESS; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Http_Message_ResponseStatusCodeInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http\\Message, ResponseStatusCodeInterface, phalcon, http_message_responsestatuscodeinterface, NULL); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_CONTINUE"), 100); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_SWITCHING_PROTOCOLS"), 101); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_PROCESSING"), 102); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_EARLY_HINTS"), 103); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_OK"), 200); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_CREATED"), 201); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_ACCEPTED"), 202); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NON_AUTHORITATIVE_INFORMATION"), 203); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NO_CONTENT"), 204); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_RESET_CONTENT"), 205); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_PARTIAL_CONTENT"), 206); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_MULTI_STATUS"), 207); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_ALREADY_REPORTED"), 208); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_IM_USED"), 226); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_MULTIPLE_CHOICES"), 300); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_MOVED_PERMANENTLY"), 301); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_FOUND"), 302); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_SEE_OTHER"), 303); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NOT_MODIFIED"), 304); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_USE_PROXY"), 305); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_RESERVED"), 306); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_TEMPORARY_REDIRECT"), 307); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_PERMANENT_REDIRECT"), 308); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_BAD_REQUEST"), 400); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_UNAUTHORIZED"), 401); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_PAYMENT_REQUIRED"), 402); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_FORBIDDEN"), 403); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NOT_FOUND"), 404); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_METHOD_NOT_ALLOWED"), 405); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NOT_ACCEPTABLE"), 406); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_PROXY_AUTHENTICATION_REQUIRED"), 407); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_REQUEST_TIMEOUT"), 408); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_CONFLICT"), 409); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_GONE"), 410); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_LENGTH_REQUIRED"), 411); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_PRECONDITION_FAILED"), 412); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_PAYLOAD_TOO_LARGE"), 413); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_URI_TOO_LONG"), 414); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_UNSUPPORTED_MEDIA_TYPE"), 415); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_RANGE_NOT_SATISFIABLE"), 416); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_EXPECTATION_FAILED"), 417); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_IM_A_TEAPOT"), 418); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_MISDIRECTED_REQUEST"), 421); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_UNPROCESSABLE_ENTITY"), 422); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_LOCKED"), 423); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_FAILED_DEPENDENCY"), 424); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_TOO_EARLY"), 425); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_UPGRADE_REQUIRED"), 426); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_PRECONDITION_REQUIRED"), 428); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_TOO_MANY_REQUESTS"), 429); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE"), 431); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_UNAVAILABLE_FOR_LEGAL_REASONS"), 451); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_INTERNAL_SERVER_ERROR"), 500); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NOT_IMPLEMENTED"), 501); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_BAD_GATEWAY"), 502); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_SERVICE_UNAVAILABLE"), 503); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_GATEWAY_TIMEOUT"), 504); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_VERSION_NOT_SUPPORTED"), 505); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_VARIANT_ALSO_NEGOTIATES"), 506); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_INSUFFICIENT_STORAGE"), 507); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_LOOP_DETECTED"), 508); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NOT_EXTENDED"), 510); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NETWORK_AUTHENTICATION_REQUIRED"), 511); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_THIS_IS_FINE"), 218); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_PAGE_EXPIRED"), 419); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_METHOD_FAILURE"), 420); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_LOGIN_TIMEOUT"), 440); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NO_RESPONSE"), 444); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_RETRY_WITH"), 449); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS"), 450); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_REQUEST_HEADER_TOO_LARGE"), 494); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_SSL_CERTIFICATE_ERROR"), 495); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_SSL_CERTIFICATE_REQUIRED"), 496); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_HTTP_REQUEST_SENT_TO_HTTPS_PORT"), 497); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_INVALID_TOKEN_ESRI"), 498); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_CLIENT_CLOSED_REQUEST"), 499); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_BANDWIDTH_LIMIT_EXCEEDED"), 509); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_UNKNOWN_ERROR"), 520); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_WEB_SERVER_IS_DOWN"), 521); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_CONNECTION_TIMEOUT"), 522); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_ORIGIN_IS_UNREACHABLE"), 523); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_TIMEOUT_OCCURRED"), 524); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_SSL_HANDSHAKE_FAILED"), 525); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_INVALID_SSL_CERTIFICATE"), 526); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_RAILGUN_ERROR"), 527); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_ORIGIN_DNS_ERROR"), 530); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NETWORK_READ_TIMEOUT_ERROR"), 598); + + zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NETWORK_CONNECT_TIMEOUT_ERROR"), 599); + + return SUCCESS; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Http_Request_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Http\\Request, Exception, phalcon, http_request_exception, zend_ce_exception, NULL, 0); + + return SUCCESS; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Http_Request_File) +{ + ZEPHIR_REGISTER_CLASS(Phalcon\\Http\\Request, File, phalcon, http_request_file, phalcon_http_request_file_method_entry, 0); + + zend_declare_property_null(phalcon_http_request_file_ce, SL("error"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_http_request_file_ce, SL("extension"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_http_request_file_ce, SL("key"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_http_request_file_ce, SL("name"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_http_request_file_ce, SL("realType"), ZEND_ACC_PROTECTED); + zend_declare_property_long(phalcon_http_request_file_ce, SL("size"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_http_request_file_ce, SL("tmp"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_http_request_file_ce, SL("type"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_http_request_file_ce, 1, phalcon_http_request_fileinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Http_Request_File, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *file_param = NULL, *key = NULL, key_sub, __$null, name, _4, _5, _6, _7, _8, _0$$3, _1$$3, _2$$4, _3$$4; + zval file; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&file); + ZVAL_UNDEF(&key_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(file) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(key) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &file_param, &key); + ZEPHIR_OBS_COPY_OR_DUP(&file, file_param); + if (!key) { + key = &key_sub; + key = &__$null; + } + zephir_memory_observe(&name); + if (zephir_array_isset_string_fetch(&name, &file, SL("name"), 0)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); + ZEPHIR_INIT_VAR(&_0$$3); + ZVAL_STRING(&_0$$3, "PATHINFO_EXTENSION"); + ZEPHIR_CALL_FUNCTION(&_1$$3, "defined", NULL, 118, &_0$$3); + zephir_check_call_status(); + if (zephir_is_true(&_1$$3)) { + ZVAL_LONG(&_2$$4, 4); + ZEPHIR_CALL_FUNCTION(&_3$$4, "pathinfo", NULL, 89, &name, &_2$$4); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("extension"), &_3$$4); + } + } + ZEPHIR_INIT_VAR(&_5); + ZVAL_STRING(&_5, "tmp_name"); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "getarrval", NULL, 353, &file, &_5); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("tmp"), &_4); + ZEPHIR_INIT_NVAR(&_5); + ZVAL_STRING(&_5, "size"); + ZEPHIR_CALL_METHOD(&_6, this_ptr, "getarrval", NULL, 353, &file, &_5); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("size"), &_6); + ZEPHIR_INIT_NVAR(&_5); + ZVAL_STRING(&_5, "type"); + ZEPHIR_CALL_METHOD(&_7, this_ptr, "getarrval", NULL, 353, &file, &_5); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_7); + ZEPHIR_INIT_NVAR(&_5); + ZVAL_STRING(&_5, "error"); + ZEPHIR_CALL_METHOD(&_8, this_ptr, "getarrval", NULL, 353, &file, &_5); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("error"), &_8); + if (zephir_is_true(key)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("key"), key); + } + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Http_Request_File, getError) +{ + + RETURN_MEMBER(getThis(), "error"); +} + +static PHP_METHOD(Phalcon_Http_Request_File, getExtension) +{ + + RETURN_MEMBER(getThis(), "extension"); +} + +static PHP_METHOD(Phalcon_Http_Request_File, getKey) +{ + + RETURN_MEMBER(getThis(), "key"); +} + +static PHP_METHOD(Phalcon_Http_Request_File, getName) +{ + + RETURN_MEMBER(getThis(), "name"); +} + +static PHP_METHOD(Phalcon_Http_Request_File, getRealType) +{ + zval finfo, mime, _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&finfo); + ZVAL_UNDEF(&mime); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZVAL_LONG(&_0, 16); + ZEPHIR_CALL_FUNCTION(&finfo, "finfo_open", NULL, 308, &_0); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&finfo)) { + RETURN_MM_STRING(""); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("tmp"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 309, &finfo, &_0); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 310, &finfo); + zephir_check_call_status(); + RETURN_CCTOR(&mime); +} + +static PHP_METHOD(Phalcon_Http_Request_File, getSize) +{ + + RETURN_MEMBER(getThis(), "size"); +} + +static PHP_METHOD(Phalcon_Http_Request_File, getTempName) +{ + + RETURN_MEMBER(getThis(), "tmp"); +} + +static PHP_METHOD(Phalcon_Http_Request_File, getType) +{ + + RETURN_MEMBER(getThis(), "type"); +} + +static PHP_METHOD(Phalcon_Http_Request_File, isUploadedFile) +{ + zend_bool _0; + zval tmp, _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&tmp); + ZVAL_UNDEF(&_1); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_CALL_METHOD(&tmp, this_ptr, "gettempname", NULL, 0); + zephir_check_call_status(); + _0 = Z_TYPE_P(&tmp) == IS_STRING; + if (_0) { + ZEPHIR_CALL_FUNCTION(&_1, "is_uploaded_file", NULL, 20, &tmp); + zephir_check_call_status(); + _0 = zephir_is_true(&_1); + } + RETURN_MM_BOOL(_0); +} + +static PHP_METHOD(Phalcon_Http_Request_File, moveTo) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *destination_param = NULL, _0; + zval destination; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&destination); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(destination) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &destination_param); + if (UNEXPECTED(Z_TYPE_P(destination_param) != IS_STRING && Z_TYPE_P(destination_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'destination' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(destination_param) == IS_STRING)) { + zephir_get_strval(&destination, destination_param); + } else { + ZEPHIR_INIT_VAR(&destination); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("tmp"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_RETURN_CALL_FUNCTION("move_uploaded_file", NULL, 354, &_0, &destination); + zephir_check_call_status(); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Http_Request_File, getArrVal) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *collection_param = NULL, *index, index_sub, *defaultValue = NULL, defaultValue_sub, __$null, value; + zval collection; + + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&value); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ARRAY(collection) + Z_PARAM_ZVAL(index) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(defaultValue) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 1, &collection_param, &index, &defaultValue); + ZEPHIR_OBS_COPY_OR_DUP(&collection, collection_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; + } + zephir_memory_observe(&value); + if (UNEXPECTED(!(zephir_array_isset_fetch(&value, &collection, index, 0)))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + RETURN_CCTOR(&value); +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Http_Request_FileInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http\\Request, FileInterface, phalcon, http_request_fileinterface, phalcon_http_request_fileinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, getError); +ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, getName); +ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, getRealType); +ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, getSize); +ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, getTempName); +ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, getType); +ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, moveTo); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Http_Cookie_CookieInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http\\Cookie, CookieInterface, phalcon, http_cookie_cookieinterface, phalcon_http_cookie_cookieinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, delete); +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, getDomain); +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, getExpiration); +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, getHttpOnly); +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, getName); +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, getOptions); +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, getPath); +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, getSecure); +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, getValue); +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, isUsingEncryption); +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, send); +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, setDomain); +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, setExpiration); +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, setHttpOnly); +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, setOptions); +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, setPath); +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, setSecure); +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, setValue); +ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, useEncryption); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Http_Cookie_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Http\\Cookie, Exception, phalcon, http_cookie_exception, zend_ce_exception, NULL, 0); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, get); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getAcceptableContent); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getBasicAuth); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getBestAccept); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getBestCharset); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getBestLanguage); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getClientAddress); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getClientCharsets); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getContentType); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getDigestAuth); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getHeader); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getHeaders); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getHttpHost); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getHTTPReferer); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getJsonRawBody); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getLanguages); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getMethod); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getPort); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getURI); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getPost); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getPut); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getQuery); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getRawBody); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getScheme); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getServer); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getServerAddress); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getServerName); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getUploadedFiles); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, getUserAgent); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, has); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, hasFiles); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, hasHeader); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, hasQuery); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, hasPost); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, hasPut); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, hasServer); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isAjax); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isConnect); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isDelete); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isGet); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isHead); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isMethod); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isOptions); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isPost); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isPurge); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isPut); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isSecure); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isSoap); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, isTrace); -ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, numFiles); @@ -159142,265 +159493,659 @@ ZEPHIR_DOC_METHOD(Phalcon_Http_RequestInterface, numFiles); -ZEPHIR_INIT_CLASS(Phalcon_Http_Response) +ZEPHIR_INIT_CLASS(Phalcon_Http_Response_Cookies) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Http\\Response, Cookies, phalcon, http_response_cookies, phalcon_di_abstractinjectionaware_ce, phalcon_http_response_cookies_method_entry, 0); + + zend_declare_property_null(phalcon_http_response_cookies_ce, SL("cookies"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_http_response_cookies_ce, SL("isSent"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_http_response_cookies_ce, SL("registered"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_http_response_cookies_ce, SL("signKey"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_http_response_cookies_ce, SL("useEncryption"), 1, ZEND_ACC_PROTECTED); + phalcon_http_response_cookies_ce->create_object = zephir_init_properties_Phalcon_Http_Response_Cookies; + + zend_class_implements(phalcon_http_response_cookies_ce, 1, phalcon_http_response_cookiesinterface_ce); + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Http_Response_Cookies, __construct) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval signKey; + zval *useEncryption_param = NULL, *signKey_param = NULL, __$true, __$false; + zend_bool useEncryption; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&signKey); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(useEncryption) + Z_PARAM_STR_OR_NULL(signKey) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 2, &useEncryption_param, &signKey_param); + if (!useEncryption_param) { + useEncryption = 1; + } else { + } + if (!signKey_param) { + ZEPHIR_INIT_VAR(&signKey); + } else { + zephir_get_strval(&signKey, signKey_param); + } + if (useEncryption) { + zephir_update_property_zval(this_ptr, ZEND_STRL("useEncryption"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("useEncryption"), &__$false); + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "setsignkey", NULL, 0, &signKey); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Http_Response_Cookies, delete) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, cookie, _0; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&cookie); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_memory_observe(&cookie); + zephir_read_property(&_0, this_ptr, ZEND_STRL("cookies"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&cookie, &_0, &name, 0))) { + RETURN_MM_BOOL(0); + } + ZEPHIR_CALL_METHOD(NULL, &cookie, "delete", NULL, 0); + zephir_check_call_status(); + RETURN_MM_BOOL(1); +} + +static PHP_METHOD(Phalcon_Http_Response_Cookies, get) +{ + zval _3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, container, encryption, cookie, _0, _1, _2, _4, _5, _6$$5; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&encryption); + ZVAL_UNDEF(&cookie); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_memory_observe(&cookie); + zephir_read_property(&_0, this_ptr, ZEND_STRL("cookies"), PH_NOISY_CC | PH_READONLY); + if (zephir_array_isset_fetch(&cookie, &_0, &name, 0)) { + RETURN_CCTOR(&cookie); + } + zephir_read_property(&_1, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_3); + zephir_create_array(&_3, 1, 0); + zephir_array_fast_append(&_3, &name); + ZEPHIR_INIT_VAR(&_4); + ZVAL_STRING(&_4, "Phalcon\\Http\\Cookie"); + ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_4, &_3); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&cookie, &_2); + zephir_read_property(&_5, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_5); + if (Z_TYPE_P(&container) == IS_OBJECT) { + ZEPHIR_CALL_METHOD(NULL, &cookie, "setdi", NULL, 0, &container); + zephir_check_call_status(); + zephir_memory_observe(&encryption); + zephir_read_property(&encryption, this_ptr, ZEND_STRL("useEncryption"), PH_NOISY_CC); + if (zephir_is_true(&encryption)) { + ZEPHIR_CALL_METHOD(NULL, &cookie, "useencryption", NULL, 0, &encryption); + zephir_check_call_status(); + zephir_read_property(&_6$$5, this_ptr, ZEND_STRL("signKey"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &cookie, "setsignkey", NULL, 0, &_6$$5); + zephir_check_call_status(); + } + } + RETURN_CCTOR(&cookie); +} + +static PHP_METHOD(Phalcon_Http_Response_Cookies, getCookies) +{ + + RETURN_MEMBER(getThis(), "cookies"); +} + +static PHP_METHOD(Phalcon_Http_Response_Cookies, has) +{ + zend_bool _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *name_param = NULL, _COOKIE, _0; + zval name; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&_COOKIE); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_get_global(&_COOKIE, SL("_COOKIE")); + zephir_fetch_params(1, 1, 0, &name_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); + } else { + ZEPHIR_INIT_VAR(&name); + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("cookies"), PH_NOISY_CC | PH_READONLY); + _1 = zephir_array_isset(&_0, &name); + if (!(_1)) { + _1 = zephir_array_isset(&_COOKIE, &name); + } + RETURN_MM_BOOL(_1); +} + +static PHP_METHOD(Phalcon_Http_Response_Cookies, isSent) +{ + + RETURN_MEMBER(getThis(), "isSent"); +} + +static PHP_METHOD(Phalcon_Http_Response_Cookies, isUsingEncryption) +{ + + RETURN_MEMBER(getThis(), "useEncryption"); +} + +static PHP_METHOD(Phalcon_Http_Response_Cookies, reset) +{ + zval _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("cookies"), &_0); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Http_Response_Cookies, send) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Http, Response, phalcon, http_response, phalcon_http_response_method_entry, 0); + zend_bool _1; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval __$true, __$false, cookie, _0, _2, _3, *_4, _5; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - zend_declare_property_null(phalcon_http_response_ce, SL("container"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_http_response_ce, SL("content"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_http_response_ce, SL("cookies"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_http_response_ce, SL("eventsManager"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_http_response_ce, SL("file"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_http_response_ce, SL("headers"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_http_response_ce, SL("sent"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_http_response_ce, SL("statusCodes"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_http_response_ce, SL("encode"), ZEND_ACC_PRIVATE); - phalcon_http_response_ce->create_object = zephir_init_properties_Phalcon_Http_Response; + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&cookie); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zend_class_implements(phalcon_http_response_ce, 1, phalcon_http_responseinterface_ce); - zend_class_implements(phalcon_http_response_ce, 1, phalcon_di_injectionawareinterface_ce); - zend_class_implements(phalcon_http_response_ce, 1, phalcon_events_eventsawareinterface_ce); - zend_class_implements(phalcon_http_response_ce, 1, phalcon_http_message_responsestatuscodeinterface_ce); - return SUCCESS; + ZEPHIR_CALL_FUNCTION(&_0, "headers_sent", NULL, 359); + zephir_check_call_status(); + _1 = ZEPHIR_IS_TRUE_IDENTICAL(&_0); + if (!(_1)) { + ZEPHIR_CALL_METHOD(&_2, this_ptr, "issent", NULL, 0); + zephir_check_call_status(); + _1 = ZEPHIR_IS_TRUE_IDENTICAL(&_2); + } + if (_1) { + RETURN_MM_BOOL(0); + } + zephir_read_property(&_3, this_ptr, ZEND_STRL("cookies"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_3, 0, "phalcon/Http/Response/Cookies.zep", 225); + if (Z_TYPE_P(&_3) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_3), _4) + { + ZEPHIR_INIT_NVAR(&cookie); + ZVAL_COPY(&cookie, _4); + ZEPHIR_CALL_METHOD(NULL, &cookie, "send", NULL, 0); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &_3, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5, &_3, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5)) { + break; + } + ZEPHIR_CALL_METHOD(&cookie, &_3, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &cookie, "send", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_3, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&cookie); + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("isSent"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("isSent"), &__$false); + } + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Http_Response, __construct) +static PHP_METHOD(Phalcon_Http_Response_Cookies, set) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *content_param = NULL, *code = NULL, code_sub, *status = NULL, status_sub, __$null, _0, _1; - zval content; + zval options, _3$$3; + zend_bool secure, httpOnly; + zend_long expire, ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, *value = NULL, value_sub, *expire_param = NULL, *path_param = NULL, *secure_param = NULL, *domain_param = NULL, *httpOnly_param = NULL, *options_param = NULL, __$true, __$false, __$null, cookie, encryption, container, response, _0, _10, _1$$3, _2$$3, _4$$3, _5$$3, _6$$4, _7$$5, _8$$5, _9$$5, _11$$6, _12$$6; + zval name, path, domain; zval *this_ptr = getThis(); - ZVAL_UNDEF(&content); - ZVAL_UNDEF(&code_sub); - ZVAL_UNDEF(&status_sub); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&path); + ZVAL_UNDEF(&domain); + ZVAL_UNDEF(&value_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); ZVAL_NULL(&__$null); + ZVAL_UNDEF(&cookie); + ZVAL_UNDEF(&encryption); + ZVAL_UNDEF(&container); + ZVAL_UNDEF(&response); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_11$$6); + ZVAL_UNDEF(&_12$$6); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&_3$$3); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 3) + ZEND_PARSE_PARAMETERS_START(1, 8) + Z_PARAM_STR(name) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(content) - Z_PARAM_ZVAL_OR_NULL(code) - Z_PARAM_ZVAL_OR_NULL(status) + Z_PARAM_ZVAL_OR_NULL(value) + Z_PARAM_LONG(expire) + Z_PARAM_STR(path) + Z_PARAM_BOOL_OR_NULL(secure, is_null_true) + Z_PARAM_STR_OR_NULL(domain) + Z_PARAM_BOOL_OR_NULL(httpOnly, is_null_true) + Z_PARAM_ARRAY(options) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 3, &content_param, &code, &status); - if (!content_param) { - ZEPHIR_INIT_VAR(&content); - } else { - if (UNEXPECTED(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 of the type string")); + zephir_fetch_params(1, 1, 7, &name_param, &value, &expire_param, &path_param, &secure_param, &domain_param, &httpOnly_param, &options_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); RETURN_MM_NULL(); } - if (EXPECTED(Z_TYPE_P(content_param) == IS_STRING)) { - zephir_get_strval(&content, content_param); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - ZEPHIR_INIT_VAR(&content); + ZEPHIR_INIT_VAR(&name); } + if (!value) { + value = &value_sub; + value = &__$null; } - if (!code) { - code = &code_sub; - code = &__$null; + if (!expire_param) { + expire = 0; + } else { + } + if (!path_param) { + ZEPHIR_INIT_VAR(&path); + ZVAL_STRING(&path, "/"); + } else { + zephir_get_strval(&path, path_param); } - if (!status) { - status = &status_sub; - status = &__$null; + if (!secure_param) { + secure = 0; + } else { + } + if (!domain_param) { + ZEPHIR_INIT_VAR(&domain); + } else { + if (UNEXPECTED(Z_TYPE_P(domain_param) != IS_STRING && Z_TYPE_P(domain_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'domain' must be of the type string")); + RETURN_MM_NULL(); } - ZEPHIR_INIT_VAR(&_0); - object_init_ex(&_0, phalcon_http_response_headers_ce); - if (zephir_has_constructor(&_0)) { - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); - zephir_check_call_status(); + if (EXPECTED(Z_TYPE_P(domain_param) == IS_STRING)) { + zephir_get_strval(&domain, domain_param); + } else { + ZEPHIR_INIT_VAR(&domain); } - - zephir_update_property_zval(this_ptr, ZEND_STRL("headers"), &_0); - ZEPHIR_INIT_VAR(&_1); - object_init_ex(&_1, phalcon_support_helper_json_encode_ce); - if (zephir_has_constructor(&_1)) { - ZEPHIR_CALL_METHOD(NULL, &_1, "__construct", NULL, 0); - zephir_check_call_status(); } - - zephir_update_property_zval(this_ptr, ZEND_STRL("encode"), &_1); - if (!ZEPHIR_IS_NULL(&content)) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setcontent", NULL, 0, &content); + if (!httpOnly_param) { + httpOnly = 0; + } else { + } + if (!options_param) { + ZEPHIR_INIT_VAR(&options); + array_init(&options); + } else { + zephir_get_arrval(&options, options_param); + } + zephir_memory_observe(&encryption); + zephir_read_property(&encryption, this_ptr, ZEND_STRL("useEncryption"), PH_NOISY_CC); + zephir_memory_observe(&cookie); + zephir_read_property(&_0, this_ptr, ZEND_STRL("cookies"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset_fetch(&cookie, &_0, &name, 0))) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_3$$3); + zephir_create_array(&_3$$3, 8, 0); + zephir_array_fast_append(&_3$$3, &name); + zephir_array_fast_append(&_3$$3, value); + ZEPHIR_INIT_VAR(&_4$$3); + ZVAL_LONG(&_4$$3, expire); + zephir_array_fast_append(&_3$$3, &_4$$3); + zephir_array_fast_append(&_3$$3, &path); + ZEPHIR_INIT_NVAR(&_4$$3); + ZVAL_BOOL(&_4$$3, secure); + zephir_array_fast_append(&_3$$3, &_4$$3); + zephir_array_fast_append(&_3$$3, &domain); + ZEPHIR_INIT_NVAR(&_4$$3); + ZVAL_BOOL(&_4$$3, httpOnly); + zephir_array_fast_append(&_3$$3, &_4$$3); + zephir_array_fast_append(&_3$$3, &options); + ZEPHIR_INIT_NVAR(&_4$$3); + ZVAL_STRING(&_4$$3, "Phalcon\\Http\\Cookie"); + ZEPHIR_CALL_METHOD(&_2$$3, &_1$$3, "get", NULL, 0, &_4$$3, &_3$$3); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&cookie, &_2$$3); + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &cookie, "setdi", NULL, 0, &_5$$3); + zephir_check_call_status(); + if (zephir_is_true(&encryption)) { + ZEPHIR_CALL_METHOD(NULL, &cookie, "useencryption", NULL, 0, &encryption); + zephir_check_call_status(); + zephir_read_property(&_6$$4, this_ptr, ZEND_STRL("signKey"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &cookie, "setsignkey", NULL, 0, &_6$$4); + zephir_check_call_status(); + } + zephir_update_property_array(this_ptr, SL("cookies"), &name, &cookie); + } else { + ZEPHIR_CALL_METHOD(NULL, &cookie, "setvalue", NULL, 0, value); + zephir_check_call_status(); + ZVAL_LONG(&_7$$5, expire); + ZEPHIR_CALL_METHOD(NULL, &cookie, "setexpiration", NULL, 0, &_7$$5); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &cookie, "setpath", NULL, 0, &path); + zephir_check_call_status(); + if (secure) { + ZVAL_BOOL(&_7$$5, 1); + } else { + ZVAL_BOOL(&_7$$5, 0); + } + ZEPHIR_CALL_METHOD(NULL, &cookie, "setsecure", NULL, 0, &_7$$5); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &cookie, "setdomain", NULL, 0, &domain); + zephir_check_call_status(); + if (httpOnly) { + ZVAL_BOOL(&_8$$5, 1); + } else { + ZVAL_BOOL(&_8$$5, 0); + } + ZEPHIR_CALL_METHOD(NULL, &cookie, "sethttponly", NULL, 0, &_8$$5); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &cookie, "setoptions", NULL, 0, &options); + zephir_check_call_status(); + zephir_read_property(&_9$$5, this_ptr, ZEND_STRL("signKey"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &cookie, "setsignkey", NULL, 0, &_9$$5); zephir_check_call_status(); } - if (Z_TYPE_P(code) != IS_NULL) { - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setstatuscode", NULL, 0, code, status); + zephir_read_property(&_10, this_ptr, ZEND_STRL("registered"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_10)) { + zephir_read_property(&_11$$6, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&container, &_11$$6); + if (Z_TYPE_P(&container) == IS_NULL) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_cookie_exception_ce, "A dependency injection container is required to access the 'response' service", "phalcon/Http/Response/Cookies.zep", 311); + return; + } + ZEPHIR_INIT_VAR(&_12$$6); + ZVAL_STRING(&_12$$6, "response"); + ZEPHIR_CALL_METHOD(&response, &container, "getshared", NULL, 0, &_12$$6); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &response, "setcookies", NULL, 0, this_ptr); zephir_check_call_status(); + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("registered"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("registered"), &__$false); + } } - ZEPHIR_MM_RESTORE(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Response, appendContent) +static PHP_METHOD(Phalcon_Http_Response_Cookies, setSignKey) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *content, content_sub, _0, _1; + zval *signKey_param = NULL; + zval signKey; zval *this_ptr = getThis(); - ZVAL_UNDEF(&content_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ZVAL(content) + ZVAL_UNDEF(&signKey); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(signKey) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &content); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getcontent", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_1); - ZEPHIR_CONCAT_VV(&_1, &_0, content); - zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &_1); + zephir_fetch_params(1, 0, 1, &signKey_param); + if (!signKey_param) { + ZEPHIR_INIT_VAR(&signKey); + } else { + zephir_get_strval(&signKey, signKey_param); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("signKey"), &signKey); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Response, getContent) +static PHP_METHOD(Phalcon_Http_Response_Cookies, useEncryption) { - zval _1; - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *useEncryption_param = NULL, __$true, __$false; + zend_bool useEncryption; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_memory_observe(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("content"), PH_NOISY_CC); - zephir_cast_to_string(&_1, &_0); - RETURN_CTOR(&_1); -} - -static PHP_METHOD(Phalcon_Http_Response, getCookies) -{ - - RETURN_MEMBER(getThis(), "cookies"); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_BOOL(useEncryption) + ZEND_PARSE_PARAMETERS_END(); + zephir_fetch_params_without_memory_grow(1, 0, &useEncryption_param); + if (useEncryption) { + zephir_update_property_zval(this_ptr, ZEND_STRL("useEncryption"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("useEncryption"), &__$false); + } + RETURN_THISW(); } -static PHP_METHOD(Phalcon_Http_Response, getDI) +zend_object *zephir_init_properties_Phalcon_Http_Response_Cookies(zend_class_entry *class_type) { - zval container, _0; + zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + - zephir_read_property(&_0, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_0); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_CALL_CE_STATIC(&container, phalcon_di_di_ce, "getdefault", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_response_exception_ce, "A dependency injection container is required to access the 'url' service", "phalcon/Http/Response.zep", 153); - return; + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("cookies"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("cookies"), &_1$$3); } - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), &container); + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } - RETURN_CCTOR(&container); } -static PHP_METHOD(Phalcon_Http_Response, getEventsManager) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Http_Response_CookiesInterface) { + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http\\Response, CookiesInterface, phalcon, http_response_cookiesinterface, phalcon_http_response_cookiesinterface_method_entry); - RETURN_MEMBER(getThis(), "eventsManager"); + return SUCCESS; } -static PHP_METHOD(Phalcon_Http_Response, getHeaders) +ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, delete); +ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, get); +ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, has); +ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, isUsingEncryption); +ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, reset); +ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, send); +ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, set); +ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, useEncryption); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Http_Response_Exception) { + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Http\\Response, Exception, phalcon, http_response_exception, zend_ce_exception, NULL, 0); - RETURN_MEMBER(getThis(), "headers"); + return SUCCESS; } -static PHP_METHOD(Phalcon_Http_Response, getReasonPhrase) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Http_Response_Headers) { - zval statusReasonPhrase, _0, _1, _2, _3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + ZEPHIR_REGISTER_CLASS(Phalcon\\Http\\Response, Headers, phalcon, http_response_headers, phalcon_http_response_headers_method_entry, 0); - ZVAL_UNDEF(&statusReasonPhrase); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zend_declare_property_null(phalcon_http_response_headers_ce, SL("headers"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_http_response_headers_ce, SL("isSent"), 0, ZEND_ACC_PROTECTED); + phalcon_http_response_headers_ce->create_object = zephir_init_properties_Phalcon_Http_Response_Headers; - zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "Status"); - ZEPHIR_CALL_METHOD(&_1, &_0, "get", NULL, 0, &_2); - zephir_check_call_status(); - ZVAL_LONG(&_3, 4); - ZEPHIR_INIT_VAR(&statusReasonPhrase); - zephir_substr(&statusReasonPhrase, &_1, 4 , 0, ZEPHIR_SUBSTR_NO_LENGTH); - ZEPHIR_INIT_NVAR(&_2); - if (zephir_is_true(&statusReasonPhrase)) { - ZEPHIR_CPY_WRT(&_2, &statusReasonPhrase); - } else { - ZEPHIR_INIT_NVAR(&_2); - ZVAL_NULL(&_2); - } - RETURN_CCTOR(&_2); + zend_class_implements(phalcon_http_response_headers_ce, 1, phalcon_http_response_headersinterface_ce); + return SUCCESS; } -static PHP_METHOD(Phalcon_Http_Response, getStatusCode) +static PHP_METHOD(Phalcon_Http_Response_Headers, get) { - zval statusCode, _0, _1, _2, _3, _4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, headers, headerValue, _0; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&statusCode); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&headers); + ZVAL_UNDEF(&headerValue); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(name) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - + zephir_fetch_params(1, 1, 0, &name_param); + zephir_get_strval(&name, name_param); zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "Status"); - ZEPHIR_CALL_METHOD(&_1, &_0, "get", NULL, 0, &_2); - zephir_check_call_status(); - ZVAL_LONG(&_3, 0); - ZVAL_LONG(&_4, 3); - ZEPHIR_INIT_VAR(&statusCode); - zephir_substr(&statusCode, &_1, 0 , 3 , 0); - ZEPHIR_INIT_NVAR(&_2); - if (zephir_is_true(&statusCode)) { - ZEPHIR_INIT_NVAR(&_2); - ZVAL_LONG(&_2, zephir_get_intval(&statusCode)); - } else { - ZEPHIR_INIT_NVAR(&_2); - ZVAL_NULL(&_2); + ZEPHIR_CPY_WRT(&headers, &_0); + zephir_memory_observe(&headerValue); + if (!(zephir_array_isset_fetch(&headerValue, &headers, &name, 0))) { + RETURN_MM_BOOL(0); } - RETURN_CCTOR(&_2); + RETURN_CCTOR(&headerValue); } -static PHP_METHOD(Phalcon_Http_Response, hasHeader) +static PHP_METHOD(Phalcon_Http_Response_Headers, has) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, headers; + zval *name_param = NULL, _0; zval name; zval *this_ptr = getThis(); ZVAL_UNDEF(&name); - ZVAL_UNDEF(&headers); + ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) Z_PARAM_STR(name) ZEND_PARSE_PARAMETERS_END(); @@ -159408,1772 +160153,1806 @@ static PHP_METHOD(Phalcon_Http_Response, hasHeader) zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); zephir_fetch_params(1, 1, 0, &name_param); zephir_get_strval(&name, name_param); - ZEPHIR_CALL_METHOD(&headers, this_ptr, "getheaders", NULL, 0); - zephir_check_call_status(); - ZEPHIR_RETURN_CALL_METHOD(&headers, "has", NULL, 0, &name); - zephir_check_call_status(); - RETURN_MM(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + RETURN_MM_BOOL(zephir_array_key_exists(&_0, &name)); } -static PHP_METHOD(Phalcon_Http_Response, isSent) +static PHP_METHOD(Phalcon_Http_Response_Headers, isSent) { - RETURN_MEMBER(getThis(), "sent"); + RETURN_MEMBER(getThis(), "isSent"); } -static PHP_METHOD(Phalcon_Http_Response, redirect) +static PHP_METHOD(Phalcon_Http_Response_Headers, remove) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long statusCode, ZEPHIR_LAST_CALL_STATUS; - zend_bool externalRedirect, _11, _0$$5; - zval *location = NULL, location_sub, *externalRedirect_param = NULL, *statusCode_param = NULL, __$null, header, url, container, matched, view, _8, _9, _12, _1$$5, _2$$5, _3$$6, _4$$6, _5$$6, _6$$10, _7$$10, _10$$11; + zval *header_param = NULL, headers, _0; + zval header; zval *this_ptr = getThis(); - ZVAL_UNDEF(&location_sub); - ZVAL_NULL(&__$null); ZVAL_UNDEF(&header); - ZVAL_UNDEF(&url); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&matched); - ZVAL_UNDEF(&view); - ZVAL_UNDEF(&_8); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_1$$5); - ZVAL_UNDEF(&_2$$5); - ZVAL_UNDEF(&_3$$6); - ZVAL_UNDEF(&_4$$6); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_6$$10); - ZVAL_UNDEF(&_7$$10); - ZVAL_UNDEF(&_10$$11); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 3) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(location) - Z_PARAM_BOOL(externalRedirect) - Z_PARAM_LONG(statusCode) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 3, &location, &externalRedirect_param, &statusCode_param); - if (!location) { - location = &location_sub; - ZEPHIR_CPY_WRT(location, &__$null); - } else { - ZEPHIR_SEPARATE_PARAM(location); - } - if (!externalRedirect_param) { - externalRedirect = 0; - } else { - } - if (!statusCode_param) { - statusCode = 302; - } else { - } - if (!(zephir_is_true(location))) { - ZEPHIR_INIT_NVAR(location); - ZVAL_STRING(location, ""); - } - if (externalRedirect) { - ZEPHIR_CPY_WRT(&header, location); - } else { - _0$$5 = Z_TYPE_P(location) == IS_STRING; - if (_0$$5) { - ZEPHIR_INIT_VAR(&_1$$5); - ZVAL_STRING(&_1$$5, "://"); - ZEPHIR_CALL_FUNCTION(&_2$$5, "strstr", NULL, 355, location, &_1$$5); - zephir_check_call_status(); - _0$$5 = zephir_is_true(&_2$$5); - } - if (_0$$5) { - ZEPHIR_INIT_VAR(&_3$$6); - ZEPHIR_INIT_VAR(&_4$$6); - ZVAL_STRING(&_4$$6, "/^[^:\\/?#]++:/"); - ZEPHIR_INIT_VAR(&_5$$6); - ZVAL_STRING(&_5$$6, "/^[^:\\/?#]++:/"); - ZEPHIR_INIT_VAR(&matched); - zephir_preg_match(&matched, &_5$$6, location, &_3$$6, 0, 0 , 0 ); - if (zephir_is_true(&matched)) { - ZEPHIR_CPY_WRT(&header, location); - } else { - ZEPHIR_INIT_NVAR(&header); - ZVAL_NULL(&header); - } - } else { - ZEPHIR_INIT_NVAR(&header); - ZVAL_NULL(&header); - } - } - ZEPHIR_CALL_METHOD(&container, this_ptr, "getdi", NULL, 0); - zephir_check_call_status(); - if (!(zephir_is_true(&header))) { - ZEPHIR_INIT_VAR(&_7$$10); - ZVAL_STRING(&_7$$10, "url"); - ZEPHIR_CALL_METHOD(&_6$$10, &container, "getshared", NULL, 0, &_7$$10); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&url, &_6$$10); - ZEPHIR_CALL_METHOD(&header, &url, "get", NULL, 0, location); - zephir_check_call_status(); - } - ZEPHIR_INIT_VAR(&_9); - ZVAL_STRING(&_9, "view"); - ZEPHIR_CALL_METHOD(&_8, &container, "has", NULL, 0, &_9); - zephir_check_call_status(); - if (zephir_is_true(&_8)) { - ZEPHIR_INIT_VAR(&_10$$11); - ZVAL_STRING(&_10$$11, "view"); - ZEPHIR_CALL_METHOD(&view, &container, "getshared", NULL, 0, &_10$$11); - zephir_check_call_status(); - if (zephir_instance_of_ev(&view, phalcon_mvc_viewinterface_ce)) { - ZEPHIR_CALL_METHOD(NULL, &view, "disable", NULL, 0); - zephir_check_call_status(); - } - } - _11 = statusCode < 300; - if (!(_11)) { - _11 = statusCode > 308; - } - if (_11) { - statusCode = 302; - } - ZVAL_LONG(&_12, statusCode); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setstatuscode", NULL, 0, &_12); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_9); - ZVAL_STRING(&_9, "Location"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, &_9, &header); - zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Http_Response, removeHeader) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, _0; - zval name; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); + ZVAL_UNDEF(&headers); ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + Z_PARAM_STR(header) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - zephir_get_strval(&name, name_param); + zephir_fetch_params(1, 1, 0, &header_param); + zephir_get_strval(&header, header_param); zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "remove", NULL, 0, &name); - zephir_check_call_status(); + ZEPHIR_CPY_WRT(&headers, &_0); + zephir_array_unset(&headers, &header, PH_SEPARATE); + zephir_update_property_zval(this_ptr, ZEND_STRL("headers"), &headers); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Response, resetHeaders) +static PHP_METHOD(Phalcon_Http_Response_Headers, reset) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_UNDEF(&_0); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "reset", NULL, 0); - zephir_check_call_status(); - RETURN_THIS(); + ZEPHIR_INIT_VAR(&_0); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("headers"), &_0); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Http_Response, send) +static PHP_METHOD(Phalcon_Http_Response_Headers, send) { - zend_bool _3$$5; + zend_string *_7; + zend_ulong _6; + zend_bool _1, _10$$6, _16$$11; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$true, __$false, content, file, _0, _1, _2$$5; + zephir_fcall_cache_entry *_9 = NULL; + zval __$true, __$false, header, value, _0, _2, _3, *_4, _5, _8$$5, _11$$6, _12$$6, _13$$6, _14$$8, _15$$10, _17$$11, _18$$11, _19$$11, _20$$13; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); ZVAL_BOOL(&__$true, 1); ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&content); - ZVAL_UNDEF(&file); + ZVAL_UNDEF(&header); + ZVAL_UNDEF(&value); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_11$$6); + ZVAL_UNDEF(&_12$$6); + ZVAL_UNDEF(&_13$$6); + ZVAL_UNDEF(&_14$$8); + ZVAL_UNDEF(&_15$$10); + ZVAL_UNDEF(&_17$$11); + ZVAL_UNDEF(&_18$$11); + ZVAL_UNDEF(&_19$$11); + ZVAL_UNDEF(&_20$$13); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_read_property(&_0, this_ptr, ZEND_STRL("sent"), PH_NOISY_CC | PH_READONLY); - if (UNEXPECTED(zephir_is_true(&_0))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_response_exception_ce, "Response was already sent", "phalcon/Http/Response.zep", 343); - return; - } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "sendheaders", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "sendcookies", NULL, 0); + ZEPHIR_CALL_FUNCTION(&_0, "headers_sent", NULL, 359); zephir_check_call_status(); - zephir_read_property(&_1, this_ptr, ZEND_STRL("content"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&content, &_1); - if (Z_TYPE_P(&content) != IS_NULL) { - zend_print_zval(&content, 0); + _1 = ZEPHIR_IS_TRUE_IDENTICAL(&_0); + if (!(_1)) { + zephir_read_property(&_2, this_ptr, ZEND_STRL("isSent"), PH_NOISY_CC | PH_READONLY); + _1 = ZEPHIR_IS_TRUE_IDENTICAL(&_2); + } + if (_1) { + RETURN_MM_BOOL(0); + } + zephir_read_property(&_3, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + zephir_is_iterable(&_3, 0, "phalcon/Http/Response/Headers.zep", 107); + if (Z_TYPE_P(&_3) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_3), _6, _7, _4) + { + ZEPHIR_INIT_NVAR(&header); + if (_7 != NULL) { + ZVAL_STR_COPY(&header, _7); + } else { + ZVAL_LONG(&header, _6); + } + ZEPHIR_INIT_NVAR(&value); + ZVAL_COPY(&value, _4); + if (Z_TYPE_P(&value) != IS_NULL) { + ZEPHIR_INIT_NVAR(&_8$$5); + ZEPHIR_CONCAT_VSV(&_8$$5, &header, ": ", &value); + ZEPHIR_CALL_FUNCTION(NULL, "header", &_9, 360, &_8$$5, &__$true); + zephir_check_call_status(); + } else { + _10$$6 = zephir_memnstr_str(&header, SL(":"), "phalcon/Http/Response/Headers.zep", 99); + if (!(_10$$6)) { + ZVAL_LONG(&_11$$6, 0); + ZVAL_LONG(&_12$$6, 5); + ZEPHIR_INIT_NVAR(&_13$$6); + zephir_substr(&_13$$6, &header, 0 , 5 , 0); + _10$$6 = ZEPHIR_IS_STRING(&_13$$6, "HTTP/"); + } + if (_10$$6) { + ZEPHIR_CALL_FUNCTION(NULL, "header", &_9, 360, &header, &__$true); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&_14$$8); + ZEPHIR_CONCAT_VS(&_14$$8, &header, ": "); + ZEPHIR_CALL_FUNCTION(NULL, "header", &_9, 360, &_14$$8, &__$true); + zephir_check_call_status(); + } + } + } ZEND_HASH_FOREACH_END(); } else { - zephir_read_property(&_2$$5, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&file, &_2$$5); - _3$$5 = Z_TYPE_P(&file) == IS_STRING; - if (_3$$5) { - _3$$5 = ((zephir_fast_strlen_ev(&file)) ? 1 : 0); - } - if (_3$$5) { - ZEPHIR_CALL_FUNCTION(NULL, "readfile", NULL, 356, &file); + ZEPHIR_CALL_METHOD(NULL, &_3, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_5, &_3, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_5)) { + break; + } + ZEPHIR_CALL_METHOD(&header, &_3, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&value, &_3, "current", NULL, 0); + zephir_check_call_status(); + if (Z_TYPE_P(&value) != IS_NULL) { + ZEPHIR_INIT_NVAR(&_15$$10); + ZEPHIR_CONCAT_VSV(&_15$$10, &header, ": ", &value); + ZEPHIR_CALL_FUNCTION(NULL, "header", &_9, 360, &_15$$10, &__$true); + zephir_check_call_status(); + } else { + _16$$11 = zephir_memnstr_str(&header, SL(":"), "phalcon/Http/Response/Headers.zep", 99); + if (!(_16$$11)) { + ZVAL_LONG(&_17$$11, 0); + ZVAL_LONG(&_18$$11, 5); + ZEPHIR_INIT_NVAR(&_19$$11); + zephir_substr(&_19$$11, &header, 0 , 5 , 0); + _16$$11 = ZEPHIR_IS_STRING(&_19$$11, "HTTP/"); + } + if (_16$$11) { + ZEPHIR_CALL_FUNCTION(NULL, "header", &_9, 360, &header, &__$true); + zephir_check_call_status(); + } else { + ZEPHIR_INIT_NVAR(&_20$$13); + ZEPHIR_CONCAT_VS(&_20$$13, &header, ": "); + ZEPHIR_CALL_FUNCTION(NULL, "header", &_9, 360, &_20$$13, &__$true); + zephir_check_call_status(); + } + } + ZEPHIR_CALL_METHOD(NULL, &_3, "next", NULL, 0); zephir_check_call_status(); } } + ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&header); if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("sent"), &__$true); + zephir_update_property_zval(this_ptr, ZEND_STRL("isSent"), &__$true); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("sent"), &__$false); + zephir_update_property_zval(this_ptr, ZEND_STRL("isSent"), &__$false); } - RETURN_THIS(); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Http_Response, sendCookies) +static PHP_METHOD(Phalcon_Http_Response_Headers, set) { - zval cookies, _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, *value_param = NULL; + zval name, value; zval *this_ptr = getThis(); - ZVAL_UNDEF(&cookies); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&value); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_STR(value) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - zephir_read_property(&_0, this_ptr, ZEND_STRL("cookies"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&cookies, &_0); - if (Z_TYPE_P(&cookies) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(NULL, &cookies, "send", NULL, 0); - zephir_check_call_status(); - } + zephir_fetch_params(1, 2, 0, &name_param, &value_param); + zephir_get_strval(&name, name_param); + zephir_get_strval(&value, value_param); + zephir_update_property_array(this_ptr, SL("headers"), &name, &value); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Response, sendHeaders) +static PHP_METHOD(Phalcon_Http_Response_Headers, setRaw) { - zend_bool _3; - zval eventsManager, headers, result, _0, _1$$3, _2$$3, _4$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *header_param = NULL, __$null; + zval header; zval *this_ptr = getThis(); - ZVAL_UNDEF(&eventsManager); - ZVAL_UNDEF(&headers); - ZVAL_UNDEF(&result); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&header); + ZVAL_NULL(&__$null); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(header) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &header_param); + zephir_get_strval(&header, header_param); + zephir_update_property_array(this_ptr, SL("headers"), &header, &__$null); + RETURN_THIS(); +} - zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&headers, &_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("eventsManager"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&eventsManager, &_0); - if (Z_TYPE_P(&eventsManager) == IS_OBJECT) { - ZEPHIR_INIT_VAR(&_2$$3); - ZVAL_STRING(&_2$$3, "response:beforeSendHeaders"); - ZEPHIR_CALL_METHOD(&_1$$3, &eventsManager, "fire", NULL, 0, &_2$$3, this_ptr); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$3)) { - RETURN_MM_BOOL(0); +static PHP_METHOD(Phalcon_Http_Response_Headers, toArray) +{ + + RETURN_MEMBER(getThis(), "headers"); +} + +zend_object *zephir_init_properties_Phalcon_Http_Response_Headers(zend_class_entry *class_type) +{ + zval _0, _1$$3; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + + + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + + { + zval local_this_ptr, *this_ptr = &local_this_ptr; + ZEPHIR_CREATE_OBJECT(this_ptr, class_type); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_0) == IS_NULL) { + ZEPHIR_INIT_VAR(&_1$$3); + array_init(&_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("headers"), &_1$$3); } + ZEPHIR_MM_RESTORE(); + return Z_OBJ_P(this_ptr); } - ZEPHIR_CALL_METHOD(&result, &headers, "send", NULL, 0); - zephir_check_call_status(); - _3 = ZEPHIR_IS_TRUE_IDENTICAL(&result); - if (_3) { - _3 = Z_TYPE_P(&eventsManager) == IS_OBJECT; - } - if (_3) { - ZEPHIR_INIT_VAR(&_4$$5); - ZVAL_STRING(&_4$$5, "response:afterSendHeaders"); - ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_4$$5, this_ptr); - zephir_check_call_status(); - } - RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Response, setCache) + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Http_Response_HeadersInterface) +{ + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http\\Response, HeadersInterface, phalcon, http_response_headersinterface, phalcon_http_response_headersinterface_method_entry); + + return SUCCESS; +} + +ZEPHIR_DOC_METHOD(Phalcon_Http_Response_HeadersInterface, get); +ZEPHIR_DOC_METHOD(Phalcon_Http_Response_HeadersInterface, has); +ZEPHIR_DOC_METHOD(Phalcon_Http_Response_HeadersInterface, reset); +ZEPHIR_DOC_METHOD(Phalcon_Http_Response_HeadersInterface, send); +ZEPHIR_DOC_METHOD(Phalcon_Http_Response_HeadersInterface, set); +ZEPHIR_DOC_METHOD(Phalcon_Http_Response_HeadersInterface, setRaw); + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Autoload_Exception) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Autoload, Exception, phalcon, autoload_exception, zend_ce_exception, NULL, 0); + + return SUCCESS; +} + + + + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Autoload_Loader) +{ + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Autoload, Loader, phalcon, autoload_loader, phalcon_events_abstracteventsaware_ce, phalcon_autoload_loader_method_entry, 0); + + zend_declare_property_null(phalcon_autoload_loader_ce, SL("checkedPath"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_autoload_loader_ce, SL("classes"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_autoload_loader_ce, SL("debug"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_autoload_loader_ce, SL("directories"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_autoload_loader_ce, SL("extensions"), ZEND_ACC_PROTECTED); + zend_declare_property_string(phalcon_autoload_loader_ce, SL("fileCheckingCallback"), "is_file", ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_autoload_loader_ce, SL("files"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_autoload_loader_ce, SL("foundPath"), ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_autoload_loader_ce, SL("isDebug"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_bool(phalcon_autoload_loader_ce, SL("isRegistered"), 0, ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_autoload_loader_ce, SL("namespaces"), ZEND_ACC_PROTECTED); + phalcon_autoload_loader_ce->create_object = zephir_init_properties_Phalcon_Autoload_Loader; + + return SUCCESS; +} + +static PHP_METHOD(Phalcon_Autoload_Loader, __construct) { - zval _1, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *minutes_param = NULL, date, _0, _2, _4; - zend_long minutes, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *isDebug_param = NULL, __$true, __$false, _0, _1, _2; + zend_bool isDebug; zval *this_ptr = getThis(); - ZVAL_UNDEF(&date); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(minutes) + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(isDebug) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &minutes_param); - if (UNEXPECTED(Z_TYPE_P(minutes_param) != IS_LONG)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'minutes' must be of the type int")); - RETURN_MM_NULL(); - } - minutes = Z_LVAL_P(minutes_param); - ZEPHIR_INIT_VAR(&date); - object_init_ex(&date, php_date_get_date_ce()); - ZEPHIR_CALL_METHOD(NULL, &date, "__construct", NULL, 0); - zephir_check_call_status(); + zephir_fetch_params(1, 0, 1, &isDebug_param); + if (!isDebug_param) { + isDebug = 0; + } else { + } ZEPHIR_INIT_VAR(&_0); - ZVAL_LONG(&_0, minutes); + ZVAL_STRING(&_0, "sha256"); ZEPHIR_INIT_VAR(&_1); - ZEPHIR_CONCAT_SVS(&_1, "+", &_0, " minutes"); - ZEPHIR_CALL_METHOD(NULL, &date, "modify", NULL, 0, &_1); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setexpires", NULL, 0, &date); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2); - ZVAL_LONG(&_2, ((minutes * 60))); - ZEPHIR_INIT_VAR(&_3); - ZEPHIR_CONCAT_SV(&_3, "max-age=", &_2); - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, "Cache-Control"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, &_4, &_3); + ZVAL_STRING(&_1, "php"); + ZEPHIR_CALL_FUNCTION(&_2, "hash", NULL, 71, &_0, &_1); zephir_check_call_status(); - RETURN_THIS(); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "php"); + zephir_update_property_array(this_ptr, SL("extensions"), &_2, &_0); + if (isDebug) { + zephir_update_property_zval(this_ptr, ZEND_STRL("isDebug"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("isDebug"), &__$false); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Http_Response, setContent) +static PHP_METHOD(Phalcon_Autoload_Loader, addClass) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *content_param = NULL; - zval content; + zval *name_param = NULL, *file_param = NULL; + zval name, file; zval *this_ptr = getThis(); - ZVAL_UNDEF(&content); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(content) + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&file); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(name) + Z_PARAM_STR(file) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &content_param); - zephir_get_strval(&content, content_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("content"), &content); + zephir_fetch_params(1, 2, 0, &name_param, &file_param); + zephir_get_strval(&name, name_param); + zephir_get_strval(&file, file_param); + zephir_update_property_array(this_ptr, SL("classes"), &name, &file); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Response, setContentLength) +static PHP_METHOD(Phalcon_Autoload_Loader, addDirectory) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *contentLength_param = NULL, _0, _1; - zend_long contentLength, ZEPHIR_LAST_CALL_STATUS; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *directory_param = NULL, _0, _1; + zval directory; zval *this_ptr = getThis(); + ZVAL_UNDEF(&directory); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_LONG(contentLength) + Z_PARAM_STR(directory) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &contentLength_param); + zephir_fetch_params(1, 1, 0, &directory_param); + zephir_get_strval(&directory, directory_param); ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "Content-Length"); - ZVAL_LONG(&_1, contentLength); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, &_0, &_1); + ZVAL_STRING(&_0, "sha256"); + ZEPHIR_CALL_FUNCTION(&_1, "hash", NULL, 71, &_0, &directory); zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("directories"), &_1, &directory); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Response, setContentType) +static PHP_METHOD(Phalcon_Autoload_Loader, addExtension) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *contentType_param = NULL, *charset = NULL, charset_sub, __$null, _0$$3, _1; - zval contentType; + zval *extension_param = NULL, _0, _1; + zval extension; zval *this_ptr = getThis(); - ZVAL_UNDEF(&contentType); - ZVAL_UNDEF(&charset_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&extension); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(contentType) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(charset) + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(extension) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &contentType_param, &charset); - zephir_get_strval(&contentType, contentType_param); - if (!charset) { - charset = &charset_sub; - charset = &__$null; - } - if (Z_TYPE_P(charset) != IS_NULL) { - ZEPHIR_INIT_VAR(&_0$$3); - ZEPHIR_CONCAT_SV(&_0$$3, "; charset=", charset); - zephir_concat_self(&contentType, &_0$$3); - } - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "Content-Type"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, &_1, &contentType); + zephir_fetch_params(1, 1, 0, &extension_param); + zephir_get_strval(&extension, extension_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "sha256"); + ZEPHIR_CALL_FUNCTION(&_1, "hash", NULL, 71, &_0, &extension); zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("extensions"), &_1, &extension); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Response, setCookies) -{ - zval *cookies, cookies_sub; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&cookies_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(cookies, phalcon_http_response_cookiesinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &cookies); - zephir_update_property_zval(this_ptr, ZEND_STRL("cookies"), cookies); - RETURN_THISW(); -} - -static PHP_METHOD(Phalcon_Http_Response, setDI) +static PHP_METHOD(Phalcon_Autoload_Loader, addFile) { - zval *container, container_sub; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *file_param = NULL, _0, _1; + zval file; zval *this_ptr = getThis(); - ZVAL_UNDEF(&container_sub); + ZVAL_UNDEF(&file); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(container, phalcon_di_diinterface_ce) + Z_PARAM_STR(file) ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &container); - zephir_update_property_zval(this_ptr, ZEND_STRL("container"), container); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &file_param); + zephir_get_strval(&file, file_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "sha256"); + ZEPHIR_CALL_FUNCTION(&_1, "hash", NULL, 71, &_0, &file); + zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("files"), &_1, &file); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Response, setEtag) +static PHP_METHOD(Phalcon_Autoload_Loader, addNamespace) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *etag_param = NULL, _0; - zval etag; + zend_bool prepend; + zval *name_param = NULL, *directories = NULL, directories_sub, *prepend_param = NULL, dirSeparator, nsName, nsSeparator, source, target, _0, _1, _2, _3, _5, _6, _7, _4$$3; + zval name; zval *this_ptr = getThis(); - ZVAL_UNDEF(&etag); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&directories_sub); + ZVAL_UNDEF(&dirSeparator); + ZVAL_UNDEF(&nsName); + ZVAL_UNDEF(&nsSeparator); + ZVAL_UNDEF(&source); + ZVAL_UNDEF(&target); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(etag) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_4$$3); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_STR(name) + Z_PARAM_ZVAL(directories) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(prepend) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &etag_param); - zephir_get_strval(&etag, etag_param); + zephir_fetch_params(1, 2, 1, &name_param, &directories, &prepend_param); + zephir_get_strval(&name, name_param); + ZEPHIR_SEPARATE_PARAM(directories); + if (!prepend_param) { + prepend = 0; + } else { + } + ZEPHIR_CPY_WRT(&nsName, &name); + ZEPHIR_INIT_VAR(&nsSeparator); + ZVAL_STRING(&nsSeparator, "\\"); + ZEPHIR_INIT_VAR(&dirSeparator); + ZVAL_STRING(&dirSeparator, "/"); ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "Etag"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, &_0, &etag); + zephir_fast_trim(&_0, &nsName, &nsSeparator, ZEPHIR_TRIM_BOTH); + ZEPHIR_INIT_VAR(&_1); + ZEPHIR_CONCAT_VV(&_1, &_0, &nsSeparator); + ZEPHIR_CPY_WRT(&nsName, &_1); + ZEPHIR_CALL_METHOD(&_2, this_ptr, "checkdirectories", NULL, 179, directories, &dirSeparator); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(directories, &_2); + zephir_read_property(&_3, this_ptr, ZEND_STRL("namespaces"), PH_NOISY_CC | PH_READONLY); + if (!(zephir_array_isset(&_3, &nsName))) { + ZEPHIR_INIT_VAR(&_4$$3); + array_init(&_4$$3); + zephir_update_property_array(this_ptr, SL("namespaces"), &nsName, &_4$$3); + } + if (prepend) { + ZEPHIR_CPY_WRT(&source, directories); + } else { + zephir_read_property(&_5, this_ptr, ZEND_STRL("namespaces"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_OBS_NVAR(&source); + zephir_array_fetch(&source, &_5, &nsName, PH_NOISY, "phalcon/Autoload/Loader.zep", 169); + } + if (prepend) { + zephir_read_property(&_6, this_ptr, ZEND_STRL("namespaces"), PH_NOISY_CC | PH_READONLY); + zephir_memory_observe(&target); + zephir_array_fetch(&target, &_6, &nsName, PH_NOISY, "phalcon/Autoload/Loader.zep", 170); + } else { + ZEPHIR_CPY_WRT(&target, directories); + } + ZEPHIR_INIT_VAR(&_7); + zephir_fast_array_merge(&_7, &source, &target); + ZEPHIR_CALL_FUNCTION(&_2, "array_unique", NULL, 180, &_7); zephir_check_call_status(); + zephir_update_property_array(this_ptr, SL("namespaces"), &nsName, &_2); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Response, setExpires) +static PHP_METHOD(Phalcon_Autoload_Loader, autoload) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *datetime, datetime_sub, date, _0, _1, _2, _3; + zval *className_param = NULL, _0, _2, _3, _5, _7, _8, _9; + zval className, _1, _4, _6, _10; zval *this_ptr = getThis(); - ZVAL_UNDEF(&datetime_sub); - ZVAL_UNDEF(&date); - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&className); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(datetime, php_date_get_date_ce()) + Z_PARAM_STR(className) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &datetime); - ZEPHIR_INIT_VAR(&date); - if (zephir_clone(&date, datetime) == FAILURE) { - RETURN_MM(); - } + zephir_fetch_params(1, 1, 0, &className_param); + zephir_get_strval(&className, className_param); ZEPHIR_INIT_VAR(&_0); - object_init_ex(&_0, php_date_get_timezone_ce()); + array_init(&_0); + zephir_update_property_zval(this_ptr, ZEND_STRL("debug"), &_0); ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "UTC"); - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0, &_1); + ZEPHIR_CONCAT_SV(&_1, "Loading: ", &className); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "adddebug", NULL, 181, &_1); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &date, "settimezone", NULL, 0, &_0); + ZEPHIR_INIT_VAR(&_2); + ZVAL_STRING(&_2, "loader:beforeCheckClass"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "firemanagerevent", NULL, 0, &_2, &className); zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "D, d M Y H:i:s"); - ZEPHIR_CALL_METHOD(&_2, &date, "format", NULL, 0, &_1); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "autoloadcheckclasses", NULL, 182, &className); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_3); - ZEPHIR_CONCAT_VS(&_3, &_2, " GMT"); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "Expires"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, &_1, &_3); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_3)) { + RETURN_MM_BOOL(1); + } + ZEPHIR_INIT_VAR(&_4); + ZEPHIR_CONCAT_SV(&_4, "Class: 404: ", &className); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "adddebug", NULL, 181, &_4); zephir_check_call_status(); - RETURN_THIS(); + ZEPHIR_CALL_METHOD(&_5, this_ptr, "autoloadchecknamespaces", NULL, 183, &className); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_5)) { + RETURN_MM_BOOL(1); + } + ZEPHIR_INIT_VAR(&_6); + ZEPHIR_CONCAT_SV(&_6, "Namespace: 404: ", &className); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "adddebug", NULL, 181, &_6); + zephir_check_call_status(); + zephir_read_property(&_8, this_ptr, ZEND_STRL("directories"), PH_NOISY_CC | PH_READONLY); + ZVAL_BOOL(&_9, 1); + ZEPHIR_CALL_METHOD(&_7, this_ptr, "autoloadcheckdirectories", NULL, 184, &_8, &className, &_9); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_7)) { + RETURN_MM_BOOL(1); + } + ZEPHIR_INIT_VAR(&_10); + ZEPHIR_CONCAT_SV(&_10, "Directories: 404: ", &className); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "adddebug", NULL, 181, &_10); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_2); + ZVAL_STRING(&_2, "loader:afterCheckClass"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "firemanagerevent", NULL, 0, &_2, &className); + zephir_check_call_status(); + RETURN_MM_BOOL(0); } -static PHP_METHOD(Phalcon_Http_Response, setEventsManager) +static PHP_METHOD(Phalcon_Autoload_Loader, getCheckedPath) { - zval *eventsManager, eventsManager_sub; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&eventsManager_sub); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(eventsManager, phalcon_events_managerinterface_ce) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &eventsManager); - zephir_update_property_zval(this_ptr, ZEND_STRL("eventsManager"), eventsManager); + RETURN_MEMBER(getThis(), "checkedPath"); } -static PHP_METHOD(Phalcon_Http_Response, setFileToSend) +static PHP_METHOD(Phalcon_Autoload_Loader, getClasses) +{ + + RETURN_MEMBER(getThis(), "classes"); +} + +static PHP_METHOD(Phalcon_Autoload_Loader, getDebug) +{ + + RETURN_MEMBER(getThis(), "debug"); +} + +static PHP_METHOD(Phalcon_Autoload_Loader, getDirectories) +{ + + RETURN_MEMBER(getThis(), "directories"); +} + +static PHP_METHOD(Phalcon_Autoload_Loader, getExtensions) +{ + + RETURN_MEMBER(getThis(), "extensions"); +} + +static PHP_METHOD(Phalcon_Autoload_Loader, getFiles) +{ + + RETURN_MEMBER(getThis(), "files"); +} + +static PHP_METHOD(Phalcon_Autoload_Loader, getFoundPath) +{ + + RETURN_MEMBER(getThis(), "foundPath"); +} + +static PHP_METHOD(Phalcon_Autoload_Loader, getNamespaces) +{ + + RETURN_MEMBER(getThis(), "namespaces"); +} + +static PHP_METHOD(Phalcon_Autoload_Loader, loadFiles) { + zval file, files, _0, *_1, _2, _3$$3, _5$$3, _7$$4, _8$$5, _9$$5, _10$$6; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL, *_6 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *filePath_param = NULL, *attachmentName = NULL, attachmentName_sub, *attachment = NULL, attachment_sub, __$true, __$null, basePath, basePathEncoding, _0$$6, _1$$5, _2$$7, _3$$7, _4$$7, _5$$8, _6$$8, _7$$8; - zval filePath; zval *this_ptr = getThis(); - ZVAL_UNDEF(&filePath); - ZVAL_UNDEF(&attachmentName_sub); - ZVAL_UNDEF(&attachment_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&basePath); - ZVAL_UNDEF(&basePathEncoding); - ZVAL_UNDEF(&_0$$6); - ZVAL_UNDEF(&_1$$5); - ZVAL_UNDEF(&_2$$7); - ZVAL_UNDEF(&_3$$7); - ZVAL_UNDEF(&_4$$7); - ZVAL_UNDEF(&_5$$8); - ZVAL_UNDEF(&_6$$8); - ZVAL_UNDEF(&_7$$8); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(filePath) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(attachmentName) - Z_PARAM_ZVAL(attachment) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&file); + ZVAL_UNDEF(&files); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_10$$6); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &filePath_param, &attachmentName, &attachment); - zephir_get_strval(&filePath, filePath_param); - if (!attachmentName) { - attachmentName = &attachmentName_sub; - attachmentName = &__$null; - } - if (!attachment) { - attachment = &attachment_sub; - attachment = &__$true; - } - ZEPHIR_INIT_VAR(&basePathEncoding); - ZVAL_STRING(&basePathEncoding, "ASCII"); - if (Z_TYPE_P(attachmentName) != IS_STRING) { - ZEPHIR_CALL_METHOD(&basePath, this_ptr, "getbasename", NULL, 357, &filePath); - zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&basePath, attachmentName); - } - if (zephir_is_true(attachment)) { - if ((zephir_function_exists_ex(ZEND_STRL("mb_detect_encoding")) == SUCCESS)) { - ZEPHIR_CALL_FUNCTION(&_0$$6, "mb_detect_order", NULL, 358); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("files"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&files, &_0); + zephir_is_iterable(&files, 0, "phalcon/Autoload/Loader.zep", 322); + if (Z_TYPE_P(&files) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&files), _1) + { + ZEPHIR_INIT_NVAR(&file); + ZVAL_COPY(&file, _1); + ZEPHIR_INIT_NVAR(&_3$$3); + ZVAL_STRING(&_3$$3, "loader:beforeCheckPath"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "firemanagerevent", &_4, 0, &_3$$3, &file); zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(&basePathEncoding, "mb_detect_encoding", NULL, 323, &basePath, &_0$$6, &__$true); + ZEPHIR_CALL_METHOD(&_5$$3, this_ptr, "requirefile", &_6, 0, &file); zephir_check_call_status(); - } - ZEPHIR_INIT_VAR(&_1$$5); - ZVAL_STRING(&_1$$5, "Content-Description: File Transfer"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setrawheader", NULL, 0, &_1$$5); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_1$$5); - ZVAL_STRING(&_1$$5, "Content-Type: application/octet-stream"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setrawheader", NULL, 0, &_1$$5); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_1$$5); - ZVAL_STRING(&_1$$5, "Content-Transfer-Encoding: binary"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setrawheader", NULL, 0, &_1$$5); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_5$$3)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("foundPath"), &file); + ZEPHIR_INIT_NVAR(&_7$$4); + ZVAL_STRING(&_7$$4, "loader:pathFound"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "firemanagerevent", &_4, 0, &_7$$4, &file); + zephir_check_call_status(); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &files, "rewind", NULL, 0); zephir_check_call_status(); - if (!ZEPHIR_IS_STRING(&basePathEncoding, "ASCII")) { - ZEPHIR_CALL_FUNCTION(&_2$$7, "rawurlencode", NULL, 327, &basePath); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&basePath, &_2$$7); - ZEPHIR_INIT_VAR(&_3$$7); - zephir_fast_strtolower(&_3$$7, &basePathEncoding); - ZEPHIR_INIT_VAR(&_4$$7); - ZEPHIR_CONCAT_SVSVSV(&_4$$7, "Content-Disposition: attachment; filename=", &basePath, "; filename*=", &_3$$7, "''", &basePath); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setrawheader", NULL, 0, &_4$$7); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &files, "valid", NULL, 0); zephir_check_call_status(); - } else { - ZEPHIR_INIT_VAR(&_5$$8); - ZVAL_STRING(&_5$$8, "\15\17\\\""); - ZEPHIR_CALL_FUNCTION(&_6$$8, "addcslashes", NULL, 215, &basePath, &_5$$8); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&file, &files, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_CPY_WRT(&basePath, &_6$$8); - ZEPHIR_INIT_VAR(&_7$$8); - ZEPHIR_CONCAT_SVS(&_7$$8, "Content-Disposition: attachment; filename=\"", &basePath, "\""); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setrawheader", NULL, 0, &_7$$8); + ZEPHIR_INIT_NVAR(&_8$$5); + ZVAL_STRING(&_8$$5, "loader:beforeCheckPath"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "firemanagerevent", &_4, 0, &_8$$5, &file); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_9$$5, this_ptr, "requirefile", &_6, 0, &file); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_9$$5)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("foundPath"), &file); + ZEPHIR_INIT_NVAR(&_10$$6); + ZVAL_STRING(&_10$$6, "loader:pathFound"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "firemanagerevent", &_4, 0, &_10$$6, &file); + zephir_check_call_status(); + } + ZEPHIR_CALL_METHOD(NULL, &files, "next", NULL, 0); zephir_check_call_status(); } } - zephir_update_property_zval(this_ptr, ZEND_STRL("file"), &filePath); - RETURN_THIS(); + ZEPHIR_INIT_NVAR(&file); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Http_Response, setHeader) +static PHP_METHOD(Phalcon_Autoload_Loader, register) { + zval _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, *value, value_sub, _0; - zval name; + zval *prepend_param = NULL, __$true, __$false, _0, _2$$3, _3$$3; + zend_bool prepend; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&value_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_ZVAL(value) + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(prepend) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &value); - zephir_get_strval(&name, name_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "set", NULL, 0, &name, value); - zephir_check_call_status(); + zephir_fetch_params(1, 0, 1, &prepend_param); + if (!prepend_param) { + prepend = 0; + } else { + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("isRegistered"), PH_NOISY_CC | PH_READONLY); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_CALL_METHOD(NULL, this_ptr, "loadfiles", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1$$3); + zephir_create_array(&_1$$3, 2, 0); + zephir_array_fast_append(&_1$$3, this_ptr); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "autoload"); + zephir_array_fast_append(&_1$$3, &_2$$3); + ZVAL_BOOL(&_3$$3, (prepend ? 1 : 0)); + ZEPHIR_CALL_FUNCTION(NULL, "spl_autoload_register", NULL, 185, &_1$$3, &__$true, &_3$$3); + zephir_check_call_status(); + if (1) { + zephir_update_property_zval(this_ptr, ZEND_STRL("isRegistered"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("isRegistered"), &__$false); + } + } RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Response, setHeaders) +static PHP_METHOD(Phalcon_Autoload_Loader, setClasses) { - zend_string *_3; - zend_ulong _2; + zend_string *_4; + zend_ulong _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_5 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *headers, headers_sub, data, name, value, *_0, _1, _4$$3, _5$$4; + zend_bool merge; + zval *classes_param = NULL, *merge_param = NULL, className, name, *_1, _2, _0$$3; + zval classes; zval *this_ptr = getThis(); - ZVAL_UNDEF(&headers_sub); - ZVAL_UNDEF(&data); + ZVAL_UNDEF(&classes); + ZVAL_UNDEF(&className); ZVAL_UNDEF(&name); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_4$$3); - ZVAL_UNDEF(&_5$$4); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(headers, phalcon_http_response_headersinterface_ce) + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_0$$3); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(classes) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(merge) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &headers); - ZEPHIR_CALL_METHOD(&data, headers, "toarray", NULL, 0); - zephir_check_call_status(); - zephir_is_iterable(&data, 0, "phalcon/Http/Response.zep", 628); - if (Z_TYPE_P(&data) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _2, _3, _0) + zephir_fetch_params(1, 1, 1, &classes_param, &merge_param); + zephir_get_arrval(&classes, classes_param); + if (!merge_param) { + merge = 0; + } else { + } + if (!merge) { + ZEPHIR_INIT_VAR(&_0$$3); + array_init(&_0$$3); + zephir_update_property_zval(this_ptr, ZEND_STRL("classes"), &_0$$3); + } + zephir_is_iterable(&classes, 0, "phalcon/Autoload/Loader.zep", 364); + if (Z_TYPE_P(&classes) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&classes), _3, _4, _1) { ZEPHIR_INIT_NVAR(&name); - if (_3 != NULL) { - ZVAL_STR_COPY(&name, _3); + if (_4 != NULL) { + ZVAL_STR_COPY(&name, _4); } else { - ZVAL_LONG(&name, _2); + ZVAL_LONG(&name, _3); } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _0); - zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_4$$3, "set", NULL, 0, &name, &value); + ZEPHIR_INIT_NVAR(&className); + ZVAL_COPY(&className, _1); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addclass", &_5, 0, &name, &className); zephir_check_call_status(); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &data, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &classes, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_1, &data, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_2, &classes, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_1)) { + if (!zend_is_true(&_2)) { break; } - ZEPHIR_CALL_METHOD(&name, &data, "key", NULL, 0); + ZEPHIR_CALL_METHOD(&name, &classes, "key", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &data, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&className, &classes, "current", NULL, 0); zephir_check_call_status(); - zephir_read_property(&_5$$4, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_5$$4, "set", NULL, 0, &name, &value); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addclass", &_5, 0, &name, &className); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &data, "next", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &classes, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&value); + ZEPHIR_INIT_NVAR(&className); ZEPHIR_INIT_NVAR(&name); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Response, setJsonContent) +static PHP_METHOD(Phalcon_Autoload_Loader, setDirectories) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long jsonOptions, depth, ZEPHIR_LAST_CALL_STATUS; - zval *content, content_sub, *jsonOptions_param = NULL, *depth_param = NULL, _0, _1, _2, _3, _4; + zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool merge; + zval *directories_param = NULL, *merge_param = NULL, _0, _1, _2; + zval directories; zval *this_ptr = getThis(); - ZVAL_UNDEF(&content_sub); + ZVAL_UNDEF(&directories); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ZVAL(content) + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(directories) Z_PARAM_OPTIONAL - Z_PARAM_LONG(jsonOptions) - Z_PARAM_LONG(depth) + Z_PARAM_BOOL(merge) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &content, &jsonOptions_param, &depth_param); - if (!jsonOptions_param) { - jsonOptions = 0; - } else { - } - if (!depth_param) { - depth = 512; + zephir_fetch_params(1, 1, 1, &directories_param, &merge_param); + zephir_get_arrval(&directories, directories_param); + if (!merge_param) { + merge = 0; } else { } ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "application/json"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setcontenttype", NULL, 0, &_0); - zephir_check_call_status(); - zephir_read_property(&_1, this_ptr, ZEND_STRL("encode"), PH_NOISY_CC | PH_READONLY); - ZVAL_LONG(&_3, jsonOptions); - ZVAL_LONG(&_4, depth); - ZEPHIR_CALL_METHOD(&_2, &_1, "__invoke", NULL, 0, content, &_3, &_4); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setcontent", NULL, 0, &_2); - zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Http_Response, setLastModified) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *datetime, datetime_sub, date, _0, _1, _2, _3; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&datetime_sub); - ZVAL_UNDEF(&date); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(datetime, php_date_get_date_ce()) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &datetime); - ZEPHIR_INIT_VAR(&date); - if (zephir_clone(&date, datetime) == FAILURE) { - RETURN_MM(); - } - ZEPHIR_INIT_VAR(&_0); - object_init_ex(&_0, php_date_get_timezone_ce()); + ZVAL_STRING(&_0, "directories"); ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "UTC"); - ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0, &_1); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &date, "settimezone", NULL, 0, &_0); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "D, d M Y H:i:s"); - ZEPHIR_CALL_METHOD(&_2, &date, "format", NULL, 0, &_1); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_3); - ZEPHIR_CONCAT_VS(&_3, &_2, " GMT"); - ZEPHIR_INIT_NVAR(&_1); - ZVAL_STRING(&_1, "Last-Modified"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setheader", NULL, 0, &_1, &_3); + ZVAL_STRING(&_1, "addDirectory"); + if (merge) { + ZVAL_BOOL(&_2, 1); + } else { + ZVAL_BOOL(&_2, 0); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addtocollection", NULL, 186, &directories, &_0, &_1, &_2); zephir_check_call_status(); - RETURN_THIS(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Http_Response, setNotModified) +static PHP_METHOD(Phalcon_Autoload_Loader, setExtensions) { - zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_6 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool merge; + zval *extensions_param = NULL, *merge_param = NULL, extension, *_4, _5, _0$$3, _1$$3, _2$$3, _3$$3; + zval extensions; zval *this_ptr = getThis(); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZVAL_LONG(&_0, 304); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "Not modified"); - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setstatuscode", NULL, 0, &_0, &_1); - zephir_check_call_status(); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Http_Response, setStatusCode) -{ - zend_bool _6$$3, _11$$5; - zend_string *_5; - zend_ulong _4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_9 = NULL; - zval message, _17, _20; - zval *code_param = NULL, *message_param = NULL, currentHeadersRaw, key, statusCodes, defaultMessage, _0, _1, *_2, _3, _15, _16, _18, _19, _21, _7$$3, _8$$3, _10$$4, _12$$5, _13$$5, _14$$6; - zend_long code, ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(¤tHeadersRaw); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&statusCodes); - ZVAL_UNDEF(&defaultMessage); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_15); - ZVAL_UNDEF(&_16); - ZVAL_UNDEF(&_18); - ZVAL_UNDEF(&_19); - ZVAL_UNDEF(&_21); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_10$$4); - ZVAL_UNDEF(&_12$$5); - ZVAL_UNDEF(&_13$$5); - ZVAL_UNDEF(&_14$$6); - ZVAL_UNDEF(&message); - ZVAL_UNDEF(&_17); - ZVAL_UNDEF(&_20); - bool is_null_true = 1; + ZVAL_UNDEF(&extensions); + ZVAL_UNDEF(&extension); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_LONG(code) + Z_PARAM_ARRAY(extensions) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(message) + Z_PARAM_BOOL(merge) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &code_param, &message_param); - if (!message_param) { - ZEPHIR_INIT_VAR(&message); + zephir_fetch_params(1, 1, 1, &extensions_param, &merge_param); + zephir_get_arrval(&extensions, extensions_param); + if (!merge_param) { + merge = 0; } else { - zephir_get_strval(&message, message_param); + } + if (!merge) { + ZEPHIR_INIT_VAR(&_0$$3); + array_init(&_0$$3); + zephir_update_property_zval(this_ptr, ZEND_STRL("extensions"), &_0$$3); + ZEPHIR_INIT_VAR(&_1$$3); + ZVAL_STRING(&_1$$3, "sha256"); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "php"); + ZEPHIR_CALL_FUNCTION(&_3$$3, "hash", NULL, 71, &_1$$3, &_2$$3); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_1$$3); + ZVAL_STRING(&_1$$3, "php"); + zephir_update_property_array(this_ptr, SL("extensions"), &_3$$3, &_1$$3); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(¤tHeadersRaw, &_0, "toarray", NULL, 0); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_1); - zephir_is_iterable(¤tHeadersRaw, 0, "phalcon/Http/Response.zep", 717); - if (Z_TYPE_P(¤tHeadersRaw) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(¤tHeadersRaw), _4, _5, _2) + zephir_is_iterable(&extensions, 0, "phalcon/Autoload/Loader.zep", 407); + if (Z_TYPE_P(&extensions) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&extensions), _4) { - ZEPHIR_INIT_NVAR(&key); - if (_5 != NULL) { - ZVAL_STR_COPY(&key, _5); - } else { - ZVAL_LONG(&key, _4); - } - ZEPHIR_INIT_NVAR(&_1); - ZVAL_COPY(&_1, _2); - _6$$3 = Z_TYPE_P(&key) == IS_STRING; - if (_6$$3) { - ZEPHIR_INIT_NVAR(&_7$$3); - ZVAL_STRING(&_7$$3, "HTTP/"); - ZEPHIR_CALL_FUNCTION(&_8$$3, "strstr", &_9, 355, &key, &_7$$3); - zephir_check_call_status(); - _6$$3 = zephir_is_true(&_8$$3); - } - if (_6$$3) { - zephir_read_property(&_10$$4, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_10$$4, "remove", NULL, 0, &key); - zephir_check_call_status(); - } + ZEPHIR_INIT_NVAR(&extension); + ZVAL_COPY(&extension, _4); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addextension", &_6, 0, &extension); + zephir_check_call_status(); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, ¤tHeadersRaw, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &extensions, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_3, ¤tHeadersRaw, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_5, &extensions, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_3)) { + if (!zend_is_true(&_5)) { break; } - ZEPHIR_CALL_METHOD(&key, ¤tHeadersRaw, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, ¤tHeadersRaw, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&extension, &extensions, "current", NULL, 0); zephir_check_call_status(); - _11$$5 = Z_TYPE_P(&key) == IS_STRING; - if (_11$$5) { - ZEPHIR_INIT_NVAR(&_12$$5); - ZVAL_STRING(&_12$$5, "HTTP/"); - ZEPHIR_CALL_FUNCTION(&_13$$5, "strstr", &_9, 355, &key, &_12$$5); - zephir_check_call_status(); - _11$$5 = zephir_is_true(&_13$$5); - } - if (_11$$5) { - zephir_read_property(&_14$$6, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_14$$6, "remove", NULL, 0, &key); - zephir_check_call_status(); - } - ZEPHIR_CALL_METHOD(NULL, ¤tHeadersRaw, "next", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addextension", &_6, 0, &extension); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &extensions, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&_1); - ZEPHIR_INIT_NVAR(&key); - if (ZEPHIR_IS_NULL(&message)) { - ZEPHIR_INIT_VAR(&statusCodes); - zephir_create_array(&statusCodes, 89, 0); - add_index_stringl(&statusCodes, 100, SL("Continue")); - add_index_stringl(&statusCodes, 101, SL("Switching Protocols")); - add_index_stringl(&statusCodes, 102, SL("Processing")); - add_index_stringl(&statusCodes, 103, SL("Early Hints")); - add_index_stringl(&statusCodes, 200, SL("OK")); - add_index_stringl(&statusCodes, 201, SL("Created")); - add_index_stringl(&statusCodes, 202, SL("Accepted")); - add_index_stringl(&statusCodes, 203, SL("Non-Authoritative Information")); - add_index_stringl(&statusCodes, 204, SL("No Content")); - add_index_stringl(&statusCodes, 205, SL("Reset Content")); - add_index_stringl(&statusCodes, 206, SL("Partial Content")); - add_index_stringl(&statusCodes, 207, SL("Multi-status")); - add_index_stringl(&statusCodes, 208, SL("Already Reported")); - add_index_stringl(&statusCodes, 226, SL("IM Used")); - add_index_stringl(&statusCodes, 300, SL("Multiple Choices")); - add_index_stringl(&statusCodes, 301, SL("Moved Permanently")); - add_index_stringl(&statusCodes, 302, SL("Found")); - add_index_stringl(&statusCodes, 303, SL("See Other")); - add_index_stringl(&statusCodes, 304, SL("Not Modified")); - add_index_stringl(&statusCodes, 305, SL("Use Proxy")); - add_index_stringl(&statusCodes, 306, SL("Switch Proxy")); - add_index_stringl(&statusCodes, 307, SL("Temporary Redirect")); - add_index_stringl(&statusCodes, 308, SL("Permanent Redirect")); - add_index_stringl(&statusCodes, 400, SL("Bad Request")); - add_index_stringl(&statusCodes, 401, SL("Unauthorized")); - add_index_stringl(&statusCodes, 402, SL("Payment Required")); - add_index_stringl(&statusCodes, 403, SL("Forbidden")); - add_index_stringl(&statusCodes, 404, SL("Not Found")); - add_index_stringl(&statusCodes, 405, SL("Method Not Allowed")); - add_index_stringl(&statusCodes, 406, SL("Not Acceptable")); - add_index_stringl(&statusCodes, 407, SL("Proxy Authentication Required")); - add_index_stringl(&statusCodes, 408, SL("Request Time-out")); - add_index_stringl(&statusCodes, 409, SL("Conflict")); - add_index_stringl(&statusCodes, 410, SL("Gone")); - add_index_stringl(&statusCodes, 411, SL("Length Required")); - add_index_stringl(&statusCodes, 412, SL("Precondition Failed")); - add_index_stringl(&statusCodes, 413, SL("Request Entity Too Large")); - add_index_stringl(&statusCodes, 414, SL("Request-URI Too Large")); - add_index_stringl(&statusCodes, 415, SL("Unsupported Media Type")); - add_index_stringl(&statusCodes, 416, SL("Requested range not satisfiable")); - add_index_stringl(&statusCodes, 417, SL("Expectation Failed")); - add_index_stringl(&statusCodes, 418, SL("I'm a teapot")); - add_index_stringl(&statusCodes, 421, SL("Misdirected Request")); - add_index_stringl(&statusCodes, 422, SL("Unprocessable Entity")); - add_index_stringl(&statusCodes, 423, SL("Locked")); - add_index_stringl(&statusCodes, 424, SL("Failed Dependency")); - add_index_stringl(&statusCodes, 425, SL("Unordered Collection")); - add_index_stringl(&statusCodes, 426, SL("Upgrade Required")); - add_index_stringl(&statusCodes, 428, SL("Precondition Required")); - add_index_stringl(&statusCodes, 429, SL("Too Many Requests")); - add_index_stringl(&statusCodes, 431, SL("Request Header Fields Too Large")); - add_index_stringl(&statusCodes, 451, SL("Unavailable For Legal Reasons")); - add_index_stringl(&statusCodes, 500, SL("Internal Server Error")); - add_index_stringl(&statusCodes, 501, SL("Not Implemented")); - add_index_stringl(&statusCodes, 502, SL("Bad Gateway")); - add_index_stringl(&statusCodes, 503, SL("Service Unavailable")); - add_index_stringl(&statusCodes, 504, SL("Gateway Time-out")); - add_index_stringl(&statusCodes, 505, SL("HTTP Version not supported")); - add_index_stringl(&statusCodes, 506, SL("Variant Also Negotiates")); - add_index_stringl(&statusCodes, 507, SL("Insufficient Storage")); - add_index_stringl(&statusCodes, 508, SL("Loop Detected")); - add_index_stringl(&statusCodes, 510, SL("Not Extended")); - add_index_stringl(&statusCodes, 511, SL("Network Authentication Required")); - add_index_stringl(&statusCodes, 218, SL("This is fine")); - add_index_stringl(&statusCodes, 419, SL("Page Expired")); - add_index_stringl(&statusCodes, 420, SL("Method Failure")); - add_index_stringl(&statusCodes, 440, SL("Login Time-out")); - add_index_stringl(&statusCodes, 444, SL("No Response")); - add_index_stringl(&statusCodes, 449, SL("Retry With")); - add_index_stringl(&statusCodes, 450, SL("Blocked by Windows Parental Controls (Microsoft)")); - add_index_stringl(&statusCodes, 494, SL("Request header too large")); - add_index_stringl(&statusCodes, 495, SL("SSL Certificate Error")); - add_index_stringl(&statusCodes, 496, SL("SSL Certificate Required")); - add_index_stringl(&statusCodes, 497, SL("HTTP Request Sent to HTTPS Port")); - add_index_stringl(&statusCodes, 498, SL("Invalid Token (Esri)")); - add_index_stringl(&statusCodes, 499, SL("Client Closed Request")); - add_index_stringl(&statusCodes, 509, SL("Bandwidth Limit Exceeded")); - add_index_stringl(&statusCodes, 520, SL("Unknown Error")); - add_index_stringl(&statusCodes, 521, SL("Web Server Is Down")); - add_index_stringl(&statusCodes, 522, SL("Connection Timed Out")); - add_index_stringl(&statusCodes, 523, SL("Origin Is Unreachable")); - add_index_stringl(&statusCodes, 524, SL("A Timeout Occurred")); - add_index_stringl(&statusCodes, 525, SL("SSL Handshake Failed")); - add_index_stringl(&statusCodes, 526, SL("Invalid SSL Certificate")); - add_index_stringl(&statusCodes, 527, SL("Railgun Error")); - add_index_stringl(&statusCodes, 530, SL("Origin DNS Error")); - add_index_stringl(&statusCodes, 598, SL("Network read timeout error")); - add_index_stringl(&statusCodes, 599, SL("Network Connect Timeout Error")); - if (UNEXPECTED(!(zephir_array_isset_long(&statusCodes, code)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_response_exception_ce, "Non-standard statuscode given without a message", "phalcon/Http/Response.zep", 824); - return; - } - zephir_memory_observe(&defaultMessage); - zephir_array_fetch_long(&defaultMessage, &statusCodes, code, PH_NOISY, "phalcon/Http/Response.zep", 827); - zephir_get_strval(&message, &defaultMessage); + ZEPHIR_INIT_NVAR(&extension); + RETURN_THIS(); +} + +static PHP_METHOD(Phalcon_Autoload_Loader, setFileCheckingCallback) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *method = NULL, method_sub, __$null, _0$$4; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&method_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0$$4); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(method) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 1, &method); + if (!method) { + method = &method_sub; + method = &__$null; + } + if (1 == zephir_is_callable(method)) { + zephir_update_property_zval(this_ptr, ZEND_STRL("fileCheckingCallback"), method); + } else if (Z_TYPE_P(method) == IS_NULL) { + ZEPHIR_INIT_VAR(&_0$$4); + ZEPHIR_INIT_NVAR(&_0$$4); + zephir_create_closure_ex(&_0$$4, NULL, phalcon_6__closure_ce, SL("__invoke")); + zephir_update_property_zval(this_ptr, ZEND_STRL("fileCheckingCallback"), &_0$$4); + } else { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_autoload_exception_ce, "The 'method' parameter must be either a callable or NULL", "phalcon/Autoload/Loader.zep", 441); + return; } - zephir_read_property(&_15, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_16); - ZVAL_LONG(&_16, code); - ZEPHIR_INIT_VAR(&_17); - ZEPHIR_CONCAT_SVSV(&_17, "HTTP/1.1 ", &_16, " ", &message); - ZEPHIR_CALL_METHOD(NULL, &_15, "setraw", NULL, 0, &_17); - zephir_check_call_status(); - zephir_read_property(&_18, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_19); - ZVAL_LONG(&_19, code); - ZEPHIR_INIT_VAR(&_20); - ZEPHIR_CONCAT_VSV(&_20, &_19, " ", &message); - ZEPHIR_INIT_VAR(&_21); - ZVAL_STRING(&_21, "Status"); - ZEPHIR_CALL_METHOD(NULL, &_18, "set", NULL, 0, &_21, &_20); - zephir_check_call_status(); RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Response, setRawHeader) +static PHP_METHOD(Phalcon_Autoload_Loader, setFiles) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *header_param = NULL, _0; - zval header; + zend_bool merge; + zval *files_param = NULL, *merge_param = NULL, _0, _1, _2; + zval files; zval *this_ptr = getThis(); - ZVAL_UNDEF(&header); + ZVAL_UNDEF(&files); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(header) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ARRAY(files) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(merge) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &header_param); - zephir_get_strval(&header, header_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &_0, "setraw", NULL, 0, &header); + zephir_fetch_params(1, 1, 1, &files_param, &merge_param); + zephir_get_arrval(&files, files_param); + if (!merge_param) { + merge = 0; + } else { + } + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "files"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "addFile"); + if (merge) { + ZVAL_BOOL(&_2, 1); + } else { + ZVAL_BOOL(&_2, 0); + } + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "addtocollection", NULL, 186, &files, &_0, &_1, &_2); zephir_check_call_status(); - RETURN_THIS(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Http_Response, getBasename) +static PHP_METHOD(Phalcon_Autoload_Loader, setNamespaces) { + zend_string *_4; + zend_ulong _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_6 = NULL, *_7 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *uri_param = NULL, *suffix = NULL, suffix_sub, __$null, filename, matches, _0, _1, _2, _3, _4, _5, _6$$3, _7$$3, _8$$3, _9$$3; - zval uri; + zend_bool merge; + zval *namespaces_param = NULL, *merge_param = NULL, dirSeparator, directories, name, *_1, _2, _0$$3, _5$$4, _8$$5; + zval namespaces; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&uri); - ZVAL_UNDEF(&suffix_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&filename); - ZVAL_UNDEF(&matches); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&namespaces); + ZVAL_UNDEF(&dirSeparator); + ZVAL_UNDEF(&directories); + ZVAL_UNDEF(&name); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$3); - ZVAL_UNDEF(&_8$$3); - ZVAL_UNDEF(&_9$$3); - bool is_null_true = 1; + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_8$$5); ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(uri) + Z_PARAM_ARRAY(namespaces) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(suffix) + Z_PARAM_BOOL(merge) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &uri_param, &suffix); - if (UNEXPECTED(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 of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(uri_param) == IS_STRING)) { - zephir_get_strval(&uri, uri_param); + zephir_fetch_params(1, 1, 1, &namespaces_param, &merge_param); + zephir_get_arrval(&namespaces, namespaces_param); + if (!merge_param) { + merge = 0; } else { - ZEPHIR_INIT_VAR(&uri); - } - if (!suffix) { - suffix = &suffix_sub; - suffix = &__$null; + } + ZEPHIR_INIT_VAR(&dirSeparator); + ZVAL_STRING(&dirSeparator, "/"); + if (!merge) { + ZEPHIR_INIT_VAR(&_0$$3); + array_init(&_0$$3); + zephir_update_property_zval(this_ptr, ZEND_STRL("namespaces"), &_0$$3); } - ZEPHIR_INIT_VAR(&_0); - ZEPHIR_INIT_VAR(&_1); - ZVAL_STRING(&_1, "/"); - zephir_fast_trim(&_0, &uri, &_1, ZEPHIR_TRIM_RIGHT); - zephir_get_strval(&uri, &_0); - ZEPHIR_INIT_VAR(&_2); - ZVAL_STRING(&_2, "/"); - ZEPHIR_INIT_VAR(&_3); - ZVAL_STRING(&_3, "@"); - ZEPHIR_CALL_FUNCTION(&_4, "preg_quote", NULL, 351, &_2, &_3); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_5); - ZEPHIR_CONCAT_SVS(&_5, "@[^", &_4, "]+$@"); - ZEPHIR_INIT_NVAR(&_2); - zephir_preg_match(&_2, &_5, &uri, &matches, 0, 0 , 0 ); - if (zephir_is_true(&_2)) { - zephir_memory_observe(&filename); - zephir_array_fetch_long(&filename, &matches, 0, PH_NOISY, "phalcon/Http/Response.zep", 867); + zephir_is_iterable(&namespaces, 0, "phalcon/Autoload/Loader.zep", 489); + if (Z_TYPE_P(&namespaces) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&namespaces), _3, _4, _1) + { + ZEPHIR_INIT_NVAR(&name); + if (_4 != NULL) { + ZVAL_STR_COPY(&name, _4); + } else { + ZVAL_LONG(&name, _3); + } + ZEPHIR_INIT_NVAR(&directories); + ZVAL_COPY(&directories, _1); + ZEPHIR_CALL_METHOD(&_5$$4, this_ptr, "checkdirectories", &_6, 179, &directories, &dirSeparator); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&directories, &_5$$4); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addnamespace", &_7, 0, &name, &directories); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_INIT_NVAR(&filename); - ZVAL_STRING(&filename, ""); - } - if (zephir_is_true(suffix)) { - ZEPHIR_INIT_VAR(&_6$$3); - ZVAL_STRING(&_6$$3, "@"); - ZEPHIR_CALL_FUNCTION(&_7$$3, "preg_quote", NULL, 351, suffix, &_6$$3); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_8$$3); - ZEPHIR_CONCAT_SVS(&_8$$3, "@", &_7$$3, "$@"); - ZEPHIR_INIT_NVAR(&_6$$3); - ZVAL_STRING(&_6$$3, ""); - ZEPHIR_CALL_FUNCTION(&_9$$3, "preg_replace", NULL, 41, &_8$$3, &_6$$3, &filename); + ZEPHIR_CALL_METHOD(NULL, &namespaces, "rewind", NULL, 0); zephir_check_call_status(); - ZEPHIR_CPY_WRT(&filename, &_9$$3); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &namespaces, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&name, &namespaces, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&directories, &namespaces, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_8$$5, this_ptr, "checkdirectories", &_6, 179, &directories, &dirSeparator); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&directories, &_8$$5); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "addnamespace", &_7, 0, &name, &directories); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &namespaces, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_CCTOR(&filename); + ZEPHIR_INIT_NVAR(&directories); + ZEPHIR_INIT_NVAR(&name); + RETURN_THIS(); } -zend_object *zephir_init_properties_Phalcon_Http_Response(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Autoload_Loader, unregister) { - zval _0, _1$$3; + zval _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); + zval __$true, __$false, _0, _2$$3; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_BOOL(&__$true, 1); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2$$3); ZVAL_UNDEF(&_1$$3); - + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("statusCodes"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("statusCodes"), &_1$$3); + zephir_read_property(&_0, this_ptr, ZEND_STRL("isRegistered"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + ZEPHIR_INIT_VAR(&_1$$3); + zephir_create_array(&_1$$3, 2, 0); + zephir_array_fast_append(&_1$$3, this_ptr); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "autoload"); + zephir_array_fast_append(&_1$$3, &_2$$3); + ZEPHIR_CALL_FUNCTION(NULL, "spl_autoload_unregister", NULL, 187, &_1$$3); + zephir_check_call_status(); + if (0) { + zephir_update_property_zval(this_ptr, ZEND_STRL("isRegistered"), &__$true); + } else { + zephir_update_property_zval(this_ptr, ZEND_STRL("isRegistered"), &__$false); } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); } + RETURN_THIS(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Http_ResponseInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http, ResponseInterface, phalcon, http_responseinterface, phalcon_http_responseinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, appendContent); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, getContent); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, getStatusCode); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, getHeaders); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, hasHeader); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, isSent); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, redirect); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, resetHeaders); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setContent); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setContentLength); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setContentType); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setExpires); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setFileToSend); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setHeader); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setJsonContent); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setNotModified); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setRawHeader); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, setStatusCode); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, send); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, sendCookies); -ZEPHIR_DOC_METHOD(Phalcon_Http_ResponseInterface, sendHeaders); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Http_Response_Cookies) +static PHP_METHOD(Phalcon_Autoload_Loader, isRegistered) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Http\\Response, Cookies, phalcon, http_response_cookies, phalcon_di_abstractinjectionaware_ce, phalcon_http_response_cookies_method_entry, 0); - - zend_declare_property_null(phalcon_http_response_cookies_ce, SL("cookies"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_http_response_cookies_ce, SL("isSent"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_http_response_cookies_ce, SL("registered"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_http_response_cookies_ce, SL("signKey"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_http_response_cookies_ce, SL("useEncryption"), 1, ZEND_ACC_PROTECTED); - phalcon_http_response_cookies_ce->create_object = zephir_init_properties_Phalcon_Http_Response_Cookies; - zend_class_implements(phalcon_http_response_cookies_ce, 1, phalcon_http_response_cookiesinterface_ce); - return SUCCESS; + RETURN_MEMBER(getThis(), "isRegistered"); } -static PHP_METHOD(Phalcon_Http_Response_Cookies, __construct) +static PHP_METHOD(Phalcon_Autoload_Loader, requireFile) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval signKey; - zval *useEncryption_param = NULL, *signKey_param = NULL, __$true, __$false; - zend_bool useEncryption; + zval *file_param = NULL, _0, _1, _2$$3; + zval file, _4, _3$$3; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&signKey); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 2) - Z_PARAM_OPTIONAL - Z_PARAM_BOOL(useEncryption) - Z_PARAM_STR_OR_NULL(signKey) + ZVAL_UNDEF(&file); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(file) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 2, &useEncryption_param, &signKey_param); - if (!useEncryption_param) { - useEncryption = 1; - } else { + zephir_fetch_params(1, 1, 0, &file_param); + zephir_get_strval(&file, file_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("fileCheckingCallback"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&_1, "call_user_func", NULL, 188, &_0, &file); + zephir_check_call_status(); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&_1)) { + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "loader:pathFound"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "firemanagerevent", NULL, 0, &_2$$3, &file); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3$$3); + ZEPHIR_CONCAT_SV(&_3$$3, "Require: ", &file); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "adddebug", NULL, 181, &_3$$3); + zephir_check_call_status(); + if (zephir_require_once_zval(&file) == FAILURE) { + RETURN_MM_NULL(); } - if (!signKey_param) { - ZEPHIR_INIT_VAR(&signKey); - } else { - zephir_get_strval(&signKey, signKey_param); - } - if (useEncryption) { - zephir_update_property_zval(this_ptr, ZEND_STRL("useEncryption"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("useEncryption"), &__$false); + RETURN_MM_BOOL(1); } - ZEPHIR_CALL_METHOD(NULL, this_ptr, "setsignkey", NULL, 0, &signKey); + ZEPHIR_INIT_VAR(&_4); + ZEPHIR_CONCAT_SV(&_4, "Require: 404: ", &file); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "adddebug", NULL, 181, &_4); zephir_check_call_status(); - ZEPHIR_MM_RESTORE(); + RETURN_MM_BOOL(0); } -static PHP_METHOD(Phalcon_Http_Response_Cookies, delete) +static PHP_METHOD(Phalcon_Autoload_Loader, addDebug) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, cookie, _0; - zval name; + zval *message_param = NULL, _0; + zval message; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&cookie); + ZVAL_UNDEF(&message); ZVAL_UNDEF(&_0); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + Z_PARAM_STR(message) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - zephir_memory_observe(&cookie); - zephir_read_property(&_0, this_ptr, ZEND_STRL("cookies"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&cookie, &_0, &name, 0))) { - RETURN_MM_BOOL(0); + zephir_fetch_params(1, 1, 0, &message_param); + zephir_get_strval(&message, message_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("isDebug"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_0)) { + zephir_update_property_array_append(this_ptr, SL("debug"), &message); } - ZEPHIR_CALL_METHOD(NULL, &cookie, "delete", NULL, 0); - zephir_check_call_status(); - RETURN_MM_BOOL(1); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Http_Response_Cookies, get) +static PHP_METHOD(Phalcon_Autoload_Loader, addToCollection) { - zval _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, container, encryption, cookie, _0, _1, _2, _4, _5, _6$$5; - zval name; + zend_bool merge; + zval collectionName, method; + zval *collection_param = NULL, *collectionName_param = NULL, *method_param = NULL, *merge_param = NULL, element, *_1, _2, _0$$3; + zval collection; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&encryption); - ZVAL_UNDEF(&cookie); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&element); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6$$5); - ZVAL_UNDEF(&_3); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&collectionName); + ZVAL_UNDEF(&method); + ZEND_PARSE_PARAMETERS_START(3, 4) + Z_PARAM_ARRAY(collection) + Z_PARAM_STR(collectionName) + Z_PARAM_STR(method) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(merge) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + zephir_fetch_params(1, 3, 1, &collection_param, &collectionName_param, &method_param, &merge_param); + zephir_get_arrval(&collection, collection_param); + zephir_get_strval(&collectionName, collectionName_param); + zephir_get_strval(&method, method_param); + if (!merge_param) { + merge = 0; } else { - ZEPHIR_INIT_VAR(&name); - } - zephir_memory_observe(&cookie); - zephir_read_property(&_0, this_ptr, ZEND_STRL("cookies"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&cookie, &_0, &name, 0)) { - RETURN_CCTOR(&cookie); + } + if (!merge) { + ZEPHIR_INIT_VAR(&_0$$3); + array_init(&_0$$3); + zephir_update_property_zval_zval(this_ptr, &collectionName, &_0$$3); } - zephir_read_property(&_1, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_3); - zephir_create_array(&_3, 1, 0); - zephir_array_fast_append(&_3, &name); - ZEPHIR_INIT_VAR(&_4); - ZVAL_STRING(&_4, "Phalcon\\Http\\Cookie"); - ZEPHIR_CALL_METHOD(&_2, &_1, "get", NULL, 0, &_4, &_3); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&cookie, &_2); - zephir_read_property(&_5, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_5); - if (Z_TYPE_P(&container) == IS_OBJECT) { - ZEPHIR_CALL_METHOD(NULL, &cookie, "setdi", NULL, 0, &container); + zephir_is_iterable(&collection, 0, "phalcon/Autoload/Loader.zep", 594); + if (Z_TYPE_P(&collection) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&collection), _1) + { + ZEPHIR_INIT_NVAR(&element); + ZVAL_COPY(&element, _1); + ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &method, NULL, 0, &element); + zephir_check_call_status(); + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &collection, "rewind", NULL, 0); zephir_check_call_status(); - zephir_memory_observe(&encryption); - zephir_read_property(&encryption, this_ptr, ZEND_STRL("useEncryption"), PH_NOISY_CC); - if (zephir_is_true(&encryption)) { - ZEPHIR_CALL_METHOD(NULL, &cookie, "useencryption", NULL, 0, &encryption); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &collection, "valid", NULL, 0); zephir_check_call_status(); - zephir_read_property(&_6$$5, this_ptr, ZEND_STRL("signKey"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &cookie, "setsignkey", NULL, 0, &_6$$5); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&element, &collection, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD_ZVAL(NULL, this_ptr, &method, NULL, 0, &element); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &collection, "next", NULL, 0); zephir_check_call_status(); } } - RETURN_CCTOR(&cookie); -} - -static PHP_METHOD(Phalcon_Http_Response_Cookies, getCookies) -{ - - RETURN_MEMBER(getThis(), "cookies"); + ZEPHIR_INIT_NVAR(&element); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Response_Cookies, has) +static PHP_METHOD(Phalcon_Autoload_Loader, autoloadCheckClasses) { - zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, _COOKIE, _0; - zval name; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *className_param = NULL, filePath, _0, _1$$3, _2$$3, _3$$3; + zval className; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_COOKIE); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&filePath); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + Z_PARAM_STR(className) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_get_global(&_COOKIE, SL("_COOKIE")); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("cookies"), PH_NOISY_CC | PH_READONLY); - _1 = zephir_array_isset(&_0, &name); - if (!(_1)) { - _1 = zephir_array_isset(&_COOKIE, &name); + zephir_fetch_params(1, 1, 0, &className_param); + zephir_get_strval(&className, className_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("classes"), PH_NOISY_CC | PH_READONLY); + if (1 == zephir_array_isset(&_0, &className)) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("classes"), PH_NOISY_CC | PH_READONLY); + zephir_memory_observe(&filePath); + zephir_array_fetch(&filePath, &_1$$3, &className, PH_NOISY, "phalcon/Autoload/Loader.zep", 610); + ZEPHIR_INIT_VAR(&_2$$3); + ZVAL_STRING(&_2$$3, "loader:pathFound"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "firemanagerevent", NULL, 0, &_2$$3, &filePath); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "requirefile", NULL, 0, &filePath); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3$$3); + ZEPHIR_CONCAT_SV(&_3$$3, "Class: load: ", &filePath); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "adddebug", NULL, 181, &_3$$3); + zephir_check_call_status(); + RETURN_MM_BOOL(1); } - RETURN_MM_BOOL(_1); -} - -static PHP_METHOD(Phalcon_Http_Response_Cookies, isSent) -{ - - RETURN_MEMBER(getThis(), "isSent"); -} - -static PHP_METHOD(Phalcon_Http_Response_Cookies, isUsingEncryption) -{ - - RETURN_MEMBER(getThis(), "useEncryption"); -} - -static PHP_METHOD(Phalcon_Http_Response_Cookies, reset) -{ - zval _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("cookies"), &_0); - RETURN_THIS(); + RETURN_MM_BOOL(0); } -static PHP_METHOD(Phalcon_Http_Response_Cookies, send) +static PHP_METHOD(Phalcon_Autoload_Loader, autoloadCheckDirectories) { - zend_bool _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval __$true, __$false, cookie, _0, _2, _3, *_4, _5; + zephir_fcall_cache_entry *_8 = NULL, *_10 = NULL, *_12 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; + zend_bool isDirectory; + zval *directories_param = NULL, className, *className_param = NULL, *isDirectory_param = NULL, dirSeparator, directory, extension, extensions, filePath, fixedDirectory, nsSeparator, _0, _1, *_2, _3, _4$$3, *_5$$3, _6$$3, _7$$4, _9$$4, _11$$6, _13$$7, _14$$7, _15$$9, _16$$10, *_17$$10, _18$$10, _19$$11, _20$$11, _21$$13, _22$$14, _23$$14, _24$$16; + zval directories; zval *this_ptr = getThis(); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&cookie); + ZVAL_UNDEF(&directories); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&dirSeparator); + ZVAL_UNDEF(&directory); + ZVAL_UNDEF(&extension); + ZVAL_UNDEF(&extensions); + ZVAL_UNDEF(&filePath); + ZVAL_UNDEF(&fixedDirectory); + ZVAL_UNDEF(&nsSeparator); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&_11$$6); + ZVAL_UNDEF(&_13$$7); + ZVAL_UNDEF(&_14$$7); + ZVAL_UNDEF(&_15$$9); + ZVAL_UNDEF(&_16$$10); + ZVAL_UNDEF(&_18$$10); + ZVAL_UNDEF(&_19$$11); + ZVAL_UNDEF(&_20$$11); + ZVAL_UNDEF(&_21$$13); + ZVAL_UNDEF(&_22$$14); + ZVAL_UNDEF(&_23$$14); + ZVAL_UNDEF(&_24$$16); + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ARRAY(directories) + Z_PARAM_STR(className) + Z_PARAM_OPTIONAL + Z_PARAM_BOOL(isDirectory) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_FUNCTION(&_0, "headers_sent", NULL, 359); - zephir_check_call_status(); - _1 = ZEPHIR_IS_TRUE_IDENTICAL(&_0); - if (!(_1)) { - ZEPHIR_CALL_METHOD(&_2, this_ptr, "issent", NULL, 0); - zephir_check_call_status(); - _1 = ZEPHIR_IS_TRUE_IDENTICAL(&_2); - } - if (_1) { - RETURN_MM_BOOL(0); - } - zephir_read_property(&_3, this_ptr, ZEND_STRL("cookies"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_3, 0, "phalcon/Http/Response/Cookies.zep", 225); - if (Z_TYPE_P(&_3) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_3), _4) + zephir_fetch_params(1, 2, 1, &directories_param, &className_param, &isDirectory_param); + zephir_get_arrval(&directories, directories_param); + zephir_get_strval(&className, className_param); + if (!isDirectory_param) { + isDirectory = 0; + } else { + } + ZEPHIR_INIT_VAR(&dirSeparator); + ZVAL_STRING(&dirSeparator, "/"); + ZEPHIR_INIT_VAR(&nsSeparator); + ZVAL_STRING(&nsSeparator, "\\"); + ZEPHIR_INIT_VAR(&_0); + zephir_fast_str_replace(&_0, &nsSeparator, &dirSeparator, &className); + ZEPHIR_CPY_WRT(&className, &_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("extensions"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&extensions, &_1); + zephir_is_iterable(&directories, 0, "phalcon/Autoload/Loader.zep", 669); + if (Z_TYPE_P(&directories) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&directories), _2) { - ZEPHIR_INIT_NVAR(&cookie); - ZVAL_COPY(&cookie, _4); - ZEPHIR_CALL_METHOD(NULL, &cookie, "send", NULL, 0); - zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&directory); + ZVAL_COPY(&directory, _2); + ZEPHIR_INIT_NVAR(&_4$$3); + zephir_fast_trim(&_4$$3, &directory, &dirSeparator, ZEPHIR_TRIM_RIGHT); + ZEPHIR_INIT_NVAR(&fixedDirectory); + ZEPHIR_CONCAT_VV(&fixedDirectory, &_4$$3, &dirSeparator); + zephir_is_iterable(&extensions, 0, "phalcon/Autoload/Loader.zep", 667); + if (Z_TYPE_P(&extensions) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&extensions), _5$$3) + { + ZEPHIR_INIT_NVAR(&extension); + ZVAL_COPY(&extension, _5$$3); + ZEPHIR_INIT_NVAR(&filePath); + ZEPHIR_CONCAT_VVSV(&filePath, &fixedDirectory, &className, ".", &extension); + zephir_update_property_zval(this_ptr, ZEND_STRL("checkedPath"), &filePath); + ZEPHIR_INIT_NVAR(&_7$$4); + ZVAL_STRING(&_7$$4, "loader:beforeCheckPath"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "firemanagerevent", &_8, 0, &_7$$4, &filePath); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_9$$4, this_ptr, "requirefile", &_10, 0, &filePath); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_9$$4)) { + if (isDirectory) { + ZEPHIR_INIT_NVAR(&_11$$6); + ZEPHIR_CONCAT_SV(&_11$$6, "Directories: ", &filePath); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "adddebug", &_12, 181, &_11$$6); + zephir_check_call_status(); + } + RETURN_MM_BOOL(1); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &extensions, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_6$$3, &extensions, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_6$$3)) { + break; + } + ZEPHIR_CALL_METHOD(&extension, &extensions, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&filePath); + ZEPHIR_CONCAT_VVSV(&filePath, &fixedDirectory, &className, ".", &extension); + zephir_update_property_zval(this_ptr, ZEND_STRL("checkedPath"), &filePath); + ZEPHIR_INIT_NVAR(&_13$$7); + ZVAL_STRING(&_13$$7, "loader:beforeCheckPath"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "firemanagerevent", &_8, 0, &_13$$7, &filePath); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_14$$7, this_ptr, "requirefile", &_10, 0, &filePath); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_14$$7)) { + if (isDirectory) { + ZEPHIR_INIT_NVAR(&_15$$9); + ZEPHIR_CONCAT_SV(&_15$$9, "Directories: ", &filePath); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "adddebug", &_12, 181, &_15$$9); + zephir_check_call_status(); + } + RETURN_MM_BOOL(1); + } + ZEPHIR_CALL_METHOD(NULL, &extensions, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&extension); } ZEND_HASH_FOREACH_END(); } else { - ZEPHIR_CALL_METHOD(NULL, &_3, "rewind", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &directories, "rewind", NULL, 0); zephir_check_call_status(); while (1) { - ZEPHIR_CALL_METHOD(&_5, &_3, "valid", NULL, 0); + ZEPHIR_CALL_METHOD(&_3, &directories, "valid", NULL, 0); zephir_check_call_status(); - if (!zend_is_true(&_5)) { + if (!zend_is_true(&_3)) { break; } - ZEPHIR_CALL_METHOD(&cookie, &_3, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&directory, &directories, "current", NULL, 0); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &cookie, "send", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &_3, "next", NULL, 0); + ZEPHIR_INIT_NVAR(&_16$$10); + zephir_fast_trim(&_16$$10, &directory, &dirSeparator, ZEPHIR_TRIM_RIGHT); + ZEPHIR_INIT_NVAR(&fixedDirectory); + ZEPHIR_CONCAT_VV(&fixedDirectory, &_16$$10, &dirSeparator); + zephir_is_iterable(&extensions, 0, "phalcon/Autoload/Loader.zep", 667); + if (Z_TYPE_P(&extensions) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&extensions), _17$$10) + { + ZEPHIR_INIT_NVAR(&extension); + ZVAL_COPY(&extension, _17$$10); + ZEPHIR_INIT_NVAR(&filePath); + ZEPHIR_CONCAT_VVSV(&filePath, &fixedDirectory, &className, ".", &extension); + zephir_update_property_zval(this_ptr, ZEND_STRL("checkedPath"), &filePath); + ZEPHIR_INIT_NVAR(&_19$$11); + ZVAL_STRING(&_19$$11, "loader:beforeCheckPath"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "firemanagerevent", &_8, 0, &_19$$11, &filePath); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_20$$11, this_ptr, "requirefile", &_10, 0, &filePath); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_20$$11)) { + if (isDirectory) { + ZEPHIR_INIT_NVAR(&_21$$13); + ZEPHIR_CONCAT_SV(&_21$$13, "Directories: ", &filePath); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "adddebug", &_12, 181, &_21$$13); + zephir_check_call_status(); + } + RETURN_MM_BOOL(1); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &extensions, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_18$$10, &extensions, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_18$$10)) { + break; + } + ZEPHIR_CALL_METHOD(&extension, &extensions, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&filePath); + ZEPHIR_CONCAT_VVSV(&filePath, &fixedDirectory, &className, ".", &extension); + zephir_update_property_zval(this_ptr, ZEND_STRL("checkedPath"), &filePath); + ZEPHIR_INIT_NVAR(&_22$$14); + ZVAL_STRING(&_22$$14, "loader:beforeCheckPath"); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "firemanagerevent", &_8, 0, &_22$$14, &filePath); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_23$$14, this_ptr, "requirefile", &_10, 0, &filePath); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_23$$14)) { + if (isDirectory) { + ZEPHIR_INIT_NVAR(&_24$$16); + ZEPHIR_CONCAT_SV(&_24$$16, "Directories: ", &filePath); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "adddebug", &_12, 181, &_24$$16); + zephir_check_call_status(); + } + RETURN_MM_BOOL(1); + } + ZEPHIR_CALL_METHOD(NULL, &extensions, "next", NULL, 0); + zephir_check_call_status(); + } + } + ZEPHIR_INIT_NVAR(&extension); + ZEPHIR_CALL_METHOD(NULL, &directories, "next", NULL, 0); zephir_check_call_status(); } } - ZEPHIR_INIT_NVAR(&cookie); - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSent"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSent"), &__$false); - } - RETURN_MM_BOOL(1); + ZEPHIR_INIT_NVAR(&directory); + RETURN_MM_BOOL(0); } -static PHP_METHOD(Phalcon_Http_Response_Cookies, set) +static PHP_METHOD(Phalcon_Autoload_Loader, autoloadCheckNamespaces) { + zend_string *_4; + zend_ulong _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval options, _3$$3; - zend_bool secure, httpOnly; - zend_long expire, ZEPHIR_LAST_CALL_STATUS; - zval *name_param = NULL, *value = NULL, value_sub, *expire_param = NULL, *path_param = NULL, *secure_param = NULL, *domain_param = NULL, *httpOnly_param = NULL, *options_param = NULL, __$true, __$false, __$null, cookie, encryption, container, response, _0, _10, _1$$3, _2$$3, _4$$3, _5$$3, _6$$4, _7$$5, _8$$5, _9$$5, _11$$6, _12$$6; - zval name, path, domain; + zephir_fcall_cache_entry *_9 = NULL, *_12 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *className_param = NULL, directories, fileName, namespaces, nsSeparator, prefix, _0, *_1, _2, _5$$3, _6$$3, _7$$3, _8$$3, _10$$5, _11$$5, _13$$6, _14$$6, _15$$6, _16$$6, _17$$8, _18$$8; + zval className; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&path); - ZVAL_UNDEF(&domain); - ZVAL_UNDEF(&value_sub); - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&cookie); - ZVAL_UNDEF(&encryption); - ZVAL_UNDEF(&container); - ZVAL_UNDEF(&response); + ZVAL_UNDEF(&className); + ZVAL_UNDEF(&directories); + ZVAL_UNDEF(&fileName); + ZVAL_UNDEF(&namespaces); + ZVAL_UNDEF(&nsSeparator); + ZVAL_UNDEF(&prefix); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_10); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_7$$5); - ZVAL_UNDEF(&_8$$5); - ZVAL_UNDEF(&_9$$5); - ZVAL_UNDEF(&_11$$6); - ZVAL_UNDEF(&_12$$6); - ZVAL_UNDEF(&options); - ZVAL_UNDEF(&_3$$3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 8) - Z_PARAM_STR(name) - Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(value) - Z_PARAM_LONG(expire) - Z_PARAM_STR(path) - Z_PARAM_BOOL_OR_NULL(secure, is_null_true) - Z_PARAM_STR_OR_NULL(domain) - Z_PARAM_BOOL_OR_NULL(httpOnly, is_null_true) - Z_PARAM_ARRAY(options) + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_10$$5); + ZVAL_UNDEF(&_11$$5); + ZVAL_UNDEF(&_13$$6); + ZVAL_UNDEF(&_14$$6); + ZVAL_UNDEF(&_15$$6); + ZVAL_UNDEF(&_16$$6); + ZVAL_UNDEF(&_17$$8); + ZVAL_UNDEF(&_18$$8); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_STR(className) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 7, &name_param, &value, &expire_param, &path_param, &secure_param, &domain_param, &httpOnly_param, &options_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - if (!value) { - value = &value_sub; - value = &__$null; - } - if (!expire_param) { - expire = 0; - } else { - } - if (!path_param) { - ZEPHIR_INIT_VAR(&path); - ZVAL_STRING(&path, "/"); - } else { - zephir_get_strval(&path, path_param); - } - if (!secure_param) { - secure = 0; - } else { - } - if (!domain_param) { - ZEPHIR_INIT_VAR(&domain); - } else { - if (UNEXPECTED(Z_TYPE_P(domain_param) != IS_STRING && Z_TYPE_P(domain_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'domain' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(domain_param) == IS_STRING)) { - zephir_get_strval(&domain, domain_param); - } else { - ZEPHIR_INIT_VAR(&domain); - } - } - if (!httpOnly_param) { - httpOnly = 0; - } else { - } - if (!options_param) { - ZEPHIR_INIT_VAR(&options); - array_init(&options); - } else { - zephir_get_arrval(&options, options_param); - } - zephir_memory_observe(&encryption); - zephir_read_property(&encryption, this_ptr, ZEND_STRL("useEncryption"), PH_NOISY_CC); - zephir_memory_observe(&cookie); - zephir_read_property(&_0, this_ptr, ZEND_STRL("cookies"), PH_NOISY_CC | PH_READONLY); - if (!(zephir_array_isset_fetch(&cookie, &_0, &name, 0))) { - zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_INIT_VAR(&_3$$3); - zephir_create_array(&_3$$3, 8, 0); - zephir_array_fast_append(&_3$$3, &name); - zephir_array_fast_append(&_3$$3, value); - ZEPHIR_INIT_VAR(&_4$$3); - ZVAL_LONG(&_4$$3, expire); - zephir_array_fast_append(&_3$$3, &_4$$3); - zephir_array_fast_append(&_3$$3, &path); - ZEPHIR_INIT_NVAR(&_4$$3); - ZVAL_BOOL(&_4$$3, secure); - zephir_array_fast_append(&_3$$3, &_4$$3); - zephir_array_fast_append(&_3$$3, &domain); - ZEPHIR_INIT_NVAR(&_4$$3); - ZVAL_BOOL(&_4$$3, httpOnly); - zephir_array_fast_append(&_3$$3, &_4$$3); - zephir_array_fast_append(&_3$$3, &options); - ZEPHIR_INIT_NVAR(&_4$$3); - ZVAL_STRING(&_4$$3, "Phalcon\\Http\\Cookie"); - ZEPHIR_CALL_METHOD(&_2$$3, &_1$$3, "get", NULL, 0, &_4$$3, &_3$$3); - zephir_check_call_status(); - ZEPHIR_CPY_WRT(&cookie, &_2$$3); - zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &cookie, "setdi", NULL, 0, &_5$$3); - zephir_check_call_status(); - if (zephir_is_true(&encryption)) { - ZEPHIR_CALL_METHOD(NULL, &cookie, "useencryption", NULL, 0, &encryption); - zephir_check_call_status(); - zephir_read_property(&_6$$4, this_ptr, ZEND_STRL("signKey"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &cookie, "setsignkey", NULL, 0, &_6$$4); - zephir_check_call_status(); - } - zephir_update_property_array(this_ptr, SL("cookies"), &name, &cookie); - } else { - ZEPHIR_CALL_METHOD(NULL, &cookie, "setvalue", NULL, 0, value); - zephir_check_call_status(); - ZVAL_LONG(&_7$$5, expire); - ZEPHIR_CALL_METHOD(NULL, &cookie, "setexpiration", NULL, 0, &_7$$5); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &cookie, "setpath", NULL, 0, &path); - zephir_check_call_status(); - if (secure) { - ZVAL_BOOL(&_7$$5, 1); - } else { - ZVAL_BOOL(&_7$$5, 0); - } - ZEPHIR_CALL_METHOD(NULL, &cookie, "setsecure", NULL, 0, &_7$$5); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &cookie, "setdomain", NULL, 0, &domain); - zephir_check_call_status(); - if (httpOnly) { - ZVAL_BOOL(&_8$$5, 1); - } else { - ZVAL_BOOL(&_8$$5, 0); - } - ZEPHIR_CALL_METHOD(NULL, &cookie, "sethttponly", NULL, 0, &_8$$5); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &cookie, "setoptions", NULL, 0, &options); - zephir_check_call_status(); - zephir_read_property(&_9$$5, this_ptr, ZEND_STRL("signKey"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_METHOD(NULL, &cookie, "setsignkey", NULL, 0, &_9$$5); - zephir_check_call_status(); - } - zephir_read_property(&_10, this_ptr, ZEND_STRL("registered"), PH_NOISY_CC | PH_READONLY); - if (ZEPHIR_IS_FALSE_IDENTICAL(&_10)) { - zephir_read_property(&_11$$6, this_ptr, ZEND_STRL("container"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&container, &_11$$6); - if (Z_TYPE_P(&container) == IS_NULL) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_http_cookie_exception_ce, "A dependency injection container is required to access the 'response' service", "phalcon/Http/Response/Cookies.zep", 311); - return; - } - ZEPHIR_INIT_VAR(&_12$$6); - ZVAL_STRING(&_12$$6, "response"); - ZEPHIR_CALL_METHOD(&response, &container, "getshared", NULL, 0, &_12$$6); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(NULL, &response, "setcookies", NULL, 0, this_ptr); + zephir_fetch_params(1, 1, 0, &className_param); + zephir_get_strval(&className, className_param); + ZEPHIR_INIT_VAR(&nsSeparator); + ZVAL_STRING(&nsSeparator, "\\"); + zephir_read_property(&_0, this_ptr, ZEND_STRL("namespaces"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&namespaces, &_0); + zephir_is_iterable(&namespaces, 0, "phalcon/Autoload/Loader.zep", 704); + if (Z_TYPE_P(&namespaces) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&namespaces), _3, _4, _1) + { + ZEPHIR_INIT_NVAR(&prefix); + if (_4 != NULL) { + ZVAL_STR_COPY(&prefix, _4); + } else { + ZVAL_LONG(&prefix, _3); + } + ZEPHIR_INIT_NVAR(&directories); + ZVAL_COPY(&directories, _1); + if (1 != zephir_start_with(&className, &prefix, NULL)) { + continue; + } + ZEPHIR_INIT_NVAR(&_5$$3); + zephir_fast_trim(&_5$$3, &prefix, &nsSeparator, ZEPHIR_TRIM_RIGHT); + ZEPHIR_INIT_NVAR(&_6$$3); + ZEPHIR_CONCAT_VV(&_6$$3, &_5$$3, &nsSeparator); + ZEPHIR_CPY_WRT(&prefix, &_6$$3); + ZVAL_LONG(&_7$$3, zephir_fast_strlen_ev(&prefix)); + ZEPHIR_INIT_NVAR(&fileName); + zephir_substr(&fileName, &className, zephir_get_intval(&_7$$3), 0, ZEPHIR_SUBSTR_NO_LENGTH); + ZEPHIR_CALL_METHOD(&_8$$3, this_ptr, "autoloadcheckdirectories", &_9, 184, &directories, &fileName); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_8$$3)) { + zephir_read_property(&_10$$5, this_ptr, ZEND_STRL("checkedPath"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_11$$5); + ZEPHIR_CONCAT_SVSV(&_11$$5, "Namespace: ", &prefix, " - ", &_10$$5); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "adddebug", &_12, 181, &_11$$5); + zephir_check_call_status(); + RETURN_MM_BOOL(1); + } + } ZEND_HASH_FOREACH_END(); + } else { + ZEPHIR_CALL_METHOD(NULL, &namespaces, "rewind", NULL, 0); zephir_check_call_status(); - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("registered"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("registered"), &__$false); + while (1) { + ZEPHIR_CALL_METHOD(&_2, &namespaces, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_2)) { + break; + } + ZEPHIR_CALL_METHOD(&prefix, &namespaces, "key", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&directories, &namespaces, "current", NULL, 0); + zephir_check_call_status(); + if (1 != zephir_start_with(&className, &prefix, NULL)) { + continue; + } + ZEPHIR_INIT_NVAR(&_13$$6); + zephir_fast_trim(&_13$$6, &prefix, &nsSeparator, ZEPHIR_TRIM_RIGHT); + ZEPHIR_INIT_NVAR(&_14$$6); + ZEPHIR_CONCAT_VV(&_14$$6, &_13$$6, &nsSeparator); + ZEPHIR_CPY_WRT(&prefix, &_14$$6); + ZVAL_LONG(&_15$$6, zephir_fast_strlen_ev(&prefix)); + ZEPHIR_INIT_NVAR(&fileName); + zephir_substr(&fileName, &className, zephir_get_intval(&_15$$6), 0, ZEPHIR_SUBSTR_NO_LENGTH); + ZEPHIR_CALL_METHOD(&_16$$6, this_ptr, "autoloadcheckdirectories", &_9, 184, &directories, &fileName); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&_16$$6)) { + zephir_read_property(&_17$$8, this_ptr, ZEND_STRL("checkedPath"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_18$$8); + ZEPHIR_CONCAT_SVSV(&_18$$8, "Namespace: ", &prefix, " - ", &_17$$8); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "adddebug", &_12, 181, &_18$$8); + zephir_check_call_status(); + RETURN_MM_BOOL(1); + } + ZEPHIR_CALL_METHOD(NULL, &namespaces, "next", NULL, 0); + zephir_check_call_status(); } } - RETURN_THIS(); + ZEPHIR_INIT_NVAR(&directories); + ZEPHIR_INIT_NVAR(&prefix); + RETURN_MM_BOOL(0); } -static PHP_METHOD(Phalcon_Http_Response_Cookies, setSignKey) +static PHP_METHOD(Phalcon_Autoload_Loader, checkDirectories) { + zend_bool _0; + zval results; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *signKey_param = NULL; - zval signKey; - zval *this_ptr = getThis(); + zephir_fcall_cache_entry *_8 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval dirSeparator; + zval *directories = NULL, directories_sub, *dirSeparator_param = NULL, directory, *_2, _3, _1$$4, _4$$5, _5$$5, _6$$5, _7$$5, _9$$6, _10$$6, _11$$6, _12$$6; - ZVAL_UNDEF(&signKey); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(0, 1) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(signKey) + ZVAL_UNDEF(&directories_sub); + ZVAL_UNDEF(&directory); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_1$$4); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_9$$6); + ZVAL_UNDEF(&_10$$6); + ZVAL_UNDEF(&_11$$6); + ZVAL_UNDEF(&_12$$6); + ZVAL_UNDEF(&dirSeparator); + ZVAL_UNDEF(&results); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_ZVAL(directories) + Z_PARAM_STR(dirSeparator) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 0, 1, &signKey_param); - if (!signKey_param) { - ZEPHIR_INIT_VAR(&signKey); - } else { - zephir_get_strval(&signKey, signKey_param); + zephir_fetch_params(1, 2, 0, &directories, &dirSeparator_param); + ZEPHIR_SEPARATE_PARAM(directories); + zephir_get_strval(&dirSeparator, dirSeparator_param); + _0 = !(Z_TYPE_P(directories) == IS_STRING); + if (_0) { + _0 = !(Z_TYPE_P(directories) == IS_ARRAY); } - zephir_update_property_zval(this_ptr, ZEND_STRL("signKey"), &signKey); - RETURN_THIS(); -} - -static PHP_METHOD(Phalcon_Http_Response_Cookies, useEncryption) -{ - zval *useEncryption_param = NULL, __$true, __$false; - zend_bool useEncryption; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_BOOL(useEncryption) - ZEND_PARSE_PARAMETERS_END(); - zephir_fetch_params_without_memory_grow(1, 0, &useEncryption_param); - if (useEncryption) { - zephir_update_property_zval(this_ptr, ZEND_STRL("useEncryption"), &__$true); + if (_0) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_autoload_exception_ce, "The directories parameter is not a string or array", "phalcon/Autoload/Loader.zep", 727); + return; + } + if (Z_TYPE_P(directories) == IS_STRING) { + ZEPHIR_INIT_VAR(&_1$$4); + zephir_create_array(&_1$$4, 1, 0); + zephir_array_fast_append(&_1$$4, directories); + ZEPHIR_CPY_WRT(directories, &_1$$4); + } + ZEPHIR_INIT_VAR(&results); + array_init(&results); + zephir_is_iterable(directories, 0, "phalcon/Autoload/Loader.zep", 741); + if (Z_TYPE_P(directories) == IS_ARRAY) { + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(directories), _2) + { + ZEPHIR_INIT_NVAR(&directory); + ZVAL_COPY(&directory, _2); + ZEPHIR_INIT_NVAR(&_4$$5); + zephir_fast_trim(&_4$$5, &directory, &dirSeparator, ZEPHIR_TRIM_RIGHT); + ZEPHIR_INIT_NVAR(&_5$$5); + ZEPHIR_CONCAT_VV(&_5$$5, &_4$$5, &dirSeparator); + ZEPHIR_CPY_WRT(&directory, &_5$$5); + ZEPHIR_INIT_NVAR(&_6$$5); + ZVAL_STRING(&_6$$5, "sha256"); + ZEPHIR_CALL_FUNCTION(&_7$$5, "hash", &_8, 71, &_6$$5, &directory); + zephir_check_call_status(); + zephir_array_update_zval(&results, &_7$$5, &directory, PH_COPY | PH_SEPARATE); + } ZEND_HASH_FOREACH_END(); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("useEncryption"), &__$false); + ZEPHIR_CALL_METHOD(NULL, directories, "rewind", NULL, 0); + zephir_check_call_status(); + while (1) { + ZEPHIR_CALL_METHOD(&_3, directories, "valid", NULL, 0); + zephir_check_call_status(); + if (!zend_is_true(&_3)) { + break; + } + ZEPHIR_CALL_METHOD(&directory, directories, "current", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_9$$6); + zephir_fast_trim(&_9$$6, &directory, &dirSeparator, ZEPHIR_TRIM_RIGHT); + ZEPHIR_INIT_NVAR(&_10$$6); + ZEPHIR_CONCAT_VV(&_10$$6, &_9$$6, &dirSeparator); + ZEPHIR_CPY_WRT(&directory, &_10$$6); + ZEPHIR_INIT_NVAR(&_11$$6); + ZVAL_STRING(&_11$$6, "sha256"); + ZEPHIR_CALL_FUNCTION(&_12$$6, "hash", &_8, 71, &_11$$6, &directory); + zephir_check_call_status(); + zephir_array_update_zval(&results, &_12$$6, &directory, PH_COPY | PH_SEPARATE); + ZEPHIR_CALL_METHOD(NULL, directories, "next", NULL, 0); + zephir_check_call_status(); + } } - RETURN_THISW(); + ZEPHIR_INIT_NVAR(&directory); + RETURN_CTOR(&results); } -zend_object *zephir_init_properties_Phalcon_Http_Response_Cookies(zend_class_entry *class_type) +zend_object *zephir_init_properties_Phalcon_Autoload_Loader(zend_class_entry *class_type) { - zval _0, _1$$3; + zval _0, _2, _4, _6, _8, _10, _1$$3, _3$$4, _5$$5, _7$$6, _9$$7, _11$$8; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_10); ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_9$$7); + ZVAL_UNDEF(&_11$$8); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); @@ -161182,11 +161961,41 @@ zend_object *zephir_init_properties_Phalcon_Http_Response_Cookies(zend_class_ent { zval local_this_ptr, *this_ptr = &local_this_ptr; ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("cookies"), PH_NOISY_CC | PH_READONLY); + zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("namespaces"), PH_NOISY_CC | PH_READONLY); if (Z_TYPE_P(&_0) == IS_NULL) { ZEPHIR_INIT_VAR(&_1$$3); array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("cookies"), &_1$$3); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("namespaces"), &_1$$3); + } + zephir_read_property_ex(&_2, this_ptr, ZEND_STRL("files"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_2) == IS_NULL) { + ZEPHIR_INIT_VAR(&_3$$4); + array_init(&_3$$4); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("files"), &_3$$4); + } + zephir_read_property_ex(&_4, this_ptr, ZEND_STRL("extensions"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_4) == IS_NULL) { + ZEPHIR_INIT_VAR(&_5$$5); + array_init(&_5$$5); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("extensions"), &_5$$5); + } + zephir_read_property_ex(&_6, this_ptr, ZEND_STRL("directories"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_6) == IS_NULL) { + ZEPHIR_INIT_VAR(&_7$$6); + array_init(&_7$$6); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("directories"), &_7$$6); + } + zephir_read_property_ex(&_8, this_ptr, ZEND_STRL("debug"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_8) == IS_NULL) { + ZEPHIR_INIT_VAR(&_9$$7); + array_init(&_9$$7); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("debug"), &_9$$7); + } + zephir_read_property_ex(&_10, this_ptr, ZEND_STRL("classes"), PH_NOISY_CC | PH_READONLY); + if (Z_TYPE_P(&_10) == IS_NULL) { + ZEPHIR_INIT_VAR(&_11$$8); + array_init(&_11$$8); + zephir_update_property_zval_ex(this_ptr, ZEND_STRL("classes"), &_11$$8); } ZEPHIR_MM_RESTORE(); return Z_OBJ_P(this_ptr); @@ -161203,21 +162012,31 @@ zend_object *zephir_init_properties_Phalcon_Http_Response_Cookies(zend_class_ent -ZEPHIR_INIT_CLASS(Phalcon_Http_Response_CookiesInterface) +ZEPHIR_INIT_CLASS(Phalcon_Image_Enum) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http\\Response, CookiesInterface, phalcon, http_response_cookiesinterface, phalcon_http_response_cookiesinterface_method_entry); + ZEPHIR_REGISTER_CLASS(Phalcon\\Image, Enum, phalcon, image_enum, NULL, 0); + + zephir_declare_class_constant_long(phalcon_image_enum_ce, SL("AUTO"), 4); + + zephir_declare_class_constant_long(phalcon_image_enum_ce, SL("HEIGHT"), 3); + + zephir_declare_class_constant_long(phalcon_image_enum_ce, SL("INVERSE"), 5); + + zephir_declare_class_constant_long(phalcon_image_enum_ce, SL("NONE"), 1); + + zephir_declare_class_constant_long(phalcon_image_enum_ce, SL("PRECISE"), 6); + + zephir_declare_class_constant_long(phalcon_image_enum_ce, SL("TENSILE"), 7); + + zephir_declare_class_constant_long(phalcon_image_enum_ce, SL("WIDTH"), 2); + + zephir_declare_class_constant_long(phalcon_image_enum_ce, SL("HORIZONTAL"), 11); + + zephir_declare_class_constant_long(phalcon_image_enum_ce, SL("VERTICAL"), 12); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, delete); -ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, get); -ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, has); -ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, isUsingEncryption); -ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, reset); -ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, send); -ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, set); -ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, useEncryption); @@ -161228,9 +162047,9 @@ ZEPHIR_DOC_METHOD(Phalcon_Http_Response_CookiesInterface, useEncryption); -ZEPHIR_INIT_CLASS(Phalcon_Http_Response_Exception) +ZEPHIR_INIT_CLASS(Phalcon_Image_Exception) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Http\\Response, Exception, phalcon, http_response_exception, zend_ce_exception, NULL, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Image, Exception, phalcon, image_exception, zend_ce_exception, NULL, 0); return SUCCESS; } @@ -161245,313 +162064,211 @@ ZEPHIR_INIT_CLASS(Phalcon_Http_Response_Exception) -ZEPHIR_INIT_CLASS(Phalcon_Http_Response_Headers) +ZEPHIR_INIT_CLASS(Phalcon_Image_ImageFactory) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Http\\Response, Headers, phalcon, http_response_headers, phalcon_http_response_headers_method_entry, 0); - - zend_declare_property_null(phalcon_http_response_headers_ce, SL("headers"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_http_response_headers_ce, SL("isSent"), 0, ZEND_ACC_PROTECTED); - phalcon_http_response_headers_ce->create_object = zephir_init_properties_Phalcon_Http_Response_Headers; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Image, ImageFactory, phalcon, image_imagefactory, phalcon_factory_abstractfactory_ce, phalcon_image_imagefactory_method_entry, 0); - zend_class_implements(phalcon_http_response_headers_ce, 1, phalcon_http_response_headersinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Http_Response_Headers, get) +static PHP_METHOD(Phalcon_Image_ImageFactory, __construct) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, headers, headerValue, _0; - zval name; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *services_param = NULL; + zval services; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&headers); - ZVAL_UNDEF(&headerValue); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + ZVAL_UNDEF(&services); + ZEND_PARSE_PARAMETERS_START(0, 1) + Z_PARAM_OPTIONAL + Z_PARAM_ARRAY(services) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - zephir_get_strval(&name, name_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&headers, &_0); - zephir_memory_observe(&headerValue); - if (!(zephir_array_isset_fetch(&headerValue, &headers, &name, 0))) { - RETURN_MM_BOOL(0); + zephir_fetch_params(1, 0, 1, &services_param); + if (!services_param) { + ZEPHIR_INIT_VAR(&services); + array_init(&services); + } else { + ZEPHIR_OBS_COPY_OR_DUP(&services, services_param); } - RETURN_CCTOR(&headerValue); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "init", NULL, 0, &services); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Http_Response_Headers, has) +static PHP_METHOD(Phalcon_Image_ImageFactory, load) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, _0; - zval name; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *config = NULL, config_sub, height, file, name, width, _0, _1, _2; zval *this_ptr = getThis(); + ZVAL_UNDEF(&config_sub); + ZVAL_UNDEF(&height); + ZVAL_UNDEF(&file); ZVAL_UNDEF(&name); + ZVAL_UNDEF(&width); ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - zephir_get_strval(&name, name_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - RETURN_MM_BOOL(zephir_array_key_exists(&_0, &name)); -} - -static PHP_METHOD(Phalcon_Http_Response_Headers, isSent) -{ - - RETURN_MEMBER(getThis(), "isSent"); -} - -static PHP_METHOD(Phalcon_Http_Response_Headers, remove) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *header_param = NULL, headers, _0; - zval header; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&header); - ZVAL_UNDEF(&headers); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(header) + Z_PARAM_ZVAL(config) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &header_param); - zephir_get_strval(&header, header_param); - zephir_read_property(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&headers, &_0); - zephir_array_unset(&headers, &header, PH_SEPARATE); - zephir_update_property_zval(this_ptr, ZEND_STRL("headers"), &headers); - RETURN_THIS(); + zephir_fetch_params(1, 1, 0, &config); + ZEPHIR_SEPARATE_PARAM(config); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfig", NULL, 0, config); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(config, &_0); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "adapter"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfigelement", NULL, 0, config, &_1); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(config, &_0); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "file"); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkconfigelement", NULL, 0, config, &_1); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(config, &_0); + zephir_memory_observe(&name); + zephir_array_fetch_string(&name, config, SL("adapter"), PH_NOISY, "phalcon/Image/ImageFactory.zep", 44); + zephir_array_unset_string(config, SL("adapter"), PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "file"); + ZEPHIR_CALL_METHOD(&file, this_ptr, "getarrval", NULL, 408, config, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "height"); + ZVAL_NULL(&_2); + ZEPHIR_CALL_METHOD(&height, this_ptr, "getarrval", NULL, 408, config, &_1, &_2); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "width"); + ZVAL_NULL(&_2); + ZEPHIR_CALL_METHOD(&width, this_ptr, "getarrval", NULL, 408, config, &_1, &_2); + zephir_check_call_status(); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "newinstance", NULL, 0, &name, &file, &width, &height); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Http_Response_Headers, reset) +static PHP_METHOD(Phalcon_Image_ImageFactory, newInstance) { zval _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long width, height, ZEPHIR_LAST_CALL_STATUS; + zval *name_param = NULL, *file_param = NULL, *width_param = NULL, *height_param = NULL, definition, _1; + zval name, file; zval *this_ptr = getThis(); + ZVAL_UNDEF(&name); + ZVAL_UNDEF(&file); + ZVAL_UNDEF(&definition); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_0); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_STR(name) + Z_PARAM_STR(file) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(width, is_null_true) + Z_PARAM_LONG_OR_NULL(height, is_null_true) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_INIT_VAR(&_0); - array_init(&_0); - zephir_update_property_zval(this_ptr, ZEND_STRL("headers"), &_0); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Http_Response_Headers, send) -{ - zend_string *_7; - zend_ulong _6; - zend_bool _1, _10$$6, _16$$11; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_9 = NULL; - zval __$true, __$false, header, value, _0, _2, _3, *_4, _5, _8$$5, _11$$6, _12$$6, _13$$6, _14$$8, _15$$10, _17$$11, _18$$11, _19$$11, _20$$13; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - - ZVAL_BOOL(&__$true, 1); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&header); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_8$$5); - ZVAL_UNDEF(&_11$$6); - ZVAL_UNDEF(&_12$$6); - ZVAL_UNDEF(&_13$$6); - ZVAL_UNDEF(&_14$$8); - ZVAL_UNDEF(&_15$$10); - ZVAL_UNDEF(&_17$$11); - ZVAL_UNDEF(&_18$$11); - ZVAL_UNDEF(&_19$$11); - ZVAL_UNDEF(&_20$$13); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_FUNCTION(&_0, "headers_sent", NULL, 359); - zephir_check_call_status(); - _1 = ZEPHIR_IS_TRUE_IDENTICAL(&_0); - if (!(_1)) { - zephir_read_property(&_2, this_ptr, ZEND_STRL("isSent"), PH_NOISY_CC | PH_READONLY); - _1 = ZEPHIR_IS_TRUE_IDENTICAL(&_2); - } - if (_1) { - RETURN_MM_BOOL(0); + zephir_fetch_params(1, 2, 2, &name_param, &file_param, &width_param, &height_param); + if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); + RETURN_MM_NULL(); } - zephir_read_property(&_3, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - zephir_is_iterable(&_3, 0, "phalcon/Http/Response/Headers.zep", 107); - if (Z_TYPE_P(&_3) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&_3), _6, _7, _4) - { - ZEPHIR_INIT_NVAR(&header); - if (_7 != NULL) { - ZVAL_STR_COPY(&header, _7); - } else { - ZVAL_LONG(&header, _6); - } - ZEPHIR_INIT_NVAR(&value); - ZVAL_COPY(&value, _4); - if (Z_TYPE_P(&value) != IS_NULL) { - ZEPHIR_INIT_NVAR(&_8$$5); - ZEPHIR_CONCAT_VSV(&_8$$5, &header, ": ", &value); - ZEPHIR_CALL_FUNCTION(NULL, "header", &_9, 360, &_8$$5, &__$true); - zephir_check_call_status(); - } else { - _10$$6 = zephir_memnstr_str(&header, SL(":"), "phalcon/Http/Response/Headers.zep", 99); - if (!(_10$$6)) { - ZVAL_LONG(&_11$$6, 0); - ZVAL_LONG(&_12$$6, 5); - ZEPHIR_INIT_NVAR(&_13$$6); - zephir_substr(&_13$$6, &header, 0 , 5 , 0); - _10$$6 = ZEPHIR_IS_STRING(&_13$$6, "HTTP/"); - } - if (_10$$6) { - ZEPHIR_CALL_FUNCTION(NULL, "header", &_9, 360, &header, &__$true); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&_14$$8); - ZEPHIR_CONCAT_VS(&_14$$8, &header, ": "); - ZEPHIR_CALL_FUNCTION(NULL, "header", &_9, 360, &_14$$8, &__$true); - zephir_check_call_status(); - } - } - } ZEND_HASH_FOREACH_END(); + if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { + zephir_get_strval(&name, name_param); } else { - ZEPHIR_CALL_METHOD(NULL, &_3, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5, &_3, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5)) { - break; - } - ZEPHIR_CALL_METHOD(&header, &_3, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&value, &_3, "current", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&value) != IS_NULL) { - ZEPHIR_INIT_NVAR(&_15$$10); - ZEPHIR_CONCAT_VSV(&_15$$10, &header, ": ", &value); - ZEPHIR_CALL_FUNCTION(NULL, "header", &_9, 360, &_15$$10, &__$true); - zephir_check_call_status(); - } else { - _16$$11 = zephir_memnstr_str(&header, SL(":"), "phalcon/Http/Response/Headers.zep", 99); - if (!(_16$$11)) { - ZVAL_LONG(&_17$$11, 0); - ZVAL_LONG(&_18$$11, 5); - ZEPHIR_INIT_NVAR(&_19$$11); - zephir_substr(&_19$$11, &header, 0 , 5 , 0); - _16$$11 = ZEPHIR_IS_STRING(&_19$$11, "HTTP/"); - } - if (_16$$11) { - ZEPHIR_CALL_FUNCTION(NULL, "header", &_9, 360, &header, &__$true); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&_20$$13); - ZEPHIR_CONCAT_VS(&_20$$13, &header, ": "); - ZEPHIR_CALL_FUNCTION(NULL, "header", &_9, 360, &_20$$13, &__$true); - zephir_check_call_status(); - } - } - ZEPHIR_CALL_METHOD(NULL, &_3, "next", NULL, 0); - zephir_check_call_status(); - } + ZEPHIR_INIT_VAR(&name); } - ZEPHIR_INIT_NVAR(&value); - ZEPHIR_INIT_NVAR(&header); - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSent"), &__$true); + if (UNEXPECTED(Z_TYPE_P(file_param) != IS_STRING && Z_TYPE_P(file_param) != IS_NULL)) { + zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'file' must be of the type string")); + RETURN_MM_NULL(); + } + if (EXPECTED(Z_TYPE_P(file_param) == IS_STRING)) { + zephir_get_strval(&file, file_param); } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("isSent"), &__$false); + ZEPHIR_INIT_VAR(&file); } - RETURN_MM_BOOL(1); -} - -static PHP_METHOD(Phalcon_Http_Response_Headers, set) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, *value_param = NULL; - zval name, value; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&value); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_STR(value) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &value_param); - zephir_get_strval(&name, name_param); - zephir_get_strval(&value, value_param); - zephir_update_property_array(this_ptr, SL("headers"), &name, &value); - RETURN_THIS(); + if (!width_param) { + width = 0; + } else { + } + if (!height_param) { + height = 0; + } else { + } + ZEPHIR_CALL_METHOD(&definition, this_ptr, "getservice", NULL, 0, &name); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + zephir_create_array(&_0, 3, 0); + zephir_array_fast_append(&_0, &file); + ZEPHIR_INIT_VAR(&_1); + ZVAL_LONG(&_1, width); + zephir_array_fast_append(&_0, &_1); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_LONG(&_1, height); + zephir_array_fast_append(&_0, &_1); + ZEPHIR_LAST_CALL_STATUS = zephir_create_instance_params(return_value, &definition, &_0); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Http_Response_Headers, setRaw) +static PHP_METHOD(Phalcon_Image_ImageFactory, getExceptionClass) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *header_param = NULL, __$null; - zval header; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&header); - ZVAL_NULL(&__$null); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(header) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &header_param); - zephir_get_strval(&header, header_param); - zephir_update_property_array(this_ptr, SL("headers"), &header, &__$null); - RETURN_THIS(); + RETURN_STRING("Phalcon\\Image\\Exception"); } -static PHP_METHOD(Phalcon_Http_Response_Headers, toArray) +static PHP_METHOD(Phalcon_Image_ImageFactory, getServices) { - RETURN_MEMBER(getThis(), "headers"); + zephir_create_array(return_value, 2, 0); + add_assoc_stringl_ex(return_value, SL("gd"), SL("Phalcon\\Image\\Adapter\\Gd")); + add_assoc_stringl_ex(return_value, SL("imagick"), SL("Phalcon\\Image\\Adapter\\Imagick")); + return; } -zend_object *zephir_init_properties_Phalcon_Http_Response_Headers(zend_class_entry *class_type) +static PHP_METHOD(Phalcon_Image_ImageFactory, getArrVal) { - zval _0, _1$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - + zval *collection_param = NULL, *index, index_sub, *defaultValue = NULL, defaultValue_sub, __$null, value; + zval collection; - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("headers"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("headers"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + ZVAL_UNDEF(&collection); + ZVAL_UNDEF(&index_sub); + ZVAL_UNDEF(&defaultValue_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&value); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(2, 3) + Z_PARAM_ARRAY(collection) + Z_PARAM_ZVAL(index) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL_OR_NULL(defaultValue) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 1, &collection_param, &index, &defaultValue); + ZEPHIR_OBS_COPY_OR_DUP(&collection, collection_param); + if (!defaultValue) { + defaultValue = &defaultValue_sub; + defaultValue = &__$null; } + zephir_memory_observe(&value); + if (UNEXPECTED(!(zephir_array_isset_fetch(&value, &collection, index, 0)))) { + RETVAL_ZVAL(defaultValue, 1, 0); + RETURN_MM(); + } + RETURN_CCTOR(&value); } @@ -161564,959 +162281,997 @@ zend_object *zephir_init_properties_Phalcon_Http_Response_Headers(zend_class_ent -ZEPHIR_INIT_CLASS(Phalcon_Http_Response_HeadersInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http\\Response, HeadersInterface, phalcon, http_response_headersinterface, phalcon_http_response_headersinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Http_Response_HeadersInterface, get); -ZEPHIR_DOC_METHOD(Phalcon_Http_Response_HeadersInterface, has); -ZEPHIR_DOC_METHOD(Phalcon_Http_Response_HeadersInterface, reset); -ZEPHIR_DOC_METHOD(Phalcon_Http_Response_HeadersInterface, send); -ZEPHIR_DOC_METHOD(Phalcon_Http_Response_HeadersInterface, set); -ZEPHIR_DOC_METHOD(Phalcon_Http_Response_HeadersInterface, setRaw); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Http_Message_RequestMethodInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http\\Message, RequestMethodInterface, phalcon, http_message_requestmethodinterface, NULL); - - zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_CONNECT"), "CONNECT"); - - zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_DELETE"), "DELETE"); - - zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_GET"), "GET"); - - zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_HEAD"), "HEAD"); - - zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_OPTIONS"), "OPTIONS"); - - zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_PATCH"), "PATCH"); - - zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_POST"), "POST"); - - zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_PURGE"), "PURGE"); - - zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_PUT"), "PUT"); - - zephir_declare_class_constant_string(phalcon_http_message_requestmethodinterface_ce, SL("METHOD_TRACE"), "TRACE"); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Http_Message_ResponseStatusCodeInterface) +ZEPHIR_INIT_CLASS(Phalcon_Image_Adapter_AbstractAdapter) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http\\Message, ResponseStatusCodeInterface, phalcon, http_message_responsestatuscodeinterface, NULL); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_CONTINUE"), 100); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_SWITCHING_PROTOCOLS"), 101); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_PROCESSING"), 102); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_EARLY_HINTS"), 103); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_OK"), 200); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_CREATED"), 201); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_ACCEPTED"), 202); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NON_AUTHORITATIVE_INFORMATION"), 203); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NO_CONTENT"), 204); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_RESET_CONTENT"), 205); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_PARTIAL_CONTENT"), 206); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_MULTI_STATUS"), 207); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_ALREADY_REPORTED"), 208); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_IM_USED"), 226); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_MULTIPLE_CHOICES"), 300); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_MOVED_PERMANENTLY"), 301); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_FOUND"), 302); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_SEE_OTHER"), 303); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NOT_MODIFIED"), 304); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_USE_PROXY"), 305); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_RESERVED"), 306); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_TEMPORARY_REDIRECT"), 307); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_PERMANENT_REDIRECT"), 308); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_BAD_REQUEST"), 400); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_UNAUTHORIZED"), 401); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_PAYMENT_REQUIRED"), 402); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_FORBIDDEN"), 403); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NOT_FOUND"), 404); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_METHOD_NOT_ALLOWED"), 405); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NOT_ACCEPTABLE"), 406); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_PROXY_AUTHENTICATION_REQUIRED"), 407); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_REQUEST_TIMEOUT"), 408); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_CONFLICT"), 409); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_GONE"), 410); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_LENGTH_REQUIRED"), 411); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_PRECONDITION_FAILED"), 412); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_PAYLOAD_TOO_LARGE"), 413); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_URI_TOO_LONG"), 414); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_UNSUPPORTED_MEDIA_TYPE"), 415); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_RANGE_NOT_SATISFIABLE"), 416); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_EXPECTATION_FAILED"), 417); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_IM_A_TEAPOT"), 418); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_MISDIRECTED_REQUEST"), 421); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_UNPROCESSABLE_ENTITY"), 422); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_LOCKED"), 423); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_FAILED_DEPENDENCY"), 424); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_TOO_EARLY"), 425); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_UPGRADE_REQUIRED"), 426); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_PRECONDITION_REQUIRED"), 428); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_TOO_MANY_REQUESTS"), 429); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_REQUEST_HEADER_FIELDS_TOO_LARGE"), 431); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_UNAVAILABLE_FOR_LEGAL_REASONS"), 451); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_INTERNAL_SERVER_ERROR"), 500); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NOT_IMPLEMENTED"), 501); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_BAD_GATEWAY"), 502); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_SERVICE_UNAVAILABLE"), 503); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_GATEWAY_TIMEOUT"), 504); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_VERSION_NOT_SUPPORTED"), 505); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_VARIANT_ALSO_NEGOTIATES"), 506); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_INSUFFICIENT_STORAGE"), 507); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_LOOP_DETECTED"), 508); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NOT_EXTENDED"), 510); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NETWORK_AUTHENTICATION_REQUIRED"), 511); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_THIS_IS_FINE"), 218); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_PAGE_EXPIRED"), 419); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_METHOD_FAILURE"), 420); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_LOGIN_TIMEOUT"), 440); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NO_RESPONSE"), 444); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_RETRY_WITH"), 449); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_BLOCKED_BY_WINDOWS_PARENTAL_CONTROLS"), 450); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_REQUEST_HEADER_TOO_LARGE"), 494); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_SSL_CERTIFICATE_ERROR"), 495); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_SSL_CERTIFICATE_REQUIRED"), 496); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_HTTP_REQUEST_SENT_TO_HTTPS_PORT"), 497); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_INVALID_TOKEN_ESRI"), 498); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_CLIENT_CLOSED_REQUEST"), 499); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_BANDWIDTH_LIMIT_EXCEEDED"), 509); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_UNKNOWN_ERROR"), 520); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_WEB_SERVER_IS_DOWN"), 521); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_CONNECTION_TIMEOUT"), 522); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_ORIGIN_IS_UNREACHABLE"), 523); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_TIMEOUT_OCCURRED"), 524); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_SSL_HANDSHAKE_FAILED"), 525); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_INVALID_SSL_CERTIFICATE"), 526); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_RAILGUN_ERROR"), 527); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_ORIGIN_DNS_ERROR"), 530); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NETWORK_READ_TIMEOUT_ERROR"), 598); - - zephir_declare_class_constant_long(phalcon_http_message_responsestatuscodeinterface_ce, SL("STATUS_NETWORK_CONNECT_TIMEOUT_ERROR"), 599); + ZEPHIR_REGISTER_CLASS(Phalcon\\Image\\Adapter, AbstractAdapter, phalcon, image_adapter_abstractadapter, phalcon_image_adapter_abstractadapter_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + zend_declare_property_null(phalcon_image_adapter_abstractadapter_ce, SL("file"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_image_adapter_abstractadapter_ce, SL("height"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_image_adapter_abstractadapter_ce, SL("image"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_image_adapter_abstractadapter_ce, SL("mime"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_image_adapter_abstractadapter_ce, SL("realpath"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_image_adapter_abstractadapter_ce, SL("type"), ZEND_ACC_PROTECTED); + zend_declare_property_null(phalcon_image_adapter_abstractadapter_ce, SL("width"), ZEND_ACC_PROTECTED); + zend_class_implements(phalcon_image_adapter_abstractadapter_ce, 1, phalcon_image_adapter_adapterinterface_ce); return SUCCESS; } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Http_Request_Exception) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, background) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Http\\Request, Exception, phalcon, http_request_exception, zend_ce_exception, NULL, 0); + zend_bool _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long opacity, ZEPHIR_LAST_CALL_STATUS; + zval *color_param = NULL, *opacity_param = NULL, colors, _1, _2, _3, _9, _10, _11, _12, _13, _14, _4$$3, _5$$3, _6$$4, _7$$4, _8$$4; + zval color; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&color); + ZVAL_UNDEF(&colors); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_13); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$4); + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_STR(color) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(opacity) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 1, &color_param, &opacity_param); + zephir_get_strval(&color, color_param); + if (!opacity_param) { + opacity = 100; + } else { + } + _0 = zephir_fast_strlen_ev(&color) > 1; + if (_0) { + ZVAL_LONG(&_1, 0); + ZVAL_LONG(&_2, 1); + ZEPHIR_INIT_VAR(&_3); + zephir_substr(&_3, &color, 0 , 1 , 0); + _0 = ZEPHIR_IS_STRING_IDENTICAL(&_3, "#"); + } + if (_0) { + ZVAL_LONG(&_4$$3, 1); + ZEPHIR_INIT_VAR(&_5$$3); + zephir_substr(&_5$$3, &color, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + zephir_get_strval(&color, &_5$$3); + } + if (zephir_fast_strlen_ev(&color) == 3) { + ZEPHIR_INIT_VAR(&_6$$4); + ZVAL_STRING(&_6$$4, "/./"); + ZEPHIR_INIT_VAR(&_7$$4); + ZVAL_STRING(&_7$$4, "$0$0"); + ZEPHIR_CALL_FUNCTION(&_8$$4, "preg_replace", NULL, 41, &_6$$4, &_7$$4, &color); + zephir_check_call_status(); + zephir_get_strval(&color, &_8$$4); + } + ZVAL_LONG(&_9, 2); + ZEPHIR_CALL_FUNCTION(&_10, "str_split", NULL, 88, &color, &_9); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_11); + ZVAL_STRING(&_11, "hexdec"); + ZEPHIR_CALL_FUNCTION(&colors, "array_map", NULL, 81, &_11, &_10); + zephir_check_call_status(); + zephir_array_fetch_long(&_12, &colors, 0, PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/AbstractAdapter.zep", 96); + zephir_array_fetch_long(&_13, &colors, 1, PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/AbstractAdapter.zep", 96); + zephir_array_fetch_long(&_14, &colors, 2, PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/AbstractAdapter.zep", 96); + ZVAL_LONG(&_9, opacity); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processbackground", NULL, 0, &_12, &_13, &_14, &_9); + zephir_check_call_status(); + RETURN_THIS(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Http_Request_File) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, blur) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Http\\Request, File, phalcon, http_request_file, phalcon_http_request_file_method_entry, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *radius_param = NULL, _0, _1, _2; + zend_long radius, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - zend_declare_property_null(phalcon_http_request_file_ce, SL("error"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_http_request_file_ce, SL("extension"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_http_request_file_ce, SL("key"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_http_request_file_ce, SL("name"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_http_request_file_ce, SL("realType"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_http_request_file_ce, SL("size"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_http_request_file_ce, SL("tmp"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_http_request_file_ce, SL("type"), ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_http_request_file_ce, 1, phalcon_http_request_fileinterface_ce); - return SUCCESS; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(radius) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &radius_param); + ZVAL_LONG(&_1, radius); + ZVAL_LONG(&_2, 1); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkhighlow", NULL, 0, &_1, &_2); + zephir_check_call_status(); + radius = zephir_get_numberval(&_0); + ZVAL_LONG(&_1, radius); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processblur", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Request_File, __construct) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, crop) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *file_param = NULL, *key = NULL, key_sub, __$null, name, _4, _5, _6, _7, _8, _0$$3, _1$$3, _2$$4, _3$$4; - zval file; + zval *width_param = NULL, *height_param = NULL, *offsetX_param = NULL, *offsetY_param = NULL, _0$$3, _1$$4, _2$$4, _3$$4, _4$$4, _5$$5, _6$$6, _7$$6, _8$$6, _9$$6, _10, _12, _14, _15, _16, _17, _11$$7, _13$$8; + zend_long width, height, offsetX, offsetY, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&file); - ZVAL_UNDEF(&key_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_7); - ZVAL_UNDEF(&_8); ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_1$$4); ZVAL_UNDEF(&_2$$4); ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_6$$6); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_8$$6); + ZVAL_UNDEF(&_9$$6); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_15); + ZVAL_UNDEF(&_16); + ZVAL_UNDEF(&_17); + ZVAL_UNDEF(&_11$$7); + ZVAL_UNDEF(&_13$$8); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(file) + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_LONG(width) + Z_PARAM_LONG(height) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(key) + Z_PARAM_LONG_OR_NULL(offsetX, is_null_true) + Z_PARAM_LONG_OR_NULL(offsetY, is_null_true) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &file_param, &key); - ZEPHIR_OBS_COPY_OR_DUP(&file, file_param); - if (!key) { - key = &key_sub; - key = &__$null; + zephir_fetch_params(1, 2, 2, &width_param, &height_param, &offsetX_param, &offsetY_param); + if (!offsetX_param) { + offsetX = 0; + } else { + } + if (!offsetY_param) { + offsetY = 0; + } else { + } + if (0 == offsetX) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + offsetX = (long) ((zephir_safe_div_long_long(((zephir_get_numberval(&_0$$3) - width)), 2))); + } else { + ZEPHIR_INIT_VAR(&_1$$4); + if (offsetX < 0) { + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_1$$4); + ZVAL_LONG(&_1$$4, ((zephir_get_numberval(&_2$$4) - width) + offsetX)); + } else { + ZEPHIR_INIT_NVAR(&_1$$4); + ZVAL_LONG(&_1$$4, offsetX); + } + offsetX = zephir_get_numberval(&_1$$4); + ZEPHIR_INIT_VAR(&_3$$4); + zephir_read_property(&_4$$4, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_LT_LONG(&_4$$4, offsetX)) { + ZEPHIR_OBS_NVAR(&_3$$4); + zephir_read_property(&_3$$4, this_ptr, ZEND_STRL("width"), PH_NOISY_CC); + } else { + ZEPHIR_INIT_NVAR(&_3$$4); + ZVAL_LONG(&_3$$4, offsetX); + } + offsetX = zephir_get_numberval(&_3$$4); } - zephir_memory_observe(&name); - if (zephir_array_isset_string_fetch(&name, &file, SL("name"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); - ZEPHIR_INIT_VAR(&_0$$3); - ZVAL_STRING(&_0$$3, "PATHINFO_EXTENSION"); - ZEPHIR_CALL_FUNCTION(&_1$$3, "defined", NULL, 118, &_0$$3); - zephir_check_call_status(); - if (zephir_is_true(&_1$$3)) { - ZVAL_LONG(&_2$$4, 4); - ZEPHIR_CALL_FUNCTION(&_3$$4, "pathinfo", NULL, 89, &name, &_2$$4); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("extension"), &_3$$4); + if (0 == offsetY) { + zephir_read_property(&_5$$5, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + offsetY = (long) ((zephir_safe_div_long_long(((zephir_get_numberval(&_5$$5) - height)), 2))); + } else { + ZEPHIR_INIT_VAR(&_6$$6); + if (offsetY < 0) { + zephir_read_property(&_7$$6, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_6$$6); + ZVAL_LONG(&_6$$6, ((zephir_get_numberval(&_7$$6) - height) + offsetY)); + } else { + ZEPHIR_INIT_NVAR(&_6$$6); + ZVAL_LONG(&_6$$6, offsetY); + } + offsetY = zephir_get_numberval(&_6$$6); + ZEPHIR_INIT_VAR(&_8$$6); + zephir_read_property(&_9$$6, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + if (ZEPHIR_LT_LONG(&_9$$6, offsetY)) { + ZEPHIR_OBS_NVAR(&_8$$6); + zephir_read_property(&_8$$6, this_ptr, ZEND_STRL("height"), PH_NOISY_CC); + } else { + ZEPHIR_INIT_NVAR(&_8$$6); + ZVAL_LONG(&_8$$6, offsetY); } + offsetY = zephir_get_numberval(&_8$$6); } - ZEPHIR_INIT_VAR(&_5); - ZVAL_STRING(&_5, "tmp_name"); - ZEPHIR_CALL_METHOD(&_4, this_ptr, "getarrval", NULL, 353, &file, &_5); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("tmp"), &_4); - ZEPHIR_INIT_NVAR(&_5); - ZVAL_STRING(&_5, "size"); - ZEPHIR_CALL_METHOD(&_6, this_ptr, "getarrval", NULL, 353, &file, &_5); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("size"), &_6); - ZEPHIR_INIT_NVAR(&_5); - ZVAL_STRING(&_5, "type"); - ZEPHIR_CALL_METHOD(&_7, this_ptr, "getarrval", NULL, 353, &file, &_5); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_7); - ZEPHIR_INIT_NVAR(&_5); - ZVAL_STRING(&_5, "error"); - ZEPHIR_CALL_METHOD(&_8, this_ptr, "getarrval", NULL, 353, &file, &_5); - zephir_check_call_status(); - zephir_update_property_zval(this_ptr, ZEND_STRL("error"), &_8); - if (zephir_is_true(key)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("key"), key); + zephir_read_property(&_10, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + if (width > ((zephir_get_numberval(&_10) - offsetX))) { + zephir_read_property(&_11$$7, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + width = (zephir_get_numberval(&_11$$7) - offsetX); } - ZEPHIR_MM_RESTORE(); + zephir_read_property(&_12, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + if (height > ((zephir_get_numberval(&_12) - offsetY))) { + zephir_read_property(&_13$$8, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + height = (zephir_get_numberval(&_13$$8) - offsetY); + } + ZVAL_LONG(&_14, width); + ZVAL_LONG(&_15, height); + ZVAL_LONG(&_16, offsetX); + ZVAL_LONG(&_17, offsetY); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processcrop", NULL, 0, &_14, &_15, &_16, &_17); + zephir_check_call_status(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Request_File, getError) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, flip) { + zend_bool _0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *direction_param = NULL, _1; + zend_long direction, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "error"); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(direction) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &direction_param); + _0 = direction != 11; + if (_0) { + _0 = direction != 12; + } + if (_0) { + direction = 11; + } + ZVAL_LONG(&_1, direction); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processflip", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Request_File, getExtension) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, getHeight) { - RETURN_MEMBER(getThis(), "extension"); + RETURN_MEMBER(getThis(), "height"); } -static PHP_METHOD(Phalcon_Http_Request_File, getKey) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, getImage) { - RETURN_MEMBER(getThis(), "key"); + RETURN_MEMBER(getThis(), "image"); } -static PHP_METHOD(Phalcon_Http_Request_File, getName) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, getMime) { - RETURN_MEMBER(getThis(), "name"); + RETURN_MEMBER(getThis(), "mime"); } -static PHP_METHOD(Phalcon_Http_Request_File, getRealType) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, getRealpath) { - zval finfo, mime, _0; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); - ZVAL_UNDEF(&finfo); - ZVAL_UNDEF(&mime); - ZVAL_UNDEF(&_0); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZVAL_LONG(&_0, 16); - ZEPHIR_CALL_FUNCTION(&finfo, "finfo_open", NULL, 308, &_0); - zephir_check_call_status(); - if (ZEPHIR_IS_FALSE_IDENTICAL(&finfo)) { - RETURN_MM_STRING(""); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("tmp"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CALL_FUNCTION(&mime, "finfo_file", NULL, 309, &finfo, &_0); - zephir_check_call_status(); - ZEPHIR_CALL_FUNCTION(NULL, "finfo_close", NULL, 310, &finfo); - zephir_check_call_status(); - RETURN_CCTOR(&mime); + RETURN_MEMBER(getThis(), "realpath"); } -static PHP_METHOD(Phalcon_Http_Request_File, getSize) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, getType) { - RETURN_MEMBER(getThis(), "size"); + RETURN_MEMBER(getThis(), "type"); } -static PHP_METHOD(Phalcon_Http_Request_File, getTempName) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, getWidth) { - RETURN_MEMBER(getThis(), "tmp"); + RETURN_MEMBER(getThis(), "width"); } -static PHP_METHOD(Phalcon_Http_Request_File, getType) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, mask) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *mask, mask_sub; + zval *this_ptr = getThis(); - RETURN_MEMBER(getThis(), "type"); + ZVAL_UNDEF(&mask_sub); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(mask, phalcon_image_adapter_adapterinterface_ce) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &mask); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processmask", NULL, 0, mask); + zephir_check_call_status(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Request_File, isUploadedFile) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, pixelate) { - zend_bool _0; - zval tmp, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zval *amount_param = NULL, _0; + zend_long amount, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&tmp); - ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(amount) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&tmp, this_ptr, "gettempname", NULL, 0); - zephir_check_call_status(); - _0 = Z_TYPE_P(&tmp) == IS_STRING; - if (_0) { - ZEPHIR_CALL_FUNCTION(&_1, "is_uploaded_file", NULL, 20, &tmp); - zephir_check_call_status(); - _0 = zephir_is_true(&_1); + zephir_fetch_params(1, 1, 0, &amount_param); + if (amount < 2) { + amount = 2; } - RETURN_MM_BOOL(_0); + ZVAL_LONG(&_0, amount); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processpixelate", NULL, 0, &_0); + zephir_check_call_status(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Request_File, moveTo) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, reflection) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *destination_param = NULL, _0; - zval destination; + zend_bool fadeIn, _0; + zval *height_param = NULL, *opacity_param = NULL, *fadeIn_param = NULL, _1, _3, _4, _5, _6, _2$$3; + zend_long height, opacity, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&destination); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(destination) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_2$$3); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_LONG(height) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(opacity) + Z_PARAM_BOOL(fadeIn) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &destination_param); - if (UNEXPECTED(Z_TYPE_P(destination_param) != IS_STRING && Z_TYPE_P(destination_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'destination' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 2, &height_param, &opacity_param, &fadeIn_param); + if (!opacity_param) { + opacity = 100; + } else { + } + if (!fadeIn_param) { + fadeIn = 0; + } else { + } + _0 = height <= 0; + if (!(_0)) { + zephir_read_property(&_1, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + _0 = ZEPHIR_LT_LONG(&_1, height); } - if (EXPECTED(Z_TYPE_P(destination_param) == IS_STRING)) { - zephir_get_strval(&destination, destination_param); + if (_0) { + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + height = zephir_get_numberval(&_2$$3); + } + ZVAL_LONG(&_4, opacity); + ZEPHIR_CALL_METHOD(&_3, this_ptr, "checkhighlow", NULL, 0, &_4); + zephir_check_call_status(); + opacity = zephir_get_numberval(&_3); + ZVAL_LONG(&_4, height); + ZVAL_LONG(&_5, opacity); + if (fadeIn) { + ZVAL_BOOL(&_6, 1); } else { - ZEPHIR_INIT_VAR(&destination); + ZVAL_BOOL(&_6, 0); } - zephir_read_property(&_0, this_ptr, ZEND_STRL("tmp"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_RETURN_CALL_FUNCTION("move_uploaded_file", NULL, 354, &_0, &destination); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processreflection", NULL, 0, &_4, &_5, &_6); zephir_check_call_status(); - RETURN_MM(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Http_Request_File, getArrVal) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, render) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *collection_param = NULL, *index, index_sub, *defaultValue = NULL, defaultValue_sub, __$null, value; - zval collection; + zend_long quality, ZEPHIR_LAST_CALL_STATUS; + zval *extension_param = NULL, *quality_param = NULL, _0$$3, _1$$3, _2$$3, _4, _5, _6; + zval extension, _3$$3; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&collection); - ZVAL_UNDEF(&index_sub); - ZVAL_UNDEF(&defaultValue_sub); - ZVAL_NULL(&__$null); - ZVAL_UNDEF(&value); + ZVAL_UNDEF(&extension); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_ARRAY(collection) - Z_PARAM_ZVAL(index) + ZEND_PARSE_PARAMETERS_START(0, 2) Z_PARAM_OPTIONAL - Z_PARAM_ZVAL_OR_NULL(defaultValue) + Z_PARAM_STR_OR_NULL(extension) + Z_PARAM_LONG(quality) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &collection_param, &index, &defaultValue); - ZEPHIR_OBS_COPY_OR_DUP(&collection, collection_param); - if (!defaultValue) { - defaultValue = &defaultValue_sub; - defaultValue = &__$null; + zephir_fetch_params(1, 0, 2, &extension_param, &quality_param); + if (!extension_param) { + ZEPHIR_INIT_VAR(&extension); + } else { + zephir_get_strval(&extension, extension_param); } - zephir_memory_observe(&value); - if (UNEXPECTED(!(zephir_array_isset_fetch(&value, &collection, index, 0)))) { - RETVAL_ZVAL(defaultValue, 1, 0); - RETURN_MM(); + if (!quality_param) { + quality = 100; + } else { + } + if (Z_TYPE_P(&extension) == IS_NULL) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1$$3, 4); + ZEPHIR_CALL_FUNCTION(&_2$$3, "pathinfo", NULL, 89, &_0$$3, &_1$$3); + zephir_check_call_status(); + zephir_cast_to_string(&_3$$3, &_2$$3); + ZEPHIR_CPY_WRT(&extension, &_3$$3); } - RETURN_CCTOR(&value); + if (1 == ZEPHIR_IS_EMPTY(&extension)) { + ZEPHIR_INIT_NVAR(&extension); + ZVAL_STRING(&extension, "png"); + } + ZVAL_LONG(&_5, quality); + ZVAL_LONG(&_6, 1); + ZEPHIR_CALL_METHOD(&_4, this_ptr, "checkhighlow", NULL, 0, &_5, &_6); + zephir_check_call_status(); + quality = zephir_get_numberval(&_4); + ZVAL_LONG(&_5, quality); + ZEPHIR_RETURN_CALL_METHOD(this_ptr, "processrender", NULL, 0, &extension, &_5); + zephir_check_call_status(); + RETURN_MM(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Http_Request_FileInterface) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, resize) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http\\Request, FileInterface, phalcon, http_request_fileinterface, phalcon_http_request_fileinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, getError); -ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, getName); -ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, getRealType); -ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, getSize); -ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, getTempName); -ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, getType); -ZEPHIR_DOC_METHOD(Phalcon_Http_Request_FileInterface, moveTo); - - - -#ifdef HAVE_CONFIG_H -#endif - + zend_bool _0$$3; + double ratio = 0; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *width_param = NULL, *height_param = NULL, *master_param = NULL, _20, _21, _22, _23, _24, _25, _26, _27, _1$$10, _2$$10, _3$$10, _4$$11, _5$$11, _6$$11, _7$$12, _8$$12, _9$$13, _10$$13, _11$$14, _12$$14, _13$$14, _14$$15, _15$$15, _16$$16, _17$$16, _18$$17, _19$$17; + zend_long width, height, master, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&_20); + ZVAL_UNDEF(&_21); + ZVAL_UNDEF(&_22); + ZVAL_UNDEF(&_23); + ZVAL_UNDEF(&_24); + ZVAL_UNDEF(&_25); + ZVAL_UNDEF(&_26); + ZVAL_UNDEF(&_27); + ZVAL_UNDEF(&_1$$10); + ZVAL_UNDEF(&_2$$10); + ZVAL_UNDEF(&_3$$10); + ZVAL_UNDEF(&_4$$11); + ZVAL_UNDEF(&_5$$11); + ZVAL_UNDEF(&_6$$11); + ZVAL_UNDEF(&_7$$12); + ZVAL_UNDEF(&_8$$12); + ZVAL_UNDEF(&_9$$13); + ZVAL_UNDEF(&_10$$13); + ZVAL_UNDEF(&_11$$14); + ZVAL_UNDEF(&_12$$14); + ZVAL_UNDEF(&_13$$14); + ZVAL_UNDEF(&_14$$15); + ZVAL_UNDEF(&_15$$15); + ZVAL_UNDEF(&_16$$16); + ZVAL_UNDEF(&_17$$16); + ZVAL_UNDEF(&_18$$17); + ZVAL_UNDEF(&_19$$17); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 3) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(width, is_null_true) + Z_PARAM_LONG_OR_NULL(height, is_null_true) + Z_PARAM_LONG(master) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 3, &width_param, &height_param, &master_param); + if (!width_param) { + width = 0; + } else { + } + if (!height_param) { + height = 0; + } else { + } + if (!master_param) { + master = 4; + } else { + } + do { + if (master == 7 || master == 4 || master == 5 || master == 6) { + _0$$3 = 0 == width; + if (!(_0$$3)) { + _0$$3 = 0 == height; + } + if (_0$$3) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width and height must be specified", "phalcon/Image/Adapter/AbstractAdapter.zep", 329); + return; + } + break; + } + if (master == 2) { + if (0 == width) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "width must be specified", "phalcon/Image/Adapter/AbstractAdapter.zep", 334); + return; + } + break; + } + if (master == 3) { + if (0 == height) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "height must be specified", "phalcon/Image/Adapter/AbstractAdapter.zep", 339); + return; + } + break; + } + } while(0); + if (master != 7) { + if (master == 4) { + ZEPHIR_INIT_VAR(&_1$$10); + zephir_read_property(&_2$$10, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_3$$10, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + if ((zephir_safe_div_zval_long(&_2$$10, width)) > (int) (zephir_safe_div_zval_long(&_3$$10, height))) { + ZEPHIR_INIT_NVAR(&_1$$10); + ZVAL_LONG(&_1$$10, 2); + } else { + ZEPHIR_INIT_NVAR(&_1$$10); + ZVAL_LONG(&_1$$10, 3); + } + master = zephir_get_numberval(&_1$$10); + } + if (master == 5) { + ZEPHIR_INIT_VAR(&_4$$11); + zephir_read_property(&_5$$11, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_6$$11, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + if ((zephir_safe_div_zval_long(&_5$$11, width)) > (int) (zephir_safe_div_zval_long(&_6$$11, height))) { + ZEPHIR_INIT_NVAR(&_4$$11); + ZVAL_LONG(&_4$$11, 3); + } else { + ZEPHIR_INIT_NVAR(&_4$$11); + ZVAL_LONG(&_4$$11, 2); + } + master = zephir_get_numberval(&_4$$11); + } + do { + if (master == 2) { + zephir_read_property(&_7$$12, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_8$$12, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + height = (long) (zephir_safe_div_long_zval((zephir_get_numberval(&_7$$12) * width), &_8$$12)); + break; + } + if (master == 3) { + zephir_read_property(&_9$$13, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_10$$13, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + width = (long) (zephir_safe_div_long_zval((zephir_get_numberval(&_9$$13) * height), &_10$$13)); + break; + } + if (master == 6) { + zephir_read_property(&_11$$14, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_12$$14, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_13$$14); + div_function(&_13$$14, &_11$$14, &_12$$14); + ratio = zephir_get_numberval(&_13$$14); + if ((zephir_safe_div_long_long(width, height)) > ratio) { + zephir_read_property(&_14$$15, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_15$$15, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + height = (long) (zephir_safe_div_long_zval((zephir_get_numberval(&_14$$15) * width), &_15$$15)); + } else { + zephir_read_property(&_16$$16, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_17$$16, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + width = (long) (zephir_safe_div_long_zval((zephir_get_numberval(&_16$$16) * height), &_17$$16)); + } + break; + } + if (master == 1) { + ZEPHIR_INIT_VAR(&_18$$17); + if (0 == width) { + ZEPHIR_OBS_NVAR(&_18$$17); + zephir_read_property(&_18$$17, this_ptr, ZEND_STRL("width"), PH_NOISY_CC); + } else { + ZEPHIR_INIT_NVAR(&_18$$17); + ZVAL_LONG(&_18$$17, width); + } + width = zephir_get_numberval(&_18$$17); + ZEPHIR_INIT_VAR(&_19$$17); + if (0 == height) { + ZEPHIR_OBS_NVAR(&_19$$17); + zephir_read_property(&_19$$17, this_ptr, ZEND_STRL("height"), PH_NOISY_CC); + } else { + ZEPHIR_INIT_NVAR(&_19$$17); + ZVAL_LONG(&_19$$17, height); + } + height = zephir_get_numberval(&_19$$17); + break; + } + } while(0); + } + ZEPHIR_INIT_VAR(&_20); + ZVAL_LONG(&_21, width); + zephir_round(&_20, &_21, NULL, NULL); + ZVAL_LONG(&_22, 1); + ZEPHIR_CALL_FUNCTION(&_23, "max", NULL, 90, &_20, &_22); + zephir_check_call_status(); + width = zephir_get_intval(&_23); + ZEPHIR_INIT_VAR(&_24); + ZVAL_LONG(&_22, height); + zephir_round(&_24, &_22, NULL, NULL); + ZVAL_LONG(&_25, 1); + ZEPHIR_CALL_FUNCTION(&_26, "max", NULL, 90, &_24, &_25); + zephir_check_call_status(); + height = zephir_get_intval(&_26); + ZVAL_LONG(&_25, width); + ZVAL_LONG(&_27, height); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processresize", NULL, 0, &_25, &_27); + zephir_check_call_status(); + RETURN_THIS(); +} -ZEPHIR_INIT_CLASS(Phalcon_Http_Cookie_CookieInterface) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, rotate) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Http\\Cookie, CookieInterface, phalcon, http_cookie_cookieinterface, phalcon_http_cookie_cookieinterface_method_entry); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *degrees_param = NULL, _0; + zend_long degrees, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&_0); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(degrees) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, °rees_param); + if (degrees > 180) { + degrees %= 360; + if (degrees > 180) { + degrees -= 360; + } + } else { + while (1) { + if (!(degrees < -180)) { + break; + } + degrees += 360; + } + } + ZVAL_LONG(&_0, degrees); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processrotate", NULL, 0, &_0); + zephir_check_call_status(); + RETURN_THIS(); } -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, delete); -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, getDomain); -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, getExpiration); -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, getHttpOnly); -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, getName); -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, getOptions); -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, getPath); -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, getSecure); -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, getValue); -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, isUsingEncryption); -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, send); -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, setDomain); -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, setExpiration); -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, setHttpOnly); -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, setOptions); -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, setPath); -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, setSecure); -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, setValue); -ZEPHIR_DOC_METHOD(Phalcon_Http_Cookie_CookieInterface, useEncryption); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Http_Cookie_Exception) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, save) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Http\\Cookie, Exception, phalcon, http_cookie_exception, zend_ce_exception, NULL, 0); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long quality, ZEPHIR_LAST_CALL_STATUS; + zval *file_param = NULL, *quality_param = NULL, _0$$3, _2; + zval file, _1$$3; + zval *this_ptr = getThis(); - return SUCCESS; + ZVAL_UNDEF(&file); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_2); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(0, 2) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(file) + Z_PARAM_LONG(quality) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 0, 2, &file_param, &quality_param); + if (!file_param) { + ZEPHIR_INIT_VAR(&file); + } else { + zephir_get_strval(&file, file_param); + } + if (!quality_param) { + quality = -1; + } else { + } + if (Z_TYPE_P(&file) == IS_NULL) { + zephir_memory_observe(&_0$$3); + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("realpath"), PH_NOISY_CC); + zephir_cast_to_string(&_1$$3, &_0$$3); + ZEPHIR_CPY_WRT(&file, &_1$$3); + } + ZVAL_LONG(&_2, quality); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processsave", NULL, 0, &file, &_2); + zephir_check_call_status(); + RETURN_THIS(); } - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Db_Column) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, sharpen) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Db, Column, phalcon, db_column, phalcon_db_column_method_entry, 0); - - zend_declare_property_null(phalcon_db_column_ce, SL("after"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_db_column_ce, SL("autoIncrement"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_db_column_ce, SL("bindType"), 2, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_db_column_ce, SL("comment"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_db_column_ce, SL("defaultValue"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_db_column_ce, SL("first"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_db_column_ce, SL("isNumeric"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_db_column_ce, SL("name"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_db_column_ce, SL("notNull"), 1, ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_db_column_ce, SL("primary"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_db_column_ce, SL("scale"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_db_column_ce, SL("size"), 0, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_db_column_ce, SL("type"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_db_column_ce, SL("typeReference"), -1, ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_db_column_ce, SL("typeValues"), ZEND_ACC_PROTECTED); - zend_declare_property_bool(phalcon_db_column_ce, SL("unsigned"), 0, ZEND_ACC_PROTECTED); - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_PARAM_BLOB"), 3); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_PARAM_BOOL"), 5); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_PARAM_DECIMAL"), 32); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_PARAM_INT"), 1); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_PARAM_NULL"), 0); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_PARAM_STR"), 2); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("BIND_SKIP"), 1024); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_BIGINTEGER"), 14); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_BIT"), 19); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_BINARY"), 27); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_BLOB"), 11); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_BOOLEAN"), 8); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_CHAR"), 5); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_DATE"), 1); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_DATETIME"), 4); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_DECIMAL"), 3); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_DOUBLE"), 9); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_ENUM"), 18); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_FLOAT"), 7); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_INTEGER"), 0); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_JSON"), 15); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_JSONB"), 16); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_LONGBLOB"), 13); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_LONGTEXT"), 24); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_MEDIUMBLOB"), 12); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_MEDIUMINTEGER"), 21); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_MEDIUMTEXT"), 23); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_SMALLINTEGER"), 22); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_TEXT"), 6); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_TIME"), 20); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_TIMESTAMP"), 17); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_TINYBLOB"), 10); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_TINYINTEGER"), 26); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_TINYTEXT"), 25); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_VARBINARY"), 28); - - zephir_declare_class_constant_long(phalcon_db_column_ce, SL("TYPE_VARCHAR"), 2); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *amount_param = NULL, _0, _1, _2; + zend_long amount, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - zend_class_implements(phalcon_db_column_ce, 1, phalcon_db_columninterface_ce); - return SUCCESS; + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(amount) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &amount_param); + ZVAL_LONG(&_1, amount); + ZVAL_LONG(&_2, 1); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkhighlow", NULL, 0, &_1, &_2); + zephir_check_call_status(); + amount = zephir_get_numberval(&_0); + ZVAL_LONG(&_1, amount); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processsharpen", NULL, 0, &_1); + zephir_check_call_status(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Db_Column, __construct) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, text) { + zend_bool _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval definition; - zval *name_param = NULL, *definition_param = NULL, __$true, __$false, type, notNull, primary, size, scale, dunsigned, first, after, bindType, isNumeric, autoIncrement, defaultValue, typeReference, typeValues, comment; - zval name; + zend_long opacity, size, ZEPHIR_LAST_CALL_STATUS; + zval *text_param = NULL, *offsetX = NULL, offsetX_sub, *offsetY = NULL, offsetY_sub, *opacity_param = NULL, *color_param = NULL, *size_param = NULL, *fontFile_param = NULL, __$false, colors, _0, _1, _3, _4, _10, _11, _12, _13, _14, _15, _16, _5$$3, _6$$3, _7$$4, _8$$4, _9$$4; + zval text, color, fontFile; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&color); + ZVAL_UNDEF(&fontFile); + ZVAL_UNDEF(&offsetX_sub); + ZVAL_UNDEF(&offsetY_sub); ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(¬Null); - ZVAL_UNDEF(&primary); - ZVAL_UNDEF(&size); - ZVAL_UNDEF(&scale); - ZVAL_UNDEF(&dunsigned); - ZVAL_UNDEF(&first); - ZVAL_UNDEF(&after); - ZVAL_UNDEF(&bindType); - ZVAL_UNDEF(&isNumeric); - ZVAL_UNDEF(&autoIncrement); - ZVAL_UNDEF(&defaultValue); - ZVAL_UNDEF(&typeReference); - ZVAL_UNDEF(&typeValues); - ZVAL_UNDEF(&comment); - ZVAL_UNDEF(&definition); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_ARRAY(definition) + ZVAL_UNDEF(&colors); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_13); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_15); + ZVAL_UNDEF(&_16); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$4); + ZVAL_UNDEF(&_9$$4); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 7) + Z_PARAM_STR(text) + Z_PARAM_OPTIONAL + Z_PARAM_ZVAL(offsetX) + Z_PARAM_ZVAL(offsetY) + Z_PARAM_LONG(opacity) + Z_PARAM_STR(color) + Z_PARAM_LONG(size) + Z_PARAM_STR_OR_NULL(fontFile) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &definition_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); - } else { - ZEPHIR_INIT_VAR(&name); - } - ZEPHIR_OBS_COPY_OR_DUP(&definition, definition_param); - zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); - zephir_memory_observe(&type); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&type, &definition, SL("type"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Column type is required", "phalcon/Db/Column.zep", 348); - return; - } - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &type); - zephir_memory_observe(&typeReference); - if (zephir_array_isset_string_fetch(&typeReference, &definition, SL("typeReference"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("typeReference"), &typeReference); - } - zephir_memory_observe(&typeValues); - if (zephir_array_isset_string_fetch(&typeValues, &definition, SL("typeValues"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("typeValues"), &typeValues); - } - zephir_memory_observe(¬Null); - if (zephir_array_isset_string_fetch(¬Null, &definition, SL("notNull"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("notNull"), ¬Null); - } - zephir_memory_observe(&primary); - if (zephir_array_isset_string_fetch(&primary, &definition, SL("primary"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("primary"), &primary); - } - zephir_memory_observe(&size); - if (zephir_array_isset_string_fetch(&size, &definition, SL("size"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("size"), &size); - } - zephir_memory_observe(&scale); - if (zephir_array_isset_string_fetch(&scale, &definition, SL("scale"), 0)) { - do { - if (ZEPHIR_IS_LONG(&type, 14) || ZEPHIR_IS_LONG(&type, 3) || ZEPHIR_IS_LONG(&type, 9) || ZEPHIR_IS_LONG(&type, 7) || ZEPHIR_IS_LONG(&type, 0) || ZEPHIR_IS_LONG(&type, 21) || ZEPHIR_IS_LONG(&type, 22) || ZEPHIR_IS_LONG(&type, 26)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("scale"), &scale); - break; - } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Column type does not support scale parameter", "phalcon/Db/Column.zep", 398); - return; - } while(0); - - } - zephir_memory_observe(&defaultValue); - if (zephir_array_isset_string_fetch(&defaultValue, &definition, SL("default"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("defaultValue"), &defaultValue); - } - zephir_memory_observe(&dunsigned); - if (zephir_array_isset_string_fetch(&dunsigned, &definition, SL("unsigned"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("unsigned"), &dunsigned); + zephir_fetch_params(1, 1, 6, &text_param, &offsetX, &offsetY, &opacity_param, &color_param, &size_param, &fontFile_param); + zephir_get_strval(&text, text_param); + if (!offsetX) { + offsetX = &offsetX_sub; + offsetX = &__$false; } - zephir_memory_observe(&isNumeric); - if (zephir_array_isset_string_fetch(&isNumeric, &definition, SL("isNumeric"), 0)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("isNumeric"), &isNumeric); + if (!offsetY) { + offsetY = &offsetY_sub; + offsetY = &__$false; } - zephir_memory_observe(&autoIncrement); - if (zephir_array_isset_string_fetch(&autoIncrement, &definition, SL("autoIncrement"), 0)) { - if (!(zephir_is_true(&autoIncrement))) { - if (0) { - zephir_update_property_zval(this_ptr, ZEND_STRL("autoIncrement"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("autoIncrement"), &__$false); - } - } else { - do { - if (ZEPHIR_IS_LONG(&type, 14) || ZEPHIR_IS_LONG(&type, 0) || ZEPHIR_IS_LONG(&type, 21) || ZEPHIR_IS_LONG(&type, 22) || ZEPHIR_IS_LONG(&type, 26)) { - if (1) { - zephir_update_property_zval(this_ptr, ZEND_STRL("autoIncrement"), &__$true); - } else { - zephir_update_property_zval(this_ptr, ZEND_STRL("autoIncrement"), &__$false); - } - break; - } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Column type cannot be auto-increment", "phalcon/Db/Column.zep", 442); - return; - } while(0); - + if (!opacity_param) { + opacity = 100; + } else { } + if (!color_param) { + ZEPHIR_INIT_VAR(&color); + ZVAL_STRING(&color, "000000"); + } else { + zephir_get_strval(&color, color_param); } - if (zephir_array_isset_string_fetch(&first, &definition, SL("first"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("first"), &first); + if (!size_param) { + size = 12; + } else { + } + if (!fontFile_param) { + ZEPHIR_INIT_VAR(&fontFile); + } else { + zephir_get_strval(&fontFile, fontFile_param); } - if (zephir_array_isset_string_fetch(&after, &definition, SL("after"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("after"), &after); + ZVAL_LONG(&_1, opacity); + ZEPHIR_CALL_METHOD(&_0, this_ptr, "checkhighlow", NULL, 0, &_1); + zephir_check_call_status(); + opacity = zephir_get_numberval(&_0); + _2 = zephir_fast_strlen_ev(&color) > 1; + if (_2) { + ZVAL_LONG(&_1, 0); + ZVAL_LONG(&_3, 1); + ZEPHIR_INIT_VAR(&_4); + zephir_substr(&_4, &color, 0 , 1 , 0); + _2 = ZEPHIR_IS_STRING_IDENTICAL(&_4, "#"); } - if (zephir_array_isset_string_fetch(&bindType, &definition, SL("bindType"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("bindType"), &bindType); + if (_2) { + ZVAL_LONG(&_5$$3, 1); + ZEPHIR_INIT_VAR(&_6$$3); + zephir_substr(&_6$$3, &color, 1 , 0, ZEPHIR_SUBSTR_NO_LENGTH); + zephir_get_strval(&color, &_6$$3); } - if (zephir_array_isset_string_fetch(&comment, &definition, SL("comment"), 1)) { - zephir_update_property_zval(this_ptr, ZEND_STRL("comment"), &comment); + if (zephir_fast_strlen_ev(&color) == 3) { + ZEPHIR_INIT_VAR(&_7$$4); + ZVAL_STRING(&_7$$4, "/./"); + ZEPHIR_INIT_VAR(&_8$$4); + ZVAL_STRING(&_8$$4, "$0$0"); + ZEPHIR_CALL_FUNCTION(&_9$$4, "preg_replace", NULL, 41, &_7$$4, &_8$$4, &color); + zephir_check_call_status(); + zephir_get_strval(&color, &_9$$4); } - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Db_Column, getAfterPosition) -{ - - RETURN_MEMBER(getThis(), "after"); -} - -static PHP_METHOD(Phalcon_Db_Column, getBindType) -{ - - RETURN_MEMBER(getThis(), "bindType"); -} - -static PHP_METHOD(Phalcon_Db_Column, getComment) -{ - - RETURN_MEMBER(getThis(), "comment"); -} - -static PHP_METHOD(Phalcon_Db_Column, getDefault) -{ - - RETURN_MEMBER(getThis(), "defaultValue"); -} - -static PHP_METHOD(Phalcon_Db_Column, getName) -{ - - RETURN_MEMBER(getThis(), "name"); -} - -static PHP_METHOD(Phalcon_Db_Column, getScale) -{ - - RETURN_MEMBER(getThis(), "scale"); -} - -static PHP_METHOD(Phalcon_Db_Column, getSize) -{ - - RETURN_MEMBER(getThis(), "size"); -} - -static PHP_METHOD(Phalcon_Db_Column, getType) -{ - - RETURN_MEMBER(getThis(), "type"); -} - -static PHP_METHOD(Phalcon_Db_Column, getTypeReference) -{ - - RETURN_MEMBER(getThis(), "typeReference"); -} - -static PHP_METHOD(Phalcon_Db_Column, getTypeValues) -{ - - RETURN_MEMBER(getThis(), "typeValues"); + ZVAL_LONG(&_10, 2); + ZEPHIR_CALL_FUNCTION(&_11, "str_split", NULL, 88, &color, &_10); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_12); + ZVAL_STRING(&_12, "hexdec"); + ZEPHIR_CALL_FUNCTION(&colors, "array_map", NULL, 81, &_12, &_11); + zephir_check_call_status(); + zephir_array_fetch_long(&_13, &colors, 0, PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/AbstractAdapter.zep", 495); + zephir_array_fetch_long(&_14, &colors, 1, PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/AbstractAdapter.zep", 496); + zephir_array_fetch_long(&_15, &colors, 2, PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/AbstractAdapter.zep", 497); + ZVAL_LONG(&_10, opacity); + ZVAL_LONG(&_16, size); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processtext", NULL, 0, &text, offsetX, offsetY, &_10, &_13, &_14, &_15, &_16, &fontFile); + zephir_check_call_status(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Db_Column, hasDefault) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, watermark) { - zval _0, _1; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; + zend_long offsetX, offsetY, opacity, ZEPHIR_LAST_CALL_STATUS; + zval *watermark, watermark_sub, *offsetX_param = NULL, *offsetY_param = NULL, *opacity_param = NULL, op, x, y, _0, _1, _2, _3, _4; zval *this_ptr = getThis(); + ZVAL_UNDEF(&watermark_sub); + ZVAL_UNDEF(&op); + ZVAL_UNDEF(&x); + ZVAL_UNDEF(&y); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZEND_PARSE_PARAMETERS_START(1, 4) + Z_PARAM_OBJECT_OF_CLASS(watermark, phalcon_image_adapter_adapterinterface_ce) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(offsetX) + Z_PARAM_LONG(offsetY) + Z_PARAM_LONG(opacity) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "isautoincrement", NULL, 0); + zephir_fetch_params(1, 1, 3, &watermark, &offsetX_param, &offsetY_param, &opacity_param); + if (!offsetX_param) { + offsetX = 0; + } else { + } + if (!offsetY_param) { + offsetY = 0; + } else { + } + if (!opacity_param) { + opacity = 100; + } else { + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, watermark, "getwidth", NULL, 0); zephir_check_call_status(); - if (zephir_is_true(&_0)) { - RETURN_MM_BOOL(0); - } - zephir_read_property(&_1, this_ptr, ZEND_STRL("defaultValue"), PH_NOISY_CC | PH_READONLY); - RETURN_MM_BOOL(Z_TYPE_P(&_1) != IS_NULL); + ZEPHIR_INIT_VAR(&_2); + zephir_sub_function(&_2, &_0, &_1); + ZVAL_LONG(&_0, offsetX); + ZVAL_LONG(&_3, 0); + ZEPHIR_CALL_METHOD(&x, this_ptr, "checkhighlow", NULL, 0, &_0, &_3, &_2); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_1, watermark, "getheight", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_4); + zephir_sub_function(&_4, &_0, &_1); + ZVAL_LONG(&_0, offsetX); + ZVAL_LONG(&_3, 0); + ZEPHIR_CALL_METHOD(&y, this_ptr, "checkhighlow", NULL, 0, &_0, &_3, &_4); + zephir_check_call_status(); + ZVAL_LONG(&_0, opacity); + ZEPHIR_CALL_METHOD(&op, this_ptr, "checkhighlow", NULL, 0, &_0); + zephir_check_call_status(); + ZVAL_LONG(&_0, opacity); + ZEPHIR_CALL_METHOD(NULL, this_ptr, "processwatermark", NULL, 0, watermark, &x, &y, &_0); + zephir_check_call_status(); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Db_Column, isAutoIncrement) +static PHP_METHOD(Phalcon_Image_Adapter_AbstractAdapter, checkHighLow) { + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *value_param = NULL, *min_param = NULL, *max_param = NULL, _0, _1, _2; + zend_long value, min, max, ZEPHIR_LAST_CALL_STATUS; - RETURN_MEMBER(getThis(), "autoIncrement"); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_LONG(value) + Z_PARAM_OPTIONAL + Z_PARAM_LONG(min) + Z_PARAM_LONG(max) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &value_param, &min_param, &max_param); + if (!min_param) { + min = 0; + } else { + } + if (!max_param) { + max = 100; + } else { + } + ZVAL_LONG(&_0, value); + ZVAL_LONG(&_1, min); + ZEPHIR_CALL_FUNCTION(&_2, "max", NULL, 90, &_0, &_1); + zephir_check_call_status(); + ZVAL_LONG(&_0, max); + ZEPHIR_RETURN_CALL_FUNCTION("min", NULL, 91, &_0, &_2); + zephir_check_call_status(); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Db_Column, isFirst) -{ - RETURN_MEMBER(getThis(), "first"); -} -static PHP_METHOD(Phalcon_Db_Column, isNotNull) -{ - RETURN_MEMBER(getThis(), "notNull"); -} +#ifdef HAVE_CONFIG_H +#endif -static PHP_METHOD(Phalcon_Db_Column, isNumeric) -{ - RETURN_MEMBER(getThis(), "isNumeric"); -} -static PHP_METHOD(Phalcon_Db_Column, isPrimary) -{ - RETURN_MEMBER(getThis(), "primary"); -} -static PHP_METHOD(Phalcon_Db_Column, isUnsigned) +ZEPHIR_INIT_CLASS(Phalcon_Image_Adapter_AdapterInterface) { + ZEPHIR_REGISTER_INTERFACE(Phalcon\\Image\\Adapter, AdapterInterface, phalcon, image_adapter_adapterinterface, phalcon_image_adapter_adapterinterface_method_entry); - RETURN_MEMBER(getThis(), "unsigned"); + return SUCCESS; } +ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, background); +ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, blur); +ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, crop); +ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, flip); +ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, mask); +ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, pixelate); +ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, reflection); +ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, render); +ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, resize); +ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, rotate); +ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, save); +ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, sharpen); +ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, text); +ZEPHIR_DOC_METHOD(Phalcon_Image_Adapter_AdapterInterface, watermark); @@ -162527,2714 +163282,3369 @@ static PHP_METHOD(Phalcon_Db_Column, isUnsigned) -ZEPHIR_INIT_CLASS(Phalcon_Db_ColumnInterface) +ZEPHIR_INIT_CLASS(Phalcon_Image_Adapter_Gd) { - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Db, ColumnInterface, phalcon, db_columninterface, phalcon_db_columninterface_method_entry); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Image\\Adapter, Gd, phalcon, image_adapter_gd, phalcon_image_adapter_abstractadapter_ce, phalcon_image_adapter_gd_method_entry, 0); return SUCCESS; } -ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getAfterPosition); -ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getBindType); -ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getDefault); -ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getName); -ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getScale); -ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getSize); -ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getType); -ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getTypeReference); -ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, getTypeValues); -ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, hasDefault); -ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, isAutoIncrement); -ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, isFirst); -ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, isNotNull); -ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, isNumeric); -ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, isPrimary); -ZEPHIR_DOC_METHOD(Phalcon_Db_ColumnInterface, isUnsigned); - - - -#ifdef HAVE_CONFIG_H -#endif - - +static PHP_METHOD(Phalcon_Image_Adapter_Gd, __construct) +{ + zend_bool _26$$13; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zend_long width, height, ZEPHIR_LAST_CALL_STATUS; + zval *file_param = NULL, *width_param = NULL, *height_param = NULL, __$true, imageInfo, _0, _1$$3, _2$$3, _3$$3, _8$$3, _25$$3, _4$$4, _5$$4, _6$$4, _7$$4, _9$$5, _10$$5, _11$$6, _12$$6, _13$$7, _14$$7, _15$$8, _16$$8, _17$$9, _18$$9, _19$$10, _20$$10, _21$$11, _22$$12, _23$$12, _24$$12, _30$$13, _31$$13, _32$$13, _33$$13, _34$$13, _35$$13, _27$$14, _28$$14, _29$$14; + zval file; + zval *this_ptr = getThis(); + ZVAL_UNDEF(&file); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&imageInfo); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_25$$3); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_10$$5); + ZVAL_UNDEF(&_11$$6); + ZVAL_UNDEF(&_12$$6); + ZVAL_UNDEF(&_13$$7); + ZVAL_UNDEF(&_14$$7); + ZVAL_UNDEF(&_15$$8); + ZVAL_UNDEF(&_16$$8); + ZVAL_UNDEF(&_17$$9); + ZVAL_UNDEF(&_18$$9); + ZVAL_UNDEF(&_19$$10); + ZVAL_UNDEF(&_20$$10); + ZVAL_UNDEF(&_21$$11); + ZVAL_UNDEF(&_22$$12); + ZVAL_UNDEF(&_23$$12); + ZVAL_UNDEF(&_24$$12); + ZVAL_UNDEF(&_30$$13); + ZVAL_UNDEF(&_31$$13); + ZVAL_UNDEF(&_32$$13); + ZVAL_UNDEF(&_33$$13); + ZVAL_UNDEF(&_34$$13); + ZVAL_UNDEF(&_35$$13); + ZVAL_UNDEF(&_27$$14); + ZVAL_UNDEF(&_28$$14); + ZVAL_UNDEF(&_29$$14); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(file) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(width, is_null_true) + Z_PARAM_LONG_OR_NULL(height, is_null_true) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 2, &file_param, &width_param, &height_param); + zephir_get_strval(&file, file_param); + if (!width_param) { + width = 0; + } else { + } + if (!height_param) { + height = 0; + } else { + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "check", NULL, 361); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("file"), &file); + ZVAL_UNDEF(&_0); + ZVAL_LONG(&_0, 0); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); + if (1 == (zephir_file_exists(&_0) == SUCCESS)) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&_2$$3, "realpath", NULL, 74, &_1$$3); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("realpath"), &_2$$3); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&imageInfo, "getimagesize", NULL, 311, &_3$$3); + zephir_check_call_status(); + if (!ZEPHIR_IS_FALSE_IDENTICAL(&imageInfo)) { + zephir_array_fetch_long(&_4$$4, &imageInfo, 0, PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/Gd.zep", 42); + zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_4$$4); + zephir_array_fetch_long(&_5$$4, &imageInfo, 1, PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/Gd.zep", 43); + zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_5$$4); + zephir_array_fetch_long(&_6$$4, &imageInfo, 2, PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/Gd.zep", 44); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_6$$4); + zephir_array_fetch_string(&_7$$4, &imageInfo, SL("mime"), PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/Gd.zep", 45); + zephir_update_property_zval(this_ptr, ZEND_STRL("mime"), &_7$$4); + } + zephir_memory_observe(&_8$$3); + zephir_read_property(&_8$$3, this_ptr, ZEND_STRL("type"), PH_NOISY_CC); + do { + if (ZEPHIR_IS_LONG(&_8$$3, 1)) { + zephir_read_property(&_9$$5, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&_10$$5, "imagecreatefromgif", NULL, 362, &_9$$5); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &_10$$5); + break; + } + if (ZEPHIR_IS_LONG(&_8$$3, 2) || ZEPHIR_IS_LONG(&_8$$3, 9)) { + zephir_read_property(&_11$$6, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&_12$$6, "imagecreatefromjpeg", NULL, 363, &_11$$6); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &_12$$6); + break; + } + if (ZEPHIR_IS_LONG(&_8$$3, 3)) { + zephir_read_property(&_13$$7, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&_14$$7, "imagecreatefrompng", NULL, 364, &_13$$7); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &_14$$7); + break; + } + if (ZEPHIR_IS_LONG(&_8$$3, 18)) { + zephir_read_property(&_15$$8, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&_16$$8, "imagecreatefromwebp", NULL, 365, &_15$$8); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &_16$$8); + break; + } + if (ZEPHIR_IS_LONG(&_8$$3, 15)) { + zephir_read_property(&_17$$9, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&_18$$9, "imagecreatefromwbmp", NULL, 366, &_17$$9); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &_18$$9); + break; + } + if (ZEPHIR_IS_LONG(&_8$$3, 16)) { + zephir_read_property(&_19$$10, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&_20$$10, "imagecreatefromxbm", NULL, 367, &_19$$10); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &_20$$10); + break; + } + zephir_read_property(&_21$$11, this_ptr, ZEND_STRL("mime"), PH_NOISY_CC | PH_READONLY); + if (zephir_is_true(&_21$$11)) { + ZEPHIR_INIT_VAR(&_22$$12); + object_init_ex(&_22$$12, phalcon_image_exception_ce); + zephir_read_property(&_23$$12, this_ptr, ZEND_STRL("mime"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_24$$12); + ZEPHIR_CONCAT_SVS(&_24$$12, "Installed GD does not support ", &_23$$12, " images"); + ZEPHIR_CALL_METHOD(NULL, &_22$$12, "__construct", NULL, 33, &_24$$12); + zephir_check_call_status(); + zephir_throw_exception_debug(&_22$$12, "phalcon/Image/Adapter/Gd.zep", 78); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Installed GD does not support such images", "phalcon/Image/Adapter/Gd.zep", 83); + return; + } while(0); + zephir_read_property(&_25$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 368, &_25$$3, &__$true); + zephir_check_call_status(); + } else { + _26$$13 = 0 == width; + if (!(_26$$13)) { + _26$$13 = 0 == height; + } + if (_26$$13) { + ZEPHIR_INIT_VAR(&_27$$14); + object_init_ex(&_27$$14, phalcon_image_exception_ce); + zephir_read_property(&_28$$14, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_29$$14); + ZEPHIR_CONCAT_SV(&_29$$14, "Failed to create image from file ", &_28$$14); + ZEPHIR_CALL_METHOD(NULL, &_27$$14, "__construct", NULL, 33, &_29$$14); + zephir_check_call_status(); + zephir_throw_exception_debug(&_27$$14, "phalcon/Image/Adapter/Gd.zep", 91); + ZEPHIR_MM_RESTORE(); + return; + } + ZVAL_LONG(&_30$$13, width); + ZVAL_LONG(&_31$$13, height); + ZEPHIR_CALL_FUNCTION(&_32$$13, "imagecreatetruecolor", NULL, 369, &_30$$13, &_31$$13); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &_32$$13); + zephir_read_property(&_30$$13, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagealphablending", NULL, 370, &_30$$13, &__$true); + zephir_check_call_status(); + zephir_read_property(&_31$$13, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 368, &_31$$13, &__$true); + zephir_check_call_status(); + zephir_read_property(&_33$$13, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("realpath"), &_33$$13); + ZVAL_UNDEF(&_34$$13); + ZVAL_LONG(&_34$$13, width); + zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_34$$13); + ZVAL_UNDEF(&_34$$13); + ZVAL_LONG(&_34$$13, height); + zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_34$$13); + ZVAL_UNDEF(&_34$$13); + ZVAL_LONG(&_34$$13, 3); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_34$$13); + ZEPHIR_INIT_VAR(&_35$$13); + ZEPHIR_INIT_NVAR(&_35$$13); + ZVAL_STRING(&_35$$13, "image/png"); + zephir_update_property_zval(this_ptr, ZEND_STRL("mime"), &_35$$13); + } + ZEPHIR_MM_RESTORE(); +} -ZEPHIR_INIT_CLASS(Phalcon_Db_Dialect) +static PHP_METHOD(Phalcon_Image_Adapter_Gd, __destruct) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Db, Dialect, phalcon, db_dialect, phalcon_db_dialect_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval __$null, image, _0; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); - zend_declare_property_null(phalcon_db_dialect_ce, SL("escapeChar"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_db_dialect_ce, SL("customFunctions"), ZEND_ACC_PROTECTED); - phalcon_db_dialect_ce->create_object = zephir_init_properties_Phalcon_Db_Dialect; + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&image); + ZVAL_UNDEF(&_0); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zend_class_implements(phalcon_db_dialect_ce, 1, phalcon_db_dialectinterface_ce); - return SUCCESS; + zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&image, &_0); + if (Z_TYPE_P(&image) != IS_NULL) { + ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &image); + zephir_check_call_status(); + } + zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &__$null); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, createSavepoint) +static PHP_METHOD(Phalcon_Image_Adapter_Gd, getVersion) { + zval info, matches, version, _0, _1, _2$$5, _3$$5, _4$$5, _5$$5; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL; - zval name; + zend_long ZEPHIR_LAST_CALL_STATUS; - ZVAL_UNDEF(&name); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&info); + ZVAL_UNDEF(&matches); + ZVAL_UNDEF(&version); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$5); + ZVAL_UNDEF(&_3$$5); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$5); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); + + if (1 != (zephir_function_exists_ex(ZEND_STRL("gd_info")) == SUCCESS)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "GD is either not installed or not enabled, check your configuration", "phalcon/Image/Adapter/Gd.zep", 134); + return; } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + ZEPHIR_INIT_VAR(&version); + ZVAL_NULL(&version); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "GD_VERSION"); + ZEPHIR_CALL_FUNCTION(&_1, "defined", NULL, 118, &_0); + zephir_check_call_status(); + if (zephir_is_true(&_1)) { + ZEPHIR_INIT_NVAR(&version); + ZEPHIR_GET_CONSTANT(&version, "GD_VERSION"); } else { - ZEPHIR_INIT_VAR(&name); + ZEPHIR_CALL_FUNCTION(&info, "gd_info", NULL, 372); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&matches); + ZVAL_NULL(&matches); + zephir_array_fetch_string(&_2$$5, &info, SL("GD Version"), PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/Gd.zep", 148); + ZEPHIR_INIT_VAR(&_3$$5); + ZVAL_STRING(&_3$$5, "/\\d+\\.\\d+(?:\\.\\d+)?/"); + ZEPHIR_INIT_VAR(&_4$$5); + ZEPHIR_INIT_VAR(&_5$$5); + ZVAL_STRING(&_5$$5, "/\\d+\\.\\d+(?:\\.\\d+)?/"); + zephir_preg_match(&_4$$5, &_5$$5, &_2$$5, &matches, 0, 0 , 0 ); + if (zephir_is_true(&_4$$5)) { + ZEPHIR_OBS_NVAR(&version); + zephir_array_fetch_long(&version, &matches, 0, PH_NOISY, "phalcon/Image/Adapter/Gd.zep", 152); + } } - ZEPHIR_CONCAT_SV(return_value, "SAVEPOINT ", &name); - RETURN_MM(); + RETURN_CCTOR(&version); } -static PHP_METHOD(Phalcon_Db_Dialect, escape) +static PHP_METHOD(Phalcon_Image_Adapter_Gd, processBackground) { - zend_bool _2$$5, _12$$7, _13$$7, _17$$9, _18$$9; - zend_string *_11; - zend_ulong _10; - zval _7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *str_param = NULL, *escapeChar_param = NULL, parts, key, part, newParts, _5, _6, *_8, _9, _0$$4, _3$$6, _14$$7, _16$$7, _19$$9, _21$$9; - zval str, escapeChar, _1$$4, _4$$6, _15$$7, _20$$9; + zval *red_param = NULL, *green_param = NULL, *blue_param = NULL, *opacity_param = NULL, __$true, background, color, copy, image, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9; + zend_long red, green, blue, opacity, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&str); - ZVAL_UNDEF(&escapeChar); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_4$$6); - ZVAL_UNDEF(&_15$$7); - ZVAL_UNDEF(&_20$$9); - ZVAL_UNDEF(&parts); - ZVAL_UNDEF(&key); - ZVAL_UNDEF(&part); - ZVAL_UNDEF(&newParts); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&background); + ZVAL_UNDEF(&color); + ZVAL_UNDEF(©); + ZVAL_UNDEF(&image); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_5); ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_9); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_3$$6); - ZVAL_UNDEF(&_14$$7); - ZVAL_UNDEF(&_16$$7); - ZVAL_UNDEF(&_19$$9); - ZVAL_UNDEF(&_21$$9); ZVAL_UNDEF(&_7); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(str) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_LONG(red) + Z_PARAM_LONG(green) + Z_PARAM_LONG(blue) + Z_PARAM_LONG(opacity) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &str_param, &escapeChar_param); - if (UNEXPECTED(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 of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(str_param) == IS_STRING)) { - zephir_get_strval(&str, str_param); - } else { - ZEPHIR_INIT_VAR(&str); - } - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!(ZEPHIR_GLOBAL(db).escape_identifiers)) { - RETURN_CTOR(&str); - } - if (ZEPHIR_IS_EMPTY(&escapeChar)) { - zephir_memory_observe(&_0$$4); - zephir_read_property(&_0$$4, this_ptr, ZEND_STRL("escapeChar"), PH_NOISY_CC); - zephir_cast_to_string(&_1$$4, &_0$$4); - ZEPHIR_CPY_WRT(&escapeChar, &_1$$4); + zephir_fetch_params(1, 4, 0, &red_param, &green_param, &blue_param, &opacity_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_DOUBLE(&_1, ((zephir_safe_div_long_long((opacity * 127), 100)) - (double) (127))); + ZEPHIR_CALL_FUNCTION(&_2, "abs", NULL, 284, &_1); + zephir_check_call_status(); + zephir_round(&_0, &_2, NULL, NULL); + opacity = zephir_get_intval(&_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&image, &_1); + zephir_read_property(&_1, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_3, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&background, this_ptr, "processcreate", NULL, 0, &_1, &_3); + zephir_check_call_status(); + ZVAL_LONG(&_4, red); + ZVAL_LONG(&_5, green); + ZVAL_LONG(&_6, blue); + ZVAL_LONG(&_7, opacity); + ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 373, &background, &_4, &_5, &_6, &_7); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(NULL, "imagealphablending", NULL, 370, &background, &__$true); + zephir_check_call_status(); + zephir_read_property(&_4, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_5, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_6, 0); + ZVAL_LONG(&_7, 0); + ZVAL_LONG(&_8, 0); + ZVAL_LONG(&_9, 0); + ZEPHIR_CALL_FUNCTION(©, "imagecopy", NULL, 374, &background, &image, &_6, &_7, &_8, &_9, &_4, &_5); + zephir_check_call_status(); + if (!ZEPHIR_IS_FALSE_IDENTICAL(©)) { + ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &image); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &background); } - if (!(zephir_memnstr_str(&str, SL("."), "phalcon/Db/Dialect.zep", 52))) { - _2$$5 = !ZEPHIR_IS_STRING(&escapeChar, ""); - if (_2$$5) { - _2$$5 = !ZEPHIR_IS_STRING(&str, "*"); - } - if (_2$$5) { - ZEPHIR_INIT_VAR(&_3$$6); - ZEPHIR_INIT_VAR(&_4$$6); - ZEPHIR_CONCAT_VV(&_4$$6, &escapeChar, &escapeChar); - zephir_fast_str_replace(&_3$$6, &escapeChar, &_4$$6, &str); - ZEPHIR_CONCAT_VVV(return_value, &escapeChar, &_3$$6, &escapeChar); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Image_Adapter_Gd, processBlur) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_2 = NULL; + zval *radius_param = NULL, _0$$3, _1$$3; + zend_long radius, ZEPHIR_LAST_CALL_STATUS, counter = 0; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(radius) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &radius_param); + counter = 0; + while (1) { + if (!(counter < radius)) { + break; } - RETURN_CTOR(&str); - } - ZEPHIR_INIT_VAR(&_5); - ZEPHIR_INIT_VAR(&_6); - zephir_fast_trim(&_6, &str, &escapeChar, ZEPHIR_TRIM_BOTH); - zephir_fast_explode_str(&_5, SL("."), &_6, LONG_MAX); - zephir_get_arrval(&_7, &_5); - ZEPHIR_CPY_WRT(&parts, &_7); - ZEPHIR_CPY_WRT(&newParts, &parts); - zephir_is_iterable(&parts, 0, "phalcon/Db/Dialect.zep", 72); - if (Z_TYPE_P(&parts) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&parts), _10, _11, _8) - { - ZEPHIR_INIT_NVAR(&key); - if (_11 != NULL) { - ZVAL_STR_COPY(&key, _11); - } else { - ZVAL_LONG(&key, _10); - } - ZEPHIR_INIT_NVAR(&part); - ZVAL_COPY(&part, _8); - _12$$7 = ZEPHIR_IS_STRING(&escapeChar, ""); - if (!(_12$$7)) { - _12$$7 = ZEPHIR_IS_STRING(&part, ""); - } - _13$$7 = _12$$7; - if (!(_13$$7)) { - _13$$7 = ZEPHIR_IS_STRING(&part, "*"); - } - if (_13$$7) { - continue; - } - ZEPHIR_INIT_NVAR(&_14$$7); - ZEPHIR_INIT_NVAR(&_15$$7); - ZEPHIR_CONCAT_VV(&_15$$7, &escapeChar, &escapeChar); - zephir_fast_str_replace(&_14$$7, &escapeChar, &_15$$7, &part); - ZEPHIR_INIT_NVAR(&_16$$7); - ZEPHIR_CONCAT_VVV(&_16$$7, &escapeChar, &_14$$7, &escapeChar); - zephir_array_update_zval(&newParts, &key, &_16$$7, PH_COPY | PH_SEPARATE); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &parts, "rewind", NULL, 0); + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1$$3, 7); + ZEPHIR_CALL_FUNCTION(NULL, "imagefilter", &_2, 375, &_0$$3, &_1$$3); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_9, &parts, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_9)) { - break; - } - ZEPHIR_CALL_METHOD(&key, &parts, "key", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&part, &parts, "current", NULL, 0); - zephir_check_call_status(); - _17$$9 = ZEPHIR_IS_STRING(&escapeChar, ""); - if (!(_17$$9)) { - _17$$9 = ZEPHIR_IS_STRING(&part, ""); - } - _18$$9 = _17$$9; - if (!(_18$$9)) { - _18$$9 = ZEPHIR_IS_STRING(&part, "*"); - } - if (_18$$9) { - continue; - } - ZEPHIR_INIT_NVAR(&_19$$9); - ZEPHIR_INIT_NVAR(&_20$$9); - ZEPHIR_CONCAT_VV(&_20$$9, &escapeChar, &escapeChar); - zephir_fast_str_replace(&_19$$9, &escapeChar, &_20$$9, &part); - ZEPHIR_INIT_NVAR(&_21$$9); - ZEPHIR_CONCAT_VVV(&_21$$9, &escapeChar, &_19$$9, &escapeChar); - zephir_array_update_zval(&newParts, &key, &_21$$9, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(NULL, &parts, "next", NULL, 0); - zephir_check_call_status(); - } + counter++; } - ZEPHIR_INIT_NVAR(&part); - ZEPHIR_INIT_NVAR(&key); - zephir_fast_join_str(return_value, SL("."), &newParts); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, escapeSchema) +static PHP_METHOD(Phalcon_Image_Adapter_Gd, processCreate) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *str_param = NULL, *escapeChar_param = NULL, _0$$4, _2; - zval str, escapeChar, _1$$4; + zval *width_param = NULL, *height_param = NULL, __$false, __$true, image, _0, _1; + zend_long width, height, ZEPHIR_LAST_CALL_STATUS; + + ZVAL_BOOL(&__$false, 0); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&image); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_LONG(width) + Z_PARAM_LONG(height) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &width_param, &height_param); + ZVAL_LONG(&_0, width); + ZVAL_LONG(&_1, height); + ZEPHIR_CALL_FUNCTION(&image, "imagecreatetruecolor", NULL, 369, &_0, &_1); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(NULL, "imagealphablending", NULL, 370, &image, &__$false); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 368, &image, &__$true); + zephir_check_call_status(); + RETURN_CCTOR(&image); +} + +static PHP_METHOD(Phalcon_Image_Adapter_Gd, processCrop) +{ + zval rect; + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *width_param = NULL, *height_param = NULL, *offsetX_param = NULL, *offsetY_param = NULL, image, _0, _1, _2, _3, _4; + zend_long width, height, offsetX, offsetY, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&str); - ZVAL_UNDEF(&escapeChar); - ZVAL_UNDEF(&_1$$4); - ZVAL_UNDEF(&_0$$4); + ZVAL_UNDEF(&image); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_STR(str) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&rect); + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_LONG(width) + Z_PARAM_LONG(height) + Z_PARAM_LONG(offsetX) + Z_PARAM_LONG(offsetY) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &str_param, &escapeChar_param); - if (UNEXPECTED(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 of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(str_param) == IS_STRING)) { - zephir_get_strval(&str, str_param); - } else { - ZEPHIR_INIT_VAR(&str); - } - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); + zephir_fetch_params(1, 4, 0, &width_param, &height_param, &offsetX_param, &offsetY_param); + ZEPHIR_INIT_VAR(&rect); + zephir_create_array(&rect, 4, 0); + ZEPHIR_INIT_VAR(&_0); + ZVAL_LONG(&_0, offsetX); + zephir_array_update_string(&rect, SL("x"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_LONG(&_0, offsetY); + zephir_array_update_string(&rect, SL("y"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_LONG(&_0, width); + zephir_array_update_string(&rect, SL("width"), &_0, PH_COPY | PH_SEPARATE); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_LONG(&_0, height); + zephir_array_update_string(&rect, SL("height"), &_0, PH_COPY | PH_SEPARATE); + zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&image, "imagecrop", NULL, 376, &_1, &rect); + zephir_check_call_status(); + zephir_read_property(&_2, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &_2); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &image); + ZEPHIR_CALL_FUNCTION(&_3, "imagesx", NULL, 377, &image); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_3); + ZEPHIR_CALL_FUNCTION(&_4, "imagesy", NULL, 378, &image); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_4); + ZEPHIR_MM_RESTORE(); +} + +static PHP_METHOD(Phalcon_Image_Adapter_Gd, processFlip) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *direction_param = NULL, _0$$3, _1$$3, _2$$4, _3$$4; + zend_long direction, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(direction) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 1, 0, &direction_param); + if (direction == 11) { + zephir_read_property(&_0$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1$$3, 1); + ZEPHIR_CALL_FUNCTION(NULL, "imageflip", NULL, 379, &_0$$3, &_1$$3); + zephir_check_call_status(); } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!(ZEPHIR_GLOBAL(db).escape_identifiers)) { - RETURN_CTOR(&str); - } - if (ZEPHIR_IS_STRING(&escapeChar, "")) { - zephir_memory_observe(&_0$$4); - zephir_read_property(&_0$$4, this_ptr, ZEND_STRL("escapeChar"), PH_NOISY_CC); - zephir_cast_to_string(&_1$$4, &_0$$4); - ZEPHIR_CPY_WRT(&escapeChar, &_1$$4); + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_3$$4, 2); + ZEPHIR_CALL_FUNCTION(NULL, "imageflip", NULL, 379, &_2$$4, &_3$$4); + zephir_check_call_status(); } - ZEPHIR_INIT_VAR(&_2); - zephir_fast_trim(&_2, &str, &escapeChar, ZEPHIR_TRIM_BOTH); - ZEPHIR_CONCAT_VVV(return_value, &escapeChar, &_2, &escapeChar); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, forUpdate) +static PHP_METHOD(Phalcon_Image_Adapter_Gd, processMask) { + zend_bool _9; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *sqlQuery_param = NULL; - zval sqlQuery; + zephir_fcall_cache_entry *_23 = NULL, *_24 = NULL, *_29 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS, alpha = 0, maskHeight = 0, maskWidth = 0, x = 0, y = 0; + zval *mask, mask_sub, __$true, blue, color, index, green, maskImage, newImage, red, tempImage, _0, _1, _2, _3, _4, _5, _6, _7, _8, _10$$3, _11$$3, _12$$3, _13$$3, _14$$3, _15$$3, _16$$3, _17$$3, _18$$3, _19$$3, _20$$4, _21$$5, _22$$5, _27$$5, _28$$5, _25$$6, _26$$6; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&sqlQuery); + ZVAL_UNDEF(&mask_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&blue); + ZVAL_UNDEF(&color); + ZVAL_UNDEF(&index); + ZVAL_UNDEF(&green); + ZVAL_UNDEF(&maskImage); + ZVAL_UNDEF(&newImage); + ZVAL_UNDEF(&red); + ZVAL_UNDEF(&tempImage); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_11$$3); + ZVAL_UNDEF(&_12$$3); + ZVAL_UNDEF(&_13$$3); + ZVAL_UNDEF(&_14$$3); + ZVAL_UNDEF(&_15$$3); + ZVAL_UNDEF(&_16$$3); + ZVAL_UNDEF(&_17$$3); + ZVAL_UNDEF(&_18$$3); + ZVAL_UNDEF(&_19$$3); + ZVAL_UNDEF(&_20$$4); + ZVAL_UNDEF(&_21$$5); + ZVAL_UNDEF(&_22$$5); + ZVAL_UNDEF(&_27$$5); + ZVAL_UNDEF(&_28$$5); + ZVAL_UNDEF(&_25$$6); + ZVAL_UNDEF(&_26$$6); ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(sqlQuery) + Z_PARAM_OBJECT_OF_CLASS(mask, phalcon_image_adapter_adapterinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &sqlQuery_param); - if (UNEXPECTED(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 0, &mask); + ZEPHIR_CALL_METHOD(&_0, mask, "render", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&maskImage, "imagecreatefromstring", NULL, 380, &_0); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_1, "imagesx", NULL, 377, &maskImage); + zephir_check_call_status(); + maskWidth = zephir_get_intval(&_1); + ZEPHIR_CALL_FUNCTION(&_2, "imagesy", NULL, 378, &maskImage); + zephir_check_call_status(); + maskHeight = zephir_get_intval(&_2); + alpha = 127; + ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 368, &maskImage, &__$true); + zephir_check_call_status(); + zephir_read_property(&_3, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_4, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&newImage, this_ptr, "processcreate", NULL, 0, &_3, &_4); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 368, &newImage, &__$true); + zephir_check_call_status(); + ZVAL_LONG(&_5, 0); + ZVAL_LONG(&_6, 0); + ZVAL_LONG(&_7, 0); + ZVAL_LONG(&_8, alpha); + ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 373, &newImage, &_5, &_6, &_7, &_8); + zephir_check_call_status(); + ZVAL_LONG(&_5, 0); + ZVAL_LONG(&_6, 0); + ZEPHIR_CALL_FUNCTION(NULL, "imagefill", NULL, 381, &newImage, &_5, &_6, &color); + zephir_check_call_status(); + zephir_read_property(&_5, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + _9 = !ZEPHIR_IS_LONG_IDENTICAL(&_5, maskWidth); + if (!(_9)) { + zephir_read_property(&_6, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + _9 = !ZEPHIR_IS_LONG_IDENTICAL(&_6, maskHeight); } - if (EXPECTED(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { - zephir_get_strval(&sqlQuery, sqlQuery_param); - } else { - ZEPHIR_INIT_VAR(&sqlQuery); + if (_9) { + zephir_read_property(&_10$$3, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_11$$3, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&tempImage, "imagecreatetruecolor", NULL, 369, &_10$$3, &_11$$3); + zephir_check_call_status(); + zephir_read_property(&_12$$3, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_13$$3, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_14$$3, 0); + ZVAL_LONG(&_15$$3, 0); + ZVAL_LONG(&_16$$3, 0); + ZVAL_LONG(&_17$$3, 0); + ZVAL_LONG(&_18$$3, maskWidth); + ZVAL_LONG(&_19$$3, maskHeight); + ZEPHIR_CALL_FUNCTION(NULL, "imagecopyresampled", NULL, 382, &tempImage, &maskImage, &_14$$3, &_15$$3, &_16$$3, &_17$$3, &_12$$3, &_13$$3, &_18$$3, &_19$$3); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &maskImage); + zephir_check_call_status(); + ZEPHIR_CPY_WRT(&maskImage, &tempImage); + } + x = 0; + while (1) { + zephir_read_property(&_7, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + if (!(ZEPHIR_GT_LONG(&_7, x))) { + break; + } + y = 0; + while (1) { + zephir_read_property(&_20$$4, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + if (!(ZEPHIR_GT_LONG(&_20$$4, y))) { + break; + } + ZVAL_LONG(&_21$$5, x); + ZVAL_LONG(&_22$$5, y); + ZEPHIR_CALL_FUNCTION(&index, "imagecolorat", &_23, 383, &maskImage, &_21$$5, &_22$$5); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&color, "imagecolorsforindex", &_24, 384, &maskImage, &index); + zephir_check_call_status(); + if (1 == zephir_array_isset_string(&color, SL("red"))) { + zephir_array_fetch_string(&_25$$6, &color, SL("red"), PH_NOISY | PH_READONLY, "phalcon/Image/Adapter/Gd.zep", 348); + ZVAL_DOUBLE(&_26$$6, zephir_safe_div_zval_long(&_25$$6, 2)); + alpha = (127 - zephir_get_intval(&_26$$6)); + } + zephir_read_property(&_21$$5, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_22$$5, x); + ZVAL_LONG(&_27$$5, y); + ZEPHIR_CALL_FUNCTION(&index, "imagecolorat", &_23, 383, &_21$$5, &_22$$5, &_27$$5); + zephir_check_call_status(); + zephir_read_property(&_22$$5, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&color, "imagecolorsforindex", &_24, 384, &_22$$5, &index); + zephir_check_call_status(); + ZEPHIR_OBS_NVAR(&red); + zephir_array_fetch_string(&red, &color, SL("red"), PH_NOISY, "phalcon/Image/Adapter/Gd.zep", 353); + ZEPHIR_OBS_NVAR(&green); + zephir_array_fetch_string(&green, &color, SL("green"), PH_NOISY, "phalcon/Image/Adapter/Gd.zep", 354); + ZEPHIR_OBS_NVAR(&blue); + zephir_array_fetch_string(&blue, &color, SL("blue"), PH_NOISY, "phalcon/Image/Adapter/Gd.zep", 355); + ZVAL_LONG(&_27$$5, alpha); + ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 373, &newImage, &red, &green, &blue, &_27$$5); + zephir_check_call_status(); + ZVAL_LONG(&_27$$5, x); + ZVAL_LONG(&_28$$5, y); + ZEPHIR_CALL_FUNCTION(NULL, "imagesetpixel", &_29, 385, &newImage, &_27$$5, &_28$$5, &color); + zephir_check_call_status(); + y++; + } + x++; } - ZEPHIR_CONCAT_VS(return_value, &sqlQuery, " FOR UPDATE"); - RETURN_MM(); + zephir_read_property(&_8, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &_8); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &maskImage); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &newImage); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, getColumnList) +static PHP_METHOD(Phalcon_Image_Adapter_Gd, processPixelate) { + zend_bool _3$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval escapeChar; - zval *columnList_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, column, *_0, _1, _2$$3, _4$$4; - zval columnList, bindCounts, columns; + zephir_fcall_cache_entry *_8 = NULL, *_10 = NULL; + zval *amount_param = NULL, color, x2, y2, _0, _1$$3, _2$$4, _4$$4, _5$$4, _6$$4, _7$$4, _9$$4; + zend_long amount, ZEPHIR_LAST_CALL_STATUS, x = 0, x1 = 0, y = 0, y1 = 0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&columnList); - ZVAL_UNDEF(&bindCounts); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&color); + ZVAL_UNDEF(&x2); + ZVAL_UNDEF(&y2); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&escapeChar); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ARRAY(columnList) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) - Z_PARAM_ARRAY(bindCounts) + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_9$$4); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(amount) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &columnList_param, &escapeChar_param, &bindCounts_param); - ZEPHIR_OBS_COPY_OR_DUP(&columnList, columnList_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!bindCounts_param) { - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); - } - ZEPHIR_INIT_VAR(&columns); - array_init(&columns); - zephir_is_iterable(&columnList, 0, "phalcon/Db/Dialect.zep", 128); - if (Z_TYPE_P(&columnList) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&columnList), _0) - { - ZEPHIR_INIT_NVAR(&column); - ZVAL_COPY(&column, _0); - ZEPHIR_CALL_METHOD(&_2$$3, this_ptr, "getsqlcolumn", &_3, 44, &column, &escapeChar, &bindCounts); - zephir_check_call_status(); - zephir_array_append(&columns, &_2$$3, PH_SEPARATE, "phalcon/Db/Dialect.zep", 125); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &columnList, "rewind", NULL, 0); - zephir_check_call_status(); + zephir_fetch_params(1, 1, 0, &amount_param); + x = 0; + while (1) { + zephir_read_property(&_0, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + if (!(ZEPHIR_GT_LONG(&_0, x))) { + break; + } + y = 0; while (1) { - ZEPHIR_CALL_METHOD(&_1, &columnList, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + if (!(ZEPHIR_GT_LONG(&_1$$3, y))) { break; } - ZEPHIR_CALL_METHOD(&column, &columnList, "current", NULL, 0); + x1 = ((x + (zephir_safe_div_long_long(amount, 2)))); + y1 = ((y + (zephir_safe_div_long_long(amount, 2)))); + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + _3$$4 = ZEPHIR_LE_LONG(&_2$$4, x1); + if (!(_3$$4)) { + zephir_read_property(&_4$$4, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + _3$$4 = ZEPHIR_LE_LONG(&_4$$4, y1); + } + if (_3$$4) { + break; + } + zephir_read_property(&_5$$4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_6$$4, x1); + ZVAL_LONG(&_7$$4, y1); + ZEPHIR_CALL_FUNCTION(&color, "imagecolorat", &_8, 383, &_5$$4, &_6$$4, &_7$$4); zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$4, this_ptr, "getsqlcolumn", &_3, 44, &column, &escapeChar, &bindCounts); - zephir_check_call_status(); - zephir_array_append(&columns, &_4$$4, PH_SEPARATE, "phalcon/Db/Dialect.zep", 125); - ZEPHIR_CALL_METHOD(NULL, &columnList, "next", NULL, 0); + ZEPHIR_INIT_NVAR(&x2); + ZVAL_LONG(&x2, (x + amount)); + ZEPHIR_INIT_NVAR(&y2); + ZVAL_LONG(&y2, (y + amount)); + zephir_read_property(&_6$$4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_7$$4, x); + ZVAL_LONG(&_9$$4, y); + ZEPHIR_CALL_FUNCTION(NULL, "imagefilledrectangle", &_10, 386, &_6$$4, &_7$$4, &_9$$4, &x2, &y2, &color); zephir_check_call_status(); + y += amount; } + x += amount; } - ZEPHIR_INIT_NVAR(&column); - zephir_fast_join_str(return_value, SL(", "), &columns); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Db_Dialect, getCustomFunctions) -{ - - RETURN_MEMBER(getThis(), "customFunctions"); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, getSqlColumn) +static PHP_METHOD(Phalcon_Image_Adapter_Gd, processReflection) { - zend_bool _5, _3$$4, _4$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval bindCounts; - zval escapeChar; - zval *column = NULL, column_sub, *escapeChar_param = NULL, *bindCounts_param = NULL, columnExpression, columnAlias, columnField, columnDomain, _6, _0$$3, _1$$6, _2$$7; + zephir_fcall_cache_entry *_25 = NULL; + zend_bool fadeIn; + zval *height_param = NULL, *opacity_param = NULL, *fadeIn_param = NULL, line, reflection, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _27, _28, _11$$5, _12$$5, _17$$5, _18$$5, _19$$5, _20$$5, _21$$5, _22$$5, _23$$5, _24$$5, _26$$5, _13$$6, _14$$6, _15$$7, _16$$7; + zend_long height, opacity, ZEPHIR_LAST_CALL_STATUS, destinationY = 0, destinationOpacity = 0, offset = 0, stepping = 0, sourceY = 0; zval *this_ptr = getThis(); - ZVAL_UNDEF(&column_sub); - ZVAL_UNDEF(&columnExpression); - ZVAL_UNDEF(&columnAlias); - ZVAL_UNDEF(&columnField); - ZVAL_UNDEF(&columnDomain); + ZVAL_UNDEF(&line); + ZVAL_UNDEF(&reflection); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); ZVAL_UNDEF(&_6); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$6); - ZVAL_UNDEF(&_2$$7); - ZVAL_UNDEF(&escapeChar); - ZVAL_UNDEF(&bindCounts); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ZVAL(column) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) - Z_PARAM_ARRAY(bindCounts) + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_27); + ZVAL_UNDEF(&_28); + ZVAL_UNDEF(&_11$$5); + ZVAL_UNDEF(&_12$$5); + ZVAL_UNDEF(&_17$$5); + ZVAL_UNDEF(&_18$$5); + ZVAL_UNDEF(&_19$$5); + ZVAL_UNDEF(&_20$$5); + ZVAL_UNDEF(&_21$$5); + ZVAL_UNDEF(&_22$$5); + ZVAL_UNDEF(&_23$$5); + ZVAL_UNDEF(&_24$$5); + ZVAL_UNDEF(&_26$$5); + ZVAL_UNDEF(&_13$$6); + ZVAL_UNDEF(&_14$$6); + ZVAL_UNDEF(&_15$$7); + ZVAL_UNDEF(&_16$$7); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_LONG(height) + Z_PARAM_LONG(opacity) + Z_PARAM_BOOL(fadeIn) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &column, &escapeChar_param, &bindCounts_param); - ZEPHIR_SEPARATE_PARAM(column); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!bindCounts_param) { - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); + zephir_fetch_params(1, 3, 0, &height_param, &opacity_param, &fadeIn_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_DOUBLE(&_1, ((zephir_safe_div_long_long((opacity * 127), 100)) - (double) (127))); + ZEPHIR_CALL_FUNCTION(&_2, "abs", NULL, 284, &_1); + zephir_check_call_status(); + zephir_round(&_0, &_2, NULL, NULL); + opacity = zephir_get_intval(&_0); + if (opacity < 127) { + stepping = (long) (zephir_safe_div_long_long(((127 - opacity)), height)); } else { - ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); - } - if (Z_TYPE_P(column) != IS_ARRAY) { - ZVAL_NULL(&_0$$3); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "preparequalified", NULL, 0, column, &_0$$3, &escapeChar); - zephir_check_call_status(); - RETURN_MM(); + stepping = (long) (zephir_safe_div_long_long(127, height)); } - if (!(zephir_array_isset_string(column, SL("type")))) { - zephir_memory_observe(&columnField); - zephir_array_fetch_long(&columnField, column, 0, PH_NOISY, "phalcon/Db/Dialect.zep", 160); - if (Z_TYPE_P(&columnField) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&columnExpression); - zephir_create_array(&columnExpression, 2, 0); - add_assoc_stringl_ex(&columnExpression, SL("type"), SL("scalar")); - zephir_array_update_string(&columnExpression, SL("value"), &columnField, PH_COPY | PH_SEPARATE); - } else if (ZEPHIR_IS_STRING_IDENTICAL(&columnField, "*")) { - ZEPHIR_INIT_VAR(&_1$$6); - zephir_create_array(&_1$$6, 1, 0); - add_assoc_stringl_ex(&_1$$6, SL("type"), SL("all")); - ZEPHIR_CPY_WRT(&columnExpression, &_1$$6); - } else { - ZEPHIR_INIT_VAR(&_2$$7); - zephir_create_array(&_2$$7, 2, 0); - add_assoc_stringl_ex(&_2$$7, SL("type"), SL("qualified")); - zephir_array_update_string(&_2$$7, SL("name"), &columnField, PH_COPY | PH_SEPARATE); - ZEPHIR_CPY_WRT(&columnExpression, &_2$$7); - } - zephir_memory_observe(&columnDomain); - _3$$4 = zephir_array_isset_long_fetch(&columnDomain, column, 1, 0); - if (_3$$4) { - _3$$4 = !ZEPHIR_IS_STRING_IDENTICAL(&columnDomain, ""); - } - if (_3$$4) { - zephir_array_update_string(&columnExpression, SL("domain"), &columnDomain, PH_COPY | PH_SEPARATE); - } - zephir_memory_observe(&columnAlias); - _4$$4 = zephir_array_isset_long_fetch(&columnAlias, column, 2, 0); - if (_4$$4) { - _4$$4 = zephir_is_true(&columnAlias); + zephir_read_property(&_1, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_3, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_4, (zephir_get_numberval(&_3) + height)); + ZEPHIR_CALL_METHOD(&reflection, this_ptr, "processcreate", NULL, 0, &_1, &_4); + zephir_check_call_status(); + zephir_read_property(&_4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_5, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_6, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_7, 0); + ZVAL_LONG(&_8, 0); + ZVAL_LONG(&_9, 0); + ZVAL_LONG(&_10, 0); + ZEPHIR_CALL_FUNCTION(NULL, "imagecopy", NULL, 374, &reflection, &_4, &_7, &_8, &_9, &_10, &_5, &_6); + zephir_check_call_status(); + offset = 0; + while (1) { + if (!(height >= offset)) { + break; } - if (_4$$4) { - zephir_array_update_string(&columnExpression, SL("sqlAlias"), &columnAlias, PH_COPY | PH_SEPARATE); + zephir_read_property(&_11$$5, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + sourceY = ((zephir_get_numberval(&_11$$5) - offset) - 1); + zephir_read_property(&_12$$5, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + destinationY = (zephir_get_numberval(&_12$$5) + offset); + if (fadeIn) { + ZEPHIR_INIT_NVAR(&_13$$6); + ZVAL_LONG(&_14$$6, (opacity + ((stepping * ((height - offset)))))); + zephir_round(&_13$$6, &_14$$6, NULL, NULL); + destinationOpacity = zephir_get_intval(&_13$$6); + } else { + ZEPHIR_INIT_NVAR(&_15$$7); + ZVAL_LONG(&_16$$7, (opacity + ((stepping * offset)))); + zephir_round(&_15$$7, &_16$$7, NULL, NULL); + destinationOpacity = zephir_get_intval(&_15$$7); } - } else { - ZEPHIR_CPY_WRT(&columnExpression, column); - } - ZEPHIR_CALL_METHOD(column, this_ptr, "getsqlexpression", NULL, 0, &columnExpression, &escapeChar, &bindCounts); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&columnAlias); - _5 = zephir_array_isset_string_fetch(&columnAlias, &columnExpression, SL("sqlAlias"), 0); - if (!(_5)) { - ZEPHIR_OBS_NVAR(&columnAlias); - _5 = zephir_array_isset_string_fetch(&columnAlias, &columnExpression, SL("alias"), 0); - } - if (_5) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "preparecolumnalias", NULL, 0, column, &columnAlias, &escapeChar); + zephir_read_property(&_17$$5, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_18$$5, 1); + ZEPHIR_CALL_METHOD(&line, this_ptr, "processcreate", NULL, 0, &_17$$5, &_18$$5); zephir_check_call_status(); - RETURN_MM(); + zephir_read_property(&_18$$5, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_19$$5, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_20$$5, 0); + ZVAL_LONG(&_21$$5, 0); + ZVAL_LONG(&_22$$5, 0); + ZVAL_LONG(&_23$$5, sourceY); + ZVAL_LONG(&_24$$5, 1); + ZEPHIR_CALL_FUNCTION(NULL, "imagecopy", NULL, 374, &line, &_18$$5, &_20$$5, &_21$$5, &_22$$5, &_23$$5, &_19$$5, &_24$$5); + zephir_check_call_status(); + ZVAL_LONG(&_20$$5, 4); + ZVAL_LONG(&_21$$5, 0); + ZVAL_LONG(&_22$$5, 0); + ZVAL_LONG(&_23$$5, 0); + ZVAL_LONG(&_24$$5, destinationOpacity); + ZEPHIR_CALL_FUNCTION(NULL, "imagefilter", &_25, 375, &line, &_20$$5, &_21$$5, &_22$$5, &_23$$5, &_24$$5); + zephir_check_call_status(); + zephir_read_property(&_20$$5, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_21$$5, 0); + ZVAL_LONG(&_22$$5, destinationY); + ZVAL_LONG(&_23$$5, 0); + ZVAL_LONG(&_24$$5, 0); + ZVAL_LONG(&_26$$5, 1); + ZEPHIR_CALL_FUNCTION(NULL, "imagecopy", NULL, 374, &reflection, &line, &_21$$5, &_22$$5, &_23$$5, &_24$$5, &_20$$5, &_26$$5); + zephir_check_call_status(); + offset++; } - ZVAL_NULL(&_6); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "preparecolumnalias", NULL, 0, column, &_6, &escapeChar); + zephir_read_property(&_7, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &_7); zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &reflection); + ZEPHIR_CALL_FUNCTION(&_27, "imagesx", NULL, 377, &reflection); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_27); + ZEPHIR_CALL_FUNCTION(&_28, "imagesy", NULL, 378, &reflection); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_28); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpression) +static PHP_METHOD(Phalcon_Image_Adapter_Gd, processRender) { - zend_bool _1$$9; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS, i = 0, _2$$9; - zval escapeChar; - zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, type, times, postTimes, rawValue, value, _11, _12, _0$$7, _3$$9, _4$$11, _5$$11, _6$$8, _7$$14, _8$$14, _9$$18, _10$$18; - zval expression, bindCounts, placeholders; + zend_long quality, ZEPHIR_LAST_CALL_STATUS; + zval *extension_param = NULL, *quality_param = NULL, __$null, _0, _1$$3, _2$$4, _3$$4, _4$$5, _5$$6, _6$$7, _7$$8, _8$$9; + zval extension, _9$$9; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expression); - ZVAL_UNDEF(&bindCounts); - ZVAL_UNDEF(&placeholders); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(×); - ZVAL_UNDEF(&postTimes); - ZVAL_UNDEF(&rawValue); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_11); - ZVAL_UNDEF(&_12); - ZVAL_UNDEF(&_0$$7); - ZVAL_UNDEF(&_3$$9); - ZVAL_UNDEF(&_4$$11); - ZVAL_UNDEF(&_5$$11); - ZVAL_UNDEF(&_6$$8); - ZVAL_UNDEF(&_7$$14); - ZVAL_UNDEF(&_8$$14); - ZVAL_UNDEF(&_9$$18); - ZVAL_UNDEF(&_10$$18); - ZVAL_UNDEF(&escapeChar); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ARRAY(expression) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) - Z_PARAM_ARRAY(bindCounts) + ZVAL_UNDEF(&extension); + ZVAL_UNDEF(&_9$$9); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_7$$8); + ZVAL_UNDEF(&_8$$9); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(extension) + Z_PARAM_LONG(quality) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); - ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!bindCounts_param) { - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); - } - zephir_memory_observe(&type); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&type, &expression, SL("type"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL expression", "phalcon/Db/Dialect.zep", 224); - return; - } + zephir_fetch_params(1, 2, 0, &extension_param, &quality_param); + zephir_get_strval(&extension, extension_param); + ZEPHIR_INIT_VAR(&_0); + zephir_fast_strtolower(&_0, &extension); + zephir_get_strval(&extension, &_0); + ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 387); + zephir_check_call_status(); do { - if (ZEPHIR_IS_STRING(&type, "scalar")) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionscalar", NULL, 45, &expression, &escapeChar, &bindCounts); - zephir_check_call_status(); - RETURN_MM(); - } - if (ZEPHIR_IS_STRING(&type, "object")) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionobject", NULL, 46, &expression, &escapeChar, &bindCounts); - zephir_check_call_status(); - RETURN_MM(); - } - if (ZEPHIR_IS_STRING(&type, "qualified")) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionqualified", NULL, 47, &expression, &escapeChar); - zephir_check_call_status(); - RETURN_MM(); - } - if (ZEPHIR_IS_STRING(&type, "literal")) { - zephir_array_fetch_string(&_0$$7, &expression, SL("value"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 258); - RETURN_CTOR(&_0$$7); - } - if (ZEPHIR_IS_STRING(&type, "placeholder")) { - zephir_memory_observe(×); - if (zephir_array_isset_string_fetch(×, &expression, SL("times"), 0)) { - ZEPHIR_INIT_VAR(&placeholders); - array_init(&placeholders); - zephir_memory_observe(&rawValue); - zephir_array_fetch_string(&rawValue, &expression, SL("rawValue"), PH_NOISY, "phalcon/Db/Dialect.zep", 264); - zephir_memory_observe(&value); - zephir_array_fetch_string(&value, &expression, SL("value"), PH_NOISY, "phalcon/Db/Dialect.zep", 265); - zephir_memory_observe(&postTimes); - if (zephir_array_isset_fetch(&postTimes, &bindCounts, &rawValue, 0)) { - ZEPHIR_CPY_WRT(×, &postTimes); - } - ZEPHIR_CPY_WRT(&_3$$9, ×); - _2$$9 = 1; - _1$$9 = 0; - if (ZEPHIR_GE_LONG(&_3$$9, _2$$9)) { - while (1) { - if (_1$$9) { - _2$$9++; - if (!(ZEPHIR_GE_LONG(&_3$$9, _2$$9))) { - break; - } - } else { - _1$$9 = 1; - } - i = _2$$9; - ZEPHIR_INIT_NVAR(&_4$$11); - ZVAL_LONG(&_4$$11, ((i - 1))); - ZEPHIR_INIT_NVAR(&_5$$11); - ZEPHIR_CONCAT_VV(&_5$$11, &value, &_4$$11); - zephir_array_append(&placeholders, &_5$$11, PH_SEPARATE, "phalcon/Db/Dialect.zep", 272); - } - } - zephir_fast_join_str(return_value, SL(", "), &placeholders); - RETURN_MM(); - } - zephir_array_fetch_string(&_6$$8, &expression, SL("value"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 278); - RETURN_CTOR(&_6$$8); - } - if (ZEPHIR_IS_STRING(&type, "binary-op")) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionbinaryoperations", NULL, 48, &expression, &escapeChar, &bindCounts); - zephir_check_call_status(); - RETURN_MM(); - } - if (ZEPHIR_IS_STRING(&type, "unary-op")) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionunaryoperations", NULL, 49, &expression, &escapeChar, &bindCounts); - zephir_check_call_status(); - RETURN_MM(); - } - if (ZEPHIR_IS_STRING(&type, "parentheses")) { - zephir_array_fetch_string(&_8$$14, &expression, SL("left"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 304); - ZEPHIR_CALL_METHOD(&_7$$14, this_ptr, "getsqlexpression", NULL, 50, &_8$$14, &escapeChar, &bindCounts); - zephir_check_call_status(); - ZEPHIR_CONCAT_SVS(return_value, "(", &_7$$14, ")"); - RETURN_MM(); - } - if (ZEPHIR_IS_STRING(&type, "functionCall")) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionfunctioncall", NULL, 51, &expression, &escapeChar, &bindCounts); - zephir_check_call_status(); - RETURN_MM(); - } - if (ZEPHIR_IS_STRING(&type, "list")) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionlist", NULL, 52, &expression, &escapeChar, &bindCounts); + if (ZEPHIR_IS_STRING(&extension, "gif")) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagegif", NULL, 388, &_1$$3); zephir_check_call_status(); - RETURN_MM(); + break; } - if (ZEPHIR_IS_STRING(&type, "all")) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionall", NULL, 53, &expression, &escapeChar); + if (ZEPHIR_IS_STRING(&extension, "jpg") || ZEPHIR_IS_STRING(&extension, "jpeg")) { + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_3$$4, quality); + ZEPHIR_CALL_FUNCTION(NULL, "imagejpeg", NULL, 389, &_2$$4, &__$null, &_3$$4); zephir_check_call_status(); - RETURN_MM(); + break; } - if (ZEPHIR_IS_STRING(&type, "select")) { - zephir_array_fetch_string(&_10$$18, &expression, SL("value"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 336); - ZEPHIR_CALL_METHOD(&_9$$18, this_ptr, "select", NULL, 0, &_10$$18); + if (ZEPHIR_IS_STRING(&extension, "png")) { + zephir_read_property(&_4$$5, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagepng", NULL, 390, &_4$$5); zephir_check_call_status(); - ZEPHIR_CONCAT_SVS(return_value, "(", &_9$$18, ")"); - RETURN_MM(); + break; } - if (ZEPHIR_IS_STRING(&type, "cast")) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressioncastvalue", NULL, 54, &expression, &escapeChar, &bindCounts); + if (ZEPHIR_IS_STRING(&extension, "wbmp")) { + zephir_read_property(&_5$$6, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagewbmp", NULL, 391, &_5$$6); zephir_check_call_status(); - RETURN_MM(); + break; } - if (ZEPHIR_IS_STRING(&type, "convert")) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressionconvertvalue", NULL, 55, &expression, &escapeChar, &bindCounts); + if (ZEPHIR_IS_STRING(&extension, "webp")) { + zephir_read_property(&_6$$7, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagewebp", NULL, 392, &_6$$7); zephir_check_call_status(); - RETURN_MM(); + break; } - if (ZEPHIR_IS_STRING(&type, "case")) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpressioncase", NULL, 56, &expression, &escapeChar, &bindCounts); + if (ZEPHIR_IS_STRING(&extension, "xbm")) { + zephir_read_property(&_7$$8, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagexbm", NULL, 393, &_7$$8, &__$null); zephir_check_call_status(); - RETURN_MM(); + break; } + ZEPHIR_INIT_VAR(&_8$$9); + object_init_ex(&_8$$9, phalcon_image_exception_ce); + ZEPHIR_INIT_VAR(&_9$$9); + ZEPHIR_CONCAT_SVS(&_9$$9, "Installed GD does not support '", &extension, "' images"); + ZEPHIR_CALL_METHOD(NULL, &_8$$9, "__construct", NULL, 33, &_9$$9); + zephir_check_call_status(); + zephir_throw_exception_debug(&_8$$9, "phalcon/Image/Adapter/Gd.zep", 552); + ZEPHIR_MM_RESTORE(); + return; } while(0); - ZEPHIR_INIT_VAR(&_11); - object_init_ex(&_11, phalcon_db_exception_ce); - ZEPHIR_INIT_VAR(&_12); - ZEPHIR_CONCAT_SVS(&_12, "Invalid SQL expression type '", &type, "'"); - ZEPHIR_CALL_METHOD(NULL, &_11, "__construct", NULL, 33, &_12); + ZEPHIR_RETURN_CALL_FUNCTION("ob_get_clean", NULL, 394); zephir_check_call_status(); - zephir_throw_exception_debug(&_11, "phalcon/Db/Dialect.zep", 369); + RETURN_MM(); +} + +static PHP_METHOD(Phalcon_Image_Adapter_Gd, processResize) +{ + zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zval *width_param = NULL, *height_param = NULL, image, _0, _1, _2, _3, _4; + zend_long width, height, ZEPHIR_LAST_CALL_STATUS; + zval *this_ptr = getThis(); + + ZVAL_UNDEF(&image); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_LONG(width) + Z_PARAM_LONG(height) + ZEND_PARSE_PARAMETERS_END(); + ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); + zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); + zephir_fetch_params(1, 2, 0, &width_param, &height_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1, width); + ZVAL_LONG(&_2, height); + ZEPHIR_CALL_FUNCTION(&image, "imagescale", NULL, 395, &_0, &_1, &_2); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &_1); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &image); + ZEPHIR_CALL_FUNCTION(&_3, "imagesx", NULL, 377, &image); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_3); + ZEPHIR_CALL_FUNCTION(&_4, "imagesy", NULL, 378, &image); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_4); ZEPHIR_MM_RESTORE(); - return; } -static PHP_METHOD(Phalcon_Db_Dialect, getSqlTable) +static PHP_METHOD(Phalcon_Image_Adapter_Gd, processRotate) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval escapeChar; - zval *table, table_sub, *escapeChar_param = NULL, tableName, schemaName, aliasName; + zval *degrees_param = NULL, __$true, copy, height, image, transparent, width, _0, _1, _2, _3, _4, _5, _6, _7, _8$$3; + zend_long degrees, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&table_sub); - ZVAL_UNDEF(&tableName); - ZVAL_UNDEF(&schemaName); - ZVAL_UNDEF(&aliasName); - ZVAL_UNDEF(&escapeChar); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(table) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(©); + ZVAL_UNDEF(&height); + ZVAL_UNDEF(&image); + ZVAL_UNDEF(&transparent); + ZVAL_UNDEF(&width); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(degrees) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &table, &escapeChar_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (Z_TYPE_P(table) == IS_ARRAY) { - zephir_memory_observe(&tableName); - zephir_array_fetch_long(&tableName, table, 0, PH_NOISY, "phalcon/Db/Dialect.zep", 385); - zephir_memory_observe(&schemaName); - zephir_array_isset_long_fetch(&schemaName, table, 1, 0); - zephir_memory_observe(&aliasName); - zephir_array_isset_long_fetch(&aliasName, table, 2, 0); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "preparetable", NULL, 0, &tableName, &schemaName, &aliasName, &escapeChar); + zephir_fetch_params(1, 1, 0, °rees_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1, 0); + ZVAL_LONG(&_2, 0); + ZVAL_LONG(&_3, 0); + ZVAL_LONG(&_4, 127); + ZEPHIR_CALL_FUNCTION(&transparent, "imagecolorallocatealpha", NULL, 373, &_0, &_1, &_2, &_3, &_4); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_2, (360 - degrees)); + ZEPHIR_CALL_FUNCTION(&image, "imagerotate", NULL, 396, &_1, &_2, &transparent); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 368, &image, &__$true); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&width, "imagesx", NULL, 377, &image); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&height, "imagesy", NULL, 378, &image); + zephir_check_call_status(); + zephir_read_property(&_2, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_3, 0); + ZVAL_LONG(&_4, 0); + ZVAL_LONG(&_5, 0); + ZVAL_LONG(&_6, 0); + ZVAL_LONG(&_7, 100); + ZEPHIR_CALL_FUNCTION(©, "imagecopymerge", NULL, 397, &_2, &image, &_3, &_4, &_5, &_6, &width, &height, &_7); + zephir_check_call_status(); + if (!ZEPHIR_IS_FALSE_IDENTICAL(©)) { + zephir_read_property(&_8$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &_8$$3); zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &image); + zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &width); + zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &height); } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "escape", NULL, 57, table, &escapeChar); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, limit) +static PHP_METHOD(Phalcon_Image_Adapter_Gd, processSave) { - zend_bool _2$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *sqlQuery_param = NULL, *number, number_sub, _0$$3, _1$$3, _3$$3, _4$$4, _5$$4; - zval sqlQuery; + zend_long quality, ZEPHIR_LAST_CALL_STATUS; + zval *file_param = NULL, *quality_param = NULL, __$false, extension, _0, _2, _15, _1$$3, _3$$4, _4$$5, _5$$6, _6$$6, _7$$6, _8$$7, _9$$8, _10$$9, _11$$10, _12$$11, _13$$12, _14$$12; + zval file; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&sqlQuery); - ZVAL_UNDEF(&number_sub); - ZVAL_UNDEF(&_0$$3); + ZVAL_UNDEF(&file); + ZVAL_BOOL(&__$false, 0); + ZVAL_UNDEF(&extension); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_15); ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_3$$3); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$5); + ZVAL_UNDEF(&_5$$6); + ZVAL_UNDEF(&_6$$6); + ZVAL_UNDEF(&_7$$6); + ZVAL_UNDEF(&_8$$7); + ZVAL_UNDEF(&_9$$8); + ZVAL_UNDEF(&_10$$9); + ZVAL_UNDEF(&_11$$10); + ZVAL_UNDEF(&_12$$11); + ZVAL_UNDEF(&_13$$12); + ZVAL_UNDEF(&_14$$12); ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(sqlQuery) - Z_PARAM_ZVAL(number) + Z_PARAM_STR(file) + Z_PARAM_LONG(quality) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &sqlQuery_param, &number); - if (UNEXPECTED(Z_TYPE_P(sqlQuery_param) != IS_STRING && Z_TYPE_P(sqlQuery_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'sqlQuery' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(sqlQuery_param) == IS_STRING)) { - zephir_get_strval(&sqlQuery, sqlQuery_param); - } else { - ZEPHIR_INIT_VAR(&sqlQuery); + zephir_fetch_params(1, 2, 0, &file_param, &quality_param); + zephir_get_strval(&file, file_param); + ZVAL_LONG(&_0, 4); + ZEPHIR_CALL_FUNCTION(&extension, "pathinfo", NULL, 89, &file, &_0); + zephir_check_call_status(); + if (1 == ZEPHIR_IS_EMPTY(&extension)) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("type"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&extension, "image_type_to_extension", NULL, 398, &_1$$3, &__$false); + zephir_check_call_status(); } - if (Z_TYPE_P(number) == IS_ARRAY) { - zephir_array_fetch_long(&_0$$3, number, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 428); - ZEPHIR_INIT_VAR(&_1$$3); - ZEPHIR_CONCAT_SV(&_1$$3, " LIMIT ", &_0$$3); - zephir_concat_self(&sqlQuery, &_1$$3); - _2$$3 = zephir_array_isset_long(number, 1); - if (_2$$3) { - zephir_array_fetch_long(&_3$$3, number, 1, PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 430); - _2$$3 = ((zephir_fast_strlen_ev(&_3$$3)) ? 1 : 0); + ZEPHIR_INIT_VAR(&_2); + zephir_fast_strtolower(&_2, &extension); + ZEPHIR_CPY_WRT(&extension, &_2); + do { + if (ZEPHIR_IS_STRING(&extension, "gif")) { + ZVAL_UNDEF(&_3$$4); + ZVAL_LONG(&_3$$4, 1); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_3$$4); + zephir_read_property(&_3$$4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagegif", NULL, 388, &_3$$4, &file); + zephir_check_call_status(); + break; } - if (_2$$3) { - zephir_array_fetch_long(&_4$$4, number, 1, PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 431); - ZEPHIR_INIT_VAR(&_5$$4); - ZEPHIR_CONCAT_SV(&_5$$4, " OFFSET ", &_4$$4); - zephir_concat_self(&sqlQuery, &_5$$4); + if (ZEPHIR_IS_STRING(&extension, "jpg") || ZEPHIR_IS_STRING(&extension, "jpeg")) { + ZVAL_UNDEF(&_4$$5); + ZVAL_LONG(&_4$$5, 2); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_4$$5); + if (quality >= 0) { + ZVAL_LONG(&_6$$6, quality); + ZVAL_LONG(&_7$$6, 1); + ZEPHIR_CALL_METHOD(&_5$$6, this_ptr, "checkhighlow", NULL, 0, &_6$$6, &_7$$6); + zephir_check_call_status(); + quality = zephir_get_numberval(&_5$$6); + zephir_read_property(&_6$$6, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_7$$6, quality); + ZEPHIR_CALL_FUNCTION(NULL, "imagejpeg", NULL, 389, &_6$$6, &file, &_7$$6); + zephir_check_call_status(); + } else { + zephir_read_property(&_8$$7, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagejpeg", NULL, 389, &_8$$7, &file); + zephir_check_call_status(); + } + break; } - RETURN_CTOR(&sqlQuery); - } - ZEPHIR_CONCAT_VSV(return_value, &sqlQuery, " LIMIT ", number); - RETURN_MM(); + if (ZEPHIR_IS_STRING(&extension, "png")) { + ZVAL_UNDEF(&_9$$8); + ZVAL_LONG(&_9$$8, 3); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_9$$8); + zephir_read_property(&_9$$8, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagepng", NULL, 390, &_9$$8, &file); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_STRING(&extension, "wbmp")) { + ZVAL_UNDEF(&_10$$9); + ZVAL_LONG(&_10$$9, 15); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_10$$9); + zephir_read_property(&_10$$9, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagewbmp", NULL, 391, &_10$$9, &file); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_STRING(&extension, "webp")) { + ZVAL_UNDEF(&_11$$10); + ZVAL_LONG(&_11$$10, 18); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_11$$10); + zephir_read_property(&_11$$10, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagewebp", NULL, 392, &_11$$10, &file); + zephir_check_call_status(); + break; + } + if (ZEPHIR_IS_STRING(&extension, "xbm")) { + ZVAL_UNDEF(&_12$$11); + ZVAL_LONG(&_12$$11, 16); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_12$$11); + zephir_read_property(&_12$$11, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagexbm", NULL, 393, &_12$$11, &file); + zephir_check_call_status(); + break; + } + ZEPHIR_INIT_VAR(&_13$$12); + object_init_ex(&_13$$12, phalcon_image_exception_ce); + ZEPHIR_INIT_VAR(&_14$$12); + ZEPHIR_CONCAT_SVS(&_14$$12, "Installed GD does not support '", &extension, "' images"); + ZEPHIR_CALL_METHOD(NULL, &_13$$12, "__construct", NULL, 33, &_14$$12); + zephir_check_call_status(); + zephir_throw_exception_debug(&_13$$12, "phalcon/Image/Adapter/Gd.zep", 679); + ZEPHIR_MM_RESTORE(); + return; + } while(0); + + zephir_read_property(&_0, this_ptr, ZEND_STRL("type"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&_15, "image_type_to_mime_type", NULL, 399, &_0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("mime"), &_15); + RETURN_MM_BOOL(1); } -static PHP_METHOD(Phalcon_Db_Dialect, registerCustomFunction) +static PHP_METHOD(Phalcon_Image_Adapter_Gd, processSharpen) { + zval matrix, _3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL, *customFunction, customFunction_sub; - zval name; + zval *amount_param = NULL, result, _0, _1, _2, _4, _5, _6, _7, _8$$3, _9$$3, _10$$3, _11$$3; + zend_long amount, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&customFunction_sub); - ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_STR(name) - Z_PARAM_ZVAL(customFunction) + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$3); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_11$$3); + ZVAL_UNDEF(&matrix); + ZVAL_UNDEF(&_3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(amount) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 0, &name_param, &customFunction); - zephir_get_strval(&name, name_param); - zephir_update_property_array(this_ptr, SL("customFunctions"), &name, customFunction); - RETURN_THIS(); + zephir_fetch_params(1, 1, 0, &amount_param); + ZEPHIR_INIT_VAR(&_0); + ZVAL_LONG(&_1, (-18 + ((amount * 0.08)))); + ZEPHIR_CALL_FUNCTION(&_2, "abs", NULL, 284, &_1); + zephir_check_call_status(); + ZVAL_LONG(&_1, 2); + zephir_round(&_0, &_2, &_1, NULL); + amount = zephir_get_intval(&_0); + ZEPHIR_INIT_VAR(&matrix); + zephir_create_array(&matrix, 3, 0); + ZEPHIR_INIT_VAR(&_3); + zephir_create_array(&_3, 3, 0); + ZEPHIR_INIT_VAR(&_4); + ZVAL_LONG(&_4, -1); + 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, -1); + zephir_array_fast_append(&_3, &_4); + zephir_array_fast_append(&matrix, &_3); + ZEPHIR_INIT_NVAR(&_3); + zephir_create_array(&_3, 3, 0); + ZEPHIR_INIT_NVAR(&_4); + ZVAL_LONG(&_4, -1); + zephir_array_fast_append(&_3, &_4); + ZEPHIR_INIT_NVAR(&_4); + ZVAL_LONG(&_4, amount); + zephir_array_fast_append(&_3, &_4); + ZEPHIR_INIT_NVAR(&_4); + ZVAL_LONG(&_4, -1); + zephir_array_fast_append(&_3, &_4); + zephir_array_fast_append(&matrix, &_3); + ZEPHIR_INIT_NVAR(&_3); + zephir_create_array(&_3, 3, 0); + ZEPHIR_INIT_NVAR(&_4); + ZVAL_LONG(&_4, -1); + 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, -1); + zephir_array_fast_append(&_3, &_4); + zephir_array_fast_append(&matrix, &_3); + zephir_read_property(&_5, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_6, (amount - 8)); + ZVAL_LONG(&_7, 0); + ZEPHIR_CALL_FUNCTION(&result, "imageconvolution", NULL, 400, &_5, &matrix, &_6, &_7); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(&result)) { + zephir_read_property(&_8$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&_9$$3, "imagesx", NULL, 377, &_8$$3); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_9$$3); + zephir_read_property(&_10$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&_11$$3, "imagesy", NULL, 378, &_10$$3); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_11$$3); + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, releaseSavepoint) +static PHP_METHOD(Phalcon_Image_Adapter_Gd, processText) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL; - zval name; + zend_long opacity, red, green, blue, size, ZEPHIR_LAST_CALL_STATUS, angle = 0, bottomLeftX = 0, bottomLeftY = 0, topRightX = 0, topRightY = 0, _0, _1; + zval *text_param = NULL, *offsetX = NULL, offsetX_sub, *offsetY = NULL, offsetY_sub, *opacity_param = NULL, *red_param = NULL, *green_param = NULL, *blue_param = NULL, *size_param = NULL, *fontFile_param = NULL, color, height, space, width, _2, _3, _4, _5$$3, _6$$3, _11$$3, _12$$3, _19$$3, _20$$3, _21$$3, _7$$5, _8$$5, _9$$5, _10$$5, _13$$6, _14$$6, _15$$6, _16$$7, _17$$7, _18$$7, _22$$8, _23$$8, _30$$8, _31$$8, _32$$8, _33$$8, _24$$9, _25$$9, _26$$9, _27$$10, _28$$10, _29$$10; + zval text, fontFile; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&name); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&fontFile); + ZVAL_UNDEF(&offsetX_sub); + ZVAL_UNDEF(&offsetY_sub); + ZVAL_UNDEF(&color); + ZVAL_UNDEF(&height); + ZVAL_UNDEF(&space); + ZVAL_UNDEF(&width); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_11$$3); + ZVAL_UNDEF(&_12$$3); + ZVAL_UNDEF(&_19$$3); + ZVAL_UNDEF(&_20$$3); + ZVAL_UNDEF(&_21$$3); + ZVAL_UNDEF(&_7$$5); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_10$$5); + ZVAL_UNDEF(&_13$$6); + ZVAL_UNDEF(&_14$$6); + ZVAL_UNDEF(&_15$$6); + ZVAL_UNDEF(&_16$$7); + ZVAL_UNDEF(&_17$$7); + ZVAL_UNDEF(&_18$$7); + ZVAL_UNDEF(&_22$$8); + ZVAL_UNDEF(&_23$$8); + ZVAL_UNDEF(&_30$$8); + ZVAL_UNDEF(&_31$$8); + ZVAL_UNDEF(&_32$$8); + ZVAL_UNDEF(&_33$$8); + ZVAL_UNDEF(&_24$$9); + ZVAL_UNDEF(&_25$$9); + ZVAL_UNDEF(&_26$$9); + ZVAL_UNDEF(&_27$$10); + ZVAL_UNDEF(&_28$$10); + ZVAL_UNDEF(&_29$$10); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(8, 9) + Z_PARAM_STR(text) + Z_PARAM_ZVAL(offsetX) + Z_PARAM_ZVAL(offsetY) + Z_PARAM_LONG(opacity) + Z_PARAM_LONG(red) + Z_PARAM_LONG(green) + Z_PARAM_LONG(blue) + Z_PARAM_LONG(size) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_NULL(fontFile) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + zephir_fetch_params(1, 8, 1, &text_param, &offsetX, &offsetY, &opacity_param, &red_param, &green_param, &blue_param, &size_param, &fontFile_param); + zephir_get_strval(&text, text_param); + ZEPHIR_SEPARATE_PARAM(offsetX); + ZEPHIR_SEPARATE_PARAM(offsetY); + if (!fontFile_param) { + ZEPHIR_INIT_VAR(&fontFile); } else { - ZEPHIR_INIT_VAR(&name); - } - ZEPHIR_CONCAT_SV(return_value, "RELEASE SAVEPOINT ", &name); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Db_Dialect, rollbackSavepoint) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval *name_param = NULL; - zval name; - - ZVAL_UNDEF(&name); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_STR(name) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &name_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); + zephir_get_strval(&fontFile, fontFile_param); } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + bottomLeftX = 0; + bottomLeftY = 0; + topRightX = 0; + topRightY = 0; + _0 = zephir_get_intval(offsetX); + ZEPHIR_INIT_NVAR(offsetX); + ZVAL_LONG(offsetX, _0); + _1 = zephir_get_intval(offsetY); + ZEPHIR_INIT_NVAR(offsetY); + ZVAL_LONG(offsetY, _1); + ZEPHIR_INIT_VAR(&_2); + ZVAL_DOUBLE(&_3, ((zephir_safe_div_long_long((opacity * 127), 100)) - (double) (127))); + ZEPHIR_CALL_FUNCTION(&_4, "abs", NULL, 284, &_3); + zephir_check_call_status(); + zephir_round(&_2, &_4, NULL, NULL); + opacity = zephir_get_intval(&_2); + ZEPHIR_INIT_VAR(&width); + if (1 != ZEPHIR_IS_EMPTY(&fontFile)) { + ZVAL_LONG(&_5$$3, size); + ZVAL_LONG(&_6$$3, 0); + ZEPHIR_CALL_FUNCTION(&space, "imagettfbbox", NULL, 401, &_5$$3, &_6$$3, &fontFile, &text); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&space)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Call to imagettfbbox() failed", "phalcon/Image/Adapter/Gd.zep", 758); + return; + } + if (1 == zephir_array_isset_long(&space, 0)) { + zephir_memory_observe(&_7$$5); + zephir_array_fetch_long(&_7$$5, &space, 0, PH_NOISY, "phalcon/Image/Adapter/Gd.zep", 762); + bottomLeftX = zephir_get_intval(&_7$$5); + zephir_memory_observe(&_8$$5); + zephir_array_fetch_long(&_8$$5, &space, 1, PH_NOISY, "phalcon/Image/Adapter/Gd.zep", 763); + bottomLeftY = zephir_get_intval(&_8$$5); + zephir_memory_observe(&_9$$5); + zephir_array_fetch_long(&_9$$5, &space, 4, PH_NOISY, "phalcon/Image/Adapter/Gd.zep", 764); + topRightX = zephir_get_intval(&_9$$5); + zephir_memory_observe(&_10$$5); + zephir_array_fetch_long(&_10$$5, &space, 5, PH_NOISY, "phalcon/Image/Adapter/Gd.zep", 765); + topRightY = zephir_get_intval(&_10$$5); + } + ZVAL_LONG(&_5$$3, (topRightX - bottomLeftX)); + ZEPHIR_CALL_FUNCTION(&_11$$3, "abs", NULL, 284, &_5$$3); + zephir_check_call_status(); + ZVAL_LONG(&width, (zephir_get_numberval(&_11$$3) + 10)); + ZVAL_LONG(&_5$$3, (topRightY - bottomLeftY)); + ZEPHIR_CALL_FUNCTION(&_12$$3, "abs", NULL, 284, &_5$$3); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&height); + ZVAL_LONG(&height, (zephir_get_numberval(&_12$$3) + 10)); + if (ZEPHIR_LT_LONG(offsetX, 0)) { + zephir_read_property(&_13$$6, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_14$$6); + zephir_sub_function(&_14$$6, &_13$$6, &width); + ZEPHIR_INIT_VAR(&_15$$6); + zephir_add_function(&_15$$6, &_14$$6, offsetX); + ZEPHIR_CPY_WRT(offsetX, &_15$$6); + } + if (ZEPHIR_LT_LONG(offsetY, 0)) { + zephir_read_property(&_16$$7, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_17$$7); + zephir_sub_function(&_17$$7, &_16$$7, &height); + ZEPHIR_INIT_VAR(&_18$$7); + zephir_add_function(&_18$$7, &_17$$7, offsetY); + ZEPHIR_CPY_WRT(offsetY, &_18$$7); + } + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_6$$3, red); + ZVAL_LONG(&_19$$3, green); + ZVAL_LONG(&_20$$3, blue); + ZVAL_LONG(&_21$$3, opacity); + ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 373, &_5$$3, &_6$$3, &_19$$3, &_20$$3, &_21$$3); + zephir_check_call_status(); + angle = 0; + zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_19$$3, size); + ZVAL_LONG(&_20$$3, angle); + ZEPHIR_CALL_FUNCTION(NULL, "imagettftext", NULL, 402, &_6$$3, &_19$$3, &_20$$3, offsetX, offsetY, &color, &fontFile, &text); + zephir_check_call_status(); } else { - ZEPHIR_INIT_VAR(&name); + ZVAL_LONG(&_22$$8, size); + ZEPHIR_CALL_FUNCTION(&_23$$8, "imagefontwidth", NULL, 403, &_22$$8); + zephir_check_call_status(); + ZVAL_LONG(&width, (zephir_get_numberval(&_23$$8) * zephir_fast_strlen_ev(&text))); + ZVAL_LONG(&_22$$8, size); + ZEPHIR_CALL_FUNCTION(&height, "imagefontheight", NULL, 404, &_22$$8); + zephir_check_call_status(); + if (ZEPHIR_LT_LONG(offsetX, 0)) { + zephir_read_property(&_24$$9, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_25$$9); + zephir_sub_function(&_25$$9, &_24$$9, &width); + ZEPHIR_INIT_VAR(&_26$$9); + zephir_add_function(&_26$$9, &_25$$9, offsetX); + ZEPHIR_CPY_WRT(offsetX, &_26$$9); + } + if (ZEPHIR_LT_LONG(offsetY, 0)) { + zephir_read_property(&_27$$10, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_28$$10); + zephir_sub_function(&_28$$10, &_27$$10, &height); + ZEPHIR_INIT_VAR(&_29$$10); + zephir_add_function(&_29$$10, &_28$$10, offsetY); + ZEPHIR_CPY_WRT(offsetY, &_29$$10); + } + zephir_read_property(&_22$$8, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_30$$8, red); + ZVAL_LONG(&_31$$8, green); + ZVAL_LONG(&_32$$8, blue); + ZVAL_LONG(&_33$$8, opacity); + ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 373, &_22$$8, &_30$$8, &_31$$8, &_32$$8, &_33$$8); + zephir_check_call_status(); + zephir_read_property(&_30$$8, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_31$$8, size); + ZEPHIR_CALL_FUNCTION(NULL, "imagestring", NULL, 405, &_30$$8, &_31$$8, offsetX, offsetY, &text, &color); + zephir_check_call_status(); } - ZEPHIR_CONCAT_SV(return_value, "ROLLBACK TO SAVEPOINT ", &name); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, select) +static PHP_METHOD(Phalcon_Image_Adapter_Gd, processWatermark) { - zend_bool _5, _9, _12, _15, _18, _21, _23; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *definition_param = NULL, tables, columns, sql, distinct, joins, where, escapeChar, groupBy, having, orderBy, limit, forUpdate, bindCounts, _0, _1, _2, _3, _4, _6$$10, _7$$10, _8$$10, _10$$11, _11$$11, _13$$12, _14$$12, _16$$13, _17$$13, _19$$14, _20$$14; - zval definition, _22$$15; + zend_long offsetX, offsetY, opacity, ZEPHIR_LAST_CALL_STATUS, height = 0, width = 0; + zval *watermark, watermark_sub, *offsetX_param = NULL, *offsetY_param = NULL, *opacity_param = NULL, __$true, color, copy, overlay, _0, _1, _2, _9, _10, _11, _12, _13, _14, _15, _16, _3$$3, _4$$3, _5$$3, _6$$3, _7$$3, _8$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&definition); - ZVAL_UNDEF(&_22$$15); - ZVAL_UNDEF(&tables); - ZVAL_UNDEF(&columns); - ZVAL_UNDEF(&sql); - ZVAL_UNDEF(&distinct); - ZVAL_UNDEF(&joins); - ZVAL_UNDEF(&where); - ZVAL_UNDEF(&escapeChar); - ZVAL_UNDEF(&groupBy); - ZVAL_UNDEF(&having); - ZVAL_UNDEF(&orderBy); - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&forUpdate); - ZVAL_UNDEF(&bindCounts); + ZVAL_UNDEF(&watermark_sub); + ZVAL_BOOL(&__$true, 1); + ZVAL_UNDEF(&color); + ZVAL_UNDEF(©); + ZVAL_UNDEF(&overlay); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_4); - ZVAL_UNDEF(&_6$$10); - ZVAL_UNDEF(&_7$$10); - ZVAL_UNDEF(&_8$$10); - ZVAL_UNDEF(&_10$$11); - ZVAL_UNDEF(&_11$$11); - ZVAL_UNDEF(&_13$$12); - ZVAL_UNDEF(&_14$$12); - ZVAL_UNDEF(&_16$$13); - ZVAL_UNDEF(&_17$$13); - ZVAL_UNDEF(&_19$$14); - ZVAL_UNDEF(&_20$$14); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_ARRAY(definition) + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_12); + ZVAL_UNDEF(&_13); + ZVAL_UNDEF(&_14); + ZVAL_UNDEF(&_15); + ZVAL_UNDEF(&_16); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_OBJECT_OF_CLASS(watermark, phalcon_image_adapter_adapterinterface_ce) + Z_PARAM_LONG(offsetX) + Z_PARAM_LONG(offsetY) + Z_PARAM_LONG(opacity) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &definition_param); - ZEPHIR_OBS_COPY_OR_DUP(&definition, definition_param); - zephir_memory_observe(&tables); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&tables, &definition, SL("tables"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'tables' is required in the definition array", "phalcon/Db/Dialect.zep", 477); - return; - } - zephir_memory_observe(&columns); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&columns, &definition, SL("columns"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "The index 'columns' is required in the definition array", "phalcon/Db/Dialect.zep", 483); - return; - } - zephir_memory_observe(&distinct); - if (zephir_array_isset_string_fetch(&distinct, &definition, SL("distinct"), 0)) { - ZEPHIR_INIT_VAR(&sql); - if (zephir_is_true(&distinct)) { - ZVAL_STRING(&sql, "SELECT DISTINCT"); - } else { - ZVAL_STRING(&sql, "SELECT ALL"); - } - } else { - ZEPHIR_INIT_NVAR(&sql); - ZVAL_STRING(&sql, "SELECT"); - } - zephir_memory_observe(&bindCounts); - zephir_array_isset_string_fetch(&bindCounts, &definition, SL("bindCounts"), 0); - if (Z_TYPE_P(&bindCounts) != IS_ARRAY) { - ZEPHIR_INIT_NVAR(&bindCounts); - array_init(&bindCounts); - } - zephir_read_property(&_0, this_ptr, ZEND_STRL("escapeChar"), PH_NOISY_CC | PH_READONLY); - ZEPHIR_CPY_WRT(&escapeChar, &_0); - ZEPHIR_CALL_METHOD(&_1, this_ptr, "getcolumnlist", NULL, 58, &columns, &escapeChar, &bindCounts); + zephir_fetch_params(1, 4, 0, &watermark, &offsetX_param, &offsetY_param, &opacity_param); + ZEPHIR_CALL_METHOD(&_0, watermark, "render", NULL, 0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_SV(&_2, " ", &_1); - zephir_concat_self(&sql, &_2); - ZEPHIR_CALL_METHOD(&_3, this_ptr, "getsqlexpressionfrom", NULL, 59, &tables, &escapeChar); + ZEPHIR_CALL_FUNCTION(&overlay, "imagecreatefromstring", NULL, 380, &_0); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_4); - ZEPHIR_CONCAT_SV(&_4, " ", &_3); - zephir_concat_self(&sql, &_4); - zephir_memory_observe(&joins); - _5 = zephir_array_isset_string_fetch(&joins, &definition, SL("joins"), 0); - if (_5) { - _5 = zephir_is_true(&joins); - } - if (_5) { - zephir_array_fetch_string(&_7$$10, &definition, SL("joins"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 517); - ZEPHIR_CALL_METHOD(&_6$$10, this_ptr, "getsqlexpressionjoins", NULL, 60, &_7$$10, &escapeChar, &bindCounts); - zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_8$$10); - ZEPHIR_CONCAT_SV(&_8$$10, " ", &_6$$10); - zephir_concat_self(&sql, &_8$$10); - } - zephir_memory_observe(&where); - _9 = zephir_array_isset_string_fetch(&where, &definition, SL("where"), 0); - if (_9) { - _9 = zephir_is_true(&where); - } - if (_9) { - ZEPHIR_CALL_METHOD(&_10$$11, this_ptr, "getsqlexpressionwhere", NULL, 61, &where, &escapeChar, &bindCounts); + ZEPHIR_CALL_FUNCTION(NULL, "imagesavealpha", NULL, 368, &overlay, &__$true); + zephir_check_call_status(); + ZEPHIR_CALL_FUNCTION(&_1, "imagesx", NULL, 377, &overlay); + zephir_check_call_status(); + width = zephir_get_intval(&_1); + ZEPHIR_CALL_FUNCTION(&_2, "imagesy", NULL, 378, &overlay); + zephir_check_call_status(); + height = zephir_get_intval(&_2); + if (opacity < 100) { + ZEPHIR_INIT_VAR(&_3$$3); + ZVAL_DOUBLE(&_4$$3, ((zephir_safe_div_long_long((opacity * 127), 100)) - (double) (127))); + ZEPHIR_CALL_FUNCTION(&_5$$3, "abs", NULL, 284, &_4$$3); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_11$$11); - ZEPHIR_CONCAT_SV(&_11$$11, " ", &_10$$11); - zephir_concat_self(&sql, &_11$$11); - } - zephir_memory_observe(&groupBy); - _12 = zephir_array_isset_string_fetch(&groupBy, &definition, SL("group"), 0); - if (_12) { - _12 = zephir_is_true(&groupBy); - } - if (_12) { - ZEPHIR_CALL_METHOD(&_13$$12, this_ptr, "getsqlexpressiongroupby", NULL, 62, &groupBy, &escapeChar); + zephir_round(&_3$$3, &_5$$3, NULL, NULL); + opacity = zephir_get_intval(&_3$$3); + ZVAL_LONG(&_4$$3, 127); + ZVAL_LONG(&_6$$3, 127); + ZVAL_LONG(&_7$$3, 127); + ZVAL_LONG(&_8$$3, opacity); + ZEPHIR_CALL_FUNCTION(&color, "imagecolorallocatealpha", NULL, 373, &overlay, &_4$$3, &_6$$3, &_7$$3, &_8$$3); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_14$$12); - ZEPHIR_CONCAT_SV(&_14$$12, " ", &_13$$12); - zephir_concat_self(&sql, &_14$$12); - } - zephir_memory_observe(&having); - _15 = zephir_array_isset_string_fetch(&having, &definition, SL("having"), 0); - if (_15) { - _15 = zephir_is_true(&having); - } - if (_15) { - ZEPHIR_CALL_METHOD(&_16$$13, this_ptr, "getsqlexpressionhaving", NULL, 63, &having, &escapeChar, &bindCounts); + ZVAL_LONG(&_4$$3, 3); + ZEPHIR_CALL_FUNCTION(NULL, "imagelayereffect", NULL, 406, &overlay, &_4$$3); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_17$$13); - ZEPHIR_CONCAT_SV(&_17$$13, " ", &_16$$13); - zephir_concat_self(&sql, &_17$$13); - } - zephir_memory_observe(&orderBy); - _18 = zephir_array_isset_string_fetch(&orderBy, &definition, SL("order"), 0); - if (_18) { - _18 = zephir_is_true(&orderBy); - } - if (_18) { - ZEPHIR_CALL_METHOD(&_19$$14, this_ptr, "getsqlexpressionorderby", NULL, 64, &orderBy, &escapeChar, &bindCounts); + ZVAL_LONG(&_4$$3, 0); + ZVAL_LONG(&_6$$3, 0); + ZVAL_LONG(&_7$$3, width); + ZVAL_LONG(&_8$$3, height); + ZEPHIR_CALL_FUNCTION(NULL, "imagefilledrectangle", NULL, 386, &overlay, &_4$$3, &_6$$3, &_7$$3, &_8$$3, &color); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_20$$14); - ZEPHIR_CONCAT_SV(&_20$$14, " ", &_19$$14); - zephir_concat_self(&sql, &_20$$14); - } - zephir_memory_observe(&limit); - _21 = zephir_array_isset_string_fetch(&limit, &definition, SL("limit"), 0); - if (_21) { - _21 = zephir_is_true(&limit); } - if (_21) { - ZEPHIR_INIT_VAR(&_22$$15); - zephir_create_array(&_22$$15, 2, 0); - zephir_array_update_string(&_22$$15, SL("sql"), &sql, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_22$$15, SL("value"), &limit, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&sql, this_ptr, "getsqlexpressionlimit", NULL, 65, &_22$$15, &escapeChar, &bindCounts); + zephir_read_property(&_9, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(NULL, "imagealphablending", NULL, 370, &_9, &__$true); + zephir_check_call_status(); + zephir_read_property(&_10, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_11, offsetX); + ZVAL_LONG(&_12, offsetY); + ZVAL_LONG(&_13, 0); + ZVAL_LONG(&_14, 0); + ZVAL_LONG(&_15, width); + ZVAL_LONG(&_16, height); + ZEPHIR_CALL_FUNCTION(©, "imagecopy", NULL, 374, &_10, &overlay, &_11, &_12, &_13, &_14, &_15, &_16); + zephir_check_call_status(); + if (ZEPHIR_IS_TRUE_IDENTICAL(©)) { + ZEPHIR_CALL_FUNCTION(NULL, "imagedestroy", NULL, 371, &overlay); zephir_check_call_status(); } - _23 = zephir_array_isset_string_fetch(&forUpdate, &definition, SL("forUpdate"), 1); - if (_23) { - _23 = zephir_is_true(&forUpdate); - } - if (_23) { - zephir_concat_self_str(&sql, SL(" FOR UPDATE")); - } - RETURN_CCTOR(&sql); -} - -static PHP_METHOD(Phalcon_Db_Dialect, supportsSavepoints) -{ - - RETURN_BOOL(1); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, supportsReleaseSavepoints) +static PHP_METHOD(Phalcon_Image_Adapter_Gd, check) { + zval version, _0, _1, _2, _3$$3, _4$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); + + ZVAL_UNDEF(&version); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "supportssavepoints", NULL, 0); + ZEPHIR_CALL_METHOD(&version, this_ptr, "getversion", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "2.0.1"); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, ">="); + ZEPHIR_CALL_FUNCTION(&_2, "version_compare", NULL, 134, &version, &_0, &_1); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_2)) { + ZEPHIR_INIT_VAR(&_3$$3); + object_init_ex(&_3$$3, phalcon_image_exception_ce); + ZEPHIR_INIT_VAR(&_4$$3); + ZEPHIR_CONCAT_SSV(&_4$$3, "Phalcon\\Image\\Adapter\\GD requires GD ", "version '2.0.1' or greater, you have ", &version); + ZEPHIR_CALL_METHOD(NULL, &_3$$3, "__construct", NULL, 33, &_4$$3); + zephir_check_call_status(); + zephir_throw_exception_debug(&_3$$3, "phalcon/Image/Adapter/Gd.zep", 898); + ZEPHIR_MM_RESTORE(); + return; + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, getColumnSize) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *column, column_sub, _0; - ZVAL_UNDEF(&column_sub); - ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &column); - ZEPHIR_CALL_METHOD(&_0, column, "getsize", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CONCAT_SVS(return_value, "(", &_0, ")"); - RETURN_MM(); -} -static PHP_METHOD(Phalcon_Db_Dialect, getColumnSizeAndScale) + +#ifdef HAVE_CONFIG_H +#endif + + + + + +ZEPHIR_INIT_CLASS(Phalcon_Image_Adapter_Imagick) { - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *column, column_sub, _0, _1; + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Image\\Adapter, Imagick, phalcon, image_adapter_imagick, phalcon_image_adapter_abstractadapter_ce, phalcon_image_adapter_imagick_method_entry, 0); - ZVAL_UNDEF(&column_sub); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &column); - ZEPHIR_CALL_METHOD(&_0, column, "getsize", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_1, column, "getscale", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CONCAT_SVSVS(return_value, "(", &_0, ",", &_1, ")"); - RETURN_MM(); + zend_declare_property_long(phalcon_image_adapter_imagick_ce, SL("version"), 0, ZEND_ACC_PROTECTED); + return SUCCESS; } -static PHP_METHOD(Phalcon_Db_Dialect, checkColumnType) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, __construct) { + zend_bool _22$$7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *column, column_sub, _0; + zend_long width, height, ZEPHIR_LAST_CALL_STATUS; + zval *file_param = NULL, *width_param = NULL, *height_param = NULL, image, _0, _1, _32, _33, _34, _35, _36, _37, _38, _39, _40, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, _10$$3, _11$$3, _15$$3, _16$$3, _17$$3, _18$$3, _7$$4, _8$$4, _9$$4, _12$$5, _13$$5, _14$$5, _19$$6, _20$$6, _21$$6, _26$$7, _27$$7, _28$$7, _29$$7, _30$$7, _31$$7, _23$$8, _24$$8, _25$$8; + zval file; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&column_sub); + ZVAL_UNDEF(&file); + ZVAL_UNDEF(&image); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_32); + ZVAL_UNDEF(&_33); + ZVAL_UNDEF(&_34); + ZVAL_UNDEF(&_35); + ZVAL_UNDEF(&_36); + ZVAL_UNDEF(&_37); + ZVAL_UNDEF(&_38); + ZVAL_UNDEF(&_39); + ZVAL_UNDEF(&_40); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_11$$3); + ZVAL_UNDEF(&_15$$3); + ZVAL_UNDEF(&_16$$3); + ZVAL_UNDEF(&_17$$3); + ZVAL_UNDEF(&_18$$3); + ZVAL_UNDEF(&_7$$4); + ZVAL_UNDEF(&_8$$4); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&_12$$5); + ZVAL_UNDEF(&_13$$5); + ZVAL_UNDEF(&_14$$5); + ZVAL_UNDEF(&_19$$6); + ZVAL_UNDEF(&_20$$6); + ZVAL_UNDEF(&_21$$6); + ZVAL_UNDEF(&_26$$7); + ZVAL_UNDEF(&_27$$7); + ZVAL_UNDEF(&_28$$7); + ZVAL_UNDEF(&_29$$7); + ZVAL_UNDEF(&_30$$7); + ZVAL_UNDEF(&_31$$7); + ZVAL_UNDEF(&_23$$8); + ZVAL_UNDEF(&_24$$8); + ZVAL_UNDEF(&_25$$8); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_STR(file) + Z_PARAM_OPTIONAL + Z_PARAM_LONG_OR_NULL(width, is_null_true) + Z_PARAM_LONG_OR_NULL(height, is_null_true) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &column); - ZEPHIR_CALL_METHOD(&_0, column, "gettype", NULL, 0); + zephir_fetch_params(1, 1, 2, &file_param, &width_param, &height_param); + zephir_get_strval(&file, file_param); + if (!width_param) { + width = 0; + } else { + } + if (!height_param) { + height = 0; + } else { + } + ZEPHIR_CALL_METHOD(NULL, this_ptr, "check", NULL, 407); zephir_check_call_status(); - if (Z_TYPE_P(&_0) == IS_STRING) { - ZEPHIR_RETURN_CALL_METHOD(column, "gettypereference", NULL, 0); + zephir_update_property_zval(this_ptr, ZEND_STRL("file"), &file); + ZEPHIR_INIT_VAR(&_0); + object_init_ex(&_0, zephir_get_internal_ce(SL("imagick"))); + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &_0); + zephir_read_property(&_1, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); + if (1 == (zephir_file_exists(&_1) == SUCCESS)) { + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_FUNCTION(&_3$$3, "realpath", NULL, 74, &_2$$3); zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("realpath"), &_3$$3); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("realpath"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_5$$3, &_4$$3, "readimage", NULL, 0, &_6$$3); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_5$$3)) { + ZEPHIR_INIT_VAR(&_7$$4); + object_init_ex(&_7$$4, phalcon_image_exception_ce); + zephir_read_property(&_8$$4, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_9$$4); + ZEPHIR_CONCAT_SVS(&_9$$4, "Imagick::readImage ", &_8$$4, " failed"); + ZEPHIR_CALL_METHOD(NULL, &_7$$4, "__construct", NULL, 33, &_9$$4); + zephir_check_call_status(); + zephir_throw_exception_debug(&_7$$4, "phalcon/Image/Adapter/Imagick.zep", 72); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_read_property(&_10$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_11$$3, &_10$$3, "getimagealphachannel", NULL, 0); + zephir_check_call_status(); + if (!zephir_is_true(&_11$$3)) { + zephir_read_property(&_12$$5, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_13$$5); + ZVAL_STRING(&_13$$5, "Imagick::ALPHACHANNEL_SET"); + ZEPHIR_CALL_FUNCTION(&_14$$5, "constant", NULL, 119, &_13$$5); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_12$$5, "setimagealphachannel", NULL, 0, &_14$$5); + zephir_check_call_status(); + } + zephir_read_property(&_15$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_16$$3, &_15$$3, "getimagetype", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_16$$3); + zephir_read_property(&_17$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_18$$3, &_17$$3, "getimagetype", NULL, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_LONG(&_18$$3, 1)) { + zephir_read_property(&_19$$6, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&image, &_19$$6, "coalesceimages", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_20$$6, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_20$$6, "clear", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_21$$6, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_21$$6, "destroy", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &image); + } + } else { + _22$$7 = 0 == width; + if (!(_22$$7)) { + _22$$7 = 0 == height; + } + if (_22$$7) { + ZEPHIR_INIT_VAR(&_23$$8); + object_init_ex(&_23$$8, phalcon_image_exception_ce); + zephir_read_property(&_24$$8, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_25$$8); + ZEPHIR_CONCAT_SV(&_25$$8, "Failed to create image from file ", &_24$$8); + ZEPHIR_CALL_METHOD(NULL, &_23$$8, "__construct", NULL, 33, &_25$$8); + zephir_check_call_status(); + zephir_throw_exception_debug(&_23$$8, "phalcon/Image/Adapter/Imagick.zep", 97); + ZEPHIR_MM_RESTORE(); + return; + } + zephir_read_property(&_26$$7, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_27$$7); + object_init_ex(&_27$$7, zephir_get_internal_ce(SL("imagickpixel"))); + ZEPHIR_INIT_VAR(&_28$$7); + ZVAL_STRING(&_28$$7, "transparent"); + ZEPHIR_CALL_METHOD(NULL, &_27$$7, "__construct", NULL, 0, &_28$$7); + zephir_check_call_status(); + ZVAL_LONG(&_29$$7, width); + ZVAL_LONG(&_30$$7, height); + ZEPHIR_CALL_METHOD(NULL, &_26$$7, "newimage", NULL, 0, &_29$$7, &_30$$7, &_27$$7); + zephir_check_call_status(); + zephir_read_property(&_29$$7, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_28$$7); + ZVAL_STRING(&_28$$7, "png"); + ZEPHIR_CALL_METHOD(NULL, &_29$$7, "setformat", NULL, 0, &_28$$7); + zephir_check_call_status(); + zephir_read_property(&_30$$7, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_28$$7); + ZVAL_STRING(&_28$$7, "png"); + ZEPHIR_CALL_METHOD(NULL, &_30$$7, "setimageformat", NULL, 0, &_28$$7); + zephir_check_call_status(); + zephir_read_property(&_31$$7, this_ptr, ZEND_STRL("file"), PH_NOISY_CC | PH_READONLY); + zephir_update_property_zval(this_ptr, ZEND_STRL("realpath"), &_31$$7); } - ZEPHIR_RETURN_CALL_METHOD(column, "gettype", NULL, 0); + zephir_read_property(&_32, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_33, &_32, "getimagewidth", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_33); + zephir_read_property(&_34, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_35, &_34, "getimageheight", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_35); + zephir_read_property(&_36, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_37, &_36, "getimagetype", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_37); + zephir_read_property(&_38, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_39, &_38, "getimageformat", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_40); + ZEPHIR_CONCAT_SV(&_40, "image/", &_39); + zephir_update_property_zval(this_ptr, ZEND_STRL("mime"), &_40); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, checkColumnTypeSql) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, __destruct) { + zval _0, _1$$3, _2$$3; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *column, column_sub, _0; + zval *this_ptr = getThis(); - ZVAL_UNDEF(&column_sub); ZVAL_UNDEF(&_0); - ZEND_PARSE_PARAMETERS_START(1, 1) - Z_PARAM_OBJECT_OF_CLASS(column, phalcon_db_columninterface_ce) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 0, &column); - ZEPHIR_CALL_METHOD(&_0, column, "gettype", NULL, 0); - zephir_check_call_status(); - if (Z_TYPE_P(&_0) != IS_STRING) { - RETURN_MM_STRING(""); + + zephir_memory_observe(&_0); + zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC); + if (zephir_is_instance_of(&_0, SL("Imagick"))) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "clear", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_2$$3, "destroy", NULL, 0); + zephir_check_call_status(); } - ZEPHIR_RETURN_CALL_METHOD(column, "gettype", NULL, 0); - zephir_check_call_status(); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionAll) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, liquidRescale) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval escapeChar; - zval *expression_param = NULL, *escapeChar_param = NULL, domain, _0; - zval expression; + zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL; + zval *width_param = NULL, *height_param = NULL, *deltaX_param = NULL, *rigidity_param = NULL, image, result, _0, _8, _9, _1$$3, _2$$3, _3$$3, _4$$3, _6$$3; + zend_long width, height, deltaX, rigidity, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expression); - ZVAL_UNDEF(&domain); + ZVAL_UNDEF(&image); + ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&escapeChar); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(expression) + ZVAL_UNDEF(&_8); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_6$$3); + ZEND_PARSE_PARAMETERS_START(2, 4) + Z_PARAM_LONG(width) + Z_PARAM_LONG(height) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) + Z_PARAM_LONG(deltaX) + Z_PARAM_LONG(rigidity) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &expression_param, &escapeChar_param); - ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); + zephir_fetch_params(1, 2, 2, &width_param, &height_param, &deltaX_param, &rigidity_param); + if (!deltaX_param) { + deltaX = 0; } else { - zephir_get_strval(&escapeChar, escapeChar_param); + } + if (!rigidity_param) { + rigidity = 0; + } else { + } + zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&image, &_0); + ZVAL_LONG(&_0, 0); + ZEPHIR_CALL_METHOD(NULL, &image, "setiteratorindex", NULL, 0, &_0); + zephir_check_call_status(); + while (1) { + if (!(1)) { + break; + } + ZVAL_LONG(&_1$$3, width); + ZVAL_LONG(&_2$$3, height); + ZVAL_LONG(&_3$$3, deltaX); + ZVAL_LONG(&_4$$3, rigidity); + ZEPHIR_CALL_METHOD(&result, &image, "liquidrescaleimage", &_5, 0, &_1$$3, &_2$$3, &_3$$3, &_4$$3); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&result)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::liquidRescale failed", "phalcon/Image/Adapter/Imagick.zep", 165); + return; + } + ZEPHIR_CALL_METHOD(&_6$$3, &image, "nextimage", &_7, 0); + zephir_check_call_status(); + if (ZEPHIR_IS_FALSE_IDENTICAL(&_6$$3)) { + break; + } } - zephir_memory_observe(&domain); - zephir_array_isset_string_fetch(&domain, &expression, SL("domain"), 0); - ZEPHIR_INIT_VAR(&_0); - ZVAL_STRING(&_0, "*"); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "preparequalified", NULL, 0, &_0, &domain, &escapeChar); + ZEPHIR_CALL_METHOD(&_8, &image, "getimagewidth", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_8); + ZEPHIR_CALL_METHOD(&_9, &image, "getimageheight", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_9); + RETURN_THIS(); } -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionBinaryOperations) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, setResourceLimit) { + zend_bool _0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval escapeChar; - zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, left, right, _0, _1, _2; - zval expression, bindCounts; + zval *type_param = NULL, *limit_param = NULL, _1$$3, _2$$3, _3$$3; + zend_long type, limit, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expression); - ZVAL_UNDEF(&bindCounts); - ZVAL_UNDEF(&left); - ZVAL_UNDEF(&right); - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_2); - ZVAL_UNDEF(&escapeChar); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ARRAY(expression) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) - Z_PARAM_ARRAY(bindCounts) + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_LONG(type) + Z_PARAM_LONG(limit) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); - ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); + zephir_fetch_params(1, 2, 0, &type_param, &limit_param); + _0 = type >= 0; + if (_0) { + _0 = type <= 6; } - if (!bindCounts_param) { - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); + if (_0) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_2$$3, type); + ZVAL_LONG(&_3$$3, limit); + ZEPHIR_CALL_METHOD(NULL, &_1$$3, "setresourcelimit", NULL, 0, &_2$$3, &_3$$3); + zephir_check_call_status(); } else { - ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Cannot set the Resource Type for this image", "phalcon/Image/Adapter/Imagick.zep", 201); + return; } - zephir_array_fetch_string(&_0, &expression, SL("left"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 654); - ZEPHIR_CALL_METHOD(&left, this_ptr, "getsqlexpression", NULL, 0, &_0, &escapeChar, &bindCounts); - zephir_check_call_status(); - zephir_array_fetch_string(&_1, &expression, SL("right"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 660); - ZEPHIR_CALL_METHOD(&right, this_ptr, "getsqlexpression", NULL, 50, &_1, &escapeChar, &bindCounts); - zephir_check_call_status(); - zephir_array_fetch_string(&_2, &expression, SL("op"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 665); - ZEPHIR_CONCAT_VSVSV(return_value, &left, " ", &_2, " ", &right); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionCase) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processBackground) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval escapeChar, sql; - zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, whenClause, _0, _1, _2, _3, *_4, _5, _6$$3, _7$$4, _8$$4, _9$$4, _10$$4, _11$$4, _12$$5, _13$$5, _14$$5, _15$$6, _16$$7, _17$$7, _18$$7, _19$$7, _20$$7, _21$$8, _22$$8, _23$$8; - zval expression, bindCounts; + zephir_fcall_cache_entry *_6 = NULL, *_8 = NULL, *_11 = NULL, *_12 = NULL, *_13 = NULL, *_18 = NULL, *_20 = NULL, *_25 = NULL; + zval *red_param = NULL, *green_param = NULL, *blue_param = NULL, *opacity_param = NULL, background, color, pixel1, pixel2, result, _0, _1, _2, _3, _4$$3, _5$$3, _7$$3, _14$$3, _15$$3, _16$$3, _17$$3, _19$$3, _21$$3, _22$$3, _23$$3, _24$$3, _26$$3, _9$$4, _10$$4; + zend_long red, green, blue, opacity = 0, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expression); - ZVAL_UNDEF(&bindCounts); - ZVAL_UNDEF(&whenClause); + ZVAL_UNDEF(&background); + ZVAL_UNDEF(&color); + ZVAL_UNDEF(&pixel1); + ZVAL_UNDEF(&pixel2); + ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); ZVAL_UNDEF(&_2); ZVAL_UNDEF(&_3); - ZVAL_UNDEF(&_5); - ZVAL_UNDEF(&_6$$3); - ZVAL_UNDEF(&_7$$4); - ZVAL_UNDEF(&_8$$4); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_14$$3); + ZVAL_UNDEF(&_15$$3); + ZVAL_UNDEF(&_16$$3); + ZVAL_UNDEF(&_17$$3); + ZVAL_UNDEF(&_19$$3); + ZVAL_UNDEF(&_21$$3); + ZVAL_UNDEF(&_22$$3); + ZVAL_UNDEF(&_23$$3); + ZVAL_UNDEF(&_24$$3); + ZVAL_UNDEF(&_26$$3); ZVAL_UNDEF(&_9$$4); ZVAL_UNDEF(&_10$$4); - ZVAL_UNDEF(&_11$$4); - ZVAL_UNDEF(&_12$$5); - ZVAL_UNDEF(&_13$$5); - ZVAL_UNDEF(&_14$$5); - ZVAL_UNDEF(&_15$$6); - ZVAL_UNDEF(&_16$$7); - ZVAL_UNDEF(&_17$$7); - ZVAL_UNDEF(&_18$$7); - ZVAL_UNDEF(&_19$$7); - ZVAL_UNDEF(&_20$$7); - ZVAL_UNDEF(&_21$$8); - ZVAL_UNDEF(&_22$$8); - ZVAL_UNDEF(&_23$$8); - ZVAL_UNDEF(&escapeChar); - ZVAL_UNDEF(&sql); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ARRAY(expression) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) - Z_PARAM_ARRAY(bindCounts) + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_LONG(red) + Z_PARAM_LONG(green) + Z_PARAM_LONG(blue) + Z_PARAM_LONG(opacity) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); - ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!bindCounts_param) { - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); - } - zephir_array_fetch_string(&_1, &expression, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 682); - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getsqlexpression", NULL, 0, &_1, &escapeChar, &bindCounts); + zephir_fetch_params(1, 4, 0, &red_param, &green_param, &blue_param, &opacity_param); + opacity /= 100; + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "rgb(%d, %d, %d)"); + ZVAL_LONG(&_1, red); + ZVAL_LONG(&_2, green); + ZVAL_LONG(&_3, blue); + ZEPHIR_CALL_FUNCTION(&color, "sprintf", NULL, 117, &_0, &_1, &_2, &_3); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2); - ZEPHIR_CONCAT_SV(&_2, "CASE ", &_0); - zephir_get_strval(&sql, &_2); - zephir_array_fetch_string(&_3, &expression, SL("when-clauses"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 684); - zephir_is_iterable(&_3, 0, "phalcon/Db/Dialect.zep", 695); - if (Z_TYPE_P(&_3) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&_3), _4) - { - ZEPHIR_INIT_NVAR(&whenClause); - ZVAL_COPY(&whenClause, _4); - zephir_array_fetch_string(&_6$$3, &whenClause, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 685); - if (ZEPHIR_IS_STRING(&_6$$3, "when")) { - zephir_array_fetch_string(&_8$$4, &whenClause, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 687); - ZEPHIR_CALL_METHOD(&_7$$4, this_ptr, "getsqlexpression", NULL, 50, &_8$$4, &escapeChar, &bindCounts); - zephir_check_call_status(); - zephir_array_fetch_string(&_10$$4, &whenClause, SL("then"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 689); - ZEPHIR_CALL_METHOD(&_9$$4, this_ptr, "getsqlexpression", NULL, 50, &_10$$4, &escapeChar, &bindCounts); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_11$$4); - ZEPHIR_CONCAT_SVSV(&_11$$4, " WHEN ", &_7$$4, " THEN ", &_9$$4); - zephir_concat_self(&sql, &_11$$4); - } else { - zephir_array_fetch_string(&_13$$5, &whenClause, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 691); - ZEPHIR_CALL_METHOD(&_12$$5, this_ptr, "getsqlexpression", NULL, 50, &_13$$5, &escapeChar, &bindCounts); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_14$$5); - ZEPHIR_CONCAT_SV(&_14$$5, " ELSE ", &_12$$5); - zephir_concat_self(&sql, &_14$$5); - } - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &_3, "rewind", NULL, 0); + ZEPHIR_INIT_VAR(&pixel1); + object_init_ex(&pixel1, zephir_get_internal_ce(SL("imagickpixel"))); + ZEPHIR_CALL_METHOD(NULL, &pixel1, "__construct", NULL, 0, &color); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&pixel2); + object_init_ex(&pixel2, zephir_get_internal_ce(SL("imagickpixel"))); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_STRING(&_0, "transparent"); + ZEPHIR_CALL_METHOD(NULL, &pixel2, "__construct", NULL, 0, &_0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&background); + object_init_ex(&background, zephir_get_internal_ce(SL("imagick"))); + ZEPHIR_CALL_METHOD(NULL, &background, "__construct", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_2, 0); + ZEPHIR_CALL_METHOD(NULL, &_1, "setiteratorindex", NULL, 0, &_2); + zephir_check_call_status(); + while (1) { + if (!(1)) { + break; + } + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &background, "newimage", &_6, 0, &_4$$3, &_5$$3, &pixel1); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5, &_3, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5)) { - break; - } - ZEPHIR_CALL_METHOD(&whenClause, &_3, "current", NULL, 0); + ZEPHIR_CALL_METHOD(&_7$$3, &background, "getimagealphachannel", &_8, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_7$$3)) { + ZEPHIR_INIT_NVAR(&_9$$4); + ZVAL_STRING(&_9$$4, "Imagick::ALPHACHANNEL_SET"); + ZEPHIR_CALL_FUNCTION(&_10$$4, "constant", &_11, 119, &_9$$4); zephir_check_call_status(); - zephir_array_fetch_string(&_15$$6, &whenClause, SL("type"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 685); - if (ZEPHIR_IS_STRING(&_15$$6, "when")) { - zephir_array_fetch_string(&_17$$7, &whenClause, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 687); - ZEPHIR_CALL_METHOD(&_16$$7, this_ptr, "getsqlexpression", NULL, 50, &_17$$7, &escapeChar, &bindCounts); - zephir_check_call_status(); - zephir_array_fetch_string(&_19$$7, &whenClause, SL("then"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 689); - ZEPHIR_CALL_METHOD(&_18$$7, this_ptr, "getsqlexpression", NULL, 50, &_19$$7, &escapeChar, &bindCounts); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_20$$7); - ZEPHIR_CONCAT_SVSV(&_20$$7, " WHEN ", &_16$$7, " THEN ", &_18$$7); - zephir_concat_self(&sql, &_20$$7); - } else { - zephir_array_fetch_string(&_22$$8, &whenClause, SL("expr"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 691); - ZEPHIR_CALL_METHOD(&_21$$8, this_ptr, "getsqlexpression", NULL, 50, &_22$$8, &escapeChar, &bindCounts); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_23$$8); - ZEPHIR_CONCAT_SV(&_23$$8, " ELSE ", &_21$$8); - zephir_concat_self(&sql, &_23$$8); - } - ZEPHIR_CALL_METHOD(NULL, &_3, "next", NULL, 0); + ZEPHIR_CALL_METHOD(NULL, &background, "setimagealphachannel", &_12, 0, &_10$$4); zephir_check_call_status(); } + ZEPHIR_CALL_METHOD(NULL, &background, "setimagebackgroundcolor", &_13, 0, &pixel2); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_14$$3); + ZVAL_STRING(&_14$$3, "Imagick::EVALUATE_MULTIPLY"); + ZEPHIR_CALL_FUNCTION(&_15$$3, "constant", &_11, 119, &_14$$3); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_14$$3); + ZVAL_STRING(&_14$$3, "Imagick::CHANNEL_ALPHA"); + ZEPHIR_CALL_FUNCTION(&_16$$3, "constant", &_11, 119, &_14$$3); + zephir_check_call_status(); + ZVAL_LONG(&_17$$3, opacity); + ZEPHIR_CALL_METHOD(NULL, &background, "evaluateimage", &_18, 0, &_15$$3, &_17$$3, &_16$$3); + zephir_check_call_status(); + zephir_read_property(&_17$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_19$$3, &_17$$3, "getcolorspace", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &background, "setcolorspace", &_20, 0, &_19$$3); + zephir_check_call_status(); + zephir_read_property(&_21$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_14$$3); + ZVAL_STRING(&_14$$3, "Imagick::COMPOSITE_DISSOLVE"); + ZEPHIR_CALL_FUNCTION(&_22$$3, "constant", &_11, 119, &_14$$3); + zephir_check_call_status(); + ZVAL_LONG(&_23$$3, 0); + ZVAL_LONG(&_24$$3, 0); + ZEPHIR_CALL_METHOD(&result, &background, "compositeimage", &_25, 0, &_21$$3, &_22$$3, &_23$$3, &_24$$3); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&result)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::compositeImage failed", "phalcon/Image/Adapter/Imagick.zep", 263); + return; + } + zephir_read_property(&_23$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_26$$3, &_23$$3, "nextimage", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_26$$3)) { + break; + } } - ZEPHIR_INIT_NVAR(&whenClause); - ZEPHIR_CONCAT_VS(return_value, &sql, " END"); - RETURN_MM(); + zephir_read_property(&_2, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_2, "clear", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_3, "destroy", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &background); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionCastValue) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processBlur) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval escapeChar; - zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, left, right, _0, _1; - zval expression, bindCounts; + zval *radius_param = NULL, _0, _1, _2$$3, _3$$3, _4$$3, _5$$3; + zend_long radius, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expression); - ZVAL_UNDEF(&bindCounts); - ZVAL_UNDEF(&left); - ZVAL_UNDEF(&right); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&escapeChar); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ARRAY(expression) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) - Z_PARAM_ARRAY(bindCounts) + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(radius) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); - ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!bindCounts_param) { - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); - } - zephir_array_fetch_string(&_0, &expression, SL("left"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 712); - ZEPHIR_CALL_METHOD(&left, this_ptr, "getsqlexpression", NULL, 0, &_0, &escapeChar, &bindCounts); - zephir_check_call_status(); - zephir_array_fetch_string(&_1, &expression, SL("right"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 718); - ZEPHIR_CALL_METHOD(&right, this_ptr, "getsqlexpression", NULL, 50, &_1, &escapeChar, &bindCounts); + zephir_fetch_params(1, 1, 0, &radius_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1, 0); + ZEPHIR_CALL_METHOD(NULL, &_0, "setiteratorindex", NULL, 0, &_1); zephir_check_call_status(); - ZEPHIR_CONCAT_SVSVS(return_value, "CAST(", &left, " AS ", &right, ")"); - RETURN_MM(); + while (1) { + if (!(1)) { + break; + } + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_3$$3, radius); + ZVAL_LONG(&_4$$3, 100); + ZEPHIR_CALL_METHOD(NULL, &_2$$3, "blurimage", NULL, 0, &_3$$3, &_4$$3); + zephir_check_call_status(); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_5$$3, &_3$$3, "nextimage", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_5$$3)) { + break; + } + } + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionConvertValue) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processCrop) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval escapeChar; - zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, left, right, _0, _1; - zval expression, bindCounts; + zephir_fcall_cache_entry *_5 = NULL, *_6 = NULL, *_8 = NULL; + zval *width_param = NULL, *height_param = NULL, *offsetX_param = NULL, *offsetY_param = NULL, image, _0, _9, _10, _1$$3, _2$$3, _3$$3, _4$$3, _7$$3; + zend_long width, height, offsetX, offsetY, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expression); - ZVAL_UNDEF(&bindCounts); - ZVAL_UNDEF(&left); - ZVAL_UNDEF(&right); + ZVAL_UNDEF(&image); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&escapeChar); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ARRAY(expression) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) - Z_PARAM_ARRAY(bindCounts) + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_7$$3); + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_LONG(width) + Z_PARAM_LONG(height) + Z_PARAM_LONG(offsetX) + Z_PARAM_LONG(offsetY) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); - ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!bindCounts_param) { - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); + zephir_fetch_params(1, 4, 0, &width_param, &height_param, &offsetX_param, &offsetY_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&image, &_0); + ZVAL_LONG(&_0, 0); + ZEPHIR_CALL_METHOD(NULL, &image, "setiteratorindex", NULL, 0, &_0); + zephir_check_call_status(); + while (1) { + if (!(1)) { + break; + } + ZVAL_LONG(&_1$$3, width); + ZVAL_LONG(&_2$$3, height); + ZVAL_LONG(&_3$$3, offsetX); + ZVAL_LONG(&_4$$3, offsetY); + ZEPHIR_CALL_METHOD(NULL, &image, "cropimage", &_5, 0, &_1$$3, &_2$$3, &_3$$3, &_4$$3); + zephir_check_call_status(); + ZVAL_LONG(&_1$$3, width); + ZVAL_LONG(&_2$$3, height); + ZVAL_LONG(&_3$$3, 0); + ZVAL_LONG(&_4$$3, 0); + ZEPHIR_CALL_METHOD(NULL, &image, "setimagepage", &_6, 0, &_1$$3, &_2$$3, &_3$$3, &_4$$3); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_7$$3, &image, "nextimage", &_8, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_7$$3)) { + break; + } } - zephir_array_fetch_string(&_0, &expression, SL("left"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 740); - ZEPHIR_CALL_METHOD(&left, this_ptr, "getsqlexpression", NULL, 0, &_0, &escapeChar, &bindCounts); + ZEPHIR_CALL_METHOD(&_9, &image, "getimagewidth", NULL, 0); zephir_check_call_status(); - zephir_array_fetch_string(&_1, &expression, SL("right"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 746); - ZEPHIR_CALL_METHOD(&right, this_ptr, "getsqlexpression", NULL, 50, &_1, &escapeChar, &bindCounts); + zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_9); + ZEPHIR_CALL_METHOD(&_10, &image, "getimageheight", NULL, 0); zephir_check_call_status(); - ZEPHIR_CONCAT_SVSVS(return_value, "CONVERT(", &left, " USING ", &right, ")"); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_10); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionFrom) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processFlip) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval escapeChar; - zval *expression, expression_sub, *escapeChar_param = NULL, table, tables, *_0$$3, _1$$3, _5$$3, _2$$4, _4$$5; + zval *direction_param = NULL, method, _0, _1, _2$$3, _3$$3, _4$$3; + zend_long direction, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expression_sub); - ZVAL_UNDEF(&table); - ZVAL_UNDEF(&tables); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&escapeChar); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ZVAL(expression) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) + ZVAL_UNDEF(&method); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(direction) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &expression, &escapeChar_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); + zephir_fetch_params(1, 1, 0, &direction_param); + if (direction == 11) { + ZEPHIR_INIT_VAR(&method); + ZVAL_STRING(&method, "flipImage"); } else { - zephir_get_strval(&escapeChar, escapeChar_param); + ZEPHIR_INIT_NVAR(&method); + ZVAL_STRING(&method, "flopImage"); } - if (Z_TYPE_P(expression) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&tables); - array_init(&tables); - zephir_is_iterable(expression, 0, "phalcon/Db/Dialect.zep", 768); - if (Z_TYPE_P(expression) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(expression), _0$$3) - { - ZEPHIR_INIT_NVAR(&table); - ZVAL_COPY(&table, _0$$3); - ZEPHIR_CALL_METHOD(&_2$$4, this_ptr, "getsqltable", &_3, 66, &table, &escapeChar); - zephir_check_call_status(); - zephir_array_append(&tables, &_2$$4, PH_SEPARATE, "phalcon/Db/Dialect.zep", 765); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, expression, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1$$3, expression, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&table, expression, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_4$$5, this_ptr, "getsqltable", &_3, 66, &table, &escapeChar); - zephir_check_call_status(); - zephir_array_append(&tables, &_4$$5, PH_SEPARATE, "phalcon/Db/Dialect.zep", 765); - ZEPHIR_CALL_METHOD(NULL, expression, "next", NULL, 0); - zephir_check_call_status(); - } + zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1, 0); + ZEPHIR_CALL_METHOD(NULL, &_0, "setiteratorindex", NULL, 0, &_1); + zephir_check_call_status(); + while (1) { + if (!(1)) { + break; + } + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD_ZVAL(NULL, &_2$$3, &method, NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_4$$3, &_3$$3, "nextimage", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_4$$3)) { + break; } - ZEPHIR_INIT_NVAR(&table); - ZEPHIR_INIT_VAR(&_5$$3); - zephir_fast_join_str(&_5$$3, SL(", "), &tables); - ZEPHIR_CPY_WRT(&tables, &_5$$3); - } else { - ZEPHIR_CPY_WRT(&tables, expression); } - ZEPHIR_CONCAT_SV(return_value, "FROM ", &tables); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionFunctionCall) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processMask) { - zend_bool _1, _3$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_7 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval escapeChar; - zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, __$false, name, customFunction, arguments, _0, _4$$4; - zval expression, bindCounts, _2$$4; + zval *image, image_sub, mask, result, _0, _1, _2, _3$$3, _4$$3, _5$$3, _6$$3, _8$$3, _9$$3, _10$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expression); - ZVAL_UNDEF(&bindCounts); - ZVAL_UNDEF(&_2$$4); - ZVAL_BOOL(&__$false, 0); - ZVAL_UNDEF(&name); - ZVAL_UNDEF(&customFunction); - ZVAL_UNDEF(&arguments); + ZVAL_UNDEF(&image_sub); + ZVAL_UNDEF(&mask); + ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_4$$4); - ZVAL_UNDEF(&escapeChar); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ARRAY(expression) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) - Z_PARAM_ARRAY(bindCounts) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$3); + ZVAL_UNDEF(&_10$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_OBJECT_OF_CLASS(image, phalcon_image_adapter_adapterinterface_ce) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); - ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!bindCounts_param) { - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); - } - zephir_memory_observe(&name); - zephir_array_fetch_string(&name, &expression, SL("name"), PH_NOISY, "phalcon/Db/Dialect.zep", 789); - zephir_memory_observe(&customFunction); - zephir_read_property(&_0, this_ptr, ZEND_STRL("customFunctions"), PH_NOISY_CC | PH_READONLY); - if (zephir_array_isset_fetch(&customFunction, &_0, &name, 0)) { - ZEPHIR_RETURN_CALL_ZVAL_FUNCTION(&customFunction, NULL, 0, this_ptr, &expression, &escapeChar); + zephir_fetch_params(1, 1, 0, &image); + ZEPHIR_INIT_VAR(&mask); + object_init_ex(&mask, zephir_get_internal_ce(SL("imagick"))); + ZEPHIR_CALL_METHOD(NULL, &mask, "__construct", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_0, image, "render", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &mask, "readimageblob", NULL, 0, &_0); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_2, 0); + ZEPHIR_CALL_METHOD(NULL, &_1, "setiteratorindex", NULL, 0, &_2); + zephir_check_call_status(); + while (1) { + if (!(1)) { + break; + } + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_BOOL(&_4$$3, 1); + ZEPHIR_CALL_METHOD(NULL, &_3$$3, "setimagematte", NULL, 0, &_4$$3); zephir_check_call_status(); - RETURN_MM(); - } - zephir_memory_observe(&arguments); - _1 = zephir_array_isset_string_fetch(&arguments, &expression, SL("arguments"), 0); - if (_1) { - _1 = Z_TYPE_P(&arguments) == IS_ARRAY; - } - if (_1) { - ZEPHIR_INIT_VAR(&_2$$4); - zephir_create_array(&_2$$4, 3, 0); - add_assoc_stringl_ex(&_2$$4, SL("type"), SL("list")); - zephir_array_update_string(&_2$$4, SL("parentheses"), &__$false, PH_COPY | PH_SEPARATE); - zephir_array_update_string(&_2$$4, SL("value"), &arguments, PH_COPY | PH_SEPARATE); - ZEPHIR_CALL_METHOD(&arguments, this_ptr, "getsqlexpression", NULL, 0, &_2$$4, &escapeChar, &bindCounts); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_5$$3); + ZVAL_STRING(&_5$$3, "Imagick::COMPOSITE_DSTIN"); + ZEPHIR_CALL_FUNCTION(&_6$$3, "constant", &_7, 119, &_5$$3); zephir_check_call_status(); - _3$$4 = zephir_array_isset_string(&expression, SL("distinct")); - if (_3$$4) { - zephir_array_fetch_string(&_4$$4, &expression, SL("distinct"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 806); - _3$$4 = zephir_is_true(&_4$$4); + ZVAL_LONG(&_8$$3, 0); + ZVAL_LONG(&_9$$3, 0); + ZEPHIR_CALL_METHOD(&result, &_4$$3, "compositeimage", NULL, 0, &mask, &_6$$3, &_8$$3, &_9$$3); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&result)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::compositeImage failed", "phalcon/Image/Adapter/Imagick.zep", 388); + return; } - if (_3$$4) { - ZEPHIR_CONCAT_VSVS(return_value, &name, "(DISTINCT ", &arguments, ")"); - RETURN_MM(); + zephir_read_property(&_8$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_10$$3, &_8$$3, "nextimage", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_10$$3)) { + break; } - ZEPHIR_CONCAT_VSVS(return_value, &name, "(", &arguments, ")"); - RETURN_MM(); } - ZEPHIR_CONCAT_VS(return_value, &name, "()"); - RETURN_MM(); + ZEPHIR_CALL_METHOD(NULL, &mask, "clear", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &mask, "destroy", NULL, 0); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionGroupBy) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processPixelate) { + double height = 0, width = 0; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval bindCounts; - zval escapeChar; - zval *expression, expression_sub, *escapeChar_param = NULL, *bindCounts_param = NULL, field, fields, *_0$$3, _1$$3, _5$$3, _2$$4, _4$$6; + zval *amount_param = NULL, _0, _1, _2, _3, _4$$3, _5$$3, _6$$3, _7$$3, _8$$3, _9$$3; + zend_long amount, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expression_sub); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4$$3); ZVAL_UNDEF(&_5$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_4$$6); - ZVAL_UNDEF(&escapeChar); - ZVAL_UNDEF(&bindCounts); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ZVAL(expression) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) - Z_PARAM_ARRAY(bindCounts) + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(amount) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &expression, &escapeChar_param, &bindCounts_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!bindCounts_param) { - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); - } - if (Z_TYPE_P(expression) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&fields); - array_init(&fields); - zephir_is_iterable(expression, 0, "phalcon/Db/Dialect.zep", 844); - if (Z_TYPE_P(expression) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(expression), _0$$3) - { - ZEPHIR_INIT_NVAR(&field); - ZVAL_COPY(&field, _0$$3); - if (UNEXPECTED(Z_TYPE_P(&field) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL-GROUP-BY expression", "phalcon/Db/Dialect.zep", 834); - return; - } - ZEPHIR_CALL_METHOD(&_2$$4, this_ptr, "getsqlexpression", &_3, 0, &field, &escapeChar, &bindCounts); - zephir_check_call_status(); - zephir_array_append(&fields, &_2$$4, PH_SEPARATE, "phalcon/Db/Dialect.zep", 841); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, expression, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1$$3, expression, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&field, expression, "current", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&field) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL-GROUP-BY expression", "phalcon/Db/Dialect.zep", 834); - return; - } - ZEPHIR_CALL_METHOD(&_4$$6, this_ptr, "getsqlexpression", &_3, 50, &field, &escapeChar, &bindCounts); - zephir_check_call_status(); - zephir_array_append(&fields, &_4$$6, PH_SEPARATE, "phalcon/Db/Dialect.zep", 841); - ZEPHIR_CALL_METHOD(NULL, expression, "next", NULL, 0); - zephir_check_call_status(); - } + zephir_fetch_params(1, 1, 0, &amount_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + width = (zephir_safe_div_zval_long(&_0, amount)); + zephir_read_property(&_1, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + height = (zephir_safe_div_zval_long(&_1, amount)); + zephir_read_property(&_2, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_3, 0); + ZEPHIR_CALL_METHOD(NULL, &_2, "setiteratorindex", NULL, 0, &_3); + zephir_check_call_status(); + while (1) { + if (!(1)) { + break; + } + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_DOUBLE(&_5$$3, width); + ZVAL_DOUBLE(&_6$$3, height); + ZEPHIR_CALL_METHOD(NULL, &_4$$3, "scaleimage", NULL, 0, &_5$$3, &_6$$3); + zephir_check_call_status(); + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_7$$3, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_5$$3, "scaleimage", NULL, 0, &_6$$3, &_7$$3); + zephir_check_call_status(); + zephir_read_property(&_8$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_9$$3, &_8$$3, "nextimage", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_9$$3)) { + break; } - ZEPHIR_INIT_NVAR(&field); - ZEPHIR_INIT_VAR(&_5$$3); - zephir_fast_join_str(&_5$$3, SL(", "), &fields); - ZEPHIR_CPY_WRT(&fields, &_5$$3); - } else { - ZEPHIR_CPY_WRT(&fields, expression); } - ZEPHIR_CONCAT_SV(return_value, "GROUP BY ", &fields); - RETURN_MM(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionHaving) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processReflection) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval escapeChar; - zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, _0; - zval expression, bindCounts; + zephir_fcall_cache_entry *_5 = NULL, *_7 = NULL, *_11 = NULL, *_13 = NULL, *_14 = NULL, *_20 = NULL, *_23 = NULL, *_26 = NULL, *_33 = NULL, *_36 = NULL, *_38 = NULL, *_41 = NULL, *_46 = NULL, *_53 = NULL; + zend_bool fadeIn, _54$$13; + zval *height_param = NULL, *opacity_param = NULL, *fadeIn_param = NULL, fade, image, pixel, pseudo, reflection, result, _0, _4, _16, _17, _28, _29, _30, _56, _57, _58, _59, _60, _1$$3, _2$$4, _3$$4, _6$$5, _8$$5, _9$$5, _10$$5, _12$$5, _15$$5, _18$$7, _19$$7, _21$$7, _22$$7, _24$$7, _25$$7, _27$$7, _31$$10, _32$$10, _34$$10, _35$$10, _37$$10, _39$$10, _40$$10, _42$$10, _43$$10, _44$$10, _45$$10, _47$$10, _48$$13, _49$$13, _50$$13, _51$$13, _52$$13, _55$$13; + zend_long height, opacity, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expression); - ZVAL_UNDEF(&bindCounts); + ZVAL_UNDEF(&fade); + ZVAL_UNDEF(&image); + ZVAL_UNDEF(&pixel); + ZVAL_UNDEF(&pseudo); + ZVAL_UNDEF(&reflection); + ZVAL_UNDEF(&result); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&escapeChar); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ARRAY(expression) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) - Z_PARAM_ARRAY(bindCounts) + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_16); + ZVAL_UNDEF(&_17); + ZVAL_UNDEF(&_28); + ZVAL_UNDEF(&_29); + ZVAL_UNDEF(&_30); + ZVAL_UNDEF(&_56); + ZVAL_UNDEF(&_57); + ZVAL_UNDEF(&_58); + ZVAL_UNDEF(&_59); + ZVAL_UNDEF(&_60); + ZVAL_UNDEF(&_1$$3); + ZVAL_UNDEF(&_2$$4); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_6$$5); + ZVAL_UNDEF(&_8$$5); + ZVAL_UNDEF(&_9$$5); + ZVAL_UNDEF(&_10$$5); + ZVAL_UNDEF(&_12$$5); + ZVAL_UNDEF(&_15$$5); + ZVAL_UNDEF(&_18$$7); + ZVAL_UNDEF(&_19$$7); + ZVAL_UNDEF(&_21$$7); + ZVAL_UNDEF(&_22$$7); + ZVAL_UNDEF(&_24$$7); + ZVAL_UNDEF(&_25$$7); + ZVAL_UNDEF(&_27$$7); + ZVAL_UNDEF(&_31$$10); + ZVAL_UNDEF(&_32$$10); + ZVAL_UNDEF(&_34$$10); + ZVAL_UNDEF(&_35$$10); + ZVAL_UNDEF(&_37$$10); + ZVAL_UNDEF(&_39$$10); + ZVAL_UNDEF(&_40$$10); + ZVAL_UNDEF(&_42$$10); + ZVAL_UNDEF(&_43$$10); + ZVAL_UNDEF(&_44$$10); + ZVAL_UNDEF(&_45$$10); + ZVAL_UNDEF(&_47$$10); + ZVAL_UNDEF(&_48$$13); + ZVAL_UNDEF(&_49$$13); + ZVAL_UNDEF(&_50$$13); + ZVAL_UNDEF(&_51$$13); + ZVAL_UNDEF(&_52$$13); + ZVAL_UNDEF(&_55$$13); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_LONG(height) + Z_PARAM_LONG(opacity) + Z_PARAM_BOOL(fadeIn) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); - ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!bindCounts_param) { - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); + zephir_fetch_params(1, 3, 0, &height_param, &opacity_param, &fadeIn_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("version"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&reflection); + if (ZEPHIR_GE_LONG(&_0, 30100)) { + zephir_read_property(&_1$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + if (zephir_clone(&reflection, &_1$$3) == FAILURE) { + RETURN_MM(); + } } else { - ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); + zephir_read_property(&_2$$4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_3$$4, &_2$$4, "clone", NULL, 0); + zephir_check_call_status(); + if (zephir_clone(&reflection, &_3$$4) == FAILURE) { + RETURN_MM(); + } } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "getsqlexpression", NULL, 0, &expression, &escapeChar, &bindCounts); + ZVAL_LONG(&_4, 0); + ZEPHIR_CALL_METHOD(NULL, &reflection, "setiteratorindex", NULL, 0, &_4); zephir_check_call_status(); - ZEPHIR_CONCAT_SV(return_value, "HAVING ", &_0); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionJoins) -{ - zend_bool _2$$3, _9$$3, _13$$11, _19$$11; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL, *_11 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval bindCounts; - zval escapeChar, sql; - zval *expression, expression_sub, *escapeChar_param = NULL, *bindCounts_param = NULL, condition, join, joinCondition, joinTable, joinType, joinConditionsArray, *_0, _1, _10$$3, _12$$3, *_4$$6, _5$$6, _8$$6, _6$$7, _7$$8, _20$$11, _21$$11, *_14$$14, _15$$14, _18$$14, _16$$15, _17$$16; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&expression_sub); - ZVAL_UNDEF(&condition); - ZVAL_UNDEF(&join); - ZVAL_UNDEF(&joinCondition); - ZVAL_UNDEF(&joinTable); - ZVAL_UNDEF(&joinType); - ZVAL_UNDEF(&joinConditionsArray); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_10$$3); - ZVAL_UNDEF(&_12$$3); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_8$$6); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_7$$8); - ZVAL_UNDEF(&_20$$11); - ZVAL_UNDEF(&_21$$11); - ZVAL_UNDEF(&_15$$14); - ZVAL_UNDEF(&_18$$14); - ZVAL_UNDEF(&_16$$15); - ZVAL_UNDEF(&_17$$16); - ZVAL_UNDEF(&escapeChar); - ZVAL_UNDEF(&sql); - ZVAL_UNDEF(&bindCounts); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ZVAL(expression) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) - Z_PARAM_ARRAY(bindCounts) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &expression, &escapeChar_param, &bindCounts_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!bindCounts_param) { - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); - } - ZEPHIR_INIT_VAR(&joinType); - ZVAL_STRING(&joinType, ""); - ZEPHIR_INIT_VAR(&sql); - zephir_is_iterable(expression, 0, "phalcon/Db/Dialect.zep", 918); - if (Z_TYPE_P(expression) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(expression), _0) - { - ZEPHIR_INIT_NVAR(&join); - ZVAL_COPY(&join, _0); - ZEPHIR_OBS_NVAR(&joinConditionsArray); - _2$$3 = zephir_array_isset_string_fetch(&joinConditionsArray, &join, SL("conditions"), 0); - if (_2$$3) { - _2$$3 = !(ZEPHIR_IS_EMPTY(&joinConditionsArray)); - } - if (_2$$3) { - if (!(zephir_array_isset_long(&joinConditionsArray, 0))) { - ZEPHIR_CALL_METHOD(&joinCondition, this_ptr, "getsqlexpression", &_3, 0, &joinConditionsArray, &escapeChar, &bindCounts); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&joinCondition); - array_init(&joinCondition); - zephir_is_iterable(&joinConditionsArray, 0, "phalcon/Db/Dialect.zep", 903); - if (Z_TYPE_P(&joinConditionsArray) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&joinConditionsArray), _4$$6) - { - ZEPHIR_INIT_NVAR(&condition); - ZVAL_COPY(&condition, _4$$6); - ZEPHIR_CALL_METHOD(&_6$$7, this_ptr, "getsqlexpression", &_3, 50, &condition, &escapeChar, &bindCounts); - zephir_check_call_status(); - zephir_array_append(&joinCondition, &_6$$7, PH_SEPARATE, "phalcon/Db/Dialect.zep", 900); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &joinConditionsArray, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_5$$6, &joinConditionsArray, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_5$$6)) { - break; - } - ZEPHIR_CALL_METHOD(&condition, &joinConditionsArray, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_7$$8, this_ptr, "getsqlexpression", &_3, 50, &condition, &escapeChar, &bindCounts); - zephir_check_call_status(); - zephir_array_append(&joinCondition, &_7$$8, PH_SEPARATE, "phalcon/Db/Dialect.zep", 900); - ZEPHIR_CALL_METHOD(NULL, &joinConditionsArray, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&condition); - ZEPHIR_INIT_NVAR(&_8$$6); - zephir_fast_join_str(&_8$$6, SL(" AND "), &joinCondition); - ZEPHIR_CPY_WRT(&joinCondition, &_8$$6); - } - } else { - ZEPHIR_INIT_NVAR(&joinCondition); - ZVAL_LONG(&joinCondition, 1); - } - ZEPHIR_OBS_NVAR(&joinType); - _9$$3 = zephir_array_isset_string_fetch(&joinType, &join, SL("type"), 0); - if (_9$$3) { - _9$$3 = zephir_is_true(&joinType); - } - if (_9$$3) { - zephir_concat_self_str(&joinType, SL(" ")); - } - zephir_array_fetch_string(&_10$$3, &join, SL("source"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 913); - ZEPHIR_CALL_METHOD(&joinTable, this_ptr, "getsqltable", &_11, 66, &_10$$3, &escapeChar); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_12$$3); - ZEPHIR_CONCAT_SVSVSV(&_12$$3, " ", &joinType, "JOIN ", &joinTable, " ON ", &joinCondition); - zephir_concat_self(&sql, &_12$$3); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, expression, "rewind", NULL, 0); + while (1) { + if (!(1)) { + break; + } + ZEPHIR_CALL_METHOD(NULL, &reflection, "flipimage", &_5, 0); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1, expression, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1)) { - break; - } - ZEPHIR_CALL_METHOD(&join, expression, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&joinConditionsArray); - _13$$11 = zephir_array_isset_string_fetch(&joinConditionsArray, &join, SL("conditions"), 0); - if (_13$$11) { - _13$$11 = !(ZEPHIR_IS_EMPTY(&joinConditionsArray)); - } - if (_13$$11) { - if (!(zephir_array_isset_long(&joinConditionsArray, 0))) { - ZEPHIR_CALL_METHOD(&joinCondition, this_ptr, "getsqlexpression", &_3, 50, &joinConditionsArray, &escapeChar, &bindCounts); - zephir_check_call_status(); - } else { - ZEPHIR_INIT_NVAR(&joinCondition); - array_init(&joinCondition); - zephir_is_iterable(&joinConditionsArray, 0, "phalcon/Db/Dialect.zep", 903); - if (Z_TYPE_P(&joinConditionsArray) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&joinConditionsArray), _14$$14) - { - ZEPHIR_INIT_NVAR(&condition); - ZVAL_COPY(&condition, _14$$14); - ZEPHIR_CALL_METHOD(&_16$$15, this_ptr, "getsqlexpression", &_3, 50, &condition, &escapeChar, &bindCounts); - zephir_check_call_status(); - zephir_array_append(&joinCondition, &_16$$15, PH_SEPARATE, "phalcon/Db/Dialect.zep", 900); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &joinConditionsArray, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_15$$14, &joinConditionsArray, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_15$$14)) { - break; - } - ZEPHIR_CALL_METHOD(&condition, &joinConditionsArray, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_17$$16, this_ptr, "getsqlexpression", &_3, 50, &condition, &escapeChar, &bindCounts); - zephir_check_call_status(); - zephir_array_append(&joinCondition, &_17$$16, PH_SEPARATE, "phalcon/Db/Dialect.zep", 900); - ZEPHIR_CALL_METHOD(NULL, &joinConditionsArray, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&condition); - ZEPHIR_INIT_NVAR(&_18$$14); - zephir_fast_join_str(&_18$$14, SL(" AND "), &joinCondition); - ZEPHIR_CPY_WRT(&joinCondition, &_18$$14); - } - } else { - ZEPHIR_INIT_NVAR(&joinCondition); - ZVAL_LONG(&joinCondition, 1); - } - ZEPHIR_OBS_NVAR(&joinType); - _19$$11 = zephir_array_isset_string_fetch(&joinType, &join, SL("type"), 0); - if (_19$$11) { - _19$$11 = zephir_is_true(&joinType); - } - if (_19$$11) { - zephir_concat_self_str(&joinType, SL(" ")); - } - zephir_array_fetch_string(&_20$$11, &join, SL("source"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 913); - ZEPHIR_CALL_METHOD(&joinTable, this_ptr, "getsqltable", &_11, 66, &_20$$11, &escapeChar); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_21$$11); - ZEPHIR_CONCAT_SVSVSV(&_21$$11, " ", &joinType, "JOIN ", &joinTable, " ON ", &joinCondition); - zephir_concat_self(&sql, &_21$$11); - ZEPHIR_CALL_METHOD(NULL, expression, "next", NULL, 0); - zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_6$$5, &reflection, "getimagewidth", &_7, 0); + zephir_check_call_status(); + ZVAL_LONG(&_8$$5, height); + ZVAL_LONG(&_9$$5, 0); + ZVAL_LONG(&_10$$5, 0); + ZEPHIR_CALL_METHOD(NULL, &reflection, "cropimage", &_11, 0, &_6$$5, &_8$$5, &_9$$5, &_10$$5); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_12$$5, &reflection, "getimagewidth", &_13, 0); + zephir_check_call_status(); + ZVAL_LONG(&_8$$5, height); + ZVAL_LONG(&_9$$5, 0); + ZVAL_LONG(&_10$$5, 0); + ZEPHIR_CALL_METHOD(NULL, &reflection, "setimagepage", &_14, 0, &_12$$5, &_8$$5, &_9$$5, &_10$$5); + zephir_check_call_status(); + zephir_read_property(&_8$$5, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_15$$5, &_8$$5, "nextimage", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_15$$5)) { + break; } } - ZEPHIR_INIT_NVAR(&join); - RETURN_CTOR(&sql); -} - -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionLimit) -{ - zend_bool _2$$4; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval bindCounts, _4; - zval escapeChar; - zval *expression, expression_sub, *escapeChar_param = NULL, *bindCounts_param = NULL, sql, value, limit, offset, _0$$4, _1$$5, _3$$7; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&expression_sub); - ZVAL_UNDEF(&sql); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&limit); - ZVAL_UNDEF(&offset); - ZVAL_UNDEF(&_0$$4); - ZVAL_UNDEF(&_1$$5); - ZVAL_UNDEF(&_3$$7); - ZVAL_UNDEF(&escapeChar); - ZVAL_UNDEF(&bindCounts); - ZVAL_UNDEF(&_4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ZVAL(expression) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) - Z_PARAM_ARRAY(bindCounts) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &expression, &escapeChar_param, &bindCounts_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); + if (fadeIn) { + ZEPHIR_INIT_VAR(&pseudo); + ZVAL_STRING(&pseudo, "gradient:black-transparent"); } else { - zephir_get_strval(&escapeChar, escapeChar_param); + ZEPHIR_INIT_NVAR(&pseudo); + ZVAL_STRING(&pseudo, "gradient:transparent-black"); } - if (!bindCounts_param) { - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); + ZEPHIR_INIT_VAR(&fade); + object_init_ex(&fade, zephir_get_internal_ce(SL("imagick"))); + ZEPHIR_CALL_METHOD(NULL, &fade, "__construct", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_16, &reflection, "getimagewidth", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_17, &reflection, "getimageheight", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &fade, "newpseudoimage", NULL, 0, &_16, &_17, &pseudo); + zephir_check_call_status(); + opacity /= 100; + ZVAL_LONG(&_4, 0); + ZEPHIR_CALL_METHOD(NULL, &reflection, "setiteratorindex", NULL, 0, &_4); + zephir_check_call_status(); + while (1) { + if (!(1)) { + break; + } + ZEPHIR_INIT_NVAR(&_18$$7); + ZVAL_STRING(&_18$$7, "Imagick::COMPOSITE_DSTOUT"); + ZEPHIR_CALL_FUNCTION(&_19$$7, "constant", &_20, 119, &_18$$7); + zephir_check_call_status(); + ZVAL_LONG(&_21$$7, 0); + ZVAL_LONG(&_22$$7, 0); + ZEPHIR_CALL_METHOD(&result, &reflection, "compositeimage", &_23, 0, &fade, &_19$$7, &_21$$7, &_22$$7); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&result)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::compositeImage failed", "phalcon/Image/Adapter/Imagick.zep", 495); + return; + } + ZEPHIR_INIT_NVAR(&_18$$7); + ZVAL_STRING(&_18$$7, "Imagick::EVALUATE_MULTIPLY"); + ZEPHIR_CALL_FUNCTION(&_24$$7, "constant", &_20, 119, &_18$$7); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_18$$7); + ZVAL_STRING(&_18$$7, "Imagick::CHANNEL_ALPHA"); + ZEPHIR_CALL_FUNCTION(&_25$$7, "constant", &_20, 119, &_18$$7); + zephir_check_call_status(); + ZVAL_LONG(&_21$$7, opacity); + ZEPHIR_CALL_METHOD(NULL, &reflection, "evaluateimage", &_26, 0, &_24$$7, &_21$$7, &_25$$7); + zephir_check_call_status(); + zephir_read_property(&_21$$7, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_27$$7, &_21$$7, "nextimage", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_27$$7)) { + break; + } } - ZEPHIR_INIT_VAR(&sql); - ZVAL_STRING(&sql, ""); - ZEPHIR_INIT_VAR(&offset); - ZVAL_NULL(&offset); - zephir_memory_observe(&value); - zephir_array_fetch_string(&value, expression, SL("value"), PH_NOISY, "phalcon/Db/Dialect.zep", 934); - if (zephir_array_isset_string(expression, SL("sql"))) { - ZEPHIR_OBS_NVAR(&sql); - zephir_array_fetch_string(&sql, expression, SL("sql"), PH_NOISY, "phalcon/Db/Dialect.zep", 937); + ZEPHIR_CALL_METHOD(NULL, &fade, "destroy", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&image); + object_init_ex(&image, zephir_get_internal_ce(SL("imagick"))); + ZEPHIR_CALL_METHOD(NULL, &image, "__construct", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&pixel); + object_init_ex(&pixel, zephir_get_internal_ce(SL("imagickpixel"))); + ZEPHIR_CALL_METHOD(NULL, &pixel, "__construct", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_28, &_4, "getimageheight", NULL, 0); + zephir_check_call_status(); + height = (zephir_get_numberval(&_28) + height); + zephir_read_property(&_29, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_30, 0); + ZEPHIR_CALL_METHOD(NULL, &_29, "setiteratorindex", NULL, 0, &_30); + zephir_check_call_status(); + while (1) { + if (!(1)) { + break; + } + zephir_read_property(&_31$$10, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_32$$10, height); + ZEPHIR_CALL_METHOD(NULL, &image, "newimage", &_33, 0, &_31$$10, &_32$$10, &pixel); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_34$$10); + ZVAL_STRING(&_34$$10, "Imagick::ALPHACHANNEL_SET"); + ZEPHIR_CALL_FUNCTION(&_35$$10, "constant", &_20, 119, &_34$$10); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &image, "setimagealphachannel", &_36, 0, &_35$$10); + zephir_check_call_status(); + zephir_read_property(&_32$$10, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_37$$10, &_32$$10, "getcolorspace", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &image, "setcolorspace", &_38, 0, &_37$$10); + zephir_check_call_status(); + zephir_read_property(&_39$$10, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_40$$10, &_39$$10, "getimagedelay", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &image, "setimagedelay", &_41, 0, &_40$$10); + zephir_check_call_status(); + zephir_read_property(&_42$$10, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_34$$10); + ZVAL_STRING(&_34$$10, "Imagick::COMPOSITE_SRC"); + ZEPHIR_CALL_FUNCTION(&_43$$10, "constant", &_20, 119, &_34$$10); + zephir_check_call_status(); + ZVAL_LONG(&_44$$10, 0); + ZVAL_LONG(&_45$$10, 0); + ZEPHIR_CALL_METHOD(&result, &image, "compositeimage", &_46, 0, &_42$$10, &_43$$10, &_44$$10, &_45$$10); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&result)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::compositeImage failed", "phalcon/Image/Adapter/Imagick.zep", 534); + return; + } + zephir_read_property(&_44$$10, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_47$$10, &_44$$10, "nextimage", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_47$$10)) { + break; + } } - if (Z_TYPE_P(&value) == IS_ARRAY) { - zephir_memory_observe(&_0$$4); - zephir_array_fetch_string(&_0$$4, &value, SL("number"), PH_NOISY, "phalcon/Db/Dialect.zep", 941); - if (Z_TYPE_P(&_0$$4) == IS_ARRAY) { - zephir_array_fetch_string(&_1$$5, &value, SL("number"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 943); - ZEPHIR_CALL_METHOD(&limit, this_ptr, "getsqlexpression", NULL, 0, &_1$$5, &escapeChar, &bindCounts); - zephir_check_call_status(); - } else { - ZEPHIR_OBS_NVAR(&limit); - zephir_array_fetch_string(&limit, &value, SL("number"), PH_NOISY, "phalcon/Db/Dialect.zep", 948); + ZVAL_LONG(&_30, 0); + ZEPHIR_CALL_METHOD(NULL, &image, "setiteratorindex", NULL, 0, &_30); + zephir_check_call_status(); + ZVAL_LONG(&_30, 0); + ZEPHIR_CALL_METHOD(NULL, &reflection, "setiteratorindex", NULL, 0, &_30); + zephir_check_call_status(); + while (1) { + if (!(1)) { + break; } - ZEPHIR_OBS_NVAR(&offset); - _2$$4 = zephir_array_isset_string_fetch(&offset, &value, SL("offset"), 0); - if (_2$$4) { - _2$$4 = Z_TYPE_P(&offset) == IS_ARRAY; + ZEPHIR_INIT_NVAR(&_48$$13); + ZVAL_STRING(&_48$$13, "Imagick::COMPOSITE_OVER"); + ZEPHIR_CALL_FUNCTION(&_49$$13, "constant", &_20, 119, &_48$$13); + zephir_check_call_status(); + zephir_read_property(&_50$$13, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_51$$13, 0); + ZEPHIR_CALL_METHOD(&result, &image, "compositeimage", &_46, 0, &reflection, &_49$$13, &_51$$13, &_50$$13); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&result)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::compositeImage failed", "phalcon/Image/Adapter/Imagick.zep", 554); + return; } - if (_2$$4) { - ZEPHIR_CALL_METHOD(&_3$$7, this_ptr, "getsqlexpression", NULL, 50, &offset, &escapeChar, &bindCounts); + ZEPHIR_CALL_METHOD(&_52$$13, &image, "nextimage", &_53, 0); + zephir_check_call_status(); + _54$$13 = !ZEPHIR_IS_TRUE_IDENTICAL(&_52$$13); + if (!(_54$$13)) { + ZEPHIR_CALL_METHOD(&_55$$13, &reflection, "nextimage", NULL, 0); zephir_check_call_status(); - ZEPHIR_CPY_WRT(&offset, &_3$$7); + _54$$13 = !ZEPHIR_IS_TRUE_IDENTICAL(&_55$$13); + } + if (_54$$13) { + break; } - } else { - ZEPHIR_CPY_WRT(&limit, &value); } - ZEPHIR_INIT_VAR(&_4); - zephir_create_array(&_4, 2, 0); - zephir_array_fast_append(&_4, &limit); - zephir_array_fast_append(&_4, &offset); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "limit", NULL, 0, &sql, &_4); + ZEPHIR_CALL_METHOD(NULL, &reflection, "destroy", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + zephir_read_property(&_30, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_30, "clear", NULL, 0); + zephir_check_call_status(); + zephir_read_property(&_56, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_56, "destroy", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("image"), &image); + zephir_read_property(&_57, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_58, &_57, "getimagewidth", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_58); + zephir_read_property(&_59, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_60, &_59, "getimageheight", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_60); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionList) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processRender) { - zend_bool _0, _1, _7$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_5 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval escapeChar; - zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, item, values, separator, *_2$$4, _3$$4, _8$$4, _9$$4, _4$$5, _6$$6; - zval expression, bindCounts, items; + zend_long quality, ZEPHIR_LAST_CALL_STATUS; + zval *extension_param = NULL, *quality_param = NULL, image, _0, _1, _2, _3, _4, _5$$4, _6$$4, _7$$4; + zval extension; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expression); - ZVAL_UNDEF(&bindCounts); - ZVAL_UNDEF(&items); - ZVAL_UNDEF(&item); - ZVAL_UNDEF(&values); - ZVAL_UNDEF(&separator); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_4$$5); - ZVAL_UNDEF(&_6$$6); - ZVAL_UNDEF(&escapeChar); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ARRAY(expression) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) - Z_PARAM_ARRAY(bindCounts) + ZVAL_UNDEF(&extension); + ZVAL_UNDEF(&image); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_7$$4); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(extension) + Z_PARAM_LONG(quality) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); - ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!bindCounts_param) { - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); - } - ZEPHIR_INIT_VAR(&items); - array_init(&items); - ZEPHIR_INIT_VAR(&separator); - ZVAL_STRING(&separator, ", "); - if (zephir_array_isset_string(&expression, SL("separator"))) { - ZEPHIR_OBS_NVAR(&separator); - zephir_array_fetch_string(&separator, &expression, SL("separator"), PH_NOISY, "phalcon/Db/Dialect.zep", 987); - } - zephir_memory_observe(&values); - _0 = zephir_array_isset_long_fetch(&values, &expression, 0, 0); - if (!(_0)) { - ZEPHIR_OBS_NVAR(&values); - _0 = zephir_array_isset_string_fetch(&values, &expression, SL("value"), 0); - } - _1 = _0; - if (_1) { - _1 = Z_TYPE_P(&values) == IS_ARRAY; - } - if (_1) { - zephir_is_iterable(&values, 0, "phalcon/Db/Dialect.zep", 996); - if (Z_TYPE_P(&values) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&values), _2$$4) - { - ZEPHIR_INIT_NVAR(&item); - ZVAL_COPY(&item, _2$$4); - ZEPHIR_CALL_METHOD(&_4$$5, this_ptr, "getsqlexpression", &_5, 0, &item, &escapeChar, &bindCounts); - zephir_check_call_status(); - zephir_array_append(&items, &_4$$5, PH_SEPARATE, "phalcon/Db/Dialect.zep", 993); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, &values, "rewind", NULL, 0); + zephir_fetch_params(1, 2, 0, &extension_param, &quality_param); + zephir_get_strval(&extension, extension_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&image, &_0); + ZEPHIR_CALL_METHOD(NULL, &image, "setformat", NULL, 0, &extension); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &image, "setimageformat", NULL, 0, &extension); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &image, "stripimage", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_1, &image, "getimagetype", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_1); + ZEPHIR_CALL_METHOD(&_2, &image, "getimageformat", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_3); + ZEPHIR_CONCAT_SV(&_3, "image/", &_2); + zephir_update_property_zval(this_ptr, ZEND_STRL("mime"), &_3); + ZEPHIR_INIT_VAR(&_4); + zephir_fast_strtolower(&_4, &extension); + zephir_get_strval(&extension, &_4); + do { + if (ZEPHIR_IS_STRING(&extension, "gif")) { + ZEPHIR_CALL_METHOD(NULL, &image, "optimizeimagelayers", NULL, 0); zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_3$$4, &values, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_3$$4)) { - break; - } - ZEPHIR_CALL_METHOD(&item, &values, "current", NULL, 0); - zephir_check_call_status(); - ZEPHIR_CALL_METHOD(&_6$$6, this_ptr, "getsqlexpression", &_5, 50, &item, &escapeChar, &bindCounts); - zephir_check_call_status(); - zephir_array_append(&items, &_6$$6, PH_SEPARATE, "phalcon/Db/Dialect.zep", 993); - ZEPHIR_CALL_METHOD(NULL, &values, "next", NULL, 0); - zephir_check_call_status(); - } - } - ZEPHIR_INIT_NVAR(&item); - _7$$4 = zephir_array_isset_string(&expression, SL("parentheses")); - if (_7$$4) { - zephir_array_fetch_string(&_8$$4, &expression, SL("parentheses"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 996); - _7$$4 = ZEPHIR_IS_FALSE_IDENTICAL(&_8$$4); + break; } - if (_7$$4) { - zephir_fast_join(return_value, &separator, &items); - RETURN_MM(); + if (ZEPHIR_IS_STRING(&extension, "jpg") || ZEPHIR_IS_STRING(&extension, "jpeg")) { + ZEPHIR_INIT_VAR(&_5$$4); + ZVAL_STRING(&_5$$4, "Imagick::COMPRESSION_JPEG"); + ZEPHIR_CALL_FUNCTION(&_6$$4, "constant", NULL, 119, &_5$$4); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &image, "setimagecompression", NULL, 0, &_6$$4); + zephir_check_call_status(); + ZVAL_LONG(&_7$$4, quality); + ZEPHIR_CALL_METHOD(NULL, &image, "setimagecompressionquality", NULL, 0, &_7$$4); + zephir_check_call_status(); } - ZEPHIR_INIT_VAR(&_9$$4); - zephir_fast_join(&_9$$4, &separator, &items); - ZEPHIR_CONCAT_SVS(return_value, "(", &_9$$4, ")"); - RETURN_MM(); - } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL-list expression", "phalcon/Db/Dialect.zep", 1003); - return; -} - -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionObject) -{ - zend_bool _0, _1; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval escapeChar; - zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, domain, objectExpression; - zval expression, bindCounts; - zval *this_ptr = getThis(); + } while(0); - ZVAL_UNDEF(&expression); - ZVAL_UNDEF(&bindCounts); - ZVAL_UNDEF(&domain); - ZVAL_UNDEF(&objectExpression); - ZVAL_UNDEF(&escapeChar); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ARRAY(expression) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) - Z_PARAM_ARRAY(bindCounts) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); - ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!bindCounts_param) { - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); - } - ZEPHIR_INIT_VAR(&domain); - ZVAL_NULL(&domain); - ZEPHIR_INIT_VAR(&objectExpression); - zephir_create_array(&objectExpression, 1, 0); - add_assoc_stringl_ex(&objectExpression, SL("type"), SL("all")); - ZEPHIR_OBS_NVAR(&domain); - _0 = zephir_array_isset_string_fetch(&domain, &expression, SL("column"), 0); - if (!(_0)) { - ZEPHIR_OBS_NVAR(&domain); - _0 = zephir_array_isset_string_fetch(&domain, &expression, SL("domain"), 0); - } - _1 = _0; - if (_1) { - _1 = !ZEPHIR_IS_STRING(&domain, ""); - } - if (_1) { - zephir_array_update_string(&objectExpression, SL("domain"), &domain, PH_COPY | PH_SEPARATE); - } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpression", NULL, 0, &objectExpression, &escapeChar, &bindCounts); + ZEPHIR_RETURN_CALL_METHOD(&image, "getimageblob", NULL, 0); zephir_check_call_status(); RETURN_MM(); } -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionOrderBy) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processResize) { - zend_bool _4$$4, _7$$7; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_3 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval bindCounts; - zval escapeChar; - zval *expression, expression_sub, *escapeChar_param = NULL, *bindCounts_param = NULL, field, fields, type, fieldSql, *_0$$3, _1$$3, _9$$3, _2$$4, _5$$6, _6$$7, _8$$9; + zephir_fcall_cache_entry *_3 = NULL, *_5 = NULL; + zval *width_param = NULL, *height_param = NULL, image, _0, _6, _7, _1$$3, _2$$3, _4$$3; + zend_long width, height, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expression_sub); - ZVAL_UNDEF(&field); - ZVAL_UNDEF(&fields); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&fieldSql); + ZVAL_UNDEF(&image); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_9$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_5$$6); - ZVAL_UNDEF(&_6$$7); - ZVAL_UNDEF(&_8$$9); - ZVAL_UNDEF(&escapeChar); - ZVAL_UNDEF(&bindCounts); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ZVAL(expression) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) - Z_PARAM_ARRAY(bindCounts) + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_4$$3); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_LONG(width) + Z_PARAM_LONG(height) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &expression, &escapeChar_param, &bindCounts_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!bindCounts_param) { - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); - } - ZEPHIR_INIT_VAR(&fieldSql); - ZVAL_NULL(&fieldSql); - if (Z_TYPE_P(expression) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&fields); - array_init(&fields); - zephir_is_iterable(expression, 0, "phalcon/Db/Dialect.zep", 1068); - if (Z_TYPE_P(expression) == IS_ARRAY) { - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(expression), _0$$3) - { - ZEPHIR_INIT_NVAR(&field); - ZVAL_COPY(&field, _0$$3); - if (UNEXPECTED(Z_TYPE_P(&field) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL-ORDER-BY expression", "phalcon/Db/Dialect.zep", 1049); - return; - } - zephir_array_fetch_long(&_2$$4, &field, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 1053); - ZEPHIR_CALL_METHOD(&fieldSql, this_ptr, "getsqlexpression", &_3, 0, &_2$$4, &escapeChar, &bindCounts); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&type); - _4$$4 = zephir_array_isset_long_fetch(&type, &field, 1, 0); - if (_4$$4) { - _4$$4 = !ZEPHIR_IS_STRING(&type, ""); - } - if (_4$$4) { - ZEPHIR_INIT_NVAR(&_5$$6); - ZEPHIR_CONCAT_SV(&_5$$6, " ", &type); - zephir_concat_self(&fieldSql, &_5$$6); - } - zephir_array_append(&fields, &fieldSql, PH_SEPARATE, "phalcon/Db/Dialect.zep", 1065); - } ZEND_HASH_FOREACH_END(); - } else { - ZEPHIR_CALL_METHOD(NULL, expression, "rewind", NULL, 0); - zephir_check_call_status(); - while (1) { - ZEPHIR_CALL_METHOD(&_1$$3, expression, "valid", NULL, 0); - zephir_check_call_status(); - if (!zend_is_true(&_1$$3)) { - break; - } - ZEPHIR_CALL_METHOD(&field, expression, "current", NULL, 0); - zephir_check_call_status(); - if (UNEXPECTED(Z_TYPE_P(&field) != IS_ARRAY)) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL-ORDER-BY expression", "phalcon/Db/Dialect.zep", 1049); - return; - } - zephir_array_fetch_long(&_6$$7, &field, 0, PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 1053); - ZEPHIR_CALL_METHOD(&fieldSql, this_ptr, "getsqlexpression", &_3, 50, &_6$$7, &escapeChar, &bindCounts); - zephir_check_call_status(); - ZEPHIR_OBS_NVAR(&type); - _7$$7 = zephir_array_isset_long_fetch(&type, &field, 1, 0); - if (_7$$7) { - _7$$7 = !ZEPHIR_IS_STRING(&type, ""); - } - if (_7$$7) { - ZEPHIR_INIT_NVAR(&_8$$9); - ZEPHIR_CONCAT_SV(&_8$$9, " ", &type); - zephir_concat_self(&fieldSql, &_8$$9); - } - zephir_array_append(&fields, &fieldSql, PH_SEPARATE, "phalcon/Db/Dialect.zep", 1065); - ZEPHIR_CALL_METHOD(NULL, expression, "next", NULL, 0); - zephir_check_call_status(); - } + zephir_fetch_params(1, 2, 0, &width_param, &height_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CPY_WRT(&image, &_0); + ZVAL_LONG(&_0, 0); + ZEPHIR_CALL_METHOD(NULL, &image, "setiteratorindex", NULL, 0, &_0); + zephir_check_call_status(); + while (1) { + if (!(1)) { + break; + } + ZVAL_LONG(&_1$$3, width); + ZVAL_LONG(&_2$$3, height); + ZEPHIR_CALL_METHOD(NULL, &image, "scaleimage", &_3, 0, &_1$$3, &_2$$3); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(&_4$$3, &image, "nextimage", &_5, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_4$$3)) { + break; } - ZEPHIR_INIT_NVAR(&field); - ZEPHIR_INIT_VAR(&_9$$3); - zephir_fast_join_str(&_9$$3, SL(", "), &fields); - ZEPHIR_CPY_WRT(&fields, &_9$$3); - } else { - ZEPHIR_CPY_WRT(&fields, expression); } - ZEPHIR_CONCAT_SV(return_value, "ORDER BY ", &fields); - RETURN_MM(); + ZEPHIR_CALL_METHOD(&_6, &image, "getimagewidth", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_6); + ZEPHIR_CALL_METHOD(&_7, &image, "getimageheight", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_7); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionQualified) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processRotate) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval escapeChar; - zval *expression_param = NULL, *escapeChar_param = NULL, column, domain; - zval expression; + zval *degrees_param = NULL, pixel, _0, _1, _9, _10, _11, _2$$3, _3$$3, _4$$3, _5$$3, _6$$3, _7$$3, _8$$3; + zend_long degrees, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expression); - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&domain); - ZVAL_UNDEF(&escapeChar); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 2) - Z_PARAM_ARRAY(expression) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) + ZVAL_UNDEF(&pixel); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_9); + ZVAL_UNDEF(&_10); + ZVAL_UNDEF(&_11); + ZVAL_UNDEF(&_2$$3); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(degrees) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 1, &expression_param, &escapeChar_param); - ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - zephir_memory_observe(&column); - zephir_array_fetch_string(&column, &expression, SL("name"), PH_NOISY, "phalcon/Db/Dialect.zep", 1083); - zephir_memory_observe(&domain); - if (!(zephir_array_isset_string_fetch(&domain, &expression, SL("domain"), 0))) { - ZEPHIR_INIT_NVAR(&domain); - ZVAL_NULL(&domain); + zephir_fetch_params(1, 1, 0, °rees_param); + zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_1, 0); + ZEPHIR_CALL_METHOD(NULL, &_0, "setiteratorindex", NULL, 0, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&pixel); + object_init_ex(&pixel, zephir_get_internal_ce(SL("imagickpixel"))); + ZEPHIR_CALL_METHOD(NULL, &pixel, "__construct", NULL, 0); + zephir_check_call_status(); + while (1) { + if (!(1)) { + break; + } + zephir_read_property(&_2$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_3$$3, degrees); + ZEPHIR_CALL_METHOD(NULL, &_2$$3, "rotateimage", NULL, 0, &pixel, &_3$$3); + zephir_check_call_status(); + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("width"), PH_NOISY_CC | PH_READONLY); + zephir_read_property(&_5$$3, this_ptr, ZEND_STRL("height"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_6$$3, 0); + ZVAL_LONG(&_7$$3, 0); + ZEPHIR_CALL_METHOD(NULL, &_3$$3, "setimagepage", NULL, 0, &_4$$3, &_5$$3, &_6$$3, &_7$$3); + zephir_check_call_status(); + zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_8$$3, &_6$$3, "nextimage", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_8$$3)) { + break; + } } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "preparequalified", NULL, 0, &column, &domain, &escapeChar); + zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_9, &_1, "getimagewidth", NULL, 0); zephir_check_call_status(); - RETURN_MM(); + zephir_update_property_zval(this_ptr, ZEND_STRL("width"), &_9); + zephir_read_property(&_10, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_11, &_10, "getimageheight", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("height"), &_11); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionScalar) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processSave) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval escapeChar; - zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, value, _0$$3; - zval expression, bindCounts; + zend_long quality, ZEPHIR_LAST_CALL_STATUS; + zval *file_param = NULL, *quality_param = NULL, extension, fp, _0, _1, _2, _3, _4, _5, _6, _7, _17, _8$$3, _9$$3, _10$$3, _11$$4, _12$$4, _13$$4, _14$$5, _15$$5, _16$$5; + zval file; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expression); - ZVAL_UNDEF(&bindCounts); - ZVAL_UNDEF(&value); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&escapeChar); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ARRAY(expression) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) - Z_PARAM_ARRAY(bindCounts) + ZVAL_UNDEF(&file); + ZVAL_UNDEF(&extension); + ZVAL_UNDEF(&fp); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6); + ZVAL_UNDEF(&_7); + ZVAL_UNDEF(&_17); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$3); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_11$$4); + ZVAL_UNDEF(&_12$$4); + ZVAL_UNDEF(&_13$$4); + ZVAL_UNDEF(&_14$$5); + ZVAL_UNDEF(&_15$$5); + ZVAL_UNDEF(&_16$$5); + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STR(file) + Z_PARAM_LONG(quality) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); - ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!bindCounts_param) { - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); - } else { - ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); - } - if (zephir_array_isset_string(&expression, SL("column"))) { - zephir_array_fetch_string(&_0$$3, &expression, SL("column"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 1107); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlcolumn", NULL, 44, &_0$$3); + zephir_fetch_params(1, 2, 0, &file_param, &quality_param); + zephir_get_strval(&file, file_param); + ZVAL_LONG(&_0, 4); + ZEPHIR_CALL_FUNCTION(&extension, "pathinfo", NULL, 89, &file, &_0); + zephir_check_call_status(); + zephir_read_property(&_0, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_0, "setformat", NULL, 0, &extension); + zephir_check_call_status(); + zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_1, "setimageformat", NULL, 0, &extension); + zephir_check_call_status(); + zephir_read_property(&_2, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_3, &_2, "getimagetype", NULL, 0); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &_3); + zephir_read_property(&_4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_5, &_4, "getimageformat", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_6); + ZEPHIR_CONCAT_SV(&_6, "image/", &_5); + zephir_update_property_zval(this_ptr, ZEND_STRL("mime"), &_6); + ZEPHIR_INIT_VAR(&_7); + zephir_fast_strtolower(&_7, &extension); + ZEPHIR_CPY_WRT(&extension, &_7); + do { + if (ZEPHIR_IS_STRING(&extension, "gif")) { + zephir_read_property(&_8$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_8$$3, "optimizeimagelayers", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_9$$3); + ZVAL_STRING(&_9$$3, "w"); + ZEPHIR_CALL_FUNCTION(&fp, "fopen", NULL, 140, &file, &_9$$3); + zephir_check_call_status(); + zephir_read_property(&_10$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_10$$3, "writeimagesfile", NULL, 0, &fp); + zephir_check_call_status(); + zephir_fclose(&fp); + RETURN_MM_NULL(); + } + if (ZEPHIR_IS_STRING(&extension, "jpg") || ZEPHIR_IS_STRING(&extension, "jpeg")) { + zephir_read_property(&_11$$4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_VAR(&_12$$4); + ZVAL_STRING(&_12$$4, "Imagick::COMPRESSION_JPEG"); + ZEPHIR_CALL_FUNCTION(&_13$$4, "constant", NULL, 119, &_12$$4); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &_11$$4, "setimagecompression", NULL, 0, &_13$$4); + zephir_check_call_status(); + } + } while(0); + + if (quality >= 0) { + ZVAL_LONG(&_15$$5, quality); + ZVAL_LONG(&_16$$5, 1); + ZEPHIR_CALL_METHOD(&_14$$5, this_ptr, "checkhighlow", NULL, 0, &_15$$5, &_16$$5); zephir_check_call_status(); - RETURN_MM(); - } - zephir_memory_observe(&value); - if (UNEXPECTED(!(zephir_array_isset_string_fetch(&value, &expression, SL("value"), 0)))) { - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL expression", "phalcon/Db/Dialect.zep", 1111); - return; - } - if (Z_TYPE_P(&value) == IS_ARRAY) { - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "getsqlexpression", NULL, 0, &value, &escapeChar, &bindCounts); + quality = zephir_get_numberval(&_14$$5); + zephir_read_property(&_15$$5, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_16$$5, quality); + ZEPHIR_CALL_METHOD(NULL, &_15$$5, "setimagecompressionquality", NULL, 0, &_16$$5); zephir_check_call_status(); - RETURN_MM(); } - RETURN_CCTOR(&value); + zephir_read_property(&_17, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(NULL, &_17, "writeimage", NULL, 0, &file); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionUnaryOperations) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processSharpen) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval escapeChar; - zval *expression_param = NULL, *escapeChar_param = NULL, *bindCounts_param = NULL, left, right, _0$$3, _1$$3, _2$$4, _3$$4; - zval expression, bindCounts; + zval *amount_param = NULL, _0, _1, _2, _3$$3, _4$$3, _5$$3, _6$$3; + zend_long amount, ZEPHIR_LAST_CALL_STATUS; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expression); - ZVAL_UNDEF(&bindCounts); - ZVAL_UNDEF(&left); - ZVAL_UNDEF(&right); - ZVAL_UNDEF(&_0$$3); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$4); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&escapeChar); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ARRAY(expression) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) - Z_PARAM_ARRAY(bindCounts) + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$3); + ZVAL_UNDEF(&_4$$3); + ZVAL_UNDEF(&_5$$3); + ZVAL_UNDEF(&_6$$3); + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(amount) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &expression_param, &escapeChar_param, &bindCounts_param); - ZEPHIR_OBS_COPY_OR_DUP(&expression, expression_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!bindCounts_param) { - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); + zephir_fetch_params(1, 1, 0, &amount_param); + ZEPHIR_INIT_VAR(&_0); + if (amount < 5) { + ZEPHIR_INIT_NVAR(&_0); + ZVAL_LONG(&_0, 5); } else { - ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); + ZEPHIR_INIT_NVAR(&_0); + ZVAL_LONG(&_0, amount); } - zephir_memory_observe(&left); - if (zephir_array_isset_string_fetch(&left, &expression, SL("left"), 0)) { - ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "getsqlexpression", NULL, 0, &left, &escapeChar, &bindCounts); + amount = zephir_get_numberval(&_0); + amount = (long) (zephir_safe_div_long_long(((amount * 3.0)), 100)); + zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_2, 0); + ZEPHIR_CALL_METHOD(NULL, &_1, "setiteratorindex", NULL, 0, &_2); + zephir_check_call_status(); + while (1) { + if (!(1)) { + break; + } + zephir_read_property(&_3$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_4$$3, 0); + ZVAL_LONG(&_5$$3, amount); + ZEPHIR_CALL_METHOD(NULL, &_3$$3, "sharpenimage", NULL, 0, &_4$$3, &_5$$3); zephir_check_call_status(); - zephir_array_fetch_string(&_1$$3, &expression, SL("op"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 1138); - ZEPHIR_CONCAT_VSV(return_value, &_0$$3, " ", &_1$$3); - RETURN_MM(); - } - zephir_memory_observe(&right); - if (zephir_array_isset_string_fetch(&right, &expression, SL("right"), 0)) { - zephir_array_fetch_string(&_2$$4, &expression, SL("op"), PH_NOISY | PH_READONLY, "phalcon/Db/Dialect.zep", 1145); - ZEPHIR_CALL_METHOD(&_3$$4, this_ptr, "getsqlexpression", NULL, 50, &right, &escapeChar, &bindCounts); + zephir_read_property(&_4$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_6$$3, &_4$$3, "nextimage", NULL, 0); zephir_check_call_status(); - ZEPHIR_CONCAT_VSV(return_value, &_2$$4, " ", &_3$$4); - RETURN_MM(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_6$$3)) { + break; + } } - ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "Invalid SQL-unary expression", "phalcon/Db/Dialect.zep", 1148); - return; + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, getSqlExpressionWhere) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processText) { + zend_bool _7$$8, _9$$8, _10$$8, _11$$8, _12$$11, _14$$11, _15$$11, _16$$11; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval bindCounts; - zval escapeChar; - zval *expression, expression_sub, *escapeChar_param = NULL, *bindCounts_param = NULL, whereSql; + zend_long opacity, red, green, blue, size, ZEPHIR_LAST_CALL_STATUS; + zval *text_param = NULL, *offsetX = NULL, offsetX_sub, *offsetY = NULL, offsetY_sub, *opacity_param = NULL, *red_param = NULL, *green_param = NULL, *blue_param = NULL, *size_param = NULL, *fontFile_param = NULL, color, draw, gravity, x, y, _0, _1, _2, _3, _4$$4, _5$$5, _6$$7, _8$$8, _13$$11, _17$$12, _18$$14, _19$$14, _20$$14; + zval text, fontFile; zval *this_ptr = getThis(); - ZVAL_UNDEF(&expression_sub); - ZVAL_UNDEF(&whereSql); - ZVAL_UNDEF(&escapeChar); - ZVAL_UNDEF(&bindCounts); + ZVAL_UNDEF(&text); + ZVAL_UNDEF(&fontFile); + ZVAL_UNDEF(&offsetX_sub); + ZVAL_UNDEF(&offsetY_sub); + ZVAL_UNDEF(&color); + ZVAL_UNDEF(&draw); + ZVAL_UNDEF(&gravity); + ZVAL_UNDEF(&x); + ZVAL_UNDEF(&y); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4$$4); + ZVAL_UNDEF(&_5$$5); + ZVAL_UNDEF(&_6$$7); + ZVAL_UNDEF(&_8$$8); + ZVAL_UNDEF(&_13$$11); + ZVAL_UNDEF(&_17$$12); + ZVAL_UNDEF(&_18$$14); + ZVAL_UNDEF(&_19$$14); + ZVAL_UNDEF(&_20$$14); bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_ZVAL(expression) + ZEND_PARSE_PARAMETERS_START(8, 9) + Z_PARAM_STR(text) + Z_PARAM_ZVAL(offsetX) + Z_PARAM_ZVAL(offsetY) + Z_PARAM_LONG(opacity) + Z_PARAM_LONG(red) + Z_PARAM_LONG(green) + Z_PARAM_LONG(blue) + Z_PARAM_LONG(size) Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(escapeChar) - Z_PARAM_ARRAY(bindCounts) + Z_PARAM_STR_OR_NULL(fontFile) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &expression, &escapeChar_param, &bindCounts_param); - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!bindCounts_param) { - ZEPHIR_INIT_VAR(&bindCounts); - array_init(&bindCounts); + zephir_fetch_params(1, 8, 1, &text_param, &offsetX, &offsetY, &opacity_param, &red_param, &green_param, &blue_param, &size_param, &fontFile_param); + zephir_get_strval(&text, text_param); + ZEPHIR_SEPARATE_PARAM(offsetX); + ZEPHIR_SEPARATE_PARAM(offsetY); + if (!fontFile_param) { + ZEPHIR_INIT_VAR(&fontFile); } else { - ZEPHIR_OBS_COPY_OR_DUP(&bindCounts, bindCounts_param); + zephir_get_strval(&fontFile, fontFile_param); } - if (Z_TYPE_P(expression) == IS_ARRAY) { - ZEPHIR_CALL_METHOD(&whereSql, this_ptr, "getsqlexpression", NULL, 0, expression, &escapeChar, &bindCounts); + opacity = (long) (zephir_safe_div_long_long(opacity, 100)); + ZEPHIR_INIT_VAR(&draw); + object_init_ex(&draw, zephir_get_internal_ce(SL("imagickdraw"))); + ZEPHIR_CALL_METHOD(NULL, &draw, "__construct", NULL, 0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "rgb(%d, %d, %d)"); + ZVAL_LONG(&_1, red); + ZVAL_LONG(&_2, green); + ZVAL_LONG(&_3, blue); + ZEPHIR_CALL_FUNCTION(&color, "sprintf", NULL, 117, &_0, &_1, &_2, &_3); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_0); + object_init_ex(&_0, zephir_get_internal_ce(SL("imagickpixel"))); + ZEPHIR_CALL_METHOD(NULL, &_0, "__construct", NULL, 0, &color); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &draw, "setfillcolor", NULL, 0, &_0); + zephir_check_call_status(); + if (Z_TYPE_P(&fontFile) != IS_NULL) { + ZEPHIR_CALL_METHOD(NULL, &draw, "setfont", NULL, 0, &fontFile); zephir_check_call_status(); - } else { - ZEPHIR_CPY_WRT(&whereSql, expression); } - ZEPHIR_CONCAT_SV(return_value, "WHERE ", &whereSql); - RETURN_MM(); -} - -static PHP_METHOD(Phalcon_Db_Dialect, prepareColumnAlias) -{ - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *qualified_param = NULL, *alias_param = NULL, *escapeChar_param = NULL, _0$$3; - zval qualified, alias, escapeChar; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&qualified); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&escapeChar); - ZVAL_UNDEF(&_0$$3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(qualified) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(alias) - Z_PARAM_STR_OR_NULL(escapeChar) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &qualified_param, &alias_param, &escapeChar_param); - if (UNEXPECTED(Z_TYPE_P(qualified_param) != IS_STRING && Z_TYPE_P(qualified_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'qualified' must be of the type string")); - RETURN_MM_NULL(); + if (size) { + ZVAL_LONG(&_4$$4, size); + ZEPHIR_CALL_METHOD(NULL, &draw, "setfontsize", NULL, 0, &_4$$4); + zephir_check_call_status(); } - if (EXPECTED(Z_TYPE_P(qualified_param) == IS_STRING)) { - zephir_get_strval(&qualified, qualified_param); - } else { - ZEPHIR_INIT_VAR(&qualified); + if (opacity) { + ZVAL_LONG(&_5$$5, opacity); + ZEPHIR_CALL_METHOD(NULL, &draw, "setfillopacity", NULL, 0, &_5$$5); + zephir_check_call_status(); } - if (!alias_param) { - ZEPHIR_INIT_VAR(&alias); - } else { - zephir_get_strval(&alias, alias_param); + ZEPHIR_INIT_VAR(&gravity); + ZVAL_NULL(&gravity); + if (((Z_TYPE_P(offsetX) == IS_TRUE || Z_TYPE_P(offsetX) == IS_FALSE) == 1)) { + if (((Z_TYPE_P(offsetY) == IS_TRUE || Z_TYPE_P(offsetY) == IS_FALSE) == 1)) { + ZEPHIR_INIT_NVAR(offsetX); + ZVAL_LONG(offsetX, 0); + ZEPHIR_INIT_NVAR(offsetY); + ZVAL_LONG(offsetY, 0); + ZEPHIR_INIT_VAR(&_6$$7); + ZVAL_STRING(&_6$$7, "Imagick::GRAVITY_CENTER"); + ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_6$$7); + zephir_check_call_status(); + } else if (Z_TYPE_P(offsetY) == IS_LONG) { + ZEPHIR_INIT_VAR(&y); + ZVAL_LONG(&y, zephir_get_intval(offsetY)); + _7$$8 = ZEPHIR_IS_TRUE_IDENTICAL(offsetX); + if (_7$$8) { + _7$$8 = ZEPHIR_LT_LONG(&y, 0); + } + if (_7$$8) { + ZEPHIR_INIT_VAR(&_8$$8); + ZVAL_STRING(&_8$$8, "Imagick::GRAVITY_SOUTHEAST"); + ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_8$$8); + zephir_check_call_status(); + } else { + } + _9$$8 = ZEPHIR_IS_TRUE_IDENTICAL(offsetX); + if (_9$$8) { + _9$$8 = ZEPHIR_GE_LONG(&y, 0); + } + if (_9$$8) { + ZEPHIR_INIT_NVAR(&_8$$8); + ZVAL_STRING(&_8$$8, "Imagick::GRAVITY_NORTHEAST"); + ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_8$$8); + zephir_check_call_status(); + } else { + } + _10$$8 = !ZEPHIR_IS_TRUE_IDENTICAL(offsetX); + if (_10$$8) { + _10$$8 = ZEPHIR_LT_LONG(&y, 0); + } + if (_10$$8) { + ZEPHIR_INIT_NVAR(&_8$$8); + ZVAL_STRING(&_8$$8, "Imagick::GRAVITY_SOUTH"); + ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_8$$8); + zephir_check_call_status(); + } else { + } + _11$$8 = !ZEPHIR_IS_TRUE_IDENTICAL(offsetX); + if (_11$$8) { + _11$$8 = ZEPHIR_GE_LONG(&y, 0); + } + if (_11$$8) { + ZEPHIR_INIT_NVAR(&_8$$8); + ZVAL_STRING(&_8$$8, "Imagick::GRAVITY_NORTH"); + ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_8$$8); + zephir_check_call_status(); + } else { + } + ZEPHIR_INIT_NVAR(offsetX); + ZVAL_LONG(offsetX, 0); + if (ZEPHIR_LT_LONG(&y, 0)) { + ZEPHIR_INIT_NVAR(offsetY); + ZVAL_LONG(offsetY, (zephir_get_numberval(&y) * -1)); + } else { + } + } + } else if (Z_TYPE_P(offsetX) == IS_LONG) { + ZEPHIR_INIT_VAR(&x); + ZVAL_LONG(&x, zephir_get_intval(offsetX)); + if (zephir_is_true(offsetX)) { + if (((Z_TYPE_P(offsetY) == IS_TRUE || Z_TYPE_P(offsetY) == IS_FALSE) == 1)) { + _12$$11 = ZEPHIR_IS_TRUE_IDENTICAL(offsetY); + if (_12$$11) { + _12$$11 = ZEPHIR_LT_LONG(&x, 0); + } + if (_12$$11) { + ZEPHIR_INIT_VAR(&_13$$11); + ZVAL_STRING(&_13$$11, "Imagick::GRAVITY_SOUTHEAST"); + ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_13$$11); + zephir_check_call_status(); + } else { + } + _14$$11 = ZEPHIR_IS_TRUE_IDENTICAL(offsetY); + if (_14$$11) { + _14$$11 = ZEPHIR_GE_LONG(&x, 0); + } + if (_14$$11) { + ZEPHIR_INIT_NVAR(&_13$$11); + ZVAL_STRING(&_13$$11, "Imagick::GRAVITY_SOUTH"); + ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_13$$11); + zephir_check_call_status(); + } else { + } + _15$$11 = !ZEPHIR_IS_TRUE_IDENTICAL(offsetY); + if (_15$$11) { + _15$$11 = ZEPHIR_LT_LONG(&x, 0); + } + if (_15$$11) { + ZEPHIR_INIT_NVAR(&_13$$11); + ZVAL_STRING(&_13$$11, "Imagick::GRAVITY_EAST"); + ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_13$$11); + zephir_check_call_status(); + } else { + } + _16$$11 = !ZEPHIR_IS_TRUE_IDENTICAL(offsetY); + if (_16$$11) { + _16$$11 = ZEPHIR_GE_LONG(&x, 0); + } + if (_16$$11) { + ZEPHIR_INIT_NVAR(&_13$$11); + ZVAL_STRING(&_13$$11, "Imagick::GRAVITY_WEST"); + ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_13$$11); + zephir_check_call_status(); + } else { + } + ZEPHIR_INIT_NVAR(offsetY); + ZVAL_LONG(offsetY, 0); + if (ZEPHIR_LT_LONG(&x, 0)) { + ZEPHIR_INIT_NVAR(offsetX); + ZVAL_LONG(offsetX, (zephir_get_numberval(&x) * -1)); + } else { + } + } else if (Z_TYPE_P(offsetY) == IS_LONG) { + ZEPHIR_INIT_NVAR(&y); + ZVAL_LONG(&y, zephir_get_intval(offsetY)); + if (ZEPHIR_LT_LONG(&x, 0)) { + ZEPHIR_INIT_NVAR(offsetX); + ZVAL_LONG(offsetX, (zephir_get_numberval(&x) * -1)); + } else { + ZEPHIR_INIT_NVAR(offsetX); + ZVAL_LONG(offsetX, 0); + } + if (ZEPHIR_LT_LONG(&y, 0)) { + ZEPHIR_INIT_NVAR(offsetY); + ZVAL_LONG(offsetY, (zephir_get_numberval(&y) * -1)); + } else { + } + if (ZEPHIR_LT_LONG(&y, 0)) { + ZEPHIR_INIT_VAR(&_17$$12); + ZVAL_STRING(&_17$$12, "Imagick::GRAVITY_SOUTHEAST"); + ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_17$$12); + zephir_check_call_status(); + } else { + } + if (ZEPHIR_GE_LONG(&y, 0)) { + ZEPHIR_INIT_NVAR(&_17$$12); + ZVAL_STRING(&_17$$12, "Imagick::GRAVITY_NORTHEAST"); + ZEPHIR_CALL_FUNCTION(&gravity, "constant", NULL, 119, &_17$$12); + zephir_check_call_status(); + } else { + } + } + } } - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); + if (Z_TYPE_P(&gravity) != IS_NULL) { + ZEPHIR_CALL_METHOD(NULL, &draw, "setgravity", NULL, 0, &gravity); + zephir_check_call_status(); } - if (!ZEPHIR_IS_STRING(&alias, "")) { - ZEPHIR_CALL_METHOD(&_0$$3, this_ptr, "escape", NULL, 57, &alias, &escapeChar); + zephir_read_property(&_1, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_2, 0); + ZEPHIR_CALL_METHOD(NULL, &_1, "setiteratorindex", NULL, 0, &_2); + zephir_check_call_status(); + while (1) { + if (!(1)) { + break; + } + zephir_read_property(&_18$$14, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_19$$14, 0); + ZEPHIR_CALL_METHOD(NULL, &_18$$14, "annotateimage", NULL, 0, &draw, offsetX, offsetY, &_19$$14, &text); zephir_check_call_status(); - ZEPHIR_CONCAT_VSV(return_value, &qualified, " AS ", &_0$$3); - RETURN_MM(); + zephir_read_property(&_19$$14, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_20$$14, &_19$$14, "nextimage", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_20$$14)) { + break; + } } - RETURN_CTOR(&qualified); + ZEPHIR_CALL_METHOD(NULL, &draw, "destroy", NULL, 0); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, prepareTable) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, processWatermark) { zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval *table_param = NULL, *schema_param = NULL, *alias_param = NULL, *escapeChar_param = NULL, _0, _1$$3, _2$$3, _3$$4, _4$$4; - zval table, schema, alias, escapeChar; + zend_long offsetX, offsetY, opacity, ZEPHIR_LAST_CALL_STATUS; + zval *image, image_sub, *offsetX_param = NULL, *offsetY_param = NULL, *opacity_param = NULL, result, watermark, _0, _1, _2, _3, _4, _5, _6$$3, _7$$3, _8$$3, _9$$3, _10$$3, _11$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&table); - ZVAL_UNDEF(&schema); - ZVAL_UNDEF(&alias); - ZVAL_UNDEF(&escapeChar); + ZVAL_UNDEF(&image_sub); + ZVAL_UNDEF(&result); + ZVAL_UNDEF(&watermark); ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - ZVAL_UNDEF(&_2$$3); - ZVAL_UNDEF(&_3$$4); - ZVAL_UNDEF(&_4$$4); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 4) - Z_PARAM_STR(table) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(schema) - Z_PARAM_STR_OR_NULL(alias) - Z_PARAM_STR_OR_NULL(escapeChar) + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_4); + ZVAL_UNDEF(&_5); + ZVAL_UNDEF(&_6$$3); + ZVAL_UNDEF(&_7$$3); + ZVAL_UNDEF(&_8$$3); + ZVAL_UNDEF(&_9$$3); + ZVAL_UNDEF(&_10$$3); + ZVAL_UNDEF(&_11$$3); + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_OBJECT_OF_CLASS(image, phalcon_image_adapter_adapterinterface_ce) + Z_PARAM_LONG(offsetX) + Z_PARAM_LONG(offsetY) + Z_PARAM_LONG(opacity) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 3, &table_param, &schema_param, &alias_param, &escapeChar_param); - if (UNEXPECTED(Z_TYPE_P(table_param) != IS_STRING && Z_TYPE_P(table_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'table' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(table_param) == IS_STRING)) { - zephir_get_strval(&table, table_param); - } else { - ZEPHIR_INIT_VAR(&table); - } - if (!schema_param) { - ZEPHIR_INIT_VAR(&schema); - } else { - zephir_get_strval(&schema, schema_param); - } - if (!alias_param) { - ZEPHIR_INIT_VAR(&alias); - } else { - zephir_get_strval(&alias, alias_param); - } - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - ZEPHIR_CALL_METHOD(&_0, this_ptr, "escape", NULL, 57, &table, &escapeChar); + zephir_fetch_params(1, 4, 0, &image, &offsetX_param, &offsetY_param, &opacity_param); + opacity = (long) (zephir_safe_div_long_long(opacity, 100)); + ZEPHIR_INIT_VAR(&watermark); + object_init_ex(&watermark, zephir_get_internal_ce(SL("imagick"))); + ZEPHIR_CALL_METHOD(NULL, &watermark, "__construct", NULL, 0); zephir_check_call_status(); - zephir_get_strval(&table, &_0); - if (!ZEPHIR_IS_STRING(&schema, "")) { - ZEPHIR_CALL_METHOD(&_1$$3, this_ptr, "escapeschema", NULL, 67, &schema, &escapeChar); + ZEPHIR_CALL_METHOD(&_0, image, "render", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &watermark, "readimageblob", NULL, 0, &_0); + zephir_check_call_status(); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "Imagick::EVALUATE_MULTIPLY"); + ZEPHIR_CALL_FUNCTION(&_2, "constant", NULL, 119, &_1); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_1); + ZVAL_STRING(&_1, "Imagick::CHANNEL_ALPHA"); + ZEPHIR_CALL_FUNCTION(&_3, "constant", NULL, 119, &_1); + zephir_check_call_status(); + ZVAL_LONG(&_4, opacity); + ZEPHIR_CALL_METHOD(NULL, &watermark, "evaluateimage", NULL, 0, &_2, &_4, &_3); + zephir_check_call_status(); + zephir_read_property(&_4, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZVAL_LONG(&_5, 0); + ZEPHIR_CALL_METHOD(NULL, &_4, "setiteratorindex", NULL, 0, &_5); + zephir_check_call_status(); + while (1) { + if (!(1)) { + break; + } + zephir_read_property(&_6$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_INIT_NVAR(&_7$$3); + ZVAL_STRING(&_7$$3, "Imagick::COMPOSITE_OVER"); + ZEPHIR_CALL_FUNCTION(&_8$$3, "constant", NULL, 119, &_7$$3); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_2$$3); - ZEPHIR_CONCAT_VSV(&_2$$3, &_1$$3, ".", &table); - zephir_get_strval(&table, &_2$$3); - } - if (!ZEPHIR_IS_STRING(&alias, "")) { - ZEPHIR_CALL_METHOD(&_3$$4, this_ptr, "escape", NULL, 57, &alias, &escapeChar); + ZVAL_LONG(&_9$$3, offsetX); + ZVAL_LONG(&_10$$3, offsetY); + ZEPHIR_CALL_METHOD(&result, &_6$$3, "compositeimage", NULL, 0, &watermark, &_8$$3, &_9$$3, &_10$$3); zephir_check_call_status(); - ZEPHIR_INIT_VAR(&_4$$4); - ZEPHIR_CONCAT_VSV(&_4$$4, &table, " AS ", &_3$$4); - zephir_get_strval(&table, &_4$$4); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&result)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick::compositeImage failed", "phalcon/Image/Adapter/Imagick.zep", 893); + return; + } + zephir_read_property(&_9$$3, this_ptr, ZEND_STRL("image"), PH_NOISY_CC | PH_READONLY); + ZEPHIR_CALL_METHOD(&_11$$3, &_9$$3, "nextimage", NULL, 0); + zephir_check_call_status(); + if (!ZEPHIR_IS_TRUE_IDENTICAL(&_11$$3)) { + break; + } } - RETURN_CTOR(&table); + ZEPHIR_CALL_METHOD(NULL, &watermark, "clear", NULL, 0); + zephir_check_call_status(); + ZEPHIR_CALL_METHOD(NULL, &watermark, "destroy", NULL, 0); + zephir_check_call_status(); + ZEPHIR_MM_RESTORE(); } -static PHP_METHOD(Phalcon_Db_Dialect, prepareQualified) +static PHP_METHOD(Phalcon_Image_Adapter_Imagick, check) { + zval _0, _1, _2, _3$$4, _4$$4; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *column_param = NULL, *domain_param = NULL, *escapeChar_param = NULL; - zval column, domain, escapeChar, _0$$3; zval *this_ptr = getThis(); - ZVAL_UNDEF(&column); - ZVAL_UNDEF(&domain); - ZVAL_UNDEF(&escapeChar); - ZVAL_UNDEF(&_0$$3); - bool is_null_true = 1; - ZEND_PARSE_PARAMETERS_START(1, 3) - Z_PARAM_STR(column) - Z_PARAM_OPTIONAL - Z_PARAM_STR_OR_NULL(domain) - Z_PARAM_STR_OR_NULL(escapeChar) - ZEND_PARSE_PARAMETERS_END(); + ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3$$4); + ZVAL_UNDEF(&_4$$4); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 1, 2, &column_param, &domain_param, &escapeChar_param); - if (UNEXPECTED(Z_TYPE_P(column_param) != IS_STRING && Z_TYPE_P(column_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'column' must be of the type string")); - RETURN_MM_NULL(); - } - if (EXPECTED(Z_TYPE_P(column_param) == IS_STRING)) { - zephir_get_strval(&column, column_param); - } else { - ZEPHIR_INIT_VAR(&column); - } - if (!domain_param) { - ZEPHIR_INIT_VAR(&domain); - } else { - zephir_get_strval(&domain, domain_param); - } - if (!escapeChar_param) { - ZEPHIR_INIT_VAR(&escapeChar); - } else { - zephir_get_strval(&escapeChar, escapeChar_param); - } - if (!ZEPHIR_IS_STRING(&domain, "")) { - ZEPHIR_INIT_VAR(&_0$$3); - ZEPHIR_CONCAT_VSV(&_0$$3, &domain, ".", &column); - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "escape", NULL, 57, &_0$$3, &escapeChar); - zephir_check_call_status(); - RETURN_MM(); + + ZEPHIR_INIT_VAR(&_0); + ZVAL_STRING(&_0, "imagick"); + if (1 != zephir_class_exists(&_0, 1)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_image_exception_ce, "Imagick is not installed, or the extension is not loaded", "phalcon/Image/Adapter/Imagick.zep", 916); + return; } - ZEPHIR_RETURN_CALL_METHOD(this_ptr, "escape", NULL, 57, &column, &escapeChar); + ZEPHIR_INIT_VAR(&_1); + ZVAL_STRING(&_1, "Imagick::IMAGICK_EXTNUM"); + ZEPHIR_CALL_FUNCTION(&_2, "defined", NULL, 118, &_1); zephir_check_call_status(); - RETURN_MM(); -} - -zend_object *zephir_init_properties_Phalcon_Db_Dialect(zend_class_entry *class_type) -{ - zval _0, _1$$3; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - ZVAL_UNDEF(&_0); - ZVAL_UNDEF(&_1$$3); - - - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - { - zval local_this_ptr, *this_ptr = &local_this_ptr; - ZEPHIR_CREATE_OBJECT(this_ptr, class_type); - zephir_read_property_ex(&_0, this_ptr, ZEND_STRL("customFunctions"), PH_NOISY_CC | PH_READONLY); - if (Z_TYPE_P(&_0) == IS_NULL) { - ZEPHIR_INIT_VAR(&_1$$3); - array_init(&_1$$3); - zephir_update_property_zval_ex(this_ptr, ZEND_STRL("customFunctions"), &_1$$3); - } - ZEPHIR_MM_RESTORE(); - return Z_OBJ_P(this_ptr); + if (zephir_is_true(&_2)) { + ZEPHIR_INIT_VAR(&_3$$4); + ZVAL_STRING(&_3$$4, "Imagick::IMAGICK_EXTNUM"); + ZEPHIR_CALL_FUNCTION(&_4$$4, "constant", NULL, 119, &_3$$4); + zephir_check_call_status(); + zephir_update_property_zval(this_ptr, ZEND_STRL("version"), &_4$$4); } + ZEPHIR_MM_RESTORE(); } @@ -165247,115 +166657,9 @@ zend_object *zephir_init_properties_Phalcon_Db_Dialect(zend_class_entry *class_t -ZEPHIR_INIT_CLASS(Phalcon_Db_DialectInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Db, DialectInterface, phalcon, db_dialectinterface, phalcon_db_dialectinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, addColumn); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, addForeignKey); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, addIndex); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, addPrimaryKey); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, createSavepoint); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, createTable); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, createView); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, describeColumns); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, describeIndexes); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, describeReferences); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, dropColumn); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, dropForeignKey); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, dropIndex); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, dropPrimaryKey); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, dropTable); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, dropView); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, forUpdate); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, getColumnDefinition); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, getColumnList); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, getCustomFunctions); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, getSqlExpression); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, limit); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, listTables); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, modifyColumn); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, registerCustomFunction); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, releaseSavepoint); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, rollbackSavepoint); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, select); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, sharedLock); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, supportsReleaseSavepoints); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, supportsSavepoints); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, tableExists); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, tableOptions); -ZEPHIR_DOC_METHOD(Phalcon_Db_DialectInterface, viewExists); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Db_Enum) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Db, Enum, phalcon, db_enum, NULL, 0); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_ASSOC"), 2); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_BOTH"), 4); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_BOUND"), 6); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_CLASS"), 8); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_CLASSTYPE"), 262144); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_COLUMN"), 7); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_FUNC"), 10); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_GROUP"), 65536); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_INTO"), 9); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_KEY_PAIR"), 12); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_LAZY"), 1); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_NAMED"), 11); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_NUM"), 3); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_OBJ"), 5); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_ORI_NEXT"), 0); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_PROPS_LATE"), 1048576); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_SERIALIZE"), 524288); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_UNIQUE"), 196608); - - zephir_declare_class_constant_long(phalcon_db_enum_ce, SL("FETCH_DEFAULT"), 0); - - return SUCCESS; -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Db_Exception) +ZEPHIR_INIT_CLASS(Phalcon_Tag_Exception) { - ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Db, Exception, phalcon, db_exception, zend_ce_exception, NULL, 0); + ZEPHIR_REGISTER_CLASS_EX(Phalcon\\Tag, Exception, phalcon, tag_exception, zend_ce_exception, NULL, 0); return SUCCESS; } @@ -165370,397 +166674,602 @@ ZEPHIR_INIT_CLASS(Phalcon_Db_Exception) -ZEPHIR_INIT_CLASS(Phalcon_Db_Index) +ZEPHIR_INIT_CLASS(Phalcon_Tag_Select) { - ZEPHIR_REGISTER_CLASS(Phalcon\\Db, Index, phalcon, db_index, phalcon_db_index_method_entry, 0); + ZEPHIR_REGISTER_CLASS(Phalcon\\Tag, Select, phalcon, tag_select, phalcon_tag_select_method_entry, ZEND_ACC_EXPLICIT_ABSTRACT_CLASS); - zend_declare_property_null(phalcon_db_index_ce, SL("columns"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_db_index_ce, SL("name"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_db_index_ce, SL("type"), ZEND_ACC_PROTECTED); - zend_class_implements(phalcon_db_index_ce, 1, phalcon_db_indexinterface_ce); return SUCCESS; } -static PHP_METHOD(Phalcon_Db_Index, __construct) +static PHP_METHOD(Phalcon_Tag_Select, selectField) { + zend_bool _1$$19; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zval columns; - zval *name_param = NULL, *columns_param = NULL, *type_param = NULL; - zval name, type; - zval *this_ptr = getThis(); + zephir_fcall_cache_entry *_7 = NULL, *_11 = NULL; + zend_long ZEPHIR_LAST_CALL_STATUS; + zval *parameters, parameters_sub, *data = NULL, data_sub, __$null, params, name, id, value, useEmpty, code, emptyValue, emptyText, options, using, _2, _3, _0$$5, _4$$22, _5$$22, _6$$23, _8$$23, _9$$23, _10$$25, _12$$25, _13$$25; + ZVAL_UNDEF(¶meters_sub); + ZVAL_UNDEF(&data_sub); + ZVAL_NULL(&__$null); + ZVAL_UNDEF(¶ms); ZVAL_UNDEF(&name); - ZVAL_UNDEF(&type); - ZVAL_UNDEF(&columns); - ZEND_PARSE_PARAMETERS_START(2, 3) - Z_PARAM_STR(name) - Z_PARAM_ARRAY(columns) + ZVAL_UNDEF(&id); + ZVAL_UNDEF(&value); + ZVAL_UNDEF(&useEmpty); + ZVAL_UNDEF(&code); + ZVAL_UNDEF(&emptyValue); + ZVAL_UNDEF(&emptyText); + ZVAL_UNDEF(&options); + ZVAL_UNDEF(&using); + ZVAL_UNDEF(&_2); + ZVAL_UNDEF(&_3); + ZVAL_UNDEF(&_0$$5); + ZVAL_UNDEF(&_4$$22); + ZVAL_UNDEF(&_5$$22); + ZVAL_UNDEF(&_6$$23); + ZVAL_UNDEF(&_8$$23); + ZVAL_UNDEF(&_9$$23); + ZVAL_UNDEF(&_10$$25); + ZVAL_UNDEF(&_12$$25); + ZVAL_UNDEF(&_13$$25); + bool is_null_true = 1; + ZEND_PARSE_PARAMETERS_START(1, 2) + Z_PARAM_ZVAL(parameters) Z_PARAM_OPTIONAL - Z_PARAM_STR(type) + Z_PARAM_ZVAL_OR_NULL(data) ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 2, 1, &name_param, &columns_param, &type_param); - if (UNEXPECTED(Z_TYPE_P(name_param) != IS_STRING && Z_TYPE_P(name_param) != IS_NULL)) { - zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'name' must be of the type string")); - RETURN_MM_NULL(); + zephir_fetch_params(1, 1, 1, ¶meters, &data); + if (!data) { + data = &data_sub; + data = &__$null; } - if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { - zephir_get_strval(&name, name_param); + if (Z_TYPE_P(parameters) != IS_ARRAY) { + ZEPHIR_INIT_VAR(¶ms); + zephir_create_array(¶ms, 2, 0); + zephir_array_fast_append(¶ms, parameters); + zephir_array_fast_append(¶ms, data); } else { - ZEPHIR_INIT_VAR(&name); + ZEPHIR_CPY_WRT(¶ms, parameters); } - ZEPHIR_OBS_COPY_OR_DUP(&columns, columns_param); - if (!type_param) { - ZEPHIR_INIT_VAR(&type); - ZVAL_STRING(&type, ""); + zephir_memory_observe(&id); + if (!(zephir_array_isset_long_fetch(&id, ¶ms, 0, 0))) { + zephir_array_fetch_string(&_0$$5, ¶ms, SL("id"), PH_NOISY | PH_READONLY, "phalcon/Tag/Select.zep", 50); + zephir_array_update_long(¶ms, 0, &_0$$5, PH_COPY | PH_SEPARATE ZEPHIR_DEBUG_PARAMS_DUMMY); + } + if (!(zephir_memnstr_str(&id, SL("["), "phalcon/Tag/Select.zep", 56))) { + if (!(zephir_array_isset_string(¶ms, SL("id")))) { + zephir_array_update_string(¶ms, SL("id"), &id, PH_COPY | PH_SEPARATE); + } + } + zephir_memory_observe(&name); + if (!(zephir_array_isset_string_fetch(&name, ¶ms, SL("name"), 0))) { + zephir_array_update_string(¶ms, SL("name"), &id, PH_COPY | PH_SEPARATE); } else { - zephir_get_strval(&type, type_param); + if (!(zephir_is_true(&name))) { + zephir_array_update_string(¶ms, SL("name"), &id, PH_COPY | PH_SEPARATE); + } } - zephir_update_property_zval(this_ptr, ZEND_STRL("name"), &name); - zephir_update_property_zval(this_ptr, ZEND_STRL("columns"), &columns); - zephir_update_property_zval(this_ptr, ZEND_STRL("type"), &type); - ZEPHIR_MM_RESTORE(); -} - -static PHP_METHOD(Phalcon_Db_Index, getColumns) -{ - - RETURN_MEMBER(getThis(), "columns"); -} - -static PHP_METHOD(Phalcon_Db_Index, getName) -{ - - RETURN_MEMBER(getThis(), "name"); -} - -static PHP_METHOD(Phalcon_Db_Index, getType) -{ - - RETURN_MEMBER(getThis(), "type"); -} - - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Db_IndexInterface) -{ - ZEPHIR_REGISTER_INTERFACE(Phalcon\\Db, IndexInterface, phalcon, db_indexinterface, phalcon_db_indexinterface_method_entry); - - return SUCCESS; -} - -ZEPHIR_DOC_METHOD(Phalcon_Db_IndexInterface, getColumns); -ZEPHIR_DOC_METHOD(Phalcon_Db_IndexInterface, getName); -ZEPHIR_DOC_METHOD(Phalcon_Db_IndexInterface, getType); - - - -#ifdef HAVE_CONFIG_H -#endif - - - - - -ZEPHIR_INIT_CLASS(Phalcon_Db_Profiler) -{ - ZEPHIR_REGISTER_CLASS(Phalcon\\Db, Profiler, phalcon, db_profiler, phalcon_db_profiler_method_entry, 0); - - zend_declare_property_null(phalcon_db_profiler_ce, SL("activeProfile"), ZEND_ACC_PROTECTED); - zend_declare_property_null(phalcon_db_profiler_ce, SL("allProfiles"), ZEND_ACC_PROTECTED); - zend_declare_property_long(phalcon_db_profiler_ce, SL("totalNanoseconds"), 0, ZEND_ACC_PROTECTED); - return SUCCESS; -} - -static PHP_METHOD(Phalcon_Db_Profiler, getLastProfile) -{ - - RETURN_MEMBER(getThis(), "activeProfile"); -} - -static PHP_METHOD(Phalcon_Db_Profiler, getNumberTotalStatements) -{ - zval _0; - zval *this_ptr = getThis(); - - ZVAL_UNDEF(&_0); - zephir_read_property(&_0, this_ptr, ZEND_STRL("allProfiles"), PH_NOISY_CC | PH_READONLY); - RETURN_LONG(zephir_fast_count_int(&_0)); -} - -static PHP_METHOD(Phalcon_Db_Profiler, getTotalElapsedNanoseconds) -{ - - RETURN_MEMBER(getThis(), "totalNanoseconds"); + zephir_memory_observe(&value); + if (!(zephir_array_isset_string_fetch(&value, ¶ms, SL("value"), 0))) { + ZEPHIR_CALL_CE_STATIC(&value, phalcon_tag_ce, "getvalue", NULL, 0, &id, ¶ms); + zephir_check_call_status(); + } else { + zephir_array_unset_string(¶ms, SL("value"), PH_SEPARATE); + } + zephir_memory_observe(&useEmpty); + if (zephir_array_isset_string_fetch(&useEmpty, ¶ms, SL("useEmpty"), 0)) { + zephir_memory_observe(&emptyValue); + if (!(zephir_array_isset_string_fetch(&emptyValue, ¶ms, SL("emptyValue"), 0))) { + ZEPHIR_INIT_NVAR(&emptyValue); + ZVAL_STRING(&emptyValue, ""); + } else { + zephir_array_unset_string(¶ms, SL("emptyValue"), PH_SEPARATE); + } + zephir_memory_observe(&emptyText); + if (!(zephir_array_isset_string_fetch(&emptyText, ¶ms, SL("emptyText"), 0))) { + ZEPHIR_INIT_NVAR(&emptyText); + ZVAL_STRING(&emptyText, "Choose..."); + } else { + zephir_array_unset_string(¶ms, SL("emptyText"), PH_SEPARATE); + } + zephir_array_unset_string(¶ms, SL("useEmpty"), PH_SEPARATE); + } + zephir_memory_observe(&options); + if (!(zephir_array_isset_long_fetch(&options, ¶ms, 1, 0))) { + ZEPHIR_CPY_WRT(&options, data); + } + if (Z_TYPE_P(&options) == IS_OBJECT) { + zephir_memory_observe(&using); + if (UNEXPECTED(!(zephir_array_isset_string_fetch(&using, ¶ms, SL("using"), 0)))) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_tag_exception_ce, "The 'using' parameter is required", "phalcon/Tag/Select.zep", 101); + return; + } + _1$$19 = Z_TYPE_P(&using) != IS_ARRAY; + if (_1$$19) { + _1$$19 = Z_TYPE_P(&using) != IS_OBJECT; + } + if (UNEXPECTED(_1$$19)) { + ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_tag_exception_ce, "The 'using' parameter should be an array", "phalcon/Tag/Select.zep", 107); + return; + } + } + zephir_array_unset_string(¶ms, SL("using"), PH_SEPARATE); + ZEPHIR_INIT_VAR(&_3); + ZVAL_STRING(&_3, "", &_3); + if (zephir_is_true(&useEmpty)) { + ZEPHIR_INIT_VAR(&_4$$22); + ZEPHIR_GET_CONSTANT(&_4$$22, "PHP_EOL"); + ZEPHIR_INIT_VAR(&_5$$22); + ZEPHIR_CONCAT_SVSVSV(&_5$$22, "\t", &_4$$22); + zephir_concat_self(&code, &_5$$22); + } + if (Z_TYPE_P(&options) == IS_OBJECT) { + ZEPHIR_INIT_VAR(&_8$$23); + ZEPHIR_GET_CONSTANT(&_8$$23, "PHP_EOL"); + ZEPHIR_INIT_VAR(&_9$$23); + ZEPHIR_CONCAT_SV(&_9$$23, "", &_8$$23); + ZEPHIR_CALL_SELF(&_6$$23, "optionsfromresultset", &_7, 0, &options, &using, &value, &_9$$23); + zephir_check_call_status(); + zephir_concat_self(&code, &_6$$23); + } else { + if (Z_TYPE_P(&options) == IS_ARRAY) { + ZEPHIR_INIT_VAR(&_12$$25); + ZEPHIR_GET_CONSTANT(&_12$$25, "PHP_EOL"); + ZEPHIR_INIT_VAR(&_13$$25); + ZEPHIR_CONCAT_SV(&_13$$25, "", &_12$$25); + ZEPHIR_CALL_SELF(&_10$$25, "optionsfromarray", &_11, 0, &options, &value, &_13$$25); + zephir_check_call_status(); + zephir_concat_self(&code, &_10$$25); + } + } + zephir_concat_self_str(&code, SL("")); + RETURN_CCTOR(&code); } -static PHP_METHOD(Phalcon_Db_Profiler, getTotalElapsedMilliseconds) +static PHP_METHOD(Phalcon_Tag_Select, optionsFromArray) { - zval _0; + zend_string *_3; + zend_ulong _2; zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; + zephir_fcall_cache_entry *_4 = NULL, *_7 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; - zval *this_ptr = getThis(); + zval closeOption, _12$$8, _13$$8, _22$$16, _23$$16; + zval *data_param = NULL, *value, value_sub, *closeOption_param = NULL, strValue, strOptionValue, code, optionValue, optionText, escaped, *_0, _1, _5$$4, _6$$4, _8$$4, _9$$4, _10$$6, _11$$7, _14$$9, _15$$10, _16$$12, _17$$12, _18$$12, _19$$12, _20$$14, _21$$15, _24$$17, _25$$18; + zval data; - ZVAL_UNDEF(&_0); + ZVAL_UNDEF(&data); + ZVAL_UNDEF(&value_sub); + ZVAL_UNDEF(&strValue); + ZVAL_UNDEF(&strOptionValue); + ZVAL_UNDEF(&code); + ZVAL_UNDEF(&optionValue); + ZVAL_UNDEF(&optionText); + ZVAL_UNDEF(&escaped); + ZVAL_UNDEF(&_1); + ZVAL_UNDEF(&_5$$4); + ZVAL_UNDEF(&_6$$4); + ZVAL_UNDEF(&_8$$4); + ZVAL_UNDEF(&_9$$4); + ZVAL_UNDEF(&_10$$6); + ZVAL_UNDEF(&_11$$7); + ZVAL_UNDEF(&_14$$9); + ZVAL_UNDEF(&_15$$10); + ZVAL_UNDEF(&_16$$12); + ZVAL_UNDEF(&_17$$12); + ZVAL_UNDEF(&_18$$12); + ZVAL_UNDEF(&_19$$12); + ZVAL_UNDEF(&_20$$14); + ZVAL_UNDEF(&_21$$15); + ZVAL_UNDEF(&_24$$17); + ZVAL_UNDEF(&_25$$18); + ZVAL_UNDEF(&closeOption); + ZVAL_UNDEF(&_12$$8); + ZVAL_UNDEF(&_13$$8); + ZVAL_UNDEF(&_22$$16); + ZVAL_UNDEF(&_23$$16); + ZEND_PARSE_PARAMETERS_START(3, 3) + Z_PARAM_ARRAY(data) + Z_PARAM_ZVAL(value) + Z_PARAM_STR(closeOption) + ZEND_PARSE_PARAMETERS_END(); ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - - ZEPHIR_CALL_METHOD(&_0, this_ptr, "gettotalelapsednanoseconds", NULL, 0); - zephir_check_call_status(); - RETURN_MM_DOUBLE(zephir_safe_div_zval_long(&_0, 1000000)); + zephir_fetch_params(1, 3, 0, &data_param, &value, &closeOption_param); + zephir_get_arrval(&data, data_param); + zephir_get_strval(&closeOption, closeOption_param); + ZEPHIR_INIT_VAR(&code); + ZVAL_STRING(&code, ""); + zephir_is_iterable(&data, 0, "phalcon/Tag/Select.zep", 186); + if (Z_TYPE_P(&data) == IS_ARRAY) { + ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _2, _3, _0) + { + ZEPHIR_INIT_NVAR(&optionValue); + if (_3 != NULL) { + ZVAL_STR_COPY(&optionValue, _3); + } else { + ZVAL_LONG(&optionValue, _2); + } + ZEPHIR_INIT_NVAR(&optionText); + ZVAL_COPY(&optionText, _0); + ZEPHIR_CALL_FUNCTION(&escaped, "htmlspecialchars", &_4, 286, &optionValue); + zephir_check_call_status(); + if (Z_TYPE_P(&optionText) == IS_ARRAY) { + ZEPHIR_INIT_NVAR(&_5$$4); + ZEPHIR_GET_CONSTANT(&_5$$4, "PHP_EOL"); + ZEPHIR_CALL_SELF(&_6$$4, "optionsfromarray", &_7, 0, &optionText, value, &closeOption); + zephir_check_call_status(); + ZEPHIR_INIT_NVAR(&_8$$4); + ZEPHIR_GET_CONSTANT(&_8$$4, "PHP_EOL"); + ZEPHIR_INIT_NVAR(&_9$$4); + ZEPHIR_CONCAT_SVSVVSV(&_9$$4, "\t", &_5$$4, &_6$$4, "\t", &_8$$4); + zephir_concat_self(&code, &_9$$4); + continue; + } + if (Z_TYPE_P(value) == IS_ARRAY) { + if (zephir_fast_in_array(&optionValue, value)) { + ZEPHIR_INIT_NVAR(&_10$$6); + ZEPHIR_CONCAT_SVSVV(&_10$$6, "\t", &_16$$12, &_17$$12, "\t", &_18$$12); + zephir_concat_self(&code, &_19$$12); + continue; + } + if (Z_TYPE_P(value) == IS_ARRAY) { + if (zephir_fast_in_array(&optionValue, value)) { + ZEPHIR_INIT_NVAR(&_20$$14); + ZEPHIR_CONCAT_SVSVV(&_20$$14, "\t", &_8$$23); - ZEPHIR_CALL_SELF(&_6$$23, "optionsfromresultset", &_7, 0, &options, &using, &value, &_9$$23); - zephir_check_call_status(); - zephir_concat_self(&code, &_6$$23); - } else { - if (Z_TYPE_P(&options) == IS_ARRAY) { - ZEPHIR_INIT_VAR(&_12$$25); - ZEPHIR_GET_CONSTANT(&_12$$25, "PHP_EOL"); - ZEPHIR_INIT_VAR(&_13$$25); - ZEPHIR_CONCAT_SV(&_13$$25, "", &_12$$25); - ZEPHIR_CALL_SELF(&_10$$25, "optionsfromarray", &_11, 0, &options, &value, &_13$$25); - zephir_check_call_status(); - zephir_concat_self(&code, &_10$$25); - } - } - zephir_concat_self_str(&code, SL("")); - RETURN_CCTOR(&code); + RETURN_MM(); } -static PHP_METHOD(Phalcon_Tag_Select, optionsFromArray) -{ - zend_string *_3; - zend_ulong _2; - zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL; - zephir_fcall_cache_entry *_4 = NULL, *_7 = NULL; - zend_long ZEPHIR_LAST_CALL_STATUS; - zval closeOption, _12$$8, _13$$8, _22$$16, _23$$16; - zval *data_param = NULL, *value, value_sub, *closeOption_param = NULL, strValue, strOptionValue, code, optionValue, optionText, escaped, *_0, _1, _5$$4, _6$$4, _8$$4, _9$$4, _10$$6, _11$$7, _14$$9, _15$$10, _16$$12, _17$$12, _18$$12, _19$$12, _20$$14, _21$$15, _24$$17, _25$$18; - zval data; - ZVAL_UNDEF(&data); - ZVAL_UNDEF(&value_sub); - ZVAL_UNDEF(&strValue); - ZVAL_UNDEF(&strOptionValue); - ZVAL_UNDEF(&code); - ZVAL_UNDEF(&optionValue); - ZVAL_UNDEF(&optionText); - ZVAL_UNDEF(&escaped); - ZVAL_UNDEF(&_1); - ZVAL_UNDEF(&_5$$4); - ZVAL_UNDEF(&_6$$4); - ZVAL_UNDEF(&_8$$4); - ZVAL_UNDEF(&_9$$4); - ZVAL_UNDEF(&_10$$6); - ZVAL_UNDEF(&_11$$7); - ZVAL_UNDEF(&_14$$9); - ZVAL_UNDEF(&_15$$10); - ZVAL_UNDEF(&_16$$12); - ZVAL_UNDEF(&_17$$12); - ZVAL_UNDEF(&_18$$12); - ZVAL_UNDEF(&_19$$12); - ZVAL_UNDEF(&_20$$14); - ZVAL_UNDEF(&_21$$15); - ZVAL_UNDEF(&_24$$17); - ZVAL_UNDEF(&_25$$18); - ZVAL_UNDEF(&closeOption); - ZVAL_UNDEF(&_12$$8); - ZVAL_UNDEF(&_13$$8); - ZVAL_UNDEF(&_22$$16); - ZVAL_UNDEF(&_23$$16); - ZEND_PARSE_PARAMETERS_START(3, 3) - Z_PARAM_ARRAY(data) - Z_PARAM_ZVAL(value) - Z_PARAM_STR(closeOption) - ZEND_PARSE_PARAMETERS_END(); - ZEPHIR_METHOD_GLOBALS_PTR = pecalloc(1, sizeof(zephir_method_globals), 0); - zephir_memory_grow_stack(ZEPHIR_METHOD_GLOBALS_PTR, __func__); - zephir_fetch_params(1, 3, 0, &data_param, &value, &closeOption_param); - zephir_get_arrval(&data, data_param); - zephir_get_strval(&closeOption, closeOption_param); - ZEPHIR_INIT_VAR(&code); - ZVAL_STRING(&code, ""); - zephir_is_iterable(&data, 0, "phalcon/Tag/Select.zep", 186); - if (Z_TYPE_P(&data) == IS_ARRAY) { - ZEND_HASH_FOREACH_KEY_VAL(Z_ARRVAL_P(&data), _2, _3, _0) - { - ZEPHIR_INIT_NVAR(&optionValue); - if (_3 != NULL) { - ZVAL_STR_COPY(&optionValue, _3); - } else { - ZVAL_LONG(&optionValue, _2); - } - ZEPHIR_INIT_NVAR(&optionText); - ZVAL_COPY(&optionText, _0); - ZEPHIR_CALL_FUNCTION(&escaped, "htmlspecialchars", &_4, 286, &optionValue); - zephir_check_call_status(); - if (Z_TYPE_P(&optionText) == IS_ARRAY) { - ZEPHIR_INIT_NVAR(&_5$$4); - ZEPHIR_GET_CONSTANT(&_5$$4, "PHP_EOL"); - ZEPHIR_CALL_SELF(&_6$$4, "optionsfromarray", &_7, 0, &optionText, value, &closeOption); - zephir_check_call_status(); - ZEPHIR_INIT_NVAR(&_8$$4); - ZEPHIR_GET_CONSTANT(&_8$$4, "PHP_EOL"); - ZEPHIR_INIT_NVAR(&_9$$4); - ZEPHIR_CONCAT_SVSVVSV(&_9$$4, "\t", &_5$$4, &_6$$4, "\t", &_8$$4); - zephir_concat_self(&code, &_9$$4); - continue; - } - if (Z_TYPE_P(value) == IS_ARRAY) { - if (zephir_fast_in_array(&optionValue, value)) { - ZEPHIR_INIT_NVAR(&_10$$6); - ZEPHIR_CONCAT_SVSVV(&_10$$6, "\t", &_16$$12, &_17$$12, "\t", &_18$$12); - zephir_concat_self(&code, &_19$$12); - continue; - } - if (Z_TYPE_P(value) == IS_ARRAY) { - if (zephir_fast_in_array(&optionValue, value)) { - ZEPHIR_INIT_NVAR(&_20$$14); - ZEPHIR_CONCAT_SVSVV(&_20$$14, "\t