/** * @param array $structure */ private function dumpStructureRecursively(array $structure) { $isFirst = true; $precededByMessage = false; foreach ($structure as $k => $v) { if ($isMessage = $v instanceof Message) { $desc = $v->getDesc(); $meaning = $v->getMeaning(); if (!$isFirst && (!$precededByMessage || $desc || $meaning)) { $this->writer->write("\n"); } if ($desc) { $desc = str_replace(array("\r\n", "\n", "\r", "\t"), array('\\r\\n', '\\n', '\\r', '\\t'), $desc); $this->writer->writeln('# Desc: ' . $desc); } if ($meaning) { $this->writer->writeln('# Meaning: ' . $meaning); } } elseif (!$isFirst) { $this->writer->write("\n"); } $isFirst = false; $precededByMessage = $isMessage; $this->writer->write(Inline::dump($k) . ':'); if ($isMessage) { $this->writer->write(' ' . Inline::dump($v->getLocaleString())); if ($v->isNew()) { $this->writer->write(' # FIXME'); } $this->writer->write("\n"); continue; } $this->writer->write("\n")->indent(); $this->dumpStructureRecursively($v); $this->writer->outdent(); } }
/** * @param array $structure */ private function dumpStructureRecursively(array $structure) { $isFirst = true; $precededByMessage = false; foreach ($structure as $k => $v) { if ($isMessage = $v instanceof Message) { $desc = $v->getDesc(); $meaning = $v->getMeaning(); if (!$isFirst && (!$precededByMessage || $desc || $meaning)) { $this->writer->write("\n"); } if ($desc) { $this->writer->writeln('// Desc: ' . $desc); } if ($meaning) { $this->writer->writeln('// Meaning: ' . $meaning); } } elseif (!$isFirst) { $this->writer->write("\n"); } $isFirst = false; $precededByMessage = $isMessage; $this->writer->write(var_export($k, true) . ' => '); if ($isMessage) { $this->writer->write(var_export($v->getLocaleString(), true) . ','); if ($v->isNew()) { $this->writer->write(' // FIXME'); } $this->writer->write("\n"); continue; } $this->writer->write("array(\n")->indent(); $this->dumpStructureRecursively($v); $this->writer->outdent()->writeln('),'); } }