public function testWriteNamespacedClassType()
    {
        $propertyMock = $this->getPropertyMock();
        $propertyMock->expects($this->atLeastOnce())->method('getDocComment')->will($this->returnValue('/**
 * @var \\Flagbit\\TestClass
 */'));
        $this->assertStringEndsWith(": Flagbit.TestClass\n", $this->propertyWriter->writeElement($propertyMock));
    }
Пример #2
0
 /**
  * @param \TokenReflection\IReflectionClass $class
  *
  * @return string
  */
 public function writeElement(IReflectionClass $class)
 {
     $classString = $this->formatLine($this->writeAbstract($class) . $this->writeObjectType($class) . ' ' . $this->formatClassName($class->getName()) . ' {');
     if ($this->constantWriter) {
         $constantReflections = $class->getOwnConstantReflections();
         foreach ($class->getConstantReflections() as $otherConstantReflection) {
             /* @var $otherConstantReflection \TokenReflection\ReflectionConstant */
             $otherConstantName = $otherConstantReflection->getName();
             foreach ($constantReflections as $constantReflection) {
                 if ($constantReflection->getName() === $otherConstantName) {
                     // skip constants already defined in our current class
                     continue 2;
                 }
             }
             $constantReflections[] = $otherConstantReflection;
         }
         $classString .= $this->constantWriter->writeElements($constantReflections);
     }
     if ($this->propertyWriter) {
         $classString .= $this->propertyWriter->writeElements($class->getOwnProperties());
         if ($this->docContentWriter) {
             $classString .= $this->docContentWriter->writeProperties($class);
         }
     }
     if ($this->methodWriter) {
         $classString .= $this->methodWriter->writeElements($class->getOwnMethods());
         if ($this->docContentWriter) {
             $classString .= $this->docContentWriter->writeMethods($class);
         }
     }
     $classString .= $this->formatLine('}');
     if ($class->getParentClassName()) {
         $classString .= $this->formatLine($this->writeObjectType($class) . ' ' . $this->formatClassName($class->getName()) . ' extends ' . $this->formatClassName($class->getParentClassName()));
     }
     if ($interfaceNames = $class->getOwnInterfaceNames()) {
         foreach ($interfaceNames as $interfaceName) {
             $classString .= $this->formatLine($this->writeObjectType($class) . ' ' . $this->formatClassName($class->getName()) . ' implements ' . $this->formatClassName($interfaceName));
         }
     }
     return $classString;
 }