|  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
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: Closed 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.
Block user comment
Status: Assign to:
Bug Type:
From: dormam at gmail dot com
New email:
PHP Version: OS:


 [2009-09-14 17:32 UTC] dormam at gmail dot com
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);
//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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-24 11:19 UTC]
-Package: Feature/Change Request +Package: Scripting Engine problem
 [2020-01-08 13:32 UTC]
Automatic comment on behalf of
Log: Fix #49555: Improve "function must be a string" error message
 [2020-01-08 13:32 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 18 08:01:28 2024 UTC