| @@ -7,8 +7,10 @@ | ||
| 7 | 7 | * @author Tobias Bäthge |
| 8 | 8 | * @since 2.0.0 |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | +declare(strict_types=1); | |
| 12 | + | |
| 11 | 13 | // Prohibit direct script loading. |
| 12 | 14 | defined( 'ABSPATH' ) || die( 'No direct script access allowed!' ); |
| 13 | 15 | |
| 14 | 16 | /** |
| @@ -28,19 +30,19 @@ | ||
| 28 | 30 | * |
| 29 | 31 | * @since 1.0.0 |
| 30 | 32 | * @since 2.0.0 The $an_array parameter is handled by reference. |
| 31 | 33 | * |
| 32 | - * @param array $an_array Two-dimensional array to be padded. | |
| 34 | + * @param array<int, array<int, mixed>> $an_array Two-dimensional array to be padded. | |
| 33 | 35 | */ |
| 34 | - public function pad_array_to_max_cols( array &$an_array ) { | |
| 36 | + public function pad_array_to_max_cols( array &$an_array ): void { | |
| 35 | 37 | $max_columns = $this->count_max_columns( $an_array ); |
| 36 | 38 | // Extend the array to at least one column. |
| 37 | 39 | $max_columns = max( 1, $max_columns ); |
| 38 | 40 | array_walk( |
| 39 | 41 | $an_array, |
| 40 | - static function( &$row, $col_idx ) use ( $max_columns ) { | |
| 42 | + static function ( array &$row, int $col_idx ) use ( $max_columns ): void { | |
| 41 | 43 | $row = array_pad( $row, $max_columns, '' ); |
| 42 | - } | |
| 44 | + }, | |
| 43 | 45 | ); |
| 44 | 46 | } |
| 45 | 47 | |
| 46 | 48 | /** |
| @@ -47,12 +49,12 @@ | ||
| 47 | 49 | * Get the highest number of columns in the rows. |
| 48 | 50 | * |
| 49 | 51 | * @since 1.0.0 |
| 50 | 52 | * |
| 51 | - * @param array $an_array Two-dimensional array. | |
| 53 | + * @param array<int, array<int, mixed>> $an_array Two-dimensional array. | |
| 52 | 54 | * @return int Highest number of columns in the rows of the array. |
| 53 | 55 | */ |
| 54 | - protected function count_max_columns( array $an_array ) { | |
| 56 | + protected function count_max_columns( array $an_array ): int { | |
| 55 | 57 | $max_columns = 0; |
| 56 | 58 | foreach ( $an_array as $row_idx => $row ) { |
| 57 | 59 | $num_columns = count( $row ); |
| 58 | 60 | $max_columns = max( $num_columns, $max_columns ); |
| @@ -57,25 +59,7 @@ | ||
| 57 | 59 | $num_columns = count( $row ); |
| 58 | 60 | $max_columns = max( $num_columns, $max_columns ); |
| 59 | 61 | } |
| 60 | 62 | 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 | 63 | } |
| 80 | 64 | |
| 81 | 65 | } // class TablePress_Import_Base |