From: jacob at jacobweber dot com Operating system: Fedora Core 3 PHP version: 5.0.4 PHP Bug Type: Class/Object related Bug description: array_splice inconsistent when passed function
Description: ------------ array_splice expects an array reference for its first argument. But sometimes you can pass it a function that doesn't return an array reference, and it will work. The function has to be a static method inside a class, and it has to return a static variable of that class. In this case, array_splice will actually update the class's variable, which it shouldn't be able to do. Even stranger, this behavior won't happen if you've assigned another variable to the result of that function. In the example below, you only get the error message when you uncomment line 8. As far as I can tell, that should have no effect. Reproduce code: --------------- <? class X { protected static $arr = array("a", "b", "c"); public static function getArr() { return self::$arr; } } #$arr1 = X::getArr(); array_splice(X::getArr(), 1, 1); print_r(X::getArr()); ?> Expected result: ---------------- Fatal error: Only variables can be passed by reference in test.php on line 9 Actual result: -------------- Array ( [0] => a [1] => c ) -- Edit bug report at http://bugs.php.net/?id=33257&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33257&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=33257&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=33257&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=33257&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=33257&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=33257&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=33257&r=needscript Try newer version: http://bugs.php.net/fix.php?id=33257&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=33257&r=support Expected behavior: http://bugs.php.net/fix.php?id=33257&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=33257&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=33257&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=33257&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33257&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=33257&r=dst IIS Stability: http://bugs.php.net/fix.php?id=33257&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=33257&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=33257&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=33257&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=33257&r=mysqlcfg