Skip to content

Commit

Permalink
Fix remaining psalm errors and warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwage committed Apr 30, 2019
1 parent 0c8f635 commit 7772e59
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 77 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
"php": "^7.2"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"doctrine/coding-standard": "^6.0",
"infection/infection": "^0.12.2",
"phpstan/phpstan": "^0.11",
"phpstan/phpstan-phpunit": "^0.11",
"vimeo/psalm": "^3.2.2",
"infection/infection": "^0.12.2"
"phpunit/phpunit": "^7.0",
"vimeo/psalm": "^3.2.2"
},
"config": {
"sort-packages": true
Expand Down
26 changes: 13 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions lib/Doctrine/Common/Collections/AbstractLazyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ public function getIterator() : Traversable

/**
* {@inheritDoc}
*
* @param int|string $offset
*/
public function offsetExists($offset) : bool
{
Expand All @@ -297,6 +299,10 @@ public function offsetExists($offset) : bool

/**
* {@inheritDoc}
*
* @param int|string $offset
*
* @return mixed
*/
public function offsetGet($offset)
{
Expand All @@ -307,6 +313,9 @@ public function offsetGet($offset)

/**
* {@inheritDoc}
*
* @param int|string $offset
* @param mixed $value
*/
public function offsetSet($offset, $value) : void
{
Expand All @@ -316,6 +325,8 @@ public function offsetSet($offset, $value) : void

/**
* {@inheritDoc}
*
* @param int|string $offset
*/
public function offsetUnset($offset) : void
{
Expand Down
22 changes: 15 additions & 7 deletions lib/Doctrine/Common/Collections/ArrayCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use function array_search;
use function array_slice;
use function array_values;
use function assert;
use function count;
use function current;
use function end;
Expand Down Expand Up @@ -163,6 +164,8 @@ public function removeElement($element) : bool
* Required by interface ArrayAccess.
*
* {@inheritDoc}
*
* @param int|string $offset
*/
public function offsetExists($offset) : bool
{
Expand All @@ -172,7 +175,9 @@ public function offsetExists($offset) : bool
/**
* Required by interface ArrayAccess.
*
* {@inheritDoc}
* @param int|string $offset
*
* @return mixed
*/
public function offsetGet($offset)
{
Expand All @@ -182,11 +187,12 @@ public function offsetGet($offset)
/**
* Required by interface ArrayAccess.
*
* {@inheritDoc}
* @param int|string|null $offset
* @param mixed $value
*/
public function offsetSet($offset, $value) : void
{
if (! isset($offset)) {
if ($offset === null) {
$this->add($value);

return;
Expand All @@ -198,7 +204,7 @@ public function offsetSet($offset, $value) : void
/**
* Required by interface ArrayAccess.
*
* {@inheritDoc}
* @param int|string $offset
*/
public function offsetUnset($offset) : void
{
Expand Down Expand Up @@ -305,6 +311,8 @@ public function isEmpty() : bool
* Required by interface IteratorAggregate.
*
* {@inheritDoc}
*
* @psalm-return Traversable<TKey, T>
*/
public function getIterator() : Traversable
{
Expand Down Expand Up @@ -411,9 +419,9 @@ public function matching(Criteria $criteria) : Collection
$next = ClosureExpressionVisitor::sortByField($field, $ordering === Criteria::DESC ? -1 : 1, $next);
}

if ($next instanceof Closure) {
uasort($filtered, $next);
}
assert($next instanceof Closure);

uasort($filtered, $next);
}

$offset = $criteria->getFirstResult();
Expand Down
17 changes: 7 additions & 10 deletions lib/Doctrine/Common/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,33 +293,30 @@ public function indexOf($element);
*/
public function slice(int $offset, ?int $length = null) : array;

/**
* {@inheritdoc}
*/
public function count() : int;

/**
* {@inheritdoc}
*/
public function getIterator() : Traversable;

/**
* {@inheritdoc}
* @param int|string $offset
*
* @return mixed
*/
public function offsetGet($offset);

/**
* {@inheritdoc}
* @param int|string $offset
* @param mixed $value
*/
public function offsetSet($offset, $value) : void;

/**
* {@inheritdoc}
* @param int|string $offset
*/
public function offsetUnset($offset) : void;

/**
* {@inheritdoc}
* @param int|string $offset
*/
public function offsetExists($offset) : bool;
}
4 changes: 2 additions & 2 deletions lib/Doctrine/Common/Collections/Criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function getFirstResult() : ?int
*/
public function setFirstResult(?int $firstResult) : self
{
$this->firstResult = $firstResult === null ? null : (int) $firstResult;
$this->firstResult = $firstResult;

return $this;
}
Expand All @@ -206,7 +206,7 @@ public function getMaxResults() : ?int
*/
public function setMaxResults(?int $maxResults) : self
{
$this->maxResults = $maxResults === null ? null : (int) $maxResults;
$this->maxResults = $maxResults;

return $this;
}
Expand Down
5 changes: 1 addition & 4 deletions lib/Doctrine/Common/Collections/Expr/Comparison.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ public function getField() : string
return $this->field;
}

/**
* @return mixed
*/
public function getValue()
public function getValue() : Value
{
return $this->value;
}
Expand Down
23 changes: 7 additions & 16 deletions lib/Doctrine/Common/Collections/ExpressionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

use Doctrine\Common\Collections\Expr\Comparison;
use Doctrine\Common\Collections\Expr\CompositeExpression;
use Doctrine\Common\Collections\Expr\Expression;
use Doctrine\Common\Collections\Expr\Value;
use function func_get_args;

/**
* Builder for Expressions in the {@link Selectable} interface.
Expand All @@ -18,20 +18,14 @@
*/
class ExpressionBuilder
{
/**
* @param mixed $x
*/
public function andX($x = null) : CompositeExpression
public function andX(Expression ...$expressions) : CompositeExpression
{
return new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args());
return new CompositeExpression(CompositeExpression::TYPE_AND, $expressions);
}

/**
* @param mixed $x
*/
public function orX($x = null) : CompositeExpression
public function orX(Expression ...$expressions) : CompositeExpression
{
return new CompositeExpression(CompositeExpression::TYPE_OR, func_get_args());
return new CompositeExpression(CompositeExpression::TYPE_OR, $expressions);
}

/**
Expand All @@ -51,12 +45,9 @@ public function gt(string $field, $value) : Comparison
}

/**
* @param string $field
* @param mixed $value
*
* @return Comparison
* @param mixed $value
*/
public function lt($field, $value)
public function lt(string $field, $value) : Comparison
{
return new Comparison($field, Comparison::LT, new Value($value));
}
Expand Down
3 changes: 0 additions & 3 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
<file>tests</file>

<rule ref="Doctrine">
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint"/>

<!-- Since Collections are built around mixed content, this has no value here -->
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversablePropertyTypeHintSpecification"/>
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableParameterTypeHintSpecification"/>
Expand Down

0 comments on commit 7772e59

Please sign in to comment.