From e162d94e14114601db77d5ae8943b43c1cbf88ac Mon Sep 17 00:00:00 2001 From: Nicolas MURE Date: Tue, 14 Nov 2017 13:44:23 +0100 Subject: [PATCH] cleanup --- src/Index/AbstractAggregateIndex.php | 12 ------ src/Index/Index.php | 62 +--------------------------- 2 files changed, 1 insertion(+), 73 deletions(-) diff --git a/src/Index/AbstractAggregateIndex.php b/src/Index/AbstractAggregateIndex.php index 8c88659..1998889 100644 --- a/src/Index/AbstractAggregateIndex.php +++ b/src/Index/AbstractAggregateIndex.php @@ -107,10 +107,6 @@ abstract class AbstractAggregateIndex implements ReadableIndex public function getDefinitions(): \Generator { foreach ($this->getIndexes() as $index) { - // foreach ($index->getDefinitions() as $fqn => $definition) { - // yield $fqn => $definition; - // } - yield from $index->getDefinitions(); } } @@ -124,10 +120,6 @@ abstract class AbstractAggregateIndex implements ReadableIndex public function getDefinitionsForFqn(string $fqn): \Generator { foreach ($this->getIndexes() as $index) { - // foreach ($index->getDefinitionsForFqn($fqn) as $symbolFqn => $definition) { - // yield $symbolFqn => $definition; - // } - yield from $index->getDefinitionsForFqn($fqn); } } @@ -157,10 +149,6 @@ abstract class AbstractAggregateIndex implements ReadableIndex public function getReferenceUris(string $fqn): \Generator { foreach ($this->getIndexes() as $index) { - // foreach ($index->getReferenceUris($fqn) as $uri) { - // yield $uri; - // } - yield from $index->getReferenceUris($fqn); } } diff --git a/src/Index/Index.php b/src/Index/Index.php index 4566383..a2927bd 100644 --- a/src/Index/Index.php +++ b/src/Index/Index.php @@ -103,12 +103,6 @@ class Index implements ReadableIndex, \Serializable */ public function getDefinitions(): \Generator { - // foreach ($this->fqnDefinitions as $fqnDefinition) { - // foreach ($fqnDefinition as $fqn => $definition) { - // yield $fqn => $definition; - // } - // } - yield from $this->yieldDefinitionsRecursively($this->definitions); } @@ -120,14 +114,10 @@ class Index implements ReadableIndex, \Serializable */ public function getDefinitionsForFqn(string $fqn): \Generator { - // foreach ($this->fqnDefinitions[$fqn] ?? [] as $symbolFqn => $definition) { - // yield $symbolFqn => $definition; - // } - $parts = $this->splitFqn($fqn); if ('' === end($parts)) { // we want to return all the definitions in the given FQN, not only - // the one matching exactly the FQN. + // the one (non member) matching exactly the FQN. array_pop($parts); } @@ -149,19 +139,6 @@ class Index implements ReadableIndex, \Serializable */ public function getDefinition(string $fqn, bool $globalFallback = false) { - // $namespacedFqn = $this->extractNamespacedFqn($fqn); - // $definitions = $this->fqnDefinitions[$namespacedFqn] ?? []; - - // if (isset($definitions[$fqn])) { - // return $definitions[$fqn]; - // } - - // if ($globalFallback) { - // $parts = explode('\\', $fqn); - // $fqn = end($parts); - // return $this->getDefinition($fqn); - // } - $parts = $this->splitFqn($fqn); $result = $this->getIndexValue($parts, $this->definitions); @@ -175,11 +152,6 @@ class Index implements ReadableIndex, \Serializable return $this->getDefinition($fqn); } - - // return $result instanceof Definition - // ? $result - // : null - // ; } /** @@ -191,13 +163,6 @@ class Index implements ReadableIndex, \Serializable */ public function setDefinition(string $fqn, Definition $definition) { - // $namespacedFqn = $this->extractNamespacedFqn($fqn); - // if (!isset($this->fqnDefinitions[$namespacedFqn])) { - // $this->fqnDefinitions[$namespacedFqn] = []; - // } - - // $this->fqnDefinitions[$namespacedFqn][$fqn] = $definition; - $parts = $this->splitFqn($fqn); $this->indexDefinition(0, $parts, $this->definitions, $definition); @@ -213,17 +178,7 @@ class Index implements ReadableIndex, \Serializable */ public function removeDefinition(string $fqn) { - // $namespacedFqn = $this->extractNamespacedFqn($fqn); - // if (isset($this->fqnDefinitions[$namespacedFqn])) { - // unset($this->fqnDefinitions[$namespacedFqn][$fqn]); - - // if (empty($this->fqnDefinitions[$namespacedFqn])) { - // unset($this->fqnDefinitions[$namespacedFqn]); - // } - // } - $parts = $this->splitFqn($fqn); - $this->removeIndexedDefinition(0, $parts, $this->definitions); unset($this->references[$fqn]); @@ -324,21 +279,6 @@ class Index implements ReadableIndex, \Serializable ]); } - /** - * @param string $fqn The symbol FQN - * @return string The namespaced FQN extracted from the given symbol FQN - */ - // private function extractNamespacedFqn(string $fqn): string - // { - // foreach (['::', '->'] as $operator) { - // if (false !== ($pos = strpos($fqn, $operator))) { - // return substr($fqn, 0, $pos); - // } - // } - - // return $fqn; - // } - /** * Returns a Genrerator containing all the into the given $storage recursively. * The generator yields key => value pairs, eg