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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 22:01:26 2024 UTC