| @@ -28,19 +28,19 @@ | ||
| 28 | 28 | * |
| 29 | 29 | * @since 1.0.0 |
| 30 | 30 | * @since 2.0.0 The $an_array parameter is handled by reference. |
| 31 | 31 | * |
| 32 | - * @param array $an_array Two-dimensional array to be padded. | |
| 32 | + * @param array<int, array<int, mixed>> $an_array Two-dimensional array to be padded. | |
| 33 | 33 | */ |
| 34 | - public function pad_array_to_max_cols( array &$an_array ) { | |
| 34 | + public function pad_array_to_max_cols( array &$an_array ): void { | |
| 35 | 35 | $max_columns = $this->count_max_columns( $an_array ); |
| 36 | 36 | // Extend the array to at least one column. |
| 37 | 37 | $max_columns = max( 1, $max_columns ); |
| 38 | 38 | array_walk( |
| 39 | 39 | $an_array, |
| 40 | - static function( &$row, $col_idx ) use ( $max_columns ) { | |
| 40 | + static function ( array &$row, int $col_idx ) use ( $max_columns ): void { | |
| 41 | 41 | $row = array_pad( $row, $max_columns, '' ); |
| 42 | - } | |
| 42 | + }, | |
| 43 | 43 | ); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
| @@ -47,12 +47,12 @@ | ||
| 47 | 47 | * Get the highest number of columns in the rows. |
| 48 | 48 | * |
| 49 | 49 | * @since 1.0.0 |
| 50 | 50 | * |
| 51 | - * @param array $an_array Two-dimensional array. | |
| 51 | + * @param array<int, array<int, mixed>> $an_array Two-dimensional array. | |
| 52 | 52 | * @return int Highest number of columns in the rows of the array. |
| 53 | 53 | */ |
| 54 | - protected function count_max_columns( array $an_array ) { | |
| 54 | + protected function count_max_columns( array $an_array ): int { | |
| 55 | 55 | $max_columns = 0; |
| 56 | 56 | foreach ( $an_array as $row_idx => $row ) { |
| 57 | 57 | $num_columns = count( $row ); |
| 58 | 58 | $max_columns = max( $num_columns, $max_columns ); |
| @@ -57,25 +57,7 @@ | ||
| 57 | 57 | $num_columns = count( $row ); |
| 58 | 58 | $max_columns = max( $num_columns, $max_columns ); |
| 59 | 59 | } |
| 60 | 60 | return $max_columns; |
| 61 | - } | |
| 62 | - | |
| 63 | - /** | |
| 64 | - * Replaces Windows line breaks \r\n with Unix line breaks \n. | |
| 65 | - * | |
| 66 | - * This function uses call by reference to save PHP memory on large arrays. | |
| 67 | - * | |
| 68 | - * @since 2.0.0 | |
| 69 | - * | |
| 70 | - * @param array $an_array Two-dimensional array to be padded. | |
| 71 | - */ | |
| 72 | - protected function normalize_line_endings( array &$an_array ) { | |
| 73 | - array_walk_recursive( | |
| 74 | - $an_array, | |
| 75 | - static function( &$cell_content, $col_idx ) { | |
| 76 | - $cell_content = str_replace( "\r\n", "\n", $cell_content ); | |
| 77 | - } | |
| 78 | - ); | |
| 79 | 61 | } |
| 80 | 62 | |
| 81 | 63 | } // class TablePress_Import_Base |