Skip to content

Commit

Permalink
Upgrade psalm-5.6. (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw authored Feb 14, 2023
1 parent 5b4ef4d commit 7250c1e
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"rector/rector": "^0.14",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.18",
"vimeo/psalm": "^4.30|^5.6",
"yiisoft/aliases": "^1.1|^2.0",
"yiisoft/cache-file": "^2.0",
"yiisoft/di": "^1.0",
Expand Down
24 changes: 13 additions & 11 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="false"
resolveFromConfigFile="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
</psalm>
3 changes: 3 additions & 0 deletions src/Expression/ArrayExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
*
* Which, depending on DBMS, will result in a well-prepared condition. For example, in PostgresSQL it will be compiled
* to `WHERE "items" @> ARRAY[1, 2, 3]::integer[]`.
*
* @template-implements ArrayAccess<int, mixed>
* @template-implements IteratorAggregate<int>
*/
class ArrayExpression implements ExpressionInterface, ArrayAccess, Countable, IteratorAggregate
{
Expand Down
6 changes: 5 additions & 1 deletion src/Helper/ArrayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,13 @@ public static function getValueByPath(object|array $array, Closure|string $key,
* @throws \Exception
*
* @return array the indexed and/or grouped array
*
* @psalm-suppress MixedArrayAssignment
*/
public static function index(array $array, string|null $key = null, array $groups = []): array
{
$result = [];

foreach ($array as $element) {
$lastArray = &$result;

Expand All @@ -229,12 +232,13 @@ public static function index(array $array, string|null $key = null, array $group
/** @psalm-var mixed $value */
$value = self::getValueByPath($element, $key);
if ($value !== null) {
$lastArray[(string)$value] = $element;
$lastArray[(string) $value] = $element;
}
}
unset($lastArray);
}

/** @psalm-var array $result */
return $result;
}

Expand Down
2 changes: 2 additions & 0 deletions src/Query/BatchQueryResultInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* foreach ($query->each() as $user) {
* }
* ```
*
* @extends Iterator<int|string, mixed>
*/
interface BatchQueryResultInterface extends Iterator
{
Expand Down
2 changes: 2 additions & 0 deletions src/Query/Data/DataReaderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*
* Note that since DataReader is a forward-only stream, you can only traverse it once. Doing it the second time will
* throw an exception.
*
* @extends Iterator<int|string, mixed>
*/
interface DataReaderInterface extends Iterator, Countable
{
Expand Down
2 changes: 2 additions & 0 deletions src/QueryBuilder/AbstractDQLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public function buildGroupBy(array $columns, array &$params = []): string
}
}

/** @psalm-var array<string, Expression|string> $columns */
return 'GROUP BY ' . implode(', ', $columns);
}

Expand Down Expand Up @@ -371,6 +372,7 @@ public function buildSelect(
}
}

/** @psalm-var array<string, Expression|string> $columns */
return $select . ' ' . implode(', ', $columns);
}

Expand Down

0 comments on commit 7250c1e

Please sign in to comment.