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

Breadcrumb

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

function MockMethod::exportDefaultValue

Throws

ReflectionException

1 call to MockMethod::exportDefaultValue()
MockMethod::methodParametersForDeclaration in vendor/phpunit/phpunit/src/Framework/MockObject/Generator/MockMethod.php
Returns the parameters of a function or method.

File

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

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 exportDefaultValue(ReflectionParameter $parameter) : string {
    try {
        $defaultValue = $parameter->getDefaultValue();
        if (!is_object($defaultValue)) {
            return var_export($defaultValue, true);
        }
        $parameterAsString = $parameter->__toString();
        return explode(' = ', substr(substr($parameterAsString, strpos($parameterAsString, '<optional> ') + strlen('<optional> ')), 0, -2))[1];
        // @codeCoverageIgnoreStart
    } catch (\ReflectionException $e) {
        throw new ReflectionException($e->getMessage(), $e->getCode(), $e);
    }
    // @codeCoverageIgnoreEnd
}

API Navigation

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