Skip to content

Commit

Permalink
Fix phpstan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Jan 16, 2020
1 parent e0a92b0 commit 38e0a29
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 25 deletions.
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 @@ -1384,8 +1384,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 @@ -1410,8 +1410,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.
*/
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.
*
* @return $this This QueryBuilder instance.
*/
Expand Down
14 changes: 5 additions & 9 deletions lib/Doctrine/DBAL/Schema/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -834,9 +834,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 @@ -846,12 +846,8 @@ 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;
}
foreach ($columns as $value) {
$columnName = $value;

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 @@ -32,8 +32,8 @@ parameters:
- '~^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::unknownAlias\(\) expects array<string>, array<int, int|string> given\.\z~'
- '~^Parameter #2 \$registeredAliases of static method Doctrine\\DBAL\\Query\\QueryException::nonUniqueAlias\(\) expects array<string>, array<int, int|string> given\.\z~'
- '~^Parameter #2 \$registeredAliases of static method Doctrine\\DBAL\\Query\\QueryException::unknownAlias\(\) expects array<string>, array<int, int\|string> given\.\z~'
- '~^Parameter #2 \$registeredAliases of static method Doctrine\\DBAL\\Query\\QueryException::nonUniqueAlias\(\) expects array<string>, array<int, int\|string> given\.\z~'

# PHPStan is too strict about preg_replace(): https://phpstan.org/r/993dc99f-0d43-4b51-868b-d01f982c1463
- '~^Method Doctrine\\DBAL\\Platforms\\AbstractPlatform::escapeStringForLike\(\) should return string but returns string\|null\.\z~'
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

0 comments on commit 38e0a29

Please sign in to comment.