+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
+
+#include <php_ini.h>
+#include <ext/standard/php_string.h>
+#include <ext/standard/info.h>
#include <zlib.h>
+
#if PHP_HTTP_HAVE_CURL
# include <curl/curl.h>
# if PHP_HTTP_HAVE_EVENT
# endif
#endif
#if PHP_HTTP_HAVE_NEON
-# include "neon/ne_utils.h"
+# include <neon/ne_utils.h>
#endif
#if PHP_HTTP_HAVE_SERF
-# include "serf.h"
+# include <serf.h>
#endif
-#include <main/php_ini.h>
-#include <ext/standard/info.h>
-#include <Zend/zend_extensions.h>
-
ZEND_DECLARE_MODULE_GLOBALS(php_http);
#ifdef COMPILE_DL_HTTP
static zend_module_dep http_module_deps[] = {
ZEND_MOD_REQUIRED("spl")
-#if PHP_HTTP_HAVE_HASH
+#ifdef PHP_HTTP_HAVE_HASH
ZEND_MOD_REQUIRED("hash")
#endif
-#if PHP_HTTP_HAVE_ICONV
+#ifdef PHP_HTTP_HAVE_ICONV
ZEND_MOD_REQUIRED("iconv")
#endif
-#if PHP_HTTP_HAVE_EVENT
+#ifdef PHP_HTTP_HAVE_EVENT
ZEND_MOD_CONFLICTS("event")
#endif
{NULL, NULL, NULL, 0}
#define PHP_HTTP_EXT_VERSION "2.0.0dev"
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#else
-# ifndef PHP_WIN32
-# include "php_config.h"
-# endif
-#endif
-
-#include "php.h"
-#if defined(PHP_WIN32)
-# if defined(PHP_HTTP_EXPORTS)
-# define PHP_HTTP_API __declspec(dllexport)
-# elif defined(COMPILE_DL_HTTP)
-# define PHP_HTTP_API __declspec(dllimport)
-# else
-# define PHP_HTTP_API
-# endif
-#else
-# define PHP_HTTP_API
-#endif
-
-/* make functions that return SUCCESS|FAILURE more obvious */
-typedef int STATUS;
-
-#include "php_http_buffer.h"
-#include "php_http_strlist.h"
-
-#if (defined(HAVE_ICONV) || defined(PHP_HTTP_HAVE_EXT_ICONV)) && (PHP_HTTP_SHARED_DEPS || !defined(COMPILE_DL_ICONV))
-# define PHP_HTTP_HAVE_ICONV
-#endif
-
-#if (defined(HAVE_HASH_EXT) || defined(PHP_HTTP_HAVE_EXT_HASH)) && (PHP_HTTP_SHARED_DEPS || !defined(COMPILE_DL_HASH)) && defined(PHP_HTTP_HAVE_PHP_HASH_H)
-# define PHP_HTTP_HAVE_HASH
-#endif
-
-#ifdef PHP_WIN32
-# define CURL_STATICLIB
-# define PHP_HTTP_HAVE_NETDB
-# include <winsock2.h>
-#elif defined(HAVE_NETDB_H)
-# define PHP_HTTP_HAVE_NETDB
-# include <netdb.h>
-# ifdef HAVE_UNISTD_H
-# include <unistd.h>
-# endif
-#endif
-
-#include <ctype.h>
-#define PHP_HTTP_IS_CTYPE(type, c) is##type((int) (unsigned char) (c))
-#define PHP_HTTP_TO_CTYPE(type, c) to##type((int) (unsigned char) (c))
-
extern zend_module_entry http_module_entry;
#define phpext_http_ptr &http_module_entry
# define _dpf(t,s,l);
#endif
-#include "php_http_misc.h"
-
-#include "php_http_cookie.h"
-#include "php_http_encoding.h"
-#include "php_http_env.h"
-#include "php_http_env_response.h"
-#include "php_http_etag.h"
-#include "php_http_exception.h"
-#include "php_http_filter.h"
-#include "php_http_headers.h"
-#include "php_http_info.h"
-#include "php_http_header_parser.h"
-#include "php_http_message_body.h"
-#include "php_http_message.h"
-#include "php_http_message_parser.h"
-#include "php_http_negotiate.h"
-#include "php_http_object.h"
-#include "php_http_params.h"
-#include "php_http_resource_factory.h"
-#include "php_http_persistent_handle.h"
-#include "php_http_property_proxy.h"
-#include "php_http_querystring.h"
-#include "php_http_request_datashare.h"
-#include "php_http_request_factory.h"
-#include "php_http_request.h"
-#include "php_http_curl.h"
-#include "php_http_neon.h"
-#include "php_http_serf.h"
-#include "php_http_request_method.h"
-#include "php_http_request_pool.h"
-#include "php_http_url.h"
-#include "php_http_version.h"
-
-ZEND_BEGIN_MODULE_GLOBALS(php_http)
- struct php_http_env_globals env;
- struct php_http_persistent_handle_globals persistent_handle;
- struct php_http_request_datashare_globals request_datashare;
-#if PHP_HTTP_HAVE_CURL && PHP_HTTP_HAVE_EVENT
- struct php_http_curl_globals curl;
-#endif
-ZEND_END_MODULE_GLOBALS(php_http)
-
-ZEND_EXTERN_MODULE_GLOBALS(php_http);
-
-#ifdef ZTS
-# include "TSRM/TSRM.h"
-# define PHP_HTTP_G ((zend_php_http_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(php_http_globals_id)])
-# undef TSRMLS_FETCH_FROM_CTX
-# define TSRMLS_FETCH_FROM_CTX(ctx) void ***tsrm_ls = ((ctx)?(ctx):ts_resource_ex(0, NULL))
-#else
-# define PHP_HTTP_G (&php_http_globals)
-#endif
-
-
#endif /* PHP_EXT_HTTP_H */
/*
--- /dev/null
+/*
+ +--------------------------------------------------------------------+
+ | PECL :: http |
+ +--------------------------------------------------------------------+
+ | Redistribution and use in source and binary forms, with or without |
+ | modification, are permitted provided that the conditions mentioned |
+ | in the accompanying LICENSE file are met. |
+ +--------------------------------------------------------------------+
+ | Copyright (c) 2004-2011, Michael Wallner <mike@php.net> |
+ +--------------------------------------------------------------------+
+*/
+
+#ifndef PHP_HTTP_API_H
+#define PHP_HTTP_API_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <php.h>
+#include <php_config.h>
+#include <SAPI.h>
+#include <zend_interfaces.h>
+
+#if defined(PHP_WIN32)
+# if defined(PHP_HTTP_EXPORTS)
+# define PHP_HTTP_API __declspec(dllexport)
+# elif defined(COMPILE_DL_HTTP)
+# define PHP_HTTP_API __declspec(dllimport)
+# else
+# define PHP_HTTP_API
+# endif
+#else
+# define PHP_HTTP_API
+#endif
+
+/* make functions that return SUCCESS|FAILURE more obvious */
+typedef int STATUS;
+
+#if (defined(HAVE_ICONV) || defined(PHP_HTTP_HAVE_EXT_ICONV)) && (PHP_HTTP_SHARED_DEPS || !defined(COMPILE_DL_ICONV))
+# define PHP_HTTP_HAVE_ICONV
+#endif
+
+#if (defined(HAVE_HASH_EXT) || defined(PHP_HTTP_HAVE_EXT_HASH)) && (PHP_HTTP_SHARED_DEPS || !defined(COMPILE_DL_HASH)) && defined(PHP_HTTP_HAVE_PHP_HASH_H)
+# define PHP_HTTP_HAVE_HASH
+#endif
+
+#ifdef PHP_WIN32
+# define CURL_STATICLIB
+# define PHP_HTTP_HAVE_NETDB
+# include <winsock2.h>
+#elif defined(HAVE_NETDB_H)
+# define PHP_HTTP_HAVE_NETDB
+# include <netdb.h>
+# ifdef HAVE_UNISTD_H
+# include <unistd.h>
+# endif
+#endif
+
+#include <ctype.h>
+#define PHP_HTTP_IS_CTYPE(type, c) is##type((int) (unsigned char) (c))
+#define PHP_HTTP_TO_CTYPE(type, c) to##type((int) (unsigned char) (c))
+
+#include "php_http_buffer.h"
+#include "php_http_strlist.h"
+#include "php_http_misc.h"
+#include "php_http_resource_factory.h"
+
+#include "php_http.h"
+#include "php_http_cookie.h"
+#include "php_http_curl.h"
+#include "php_http_encoding.h"
+#include "php_http_env.h"
+#include "php_http_env_response.h"
+#include "php_http_etag.h"
+#include "php_http_exception.h"
+#include "php_http_filter.h"
+#include "php_http_header_parser.h"
+#include "php_http_headers.h"
+#include "php_http_info.h"
+#include "php_http_message.h"
+#include "php_http_message_body.h"
+#include "php_http_message_parser.h"
+#include "php_http_negotiate.h"
+#include "php_http_neon.h"
+#include "php_http_object.h"
+#include "php_http_params.h"
+#include "php_http_persistent_handle.h"
+#include "php_http_property_proxy.h"
+#include "php_http_querystring.h"
+#include "php_http_request.h"
+#include "php_http_request_datashare.h"
+#include "php_http_request_factory.h"
+#include "php_http_request_method.h"
+#include "php_http_request_pool.h"
+#include "php_http_serf.h"
+#include "php_http_url.h"
+#include "php_http_version.h"
+
+ZEND_BEGIN_MODULE_GLOBALS(php_http)
+ struct php_http_env_globals env;
+ struct php_http_persistent_handle_globals persistent_handle;
+ struct php_http_request_datashare_globals request_datashare;
+#if PHP_HTTP_HAVE_CURL && PHP_HTTP_HAVE_EVENT
+ struct php_http_curl_globals curl;
+#endif
+ZEND_END_MODULE_GLOBALS(php_http)
+
+ZEND_EXTERN_MODULE_GLOBALS(php_http);
+
+#ifdef ZTS
+# include "TSRM/TSRM.h"
+# define PHP_HTTP_G ((zend_php_http_globals *) (*((void ***) tsrm_ls))[TSRM_UNSHUFFLE_RSRC_ID(php_http_globals_id)])
+# undef TSRMLS_FETCH_FROM_CTX
+# define TSRMLS_FETCH_FROM_CTX(ctx) void ***tsrm_ls = ((ctx)?(ctx):ts_resource_ex(0, NULL))
+#else
+# define PHP_HTTP_G (&php_http_globals)
+#endif
+
+#endif /* PHP_HTTP_API_H */
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: noet sw=4 ts=4 fdm=marker
+ * vim<600: noet sw=4 ts=4
+ */
+--------------------------------------------------------------------+
*/
-#include "php.h"
+#include <php.h>
#include "php_http_buffer.h"
PHP_HTTP_BUFFER_API php_http_buffer_t *php_http_buffer_init_ex(php_http_buffer_t *buf, size_t chunk_size, int flags)
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
#include <ext/date/php_date.h>
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
#if PHP_HTTP_HAVE_CURL
-#include "php_http_request.h"
-#include "php_http_request_pool.h"
-
#include <curl/curl.h>
#define PHP_HTTP_CURL_VERSION(x, y, z) (LIBCURL_VERSION_NUM >= (((x)<<16) + ((y)<<8) + (z)))
#endif
#include <ext/spl/spl_iterators.h>
-#include <Zend/zend_interfaces.h>
typedef struct php_http_curl_request {
#if PHP_HTTP_HAVE_CURL
+#include "php_http_request.h"
+#include "php_http_request_pool.h"
+#include "php_http_request_datashare.h"
+
PHP_HTTP_API php_http_request_ops_t *php_http_curl_get_request_ops(void);
PHP_HTTP_API php_http_request_pool_ops_t *php_http_curl_get_request_pool_ops(void);
PHP_HTTP_API php_http_request_datashare_ops_t *php_http_curl_get_request_datashare_ops(void);
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
#include <zlib.h>
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
-
-#include <main/SAPI.h>
+#include "php_http_api.h"
PHP_RINIT_FUNCTION(http_env)
{
#define PHP_HTTP_ENV_H
#include "php_http_message_body.h"
-#include "php_http_encoding.h"
#include "php_http_version.h"
struct php_http_env_globals {
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
-#include <main/SAPI.h>
#include <ext/date/php_date.h>
#include <ext/standard/php_string.h>
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
-#if PHP_HTTP_HAVE_HASH
+#ifdef PHP_HTTP_HAVE_HASH
# include "php_hash.h"
#endif
void *ctx;
php_http_etag_t *e;
-#if PHP_HTTP_HAVE_HASH
+#ifdef PHP_HTTP_HAVE_HASH
const php_hash_ops *eho = NULL;
if (mode && (eho = php_hash_fetch_ops(mode, strlen(mode)))) {
unsigned char digest[128] = {0};
char *etag = NULL;
-#if PHP_HTTP_HAVE_HASH
+#ifdef PHP_HTTP_HAVE_HASH
const php_hash_ops *eho = NULL;
if (e->mode && (eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) {
PHP_HTTP_API size_t php_http_etag_update(php_http_etag_t *e, const char *data_ptr, size_t data_len)
{
-#if PHP_HTTP_HAVE_HASH
+#ifdef PHP_HTTP_HAVE_HASH
const php_hash_ops *eho = NULL;
if (e->mode && (eho = php_hash_fetch_ops(e->mode, strlen(e->mode)))) {
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
-#include <Zend/zend_exceptions.h>
+#include <zend_exceptions.h>
#ifndef PHP_HTTP_DBG_EXCEPTIONS
# define PHP_HTTP_DBG_EXCEPTIONS 0
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
PHP_MINIT_FUNCTION(http_filter)
{
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
typedef struct php_http_header_parser_state_spec {
php_http_header_parser_state_t state;
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
-
-#include <Zend/zend_interfaces.h>
+#include "php_http_api.h"
PHP_HTTP_API STATUS php_http_headers_parse(const char *header, size_t length, HashTable *headers, php_http_info_callback_t callback_func, void **callback_data TSRMLS_DC)
{
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
PHP_HTTP_API void php_http_info_default_callback(void **nothing, HashTable **headers, php_http_info_t *info TSRMLS_DC)
{
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
-#include <main/SAPI.h>
+#include <SAPI.h>
#include <ext/spl/spl_iterators.h>
-#include <Zend/zend_interfaces.h>
+#include <zend_interfaces.h>
PHP_HTTP_API zend_bool php_http_message_info_callback(php_http_message_t **message, HashTable **headers, php_http_info_t *info TSRMLS_DC)
{
#ifndef PHP_HTTP_MESSAGE_H
#define PHP_HTTP_MESSAGE_H
+#include "php_http_message_body.h"
+
/* required minimum length of an HTTP message "HTTP/1.1" */
#define PHP_HTTP_MESSAGE_MIN_SIZE 8
#define PHP_HTTP_MESSAGE_TYPE(TYPE, msg) ((msg) && ((msg)->type == PHP_HTTP_ ##TYPE))
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
-#include <libgen.h>
#include <ext/standard/php_lcg.h>
#include <ext/standard/php_string.h>
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
typedef struct php_http_message_parser_state_spec {
php_http_message_parser_state_t state;
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
#include <ext/standard/php_lcg.h>
#include <ext/standard/php_string.h>
-#include <Zend/zend_exceptions.h>
+#include <zend_exceptions.h>
/* SLEEP */
#else
struct timeval timeout;
- timeout.tv.sec = (time_t) s;
+ timeout.tv_sec = (time_t) s;
timeout.tv_usec = PHP_HTTP_USEC(s) % PHP_HTTP_MCROSEC;
select(0, NULL, NULL, NULL, &timeout);
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
#include <ext/standard/php_string.h>
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
#if PHP_HTTP_HAVE_NEON
#if PHP_HTTP_HAVE_NEON
+#include "php_http_request.h"
+
php_http_request_ops_t *php_http_neon_get_request_ops(void);
PHP_MINIT_FUNCTION(http_neon);
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
STATUS php_http_new(zend_object_value *ov, zend_class_entry *ce, php_http_new_t create, zend_class_entry *parent_ce, void *intern_ptr, void **obj_ptr TSRMLS_DC)
{
default:
php_http_error(HE_WARNING, PHP_HTTP_E_RUNTIME, "unknown error handling code (%ld)", eh);
+ break;
}
}
default:
php_http_error(HE_WARNING, PHP_HTTP_E_RUNTIME, "unknown error handling code (%ld)", eh);
+ break;
}
}
}
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
#include <ext/standard/php_string.h>
-#include <Zend/zend_interfaces.h>
+#include <zend_interfaces.h>
static php_http_params_token_t def_param_sep = {",", 1}, *def_param_sep_ptr[] = {&def_param_sep, NULL};
static php_http_params_token_t def_arg_sep = {";", 1}, *def_arg_sep_ptr[] = {&def_arg_sep, NULL};
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
#ifndef PHP_HTTP_DEBUG_PHANDLES
# define PHP_HTTP_DEBUG_PHANDLES 0
#ifndef PHP_HTTP_PERSISTENT_HANDLE_H
#define PHP_HTTP_PERSISTENT_HANDLE_H
-#include "php_http_resource_factory.h"
-
typedef struct php_http_persistent_handle_factory {
void *provider;
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
php_http_property_proxy_t *php_http_property_proxy_init(php_http_property_proxy_t *proxy, zval *object, zval *member TSRMLS_DC)
{
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
-#include <main/php_variables.h>
+#include <php_variables.h>
#include <ext/spl/spl_array.h>
-#include <Zend/zend_interfaces.h>
+#include <zend_interfaces.h>
#ifdef PHP_HTTP_HAVE_ICONV
# undef PHP_ATOM_INC
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
#include <ext/spl/spl_observer.h>
#include <ext/spl/spl_iterators.h>
-#include <Zend/zend_interfaces.h>
PHP_HTTP_API php_http_request_t *php_http_request_init(php_http_request_t *h, php_http_request_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC)
{
static int apply_pretty_key(void *pDest TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
{
if (hash_key->arKey && hash_key->nKeyLength > 1) {
+ /* FIXME: this seems evil */
hash_key->h = zend_hash_func(php_http_pretty_key(hash_key->arKey, hash_key->nKeyLength - 1, 1, 0), hash_key->nKeyLength);
}
return ZEND_HASH_APPLY_KEEP;
#ifndef PHP_HTTP_REQUEST_H
#define PHP_HTTP_REQUEST_H
+#include "php_http_request_method.h"
#include "php_http_message_body.h"
#include "php_http_message_parser.h"
-#include "php_http_request_method.h"
typedef struct php_http_request_progress_state {
struct {
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
#include <curl/curl.h>
#include <ext/standard/php_string.h>
#ifndef PHP_HTTP_REQUEST_DATASHARE_H
#define PHP_HTTP_REQUEST_DATASHARE_H
-#include "php_http_request.h"
-
typedef enum php_http_request_datashare_setopt_opt {
PHP_HTTP_REQUEST_DATASHARE_OPT_COOKIES,
PHP_HTTP_REQUEST_DATASHARE_OPT_RESOLVER,
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
#include <ext/standard/php_string.h>
#include <ext/spl/spl_observer.h>
-#include <Zend/zend_interfaces.h>
/*
* array of name => php_http_request_factory_driver_t*
#include "php_http_request.h"
#include "php_http_request_pool.h"
+#include "php_http_request_datashare.h"
typedef struct php_http_request_factory_driver {
php_http_request_ops_t *request_ops;
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
PHP_HTTP_API void php_http_request_info(php_http_request_t *request, HashTable *info)
{
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
-
-#include <Zend/zend_interfaces.h>
+#include "php_http_api.h"
static PHP_HTTP_STRLIST(php_http_request_methods) =
PHP_HTTP_STRLIST_ITEM("UNKNOWN")
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
-#include <Zend/zend_interfaces.h>
#include <ext/spl/spl_iterators.h>
PHP_HTTP_API php_http_request_pool_t *php_http_request_pool_init(php_http_request_pool_t *h, php_http_request_pool_ops_t *ops, php_http_resource_factory_t *rf, void *init_arg TSRMLS_DC)
#ifndef PHP_HTTP_REQUESTPOOL_H
#define PHP_HTTP_REQUESTPOOL_H
-#include "php_http_request.h"
-
typedef enum php_http_request_pool_setopt_opt {
PHP_HTTP_REQUEST_POOL_OPT_ENABLE_PIPELINING,
PHP_HTTP_REQUEST_POOL_OPT_USE_EVENTS,
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
-#include "php_http_resource_factory.h"
+#include "php_http_api.h"
PHP_HTTP_API php_http_resource_factory_t *php_http_resource_factory_init(php_http_resource_factory_t *f, php_http_resource_factory_ops_t *fops, void *data, void (*dtor)(void *data))
{
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
PHP_HTTP_API php_http_strlist_iterator_t *php_http_strlist_iterator_init(php_http_strlist_iterator_t *iter, const char list[], unsigned factor)
{
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
-#include <main/SAPI.h>
+#include <SAPI.h>
#include <ext/standard/php_string.h>
static inline char *localhostname(void)
+--------------------------------------------------------------------+
*/
-#include "php_http.h"
+#include "php_http_api.h"
PHP_HTTP_API php_http_version_t *php_http_version_init(php_http_version_t *v, unsigned major, unsigned minor TSRMLS_DC)
{
die(sprintf("Usage: %s <ext>\n", $argv[0]));
$ext = new ReflectionExtension($ext);
+foreach ($ext->getConstants() as $constant => $value) {
+ printf("const %s = %s;\n", $constant, $value);
+}
+printf("\n");
+
+foreach ($ext->getFunctions() as $f) {
+ printf("function %s(", $f->getName());
+ $ps = array();
+ foreach ($f->getParameters() as $p) {
+ $p1 = sprintf("%s%s\$%s", t($p), $p->isPassedByReference()?"&":"", $p->getName());
+ if ($p->isOptional()) {
+ if ($p->isDefaultValueAvailable()) {
+ $p1 .= sprintf(" = %s", var_export($p->getDefaultValue(), true));
+ } elseif (!($p->isArray() || $p->getClass()) || $p->allowsNull()) {
+ $p1 .= " = NULL";
+ } elseif ($p->isArray()) {
+ $p1 .= " = array()";
+ }
+ }
+ $ps[] = $p1;
+ }
+ printf("%s) {\n}\n", implode(", ", $ps));
+}
+printf("\n");
+
foreach ($ext->getClasses() as $class) {
printf("%s%s %s ", m($class->getModifiers()), $class->isInterface() ? "interface":"class" ,$class->getName());
$ps = array();
foreach ($m->getParameters() as $p) {
$p1 = sprintf("%s%s\$%s", t($p), $p->isPassedByReference()?"&":"", $p->getName());
- if ($p->isDefaultValueAvailable()) {
- $p1 .= sprintf(" = %s", var_export($p->getDefaultValue(), true));
- } elseif ($p->allowsNull() || $p->isOptional()) {
- $p1 .= sprintf(" = NULL");
- }
+ if ($p->isOptional()) {
+ if ($p->isDefaultValueAvailable()) {
+ $p1 .= sprintf(" = %s", var_export($p->getDefaultValue(), true));
+ } elseif (!($p->isArray() || $p->getClass()) || $p->allowsNull()) {
+ $p1 .= sprintf(" = NULL");
+ } elseif ($p->isArray()) {
+ $p1 .= " = array()";
+ }
+ }
$ps[] = $p1;
}
printf("%s) {\n\t}\n", implode(", ", $ps));
chdir(__DIR__);
$time = microtime(true);
-$factory = new HttpRequestFactory("curl", array("requestPoolClass" => "Pool"));
+$factory = new HttpRequestFactory(array("driver" => "curl", "requestPoolClass" => "Pool"));
$factory->createPool()->run($factory);
printf("Elapsed: %0.3fs\n", microtime(true)-$time);