]> granicus.if.org Git - php/commitdiff
- Fix code && new test
authorFelipe Pena <felipe@php.net>
Mon, 11 May 2009 14:59:37 +0000 (14:59 +0000)
committerFelipe Pena <felipe@php.net>
Mon, 11 May 2009 14:59:37 +0000 (14:59 +0000)
Zend/tests/exception_010.phpt [new file with mode: 0644]
Zend/zend_exceptions.c

diff --git a/Zend/tests/exception_010.phpt b/Zend/tests/exception_010.phpt
new file mode 100644 (file)
index 0000000..6bff8c6
--- /dev/null
@@ -0,0 +1,30 @@
+--TEST--
+Testing Exception's methods
+--FILE--
+<?php
+
+$x = new Exception;
+$x->gettraceasstring(1);
+$x->gettraceasstring();
+$x->__tostring(1);
+$x->gettrace(1);
+$x->getline(1);
+$x->getfile(1);
+$x->getmessage(1);
+$x->getcode(1);
+
+?>
+--EXPECTF--
+Warning: Exception::getTraceAsString() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: Exception::__toString() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: Exception::getTrace() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: Exception::getLine() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: Exception::getFile() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: Exception::getMessage() expects exactly 0 parameters, 1 given in %s on line %d
+
+Warning: Exception::getCode() expects exactly 0 parameters, 1 given in %s on line %d
index 5c1af3fcad86a29b2749d9675cf1c9735f3782da..519ab6ee3829fc54247e322ae4bb135f8df0ab36 100644 (file)
@@ -561,10 +561,13 @@ static int _build_trace_string(zval **frame TSRMLS_DC, int num_args, va_list arg
 ZEND_METHOD(exception, getTraceAsString)
 {
        zval *trace;
-       char *res = estrdup(""), **str = &res, *s_tmp;
+       char *res, **str, *s_tmp;
        int res_len = 0, *len = &res_len, num = 0;
        
        DEFAULT_0_PARAMS;
+       
+       res = estrdup("");
+       str = &res;
 
        trace = zend_read_property(default_exception_ce, getThis(), "trace", sizeof("trace")-1, 1 TSRMLS_CC);
        zend_hash_apply_with_arguments(Z_ARRVAL_P(trace) TSRMLS_CC, (apply_func_args_t)_build_trace_string, 3, str, len, &num);
@@ -608,12 +611,14 @@ int zend_spprintf(char **message, int max_len, char *format, ...) /* {{{ */
 ZEND_METHOD(exception, __toString)
 {
        zval message, file, line, *trace, *exception;
-       char *str = estrndup("", 0), *prev_str;
+       char *str, *prev_str;
        int len = 0;
        zend_fcall_info fci;
        zval fname;
        
        DEFAULT_0_PARAMS;
+       
+       str = estrndup("", 0);
 
        exception = getThis();
        ZVAL_ASCII_STRINGL(&fname, "gettraceasstring", sizeof("gettraceasstring")-1, 1);