Bug #75608 [Com]: Narrowing occurred during type inference
| From: | a dot hacicheant at gmail dot com | Date: | Mon, 08 Jan 2018 15:24:54 +0000 |
| Subject: | Bug #75608 [Com]: Narrowing occurred during type inference | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-213426@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75608&edit=1
ID: 75608
Comment by: a dot hacicheant at gmail dot com
Reported by: anatoly dot pashin at gmail dot com
Summary: Narrowing occurred during type inference
Status: Closed
Type: Bug
Package: *General Issues
Operating System: centos
PHP Version: 7.1.12
Assigned To: laruence
Block user comment: N
Private report: N
New Comment:
The problem is not solved in 7.1.3 version.
I've got the same issue with PHP_CodeSniffer
https://github.com/squizlabs/PHP_CodeSniffer/issues/1785
(last comments)
Previous Comments:
------------------------------------------------------------------------
[2017-12-04 14:40:14] anatoly dot pashin at gmail dot com
Sorry, Dmitry, is my code sampl ecovered too? Didn't found it in diff.
------------------------------------------------------------------------
[2017-12-04 14:23:43] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5934bff91337b876195e9290b0811240052be7a3
Log: Fixed bug #75608 ("Narrowing occurred during type inference" error)
------------------------------------------------------------------------
[2017-12-04 02:58:48] anatoly dot pashin at gmail dot com
Laruence, I managed to get minimal reproducible example. Following code produces warning constantly.
class DeliveryTariffs extends BaseActiveRecord
{
public static function foo($arg1, $arg2 = null)
{
$a = self::someMethod();
$b = [];
foreach ($a as $c) {
foreach ($b as $d => $e) {
if (count(array_intersect($e['f'], $j['f'])) /
min(count($e['f']), count($j['f'])) > 0.5) {
$b[$d]['g'][$h] = $j['g'][$h];
$i = true;
break;
}
}
if (!$i) {
$b[] = $j;
}
}
return $b;
}
}
------------------------------------------------------------------------
[2017-12-04 02:01:12] anatoly dot pashin at gmail dot com
Laruence, I know problem is not in YiiBase.php :) it tries to include SpDelivery.php, which I
can't post here. If you agree to not share it, I can email it to you privately.
I can't determine which part of code in SpDelivery.php causes issue, because error goes away
from time to time when I try to edit that file. So I change any line, error gone. I change another
one and it's returned.
About file acm at tweakers dot net posted: I can't reproduce it from cli (because opcache is
disabled in cli). I see 'Narrowing occurred during type inference' error message when I
try to open it from webroot through php-fpm. But when I press f5 to refresh page, error is gone and
script is executed successfully.
PHP 7.1.12 (cli) (built: Dec 1 2017 14:08:55) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.12, Copyright (c) 1999-2017, by Zend Technologies
with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans
------------------------------------------------------------------------
[2017-12-01 14:05:35] acm at tweakers dot net
We see the same issue (with the ppa version for ubuntu, 7.1.12-1, from https://launchpad.net/~ondrej/+archive/ubuntu/php).
After stripping a class of pretty much all its functionality, we ended with this below php code.
Note, the below code is actually not useful anymore. But just running 'php filename.php'
triggers this warning:
PHP Warning: Narrowing occurred during type inference. Please file a bug report on bugs.php.net in
Unknown on line 0
<?php
class ReactionRatingService
{
public function calculateBoostPoints()
{
while ($reaction = $reactions) {
$reactionRatings = $this->validFunction();
$totalWeight = 0;
$runningScore = 0;
$queue = [];
foreach ($reactionRatings as $ratingData) {
if ($runningScore != $reaction['Score']) {
if ( ! $ratingData['BoostEarned']) {
$queue[] = $ratingData['UserID'];
}
} else {
foreach ($queue as $userId) {
$userBoostPointsRecalculate[$userId][] = $reaction['ID'];
}
}
$totalWeight += $ratingData['Weight'];
}
}
}
}
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=75608
--
Edit this bug report at https://bugs.php.net/bug.php?id=75608&edit=1