Skip to content

Commit

Permalink
set return types in Countries class now PHP 8.2 is minimum required v…
Browse files Browse the repository at this point in the history
…ersion
  • Loading branch information
dannyvankooten committed Jan 12, 2025
1 parent b1a4b1e commit 9e82277
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ composer.lock
.idea
.phpunit.result.cache
.php-cs-fixer.cache
.phpunit.cache
31 changes: 9 additions & 22 deletions src/Countries.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace Ibericode\Vat;

use DateTime;

/**
* Class Countries
*
Expand Down Expand Up @@ -338,8 +336,7 @@ public function isCountryCodeInEU(string $code): bool
* @return mixed Can return any type.
* @since 5.0.0
*/
#[\ReturnTypeWillChange]
public function current()
public function current(): mixed
{
return current($this->data);
}
Expand All @@ -350,8 +347,7 @@ public function current()
* @return void Any returned value is ignored.
* @since 5.0.0
*/
#[\ReturnTypeWillChange]
public function next()
public function next(): void
{
next($this->data);
}
Expand All @@ -362,8 +358,7 @@ public function next()
* @return mixed scalar on success, or null on failure.
* @since 5.0.0
*/
#[\ReturnTypeWillChange]
public function key()
public function key(): mixed
{
return key($this->data);
}
Expand All @@ -375,8 +370,7 @@ public function key()
* Returns true on success or false on failure.
* @since 5.0.0
*/
#[\ReturnTypeWillChange]
public function valid()
public function valid(): bool
{
return key($this->data) !== null;
}
Expand All @@ -387,8 +381,7 @@ public function valid()
* @return void Any returned value is ignored.
* @since 5.0.0
*/
#[\ReturnTypeWillChange]
public function rewind()
public function rewind(): void
{
reset($this->data);
}
Expand All @@ -397,8 +390,7 @@ public function rewind()
* @param string $countryCode
* @return bool
*/
#[\ReturnTypeWillChange]
public function offsetExists($countryCode)
public function offsetExists($countryCode): bool
{
return isset($this->data[$countryCode]);
}
Expand All @@ -408,8 +400,7 @@ public function offsetExists($countryCode)
* @return string
* @throws \Exception
*/
#[\ReturnTypeWillChange]
public function offsetGet($countryCode)
public function offsetGet($countryCode): mixed
{
if (!$this->offsetExists($countryCode)) {
throw new Exception("Invalid country code {$countryCode}");
Expand All @@ -421,22 +412,18 @@ public function offsetGet($countryCode)
/**
* @param string $countryCode
* @param string $name
* @return string
* @throws \Exception
*/
#[\ReturnTypeWillChange]
public function offsetSet($countryCode, $name)
public function offsetSet($countryCode, $name): void
{
throw new Exception('Invalid use of Countries class');
}

/**
* @param string $countryCode
* @return string
* @throws \Exception
*/
#[\ReturnTypeWillChange]
public function offsetUnset($countryCode)
public function offsetUnset($countryCode): void
{
throw new Exception('Invalid use of Countries class');
}
Expand Down

0 comments on commit 9e82277

Please sign in to comment.