Beispiel #1
0
 /**
  * @param ConstantReflection $constant
  *
  * @return string
  */
 public static function getConstantSource($constant)
 {
     $map = $constant->toArray();
     $lineNo = $map['line'];
     $filePath = $constant->getClass()->getFile();
     $sourceLines = file($filePath, FILE_IGNORE_NEW_LINES);
     $line = $sourceLines[$lineNo - 1];
     $pattern = '/' . preg_quote($map['name']) . '\\s*=(\\s*.*)/';
     if (!preg_match($pattern, $line, $matches)) {
         return '';
     }
     return $matches[1];
 }
 public static function fromArray(Project $project, $array)
 {
     $class = new self($array['name'], $array['line']);
     $class->shortDesc = $array['short_desc'];
     $class->longDesc = $array['long_desc'];
     $class->hint = $array['hint'];
     $class->tags = $array['tags'];
     $class->namespace = $array['namespace'];
     $class->hash = $array['hash'];
     $class->file = $array['file'];
     $class->relativeFilePath = $array['relative_file'];
     $class->modifiers = $array['modifiers'];
     if ($array['is_interface']) {
         $class->setInterface(true);
     }
     if ($array['is_trait']) {
         $class->setTrait(true);
     }
     $class->aliases = $array['aliases'];
     $class->errors = $array['errors'];
     $class->parent = $array['parent'];
     $class->interfaces = $array['interfaces'];
     $class->constants = $array['constants'];
     $class->traits = $array['traits'];
     $class->setProject($project);
     foreach ($array['methods'] as $method) {
         $method = MethodReflection::fromArray($project, $method);
         $method->setClass($class);
         $class->addMethod($method);
     }
     foreach ($array['properties'] as $property) {
         $property = PropertyReflection::fromArray($project, $property);
         $property->setClass($class);
         $class->addProperty($property);
     }
     foreach ($array['constants'] as $constant) {
         $constant = ConstantReflection::fromArray($project, $constant);
         $constant->setClass($class);
         $class->addConstant($constant);
     }
     return $class;
 }
 public function addConstant(ConstantReflection $constant)
 {
     $this->constants[$constant->getName()] = $constant;
     $constant->setClass($this);
 }