helly Mon Nov 1 12:40:01 2004 EDT
Modified files:
/php-src/ext/spl php_spl.c spl.php spl_exceptions.c
spl_exceptions.h spl_iterators.c
Log:
- Two new exceptions
- Make use of new exception classes
http://cvs.php.net/diff.php/php-src/ext/spl/php_spl.c?r1=1.36&r2=1.37&ty=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.36 php-src/ext/spl/php_spl.c:1.37
--- php-src/ext/spl/php_spl.c:1.36 Mon Nov 1 10:50:25 2004
+++ php-src/ext/spl/php_spl.c Mon Nov 1 12:39:59 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_spl.c,v 1.36 2004/11/01 15:50:25 helly Exp $ */
+/* $Id: php_spl.c,v 1.37 2004/11/01 17:39:59 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -166,6 +166,7 @@
SPL_ADD_CLASS(AppendIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(ArrayObject, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(ArrayIterator, z_list, sub, allow, ce_flags); \
+ SPL_ADD_CLASS(BadFunctionCallException, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(CachingIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(CachingRecursiveIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(Countable, z_list, sub, allow, ce_flags); \
http://cvs.php.net/diff.php/php-src/ext/spl/spl.php?r1=1.36&r2=1.37&ty=u
Index: php-src/ext/spl/spl.php
diff -u php-src/ext/spl/spl.php:1.36 php-src/ext/spl/spl.php:1.37
--- php-src/ext/spl/spl.php:1.36 Mon Nov 1 12:05:45 2004
+++ php-src/ext/spl/spl.php Mon Nov 1 12:39:59 2004
@@ -146,6 +146,20 @@
}
/** @ingroup SPL
+ * @brief Exception thrown when a function call was illegal.
+ */
+class BadFunctionCallException extends LogicException
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception thrown when a method call was illegal.
+ */
+class BadMethodCallException extends BadFunctionCallException
+{
+}
+
+/** @ingroup SPL
* @brief Exception that denotes a value not in the valid domain was used.
*
* This kind of exception should be used to inform about domain erors in
http://cvs.php.net/diff.php/php-src/ext/spl/spl_exceptions.c?r1=1.2&r2=1.3&ty=u
Index: php-src/ext/spl/spl_exceptions.c
diff -u php-src/ext/spl/spl_exceptions.c:1.2 php-src/ext/spl/spl_exceptions.c:1.3
--- php-src/ext/spl/spl_exceptions.c:1.2 Mon Nov 1 12:26:15 2004
+++ php-src/ext/spl/spl_exceptions.c Mon Nov 1 12:39:59 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_exceptions.c,v 1.2 2004/11/01 17:26:15 helly Exp $ */
+/* $Id: spl_exceptions.c,v 1.3 2004/11/01 17:39:59 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -34,6 +34,8 @@
#include "spl_exceptions.h"
zend_class_entry *spl_ce_LogicException;
+zend_class_entry *spl_ce_BadFunctionCallException;
+zend_class_entry *spl_ce_BadMethodCallException;
zend_class_entry *spl_ce_DomainException;
zend_class_entry *spl_ce_InvalidArgumentException;
zend_class_entry *spl_ce_LengthException;
@@ -50,6 +52,8 @@
PHP_MINIT_FUNCTION(spl_exceptions)
{
REGISTER_SPL_SUB_CLASS_EX(LogicException, Exception, NULL, NULL);
+ REGISTER_SPL_SUB_CLASS_EX(BadFunctionCallException, LogicException, NULL, NULL);
+ REGISTER_SPL_SUB_CLASS_EX(BadMethodCallException, BadFunctionCallException,
NULL, NULL);
REGISTER_SPL_SUB_CLASS_EX(DomainException, LogicException, NULL, NULL);
REGISTER_SPL_SUB_CLASS_EX(InvalidArgumentException, LogicException, NULL, NULL);
REGISTER_SPL_SUB_CLASS_EX(LengthException, LogicException, NULL, NULL);
http://cvs.php.net/diff.php/php-src/ext/spl/spl_exceptions.h?r1=1.1&r2=1.2&ty=u
Index: php-src/ext/spl/spl_exceptions.h
diff -u php-src/ext/spl/spl_exceptions.h:1.1 php-src/ext/spl/spl_exceptions.h:1.2
--- php-src/ext/spl/spl_exceptions.h:1.1 Mon Nov 1 10:50:25 2004
+++ php-src/ext/spl/spl_exceptions.h Mon Nov 1 12:39:59 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_exceptions.h,v 1.1 2004/11/01 15:50:25 helly Exp $ */
+/* $Id: spl_exceptions.h,v 1.2 2004/11/01 17:39:59 helly Exp $ */
#ifndef SPL_EXCEPTIONS_H
#define SPL_EXCEPTIONS_H
@@ -25,6 +25,8 @@
#include "php_spl.h"
extern zend_class_entry *spl_ce_LogicException;
+extern zend_class_entry *spl_ce_BadFunctionCallException;
+extern zend_class_entry *spl_ce_BadMethodCallException;
extern zend_class_entry *spl_ce_DomainException;
extern zend_class_entry *spl_ce_InvalidArgumentException;
extern zend_class_entry *spl_ce_LengthException;
http://cvs.php.net/diff.php/php-src/ext/spl/spl_iterators.c?r1=1.49&r2=1.50&ty=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.49 php-src/ext/spl/spl_iterators.c:1.50
--- php-src/ext/spl/spl_iterators.c:1.49 Sun Oct 31 19:26:57 2004
+++ php-src/ext/spl/spl_iterators.c Mon Nov 1 12:39:59 2004
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_iterators.c,v 1.49 2004/11/01 00:26:57 helly Exp $ */
+/* $Id: spl_iterators.c,v 1.50 2004/11/01 17:39:59 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -34,6 +34,7 @@
#include "spl_iterators.h"
#include "spl_directory.h"
#include "spl_array.h"
+#include "spl_exceptions.h"
#define INLINE inline
@@ -244,7 +245,7 @@
if (child) {
zval_ptr_dtor(&child);
}
-
zend_throw_exception(zend_exception_get_default(), "Objects returned by
RecursiveIterator::getChildren() must implement RecursiveIterator", 0 TSRMLS_CC);
+
zend_throw_exception(spl_ce_InvalidArgumentException, "Objects returned by
RecursiveIterator::getChildren() must implement RecursiveIterator", 0 TSRMLS_CC);
return;
}
if (object->mode == RIT_CHILD_FIRST) {
@@ -612,12 +613,12 @@
}
if (intern->u.limit.offset < 0) {
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
- zend_throw_exception(zend_exception_get_default(),
"Parameter offset must be > 0", 0 TSRMLS_CC);
+ zend_throw_exception(spl_ce_OutOfRangeException,
"Parameter offset must be > 0", 0 TSRMLS_CC);
return NULL;
}
if (intern->u.limit.count < 0 && intern->u.limit.count != -1) {
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
- zend_throw_exception(zend_exception_get_default(),
"Parameter count must either be -1 or a value greater than or equal 0", 0 TSRMLS_CC);
+ zend_throw_exception(spl_ce_OutOfRangeException,
"Parameter count must either be -1 or a value greater than or equal 0", 0 TSRMLS_CC);
return NULL;
}
break;
@@ -1041,11 +1042,11 @@
spl_dual_it_free(intern TSRMLS_CC);
if (pos < intern->u.limit.offset) {
- zend_throw_exception_ex(zend_exception_get_default(), 0 TSRMLS_CC,
"Cannot seek to %ld which is below the offset %ld", pos, intern->u.limit.offset);
+ zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0 TSRMLS_CC,
"Cannot seek to %ld which is below the offset %ld", pos, intern->u.limit.offset);
return;
}
if (pos > intern->u.limit.offset + intern->u.limit.count &&
intern->u.limit.count != -1) {
- zend_throw_exception_ex(zend_exception_get_default(), 0 TSRMLS_CC,
"Cannot seek to %ld which is behind offest %ld plus count %ld", pos,
intern->u.limit.offset, intern->u.limit.count);
+ zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0 TSRMLS_CC,
"Cannot seek to %ld which is behind offest %ld plus count %ld", pos,
intern->u.limit.offset, intern->u.limit.count);
return;
}
if (instanceof_function(intern->inner.ce, spl_ce_SeekableIterator TSRMLS_CC)) {
@@ -1325,7 +1326,7 @@
intern = (spl_dual_it_object*)zend_object_store_get_object(getThis()
TSRMLS_CC);
if (!(intern->u.caching.flags & CIT_CALL_TOSTRING)) {
- zend_throw_exception_ex(zend_exception_get_default(), 0 TSRMLS_CC, "%s
does not fetch string value (see CachingIterator::__construct)",
Z_OBJCE_P(getThis())->name);
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC,
"%s does not fetch string value (see CachingIterator::__construct)",
Z_OBJCE_P(getThis())->name);
}
if (intern->u.caching.zstr) {
RETURN_STRINGL(Z_STRVAL_P(intern->u.caching.zstr),
Z_STRLEN_P(intern->u.caching.zstr), 1);
@@ -1554,14 +1555,14 @@
Throws exception */
SPL_METHOD(EmptyIterator, key)
{
- zend_throw_exception(NULL, "Accessing the key of an EmptyIterator", 0
TSRMLS_CC);
+ zend_throw_exception(spl_ce_BadMethodCallException, "Accessing the key of an
EmptyIterator", 0 TSRMLS_CC);
} /* }}} */
/* {{{ proto EmptyIterator::current()
Throws exception */
SPL_METHOD(EmptyIterator, current)
{
- zend_throw_exception(NULL, "Accessing the value of an EmptyIterator", 0
TSRMLS_CC);
+ zend_throw_exception(spl_ce_BadMethodCallException, "Accessing the value of an
EmptyIterator", 0 TSRMLS_CC);
} /* }}} */
/* {{{ proto EmptyIterator::next()
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php