1
0
mirror of https://github.com/php/php-src.git synced 2026-04-28 10:43:30 +02:00

Merge branch 'PHP-7.0'

This commit is contained in:
Nikita Popov
2015-12-14 00:29:57 +01:00
2 changed files with 22 additions and 1 deletions
@@ -0,0 +1,19 @@
--TEST--
Array addition is not commutative -- do not swap operands
--FILE--
<?php
$array = [1, 2, 3];
$array = [4, 5, 6] + $array;
var_dump($array);
?>
--EXPECT--
array(3) {
[0]=>
int(4)
[1]=>
int(5)
[2]=>
int(6)
}
+3 -1
View File
@@ -106,7 +106,9 @@ void zend_optimizer_pass3(zend_op_array *op_array)
zend_uchar tmp_type = opline->op1_type;
znode_op tmp = opline->op1;
if (opline->opcode != ZEND_ADD || ZEND_OP1_TYPE(opline) == IS_CONST) {
if (opline->opcode != ZEND_ADD
|| (ZEND_OP1_TYPE(opline) == IS_CONST
&& Z_TYPE(ZEND_OP1_LITERAL(opline)) != IS_ARRAY)) {
/* protection from array add: $a = array + $a is not commutative! */
COPY_NODE(opline->op1, opline->op2);
COPY_NODE(opline->op2, tmp);