|  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

I've this one on reddit ( ).
I've verified this in PHP 7 RC 3 but according to the author of the reddit post and to testing website such as, 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:
$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.


Add a Patch

Pull Requests

Add a Pull Request


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

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