akalongman / akalongman/php-ip-tools
isRemote() is not the same as !isLocal()
Open
- Dominant language
- PHP
- Stars
- 147
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Description
When passing an empty string as the IP like this:
```php
$ip = '';
$is_remote = Ip::isRemote($ip);
```
it returns `true`, even thought the IP itself is invalid.
This is because `isLocal()` returns `false` (due to the IP being invalid), and `isRemote()` simply switches the result to `true`.
Workaround:
```php
$ip = '';
$is_remote = Ip::isValid($ip) && Ip::isRemote($ip);
```
Contributor guide
Assessment
This issue has not been assessed yet.