Example #1
0
/**
 * Returns the complete location where the joined/filtered collection must be written
 */
PHP_METHOD(Phalcon_Assets_Collection, getRealTargetPath) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *basePath_param = NULL, *targetPath, *completePath;
	zval *basePath = NULL;

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

	if (unlikely(Z_TYPE_P(basePath_param) != IS_STRING && Z_TYPE_P(basePath_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'basePath' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}

	if (likely(Z_TYPE_P(basePath_param) == IS_STRING)) {
		zephir_get_strval(basePath, basePath_param);
	} else {
		ZEPHIR_INIT_VAR(basePath);
		ZVAL_EMPTY_STRING(basePath);
	}


	ZEPHIR_OBS_VAR(targetPath);
	zephir_read_property_this(&targetPath, this_ptr, SL("_targetPath"), PH_NOISY_CC);
	ZEPHIR_INIT_VAR(completePath);
	ZEPHIR_CONCAT_VV(completePath, basePath, targetPath);
	if ((zephir_file_exists(completePath TSRMLS_CC) == SUCCESS)) {
		ZEPHIR_RETURN_CALL_FUNCTION("realpath", NULL, 62, completePath);
		zephir_check_call_status();
		RETURN_MM();
	}
	RETURN_CCTOR(completePath);

}
Example #2
0
/**
 * Reads parsed annotations from files
 *
 * @param string key
 * @return \Phalcon\Annotations\Reflection
 */
PHP_METHOD(Phalcon_Annotations_Adapter_Files, read) {

	zval *key_param = NULL, *path = NULL, *_0, *_1, _2, *_3$$3 = NULL;
	zval *key = NULL;

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

	zephir_get_strval(key, key_param);


	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_annotationsDir"), PH_NOISY_CC);
	ZEPHIR_INIT_VAR(_1);
	ZEPHIR_SINIT_VAR(_2);
	ZVAL_STRING(&_2, "_", 0);
	zephir_prepare_virtual_path(_1, key, &_2 TSRMLS_CC);
	ZEPHIR_INIT_VAR(path);
	ZEPHIR_CONCAT_VVS(path, _0, _1, ".php");
	if ((zephir_file_exists(path TSRMLS_CC) == SUCCESS)) {
		ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(&_3$$3);
		if (zephir_require_zval_ret(&_3$$3, path TSRMLS_CC) == FAILURE) {
			RETURN_MM_NULL();
		}
		RETURN_CCTOR(_3$$3);
	}
	RETURN_MM_BOOL(0);

}
Example #3
0
/**
 * Render view
 */
PHP_METHOD(Owl_Mvc_View, render) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *parameters = NULL;
	zval *path_param = NULL, *parameters_param = NULL, *_0, *_1, *_2, *_3, *_4, *tmp = NULL;
	zval *path = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &path_param, &parameters_param);

	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 (!parameters_param) {
	ZEPHIR_INIT_VAR(parameters);
	array_init(parameters);
	} else {
		zephir_get_arrval(parameters, parameters_param);
	}


	_0 = zephir_fetch_nproperty_this(this_ptr, SL("path"), PH_NOISY_CC);
	ZEPHIR_INIT_VAR(_1);
	ZEPHIR_CONCAT_VV(_1, _0, path);
	if (!((zephir_file_exists(_1 TSRMLS_CC) == SUCCESS))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(owl_exception_ce, "File is not exists", "owl/Mvc/View.zep", 21);
		return;
	}
	ZEPHIR_CALL_FUNCTION(NULL, "ob_start", NULL, 23);
	zephir_check_call_status();
	if (!(Z_TYPE_P(parameters) == IS_NULL)) {
		ZEPHIR_INIT_VAR(_2);
		ZVAL_LONG(_2, 0);
		Z_SET_ISREF_P(parameters);
		ZEPHIR_CALL_FUNCTION(NULL, "extract", NULL, 24, parameters, _2);
		Z_UNSET_ISREF_P(parameters);
		zephir_check_call_status();
	}
	_3 = zephir_fetch_nproperty_this(this_ptr, SL("path"), PH_NOISY_CC);
	ZEPHIR_INIT_VAR(_4);
	ZEPHIR_CONCAT_VV(_4, _3, path);
	if (zephir_require_zval(_4 TSRMLS_CC) == FAILURE) {
		RETURN_MM_NULL();
	}
	ZEPHIR_CALL_FUNCTION(&tmp, "ob_get_contents", NULL, 25);
	zephir_check_call_status();
	ZEPHIR_CALL_FUNCTION(NULL, "ob_end_clean", NULL, 26);
	zephir_check_call_status();
	RETURN_CCTOR(tmp);

}
Example #4
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);

}
Example #5
0
PHP_METHOD(Test_Exists, testFileExists) {

	zval *fileName;

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



	RETURN_BOOL((zephir_file_exists(fileName TSRMLS_CC) == SUCCESS));

}
Example #6
0
PHP_METHOD(Yb_Std, outputScript) {

	int ZEPHIR_LAST_CALL_STATUS;
	zval *data = NULL;
	zval *path_param = NULL, *data_param = NULL, *_0$$3, *_2, *_3;
	zval *path = NULL, *_1$$3;

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

	zephir_get_strval(path, path_param);
	zephir_get_arrval(data, data_param);


	if (unlikely(!((zephir_file_exists(path TSRMLS_CC) == SUCCESS)))) {
		ZEPHIR_INIT_VAR(_0$$3);
		object_init_ex(_0$$3, yb_exception_ce);
		ZEPHIR_INIT_VAR(_1$$3);
		ZEPHIR_CONCAT_SV(_1$$3, "Cannot find script path: ", path);
		ZEPHIR_CALL_METHOD(NULL, _0$$3, "__construct", NULL, 2, _1$$3);
		zephir_check_call_status();
		zephir_throw_exception_debug(_0$$3, "yb/std.zep", 423 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	ZEPHIR_INIT_VAR(_2);
	ZVAL_LONG(_2, 4);
	ZEPHIR_INIT_VAR(_3);
	ZVAL_STRING(_3, "", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_MAKE_REF(data);
	ZEPHIR_CALL_FUNCTION(NULL, "extract", NULL, 81, data, _2, _3);
	zephir_check_temp_parameter(_3);
	ZEPHIR_UNREF(data);
	zephir_check_call_status();
	if (zephir_require_zval(path TSRMLS_CC) == FAILURE) {
		RETURN_MM_NULL();
	}
	ZEPHIR_MM_RESTORE();

}
Example #7
0
/**
 * Returns the complete location where the resource must be written
 */
PHP_METHOD(Phalcon_Assets_Resource, getRealTargetPath) {

	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval *basePath_param = NULL, *targetPath = NULL, *completePath = NULL, *_0;
	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(targetPath);
	zephir_read_property_this(&targetPath, this_ptr, SL("_targetPath"), PH_NOISY_CC);
	if (ZEPHIR_IS_EMPTY(targetPath)) {
		ZEPHIR_OBS_NVAR(targetPath);
		zephir_read_property_this(&targetPath, 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(completePath);
		ZEPHIR_CONCAT_VV(completePath, basePath, targetPath);
		if ((zephir_file_exists(completePath TSRMLS_CC) == SUCCESS)) {
			ZEPHIR_RETURN_CALL_FUNCTION("realpath", NULL, 67, completePath);
			zephir_check_call_status();
			RETURN_MM();
		}
		RETURN_CCTOR(completePath);
	}
	RETURN_CCTOR(targetPath);

}
Example #8
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();

}
Example #9
0
/**
 * Returns a cached content
 */
PHP_METHOD(Phalcon_Cache_Backend_File, get) {

	int lifetime, ZEPHIR_LAST_CALL_STATUS, ttl = 0, modifiedTime = 0;
	zval *keyName_param = NULL, *lifetime_param = NULL, *prefixedKey = NULL, *cacheDir = NULL, *cacheFile = NULL, *frontend = NULL, *lastLifetime = NULL, *cachedContent = NULL, *ret = NULL, *_0, *_1 = NULL, *_2, *_3$$6 = NULL, *_4$$4, *_5$$4, *_6$$10, *_7$$10;
	zval *keyName = NULL;

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

	zephir_get_strval(keyName, keyName_param);
	if (!lifetime_param) {
		lifetime = 0;
	} else {
		lifetime = zephir_get_intval(lifetime_param);
	}


	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(&_1, this_ptr, "getkey", NULL, 0, keyName);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(prefixedKey);
	ZEPHIR_CONCAT_VV(prefixedKey, _0, _1);
	zephir_update_property_this(this_ptr, SL("_lastKey"), prefixedKey TSRMLS_CC);
	ZEPHIR_OBS_VAR(cacheDir);
	_2 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC);
	if (!(zephir_array_isset_string_fetch(&cacheDir, _2, SS("cacheDir"), 0 TSRMLS_CC))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/file.zep", 111);
		return;
	}
	ZEPHIR_INIT_VAR(cacheFile);
	ZEPHIR_CONCAT_VV(cacheFile, cacheDir, prefixedKey);
	if ((zephir_file_exists(cacheFile TSRMLS_CC) == SUCCESS) == 1) {
		ZEPHIR_OBS_VAR(frontend);
		zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC);
		if (!(lifetime)) {
			ZEPHIR_OBS_VAR(lastLifetime);
			zephir_read_property_this(&lastLifetime, this_ptr, SL("_lastLifetime"), PH_NOISY_CC);
			if (!(zephir_is_true(lastLifetime))) {
				ZEPHIR_CALL_METHOD(&_3$$6, frontend, "getlifetime", NULL, 0);
				zephir_check_call_status();
				ttl = zephir_get_intval(_3$$6);
			} else {
				ttl = zephir_get_intval(lastLifetime);
			}
		} else {
			ttl = lifetime;
		}
		ZEPHIR_CALL_FUNCTION(NULL, "clearstatcache", NULL, 114, ZEPHIR_GLOBAL(global_true), cacheFile);
		zephir_check_call_status();
		ZEPHIR_INIT_VAR(_4$$4);
		zephir_filemtime(_4$$4, cacheFile TSRMLS_CC);
		modifiedTime = zephir_get_intval(_4$$4);
		ZEPHIR_INIT_VAR(_5$$4);
		zephir_time(_5$$4);
		if (ZEPHIR_LT_LONG(_5$$4, (modifiedTime + ttl))) {
			ZEPHIR_INIT_VAR(cachedContent);
			zephir_file_get_contents(cachedContent, cacheFile TSRMLS_CC);
			if (ZEPHIR_IS_FALSE_IDENTICAL(cachedContent)) {
				ZEPHIR_INIT_VAR(_6$$10);
				object_init_ex(_6$$10, phalcon_cache_exception_ce);
				ZEPHIR_INIT_VAR(_7$$10);
				ZEPHIR_CONCAT_SVS(_7$$10, "Cache file ", cacheFile, " could not be opened");
				ZEPHIR_CALL_METHOD(NULL, _6$$10, "__construct", NULL, 9, _7$$10);
				zephir_check_call_status();
				zephir_throw_exception_debug(_6$$10, "phalcon/cache/backend/file.zep", 148 TSRMLS_CC);
				ZEPHIR_MM_RESTORE();
				return;
			}
			if (zephir_is_numeric(cachedContent)) {
				RETURN_CCTOR(cachedContent);
			} else {
				ZEPHIR_CALL_METHOD(&ret, frontend, "afterretrieve", NULL, 0, cachedContent);
				zephir_check_call_status();
				RETURN_CCTOR(ret);
			}
		}
	}
	RETURN_MM_NULL();

}
Example #10
0
/**
 * Handle the whole command-line tasks
 */
PHP_METHOD(Phalcon_Cli_Console, handle) {

	zend_bool _5;
	zend_long ZEPHIR_LAST_CALL_STATUS;
	zval *arguments_param = NULL, __$false, dependencyInjector, router, eventsManager, moduleName, modules, module, path, className, moduleObject, dispatcher, task, _0, _3, _4, _15, _16, _17, _18, _1$$4, _2$$4, _6$$6, _7$$10, _8$$10, _9$$12, _10$$12, _11$$17, _12$$17, _13$$18, _14$$18, _19$$20, _20$$20, _21$$22;
	zval arguments;
	zval *this_ptr = getThis();

	ZVAL_UNDEF(&arguments);
	ZVAL_BOOL(&__$false, 0);
	ZVAL_UNDEF(&dependencyInjector);
	ZVAL_UNDEF(&router);
	ZVAL_UNDEF(&eventsManager);
	ZVAL_UNDEF(&moduleName);
	ZVAL_UNDEF(&modules);
	ZVAL_UNDEF(&module);
	ZVAL_UNDEF(&path);
	ZVAL_UNDEF(&className);
	ZVAL_UNDEF(&moduleObject);
	ZVAL_UNDEF(&dispatcher);
	ZVAL_UNDEF(&task);
	ZVAL_UNDEF(&_0);
	ZVAL_UNDEF(&_3);
	ZVAL_UNDEF(&_4);
	ZVAL_UNDEF(&_15);
	ZVAL_UNDEF(&_16);
	ZVAL_UNDEF(&_17);
	ZVAL_UNDEF(&_18);
	ZVAL_UNDEF(&_1$$4);
	ZVAL_UNDEF(&_2$$4);
	ZVAL_UNDEF(&_6$$6);
	ZVAL_UNDEF(&_7$$10);
	ZVAL_UNDEF(&_8$$10);
	ZVAL_UNDEF(&_9$$12);
	ZVAL_UNDEF(&_10$$12);
	ZVAL_UNDEF(&_11$$17);
	ZVAL_UNDEF(&_12$$17);
	ZVAL_UNDEF(&_13$$18);
	ZVAL_UNDEF(&_14$$18);
	ZVAL_UNDEF(&_19$$20);
	ZVAL_UNDEF(&_20$$20);
	ZVAL_UNDEF(&_21$$22);

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

	if (!arguments_param) {
		ZEPHIR_INIT_VAR(&arguments);
		array_init(&arguments);
	} else {
		zephir_get_arrval(&arguments, arguments_param);
	}


	ZEPHIR_OBS_VAR(&dependencyInjector);
	zephir_read_property(&dependencyInjector, this_ptr, SL("_dependencyInjector"), PH_NOISY_CC);
	if (Z_TYPE_P(&dependencyInjector) != IS_OBJECT) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_console_exception_ce, "A dependency injection object is required to access internal services", "phalcon/cli/console.zep", 42);
		return;
	}
	zephir_read_property(&_0, this_ptr, SL("_eventsManager"), PH_NOISY_CC | PH_READONLY);
	ZEPHIR_CPY_WRT(&eventsManager, &_0);
	if (Z_TYPE_P(&eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_VAR(&_2$$4);
		ZVAL_STRING(&_2$$4, "console:boot");
		ZEPHIR_CALL_METHOD(&_1$$4, &eventsManager, "fire", NULL, 0, &_2$$4, this_ptr);
		zephir_check_call_status();
		if (ZEPHIR_IS_FALSE_IDENTICAL(&_1$$4)) {
			RETURN_MM_BOOL(0);
		}
	}
	ZEPHIR_INIT_VAR(&_4);
	ZVAL_STRING(&_4, "router");
	ZEPHIR_CALL_METHOD(&_3, &dependencyInjector, "getshared", NULL, 0, &_4);
	zephir_check_call_status();
	ZEPHIR_CPY_WRT(&router, &_3);
	_5 = !(zephir_fast_count_int(&arguments TSRMLS_CC));
	if (_5) {
		zephir_read_property(&_0, this_ptr, SL("_arguments"), PH_NOISY_CC | PH_READONLY);
		_5 = zephir_is_true(&_0);
	}
	if (_5) {
		zephir_read_property(&_6$$6, this_ptr, SL("_arguments"), PH_NOISY_CC | PH_READONLY);
		ZEPHIR_CALL_METHOD(NULL, &router, "handle", NULL, 0, &_6$$6);
		zephir_check_call_status();
	} else {
		ZEPHIR_CALL_METHOD(NULL, &router, "handle", NULL, 0, &arguments);
		zephir_check_call_status();
	}
	ZEPHIR_CALL_METHOD(&moduleName, &router, "getmodulename", NULL, 0);
	zephir_check_call_status();
	if (!(zephir_is_true(&moduleName))) {
		ZEPHIR_OBS_NVAR(&moduleName);
		zephir_read_property(&moduleName, this_ptr, SL("_defaultModule"), PH_NOISY_CC);
	}
	if (zephir_is_true(&moduleName)) {
		if (Z_TYPE_P(&eventsManager) == IS_OBJECT) {
			ZEPHIR_INIT_VAR(&_8$$10);
			ZVAL_STRING(&_8$$10, "console:beforeStartModule");
			ZEPHIR_CALL_METHOD(&_7$$10, &eventsManager, "fire", NULL, 0, &_8$$10, this_ptr, &moduleName);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(&_7$$10)) {
				RETURN_MM_BOOL(0);
			}
		}
		ZEPHIR_OBS_VAR(&modules);
		zephir_read_property(&modules, this_ptr, SL("_modules"), PH_NOISY_CC);
		if (!(zephir_array_isset(&modules, &moduleName))) {
			ZEPHIR_INIT_VAR(&_9$$12);
			object_init_ex(&_9$$12, phalcon_cli_console_exception_ce);
			ZEPHIR_INIT_VAR(&_10$$12);
			ZEPHIR_CONCAT_SVS(&_10$$12, "Module '", &moduleName, "' isn't registered in the console container");
			ZEPHIR_CALL_METHOD(NULL, &_9$$12, "__construct", NULL, 4, &_10$$12);
			zephir_check_call_status();
			zephir_throw_exception_debug(&_9$$12, "phalcon/cli/console.zep", 82 TSRMLS_CC);
			ZEPHIR_MM_RESTORE();
			return;
		}
		ZEPHIR_OBS_VAR(&module);
		zephir_array_fetch(&module, &modules, &moduleName, PH_NOISY, "phalcon/cli/console.zep", 85 TSRMLS_CC);
		if (Z_TYPE_P(&module) != IS_ARRAY) {
			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_console_exception_ce, "Invalid module definition path", "phalcon/cli/console.zep", 87);
			return;
		}
		ZEPHIR_OBS_VAR(&className);
		if (!(zephir_array_isset_string_fetch(&className, &module, SL("className"), 0))) {
			ZEPHIR_INIT_NVAR(&className);
			ZVAL_STRING(&className, "Module");
		}
		ZEPHIR_OBS_VAR(&path);
		if (zephir_array_isset_string_fetch(&path, &module, SL("path"), 0)) {
			if (!(zephir_class_exists(&className, zephir_is_true(&__$false)  TSRMLS_CC))) {
				if (!((zephir_file_exists(&path TSRMLS_CC) == SUCCESS))) {
					ZEPHIR_INIT_VAR(&_11$$17);
					object_init_ex(&_11$$17, phalcon_cli_console_exception_ce);
					ZEPHIR_INIT_VAR(&_12$$17);
					ZEPHIR_CONCAT_SVS(&_12$$17, "Module definition path '", &path, "' doesn't exist");
					ZEPHIR_CALL_METHOD(NULL, &_11$$17, "__construct", NULL, 4, &_12$$17);
					zephir_check_call_status();
					zephir_throw_exception_debug(&_11$$17, "phalcon/cli/console.zep", 97 TSRMLS_CC);
					ZEPHIR_MM_RESTORE();
					return;
				}
				if (zephir_require_zval(&path TSRMLS_CC) == FAILURE) {
					RETURN_MM_NULL();
				}
			}
		}
		ZEPHIR_CALL_METHOD(&moduleObject, &dependencyInjector, "get", NULL, 0, &className);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, &moduleObject, "registerautoloaders", NULL, 0);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, &moduleObject, "registerservices", NULL, 0, &dependencyInjector);
		zephir_check_call_status();
		if (Z_TYPE_P(&eventsManager) == IS_OBJECT) {
			ZEPHIR_INIT_VAR(&_14$$18);
			ZVAL_STRING(&_14$$18, "console:afterStartModule");
			ZEPHIR_CALL_METHOD(&_13$$18, &eventsManager, "fire", NULL, 0, &_14$$18, this_ptr, &moduleObject);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(&_13$$18)) {
				RETURN_MM_BOOL(0);
			}
		}
	}
	ZEPHIR_INIT_NVAR(&_4);
	ZVAL_STRING(&_4, "dispatcher");
	ZEPHIR_CALL_METHOD(&_3, &dependencyInjector, "getshared", NULL, 0, &_4);
	zephir_check_call_status();
	ZEPHIR_CPY_WRT(&dispatcher, &_3);
	ZEPHIR_CALL_METHOD(&_3, &router, "getmodulename", NULL, 0);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setmodulename", NULL, 0, &_3);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&_15, &router, "gettaskname", NULL, 0);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(NULL, &dispatcher, "settaskname", NULL, 0, &_15);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&_16, &router, "getactionname", NULL, 0);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setactionname", NULL, 0, &_16);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&_17, &router, "getparams", NULL, 0);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setparams", NULL, 0, &_17);
	zephir_check_call_status();
	zephir_read_property(&_18, this_ptr, SL("_options"), PH_NOISY_CC | PH_READONLY);
	ZEPHIR_CALL_METHOD(NULL, &dispatcher, "setoptions", NULL, 0, &_18);
	zephir_check_call_status();
	if (Z_TYPE_P(&eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_VAR(&_20$$20);
		ZVAL_STRING(&_20$$20, "console:beforeHandleTask");
		ZEPHIR_CALL_METHOD(&_19$$20, &eventsManager, "fire", NULL, 0, &_20$$20, this_ptr, &dispatcher);
		zephir_check_call_status();
		if (ZEPHIR_IS_FALSE_IDENTICAL(&_19$$20)) {
			RETURN_MM_BOOL(0);
		}
	}
	ZEPHIR_CALL_METHOD(&task, &dispatcher, "dispatch", NULL, 0);
	zephir_check_call_status();
	if (Z_TYPE_P(&eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_VAR(&_21$$22);
		ZVAL_STRING(&_21$$22, "console:afterHandleTask");
		ZEPHIR_CALL_METHOD(NULL, &eventsManager, "fire", NULL, 0, &_21$$22, this_ptr, &task);
		zephir_check_call_status();
	}
	RETURN_CCTOR(&task);

}
Example #11
0
/**
 * Returns a cached content
 *
 * @param int|string keyName
 * @param   int lifetime
 * @return  mixed
 */
PHP_METHOD(Phalcon_Cache_Backend_File, get) {

	zephir_nts_static zephir_fcall_cache_entry *_8 = NULL;
	int ttl, modifiedTime, ZEPHIR_LAST_CALL_STATUS;
	zval *keyName, *lifetime = NULL, *prefixedKey, *cacheDir, *cacheFile, *frontend, *lastLifetime, *cachedContent, *ret = NULL, *_0, *_1 = NULL, *_2, *_3 = NULL, *_4, *_5, *_6, *_7;

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

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


	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_prefix"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(&_1, this_ptr, "getkey", NULL, keyName);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(prefixedKey);
	ZEPHIR_CONCAT_VV(prefixedKey, _0, _1);
	zephir_update_property_this(this_ptr, SL("_lastKey"), prefixedKey TSRMLS_CC);
	ZEPHIR_OBS_VAR(cacheDir);
	_2 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC);
	if (!(zephir_array_isset_string_fetch(&cacheDir, _2, SS("cacheDir"), 0 TSRMLS_CC))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cache_exception_ce, "Unexpected inconsistency in options", "phalcon/cache/backend/file.zep", 115);
		return;
	}
	ZEPHIR_INIT_VAR(cacheFile);
	ZEPHIR_CONCAT_VV(cacheFile, cacheDir, prefixedKey);
	if ((zephir_file_exists(cacheFile TSRMLS_CC) == SUCCESS) == 1) {
		ZEPHIR_OBS_VAR(frontend);
		zephir_read_property_this(&frontend, this_ptr, SL("_frontend"), PH_NOISY_CC);
		if (!(zephir_is_true(lifetime))) {
			ZEPHIR_OBS_VAR(lastLifetime);
			zephir_read_property_this(&lastLifetime, this_ptr, SL("_lastLifetime"), PH_NOISY_CC);
			if (!(zephir_is_true(lastLifetime))) {
				ZEPHIR_CALL_METHOD(&_3, frontend, "getlifetime", NULL);
				zephir_check_call_status();
				ttl = zephir_get_intval(_3);
			} else {
				ttl = zephir_get_intval(lastLifetime);
			}
		} else {
			ttl = zephir_get_intval(lifetime);
		}
		ZEPHIR_INIT_VAR(_4);
		zephir_filemtime(_4, cacheFile TSRMLS_CC);
		modifiedTime = zephir_get_intval(_4);
		ZEPHIR_INIT_VAR(_5);
		zephir_time(_5);
		if (!((zephir_get_numberval(_5) - ttl) > modifiedTime)) {
			ZEPHIR_INIT_VAR(cachedContent);
			zephir_file_get_contents(cachedContent, cacheFile TSRMLS_CC);
			if (ZEPHIR_IS_FALSE_IDENTICAL(cachedContent)) {
				ZEPHIR_INIT_VAR(_6);
				object_init_ex(_6, phalcon_cache_exception_ce);
				ZEPHIR_INIT_VAR(_7);
				ZEPHIR_CONCAT_SVS(_7, "Cache file ", cacheFile, " could not be opened");
				ZEPHIR_CALL_METHOD(NULL, _6, "__construct", &_8, _7);
				zephir_check_call_status();
				zephir_throw_exception_debug(_6, "phalcon/cache/backend/file.zep", 151 TSRMLS_CC);
				ZEPHIR_MM_RESTORE();
				return;
			}
			if (zephir_is_numeric(cachedContent)) {
				RETURN_CCTOR(cachedContent);
			} else {
				ZEPHIR_CALL_METHOD(&ret, frontend, "afterretrieve", NULL, cachedContent);
				zephir_check_call_status();
				RETURN_CCTOR(ret);
			}
		}
	}
	ZEPHIR_MM_RESTORE();

}
Example #12
0
/**
 * Tries to render the view with every engine registered in the component
 *
 * @param string path
 * @param array  params
 */
PHP_METHOD(Phalcon_Mvc_View_Simple, _internalRender) {

	zephir_fcall_cache_entry *_11 = NULL, *_12 = NULL;
	HashTable *_4;
	HashPosition _3;
	int ZEPHIR_LAST_CALL_STATUS;
	zend_bool notExists, mustClean, _7, _9;
	zval *path_param = NULL, *params, *eventsManager, *engines = NULL, *extension = NULL, *engine = NULL, *viewEnginePath = NULL, *viewsDirPath, *_0 = NULL, *_1 = NULL, *_2, **_5, *_6 = NULL, _8 = zval_used_for_init, *_10 = NULL;
	zval *path = NULL;

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

	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);
	}


	ZEPHIR_OBS_VAR(eventsManager);
	zephir_read_property_this(&eventsManager, this_ptr, SL("_eventsManager"), PH_NOISY_CC);
	if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
		zephir_update_property_this(this_ptr, SL("_activeRenderPath"), path TSRMLS_CC);
	}
	if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_VAR(_1);
		ZVAL_STRING(_1, "view:beforeRender", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&_0, eventsManager, "fire", NULL, 0, _1, this_ptr);
		zephir_check_temp_parameter(_1);
		zephir_check_call_status();
		if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) {
			RETURN_MM_NULL();
		}
	}
	notExists = 1;
	mustClean = 1;
	_2 = zephir_fetch_nproperty_this(this_ptr, SL("_viewsDir"), PH_NOISY_CC);
	ZEPHIR_INIT_VAR(viewsDirPath);
	ZEPHIR_CONCAT_VV(viewsDirPath, _2, path);
	ZEPHIR_CALL_METHOD(&engines, this_ptr, "_loadtemplateengines", NULL, 0);
	zephir_check_call_status();
	zephir_is_iterable(engines, &_4, &_3, 0, 0, "phalcon/mvc/view/simple.zep", 261);
	for (
	  ; zephir_hash_get_current_data_ex(_4, (void**) &_5, &_3) == SUCCESS
	  ; zephir_hash_move_forward_ex(_4, &_3)
	) {
		ZEPHIR_GET_HMKEY(extension, _4, _3);
		ZEPHIR_GET_HVALUE(engine, _5);
		ZEPHIR_INIT_LNVAR(_6);
		ZEPHIR_CONCAT_VV(_6, viewsDirPath, extension);
		if ((zephir_file_exists(_6 TSRMLS_CC) == SUCCESS)) {
			ZEPHIR_INIT_NVAR(viewEnginePath);
			ZEPHIR_CONCAT_VV(viewEnginePath, viewsDirPath, extension);
		} else {
			_7 = zephir_is_true(extension);
			if (_7) {
				ZEPHIR_SINIT_NVAR(_8);
				ZVAL_LONG(&_8, -zephir_fast_strlen_ev(extension));
				ZEPHIR_INIT_NVAR(_1);
				zephir_substr(_1, viewsDirPath, zephir_get_intval(&_8), 0, ZEPHIR_SUBSTR_NO_LENGTH);
				_7 = ZEPHIR_IS_EQUAL(_1, extension);
			}
			_9 = _7;
			if (_9) {
				_9 = (zephir_file_exists(viewsDirPath TSRMLS_CC) == SUCCESS);
			}
			if (_9) {
				ZEPHIR_CPY_WRT(viewEnginePath, viewsDirPath);
			} else {
				ZEPHIR_INIT_NVAR(viewEnginePath);
				ZVAL_STRING(viewEnginePath, "", 1);
			}
		}
		if (zephir_is_true(viewEnginePath)) {
			if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
				ZEPHIR_INIT_NVAR(_10);
				ZVAL_STRING(_10, "view:beforeRenderView", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(&_0, eventsManager, "fire", &_11, 0, _10, this_ptr, viewEnginePath);
				zephir_check_temp_parameter(_10);
				zephir_check_call_status();
				if (ZEPHIR_IS_FALSE_IDENTICAL(_0)) {
					continue;
				}
			}
			ZEPHIR_CALL_METHOD(NULL, engine, "render", NULL, 0, viewEnginePath, params, (mustClean ? ZEPHIR_GLOBAL(global_true) : ZEPHIR_GLOBAL(global_false)));
			zephir_check_call_status();
			notExists = 0;
			if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
				ZEPHIR_INIT_NVAR(_10);
				ZVAL_STRING(_10, "view:afterRenderView", ZEPHIR_TEMP_PARAM_COPY);
				ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", &_12, 0, _10, this_ptr);
				zephir_check_temp_parameter(_10);
				zephir_check_call_status();
			}
			break;
		}
	}
	if (notExists == 1) {
		ZEPHIR_INIT_NVAR(_1);
		object_init_ex(_1, phalcon_mvc_view_exception_ce);
		ZEPHIR_INIT_LNVAR(_6);
		ZEPHIR_CONCAT_SVS(_6, "View '", viewsDirPath, "' was not found in the views directory");
		ZEPHIR_CALL_METHOD(NULL, _1, "__construct", NULL, 9, _6);
		zephir_check_call_status();
		zephir_throw_exception_debug(_1, "phalcon/mvc/view/simple.zep", 262 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_NVAR(_1);
		ZVAL_STRING(_1, "view:afterRender", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _1, this_ptr);
		zephir_check_temp_parameter(_1);
		zephir_check_call_status();
	}
	ZEPHIR_MM_RESTORE();

}
Example #13
0
/**
 * Handle the whole command-line tasks
 */
PHP_METHOD(Phalcon_Cli_Console, handle) {

	zend_bool _5;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *arguments_param = NULL, *dependencyInjector = NULL, *router = NULL, *eventsManager = NULL, *moduleName = NULL, *modules = NULL, *module = NULL, *path = NULL, *className = NULL, *moduleObject = NULL, *dispatcher = NULL, *task = NULL, *_0, *_3 = NULL, *_4 = NULL, *_15 = NULL, *_16 = NULL, *_17, *_1$$4 = NULL, *_2$$4, *_6$$6, *_7$$10 = NULL, *_8$$10, *_9$$12, *_10$$12, *_11$$15, *_12$$15, *_13$$17 = NULL, *_14$$17, *_18$$19 = NULL, *_19$$19, *_20$$21;
	zval *arguments = NULL;

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

	if (!arguments_param) {
		ZEPHIR_INIT_VAR(arguments);
		array_init(arguments);
	} else {
		zephir_get_arrval(arguments, arguments_param);
	}


	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_cli_console_exception_ce, "A dependency injection object is required to access internal services", "phalcon/cli/console.zep", 69);
		return;
	}
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC);
	ZEPHIR_CPY_WRT(eventsManager, _0);
	if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_VAR(_2$$4);
		ZVAL_STRING(_2$$4, "console:boot", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&_1$$4, eventsManager, "fire", NULL, 0, _2$$4, this_ptr);
		zephir_check_temp_parameter(_2$$4);
		zephir_check_call_status();
		if (ZEPHIR_IS_FALSE_IDENTICAL(_1$$4)) {
			RETURN_MM_BOOL(0);
		}
	}
	ZEPHIR_INIT_VAR(_4);
	ZVAL_STRING(_4, "router", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&_3, dependencyInjector, "getshared", NULL, 0, _4);
	zephir_check_temp_parameter(_4);
	zephir_check_call_status();
	ZEPHIR_CPY_WRT(router, _3);
	_5 = !(zephir_fast_count_int(arguments TSRMLS_CC));
	if (_5) {
		_0 = zephir_fetch_nproperty_this(this_ptr, SL("_arguments"), PH_NOISY_CC);
		_5 = zephir_is_true(_0);
	}
	if (_5) {
		_6$$6 = zephir_fetch_nproperty_this(this_ptr, SL("_arguments"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(NULL, router, "handle", NULL, 0, _6$$6);
		zephir_check_call_status();
	} else {
		ZEPHIR_CALL_METHOD(NULL, router, "handle", NULL, 0, arguments);
		zephir_check_call_status();
	}
	ZEPHIR_CALL_METHOD(&moduleName, router, "getmodulename", NULL, 0);
	zephir_check_call_status();
	if (!(zephir_is_true(moduleName))) {
		ZEPHIR_OBS_NVAR(moduleName);
		zephir_read_property_this(&moduleName, this_ptr, SL("_defaultModule"), PH_NOISY_CC);
	}
	if (zephir_is_true(moduleName)) {
		if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
			ZEPHIR_INIT_VAR(_8$$10);
			ZVAL_STRING(_8$$10, "console:beforeStartModule", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&_7$$10, eventsManager, "fire", NULL, 0, _8$$10, this_ptr, moduleName);
			zephir_check_temp_parameter(_8$$10);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_7$$10)) {
				RETURN_MM_BOOL(0);
			}
		}
		ZEPHIR_OBS_VAR(modules);
		zephir_read_property_this(&modules, this_ptr, SL("_modules"), PH_NOISY_CC);
		if (!(zephir_array_isset(modules, moduleName))) {
			ZEPHIR_INIT_VAR(_9$$12);
			object_init_ex(_9$$12, phalcon_cli_console_exception_ce);
			ZEPHIR_INIT_VAR(_10$$12);
			ZEPHIR_CONCAT_SVS(_10$$12, "Module '", moduleName, "' isn't registered in the console container");
			ZEPHIR_CALL_METHOD(NULL, _9$$12, "__construct", NULL, 9, _10$$12);
			zephir_check_call_status();
			zephir_throw_exception_debug(_9$$12, "phalcon/cli/console.zep", 109 TSRMLS_CC);
			ZEPHIR_MM_RESTORE();
			return;
		}
		ZEPHIR_OBS_VAR(module);
		zephir_array_fetch(&module, modules, moduleName, PH_NOISY, "phalcon/cli/console.zep", 112 TSRMLS_CC);
		if (Z_TYPE_P(module) != IS_ARRAY) {
			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_console_exception_ce, "Invalid module definition path", "phalcon/cli/console.zep", 114);
			return;
		}
		ZEPHIR_OBS_VAR(path);
		if (zephir_array_isset_string_fetch(&path, module, SS("path"), 0 TSRMLS_CC)) {
			if (!((zephir_file_exists(path TSRMLS_CC) == SUCCESS))) {
				ZEPHIR_INIT_VAR(_11$$15);
				object_init_ex(_11$$15, phalcon_cli_console_exception_ce);
				ZEPHIR_INIT_VAR(_12$$15);
				ZEPHIR_CONCAT_SVS(_12$$15, "Module definition path '", path, "' doesn't exist");
				ZEPHIR_CALL_METHOD(NULL, _11$$15, "__construct", NULL, 9, _12$$15);
				zephir_check_call_status();
				zephir_throw_exception_debug(_11$$15, "phalcon/cli/console.zep", 119 TSRMLS_CC);
				ZEPHIR_MM_RESTORE();
				return;
			}
			if (zephir_require_zval(path TSRMLS_CC) == FAILURE) {
				RETURN_MM_NULL();
			}
		}
		ZEPHIR_OBS_VAR(className);
		if (!(zephir_array_isset_string_fetch(&className, module, SS("className"), 0 TSRMLS_CC))) {
			ZEPHIR_INIT_NVAR(className);
			ZVAL_STRING(className, "Module", 1);
		}
		ZEPHIR_CALL_METHOD(&moduleObject, dependencyInjector, "get", NULL, 0, className);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, moduleObject, "registerautoloaders", NULL, 0);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, moduleObject, "registerservices", NULL, 0, dependencyInjector);
		zephir_check_call_status();
		if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
			ZEPHIR_INIT_VAR(_14$$17);
			ZVAL_STRING(_14$$17, "console:afterStartModule", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&_13$$17, eventsManager, "fire", NULL, 0, _14$$17, this_ptr, moduleObject);
			zephir_check_temp_parameter(_14$$17);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_13$$17)) {
				RETURN_MM_BOOL(0);
			}
		}
	}
	ZEPHIR_INIT_NVAR(_4);
	ZVAL_STRING(_4, "dispatcher", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&_3, dependencyInjector, "getshared", NULL, 0, _4);
	zephir_check_temp_parameter(_4);
	zephir_check_call_status();
	ZEPHIR_CPY_WRT(dispatcher, _3);
	ZEPHIR_CALL_METHOD(&_3, router, "gettaskname", NULL, 0);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(NULL, dispatcher, "settaskname", NULL, 0, _3);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&_15, router, "getactionname", NULL, 0);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(NULL, dispatcher, "setactionname", NULL, 0, _15);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&_16, router, "getparams", NULL, 0);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(NULL, dispatcher, "setparams", NULL, 0, _16);
	zephir_check_call_status();
	_17 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(NULL, dispatcher, "setoptions", NULL, 0, _17);
	zephir_check_call_status();
	if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_VAR(_19$$19);
		ZVAL_STRING(_19$$19, "console:beforeHandleTask", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&_18$$19, eventsManager, "fire", NULL, 0, _19$$19, this_ptr, dispatcher);
		zephir_check_temp_parameter(_19$$19);
		zephir_check_call_status();
		if (ZEPHIR_IS_FALSE_IDENTICAL(_18$$19)) {
			RETURN_MM_BOOL(0);
		}
	}
	ZEPHIR_CALL_METHOD(&task, dispatcher, "dispatch", NULL, 0);
	zephir_check_call_status();
	if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_VAR(_20$$21);
		ZVAL_STRING(_20$$21, "console:afterHandleTask", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, 0, _20$$21, this_ptr, task);
		zephir_check_temp_parameter(_20$$21);
		zephir_check_call_status();
	}
	RETURN_CCTOR(task);

}
Example #14
0
/**
 * Handle the whole command-line tasks
 *
 * @param array arguments
 * @return mixed
 */
PHP_METHOD(Phalcon_Cli_Console, handle) {

	zephir_nts_static zephir_fcall_cache_entry *_6 = NULL;
	zend_bool _3;
	int ZEPHIR_LAST_CALL_STATUS;
	zval *arguments = NULL, *dependencyInjector, *router = NULL, *eventsManager = NULL, *moduleName = NULL, *modules, *module, *path, *className = NULL, *moduleObject = NULL, *dispatcher = NULL, *task = NULL, *_0, *_1 = NULL, *_2 = NULL, *_4, *_5 = NULL, *_7 = NULL, *_8 = NULL, *_9 = NULL, *_10 = NULL;

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

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


	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_cli_console_exception_ce, "A dependency injection object is required to access internal services", "phalcon/cli/console.zep", 171);
		return;
	}
	_0 = zephir_fetch_nproperty_this(this_ptr, SL("_eventsManager"), PH_NOISY_CC);
	ZEPHIR_CPY_WRT(eventsManager, _0);
	ZEPHIR_INIT_VAR(_2);
	ZVAL_STRING(_2, "router", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&_1, dependencyInjector, "getshared", NULL, _2);
	zephir_check_temp_parameter(_2);
	zephir_check_call_status();
	ZEPHIR_CPY_WRT(router, _1);
	_3 = !zephir_is_true(arguments);
	if (_3) {
		_0 = zephir_fetch_nproperty_this(this_ptr, SL("_arguments"), PH_NOISY_CC);
		_3 = zephir_is_true(_0);
	}
	if (_3) {
		_4 = zephir_fetch_nproperty_this(this_ptr, SL("_arguments"), PH_NOISY_CC);
		ZEPHIR_CALL_METHOD(NULL, router, "handle", NULL, _4);
		zephir_check_call_status();
	} else {
		ZEPHIR_CALL_METHOD(NULL, router, "handle", NULL, arguments);
		zephir_check_call_status();
	}
	ZEPHIR_CALL_METHOD(&moduleName, router, "getmodulename", NULL);
	zephir_check_call_status();
	if (zephir_is_true(moduleName)) {
		if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
			ZEPHIR_INIT_NVAR(_2);
			ZVAL_STRING(_2, "console:beforeStartModule", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&_1, eventsManager, "fire", NULL, _2, this_ptr, moduleName);
			zephir_check_temp_parameter(_2);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_1)) {
				RETURN_MM_BOOL(0);
			}
		}
		ZEPHIR_OBS_VAR(modules);
		zephir_read_property_this(&modules, this_ptr, SL("_modules"), PH_NOISY_CC);
		if (!(zephir_array_isset(modules, moduleName))) {
			ZEPHIR_INIT_NVAR(_2);
			object_init_ex(_2, phalcon_cli_console_exception_ce);
			ZEPHIR_INIT_VAR(_5);
			ZEPHIR_CONCAT_SVS(_5, "Module '", moduleName, "' isn't registered in the console container");
			ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, _5);
			zephir_check_call_status();
			zephir_throw_exception_debug(_2, "phalcon/cli/console.zep", 195 TSRMLS_CC);
			ZEPHIR_MM_RESTORE();
			return;
		}
		ZEPHIR_OBS_VAR(module);
		zephir_array_fetch(&module, modules, moduleName, PH_NOISY, "phalcon/cli/console.zep", 198 TSRMLS_CC);
		if (Z_TYPE_P(module) != IS_ARRAY) {
			ZEPHIR_THROW_EXCEPTION_DEBUG_STR(phalcon_cli_console_exception_ce, "Invalid module definition path", "phalcon/cli/console.zep", 200);
			return;
		}
		ZEPHIR_OBS_VAR(path);
		if (zephir_array_isset_string_fetch(&path, module, SS("path"), 0 TSRMLS_CC)) {
			if (!((zephir_file_exists(path TSRMLS_CC) == SUCCESS))) {
				ZEPHIR_INIT_NVAR(_2);
				object_init_ex(_2, phalcon_cli_console_exception_ce);
				ZEPHIR_INIT_LNVAR(_5);
				ZEPHIR_CONCAT_SVS(_5, "Module definition path '", path, "' doesn't exist");
				ZEPHIR_CALL_METHOD(NULL, _2, "__construct", &_6, _5);
				zephir_check_call_status();
				zephir_throw_exception_debug(_2, "phalcon/cli/console.zep", 205 TSRMLS_CC);
				ZEPHIR_MM_RESTORE();
				return;
			}
			if (zephir_require_zval(path TSRMLS_CC) == FAILURE) {
				RETURN_MM_NULL();
			}
		}
		ZEPHIR_OBS_VAR(className);
		if (!(zephir_array_isset_string_fetch(&className, module, SS("className"), 0 TSRMLS_CC))) {
			ZEPHIR_INIT_NVAR(className);
			ZVAL_STRING(className, "Module", 1);
		}
		ZEPHIR_CALL_METHOD(&moduleObject, dependencyInjector, "get", NULL, className);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, moduleObject, "registerautoloaders", NULL);
		zephir_check_call_status();
		ZEPHIR_CALL_METHOD(NULL, moduleObject, "registerservices", NULL, dependencyInjector);
		zephir_check_call_status();
		if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
			zephir_update_property_this(this_ptr, SL("_moduleObject"), moduleObject TSRMLS_CC);
			ZEPHIR_INIT_NVAR(_2);
			ZVAL_STRING(_2, "console:afterStartModule", ZEPHIR_TEMP_PARAM_COPY);
			ZEPHIR_CALL_METHOD(&_7, eventsManager, "fire", NULL, _2, this_ptr, moduleObject);
			zephir_check_temp_parameter(_2);
			zephir_check_call_status();
			if (ZEPHIR_IS_FALSE_IDENTICAL(_7)) {
				RETURN_MM_BOOL(0);
			}
		}
	}
	ZEPHIR_INIT_NVAR(_2);
	ZVAL_STRING(_2, "dispatcher", ZEPHIR_TEMP_PARAM_COPY);
	ZEPHIR_CALL_METHOD(&_7, dependencyInjector, "getshared", NULL, _2);
	zephir_check_temp_parameter(_2);
	zephir_check_call_status();
	ZEPHIR_CPY_WRT(dispatcher, _7);
	ZEPHIR_CALL_METHOD(&_7, router, "gettaskname", NULL);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(NULL, dispatcher, "settaskname", NULL, _7);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&_8, router, "getactionname", NULL);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(NULL, dispatcher, "setactionname", NULL, _8);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(&_9, router, "getparams", NULL);
	zephir_check_call_status();
	ZEPHIR_CALL_METHOD(NULL, dispatcher, "setparams", NULL, _9);
	zephir_check_call_status();
	_4 = zephir_fetch_nproperty_this(this_ptr, SL("_options"), PH_NOISY_CC);
	ZEPHIR_CALL_METHOD(NULL, dispatcher, "setoptions", NULL, _4);
	zephir_check_call_status();
	if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_NVAR(_2);
		ZVAL_STRING(_2, "console:beforeHandleTask", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(&_10, eventsManager, "fire", NULL, _2, this_ptr, dispatcher);
		zephir_check_temp_parameter(_2);
		zephir_check_call_status();
		if (ZEPHIR_IS_FALSE_IDENTICAL(_10)) {
			RETURN_MM_BOOL(0);
		}
	}
	ZEPHIR_CALL_METHOD(&task, dispatcher, "dispatch", NULL);
	zephir_check_call_status();
	if (Z_TYPE_P(eventsManager) == IS_OBJECT) {
		ZEPHIR_INIT_NVAR(_2);
		ZVAL_STRING(_2, "console:afterHandleTask", ZEPHIR_TEMP_PARAM_COPY);
		ZEPHIR_CALL_METHOD(NULL, eventsManager, "fire", NULL, _2, this_ptr, task);
		zephir_check_temp_parameter(_2);
		zephir_check_call_status();
	}
	RETURN_CCTOR(task);

}
Example #15
0
/**
 * Reads and decodes a JSON-encoded file into an object or array
 *
 * @param string $file A readable JSON file.
 * @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, decodeFile) {

	int depth, flags, ZEPHIR_LAST_CALL_STATUS;
	zend_bool assoc;
	zval *file_param = NULL, *assoc_param = NULL, *depth_param = NULL, *flags_param = NULL, *json = NULL, *_2, *_3, *_4, *_0$$3;
	zval *file = NULL, *_1$$3;

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

	if (unlikely(Z_TYPE_P(file_param) != IS_STRING && Z_TYPE_P(file_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'file' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(file_param) == IS_STRING)) {
		zephir_get_strval(file, file_param);
	} else {
		ZEPHIR_INIT_VAR(file);
		ZVAL_EMPTY_STRING(file);
	}
	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_file_exists(file TSRMLS_CC) == SUCCESS))) {
		ZEPHIR_INIT_VAR(_0$$3);
		object_init_ex(_0$$3, spl_ce_RuntimeException);
		ZEPHIR_INIT_VAR(_1$$3);
		ZEPHIR_CONCAT_SV(_1$$3, "Unreadable file: ", file);
		ZEPHIR_CALL_METHOD(NULL, _0$$3, "__construct", NULL, 111, _1$$3);
		zephir_check_call_status();
		zephir_throw_exception_debug(_0$$3, "xpl/json.zep", 62 TSRMLS_CC);
		ZEPHIR_MM_RESTORE();
		return;
	}
	ZEPHIR_INIT_VAR(json);
	zephir_file_get_contents(json, file TSRMLS_CC);
	ZEPHIR_INIT_VAR(_2);
	if (assoc) {
		ZVAL_BOOL(_2, 1);
	} else {
		ZVAL_BOOL(_2, 0);
	}
	ZEPHIR_INIT_VAR(_3);
	ZVAL_LONG(_3, depth);
	ZEPHIR_INIT_VAR(_4);
	ZVAL_LONG(_4, flags);
	ZEPHIR_RETURN_CALL_SELF("decode", NULL, 0, json, _2, _3, _4);
	zephir_check_call_status();
	RETURN_MM();

}
Example #16
0
/**
 * Returns a ClassLoader for the given Composer installation.
 *
 * @param string vendorPath
 * @param boolean prepend [Optional] Default = true
 *
 * @return \Xpl\ClassLoader
 */
PHP_METHOD(Xpl_ClassLoader, composer) {

	HashTable *_8, *_12, *_18$$10;
	HashPosition _7, _11, _17$$10;
	zephir_fcall_cache_entry *_10 = NULL, *_14 = NULL;
	int ZEPHIR_LAST_CALL_STATUS;
	zend_bool prepend;
	zval *vendorPath_param = NULL, *prepend_param = NULL, *composerPath = NULL, *instances = NULL, *loader = NULL, *ns = NULL, *path = NULL, *namespaces = NULL, *psr4 = NULL, *classMap = NULL, *filesPath = NULL, *files = NULL, *_0, _1, *_2, *_3, *_4 = NULL, *_5, *_6, **_9, **_13, *_15, *_16$$10 = NULL, **_19$$10;
	zval *vendorPath = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 1, 1, &vendorPath_param, &prepend_param);

	if (unlikely(Z_TYPE_P(vendorPath_param) != IS_STRING && Z_TYPE_P(vendorPath_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'vendorPath' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(vendorPath_param) == IS_STRING)) {
		zephir_get_strval(vendorPath, vendorPath_param);
	} else {
		ZEPHIR_INIT_VAR(vendorPath);
		ZVAL_EMPTY_STRING(vendorPath);
	}
	if (!prepend_param) {
		prepend = 1;
	} else {
		prepend = zephir_get_boolval(prepend_param);
	}


	ZEPHIR_INIT_VAR(_0);
	ZEPHIR_SINIT_VAR(_1);
	ZVAL_STRING(&_1, "/\\", 0);
	zephir_fast_trim(_0, vendorPath, &_1, ZEPHIR_TRIM_RIGHT TSRMLS_CC);
	ZEPHIR_INIT_VAR(_2);
	ZEPHIR_CONCAT_VS(_2, _0, "/composer");
	ZEPHIR_CALL_FUNCTION(&composerPath, "realpath", NULL, 47, _2);
	zephir_check_call_status();
	if (!(zephir_is_true(composerPath))) {
		ZEPHIR_THROW_EXCEPTION_DEBUG_STR(spl_ce_InvalidArgumentException, "Composer directory does not exist", "xpl/classloader.zep", 147);
		return;
	}
	zephir_concat_self_str(&composerPath, SL("/") TSRMLS_CC);
	ZEPHIR_OBS_VAR(instances);
	zephir_read_static_property_ce(&instances, xpl_classloader_ce, SL("composerInstances") TSRMLS_CC);
	if (Z_TYPE_P(instances) != IS_NULL) {
		ZEPHIR_OBS_VAR(loader);
		if (zephir_array_isset_fetch(&loader, instances, composerPath, 0 TSRMLS_CC)) {
			RETURN_CCTOR(loader);
		}
	} else {
		ZEPHIR_INIT_NVAR(instances);
		array_init(instances);
	}
	ZEPHIR_INIT_NVAR(loader);
	object_init_ex(loader, xpl_classloader_ce);
	if (zephir_has_constructor(loader TSRMLS_CC)) {
		ZEPHIR_CALL_METHOD(NULL, loader, "__construct", NULL, 0);
		zephir_check_call_status();
	}
	ZEPHIR_INIT_VAR(_3);
	ZEPHIR_CONCAT_VS(_3, composerPath, "autoload_namespaces.php");
	ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(&_4);
	if (zephir_require_zval_ret(&_4, _3 TSRMLS_CC) == FAILURE) {
		RETURN_MM_NULL();
	}
	ZEPHIR_CPY_WRT(namespaces, _4);
	ZEPHIR_INIT_VAR(_5);
	ZEPHIR_CONCAT_VS(_5, composerPath, "autoload_psr4.php");
	ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(&_4);
	if (zephir_require_zval_ret(&_4, _5 TSRMLS_CC) == FAILURE) {
		RETURN_MM_NULL();
	}
	ZEPHIR_CPY_WRT(psr4, _4);
	ZEPHIR_INIT_VAR(_6);
	ZEPHIR_CONCAT_VS(_6, composerPath, "autoload_classmap.php");
	ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(&_4);
	if (zephir_require_zval_ret(&_4, _6 TSRMLS_CC) == FAILURE) {
		RETURN_MM_NULL();
	}
	ZEPHIR_CPY_WRT(classMap, _4);
	ZEPHIR_INIT_VAR(filesPath);
	ZEPHIR_CONCAT_VS(filesPath, composerPath, "autoload_files.php");
	zephir_is_iterable(namespaces, &_8, &_7, 0, 0, "xpl/classloader.zep", 171);
	for (
	  ; zephir_hash_get_current_data_ex(_8, (void**) &_9, &_7) == SUCCESS
	  ; zephir_hash_move_forward_ex(_8, &_7)
	) {
		ZEPHIR_GET_HMKEY(ns, _8, _7);
		ZEPHIR_GET_HVALUE(path, _9);
		ZEPHIR_CALL_METHOD(NULL, loader, "set", &_10, 48, ns, path);
		zephir_check_call_status();
	}
	zephir_is_iterable(psr4, &_12, &_11, 0, 0, "xpl/classloader.zep", 175);
	for (
	  ; zephir_hash_get_current_data_ex(_12, (void**) &_13, &_11) == SUCCESS
	  ; zephir_hash_move_forward_ex(_12, &_11)
	) {
		ZEPHIR_GET_HMKEY(ns, _12, _11);
		ZEPHIR_GET_HVALUE(path, _13);
		ZEPHIR_CALL_METHOD(NULL, loader, "setpsr4", &_14, 49, ns, path);
		zephir_check_call_status();
	}
	if (zephir_fast_count_int(classMap TSRMLS_CC)) {
		ZEPHIR_CALL_METHOD(NULL, loader, "addclassmap", NULL, 50, classMap);
		zephir_check_call_status();
	}
	ZEPHIR_INIT_VAR(_15);
	if (prepend) {
		ZVAL_BOOL(_15, 1);
	} else {
		ZVAL_BOOL(_15, 0);
	}
	ZEPHIR_CALL_METHOD(NULL, loader, "register", NULL, 51, _15);
	zephir_check_call_status();
	if ((zephir_file_exists(filesPath TSRMLS_CC) == SUCCESS)) {
		ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(&_16$$10);
		if (zephir_require_zval_ret(&_16$$10, filesPath TSRMLS_CC) == FAILURE) {
			RETURN_MM_NULL();
		}
		ZEPHIR_CPY_WRT(files, _16$$10);
		zephir_is_iterable(files, &_18$$10, &_17$$10, 0, 0, "xpl/classloader.zep", 186);
		for (
		  ; zephir_hash_get_current_data_ex(_18$$10, (void**) &_19$$10, &_17$$10) == SUCCESS
		  ; zephir_hash_move_forward_ex(_18$$10, &_17$$10)
		) {
			ZEPHIR_GET_HVALUE(path, _19$$10);
			if (zephir_require_zval(path TSRMLS_CC) == FAILURE) {
				RETURN_MM_NULL();
			}
		}
	}
	ZEPHIR_CALL_METHOD(NULL, loader, "setcomposerpath", NULL, 52, composerPath);
	zephir_check_call_status();
	zephir_array_update_zval(&instances, composerPath, &loader, PH_COPY | PH_SEPARATE);
	zephir_update_static_property_ce(xpl_classloader_ce, SL("composerInstances"), &instances TSRMLS_CC);
	RETURN_CCTOR(loader);

}
Example #17
0
PHP_METHOD(Xpl_ClassLoader, findFileWithExtension) {

	HashTable *_16, *_39, *_6$$3, *_11$$5, *_32$$12, *_35$$14;
	HashPosition _15, _38, _5$$3, _10$$5, _31$$12, _34$$14;
	int ZEPHIR_LAST_CALL_STATUS;
	zephir_fcall_cache_entry *_3 = NULL;
	zval *className_param = NULL, *ext_param = NULL, *logicalPathPsr4 = NULL, *firstChar = NULL, *prefixLengthsPsr4 = NULL, *prefix = NULL, *length = NULL, *dir = NULL, *file = NULL, *prefixesPsr0 = NULL, *logicalPathPsr0 = NULL, *nsPos = NULL, *dirs = NULL, _0 = zval_used_for_init, _1 = zval_used_for_init, *_2 = NULL, *_4, *_14, **_17, _18, *_30, *_37, **_40, *_41, **_7$$3, *_8$$5, *_9$$5, **_12$$5, *_13$$6 = NULL, _19$$10, _20$$10, *_21$$10, _22$$10, *_23$$10, _24$$10, _25$$10, *_26$$10 = NULL, _27$$11, _28$$11, *_29$$11 = NULL, **_33$$12, **_36$$14;
	zval *className = NULL, *ext = NULL;

	ZEPHIR_MM_GROW();
	zephir_fetch_params(1, 2, 0, &className_param, &ext_param);

	if (unlikely(Z_TYPE_P(className_param) != IS_STRING && Z_TYPE_P(className_param) != IS_NULL)) {
		zephir_throw_exception_string(spl_ce_InvalidArgumentException, SL("Parameter 'className' must be a string") TSRMLS_CC);
		RETURN_MM_NULL();
	}
	if (likely(Z_TYPE_P(className_param) == IS_STRING)) {
		zephir_get_strval(className, className_param);
	} else {
		ZEPHIR_INIT_VAR(className);
		ZVAL_EMPTY_STRING(className);
	}
	zephir_get_strval(ext, ext_param);


	ZEPHIR_SINIT_VAR(_0);
	ZVAL_STRING(&_0, "\\", 0);
	ZEPHIR_SINIT_VAR(_1);
	ZVAL_STRING(&_1, "/", 0);
	ZEPHIR_CALL_FUNCTION(&_2, "strtr", &_3, 56, className, &_0, &_1);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(logicalPathPsr4);
	ZEPHIR_CONCAT_VV(logicalPathPsr4, _2, ext);
	ZEPHIR_SINIT_NVAR(_0);
	ZVAL_LONG(&_0, 0);
	ZEPHIR_SINIT_NVAR(_1);
	ZVAL_LONG(&_1, 1);
	ZEPHIR_INIT_VAR(firstChar);
	zephir_substr(firstChar, className, 0 , 1 , 0);
	ZEPHIR_OBS_VAR(prefixLengthsPsr4);
	_4 = zephir_fetch_nproperty_this(this_ptr, SL("prefixLengthsPsr4"), PH_NOISY_CC);
	if (zephir_array_isset_fetch(&prefixLengthsPsr4, _4, firstChar, 0 TSRMLS_CC)) {
		zephir_is_iterable(prefixLengthsPsr4, &_6$$3, &_5$$3, 0, 0, "xpl/classloader.zep", 505);
		for (
		  ; zephir_hash_get_current_data_ex(_6$$3, (void**) &_7$$3, &_5$$3) == SUCCESS
		  ; zephir_hash_move_forward_ex(_6$$3, &_5$$3)
		) {
			ZEPHIR_GET_HMKEY(prefix, _6$$3, _5$$3);
			ZEPHIR_GET_HVALUE(length, _7$$3);
			if (zephir_start_with(className, prefix, ZEPHIR_GLOBAL(global_false))) {
				_8$$5 = zephir_fetch_nproperty_this(this_ptr, SL("prefixDirsPsr4"), PH_NOISY_CC);
				zephir_array_fetch(&_9$$5, _8$$5, prefix, PH_NOISY | PH_READONLY, "xpl/classloader.zep", 495 TSRMLS_CC);
				zephir_is_iterable(_9$$5, &_11$$5, &_10$$5, 0, 0, "xpl/classloader.zep", 503);
				for (
				  ; zephir_hash_get_current_data_ex(_11$$5, (void**) &_12$$5, &_10$$5) == SUCCESS
				  ; zephir_hash_move_forward_ex(_11$$5, &_10$$5)
				) {
					ZEPHIR_GET_HVALUE(dir, _12$$5);
					ZEPHIR_INIT_NVAR(_13$$6);
					zephir_substr(_13$$6, logicalPathPsr4, zephir_get_intval(length), 0, ZEPHIR_SUBSTR_NO_LENGTH);
					ZEPHIR_INIT_NVAR(file);
					ZEPHIR_CONCAT_VSV(file, dir, "/", _13$$6);
					if ((zephir_file_exists(file TSRMLS_CC) == SUCCESS)) {
						RETURN_CCTOR(file);
					}
				}
			}
		}
	}
	_14 = zephir_fetch_nproperty_this(this_ptr, SL("fallbackDirsPsr4"), PH_NOISY_CC);
	zephir_is_iterable(_14, &_16, &_15, 0, 0, "xpl/classloader.zep", 517);
	for (
	  ; zephir_hash_get_current_data_ex(_16, (void**) &_17, &_15) == SUCCESS
	  ; zephir_hash_move_forward_ex(_16, &_15)
	) {
		ZEPHIR_GET_HVALUE(dir, _17);
		ZEPHIR_INIT_NVAR(file);
		ZEPHIR_CONCAT_VSV(file, dir, "/", logicalPathPsr4);
		if ((zephir_file_exists(file TSRMLS_CC) == SUCCESS)) {
			RETURN_CCTOR(file);
		}
	}
	ZEPHIR_SINIT_VAR(_18);
	ZVAL_STRING(&_18, "\\", 0);
	ZEPHIR_CALL_FUNCTION(&nsPos, "strrpos", NULL, 57, className, &_18);
	zephir_check_call_status();
	ZEPHIR_INIT_VAR(logicalPathPsr0);
	if (zephir_is_true(nsPos)) {
		ZEPHIR_SINIT_VAR(_19$$10);
		ZVAL_LONG(&_19$$10, 0);
		ZEPHIR_SINIT_VAR(_20$$10);
		ZVAL_LONG(&_20$$10, (zephir_get_numberval(nsPos) + 1));
		ZEPHIR_INIT_VAR(_21$$10);
		zephir_substr(_21$$10, logicalPathPsr4, 0 , zephir_get_intval(&_20$$10), 0);
		ZEPHIR_SINIT_VAR(_22$$10);
		ZVAL_LONG(&_22$$10, (zephir_get_numberval(nsPos) + 1));
		ZEPHIR_INIT_VAR(_23$$10);
		zephir_substr(_23$$10, logicalPathPsr4, zephir_get_intval(&_22$$10), 0, ZEPHIR_SUBSTR_NO_LENGTH);
		ZEPHIR_SINIT_VAR(_24$$10);
		ZVAL_STRING(&_24$$10, "_", 0);
		ZEPHIR_SINIT_VAR(_25$$10);
		ZVAL_STRING(&_25$$10, "/", 0);
		ZEPHIR_CALL_FUNCTION(&_26$$10, "strtr", &_3, 56, _23$$10, &_24$$10, &_25$$10);
		zephir_check_call_status();
		ZEPHIR_CONCAT_VV(logicalPathPsr0, _21$$10, _26$$10);
	} else {
		ZEPHIR_SINIT_VAR(_27$$11);
		ZVAL_STRING(&_27$$11, "_", 0);
		ZEPHIR_SINIT_VAR(_28$$11);
		ZVAL_STRING(&_28$$11, "/", 0);
		ZEPHIR_CALL_FUNCTION(&_29$$11, "strtr", &_3, 56, className, &_27$$11, &_28$$11);
		zephir_check_call_status();
		ZEPHIR_CONCAT_VV(logicalPathPsr0, _29$$11, ext);
	}
	ZEPHIR_OBS_VAR(prefixesPsr0);
	_30 = zephir_fetch_nproperty_this(this_ptr, SL("prefixesPsr0"), PH_NOISY_CC);
	if (zephir_array_isset_fetch(&prefixesPsr0, _30, firstChar, 0 TSRMLS_CC)) {
		zephir_is_iterable(prefixesPsr0, &_32$$12, &_31$$12, 0, 0, "xpl/classloader.zep", 546);
		for (
		  ; zephir_hash_get_current_data_ex(_32$$12, (void**) &_33$$12, &_31$$12) == SUCCESS
		  ; zephir_hash_move_forward_ex(_32$$12, &_31$$12)
		) {
			ZEPHIR_GET_HMKEY(prefix, _32$$12, _31$$12);
			ZEPHIR_GET_HVALUE(dirs, _33$$12);
			if (zephir_start_with(className, prefix, NULL)) {
				zephir_is_iterable(dirs, &_35$$14, &_34$$14, 0, 0, "xpl/classloader.zep", 544);
				for (
				  ; zephir_hash_get_current_data_ex(_35$$14, (void**) &_36$$14, &_34$$14) == SUCCESS
				  ; zephir_hash_move_forward_ex(_35$$14, &_34$$14)
				) {
					ZEPHIR_GET_HVALUE(dir, _36$$14);
					ZEPHIR_INIT_NVAR(file);
					ZEPHIR_CONCAT_VSV(file, dir, "/", logicalPathPsr0);
					if ((zephir_file_exists(file TSRMLS_CC) == SUCCESS)) {
						RETURN_CCTOR(file);
					}
				}
			}
		}
	}
	_37 = zephir_fetch_nproperty_this(this_ptr, SL("fallbackDirsPsr0"), PH_NOISY_CC);
	zephir_is_iterable(_37, &_39, &_38, 0, 0, "xpl/classloader.zep", 559);
	for (
	  ; zephir_hash_get_current_data_ex(_39, (void**) &_40, &_38) == SUCCESS
	  ; zephir_hash_move_forward_ex(_39, &_38)
	) {
		ZEPHIR_GET_HVALUE(dir, _40);
		ZEPHIR_INIT_NVAR(file);
		ZEPHIR_CONCAT_VSV(file, dir, "/", logicalPathPsr0);
		if ((zephir_file_exists(file TSRMLS_CC) == SUCCESS)) {
			RETURN_CCTOR(file);
		}
	}
	_41 = zephir_fetch_nproperty_this(this_ptr, SL("useIncludePath"), PH_NOISY_CC);
	if (ZEPHIR_IS_TRUE_IDENTICAL(_41)) {
		ZEPHIR_CALL_FUNCTION(&file, "stream_resolve_include_path", NULL, 58, logicalPathPsr0);
		zephir_check_call_status();
		if (zephir_is_true(file)) {
			RETURN_CCTOR(file);
		}
	}
	RETURN_MM_NULL();

}
Example #18
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();

}
/**
 * Generates an unique auth code.
 *
 * Implementing classes may want to override this function to implement
 * other auth code generation schemes.
 *
 * @return string An unique auth code.
 *
 * @ingroup oauth2_section_4
 */
PHP_METHOD(OAuth2_ResponseType_AuthorizationCode, generateAuthorizationCode) {

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

	ZEPHIR_MM_GROW();

	tokenLen = 40;
	ZEPHIR_SINIT_VAR(_0);
	ZVAL_STRING(&_0, "/dev/urandom", 0);
	if ((zephir_function_exists_ex(SS("mcrypt_create_iv") TSRMLS_CC) == SUCCESS)) {
		ZEPHIR_SINIT_VAR(_1);
		ZVAL_LONG(&_1, 100);
		ZEPHIR_SINIT_VAR(_2);
		ZVAL_LONG(&_2, 1);
		ZEPHIR_CALL_FUNCTION(&randomData, "mcrypt_create_iv", NULL, &_1, &_2);
		zephir_check_call_status();
	} else if ((zephir_function_exists_ex(SS("openssl_random_pseudo_bytes") TSRMLS_CC) == SUCCESS)) {
		ZEPHIR_INIT_VAR(_3);
		ZVAL_LONG(_3, 100);
		ZEPHIR_CALL_FUNCTION(&randomData, "openssl_random_pseudo_bytes", NULL, _3);
		zephir_check_call_status();
	} else if ((zephir_file_exists(&_0 TSRMLS_CC) == SUCCESS)) {
		ZEPHIR_SINIT_NVAR(_1);
		ZVAL_STRING(&_1, "/dev/urandom", 0);
		ZEPHIR_SINIT_NVAR(_2);
		ZVAL_LONG(&_2, 0);
		ZEPHIR_SINIT_VAR(_4);
		ZVAL_LONG(&_4, 100);
		ZEPHIR_CALL_FUNCTION(&_5, "file_get_contents", &_6, &_1, ZEPHIR_GLOBAL(global_false), ZEPHIR_GLOBAL(global_null), &_2, &_4);
		zephir_check_call_status();
		ZEPHIR_CALL_FUNCTION(&_7, "mt_rand", &_8);
		zephir_check_call_status();
		ZEPHIR_CALL_FUNCTION(&_9, "uniqid", &_10, _7, ZEPHIR_GLOBAL(global_true));
		zephir_check_call_status();
		ZEPHIR_INIT_NVAR(randomData);
		ZEPHIR_CONCAT_VV(randomData, _5, _9);
	} else {
		ZEPHIR_CALL_FUNCTION(&_5, "mt_rand", &_8);
		zephir_check_call_status();
		ZEPHIR_CALL_FUNCTION(&_7, "mt_rand", &_8);
		zephir_check_call_status();
		ZEPHIR_CALL_FUNCTION(&_9, "mt_rand", &_8);
		zephir_check_call_status();
		ZEPHIR_CALL_FUNCTION(&_11, "mt_rand", &_8);
		zephir_check_call_status();
		ZEPHIR_CALL_FUNCTION(&_12, "microtime", &_13, ZEPHIR_GLOBAL(global_true));
		zephir_check_call_status();
		ZEPHIR_CALL_FUNCTION(&_14, "mt_rand", &_8);
		zephir_check_call_status();
		ZEPHIR_CALL_FUNCTION(&_15, "uniqid", &_10, _14, ZEPHIR_GLOBAL(global_true));
		zephir_check_call_status();
		ZEPHIR_INIT_NVAR(randomData);
		ZEPHIR_CONCAT_VVVVVV(randomData, _5, _7, _9, _11, _12, _15);
	}
	ZEPHIR_SINIT_NVAR(_1);
	ZVAL_STRING(&_1, "sha512", 0);
	ZEPHIR_CALL_FUNCTION(&_5, "hash", NULL, &_1, randomData);
	zephir_check_call_status();
	ZEPHIR_SINIT_NVAR(_1);
	ZVAL_LONG(&_1, 0);
	ZEPHIR_SINIT_NVAR(_2);
	ZVAL_LONG(&_2, tokenLen);
	ZEPHIR_RETURN_CALL_FUNCTION("substr", &_16, _5, &_1, &_2);
	zephir_check_call_status();
	RETURN_MM();

}