public function parse($contents) { if (strpos($contents, '$messages') === false) { // This happens for some core languages that only have a fallback. return array(); } $php = $this->cleanupFile($contents); $reader = new QuickArrayReader("<?php {$php}"); $messages = $reader->getVar('messages'); if ($this->code) { return array($this->code => $messages); } // Assuming that the array is keyed by language codes return $messages; }
/** * @param $php * @param $varname * @return bool|array */ public static function parsePHP($php, $varname) { try { $reader = new QuickArrayReader("<?php {$php}"); return $reader->getVar($varname); } catch (Exception $e) { self::myLog("Failed to read file: " . $e); return false; } }
function quickTokenExtractArray($php, $varname) { $reader = new QuickArrayReader("<?php {$php}"); return $reader->getVar($varname); }