From ac8bcf83596bc212662bc636fcffaab17a3b2913 Mon Sep 17 00:00:00 2001 From: Heverton Coneglian de Freitas Date: Tue, 18 Jan 2022 17:01:50 -0300 Subject: [PATCH] Fixes deprecations errors on php 8.1 --- Cmfcmf/OpenWeatherMap/CurrentWeatherGroup.php | 5 +++++ Cmfcmf/OpenWeatherMap/Forecast.php | 2 +- Cmfcmf/OpenWeatherMap/Util/Unit.php | 1 + Cmfcmf/OpenWeatherMap/WeatherForecast.php | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Cmfcmf/OpenWeatherMap/CurrentWeatherGroup.php b/Cmfcmf/OpenWeatherMap/CurrentWeatherGroup.php index a0e3b46..b499e1e 100644 --- a/Cmfcmf/OpenWeatherMap/CurrentWeatherGroup.php +++ b/Cmfcmf/OpenWeatherMap/CurrentWeatherGroup.php @@ -55,6 +55,7 @@ public function __construct(\stdClass $json, $units) /** * @internal */ + #[\ReturnTypeWillChange] public function rewind() { $this->position = 0; @@ -63,6 +64,7 @@ public function rewind() /** * @internal */ + #[\ReturnTypeWillChange] public function current() { return $this->currentWeathers[$this->position]; @@ -71,6 +73,7 @@ public function current() /** * @internal */ + #[\ReturnTypeWillChange] public function key() { return $this->current()->city->id; @@ -79,6 +82,7 @@ public function key() /** * @internal */ + #[\ReturnTypeWillChange] public function next() { ++$this->position; @@ -87,6 +91,7 @@ public function next() /** * @internal */ + #[\ReturnTypeWillChange] public function valid() { return isset($this->currentWeathers[$this->position]); diff --git a/Cmfcmf/OpenWeatherMap/Forecast.php b/Cmfcmf/OpenWeatherMap/Forecast.php index 7fffd34..8d783f2 100644 --- a/Cmfcmf/OpenWeatherMap/Forecast.php +++ b/Cmfcmf/OpenWeatherMap/Forecast.php @@ -80,7 +80,7 @@ public function __construct(\SimpleXMLElement $xml, $units) $this->clouds = new Unit($xml->clouds['all'], $xml->clouds['unit'], $xml->clouds['value']); $this->precipitation = new Unit($xml->precipitation['value'], null, $xml->precipitation['type']); $this->weather = new Weather($xml->symbol['number'], $xml->symbol['name'], $xml->symbol['var']); - $this->lastUpdate = new \DateTime($xml->lastupdate['value'], $utctz); + $this->lastUpdate = new \DateTime($xml->lastupdate['value'] ?? 'now', $utctz); if (isset($xml['from'])) { $this->time = new Time($xml['from'], $xml['to']); diff --git a/Cmfcmf/OpenWeatherMap/Util/Unit.php b/Cmfcmf/OpenWeatherMap/Util/Unit.php index 577db62..4e27d73 100644 --- a/Cmfcmf/OpenWeatherMap/Util/Unit.php +++ b/Cmfcmf/OpenWeatherMap/Util/Unit.php @@ -152,6 +152,7 @@ public function getFormatted() * * @return array */ + #[\ReturnTypeWillChange] public function jsonSerialize() { return [ diff --git a/Cmfcmf/OpenWeatherMap/WeatherForecast.php b/Cmfcmf/OpenWeatherMap/WeatherForecast.php index 002015c..6c1d5f5 100644 --- a/Cmfcmf/OpenWeatherMap/WeatherForecast.php +++ b/Cmfcmf/OpenWeatherMap/WeatherForecast.php @@ -99,6 +99,7 @@ public function __construct($xml, $units, $days) /** * @internal */ + #[\ReturnTypeWillChange] public function rewind() { $this->position = 0; @@ -107,6 +108,7 @@ public function rewind() /** * @internal */ + #[\ReturnTypeWillChange] public function current() { return $this->forecasts[$this->position]; @@ -115,6 +117,7 @@ public function current() /** * @internal */ + #[\ReturnTypeWillChange] public function key() { return $this->position; @@ -123,6 +126,7 @@ public function key() /** * @internal */ + #[\ReturnTypeWillChange] public function next() { ++$this->position; @@ -131,6 +135,7 @@ public function next() /** * @internal */ + #[\ReturnTypeWillChange] public function valid() { return isset($this->forecasts[$this->position]);