: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* I18N: WP_Translation_File_PHP class.
* Class WP_Translation_File_PHP.
class WP_Translation_File_PHP extends WP_Translation_File {
protected function parse_file() {
$result = include $this->file;
if ( ! $result || ! is_array( $result ) ) {
$this->error = 'Invalid data';
if ( isset( $result['messages'] ) && is_array( $result['messages'] ) ) {
foreach ( $result['messages'] as $original => $translation ) {
$this->entries[ (string) $original ] = $translation;
unset( $result['messages'] );
$this->headers = array_change_key_case( $result );
* Exports translation contents as a string.
* @return string Translation file contents.
public function export(): string {
$data = array_merge( $this->headers, array( 'messages' => $this->entries ) );
return '<?php' . PHP_EOL . 'return ' . $this->var_export( $data ) . ';' . PHP_EOL;
* Outputs or returns a parsable string representation of a variable.
* Like {@see var_export()} but "minified", using short array syntax
* @param mixed $value The variable you want to export.
* @return string The variable representation.
private function var_export( $value ): string {
if ( ! is_array( $value ) ) {
return var_export( $value, true );
$is_list = array_is_list( $value );
foreach ( $value as $key => $val ) {
$entries[] = $is_list ? $this->var_export( $val ) : var_export( $key, true ) . '=>' . $this->var_export( $val );
return '[' . implode( ',', $entries ) . ']';