]> granicus.if.org Git - php/commitdiff
Switch code on thrown TypeError and ParseError to 0, update related tests
authorAaron Piotrowski <aaron@trowski.com>
Tue, 7 Jul 2015 21:54:39 +0000 (16:54 -0500)
committerAaron Piotrowski <aaron@trowski.com>
Tue, 7 Jul 2015 21:54:39 +0000 (16:54 -0500)
Zend/tests/bug69640.phpt
Zend/zend.c
Zend/zend_exceptions.c
Zend/zend_language_scanner.c
Zend/zend_language_scanner.l
tests/classes/type_hinting_004.phpt

index e7ff7c99c144678589e3c94a73dd6ea86327e41e..bdc78147123b9fda08851c3d88b191a6db9f25f5 100644 (file)
@@ -5,4 +5,4 @@ Bug #69640 Unhandled Error thrown from userland do not produce any output
 throw new \ParseError('I mess everything up! :trollface:');
 ?>
 --EXPECTF--
-Fatal error: I mess everything up! :trollface: in %sbug69640.php on line 2
+Parse error: I mess everything up! :trollface: in %sbug69640.php on line 2
index e200c05b67270427612a7eb497997d5ff5831a24..200c6a9aa28345b5c4733e011e9717d38cb41afc 100644 (file)
@@ -882,7 +882,7 @@ void zenderror(const char *error) /* {{{ */
                return;
        }
 
-       zend_throw_exception(zend_ce_parse_error, error, E_PARSE);
+       zend_throw_exception(zend_ce_parse_error, error, 0);
 }
 /* }}} */
 
@@ -1325,7 +1325,7 @@ ZEND_API void zend_type_error(const char *format, ...) /* {{{ */
 
        va_start(va, format);
        zend_vspprintf(&message, 0, format, va);
-       zend_throw_exception(zend_ce_type_error, message, E_ERROR);
+       zend_throw_exception(zend_ce_type_error, message, 0);
        efree(message);
        va_end(va);
 } /* }}} */
@@ -1338,7 +1338,7 @@ ZEND_API void zend_internal_type_error(zend_bool throw_exception, const char *fo
        va_start(va, format);
        zend_vspprintf(&message, 0, format, va);
        if (throw_exception) {
-               zend_throw_exception(zend_ce_type_error, message, E_ERROR);
+               zend_throw_exception(zend_ce_type_error, message, 0);
        } else {
                zend_error(E_WARNING, message);
        }
index 1c35281177f46018e312362bfb2832421cb87db0..5d6cc592596d8cc32bd2f01833c29ec1d1720e38 100644 (file)
@@ -965,9 +965,8 @@ ZEND_API void zend_exception_error(zend_object *ex, int severity) /* {{{ */
                zend_string *message = zval_get_string(GET_PROPERTY(&exception, "message"));
                zend_string *file = zval_get_string(GET_PROPERTY_SILENT(&exception, "file"));
                zend_long line = zval_get_long(GET_PROPERTY_SILENT(&exception, "line"));
-               zend_long code = zval_get_long(GET_PROPERTY_SILENT(&exception, "code"));
 
-               zend_error_helper(code? code : E_ERROR, ZSTR_VAL(file), line, "%s", ZSTR_VAL(message));
+               zend_error_helper(E_PARSE, ZSTR_VAL(file), line, "%s", ZSTR_VAL(message));
 
                zend_string_release(file);
                zend_string_release(message);
index 6bfe1dd7b376e6635836604b70cd35237535e3a5..0f67e6e89f1afc8ae3b3d368959b3aef4bc0c16b 100644 (file)
@@ -1011,7 +1011,7 @@ static int zend_scan_escape_string(zval *zendlval, char *str, int len, char quot
 
                                                if (!valid) {
                                                        zend_throw_exception(zend_ce_parse_error,
-                                                               "Invalid UTF-8 codepoint escape sequence", E_PARSE);
+                                                               "Invalid UTF-8 codepoint escape sequence", 0);
                                                        zval_ptr_dtor(zendlval);
                                                        return FAILURE;
                                                }
@@ -1022,7 +1022,7 @@ static int zend_scan_escape_string(zval *zendlval, char *str, int len, char quot
                                                /* per RFC 3629, UTF-8 can only represent 21 bits */
                                                if (codepoint > 0x10FFFF || errno) {
                                                        zend_throw_exception(zend_ce_parse_error,
-                                                               "Invalid UTF-8 codepoint escape sequence: Codepoint too large", E_PARSE);
+                                                               "Invalid UTF-8 codepoint escape sequence: Codepoint too large", 0);
                                                        zval_ptr_dtor(zendlval);
                                                        return FAILURE;
                                                }
@@ -2743,7 +2743,7 @@ yy136:
                 * Because the lexing itself doesn't do that for us
                 */
                if (end != yytext + yyleng) {
-                       zend_throw_exception(zend_ce_parse_error, "Invalid numeric literal", E_PARSE);
+                       zend_throw_exception(zend_ce_parse_error, "Invalid numeric literal", 0);
                        RETURN_TOKEN(T_ERROR);
                }
        } else {
@@ -2760,7 +2760,7 @@ yy136:
                        /* Also not an assert for the same reason */
                        if (end != yytext + yyleng) {
                                zend_throw_exception(zend_ce_parse_error,
-                                       "Invalid numeric literal", E_PARSE);
+                                       "Invalid numeric literal", 0);
                                RETURN_TOKEN(T_ERROR);
                        }
                        ZEND_ASSERT(!errno);
@@ -2768,7 +2768,7 @@ yy136:
                }
                /* Also not an assert for the same reason */
                if (end != yytext + yyleng) {
-                       zend_throw_exception(zend_ce_parse_error, "Invalid numeric literal", E_PARSE);
+                       zend_throw_exception(zend_ce_parse_error, "Invalid numeric literal", 0);
                        RETURN_TOKEN(T_ERROR);
                }
        }
index a20f7d57f6fb1a37d044a2c627af062cb61647d9..0b4a6e1881b3478cdc22127920dca6a607b379ba 100644 (file)
@@ -1009,7 +1009,7 @@ static int zend_scan_escape_string(zval *zendlval, char *str, int len, char quot
 
                                                if (!valid) {
                                                        zend_throw_exception(zend_ce_parse_error,
-                                                               "Invalid UTF-8 codepoint escape sequence", E_PARSE);
+                                                               "Invalid UTF-8 codepoint escape sequence", 0);
                                                        zval_ptr_dtor(zendlval);
                                                        return FAILURE;
                                                }
@@ -1020,7 +1020,7 @@ static int zend_scan_escape_string(zval *zendlval, char *str, int len, char quot
                                                /* per RFC 3629, UTF-8 can only represent 21 bits */
                                                if (codepoint > 0x10FFFF || errno) {
                                                        zend_throw_exception(zend_ce_parse_error,
-                                                               "Invalid UTF-8 codepoint escape sequence: Codepoint too large", E_PARSE);
+                                                               "Invalid UTF-8 codepoint escape sequence: Codepoint too large", 0);
                                                        zval_ptr_dtor(zendlval);
                                                        return FAILURE;
                                                }
@@ -1658,7 +1658,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
                 * Because the lexing itself doesn't do that for us
                 */
                if (end != yytext + yyleng) {
-                       zend_throw_exception(zend_ce_parse_error, "Invalid numeric literal", E_PARSE);
+                       zend_throw_exception(zend_ce_parse_error, "Invalid numeric literal", 0);
                        RETURN_TOKEN(T_ERROR);
                }
        } else {
@@ -1675,7 +1675,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
                        /* Also not an assert for the same reason */
                        if (end != yytext + yyleng) {
                                zend_throw_exception(zend_ce_parse_error,
-                                       "Invalid numeric literal", E_PARSE);
+                                       "Invalid numeric literal", 0);
                                RETURN_TOKEN(T_ERROR);
                        }
                        ZEND_ASSERT(!errno);
@@ -1683,7 +1683,7 @@ NEWLINE ("\r"|"\n"|"\r\n")
                }
                /* Also not an assert for the same reason */
                if (end != yytext + yyleng) {
-                       zend_throw_exception(zend_ce_parse_error, "Invalid numeric literal", E_PARSE);
+                       zend_throw_exception(zend_ce_parse_error, "Invalid numeric literal", 0);
                        RETURN_TOKEN(T_ERROR);
                }
        }
index c5f8d3984b7c927ef1c2cf5c8c940f8d5088d7a9..8883f2633684093dfdcae1a879a9e5a5d9f85ca3 100644 (file)
@@ -149,10 +149,10 @@ Ensure type hints are enforced for functions invoked as callbacks.
 ?>
 --EXPECTF--
 ---> Type hints with callback function:
-1: Argument 1 passed to f1() must be an instance of A, integer given%s(%d)
+0: Argument 1 passed to f1() must be an instance of A, integer given%s(%d)
 
 in f1;
-1: Argument 1 passed to f2() must be an instance of A, integer given%s(%d)
+0: Argument 1 passed to f2() must be an instance of A, integer given%s(%d)
 
 in f2;
 in f2;
@@ -160,10 +160,10 @@ in f2;
 
 
 ---> Type hints with callback static method:
-1: Argument 1 passed to C::f1() must be an instance of A, integer given%s(%d)
+0: Argument 1 passed to C::f1() must be an instance of A, integer given%s(%d)
 
 in C::f1 (static);
-1: Argument 1 passed to C::f2() must be an instance of A, integer given%s(%d)
+0: Argument 1 passed to C::f2() must be an instance of A, integer given%s(%d)
 
 in C::f2 (static);
 in C::f2 (static);
@@ -171,10 +171,10 @@ in C::f2 (static);
 
 
 ---> Type hints with callback instance method:
-1: Argument 1 passed to D::f1() must be an instance of A, integer given%s(%d)
+0: Argument 1 passed to D::f1() must be an instance of A, integer given%s(%d)
 
 in C::f1 (instance);
-1: Argument 1 passed to D::f2() must be an instance of A, integer given%s(%d)
+0: Argument 1 passed to D::f2() must be an instance of A, integer given%s(%d)
 
 in C::f2 (instance);
 in C::f2 (instance);