Browse Source

Switch code on thrown TypeError and ParseError to 0, update related tests

pull/1399/head
Aaron Piotrowski 11 years ago
parent
commit
a1a83bf5f0
  1. 2
      Zend/tests/bug69640.phpt
  2. 6
      Zend/zend.c
  3. 3
      Zend/zend_exceptions.c
  4. 10
      Zend/zend_language_scanner.c
  5. 10
      Zend/zend_language_scanner.l
  6. 12
      tests/classes/type_hinting_004.phpt

2
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

6
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);
}

3
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);

10
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);
}
}

10
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);
}
}

12
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);

Loading…
Cancel
Save