Bug #69010 [NEW]: Accessing bool/int/double/resource with array index returns NULL and no warning
From: mfischer@php.net
Operating system: OSX 10.10
PHP version: master-Git-2015-02-08 (Git)
Package: Arrays related
Bug Type: Bug
Bug description:Accessing bool/int/double/resource with array index returns NULL and no warning
Description:
------------
Accessing booleans, integers and resources with an array index returns
NULL but emits no warning/notice of a potential error.
Tested with
$ sapi/cli/php -v
PHP 7.0.0-dev (cli) (built: Feb 8 2015 01:14:57)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
I made up the notice messages in "Expected result" to put emphasis what
I would have expected.
Similar report: https://bugs.php.net/bug.php?id=44821 , categorized
as
documentation problem which doesn't sound right.
Test script:
---------------
<?php
$a = false;
$b = $a['index'];
var_dump($b);
$a = 1;
$b = $a['index'];
var_dump($b);
$a = 1.1;
$b = $a['index'];
var_dump($b);
$a = NULL;
$b = $a['index'];
var_dump($b);
$a = fopen($argv[0], 'r');
$b = $a['index'];
var_dump($b);
Expected result:
----------------
Notice: Illegal array access on boolean in Command line code on line 1
NULL
Notice: Illegal array access on integer in Command line code on line 1
NULL
Notice: Illegal array access on double in Command line code on line 1
NULL
Notice: Illegal array access on NULL in Command line code on line 1
NULL
Notice: Illegal array access on resource in Command line code on line 1
NULL
Actual result:
--------------
NULL
NULL
NULL
NULL
NULL
--
Edit bug report at https://bugs.php.net/bug.php?id=69010&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69010&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69010&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69010&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69010&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69010&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69010&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69010&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69010&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69010&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69010&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69010&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69010&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69010&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69010&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69010&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69010&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69010&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69010&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69010&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69010&r=mysqlcfg
Thread (4 messages)
- mfischer@php.net