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

Update Psalm to 5.12.0 #6061

Merged
merged 11 commits into from
Jun 13, 2023
Prev Previous commit
Next Next commit
Add more assertions against the column counts
  • Loading branch information
morozov committed Jun 12, 2023
commit 3ff4818e85193da482c9a6c228a397d7590208e9
15 changes: 11 additions & 4 deletions src/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use Traversable;

use function array_shift;
use function assert;
use function count;

class Result
{
Expand Down Expand Up @@ -109,8 +111,10 @@ public function fetchAllKeyValue(): array

$data = [];

foreach ($this->fetchAllNumeric() as [$key, $value]) {
$data[$key] = $value;
foreach ($this->fetchAllNumeric() as $row) {
assert(count($row) >= 2);
[$key, $value] = $row;
$data[$key] = $value;
}

return $data;
Expand Down Expand Up @@ -174,15 +178,18 @@ public function iterateAssociative(): Traversable
}

/**
* {@inheritDoc}
* @return Traversable<mixed,mixed>
*
* @throws Exception
*/
public function iterateKeyValue(): Traversable
{
$this->ensureHasKeyValue();

foreach ($this->iterateNumeric() as [$key, $value]) {
foreach ($this->iterateNumeric() as $row) {
assert(count($row) >= 2);
[$key, $value] = $row;

yield $key => $value;
}
}
Expand Down