Skip to content

Commit

Permalink
Address reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
Girgias committed Aug 13, 2024
1 parent 168bb84 commit 1f2ca96
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Zend/tests/exit/define_goto_label_exit_with_jump.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ echo "After\n";

?>
--EXPECTF--
Parse error: syntax error, unexpected token "exit", expecting identifier in %s on line %d
Parse error: syntax error, unexpected token "exit", expecting identifier in %s on line %d
4 changes: 2 additions & 2 deletions Zend/tests/exit/exit_statements.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Using exit/die as a statement/constant
--FILE--
<?php

const FILE_PATH = __DIR__ . '/exit_statements.inc';
const FILE_PATH = __DIR__ . '/exit_statements.php';
const FILE_CONTENT = <<<'TEMPLATE'
<?php
echo "Before FUNCTION";
Expand Down Expand Up @@ -32,7 +32,7 @@ foreach (['exit', 'die'] as $value) {
?>
--CLEAN--
<?php
const FILE_PATH = __DIR__ . '/exit_statements.inc';
const FILE_PATH = __DIR__ . '/exit_statements.php';
@unlink(FILE_PATH);
?>
--EXPECT--
Expand Down
23 changes: 23 additions & 0 deletions Zend/tests/exit/exit_string_with_buffer_output.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
Throwing output buffer with exit("Message")
--FILE--
<?php

ob_start(function ($text) {
fwrite(STDOUT, "Handler: " . $text);
throw new Exception('test');
}, chunk_size: 10);

try {
exit("Hello world!\n");
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
echo "After?\n";

?>
--EXPECT--
Handler: Hello world!
Hello world!
Exception: test
After?
4 changes: 2 additions & 2 deletions Zend/tests/exit/exit_values.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $values = [
new stdClass(),
];

const FILE_PATH = __DIR__ . '/exit_values.inc';
const FILE_PATH = __DIR__ . '/exit_values_test.php';
const FILE_CONTENT = <<<'TEMPLATE'
<?php
try {
Expand Down Expand Up @@ -73,7 +73,7 @@ foreach ([FILE_CONTENT, str_replace('exit', 'die', FILE_CONTENT)] as $code) {
?>
--CLEAN--
<?php
const FILE_PATH = __DIR__ . '/exit_values.inc';
const FILE_PATH = __DIR__ . '/exit_values_test.php';
@unlink(FILE_PATH);
?>
--EXPECTF--
Expand Down
4 changes: 4 additions & 0 deletions Zend/zend_builtin_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ ZEND_FUNCTION(exit)
if (str) {
size_t len = ZSTR_LEN(str);
if (len != 0) {
/* An exception might be emitted by an output handler */
zend_write(ZSTR_VAL(str), len);
if (EG(exception)) {
RETURN_THROWS();
}
}
} else {
EG(exit_status) = code;
Expand Down
1 change: 0 additions & 1 deletion Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -10678,7 +10678,6 @@ static void zend_compile_const(znode *result, zend_ast *ast) /* {{{ */

bool is_fully_qualified;
zend_string *orig_name = zend_ast_get_str(name_ast);

zend_string *resolved_name = zend_resolve_const_name(orig_name, name_ast->attr, &is_fully_qualified);

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__"))) {
Expand Down

0 comments on commit 1f2ca96

Please sign in to comment.