Chris@0: cleaner = $cleaner; Chris@0: } Chris@0: Chris@0: /** Chris@0: * If this is a standalone namespace line, remember it for later. Chris@0: * Chris@0: * Otherwise, apply remembered namespaces to the code until a new namespace Chris@0: * is encountered. Chris@0: * Chris@0: * @param array $nodes Chris@0: */ Chris@0: public function beforeTraverse(array $nodes) Chris@0: { Chris@0: if (empty($nodes)) { Chris@0: return $nodes; Chris@0: } Chris@0: Chris@0: $last = end($nodes); Chris@0: if (!$last instanceof Namespace_) { Chris@0: return $this->namespace ? array(new Namespace_($this->namespace, $nodes)) : $nodes; Chris@0: } Chris@0: Chris@0: $this->setNamespace($last->name); Chris@0: Chris@0: return $nodes; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Remember the namespace and (re)set the namespace on the CodeCleaner as Chris@0: * well. Chris@0: * Chris@0: * @param null|Name $namespace Chris@0: */ Chris@0: private function setNamespace($namespace) Chris@0: { Chris@0: $this->namespace = $namespace; Chris@0: $this->cleaner->setNamespace($namespace === null ? null : $namespace->parts); Chris@0: } Chris@0: }