private function registerPredefinedClassTypes(SchemaInterface $expectedSchema)
 {
     $classType = new ClassType('Exception', '\\Exception');
     $classType->addProperty(new PropertyDefinition('message', new StringType()));
     $cause = new PropertyDefinition('cause', $classType, true);
     $cause->setTargetPropertyName('previous');
     $classType->addProperty($cause);
     $expectedSchema->registerType('Exception', $classType);
 }
 /**
  * @param PropertyOutline $property
  * @param ClassTypeImplementation $classOptions
  * @param ImplementationInterface $implementation
  *
  * @return PropertyDefinition
  */
 protected function createPropertyDefinition(PropertyOutline $property, ClassTypeImplementation $classOptions, ImplementationInterface $implementation)
 {
     $propertyType = $this->schemaLinker->generateType($property->getType(), $implementation);
     $propertyDefinition = new PropertyDefinition($property->getName(), $propertyType);
     $propertyImplementation = $classOptions->getImplementationForProperty($property->getName());
     $targetPropertyName = $propertyImplementation->getTargetPropertyName();
     if ($targetPropertyName) {
         $propertyDefinition->setTargetPropertyName($targetPropertyName);
     }
     // nullable
     $propertyDefinition->setIsNullable($property->isNullable());
     // default value
     if ($property->hasDefaultValue()) {
         $propertyDefinition->setDefaultValue($property->getDefaultValue());
     }
     // setters and getters
     $setter = $propertyImplementation->getSetter();
     if ($setter) {
         $propertyDefinition->setSetterName($setter);
     }
     $getter = $propertyImplementation->getGetter();
     if ($getter) {
         $propertyDefinition->setGetterName($getter);
     }
     return $propertyDefinition;
 }
 /**
  * @depends testSetDefaultValue
  */
 public function testRemovingDefaultValue()
 {
     $this->object->setDefaultValue('some');
     $this->assertMethodChaining($this->object->removeDefaultValue(), 'removeDefaultValue');
     $this->assertFalse($this->object->hasDefaultValue());
 }
Example #4
0
 /**
  * Adds property definition
  *
  * @param PropertyDefinition $property
  * @return self
  */
 public function addProperty(PropertyDefinition $property)
 {
     $this->properties[$property->getName()] = $property;
     return $this;
 }