Skip to content

Commit 5934bff

Browse files
committed
Fixed bug #75608 ("Narrowing occurred during type inference" error)
1 parent 1da28c5 commit 5934bff

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ PHP NEWS
1919
requests). (Remi)
2020

2121
- Opcache:
22+
. Fixed bug #75608 ("Narrowing occurred during type inference" error).
23+
(Laruence, Dmitry)
2224
. Fixed bug #75570 ("Narrowing occurred during type inference" error).
2325
(Dmitry)
2426

ext/opcache/Optimizer/zend_inference.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2928,7 +2928,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
29282928
break;
29292929
case ZEND_FE_FETCH_R:
29302930
case ZEND_FE_FETCH_RW:
2931-
tmp = (t2 & MAY_BE_REF);
2931+
tmp = t2;
29322932
if (t1 & MAY_BE_OBJECT) {
29332933
if (opline->opcode == ZEND_FE_FETCH_RW) {
29342934
tmp |= MAY_BE_REF | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
@@ -2953,7 +2953,7 @@ static int zend_update_type_info(const zend_op_array *op_array,
29532953
}
29542954
UPDATE_SSA_TYPE(tmp, ssa_ops[i].op2_def);
29552955
if (ssa_ops[i].result_def >= 0) {
2956-
tmp = 0;
2956+
tmp = (ssa_ops[i].result_use >= 0) ? RES_USE_INFO() : 0;
29572957
if (t1 & MAY_BE_OBJECT) {
29582958
tmp |= MAY_BE_RC1 | MAY_BE_RCN | MAY_BE_ANY | MAY_BE_ARRAY_KEY_ANY | MAY_BE_ARRAY_OF_ANY | MAY_BE_ARRAY_OF_REF;
29592959
}

ext/opcache/tests/bug75608.phpt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
--TEST--
2+
Bug #75608 ("Narrowing occurred during type inference" error)
3+
--FILE--
4+
<?php
5+
class ReactionRatingService
6+
{
7+
public function calculateBoostPoints()
8+
{
9+
while ($reaction = $reactions) {
10+
$reactionRatings = $this->validFunction();
11+
12+
$totalWeight = 0;
13+
$runningScore = 0;
14+
$queue = [];
15+
foreach ($reactionRatings as $ratingData) {
16+
if ($runningScore != $reaction['Score']) {
17+
if ( ! $ratingData['BoostEarned']) {
18+
$queue[] = $ratingData['UserID'];
19+
}
20+
} else {
21+
foreach ($queue as $userId) {
22+
$userBoostPointsRecalculate[$userId][] = $reaction['ID'];
23+
}
24+
}
25+
$totalWeight += $ratingData['Weight'];
26+
}
27+
}
28+
}
29+
}
30+
?>
31+
OK
32+
--EXPECT--
33+
OK

0 commit comments

Comments
 (0)