Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove deprecated Request::isValidIP() #8090

Merged
merged 4 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading