Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Handle reflected param names for variable length arguments #642

Merged
merged 1 commit into from

3 participants

Jeremy Mikola Derick Rethans Sebastian Bergmann
Jeremy Mikola

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


This came up as I was attempting to Mock the MongoCollection::aggregate() method, which uses the convention for defining variable length arguments. I'm aware the docs currently use $.. as the name instead of the $... convention -- that was an oversight, which is being changed.

Jeremy Mikola jmikola 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
0acdf52
Jeremy Mikola jmikola referenced this pull request in mongodb/mongo-php-driver
Closed

Use "..." as reflection name for variable length arguments #170

Derick Rethans

$.. is now $...

Sebastian Bergmann sebastianbergmann merged commit 6fa8e83 into from
Sebastian Bergmann

Thanks! Released as part of PHPUnit 3.7.0RC4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 10, 2012
  1. Jeremy Mikola

    Handle reflected param names for variable length arguments

    jmikola authored
    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
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 2 deletions.
  1. +5 −2 PHPUnit/Util/Class.php
7 PHPUnit/Util/Class.php
View
@@ -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 = '';
Something went wrong with that request. Please try again.