Skip to content
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

cleaner code with null safe #41478

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
8 changes: 8 additions & 0 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2139,6 +2139,14 @@
<code>$file</code>
</MoreSpecificImplementedParamType>
</file>
<file src="lib/private/Files/Cache/Scanner.php">
<RedundantCondition>
<code>$metadataQuery?->extractMetadata($data)->asArray() ?? []</code>
</RedundantCondition>
<TypeDoesNotContainNull>
<code>$metadataQuery?->extractMetadata($data)->asArray() ?? []</code>
</TypeDoesNotContainNull>
</file>
<file src="lib/private/Files/Cache/Scanner.php">
<InvalidArgument>
<code>self::SCAN_RECURSIVE_INCOMPLETE</code>
Expand Down
9 changes: 2 additions & 7 deletions lib/private/Files/Cache/QuerySearchHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,8 @@
$result = $query->execute();
$files = $result->fetchAll();

$rawEntries = array_map(function (array $data) use ($metadataQuery) {
// migrate to null safe ...
if ($metadataQuery === null) {
$data['metadata'] = [];
} else {
$data['metadata'] = $metadataQuery->extractMetadata($data)->asArray();
}
$rawEntries = array_map(function (array $data) use ($metadataQuery): CacheEntry {
$data['metadata'] = $metadataQuery?->extractMetadata($data)->asArray() ?? [];

Check failure on line 198 in lib/private/Files/Cache/QuerySearchHelper.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

RedundantCondition

lib/private/Files/Cache/QuerySearchHelper.php:198:24: RedundantCondition: Type array<array-key, mixed> for $<tmp coalesce var>7379 is never null (see https://psalm.dev/122)

Check failure on line 198 in lib/private/Files/Cache/QuerySearchHelper.php

View workflow job for this annotation

GitHub Actions / static-code-analysis

TypeDoesNotContainNull

lib/private/Files/Cache/QuerySearchHelper.php:198:78: TypeDoesNotContainNull: Cannot resolve types for $<tmp coalesce var>7379 - array<array-key, mixed> does not contain null (see https://psalm.dev/090)
return Cache::cacheEntryFromData($data, $this->mimetypeLoader);
}, $files);

Expand Down
Loading