diff --git a/ext/spl/config.m4 b/ext/spl/config.m4
index a0f0d1a06d01..5edc8d83a456 100755
--- a/ext/spl/config.m4
+++ b/ext/spl/config.m4
@@ -22,6 +22,6 @@ int main(int argc, char **argv) {
CPPFLAGS=$old_CPPFLAGS
AC_DEFINE_UNQUOTED(HAVE_PACKED_OBJECT_VALUE, $ac_result, [Whether struct _zend_object_value is packed])
AC_DEFINE(HAVE_SPL, 1, [Whether you want SPL (Standard PHP Library) support])
- PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c, no)
- PHP_INSTALL_HEADERS([ext/spl], [php_spl.h spl_array.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h])
+ PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_validators.c spl_filters.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c, no)
+ PHP_INSTALL_HEADERS([ext/spl], [php_spl.h spl_array.h spl_validators.h spl_filters.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h])
PHP_ADD_EXTENSION_DEP(spl, pcre, true)
diff --git a/ext/spl/config.w32 b/ext/spl/config.w32
index 77cbd20346a2..6ad06c9c3cd6 100644
--- a/ext/spl/config.w32
+++ b/ext/spl/config.w32
@@ -1,7 +1,7 @@
// $Id$
// vim:ft=javascript
-EXTENSION("spl", "php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c", false /*never shared */);
+EXTENSION("spl", "php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_validators.c spl_filters.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c", false /*never shared */);
AC_DEFINE('HAVE_SPL', 1);
PHP_SPL="yes";
-PHP_INSTALL_HEADERS("ext/spl", "php_spl.h spl_array.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h");
+PHP_INSTALL_HEADERS("ext/spl", "php_spl.h spl_validators.h spl_filters.h spl_array.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h");
diff --git a/ext/spl/package.xml b/ext/spl/package.xml
index 372aaecd9fe2..4c6772003dc0 100755
--- a/ext/spl/package.xml
+++ b/ext/spl/package.xml
@@ -26,6 +26,8 @@ standard problems.
+
+
@@ -34,6 +36,8 @@ standard problems.
+
+
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index cd0086626fc7..9a4050dd519b 100755
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -37,6 +37,8 @@
#include "spl_dllist.h"
#include "spl_fixedarray.h"
#include "spl_heap.h"
+#include "spl_validators.h"
+#include "spl_filters.h"
#include "zend_exceptions.h"
#include "zend_interfaces.h"
#include "ext/standard/php_rand.h"
@@ -195,6 +197,7 @@ PHP_FUNCTION(class_uses)
SPL_ADD_CLASS(DomainException, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(EmptyIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(FilesystemIterator, z_list, sub, allow, ce_flags); \
+ SPL_ADD_CLASS(Filter, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(FilterIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(GlobIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(InfiniteIterator, z_list, sub, allow, ce_flags); \
@@ -239,6 +242,7 @@ PHP_FUNCTION(class_uses)
SPL_ADD_CLASS(SplTempFileObject, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(UnderflowException, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(UnexpectedValueException, z_list, sub, allow, ce_flags); \
+ SPL_ADD_CLASS(Validator, z_list, sub, allow, ce_flags); \
/* {{{ proto array spl_classes()
Return an array containing the names of all clsses and interfaces defined in SPL */
@@ -939,7 +943,9 @@ PHP_MINIT_FUNCTION(spl)
PHP_MINIT(spl_heap)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(spl_fixedarray)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(spl_observer)(INIT_FUNC_ARGS_PASSTHRU);
-
+ PHP_MINIT(spl_filters)(INIT_FUNC_ARGS_PASSTHRU);
+ PHP_MINIT(spl_validators)(INIT_FUNC_ARGS_PASSTHRU);
+
return SUCCESS;
}
/* }}} */
diff --git a/ext/spl/spl_filters.c b/ext/spl/spl_filters.c
new file mode 100644
index 000000000000..d75e78d4c174
--- /dev/null
+++ b/ext/spl/spl_filters.c
@@ -0,0 +1,56 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2012 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Axel Etcheverry |
+ +----------------------------------------------------------------------+
+ */
+
+/* $Id$ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "zend_interfaces.h"
+
+#include "php_spl.h"
+#include "spl_functions.h"
+#include "spl_engine.h"
+#include "spl_filters.h"
+
+PHPAPI zend_class_entry *spl_ce_Filter;
+
+ZEND_BEGIN_ARG_INFO(arginfo_filter_filter, 0)
+ ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+
+static const zend_function_entry spl_funcs_Filter[] = {
+ SPL_ABSTRACT_ME(Filter, filter, arginfo_filter_filter)
+ PHP_FE_END
+};
+
+/* {{{ PHP_MINIT_FUNCTION(spl_filters)
+ */
+PHP_MINIT_FUNCTION(spl_filters)
+{
+
+ REGISTER_SPL_INTERFACE(Filter);
+
+ return SUCCESS;
+}
+/* }}} */
+
diff --git a/ext/spl/spl_filters.h b/ext/spl/spl_filters.h
new file mode 100644
index 000000000000..a2c5e3b22fba
--- /dev/null
+++ b/ext/spl/spl_filters.h
@@ -0,0 +1,43 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2012 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Axel Etcheverry |
+ +----------------------------------------------------------------------+
+ */
+
+/* $Id$ */
+
+#ifndef SPL_FILTER_H
+#define SPL_FILTER_H
+
+#include "php.h"
+#include "php_spl.h"
+#if HAVE_PCRE || HAVE_BUNDLED_PCRE
+#include "ext/pcre/php_pcre.h"
+#endif
+
+extern PHPAPI zend_class_entry *spl_ce_Filter;
+
+PHP_MINIT_FUNCTION(spl_filters);
+
+#endif /* SPL_FILTER_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim600: fdm=marker
+ * vim: noet sw=4 ts=4
+ */
diff --git a/ext/spl/spl_validators.c b/ext/spl/spl_validators.c
new file mode 100644
index 000000000000..1af580fef824
--- /dev/null
+++ b/ext/spl/spl_validators.c
@@ -0,0 +1,60 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2012 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Axel Etcheverry |
+ +----------------------------------------------------------------------+
+ */
+
+/* $Id$ */
+
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "zend_interfaces.h"
+
+#include "php_spl.h"
+#include "spl_functions.h"
+#include "spl_engine.h"
+#include "spl_validators.h"
+
+PHPAPI zend_class_entry *spl_ce_Validator;
+
+ZEND_BEGIN_ARG_INFO(arginfo_validator_void, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO(arginfo_validator_is_valid, 0)
+ ZEND_ARG_INFO(0, value)
+ZEND_END_ARG_INFO()
+
+static const zend_function_entry spl_funcs_Validator[] = {
+ SPL_ABSTRACT_ME(Validator, isValid, arginfo_validator_is_valid)
+ SPL_ABSTRACT_ME(Validator, getMessages, arginfo_validator_void)
+ PHP_FE_END
+};
+
+/* {{{ PHP_MINIT_FUNCTION(spl_validators)
+ */
+PHP_MINIT_FUNCTION(spl_validators)
+{
+
+ REGISTER_SPL_INTERFACE(Validator);
+
+ return SUCCESS;
+}
+/* }}} */
\ No newline at end of file
diff --git a/ext/spl/spl_validators.h b/ext/spl/spl_validators.h
new file mode 100644
index 000000000000..4b83339e6962
--- /dev/null
+++ b/ext/spl/spl_validators.h
@@ -0,0 +1,31 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2012 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Axel Etcheverry |
+ +----------------------------------------------------------------------+
+ */
+
+/* $Id$ */
+
+#ifndef SPL_VALIDATOR_H
+#define SPL_VALIDATOR_H
+
+#include "php.h"
+#include "php_spl.h"
+
+extern PHPAPI zend_class_entry *spl_ce_Validator;
+
+PHP_MINIT_FUNCTION(spl_validators);
+
+#endif /* SPL_VALIDATOR_H */
\ No newline at end of file
diff --git a/ext/spl/tests/filters_001.phpt b/ext/spl/tests/filters_001.phpt
new file mode 100644
index 000000000000..d7698236becb
--- /dev/null
+++ b/ext/spl/tests/filters_001.phpt
@@ -0,0 +1,20 @@
+--TEST--
+SPL: Filter
+--FILE--
+filter(' good '));
+?>
+--EXPECT--
+bool(true)
+string(4) "good"
\ No newline at end of file
diff --git a/ext/spl/tests/validator_001.phpt b/ext/spl/tests/validator_001.phpt
new file mode 100644
index 000000000000..0185da8908a2
--- /dev/null
+++ b/ext/spl/tests/validator_001.phpt
@@ -0,0 +1,40 @@
+--TEST--
+SPL: Validator
+--FILE--
+messages[] = sprintf("Error : '%s' is not equal to 'test'", $value);
+
+ return false;
+ }
+
+ public function getMessages()
+ {
+ return $this->messages;
+ }
+}
+
+$test = new Test();
+
+var_dump($test instanceof Validator) . PHP_EOL;
+var_dump($test->isValid('test')) . PHP_EOL;
+var_dump($test->isValid('test1')) . PHP_EOL;
+var_dump($test->getMessages()) . PHP_EOL;
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)
+array(1) {
+ [0]=>
+ string(38) "Error : 'test1' is not equal to 'test'"
+}