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

Fix Client template #1017

Merged
merged 1 commit into from
Jan 17, 2023
Merged

Fix Client template #1017

merged 1 commit into from
Jan 17, 2023

Conversation

franmomu
Copy link
Contributor

#810 added generics to Client, that means that when using Client you should specify both parameters, getting this kind of message using static analysis tools:

Method App\My\Service::__construct() has parameter $redisClient with generic class Predis\Client but does not specify its types:
         TKey, TValue

Looking at what Client::getIterator() does:

predis/src/Client.php

Lines 523 to 539 in fbf2701

public function getIterator()
{
$clients = array();
$connection = $this->getConnection();
if (!$connection instanceof Traversable) {
return new \ArrayIterator(array(
(string) $connection => new static($connection, $this->getOptions())
));
}
foreach ($connection as $node) {
$clients[(string) $node] = new static($node, $this->getOptions());
}
return new \ArrayIterator($clients);
}

it returns an \ArrayIterator having as keys strings and as values instances of the class itself, so I think this class shouldn't be generic.

@tillkruss
Copy link
Member

Are you running PHPStan? How do you feel about setting up basic level 1 or 2 testing for this repo?

@tillkruss tillkruss self-assigned this Jan 17, 2023
@tillkruss tillkruss merged commit 2bfc8a9 into predis:main Jan 17, 2023
@franmomu franmomu deleted the fix_client_template branch January 18, 2023 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants