Skip to content

Commit

Permalink
Merge pull request #8090 from kenjis/remove-Request-isValidIP
Browse files Browse the repository at this point in the history
refactor: remove deprecated Request::isValidIP()
  • Loading branch information
kenjis authored Oct 26, 2023
2 parents bfd7719 + 5a20f7b commit 785995a
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 143 deletions.
16 changes: 0 additions & 16 deletions system/HTTP/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace CodeIgniter\HTTP;

use CodeIgniter\Validation\FormatRules;
use Config\App;

/**
Expand Down Expand Up @@ -50,21 +49,6 @@ public function __construct($config = null) // @phpstan-ignore-line
}
}

/**
* Validate an IP address
*
* @param string $ip IP Address
* @param string $which IP protocol: 'ipv4' or 'ipv6'
*
* @deprecated 4.0.5 Use Validation instead
*
* @codeCoverageIgnore
*/
public function isValidIP(?string $ip = null, ?string $which = null): bool
{
return (new FormatRules())->valid_ip($ip, $which);
}

/**
* Get the request method.
*
Expand Down
10 changes: 0 additions & 10 deletions system/HTTP/RequestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@ interface RequestInterface extends OutgoingRequestInterface
*/
public function getIPAddress(): string;

/**
* Validate an IP address
*
* @param string $ip IP Address
* @param string $which IP protocol: 'ipv4' or 'ipv6'
*
* @deprecated Use Validation instead
*/
public function isValidIP(string $ip, ?string $which = null): bool;

/**
* Fetch an item from the $_SERVER array.
* Supplied by RequestTrait.
Expand Down
58 changes: 0 additions & 58 deletions tests/system/HTTP/CLIRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,64 +517,6 @@ public function testFetchGlobalWithEmptyNotation(): void
$this->assertSame($expected, $this->request->fetchGlobal('post', 'clients[]'));
}

public static function provideValidIPAddress(): iterable
{
return [
'empty' => [
false,
'',
],
'zero' => [
false,
0,
],
'large_ipv4' => [
false,
'256.256.256.999',
'ipv4',
],
'good_ipv4' => [
true,
'100.100.100.0',
'ipv4',
],
'good_default' => [
true,
'100.100.100.0',
],
'zeroed_ipv4' => [
true,
'0.0.0.0',
],
'large_ipv6' => [
false,
'h123:0000:0000:0000:0000:0000:0000:0000',
'ipv6',
],
'good_ipv6' => [
true,
'2001:0db8:85a3:0000:0000:8a2e:0370:7334',
],
'confused_ipv6' => [
false,
'255.255.255.255',
'ipv6',
],
];
}

/**
* @dataProvider provideValidIPAddress
*
* @param mixed $expected
* @param mixed $address
* @param mixed|null $type
*/
public function testValidIPAddress($expected, $address, $type = null): void
{
$this->assertSame($expected, $this->request->isValidIP($address, $type));
}

public function testGetIPAddressDefault(): void
{
$this->assertSame('0.0.0.0', $this->request->getIPAddress());
Expand Down
58 changes: 0 additions & 58 deletions tests/system/HTTP/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,64 +533,6 @@ public function testFetchGlobalFiltersWithArrayChildElement(): void
$this->assertSame($expected, $this->request->fetchGlobal('post', 'people[0]', FILTER_VALIDATE_INT));
}

public static function provideValidIPAddress(): iterable
{
return [
'empty' => [
false,
'',
],
'zero' => [
false,
0,
],
'large_ipv4' => [
false,
'256.256.256.999',
'ipv4',
],
'good_ipv4' => [
true,
'100.100.100.0',
'ipv4',
],
'good_default' => [
true,
'100.100.100.0',
],
'zeroed_ipv4' => [
true,
'0.0.0.0',
],
'large_ipv6' => [
false,
'h123:0000:0000:0000:0000:0000:0000:0000',
'ipv6',
],
'good_ipv6' => [
true,
'2001:0db8:85a3:0000:0000:8a2e:0370:7334',
],
'confused_ipv6' => [
false,
'255.255.255.255',
'ipv6',
],
];
}

/**
* @dataProvider provideValidIPAddress
*
* @param mixed $expected
* @param mixed $address
* @param mixed|null $type
*/
public function testValidIPAddress($expected, $address, $type = null): void
{
$this->assertSame($expected, $this->request->isValidIP($address, $type));
}

public function testGetIPAddressDefault(): void
{
$this->assertSame('0.0.0.0', $this->request->getIPAddress());
Expand Down
4 changes: 3 additions & 1 deletion user_guide_src/source/changelogs/v4.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ Spark Commands
Others
------

- **IncomingRequest::** The visibility of the deprecated properties ``$uri`` and
- **IncomingRequest:** The visibility of the deprecated properties ``$uri`` and
- **RequestInterface:** The deprecated ``isValidIP()`` method has been removed.
- **Request:** The deprecated ``isValidIP()`` method has been removed.
``$config`` has been changed to protected.
- **Config:** The deprecated ``CodeIgniter\Config\Config`` class has been removed.

Expand Down

0 comments on commit 785995a

Please sign in to comment.