-
-
Notifications
You must be signed in to change notification settings - Fork 0
Type hint CopyrightFactory::make()
#31
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the type safety of the CopyrightFactory::make() method by changing its parameter type from mixed to array. The change includes adding proper PHPDoc documentation for the expected array structure and moving the type validation logic upstream to the caller.
Key changes:
- Added explicit
arraytype hint toCopyrightFactory::make()method - Added PHPDoc annotation documenting the expected array structure with optional keys
- Moved array validation from
CopyrightFactory::make()toRecordFactory::makeCopyrights()
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/CopyrightFactory.php | Updated make() method signature to accept array instead of mixed, added PHPDoc, removed internal validation |
| src/RecordFactory.php | Added upstream validation to filter non-array elements before calling CopyrightFactory::make() |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (! is_array($rawCopyrights)) { | ||
| return []; | ||
| } | ||
| $rawCopyrights = array_filter($rawCopyrights, static fn (mixed $s) => is_array($s)); |
Copilot
AI
Oct 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The array_filter removes non-array elements but doesn't preserve keys. Consider using array_values() after filtering to reindex the array, or verify that maintaining original keys is intentional for downstream processing.
| $rawCopyrights = array_filter($rawCopyrights, static fn (mixed $s) => is_array($s)); | |
| $rawCopyrights = array_values(array_filter($rawCopyrights, static fn (mixed $s) => is_array($s))); |
| * notice?: mixed, | ||
| * license?: mixed, | ||
| * license_url?: mixed |
Copilot
AI
Oct 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PHPDoc uses mixed types for all array values, which provides limited type information. Consider documenting the expected types (e.g., string) for these fields to improve type safety and developer understanding.
| * notice?: mixed, | |
| * license?: mixed, | |
| * license_url?: mixed | |
| * notice?: string|null, | |
| * license?: string|null, | |
| * license_url?: string|null |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #31 +/- ##
============================================
- Coverage 88.50% 88.11% -0.39%
Complexity 77 77
============================================
Files 12 12
Lines 200 202 +2
============================================
+ Hits 177 178 +1
- Misses 23 24 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.