|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74980 Narrowing occurred during type inference
Submitted: 2017-07-24 12:46 UTC Modified: 2017-07-24 13:30 UTC
From: Assigned:
Status: Closed Package: opcache
PHP Version: 7.2.0beta1 OS: openSUSE 42.2 (x86_64)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
14 + 22 = ?
Subscribe to this entry?

 [2017-07-24 12:46 UTC]
Our codebase triggered
  "E_WARNING: Narrowing occurred during type inference. Please file a bug report on"
in our class loader which is installed using spl_autoload_register().

When trying to fetch the page a second time it reports
  "Fatal error: Cannot declare class xy, because the name is already in use in xy.class  on line 3"

  sudo apachectl graceful
to clear the opcache and reloading bring the Narrowing warning again.

I don't have a short reproduction script but I still reported the bug as the warning says so :-)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-24 13:30 UTC]
Are you able to determine on which file this is triggered (e.g. by just printing out the file name in the class loader and seeing after which the error occurs)? I'm assuming it's probably not the class loader itself?

If you can find the file, can you send it to This is one of those cases where a single file should be able to reliably reproduce the problem without context.
 [2017-07-24 15:31 UTC]
I managed to produce a test file narrowing.php


class A

static function foo()
	foreach ([] as $value)
		$arr["foo"]["bar"] = $value;

	foreach ($arr as $value)
		bar($value + []);


with a php.ini like

zend_extension                  =
opcache.enable_cli		= 1

and then calling it with

php -c php.ini narrowing.php

results in

Warning: Narrowing occurred during type inference. Please file a bug report on in Unknown on line 0
 [2017-07-26 04:08 UTC]
Automatic comment on behalf of
Log: Fixed bug #74980 (Narrowing occurred during type inference)
 [2017-07-26 04:08 UTC]
-Status: Open +Status: Closed
 [2017-11-28 09:28 UTC] matteoipri at gmail dot com
Hi all,
Arch Linux and PHP 7.1.12-1 here running Nextcloud on the server.
Since the update to 7.1.12 in the logs I find the following message:

Narrowing occurred during type inference. Please file a bug report on at /usr/share/nginx/nextcloud/lib/composer/composer/ClassLoader.php#444

I am not the only one to have this same error, see Nextcloud forum:

How can I help? Should I open a new bug?
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Nov 27 01:04:48 2022 UTC