diff options
Diffstat (limited to 'MLEB/Translate/ffs/AmdFFS.php')
-rw-r--r-- | MLEB/Translate/ffs/AmdFFS.php | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/MLEB/Translate/ffs/AmdFFS.php b/MLEB/Translate/ffs/AmdFFS.php index d6caa9fc..bd759e8f 100644 --- a/MLEB/Translate/ffs/AmdFFS.php +++ b/MLEB/Translate/ffs/AmdFFS.php @@ -17,7 +17,7 @@ * "key2": "anothervalue" * }); * - * It also supports the the top-level bundle with a root construction and language indicators. + * It also supports the top-level bundle with a root construction and language indicators. * The following example will give the same messages as above: * define({ * "root": { @@ -34,7 +34,7 @@ * @file * @author Matthias Palmér * @copyright Copyright © 2011-2015, MetaSolutions AB - * @license GPL-2.0+ + * @license GPL-2.0-or-later */ /** @@ -51,23 +51,23 @@ class AmdFFS extends SimpleFFS { * @return bool */ public static function isValid( $data ) { - $data = AmdFFS::extractMessagePart( $data ); - return is_array( FormatJSON::decode( $data, /*as array*/true ) ); + $data = self::extractMessagePart( $data ); + return is_array( FormatJson::decode( $data, /*as array*/true ) ); } public function getFileExtensions() { - return array( '.js' ); + return [ '.js' ]; } /** - * @param array $data + * @param string $data * @return array Parsed data. */ public function readFromVariable( $data ) { - $authors = AmdFFS::extractAuthors( $data ); - $data = AmdFFS::extractMessagePart( $data ); - $messages = (array) FormatJSON::decode( $data, /*as array*/true ); - $metadata = array(); + $authors = self::extractAuthors( $data ); + $data = self::extractMessagePart( $data ); + $messages = (array)FormatJson::decode( $data, /*as array*/true ); + $metadata = []; // Take care of regular language bundles, as well as the root bundle. if ( isset( $messages['root'] ) ) { @@ -76,11 +76,11 @@ class AmdFFS extends SimpleFFS { $messages = $this->group->getMangler()->mangle( $messages ); } - return array( + return [ 'MESSAGES' => $messages, 'AUTHORS' => $authors, 'METADATA' => $metadata, - ); + ]; } /** @@ -88,12 +88,10 @@ class AmdFFS extends SimpleFFS { * @return string */ protected function writeReal( MessageCollection $collection ) { - $messages = array(); - $template = $this->read( $collection->getLanguage() ); - + $messages = []; $mangler = $this->group->getMangler(); - /// @var $m ThinMessage + /** @var ThinMessage $m */ foreach ( $collection as $key => $m ) { $value = $m->translation(); if ( $value === null ) { @@ -113,7 +111,7 @@ class AmdFFS extends SimpleFFS { return ''; } $header = $this->header( $collection->code, $collection->getAuthors() ); - return $header . FormatJSON::encode( $messages, "\t", FormatJson::UTF8_OK ) . ");\n"; + return $header . FormatJson::encode( $messages, "\t", FormatJson::UTF8_OK ) . ");\n"; } /** @@ -161,15 +159,15 @@ EOT; } /** - * @param array $authors + * @param string[] $authors * @return string */ private function authorsList( array $authors ) { - if ( count( $authors ) === 0 ) { + if ( $authors === [] ) { return ''; } - $prefix = " * - "; + $prefix = ' * - '; $authorList = implode( "\n$prefix", $authors ); return " * Translators:\n$prefix$authorList"; } |