Bug #71812 [NEW]: wrong code example in php doc

From: Date: Sun, 13 Mar 2016 06:53:50 +0000
Subject: Bug #71812 [NEW]: wrong code example in php doc
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-13317@lists.php.net to get a copy of this message
From: marcosptf at yahoo dot com dot br Operating system: Fedora 20 PHP version: Irrelevant Package: Documentation problem Bug Type: Bug Bug description:wrong code example in php doc Description: ------------ Hello to everyone!!! here ===> http://php.net/manual/en/function.forward-static-call-array.php the docs is fine, the description about this function work is totally correct, but the code example, is wrong; i have write a php test to this function, and i see that the code example is fine but have a mistake. here ===> https://www.flickr.com/photos/marcosptf/25445244080/in/dateposted-public/ we can see if copy + paste from official php doc the code to run in php -a terminal, the result is a warning because the function test() is call before exist. here ===> https://www.flickr.com/photos/marcosptf/25119350863/in/dateposted-public/ we can see if move the function test() to top of code, works fine i have open a pr to test this function ====> https://github.com/php/php-src/pull/1810 and open this bug to someone fix this mistake. thanks from php-sp Brazil!!!! Test script: --------------- <?php class A { const NAME = 'A'; public static function test() { $args = func_get_args(); echo static::NAME, " ".join(',', $args)." \n"; } } class B extends A { const NAME = 'B'; public static function test() { echo self::NAME, "\n"; forward_static_call_array(array('A', 'test'), array('more', 'args')); forward_static_call_array( 'test', array('other', 'args')); } } B::test('foo'); function test() { $args = func_get_args(); echo "C ".join(',', $args)." \n"; } ?> Expected result: ---------------- B B more,args C other,args Actual result: -------------- B B more,args PHP Warning: forward_static_call_array() expects parameter 1 to be a valid callback, function 'test' not found or invalid function name in php shell code on line 8 PHP Stack trace: PHP 1. {main}() php shell code:0 PHP 2. B::test() php shell code:1 PHP 3. forward_static_call_array() php shell code:8 -- Edit bug report at https://bugs.php.net/bug.php?id=71812&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71812&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71812&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71812&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=71812&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=71812&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=71812&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=71812&r=needscript Try newer version: https://bugs.php.net/fix.php?id=71812&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=71812&r=support Expected behavior: https://bugs.php.net/fix.php?id=71812&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=71812&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=71812&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=71812&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71812&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=71812&r=dst IIS Stability: https://bugs.php.net/fix.php?id=71812&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=71812&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=71812&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=71812&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=71812&r=mysqlcfg

« previous php.doc.bugs (#13317) next »