#ifdef HAVE_CONFIG_H
#include "../../ext_config.h"
#endif
#include <php.h>
#include "../../php_ext.h"
#include "../../ext.h"
#include <Zend/zend_operators.h>
#include <Zend/zend_exceptions.h>
#include <Zend/zend_interfaces.h>
#include "kernel/main.h"
#include "kernel/fcall.h"
#include "kernel/memory.h"
#include "kernel/operators.h"
#include "kernel/object.h"
#include "kernel/string.h"
#include "kernel/array.h"
#include "kernel/main.h"
#include "kernel/exception.h"
#include "ext/spl/spl_exceptions.h"
#include "ext/spl/spl_directory.h"
#include "kernel/concat.h"
#include "kernel/file.h"
/**
* HTTP 请求
* This class borrows heavily from the Symfony4 Framework and is part of the symfony package
*
* @author Xiangmin Liu <635750556@qq.com>
*
* @since 2018.03.05
* @version 1.0
* @see Symfony\Component\HttpFoundation (https://github.com/symfony/symfony)
*/
ZEPHIR_INIT_CLASS(Leevel_Http_Request) {
ZEPHIR_REGISTER_CLASS(Leevel\\Http, Request, leevel, http_request, leevel_http_request_method_entry, 0);
/**
* GET Bag
*
* @var \Leevel\Http\Bag
*/
zend_declare_property_null(leevel_http_request_ce, SL("query"), ZEND_ACC_PUBLIC TSRMLS_CC);
/**
* POST Bag
*
* @var \Leevel\Http\Bag
*/
zend_declare_property_null(leevel_http_request_ce, SL("request"), ZEND_ACC_PUBLIC TSRMLS_CC);
/**
* 路由解析后的参数
*
* @var \Leevel\Http\Bag
*/
zend_declare_property_null(leevel_http_request_ce, SL("params"), ZEND_ACC_PUBLIC TSRMLS_CC);
/**
* COOKIE Bag
*
* @var \Leevel\Http\Bag
*/
zend_declare_property_null(leevel_http_request_ce, SL("cookies"), ZEND_ACC_PUBLIC TSRMLS_CC);
/**
* FILE Bag
*
* @var \Leevel\Http\FileBag
*/
zend_declare_property_null(leevel_http_request_ce, SL("files"), ZEND_ACC_PUBLIC TSRMLS_CC);
/**
* SERVER Bag
*
* @var \Leevel\Http\ServerBag
*/
zend_declare_property_null(leevel_http_request_ce, SL("server"), ZEND_ACC_PUBLIC TSRMLS_CC);
/**
* HEADER Bag
*
* @var \Leevel\Http\HeaderBag
*/
zend_declare_property_null(leevel_http_request_ce, SL("headers"), ZEND_ACC_PUBLIC TSRMLS_CC);
/**
* 内容
*
* @var string|resource|false|null
*/
zend_declare_property_null(leevel_http_request_ce, SL("content"), ZEND_ACC_PROTECTED TSRMLS_CC);
/**
* 基础 url
*
* @var string
*/
zend_declare_property_null(leevel_http_request_ce, SL("baseUrl"), ZEND_ACC_PROTECTED TSRMLS_CC);
/**
* 基础路径
*
* @var string
*/
zend_declare_property_null(leevel_http_request_ce, SL("basePath"), ZEND_ACC_PROTECTED TSRMLS_CC);
/**
* 请求 url
*
* @var string
*/
zend_declare_property_null(leevel_http_request_ce, SL("requestUri"), ZEND_ACC_PROTECTED TSRMLS_CC);
/**
* 请求类型
*
* @var string
*/
zend_declare_property_null(leevel_http_request_ce, SL("method"), ZEND_ACC_PROTECTED TSRMLS_CC);
/**
* pathInfo
*
* @var string
*/
zend_declare_property_null(leevel_http_request_ce, SL("pathInfo"), ZEND_ACC_PROTECTED TSRMLS_CC);
/**
* 应用名字
*
* @var string
*/
zend_declare_property_null(leevel_http_request_ce, SL("app"), ZEND_ACC_PROTECTED TSRMLS_CC);
/**
* 控制器名字
*
* @var string
*/
zend_declare_property_null(leevel_http_request_ce, SL("controller"), ZEND_ACC_PROTECTED TSRMLS_CC);
/**
* 方法名字
*
* @var string
*/
zend_declare_property_null(leevel_http_request_ce, SL("action"), ZEND_ACC_PROTECTED TSRMLS_CC);
/**
* 当前语言
*
* @var string
*/
zend_declare_property_null(leevel_http_request_ce, SL("language"), ZEND_ACC_PROTECTED TSRMLS_CC);
/**
* 注册的动态扩展
*
* @var array
*/
zend_declare_property_null(leevel_http_request_ce, SL("macro"), ZEND_ACC_PROTECTED|ZEND_ACC_STATIC TSRMLS_CC);
zend_class_implements(leevel_http_request_ce TSRMLS_CC, 1, leevel_support_imacro_ce);
zend_class_implements(leevel_http_request_ce TSRMLS_CC, 1, leevel_http_irequest_ce);
zend_class_implements(leevel_http_request_ce TSRMLS_CC, 1, leevel_support_iarray_ce);
zend_class_implements(leevel_http_request_ce TSRMLS_CC, 1, zend_ce_arrayaccess);
return SUCCESS;
}
/**
* 构造函数
*
* @param array $query
* @param array $request
* @param array $params
* @param array $cookies
* @param array $files
* @param array $server
* @param string $content
* @return void
*/
PHP_METHOD(Leevel_Http_Request, __construct) {
zend_long ZEPHIR_LAST_CALL_STATUS;
zval *query_param = NULL, *request_param = NULL, *params_param = NULL, *cookies_param = NULL, *files_param = NULL, *server_param = NULL, *content = NULL, content_sub, __$null;
zval query, request, params, cookies, files, server;
zval *this_ptr = getThis();
ZVAL_UNDEF(&query);
ZVAL_UNDEF(&request);
ZVAL_UNDEF(¶ms);
ZVAL_UNDEF(&cookies);
ZVAL_UNDEF(&files);
ZVAL_UNDEF(&server);
ZVAL_UNDEF(&content_sub);
ZVAL_NULL(&__$null);
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 0, 7, &query_param, &request_param, ¶ms_param, &cookies_param, &files_param, &server_param, &content);
if (!query_param) {
ZEPHIR_INIT_VAR(&query);
array_init(&query);
} else {
zephir_get_arrval(&query, query_param);
}
if (!request_param) {
ZEPHIR_INIT_VAR(&request);
array_init(&request);
} else {
zephir_get_arrval(&request, request_param);
}
if (!params_param) {
ZEPHIR_INIT_VAR(¶ms);
array_init(¶ms);
} else {
zephir_get_arrval(¶ms, params_param);
}
if (!cookies_param) {
ZEPHIR_INIT_VAR(&cookies);
array_init(&cookies);
} else {
zephir_get_arrval(&cookies, cookies_param);
}
if (!files_param) {
ZEPHIR_INIT_VAR(&files);
array_init(&files);
} else {
zephir_get_arrval(&files, files_param);
}
if (!server_param) {
ZEPHIR_INIT_VAR(&server);
array_init(&server);
} else {
zephir_get_arrval(&server, server_param);
}
if (!content) {
content = &content_sub;
content = &__$null;
}
ZEPHIR_CALL_METHOD(NULL, this_ptr, "reset", NULL, 0, &query, &request, ¶ms, &cookies, &files, &server, content);
zephir_check_call_status();
ZEPHIR_MM_RESTORE();
}
/**
* 重置或者初始化
*
* @param array $query
* @param array $request
* @param array $params
* @param array $cookies
* @param array $files
* @param array $server
* @param string $content
* @return void
*/
PHP_METHOD(Leevel_Http_Request, reset) {
zephir_fcall_cache_entry *_1 = NULL;
zend_long ZEPHIR_LAST_CALL_STATUS;
zval *query_param = NULL, *request_param = NULL, *params_param = NULL, *cookies_param = NULL, *files_param = NULL, *server_param = NULL, *content = NULL, content_sub, __$null, _0, _2, _3, _4, _5, _6, _7, _8, _9;
zval query, request, params, cookies, files, server;
zval *this_ptr = getThis();
ZVAL_UNDEF(&query);
ZVAL_UNDEF(&request);
ZVAL_UNDEF(¶ms);
ZVAL_UNDEF(&cookies);
ZVAL_UNDEF(&files);
ZVAL_UNDEF(&server);
ZVAL_UNDEF(&content_sub);
ZVAL_NULL(&__$null);
ZVAL_UNDEF(&_0);
ZVAL_UNDEF(&_2);
ZVAL_UNDEF(&_3);
ZVAL_UNDEF(&_4);
ZVAL_UNDEF(&_5);
ZVAL_UNDEF(&_6);
ZVAL_UNDEF(&_7);
ZVAL_UNDEF(&_8);
ZVAL_UNDEF(&_9);
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 0, 7, &query_param, &request_param, ¶ms_param, &cookies_param, &files_param, &server_param, &content);
if (!query_param) {
ZEPHIR_INIT_VAR(&query);
array_init(&query);
} else {
zephir_get_arrval(&query, query_param);
}
if (!request_param) {
ZEPHIR_INIT_VAR(&request);
array_init(&request);
} else {
zephir_get_arrval(&request, request_param);
}
if (!params_param) {
ZEPHIR_INIT_VAR(¶ms);
array_init(¶ms);
} else {
zephir_get_arrval(¶ms, params_param);
}
if (!cookies_param) {
ZEPHIR_INIT_VAR(&cookies);
array_init(&cookies);
} else {
zephir_get_arrval(&cookies, cookies_param);
}
if (!files_param) {
ZEPHIR_INIT_VAR(&files);
array_init(&files);
} else {
zephir_get_arrval(&files, files_param);
}
if (!server_param) {
ZEPHIR_INIT_VAR(&server);
array_init(&server);
} else {
zephir_get_arrval(&server, server_param);
}
if (!content) {
content = &content_sub;
content = &__$null;
}
ZE