/**
  * @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('DummyValidator');
     $classDefinition = new ClassDefinition(new Identifier($className->shortName()->string()));
     $classDefinition->setParentName(QualifiedIdentifier::fromString('AbstractValidator'));
     $classDefinition->add($this->generateCallMethod());
     $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('Exception', 'MissingArgumentException');
     $classDefinition = new ClassDefinition(new Identifier($className->shortName()->string()), ClassModifier::FINAL_());
     $classDefinition->setParentName(QualifiedIdentifier::fromString('UnexpectedInputException'));
     $classDefinition->add($this->generateConstructor());
     $classDefinition->add($this->generateParameterNameMethod());
     $classDefinition->add($this->generateIndexMethod());
     $classDefinition->add($this->generateExpectedTypeMethod());
     $classDefinition->add(new Property(new Identifier('parameterName'), AccessModifier::PRIVATE_()));
     $classDefinition->add(new Property(new Identifier('index'), AccessModifier::PRIVATE_()));
     $classDefinition->add(new Property(new Identifier('expectedType'), 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('TypeInspector');
     $classDefinition = new ClassDefinition(new Identifier($className->shortName()->string()));
     $classDefinition->add($this->generateTypeMethod());
     $classDefinition->add($this->generateArrayTypeMethod());
     $classDefinition->add($this->generateObjectTypeMethod());
     $classDefinition->add($this->generateTraversableSubTypesMethod());
     $classDefinition->add($this->generateResourceTypeMethod());
     $classDefinition->add($this->generateStreamTypeMethod());
     $primaryBlock = new PhpBlock();
     $primaryBlock->add(new NamespaceStatement(QualifiedIdentifier::fromString($className->parent()->toRelative()->string())));
     $primaryBlock->add($classDefinition);
     $syntaxTree = new SyntaxTree();
     $syntaxTree->add($primaryBlock);
     return $syntaxTree;
 }
Exemple #5
0
 /**
  * @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;
 }