src/Eloquent/Typhoon/Generator/ParameterListGenerator.php
public function visitParameter(Parameter $parameter)
    {
        $this->typeCheck->visitParameter(func_get_args());

        $typeExpression = $parameter->type()->accept($this->typeGenerator());
        if (null === $typeExpression) {
            return array();
        }

        $expressions = array();
        if ($typeExpression instanceof Closure) {
            $checkVariable = new Variable(new Identifier('check'));
            $expressions[] = new ExpressionStatement(new Assign(
                $checkVariable,
                $typeExpression
            ));
            $conditionExpression = new Call($checkVariable);
            $conditionExpression->add($this->argumentExpression);
        } else {
            $conditionExpression = $typeExpression;
        }

        $newExceptionCall = new Call(QualifiedIdentifier::fromString(
            $this->validatorNamespace()->joinAtoms(
                'Exception',
                'UnexpectedArgumentValueException'
            )->string()
        ));
        $newExceptionCall->add(new Literal($parameter->name()));
        $newExceptionCall->add($this->indexExpression);
        $newExceptionCall->add($this->argumentExpression);
        $newExceptionCall->add(new Literal(
            $this->renderTypeName($parameter->type())
        ));
        $ifStatement = new IfStatement(new LogicalNot($conditionExpression));
        $ifStatement->trueBranch()->add(
            new ThrowStatement(new NewOperator($newExceptionCall))
        );
        $expressions[] = $ifStatement;

        return $expressions;
    }
public function visitParameter(Parameter $parameter)
    {
        $this->typeCheck->visitParameter(func_get_args());

        $typeExpression = $parameter->type()->accept($this->typeGenerator());
        if (null === $typeExpression) {
            return array();
        }

        $expressions = array();
        if ($typeExpression instanceof Closure) {
            $checkVariable = new Variable(new Identifier('check'));
            $expressions[] = new ExpressionStatement(new Assign(
                $checkVariable,
                $typeExpression
            ));
            $conditionExpression = new Call($checkVariable);
            $conditionExpression->add($this->argumentExpression);
        } else {
            $conditionExpression = $typeExpression;
        }

        $newExceptionCall = new Call(QualifiedIdentifier::fromString(
            $this->validatorNamespace()->joinAtoms(
                'Exception',
                'UnexpectedArgumentValueException'
            )->string()
        ));
        $newExceptionCall->add(new Literal($parameter->name()));
        $newExceptionCall->add($this->indexExpression);
        $newExceptionCall->add($this->argumentExpression);
        $newExceptionCall->add(new Literal(
            $this->renderTypeName($parameter->type())
        ));
        $ifStatement = new IfStatement(new LogicalNot($conditionExpression));
        $ifStatement->trueBranch()->add(
            new ThrowStatement(new NewOperator($newExceptionCall))
        );
        $expressions[] = $ifStatement;

        return $expressions;
    }
@param Parameter $parameter

@return array<integer,IStatement>