Skip to content

Commit 4250a7a

Browse files
committed
Address review comments
1 parent a3c7dea commit 4250a7a

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
}
@@ -1546,7 +1546,7 @@ ZEND_VM_HELPER(zend_pre_dec_helper, VAR|CV, ANY)
15461546
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var_ptr) == IS_UNDEF)) {
15471547
ZVAL_UNDEFINED_OP1();
15481548
if (UNEXPECTED(EG(exception))) {
1549-
/* Smart branch expects result to be set with exceptions */
1549+
/* opcodes are expected to set the result value */
15501550
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
15511551
ZVAL_NULL(EX_VAR(opline->result.var));
15521552
}
@@ -1605,7 +1605,7 @@ ZEND_VM_HELPER(zend_post_inc_helper, VAR|CV, ANY)
16051605
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var_ptr) == IS_UNDEF)) {
16061606
ZVAL_UNDEFINED_OP1();
16071607
if (UNEXPECTED(EG(exception))) {
1608-
/* Smart branch expects result to be set with exceptions */
1608+
/* opcodes are expected to set the result value */
16091609
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
16101610
ZVAL_NULL(EX_VAR(opline->result.var));
16111611
}
@@ -1663,7 +1663,7 @@ ZEND_VM_HELPER(zend_post_dec_helper, VAR|CV, ANY)
16631663
if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(var_ptr) == IS_UNDEF)) {
16641664
ZVAL_UNDEFINED_OP1();
16651665
if (UNEXPECTED(EG(exception))) {
1666-
/* Smart branch expects result to be set with exceptions */
1666+
/* opcodes are expected to set the result value */
16671667
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
16681668
ZVAL_NULL(EX_VAR(opline->result.var));
16691669
}

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)