Add residential property to Anonymizer record#319
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe anonymizer model now supports a residential feed containing confidence, last-seen, and provider data. A new immutable record handles parsing and serialization, with tests covering full, residential-only, and empty inputs. ChangesAnonymizer residential feed
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant InputRecord
participant Anonymizer
participant AnonymizerFeed
InputRecord->>Anonymizer: residential array
Anonymizer->>AnonymizerFeed: construct feed record
Anonymizer->>AnonymizerFeed: jsonSerialize()
AnonymizerFeed-->>Anonymizer: residential JSON fields
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a new residential property to the Anonymizer record, represented by the new AnonymizerFeed class, to support data from the GeoIP Residential Proxy database. It also includes comprehensive test coverage for this new feature. The review feedback suggests adding a defensive type check to ensure $record['residential'] is an array before instantiating AnonymizerFeed to prevent potential runtime type errors.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| $this->residential = isset($record['residential']) | ||
| ? new AnonymizerFeed($record['residential']) | ||
| : null; |
There was a problem hiding this comment.
To prevent a potential TypeError at runtime, it is safer to verify that $record['residential'] is indeed an array before passing it to the AnonymizerFeed constructor. If the API response is malformed or contains an unexpected type for this key, this defensive check will prevent a crash.
$this->residential = isset($record['residential']) && \is_array($record['residential'])
? new AnonymizerFeed($record['residential'])
: null;There was a problem hiding this comment.
Claude, on behalf of Greg: Declining this one. The record constructors in this library intentionally read fields with plain ?? null / isset access and no type guards — every sibling field in this constructor and the other Record classes follow that pattern, and the input comes from our own web service response decoding rather than untrusted data. A one-off is_array check here would be inconsistent with the rest of the records.
f0d050c to
0449833
Compare
8f738eb to
1abe2bc
Compare
Add a residential sub-object to the anonymizer object with confidence, networkLastSeen, and providerName. Residential proxy data may be present even when the other anonymizer properties are unset, so the anonymizer object may now be returned with only this property set. The new GeoIp2\Record\AnonymizerFeed class is written to be reused if the server adds sibling sub-objects (vpn, mobile, datacenter) with the same shape. STF-997 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1abe2bc to
be47d40
Compare
Summary
The GeoIP Insights web service is adding a
residentialsub-object to theanonymizerobject. It contains residential proxy data for the network and may be populated even when no other anonymizer properties are set.confidence,network_last_seen,provider_name) namedAnonymizerFeed, so future anonymizer feeds can share itresidentialproperty on theAnonymizerrecordresidentialis always constructed (an emptyAnonymizerFeedwhen there is no data), matching the library's existing sub-object pattern, and is omitted fromjsonSerialize()output when empty.Testing
phpunit,php-cs-fixer,phpcs, andphpstanall pass.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation