@@ -15,7 +15,7 @@ class Index implements ReadableIndex, \Serializable
1515 use EmitterTrait;
1616
1717 /**
18- * An associative array that maps namespaces to
18+ * An associative array that maps fully qualified names to
1919 * an associative array that maps fully qualified symbol names
2020 * to global Definitions, e.g. :
2121 * [
@@ -27,7 +27,7 @@ class Index implements ReadableIndex, \Serializable
2727 *
2828 * @var array
2929 */
30- private $ namespaceDefinitions = [];
30+ private $ fqnDefinitions = [];
3131
3232 /**
3333 * An associative array that maps fully qualified symbol names
@@ -108,8 +108,8 @@ public function isStaticComplete(): bool
108108 */
109109 public function getDefinitions (): \Generator
110110 {
111- foreach ($ this ->namespaceDefinitions as $ namespaceDefinition ) {
112- foreach ($ namespaceDefinition as $ fqn => $ definition ) {
111+ foreach ($ this ->fqnDefinitions as $ fqnDefinition ) {
112+ foreach ($ fqnDefinition as $ fqn => $ definition ) {
113113 yield $ fqn => $ definition ;
114114 }
115115 }
@@ -129,15 +129,15 @@ public function getGlobalDefinitions(): \Generator
129129 }
130130
131131 /**
132- * Returns a Generator providing the Definitions that are in the given namespace
132+ * Returns a Generator providing the Definitions that are in the given FQN
133133 *
134- * @param string $namespace
134+ * @param string $fqn
135135 * @return \Generator providing Definitions[]
136136 */
137- public function getDefinitionsForNamespace (string $ namespace ): \Generator
137+ public function getDefinitionsForFqn (string $ fqn ): \Generator
138138 {
139- foreach ($ this ->namespaceDefinitions [ $ namespace ] ?? [] as $ fqn => $ definition ) {
140- yield $ fqn => $ definition ;
139+ foreach ($ this ->fqnDefinitions [ $ fqn ] ?? [] as $ symbolFqn => $ definition ) {
140+ yield $ symbolFqn => $ definition ;
141141 }
142142 }
143143
@@ -150,8 +150,8 @@ public function getDefinitionsForNamespace(string $namespace): \Generator
150150 */
151151 public function getDefinition (string $ fqn , bool $ globalFallback = false )
152152 {
153- $ namespace = $ this ->extractNamespace ($ fqn );
154- $ definitions = $ this ->namespaceDefinitions [ $ namespace ] ?? [];
153+ $ namespacedFqn = $ this ->extractNamespacedFqn ($ fqn );
154+ $ definitions = $ this ->fqnDefinitions [ $ namespacedFqn ] ?? [];
155155
156156 if (isset ($ definitions [$ fqn ])) {
157157 return $ definitions [$ fqn ];
@@ -173,12 +173,12 @@ public function getDefinition(string $fqn, bool $globalFallback = false)
173173 */
174174 public function setDefinition (string $ fqn , Definition $ definition )
175175 {
176- $ namespace = $ this ->extractNamespace ($ fqn );
177- if (!isset ($ this ->namespaceDefinitions [ $ namespace ])) {
178- $ this ->namespaceDefinitions [ $ namespace ] = [];
176+ $ namespacedFqn = $ this ->extractNamespacedFqn ($ fqn );
177+ if (!isset ($ this ->fqnDefinitions [ $ namespacedFqn ])) {
178+ $ this ->fqnDefinitions [ $ namespacedFqn ] = [];
179179 }
180180
181- $ this ->namespaceDefinitions [ $ namespace ][$ fqn ] = $ definition ;
181+ $ this ->fqnDefinitions [ $ namespacedFqn ][$ fqn ] = $ definition ;
182182 $ this ->setGlobalDefinition ($ fqn , $ definition );
183183 $ this ->emit ('definition-added ' );
184184 }
@@ -192,12 +192,12 @@ public function setDefinition(string $fqn, Definition $definition)
192192 */
193193 public function removeDefinition (string $ fqn )
194194 {
195- $ namespace = $ this ->extractNamespace ($ fqn );
196- if (isset ($ this ->namespaceDefinitions [ $ namespace ])) {
197- unset($ this ->namespaceDefinitions [ $ namespace ][$ fqn ]);
195+ $ namespacedFqn = $ this ->extractNamespacedFqn ($ fqn );
196+ if (isset ($ this ->fqnDefinitions [ $ namespacedFqn ])) {
197+ unset($ this ->fqnDefinitions [ $ namespacedFqn ][$ fqn ]);
198198
199- if (empty ($ this ->namespaceDefinitions [ $ namespace ])) {
200- unset($ this ->namespaceDefinitions [ $ namespace ]);
199+ if (empty ($ this ->fqnDefinitions [ $ namespacedFqn ])) {
200+ unset($ this ->fqnDefinitions [ $ namespacedFqn ]);
201201 }
202202 }
203203
@@ -277,8 +277,8 @@ public function unserialize($serialized)
277277 $ this ->$ prop = $ val ;
278278 }
279279
280- foreach ($ this ->namespaceDefinitions as $ namespaceDefinition ) {
281- foreach ($ namespaceDefinition as $ fqn => $ definition ) {
280+ foreach ($ this ->fqnDefinitions as $ fqnDefinition ) {
281+ foreach ($ fqnDefinition as $ fqn => $ definition ) {
282282 $ this ->setGlobalDefinition ($ fqn , $ definition );
283283 }
284284 }
@@ -291,7 +291,7 @@ public function unserialize($serialized)
291291 public function serialize ()
292292 {
293293 return serialize ([
294- 'namespaceDefinitions ' => $ this ->namespaceDefinitions ,
294+ 'fqnDefinitions ' => $ this ->fqnDefinitions ,
295295 'references ' => $ this ->references ,
296296 'complete ' => $ this ->complete ,
297297 'staticComplete ' => $ this ->staticComplete
@@ -313,10 +313,10 @@ private function setGlobalDefinition(string $fqn, Definition $definition)
313313 }
314314
315315 /**
316- * @param string $fqn
317- * @return string The namespace extracted from the given FQN
316+ * @param string $fqn The symbol FQN
317+ * @return string The namespaced FQN extracted from the given symbol FQN
318318 */
319- private function extractNamespace (string $ fqn ): string
319+ private function extractNamespacedFqn (string $ fqn ): string
320320 {
321321 foreach ([':: ' , '-> ' ] as $ operator ) {
322322 if (false !== ($ pos = strpos ($ fqn , $ operator ))) {
0 commit comments