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

Add helper for PSR-16/void-cache #1190

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Add helper for PSR-16/void-cache #1190

wants to merge 1 commit into from

Conversation

SQKo
Copy link
Member

@SQKo SQKo commented Dec 3, 2023

A void/null cache class for PSR-16/SimpleCache implementation

might want to have its own repo

Comment on lines +38 to +44
$result = [];

foreach ($keys as $key) {
$result[$key] = $default;
}

return $result;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$result = [];
foreach ($keys as $key) {
$result[$key] = $default;
}
return $result;
return array_fill_keys($keys, $default);

Though not sure if it accepts iterable, so maybe this instead?

Suggested change
$result = [];
foreach ($keys as $key) {
$result[$key] = $default;
}
return $result;
return array_fill_keys(iterator_to_array($keys), $default);

Copy link
Member Author

@SQKo SQKo May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought of this before, but i changed my mind

Now i forgot why i changed my mind, it was probably something with the object's getIterator() implementation and the use of Generator, but not sure which

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants