Skip to content

Commit ce39be3

Browse files
committed
Adjust to new Coding Standard
And start relying on some new features that come with it.
1 parent df9c3f6 commit ce39be3

File tree

6 files changed

+14
-23
lines changed

6 files changed

+14
-23
lines changed

src/ArrayAccessible.php

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace DMS\PHPUnitExtensions\ArraySubset;
56

67
use ArrayAccess;
78
use ArrayIterator;
89
use IteratorAggregate;
9-
use ReturnTypeWillChange; // phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse
10+
use ReturnTypeWillChange;
1011
use Traversable;
1112

1213
use function array_key_exists;
@@ -26,30 +27,18 @@ public function __construct(array $array = [])
2627
$this->array = $array;
2728
}
2829

29-
/**
30-
* @param mixed $offset
31-
*/
32-
public function offsetExists($offset): bool
30+
public function offsetExists(mixed $offset): bool
3331
{
3432
return array_key_exists($offset, $this->array);
3533
}
3634

37-
/**
38-
* @param mixed $offset
39-
*
40-
* @return mixed
41-
*/
4235
#[ReturnTypeWillChange]
43-
public function offsetGet($offset)
36+
public function offsetGet(mixed $offset): mixed
4437
{
4538
return $this->array[$offset];
4639
}
4740

48-
/**
49-
* @param mixed $offset
50-
* @param mixed $value
51-
*/
52-
public function offsetSet($offset, $value): void
41+
public function offsetSet(mixed $offset, mixed $value): void
5342
{
5443
if ($offset === null) {
5544
$this->array[] = $value;
@@ -58,10 +47,7 @@ public function offsetSet($offset, $value): void
5847
}
5948
}
6049

61-
/**
62-
* @param mixed $offset
63-
*/
64-
public function offsetUnset($offset): void
50+
public function offsetUnset(mixed $offset): void
6551
{
6652
unset($this->array[$offset]);
6753
}

src/ArraySubsetAsserts.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace DMS\PHPUnitExtensions\ArraySubset;

src/Assert.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace DMS\PHPUnitExtensions\ArraySubset;

src/Constraint/ArraySubset.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace DMS\PHPUnitExtensions\ArraySubset\Constraint;
@@ -62,7 +63,7 @@ public function __construct(iterable $subset, bool $strict = false)
6263
* @throws ExpectationFailedException
6364
* @throws InvalidArgumentException
6465
*/
65-
public function evaluate($other, string $description = '', bool $returnResult = false): ?bool
66+
public function evaluate(array|ArrayAccess $other, string $description = '', bool $returnResult = false): ?bool
6667
{
6768
//type cast $other & $this->subset as an array to allow
6869
//support in standard array functions.
@@ -119,7 +120,7 @@ public function toString(): string
119120
*
120121
* @throws InvalidArgumentException
121122
*/
122-
protected function failureDescription($other): string
123+
protected function failureDescription(mixed $other): string
123124
{
124125
return 'an array ' . $this->toString();
125126
}

tests/Unit/AssertTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace DMS\PHPUnitExtensions\ArraySubset\Tests\Unit;

tests/Unit/Constraint/ArraySubsetTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
namespace DMS\PHPUnitExtensions\ArraySubset\Tests\Unit\Constraint;
@@ -63,7 +64,7 @@ public static function evaluateDataProvider(): array
6364
*
6465
* @dataProvider evaluateDataProvider
6566
*/
66-
public function testEvaluate(bool $expected, $subset, $other, bool $strict): void
67+
public function testEvaluate(bool $expected, array|Traversable $subset, array|Traversable $other, bool $strict): void
6768
{
6869
$constraint = new ArraySubset($subset, $strict);
6970

0 commit comments

Comments
 (0)