Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Handle reflected param names for variable length arguments #642

Merged
merged 1 commit into from

3 participants

@jmikola

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.

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

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

@derickr

$.. is now $...

@sebastianbergmann sebastianbergmann merged commit 6fa8e83 into sebastianbergmann:master
@sebastianbergmann

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. @jmikola

    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
View
7 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 = '';
Something went wrong with that request. Please try again.