src/Drupal/Component/Utility/ArgumentsResolver.php
protected function getArgument(\ReflectionParameter $parameter) {
    $parameter_type_hint = $parameter->getClass();
    $parameter_name = $parameter->getName();

    // If the argument exists and is NULL, return it, regardless of
    // parameter type hint.
    if (!isset($this->objects[$parameter_name]) && array_key_exists($parameter_name, $this->objects)) {
      return NULL;
    }

    if ($parameter_type_hint) {
      // If the argument exists and complies with the type hint, return it.
      if (isset($this->objects[$parameter_name]) && is_object($this->objects[$parameter_name]) && $parameter_type_hint->isInstance($this->objects[$parameter_name])) {
        return $this->objects[$parameter_name];
      }
      // Otherwise, resolve wildcard arguments by type matching.
      foreach ($this->wildcards as $wildcard) {
        if ($parameter_type_hint->isInstance($wildcard)) {
          return $wildcard;
        }
      }
    }
    elseif (isset($this->scalars[$parameter_name])) {
      return $this->scalars[$parameter_name];
    }

    // If the callable provides a default value, use it.
    if ($parameter->isDefaultValueAvailable()) {
      return $parameter->getDefaultValue();
    }

    // Can't resolve it: call a method that throws an exception or can be
    // overridden to do something else.
    return $this->handleUnresolvedArgument($parameter);
  }
protected function getArgument(\ReflectionParameter $parameter) {
    $parameter_type_hint = $parameter->getClass();
    $parameter_name = $parameter->getName();

    // If the argument exists and is NULL, return it, regardless of
    // parameter type hint.
    if (!isset($this->objects[$parameter_name]) && array_key_exists($parameter_name, $this->objects)) {
      return NULL;
    }

    if ($parameter_type_hint) {
      // If the argument exists and complies with the type hint, return it.
      if (isset($this->objects[$parameter_name]) && is_object($this->objects[$parameter_name]) && $parameter_type_hint->isInstance($this->objects[$parameter_name])) {
        return $this->objects[$parameter_name];
      }
      // Otherwise, resolve wildcard arguments by type matching.
      foreach ($this->wildcards as $wildcard) {
        if ($parameter_type_hint->isInstance($wildcard)) {
          return $wildcard;
        }
      }
    }
    elseif (isset($this->scalars[$parameter_name])) {
      return $this->scalars[$parameter_name];
    }

    // If the callable provides a default value, use it.
    if ($parameter->isDefaultValueAvailable()) {
      return $parameter->getDefaultValue();
    }

    // Can't resolve it: call a method that throws an exception or can be
    // overridden to do something else.
    return $this->handleUnresolvedArgument($parameter);
  }
protected function getArgument ( \ ReflectionParameter $ parameter ) { $ parameter_type_hint = $ parameter -> getClass ( ) ; $ parameter_name = $ parameter -> getName ( ) ; // If the argument exists and is NULL, return it, regardless of // parameter type hint. if ( ! isset ( $ this -> objects [ $ parameter_name ] ) && array_key_exists ( $ parameter_name , $ this -> objects ) ) { return NULL ; } if ( $ parameter_type_hint ) { // If the argument exists and complies with the type hint, return it. if ( isset ( $ this -> objects [ $ parameter_name ] ) && is_object ( $ this -> objects [ $ parameter_name ] ) && $ parameter_type_hint -> isInstance ( $ this -> objects [ $ parameter_name ] ) ) { return $ this -> objects [ $ parameter_name ] ; } // Otherwise, resolve wildcard arguments by type matching. foreach ( $ this -> wildcards as $ wildcard ) { if ( $ parameter_type_hint -> isInstance ( $ wildcard ) ) { return $ wildcard ; } } } elseif ( isset ( $ this -> scalars [ $ parameter_name ] ) ) { return $ this -> scalars [ $ parameter_name ] ; } // If the callable provides a default value, use it. if ( $ parameter -> isDefaultValueAvailable ( ) ) { return $ parameter -> getDefaultValue ( ) ; } // Can't resolve it: call a method that throws an exception or can be // overridden to do something else. return $ this -> handleUnresolvedArgument ( $ parameter ) ; }
Gets the argument value for a parameter.

@param \ReflectionParameter $parameter
The parameter of a callable to get the value for.

@return mixed
The value of the requested parameter value.

@throws \RuntimeException
Thrown when there is a missing parameter.
Gets the argument value for a parameter .