Пример #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);
 }