You are here

protected function ProxyBuilder::buildParameter in Service Container 7.2

Same name and namespace in other branches
  1. 7 lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php \Drupal\Component\ProxyBuilder\ProxyBuilder::buildParameter()

Builds a string for a single parameter of a method.

Parameters

\ReflectionParameter $parameter: A reflection object of the parameter.

Return value

string

1 call to ProxyBuilder::buildParameter()
ProxyBuilder::buildMethod in lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php
Generates the string representation of a single method: signature, body.

File

lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php, line 262
Contains \Drupal\Component\ProxyBuilder\ProxyBuilder.

Class

ProxyBuilder
Generates the string representation of the proxy service.

Namespace

Drupal\Component\ProxyBuilder

Code

protected function buildParameter(\ReflectionParameter $parameter) {
  $parameter_string = '';
  if ($parameter
    ->isArray()) {
    $parameter_string .= 'array ';
  }
  elseif ($parameter
    ->isCallable()) {
    $parameter_string .= 'callable ';
  }
  elseif ($class = $parameter
    ->getClass()) {
    $parameter_string .= '\\' . $class
      ->getName() . ' ';
  }
  if ($parameter
    ->isPassedByReference()) {
    $parameter_string .= '&';
  }
  $parameter_string .= '$' . $parameter
    ->getName();
  if ($parameter
    ->isDefaultValueAvailable()) {
    $parameter_string .= ' = ';
    $parameter_string .= var_export($parameter
      ->getDefaultValue(), TRUE);
  }
  return $parameter_string;
}