Checks if the function/method has a specific optional parameter.

@param mixed $parameter
Either the name of the parameter (with or without leading $), or a
ParameterNode.
@param string $type
Optional type hint to check.

@return boolean
177587
public function hasOptionalParameter($parameter, $type = NULL) {
    return $this->hasParameter($parameter, $type) && $this->getParameterByName($parameter)->isOptional();
  }
381987
public function bindValue($parameter, $value, $type = null)
    {
        return $this->bindParam($parameter, $value, $type);
    }
222270
public boolean hasParameter(String parameter) {
    if (info == null || info.parameters == null) {
      return false;
    }
    return info.parameters.containsKey(parameter);
  }
55491
public static function exists($type = 'post')
    {
        switch ($type) {
            case 'post':
                return (!empty($_POST)) ? true : false;
                break;
            case 'get':
                return (!empty($_GET)) ? true : false;
                break;
            default:
                return false;
                break;
        }
    }
371240
private static function matchType(\ReflectionParameter $parameter, $value) : bool
    {
        if ($class = $parameter->getClass()) {
            return \is_object($value) && $class->isInstance($value);
        }

        if ($parameter->isArray()) {
            return \is_array($value);
        }

        if ($parameter->isCallable()) {
            return \is_callable($value);
        }

        if (!$type = $parameter->getType()) {
            return true;
        }

        switch ($type->getName()) {
            case 'bool': return \is_bool($value);
            case 'float': return \is_float($value);
            case 'int': return \is_int($value);
            case 'string': return \is_string($value);
            case 'iterable': return \is_iterable($value);
        }

        return true;
    }
679615
protected function isCallableOption($callback, $parameter)
    {
        $option  = 'function(' . $parameter . '){' . PHP_EOL;
        $option .= Buffering\Callback::do($callback);
        $option .= '}';

        return $option;
    }
752120
private function checkQueryResourceId(array $parameters, string $type): void
    {
        if (!$this->resourceId && $parameters['resource_id']) {
            throw new \InvalidArgumentException(\sprintf(
                'Trying to query with a resource ID, but the repository %s does not provide support for them',
                $this->name
            ));
        }
        if (self::ENDPOINT_SINGLE === $type && !$parameters['resource_id']) {
            throw new \InvalidArgumentException(\sprintf(
                'Trying to query a single element without providing a resource ID for repository %s',
                $this->name
            ));
        }
        if (self::ENPOINT_COLLECTION === $type && $parameters['resource_id']) {
            throw new \InvalidArgumentException(\sprintf(
                'Trying to query a collection element by providing a resource ID for repository %s',
                $this->name
            ));
        }
    }
271216
private function isDataProvider(string $type): bool
    {
        return (!$this->isSimpleType($type) && !$this->isCollection($type));
    }
640829
public function hasMessages($type = null)
    {
        if ( ! is_null($type)) {
            return ! empty($_SESSION[$this->key][$type]);
        }
        
        foreach ($this->types as $type) {
            if ( ! empty($_SESSION[$this->key][$type])) {
                return true;
            }
        }

        return false;
    }
815995
protected function wrapPHPValue($parameter)
    {
        switch ($parameter['default']['type']) {
            case 'null':
                return 'null';
                break;

            case 'string':
            case 'char':
                return '\''.addslashes($parameter['default']['value']).'\'';
                break;

            case 'empty-array':
                return 'array()';
                break;

            case 'array':
                $parameters = [];

                foreach ($parameter['default']['left'] as $value) {
                    $source = '';

                    if (isset($value['key'])) {
                        $source .= $this->wrapPHPValue([
                            'default' => $value['key'],
                            'type' => $value['key']['type'],
                        ]).' => ';
                    }

                    $parameters[] = $source.$this->wrapPHPValue([
                        'default' => $value['value'],
                        'type' => $value['value']['type'],
                    ]);
                }

                return 'array('.implode(', ', $parameters).')';
                break;

            case 'static-constant-access':
                return $parameter['default']['left']['value'].'::'.$parameter['default']['right']['value'];
                break;

            case 'int':
            case 'double':
            case 'bool':
                return $parameter['default']['value'];
                break;

            default:
                throw new Exception('Stubs - value with type: '.$parameter['default']['type'].' is not supported');
                break;
        }
    }
667532
public JSTypeExpression getParameterType(String parameter) {
    if (info == null || info.parameters == null) {
      return null;
    }
    return info.parameters.get(parameter);
  }
1293024
protected function isRequiredParameter($parameter)
    {
        $method = $this->getRequestMethod();
        $requirements = $this->getParametersRequirements();

        $requirements = array_change_key_case($requirements, CASE_LOWER);
        $method = strtolower($method);

        if (!isset($requirements[$method])) {
            return false;
        }

        if (in_array($parameter,$requirements[$method])) {
            return true;
        }

        $isRequired = false;

        //The requirements may have been declared using URIs, look up for the URI
        $aliases = $this->getParametersAliases();
        if (isset($aliases[$parameter])) {
            $isRequired = in_array($aliases[$parameter],$requirements[$method]);
        }
        return $isRequired;
    }
169297
public function has(string $type): bool
    {
        return isset($this->values[$type]) && \count($this->values[$type]) > 0;
    }
405132
public function optional($type)
    {
        foreach ($this->arguments as $index => $argument) {
            if (gettype($argument) === $type || is_a($argument, $type, true)) {
                array_splice($this->arguments, $index, 1);

                return $argument;
            }
        }
    }
866599
private function determineParamValue(\ReflectionParameter $parameter)
    {
        $class = $parameter->getClass();

        if (!empty($class)) {
            // If this is a object we may be able to map it to something in our context
            $className = $class->getName();

            // Determine strong type-based link
            if (isset($this->instances[$className])) {
                return $this->instances[$className];
            }

            // Determine weak type-based link
            if (isset($this->weakLinks[$className])) {
                $lowerClassName = $this->weakLinks[$className];
                return $this->instances[$lowerClassName];
            }
        } else {
            // If this is a primitive type, attempt to determine it by its name
            $varName = $parameter->getName();

            if (isset($this->variablesByName[$varName])) {
                return $this->variablesByName[$varName];
            }
        }

        // We were unable to determine a suitable value based on this context. Pass back its default value if possible.
        if ($parameter->isDefaultValueAvailable()) {
            return $parameter->getDefaultValue();
        }

        // As a final fallback we will primitive pass NULL and let the function deal with it.
        return null;
    }
174213
public function getParameter(string $parameter)
    {
        if ($this->hasParameter($parameter)) {
            return $this->getParameters()[$parameter];
        }

        throw new \InvalidArgumentException(sprintf('Parameter "%s" does not exist', $parameter));
    }
1034663
public function supports($resource, $type = null): bool
    {
        \assert('is_string($resource) && ($type === null || is_string($type))');
        return $this->parser->supports(pathinfo($resource, PATHINFO_EXTENSION));
    }