Exemplo n.º 1
0
 public static function fromReflection(ZendL_Reflection_Class $reflectionClass)
 {
     $class = new self();
     $class->setSourceContent($class->getSourceContent());
     $class->setSourceDirty(false);
     if ($reflectionClass->getDocComment() != '') {
         $class->setDocblock(ZendL_Tool_CodeGenerator_Php_Docblock::fromReflection($reflectionClass->getDocblock()));
     }
     $class->setAbstract($reflectionClass->isAbstract());
     $class->setName($reflectionClass->getName());
     if ($parentClass = $reflectionClass->getParentClass()) {
         $class->setExtendedClass($parentClass->getName());
     }
     $class->setImplementedInterfaces($reflectionClass->getInterfaceNames());
     $properties = array();
     foreach ($reflectionClass->getProperties() as $reflectionProperty) {
         if ($reflectionProperty->getDeclaringClass()->getName() == $class->getName()) {
             $properties[] = ZendL_Tool_CodeGenerator_Php_Property::fromReflection($reflectionProperty);
         }
     }
     $class->setProperties($properties);
     $methods = array();
     foreach ($reflectionClass->getMethods() as $reflectionMethod) {
         if ($reflectionMethod->getDeclaringClass()->getName() == $class->getName()) {
             $methods[] = ZendL_Tool_CodeGenerator_Php_Method::fromReflection($reflectionMethod);
         }
     }
     $class->setMethods($methods);
     return $class;
 }
Exemplo n.º 2
0
    public function testDocblockContents()
    {
        $classReflection = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass5');
        $classDocblock = $classReflection->getDocblock();
        $expectedContents = <<<EOS
TestSampleClass5 Docblock Short Desc

This is a long description for 
the docblock of this class, it
should be longer than 3 lines.
It indeed is longer than 3 lines
now.

@author Ralph Schindler <*****@*****.**>

EOS;
        $this->assertEquals($classDocblock->getContents(), $expectedContents);
    }
Exemplo n.º 3
0
 public function testStartLine()
 {
     $reflectionClass = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass5');
     $this->assertEquals($reflectionClass->getStartLine(), 87);
     $this->assertEquals($reflectionClass->getStartLine(true), 76);
 }
Exemplo n.º 4
0
 public function testType()
 {
     $classReflection = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass5');
     $paramTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('return');
     $this->assertEquals($paramTag->getType(), 'mixed');
 }
Exemplo n.º 5
0
 public function testTagDescription()
 {
     $classReflection = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass5');
     $authorTag = $classReflection->getDocblock()->getTag('author');
     $this->assertEquals($authorTag->getDescription(), 'Ralph Schindler <*****@*****.**>');
 }
Exemplo n.º 6
0
 public function testVariableName()
 {
     $classReflection = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass5');
     $paramTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('param');
     $this->assertEquals($paramTag->getVariableName(), '$one');
 }