| @@ -7,8 +7,10 @@ | ||
| 7 | 7 | * @author Tobias Bäthge |
| 8 | 8 | * @since 1.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 | /** |
| @@ -24,27 +26,24 @@ | ||
| 24 | 26 | /** |
| 25 | 27 | * The used character for the enclosure of a cell. Defaults to quotation mark ". |
| 26 | 28 | * |
| 27 | 29 | * @since 1.0.0 |
| 28 | - * @var string | |
| 29 | 30 | */ |
| 30 | - protected $enclosure = '"'; | |
| 31 | + protected string $enclosure = '"'; | |
| 31 | 32 | |
| 32 | 33 | /** |
| 33 | 34 | * Number of rows to analyze when attempting to auto-detect the CSV delimiter. |
| 34 | 35 | * |
| 35 | 36 | * @since 1.0.0 |
| 36 | - * @var int | |
| 37 | 37 | */ |
| 38 | - protected $delimiter_search_max_lines = 15; | |
| 38 | + protected int $delimiter_search_max_lines = 15; | |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * Characters to ignore when attempting to auto-detect delimiter. |
| 42 | 42 | * |
| 43 | 43 | * @since 1.0.0 |
| 44 | - * @var string | |
| 45 | 44 | */ |
| 46 | - protected $non_delimiter_chars = "a-zA-Z0-9\n\r"; | |
| 45 | + protected string $non_delimiter_chars = "a-zA-Z0-9\n\r"; | |
| 47 | 46 | |
| 48 | 47 | /** |
| 49 | 48 | * The preferred delimiter characters, only used when all filtering method return multiple possible delimiters (happens very rarely). |
| 50 | 49 | * There must not be more than 9 characters in the preferred delimiter character list, see `_check_delimiter_count()`. |
| @@ -49,19 +48,17 @@ | ||
| 49 | 48 | * The preferred delimiter characters, only used when all filtering method return multiple possible delimiters (happens very rarely). |
| 50 | 49 | * There must not be more than 9 characters in the preferred delimiter character list, see `_check_delimiter_count()`. |
| 51 | 50 | * |
| 52 | 51 | * @since 1.0.0 |
| 53 | - * @var string | |
| 54 | 52 | */ |
| 55 | - protected $preferred_delimiter_chars = ";,\t"; | |
| 53 | + protected string $preferred_delimiter_chars = ";,\t"; | |
| 56 | 54 | |
| 57 | 55 | /** |
| 58 | 56 | * The CSV data string that shall be parsed to an array. |
| 59 | 57 | * |
| 60 | 58 | * @since 1.0.0 |
| 61 | - * @var string | |
| 62 | 59 | */ |
| 63 | - protected $import_data; | |
| 60 | + protected string $import_data = ''; | |
| 64 | 61 | |
| 65 | 62 | /** |
| 66 | 63 | * The error state while parsing input data. |
| 67 | 64 | * |
| @@ -70,11 +67,10 @@ | ||
| 70 | 67 | * 2 = The enclosure character was found in a non-enclosed field. This means the file is either corrupt, |
| 71 | 68 | * or does not follow the common CSV standard. Please validate the parsed data manually. |
| 72 | 69 | * |
| 73 | 70 | * @since 1.0.0 |
| 74 | - * @var int | |
| 75 | 71 | */ |
| 76 | - public $error = 0; | |
| 72 | + public int $error = 0; | |
| 77 | 73 | |
| 78 | 74 | /** |
| 79 | 75 | * Detailed error information. |
| 80 | 76 | * |
| @@ -80,9 +76,9 @@ | ||
| 80 | 76 | * |
| 81 | 77 | * @since 1.0.0 |
| 82 | 78 | * @var array<string, array<string, int|string>> |
| 83 | 79 | */ |
| 84 | - public $error_info = array(); | |
| 80 | + public array $error_info = array(); | |
| 85 | 81 | |
| 86 | 82 | /** |
| 87 | 83 | * Class Constructor. |
| 88 | 84 | * |
| @@ -134,9 +130,9 @@ | ||
| 134 | 130 | $enclosed = ! $enclosed; // Flip bool. |
| 135 | 131 | } elseif ( $enclosed ) { |
| 136 | 132 | ++$i; // Skip next character. |
| 137 | 133 | } |
| 138 | - } elseif ( ( "\n" === $curr_char && "\r" !== $prev_char || "\r" === $curr_char ) && ! $enclosed ) { | |
| 134 | + } elseif ( ( ( "\n" === $curr_char && "\r" !== $prev_char ) || "\r" === $curr_char ) && ! $enclosed ) { | |
| 139 | 135 | // Reached end of a line. |
| 140 | 136 | ++$current_line; |
| 141 | 137 | if ( $current_line >= $this->delimiter_search_max_lines ) { |
| 142 | 138 | break; |