You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #58038 [HttpFoundation] Add optional $v4Bytes and $v6Bytes parameters to IpUtils::anonymize() (alexandre-daubois)
This PR was merged into the 7.2 branch.
Discussion
----------
[HttpFoundation] Add optional `$v4Bytes` and `$v6Bytes` parameters to `IpUtils::anonymize()`
| Q | A
| ------------- | ---
| Branch? | 7.2
| Bug fix? | on
| New feature? | yes
| Deprecations? | no
| Issues | Fix#50778
| License | MIT
| Doc PR | symfony/symfony-docs#20138
This PR answers to the need of more anonymization of IP addresses. This adds 2 new parameters to the `IpUtils::anonymize()` that you can use this way:
```php
$ipv4 = '123.234.235.236';
$anonymousIpv4 = IpUtils::anonymize($ipv4, v4Bytes: 3);
// $anonymousIpv4 = '123.0.0.0'
$ipv6 = '2a01:198:603:10:396e:4789:8e99:890f';
$anonymousIpv6 = IpUtils::anonymize($ipv6, v6Bytes: 10);
// $anonymousIpv6 = '2a01:198:603::'
```
Commits
-------
53c4f92 [HttpFoundation] Add optional `$v4Bytes` and `$v6Bytes` parameters to `IpUtils::anonymize()`
0 commit comments