Ejemplo n.º 1
0
 protected function handleSetter(Generator\ClassGenerator $generator, PHPProperty $prop, PHPClass $class)
 {
     $name = "set" . Inflector::classify($prop->getName());
     $type = $this->getPropertyType($prop);
     $namespace = explode("\\", $type);
     $namespaceClass = array_pop($namespace);
     $namespace = implode("\\", $namespace);
     if ($namespace == $class->getNamespace() || $namespace == "\\" . $class->getNamespace()) {
         $type = $namespaceClass;
     }
     if (substr($type, -2) == "[]") {
         $type = "array";
     }
     $fullName = "method {$class->getName()} {$name}({$type} \${$prop->getName()})";
     $docblock = $generator->getDocBlock();
     $docblock->setWordWrap(false);
     $tag = new Generator\DocBlock\Tag();
     $tag->setName($fullName);
     $docblock->setTag($tag);
     return;
 }
Ejemplo n.º 2
0
 private function handleProperty(Generator\ClassGenerator $class, PHPProperty $prop)
 {
     $generatedProp = new PropertyGenerator($prop->getName());
     $generatedProp->setVisibility(PropertyGenerator::VISIBILITY_PRIVATE);
     $class->addPropertyFromGenerator($generatedProp);
     if ($prop->getType() && (!$prop->getType()->getNamespace() && $prop->getType()->getName() == "array")) {
         // $generatedProp->setDefaultValue(array(), PropertyValueGenerator::TYPE_AUTO, PropertyValueGenerator::OUTPUT_SINGLE_LINE);
     }
     $docBlock = new DocBlockGenerator();
     $generatedProp->setDocBlock($docBlock);
     if ($prop->getDoc()) {
         $docBlock->setLongDescription($prop->getDoc());
     }
     $tag = new PropertyTag($prop->getName(), 'mixed');
     $type = $prop->getType();
     if ($type && $type instanceof PHPClassOf) {
         $tt = $type->getArg()->getType();
         $tag->setTypes($this->getPhpType($tt) . "[]");
         if ($p = $this->isOneType($tt)) {
             if ($t = $p->getType()) {
                 $tag->setTypes($this->getPhpType($t) . "[]");
             }
         }
     } elseif ($type) {
         if ($this->isNativeType($type)) {
             $tag->setTypes($this->getPhpType($type));
         } elseif (($p = $this->isOneType($type)) && ($t = $p->getType())) {
             $tag->setTypes($this->getPhpType($t));
         } else {
             $tag->setTypes($this->getPhpType($prop->getType()));
         }
     }
     $docBlock->setTag($tag);
 }