Skip to content

Commit 4a98f42

Browse files
committed
Merge branch 'PHP-7.3' into PHP-7.4
2 parents bb75a53 + 33c2b47 commit 4a98f42

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

ext/opcache/Optimizer/zend_inference.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2104,7 +2104,6 @@ static uint32_t assign_dim_result_type(
21042104
tmp |= MAY_BE_RC1 | MAY_BE_RCN;
21052105
}
21062106
if (tmp & MAY_BE_ARRAY) {
2107-
tmp |= (value_type & MAY_BE_ANY) << MAY_BE_ARRAY_SHIFT;
21082107
if (value_type & MAY_BE_UNDEF) {
21092108
tmp |= MAY_BE_ARRAY_OF_NULL;
21102109
}
@@ -2125,6 +2124,11 @@ static uint32_t assign_dim_result_type(
21252124
tmp |= MAY_BE_ARRAY_KEY_STRING;
21262125
}
21272126
}
2127+
/* Only add value type if we have a key type. It might be that the key type is illegal
2128+
* for arrays. */
2129+
if (tmp & MAY_BE_ARRAY_KEY_ANY) {
2130+
tmp |= (value_type & MAY_BE_ANY) << MAY_BE_ARRAY_SHIFT;
2131+
}
21282132
}
21292133
return tmp;
21302134
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Don't add array value type is key type is illegal
3+
--FILE--
4+
<?php
5+
6+
function test(\SplObjectStorage $definitions = null) {
7+
$argument = new stdClass;
8+
$definitions[$argument] = 1;
9+
$definitions[$argument] += 1;
10+
$argument = [];
11+
$definitions[$argument] = 1;
12+
$definitions[$argument] += 1;
13+
}
14+
15+
?>
16+
===DONE===
17+
--EXPECT--
18+
===DONE===

0 commit comments

Comments
 (0)