Bug #73326 [NEW]: Imported functions cannot be passed as callable parameters

From: Date: Sun, 16 Oct 2016 11:59:58 +0000
Subject: Bug #73326 [NEW]: Imported functions cannot be passed as callable parameters
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204826@lists.php.net to get a copy of this message
From: castarco at litipk dot com Operating system: Ubuntu 16.04 64 bits PHP version: 7.0.12 Package: Reproducible crash Bug Type: Bug Bug description:Imported functions cannot be passed as callable parameters Description: ------------ I won't provide a test script because to test this bug we need to use many files. Assumptions: 1. I have a function placed in some file, following the PSR-4 conventions. 2. I'm using Composer, and I force the autoloading of the file where I put the functions. 3. I import it using something like: use function MyNamespace\functionName as myLocalFunction; 4. I check that the autoload has been done, I can directly call the function without problems: myLocalFunction($x); 5. I can pass that function as a callable, but only with its fully qualified name: array_filter($myData, 'MyNamespace\\functionName'); 6. I cannot pass that function using the "local name": array_filter($myData, 'myLocalFunction'); // This will crash 7. Even if I don't use aliasing whilst importing the function, the crash happens too. Actual result: -------------- array_filter() expects parameter 2 to be a valid callback, function 'myLocalFunction' not found or invalid function name -- Edit bug report at https://bugs.php.net/bug.php?id=73326&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=73326&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=73326&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=73326&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=73326&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=73326&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=73326&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=73326&r=needscript Try newer version: https://bugs.php.net/fix.php?id=73326&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=73326&r=support Expected behavior: https://bugs.php.net/fix.php?id=73326&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=73326&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=73326&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=73326&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=73326&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=73326&r=dst IIS Stability: https://bugs.php.net/fix.php?id=73326&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=73326&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=73326&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=73326&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=73326&r=mysqlcfg

« previous php.bugs (#204826) next »