Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. MockMethod.php

function MockMethod::methodParametersForCall

Returns the parameters of a function or method.

Throws

ReflectionException

1 call to MockMethod::methodParametersForCall()
MockMethod::fromReflection in vendor/phpunit/phpunit/src/Framework/MockObject/Generator/MockMethod.php

File

vendor/phpunit/phpunit/src/Framework/MockObject/Generator/MockMethod.php, line 315

Class

MockMethod
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit

Namespace

PHPUnit\Framework\MockObject\Generator

Code

private static function methodParametersForCall(ReflectionMethod $method) : string {
    $parameters = [];
    foreach ($method->getParameters() as $i => $parameter) {
        $name = '$' . $parameter->getName();
        
        /* 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;
        }
        if ($parameter->isVariadic()) {
            continue;
        }
        if ($parameter->isPassedByReference()) {
            $parameters[] = '&' . $name;
        }
        else {
            $parameters[] = $name;
        }
    }
    return implode(', ', $parameters);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal