php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #49555 Fatal error "Function must be a string" message should be renamed.
Submitted: 2009-09-14 17:32 UTC Modified: 2010-11-24 11:19 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: dormam at gmail dot com Assigned:
Status: Open Package: Scripting Engine problem
PHP Version: 5.3.0 OS: Ubuntu Jaunty
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: dormam at gmail dot com
New email:
PHP Version: OS:

 

 [2009-09-14 17:32 UTC] dormam at gmail dot com
Description:
------------
In the past, to call a variable as a function, the variable had to be a string: $var = 'strlen'; $var(/*args*/); calls strlen.

But in the present, the message is a bit misleading, since it must not necessarily be a string: $foo = function() {echo "bar";};

I consider this to be a very minor thing, but consider the message wrong, anyway.

Reproduce code:
---------------
function badLambdaCreator($argument) {
    function($test) use ($argument) { 
        /*Do something*/
    };
    /*No return given :O*/
}
$foo = badLambdaCreator(10);
$foo(50); 
//Fatal error telling you to use strings, 
//while a lambda is fine too.

Expected result:
----------------
A fatal error that also includes lambdas (I guess callbacks work? I'm not sure what name is the most appropiate).

Actual result:
--------------
An error that tells you that **ONLY** strings can be used.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-24 11:19 UTC] jani@php.net
-Package: Feature/Change Request +Package: Scripting Engine problem
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Sep 15 12:01:26 2019 UTC