src/Eloquent/Typhoon/Generator/FacadeGenerator.php
protected function generateDefineValidatorMethod(
        RuntimeConfiguration $configuration
    ) {
        $this->typeCheck->generateDefineValidatorMethod(func_get_args());

        $classNameIdentifier = new Identifier('className');
        $classNameVariable = new Variable($classNameIdentifier);
        $classGeneratorIdentifier = new Identifier('classGenerator');
        $classGeneratorVariable = new Variable($classGeneratorIdentifier);
        $classGeneratorClassIdentifier = QualifiedIdentifier::fromString(
            '\Eloquent\Typhoon\Generator\ValidatorClassGenerator'
        );

        $method = new ConcreteMethod(
            new Identifier('defineValidator'),
            AccessModifier::PROTECTED_(),
            true
        );
        $method->addParameter(new Parameter($classNameIdentifier));
        $classGeneratorParameter = new Parameter(
            $classGeneratorIdentifier,
            new ObjectTypeHint($classGeneratorClassIdentifier)
        );
        $classGeneratorParameter->setDefaultValue(new Literal(null));
        $method->addParameter($classGeneratorParameter);

        $nullClassGeneratorIf = new IfStatement(new StrictEquals(
            new Literal(null),
            $classGeneratorVariable
        ));
        $nullClassGeneratorIf->trueBranch()->add(new ExpressionStatement(
            new Assign(
                $classGeneratorVariable,
                new NewOperator($classGeneratorClassIdentifier)
            )
        ));
        $method->statementBlock()->add($nullClassGeneratorIf);

        $evalCall = new Call(QualifiedIdentifier::fromString('eval'));
        $generateFromClassCall = new Call(new Member(
            $classGeneratorVariable,
            new Constant(new Identifier('generateFromClass'))
        ));
        $generateFromClassCall->add(new Call(new StaticMember(
            new Constant(new Identifier('static')),
            new Constant(new Identifier('configuration'))
        )));
        $newReflectorCall = new Call(
            QualifiedIdentifier::fromString('\ReflectionClass')
        );
        $newReflectorCall->add($classNameVariable);
        $newReflector = new NewOperator($newReflectorCall);
        $generateFromClassCall->add($newReflector);
        $evalCall->add(new Concat(
            new Literal('?>'),
            $generateFromClassCall
        ));
        $method->statementBlock()->add(new ExpressionStatement($evalCall));

        return $method;
    }
protected function generateDefineValidatorMethod(
        RuntimeConfiguration $configuration
    ) {
        $this->typeCheck->generateDefineValidatorMethod(func_get_args());

        $classNameIdentifier = new Identifier('className');
        $classNameVariable = new Variable($classNameIdentifier);
        $classGeneratorIdentifier = new Identifier('classGenerator');
        $classGeneratorVariable = new Variable($classGeneratorIdentifier);
        $classGeneratorClassIdentifier = QualifiedIdentifier::fromString(
            '\Eloquent\Typhoon\Generator\ValidatorClassGenerator'
        );

        $method = new ConcreteMethod(
            new Identifier('defineValidator'),
            AccessModifier::PROTECTED_(),
            true
        );
        $method->addParameter(new Parameter($classNameIdentifier));
        $classGeneratorParameter = new Parameter(
            $classGeneratorIdentifier,
            new ObjectTypeHint($classGeneratorClassIdentifier)
        );
        $classGeneratorParameter->setDefaultValue(new Literal(null));
        $method->addParameter($classGeneratorParameter);

        $nullClassGeneratorIf = new IfStatement(new StrictEquals(
            new Literal(null),
            $classGeneratorVariable
        ));
        $nullClassGeneratorIf->trueBranch()->add(new ExpressionStatement(
            new Assign(
                $classGeneratorVariable,
                new NewOperator($classGeneratorClassIdentifier)
            )
        ));
        $method->statementBlock()->add($nullClassGeneratorIf);

        $evalCall = new Call(QualifiedIdentifier::fromString('eval'));
        $generateFromClassCall = new Call(new Member(
            $classGeneratorVariable,
            new Constant(new Identifier('generateFromClass'))
        ));
        $generateFromClassCall->add(new Call(new StaticMember(
            new Constant(new Identifier('static')),
            new Constant(new Identifier('configuration'))
        )));
        $newReflectorCall = new Call(
            QualifiedIdentifier::fromString('\ReflectionClass')
        );
        $newReflectorCall->add($classNameVariable);
        $newReflector = new NewOperator($newReflectorCall);
        $generateFromClassCall->add($newReflector);
        $evalCall->add(new Concat(
            new Literal('?>'),
            $generateFromClassCall
        ));
        $method->statementBlock()->add(new ExpressionStatement($evalCall));

        return $method;
    }
protected function generateDefineValidatorMethod ( RuntimeConfiguration $ configuration ) { $ this -> typeCheck -> generateDefineValidatorMethod ( func_get_args ( ) ) ; $ classNameIdentifier = new Identifier ( 'className' ) ; $ classNameVariable = new Variable ( $ classNameIdentifier ) ; $ classGeneratorIdentifier = new Identifier ( 'classGenerator' ) ; $ classGeneratorVariable = new Variable ( $ classGeneratorIdentifier ) ; $ classGeneratorClassIdentifier = QualifiedIdentifier :: fromString ( '\Eloquent\Typhoon\Generator\ValidatorClassGenerator' ) ; $ method = new ConcreteMethod ( new Identifier ( 'defineValidator' ) , AccessModifier :: PROTECTED_ ( ) , true ) ; $ method -> addParameter ( new Parameter ( $ classNameIdentifier ) ) ; $ classGeneratorParameter = new Parameter ( $ classGeneratorIdentifier , new ObjectTypeHint ( $ classGeneratorClassIdentifier ) ) ; $ classGeneratorParameter -> setDefaultValue ( new Literal ( null ) ) ; $ method -> addParameter ( $ classGeneratorParameter ) ; $ nullClassGeneratorIf = new IfStatement ( new StrictEquals ( new Literal ( null ) , $ classGeneratorVariable ) ) ; $ nullClassGeneratorIf -> trueBranch ( ) -> add ( new ExpressionStatement ( new Assign ( $ classGeneratorVariable , new NewOperator ( $ classGeneratorClassIdentifier ) ) ) ) ; $ method -> statementBlock ( ) -> add ( $ nullClassGeneratorIf ) ; $ evalCall = new Call ( QualifiedIdentifier :: fromString ( 'eval' ) ) ; $ generateFromClassCall = new Call ( new Member ( $ classGeneratorVariable , new Constant ( new Identifier ( 'generateFromClass' ) ) ) ) ; $ generateFromClassCall -> add ( new Call ( new StaticMember ( new Constant ( new Identifier ( 'static' ) ) , new Constant ( new Identifier ( 'configuration' ) ) ) ) ) ; $ newReflectorCall = new Call ( QualifiedIdentifier :: fromString ( '\ReflectionClass' ) ) ; $ newReflectorCall -> add ( $ classNameVariable ) ; $ newReflector = new NewOperator ( $ newReflectorCall ) ; $ generateFromClassCall -> add ( $ newReflector ) ; $ evalCall -> add ( new Concat ( new Literal ( '?>' ) , $ generateFromClassCall ) ) ; $ method -> statementBlock ( ) -> add ( new ExpressionStatement ( $ evalCall ) ) ; return $ method ; }
@param RuntimeConfiguration $configuration

@return ConcreteMethod
@param RuntimeConfiguration $configuration