diff options
Diffstat (limited to 'www/wiki/extensions/Translate/ffs/FlatPhpFFS.php')
-rw-r--r-- | www/wiki/extensions/Translate/ffs/FlatPhpFFS.php | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/www/wiki/extensions/Translate/ffs/FlatPhpFFS.php b/www/wiki/extensions/Translate/ffs/FlatPhpFFS.php index 4ede4b50..830b437b 100644 --- a/www/wiki/extensions/Translate/ffs/FlatPhpFFS.php +++ b/www/wiki/extensions/Translate/ffs/FlatPhpFFS.php @@ -6,7 +6,7 @@ * @author Niklas Laxström * @author Siebrand Mazeland * @copyright Copyright © 2008-2010, Niklas Laxström, Siebrand Mazeland - * @license GPL-2.0+ + * @license GPL-2.0-or-later */ /** @@ -15,49 +15,45 @@ */ class FlatPhpFFS extends SimpleFFS implements MetaYamlSchemaExtender { public function getFileExtensions() { - return array( '.php' ); + return [ '.php' ]; } - // READ - /** * @param string $data * @return array Parsed data. */ public function readFromVariable( $data ) { # Authors first - $matches = array(); + $matches = []; preg_match_all( '/^ \* @author\s+(.+)$/m', $data, $matches ); $authors = $matches[1]; # Then messages - $matches = array(); + $matches = []; $regex = '/^\$(.*?)\s*=\s*[\'"](.*?)[\'"];.*?$/mus'; preg_match_all( $regex, $data, $matches, PREG_SET_ORDER ); - $messages = array(); + $messages = []; foreach ( $matches as $_ ) { $legal = Title::legalChars(); $key = preg_replace_callback( "/([^$legal]|\\\\)/u", - function( $m ) { + function ( $m ) { return '\x' . dechex( ord( $m[0] ) ); }, $_[1] ); - $value = str_replace( array( "\'", "\\\\" ), array( "'", "\\" ), $_[2] ); + $value = str_replace( [ "\'", "\\\\" ], [ "'", "\\" ], $_[2] ); $messages[$key] = $value; } $messages = $this->group->getMangler()->mangle( $messages ); - return array( + return [ 'AUTHORS' => $authors, 'MESSAGES' => $messages, - ); + ]; } - // WRITE - protected function writeReal( MessageCollection $collection ) { if ( isset( $this->extra['header'] ) ) { $output = $this->extra['header']; @@ -135,21 +131,21 @@ PHP; } public static function getExtraSchema() { - $schema = array( - 'root' => array( + $schema = [ + 'root' => [ '_type' => 'array', - '_children' => array( - 'FILES' => array( + '_children' => [ + 'FILES' => [ '_type' => 'array', - '_children' => array( - 'header' => array( + '_children' => [ + 'header' => [ '_type' => 'text', - ), - ) - ) - ) - ) - ); + ], + ] + ] + ] + ] + ]; return $schema; } |