Skip to content

Commit 785995a

Browse files
authored
Merge pull request #8090 from kenjis/remove-Request-isValidIP
refactor: remove deprecated Request::isValidIP()
2 parents bfd7719 + 5a20f7b commit 785995a

File tree

5 files changed

+3
-143
lines changed

5 files changed

+3
-143
lines changed

system/HTTP/Request.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace CodeIgniter\HTTP;
1313

14-
use CodeIgniter\Validation\FormatRules;
1514
use Config\App;
1615

1716
/**
@@ -50,21 +49,6 @@ public function __construct($config = null) // @phpstan-ignore-line
5049
}
5150
}
5251

53-
/**
54-
* Validate an IP address
55-
*
56-
* @param string $ip IP Address
57-
* @param string $which IP protocol: 'ipv4' or 'ipv6'
58-
*
59-
* @deprecated 4.0.5 Use Validation instead
60-
*
61-
* @codeCoverageIgnore
62-
*/
63-
public function isValidIP(?string $ip = null, ?string $which = null): bool
64-
{
65-
return (new FormatRules())->valid_ip($ip, $which);
66-
}
67-
6852
/**
6953
* Get the request method.
7054
*

system/HTTP/RequestInterface.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,6 @@ interface RequestInterface extends OutgoingRequestInterface
2626
*/
2727
public function getIPAddress(): string;
2828

29-
/**
30-
* Validate an IP address
31-
*
32-
* @param string $ip IP Address
33-
* @param string $which IP protocol: 'ipv4' or 'ipv6'
34-
*
35-
* @deprecated Use Validation instead
36-
*/
37-
public function isValidIP(string $ip, ?string $which = null): bool;
38-
3929
/**
4030
* Fetch an item from the $_SERVER array.
4131
* Supplied by RequestTrait.

tests/system/HTTP/CLIRequestTest.php

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -517,64 +517,6 @@ public function testFetchGlobalWithEmptyNotation(): void
517517
$this->assertSame($expected, $this->request->fetchGlobal('post', 'clients[]'));
518518
}
519519

520-
public static function provideValidIPAddress(): iterable
521-
{
522-
return [
523-
'empty' => [
524-
false,
525-
'',
526-
],
527-
'zero' => [
528-
false,
529-
0,
530-
],
531-
'large_ipv4' => [
532-
false,
533-
'256.256.256.999',
534-
'ipv4',
535-
],
536-
'good_ipv4' => [
537-
true,
538-
'100.100.100.0',
539-
'ipv4',
540-
],
541-
'good_default' => [
542-
true,
543-
'100.100.100.0',
544-
],
545-
'zeroed_ipv4' => [
546-
true,
547-
'0.0.0.0',
548-
],
549-
'large_ipv6' => [
550-
false,
551-
'h123:0000:0000:0000:0000:0000:0000:0000',
552-
'ipv6',
553-
],
554-
'good_ipv6' => [
555-
true,
556-
'2001:0db8:85a3:0000:0000:8a2e:0370:7334',
557-
],
558-
'confused_ipv6' => [
559-
false,
560-
'255.255.255.255',
561-
'ipv6',
562-
],
563-
];
564-
}
565-
566-
/**
567-
* @dataProvider provideValidIPAddress
568-
*
569-
* @param mixed $expected
570-
* @param mixed $address
571-
* @param mixed|null $type
572-
*/
573-
public function testValidIPAddress($expected, $address, $type = null): void
574-
{
575-
$this->assertSame($expected, $this->request->isValidIP($address, $type));
576-
}
577-
578520
public function testGetIPAddressDefault(): void
579521
{
580522
$this->assertSame('0.0.0.0', $this->request->getIPAddress());

tests/system/HTTP/RequestTest.php

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -533,64 +533,6 @@ public function testFetchGlobalFiltersWithArrayChildElement(): void
533533
$this->assertSame($expected, $this->request->fetchGlobal('post', 'people[0]', FILTER_VALIDATE_INT));
534534
}
535535

536-
public static function provideValidIPAddress(): iterable
537-
{
538-
return [
539-
'empty' => [
540-
false,
541-
'',
542-
],
543-
'zero' => [
544-
false,
545-
0,
546-
],
547-
'large_ipv4' => [
548-
false,
549-
'256.256.256.999',
550-
'ipv4',
551-
],
552-
'good_ipv4' => [
553-
true,
554-
'100.100.100.0',
555-
'ipv4',
556-
],
557-
'good_default' => [
558-
true,
559-
'100.100.100.0',
560-
],
561-
'zeroed_ipv4' => [
562-
true,
563-
'0.0.0.0',
564-
],
565-
'large_ipv6' => [
566-
false,
567-
'h123:0000:0000:0000:0000:0000:0000:0000',
568-
'ipv6',
569-
],
570-
'good_ipv6' => [
571-
true,
572-
'2001:0db8:85a3:0000:0000:8a2e:0370:7334',
573-
],
574-
'confused_ipv6' => [
575-
false,
576-
'255.255.255.255',
577-
'ipv6',
578-
],
579-
];
580-
}
581-
582-
/**
583-
* @dataProvider provideValidIPAddress
584-
*
585-
* @param mixed $expected
586-
* @param mixed $address
587-
* @param mixed|null $type
588-
*/
589-
public function testValidIPAddress($expected, $address, $type = null): void
590-
{
591-
$this->assertSame($expected, $this->request->isValidIP($address, $type));
592-
}
593-
594536
public function testGetIPAddressDefault(): void
595537
{
596538
$this->assertSame('0.0.0.0', $this->request->getIPAddress());

user_guide_src/source/changelogs/v4.5.0.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ Spark Commands
136136
Others
137137
------
138138

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

0 commit comments

Comments
 (0)