|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-04-09 07:55 UTC] nikic@php.net
[2019-04-09 08:31 UTC] cmb@php.net
-Package: Compile Failure
+Package: *General Issues
[2019-04-18 07:25 UTC] cmb@php.net
-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: cmb
[2019-04-18 07:25 UTC] cmb@php.net
[2019-04-28 04:22 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 22 06:00:01 2025 UTC |
Description: ------------ Adding a class / interface constant that references to another constant via an array key that's non-existent kills the PHP process silently. (without invoking die() or exit()) There are no error messages thrown, nor a warning, or anything. PHP just dies. There are two different results on two different scenarios. If this bug was done on an interface, PHP silently kills itself, as mentioned for several times. If this bug was done on a class, PHP Freezes silently and refuses to do anything. I've only tested this for a few minutes, I don't know if it un-freezes and exits after a while. Due to no error messages are being displayed, this made debugging it a bit tricky at first. It took me quite a few minutes before finding out that it was an invalid array key access. Even while I'm using PHPStorm (the class constant 'ARRAY_1' is an empty array), the erroneous code does not get pointed out or highlighted. Test script: --------------- // Only use one of these to get different results. // Insta-kill interface BrokenInterface { // this can be anything... even null. just with a non-existent key public const ARRAY_1 = []; public const ARRAY_2 = [ self::ARRAY_1["nonExistentKey"] ]; } class UseThisClass implements BrokenInterface {} (new UseThisClass()); // Freeze class BrokenClass { // this can be anything... even null. just with a non-existent key public const ARRAY_1 = []; public const ARRAY_2 = [ self::ARRAY_1["nonExistentKey"] ]; } (new BrokenClass()); Expected result: ---------------- A Compile Error should be thrown. Actual result: -------------- PHP Silently shuts down without any warning or error message.