Bug #78779 [Fbk->NoF]: Null Coalescing Operator: Trying to access array offset on value of type null

From: Date: Sun, 15 Dec 2019 04:22:08 +0000
Subject: Bug #78779 [Fbk->NoF]: Null Coalescing Operator: Trying to access array offset on value of type null
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224304@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78779&edit=1 ID: 78779 Updated by: php-bugs@lists.php.net Reported by: bugreport2 at gmail dot com Summary: Null Coalescing Operator: Trying to access array offset on value of type null -Status: Feedback +Status: No Feedback Type: Bug Package: Scripting Engine problem Operating System: Linux PHP Version: 7.4Git-2019-11-04 (Git) Private report: N New Comment: No feedback was provided. The bug is being suspended because we assume that you are no longer experiencing the problem. If this is not the case and you are able to provide the information that was requested earlier, please do so and change the status of the bug back to "Re-Opened". Thank you. Previous Comments: ------------------------------------------------------------------------ [2019-12-07 19:28:36] contact at kevin-anidjar dot com My bad, did not see this in the changelog: Array-style access of non-arrays Trying to use values of type null, bool, int, float or resource as an array (such as $null["key"]) will now generate a notice. ------------------------------------------------------------------------ [2019-12-07 19:21:12] bugreports3 at gmail dot com > in previous PHP versions, this code did not throw an error > and the returned value was instead considered as null but your code is *expected* to throw an error in newer versions while "$arr[0] ?? ''" is not, no matter if $arr or $arr[0] is undefined ------------------------------------------------------------------------ [2019-12-07 19:16:39] contact at kevin-anidjar dot com @requinix@php.net: in previous PHP versions, this code did not throw an error and the returned value was instead considered as null. ------------------------------------------------------------------------ [2019-12-07 19:07:58] requinix@php.net @kevin-anidjar: That does not reproduce the issue. The code must use ?? immediately after a value and without that value going through a function. ------------------------------------------------------------------------ [2019-12-07 19:07:35] bugreports3 at gmail dot com sadly "echo strval($arr['foo']) ?? 'bar';" is a invalid reproducer and expected to thow a warning becaus ein that line strval() is feeded with $arr['foo'] and "?? 'bar'" would only be relevant wehn that returns NULL which is not possible by the nature of strval() this is a completly different beast $oldcontent = $arr[0] ?? ''; ------------------------------------------------------------------------ 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=78779 -- Edit this bug report at https://bugs.php.net/bug.php?id=78779&edit=1

« previous php.bugs (#224304) next »