/** * @param RuntimeConfiguration $configuration * @param null &$className * * @return SyntaxTree */ public function generateSyntaxTree(RuntimeConfiguration $configuration, &$className = null) { $this->typeCheck->generateSyntaxTree(func_get_args()); $className = $configuration->validatorNamespace()->joinAtoms('Exception', 'UnexpectedArgumentValueException'); $classDefinition = new ClassDefinition(new Identifier($className->shortName()->string()), ClassModifier::FINAL_()); $classDefinition->setParentName(QualifiedIdentifier::fromString('UnexpectedInputException')); $classDefinition->add($this->generateConstructor($configuration)); $classDefinition->add($this->generateParameterNameMethod()); $classDefinition->add($this->generateIndexMethod()); $classDefinition->add($this->generateValueMethod()); $classDefinition->add($this->generateExpectedTypeMethod()); $classDefinition->add($this->generateTypeInspectorMethod()); $classDefinition->add($this->generateUnexpectedTypeMethod()); $classDefinition->add(new Property(new Identifier('parameterName'), AccessModifier::PRIVATE_())); $classDefinition->add(new Property(new Identifier('index'), AccessModifier::PRIVATE_())); $classDefinition->add(new Property(new Identifier('value'), AccessModifier::PRIVATE_())); $classDefinition->add(new Property(new Identifier('expectedValue'), AccessModifier::PRIVATE_())); $classDefinition->add(new Property(new Identifier('typeInspector'), AccessModifier::PRIVATE_())); $classDefinition->add(new Property(new Identifier('unexpectedValue'), AccessModifier::PRIVATE_())); $primaryBlock = new PhpBlock(); $primaryBlock->add(new NamespaceStatement(QualifiedIdentifier::fromString($className->parent()->toRelative()->string()))); $primaryBlock->add($classDefinition); $syntaxTree = new SyntaxTree(); $syntaxTree->add($primaryBlock); return $syntaxTree; }
/** * @param RuntimeConfiguration $configuration * @param null &$className * * @return SyntaxTree */ public function generateSyntaxTree(RuntimeConfiguration $configuration, &$className = null) { $this->typeCheck->generateSyntaxTree(func_get_args()); $className = $configuration->validatorNamespace()->joinAtoms('Exception', 'UnexpectedInputException'); $classDefinition = new ClassDefinition(new Identifier($className->shortName()->string()), ClassModifier::ABSTRACT_()); $classDefinition->setParentName(QualifiedIdentifier::fromString('\\InvalidArgumentException')); $classDefinition->add($this->generateConstructor()); $primaryBlock = new PhpBlock(); $primaryBlock->add(new NamespaceStatement(QualifiedIdentifier::fromString($className->parent()->toRelative()->string()))); $primaryBlock->add($classDefinition); $syntaxTree = new SyntaxTree(); $syntaxTree->add($primaryBlock); return $syntaxTree; }
/** * @param RuntimeConfiguration $configuration * @param null &$className * * @return SyntaxTree */ public function generateSyntaxTree(RuntimeConfiguration $configuration, &$className = null) { $this->typeCheck->generateSyntaxTree(func_get_args()); $className = $configuration->validatorNamespace()->joinAtoms('AbstractValidator'); $classDefinition = new ClassDefinition(new Identifier($className->shortName()->string()), ClassModifier::ABSTRACT_()); $classDefinition->add($this->generateConstructor()); $classDefinition->add($this->generateCallMethod()); $classDefinition->add(new Property(new Identifier('reflector'))); $primaryBlock = new PhpBlock(); $primaryBlock->add(new NamespaceStatement(QualifiedIdentifier::fromString($className->parent()->toRelative()->string()))); $primaryBlock->add($classDefinition); $syntaxTree = new SyntaxTree(); $syntaxTree->add($primaryBlock); return $syntaxTree; }
/** * @param RuntimeConfiguration $configuration * @param null &$className * * @return SyntaxTree */ public function generateSyntaxTree(RuntimeConfiguration $configuration, &$className = null) { $this->typeCheck->generateSyntaxTree(func_get_args()); $className = $configuration->validatorNamespace()->joinAtoms('TypeCheck'); $classDefinition = new ClassDefinition(new Identifier($className->shortName()->string()), ClassModifier::ABSTRACT_()); $classDefinition->add($this->generateGetMethod()); $classDefinition->add($this->generateInstallMethod()); $classDefinition->add($this->generateSetRuntimeGenerationMethod()); $classDefinition->add($this->generateRuntimeGenerationMethod()); $classDefinition->add($this->generateCreateValidatorMethod($configuration)); $classDefinition->add($this->generateDefineValidatorMethod($configuration)); $classDefinition->add($this->generateConfigurationMethod($configuration)); $instancesProperty = new Property(new Identifier('instances'), AccessModifier::PRIVATE_(), true); $instancesProperty->setDefaultValue(new ArrayLiteral()); $classDefinition->add($instancesProperty); $dummyModeProperty = new Property(new Identifier('dummyMode'), AccessModifier::PRIVATE_(), true); $dummyModeProperty->setDefaultValue(new Literal(false)); $classDefinition->add($dummyModeProperty); $runtimeGenerationProperty = new Property(new Identifier('runtimeGeneration'), AccessModifier::PRIVATE_(), true); $runtimeGenerationProperty->setDefaultValue(new Literal(false)); $classDefinition->add($runtimeGenerationProperty); $primaryBlock = new PhpBlock(); $primaryBlock->add(new NamespaceStatement(QualifiedIdentifier::fromString($className->parent()->toRelative()->string()))); $primaryBlock->add($classDefinition); $syntaxTree = new SyntaxTree(); $syntaxTree->add($primaryBlock); return $syntaxTree; }