From 6578230237f19f70c4dddf1c4fd16d8f5fb80b6a Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 25 Oct 2023 10:58:08 +0900 Subject: [PATCH 1/4] refactor: remove deprecated Request::isValidIP() --- system/HTTP/Request.php | 16 -------- tests/system/HTTP/CLIRequestTest.php | 58 ---------------------------- tests/system/HTTP/RequestTest.php | 58 ---------------------------- 3 files changed, 132 deletions(-) diff --git a/system/HTTP/Request.php b/system/HTTP/Request.php index afb0b22ad5d0..baf60c0305b6 100644 --- a/system/HTTP/Request.php +++ b/system/HTTP/Request.php @@ -11,7 +11,6 @@ namespace CodeIgniter\HTTP; -use CodeIgniter\Validation\FormatRules; use Config\App; /** @@ -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. * diff --git a/tests/system/HTTP/CLIRequestTest.php b/tests/system/HTTP/CLIRequestTest.php index 1298df1b9ad3..e15f0fca4f87 100644 --- a/tests/system/HTTP/CLIRequestTest.php +++ b/tests/system/HTTP/CLIRequestTest.php @@ -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()); diff --git a/tests/system/HTTP/RequestTest.php b/tests/system/HTTP/RequestTest.php index 621227c4b888..be20b4ff8f5b 100644 --- a/tests/system/HTTP/RequestTest.php +++ b/tests/system/HTTP/RequestTest.php @@ -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()); From 97b3cab5475dda2a4faac2a2efc3291fc9083db8 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 25 Oct 2023 11:02:38 +0900 Subject: [PATCH 2/4] refactor: remove deprecated RequestInterface::isValidIP() --- system/HTTP/RequestInterface.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/system/HTTP/RequestInterface.php b/system/HTTP/RequestInterface.php index 367c494928b8..cb55ccb5bff4 100644 --- a/system/HTTP/RequestInterface.php +++ b/system/HTTP/RequestInterface.php @@ -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. From d5b37deb1f0850003a155745c6967949cbf1aae2 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 25 Oct 2023 11:03:12 +0900 Subject: [PATCH 3/4] docs: add changelog --- user_guide_src/source/changelogs/v4.5.0.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/user_guide_src/source/changelogs/v4.5.0.rst b/user_guide_src/source/changelogs/v4.5.0.rst index 48cd6ddf2ca2..c4d4048c4f5f 100644 --- a/user_guide_src/source/changelogs/v4.5.0.rst +++ b/user_guide_src/source/changelogs/v4.5.0.rst @@ -137,6 +137,8 @@ Others ------ - **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. From 5a20f7bd9b422b840eee034ca02a5b92c8d78ff6 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 25 Oct 2023 11:04:41 +0900 Subject: [PATCH 4/4] docs: fix typo --- user_guide_src/source/changelogs/v4.5.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelogs/v4.5.0.rst b/user_guide_src/source/changelogs/v4.5.0.rst index c4d4048c4f5f..fb0ab21a3734 100644 --- a/user_guide_src/source/changelogs/v4.5.0.rst +++ b/user_guide_src/source/changelogs/v4.5.0.rst @@ -136,7 +136,7 @@ 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.