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

Fix phpstan errors #3824

Merged
merged 1 commit into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,9 @@ private function addIdentifierCondition(
*
* Table expression and columns are not escaped and are not safe for user-input.
*
* @param string $table The SQL expression of the table on which to delete.
* @param array<string, mixed> $identifier The deletion criteria. An associative array containing column-value pairs.
* @param array<int, int|string>|array<string, int|string> $types The query parameter types.
* @param string $table The SQL expression of the table on which to delete.
* @param array<string, mixed> $identifier The deletion criteria. An associative array containing column-value pairs.
* @param array<int|string, int|string> $types The query parameter types.
*
* @return int The number of affected rows.
*
Expand Down Expand Up @@ -696,8 +696,8 @@ public function insert(string $table, array $data, array $types = []) : int
/**
* Extract ordered type list from an ordered column list and type map.
*
* @param array<int, string> $columnList
* @param array<int, int|string> $types The query parameter types.
* @param array<int, string> $columnList
* @param array<int|string, int|string> $types The query parameter types.
*
* @return array<int, int>|array<int, string>
*/
Expand Down Expand Up @@ -1358,8 +1358,8 @@ private function _bindTypedValues(DriverStatement $stmt, array $params, array $t
/**
* Gets the binding type of a given type. The given type can be a PDO or DBAL mapping type.
*
* @param mixed $value The value to bind.
* @param int|string|null $type The type to bind (PDO or DBAL).
* @param mixed $value The value to bind.
* @param int|string|Type|null $type The type to bind (PDO or DBAL).
*
* @return array<int, mixed> [0] => the (escaped) value, [1] => the binding type.
*/
Expand All @@ -1384,8 +1384,8 @@ private function getBindingInfo($value, $type) : array
* @internal This is a purely internal method. If you rely on this method, you are advised to
* copy/paste the code as this method may change, or be removed without prior notice.
*
* @param array<int, mixed>|array<string, mixed> $params
* @param array<int, int|string>|array<string, int|string> $types The query parameter types.
* @param array<int, mixed>|array<string, mixed> $params
* @param array<int, int|string|Type>|array<string, int|string|Type> $types The query parameter types.
*
* @return array<int, mixed>|array<string, mixed>
*/
Expand Down
8 changes: 5 additions & 3 deletions lib/Doctrine/DBAL/Logging/SQLLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Doctrine\DBAL\Logging;

use Doctrine\DBAL\Types\Type;

/**
* Interface for SQL loggers.
*/
Expand All @@ -12,9 +14,9 @@ interface SQLLogger
/**
* Logs a SQL statement somewhere.
*
* @param string $sql The SQL to be executed.
* @param mixed[] $params The SQL parameters.
* @param int[]|string[] $types The SQL parameter types.
* @param string $sql The SQL to be executed.
* @param mixed[] $params The SQL parameters.
* @param int[]|string[]|Type[] $types The SQL parameter types.
morozov marked this conversation as resolved.
Show resolved Hide resolved
*/
public function startQuery(string $sql, array $params = [], array $types = []) : void;

Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Query/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ public function setValue(string $column, string $value) : self
* );
* </code>
*
* @param array<int, mixed> $values The values to specify for the insert query indexed by column names.
* @param array<string, mixed> $values The values to specify for the insert query indexed by column names.
morozov marked this conversation as resolved.
Show resolved Hide resolved
*
* @return $this This QueryBuilder instance.
*/
Expand Down
14 changes: 4 additions & 10 deletions lib/Doctrine/DBAL/Schema/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -840,9 +840,9 @@ private function _createUniqueConstraint(array $columns, string $indexName, arra
}

/**
* @param array<string|int, string> $columns
* @param array<int, string> $flags
* @param array<string, mixed> $options
* @param array<int, string> $columns
* @param array<int, string> $flags
* @param array<string, mixed> $options
*
* @throws SchemaException
*/
Expand All @@ -852,13 +852,7 @@ private function _createIndex(array $columns, string $indexName, bool $isUnique,
throw IndexNameInvalid::new($indexName);
}

foreach ($columns as $index => $value) {
if (is_string($index)) {
$columnName = $index;
} else {
$columnName = $value;
}
morozov marked this conversation as resolved.
Show resolved Hide resolved

foreach ($columns as $columnName) {
if (! $this->hasColumn($columnName)) {
throw ColumnDoesNotExist::new($columnName, $this->_name);
}
Expand Down
4 changes: 2 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ parameters:
# https://bugs.php.net/bug.php?id=78126
- '~^Call to an undefined method PDO::sqliteCreateFunction\(\)\.\z~'

# https://github.com/phpstan/phpstan/issues/1847
- '~^Parameter #2 \$registeredAliases of static method Doctrine\\DBAL\\Query\\QueryException::nonUniqueAlias\(\) expects array<string>, array<int, int|string> given\.\z~'
# https://github.com/phpstan/phpstan/issues/2857
- '~^Parameter #2 \$registeredAliases of static method Doctrine\\DBAL\\Query\\Exception\\NonUniqueAlias::new\(\) expects array<string>, array<int, int\|string> given\.\z~'

# legacy remnants from doctrine/common
- '~^Class Doctrine\\Common\\(Collections\\Collection|Persistence\\Proxy) not found\.\z~'
Expand Down
14 changes: 0 additions & 14 deletions tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -617,20 +617,6 @@ public function testGeneratesDropIndexSQL() : void
));
}

public function testCannotGenerateDropIndexSQLWithInvalidIndexParameter() : void
{
$this->expectException(InvalidArgumentException::class);

$this->platform->getDropIndexSQL(['index'], 'table');
}

public function testCannotGenerateDropIndexSQLWithInvalidTableParameter() : void
{
$this->expectException(InvalidArgumentException::class);

$this->platform->getDropIndexSQL('index', ['table']);
}

public function testGeneratesSQLSnippets() : void
{
self::assertEquals('STRING(column1, "string1", column2, "string2")', $this->platform->getConcatExpression(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function testTableOptions() : void
}

/**
* @param string[] $overrideOptions
* @param array<string, mixed> $overrideOptions
*
* @return string[]
*/
Expand Down