Bug #77287 [Opn]: Fatal error: Uncaught TypeError

From: Date: Wed, 02 Jan 2019 12:20:20 +0000
Subject: Bug #77287 [Opn]: Fatal error: Uncaught TypeError
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-218748@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77287&edit=1 ID: 77287 Updated by: nikic@php.net Reported by: someone dot is dot alive at gmail dot com Summary: Fatal error: Uncaught TypeError Status: Open Type: Bug Package: opcache Operating System: Windows PHP Version: 7.3.0 -Assigned To: +Assigned To: nikic Block user comment: N Private report: N New Comment: Could it be that you're on a 32-bit system (or use a 32-bit PHP build)? Previous Comments: ------------------------------------------------------------------------ [2018-12-28 11:35:55] pirogen at protonmail dot com It looks like the bug only occurs with *both* opcache and xdebug enabled. Disabling *either* makes the issue go away. ------------------------------------------------------------------------ [2018-12-26 00:49:14] pirogen at protonmail dot com I've encountered this as well after upgrading from 7.2 to 7.3 on Debian Testing. Unfortunately, I can't seem to reproduce it in a minimal fashion; it only occurs in a project with rather large graph of inter-dependent objects. The bug manifests itself with class methods that use constants (can be a class constant, built-in constant or user-defined global constant) as default parameter values, i.e.: public function someMethod($some_param=SOME_CONSTANT) {} When someMethod is called with no arguments, $some_param *sometimes* (more often than not, but not always) receives a value that var_dump() identifies as NFC. Which, if passed down to a function or method that expects a specific type, throws a "[function] expects parameter [num] to be [type], unknown given" error OP mentions. ------------------------------------------------------------------------ [2018-12-17 00:40:12] andrew at fw dot net dot nz I encountered the same error after upgrading php-fpm from 7.2 to 7.3 on Ubuntu 18.04. An argument with a default parameter threw a type error "unknown given" when the callee did not provide the argument at all. I ran opcache_reset() which resolved it. A google search found another mention of the same error in 7.3 here: https://github.com/nextcloud/server/issues/11868 ------------------------------------------------------------------------ [2018-12-12 10:59:04] nikic@php.net Can't repro on Ubuntu, possibly Windows only. The resolved default value for the 2nd arg will be stored in the RT cache, so maybe there is an invalidation problem. ------------------------------------------------------------------------ [2018-12-12 10:26:01] someone dot is dot alive at gmail dot com I think i found a problem - when opcache is enabled i get the error. Usually happens when i edit file (e.g. (un)comment TestConst::STEP_2) This is the shortest code to reproduce: - no exception at all (e.g. for first 10 requests or it may throw error on first attempt) - Argument 2 passed to PHPDemo\Utils::testInput() must be of the type int, unknown given - Argument 2 passed to PHPDemo\Utils::testInput() must be of the type int, object given - Argument 2 passed to PHPDemo\Utils::testInput() must be of the type int, bool given <?php namespace PHPDemo; class TestConst { const STEP_1 = 1; const STEP_2 = 2; } class Utils { public static function testInput(string $name, int $step = TestConst::STEP_1) { } } Utils::testInput('abc 1'); ------ I deleted all cached files, restarted server OPCache log (opcache.log_verbosity_level=4) Wed Dec 12 11:15:22 2018 (33644): Debug Restart Scheduled! Reason: user Wed Dec 12 11:15:22 2018 (33644): Debug Restarting! Wed Dec 12 11:17:53 2018 (33644): Message Cached script 'D:\www\demo.php' Wed Dec 12 11:15:45 2018 (33644): Message Added key 'D:/www/demo.php' Wed Dec 12 11:18:44 2018 (33644): Message Cached script 'D:\www\demo.php' Wed Dec 12 11:18:44 2018 (33644): Message Added key 'D:/www/demo.php' ------------------------------------------------------------------------ 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=77287 -- Edit this bug report at https://bugs.php.net/bug.php?id=77287&edit=1

« previous php.bugs (#218748) next »