Skip to content

Commit

Permalink
Fix psalm (#832)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov authored May 4, 2024
1 parent db7394f commit c2deb4c
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 29 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
on:
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'phpunit.xml.dist'
paths:
- 'src/**'
- 'config/**'
- 'psalm*.xml'

push:
paths-ignore:
- 'docs/**'
- 'README.md'
- 'CHANGELOG.md'
- '.gitignore'
- '.gitattributes'
- 'infection.json.dist'
- 'phpunit.xml.dist'
paths:
- 'src/**'
- 'config/**'
- 'psalm*.xml'

name: static analysis

Expand All @@ -28,4 +20,12 @@ jobs:
os: >-
['ubuntu-latest']
php: >-
['8.1', '8.2', '8.3']
['8.1', '8.2']
psalm83:
uses: yiisoft/actions/.github/workflows/psalm.yml@master
with:
psalm-config: psalm83.xml
os: >-
['ubuntu-latest']
php: >-
['8.3']
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"rector/rector": "^1.0",
"roave/infection-static-analysis-plugin": "^1.16",
"spatie/phpunit-watcher": "^1.23",
"vimeo/psalm": "^4.30|^5.20",
"vimeo/psalm": "^4.30|^5.24",
"yiisoft/aliases": "^3.0",
"yiisoft/cache-file": "^3.1",
"yiisoft/di": "^1.0",
Expand Down
6 changes: 3 additions & 3 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="false"
findUnusedVariablesAndParams="true"
findUnusedPsalmSuppress="true"
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>
<directory name="config" />
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
Expand Down
22 changes: 22 additions & 0 deletions psalm83.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="false"
findUnusedVariablesAndParams="true"
findUnusedPsalmSuppress="true"
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" />
<directory name="config" />
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress" />
<RiskyTruthyFalsyComparison errorLevel="suppress" />
<MissingClassConstType errorLevel="suppress" />
</issueHandlers>
</psalm>
1 change: 0 additions & 1 deletion src/Driver/Pdo/AbstractPdoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public function prepare(bool|null $forRead = null): void
$this->bindPendingParams();
} catch (PDOException $e) {
$message = $e->getMessage() . "\nFailed to prepare SQL: $sql";
/** @psalm-var array|null $errorInfo */
$errorInfo = $e->errorInfo ?? null;

throw new Exception($message, $errorInfo, $e);
Expand Down
2 changes: 0 additions & 2 deletions src/Driver/Pdo/AbstractPdoSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ abstract class AbstractPdoSchema extends AbstractSchema
*/
protected function generateCacheKey(): array
{
$cacheKey = [];

if ($this->db instanceof PdoConnectionInterface) {
$cacheKey = [$this->db->getDriver()->getDsn(), $this->db->getDriver()->getUsername()];
} else {
Expand Down
1 change: 0 additions & 1 deletion src/Exception/ConvertException.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function run(): Exception
{
$message = $this->e->getMessage() . PHP_EOL . 'The SQL being executed was: ' . $this->rawSql;

/** @var array|null $errorInfo */
$errorInfo = $this->e instanceof PDOException ? $this->e->errorInfo : null;

return match (
Expand Down
1 change: 0 additions & 1 deletion src/Expression/AbstractExpressionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ private function appendParams(array &$expressionParams, array &$params): array

$replacements = [];

/** @var non-empty-string $name */
foreach ($nonUniqueParams as $name => $value) {
$paramName = $name[0] === ':' ? substr($name, 1) : $name;
$uniqueName = $this->getUniqueName($paramName, $params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public function build(HashConditionInterface $expression, array &$params = []):

/**
* @psalm-var array<string, array|mixed> $hash
* @psalm-var array|mixed $value
*/
foreach ($hash as $column => $value) {
if (is_iterable($value) || $value instanceof QueryInterface) {
Expand Down
2 changes: 0 additions & 2 deletions src/QueryBuilder/DQLQueryBuilderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,6 @@ public function createConditionFromArray(array $condition): ConditionInterface;
* @throws InvalidArgumentException
*
* @return object Instance of {@see ExpressionBuilderInterface} for the given expression.
*
* @psalm-suppress InvalidStringClass
*/
public function getExpressionBuilder(ExpressionInterface $expression): object;

Expand Down

0 comments on commit c2deb4c

Please sign in to comment.