Torann / laravel-geoip

Determine the geographical location of website visitors based on their IP addresses.
http://lyften.com/projects/laravel-geoip
BSD 2-Clause "Simplified" License
2.07k stars 372 forks source link

Location::offsetExists($offset) signature is not compatible with PHP 8.1 #209

Closed alies-dev closed 2 years ago

alies-dev commented 2 years ago
NOTICE: PHP message: PHP Deprecated:  Return type of Torann\GeoIP\Location::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/vendor/torann/geoip/src/Location.php on line 157

current implementation:

/**
 * Determine if the given attribute exists.
 *
 * @param  mixed $offset
 *
 * @return bool
 */
public function offsetExists($offset)
{
    return isset($this->$offset);
}

should be:

public function offsetExists(mixed $offset): bool
{
    return isset($this->$offset);
}

or you can suppress it:

#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
    return isset($this->$offset);
}

Why it's important:

Some teams prefer to setup PHP to throw an exception on E_DEPRECATED on local/dev env