示例#1
0
 public function testRealize()
 {
     $this->property->setVisibility('private')->setStatic(true);
     $this->assertEquals('private static $prop', $this->realizer->realize($this->property));
     $this->property->setDefaultValue('default');
     $this->assertEquals('private static $prop = mockedDefValue', $this->realizer->realize($this->property), 'Realization with sting default value');
 }
示例#2
0
 /**
  * @param \ReflectionProperty $property
  * @return Property
  */
 public function property(\ReflectionProperty $property)
 {
     $phpyProperty = new Property($property->getName());
     $phpyProperty->setStatic($property->isStatic());
     $refClass = $property->getDeclaringClass();
     $defClassValues = $refClass->getDefaultProperties();
     if (isset($defClassValues[$property->getName()])) {
         $phpyProperty->setDefaultValue($defClassValues[$property->getName()]);
     }
     if ($property->isPublic()) {
         $phpyProperty->setVisibility('public');
     } elseif ($property->isProtected()) {
         $phpyProperty->setVisibility('protected');
     } else {
         $phpyProperty->setVisibility('private');
     }
     return $phpyProperty;
 }
示例#3
0
 public function testAfterRemovingDefaultValueHasDefaultValueReturnsFalse()
 {
     $this->property->setDefaultValue('xxx')->removeDefaultValue();
     $this->assertFalse($this->property->hasDefaultValue());
 }
示例#4
0
 /**
  * Add a property to the class
  *
  * @param Property $property
  * @throws \InvalidArgumentException
  * @return MetaClass The current instance
  */
 public function addProperty(Property $property)
 {
     if ($this->hasProperty($property->getName())) {
         throw new \InvalidArgumentException('Class already has a property named ' . $property->getName());
     }
     $this->properties[] = $property;
     return $this;
 }
示例#5
0
 /**
  * Returns the string of property modifiers
  *
  * @param Property $property
  * @return string
  */
 private function getModifiersString(Property $property)
 {
     $modifiers = array();
     $modifiers[] = $property->getVisibility();
     if ($property->isStatic()) {
         $modifiers[] = 'static';
     }
     return implode(' ', $modifiers);
 }