Skip to content

Fix deprecation notice on PHP 8.5 about using null for array access.#29

Merged
joshmcrae merged 2 commits intotithely:masterfrom
rrigby:fix-null-array-access
Apr 1, 2026
Merged

Fix deprecation notice on PHP 8.5 about using null for array access.#29
joshmcrae merged 2 commits intotithely:masterfrom
rrigby:fix-null-array-access

Conversation

@rrigby
Copy link
Copy Markdown
Contributor

@rrigby rrigby commented Mar 6, 2026

Check for null before trying to access array. This happens when a the key for a join is nullable.
Also some minor improvements, use array_unique for the in() query param to prevent us passing the same thing a hundred times to in
And do array_values when we do the grouping so we only do it once.

This resolves it, plus slightly improves performance.
@rrigby rrigby changed the title Fix deprecation notice on 8.5 about using null for array access. Fix deprecation notice on PHP 8.5 about using null for array access. Mar 7, 2026
$mapping
->join($property->getJoinTable(), $property->getJoinLocalColumn(), $property->getForeignColumn())
->in(sprintf('%s.%s', $property->getJoinTable(), $property->getJoinForeignColumn()), array_column($data, $property->getLocalColumn()));
->in(sprintf('%s.%s', $property->getJoinTable(), $property->getJoinForeignColumn()), $localValues);

Check failure

Code scanning / Psalm

PossiblyNullArgument Error

Argument 2 of sprintf cannot be null, possibly null value provided
$mapping
->join($property->getJoinTable(), $property->getJoinLocalColumn(), $property->getForeignColumn())
->in(sprintf('%s.%s', $property->getJoinTable(), $property->getJoinForeignColumn()), array_column($data, $property->getLocalColumn()));
->in(sprintf('%s.%s', $property->getJoinTable(), $property->getJoinForeignColumn()), $localValues);

Check failure

Code scanning / Psalm

PossiblyNullArgument Error

Argument 3 of sprintf cannot be null, possibly null value provided
$properties[$property->getName()] = Collection::group($results, function ($result) use ($groupColumn) {
return $result[$groupColumn];
});
$properties[$property->getName()] = array_map(fn($group) => array_values($group), Collection::group($results, fn ($result) => $result[$groupColumn]));

Check failure

Code scanning / Psalm

PossiblyNullArrayOffset Error

Cannot access value on variable $result using possibly null offset null|string
@joshmcrae
Copy link
Copy Markdown
Member

Looks okay. Need to update your fork from tithely:master to resolve conflicts.

@joshmcrae joshmcrae merged commit 5009bfe into tithely:master Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants