Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/CopyrightFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ class CopyrightFactory
/** @var Copyright[] */
private array $cache = [];

public function make(mixed $data): ?Copyright // TODO!
/**
* @param array{
* notice?: mixed,
* license?: mixed,
* license_url?: mixed
Comment on lines +14 to +16
Copy link

Copilot AI Oct 26, 2025

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.

Suggested change
* notice?: mixed,
* license?: mixed,
* license_url?: mixed
* notice?: string|null,
* license?: string|null,
* license_url?: string|null

Copilot uses AI. Check for mistakes.
* } $data
*/
public function make(array $data): ?Copyright
{
if (! is_array($data)) {
return null;
}

$key = hash(
'xxh3',
json_encode($data, JSON_THROW_ON_ERROR)
Expand Down
10 changes: 8 additions & 2 deletions src/RecordFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,15 @@ private function makeReferences(array $data): array
*/
private function makeCopyrights(array $data): array
{
$rawCopyrights = $data['copyrights'] ?? null;
if (! is_array($rawCopyrights)) {
return [];
}
$rawCopyrights = array_filter($rawCopyrights, static fn (mixed $s) => is_array($s));
Copy link

Copilot AI Oct 26, 2025

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.

Suggested change
$rawCopyrights = array_filter($rawCopyrights, static fn (mixed $s) => is_array($s));
$rawCopyrights = array_values(array_filter($rawCopyrights, static fn (mixed $s) => is_array($s)));

Copilot uses AI. Check for mistakes.

$copyrights = array_map(
fn (mixed $datum): ?Copyright => $this->copyrightFactory->make($datum),
(array) ($data['copyrights'] ?? []),
fn (array $datum): ?Copyright => $this->copyrightFactory->make($datum),
$rawCopyrights,
);
$copyrights = array_filter($copyrights);

Expand Down