Skip to content

Commit 43a7a9a

Browse files
committed
Update test and add fix by arnaud-lb
1 parent a55bf78 commit 43a7a9a

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

Zend/zend_language_scanner.l

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ void shutdown_scanner(void)
210210
zend_ptr_stack_destroy(&SCNG(heredoc_label_stack));
211211
SCNG(heredoc_scan_ahead) = 0;
212212
SCNG(on_event) = NULL;
213+
SCNG(on_event_context) = NULL;
213214
}
214215

215216
ZEND_API void zend_save_lexical_state(zend_lex_state *lex_state)
@@ -581,6 +582,8 @@ ZEND_API zend_result open_file_for_scanning(zend_file_handle *file_handle)
581582
zend_set_compiled_filename(compiled_filename);
582583
zend_string_release_ex(compiled_filename, 0);
583584

585+
SCNG(on_event) = NULL;
586+
SCNG(on_event_context) = NULL;
584587
RESET_DOC_COMMENT();
585588
CG(zend_lineno) = 1;
586589
CG(increment_lineno) = 0;
@@ -766,6 +769,8 @@ ZEND_API void zend_prepare_string_for_scanning(zval *str, zend_string *filename)
766769
zend_set_compiled_filename(filename);
767770
CG(zend_lineno) = 1;
768771
CG(increment_lineno) = 0;
772+
SCNG(on_event) = NULL;
773+
SCNG(on_event_context) = NULL;
769774
RESET_DOC_COMMENT();
770775
}
771776

@@ -1636,6 +1641,9 @@ OPTIONAL_WHITESPACE_OR_COMMENTS ({WHITESPACE}|{MULTI_LINE_COMMENT}|{SINGLE_LINE_
16361641
<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("integer"){TABS_AND_SPACES}")" {
16371642
if (PARSER_MODE()) {
16381643
zend_error(E_DEPRECATED, "Non-canonical cast (integer) is deprecated, use the (int) cast instead");
1644+
if (PARSER_MODE() && EG(exception)) {
1645+
RETURN_TOKEN(T_ERROR);
1646+
}
16391647
}
16401648
RETURN_TOKEN(T_INT_CAST);
16411649
}
@@ -1647,6 +1655,9 @@ OPTIONAL_WHITESPACE_OR_COMMENTS ({WHITESPACE}|{MULTI_LINE_COMMENT}|{SINGLE_LINE_
16471655
<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("double"){TABS_AND_SPACES}")" {
16481656
if (PARSER_MODE()) {
16491657
zend_error(E_DEPRECATED, "Non-canonical cast (double) is deprecated, use the (float) cast instead");
1658+
if (PARSER_MODE() && EG(exception)) {
1659+
RETURN_TOKEN(T_ERROR);
1660+
}
16501661
}
16511662
RETURN_TOKEN(T_DOUBLE_CAST);
16521663
}
@@ -1666,6 +1677,9 @@ OPTIONAL_WHITESPACE_OR_COMMENTS ({WHITESPACE}|{MULTI_LINE_COMMENT}|{SINGLE_LINE_
16661677
<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("binary"){TABS_AND_SPACES}")" {
16671678
if (PARSER_MODE()) {
16681679
zend_error(E_DEPRECATED, "Non-canonical cast (binary) is deprecated, use the (string) cast instead");
1680+
if (PARSER_MODE() && EG(exception)) {
1681+
RETURN_TOKEN(T_ERROR);
1682+
}
16691683
}
16701684
RETURN_TOKEN(T_STRING_CAST);
16711685
}
@@ -1685,6 +1699,9 @@ OPTIONAL_WHITESPACE_OR_COMMENTS ({WHITESPACE}|{MULTI_LINE_COMMENT}|{SINGLE_LINE_
16851699
<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("boolean"){TABS_AND_SPACES}")" {
16861700
if (PARSER_MODE()) {
16871701
zend_error(E_DEPRECATED, "Non-canonical cast (boolean) is deprecated, use the (bool) cast instead");
1702+
if (PARSER_MODE() && EG(exception)) {
1703+
RETURN_TOKEN(T_ERROR);
1704+
}
16881705
}
16891706
RETURN_TOKEN(T_BOOL_CAST);
16901707
}

ext/tokenizer/tests/bug19507.phpt renamed to ext/tokenizer/tests/gh19507.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ $tokens = PhpToken::tokenize('<?php (double) $x;', TOKEN_PARSE);
1515
foreach ($tokens as $token) {
1616
echo $token->getTokenName(), "\n";
1717
}
18-
18+
?>
1919
--EXPECT--
2020
error handler called: Non-canonical cast (double) is deprecated, use the (float) cast instead
2121
T_OPEN_TAG
22-
T_LNUMBER
23-
;
2422
T_DOUBLE_CAST
2523
T_WHITESPACE
2624
T_VARIABLE

0 commit comments

Comments
 (0)