Skip to content

Commit

Permalink
WIP Psalm 5.10.0-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed Apr 3, 2023
1 parent e252152 commit 4263e6f
Show file tree
Hide file tree
Showing 24 changed files with 135 additions and 77 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"squizlabs/php_codesniffer": "3.7.2",
"symfony/cache": "^5.4|^6.0",
"symfony/console": "^4.4|^5.4|^6.0",
"vimeo/psalm": "4.30.0"
"vimeo/psalm": "^5.10.0@dev"
},
"suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files."
Expand Down
41 changes: 38 additions & 3 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
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"
findUnusedBaselineEntry="false"
findUnusedCode="false"
>
<projectFiles>
<directory name="src" />
Expand Down Expand Up @@ -607,6 +609,9 @@
<!-- We're testing with invalid input here. -->
<file name="tests/Functional/LegacyAPITest.php"/>
<file name="tests/Platforms/AbstractPlatformTestCase.php"/>

<!-- See https://bugs.php.net/bug.php?id=77591 -->
<referencedFunction name="db2_autocommit"/>
</errorLevel>
</InvalidArgument>
<InvalidDocblock>
Expand All @@ -627,6 +632,12 @@
<file name="src/Driver/PDO/Exception.php"/>
</errorLevel>
</InvalidPropertyAssignmentValue>
<LessSpecificReturnStatement>
<errorLevel type="suppress">
<!-- Psalm does not understand the polymorphism of the PDO::fetch() and fetchAll() methods -->
<file name="src/Driver/PDO/Result.php"/>
</errorLevel>
</LessSpecificReturnStatement>
<MissingConstructor>
<errorLevel type="suppress">
<!--
Expand All @@ -636,6 +647,12 @@
<file name="src/Schema/SchemaConfig.php"/>
</errorLevel>
</MissingConstructor>
<MoreSpecificReturnType>
<errorLevel type="suppress">
<!-- Psalm does not understand the polymorphism of the PDO::fetch() and fetchAll() methods -->
<file name="src/Driver/PDO/Result.php"/>
</errorLevel>
</MoreSpecificReturnType>
<NullableReturnStatement>
<errorLevel type="suppress">
<!--
Expand Down Expand Up @@ -811,6 +828,7 @@
This issue should be fixed in 4.0
-->
<file name="src/Connection.php"/>
<file name="src/Driver/Mysqli/Result.php"/>
<file name="src/Statement.php"/>
<file name="src/Query/QueryBuilder.php"/>
</errorLevel>
Expand All @@ -823,6 +841,7 @@
This issue should be fixed in 4.0
-->
<file name="src/Connection.php"/>
<file name="src/Driver/Mysqli/Result.php"/>
<file name="src/Statement.php"/>
<file name="src/Query/QueryBuilder.php"/>
</errorLevel>
Expand All @@ -838,10 +857,26 @@

<!-- See https://github.com/doctrine/dbal/pull/3574 -->
<file name="tests/Query/Expression/ExpressionBuilderTest.php"/>

<!-- See https://bugs.php.net/bug.php?id=77591 -->
<referencedFunction name="db2_autocommit"/>
</errorLevel>
</InvalidScalarArgument>
<MethodSignatureMustProvideReturnType>
<errorLevel type="suppress">
<!-- https://github.com/vimeo/psalm/issues/8557 -->
<file name="src/Query/Expression/CompositeExpression.php"/>
<file name="src/Query/QueryBuilder.php"/>
</errorLevel>
</MethodSignatureMustProvideReturnType>
<NoValue>
<errorLevel type="suppress">
<!-- We're checking for invalid input. -->
<file name="src/Platforms/AbstractPlatform.php"/>
<file name="src/Platforms/SQLServerPlatform.php"/>
</errorLevel>
</NoValue>
<UnsupportedReferenceUsage>
<errorLevel type="suppress">
<file name="src/Driver/SQLSrv/Statement.php"/>
</errorLevel>
</UnsupportedReferenceUsage>
</issueHandlers>
</psalm>
2 changes: 1 addition & 1 deletion src/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
final class CannotCopyStreamToStream extends AbstractException
{
/** @psalm-param array{message: string}|null $error */
/** @psalm-param array{message: string, ...mixed}|null $error */
public static function new(?array $error): self
{
$message = 'Could not copy source stream to temporary file';
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/IBMDB2/Exception/CannotCreateTemporaryFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
final class CannotCreateTemporaryFile extends AbstractException
{
/** @psalm-param array{message: string}|null $error */
/** @psalm-param array{message: string, ...mixed}|null $error */
public static function new(?array $error): self
{
$message = 'Could not create temporary file';
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/IBMDB2/Exception/PrepareFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
final class PrepareFailed extends AbstractException
{
/** @psalm-param array{message: string}|null $error */
/** @psalm-param array{message: string, ...mixed}|null $error */
public static function new(?array $error): self
{
if ($error === null) {
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/Mysqli/Exception/ConnectionError.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public static function upcast(mysqli_sql_exception $exception): self
$p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate');
$p->setAccessible(true);

return new self($exception->getMessage(), $p->getValue($exception), (int) $exception->getCode(), $exception);
return new self($exception->getMessage(), $p->getValue($exception), $exception->getCode(), $exception);
}
}
2 changes: 1 addition & 1 deletion src/Driver/Mysqli/Exception/ConnectionFailed.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public static function upcast(mysqli_sql_exception $exception): self
$p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate');
$p->setAccessible(true);

return new self($exception->getMessage(), $p->getValue($exception), (int) $exception->getCode(), $exception);
return new self($exception->getMessage(), $p->getValue($exception), $exception->getCode(), $exception);
}
}
2 changes: 1 addition & 1 deletion src/Driver/Mysqli/Exception/InvalidCharset.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function upcast(mysqli_sql_exception $exception, string $charset):
return new self(
sprintf('Failed to set charset "%s": %s', $charset, $exception->getMessage()),
$p->getValue($exception),
(int) $exception->getCode(),
$exception->getCode(),
$exception,
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/Mysqli/Exception/StatementError.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public static function upcast(mysqli_sql_exception $exception): self
$p = new ReflectionProperty(mysqli_sql_exception::class, 'sqlstate');
$p->setAccessible(true);

return new self($exception->getMessage(), $p->getValue($exception), (int) $exception->getCode(), $exception);
return new self($exception->getMessage(), $p->getValue($exception), $exception->getCode(), $exception);
}
}
2 changes: 1 addition & 1 deletion src/Platforms/AbstractMySQLPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -1417,7 +1417,7 @@ public function createSchemaManager(Connection $connection): MySQLSchemaManager
}

/**
* @param list<T> $assets
* @param array<T> $assets
*
* @return array<string,T>
*
Expand Down
8 changes: 4 additions & 4 deletions src/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -2172,7 +2172,7 @@ private function buildCreateTableSQL(Table $table, bool $createIndexes, bool $cr
}

/**
* @param list<Table> $tables
* @param array<Table> $tables
*
* @return list<string>
*
Expand All @@ -2199,7 +2199,7 @@ public function getCreateTablesSQL(array $tables): array
}

/**
* @param list<Table> $tables
* @param array<Table> $tables
*
* @return list<string>
*/
Expand Down Expand Up @@ -2840,7 +2840,7 @@ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff)
return $sql;
}

/** @return string[] */
/** @return list<string> */
protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff)
{
$sql = [];
Expand Down Expand Up @@ -2888,7 +2888,7 @@ protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff)
* @param Index $index The definition of the index to rename to.
* @param string $tableName The table to rename the given index on.
*
* @return string[] The sequence of SQL statements for renaming the given index.
* @return list<string> The sequence of SQL statements for renaming the given index.
*/
protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName)
{
Expand Down
48 changes: 24 additions & 24 deletions src/Schema/SchemaDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SchemaDiff
*
* @internal Use {@link getCreatedSchemas()} instead.
*
* @var string[]
* @var array<string, string>
*/
public $newNamespaces = [];

Expand All @@ -38,7 +38,7 @@ class SchemaDiff
*
* @internal Use {@link getDroppedSchemas()} instead.
*
* @var string[]
* @var array<string, string>
*/
public $removedNamespaces = [];

Expand All @@ -47,7 +47,7 @@ class SchemaDiff
*
* @internal Use {@link getCreatedTables()} instead.
*
* @var Table[]
* @var array<string, Table>
*/
public $newTables = [];

Expand All @@ -56,7 +56,7 @@ class SchemaDiff
*
* @internal Use {@link getAlteredTables()} instead.
*
* @var TableDiff[]
* @var array<string, TableDiff>
*/
public $changedTables = [];

Expand All @@ -65,28 +65,28 @@ class SchemaDiff
*
* @internal Use {@link getDroppedTables()} instead.
*
* @var Table[]
* @var array<string, Table>
*/
public $removedTables = [];

/**
* @internal Use {@link getCreatedSequences()} instead.
*
* @var Sequence[]
* @var list<Sequence>
*/
public $newSequences = [];

/**
* @internal Use {@link getAlteredSequences()} instead.
*
* @var Sequence[]
* @var list<Sequence>
*/
public $changedSequences = [];

/**
* @internal Use {@link getDroppedSequences()} instead.
*
* @var Sequence[]
* @var list<Sequence>
*/
public $removedSequences = [];

Expand All @@ -102,14 +102,14 @@ class SchemaDiff
*
* @internal The diff can be only instantiated by a {@see Comparator}.
*
* @param Table[] $newTables
* @param TableDiff[] $changedTables
* @param Table[] $removedTables
* @param array<string> $createdSchemas
* @param array<string> $droppedSchemas
* @param array<Sequence> $createdSequences
* @param array<Sequence> $alteredSequences
* @param array<Sequence> $droppedSequences
* @param array<string, Table> $newTables
* @param array<string, TableDiff> $changedTables
* @param array<string, Table> $removedTables
* @param array<string, string> $createdSchemas
* @param array<string, string> $droppedSchemas
* @param list<Sequence> $createdSequences
* @param list<Sequence> $alteredSequences
* @param list<Sequence> $droppedSequences
*/
public function __construct(
$newTables = [],
Expand Down Expand Up @@ -137,49 +137,49 @@ public function __construct(
$this->removedSequences = $droppedSequences;
}

/** @return array<string> */
/** @return array<string, string> */
public function getCreatedSchemas(): array
{
return $this->newNamespaces;
}

/** @return array<string> */
/** @return array<string, string> */
public function getDroppedSchemas(): array
{
return $this->removedNamespaces;
}

/** @return array<Table> */
/** @return array<string, Table> */
public function getCreatedTables(): array
{
return $this->newTables;
}

/** @return array<TableDiff> */
/** @return array<string, TableDiff> */
public function getAlteredTables(): array
{
return $this->changedTables;
}

/** @return array<Table> */
/** @return array<string, Table> */
public function getDroppedTables(): array
{
return $this->removedTables;
}

/** @return array<Sequence> */
/** @return list<Sequence> */
public function getCreatedSequences(): array
{
return $this->newSequences;
}

/** @return array<Sequence> */
/** @return list<Sequence> */
public function getAlteredSequences(): array
{
return $this->changedSequences;
}

/** @return array<Sequence> */
/** @return list<Sequence> */
public function getDroppedSequences(): array
{
return $this->removedSequences;
Expand Down
14 changes: 6 additions & 8 deletions src/Schema/TableDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class TableDiff
*
* @internal Use {@see getAddedForeignKeys()} instead.
*
* @var ForeignKeyConstraint[]
* @var list<ForeignKeyConstraint>
*/
public $addedForeignKeys = [];

Expand All @@ -114,7 +114,7 @@ class TableDiff
*
* @internal Use {@see getModifiedForeignKeys()} instead.
*
* @var ForeignKeyConstraint[]
* @var list<ForeignKeyConstraint>
*/
public $changedForeignKeys = [];

Expand All @@ -123,7 +123,7 @@ class TableDiff
*
* @internal Use {@see getDroppedForeignKeys()} instead.
*
* @var (ForeignKeyConstraint|string)[]
* @var list<ForeignKeyConstraint|string>
*/
public $removedForeignKeys = [];

Expand Down Expand Up @@ -333,12 +333,10 @@ public function getDroppedForeignKeys(): array
*/
public function unsetDroppedForeignKey($foreignKey): void
{
$this->removedForeignKeys = array_filter(
$this->removedForeignKeys = array_values(array_filter(
$this->removedForeignKeys,
static function ($removedForeignKey) use ($foreignKey): bool {
return $removedForeignKey !== $foreignKey;
},
);
static fn ($removedForeignKey): bool => $removedForeignKey !== $foreignKey,
));
}

/**
Expand Down

0 comments on commit 4263e6f

Please sign in to comment.