public function traverse(Project $project) { // parent classes/interfaces are visited before their "children" $classes = $project->getProjectClasses(); $modified = array(); while ($class = array_shift($classes)) { // re-push the class at the end if parent class/interfaces have not been visited yet if (($parent = $class->getParent()) && isset($classes[$parent->getName()])) { $classes[$class->getName()] = $class; continue; } foreach ($class->getInterfaces() as $interface) { if (isset($classes[$interface->getName()])) { $classes[$class->getName()] = $class; continue 2; } } $isModified = false; foreach ($this->visitors as $visitor) { $isModified = $visitor->visit($class) || $isModified; } if ($isModified) { $modified[] = $class; } } return $modified; }
public function __construct(Project $project) { $this->hashes = array(); $this->classes = array(); foreach ($project->getProjectClasses() as $class) { $this->addClass($class); } $this->visited = array(); $this->modified = array(); }
public function getIndex(Project $project) { $index = array('searchIndex' => array(), 'info' => array()); foreach ($project->getNamespaces() as $namespace) { $index['searchIndex'][] = $this->getSearchString($namespace); $index['info'][] = array(self::TYPE_NAMESPACE, $namespace); } foreach ($project->getProjectClasses() as $class) { $index['searchIndex'][] = $this->getSearchString((string) $class); $index['info'][] = array(self::TYPE_CLASS, $class); } foreach ($project->getProjectClasses() as $class) { foreach ($class->getMethods() as $method) { $index['searchIndex'][] = $this->getSearchString((string) $method); $index['info'][] = array(self::TYPE_METHOD, $method); } } return $index; }
public function __construct(Project $project = null) { $this->classes = array(); if (null !== $project) { foreach ($project->getProjectClasses() as $class) { $this->classes[$class->getName()] = $class->getHash(); } } $this->versions = array(); if (null !== $project) { foreach ($project->getVersions() as $version) { $this->versions[] = (string) $version; } } $this->namespaces = array(); if (null !== $project) { $this->namespaces = $project->getConfig('simulate_namespaces') ? $project->getSimulatedNamespaces() : $project->getNamespaces(); } }
public function traverse(Project $project) { // parent classes/interfaces are visited before their "children" $classes = $project->getProjectClasses(); $modified = new \SplObjectStorage(); while ($class = array_shift($classes)) { // re-push the class at the end if parent class/interfaces have not been visited yet if (($parent = $class->getParent()) && isset($classes[$parent->getName()])) { $classes[$class->getName()] = $class; continue; } foreach ($interfaces = $class->getInterfaces() as $interface) { if (isset($classes[$interface->getName()])) { $classes[$class->getName()] = $class; continue 2; } } // only visits classes not coming from the cache // and for which parent/interfaces also come from the cache $visit = !$class->isFromCache() || $parent && !$parent->isFromCache(); foreach ($interfaces as $interface) { if (!$interface->isFromCache()) { $visit = true; break; } } if (!$visit) { continue; } $isModified = false; foreach ($this->visitors as $visitor) { $isModified = $visitor->visit($class) || $isModified; } if ($isModified) { $modified->attach($class); } } return $modified; }
protected function getIndex(Project $project) { $items = array(); foreach ($project->getProjectClasses() as $class) { $letter = strtoupper(substr($class->getShortName(), 0, 1)); $items[$letter][] = array('class', $class); foreach ($class->getProperties() as $property) { $letter = strtoupper(substr($property->getName(), 0, 1)); $items[$letter][] = array('property', $property); } foreach ($class->getMethods() as $method) { $letter = strtoupper(substr($method->getName(), 0, 1)); $items[$letter][] = array('method', $method); } } ksort($items); return $items; }
/** * Get all classes in the project. * * @return array */ public function getClasses() { $this->parse(); return $this->project->getProjectClasses(); }