Req #69010 [Opn]: Accessing bool/int/double/resource with array index returns NULL and no warning

From: Date: Mon, 09 Feb 2015 05:12:05 +0000
Subject: Req #69010 [Opn]: Accessing bool/int/double/resource with array index returns NULL and no warning
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190538@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69010&edit=1 ID: 69010 Updated by: laruence@php.net Reported by: mfischer@php.net Summary: Accessing bool/int/double/resource with array index returns NULL and no warning Status: Open Type: Feature/Change Request Package: Arrays related Operating System: OSX 10.10 PHP Version: master-Git-2015-02-08 (Git) Block user comment: N Private report: N New Comment: others are okey, but for NULL.. any undefined variables are NULL Previous Comments: ------------------------------------------------------------------------ [2015-02-08 00:54:16] mfischer@php.net 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 this bug report at https://bugs.php.net/bug.php?id=69010&edit=1

« previous php.bugs (#190538) next »