com php-src: Switch code on thrown TypeError and ParseError to 0, update related tests: Zend/tests/bug69640.phpt Zend/zend.c Zend/zend_exceptions.c
Zend/zend_language_scanner.c Zend/zend_language_scanner.l tests/classes/type_hi nting_004.phpt
| From: | Aaron Piotrowski | Date: | Tue, 07 Jul 2015 21:54:39 +0000 |
| Subject: | com php-src: Switch code on thrown TypeError and ParseError to 0, update related tests: Zend/tests/bug69640.phpt Zend/zend.c Zend/zend_exceptions.c Zend/zend_language_scanner.c Zend/zend_language_scanner.l tests/classes/type_hi nting_004.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87829@lists.php.net to get a copy of this message | ||
Commit: a1a83bf5f0f97dbf1a30622ec23365766d590591
Author: Aaron Piotrowski <aaron@trowski.com> Tue, 7 Jul 2015 16:54:39 -0500
Parents: dbadf447b2514c254ada0ed8b9f6c1ae34936186
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a1a83bf5f0f97dbf1a30622ec23365766d590591
Log:
Switch code on thrown TypeError and ParseError to 0, update related tests
Changed paths:
M Zend/tests/bug69640.phpt
M Zend/zend.c
M Zend/zend_exceptions.c
M Zend/zend_language_scanner.c
M Zend/zend_language_scanner.l
M tests/classes/type_hinting_004.phpt
Diff:
diff --git a/Zend/tests/bug69640.phpt b/Zend/tests/bug69640.phpt
index e7ff7c9..bdc7814 100644
--- a/Zend/tests/bug69640.phpt
+++ b/Zend/tests/bug69640.phpt
@@ -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
diff --git a/Zend/zend.c b/Zend/zend.c
index e200c05..200c6a9 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -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);
}
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index 1c35281..5d6cc59 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -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);
diff --git a/Zend/zend_language_scanner.c b/Zend/zend_language_scanner.c
index 6bfe1dd..0f67e6e 100644
--- a/Zend/zend_language_scanner.c
+++ b/Zend/zend_language_scanner.c
@@ -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);
}
}
diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l
index a20f7d5..0b4a6e1 100644
--- a/Zend/zend_language_scanner.l
+++ b/Zend/zend_language_scanner.l
@@ -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);
}
}
diff --git a/tests/classes/type_hinting_004.phpt b/tests/classes/type_hinting_004.phpt
index c5f8d39..8883f26 100644
--- a/tests/classes/type_hinting_004.phpt
+++ b/tests/classes/type_hinting_004.phpt
@@ -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);