Bug #72248 [NEW]: Optimization erroneously enforces strict types in call_user_func

From: Date: Fri, 20 May 2016 13:47:41 +0000
Subject: Bug #72248 [NEW]: Optimization erroneously enforces strict types in call_user_func
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201208@lists.php.net to get a copy of this message
From: bwoebi Operating system: Irrelevant PHP version: 7.0.6 Package: Scripting Engine problem Bug Type: Bug Bug description:Optimization erroneously enforces strict types in call_user_func Description: ------------ Due to our call_user_func() optimizations (which by the way also removes the additional internal stack frame in the stacktrace...; which ultimately causes the misbehavior), call_user_func[_array]() calls apply, when optimized, the strict_type mode of the caller, which they shouldn't. In general, PHP functions count internally as weakly typed and this behavior shall be always the same. Test script: --------------- // first script (works as expected, with namespace) <?php declare(strict_types=1); namespace a; var_dump(call_user_func("strlen", 1));' // second script (bad behavior, without namespace) <?php declare(strict_types=1); var_dump(call_user_func("strlen", 1));' Expected result: ---------------- // first script int(1) // second script int(1) Actual result: -------------- // first script int(1) // second script Fatal error: Uncaught TypeError: strlen() expects parameter 1 to be string, integer given in Command line code:1 Stack trace: #0 Command line code(1): strlen(1) #1 {main} thrown in Command line code on line 1 -- Edit bug report at https://bugs.php.net/bug.php?id=72248&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72248&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72248&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72248&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72248&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72248&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72248&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72248&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72248&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72248&r=support Expected behavior: https://bugs.php.net/fix.php?id=72248&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72248&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72248&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72248&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72248&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72248&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72248&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72248&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72248&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72248&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72248&r=mysqlcfg

« previous php.bugs (#201208) next »