src/Eloquent/Typhoon/Generator/ParameterListMerge/MergeTool.php
public function merge(
        RuntimeConfiguration $configuration,
        ClassDefinition $classDefinition = null,
        MethodDefinition $methodDefinition,
        ParameterList $documentedParameterList,
        ParameterList $nativeParameterList
    ) {
        $this->typeCheck->merge(func_get_args());

        $documentedParameters = $documentedParameterList->parameters();
        $nativeParameters = $nativeParameterList->parameters();

        $parameters = array();
        foreach ($nativeParameters as $index => $nativeParameter) {
            if (array_key_exists($index, $documentedParameters)) {
                $parameters[] = $this->mergeParameter(
                    $configuration,
                    $classDefinition,
                    $methodDefinition,
                    $documentedParameters[$index],
                    $nativeParameter
                );
            } else {
                $this->handleError(new UndocumentedParameter(
                    $classDefinition,
                    $methodDefinition,
                    $nativeParameter->name()
                ));

                $parameters[] = $nativeParameter;
            }
        }

        $documentedParameterCount = count($documentedParameters);
        $nativeParameterCount = count($nativeParameters);

        $isVariableLength = false;
        if ($documentedParameterList->isVariableLength()) {
            if ($documentedParameterCount > $nativeParameterCount + 1) {
                $this->handleError(new DocumentedParameterUndefined(
                    $classDefinition,
                    $methodDefinition,
                    $documentedParameters[$nativeParameterCount + 1]->name()
                ));
            } elseif ($documentedParameterCount === $nativeParameterCount) {
                $this->handleError(new DefinedParameterVariableLength(
                    $classDefinition,
                    $methodDefinition,
                    $nativeParameters[$nativeParameterCount - 1]->name()
                ));
            } elseif ($documentedParameterCount === $nativeParameterCount + 1) {
                $isVariableLength = true;
                $parameters[] = $documentedParameters[$nativeParameterCount];
            }
        } elseif ($documentedParameterCount > $nativeParameterCount) {
            for ($i = $nativeParameterCount; $i < $documentedParameterCount; $i ++) {
                $this->handleError(new DocumentedParameterUndefined(
                    $classDefinition,
                    $methodDefinition,
                    $documentedParameters[$i]->name()
                ));
            }
        }

        return new ParameterList($parameters, $isVariableLength);
    }
public function merge(
        RuntimeConfiguration $configuration,
        ClassDefinition $classDefinition = null,
        MethodDefinition $methodDefinition,
        ParameterList $documentedParameterList,
        ParameterList $nativeParameterList
    ) {
        $this->typeCheck->merge(func_get_args());

        $documentedParameters = $documentedParameterList->parameters();
        $nativeParameters = $nativeParameterList->parameters();

        $parameters = array();
        foreach ($nativeParameters as $index => $nativeParameter) {
            if (array_key_exists($index, $documentedParameters)) {
                $parameters[] = $this->mergeParameter(
                    $configuration,
                    $classDefinition,
                    $methodDefinition,
                    $documentedParameters[$index],
                    $nativeParameter
                );
            } else {
                $this->handleError(new UndocumentedParameter(
                    $classDefinition,
                    $methodDefinition,
                    $nativeParameter->name()
                ));

                $parameters[] = $nativeParameter;
            }
        }

        $documentedParameterCount = count($documentedParameters);
        $nativeParameterCount = count($nativeParameters);

        $isVariableLength = false;
        if ($documentedParameterList->isVariableLength()) {
            if ($documentedParameterCount > $nativeParameterCount + 1) {
                $this->handleError(new DocumentedParameterUndefined(
                    $classDefinition,
                    $methodDefinition,
                    $documentedParameters[$nativeParameterCount + 1]->name()
                ));
            } elseif ($documentedParameterCount === $nativeParameterCount) {
                $this->handleError(new DefinedParameterVariableLength(
                    $classDefinition,
                    $methodDefinition,
                    $nativeParameters[$nativeParameterCount - 1]->name()
                ));
            } elseif ($documentedParameterCount === $nativeParameterCount + 1) {
                $isVariableLength = true;
                $parameters[] = $documentedParameters[$nativeParameterCount];
            }
        } elseif ($documentedParameterCount > $nativeParameterCount) {
            for ($i = $nativeParameterCount; $i < $documentedParameterCount; $i ++) {
                $this->handleError(new DocumentedParameterUndefined(
                    $classDefinition,
                    $methodDefinition,
                    $documentedParameters[$i]->name()
                ));
            }
        }

        return new ParameterList($parameters, $isVariableLength);
    }
public function merge ( RuntimeConfiguration $ configuration , ClassDefinition $ classDefinition = null , MethodDefinition $ methodDefinition , ParameterList $ documentedParameterList , ParameterList $ nativeParameterList ) { $ this -> typeCheck -> merge ( func_get_args ( ) ) ; $ documentedParameters = $ documentedParameterList -> parameters ( ) ; $ nativeParameters = $ nativeParameterList -> parameters ( ) ; $ parameters = array ( ) ; foreach ( $ nativeParameters as $ index => $ nativeParameter ) { if ( array_key_exists ( $ index , $ documentedParameters ) ) { $ parameters [ ] = $ this -> mergeParameter ( $ configuration , $ classDefinition , $ methodDefinition , $ documentedParameters [ $ index ] , $ nativeParameter ) ; } else { $ this -> handleError ( new UndocumentedParameter ( $ classDefinition , $ methodDefinition , $ nativeParameter -> name ( ) ) ) ; $ parameters [ ] = $ nativeParameter ; } } $ documentedParameterCount = count ( $ documentedParameters ) ; $ nativeParameterCount = count ( $ nativeParameters ) ; $ isVariableLength = false ; if ( $ documentedParameterList -> isVariableLength ( ) ) { if ( $ documentedParameterCount > $ nativeParameterCount + 1 ) { $ this -> handleError ( new DocumentedParameterUndefined ( $ classDefinition , $ methodDefinition , $ documentedParameters [ $ nativeParameterCount + 1 ] -> name ( ) ) ) ; } elseif ( $ documentedParameterCount === $ nativeParameterCount ) { $ this -> handleError ( new DefinedParameterVariableLength ( $ classDefinition , $ methodDefinition , $ nativeParameters [ $ nativeParameterCount - 1 ] -> name ( ) ) ) ; } elseif ( $ documentedParameterCount === $ nativeParameterCount + 1 ) { $ isVariableLength = true ; $ parameters [ ] = $ documentedParameters [ $ nativeParameterCount ] ; } } elseif ( $ documentedParameterCount > $ nativeParameterCount ) { for ( $ i = $ nativeParameterCount ; $ i < $ documentedParameterCount ; $ i ++ ) { $ this -> handleError ( new DocumentedParameterUndefined ( $ classDefinition , $ methodDefinition , $ documentedParameters [ $ i ] -> name ( ) ) ) ; } } return new ParameterList ( $ parameters , $ isVariableLength ) ; }
@param RuntimeConfiguration $configuration
@param ClassDefinition|null $classDefinition
@param MethodDefinition     $methodDefinition
@param ParameterList        $documentedParameterList
@param ParameterList        $nativeParameterList

@return ParameterList
@param RuntimeConfiguration $configuration @param ClassDefinition|null $classDefinition @param MethodDefinition $methodDefinition @param ParameterList $documentedParameterList @param ParameterList $nativeParameterList