Beispiel #1
0
PHP_METHOD(Test_TryTest, testTry4) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *a_param = 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_INIT_NVAR(_1);
	ZEPHIR_CPY_WRT(_1, EG(exception));
	if (zephir_instance_of_ev(_1, spl_ce_RuntimeException TSRMLS_CC)) {
		zend_clear_exception(TSRMLS_C);
		RETURN_MM_STRING("domain error", 1);
	}
	ZEPHIR_INIT_NVAR(_1);
	ZEPHIR_CPY_WRT(_1, EG(exception));
	if (zephir_instance_of_ev(_1, zend_exception_get_default(TSRMLS_C) TSRMLS_CC)) {
		zend_clear_exception(TSRMLS_C);
		RETURN_MM_STRING("error", 1);
	}
	RETURN_MM_BOOL(0);

}
Beispiel #2
0
PHP_METHOD(Test_TryTest, testTry2) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *_0, *_1;

	ZEPHIR_MM_GROW();


	/* try_start_1: */

		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;


	try_end_1:

	zend_clear_exception(TSRMLS_C);
	ZEPHIR_MM_RESTORE();

}
Beispiel #3
0
PHP_METHOD(Test_TryTest, testTry3) {

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

	ZEPHIR_MM_GROW();


	/* try_start_1: */

		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;


	try_end_1:

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

}
Beispiel #4
0
/**
 * Set a group of paths to be returned when none of the defined routes are matched
 *
 * @param array paths
 * @return Test\Router
 */
PHP_METHOD(Test_Router, notFound) {

	zval *paths, *_0, *_1;

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



	if ((Z_TYPE_P(paths) != IS_ARRAY)) {
		if ((Z_TYPE_P(paths) != IS_STRING)) {
			ZEPHIR_INIT_VAR(_0);
			object_init_ex(_0, test_router_exception_ce);
			ZEPHIR_INIT_VAR(_1);
			ZVAL_STRING(_1, "The not-found paths must be an array or string", 1);
			zephir_call_method_p1_noret(_0, "__construct", _1);
			zephir_throw_exception(_0 TSRMLS_CC);
			ZEPHIR_MM_RESTORE();
			return;
		}
	}
	zephir_update_property_this(this_ptr, SL("_notFoundPaths"), paths TSRMLS_CC);
	RETURN_THIS();

}
Beispiel #5
0
PHP_METHOD(Test_Exceptions, testException4) {

	zval *_0;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(_0);
	zephir_call_method(_0, this_ptr, "getexception");
	zephir_throw_exception(_0 TSRMLS_CC);
	ZEPHIR_MM_RESTORE();
	return;

}
Beispiel #6
0
PHP_METHOD(Test_Exceptions, testException4) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *_0 = NULL;

	ZEPHIR_MM_GROW();

	ZEPHIR_CALL_METHOD(&_0, this_ptr, "getexception",  NULL);
	zephir_check_call_status();
	zephir_throw_exception(_0 TSRMLS_CC);
	ZEPHIR_MM_RESTORE();
	return;

}
Beispiel #7
0
PHP_METHOD(OAuth_V1_Service, getAuthorizationUri) {

	zend_function *_6 = NULL;
	HashTable *_4;
	HashPosition _3;
	zend_class_entry *_1;
	zval *params = NULL, *uri, *endpoint, *key = NULL, *value = NULL, *_0, *_2, **_5;

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

	if (!params) {
		params = ZEPHIR_GLOBAL(global_null);
	}


	if (((Z_TYPE_P(params) != IS_ARRAY) && (Z_TYPE_P(params) != IS_NULL))) {
		ZEPHIR_INIT_VAR(_0);
		_1 = zend_fetch_class(SL("InvalidArgumentException"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
		object_init_ex(_0, _1);
		ZEPHIR_INIT_VAR(_2);
		ZVAL_STRING(_2, "The params must be an Array", 1);
		zephir_call_method_p1_noret(_0, "__construct", _2);
		zephir_throw_exception(_0 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	ZEPHIR_INIT_VAR(endpoint);
	object_init_ex(endpoint, oauth_uri_ce);
	zephir_call_method_noret(endpoint, "__construct");
	ZEPHIR_INIT_VAR(uri);
	if (zephir_clone(uri, endpoint TSRMLS_CC) == FAILURE) {
		RETURN_MM();
	}
	if ((Z_TYPE_P(params) != IS_ARRAY)) {
		zephir_is_iterable(params, &_4, &_3, 0, 0);
		for (
			; zend_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS
			; zend_hash_move_forward_ex(_4, &_3)
		) {
			ZEPHIR_GET_HMKEY(key, _4, _3);
			ZEPHIR_GET_HVALUE(value, _5);
			zephir_call_method_p2_cache_noret(uri, "addtoquery", &_6, key, value);
		}
	}
	RETURN_CCTOR(uri);

}
Beispiel #8
0
PHP_METHOD(Test_Exceptions, testException2) {

	zval *msg, *_0;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(msg);
	ZVAL_STRING(msg, "hello2", 1);
	ZEPHIR_INIT_VAR(_0);
	object_init_ex(_0, test_exception_ce);
	zephir_call_method_p1_noret(_0, "__construct", msg);
	zephir_throw_exception(_0 TSRMLS_CC);
	ZEPHIR_MM_RESTORE();
	return;

}
Beispiel #9
0
PHP_METHOD(Test_Exceptions, testException3) {

	zval *ex, *msg;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(msg);
	ZVAL_STRING(msg, "hello3", 1);
	ZEPHIR_INIT_VAR(ex);
	object_init_ex(ex, test_exception_ce);
	zephir_call_method_p1_noret(ex, "__construct", msg);
	zephir_throw_exception(ex TSRMLS_CC);
	ZEPHIR_MM_RESTORE();
	return;

}
Beispiel #10
0
PHP_METHOD(Test_Exceptions, testException3) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *ex, *msg;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(msg);
	ZVAL_STRING(msg, "hello3", 1);
	ZEPHIR_INIT_VAR(ex);
	object_init_ex(ex, test_exception_ce);
	ZEPHIR_CALL_METHOD(NULL, ex, "__construct", NULL, msg);
	zephir_check_call_status();
	zephir_throw_exception(ex TSRMLS_CC);
	ZEPHIR_MM_RESTORE();
	return;

}
Beispiel #11
0
PHP_METHOD(Test_TryTest, testThrow2) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *message, *_0;

	ZEPHIR_MM_GROW();
	ZEPHIR_INIT_VAR(message);
	ZVAL_STRING(message, "error", 1);

	ZEPHIR_INIT_VAR(_0);
	object_init_ex(_0, zend_exception_get_default(TSRMLS_C));
	ZEPHIR_CALL_METHOD(NULL, _0, "__construct", NULL, message);
	zephir_check_call_status();
	zephir_throw_exception(_0 TSRMLS_CC);
	ZEPHIR_MM_RESTORE();
	return;

}
Beispiel #12
0
/**
 * Build signature string from array.
 *
 * @param array signatureData
 * @return string
 */
PHP_METHOD(OAuth_V1_Signature, buildSignatureString) {

	HashTable *_4;
	HashPosition _3;
	zend_class_entry *_1;
	zval *signatureData, *signatureString = NULL, *delimiter = NULL, *key = NULL, *value = NULL, *_0, *_2, **_5;

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



	if ((Z_TYPE_P(signatureData) != IS_ARRAY)) {
		ZEPHIR_INIT_VAR(_0);
		_1 = zend_fetch_class(SL("InvalidArgumentException"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
		object_init_ex(_0, _1);
		ZEPHIR_INIT_VAR(_2);
		ZVAL_STRING(_2, "The signatureData must be an Array", 1);
		zephir_call_method_p1_noret(_0, "__construct", _2);
		zephir_throw_exception(_0 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	ZEPHIR_INIT_VAR(signatureString);
	ZVAL_STRING(signatureString, "", 1);
	ZEPHIR_INIT_VAR(delimiter);
	ZVAL_STRING(delimiter, "", 1);
	zephir_is_iterable(signatureData, &_4, &_3, 0, 0);
	for (
		; zend_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS
		; zend_hash_move_forward_ex(_4, &_3)
	) {
		ZEPHIR_GET_HMKEY(key, _4, _3);
		ZEPHIR_GET_HVALUE(value, _5);
		ZEPHIR_INIT_NVAR(signatureString);
		ZEPHIR_CONCAT_VVSV(signatureString, delimiter, key, "=", value);
		ZEPHIR_INIT_NVAR(delimiter);
		ZVAL_STRING(delimiter, "&", 1);
	}
	RETURN_CCTOR(signatureString);

}
Beispiel #13
0
/**
 * Hash
 *
 * @param string data 
 * @return string
 */
PHP_METHOD(OAuth_V1_Signature, hash) {

	zval *data_param = NULL, *algorithm = NULL, *hash, *signingKey, *_0, _1, *_2;
	zval *data = NULL;

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

		zephir_get_strval(data, data_param);


	ZEPHIR_INIT_VAR(algorithm);
	zephir_call_method(algorithm, this_ptr, "gethashingalgorithm");
	ZEPHIR_INIT_VAR(_0);
	zephir_fast_strtoupper(_0, algorithm);
	ZEPHIR_CPY_WRT(algorithm, _0);
	do {
		if (ZEPHIR_IS_STRING(algorithm, "HMAC-SHA1")) {
			ZEPHIR_INIT_VAR(signingKey);
			zephir_call_method(signingKey, this_ptr, "getsigningkey");
			ZEPHIR_SINIT_VAR(_1);
			ZVAL_STRING(&_1, "sha1", 0);
			ZEPHIR_INIT_VAR(hash);
			zephir_call_func_p4(hash, "hash_hmac", &_1, data, signingKey, ZEPHIR_GLOBAL(global_true));
			break;
		}
		ZEPHIR_INIT_BNVAR(_0);
		object_init_ex(_0, oauth_v1_unsupportedhashalgorithmexception_ce);
		ZEPHIR_INIT_VAR(_2);
		ZEPHIR_CONCAT_SVS(_2, "Unsupported hashing algorithm (", algorithm, ") used.");
		zephir_call_method_p2_noret(_0, "__construct", algorithm, _2);
		zephir_throw_exception(_0 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	} while(0);

	RETURN_CCTOR(hash);

}
Beispiel #14
0
/**
 * Sets an array of default paths. If a route is missing a path the router will use the defined here
 * This method must not be used to set a 404 route
 *
 *<code>
 * $router->setDefaults(array(
 *		'module' => 'common',
 *		'action' => 'index'
 * ));
 *</code>
 *
 * @param array defaults
 * @return Test\Router
 */
PHP_METHOD(Test_Router, setDefaults) {

	zval *defaults, *namespaceName, *module, *controller, *action, *params, *_0, *_1;

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



	if ((Z_TYPE_P(defaults) == IS_ARRAY)) {
		ZEPHIR_INIT_VAR(_0);
		object_init_ex(_0, test_router_exception_ce);
		ZEPHIR_INIT_VAR(_1);
		ZVAL_STRING(_1, "Defaults must be an array", 1);
		zephir_call_method_p1_noret(_0, "__construct", _1);
		zephir_throw_exception(_0 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	if (zephir_array_isset_string_fetch(&namespaceName, defaults, SS("namespace"), 1 TSRMLS_CC)) {
		zephir_update_property_this(this_ptr, SL("_defaultNamespace"), namespaceName TSRMLS_CC);
	}
	if (zephir_array_isset_string_fetch(&module, defaults, SS("module"), 1 TSRMLS_CC)) {
		zephir_update_property_this(this_ptr, SL("_defaultModule"), module TSRMLS_CC);
	}
	if (zephir_array_isset_string_fetch(&controller, defaults, SS("controller"), 1 TSRMLS_CC)) {
		zephir_update_property_this(this_ptr, SL("_defaultController"), controller TSRMLS_CC);
	}
	if (zephir_array_isset_string_fetch(&action, defaults, SS("action"), 1 TSRMLS_CC)) {
		zephir_update_property_this(this_ptr, SL("_defaultAction"), action TSRMLS_CC);
	}
	if (zephir_array_isset_string_fetch(&params, defaults, SS("params"), 1 TSRMLS_CC)) {
		zephir_update_property_this(this_ptr, SL("_defaultParams"), params TSRMLS_CC);
	}
	RETURN_THIS();

}
Beispiel #15
0
/**
 * Hendle the controller calling process.
 *
 * The steps is:
 *  - Does alias controller are defined in main config?
 *  - If not, is sub-controller exists?
 *  - If not, module with this name exists?
 *  - If all fault, then throw 404.
 *
 *  @return void
 */
PHP_METHOD(Panada_Gear, controllerHandler) {

    zend_class_entry *_8;
    zephir_nts_static zephir_fcall_cache_entry *_3 = NULL, *_12 = NULL, *_19 = NULL;
    int ZEPHIR_LAST_CALL_STATUS;
    zval *instance, *request = NULL, *method = NULL, *classFile, *controllerNamespace, *_0, *_1, *_2, *_4, *_5, *_6 = NULL, *_7 = NULL, *_9, *_10 = NULL, _11, *_13, *_14, *_15, *_16, *_17 = NULL, *_18;

    ZEPHIR_MM_GROW();

    _0 = zephir_fetch_nproperty_this(this_ptr, SL("firstUriPath"), PH_NOISY_CC);
    ZEPHIR_INIT_VAR(controllerNamespace);
    ZEPHIR_CONCAT_SV(controllerNamespace, "Controllers\\", _0);
    ZEPHIR_INIT_VAR(_1);
    ZEPHIR_GET_CONSTANT(_1, "APP");
    _2 = zephir_fetch_nproperty_this(this_ptr, SL("firstUriPath"), PH_NOISY_CC);
    ZEPHIR_INIT_VAR(classFile);
    ZEPHIR_CONCAT_VSVS(classFile, _1, "Controllers/", _2, ".php");
    if (!((zephir_file_exists(classFile TSRMLS_CC) == SUCCESS))) {
        ZEPHIR_CALL_METHOD(NULL, this_ptr, "subcontrollerhandler", &_3);
        zephir_check_call_status();
        RETURN_MM_NULL();
    }
    _4 = zephir_fetch_nproperty_this(this_ptr, SL("uriObj"), PH_NOISY_CC);
    ZEPHIR_CALL_METHOD(&method, _4, "getmethod",  NULL);
    zephir_check_call_status();
    _5 = zephir_fetch_nproperty_this(this_ptr, SL("uriObj"), PH_NOISY_CC);
    ZEPHIR_CALL_METHOD(&request, _5, "getrequests",  NULL);
    zephir_check_call_status();
    if (!(zephir_is_true(request))) {
        ZEPHIR_INIT_VAR(request);
        array_init(request);
    }
    if (!(zephir_class_exists(controllerNamespace, 1 TSRMLS_CC))) {
        ZEPHIR_INIT_VAR(_6);
        object_init_ex(_6, panada_resources_runexception_ce);
        ZEPHIR_INIT_VAR(_7);
        ZEPHIR_CONCAT_SVSV(_7, "Class ", controllerNamespace, "  not found in ", classFile);
        ZEPHIR_CALL_METHOD(NULL, _6, "__construct", NULL, _7);
        zephir_check_call_status();
        zephir_throw_exception(_6 TSRMLS_CC);
        ZEPHIR_MM_RESTORE();
        return;
    }
    ZEPHIR_INIT_VAR(instance);
    _8 = zend_fetch_class(Z_STRVAL_P(controllerNamespace), Z_STRLEN_P(controllerNamespace), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
    object_init_ex(instance, _8);
    if (zephir_has_constructor(instance TSRMLS_CC)) {
        ZEPHIR_CALL_METHOD(NULL, instance, "__construct", NULL);
        zephir_check_call_status();
    }
    if (!((zephir_method_exists(instance, method TSRMLS_CC)  == SUCCESS))) {
        _9 = zephir_fetch_nproperty_this(this_ptr, SL("uriObj"), PH_NOISY_CC);
        ZEPHIR_CALL_METHOD(&_10, _9, "path",  NULL);
        zephir_check_call_status();
        ZEPHIR_SINIT_VAR(_11);
        ZVAL_LONG(&_11, 1);
        ZEPHIR_CALL_FUNCTION(&request, "array_slice", &_12, _10, &_11);
        zephir_check_call_status();
        _13 = zephir_fetch_nproperty_this(this_ptr, SL("config"), PH_NOISY_CC);
        zephir_array_fetch_string(&_14, _13, SL("main"), PH_NOISY | PH_READONLY TSRMLS_CC);
        zephir_array_fetch_string(&_15, _14, SL("alias"), PH_NOISY | PH_READONLY TSRMLS_CC);
        ZEPHIR_OBS_VAR(method);
        zephir_array_fetch_string(&method, _15, SL("method"), PH_NOISY TSRMLS_CC);
        if (!((zephir_method_exists(instance, method TSRMLS_CC)  == SUCCESS))) {
            ZEPHIR_INIT_LNVAR(_6);
            object_init_ex(_6, panada_resources_runexception_ce);
            _16 = zephir_fetch_nproperty_this(this_ptr, SL("uriObj"), PH_NOISY_CC);
            ZEPHIR_CALL_METHOD(&_17, _16, "getmethod",  NULL);
            zephir_check_call_status();
            _18 = zephir_fetch_nproperty_this(this_ptr, SL("firstUriPath"), PH_NOISY_CC);
            ZEPHIR_INIT_LNVAR(_7);
            ZEPHIR_CONCAT_SVSV(_7, "Method ", _17, " does not exists in controller ", _18);
            ZEPHIR_CALL_METHOD(NULL, _6, "__construct", NULL, _7);
            zephir_check_call_status();
            zephir_throw_exception(_6 TSRMLS_CC);
            ZEPHIR_MM_RESTORE();
            return;
        }
    }
    ZEPHIR_CALL_METHOD(NULL, this_ptr, "run", &_19, instance, method, request);
    zephir_check_call_status();
    ZEPHIR_MM_RESTORE();

}
Beispiel #16
0
PHP_METHOD(Test_FortyTwo, proof) {

	zend_function *_10 = NULL;
	zend_class_entry *_9;
	zend_bool _5;
	HashTable *_3;
	HashPosition _2;
	int i, j, _6, _7;
	zval *box, *side = NULL, *_0 = NULL, *_1 = NULL, **_4, *_8;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(box);
	array_init_size(box, 17);
	ZEPHIR_INIT_VAR(_0);
	array_init_size(_0, 5);
	ZEPHIR_INIT_VAR(_1);
	ZVAL_LONG(_1, 10);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 24);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 8);
	zephir_array_fast_append(_0, _1);
	zephir_array_fast_append(box, _0);
	ZEPHIR_INIT_BNVAR(_0);
	array_init_size(_0, 5);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 8);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 15);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 19);
	zephir_array_fast_append(_0, _1);
	zephir_array_fast_append(box, _0);
	ZEPHIR_INIT_BNVAR(_0);
	array_init_size(_0, 5);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 19);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 17);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 6);
	zephir_array_fast_append(_0, _1);
	zephir_array_fast_append(box, _0);
	ZEPHIR_INIT_BNVAR(_0);
	array_init_size(_0, 5);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 6);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 16);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 20);
	zephir_array_fast_append(_0, _1);
	zephir_array_fast_append(box, _0);
	ZEPHIR_INIT_BNVAR(_0);
	array_init_size(_0, 5);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 20);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 13);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 9);
	zephir_array_fast_append(_0, _1);
	zephir_array_fast_append(box, _0);
	ZEPHIR_INIT_BNVAR(_0);
	array_init_size(_0, 5);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 9);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 11);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 22);
	zephir_array_fast_append(_0, _1);
	zephir_array_fast_append(box, _0);
	ZEPHIR_INIT_BNVAR(_0);
	array_init_size(_0, 5);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 22);
	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, 18);
	zephir_array_fast_append(_0, _1);
	zephir_array_fast_append(box, _0);
	ZEPHIR_INIT_BNVAR(_0);
	array_init_size(_0, 5);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 18);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 4);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 20);
	zephir_array_fast_append(_0, _1);
	zephir_array_fast_append(box, _0);
	ZEPHIR_INIT_BNVAR(_0);
	array_init_size(_0, 5);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 5);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 21);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 16);
	zephir_array_fast_append(_0, _1);
	zephir_array_fast_append(box, _0);
	ZEPHIR_INIT_BNVAR(_0);
	array_init_size(_0, 5);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 16);
	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, 23);
	zephir_array_fast_append(_0, _1);
	zephir_array_fast_append(box, _0);
	ZEPHIR_INIT_BNVAR(_0);
	array_init_size(_0, 5);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 23);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 7);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 12);
	zephir_array_fast_append(_0, _1);
	zephir_array_fast_append(box, _0);
	ZEPHIR_INIT_BNVAR(_0);
	array_init_size(_0, 5);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 12);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 25);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 5);
	zephir_array_fast_append(_0, _1);
	zephir_array_fast_append(box, _0);
	ZEPHIR_INIT_BNVAR(_0);
	array_init_size(_0, 5);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 24);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 7);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 11);
	zephir_array_fast_append(_0, _1);
	zephir_array_fast_append(box, _0);
	ZEPHIR_INIT_BNVAR(_0);
	array_init_size(_0, 5);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 11);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 27);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 4);
	zephir_array_fast_append(_0, _1);
	zephir_array_fast_append(box, _0);
	ZEPHIR_INIT_BNVAR(_0);
	array_init_size(_0, 5);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 11);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 27);
	zephir_array_fast_append(_0, _1);
	ZEPHIR_INIT_BNVAR(_1);
	ZVAL_LONG(_1, 4);
	zephir_array_fast_append(_0, _1);
	zephir_array_fast_append(box, _0);
	zephir_is_iterable(box, &_3, &_2, 0, 0);
	for (
		; zend_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS
		; zend_hash_move_forward_ex(_3, &_2)
	) {
		ZEPHIR_GET_HVALUE(side, _4);
		j = 0;
		_7 = 2;
		_6 = 0;
		_5 = 0;
		if ((_6 <= _7)) {
			while (1) {
				if (_5) {
					_6++;
					if (!((_6 <= _7))) {
						break;
					}
				} else {
					_5 = 1;
				}
				i = _6;
				zephir_array_fetch_long(&_8, side, i, PH_NOISY | PH_READONLY TSRMLS_CC);
				j += zephir_get_numberval(_8);
			}
		}
		if ((j != 42)) {
			ZEPHIR_INIT_NVAR(_0);
			_9 = zend_fetch_class(SL("Exception"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
			object_init_ex(_0, _9);
			ZEPHIR_INIT_NVAR(_1);
			ZVAL_STRING(_1, "not true", 1);
			zephir_call_method_p1_cache_noret(_0, "__construct", &_10, _1);
			zephir_throw_exception(_0 TSRMLS_CC);
			ZEPHIR_MM_RESTORE();
			return;
		}
	}
	ZEPHIR_MM_RESTORE();

}
Beispiel #17
0
/**
 * Handles routing information received from the rewrite engine
 *
 *<code>
 * //Read the info from the rewrite engine
 * $router->handle();
 *
 * //Manually passing an URL
 * $router->handle('/posts/edit/1');
 *</code>
 *
 * @param string uri
 */
PHP_METHOD(Test_Router, handle) {

	zend_function *_8 = NULL, *_9 = NULL, *_11 = NULL, *_12 = NULL, *_14 = NULL;
	HashTable *_3, *_16;
	HashPosition _2, _15;
	zval *uri = NULL, *realUri = NULL, *request = NULL, *currentHostName = NULL, *routeFound = NULL, *parts = NULL, *params, *matches, *notFoundPaths, *vnamespace, *module, *controller, *action, *paramsStr, *strParams, *paramsMerge = NULL, *route = NULL, *methods = NULL, *dependencyInjector = NULL, *hostname = NULL, *regexHostName = NULL, *matched = NULL, *pattern = NULL, *handledUri = NULL, *beforeMatch = NULL, *paths = NULL, *converters = NULL, *part = NULL, *position = NULL, *matchPosition = NULL, *_0, *_1, **_4, *_5, *_6 = NULL, *_7 = NULL, *_10 = NULL, *_13 = NULL, **_17, *_18, *_19, *_20, *_21, *_22;

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

	if (!uri) {
		uri = ZEPHIR_GLOBAL(global_null);
	}


	if (!(zephir_is_true(uri))) {
		ZEPHIR_INIT_VAR(realUri);
		zephir_call_method(realUri, this_ptr, "getrewriteuri");
	} else {
		ZEPHIR_CPY_WRT(realUri, uri);
	}
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_removeExtraSlashes"), PH_NOISY_CC);
	if (zephir_is_true(_0)) {
		ZEPHIR_INIT_VAR(handledUri);
		zephir_call_method_p1(handledUri, this_ptr, "doremoveextraslashes", realUri);
	} else {
		ZEPHIR_CPY_WRT(handledUri, realUri);
	}
	ZEPHIR_INIT_VAR(request);
	ZVAL_NULL(request);
	ZEPHIR_INIT_VAR(currentHostName);
	ZVAL_NULL(currentHostName);
	ZEPHIR_INIT_VAR(routeFound);
	ZVAL_BOOL(routeFound, 0);
	ZEPHIR_INIT_VAR(parts);
	array_init(parts);
	ZEPHIR_INIT_VAR(params);
	array_init(params);
	ZEPHIR_INIT_VAR(matches);
	ZVAL_NULL(matches);
	zephir_update_property_this(this_ptr, SL("_wasMatched"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
	zephir_update_property_this(this_ptr, SL("_matchedRoute"), ZEPHIR_GLOBAL(global_null) TSRMLS_CC);
	_1 = zephir_fetch_nproperty_this(this_ptr, SL("_routes"), PH_NOISY_CC);
	zephir_is_iterable(_1, &_3, &_2, 0, 1);
	for (
	  ; zend_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS
	  ; zend_hash_move_backwards_ex(_3, &_2)
	) {
		ZEPHIR_GET_HVALUE(route, _4);
		ZEPHIR_INIT_NVAR(methods);
		zephir_call_method(methods, route, "gethttpmethods");
		if ((Z_TYPE_P(methods) != IS_NULL)) {
			if ((Z_TYPE_P(request) == IS_NULL)) {
				_5 = zephir_fetch_nproperty_this(this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);
				ZEPHIR_CPY_WRT(dependencyInjector, _5);
				if ((Z_TYPE_P(dependencyInjector) != IS_OBJECT)) {
					ZEPHIR_INIT_LNVAR(_6);
					object_init_ex(_6, test_router_exception_ce);
					ZEPHIR_INIT_NVAR(_7);
					ZVAL_STRING(_7, "A dependency injection container is required to access the 'request' service", 1);
					zephir_call_method_p1_cache_noret(_6, "__construct", &_8, _7);
					zephir_throw_exception(_6 TSRMLS_CC);
					ZEPHIR_MM_RESTORE();
					return;
				}
				ZEPHIR_INIT_NVAR(_7);
				ZVAL_STRING(_7, "request", 1);
				ZEPHIR_INIT_NVAR(request);
				zephir_call_method_p1_cache(request, dependencyInjector, "getshared", &_9, _7);
			}
			ZEPHIR_INIT_NVAR(_7);
			zephir_call_method_p1(_7, request, "ismethod", methods);
			if (ZEPHIR_IS_FALSE(_7)) {
				continue;
			}
		}
		ZEPHIR_INIT_NVAR(hostname);
		zephir_call_method(hostname, route, "gethostname");
		if ((Z_TYPE_P(hostname) != IS_NULL)) {
			if ((Z_TYPE_P(request) == IS_NULL)) {
				ZEPHIR_OBS_NVAR(dependencyInjector);
				zephir_read_property_this(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);
				if ((Z_TYPE_P(dependencyInjector) != IS_OBJECT)) {
					ZEPHIR_INIT_LNVAR(_6);
					object_init_ex(_6, test_router_exception_ce);
					ZEPHIR_INIT_NVAR(_10);
					ZVAL_STRING(_10, "A dependency injection container is required to access the 'request' service", 1);
					zephir_call_method_p1_cache_noret(_6, "__construct", &_11, _10);
					zephir_throw_exception(_6 TSRMLS_CC);
					ZEPHIR_MM_RESTORE();
					return;
				}
				ZEPHIR_INIT_NVAR(_7);
				ZVAL_STRING(_7, "request", 1);
				ZEPHIR_INIT_NVAR(request);
				zephir_call_method_p1_cache(request, dependencyInjector, "getshared", &_12, _7);
			}
			if ((Z_TYPE_P(currentHostName) != IS_OBJECT)) {
				ZEPHIR_INIT_NVAR(currentHostName);
				zephir_call_method(currentHostName, request, "gethttphost");
			}
			if ((Z_TYPE_P(currentHostName) != IS_NULL)) {
				continue;
			}
			ZEPHIR_INIT_NVAR(matched);
			if (zephir_memnstr_str(hostname, SL("("), "test/router.zep", 381)) {
				if (zephir_memnstr_str(hostname, SL("#"), "test/router.zep", 382)) {
					ZEPHIR_INIT_NVAR(regexHostName);
					ZEPHIR_CONCAT_SVS(regexHostName, "#^", hostname, "$#");
				} else {
					ZEPHIR_CPY_WRT(regexHostName, hostname);
				}
				ZEPHIR_INIT_NVAR(_13);
				zephir_preg_match(matched, &(matched), regexHostName, currentHostName, _13, 0, 0 , 0  TSRMLS_CC);
			} else {
				ZVAL_BOOL(matched, ZEPHIR_IS_EQUAL(currentHostName, hostname));
			}
			if (!(zephir_is_true(matched))) {
				continue;
			}
		}
		ZEPHIR_INIT_NVAR(pattern);
		zephir_call_method(pattern, route, "getcompiledpattern");
		ZEPHIR_INIT_NVAR(routeFound);
		if (zephir_memnstr_str(pattern, SL("^"), "test/router.zep", 400)) {
			zephir_preg_match(routeFound, &(routeFound), pattern, handledUri, matches, 0, 0 , 0  TSRMLS_CC);
		} else {
			ZVAL_BOOL(routeFound, ZEPHIR_IS_EQUAL(pattern, handledUri));
		}
		if (zephir_is_true(routeFound)) {
			ZEPHIR_INIT_NVAR(beforeMatch);
			zephir_call_method(beforeMatch, route, "getbeforematch");
			if ((Z_TYPE_P(beforeMatch) != IS_NULL)) {
				if (zephir_is_callable(beforeMatch TSRMLS_CC)) {
					ZEPHIR_INIT_LNVAR(_6);
					object_init_ex(_6, test_router_exception_ce);
					ZEPHIR_INIT_NVAR(_7);
					ZVAL_STRING(_7, "Before-Match callback is not callable in matched route", 1);
					zephir_call_method_p1_cache_noret(_6, "__construct", &_14, _7);
					zephir_throw_exception(_6 TSRMLS_CC);
					ZEPHIR_MM_RESTORE();
					return;
				}
			}
		}
		if (zephir_is_true(routeFound)) {
			ZEPHIR_INIT_NVAR(paths);
			zephir_call_method(paths, route, "getpaths");
			ZEPHIR_CPY_WRT(parts, paths);
			if ((Z_TYPE_P(matches) == IS_ARRAY)) {
				ZEPHIR_INIT_NVAR(converters);
				zephir_call_method(converters, route, "getconverters");
				zephir_is_iterable(paths, &_16, &_15, 0, 0);
				for (
				  ; zend_hash_get_current_data_ex(_16, (void**) &_17, &_15) == SUCCESS
				  ; zephir_hash_move_forward_ex(_16, &_15)
				) {
					ZEPHIR_GET_HMKEY(part, _16, _15);
					ZEPHIR_GET_HVALUE(position, _17);
					ZEPHIR_OBS_NVAR(matchPosition);
					if (zephir_array_isset_fetch(&matchPosition, matches, position, 0 TSRMLS_CC)) {
						if ((Z_TYPE_P(converters) == IS_ARRAY)) {
							if (zephir_array_isset(converters, part)) {
								continue;
							}
						}
						zephir_array_update_zval(&parts, part, &matchPosition, PH_COPY | PH_SEPARATE);
					} else {
						if ((Z_TYPE_P(converters) == IS_ARRAY)) {
							if (zephir_array_isset(converters, part)) {
							}
						}
					}
				}
				zephir_update_property_this(this_ptr, SL("_matches"), matches TSRMLS_CC);
			}
			zephir_update_property_this(this_ptr, SL("_matchedRoute"), route TSRMLS_CC);
			break;
		}
	}
	if (zephir_is_true(routeFound)) {
		zephir_update_property_this(this_ptr, SL("_wasMatched"), (1) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
	} else {
		zephir_update_property_this(this_ptr, SL("_wasMatched"), (0) ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false) TSRMLS_CC);
	}
	if (!(zephir_is_true(routeFound))) {
		ZEPHIR_OBS_VAR(notFoundPaths);
		zephir_read_property_this(&notFoundPaths, this_ptr, SL("_notFoundPaths"), PH_NOISY_CC);
		if ((Z_TYPE_P(notFoundPaths) != IS_NULL)) {
			ZEPHIR_CPY_WRT(parts, notFoundPaths);
			ZEPHIR_INIT_BNVAR(routeFound);
			ZVAL_BOOL(routeFound, 1);
		}
	}
	if (zephir_is_true(routeFound)) {
		ZEPHIR_OBS_VAR(vnamespace);
		if (zephir_array_isset_string_fetch(&vnamespace, parts, SS("namespace"), 0 TSRMLS_CC)) {
			if (!(zephir_is_numeric(vnamespace))) {
				zephir_update_property_this(this_ptr, SL("_namespace"), vnamespace TSRMLS_CC);
			}
			zephir_array_fetch_string(&_18, parts, SL("namespace"), PH_NOISY | PH_READONLY TSRMLS_CC);
			zephir_array_unset(&parts, _18, PH_SEPARATE);
		} else {
			_5 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultNamespace"), PH_NOISY_CC);
			zephir_update_property_this(this_ptr, SL("_namespace"), _5 TSRMLS_CC);
		}
		ZEPHIR_OBS_VAR(module);
		if (zephir_array_isset_string_fetch(&module, parts, SS("module"), 0 TSRMLS_CC)) {
			if (!(zephir_is_numeric(module))) {
				zephir_update_property_this(this_ptr, SL("_module"), module TSRMLS_CC);
			}
			zephir_array_fetch_string(&_18, parts, SL("module"), PH_NOISY | PH_READONLY TSRMLS_CC);
			zephir_array_unset(&parts, _18, PH_SEPARATE);
		} else {
			_5 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultModule"), PH_NOISY_CC);
			zephir_update_property_this(this_ptr, SL("_module"), _5 TSRMLS_CC);
		}
		ZEPHIR_OBS_VAR(controller);
		if (zephir_array_isset_string_fetch(&controller, parts, SS("controller"), 0 TSRMLS_CC)) {
			if (!(zephir_is_numeric(controller))) {
				zephir_update_property_this(this_ptr, SL("_controller"), controller TSRMLS_CC);
			}
			zephir_array_fetch_string(&_18, parts, SL("controller"), PH_NOISY | PH_READONLY TSRMLS_CC);
			zephir_array_unset(&parts, _18, PH_SEPARATE);
		} else {
			_5 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultController"), PH_NOISY_CC);
			zephir_update_property_this(this_ptr, SL("_controller"), _5 TSRMLS_CC);
		}
		ZEPHIR_OBS_VAR(action);
		if (zephir_array_isset_string_fetch(&action, parts, SS("action"), 0 TSRMLS_CC)) {
			if (!(zephir_is_numeric(action))) {
				zephir_update_property_this(this_ptr, SL("_action"), action TSRMLS_CC);
			}
			zephir_array_fetch_string(&_18, parts, SL("action"), PH_NOISY | PH_READONLY TSRMLS_CC);
			zephir_array_unset(&parts, _18, PH_SEPARATE);
		} else {
			_5 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAction"), PH_NOISY_CC);
			zephir_update_property_this(this_ptr, SL("_action"), _5 TSRMLS_CC);
		}
		ZEPHIR_OBS_VAR(paramsStr);
		if (zephir_array_isset_string_fetch(&paramsStr, parts, SS("params"), 0 TSRMLS_CC)) {
			ZEPHIR_INIT_VAR(strParams);
			zephir_substr(strParams, paramsStr, 1 , 0 );
			if (zephir_is_true(strParams)) {
				ZEPHIR_INIT_BNVAR(params);
				zephir_fast_explode_str(params, SL("/"), strParams, LONG_MAX TSRMLS_CC);
			}
			zephir_array_fetch_string(&_18, parts, SL("params"), PH_NOISY | PH_READONLY TSRMLS_CC);
			zephir_array_unset(&parts, _18, PH_SEPARATE);
		}
		if (zephir_fast_count_int(params TSRMLS_CC)) {
			ZEPHIR_INIT_VAR(paramsMerge);
			zephir_fast_array_merge(paramsMerge, &(params), &(parts) TSRMLS_CC);
		} else {
			ZEPHIR_CPY_WRT(paramsMerge, parts);
		}
		zephir_update_property_this(this_ptr, SL("_params"), paramsMerge TSRMLS_CC);
	} else {
		_5 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultNamespace"), PH_NOISY_CC);
		zephir_update_property_this(this_ptr, SL("_namespace"), _5 TSRMLS_CC);
		_19 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultModule"), PH_NOISY_CC);
		zephir_update_property_this(this_ptr, SL("_module"), _19 TSRMLS_CC);
		_20 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultController"), PH_NOISY_CC);
		zephir_update_property_this(this_ptr, SL("_controller"), _20 TSRMLS_CC);
		_21 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultAction"), PH_NOISY_CC);
		zephir_update_property_this(this_ptr, SL("_action"), _21 TSRMLS_CC);
		_22 = zephir_fetch_nproperty_this(this_ptr, SL("_defaultParams"), PH_NOISY_CC);
		zephir_update_property_this(this_ptr, SL("_params"), _22 TSRMLS_CC);
	}
	ZEPHIR_MM_RESTORE();

}
Beispiel #18
0
/**
 * Mounts a group of routes in the router
 *
 * @param Test\Router\Group route
 * @return Test\Router
 */
PHP_METHOD(Test_Router, mount) {

	HashTable *_3, *_6;
	HashPosition _2, _5;
	zval *group, *groupRoutes, *beforeMatch, *hostname, *routes, *route = NULL, *_0 = NULL, *_1 = NULL, **_4, **_7;

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



	if ((Z_TYPE_P(group) != IS_OBJECT)) {
		ZEPHIR_INIT_VAR(_0);
		object_init_ex(_0, test_router_exception_ce);
		ZEPHIR_INIT_VAR(_1);
		ZVAL_STRING(_1, "The group of routes is not valid", 1);
		zephir_call_method_p1_noret(_0, "__construct", _1);
		zephir_throw_exception(_0 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	ZEPHIR_INIT_VAR(groupRoutes);
	zephir_call_method(groupRoutes, group, "getroutes");
	if (!(zephir_fast_count_int(groupRoutes TSRMLS_CC))) {
		ZEPHIR_INIT_LNVAR(_0);
		object_init_ex(_0, test_router_exception_ce);
		ZEPHIR_INIT_NVAR(_1);
		ZVAL_STRING(_1, "The group of routes does not contain any routes", 1);
		zephir_call_method_p1_noret(_0, "__construct", _1);
		zephir_throw_exception(_0 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	ZEPHIR_INIT_VAR(beforeMatch);
	zephir_call_method(beforeMatch, group, "getbeforematch");
	if ((Z_TYPE_P(beforeMatch) != IS_NULL)) {
		zephir_is_iterable(groupRoutes, &_3, &_2, 0, 0);
		for (
		  ; zend_hash_get_current_data_ex(_3, (void**) &_4, &_2) == SUCCESS
		  ; zephir_hash_move_forward_ex(_3, &_2)
		) {
			ZEPHIR_GET_HVALUE(route, _4);
			zephir_call_method_p1_noret(route, "beforematch", beforeMatch);
		}
	}
	ZEPHIR_INIT_VAR(hostname);
	zephir_call_method(hostname, group, "gethostname");
	if ((Z_TYPE_P(hostname) != IS_NULL)) {
		zephir_is_iterable(groupRoutes, &_6, &_5, 0, 0);
		for (
		  ; zend_hash_get_current_data_ex(_6, (void**) &_7, &_5) == SUCCESS
		  ; zephir_hash_move_forward_ex(_6, &_5)
		) {
			ZEPHIR_GET_HVALUE(route, _7);
			zephir_call_method_p1_noret(route, "sethostname", hostname);
		}
	}
	ZEPHIR_OBS_VAR(routes);
	zephir_read_property_this(&routes, this_ptr, SL("_routes"), PH_NOISY_CC);
	if ((Z_TYPE_P(routes) == IS_ARRAY)) {
		ZEPHIR_INIT_NVAR(_1);
		zephir_fast_array_merge(_1, &(routes), &(groupRoutes) TSRMLS_CC);
		zephir_update_property_this(this_ptr, SL("_routes"), _1 TSRMLS_CC);
	} else {
		zephir_update_property_this(this_ptr, SL("_routes"), groupRoutes TSRMLS_CC);
	}
	RETURN_THIS();

}
Beispiel #19
0
/**
 * Magic loader to load instantiated class.
 *
 * @param  string $file Class namespace.
 * @return void
 */
PHP_METHOD(Panada_Gear, loader) {

    zephir_nts_static zephir_fcall_cache_entry *_16 = NULL;
    int ZEPHIR_LAST_CALL_STATUS;
    zval *file = NULL, *folder = NULL, *prefix, *_0, *_1, *_2, *_3, *_4 = NULL, *_5 = NULL, *_6, *_7, *_8, *_9, *_10, *_11, *_12, _13, _14, *_15 = NULL;

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

    ZEPHIR_SEPARATE_PARAM(file);


    ZEPHIR_INIT_VAR(prefix);
    zephir_fast_explode_str(prefix, SL("\\"), file, LONG_MAX TSRMLS_CC);
    zephir_array_fetch_long(&_0, prefix, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
    do {
        if (ZEPHIR_IS_STRING(_0, "Models")) {
            ZEPHIR_INIT_VAR(folder);
            ZEPHIR_GET_CONSTANT(folder, "APP");
            break;
        }
        if (ZEPHIR_IS_STRING(_0, "Libraries")) {
            ZEPHIR_INIT_NVAR(folder);
            ZEPHIR_GET_CONSTANT(folder, "APP");
            break;
        }
        if (ZEPHIR_IS_STRING(_0, "Controllers")) {
            ZEPHIR_INIT_NVAR(folder);
            ZEPHIR_GET_CONSTANT(folder, "APP");
            break;
        }
        if (ZEPHIR_IS_STRING(_0, "Resources")) {
            ZEPHIR_INIT_NVAR(folder);
            ZEPHIR_GET_CONSTANT(folder, "GEAR");
            break;
        }
        if (ZEPHIR_IS_STRING(_0, "Drivers")) {
            ZEPHIR_INIT_NVAR(folder);
            ZEPHIR_GET_CONSTANT(folder, "GEAR");
            break;
        }
        if (ZEPHIR_IS_STRING(_0, "Modules")) {
            _1 = zephir_fetch_nproperty_this(this_ptr, SL("config"), PH_NOISY_CC);
            zephir_array_fetch_string(&_2, _1, SL("main"), PH_NOISY | PH_READONLY TSRMLS_CC);
            zephir_array_fetch_string(&_3, _2, SL("module"), PH_NOISY | PH_READONLY TSRMLS_CC);
            ZEPHIR_OBS_NVAR(folder);
            zephir_array_fetch_string(&folder, _3, SL("path"), PH_NOISY TSRMLS_CC);
            break;
        }
        _1 = zephir_fetch_nproperty_this(this_ptr, SL("config"), PH_NOISY_CC);
        zephir_array_fetch_string(&_2, _1, SL("main"), PH_NOISY | PH_READONLY TSRMLS_CC);
        if (!(zephir_array_isset_string(_2, SS("namespace")))) {
            ZEPHIR_INIT_VAR(_4);
            object_init_ex(_4, panada_resources_runexception_ce);
            ZEPHIR_INIT_VAR(_5);
            ZEPHIR_CONCAT_SVS(_5, "Resource ", file, " not available!");
            ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, _5);
            zephir_check_call_status();
            zephir_throw_exception(_4 TSRMLS_CC);
            ZEPHIR_MM_RESTORE();
            return;
        }
        _6 = zephir_fetch_nproperty_this(this_ptr, SL("config"), PH_NOISY_CC);
        zephir_array_fetch_string(&_3, _6, SL("main"), PH_NOISY | PH_READONLY TSRMLS_CC);
        zephir_array_fetch_string(&_7, _3, SL("namespace"), PH_NOISY | PH_READONLY TSRMLS_CC);
        zephir_array_fetch_long(&_8, prefix, 0, PH_NOISY | PH_READONLY TSRMLS_CC);
        if (!(zephir_array_isset(_7, _8))) {
            ZEPHIR_INIT_LNVAR(_4);
            object_init_ex(_4, panada_resources_runexception_ce);
            ZEPHIR_INIT_LNVAR(_5);
            ZEPHIR_CONCAT_SVS(_5, "Resource ", file, " not available!");
            ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, _5);
            zephir_check_call_status();
            zephir_throw_exception(_4 TSRMLS_CC);
            ZEPHIR_MM_RESTORE();
            return;
        }
        _9 = zephir_fetch_nproperty_this(this_ptr, SL("config"), PH_NOISY_CC);
        zephir_array_fetch_string(&_10, _9, SL("main"), PH_NOISY | PH_READONLY TSRMLS_CC);
        zephir_array_fetch_string(&_11, _10, SL("namespace"), PH_NOISY | PH_READONLY TSRMLS_CC);
        ZEPHIR_OBS_NVAR(folder);
        ZEPHIR_OBS_VAR(_12);
        zephir_array_fetch_long(&_12, prefix, 0, PH_NOISY TSRMLS_CC);
        zephir_array_fetch(&folder, _11, _12, PH_NOISY TSRMLS_CC);
        break;
    } while(0);

    ZEPHIR_SINIT_VAR(_13);
    ZVAL_STRING(&_13, "\\", 0);
    ZEPHIR_SINIT_VAR(_14);
    ZVAL_STRING(&_14, "/", 0);
    ZEPHIR_CALL_FUNCTION(&_15, "str_ireplace", &_16, &_13, &_14, file);
    zephir_check_call_status();
    ZEPHIR_INIT_LNVAR(_4);
    ZEPHIR_CONCAT_VVS(_4, folder, _15, ".php");
    ZEPHIR_CPY_WRT(file, _4);
    if (!((zephir_file_exists(file TSRMLS_CC) == SUCCESS))) {
        ZEPHIR_INIT_LNVAR(_4);
        object_init_ex(_4, panada_resources_runexception_ce);
        ZEPHIR_INIT_LNVAR(_5);
        ZEPHIR_CONCAT_SVS(_5, "Resource ", file, " not available!");
        ZEPHIR_CALL_METHOD(NULL, _4, "__construct", NULL, _5);
        zephir_check_call_status();
        zephir_throw_exception(_4 TSRMLS_CC);
        ZEPHIR_MM_RESTORE();
        return;
    }
    if (zephir_require_zval(file TSRMLS_CC) == FAILURE) {
        RETURN_MM_NULL();
    }
    ZEPHIR_MM_RESTORE();

}
Beispiel #20
0
/**
 * Gets the signature
 *
 * @param OAuth\UriInterface uri
 * @param array params
 * @param string method
 *
 * @return string
 */
PHP_METHOD(OAuth_V1_Signature, getSignature) {

	HashTable *_4;
	HashPosition _3;
	zend_class_entry *_1;
	zval *method = NULL;
	zval *uri, *params, *method_param = NULL, *signature, *signatureData, *signatureString, *signatureStringEncoded, *query, *queryStringData = NULL, *queryStringKey = NULL, *queryStringValue = NULL, *queryStringKeyEncoded = NULL, *queryStringValueEncoded = NULL, *scheme, *authority, *path, *hasExplicitTrailingHostSlash, *baseUri, *baseUriEncoded, *dataString, *dataHash, *_0 = NULL, *_2, **_5;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 1, &uri, &params, &method_param);

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


	ZEPHIR_INIT_VAR(query);
	zephir_call_method(query, uri, "getquery");
	ZEPHIR_INIT_VAR(queryStringData);
	array_init(queryStringData);
	ZEPHIR_INIT_VAR(signatureData);
	array_init(signatureData);
	if ((Z_TYPE_P(params) != IS_ARRAY)) {
		ZEPHIR_INIT_VAR(_0);
		_1 = zend_fetch_class(SL("InvalidArgumentException"), ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
		object_init_ex(_0, _1);
		ZEPHIR_INIT_VAR(_2);
		ZVAL_STRING(_2, "The params must be an Array", 1);
		zephir_call_method_p1_noret(_0, "__construct", _2);
		zephir_throw_exception(_0 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	ZEPHIR_INIT_NVAR(_0);
	zephir_fast_array_merge(_0, &(queryStringData), &(params) TSRMLS_CC);
	ZEPHIR_CPY_WRT(queryStringData, _0);
	Z_SET_ISREF_P(queryStringData);
	zephir_call_func_p2_noret("parse_str", query, queryStringData);
	Z_UNSET_ISREF_P(queryStringData);
	zephir_is_iterable(queryStringData, &_4, &_3, 0, 0);
	for (
		; zend_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS
		; zend_hash_move_forward_ex(_4, &_3)
	) {
		ZEPHIR_GET_HMKEY(queryStringKey, _4, _3);
		ZEPHIR_GET_HVALUE(queryStringValue, _5);
		ZEPHIR_INIT_NVAR(queryStringKeyEncoded);
		zephir_call_func_p1(queryStringKeyEncoded, "rawurlencode", queryStringKey);
		ZEPHIR_INIT_NVAR(queryStringValueEncoded);
		zephir_call_func_p1(queryStringValueEncoded, "rawurlencode", queryStringValue);
		zephir_array_update_zval(&signatureData, queryStringKeyEncoded, &queryStringValueEncoded, PH_COPY | PH_SEPARATE);
	}
	Z_SET_ISREF_P(signatureData);
	zephir_call_func_p1_noret("ksort", signatureData);
	Z_UNSET_ISREF_P(signatureData);
	ZEPHIR_INIT_VAR(scheme);
	zephir_call_method(scheme, uri, "getscheme");
	ZEPHIR_INIT_VAR(authority);
	zephir_call_method(authority, uri, "getrawauthority");
	ZEPHIR_INIT_VAR(path);
	zephir_call_method(path, uri, "getpath");
	ZEPHIR_INIT_VAR(hasExplicitTrailingHostSlash);
	zephir_call_method(hasExplicitTrailingHostSlash, uri, "hasexplicittrailinghostslash");
	ZEPHIR_INIT_VAR(baseUri);
	ZEPHIR_CONCAT_VSV(baseUri, scheme, "://", authority);
	if (ZEPHIR_IS_STRING(path, "/")) {
		if (zephir_is_true(hasExplicitTrailingHostSlash)) {
			zephir_concat_self_str(&baseUri, SL("/") TSRMLS_CC);
		}
	} else {
		zephir_concat_self(&baseUri, path TSRMLS_CC);
	}
	ZEPHIR_INIT_VAR(baseUriEncoded);
	zephir_call_func_p1(baseUriEncoded, "rawurlencode", baseUri);
	ZEPHIR_INIT_VAR(signatureString);
	zephir_call_method_p1(signatureString, this_ptr, "buildsignaturestring", signatureData);
	ZEPHIR_INIT_VAR(signatureStringEncoded);
	zephir_call_func_p1(signatureStringEncoded, "rawurlencode", signatureString);
	ZEPHIR_INIT_VAR(dataString);
	zephir_fast_strtoupper(dataString, method);
	ZEPHIR_INIT_BNVAR(dataString);
	ZEPHIR_CONCAT_VSVSV(dataString, dataString, "&", baseUriEncoded, "&", signatureStringEncoded);
	ZEPHIR_INIT_VAR(dataHash);
	zephir_call_method_p1(dataHash, this_ptr, "hash", dataString);
	ZEPHIR_INIT_VAR(signature);
	zephir_call_func_p1(signature, "base64_encode", dataHash);
	RETURN_CCTOR(signature);

}