Skip to content

Commit c591cf8

Browse files
committed
ext/standard/head.c: no need to rely on ZEND_NUM_ARGS()
1 parent 7026b1b commit c591cf8

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

ext/standard/head.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -314,32 +314,31 @@ PHP_FUNCTION(setrawcookie)
314314
/* {{{ Returns true if headers have already been sent, false otherwise */
315315
PHP_FUNCTION(headers_sent)
316316
{
317-
zval *arg1 = NULL, *arg2 = NULL;
318-
const char *file="";
319-
int line=0;
317+
zval *by_ref_filename = NULL;
318+
zval *by_ref_line = NULL;
319+
const char *file = "";
320+
int line = 0;
320321

321322
ZEND_PARSE_PARAMETERS_START(0, 2)
322323
Z_PARAM_OPTIONAL
323-
Z_PARAM_ZVAL(arg1)
324-
Z_PARAM_ZVAL(arg2)
324+
Z_PARAM_ZVAL(by_ref_filename)
325+
Z_PARAM_ZVAL(by_ref_line)
325326
ZEND_PARSE_PARAMETERS_END();
326327

327328
if (SG(headers_sent)) {
328329
line = php_output_get_start_lineno();
329330
file = php_output_get_start_filename();
330331
}
331332

332-
switch(ZEND_NUM_ARGS()) {
333-
case 2:
334-
ZEND_TRY_ASSIGN_REF_LONG(arg2, line);
335-
ZEND_FALLTHROUGH;
336-
case 1:
333+
if (by_ref_filename) {
337334
if (file) {
338-
ZEND_TRY_ASSIGN_REF_STRING(arg1, file);
335+
ZEND_TRY_ASSIGN_REF_STRING(by_ref_filename, file);
339336
} else {
340-
ZEND_TRY_ASSIGN_REF_EMPTY_STRING(arg1);
337+
ZEND_TRY_ASSIGN_REF_EMPTY_STRING(by_ref_filename);
341338
}
342-
break;
339+
}
340+
if (by_ref_line) {
341+
ZEND_TRY_ASSIGN_REF_LONG(by_ref_line, line);
343342
}
344343

345344
RETURN_BOOL(SG(headers_sent));

0 commit comments

Comments
 (0)