Req #49555 [Opn->Csd]: Fatal error "Function must be a string" message should be renamed.

From: Date: Wed, 08 Jan 2020 13:32:51 +0000
Subject: Req #49555 [Opn->Csd]: Fatal error "Function must be a string" message should be renamed.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224776@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=49555&edit=1 ID: 49555 Updated by: nikic@php.net Reported by: dormam at gmail dot com Summary: Fatal error "Function must be a string" message should be renamed. -Status: Open +Status: Closed Type: Feature/Change Request Package: Scripting Engine problem Operating System: Ubuntu Jaunty PHP Version: 5.3.0 Block user comment: N Private report: N New Comment: Automatic comment on behalf of nikita.ppv@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=d0d1654a34bb4923196fb8df2d19c432f13ede3e Log: Fix #49555: Improve "function must be a string" error message Previous Comments: ------------------------------------------------------------------------ [2009-09-14 17:32:07] 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=49555&edit=1

« previous php.bugs (#224776) next »