#include "php_http_request_object.h"
#include "php_http_exception_object.h"
+#include "missing.h"
+
#include "zend_interfaces.h"
+#if defined(HAVE_SPL) && !defined(WONKY)
+/* SPL doesn't install its headers */
+extern PHPAPI zend_class_entry *spl_ce_Countable;
+#endif
#ifdef PHP_WIN32
# include <winsock2.h>
HTTP_EMPTY_ARGS(next, 0);
HTTP_EMPTY_ARGS(rewind, 0);
+HTTP_EMPTY_ARGS(count, 0);
+
HTTP_EMPTY_ARGS(getAttachedRequests, 0);
HTTP_EMPTY_ARGS(getFinishedRequests, 0);
HTTP_REQPOOL_ME(next, ZEND_ACC_PUBLIC)
HTTP_REQPOOL_ME(rewind, ZEND_ACC_PUBLIC)
+ /* implmenents Countable */
+ HTTP_REQPOOL_ME(count, ZEND_ACC_PUBLIC)
+
HTTP_REQPOOL_ME(getAttachedRequests, ZEND_ACC_PUBLIC)
HTTP_REQPOOL_ME(getFinishedRequests, ZEND_ACC_PUBLIC)
PHP_MINIT_FUNCTION(http_requestpool_object)
{
HTTP_REGISTER_CLASS_EX(HttpRequestPool, http_requestpool_object, NULL, 0);
+#if defined(HAVE_SPL) && !defined(WONKY)
+ zend_class_implements(http_requestpool_object_ce TSRMLS_CC, 2, spl_ce_Countable, zend_ce_iterator);
+#else
zend_class_implements(http_requestpool_object_ce TSRMLS_CC, 1, zend_ce_iterator);
+#endif
+
http_requestpool_object_handlers.clone_obj = NULL;
return SUCCESS;
}
}
/* }}} */
+/* {{{ proto int HttpRequestPool::count()
+ *
+ * Implements Countable.
+ *
+ * Returns the number of attached HttpRequest objects.
+ */
+PHP_METHOD(HttpRequestPool, count)
+{
+ NO_ARGS {
+ getObject(http_requestpool_object, obj);
+ RETURN_LONG((long) zend_llist_count(&obj->pool.handles));
+ }
+}
+/* }}} */
+
/* {{{ proto array HttpRequestPool::getAttachedRequests()
*
* Get attached HttpRequest objects.