Beispiel #1
0
 public function testProperty()
 {
     $class = new ReflectionClass(__NAMESPACE__ . '\\TestClass');
     $gClass = GClass::reflectorFactory($class);
     $prop1 = GProperty::reflectorFactory($class->getProperty('prop1'), $gClass);
     $this->assertEquals(TRUE, $prop1->hasDefaultValue(), 'hasDefaultValue');
     $this->assertEquals('prop1', $prop1->getName());
     $this->assertEquals('banane', $prop1->getDefaultValue());
     $this->assertEquals(TRUE, $prop1->isProtected());
     $this->assertEquals("protected \$prop1 = 'banane'", $prop1->php());
     $prop2 = GProperty::reflectorFactory($class->getProperty('prop2'), $gClass);
     //$this->assertEquals(FALSE, $prop2->hasDefaultValue(), 'hasDefaultValue'); // php bug? hier gibt reflection TRUE als isDefault aus
     $this->assertEquals('prop2', $prop2->getName());
     $this->assertEquals(FALSE, $prop2->isProtected());
     $this->assertEquals(TRUE, $prop2->isPublic());
     $this->assertEquals(TRUE, $prop2->isStatic());
     $this->assertEquals("public static \$prop2", $prop2->php());
 }
Beispiel #2
0
 public function elevate(Reflector $reflector)
 {
     $this->reflector = $reflector;
     /* Values erst elevaten damit der namespace + name korrekt ist für equals bei declaring class */
     $this->defaultProperties = $this->reflector->getDefaultProperties();
     $this->elevateValues('modifiers', 'startLine', 'endLine', array('srcFileName', 'getFileName'), array('name', 'getShortName'), 'interfaces');
     $this->setNamespace($this->reflector->getNamespaceName());
     /* ClassDocBlock */
     $this->elevateDocBlock($this->reflector);
     foreach ($this->reflector->getMethods() as $rMethod) {
         try {
             $gMethod = GMethod::reflectorFactory($rMethod);
         } catch (ReflectionException $e) {
             // das ist nicht die von php
             $e->appendMessage("\n" . 'Methode in: ' . $this->getFQN());
             throw $e;
         }
         if ($gMethod->getDeclaringClass() instanceof GClassReference && $gMethod->getDeclaringClass()->equals($this)) {
             $gMethod->setDeclaringClass($this);
             // replace Reference
             // source weitergeben
             $gMethod->setSrcFileName($this->srcFileName);
         }
         $this->methods[$gMethod->getName()] = $gMethod;
         $this->methodsOrder[] = $gMethod->getName();
     }
     foreach ($this->reflector->getProperties() as $rProperty) {
         $gProperty = GProperty::reflectorFactory($rProperty, $this);
         if ($gProperty->getDeclaringClass() instanceof GClassReference && $gProperty->getDeclaringClass()->equals($this)) {
             $gProperty->setDeclaringClass($this);
             // replace Reference
         }
         // nicht addProperty nehmen das würde declaringClass falsch setzen
         $this->properties[$gProperty->getName()] = $gProperty;
     }
     /* Interfaces */
     foreach ($this->interfaces as $name => $interface) {
         $this->interfaces[$name] = new GClass($interface);
     }
     /* Constants */
     foreach ($this->reflector->getConstants() as $name => $value) {
         $constant = new GClassConstant($name, $this, $value);
         $this->constants[$constant->getName()] = $constant;
     }
     /* Static Properties */
     //@TODO
     if ($this->reflector->getParentClass() != NULL) {
         $this->parentClass = new GClass($this->reflector->getParentClass());
     }
     $this->elevated = TRUE;
     return $this;
 }