Beispiel #1
0
/**
 * Phalcon\Config\Adapter\Php constructor
 */
PHP_METHOD(Phalcon_Config_Adapter_Php, __construct) {

	int ZEPHIR_LAST_CALL_STATUS;
	zephir_fcall_cache_entry *_0 = NULL;
	zval *filePath_param = NULL, *_1 = NULL;
	zval *filePath = NULL;

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

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


	ZEPHIR_OBSERVE_OR_NULLIFY_PPZV(&_1);
	if (zephir_require_zval_ret(&_1, filePath TSRMLS_CC) == FAILURE) {
		RETURN_MM_NULL();
	}
	ZEPHIR_CALL_PARENT(NULL, phalcon_config_adapter_php_ce, this_ptr, "__construct", &_0, 19, _1);
	zephir_check_call_status();
	ZEPHIR_MM_RESTORE();

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

}
Beispiel #3
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);

}