public function acceptMethod(MethodReflection $method) { if ($method->isPrivate()) { return false; } if ($method->isProtected() && !$this->hasApiTag($method)) { return false; } if ($this->shouldBeIgnored($method)) { return false; } if ($this->hasApiTag($method)) { return true; } if ($this->hasApiTag($method->getClass())) { return true; } return false; }
/** * Adds a new method to the class using an array of tokens * * @param ClassReflection $class Class reflection * @param string $methodTag Method tag contents * * @return bool */ protected function injectMethod(ClassReflection $class, $methodTag) { $data = $this->parseMethod($methodTag); // Bail if the method format is invalid if (!$data) { return false; } $method = new MethodReflection($data['name'], $class->getLine()); $method->setDocComment($data['description']); $method->setShortDesc($data['description']); if ($data['hint']) { $method->setHint(array(array($data['hint'], null))); } // Add arguments to the method foreach ($data['args'] as $name => $arg) { $param = new ParameterReflection($name, $class->getLine()); if (!empty($arg['hint'])) { $param->setHint(array(array($arg['hint'], null))); } if (!empty($arg['default'])) { $param->setDefault($arg['default']); } $method->addParameter($param); } $class->addMethod($method); return true; }
public function pathForMethod(array $context, MethodReflection $method) { return $this->relativeUri($this->currentDepth) . str_replace('\\', '/', $method->getClass()->getName()) . '.html#method_' . $method->getName(); }
protected function updateMethodParametersFromTags(MethodReflection $method, array $tags) { // bypass if there is no @param tags defined (@param tags are optional) if (!count($tags)) { return array(); } if (count($method->getParameters()) != count($tags)) { return array(sprintf('"%d" @param tags are defined by "%d" are expected', count($tags), count($method->getParameters()))); } $errors = array(); foreach (array_keys($method->getParameters()) as $i => $name) { if ($tags[$i][1] && $tags[$i][1] != $name) { $errors[] = sprintf('The "%s" @param tag variable name is wrong (should be "%s")', $tags[$i][1], $name); } } if ($errors) { return $errors; } foreach ($tags as $i => $tag) { $parameter = $method->getParameter($tag[1] ? $tag[1] : $i); $parameter->setShortDesc($tag[2]); if (!$parameter->hasHint()) { $parameter->setHint($this->resolveHint($tag[0])); } } return array(); }
public function acceptMethod(MethodReflection $method) { return $method->isPublic(); }
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 addMethod(MethodReflection $method) { $this->methods[$method->getName()] = $method; $method->setClass($this); }
public function testSetGetModifiers() { $method = new MethodReflection('foo', 0); $method->setModifiers(0); $this->assertTrue($method->isPublic()); $method->setModifiers(MethodReflection::MODIFIER_PUBLIC); $this->assertTrue($method->isPublic()); $method->setModifiers(MethodReflection::MODIFIER_PROTECTED); $this->assertTrue($method->isProtected()); $method->setModifiers(MethodReflection::MODIFIER_PRIVATE); $this->assertTrue($method->isPrivate()); $method->setModifiers(MethodReflection::MODIFIER_ABSTRACT); $this->assertTrue($method->isPublic()); $this->assertTrue($method->isAbstract()); }
public function acceptMethod(MethodReflection $method) { return !$method->isPrivate(); }