/** * Resolves the list of extension dependencies from the messages that were * stored using {@see ExtensionDependencyResolver}. * * @return array A list of extension dependencies. */ public static function getDependencies() { // Collect all of the extension names that we received $dependencies = array_map(function ($entry) { return strtolower($entry['message']); }, DependencyCollector::read()); // Remove all duplicates $dependencies = array_values(array_unique($dependencies)); // Resolve the dependency chain $resolver = new ExtensionDependencyResolver($dependencies); return $resolver->resolve(); }
/** * Retrieve the properties for the class. * * @return array A list of properties. */ public function getMethods() { $rclass_methods = $this->class->getMethods(); // Add methods and parameters $rclass_methods = array_values(array_filter($rclass_methods, function ($rmethod) { if ($exclusions = ConfigStore::get('source.exclude.methods')) { return !preg_match($exclusions, $rmethod->getName()); } return true; })); foreach ($rclass_methods as $rmethod) { $documentThis = true; if (!isset($this->methods['count'])) { $this->methods['count'] = count($rclass_methods); } if (!isset($this->methods['method'])) { $this->methods['method'] = array(); } $rmethod = InheritdocHandler::resolve($rmethod); $_tags = new TagHandler($rmethod->getDocComment(), $this->ancestry); $method_docblock = new DocBlock($rmethod->getDocComment()); $entry = array(); $entry['name'] = $rmethod->getName(); $entry['visibility'] = $this->methodAccess($rmethod); if ($extension = $rmethod->getExtensionName()) { $entry['extension'] = $extension; DependencyCollector::add($extension); } if ($rmethod->getFileName()) { $entry['path'] = str_replace(array(VANITY_SYSTEM . '/', VANITY_PROJECT_WORKING_DIR . '/'), '', $rmethod->getFileName()); $entry['lines'] = array('start' => $rmethod->getStartLine(), 'end' => $rmethod->getEndLine()); if ($viewsource = ConfigStore::get('source.viewsource')) { $entry['viewsource'] = str_replace(array('%PATH%', '%LINE%'), array($entry['path'], $entry['lines']['start']), $viewsource); } } if ($description = $_tags->getDescription()) { $entry['description'] = $description; } // Method inheritance if (($declaring_class = $rmethod->getDeclaringClass()->getName()) !== $this->class->getName()) { if (!isset($entry['inheritance'])) { $entry['inheritance'] = array(); } if (!isset($entry['inheritance']['class'])) { $entry['inheritance']['class'] = array(); } $declaring_class = new ReflectionClass($declaring_class); $subentry = array(); $subentry['name'] = $declaring_class->getName(); if ($declaring_class->getFileName()) { $subentry['path'] = str_replace(VANITY_PROJECT_WORKING_DIR . '/', '', $declaring_class->getFileName()); } $entry['inheritance']['class'][] = $subentry; } // Method tags if (count($method_docblock->getTags())) { if (!isset($entry['metadata'])) { $entry['metadata'] = array(); } if (!isset($entry['metadata']['tag'])) { $entry['metadata']['tag'] = array(); } foreach ($method_docblock->getTags() as $rtag) { $dtag = new Tag($rtag, $this->ancestry); $tagData = $dtag->determine()->process(ConfigStore::get('source.resolve_aliases')); if ($tagData['name'] === 'alias') { SystemStore::add('alias.' . $tagData['entity'], $this->class->getName() . '::' . $rmethod->getName()); $documentThis = false; } $entry['metadata']['tag'][] = $tagData; } } // Method parameters if ($count = count($rmethod->getParameters())) { if (!isset($entry['parameters'])) { $entry['parameters'] = array(); } if (!isset($entry['parameters']['count'])) { $entry['parameters']['count'] = $count; } if (!isset($entry['parameters']['parameter'])) { $entry['parameters']['parameter'] = array(); } foreach ($rmethod->getParameters() as $rparameter) { $tag_finder = new TagFinder($entry); $param = array(); $param['name'] = $rparameter->getName(); $param['required'] = !$rparameter->isOptional(); $param['passed_by_reference'] = $rparameter->isPassedByReference(); if ($rparameter->isDefaultValueAvailable()) { $param['default'] = $rparameter->getDefaultValue(); } // Pull-in from @tags if ($_description = $tag_finder->find('description', $param['name'])) { $param['description'] = $_description; } if ($_type = $tag_finder->find('type', $param['name'])) { $param['type'] = $this->ancestry->resolveNamespace($_type); } if ($_types = $tag_finder->find('types', $param['name'])) { $param['types'] = $_types; } // Clean-up parameter metadata tags if (isset($entry['metadata']) && isset($entry['metadata']['tag'])) { foreach ($entry['metadata']['tag'] as $index => $tag) { if ($tag['name'] === 'param' && $tag['variable'] === $param['name']) { unset($entry['metadata']['tag'][$index]); } } } // Type hinting trumps docblock if ($rparameter->getClass()) { if (isset($param['type']) && $param['type'] !== $rparameter->getClass()->getName()) { // @todo: Resolve namespace of declaring class. Inconsistency::add($this->class->getName() . '::' . $rmethod->getName() . '($' . $rparameter->getName() . ') [' . $param['type'] . ' => ' . $rparameter->getClass()->getName() . ']'); } $param['type'] = $rparameter->getClass()->getName(); if (isset($param['types'])) { unset($param['types']); } } $entry['parameters']['parameter'][] = $param; } } // Return value $entry['return'] = array('type' => 'void'); if (isset($entry['metadata']) && isset($entry['metadata']['tag'])) { foreach ($entry['metadata']['tag'] as $index => $tag) { if ($tag['name'] === 'return') { $entry['return'] = $tag; unset($entry['return']['name']); // Clean-up return metadata tags unset($entry['metadata']['tag'][$index]); } } } if ($documentThis) { $this->methods['method'][] = $entry; } } return $this->methods; }