Skip to content

Commit

Permalink
Fix issue identified by Psalm
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Mar 10, 2021
1 parent 6bd65c3 commit 2bc4a05
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 0 additions & 4 deletions .psalm/baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,6 @@
<code>static::assertThat($haystack, $constraint, $message)</code>
<code>static::assertThat($haystack, $constraint, $message)</code>
</MissingThrowsDocblock>
<PossiblyInvalidArgument occurrences="2">
<code>$expected</code>
<code>$expected</code>
</PossiblyInvalidArgument>
</file>
<file src="src/Framework/Assert/Functions.php">
<DeprecatedClass occurrences="3">
Expand Down
5 changes: 2 additions & 3 deletions src/Framework/Constraint/Cardinality/Count.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
namespace PHPUnit\Framework\Constraint;

use function count;
use function is_array;
use function is_countable;
use function iterator_count;
use function sprintf;
use Countable;
use EmptyIterator;
use Generator;
use Iterator;
Expand Down Expand Up @@ -57,7 +56,7 @@ protected function matches($other): bool
*/
protected function getCountOf($other): ?int
{
if ($other instanceof Countable || is_array($other)) {
if (is_countable($other)) {
return count($other);
}

Expand Down
5 changes: 4 additions & 1 deletion src/Framework/Constraint/Cardinality/SameSize.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
*/
final class SameSize extends Count
{
public function __construct(iterable $expected)
/**
* @psalm-param \Countable|iterable $expected
*/
public function __construct($expected)
{
parent::__construct((int) $this->getCountOf($expected));
}
Expand Down

0 comments on commit 2bc4a05

Please sign in to comment.