Bug #80836 [Csd->Opn]: is_array defies it own purpose by throwing fatal when passed an stdClass
| From: | daverandom@php.net | Date: | Fri, 05 Mar 2021 21:21:03 +0000 |
| Subject: | Bug #80836 [Csd->Opn]: is_array defies it own purpose by throwing fatal when passed an stdClass | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-232584@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80836&edit=1
ID: 80836
Updated by: daverandom@php.net
Reported by: chris at summit-tech dot ca
Summary: is_array defies it own purpose by throwing fatal
when passed an stdClass
-Status: Closed
+Status: Open
Type: Bug
Package: Compile Failure
Operating System: Windows
PHP Version: 8.0.3
Block user comment: N
Private report: N
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
The error produced by this code is due to treating an undefined variable as an object, nothing to do
with is_array() https://3v4l.org/hOQov
Although it is possible to implicitly declare an array in this fashion, the same is not true of an
object, which is a reference value and thus cannot be used unless it has been explicitly created.
Previous Comments:
------------------------------------------------------------------------
[2021-03-05 21:20:44] chris at summit-tech dot ca
Incorrectly described, closing
------------------------------------------------------------------------
[2021-03-05 21:14:28] chris at summit-tech dot ca
Description:
------------
This function has been rendered utterly useless as passing it some non-array objects such as
stdClass results in a ridiculous error: Fatal error: Uncaught Error: Cannot use object of type
stdClass as array
Test script:
---------------
$test->bla = "bla"; //Forcibly makes an stdClass obj
if (is_array($test)){
echo "This doesn't run";
}
Expected result:
----------------
is_array should return false and not stupidly throw a fatal
Actual result:
--------------
fatal error that defies the purpose of this function's entire existence
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80836&edit=1