Skip to content

Commit

Permalink
Psalm level 1
Browse files Browse the repository at this point in the history
  • Loading branch information
xepozz committed Mar 16, 2024
1 parent dea5f69 commit 458a04b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<psalm
errorLevel="2"
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand Down
12 changes: 8 additions & 4 deletions src/Remap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Xepozz\Remap;

use Generator;
use Iterator;
use Throwable;
use Yiisoft\Db\Connection\ConnectionInterface;
use Yiisoft\Db\Exception\Exception;
Expand All @@ -20,18 +22,20 @@ public function __construct(

/**
* @template T
* @param class-string<T> $class
* @return iterable<T>
* @throws Throwable
* @psalm-param class-string<T> $class
* @psalm-param string|array{0:string,1:array} $sql
* @psalm-return Generator<T>
* @throws Exception
* @throws InvalidConfigException
* @throws Throwable
*/
public function map(string $class, string|array $sql, array $params = []): iterable
public function map(string $class, string|array $sql, array $params = []): Generator
{
if (is_array($sql)) {
$params = $sql[1] ?? $params;
$sql = $sql[0];
}
/** @psalm-var Iterator<array> $iterator */
$iterator = $this->connection->createCommand($sql, $params)->query();
foreach ($iterator as $row) {
yield $this->hydrator->create($class, $row);
Expand Down

0 comments on commit 458a04b

Please sign in to comment.