wp/wp-includes/pomo/po.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
--- a/wp/wp-includes/pomo/po.php	Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-includes/pomo/po.php	Tue Sep 27 16:37:53 2022 +0200
@@ -13,7 +13,15 @@
 	define( 'PO_MAX_LINE_LEN', 79 );
 }
 
-ini_set( 'auto_detect_line_endings', 1 );
+/*
+ * The `auto_detect_line_endings` setting has been deprecated in PHP 8.1,
+ * but will continue to work until PHP 9.0.
+ * For now, we're silencing the deprecation notice as there may still be
+ * translation files around which haven't been updated in a long time and
+ * which still use the old MacOS standalone `\r` as a line ending.
+ * This fix should be revisited when PHP 9.0 is in alpha/beta.
+ */
+@ini_set( 'auto_detect_line_endings', 1 ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
 
 /**
  * Routines for working with PO files
@@ -28,7 +36,7 @@
 		 *
 		 * @return string msgid/msgstr PO entry for this PO file headers, doesn't contain newline at the end
 		 */
-		function export_headers() {
+		public function export_headers() {
 			$header_string = '';
 			foreach ( $this->headers as $header => $value ) {
 				$header_string .= "$header: $value\n";
@@ -47,7 +55,7 @@
 		 *
 		 * @return string sequence of mgsgid/msgstr PO strings, doesn't containt newline at the end
 		 */
-		function export_entries() {
+		public function export_entries() {
 			// TODO: Sorting.
 			return implode( "\n\n", array_map( array( 'PO', 'export_entry' ), $this->entries ) );
 		}
@@ -58,7 +66,7 @@
 		 * @param bool $include_headers whether to include the headers in the export
 		 * @return string ready for inclusion in PO file string for headers and all the enrtries
 		 */
-		function export( $include_headers = true ) {
+		public function export( $include_headers = true ) {
 			$res = '';
 			if ( $include_headers ) {
 				$res .= $this->export_headers();
@@ -75,7 +83,7 @@
 		 * @param bool   $include_headers Whether to include the headers in the export.
 		 * @return bool true on success, false on error
 		 */
-		function export_to_file( $filename, $include_headers = true ) {
+		public function export_to_file( $filename, $include_headers = true ) {
 			$fh = fopen( $filename, 'w' );
 			if ( false === $fh ) {
 				return false;
@@ -95,7 +103,7 @@
 		 *
 		 * @param string $text Text to include as a comment.
 		 */
-		function set_comment_before_headers( $text ) {
+		public function set_comment_before_headers( $text ) {
 			$this->comments_before_headers = $text;
 		}
 
@@ -163,7 +171,7 @@
 				}
 			}
 
-			// Standardise the line endings on imported content, technically PO files shouldn't contain \r.
+			// Standardize the line endings on imported content, technically PO files shouldn't contain \r.
 			$unpoified = str_replace( array( "\r\n", "\r" ), "\n", $unpoified );
 
 			return $unpoified;
@@ -285,7 +293,7 @@
 		 * @param string $filename
 		 * @return bool
 		 */
-		function import_from_file( $filename ) {
+		public function import_from_file( $filename ) {
 			$f = fopen( $filename, 'r' );
 			if ( ! $f ) {
 				return false;
@@ -327,7 +335,7 @@
 		 * @param int      $lineno
 		 * @return null|false|array
 		 */
-		function read_entry( $f, $lineno = 0 ) {
+		public function read_entry( $f, $lineno = 0 ) {
 			$entry = new Translation_Entry();
 			// Where were we in the last step.
 			// Can be: comment, msgctxt, msgid, msgid_plural, msgstr, msgstr_plural.
@@ -456,7 +464,7 @@
 		 * @param string   $action
 		 * @return bool
 		 */
-		function read_line( $f, $action = 'read' ) {
+		public function read_line( $f, $action = 'read' ) {
 			static $last_line     = '';
 			static $use_last_line = false;
 			if ( 'clear' === $action ) {
@@ -478,7 +486,7 @@
 		 * @param Translation_Entry $entry
 		 * @param string            $po_comment_line
 		 */
-		function add_comment_to_entry( &$entry, $po_comment_line ) {
+		public function add_comment_to_entry( &$entry, $po_comment_line ) {
 			$first_two = substr( $po_comment_line, 0, 2 );
 			$comment   = trim( substr( $po_comment_line, 2 ) );
 			if ( '#:' === $first_two ) {