Bug #70435 [Opn->Fbk]: Wrong return type when opcache is enabled

From: Date: Fri, 25 Sep 2015 10:48:39 +0000
Subject: Bug #70435 [Opn->Fbk]: Wrong return type when opcache is enabled
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-196233@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70435&edit=1 ID: 70435 Updated by: ab@php.net Reported by: peehaa@php.net Summary: Wrong return type when opcache is enabled -Status: Open +Status: Feedback Type: Bug Package: opcache Operating System: Windows 7 PHP Version: 7.0.0RC2 Block user comment: N Private report: N New Comment: @peehaa I've just pulled your reproduce repo, testing with the todays PHP-7.0, but cannot reproduce it. Either it has been fixed inbetween by something else, or i'm doing something wrong. Please check again with some recent snapshots (or ping if you need me to provide one). Thanks. Previous Comments: ------------------------------------------------------------------------ [2015-09-06 16:28:25] peehaa@php.net I realized the repro code is larger than optimal laurence. As stated in my OP I have tried to isolate and minimize the problem code as far as I could. The fact that it is about opcache heisenbugs also doesn't really help. I tried to make it as easy and convenient as possible by creating a repo for it which can just be run on a webserver without much hassle. If you have any idea how I could submit a couple of lines with the problem code which starts with <?php and ends with ?> I am more than happy to provide it, but as of now I have no idea how I could possibly fulfill your request. ------------------------------------------------------------------------ [2015-09-06 16:18:15] danack@php.net Laruence, the bug appears to only happen when there are multiple scripts involved. It does not happen inside a single script. Can you give some more usable advice on how to proceed, rather than insisting on it being demonstrated in a single script? The reporter is known to be reasonably competent, they'll be able to follow your instructions...but they aren't able to reproduce a bug under conditions where it is known not to occur. ------------------------------------------------------------------------ [2015-09-06 15:47:00] laruence@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. ------------------------------------------------------------------------ [2015-09-05 19:50:03] peehaa@php.net Description: ------------ When running on apache with opcache enabled I get a TypeError on the return value. However the actual return type it is complaining about is different than the return type I have defined. It seems as if the CLI is not affected by this. I tried to isolate the problem code as far as I could, but I couldn't get it any smaller than this https://github.com/CodeCollab/Demo/tree/opcache-return-type-bug At some point it suddenly started working as it should, but after an apache restart the problem was back. I will add the specific part of the code that results in the error below but the actual (working) test case is the linked github repo above. The part that throws is https://github.com/CodeCollab/Demo/blob/opcache-return-type-bug/vendor/codecollab/router/src/Router.php#L21. Windows 7, Apache 2.4.12, PHP RC2 Test script: --------------- public function addRoute(string $verb, string $path, array $callback): Router { $this->routeCollector->addRoute($verb, $path, $callback); //var_dump($this); // object(CodeCollab\Router\Router)#5 (4) { ... } return $this; } Expected result: ---------------- Instance of CodeCollab\Router\Router is returned. Actual result: -------------- Fatal error: Uncaught TypeError: Return value of CodeCollab\Router\Router::addRoute() must be an instance of FastRoute\RouteCollector, instance of CodeCollab\Router\Router returned in C:\Users\PeeHaa\Desktop\ph\Websites\CodeCollabLib\Demo\vendor\codecollab\router\src\Router.php on line 21 in ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70435&edit=1

« previous php.bugs (#196233) next »