Skip to content

Commit

Permalink
Fix errors reported by psalm.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Dec 3, 2020
1 parent f31de42 commit fc18891
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Driver/Sqlserver.php
Expand Up @@ -373,10 +373,10 @@ protected function _pagingSubquery(Query $original, ?int $limit, ?int $offset):
->from(['_cake_paging_' => $query]);

if ($offset) {
$outer->where(["$field > " . (int)$offset]);
$outer->where(["$field > " . $offset]);
}
if ($limit) {
$value = (int)$offset + (int)$limit;
$value = (int)$offset + $limit;
$outer->where(["$field <= $value"]);
}

Expand Down
2 changes: 1 addition & 1 deletion Expression/QueryExpression.php
Expand Up @@ -350,7 +350,7 @@ public function addCase($conditions, $values = [], $types = [])
* "field NOT IN (value1, value2)".
*
* @param string|\Cake\Database\ExpressionInterface $field Database field to be compared against value
* @param array|\Cake\Database\ExpressionInterface $values the value to be bound to $field for comparison
* @param string|array|\Cake\Database\ExpressionInterface $values the value to be bound to $field for comparison
* @param string|null $type the type name for $value as configured using the Type map.
* @return $this
*/
Expand Down
2 changes: 1 addition & 1 deletion IdentifierQuoter.php
Expand Up @@ -134,7 +134,7 @@ protected function _quoteParts(Query $query): void
protected function _basicQuoter(array $part): array
{
$result = [];
foreach ((array)$part as $alias => $value) {
foreach ($part as $alias => $value) {
$value = !is_string($value) ? $value : $this->_driver->quoteIdentifier($value);
$alias = is_numeric($alias) ? $alias : $this->_driver->quoteIdentifier($alias);
$result[$alias] = $value;
Expand Down
11 changes: 4 additions & 7 deletions Query.php
Expand Up @@ -867,7 +867,10 @@ protected function _makeJoin($table, $conditions, $type): array
$table = current($table);
}

/** @psalm-suppress InvalidReturnStatement */
/**
* @psalm-suppress InvalidArrayOffset
* @psalm-suppress InvalidReturnStatement
*/
return [
$alias => [
'table' => $table,
Expand Down Expand Up @@ -1490,9 +1493,6 @@ public function page(int $num, ?int $limit = null)
public function limit($num)
{
$this->_dirty();
if ($num !== null && !is_object($num)) {
$num = (int)$num;
}
$this->_parts['limit'] = $num;

return $this;
Expand All @@ -1519,9 +1519,6 @@ public function limit($num)
public function offset($num)
{
$this->_dirty();
if ($num !== null && !is_object($num)) {
$num = (int)$num;
}
$this->_parts['offset'] = $num;

return $this;
Expand Down
2 changes: 1 addition & 1 deletion Schema/MysqlSchemaDialect.php
Expand Up @@ -451,7 +451,7 @@ public function columnSql(TableSchema $schema, string $name): string
$out .= ' NOT NULL';
}
$addAutoIncrement = (
(array)$schema->getPrimaryKey() === [$name] &&
$schema->getPrimaryKey() === [$name] &&
!$schema->hasAutoincrement() &&
!isset($data['autoIncrement'])
);
Expand Down
6 changes: 3 additions & 3 deletions Schema/SqliteSchemaDialect.php
Expand Up @@ -363,7 +363,7 @@ public function columnSql(TableSchema $schema, string $name): string
isset($data['unsigned']) &&
$data['unsigned'] === true
) {
if ($data['type'] !== TableSchema::TYPE_INTEGER || (array)$schema->getPrimaryKey() !== [$name]) {
if ($data['type'] !== TableSchema::TYPE_INTEGER || $schema->getPrimaryKey() !== [$name]) {
$out .= ' UNSIGNED';
}
}
Expand Down Expand Up @@ -410,7 +410,7 @@ public function columnSql(TableSchema $schema, string $name): string
if (
in_array($data['type'], $integerTypes, true) &&
isset($data['length']) &&
(array)$schema->getPrimaryKey() !== [$name]
$schema->getPrimaryKey() !== [$name]
) {
$out .= '(' . (int)$data['length'] . ')';
}
Expand All @@ -430,7 +430,7 @@ public function columnSql(TableSchema $schema, string $name): string
$out .= ' NOT NULL';
}

if ($data['type'] === TableSchema::TYPE_INTEGER && (array)$schema->getPrimaryKey() === [$name]) {
if ($data['type'] === TableSchema::TYPE_INTEGER && $schema->getPrimaryKey() === [$name]) {
$out .= ' PRIMARY KEY AUTOINCREMENT';
}

Expand Down
2 changes: 1 addition & 1 deletion Schema/TableSchema.php
Expand Up @@ -710,7 +710,7 @@ public function getOptions(): array
*/
public function setTemporary(bool $temporary)
{
$this->_temporary = (bool)$temporary;
$this->_temporary = $temporary;

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion Statement/BufferResultsTrait.php
Expand Up @@ -38,7 +38,7 @@ trait BufferResultsTrait
*/
public function bufferResults(bool $buffer)
{
$this->_bufferResults = (bool)$buffer;
$this->_bufferResults = $buffer;

return $this;
}
Expand Down

0 comments on commit fc18891

Please sign in to comment.