Req #73980 [Opn->Dup]: PHP error reporting is less strict for bools access as array than for arrays
| From: | requinix@php.net | Date: | Mon, 23 Jan 2017 16:08:07 +0000 |
| Subject: | Req #73980 [Opn->Dup]: PHP error reporting is less strict for bools access as array than for arrays | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-206896@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73980&edit=1
ID: 73980
Updated by: requinix@php.net
Reported by: benp at yelp dot com
Summary: PHP error reporting is less strict for bools access
as array than for arrays
-Status: Open
+Status: Duplicate
Type: Feature/Change Request
-Package: PHP Language Specification
+Package: Scripting Engine problem
PHP Version: 7.1.1
Block user comment: N
Private report: N
New Comment:
Already considered and accepted, and while it's mostly implemented there are some issues to
address.
https://wiki.php.net/rfc/notice-for-non-valid-array-container
https://github.com/php/php-src/pull/2031
Previous Comments:
------------------------------------------------------------------------
[2017-01-23 14:36:25] benp at yelp dot com
Description:
------------
This is well-known from long-past bugs e.g. https://bugs.php.net/bug.php?id=41195, but it
really should be reconsidered at some point for future language versions.
It's pretty nuts that undefined offset access is more strict for arrays than it is for booleans
(and other objects). Booleans should probably be able to complain about being accessed as arrays.
Test script:
---------------
<?php
error_reporting(E_ALL);
$boolean = true;
$array = [];
$boolean['hello']; // No error
$array['hello']; // E_NOTICE
Expected result:
----------------
$boolean['hello'] should throw some error.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73980&edit=1