|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55222 Fatal Error disappears when using paranthesis
Submitted: 2011-07-17 16:51 UTC Modified: 2016-02-14 21:56 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: hanskrentel at yahoo dot de Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3.6 OS: Linux
Private report: No CVE-ID: None
 [2011-07-17 16:51 UTC] hanskrentel at yahoo dot de
PHP 5.3 is giving me nice, sound FATAL ERRORS when using functions like reset() within a variable. However it looks like that it's not always taken care of that consequentially.

I don't even get a strict standards warning even.

Test script:

function get_array() {
   return Array(1);

function foo() {
   // return reset( (get_array()?:null) );
   //               ^Fatal error: Only variables can be passed by reference
   return reset( (get_array()) ); 
  //             ^Only? This one works OK


Expected result:
Fatat error.

Actual result:
All fine.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-17 16:52 UTC] hanskrentel at yahoo dot de
within = without in the description.
 [2011-07-18 22:21 UTC]
-Status: Open +Status: Bogus
 [2011-07-18 22:21 UTC]
reset() requires a variable that can be passed by reference. There's really no way 
to get around that, hence the fatal error.
 [2011-07-19 08:10 UTC] hanskrentel at yahoo dot de
Actually I'm concerned that

    reset( (get_array()) );

does _not_ give a fatal error. This contradicts the last comment "There's really 
no way to get around that [getting a fatal error]".

Why does it not give a fatal error? There is no variable.
 [2011-07-27 16:34 UTC] hanskrentel at yahoo dot de
I can only remind again that the first comment from obviously misread this report.

I am _missing_ the fatal error.
 [2011-07-27 16:51 UTC]
-Status: Bogus +Status: Verified
 [2011-08-24 08:56 UTC] hanskrentel at yahoo dot de
I assume you want to say that the linked answer explicitly explains the problem.

Should we make use of this feature when programming PHP or not?
 [2011-09-12 07:21 UTC] tom at kera dot name
cataphract, this bug report came out of that Stack Overflow post. I don't think that the Stack Overflow post resolves it in any useful way.
 [2014-03-17 21:38 UTC]
@hanskretel: No, you should not. As this is a bug, the behavior might change in a future PHP version without further notice.
 [2016-02-14 21:56 UTC]
-Status: Verified +Status: Closed -Assigned To: +Assigned To: nikic
 [2016-02-14 21:56 UTC]
In PHP 7 this consistently throws a notice, the parenthesis no longer make a difference.
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC