wp/wp-includes/pomo/mo.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
--- a/wp/wp-includes/pomo/mo.php	Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-includes/pomo/mo.php	Tue Dec 15 13:49:49 2020 +0100
@@ -7,8 +7,8 @@
  * @subpackage mo
  */
 
-require_once dirname( __FILE__ ) . '/translations.php';
-require_once dirname( __FILE__ ) . '/streams.php';
+require_once __DIR__ . '/translations.php';
+require_once __DIR__ . '/streams.php';
 
 if ( ! class_exists( 'MO', false ) ) :
 	class MO extends Gettext_Translations {
@@ -101,7 +101,7 @@
 			ksort( $entries );
 			$magic                     = 0x950412de;
 			$revision                  = 0;
-			$total                     = count( $entries ) + 1; // all the headers are one entry
+			$total                     = count( $entries ) + 1; // All the headers are one entry.
 			$originals_lenghts_addr    = 28;
 			$translations_lenghts_addr = $originals_lenghts_addr + 8 * $total;
 			$size_of_hash              = 0;
@@ -122,7 +122,7 @@
 			);
 			fseek( $fh, $originals_lenghts_addr );
 
-			// headers' msgid is an empty string
+			// Headers' msgid is an empty string.
 			fwrite( $fh, pack( 'VV', 0, $current_addr ) );
 			$current_addr++;
 			$originals_table = "\0";
@@ -133,7 +133,7 @@
 				$originals_table .= $this->export_original( $entry ) . "\0";
 				$length           = $reader->strlen( $this->export_original( $entry ) );
 				fwrite( $fh, pack( 'VV', $length, $current_addr ) );
-				$current_addr += $length + 1; // account for the NULL byte after
+				$current_addr += $length + 1; // Account for the NULL byte after.
 			}
 
 			$exported_headers = $this->export_headers();
@@ -158,7 +158,7 @@
 		 * @return string
 		 */
 		function export_original( $entry ) {
-			//TODO: warnings for control characters
+			// TODO: Warnings for control characters.
 			$exported = $entry->singular;
 			if ( $entry->is_plural ) {
 				$exported .= "\0" . $entry->plural;
@@ -174,7 +174,7 @@
 		 * @return string
 		 */
 		function export_translations( $entry ) {
-			//TODO: warnings for control characters
+			// TODO: Warnings for control characters.
 			return $entry->is_plural ? implode( "\0", $entry->translations ) : $entry->translations[0];
 		}
 
@@ -194,7 +194,7 @@
 		 * @return string|false
 		 */
 		function get_byteorder( $magic ) {
-			// The magic is 0x950412de
+			// The magic is 0x950412de.
 
 			// bug in PHP 5.0.2, see https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565
 			$magic_little    = (int) - 1794895138;
@@ -221,28 +221,28 @@
 			}
 			$reader->setEndian( $endian_string );
 
-			$endian = ( 'big' == $endian_string ) ? 'N' : 'V';
+			$endian = ( 'big' === $endian_string ) ? 'N' : 'V';
 
 			$header = $reader->read( 24 );
 			if ( $reader->strlen( $header ) != 24 ) {
 				return false;
 			}
 
-			// parse header
+			// Parse header.
 			$header = unpack( "{$endian}revision/{$endian}total/{$endian}originals_lenghts_addr/{$endian}translations_lenghts_addr/{$endian}hash_length/{$endian}hash_addr", $header );
 			if ( ! is_array( $header ) ) {
 				return false;
 			}
 
-			// support revision 0 of MO format specs, only
-			if ( $header['revision'] != 0 ) {
+			// Support revision 0 of MO format specs, only.
+			if ( 0 != $header['revision'] ) {
 				return false;
 			}
 
-			// seek to data blocks
+			// Seek to data blocks.
 			$reader->seekto( $header['originals_lenghts_addr'] );
 
-			// read originals' indices
+			// Read originals' indices.
 			$originals_lengths_length = $header['translations_lenghts_addr'] - $header['originals_lenghts_addr'];
 			if ( $originals_lengths_length != $header['total'] * 8 ) {
 				return false;
@@ -253,7 +253,7 @@
 				return false;
 			}
 
-			// read translations' indices
+			// Read translations' indices.
 			$translations_lenghts_length = $header['hash_addr'] - $header['translations_lenghts_addr'];
 			if ( $translations_lenghts_length != $header['total'] * 8 ) {
 				return false;
@@ -264,11 +264,11 @@
 				return false;
 			}
 
-			// transform raw data into set of indices
+			// Transform raw data into set of indices.
 			$originals    = $reader->str_split( $originals, 8 );
 			$translations = $reader->str_split( $translations, 8 );
 
-			// skip hash table
+			// Skip hash table.
 			$strings_addr = $header['hash_addr'] + $header['hash_length'] * 4;
 
 			$reader->seekto( $strings_addr );
@@ -283,7 +283,7 @@
 					return false;
 				}
 
-				// adjust offset due to reading strings to separate space before
+				// Adjust offset due to reading strings to separate space before.
 				$o['pos'] -= $strings_addr;
 				$t['pos'] -= $strings_addr;
 
@@ -319,14 +319,14 @@
 				$original       = $parts[1];
 				$entry->context = $parts[0];
 			}
-			// look for plural original
+			// Look for plural original.
 			$parts           = explode( "\0", $original );
 			$entry->singular = $parts[0];
 			if ( isset( $parts[1] ) ) {
 				$entry->is_plural = true;
 				$entry->plural    = $parts[1];
 			}
-			// plural translations are also separated by \0
+			// Plural translations are also separated by \0.
 			$entry->translations = explode( "\0", $translation );
 			return $entry;
 		}