File tree 2 files changed +30
-6
lines changed 2 files changed +30
-6
lines changed Original file line number Diff line number Diff line change 1
- <?php declare (strict_types=1 );
1
+ <?php
2
+ declare (strict_types=1 );
2
3
3
4
namespace DMS \PHPUnitExtensions \ArraySubset ;
4
5
5
6
use ArrayAccess ;
6
7
use ArrayIterator ;
7
8
use IteratorAggregate ;
9
+ use Traversable ;
10
+ use function array_key_exists ;
8
11
9
12
class ArrayAccessible implements ArrayAccess, IteratorAggregate
10
13
{
14
+ /**
15
+ * @var mixed[]
16
+ */
11
17
private $ array ;
12
18
19
+ /**
20
+ * @param mixed[] $array
21
+ */
13
22
public function __construct (array $ array = [])
14
23
{
15
24
$ this ->array = $ array ;
16
25
}
17
26
18
- public function offsetExists ($ offset )
27
+ /**
28
+ * @param mixed $offset
29
+ */
30
+ public function offsetExists ($ offset ): bool
19
31
{
20
- return \ array_key_exists ($ offset , $ this ->array );
32
+ return array_key_exists ($ offset , $ this ->array );
21
33
}
22
34
35
+ /**
36
+ * @param mixed $offset
37
+ *
38
+ * @return mixed
39
+ */
23
40
public function offsetGet ($ offset )
24
41
{
25
42
return $ this ->array [$ offset ];
26
43
}
27
44
45
+ /**
46
+ * @param mixed $offset
47
+ * @param mixed $value
48
+ */
28
49
public function offsetSet ($ offset , $ value ): void
29
50
{
30
- if (null === $ offset ) {
51
+ if ($ offset === null ) {
31
52
$ this ->array [] = $ value ;
32
53
} else {
33
54
$ this ->array [$ offset ] = $ value ;
34
55
}
35
56
}
36
57
58
+ /**
59
+ * @param mixed $offset
60
+ */
37
61
public function offsetUnset ($ offset ): void
38
62
{
39
63
unset($ this ->array [$ offset ]);
40
64
}
41
65
42
- public function getIterator ()
66
+ public function getIterator (): Traversable
43
67
{
44
68
return new ArrayIterator ($ this ->array );
45
69
}
Original file line number Diff line number Diff line change 3
3
4
4
namespace DMS \PHPUnitExtensions \ArraySubset \Tests \Unit \Constraint ;
5
5
6
- use DMS \PHPUnitExtensions \ArraySubset \ArrayAccessible ;
7
6
use ArrayObject ;
8
7
use Countable ;
8
+ use DMS \PHPUnitExtensions \ArraySubset \ArrayAccessible ;
9
9
use DMS \PHPUnitExtensions \ArraySubset \Constraint \ArraySubset ;
10
10
use PHPUnit \Framework \ExpectationFailedException ;
11
11
use PHPUnit \Framework \SelfDescribing ;
You can’t perform that action at this time.
0 commit comments