PHP_METHOD(PhalconPlus_Base_Service, __get) { zend_long ZEPHIR_LAST_CALL_STATUS; zval *key_param = NULL, *_0 = NULL, *_1$$3, *_2$$4; zval *key = NULL; ZEPHIR_MM_GROW(); 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 a string") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(key_param) == IS_STRING)) { zephir_get_strval(key, key_param); } else { ZEPHIR_INIT_VAR(key); ZVAL_EMPTY_STRING(key); } ZEPHIR_CALL_FUNCTION(&_0, "property_exists", NULL, 1, this_ptr, key); zephir_check_call_status(); if (zephir_is_true(_0)) { ZEPHIR_OBS_VAR(_1$$3); zephir_read_property_zval(&_1$$3, this_ptr, key, PH_NOISY_CC); RETURN_CCTOR(_1$$3); } else { _2$$4 = zephir_fetch_nproperty_this(this_ptr, SL("di"), PH_NOISY_CC); ZEPHIR_RETURN_CALL_METHOD(_2$$4, "get", NULL, 0, key); zephir_check_call_status(); RETURN_MM(); } }
/** * Gets an attribute from the configuration, if the attribute isn't defined returns null * If the value is exactly null or is not defined the default value will be used instead * *<code> * echo $config->get('controllersDir', '../app/controllers/'); *</code> */ PHP_METHOD(Phalcon_Config, get) { int ZEPHIR_LAST_CALL_STATUS; zval *index = NULL, *defaultValue = NULL, *_0 = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &index, &defaultValue); ZEPHIR_SEPARATE_PARAM(index); if (!defaultValue) { defaultValue = ZEPHIR_GLOBAL(global_null); } ZEPHIR_CALL_FUNCTION(&_0, "strval", NULL, 20, index); zephir_check_call_status(); ZEPHIR_CPY_WRT(index, _0); if (zephir_isset_property_zval(this_ptr, index TSRMLS_CC)) { ZEPHIR_OBS_VAR(_1); zephir_read_property_zval(&_1, this_ptr, index, PH_NOISY_CC); RETURN_CCTOR(_1); } RETVAL_ZVAL(defaultValue, 1, 0); RETURN_MM(); }
PHP_METHOD(Test_Properties_PublicProperties, test394Issue) { zval *_1; zval *_0 = NULL; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "someTrue", 1); ZEPHIR_OBS_VAR(_1); zephir_read_property_zval(&_1, this_ptr, _0, PH_NOISY_CC); RETURN_CCTOR(_1); }
PHP_METHOD(Test_IssetTest, testIssetDynamicProperty1) { zval *_0 = NULL; zval *g; ZEPHIR_MM_GROW(); ZEPHIR_INIT_VAR(_0); ZEPHIR_INIT_NVAR(_0); ZVAL_STRING(_0, "s", 1); ZEPHIR_OBS_VAR(g); zephir_read_property_zval(&g, this_ptr, _0, PH_NOISY_CC); if (zephir_array_isset_string(g, SS("a"))) { RETURN_MM_BOOL(1); } RETURN_MM_BOOL(0); }
/** * Gets an attribute using the array-syntax * *<code> * print_r($config['database']); *</code> */ PHP_METHOD(Phalcon_Config, offsetGet) { int ZEPHIR_LAST_CALL_STATUS; zval *index = NULL, *_0 = NULL, *_1; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &index); ZEPHIR_SEPARATE_PARAM(index); ZEPHIR_CALL_FUNCTION(&_0, "strval", NULL, 20, index); zephir_check_call_status(); ZEPHIR_CPY_WRT(index, _0); ZEPHIR_OBS_VAR(_1); zephir_read_property_zval(&_1, this_ptr, index, PH_NOISY_CC); RETURN_CCTOR(_1); }
/** * Returns an item by key * * @param string * @return mixed */ PHP_METHOD(Xpl_Collection_ArrayObject, get) { zval *key_param = NULL, *_0; zval *key = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &key_param); zephir_get_strval(key, key_param); ZEPHIR_INIT_VAR(_0); if (zephir_isset_property_zval(this_ptr, key TSRMLS_CC)) { zephir_read_property_zval(&_0, this_ptr, key, PH_NOISY_CC); } else { ZVAL_NULL(_0); } RETURN_CCTOR(_0); }
/** * Gets the a value to validate in the array/object data source * * @param string field * @return mixed */ PHP_METHOD(Phalcon_Validation, getValue) { zend_bool _0$$10; zephir_fcall_cache_entry *_1 = NULL; zend_long ZEPHIR_LAST_CALL_STATUS; zval *field_param = NULL, *entity = NULL, *method = NULL, *value = NULL, *data = NULL, *values = NULL, *filters = NULL, *fieldFilters = NULL, *dependencyInjector = NULL, *filterService = NULL, *camelizedField = NULL, *_2$$20, *_3$$20 = NULL, *_4$$28 = NULL; zval *field = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 0, &field_param); zephir_get_strval(field, field_param); ZEPHIR_OBS_VAR(entity); zephir_read_property_this(&entity, this_ptr, SL("_entity"), PH_NOISY_CC); if (Z_TYPE_P(entity) == IS_OBJECT) { ZEPHIR_INIT_VAR(camelizedField); zephir_camelize(camelizedField, field, NULL ); ZEPHIR_INIT_VAR(method); ZEPHIR_CONCAT_SV(method, "get", camelizedField); if ((zephir_method_exists(entity, method TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD_ZVAL(&value, entity, method, NULL, 0); zephir_check_call_status(); } else { if ((zephir_method_exists_ex(entity, SS("readattribute") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(&value, entity, "readattribute", NULL, 0, field); zephir_check_call_status(); } else { ZEPHIR_INIT_NVAR(value); if (zephir_isset_property_zval(entity, field TSRMLS_CC)) { zephir_read_property_zval(&value, entity, field, PH_NOISY_CC); } else { ZVAL_NULL(value); } } } } else { ZEPHIR_OBS_VAR(data); zephir_read_property_this(&data, this_ptr, SL("_data"), PH_NOISY_CC); _0$$10 = Z_TYPE_P(data) != IS_ARRAY; if (_0$$10) { _0$$10 = Z_TYPE_P(data) != IS_OBJECT; } if (_0$$10) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "There is no data to validate", "phalcon/validation.zep", 499); return; } ZEPHIR_OBS_VAR(values); zephir_read_property_this(&values, this_ptr, SL("_values"), PH_NOISY_CC); ZEPHIR_OBS_NVAR(value); if (zephir_array_isset_fetch(&value, values, field, 0 TSRMLS_CC)) { RETURN_CCTOR(value); } ZEPHIR_INIT_NVAR(value); ZVAL_NULL(value); if (Z_TYPE_P(data) == IS_ARRAY) { if (zephir_array_isset(data, field)) { ZEPHIR_OBS_NVAR(value); zephir_array_fetch(&value, data, field, PH_NOISY, "phalcon/validation.zep", 511 TSRMLS_CC); } } else { if (Z_TYPE_P(data) == IS_OBJECT) { if (zephir_isset_property_zval(data, field TSRMLS_CC)) { ZEPHIR_OBS_NVAR(value); zephir_read_property_zval(&value, data, field, PH_NOISY_CC); } } } } if (Z_TYPE_P(value) == IS_NULL) { RETURN_MM_NULL(); } ZEPHIR_OBS_VAR(filters); zephir_read_property_this(&filters, this_ptr, SL("_filters"), PH_NOISY_CC); ZEPHIR_OBS_VAR(fieldFilters); if (zephir_array_isset_fetch(&fieldFilters, filters, field, 0 TSRMLS_CC)) { if (zephir_is_true(fieldFilters)) { ZEPHIR_CALL_METHOD(&dependencyInjector, this_ptr, "getdi", NULL, 0); zephir_check_call_status(); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_CALL_CE_STATIC(&dependencyInjector, phalcon_di_ce, "getdefault", &_1, 1); zephir_check_call_status(); if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "A dependency injector is required to obtain the 'filter' service", "phalcon/validation.zep", 536); return; } } ZEPHIR_INIT_VAR(_2$$20); ZVAL_STRING(_2$$20, "filter", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&filterService, dependencyInjector, "getshared", NULL, 0, _2$$20); zephir_check_temp_parameter(_2$$20); zephir_check_call_status(); if (Z_TYPE_P(filterService) != IS_OBJECT) { ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_validation_exception_ce, "Returned 'filter' service is invalid", "phalcon/validation.zep", 542); return; } ZEPHIR_CALL_METHOD(&_3$$20, filterService, "sanitize", NULL, 0, value, fieldFilters); zephir_check_call_status(); ZEPHIR_CPY_WRT(value, _3$$20); if (Z_TYPE_P(entity) == IS_OBJECT) { ZEPHIR_INIT_NVAR(method); ZEPHIR_CONCAT_SV(method, "set", camelizedField); if ((zephir_method_exists(entity, method TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD_ZVAL(NULL, entity, method, NULL, 0, value); zephir_check_call_status(); } else { if ((zephir_method_exists_ex(entity, SS("writeattribute") TSRMLS_CC) == SUCCESS)) { ZEPHIR_CALL_METHOD(NULL, entity, "writeattribute", NULL, 0, field, value); zephir_check_call_status(); } else { ZEPHIR_CALL_FUNCTION(&_4$$28, "property_exists", NULL, 329, entity, field); zephir_check_call_status(); if (zephir_is_true(_4$$28)) { zephir_update_property_zval_zval(entity, field, value TSRMLS_CC); } } } } RETURN_CCTOR(value); } } if (Z_TYPE_P(entity) != IS_OBJECT) { zephir_update_property_array(this_ptr, SL("_values"), field, value TSRMLS_CC); } RETURN_CCTOR(value); }
PHP_METHOD(PhalconPlus_Db_Mysql, __construct) { zval *_2, *_4; int ZEPHIR_LAST_CALL_STATUS; zval *confName = NULL; zval *di, *confName_param = NULL, *_0, *config = NULL, *dbConfig, *_1, *_3 = NULL, *_5, *_6; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &di, &confName_param); if (unlikely(Z_TYPE_P(confName_param) != IS_STRING && Z_TYPE_P(confName_param) != IS_NULL)) { zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'confName' must be a string") TSRMLS_CC); RETURN_MM_NULL(); } if (likely(Z_TYPE_P(confName_param) == IS_STRING)) { zephir_get_strval(confName, confName_param); } else { ZEPHIR_INIT_VAR(confName); ZVAL_EMPTY_STRING(confName); } ZEPHIR_INIT_VAR(_0); array_init(_0); zephir_update_property_this(this_ptr, SL("descriptor"), _0 TSRMLS_CC); ZEPHIR_INIT_VAR(_1); ZVAL_STRING(_1, "config", ZEPHIR_TEMP_PARAM_COPY); ZEPHIR_CALL_METHOD(&config, di, "get", NULL, _1); zephir_check_temp_parameter(_1); zephir_check_call_status(); ZEPHIR_OBS_VAR(dbConfig); zephir_read_property_zval(&dbConfig, config, confName, PH_NOISY_CC); zephir_update_property_this(this_ptr, SL("di"), di TSRMLS_CC); ZEPHIR_INIT_VAR(_2); zephir_create_array(_2, 6, 0 TSRMLS_CC); ZEPHIR_OBS_VAR(_3); zephir_read_property(&_3, dbConfig, SL("host"), PH_NOISY_CC); zephir_array_update_string(&_2, SL("host"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_3); zephir_read_property(&_3, dbConfig, SL("port"), PH_NOISY_CC); zephir_array_update_string(&_2, SL("port"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_3); zephir_read_property(&_3, dbConfig, SL("username"), PH_NOISY_CC); zephir_array_update_string(&_2, SL("username"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_3); zephir_read_property(&_3, dbConfig, SL("password"), PH_NOISY_CC); zephir_array_update_string(&_2, SL("password"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(_3); zephir_read_property(&_3, dbConfig, SL("dbname"), PH_NOISY_CC); zephir_array_update_string(&_2, SL("dbname"), &_3, PH_COPY | PH_SEPARATE); ZEPHIR_INIT_VAR(_4); zephir_create_array(_4, 3, 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(_3); zephir_read_property(&_3, dbConfig, SL("charset"), PH_NOISY_CC); ZEPHIR_INIT_VAR(_5); ZEPHIR_CONCAT_SV(_5, "SET NAMES ", _3); zephir_array_update_long(&_4, 1002, &_5, PH_COPY, "phalconplus/Db/Mysql.zep", 29); ZEPHIR_OBS_VAR(_6); zephir_read_property(&_6, dbConfig, SL("timeout"), PH_NOISY_CC); zephir_array_update_long(&_4, 2, &_6, PH_COPY, "phalconplus/Db/Mysql.zep", 29); add_index_long(_4, 3, 2); zephir_array_update_string(&_2, SL("options"), &_4, PH_COPY | PH_SEPARATE); zephir_update_property_this(this_ptr, SL("descriptor"), _2 TSRMLS_CC); ZEPHIR_MM_RESTORE(); }
/** * Helper method for merge configs (forwarding nested config instance) * * @param Config config * @param Config instance = null * * @return Config merged config */ PHP_METHOD(Phalcon_Config, _merge) { zephir_fcall_cache_entry *_8 = NULL, *_9 = NULL; zend_bool _4, _5; HashTable *_2; HashPosition _1; int ZEPHIR_LAST_CALL_STATUS; zval *config, *instance = NULL, *key = NULL, *value = NULL, *number = NULL, *_0 = NULL, **_3, *_6 = NULL, *_7 = NULL; ZEPHIR_MM_GROW(); zephir_fetch_params(1, 1, 1, &config, &instance); if (!instance) { ZEPHIR_CPY_WRT(instance, ZEPHIR_GLOBAL(global_null)); } else { ZEPHIR_SEPARATE_PARAM(instance); } if (Z_TYPE_P(instance) != IS_OBJECT) { ZEPHIR_CPY_WRT(instance, this_ptr); } ZEPHIR_CALL_METHOD(&number, instance, "count", NULL, 0); zephir_check_call_status(); ZEPHIR_CALL_FUNCTION(&_0, "get_object_vars", NULL, 23, config); zephir_check_call_status(); zephir_is_iterable(_0, &_2, &_1, 0, 0, "phalcon/config.zep", 239); for ( ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS ; zephir_hash_move_forward_ex(_2, &_1) ) { ZEPHIR_GET_HMKEY(key, _2, _1); ZEPHIR_GET_HVALUE(value, _3); _4 = zephir_isset_property_zval(instance, key TSRMLS_CC); if (_4) { _4 = Z_TYPE_P(value) == IS_OBJECT; } _5 = _4; if (_5) { ZEPHIR_OBS_NVAR(_6); zephir_read_property_zval(&_6, instance, key, PH_NOISY_CC); _5 = Z_TYPE_P(_6) == IS_OBJECT; } if (_5) { ZEPHIR_OBS_NVAR(_7); zephir_read_property_zval(&_7, instance, key, PH_NOISY_CC); ZEPHIR_CALL_METHOD(NULL, this_ptr, "_merge", &_8, 22, value, _7); zephir_check_call_status(); } else { if (Z_TYPE_P(key) == IS_LONG) { ZEPHIR_CALL_FUNCTION(&key, "strval", &_9, 20, number); zephir_check_call_status(); ZEPHIR_SEPARATE(number); zephir_increment(number); } zephir_update_property_zval_zval(instance, key, value TSRMLS_CC); } } RETVAL_ZVAL(instance, 1, 0); RETURN_MM(); }
PHP_METHOD(PhalconPlus_Db_Mysql, __construct) { zval _9; zend_long ZEPHIR_LAST_CALL_STATUS; zval name; zval *di, di_sub, *name_param = NULL, config, dbConfig, _0, options, _3, _4, _5, _1$$3, _2$$4, _6$$5, _7$$5, _8$$5; zval *this_ptr = getThis(); ZVAL_UNDEF(&di_sub); ZVAL_UNDEF(&config); ZVAL_UNDEF(&dbConfig); ZVAL_UNDEF(&_0); ZVAL_UNDEF(&options); ZVAL_UNDEF(&_3); ZVAL_UNDEF(&_4); ZVAL_UNDEF(&_5); ZVAL_UNDEF(&_1$$3); ZVAL_UNDEF(&_2$$4); ZVAL_UNDEF(&_6$$5); ZVAL_UNDEF(&_7$$5); ZVAL_UNDEF(&_8$$5); ZVAL_UNDEF(&name); ZVAL_UNDEF(&_9); ZEPHIR_MM_GROW(); zephir_fetch_params(1, 2, 0, &di, &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") TSRMLS_CC); RETURN_MM_NULL(); } if (EXPECTED(Z_TYPE_P(name_param) == IS_STRING)) { zephir_get_strval(&name, name_param); } else { ZEPHIR_INIT_VAR(&name); ZVAL_EMPTY_STRING(&name); } ZEPHIR_INIT_VAR(&_0); ZVAL_STRING(&_0, "config"); ZEPHIR_CALL_METHOD(&config, di, "get", NULL, 0, &_0); zephir_check_call_status(); ZEPHIR_OBS_VAR(&dbConfig); zephir_read_property_zval(&dbConfig, &config, &name, PH_NOISY_CC); zephir_update_property_zval(this_ptr, SL("di"), di); zephir_update_property_zval(this_ptr, SL("name"), &name); if (zephir_isset_property(&dbConfig, SL("retryTimes"))) { zephir_read_property(&_1$$3, &dbConfig, SL("retryTimes"), PH_NOISY_CC | PH_READONLY); zephir_update_property_zval(this_ptr, SL("retryTimes"), &_1$$3); } if (zephir_isset_property(&dbConfig, SL("retryInterval"))) { zephir_read_property(&_2$$4, &dbConfig, SL("retryInterval"), PH_NOISY_CC | PH_READONLY); zephir_update_property_zval(this_ptr, SL("retryInterval"), &_2$$4); } ZEPHIR_INIT_VAR(&options); zephir_create_array(&options, 3, 0 TSRMLS_CC); zephir_read_property(&_3, &dbConfig, SL("charset"), PH_NOISY_CC | PH_READONLY); ZEPHIR_INIT_VAR(&_4); ZEPHIR_CONCAT_SV(&_4, "SET NAMES ", &_3); zephir_array_update_long(&options, 1002, &_4, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); ZEPHIR_OBS_VAR(&_5); zephir_read_property(&_5, &dbConfig, SL("timeout"), PH_NOISY_CC); zephir_array_update_long(&options, 2, &_5, PH_COPY ZEPHIR_DEBUG_PARAMS_DUMMY); add_index_long(&options, 3, 2); if (zephir_isset_property(&dbConfig, SL("options"))) { zephir_read_property(&_6$$5, &dbConfig, SL("options"), PH_NOISY_CC | PH_READONLY); ZEPHIR_CALL_METHOD(&_7$$5, &_6$$5, "toarray", NULL, 0); zephir_check_call_status(); ZEPHIR_INIT_VAR(&_8$$5); zephir_add_function(&_8$$5, &_7$$5, &options); zephir_update_property_zval(this_ptr, SL("options"), &_8$$5); } else { zephir_update_property_zval(this_ptr, SL("options"), &options); } ZEPHIR_INIT_VAR(&_9); zephir_create_array(&_9, 6, 0 TSRMLS_CC); ZEPHIR_OBS_NVAR(&_5); zephir_read_property(&_5, &dbConfig, SL("host"), PH_NOISY_CC); zephir_array_update_string(&_9, SL("host"), &_5, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(&_5); zephir_read_property(&_5, &dbConfig, SL("port"), PH_NOISY_CC); zephir_array_update_string(&_9, SL("port"), &_5, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(&_5); zephir_read_property(&_5, &dbConfig, SL("username"), PH_NOISY_CC); zephir_array_update_string(&_9, SL("username"), &_5, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(&_5); zephir_read_property(&_5, &dbConfig, SL("password"), PH_NOISY_CC); zephir_array_update_string(&_9, SL("password"), &_5, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(&_5); zephir_read_property(&_5, &dbConfig, SL("dbname"), PH_NOISY_CC); zephir_array_update_string(&_9, SL("dbname"), &_5, PH_COPY | PH_SEPARATE); ZEPHIR_OBS_NVAR(&_5); zephir_read_property(&_5, this_ptr, SL("options"), PH_NOISY_CC); zephir_array_update_string(&_9, SL("options"), &_5, PH_COPY | PH_SEPARATE); zephir_update_property_zval(this_ptr, SL("descriptor"), &_9); ZEPHIR_MM_RESTORE(); }