From 25cbb212c87d8c7cde20c5ac271225c5920fe2cd Mon Sep 17 00:00:00 2001 From: Fabian Berg Date: Mon, 28 Apr 2025 13:22:18 +0200 Subject: [PATCH] php8.4 fixes --- application/models/Update_model.php | 22 +++++++++++----------- src/Label/vendor/php-ds/php-ds/src/Map.php | 12 ++++++------ src/Label/vendor/php-ds/php-ds/src/Set.php | 12 ++++++------ src/StaticMap/src/OpenStreetMap.php | 12 ++++++------ src/predict/Predict/Sat.php | 4 ++-- system/libraries/Encryption.php | 8 ++++---- 6 files changed, 35 insertions(+), 35 deletions(-) diff --git a/application/models/Update_model.php b/application/models/Update_model.php index 42d1c9955..baca22d49 100644 --- a/application/models/Update_model.php +++ b/application/models/Update_model.php @@ -105,9 +105,9 @@ class Update_model extends CI_Model { return "Something went wrong with fetching the SOTA file"; } - $data = fgetcsv($csvhandle, 1000, ","); // Skip line we are not interested in - $data = fgetcsv($csvhandle, 1000, ","); // Skip line we are not interested in - $data = fgetcsv($csvhandle, 1000, ","); + $data = fgetcsv($csvhandle, 1000, ",", '"', '\\'); // Skip line we are not interested in + $data = fgetcsv($csvhandle, 1000, ",", '"', '\\'); // Skip line we are not interested in + $data = fgetcsv($csvhandle, 1000, ",", '"', '\\'); $sotafilehandle = fopen($sotafile, 'w'); if ($sotafilehandle === FALSE) { @@ -120,7 +120,7 @@ class Update_model extends CI_Model { fwrite($sotafilehandle, $data[0] . PHP_EOL); $nCount++; } - } while ($data = fgetcsv($csvhandle, 1000, ",")); + } while ($data = fgetcsv($csvhandle, 1000, ",", '"', '\\')); fclose($csvhandle); fclose($sotafilehandle); @@ -157,11 +157,11 @@ class Update_model extends CI_Model { return "FAILED: Could not write to wwff.txt file"; } - $data = str_getcsv($csv, "\n"); + $data = str_getcsv($csv, "\n", '"', '\\'); $nCount = 0; foreach ($data as $idx => $row) { if ($idx == 0) continue; // Skip line we are not interested in - $row = str_getcsv($row, ','); + $row = str_getcsv($row, ',', '"', '\\'); if ($row[0]) { fwrite($wwfffilehandle, $row[0] . PHP_EOL); $nCount++; @@ -201,11 +201,11 @@ class Update_model extends CI_Model { if ($potafilehandle === FALSE) { return "FAILED: Could not write to pota.txt file"; } - $data = str_getcsv($csv, "\n"); + $data = str_getcsv($csv, "\n", '"', '\\'); $nCount = 0; foreach ($data as $idx => $row) { if ($idx == 0) continue; // Skip line we are not interested in - $row = str_getcsv($row, ','); + $row = str_getcsv($row, ',', '"', '\\'); if ($row[0]) { fwrite($potafilehandle, $row[0] . PHP_EOL); $nCount++; @@ -240,7 +240,7 @@ class Update_model extends CI_Model { $this->db->empty_table("lotw_users"); $this->db->query("ALTER TABLE lotw_users AUTO_INCREMENT 1"); $i = 0; - $data = fgetcsv($handle, 1000, ","); + $data = fgetcsv($handle, 1000, ",", '"', '\\'); do { if ($data[0]) { $lotwdata[$i]['callsign'] = $data[0]; @@ -252,7 +252,7 @@ class Update_model extends CI_Model { } $i++; } - } while ($data = fgetcsv($handle, 1000, ",")); + } while ($data = fgetcsv($handle, 1000, ",", '"', '\\')); fclose($handle); $this->db->insert_batch('lotw_users', $lotwdata); @@ -476,7 +476,7 @@ class Update_model extends CI_Model { function update_norad_ids() { $csvfile = 'https://www.df2et.de/cqrlog/lotw_norad.csv'; $csvhandle = fopen($csvfile, "r"); - while (false !== ($data = fgetcsv($csvhandle, 1000, ","))) { + while (false !== ($data = fgetcsv($csvhandle, 1000, ",", '"', '\\'))) { $this->db->set('norad_id', $data[1]); $this->db->where('name', $data[0]); $this->db->update('satellite'); diff --git a/src/Label/vendor/php-ds/php-ds/src/Map.php b/src/Label/vendor/php-ds/php-ds/src/Map.php index a45cc5eec..fe6cf4ecf 100644 --- a/src/Label/vendor/php-ds/php-ds/src/Map.php +++ b/src/Label/vendor/php-ds/php-ds/src/Map.php @@ -287,7 +287,7 @@ final class Map implements Collection, \ArrayAccess * @psalm-param (callable(TKey, TValue): bool)|null $callback * @psalm-return Map */ - public function filter(callable $callback = null): Map + public function filter(?callable $callback = null): Map { $filtered = new self(); @@ -552,7 +552,7 @@ final class Map implements Collection, \ArrayAccess * * @psalm-return Map */ - public function slice(int $offset, int $length = null): Map + public function slice(int $offset, ?int $length = null): Map { $map = new self(); @@ -578,7 +578,7 @@ final class Map implements Collection, \ArrayAccess * * @psalm-param (callable(TValue, TValue): int)|null $comparator */ - public function sort(callable $comparator = null) + public function sort(?callable $comparator = null) { if ($comparator) { usort($this->pairs, function($a, $b) use ($comparator) { @@ -603,7 +603,7 @@ final class Map implements Collection, \ArrayAccess * @psalm-param (callable(TValue, TValue): int)|null $comparator * @psalm-return Map */ - public function sorted(callable $comparator = null): Map + public function sorted(?callable $comparator = null): Map { $copy = $this->copy(); $copy->sort($comparator); @@ -619,7 +619,7 @@ final class Map implements Collection, \ArrayAccess * * @psalm-param (callable(TKey, TKey): int)|null $comparator */ - public function ksort(callable $comparator = null) + public function ksort(?callable $comparator = null) { if ($comparator) { usort($this->pairs, function($a, $b) use ($comparator) { @@ -644,7 +644,7 @@ final class Map implements Collection, \ArrayAccess * @psalm-param (callable(TKey, TKey): int)|null $comparator * @psalm-return Map */ - public function ksorted(callable $comparator = null): Map + public function ksorted(?callable $comparator = null): Map { $copy = $this->copy(); $copy->ksort($comparator); diff --git a/src/Label/vendor/php-ds/php-ds/src/Set.php b/src/Label/vendor/php-ds/php-ds/src/Set.php index cd7323115..970770234 100644 --- a/src/Label/vendor/php-ds/php-ds/src/Set.php +++ b/src/Label/vendor/php-ds/php-ds/src/Set.php @@ -175,7 +175,7 @@ final class Set implements Collection, \ArrayAccess * @psalm-param (callable(TValue): bool)|null $callback * @psalm-return Set */ - public function filter(callable $callback = null): Set + public function filter(?callable $callback = null): Set { return new self(array_filter($this->toArray(), $callback ?: 'boolval')); } @@ -241,7 +241,7 @@ final class Set implements Collection, \ArrayAccess * * @param string|null $glue */ - public function join(string $glue = null): string + public function join(?string $glue = null): string { return implode($glue ?? '', $this->toArray()); } @@ -345,7 +345,7 @@ final class Set implements Collection, \ArrayAccess * at that offset in the set. If offset is negative, * the set will start that far from the end. * - * @param int $length If a length is given and is positive, the resulting + * @param int|null $length If a length is given and is positive, the resulting * set will have up to that many values in it. * If the requested length results in an overflow, only * values up to the end of the set will be included. @@ -361,7 +361,7 @@ final class Set implements Collection, \ArrayAccess * * @psalm-return Set */ - public function slice(int $offset, int $length = null): Set + public function slice(int $offset, ?int $length = null): Set { $sliced = new self(); $sliced->table = $this->table->slice($offset, $length); @@ -377,7 +377,7 @@ final class Set implements Collection, \ArrayAccess * * @psalm-param (callable(TValue, TValue): int)|null $comparator */ - public function sort(callable $comparator = null) + public function sort(?callable $comparator = null) { $this->table->ksort($comparator); } @@ -394,7 +394,7 @@ final class Set implements Collection, \ArrayAccess * @psalm-param (callable(TValue, TValue): int)|null $comparator * @psalm-return Set */ - public function sorted(callable $comparator = null): Set + public function sorted(?callable $comparator = null): Set { $sorted = $this->copy(); $sorted->table->ksort($comparator); diff --git a/src/StaticMap/src/OpenStreetMap.php b/src/StaticMap/src/OpenStreetMap.php index 28d3e9238..6d6cec06d 100644 --- a/src/StaticMap/src/OpenStreetMap.php +++ b/src/StaticMap/src/OpenStreetMap.php @@ -21,10 +21,10 @@ class OpenStreetMap * @param int $zoom Zoom * @param int $imageWidth Width of the generated map image * @param int $imageHeight Height of the generated map image - * @param TileLayer $tileLayer Tile server configuration, defaults to OpenStreetMaps tile server + * @param TileLayer|null $tileLayer Tile server configuration, defaults to OpenStreetMaps tile server * @param int $tileSize Tile size in pixels */ - public static function createFromLatLngZoom(LatLng $centerMap, int $zoom, int $imageWidth, int $imageHeight, TileLayer $tileLayer = null, int $tileSize = 256): OpenStreetMap + public static function createFromLatLngZoom(LatLng $centerMap, int $zoom, int $imageWidth, int $imageHeight, ?TileLayer $tileLayer = null, int $tileSize = 256): OpenStreetMap { return new OpenStreetMap($centerMap, $zoom, $imageWidth, $imageHeight, $tileLayer, $tileSize); } @@ -36,11 +36,11 @@ class OpenStreetMap * @param int $padding Padding to add before top left and after bottom right position. * @param int $imageWidth Width of the generated map image * @param int $imageHeight Height of the generated map image - * @param TileLayer $tileLayer Tile server configuration, defaults to OpenStreetMaps tile server + * @param TileLayer|null $tileLayer Tile server configuration, defaults to OpenStreetMaps tile server * @param int $tileSize Tile size in pixels * @return OpenStreetMap */ - public static function createFromBoundingBox(LatLng $topLeft, LatLng $bottomRight, int $padding, int $imageWidth, int $imageHeight, TileLayer $tileLayer = null, int $tileSize = 256): OpenStreetMap + public static function createFromBoundingBox(LatLng $topLeft, LatLng $bottomRight, int $padding, int $imageWidth, int $imageHeight, ?TileLayer $tileLayer = null, int $tileSize = 256): OpenStreetMap { if ($tileLayer === null) { $tileLayer = TileLayer::defaultTileLayer(); @@ -73,10 +73,10 @@ class OpenStreetMap * @param int $zoom Zoom * @param int $imageWidth Width of the generated map image * @param int $imageHeight Height of the generated map image - * @param TileLayer $tileLayer Tile server configuration, defaults to OpenStreetMaps tile server + * @param TileLayer|null $tileLayer Tile server configuration, defaults to OpenStreetMaps tile server * @param int $tileSize Tile size in pixels */ - public function __construct(LatLng $centerMap, int $zoom, int $imageWidth, int $imageHeight, TileLayer $tileLayer = null, int $tileSize = 256) + public function __construct(LatLng $centerMap, int $zoom, int $imageWidth, int $imageHeight, ?TileLayer $tileLayer = null, int $tileSize = 256) { if ($tileLayer === null) { $tileLayer = TileLayer::defaultTileLayer(); diff --git a/src/predict/Predict/Sat.php b/src/predict/Predict/Sat.php index 2a5134508..e21e71a5d 100644 --- a/src/predict/Predict/Sat.php +++ b/src/predict/Predict/Sat.php @@ -126,12 +126,12 @@ class Predict_Sat /** Initialise satellite data. * @param sat The satellite to initialise. - * @param qth Optional QTH info, use (0,0) if NULL. + * @param qth|null Optional QTH info, use (0,0) if NULL. * * This function calculates the satellite data at t = 0, ie. epoch time * The function is called automatically by gtk_sat_data_read_sat. */ - public function sat_data_init_sat(Predict_Sat $sat, Predict_QTH $qth = null) + public function sat_data_init_sat(Predict_Sat $sat, ?Predict_QTH $qth = null) { $obs_geodetic = new Predict_Geodetic(); $obs_set = new Predict_ObsSet(); diff --git a/system/libraries/Encryption.php b/system/libraries/Encryption.php index f7e0ff37a..b58832968 100644 --- a/system/libraries/Encryption.php +++ b/system/libraries/Encryption.php @@ -365,10 +365,10 @@ class CI_Encryption { * Encrypt * * @param string $data Input data - * @param array $params Input parameters + * @param array|null $params Input parameters * @return string */ - public function encrypt($data, array $params = NULL) + public function encrypt($data, ?array $params = NULL) { if (($params = $this->_get_params($params)) === FALSE) { @@ -500,10 +500,10 @@ class CI_Encryption { * Decrypt * * @param string $data Encrypted data - * @param array $params Input parameters + * @param array|null $params Input parameters * @return string */ - public function decrypt($data, array $params = NULL) + public function decrypt($data, ?array $params = NULL) { if (($params = $this->_get_params($params)) === FALSE) {