Bug #78925 [Nab]: Side-effects for uninitialised typed property

From: Date: Sun, 08 Dec 2019 12:46:34 +0000
Subject: Bug #78925 [Nab]: Side-effects for uninitialised typed property
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224127@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78925&edit=1 ID: 78925 Updated by: nikic@php.net Reported by: nexor1984 at gmail dot com -Summary: Can't preload class ... with unresolved initializer for property ... +Summary: Side-effects for uninitialised typed property Status: Not a bug Type: Bug Package: opcache Operating System: Linux PHP Version: 7.4.0 Assigned To: dmitry Block user comment: N Private report: N New Comment: @beberlei: That looks like a bug :( As we won't actually restore the constant value, it might be defined to some other value, rendering the constexpr evaluation incorrect. Previous Comments: ------------------------------------------------------------------------ [2019-12-08 12:41:37] beberlei@php.net It looks like its working when you declare the constant directly in the preloading script and then opcache_compile_file with the class where its used. The script with the global constant must be executed, not just opcache_compile_file'd. https://gist.github.com/beberlei/67cb3682af3cf6599307765cd30c5222 It looks like that even handles the case where the script redeclares the constant with define. ------------------------------------------------------------------------ [2019-12-08 07:48:11] nikic@php.net Constants are not preloaded, you cannot preload classes making use of (non-internal) constants in initializers. @dmitry: I don't quite remember why we can't preload constants, what was the reason for this? ------------------------------------------------------------------------ [2019-12-07 22:18:16] nexor1984 at gmail dot com Description: ------------ Trying to preload a file like: <?php define('PEAR_ERROR_RETURN', 1); class PEAR_Error { var $mode = PEAR_ERROR_RETURN; } gives an error: PHP Warning: Can't preload class PEAR_Error with unresolved initializer for property $mode in /var/www/html/phptest/lib/pear/PEAR.php on line 5 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78925&edit=1

« previous php.bugs (#224127) next »