Permalink
Browse files

Handle reflected param names for variable length arguments

The existing code handled cases where a PHP extension declared an argument for the reflection API without providing a name (typically done for referenced arguments). Also handle the case where the name it provides is "..." (i.e. variable arguments), as that would break mock object generation.

See: http://php.net/manual/en/language.pseudo-types.php
  • Loading branch information...
1 parent 837c66e commit 0acdf520a49578aa299981edb29c31f1bdef6bea @jmikola committed Sep 10, 2012
Showing with 5 additions and 2 deletions.
  1. +5 −2 PHPUnit/Util/Class.php
@@ -138,8 +138,11 @@ public static function getMethodParameters($method, $forCall = FALSE)
foreach ($method->getParameters() as $i => $parameter) {
$name = '$' . $parameter->getName();
- if ($name === '$') {
- $name .= 'arg' . $i;
+ /* Note: PHP extensions may use empty names for reference arguments
+ * or "..." for methods taking a variable number of arguments.
+ */
+ if ($name === '$' || $name === '$...') {
+ $name = '$arg' . $i;
}
$default = '';

0 comments on commit 0acdf52

Please sign in to comment.