Exemple #1
0
/**
 * Destroys the active session
 *
 *<code>
 *	var_dump($session->destroy());
 *	var_dump($session->destroy(true));
 *</code>
 */
PHP_METHOD(Phalcon_Session_Adapter, destroy) {

	HashTable *_2$$4;
	HashPosition _1$$4;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *removeData_param = NULL, *_SESSION = NULL, *uniqueId = NULL, *key = NULL, *_0$$4 = NULL, **_3$$4, *_4$$5 = NULL;
	zend_bool removeData;

	ZEPHIR_MM_GROW();
	zephir_get_global(&_SESSION, SS("_SESSION") TSRMLS_CC);
	zephir_fetch_params(1, 0, 1, &removeData_param);

	if (!removeData_param) {
		removeData = 0;
	} else {
		removeData = zephir_get_boolval(removeData_param);
	}


	if (removeData) {
		ZEPHIR_OBS_VAR(uniqueId);
		zephir_read_property_this(&uniqueId, this_ptr, SL("_uniqueId"), PH_NOISY_CC);
		if (!(ZEPHIR_IS_EMPTY(uniqueId))) {
			ZEPHIR_INIT_VAR(_0$$4);
			zephir_is_iterable(_SESSION, &_2$$4, &_1$$4, 1, 0, "phalcon/session/adapter.zep", 262);
			for (
			  ; zephir_hash_get_current_data_ex(_2$$4, (void**) &_3$$4, &_1$$4) == SUCCESS
			  ; zephir_hash_move_forward_ex(_2$$4, &_1$$4)
			) {
				ZEPHIR_GET_HMKEY(key, _2$$4, _1$$4);
				ZEPHIR_GET_HVALUE(_0$$4, _3$$4);
				ZEPHIR_INIT_LNVAR(_4$$5);
				ZEPHIR_CONCAT_VS(_4$$5, uniqueId, "#");
				if (zephir_start_with(key, _4$$5, NULL)) {
					zephir_array_unset(&_SESSION, key, PH_SEPARATE);
				}
			}
			zend_hash_destroy(_2$$4);
			FREE_HASHTABLE(_2$$4);
		} else {
			ZEPHIR_INIT_NVAR(_SESSION);
			array_init(_SESSION);
		}
	}
	if (0) {
		zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC);
	} else {
		zephir_update_property_this(this_ptr, SL("_started"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
	}
	ZEPHIR_RETURN_CALL_FUNCTION("session_destroy", NULL, 32);
	zephir_check_call_status();
	RETURN_MM();

}
Exemple #2
0
PHP_METHOD(Test_TryTest, testTry6) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *a_param = NULL, *e = NULL, *_0 = NULL, *_1 = NULL;
	zend_bool a;

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

	a = zephir_get_boolval(a_param);



	/* try_start_1: */

		if (a) {
			ZEPHIR_INIT_VAR(_0);
			object_init_ex(_0, zend_exception_get_default(TSRMLS_C));
			ZEPHIR_INIT_VAR(_1);
			ZVAL_STRING(_1, "error!", 0);
			ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1);
			zephir_check_temp_parameter(_1);
			zephir_check_call_status_or_jump(try_end_1);
			zephir_throw_exception(_0 TSRMLS_CC);
			goto try_end_1;

		} else {
			ZEPHIR_INIT_LNVAR(_0);
			object_init_ex(_0, spl_ce_RuntimeException);
			ZEPHIR_INIT_NVAR(_1);
			ZVAL_STRING(_1, "error!", 0);
			ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, _1);
			zephir_check_temp_parameter(_1);
			zephir_check_call_status_or_jump(try_end_1);
			zephir_throw_exception(_0 TSRMLS_CC);
			goto try_end_1;

		}

	try_end_1:

	ZEPHIR_CPY_WRT(e, EG(exception));
	if (zephir_instance_of_ev(e, spl_ce_RuntimeException TSRMLS_CC)) {
		zend_clear_exception(TSRMLS_C);
		RETURN_MM_STRING("domain error", 1);
	}
	ZEPHIR_CPY_WRT(e, EG(exception));
	if (zephir_instance_of_ev(e, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
		zend_clear_exception(TSRMLS_C);
		RETURN_MM_STRING("error", 1);
	}
	RETURN_MM_BOOL(0);

}
/**
 * Adds a CSS resource to the collection
 */
PHP_METHOD(Phalcon_Assets_Collection, addCss) {

	int ZEPHIR_LAST_CALL_STATUS;
	zend_bool filter;
	zval *path_param = NULL, *local = NULL, *filter_param = NULL, *attributes = NULL, *collectionLocal = NULL, *collectionAttributes = NULL, *_0;
	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_css_ce);
	ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, 92, path, collectionLocal, (filter ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false)), collectionAttributes);
	zephir_check_call_status();
	zephir_update_property_array_append(this_ptr, SL("_resources"), _0 TSRMLS_CC);
	RETURN_THIS();

}
Exemple #4
0
/**
 * Test\Router constructor
 *
 * @param boolean defaultRoutes
 */
PHP_METHOD(Test_Router, __construct) {

	zephir_fcall_cache_entry *_3 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *_1, *_5;
	zval *defaultRoutes_param = NULL, *routes, *_0, *_2 = NULL, *_4;
	zend_bool defaultRoutes;

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

	if (!defaultRoutes_param) {
		defaultRoutes = 1;
	} else {
		defaultRoutes = zephir_get_boolval(defaultRoutes_param);
	}


	ZEPHIR_INIT_VAR(routes);
	array_init(routes);
	if ((defaultRoutes == 1)) {
		ZEPHIR_INIT_VAR(_0);
		object_init_ex(_0, test_router_route_ce);
		ZEPHIR_INIT_VAR(_1);
		array_init_size(_1, 2);
		add_assoc_long_ex(_1, SS("controller"), 1);
		ZEPHIR_INIT_VAR(_2);
		ZVAL_STRING(_2, "#^/([a-zA-Z0-9\\_\\-]+)[/]{0,1}$#", 0);
		ZEPHIR_CALL_METHOD(NULL, _0, "__construct", &_3, _2, _1);
		zephir_check_temp_parameter(_2);
		zephir_check_call_status();
		zephir_array_append(&routes, _0, PH_SEPARATE);
		ZEPHIR_INIT_VAR(_4);
		object_init_ex(_4, test_router_route_ce);
		ZEPHIR_INIT_VAR(_5);
		array_init_size(_5, 5);
		add_assoc_long_ex(_5, SS("controller"), 1);
		add_assoc_long_ex(_5, SS("action"), 2);
		add_assoc_long_ex(_5, SS("params"), 3);
		ZEPHIR_INIT_NVAR(_2);
		ZVAL_STRING(_2, "#^/([a-zA-Z0-9\\_\\-]+)/([a-zA-Z0-9\\.\\_]+)(/.*)*$#", 0);
		ZEPHIR_CALL_METHOD(NULL, _4, "__construct", &_3, _2, _5);
		zephir_check_temp_parameter(_2);
		zephir_check_call_status();
		zephir_array_append(&routes, _4, PH_SEPARATE);
	}
	ZEPHIR_INIT_NVAR(_2);
	array_init(_2);
	zephir_update_property_this(this_ptr, SL("_params"), _2 TSRMLS_CC);
	zephir_update_property_this(this_ptr, SL("_routes"), routes TSRMLS_CC);
	ZEPHIR_MM_RESTORE();

}
Exemple #5
0
/**
 * Tells the event manager if it needs to collect all the responses returned by every
 * registered listener in a single fire
 *
 * @param boolean collect
 */
PHP_METHOD(Phalcon_Events_Manager, collectResponses) {

	zval *collect_param = NULL;
	zend_bool collect;

	zephir_fetch_params(0, 1, 0, &collect_param);

	collect = zephir_get_boolval(collect_param);


	zephir_update_property_this(this_ptr, SL("_collect"), collect ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);

}
Exemple #6
0
/**
 * Set if priorities are enabled in the EventsManager
 *
 * @param boolean enablePriorities
 */
PHP_METHOD(Phalcon_Events_Manager, enablePriorities) {

	zval *enablePriorities_param = NULL;
	zend_bool enablePriorities;

	zephir_fetch_params(0, 1, 0, &enablePriorities_param);

	enablePriorities = zephir_get_boolval(enablePriorities_param);


	zephir_update_property_this(this_ptr, SL("_enablePriorities"), enablePriorities ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);

}
/**
 * Sets flag to rollback on abort the HTTP connection
 */
PHP_METHOD(Phalcon_Mvc_Model_Transaction, setRollbackOnAbort) {

	zval *rollbackOnAbort_param = NULL;
	zend_bool rollbackOnAbort;

	zephir_fetch_params(0, 1, 0, &rollbackOnAbort_param);

	rollbackOnAbort = zephir_get_boolval(rollbackOnAbort_param);


	zephir_update_property_this(this_ptr, SL("_rollbackOnAbort"), rollbackOnAbort ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);

}
/**
 * Sets if is a reused transaction or new once
 */
PHP_METHOD(Phalcon_Mvc_Model_Transaction, setIsNewTransaction) {

	zval *isNew_param = NULL;
	zend_bool isNew;

	zephir_fetch_params(0, 1, 0, &isNew_param);

	isNew = zephir_get_boolval(isNew_param);


	zephir_update_property_this(this_ptr, SL("_isNewTransaction"), isNew ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);

}
Exemple #9
0
PHP_METHOD(Test_Oo_OoParams, setStrictEnabled) {

	zval *enabled_param = NULL;
	zend_bool enabled;

	zephir_fetch_params(0, 1, 0, &enabled_param);

	enabled = zephir_get_boolval(enabled_param);


	RETURN_BOOL(enabled);

}
/**
 * Commits the active transaction in the connection
 *
 * @param boolean nesting
 * @return boolean
 */
PHP_METHOD(Pdm_Db_Adapter_AbstractPdo, commit) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *nesting_param = NULL, *transactionLevel = NULL, *savepointName = NULL, *_0, *_1 = NULL;
	zend_bool nesting;

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

	if (!nesting_param) {
		nesting = 1;
	} else {
		nesting = zephir_get_boolval(nesting_param);
	}


	_0 = zephir_fetch_nproperty_this(this_ptr, SL("transactionLevel"), PH_NOISY_CC);
	ZEPHIR_CPY_WRT(transactionLevel, _0);
	if (!(zephir_is_true(transactionLevel))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(pdm_db_adapter_exception_ce, "There is no active transaction", "pdm/db/adapter/abstractpdo.zep", 473);
		return;
	}
	if (ZEPHIR_IS_LONG(transactionLevel, 1)) {
		RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("transactionLevel") TSRMLS_CC));
		_0 = zephir_fetch_nproperty_this(this_ptr, SL("pdo"), PH_NOISY_CC);
		ZEPHIR_RETURN_CALL_METHOD(_0, "commit", NULL);
		zephir_check_call_status();
		RETURN_MM();
	} else {
		if (zephir_is_true(transactionLevel)) {
			if (nesting) {
				ZEPHIR_CALL_METHOD(&_1, this_ptr, "isnestedtransactionswithsavepoints",  NULL);
				zephir_check_call_status();
				if (zephir_is_true(_1)) {
					ZEPHIR_CALL_METHOD(&savepointName, this_ptr, "getnestedtransactionsavepointname",  NULL);
					zephir_check_call_status();
					RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("transactionLevel") TSRMLS_CC));
					ZEPHIR_RETURN_CALL_METHOD(this_ptr, "releasesavepoint", NULL, savepointName);
					zephir_check_call_status();
					RETURN_MM();
				}
			}
		}
	}
	if (ZEPHIR_GT_LONG(transactionLevel, 0)) {
		RETURN_ON_FAILURE(zephir_property_decr(this_ptr, SL("transactionLevel") TSRMLS_CC));
	}
	RETURN_MM_BOOL(0);

}
Exemple #11
0
/**
 * Sets if the resource must be filtered or not
 */
PHP_METHOD(Phalcon_Assets_Inline, setFilter) {

	zval *filter_param = NULL;
	zend_bool filter;

	zephir_fetch_params(0, 1, 0, &filter_param);

	filter = zephir_get_boolval(filter_param);


	zephir_update_property_this(this_ptr, SL("_filter"), filter ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
	RETURN_THISW();

}
Exemple #12
0
/**
 * Set if the resultset is fresh or an old one cached
 */
PHP_METHOD(Phalcon_Mvc_Model_Resultset, setIsFresh) {

	zval *isFresh_param = NULL;
	zend_bool isFresh;

	zephir_fetch_params(0, 1, 0, &isFresh_param);

	isFresh = zephir_get_boolval(isFresh_param);


	zephir_update_property_this(this_ptr, SL("_isFresh"), isFresh ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
	RETURN_THISW();

}
Exemple #13
0
/**
 * Set whether the output must be implicitly flushed to the output or returned as string
 */
PHP_METHOD(Phalcon_Flash, setImplicitFlush) {

	zval *implicitFlush_param = NULL;
	zend_bool implicitFlush;

	zephir_fetch_params(0, 1, 0, &implicitFlush_param);

	implicitFlush = zephir_get_boolval(implicitFlush_param);


	zephir_update_property_this(this_ptr, SL("_implicitFlush"), implicitFlush ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
	RETURN_THISW();

}
Exemple #14
0
/**
 * Set if the output must be implicitly formatted with HTML
 */
PHP_METHOD(Phalcon_Flash, setAutomaticHtml) {

	zval *automaticHtml_param = NULL;
	zend_bool automaticHtml;

	zephir_fetch_params(0, 1, 0, &automaticHtml_param);

	automaticHtml = zephir_get_boolval(automaticHtml_param);


	zephir_update_property_this(this_ptr, SL("_automaticHtml"), automaticHtml ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
	RETURN_THISW();

}
Exemple #15
0
/**
 * Sets if files must be completely opened and showed in the output
 * or just the fragment related to the exception
 */
PHP_METHOD(Phalcon_Debug, setShowFileFragment) {

	zval *showFileFragment_param = NULL;
	zend_bool showFileFragment;

	zephir_fetch_params(0, 1, 0, &showFileFragment_param);

	showFileFragment = zephir_get_boolval(showFileFragment_param);


	zephir_update_property_this(this_ptr, SL("_showFileFragment"), showFileFragment ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
	RETURN_THISW();

}
Exemple #16
0
/**
 * Add servers to memcache pool
 */
PHP_METHOD(Phalcon_Cache_Backend_Memcache, addServers) {

    zend_bool persistent;
    int port, ZEPHIR_LAST_CALL_STATUS;
    zval *host_param = NULL, *port_param = NULL, *persistent_param = NULL, *memcache = NULL, *success = NULL, *_0, *_1;
    zval *host = NULL;

    ZEPHIR_MM_GROW();
    zephir_fetch_params(1, 2, 1, &host_param, &port_param, &persistent_param);

    if (unlikely(Z_TYPE_P(host_param) != IS_STRING && Z_TYPE_P(host_param) != IS_NULL)) {
        zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'host' must be a string") TSRMLS_CC);
        RETURN_MM_NULL();
    }
    if (likely(Z_TYPE_P(host_param) == IS_STRING)) {
        zephir_get_strval(host, host_param);
    } else {
        ZEPHIR_INIT_VAR(host);
        ZVAL_EMPTY_STRING(host);
    }
    port = zephir_get_intval(port_param);
    if (!persistent_param) {
        persistent = 0;
    } else {
        persistent = zephir_get_boolval(persistent_param);
    }


    ZEPHIR_OBS_VAR(memcache);
    zephir_read_property_this(&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_this(&memcache, this_ptr, SL("_memcache"), PH_NOISY_CC);
    }
    ZEPHIR_INIT_VAR(_0);
    ZVAL_LONG(_0, port);
    ZEPHIR_INIT_VAR(_1);
    if (persistent) {
        ZVAL_BOOL(_1, 1);
    } else {
        ZVAL_BOOL(_1, 0);
    }
    ZEPHIR_CALL_METHOD(&success, memcache, "addserver", NULL, 0, host, _0, _1);
    zephir_check_call_status();
    zephir_update_property_this(this_ptr, SL("_memcache"), memcache TSRMLS_CC);
    RETURN_CCTOR(success);

}
Exemple #17
0
/**
 * Decodes a JSON-encoded string into an object or array
 *
 * @param string $json A well-formed JSON string.
 * @param boolean $assoc [Optional] Whether to decode to an associative array. Default false.
 * @param int $depth [Optional] Depth to decode to. Default 512
 * @param int $flags [Optional] Bitwise flags for use in json_decode(). Default is 0
 * @return object|array|null JSON data decoded to object(s) or array(s).
 */
PHP_METHOD(Xpl_Json, decode) {

	int depth, flags;
	zend_bool assoc;
	zval *json_param = NULL, *assoc_param = NULL, *depth_param = NULL, *flags_param = NULL, _0, _1, _2;
	zval *json = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 3, &json_param, &assoc_param, &depth_param, &flags_param);

	if (unlikely(Z_TYPE_P(json_param) != IS_STRING && Z_TYPE_P(json_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'json' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(json_param) == IS_STRING)) {
		zephir_get_strval(json, json_param);
	} else {
		ZEPHIR_INIT_VAR(json);
		ZVAL_EMPTY_STRING(json);
	}
	if (!assoc_param) {
		assoc = 0;
	} else {
		assoc = zephir_get_boolval(assoc_param);
	}
	if (!depth_param) {
		depth = 512;
	} else {
		depth = zephir_get_intval(depth_param);
	}
	if (!flags_param) {
		flags = 0;
	} else {
		flags = zephir_get_intval(flags_param);
	}


	if (ZEPHIR_IS_EMPTY(json)) {
		RETURN_MM_NULL();
	}
	ZEPHIR_SINIT_VAR(_0);
	ZVAL_BOOL(&_0, (assoc ? 1 : 0));
	ZEPHIR_SINIT_VAR(_1);
	ZVAL_LONG(&_1, depth);
	ZEPHIR_SINIT_VAR(_2);
	ZVAL_LONG(&_2, flags);
	zephir_json_decode(return_value, &(return_value), json, zephir_get_intval(&_0)  TSRMLS_CC);
	RETURN_MM();

}
Exemple #18
0
/**
 * Set if cookies in the bag must be automatically encrypted/decrypted
 */
PHP_METHOD(Phalcon_Http_Response_Cookies, useEncryption) {

	zval *useEncryption_param = NULL;
	zend_bool useEncryption;

	zephir_fetch_params(0, 1, 0, &useEncryption_param);

	useEncryption = zephir_get_boolval(useEncryption_param);


	zephir_update_property_this(this_ptr, SL("_useEncryption"), useEncryption ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
	RETURN_THISW();

}
/**
 * Sets if all filtered resources in the collection must be joined in a single result file
 */
PHP_METHOD(Phalcon_Assets_Collection, join) {

	zval *join_param = NULL;
	zend_bool join;

	zephir_fetch_params(0, 1, 0, &join_param);

	join = zephir_get_boolval(join_param);


	zephir_update_property_this(this_ptr, SL("_join"), join ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
	RETURN_THISW();

}
Exemple #20
0
/**
 * 检查字符串长度。
 * @param string str 字符串。
 * @param int min 最小长度。
 * @param int max 最大长度。
 * @param bool is_utf8 是否UTF-8字符。
 * @return boolean
 */
PHP_METHOD(Winer_Validator, len) {

	zend_bool is_utf8, _1;
	int min, max, len, ZEPHIR_LAST_CALL_STATUS;
	zval *str_param = NULL, *min_param = NULL, *max_param = NULL, *is_utf8_param = NULL, *_0 = NULL;
	zval *str = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 3, &str_param, &min_param, &max_param, &is_utf8_param);

	zephir_get_strval(str, str_param);
	if (!min_param) {
		min = 0;
	} else {
		min = zephir_get_intval(min_param);
	}
	if (!max_param) {
		max = 255;
	} else {
		max = zephir_get_intval(max_param);
	}
	if (!is_utf8_param) {
		is_utf8 = 0;
	} else {
		is_utf8 = zephir_get_boolval(is_utf8_param);
	}


	ZEPHIR_INIT_VAR(_0);
	if (is_utf8) {
		ZEPHIR_CALL_FUNCTION(&_0, "mb_strlen", NULL, str);
		zephir_check_call_status();
	} else {
		ZEPHIR_INIT_NVAR(_0);
		ZVAL_LONG(_0, zephir_fast_strlen_ev(str));
	}
	len = zephir_get_numberval(_0);
	_1 = (len >= min);
	if (_1) {
		_1 = (len <= max);
	}
	if (_1) {
		RETURN_MM_BOOL(1);
	} else {
		RETURN_MM_BOOL(0);
	}

}
PHP_METHOD(PocketMine_Level_Generator_Noise_Generator, noise3D) {

	zephir_fcall_cache_entry *_5 = NULL;
	int i = 0, ZEPHIR_LAST_CALL_STATUS;
	zend_bool normalized;
	zval *x_param = NULL, *y_param = NULL, *z_param = NULL, *normalized_param = NULL, *_0, *_1 = NULL, *_2 = NULL, *_3 = NULL, *_4 = NULL, *_6, *_7;
	double x, y, z, result = 0, amp = 1, freq = 1, max = 0;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 3, 1, &x_param, &y_param, &z_param, &normalized_param);

	x = zephir_get_doubleval(x_param);
	y = zephir_get_doubleval(y_param);
	z = zephir_get_doubleval(z_param);
	if (!normalized_param) {
		normalized = 0;
	} else {
		normalized = zephir_get_boolval(normalized_param);
	}


	while (1) {
		_0 = zephir_fetch_nproperty_this(this_ptr, SL("octaves"), PH_NOISY_CC);
		if (!(ZEPHIR_GT_LONG(_0, i))) {
			break;
		}
		ZEPHIR_INIT_NVAR(_2);
		ZVAL_DOUBLE(_2, (x * freq));
		ZEPHIR_INIT_NVAR(_3);
		ZVAL_DOUBLE(_3, (y * freq));
		ZEPHIR_INIT_NVAR(_4);
		ZVAL_DOUBLE(_4, (z * freq));
		ZEPHIR_CALL_METHOD(&_1, this_ptr, "getnoise3d", &_5, _2, _3, _4);
		zephir_check_call_status();
		result += (double) (zephir_get_doubleval(_1) * amp);
		max += amp;
		_6 = zephir_fetch_nproperty_this(this_ptr, SL("frequency"), PH_NOISY_CC);
		freq *= zephir_get_numberval(_6);
		_7 = zephir_fetch_nproperty_this(this_ptr, SL("amplitude"), PH_NOISY_CC);
		amp *= zephir_get_numberval(_7);
		i++;
	}
	if (normalized == 1) {
		result = (result / max);
	}
	RETURN_MM_DOUBLE(result);

}
Exemple #22
0
/**
 * Returns a new \Phalcon\Mvc\Model\Transaction or an already created once
 * This method registers a shutdown function to rollback active connections
 */
PHP_METHOD(Phalcon_Mvc_Model_Transaction_Manager, get) {

	zval *_2$$4;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval *autoBegin_param = NULL, *_0, *_4, *_1$$3, *_3$$4;
	zend_bool autoBegin;

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

	if (!autoBegin_param) {
		autoBegin = 1;
	} else {
		autoBegin = zephir_get_boolval(autoBegin_param);
	}


	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_initialized"), PH_NOISY_CC);
	if (!(zephir_is_true(_0))) {
		_1$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_rollbackPendent"), PH_NOISY_CC);
		if (zephir_is_true(_1$$3)) {
			ZEPHIR_INIT_VAR(_2$$4);
			zephir_create_array(_2$$4, 2, 0 TSRMLS_CC);
			zephir_array_fast_append(_2$$4, this_ptr);
			ZEPHIR_INIT_VAR(_3$$4);
			ZVAL_STRING(_3$$4, "rollbackPendent", 1);
			zephir_array_fast_append(_2$$4, _3$$4);
			ZEPHIR_CALL_FUNCTION(NULL, "register_shutdown_function", NULL, 382, _2$$4);
			zephir_check_call_status();
		}
		if (1) {
			zephir_update_property_this(getThis(), SL("_initialized"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC);
		} else {
			zephir_update_property_this(getThis(), SL("_initialized"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
		}
	}
	ZEPHIR_INIT_VAR(_4);
	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();

}
Exemple #23
0
/**
 * Sets the bound parameters in the criteria
 * This method replaces all previously set bound parameters
 */
PHP_METHOD(Phalcon_Mvc_Model_Criteria, bind) {

	zend_bool merge;
	zval *bindParams_param = NULL, *merge_param = NULL, *bind = NULL, *_0$$3, *_1$$4, *_2$$6, *_3$$6, *_4$$7, *_5$$8;
	zval *bindParams = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &bindParams_param, &merge_param);

	bindParams = bindParams_param;
	if (!merge_param) {
		merge = 0;
	} else {
		merge = zephir_get_boolval(merge_param);
	}


	if (merge) {
		_0$$3 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC);
		if (zephir_array_isset_string(_0$$3, SS("bind"))) {
			_1$$4 = zephir_fetch_nproperty_this(this_ptr, SL("_params"), PH_NOISY_CC);
			ZEPHIR_OBS_VAR(bind);
			zephir_array_fetch_string(&bind, _1$$4, SL("bind"), PH_NOISY, "phalcon/mvc/model/criteria.zep", 106 TSRMLS_CC);
		} else {
			ZEPHIR_INIT_NVAR(bind);
			ZVAL_NULL(bind);
		}
		if (Z_TYPE_P(bind) == IS_ARRAY) {
			ZEPHIR_INIT_VAR(_2$$6);
			zephir_add_function(_2$$6, bind, bindParams);
			ZEPHIR_INIT_VAR(_3$$6);
			ZVAL_STRING(_3$$6, "bind", 1);
			zephir_update_property_array(this_ptr, SL("_params"), _3$$6, _2$$6 TSRMLS_CC);
		} else {
			ZEPHIR_INIT_VAR(_4$$7);
			ZVAL_STRING(_4$$7, "bind", 1);
			zephir_update_property_array(this_ptr, SL("_params"), _4$$7, bindParams TSRMLS_CC);
		}
	} else {
		ZEPHIR_INIT_VAR(_5$$8);
		ZVAL_STRING(_5$$8, "bind", 1);
		zephir_update_property_array(this_ptr, SL("_params"), _5$$8, bindParams TSRMLS_CC);
	}
	RETURN_THIS();

}
Exemple #24
0
PHP_METHOD(Test_Mcall, optionalParameterBoolFalse) {

	zval *param_param = NULL;
	zend_bool param;

	zephir_fetch_params(0, 0, 1, &param_param);

	if (!param_param) {
		param = 0;
	} else {
		param = zephir_get_boolval(param_param);
	}


	RETURN_BOOL(param);

}
Exemple #25
0
/**
 * For bool parameter
 * @link https://github.com/phalcon/zephir/issues/696
 */
PHP_METHOD(Test_MethodArgs, methodOptionalBoolValueWithDefaultStaticConstantAccess) {

	zval *parameter_param = NULL;
	zend_bool parameter;

	zephir_fetch_params(0, 0, 1, &parameter_param);

	if (!parameter_param) {
		parameter = 1;
	} else {
		parameter = zephir_get_boolval(parameter_param);
	}


	RETURN_BOOL(parameter);

}
Exemple #26
0
PHP_METHOD(Yb_Std, valueAt) {

	int ZEPHIR_LAST_CALL_STATUS;
	zend_bool noException, _0;
	zval *key = NULL, *_2$$4;
	zval *arr_param = NULL, *key_param = NULL, *defaultValue = NULL, *noException_param = NULL, *value = NULL, *_1$$4;
	zval *arr = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 2, &arr_param, &key_param, &defaultValue, &noException_param);

	zephir_get_arrval(arr, arr_param);
	zephir_get_strval(key, key_param);
	if (!defaultValue) {
		defaultValue = ZEPHIR_GLOBAL(global_null);
	}
	if (!noException_param) {
		noException = 0;
	} else {
		noException = zephir_get_boolval(noException_param);
	}


	ZEPHIR_OBS_VAR(value);
	if (zephir_array_isset_fetch(&value, arr, key, 0 TSRMLS_CC)) {
		RETURN_CCTOR(value);
	}
	_0 = Z_TYPE_P(defaultValue) == IS_NULL;
	if (_0) {
		_0 = !noException;
	}
	if (unlikely(_0)) {
		ZEPHIR_INIT_VAR(_1$$4);
		object_init_ex(_1$$4, yb_exception_ce);
		ZEPHIR_INIT_VAR(_2$$4);
		ZEPHIR_CONCAT_SV(_2$$4, "Missing value at: ", key);
		ZEPHIR_CALL_METHOD(NULL, _1$$4, "__construct", NULL, 2, _2$$4);
		zephir_check_call_status();
		zephir_throw_exception_debug(_1$$4, "yb/std.zep", 216 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	RETVAL_ZVAL(defaultValue, 1, 0);
	RETURN_MM();

}
Exemple #27
0
PHP_METHOD(Test_Exists, testInterfaceExists) {

	zend_bool autoload;
	zval *interfaceName, *autoload_param = NULL;

	zephir_fetch_params(0, 1, 1, &interfaceName, &autoload_param);

	if (!autoload_param) {
		autoload = 1;
	} else {
		autoload = zephir_get_boolval(autoload_param);
	}


	RETURN_BOOL(zephir_interface_exists(interfaceName, ZEPHIR_IS_TRUE((autoload ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false)))  TSRMLS_CC));

}
/**
 * Constructor
 *
 * @param boolean pretty
 */
PHP_METHOD(Phal_Format_AbstractWriter, __construct) {

	zval *pretty_param = NULL;
	zend_bool pretty;

	zephir_fetch_params(0, 0, 1, &pretty_param);

	if (!pretty_param) {
		pretty = 0;
	} else {
		pretty = zephir_get_boolval(pretty_param);
	}


	zephir_update_property_this(this_ptr, SL("pretty"), pretty ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);

}
Exemple #29
0
/**
 * Sets if the service is shared or not
 */
PHP_METHOD(Phalcon_Di_Service, setShared) {

	zval *shared_param = NULL;
	zend_bool shared;

	zephir_fetch_params(0, 1, 0, &shared_param);

	shared = zephir_get_boolval(shared_param);


	if (shared) {
		zephir_update_property_this(this_ptr, SL("_shared"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC);
	} else {
		zephir_update_property_this(this_ptr, SL("_shared"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
	}

}
Exemple #30
0
/**
 * Sets the double_encode to be used by the escaper
 *
 *<code>
 * $escaper->setDoubleEncode(false);
 *</code>
 */
PHP_METHOD(Phalcon_Escaper, setDoubleEncode) {

	zval *doubleEncode_param = NULL;
	zend_bool doubleEncode;

	zephir_fetch_params(0, 1, 0, &doubleEncode_param);

	doubleEncode = zephir_get_boolval(doubleEncode_param);


	if (doubleEncode) {
		zephir_update_property_this(getThis(), SL("_doubleEncode"), ZEPHIR_GLOBAL(global_true) TSRMLS_CC);
	} else {
		zephir_update_property_this(getThis(), SL("_doubleEncode"), ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
	}

}