Bug #52183 [NEW]: Reflectionfunction reports invalid number of arguments for function aliases

From: Date: Fri, 25 Jun 2010 10:50:48 +0000
Subject: Bug #52183 [NEW]: Reflectionfunction reports invalid number of arguments for function aliases
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-151860@lists.php.net to get a copy of this message
From: Operating system: Linux PHP version: 5.3.2 Package: Reflection related Bug Type: Bug Bug description:Reflectionfunction reports invalid number of arguments for function aliases Description: ------------ When defining a function alias internally in PHP, PHP_FALIAS requires an arginfo as the third parameter. For example gzwrite() is internally represented as a function alias to fwrite(): PHP_FALIAS(gzwrite, fwrite, NULL) Here however the argument info is not provided. This leads to the fact that the reflection api can't extract the parameters of gzwrite. Why does an FALIAS require an arginfo? Couldn't it just take the argument info of the alias function if the arginfo is null? The impact is that you can't determine the required arguments from the gzwrite function. I hacked the code and added the arginfo stuff and the reflection api immediatly noticed that gzwrite requires 2 parameters. We are doing massive static code analysis and our code analysis returns bogus results due to the fact that the reflection api can't report the real arguments of a function. Test script: --------------- <?php foreach (array("gzwrite","fwrite") as $function) { $refl=new ReflectionFunction($function); var_dump($refl->getNumberOfRequiredParameters()); var_dump($refl->getNumberOfParameters()); } ?> Expected result: ---------------- int(2) int(3) int(2) int(3) Actual result: -------------- int(0) int(0) int(2) int(3) -- Edit bug report at http://bugs.php.net/bug.php?id=52183&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52183&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52183&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52183&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52183&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52183&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52183&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52183&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52183&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52183&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52183&r=support Expected behavior: http://bugs.php.net/fix.php?id=52183&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52183&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52183&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52183&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52183&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52183&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52183&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52183&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52183&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52183&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52183&r=mysqlcfg

« previous php.bugs (#151860) next »