mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Code Modernization: Rename parameters that use reserved keywords in wp-includes/pomo/po.php
.
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names. This commit renames the `$string` parameter to `$input_string` in: * `PO::poify()` * `PO::unpoify()` * `PO::prepend_each_line()` Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284], [53285], [53287], [53364], [53365], [54927], [54929], [54930], [54931], [54932], [54933], [54938], [54943], [54944], [54945], [54946], [54947], [54948], [54950], [54951], [54952], [54956]. Props jrf, aristath, poena, justinahinon, SergeyBiryukov. See #56788. Built from https://develop.svn.wordpress.org/trunk@54959 git-svn-id: http://core.svn.wordpress.org/trunk@54511 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cf9793f0df
commit
68f2c6cd13
@ -110,10 +110,10 @@ if ( ! class_exists( 'PO', false ) ) :
|
|||||||
/**
|
/**
|
||||||
* Formats a string in PO-style
|
* Formats a string in PO-style
|
||||||
*
|
*
|
||||||
* @param string $string the string to format
|
* @param string $input_string the string to format
|
||||||
* @return string the poified string
|
* @return string the poified string
|
||||||
*/
|
*/
|
||||||
public static function poify( $string ) {
|
public static function poify( $input_string ) {
|
||||||
$quote = '"';
|
$quote = '"';
|
||||||
$slash = '\\';
|
$slash = '\\';
|
||||||
$newline = "\n";
|
$newline = "\n";
|
||||||
@ -124,12 +124,12 @@ if ( ! class_exists( 'PO', false ) ) :
|
|||||||
"\t" => '\t',
|
"\t" => '\t',
|
||||||
);
|
);
|
||||||
|
|
||||||
$string = str_replace( array_keys( $replaces ), array_values( $replaces ), $string );
|
$input_string = str_replace( array_keys( $replaces ), array_values( $replaces ), $input_string );
|
||||||
|
|
||||||
$po = $quote . implode( "{$slash}n{$quote}{$newline}{$quote}", explode( $newline, $string ) ) . $quote;
|
$po = $quote . implode( "{$slash}n{$quote}{$newline}{$quote}", explode( $newline, $input_string ) ) . $quote;
|
||||||
// Add empty string on first line for readbility.
|
// Add empty string on first line for readbility.
|
||||||
if ( false !== strpos( $string, $newline ) &&
|
if ( false !== strpos( $input_string, $newline ) &&
|
||||||
( substr_count( $string, $newline ) > 1 || substr( $string, -strlen( $newline ) ) !== $newline ) ) {
|
( substr_count( $input_string, $newline ) > 1 || substr( $input_string, -strlen( $newline ) ) !== $newline ) ) {
|
||||||
$po = "$quote$quote$newline$po";
|
$po = "$quote$quote$newline$po";
|
||||||
}
|
}
|
||||||
// Remove empty strings.
|
// Remove empty strings.
|
||||||
@ -140,17 +140,17 @@ if ( ! class_exists( 'PO', false ) ) :
|
|||||||
/**
|
/**
|
||||||
* Gives back the original string from a PO-formatted string
|
* Gives back the original string from a PO-formatted string
|
||||||
*
|
*
|
||||||
* @param string $string PO-formatted string
|
* @param string $input_string PO-formatted string
|
||||||
* @return string enascaped string
|
* @return string enascaped string
|
||||||
*/
|
*/
|
||||||
public static function unpoify( $string ) {
|
public static function unpoify( $input_string ) {
|
||||||
$escapes = array(
|
$escapes = array(
|
||||||
't' => "\t",
|
't' => "\t",
|
||||||
'n' => "\n",
|
'n' => "\n",
|
||||||
'r' => "\r",
|
'r' => "\r",
|
||||||
'\\' => '\\',
|
'\\' => '\\',
|
||||||
);
|
);
|
||||||
$lines = array_map( 'trim', explode( "\n", $string ) );
|
$lines = array_map( 'trim', explode( "\n", $input_string ) );
|
||||||
$lines = array_map( array( 'PO', 'trim_quotes' ), $lines );
|
$lines = array_map( array( 'PO', 'trim_quotes' ), $lines );
|
||||||
$unpoified = '';
|
$unpoified = '';
|
||||||
$previous_is_backslash = false;
|
$previous_is_backslash = false;
|
||||||
@ -178,18 +178,18 @@ if ( ! class_exists( 'PO', false ) ) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts $with in the beginning of every new line of $string and
|
* Inserts $with in the beginning of every new line of $input_string and
|
||||||
* returns the modified string
|
* returns the modified string
|
||||||
*
|
*
|
||||||
* @param string $string prepend lines in this string
|
* @param string $input_string prepend lines in this string
|
||||||
* @param string $with prepend lines with this string
|
* @param string $with prepend lines with this string
|
||||||
*/
|
*/
|
||||||
public static function prepend_each_line( $string, $with ) {
|
public static function prepend_each_line( $input_string, $with ) {
|
||||||
$lines = explode( "\n", $string );
|
$lines = explode( "\n", $input_string );
|
||||||
$append = '';
|
$append = '';
|
||||||
if ( "\n" === substr( $string, -1 ) && '' === end( $lines ) ) {
|
if ( "\n" === substr( $input_string, -1 ) && '' === end( $lines ) ) {
|
||||||
/*
|
/*
|
||||||
* Last line might be empty because $string was terminated
|
* Last line might be empty because $input_string was terminated
|
||||||
* with a newline, remove it from the $lines array,
|
* with a newline, remove it from the $lines array,
|
||||||
* we'll restore state by re-terminating the string at the end.
|
* we'll restore state by re-terminating the string at the end.
|
||||||
*/
|
*/
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.2-alpha-54958';
|
$wp_version = '6.2-alpha-54959';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user