Skip to content

Commit 846afa3

Browse files
committed
Address reviews
1 parent 032f61d commit 846afa3

6 files changed

+32
-6
lines changed

Zend/tests/exit/define_goto_label_exit_with_jump.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ echo "After\n";
1111

1212
?>
1313
--EXPECTF--
14-
Parse error: syntax error, unexpected token "exit", expecting identifier in %s on line %d
14+
Parse error: syntax error, unexpected token "exit", expecting identifier in %s on line %d

Zend/tests/exit/exit_statements.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Using exit/die as a statement/constant
33
--FILE--
44
<?php
55

6-
const FILE_PATH = __DIR__ . '/exit_statements.inc';
6+
const FILE_PATH = __DIR__ . '/exit_statements.php';
77
const FILE_CONTENT = <<<'TEMPLATE'
88
<?php
99
echo "Before FUNCTION";
@@ -32,7 +32,7 @@ foreach (['exit', 'die'] as $value) {
3232
?>
3333
--CLEAN--
3434
<?php
35-
const FILE_PATH = __DIR__ . '/exit_statements.inc';
35+
const FILE_PATH = __DIR__ . '/exit_statements.php';
3636
@unlink(FILE_PATH);
3737
?>
3838
--EXPECT--
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
Throwing output buffer with exit("Message")
3+
--FILE--
4+
<?php
5+
6+
ob_start(function ($text) {
7+
fwrite(STDOUT, "Handler: " . $text);
8+
throw new Exception('test');
9+
}, chunk_size: 10);
10+
11+
try {
12+
exit("Hello world!\n");
13+
} catch (Throwable $e) {
14+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
15+
}
16+
echo "After?\n";
17+
18+
?>
19+
--EXPECT--
20+
Handler: Hello world!
21+
Hello world!
22+
Exception: test
23+
After?

Zend/tests/exit/exit_values.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $values = [
3737
new stdClass(),
3838
];
3939

40-
const FILE_PATH = __DIR__ . '/exit_values.inc';
40+
const FILE_PATH = __DIR__ . '/exit_values_test.php';
4141
const FILE_CONTENT = <<<'TEMPLATE'
4242
<?php
4343
try {
@@ -73,7 +73,7 @@ foreach ([FILE_CONTENT, str_replace('exit', 'die', FILE_CONTENT)] as $code) {
7373
?>
7474
--CLEAN--
7575
<?php
76-
const FILE_PATH = __DIR__ . '/exit_values.inc';
76+
const FILE_PATH = __DIR__ . '/exit_values_test.php';
7777
@unlink(FILE_PATH);
7878
?>
7979
--EXPECTF--

Zend/zend_builtin_functions.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ ZEND_FUNCTION(exit)
8282
if (str) {
8383
size_t len = ZSTR_LEN(str);
8484
if (len != 0) {
85+
/* An exception might be emitted by an output handler */
8586
zend_write(ZSTR_VAL(str), len);
87+
if (EG(exception)) {
88+
RETURN_THROWS();
89+
}
8690
}
8791
} else {
8892
EG(exit_status) = code;

Zend/zend_compile.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10675,7 +10675,6 @@ static void zend_compile_const(znode *result, zend_ast *ast) /* {{{ */
1067510675

1067610676
bool is_fully_qualified;
1067710677
zend_string *orig_name = zend_ast_get_str(name_ast);
10678-
1067910678
zend_string *resolved_name = zend_resolve_const_name(orig_name, name_ast->attr, &is_fully_qualified);
1068010679

1068110680
if (zend_string_equals_literal(resolved_name, "__COMPILER_HALT_OFFSET__") || (name_ast->attr != ZEND_NAME_RELATIVE && zend_string_equals_literal(orig_name, "__COMPILER_HALT_OFFSET__"))) {

0 commit comments

Comments
 (0)