Edit report at http://bugs.php.net/bug.php?id=52183&edit=1
ID: 52183 Updated by: [email protected] Reported by: andreas dot streichardt at globalpark dot com Summary: Reflectionfunction reports invalid number of arguments for function aliases -Status: Open +Status: Closed Type: Bug Package: Reflection related Operating System: Linux PHP Version: 5.3.2 -Assigned To: +Assigned To: felipe New Comment: This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2010-06-26 18:03:43] [email protected] Automatic comment from SVN on behalf of felipe Revision: http://svn.php.net/viewvc/?view=revision&revision=300764 Log: - Fixed bug #52183 (Reflectionfunction reports invalid number of arguments for function aliases) ------------------------------------------------------------------------ [2010-06-26 17:27:35] [email protected] To get the arginfo from original function will decrease the performance and will lead to change the internal function structure... I think is better to add the arginfo as the normal functions for the aliases. ------------------------------------------------------------------------ [2010-06-25 12:50:47] andreas dot streichardt at globalpark dot com 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 this bug report at http://bugs.php.net/bug.php?id=52183&edit=1
