Skip to content

Commit 3940fca

Browse files
committed
Address review comments
1 parent a1ae0a2 commit 3940fca

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

Zend/tests/in-de-crement/incdec_undefined_vars_exception.phpt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,37 @@ try {
1212
$x++;
1313
} catch (\Exception $e) {
1414
echo $e->getMessage(), PHP_EOL;
15-
if (!isset($x)) { echo("UNDEF\n"); } else { var_dump($x); }
15+
if (!isset($x) && !@is_null($x)) { echo("UNDEF\n"); } else { var_dump($x); }
1616
}
1717
unset($x);
1818
try {
1919
$x--;
2020
} catch (\Exception $e) {
2121
echo $e->getMessage(), PHP_EOL;
22-
if (!isset($x)) { echo("UNDEF\n"); } else { var_dump($x); }
22+
if (!isset($x) && !@is_null($x)) { echo("UNDEF\n"); } else { var_dump($x); }
2323
}
2424
unset($x);
2525
try {
2626
++$x;
2727
} catch (\Exception $e) {
2828
echo $e->getMessage(), PHP_EOL;
29-
if (!isset($x)) { echo("UNDEF\n"); } else { var_dump($x); }
29+
if (!isset($x) && !@is_null($x)) { echo("UNDEF\n"); } else { var_dump($x); }
3030
}
3131
unset($x);
3232
try {
3333
--$x;
3434
} catch (\Exception $e) {
3535
echo $e->getMessage(), PHP_EOL;
36-
if (!isset($x)) { echo("UNDEF\n"); } else { var_dump($x); }
36+
if (!isset($x) && !@is_null($x)) { echo("UNDEF\n"); } else { var_dump($x); }
3737
}
3838
unset($x);
3939
?>
4040
--EXPECT--
4141
Undefined variable $x
42-
UNDEF
42+
NULL
4343
Undefined variable $x
44-
UNDEF
44+
NULL
4545
Undefined variable $x
46-
UNDEF
46+
NULL
4747
Undefined variable $x
48-
UNDEF
48+
NULL

Zend/tests/in-de-crement/incdec_undefined_vars_exception_use_result_op.phpt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,37 @@ try {
1212
$y = $x++;
1313
} catch (\Exception $e) {
1414
echo $e->getMessage(), PHP_EOL;
15-
if (!isset($x)) { echo("UNDEF\n"); } else { var_dump($x); }
15+
if (!isset($x) && !@is_null($x)) { echo("UNDEF\n"); } else { var_dump($x); }
1616
}
1717
unset($x);
1818
try {
1919
$y = $x--;
2020
} catch (\Exception $e) {
2121
echo $e->getMessage(), PHP_EOL;
22-
if (!isset($x)) { echo("UNDEF\n"); } else { var_dump($x); }
22+
if (!isset($x) && !@is_null($x)) { echo("UNDEF\n"); } else { var_dump($x); }
2323
}
2424
unset($x);
2525
try {
2626
$y = ++$x;
2727
} catch (\Exception $e) {
2828
echo $e->getMessage(), PHP_EOL;
29-
if (!isset($x)) { echo("UNDEF\n"); } else { var_dump($x); }
29+
if (!isset($x) && !@is_null($x)) { echo("UNDEF\n"); } else { var_dump($x); }
3030
}
3131
unset($x);
3232
try {
3333
$y = --$x;
3434
} catch (\Exception $e) {
3535
echo $e->getMessage(), PHP_EOL;
36-
if (!isset($x)) { echo("UNDEF\n"); } else { var_dump($x); }
36+
if (!isset($x) && !@is_null($x)) { echo("UNDEF\n"); } else { var_dump($x); }
3737
}
3838
unset($x);
3939
?>
4040
--EXPECT--
4141
Undefined variable $x
42-
UNDEF
42+
NULL
4343
Undefined variable $x
44-
UNDEF
44+
NULL
4545
Undefined variable $x
46-
UNDEF
46+
NULL
4747
Undefined variable $x
48-
UNDEF
48+
NULL

Zend/zend_vm_def.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,7 @@ ZEND_VM_HELPER(zend_pre_inc_helper, VAR|CV, ANY)
14881488
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var_ptr) == IS_UNDEF)) {
14891489
ZVAL_UNDEFINED_OP1();
14901490
if (UNEXPECTED(EG(exception))) {
1491-
/* Smart branch expects result to be set with exceptions */
1491+
/* opcodes are expected to set the result value */
14921492
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
14931493
ZVAL_NULL(EX_VAR(opline->result.var));
14941494
}
@@ -1553,7 +1553,7 @@ ZEND_VM_HELPER(zend_pre_dec_helper, VAR|CV, ANY)
15531553
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var_ptr) == IS_UNDEF)) {
15541554
ZVAL_UNDEFINED_OP1();
15551555
if (UNEXPECTED(EG(exception))) {
1556-
/* Smart branch expects result to be set with exceptions */
1556+
/* opcodes are expected to set the result value */
15571557
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
15581558
ZVAL_NULL(EX_VAR(opline->result.var));
15591559
}
@@ -1619,7 +1619,7 @@ ZEND_VM_HELPER(zend_post_inc_helper, VAR|CV, ANY)
16191619
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var_ptr) == IS_UNDEF)) {
16201620
ZVAL_UNDEFINED_OP1();
16211621
if (UNEXPECTED(EG(exception))) {
1622-
/* Smart branch expects result to be set with exceptions */
1622+
/* opcodes are expected to set the result value */
16231623
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
16241624
ZVAL_NULL(EX_VAR(opline->result.var));
16251625
}
@@ -1677,7 +1677,7 @@ ZEND_VM_HELPER(zend_post_dec_helper, VAR|CV, ANY)
16771677
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var_ptr) == IS_UNDEF)) {
16781678
ZVAL_UNDEFINED_OP1();
16791679
if (UNEXPECTED(EG(exception))) {
1680-
/* Smart branch expects result to be set with exceptions */
1680+
/* opcodes are expected to set the result value */
16811681
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
16821682
ZVAL_NULL(EX_VAR(opline->result.var));
16831683
}

Zend/zend_vm_execute.h

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)