示例#1
0
文件: trie.zep.c 项目: 9466/zephir
PHP_METHOD(Test_Trie, getTrieNodeByKey) {

	zend_class_entry *_5;
	zephir_nts_static zephir_fcall_cache_entry *_2 = NULL;
	int i, ZEPHIR_LAST_CALL_STATUS;
	zend_bool create;
	zval *key_param = NULL, *create_param = NULL, *trieNode = NULL, *keyLen, *character = NULL, _0 = zval_used_for_init, _1 = zval_used_for_init, *_3 = NULL, *_4 = NULL, *_6 = NULL, *_7;
	zval *key = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &key_param, &create_param);

	zephir_get_strval(key, key_param);
	if (!create_param) {
		create = 0;
	} else {
		create = zephir_get_boolval(create_param);
	}


	ZEPHIR_OBS_VAR(trieNode);
	zephir_read_property_this(&trieNode, this_ptr, SL("trie"), PH_NOISY_CC);
	ZEPHIR_INIT_VAR(keyLen);
	ZVAL_LONG(keyLen, zephir_fast_strlen_ev(key));
	i = 0;
	while (1) {
		if (!(ZEPHIR_GT_LONG(keyLen, i))) {
			break;
		}
		ZEPHIR_SINIT_NVAR(_0);
		ZVAL_LONG(&_0, i);
		ZEPHIR_SINIT_NVAR(_1);
		ZVAL_LONG(&_1, 1);
		ZEPHIR_CALL_FUNCTION(&character, "substr", &_2, key, &_0, &_1);
		zephir_check_call_status();
		ZEPHIR_OBS_NVAR(_3);
		zephir_read_property(&_3, trieNode, SL("children"), PH_NOISY_CC);
		if (!(zephir_array_isset(_3, character))) {
			if (create) {
				ZEPHIR_INIT_LNVAR(_4);
				_5 = zend_fetch_class(SL("tries\\trienode"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
				object_init_ex(_4, _5);
				if (zephir_has_constructor(_4 TSRMLS_CC)) {
					ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL);
					zephir_check_call_status();
				}
				zephir_update_property_array(trieNode, SL("children"), character, _4 TSRMLS_CC);
			} else {
				RETURN_MM_BOOL(0);
			}
		}
		ZEPHIR_OBS_NVAR(_6);
		zephir_read_property(&_6, trieNode, SL("children"), PH_NOISY_CC);
		zephir_array_fetch(&_7, _6, character, PH_NOISY | PH_READONLY TSRMLS_CC);
		ZEPHIR_CPY_WRT(trieNode, _7);
		i += 1;
	}
	RETURN_CCTOR(trieNode);

}
示例#2
0
/**
 * Returns an array of default parameters
 */
PHP_METHOD(Phalcon_Mvc_Router, getDefaults) {

	zval *_0 = NULL;

	ZEPHIR_MM_GROW();

	zephir_create_array(return_value, 5, 0 TSRMLS_CC);
	ZEPHIR_OBS_VAR(_0);
	zephir_read_property_this(&_0, this_ptr, SL("_defaultNamespace"), PH_NOISY_CC);
	zephir_array_update_string(&return_value, SL("namespace"), &_0, PH_COPY | PH_SEPARATE);
	ZEPHIR_OBS_NVAR(_0);
	zephir_read_property_this(&_0, this_ptr, SL("_defaultModule"), PH_NOISY_CC);
	zephir_array_update_string(&return_value, SL("module"), &_0, PH_COPY | PH_SEPARATE);
	ZEPHIR_OBS_NVAR(_0);
	zephir_read_property_this(&_0, this_ptr, SL("_defaultController"), PH_NOISY_CC);
	zephir_array_update_string(&return_value, SL("controller"), &_0, PH_COPY | PH_SEPARATE);
	ZEPHIR_OBS_NVAR(_0);
	zephir_read_property_this(&_0, this_ptr, SL("_defaultAction"), PH_NOISY_CC);
	zephir_array_update_string(&return_value, SL("action"), &_0, PH_COPY | PH_SEPARATE);
	ZEPHIR_OBS_NVAR(_0);
	zephir_read_property_this(&_0, this_ptr, SL("_defaultParams"), PH_NOISY_CC);
	zephir_array_update_string(&return_value, SL("params"), &_0, PH_COPY | PH_SEPARATE);
	RETURN_MM();

}
示例#3
0
/**
 * Magic function so that $obj->value will work.
 *
 * @param string $name
 * @return mixed
 */
PHP_METHOD(Yaf_Session, __get) {

    zval *name_param = NULL, *result = NULL, *_0, *_1, *_SESSION;
    zval *name = NULL;

    ZEPHIR_MM_GROW();
    zephir_fetch_params(1, 1, 0, &name_param);

    zephir_get_strval(name, name_param);


    ZEPHIR_INIT_VAR(result);
    ZVAL_NULL(result);
    if (ZEPHIR_IS_STRING(name, "")) {
        RETURN_MM_NULL();
    }
    _0 = zephir_fetch_nproperty_this(this_ptr, SL("session"), PH_NOISY_CC);
    if (zephir_array_key_exists(_0, name TSRMLS_CC)) {
        _1 = zephir_fetch_nproperty_this(this_ptr, SL("session"), PH_NOISY_CC);
        ZEPHIR_OBS_NVAR(result);
        zephir_array_fetch(&result, _1, name, PH_NOISY, "yaf/session.zep", 81 TSRMLS_CC);
    } else {
        zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC);
        if (zephir_array_key_exists(_SESSION, name TSRMLS_CC)) {
            zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC);
            ZEPHIR_OBS_NVAR(result);
            zephir_array_fetch(&result, _SESSION, name, PH_NOISY, "yaf/session.zep", 85 TSRMLS_CC);
        }
    }
    RETURN_CCTOR(result);

}
示例#4
0
/**
 * Get the server variable SERVER_NAME
 *
 * @return string server name
 */
PHP_METHOD(Phady_Util_Tools, getServerName) {

	zend_bool _0;
	zval *server = NULL, *_SERVER, *_1;

	ZEPHIR_MM_GROW();
	zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC);
	ZEPHIR_INIT_VAR(server);
	ZVAL_STRING(server, "", 1);

	_0 = zephir_array_isset_string(_SERVER, SS("HTTP_X_FORWARDED_SERVER"));
	if (_0) {
		zephir_array_fetch_string(&_1, _SERVER, SL("HTTP_X_FORWARDED_SERVER"), PH_NOISY | PH_READONLY, "phady/util/tools.zep", 37 TSRMLS_CC);
		_0 = zephir_is_true(_1);
	}
	if (_0) {
		ZEPHIR_OBS_NVAR(server);
		zephir_array_fetch_string(&server, _SERVER, SL("HTTP_X_FORWARDED_SERVER"), PH_NOISY, "phady/util/tools.zep", 38 TSRMLS_CC);
	} else {
		ZEPHIR_OBS_NVAR(server);
		zephir_array_fetch_string(&server, _SERVER, SL("SERVER_NAME"), PH_NOISY, "phady/util/tools.zep", 40 TSRMLS_CC);
	}
	RETURN_CCTOR(server);

}
示例#5
0
/**
 * Serializing a resultset will dump all related rows into a big array
 */
PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, serialize) {

	zval *_1 = NULL, *_2 = NULL, *_3;
	zval *_0;
	int ZEPHIR_LAST_CALL_STATUS;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(_0);
	zephir_create_array(_0, 5, 0 TSRMLS_CC);
	ZEPHIR_OBS_VAR(_1);
	zephir_read_property_this(&_1, this_ptr, SL("_model"), PH_NOISY_CC);
	zephir_array_update_string(&_0, SL("model"), &_1, PH_COPY | PH_SEPARATE);
	ZEPHIR_OBS_NVAR(_1);
	zephir_read_property_this(&_1, this_ptr, SL("_cache"), PH_NOISY_CC);
	zephir_array_update_string(&_0, SL("cache"), &_1, PH_COPY | PH_SEPARATE);
	ZEPHIR_INIT_VAR(_3);
	ZVAL_BOOL(_3, 0);
	ZEPHIR_CALL_METHOD(&_2, this_ptr, "toarray", NULL, 0, _3);
	zephir_check_call_status();
	zephir_array_update_string(&_0, SL("rows"), &_2, PH_COPY | PH_SEPARATE);
	ZEPHIR_OBS_NVAR(_1);
	zephir_read_property_this(&_1, this_ptr, SL("_columnMap"), PH_NOISY_CC);
	zephir_array_update_string(&_0, SL("columnMap"), &_1, PH_COPY | PH_SEPARATE);
	ZEPHIR_OBS_NVAR(_1);
	zephir_read_property_this(&_1, this_ptr, SL("_hydrateMode"), PH_NOISY_CC);
	zephir_array_update_string(&_0, SL("hydrateMode"), &_1, PH_COPY | PH_SEPARATE);
	ZEPHIR_RETURN_CALL_FUNCTION("serialize", NULL, 65, _0);
	zephir_check_call_status();
	RETURN_MM();

}
示例#6
0
/**
 * Adds a javascript resource to the collection
 *
 * @param string path
 * @param boolean local
 * @param boolean filter
 * @param array attributes
 * @return \Phalcon\Assets\Collection
 */
PHP_METHOD(Phalcon_Assets_Collection, addJs) {

	int ZEPHIR_LAST_CALL_STATUS;
	zend_bool filter;
	zval *path_param = NULL, *local = NULL, *filter_param = NULL, *attributes = NULL, *collectionLocal = NULL, *collectionAttributes = NULL, *_0, *_1;
	zval *path = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 3, &path_param, &local, &filter_param, &attributes);

	if (unlikely(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 a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(path_param) == IS_STRING)) {
		zephir_get_strval(path, path_param);
	} else {
		ZEPHIR_INIT_VAR(path);
		ZVAL_EMPTY_STRING(path);
	}
	if (!local) {
		local = ZEPHIR_GLOBAL(global_null);
	}
	if (!filter_param) {
		filter = 1;
	} else {
		filter = zephir_get_boolval(filter_param);
	}
	if (!attributes) {
		attributes = ZEPHIR_GLOBAL(global_null);
	}


	if (Z_TYPE_P(local) == IS_BOOL) {
		ZEPHIR_CPY_WRT(collectionLocal, local);
	} else {
		ZEPHIR_OBS_NVAR(collectionLocal);
		zephir_read_property_this(&collectionLocal, this_ptr, SL("_local"), PH_NOISY_CC);
	}
	if (Z_TYPE_P(attributes) == IS_ARRAY) {
		ZEPHIR_CPY_WRT(collectionAttributes, attributes);
	} else {
		ZEPHIR_OBS_NVAR(collectionAttributes);
		zephir_read_property_this(&collectionAttributes, this_ptr, SL("_attributes"), PH_NOISY_CC);
	}
	ZEPHIR_INIT_VAR(_0);
	object_init_ex(_0, phalcon_assets_resource_js_ce);
	ZEPHIR_INIT_VAR(_1);
	if (filter) {
		ZVAL_BOOL(_1, 1);
	} else {
		ZVAL_BOOL(_1, 0);
	}
	ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 102, path, collectionLocal, _1, collectionAttributes);
	zephir_check_call_status();
	zephir_update_property_array_append(this_ptr, SL("_resources"), _0 TSRMLS_CC);
	RETURN_THIS();

}
示例#7
0
文件: router.zep.c 项目: noikiy/owl
PHP_METHOD(Owl_Router_Router, match) {

	zend_bool _5, _7;
	int ZEPHIR_LAST_CALL_STATUS;
	HashTable *_2;
	HashPosition _1;
	zval *uri_param = NULL, *method_param = NULL, *router = NULL, *_0, **_3, *_4 = NULL, *_6 = NULL, *_8 = NULL;
	zval *uri = NULL, *method = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &uri_param, &method_param);

	zephir_get_strval(uri, uri_param);
	if (!method_param) {
		ZEPHIR_INIT_VAR(method);
		ZVAL_STRING(method, "GET", 1);
	} else {
		zephir_get_strval(method, method_param);
	}


	_0 = zephir_fetch_nproperty_this(this_ptr, SL("routers"), PH_NOISY_CC);
	zephir_is_iterable(_0, &_2, &_1, 0, 0, "owl/Router/Router.zep", 56);
	for (
	  ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS
	  ; zephir_hash_move_forward_ex(_2, &_1)
	) {
		ZEPHIR_GET_HVALUE(router, _3);
		ZEPHIR_CALL_METHOD(&_4, router, "match", NULL, 0, uri);
		zephir_check_call_status();
		_5 = zephir_is_true(_4);
		if (_5) {
			ZEPHIR_OBS_NVAR(_6);
			zephir_read_property(&_6, router, SL("method"), PH_NOISY_CC);
			_7 = ZEPHIR_IS_LONG(_6, 7);
			if (!(_7)) {
				ZEPHIR_OBS_NVAR(_8);
				zephir_read_property(&_8, router, SL("method"), PH_NOISY_CC);
				_7 = ZEPHIR_IS_EQUAL(_8, method);
			}
			_5 = _7;
		}
		if (_5) {
			RETURN_CCTOR(router);
		}
	}
	RETURN_MM_BOOL(0);

}
示例#8
0
文件: json.zep.c 项目: noikiy/owl
/**
 * @inheritdoc
 */
PHP_METHOD(Owl_Log_Formatter_Json, format) {

	int ZEPHIR_LAST_CALL_STATUS;
	zephir_fcall_cache_entry *_2 = NULL;
	zval *_0;
	zval *record, *_1 = NULL, *_3, *_4 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &record);



	ZEPHIR_INIT_VAR(_0);
	zephir_create_array(_0, 3, 0 TSRMLS_CC);
	ZEPHIR_OBS_VAR(_3);
	zephir_read_property(&_3, record, SL("level"), PH_NOISY_CC);
	ZEPHIR_CALL_CE_STATIC(&_1, owl_log_logger_ce, "getleveltitle", &_2, 18, _3);
	zephir_check_call_status();
	zephir_array_update_string(&_0, SL("type"), &_1, PH_COPY | PH_SEPARATE);
	ZEPHIR_OBS_VAR(_4);
	zephir_read_property(&_4, record, SL("message"), PH_NOISY_CC);
	zephir_array_update_string(&_0, SL("message"), &_4, PH_COPY | PH_SEPARATE);
	ZEPHIR_OBS_NVAR(_4);
	zephir_read_property(&_4, record, SL("timestamp"), PH_NOISY_CC);
	zephir_array_update_string(&_0, SL("timestamp"), &_4, PH_COPY | PH_SEPARATE);
	zephir_json_encode(return_value, &(return_value), _0, 0  TSRMLS_CC);
	RETURN_MM();

}
示例#9
0
/**
 * Filter records by levels
 */
PHP_METHOD(Owl_Log_AbstractWriter, filterRecords) {

	HashTable *_2;
	HashPosition _1;
	zval *records_param = NULL, *index = NULL, *record = NULL, *_0, **_3, *_4 = NULL, *_5;
	zval *records = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &records_param);

	zephir_get_arrval(records, records_param);


	ZEPHIR_OBS_VAR(_0);
	zephir_read_property_this(&_0, this_ptr, SL("levels"), PH_NOISY_CC);
	if (ZEPHIR_IS_EMPTY(_0)) {
		RETURN_CTOR(records);
	}
	zephir_is_iterable(records, &_2, &_1, 1, 0, "owl/Log/AbstractWriter.zep", 125);
	for (
	  ; zephir_hash_get_current_data_ex(_2, (void**) &_3, &_1) == SUCCESS
	  ; zephir_hash_move_forward_ex(_2, &_1)
	) {
		ZEPHIR_GET_HMKEY(index, _2, _1);
		ZEPHIR_GET_HVALUE(record, _3);
		ZEPHIR_OBS_NVAR(_4);
		zephir_read_property(&_4, record, SL("level"), PH_NOISY_CC);
		_5 = zephir_fetch_nproperty_this(this_ptr, SL("levels"), PH_NOISY_CC);
		if (!(zephir_fast_in_array(_4, _5 TSRMLS_CC))) {
			zephir_array_unset(&records, index, PH_SEPARATE);
		}
	}
	RETURN_CTOR(records);

}
示例#10
0
/**
 * @param \Phal\Entity
 * @param array data
 * @return void
 */
PHP_METHOD(Phal_Format_Reader_Hal_JsonReader, transformMetadata) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *resource, *data, *key = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &resource, &data);



	if (!(zephir_instance_of_ev(resource, phal_entity_ce TSRMLS_CC))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Parameter 'resource' must be an instance of 'Phal\\Entity'", "", 0);
		return;
	}
	if (Z_TYPE_P(data) != IS_ARRAY) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "data must be array", "phal/format/reader/hal/jsonreader.zep", 43);
		return;
	}
	ZEPHIR_OBS_VAR(key);
	if (zephir_array_isset_string_fetch(&key, data, SS("_links"), 0 TSRMLS_CC)) {
		ZEPHIR_CALL_METHOD(NULL, this_ptr, "transformlinks", NULL, resource, key);
		zephir_check_call_status();
	}
	ZEPHIR_OBS_NVAR(key);
	if (zephir_array_isset_string_fetch(&key, data, SS("_embedded"), 0 TSRMLS_CC)) {
		ZEPHIR_CALL_METHOD(NULL, this_ptr, "transformembeddeds", NULL, resource, key);
		zephir_check_call_status();
	}
	ZEPHIR_MM_RESTORE();

}
示例#11
0
/**
 * Phalcon\Logger\Adapter\File constructor
 *
 * @param string name
 * @param array options
 */
PHP_METHOD(Phalcon_Logger_Adapter_File, __construct) {

	int ZEPHIR_LAST_CALL_STATUS;
	zephir_nts_static zephir_fcall_cache_entry *_0 = NULL, *_3 = NULL;
	zval *name_param = NULL, *options = NULL, *mode = NULL, *handler = NULL, *_1;
	zval *name = NULL, *_2;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &name_param, &options);

	if (unlikely(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 a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}

	if (likely(Z_TYPE_P(name_param) == IS_STRING)) {
		zephir_get_strval(name, name_param);
	} else {
		ZEPHIR_INIT_VAR(name);
		ZVAL_EMPTY_STRING(name);
	}
	if (!options) {
		options = ZEPHIR_GLOBAL(global_null);
	}
	ZEPHIR_INIT_VAR(mode);
	ZVAL_NULL(mode);


	if (Z_TYPE_P(options) == IS_ARRAY) {
		ZEPHIR_OBS_NVAR(mode);
		if (zephir_array_isset_string_fetch(&mode, options, SS("mode"), 0 TSRMLS_CC)) {
			if (zephir_memnstr_str(mode, SL("r"), "phalcon/logger/adapter/file.zep", 72)) {
				ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_logger_exception_ce, "Logger must be opened in append or write mode", "phalcon/logger/adapter/file.zep", 73);
				return;
			}
		}
	}
	if (Z_TYPE_P(mode) == IS_NULL) {
		ZEPHIR_INIT_NVAR(mode);
		ZVAL_STRING(mode, "ab", 1);
	}
	ZEPHIR_CALL_FUNCTION(&handler, "fopen", &_0, name, mode);
	zephir_check_call_status();
	if (Z_TYPE_P(handler) != IS_RESOURCE) {
		ZEPHIR_INIT_VAR(_1);
		object_init_ex(_1, phalcon_logger_exception_ce);
		ZEPHIR_INIT_VAR(_2);
		ZEPHIR_CONCAT_SVS(_2, "Can't open log file at '", name, "'");
		ZEPHIR_CALL_METHOD(NULL, _1, "__construct", &_3, _2);
		zephir_check_call_status();
		zephir_throw_exception_debug(_1, "phalcon/logger/adapter/file.zep", 87 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	zephir_update_property_this(this_ptr, SL("_path"), name TSRMLS_CC);
	zephir_update_property_this(this_ptr, SL("_options"), options TSRMLS_CC);
	zephir_update_property_this(this_ptr, SL("_fileHandler"), handler TSRMLS_CC);
	ZEPHIR_MM_RESTORE();

}
示例#12
0
/**
 * Adds a inline javascript to the collection
 */
PHP_METHOD(Phalcon_Assets_Collection, addInlineJs) {

	int ZEPHIR_LAST_CALL_STATUS;
	zend_bool filter;
	zval *content_param = NULL, *filter_param = NULL, *attributes = NULL, *collectionAttributes = NULL, *_0;
	zval *content = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 2, &content_param, &filter_param, &attributes);

	zephir_get_strval(content, content_param);
	if (!filter_param) {
		filter = 1;
	} else {
		filter = zephir_get_boolval(filter_param);
	}
	if (!attributes) {
		attributes = ZEPHIR_GLOBAL(global_null);
	}


	if (Z_TYPE_P(attributes) == IS_ARRAY) {
		ZEPHIR_CPY_WRT(collectionAttributes, attributes);
	} else {
		ZEPHIR_OBS_NVAR(collectionAttributes);
		zephir_read_property_this(&collectionAttributes, this_ptr, SL("_attributes"), PH_NOISY_CC);
	}
	ZEPHIR_INIT_VAR(_0);
	object_init_ex(_0, phalcon_assets_inline_js_ce);
	ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 95, content, (filter ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false)), collectionAttributes);
	zephir_check_call_status();
	zephir_update_property_array_append(this_ptr, SL("_codes"), _0 TSRMLS_CC);
	RETURN_THIS();

}
示例#13
0
/**
 * Returns the complete location where the resource is located
 */
PHP_METHOD(Phalcon_Assets_Resource, getRealSourcePath) {

	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval *basePath_param = NULL, *sourcePath = NULL, *_0, *_1$$4;
	zval *basePath = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 0, 1, &basePath_param);

	if (!basePath_param) {
		ZEPHIR_INIT_VAR(basePath);
		ZVAL_EMPTY_STRING(basePath);
	} else {
		zephir_get_strval(basePath, basePath_param);
	}


	ZEPHIR_OBS_VAR(sourcePath);
	zephir_read_property_this(&sourcePath, this_ptr, SL("_sourcePath"), PH_NOISY_CC);
	if (ZEPHIR_IS_EMPTY(sourcePath)) {
		ZEPHIR_OBS_NVAR(sourcePath);
		zephir_read_property_this(&sourcePath, this_ptr, SL("_path"), PH_NOISY_CC);
	}
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_local"), PH_NOISY_CC);
	if (zephir_is_true(_0)) {
		ZEPHIR_INIT_VAR(_1$$4);
		ZEPHIR_CONCAT_VV(_1$$4, basePath, sourcePath);
		ZEPHIR_RETURN_CALL_FUNCTION("realpath", NULL, 67, _1$$4);
		zephir_check_call_status();
		RETURN_MM();
	}
	RETURN_CCTOR(sourcePath);

}
示例#14
0
/**
 * Create a Phalcon\Cache based on the internal cache options
 */
PHP_METHOD(Phalcon_Mvc_View_Simple, _createCache) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *dependencyInjector, *cacheService = NULL, *cacheOptions, *viewCache = NULL, *_0 = NULL;

	ZEPHIR_MM_GROW();

	ZEPHIR_OBS_VAR(dependencyInjector);
	zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);
	if (Z_TYPE_P(dependencyInjector) != IS_OBJECT) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "A dependency injector container is required to obtain the view cache services", "phalcon/mvc/view/simple.zep", 478);
		return;
	}
	ZEPHIR_INIT_VAR(cacheService);
	ZVAL_STRING(cacheService, "viewCache", 1);
	ZEPHIR_OBS_VAR(cacheOptions);
	zephir_read_property_this(&cacheOptions, this_ptr, SL("_cacheOptions"), PH_NOISY_CC);
	if (Z_TYPE_P(cacheOptions) == IS_ARRAY) {
		if (zephir_array_isset_string(cacheOptions, SS("service"))) {
			ZEPHIR_OBS_NVAR(cacheService);
			zephir_array_isset_string_fetch(&cacheService, cacheOptions, SS("service"), 0 TSRMLS_CC);
		}
	}
	ZEPHIR_CALL_METHOD(&_0, dependencyInjector, "getshared", NULL, 0, cacheService);
	zephir_check_call_status();
	ZEPHIR_CPY_WRT(viewCache, _0);
	if (Z_TYPE_P(viewCache) != IS_OBJECT) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_mvc_view_exception_ce, "The injected caching service is invalid", "phalcon/mvc/view/simple.zep", 495);
		return;
	}
	RETURN_CCTOR(viewCache);

}
示例#15
0
/**
 * Reads the ordered/reversed column map for certain model
 *
 *<code>
 *	print_r($metaData->readColumnMap(new Robots()));
 *</code>
 */
PHP_METHOD(Phalcon_Mvc_Model_MetaData, readColumnMap) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *model, *keyName, *data = NULL, *_0, *_1, *_2, *_3, *_4;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &model);



	if (!(ZEPHIR_GLOBAL(orm).column_renaming)) {
		RETURN_MM_NULL();
	}
	ZEPHIR_INIT_VAR(keyName);
	zephir_get_class(keyName, model, 1 TSRMLS_CC);
	ZEPHIR_OBS_VAR(data);
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_columnMap"), PH_NOISY_CC);
	if (!(zephir_array_isset_fetch(&data, _0, keyName, 0 TSRMLS_CC))) {
		ZEPHIR_INIT_VAR(_1);
		ZVAL_NULL(_1);
		ZEPHIR_INIT_VAR(_2);
		ZVAL_NULL(_2);
		ZEPHIR_INIT_VAR(_3);
		ZVAL_NULL(_3);
		ZEPHIR_CALL_METHOD(NULL, this_ptr, "_initialize", NULL, 10, model, _1, _2, _3);
		zephir_check_call_status();
		_4 = zephir_fetch_nproperty_this(this_ptr, SL("_columnMap"), PH_NOISY_CC);
		ZEPHIR_OBS_NVAR(data);
		zephir_array_fetch(&data, _4, keyName, PH_NOISY, "phalcon/mvc/model/metadata.zep", 329 TSRMLS_CC);
	}
	RETURN_CCTOR(data);

}
示例#16
0
PHP_METHOD(Test_Bench_Foo, read_static) {

	int _1;
	zend_bool _0;
	zval *n, *x = NULL, *i = NULL, *_2 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &n);



	ZEPHIR_CPY_WRT(_2, n);
	_1 = 1;
	_0 = 0;
	if (ZEPHIR_GE_LONG(_2, _1)) {
		while (1) {
			if (_0) {
				_1++;
				if (!(ZEPHIR_GE_LONG(_2, _1))) {
					break;
				}
			} else {
				_0 = 1;
			}
			ZEPHIR_INIT_NVAR(i);
			ZVAL_LONG(i, _1);
			ZEPHIR_OBS_NVAR(x);
			zephir_read_static_property_ce(&x, test_bench_foo_ce, SL("a") TSRMLS_CC);
		}
	}
	ZEPHIR_MM_RESTORE();

}
示例#17
0
/**
 * Reads column-map information for certain model using a MODEL_* constant
 *
 *<code>
 * print_r(
 *     $metaData->readColumnMapIndex(
 *         new Robots(),
 *         MetaData::MODELS_REVERSE_COLUMN_MAP
 *     )
 * );
 *</code>
 */
PHP_METHOD(Phalcon_Mvc_Model_MetaData, readColumnMapIndex) {

	int index, ZEPHIR_LAST_CALL_STATUS;
	zval *model, *index_param = NULL, *keyName = NULL, *columnMapModel = NULL, *map = NULL, *_0, *_1$$4, *_2$$4, *_3$$4, *_4$$4;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &model, &index_param);

	index = zephir_get_intval(index_param);


	if (!(ZEPHIR_GLOBAL(orm).column_renaming)) {
		RETURN_MM_NULL();
	}
	ZEPHIR_INIT_VAR(keyName);
	zephir_get_class(keyName, model, 1 TSRMLS_CC);
	ZEPHIR_OBS_VAR(columnMapModel);
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_columnMap"), PH_NOISY_CC);
	if (!(zephir_array_isset_fetch(&columnMapModel, _0, keyName, 0 TSRMLS_CC))) {
		ZEPHIR_INIT_VAR(_1$$4);
		ZVAL_NULL(_1$$4);
		ZEPHIR_INIT_VAR(_2$$4);
		ZVAL_NULL(_2$$4);
		ZEPHIR_INIT_VAR(_3$$4);
		ZVAL_NULL(_3$$4);
		ZEPHIR_CALL_METHOD(NULL, this_ptr, "_initialize", NULL, 10, model, _1$$4, _2$$4, _3$$4);
		zephir_check_call_status();
		_4$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_columnMap"), PH_NOISY_CC);
		ZEPHIR_OBS_NVAR(columnMapModel);
		zephir_array_fetch(&columnMapModel, _4$$4, keyName, PH_NOISY, "phalcon/mvc/model/metadata.zep", 378 TSRMLS_CC);
	}
	zephir_array_isset_long_fetch(&map, columnMapModel, index, 1 TSRMLS_CC);
	RETURN_CTOR(map);

}
示例#18
0
PHP_METHOD(Test_Oo_PropertyAccess, __construct) {

	zval *test, *test1, *_0, *_1, *_2, *_3, *_4, *_5, *_6, *_7 = NULL, *_8, *_9;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(test);
	object_init(test);
	ZEPHIR_INIT_VAR(_0);
	array_init_size(_0, 6);
	ZEPHIR_INIT_VAR(_1);
	ZVAL_LONG(_1, 1);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 2);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 3);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 5);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_DOUBLE(_1, 6.00);
	zephir_array_fast_append(_0, _1);
	zephir_update_property_zval(test, SL("test"), _0 TSRMLS_CC);
	ZEPHIR_OBS_VAR(_2);
	zephir_read_property(&_2, test, SL("test"), PH_NOISY_CC);
	zephir_array_fetch_long(&_3, _2, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
	zephir_update_property_zval(test, SL("test2"), _3 TSRMLS_CC);
	ZEPHIR_OBS_VAR(_4);
	zephir_read_property(&_4, test, SL("test"), PH_NOISY_CC);
	zephir_array_fetch_long(&_5, _4, 1, PH_NOISY | PH_READONLY TSRMLS_CC);
	zephir_update_property_zval(test, SL("test3"), _5 TSRMLS_CC);
	ZEPHIR_INIT_BNVAR(_1);
	array_init_size(_1, 5);
	ZEPHIR_OBS_VAR(_6);
	zephir_read_property(&_6, test, SL("test"), PH_NOISY_CC);
	ZEPHIR_OBS_VAR(_7);
	zephir_array_fetch_long(&_7, _6, 1, PH_NOISY TSRMLS_CC);
	zephir_array_fast_append(_1, _7);
	ZEPHIR_INIT_VAR(_8);
	ZVAL_LONG(_8, 1);
	zephir_array_fast_append(_1, _8);
	ZEPHIR_INIT_BNVAR(_8);
	ZVAL_LONG(_8, 2);
	zephir_array_fast_append(_1, _8);
	ZEPHIR_INIT_BNVAR(_8);
	ZVAL_LONG(_8, 3);
	zephir_array_fast_append(_1, _8);
	zephir_update_property_zval(test, SL("test3"), _1 TSRMLS_CC);
	zephir_update_property_this(this_ptr, SL("a"), test TSRMLS_CC);
	_9 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC);
	ZEPHIR_OBS_NVAR(_7);
	zephir_read_property(&_7, _9, SL("test2"), PH_NOISY_CC);
	zephir_update_property_this(this_ptr, SL("b"), _7 TSRMLS_CC);
	test1 = zephir_fetch_nproperty_this(this_ptr, SL("a"), PH_NOISY_CC);
	ZEPHIR_MM_RESTORE();

}
示例#19
0
PHP_METHOD(Test_Bench_Foo, empty_prop) {

	int _1;
	zend_bool x, _0;
	zval *n, *i = NULL, *_2 = NULL, *_3 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &n);



	ZEPHIR_CPY_WRT(_2, n);
	_1 = 1;
	_0 = 0;
	if (ZEPHIR_GE_LONG(_2, _1)) {
		while (1) {
			if (_0) {
				_1++;
				if (!(ZEPHIR_GE_LONG(_2, _1))) {
					break;
				}
			} else {
				_0 = 1;
			}
			ZEPHIR_INIT_NVAR(i);
			ZVAL_LONG(i, _1);
			ZEPHIR_OBS_NVAR(_3);
			zephir_read_property_this(&_3, this_ptr, SL("b"), PH_NOISY_CC);
			x = ZEPHIR_IS_EMPTY(_3);
		}
	}
	ZEPHIR_MM_RESTORE();

}
示例#20
0
/**
 * Get rewrite info. This info is read from $_GET['_url']. This returns '/' if the rewrite information cannot be read
 *
 * @return string
 */
PHP_METHOD(Test_Router, getRewriteUri) {

	zval *url = NULL, *urlParts, *realUri, *_0, *_GET, *_SERVER;

	ZEPHIR_MM_GROW();

	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_uriSource"), PH_NOISY_CC);
	if (!(zephir_is_true(_0))) {
		ZEPHIR_OBS_VAR(url);
		zephir_get_global(&_GET, SS("_GET") TSRMLS_CC);
		if (zephir_array_isset_string_fetch(&url, _GET, SS("_url"), 0 TSRMLS_CC)) {
			if (!(zephir_is_true(url))) {
				RETURN_CCTOR(url);
			}
		}
	} else {
		ZEPHIR_OBS_NVAR(url);
		zephir_get_global(&_SERVER, SS("_SERVER") TSRMLS_CC);
		if (zephir_array_isset_string_fetch(&url, _SERVER, SS("REQUEST_URI"), 0 TSRMLS_CC)) {
			ZEPHIR_INIT_VAR(urlParts);
			zephir_fast_explode_str(urlParts, SL("?"), url, LONG_MAX TSRMLS_CC);
			zephir_array_fetch_long(&realUri, urlParts, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
			if (!(zephir_is_true(realUri))) {
				RETURN_CTOR(realUri);
			}
		}
	}
	RETURN_MM_STRING("/", 1);

}
示例#21
0
/**
 * This method is automatically called in Phalcon\Db\Adapter\Pdo constructor.
 * Call it when you need to restore a database connection.
 *
 * @param array $descriptor
 * @return boolean
 */
PHP_METHOD(Phalcon_Db_Adapter_Pdo_Sqlite, connect) {

	int ZEPHIR_LAST_CALL_STATUS;
	zephir_fcall_cache_entry *_0 = NULL;
	zval *descriptor = NULL, *dbname;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 0, 1, &descriptor);

	if (!descriptor) {
		ZEPHIR_CPY_WRT(descriptor, ZEPHIR_GLOBAL(global_null));
	} else {
		ZEPHIR_SEPARATE_PARAM(descriptor);
	}


	if (Z_TYPE_P(descriptor) == IS_NULL) {
		ZEPHIR_OBS_NVAR(descriptor);
		zephir_read_property_this(&descriptor, this_ptr, SL("_descriptor"), PH_NOISY_CC);
	}
	ZEPHIR_OBS_VAR(dbname);
	if (!(zephir_array_isset_string_fetch(&dbname, descriptor, SS("dbname"), 0 TSRMLS_CC))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_db_exception_ce, "dbname must be specified", "phalcon/db/adapter/pdo/sqlite.zep", 70);
		return;
	}
	zephir_array_update_string(&descriptor, SL("dsn"), &dbname, PH_COPY | PH_SEPARATE);
	ZEPHIR_CALL_PARENT(NULL, phalcon_db_adapter_pdo_sqlite_ce, this_ptr, "connect", &_0, 141, descriptor);
	zephir_check_call_status();
	ZEPHIR_MM_RESTORE();

}
示例#22
0
PHP_METHOD(Test_Geometry, runOptimize) {

	zephir_fcall_cache_entry *_0 = NULL;
	int count, ZEPHIR_LAST_CALL_STATUS, i;
	zval *list_param = NULL, *count_param = NULL, *item = NULL, *_1$$3, *_2$$3, *_3$$3, *_4$$3;
	zval *list = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &list_param, &count_param);

	zephir_get_arrval(list, list_param);
	count = zephir_get_intval(count_param);


	i = 0;
	while (1) {
		if (!(i < count)) {
			break;
		}
		ZEPHIR_OBS_NVAR(item);
		zephir_array_fetch_long(&item, list, i, PH_NOISY, "test/geometry.zep", 22 TSRMLS_CC);
		zephir_array_fetch_long(&_1$$3, item, 0, PH_NOISY | PH_READONLY, "test/geometry.zep", 24 TSRMLS_CC);
		zephir_array_fetch_long(&_2$$3, item, 1, PH_NOISY | PH_READONLY, "test/geometry.zep", 24 TSRMLS_CC);
		zephir_array_fetch_long(&_3$$3, item, 2, PH_NOISY | PH_READONLY, "test/geometry.zep", 24 TSRMLS_CC);
		zephir_array_fetch_long(&_4$$3, item, 3, PH_NOISY | PH_READONLY, "test/geometry.zep", 24 TSRMLS_CC);
		ZEPHIR_CALL_STATIC(NULL, "distancestatic", &_0, 0, _1$$3, _2$$3, _3$$3, _4$$3);
		zephir_check_call_status();
		i++;
	}
	ZEPHIR_MM_RESTORE();

}
示例#23
0
/**
 * Gets number of rows returned by a resultset
 *
 *<code>
 *	$result = $connection->query("SELECT * FROM robots ORDER BY name");
 *	echo 'There are ', $result->numRows(), ' rows in the resultset';
 *</code>
 */
PHP_METHOD(Phalcon_Db_Result_Pdo, numRows) {

	zend_bool _0$$3;
	zval *sqlStatement = NULL, *rowCount = NULL, *connection = NULL, *type = NULL, *pdoStatement = NULL, *matches = NULL, *result = NULL, *row = NULL, *_1$$6, _2$$6, *_3$$7, *_4$$7, *_5$$7, *_6$$7;
	int ZEPHIR_LAST_CALL_STATUS;

	ZEPHIR_MM_GROW();

	ZEPHIR_OBS_VAR(rowCount);
	zephir_read_property_this(&rowCount, this_ptr, SL("_rowCount"), PH_NOISY_CC);
	if (ZEPHIR_IS_FALSE_IDENTICAL(rowCount)) {
		ZEPHIR_OBS_VAR(connection);
		zephir_read_property_this(&connection, this_ptr, SL("_connection"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(&type, connection, "gettype", NULL, 0);
		zephir_check_call_status();
		_0$$3 = ZEPHIR_IS_STRING(type, "mysql");
		if (!(_0$$3)) {
			_0$$3 = ZEPHIR_IS_STRING(type, "pgsql");
		}
		if (_0$$3) {
			ZEPHIR_OBS_VAR(pdoStatement);
			zephir_read_property_this(&pdoStatement, this_ptr, SL("_pdoStatement"), PH_NOISY_CC);
			ZEPHIR_CALL_METHOD(&rowCount, pdoStatement, "rowcount", NULL, 0);
			zephir_check_call_status();
		}
		if (ZEPHIR_IS_FALSE_IDENTICAL(rowCount)) {
			ZEPHIR_OBS_VAR(sqlStatement);
			zephir_read_property_this(&sqlStatement, this_ptr, SL("_sqlStatement"), PH_NOISY_CC);
			if (!(zephir_start_with_str(sqlStatement, SL("SELECT COUNT(*) ")))) {
				ZEPHIR_INIT_VAR(matches);
				ZVAL_NULL(matches);
				ZEPHIR_INIT_VAR(_1$$6);
				ZEPHIR_SINIT_VAR(_2$$6);
				ZVAL_STRING(&_2$$6, "/^SELECT\\s+(.*)/i", 0);
				zephir_preg_match(_1$$6, &_2$$6, sqlStatement, matches, 0, 0 , 0  TSRMLS_CC);
				if (zephir_is_true(_1$$6)) {
					zephir_array_fetch_long(&_3$$7, matches, 1, PH_NOISY | PH_READONLY, "phalcon/db/result/pdo.zep", 217 TSRMLS_CC);
					ZEPHIR_INIT_VAR(_4$$7);
					ZEPHIR_CONCAT_SVS(_4$$7, "SELECT COUNT(*) \"numrows\" FROM (SELECT ", _3$$7, ")");
					_5$$7 = zephir_fetch_nproperty_this(this_ptr, SL("_bindParams"), PH_NOISY_CC);
					_6$$7 = zephir_fetch_nproperty_this(this_ptr, SL("_bindTypes"), PH_NOISY_CC);
					ZEPHIR_CALL_METHOD(&result, connection, "query", NULL, 0, _4$$7, _5$$7, _6$$7);
					zephir_check_call_status();
					ZEPHIR_CALL_METHOD(&row, result, "fetch", NULL, 0);
					zephir_check_call_status();
					ZEPHIR_OBS_NVAR(rowCount);
					zephir_array_fetch_string(&rowCount, row, SL("numrows"), PH_NOISY, "phalcon/db/result/pdo.zep", 219 TSRMLS_CC);
				}
			} else {
				ZEPHIR_INIT_NVAR(rowCount);
				ZVAL_LONG(rowCount, 1);
			}
		}
		zephir_update_property_this(this_ptr, SL("_rowCount"), rowCount TSRMLS_CC);
	}
	RETURN_CCTOR(rowCount);

}
PHP_METHOD(PocketMine_Math_Vector2, distanceSquared) {

	zephir_nts_static zephir_fcall_cache_entry *_5 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *x, *y = NULL, *_0 = NULL, *_1 = NULL, *_2 = NULL, _3 = zval_used_for_init, _4 = zval_used_for_init, *_6 = NULL, *_7;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &x, &y);

	if (!y) {
		ZEPHIR_INIT_VAR(y);
		ZVAL_LONG(y, 0);
	}


	if (zephir_instance_of_ev(x, pocketmine_math_vector2_ce TSRMLS_CC)) {
		ZEPHIR_OBS_VAR(_1);
		zephir_read_property(&_1, x, SL("x"), PH_NOISY_CC);
		ZEPHIR_OBS_VAR(_2);
		zephir_read_property(&_2, x, SL("y"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(&_0, this_ptr, "distancesquared", NULL, _1, _2);
		zephir_check_call_status();
		RETURN_MM_DOUBLE(zephir_get_doubleval(_0));
	}
	ZEPHIR_OBS_NVAR(_1);
	zephir_read_property_this(&_1, this_ptr, SL("x"), PH_NOISY_CC);
	ZEPHIR_SINIT_VAR(_3);
	ZVAL_DOUBLE(&_3, (zephir_get_doubleval(_1) - zephir_get_doubleval(x)));
	ZEPHIR_SINIT_VAR(_4);
	ZVAL_LONG(&_4, 2);
	ZEPHIR_CALL_FUNCTION(&_0, "pow", &_5, &_3, &_4);
	zephir_check_call_status();
	ZEPHIR_OBS_NVAR(_2);
	zephir_read_property_this(&_2, this_ptr, SL("y"), PH_NOISY_CC);
	ZEPHIR_SINIT_NVAR(_3);
	ZVAL_DOUBLE(&_3, (zephir_get_doubleval(_2) - zephir_get_doubleval(y)));
	ZEPHIR_SINIT_NVAR(_4);
	ZVAL_LONG(&_4, 2);
	ZEPHIR_CALL_FUNCTION(&_6, "pow", &_5, &_3, &_4);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(_7);
	zephir_add_function(_7, _0, _6 TSRMLS_CC);
	RETURN_MM_DOUBLE(zephir_get_doubleval(_7));

}
示例#25
0
/**
 * @param array data
 * @return \Phal\Link
 */
PHP_METHOD(Phal_Format_Reader_Hal_JsonReader, doTransformLink) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *data_param = NULL, *link, *key = NULL;
	zval *data = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 0, &data_param);

	zephir_get_arrval(data, data_param);


	ZEPHIR_INIT_VAR(link);
	object_init_ex(link, phal_link_ce);
	ZEPHIR_CALL_METHOD(NULL, link, "__construct", NULL);
	zephir_check_call_status();
	ZEPHIR_OBS_VAR(key);
	if (zephir_array_isset_string_fetch(&key, data, SS("href"), 0 TSRMLS_CC)) {
		ZEPHIR_CALL_METHOD(NULL, link, "sethref", NULL, key);
		zephir_check_call_status();
	}
	ZEPHIR_OBS_NVAR(key);
	if (zephir_array_isset_string_fetch(&key, data, SS("templated"), 0 TSRMLS_CC)) {
		ZEPHIR_CALL_METHOD(NULL, link, "settemplated", NULL, key);
		zephir_check_call_status();
	}
	ZEPHIR_OBS_NVAR(key);
	if (zephir_array_isset_string_fetch(&key, data, SS("type"), 0 TSRMLS_CC)) {
		ZEPHIR_CALL_METHOD(NULL, link, "settype", NULL, key);
		zephir_check_call_status();
	}
	ZEPHIR_OBS_NVAR(key);
	if (zephir_array_isset_string_fetch(&key, data, SS("deprecation"), 0 TSRMLS_CC)) {
		ZEPHIR_CALL_METHOD(NULL, link, "setdeprecation", NULL, key);
		zephir_check_call_status();
	}
	ZEPHIR_OBS_NVAR(key);
	if (zephir_array_isset_string_fetch(&key, data, SS("name"), 0 TSRMLS_CC)) {
		ZEPHIR_CALL_METHOD(NULL, link, "setname", NULL, key);
		zephir_check_call_status();
	}
	ZEPHIR_OBS_NVAR(key);
	if (zephir_array_isset_string_fetch(&key, data, SS("profile"), 0 TSRMLS_CC)) {
		ZEPHIR_CALL_METHOD(NULL, link, "setprofile", NULL, key);
		zephir_check_call_status();
	}
	ZEPHIR_OBS_NVAR(key);
	if (zephir_array_isset_string_fetch(&key, data, SS("title"), 0 TSRMLS_CC)) {
		ZEPHIR_CALL_METHOD(NULL, link, "settitle", NULL, key);
		zephir_check_call_status();
	}
	ZEPHIR_OBS_NVAR(key);
	if (zephir_array_isset_string_fetch(&key, data, SS("hreflang"), 0 TSRMLS_CC)) {
		ZEPHIR_CALL_METHOD(NULL, link, "sethreflang", NULL, key);
		zephir_check_call_status();
	}
	RETURN_CCTOR(link);

}
示例#26
0
/**
 * Load translates from file
 *
 * @param string file
 * @param int length
 * @param string delimiter
 * @param string enclosure
 */
PHP_METHOD(Phalcon_Translate_Adapter_Csv, _load) {

	zend_bool _6;
	zephir_fcall_cache_entry *_3 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *file, *length, *delimiter, *enclosure, *data = NULL, *fileHandler = NULL, _0 = zval_used_for_init, *_1 = NULL, *_2, *_4, _5 = zval_used_for_init, *_7, *_8 = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 4, 0, &file, &length, &delimiter, &enclosure);



	ZEPHIR_SINIT_VAR(_0);
	ZVAL_STRING(&_0, "rb", 0);
	ZEPHIR_CALL_FUNCTION(&fileHandler, "fopen", NULL, 292, file, &_0);
	zephir_check_call_status();
	if (Z_TYPE_P(fileHandler) != IS_RESOURCE) {
		ZEPHIR_INIT_VAR(_1);
		object_init_ex(_1, phalcon_translate_exception_ce);
		ZEPHIR_INIT_VAR(_2);
		ZEPHIR_CONCAT_SVS(_2, "Error opening translation file '", file, "'");
		ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _2);
		zephir_check_call_status();
		zephir_throw_exception_debug(_1, "phalcon/translate/adapter/csv.zep", 64 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	while (1) {
		ZEPHIR_CALL_FUNCTION(&data, "fgetcsv", &_3, 428, fileHandler, length, delimiter, enclosure);
		zephir_check_call_status();
		if (ZEPHIR_IS_FALSE_IDENTICAL(data)) {
			break;
		}
		zephir_array_fetch_long(&_4, data, 0, PH_NOISY | PH_READONLY, "phalcon/translate/adapter/csv.zep", 74 TSRMLS_CC);
		ZEPHIR_SINIT_NVAR(_0);
		ZVAL_LONG(&_0, 0);
		ZEPHIR_SINIT_NVAR(_5);
		ZVAL_LONG(&_5, 1);
		ZEPHIR_INIT_NVAR(_1);
		zephir_substr(_1, _4, 0 , 1 , 0);
		_6 = ZEPHIR_IS_STRING_IDENTICAL(_1, "#");
		if (!(_6)) {
			_6 = !(zephir_array_isset_long(data, 1));
		}
		if (_6) {
			continue;
		}
		zephir_array_fetch_long(&_7, data, 1, PH_NOISY | PH_READONLY, "phalcon/translate/adapter/csv.zep", 78 TSRMLS_CC);
		ZEPHIR_OBS_NVAR(_8);
		zephir_array_fetch_long(&_8, data, 0, PH_NOISY, "phalcon/translate/adapter/csv.zep", 78 TSRMLS_CC);
		zephir_update_property_array(this_ptr, SL("_translate"), _8, _7 TSRMLS_CC);
	}
	zephir_fclose(fileHandler TSRMLS_CC);
	ZEPHIR_MM_RESTORE();

}
示例#27
0
/**
 * Generate the HTML to label the element
 *
 * @param array attributes
 */
PHP_METHOD(Phalcon_Forms_Element, label) {

	zend_bool _2;
	zephir_fcall_cache_entry *_0 = NULL;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval *attributes = NULL, *internalAttributes = NULL, *label = NULL, *name = NULL, *code = NULL, *_1, *_3$$7, *_4$$8;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 0, 1, &attributes);

	if (!attributes) {
		ZEPHIR_CPY_WRT(attributes, ZEPHIR_GLOBAL(global_null));
	} else {
		ZEPHIR_SEPARATE_PARAM(attributes);
	}


	ZEPHIR_CALL_METHOD(&internalAttributes, this_ptr, "getattributes", NULL, 0);
	zephir_check_call_status();
	ZEPHIR_OBS_VAR(name);
	if (!(zephir_array_isset_string_fetch(&name, internalAttributes, SS("id"), 0 TSRMLS_CC))) {
		ZEPHIR_OBS_NVAR(name);
		zephir_read_property_this(&name, this_ptr, SL("_name"), PH_NOISY_CC);
	}
	if (Z_TYPE_P(attributes) == IS_ARRAY) {
		if (!(zephir_array_isset_string(attributes, SS("for")))) {
			zephir_array_update_string(&attributes, SL("for"), &name, PH_COPY | PH_SEPARATE);
		}
	} else {
		ZEPHIR_INIT_NVAR(attributes);
		zephir_create_array(attributes, 1, 0 TSRMLS_CC);
		zephir_array_update_string(&attributes, SL("for"), &name, PH_COPY | PH_SEPARATE);
	}
	ZEPHIR_INIT_VAR(_1);
	ZVAL_STRING(_1, "<label", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_CE_STATIC(&code, phalcon_tag_ce, "renderattributes", &_0, 4, _1, attributes);
	zephir_check_temp_parameter(_1);
	zephir_check_call_status();
	ZEPHIR_OBS_VAR(label);
	zephir_read_property_this(&label, this_ptr, SL("_label"), PH_NOISY_CC);
	_2 = zephir_is_true(label);
	if (!(_2)) {
		_2 = zephir_is_numeric(label);
	}
	if (_2) {
		ZEPHIR_INIT_VAR(_3$$7);
		ZEPHIR_CONCAT_SVS(_3$$7, ">", label, "</label>");
		zephir_concat_self(&code, _3$$7 TSRMLS_CC);
	} else {
		ZEPHIR_INIT_VAR(_4$$8);
		ZEPHIR_CONCAT_SVS(_4$$8, ">", name, "</label>");
		zephir_concat_self(&code, _4$$8 TSRMLS_CC);
	}
	RETURN_CCTOR(code);

}
示例#28
0
/**
 * Returns the content of the resource as an string
 * Optionally a base path where the resource is located can be set
 */
PHP_METHOD(Phalcon_Assets_Resource, getContent) {

	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval *basePath_param = NULL, *sourcePath = NULL, *completePath = NULL, *content = NULL, *_0, *_1$$5, *_2$$5, *_3$$6, *_4$$6;
	zval *basePath = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 0, 1, &basePath_param);

	if (!basePath_param) {
		ZEPHIR_INIT_VAR(basePath);
		ZVAL_EMPTY_STRING(basePath);
	} else {
		zephir_get_strval(basePath, basePath_param);
	}


	ZEPHIR_OBS_VAR(sourcePath);
	zephir_read_property_this(&sourcePath, this_ptr, SL("_sourcePath"), PH_NOISY_CC);
	if (ZEPHIR_IS_EMPTY(sourcePath)) {
		ZEPHIR_OBS_NVAR(sourcePath);
		zephir_read_property_this(&sourcePath, this_ptr, SL("_path"), PH_NOISY_CC);
	}
	ZEPHIR_INIT_VAR(completePath);
	ZEPHIR_CONCAT_VV(completePath, basePath, sourcePath);
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_local"), PH_NOISY_CC);
	if (zephir_is_true(_0)) {
		if (!((zephir_file_exists(completePath TSRMLS_CC) == SUCCESS))) {
			ZEPHIR_INIT_VAR(_1$$5);
			object_init_ex(_1$$5, phalcon_assets_exception_ce);
			ZEPHIR_INIT_VAR(_2$$5);
			ZEPHIR_CONCAT_SVS(_2$$5, "Resource's content for '", completePath, "' cannot be read");
			ZEPHIR_CALL_METHOD(NULL, _1$$5, "__construct", NULL, 9, _2$$5);
			zephir_check_call_status();
			zephir_throw_exception_debug(_1$$5, "phalcon/assets/resource.zep", 183 TSRMLS_CC);
			ZEPHIR_MM_RESTORE();
			return;
		}
	}
	ZEPHIR_INIT_VAR(content);
	zephir_file_get_contents(content, completePath TSRMLS_CC);
	if (ZEPHIR_IS_FALSE_IDENTICAL(content)) {
		ZEPHIR_INIT_VAR(_3$$6);
		object_init_ex(_3$$6, phalcon_assets_exception_ce);
		ZEPHIR_INIT_VAR(_4$$6);
		ZEPHIR_CONCAT_SVS(_4$$6, "Resource's content for '", completePath, "' cannot be read");
		ZEPHIR_CALL_METHOD(NULL, _3$$6, "__construct", NULL, 9, _4$$6);
		zephir_check_call_status();
		zephir_throw_exception_debug(_3$$6, "phalcon/assets/resource.zep", 192 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	RETURN_CCTOR(content);

}
示例#29
0
文件: std.zep.c 项目: VergilTang/yb
PHP_METHOD(Yb_Std, uniqueValues) {

	HashTable *_1;
	HashPosition _0;
	zephir_fcall_cache_entry *_5 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *uniqueKey = NULL;
	zval *data_param = NULL, *uniqueKey_param = NULL, *k = NULL, *v = NULL, *arr = NULL, *uniqueValue = NULL, **_2, *_3$$4 = NULL, *_4$$4 = NULL, *_6$$5 = NULL, *_7$$5 = NULL;
	zval *data = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &data_param, &uniqueKey_param);

	zephir_get_arrval(data, data_param);
	zephir_get_strval(uniqueKey, uniqueKey_param);


	ZEPHIR_INIT_VAR(arr);
	array_init(arr);
	zephir_is_iterable(data, &_1, &_0, 0, 0, "yb/std.zep", 377);
	for (
	  ; zephir_hash_get_current_data_ex(_1, (void**) &_2, &_0) == SUCCESS
	  ; zephir_hash_move_forward_ex(_1, &_0)
	) {
		ZEPHIR_GET_HMKEY(k, _1, _0);
		ZEPHIR_GET_HVALUE(v, _2);
		if (unlikely(Z_TYPE_P(v) != IS_ARRAY)) {
			ZEPHIR_INIT_NVAR(_3$$4);
			object_init_ex(_3$$4, yb_exception_ce);
			ZEPHIR_INIT_LNVAR(_4$$4);
			ZEPHIR_CONCAT_SV(_4$$4, "Invalid item type, array required at: ", k);
			ZEPHIR_CALL_METHOD(NULL, _3$$4, "__construct", &_5, 2, _4$$4);
			zephir_check_call_status();
			zephir_throw_exception_debug(_3$$4, "yb/std.zep", 368 TSRMLS_CC);
			ZEPHIR_MM_RESTORE();
			return;
		}
		ZEPHIR_OBS_NVAR(uniqueValue);
		if (unlikely(!(zephir_array_isset_fetch(&uniqueValue, v, uniqueKey, 0 TSRMLS_CC)))) {
			ZEPHIR_INIT_NVAR(_6$$5);
			object_init_ex(_6$$5, yb_exception_ce);
			ZEPHIR_INIT_LNVAR(_7$$5);
			ZEPHIR_CONCAT_SV(_7$$5, "Cannot find value of unique at: ", k);
			ZEPHIR_CALL_METHOD(NULL, _6$$5, "__construct", &_5, 2, _7$$5);
			zephir_check_call_status();
			zephir_throw_exception_debug(_6$$5, "yb/std.zep", 371 TSRMLS_CC);
			ZEPHIR_MM_RESTORE();
			return;
		}
		zephir_array_update_zval(&arr, uniqueValue, &ZEPHIR_GLOBAL(global_null), PH_COPY | PH_SEPARATE);
	}
	zephir_array_keys(return_value, arr TSRMLS_CC);
	RETURN_MM();

}
示例#30
0
/**
 * Returns a cached content
 */
PHP_METHOD(Phalcon_Cache_Backend_Libmemcached, get) {

	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval *keyName_param = NULL, *lifetime = NULL, lifetime_sub, __$null, memcache, prefixedKey, cachedContent, _0, _1, _2;
	zval keyName;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&keyName);
	ZVAL_UNDEF(&lifetime_sub);
	ZVAL_NULL(&__$null);
	ZVAL_UNDEF(&memcache);
	ZVAL_UNDEF(&prefixedKey);
	ZVAL_UNDEF(&cachedContent);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_1);
	ZVAL_UNDEF(&_2);

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &keyName_param, &lifetime);

	zephir_get_strval(&keyName, keyName_param);
	if (!lifetime) {
		lifetime = &lifetime_sub;
		lifetime = &__$null;
	}


	ZEPHIR_OBS_VAR(&memcache);
	zephir_read_property(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC);
	if (Z_TYPE_P(&memcache) != IS_OBJECT) {
		ZEPHIR_CALL_METHOD(NULL, this_ptr, "_connect", NULL, 0);
		zephir_check_call_status();
		ZEPHIR_OBS_NVAR(&memcache);
		zephir_read_property(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC);
	}
	zephir_read_property(&_0, this_ptr, SL("_prefix"), PH_NOISY_CC | PH_READONLY);
	ZEPHIR_INIT_VAR(&prefixedKey);
	ZEPHIR_CONCAT_VV(&prefixedKey, &_0, &keyName);
	zephir_update_property_zval(this_ptr, SL("_lastKey"), &prefixedKey);
	ZEPHIR_CALL_METHOD(&cachedContent, &memcache, "get", NULL, 0, &prefixedKey);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&_1, &memcache, "getresultcode", NULL, 0);
	zephir_check_call_status();
	if (ZEPHIR_IS_LONG_IDENTICAL(&_1, 16)) {
		RETURN_MM_NULL();
	}
	if (zephir_is_numeric(&cachedContent)) {
		RETURN_CCTOR(&cachedContent);
	}
	zephir_read_property(&_2, this_ptr, SL("_frontend"), PH_NOISY_CC | PH_READONLY);
	ZEPHIR_RETURN_CALL_METHOD(&_2, "afterretrieve", NULL, 0, &cachedContent);
	zephir_check_call_status();
	RETURN_MM();

}