php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70541 Changing variable type never trigger but in one case
Submitted: 2015-09-21 08:46 UTC Modified: 2015-09-23 16:54 UTC
From: jonathan dot massuchetti at gmail dot com Assigned:
Status: Suspended Package: *General Issues
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jonathan dot massuchetti at gmail dot com
New email:
PHP Version: OS:

 

 [2015-09-21 08:46 UTC] jonathan dot massuchetti at gmail dot com
Description:
------------
Hello,

I've this one on reddit ( https://www.reddit.com/r/lolphp/comments/3hm7hh/conjure_arrays_from_nothing ).
I've verified this in PHP 7 RC 3 but according to the author of the reddit post and to testing website such as 3v4l.org, it is a valid issue from PHP 4.3 to PHP 7.0.0 RC 3.

So as a brief description, you set a variable to false, than you implicitly turn it into an array, no error is triggered.
But when you set it to true, and then change it into an array, a warning is raised.

Test script:
---------------
<?php
$foo = false;
$foo["bar"] = "baz";

// No warning

$foo = true;
$foo["bar"] = "baz";


// Warning: Cannot use a scalar value as an array

Expected result:
----------------
Consistant output. Always or never. IMHO it should be always.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-21 17:02 UTC] bwoebi@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: bwoebi
 [2015-09-21 17:02 UTC] bwoebi@php.net
I totally agree this should be fixed. *puts on ToDo list*
 [2015-09-23 16:54 UTC] bwoebi@php.net
-Status: Assigned +Status: Suspended -Assigned To: bwoebi +Assigned To:
 [2015-09-23 16:54 UTC] bwoebi@php.net
That needs a RFC (I guess… or at least some thorough internals discussion).

Suspending as it'll target minimum 7.1.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC