Bug #75608 [Asn->Csd]: Narrowing occurred during type inference

From: Date: Mon, 04 Dec 2017 14:23:45 +0000
Subject: Bug #75608 [Asn->Csd]: Narrowing occurred during type inference
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212902@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 Updated by: dmitry@php.net Reported by: anatoly dot pashin at gmail dot com Summary: Narrowing occurred during type inference -Status: Assigned +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: 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 (&quot;Narrowing occurred during type inference&quot; error) Previous Comments: ------------------------------------------------------------------------ [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']; } } } } ------------------------------------------------------------------------ [2017-12-01 10:07:34] laruence@php.net the error seems not in YiiBase.php but the file which is trying to include in line 421 could you please try to figure out which file it was trying to include? thanks ------------------------------------------------------------------------ [2017-12-01 02:03:00] anatoly dot pashin at gmail dot com Description: ------------ Today we updated php to 7.1.12 and saw some errors during deploy. Deploy algo: 1. get new files in /www/versions/795.17 directory 2. change symbolic link so it points to it 3. call php-fpm reload. Error is thrown for some requests after 1-2 minute after reload. You can see source of YiiBase.php at https://github.com/yiisoft/yii/blob/master/framework/YiiBase.php Please tell me email which I can send SpDelivery.php privately. Test script: --------------- System_PhpException: Uncaught exception 'System_PhpException' with message 'Narrowing occurred during type inference. Please file a bug report on bugs.php.net' in /www/versions/795.17/vendor/yiisoft/yii/framework/YiiBase.php:421 in System_Global::{closure} called at /www/versions/795.17/vendor/yiisoft/yii/framework/YiiBase.php (421) in include called at /www/versions/795.17/vendor/yiisoft/yii/framework/YiiBase.php (421) in YiiBase::autoload called at ? (?) in spl_autoload_call called at /www/versions/795.17/src/DeliveryCalculator/SpDelivery.php (67) in Sp\DeliveryCalculator\SpDelivery::detectTariffs called at /www/versions/795.17/src/DeliveryCalculator/SpDelivery.php (21) in Sp\DeliveryCalculator\SpDelivery::getCalculation called at /www/versions/795.17/protected/models/Distributors.php (982) in Distributors::getMinimalDeliveryCalculation called at /www/versions/795.17/protected/components/SHtml.php (1618) in SHtml::getDeliverySummary called at /www/versions/795.17/public_html/includes/classes/Widgets/Layout.php (65) in Widgets_Layout::getHeader called at /www/versions/795.17/public_html/includes/classes/Widgets/HtmlPage.php (213) in Widgets_HtmlPage::printHeader called at /www/versions/795.17/public_html/ui/megaorder.php (103) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=75608&edit=1

« previous php.bugs (#212902) next »