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'); }
/** * @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; }
public function testAfterRemovingDefaultValueHasDefaultValueReturnsFalse() { $this->property->setDefaultValue('xxx')->removeDefaultValue(); $this->assertFalse($this->property->hasDefaultValue()); }
/** * 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; }
/** * 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); }