Configure the beste resource to each parameter of one method or function

@param ReflectionParameter $reflectionParameter
@param array $data
@param bool $labels
@return mixed
164935
private function parseParameter(ReflectionParameter $reflectionParameter, &$data, $labels)
    {
        // get the principal properties
        $name = $reflectionParameter->getName();
        $value = null;
        if ($reflectionParameter->isOptional()) {
            $value = $reflectionParameter->getDefaultValue();
        }

        // parse data using labels
        if ($labels) {
            if (isset($data[$name])) {
                $value = off($data, $name, $value);
                unset($data[$name]);
            }
            return $value;
        }

        // parse data without labels
        if (isset($data[0])) {
            $value = $data[0];
            array_shift($data);
            reset($data);
        }
        return $value;
    }
1337625
private function buildLabels($labels)
    {
        $collection = [];
        foreach ($labels as $label) {
            $collection[] = Label::createFromData($label);
        }

        return $collection;
    }
800782
protected function setParameters(Swift_Mime_SimpleMessage $message, $data)
    {
        $this->numberOfRecipients = 0;

        $smtp_api = [];
        foreach ($message->getChildren() as $attachment) {
            if (!$attachment instanceof Swift_Image
                || !in_array(self::SMTP_API_NAME, [$attachment->getFilename(), $attachment->getContentType()])
            ) {
                continue;
            }
            $smtp_api = self::decode($attachment->getBody());
        }

        if (!is_array($smtp_api)) {
            return $data;
        }

        foreach ($smtp_api as $key => $val) {

            switch ($key) {

                case 'api_key':
                    $this->apiKey = $val;
                    continue 2;

                case 'personalizations':
                    $this->setPersonalizations($data, $val);
                    continue 2;

                case 'attachments':
                    $val = array_merge($this->attachments, $val);
                    break;

                case 'unique_args':
                    throw new \Exception('Sendgrid v3 now uses custom_args instead of unique_args');

                case 'custom_args':
                    foreach ($val as $name => $value) {
                        if (!is_string($value)) {
                            throw new \Exception('Sendgrid v3 custom arguments have to be a string.');
                        }
                    }
                    break;

            }

            array_set($data, $key, $val);
        }
        return $data;
    }
1318204
private function parseParameterControl($control, $parameters) {
        if($control instanceof \bootbuilder\Pane\Pane) {
            $control->parseParameters($parameters);
        }elseif($control instanceof \bootbuilder\Controls\Control) {
            if(isset($parameters[$control->getName()])) {
                if($control instanceof \bootbuilder\Controls\Checkbox) {
                    if($control instanceof \bootbuilder\Controls\Radio) {
                        if($control->getValue() == $parameters[$control->getName()]) {
                            $control->setChecked(true);
                        }else{
                            $control->setChecked(false);
                        }
                    }else{
                        $control->setChecked(true);
                    }
                }else{
                    $control->setValue(htmlentities($parameters[$control->getName()]));
                }
            }
        }
        
        return $control;
    }
1290657
private static function compareParameters(\ReflectionParameter $a, \ReflectionParameter $b) : int
    {
        if (0 !== $result = self::compareParameterClasses($a, $b)) {
            return $result;
        }

        if ($a->isArray() ^ $b->isArray()) {
            return $b->isArray() << 1 - 1;
        }

        if ($a->isCallable() ^ $b->isCallable()) {
            return $b->isCallable() << 1 - 1;
        }

        return $a->getPosition() - $b->getPosition();
    }
320521
private function buildLabeledPropertyMetadata(
        \SimpleXMLElement $propertyNode,
        $className,
        \ReflectionClass $reflection
    ) {
        if (!isset($propertyNode->label['name'])) {
            throw new MappingException(
                sprintf('Class "%s" OGM XML property label configuration is missing "name" attribute', $className)
            );
        }

        $name = (string) $propertyNode['name'];
        $label = new Label();
        $label->name = (string) $propertyNode->label['name'];

        return new LabeledPropertyMetadata(
            $name,
            $reflection->getProperty($name),
            $label
        );
    }
959424
public function resolve(\ReflectionMethod $function, array $arguments)
    {
        // No `@ScenarioStateArgument` annotation found
        if (null === $this->reader->getMethodAnnotation($function, ScenarioStateArgument::class)) {
            return $arguments;
        }

        $paramsKeys = array_map(function (\ReflectionParameter $element) {
            return $element->getName();
        }, $function->getParameters());
        $store = $this->store->getStore();

        // Prepare arguments from annotations
        /** @var ScenarioStateArgument[] $annotations */
        $annotations = $this->reader->getMethodAnnotations($function);
        foreach ($annotations as $annotation) {
            if ($annotation instanceof ScenarioStateArgument &&
                in_array($annotation->getArgument(), $paramsKeys) &&
                $store->hasStateFragment($annotation->getName())
            ) {
                $arguments[$annotation->getArgument()] = $store->getStateFragment($annotation->getName());
            }
        }

        // Reorder arguments
        $params = [];
        foreach ($function->getParameters() as $parameter) {
            $name = $parameter->getName();
            $params[$name] = isset($arguments[$name]) ? $arguments[$name] : $arguments[$parameter->getPosition()];
        }

        return $params;
    }
466522
protected function applyCustomFormat($format, $data)
    {
        $aClassFunc = $this->getFuncParams($format);

        $params = array_key_exists(
            'params',
            $format
        ) ? $format['params'] : [];

        array_unshift($params, $data);

        $object = (new \ReflectionClass($aClassFunc['class']))->newInstance();

        $data = call_user_func_array([$object, $aClassFunc['method']], $params);

        return $data;
    }
865288
private function getReflectionParamData(\ReflectionParameter $param)
    {
        $param_type = self::getPsalmTypeFromReflectionType($param->getType());
        $param_name = (string)$param->getName();

        $is_optional = (bool)$param->isOptional();

        return new FunctionLikeParameter(
            $param_name,
            (bool)$param->isPassedByReference(),
            $param_type,
            null,
            null,
            $is_optional,
            $param_type->isNullable(),
            $param->isVariadic()
        );
    }
687234
private function getDependencyInjectionParameters(array $reflectionParameters, array $arguments = []): array
    {
        $parameters = [];

        // Treat arguments
        $argumentsClass = [];
        foreach ($arguments as $name => &$argument) {
            if (!is_null($this->getContainer())) {
                // Service recursively
                if (is_string($argument) && substr($argument, 0, 1) == '@') {
                    $subServiceName = substr($argument, 1);
                    $argument = $this->getContainer()->get($subServiceName);
                }
            }

            // Get all classes of argument if it's an object.
            // It's necessary to know if argument can match with an injection.
            if (is_object($argument) && !($argument instanceof \stdClass)) {
                foreach ($this->getClassIndex()->getAllClasses($argument) as $class) {
                    $argumentsClass[$class][] = $name;
                }
            }
        }

        // Try to get all parameters values
        foreach ($reflectionParameters as $reflectionParameter) {
            if ($reflectionParameter instanceof \ReflectionParameter) {
                $parameters[$reflectionParameter->getName()] =
                    $this->getDependencyInjectionParameter($reflectionParameter,
                                                           $arguments,
                                                           $argumentsClass);
            }
        }

        return $parameters;
    }
119202
protected function getLabelFromRecordData(array $data)
    {
        $label = Arrays::getValueByPath($data, $this->labelDataKey);
        if ($label === null) {
            throw new \Exception('Could not determine label from record data (key: ' . $this->labelDataKey . '). See ' . self::class . ' for more information.', 1462968958372);
        }
        return (string)$label;
    }
931352
protected function convertParameterReflectionToArray(ParameterReflection $parameter, MethodReflection $method = null)
    {
        $parameterInformation = [
            self::DATA_PARAMETER_POSITION => $parameter->getPosition()
        ];
        if ($parameter->isPassedByReference()) {
            $parameterInformation[self::DATA_PARAMETER_BY_REFERENCE] = true;
        }
        if ($parameter->isArray()) {
            $parameterInformation[self::DATA_PARAMETER_ARRAY] = true;
        }
        if ($parameter->isOptional()) {
            $parameterInformation[self::DATA_PARAMETER_OPTIONAL] = true;
        }
        if ($parameter->allowsNull()) {
            $parameterInformation[self::DATA_PARAMETER_ALLOWS_NULL] = true;
        }

        $parameterClass = $parameter->getClass();
        if ($parameterClass !== null) {
            $parameterInformation[self::DATA_PARAMETER_CLASS] = $parameterClass->getName();
        }
        if ($parameter->isOptional() && $parameter->isDefaultValueAvailable()) {
            $parameterInformation[self::DATA_PARAMETER_DEFAULT_VALUE] = $parameter->getDefaultValue();
        }
        if ($method !== null) {
            $paramAnnotations = $method->isTaggedWith('param') ? $method->getTagValues('param') : [];
            if (isset($paramAnnotations[$parameter->getPosition()])) {
                $explodedParameters = explode(' ', $paramAnnotations[$parameter->getPosition()]);
                if (count($explodedParameters) >= 2) {
                    $parameterType = $this->expandType($method->getDeclaringClass(), $explodedParameters[0]);
                    $parameterInformation[self::DATA_PARAMETER_TYPE] = $this->cleanClassName($parameterType);
                }
            }
            if (!$parameter->isArray()) {
                $builtinType = $parameter->getBuiltinType();
                if ($builtinType !== null) {
                    $parameterInformation[self::DATA_PARAMETER_TYPE] = $builtinType;
                    $parameterInformation[self::DATA_PARAMETER_SCALAR_DECLARATION] = true;
                }
            }
        }
        if (!isset($parameterInformation[self::DATA_PARAMETER_TYPE]) && $parameterClass !== null) {
            $parameterInformation[self::DATA_PARAMETER_TYPE] = $this->cleanClassName($parameterClass->getName());
        } elseif (!isset($parameterInformation[self::DATA_PARAMETER_TYPE])) {
            $parameterInformation[self::DATA_PARAMETER_TYPE] = $parameter->isArray() ? 'array' : 'mixed';
        }

        return $parameterInformation;
    }
488327
protected function getValidationLabelsForElements(array $labels = [])
    {
        $this->getElements()->onlyActive()->each(function ($element) use (&$labels) {
            $element = $this->getElementContainer($element);

            if ($element instanceof Validable) {
                $labels += $element->getValidationLabels();
            }
        });

        return $labels;
    }
494236
protected function resolveArguments(
        ContainerInterface $container,
        \ReflectionMethod $method,
        array $parameters
    ) {
        try {
            //Getting set of arguments should be sent to requested method
            return $container->get(ResolverInterface::class)->resolveArguments(
                $method,
                $parameters
            );
        } catch (ArgumentException $e) {
            throw new ControllerException(
                "Missing/invalid parameter '{$e->getParameter()->name}'",
                ControllerException::BAD_ARGUMENT
            );
        } catch (ContainerExceptionInterface $e) {
            throw new ControllerException($e->getMessage(), ControllerException::ERROR, $e);
        }
    }
828975
public function resolveMethodDependencies(array $parameters, ReflectionFunctionAbstract $reflector)
	{
		foreach ($reflector->getParameters() as $key => $parameter)
		{
			// If the parameter has a type-hinted class, we will check to see if it is already in
			// the list of parameters. If it is we will just skip it as it is probably a model
			// binding and we do not want to mess with those; otherwise, we resolve it here.
			$class = $parameter->getClass();

			if ($class && ! $this->alreadyInParameters($class->name, $parameters))
			{
				array_splice(
					$parameters, $key, 0, [$this->container->make($class->name)]
				);
			}
		}

		return $parameters;
	}
310012
protected function getParameter(\ReflectionParameter $parameter)
    {
        if ($parameter->isOptional()) {
            return $parameter->getDefaultValue();
        }

        $type = (string)$parameter->getType();
        return $this->get($type);
    }
253685
protected static function addLabel(InputInterface $input, array $data)
    {
        if (!isset($data['label'])) {
            return;
        }
        if (is_string($data['label'])) {
            $input->setLabel($data['label']);
            return;
        }

        $label = new Label('', $data['label']['value']);
        self::populateElement($label, $data['label']);
        $input->setLabel($label);
    }