Skip to content

Run CS on PR #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/check-cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
branches:
- master
pull_request:
branches:
- "*"

jobs:
fix-style:
Expand Down
34 changes: 29 additions & 5 deletions src/ArrayAccessible.php
Original file line number Diff line number Diff line change
@@ -1,45 +1,69 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);

namespace DMS\PHPUnitExtensions\ArraySubset;

use ArrayAccess;
use ArrayIterator;
use IteratorAggregate;
use Traversable;
use function array_key_exists;

class ArrayAccessible implements ArrayAccess, IteratorAggregate
{
/**
* @var mixed[]
*/
private $array;

/**
* @param mixed[] $array
*/
public function __construct(array $array = [])
{
$this->array = $array;
}

public function offsetExists($offset)
/**
* @param mixed $offset
*/
public function offsetExists($offset): bool
{
return \array_key_exists($offset, $this->array);
return array_key_exists($offset, $this->array);
}

/**
* @param mixed $offset
*
* @return mixed
*/
public function offsetGet($offset)
{
return $this->array[$offset];
}

/**
* @param mixed $offset
* @param mixed $value
*/
public function offsetSet($offset, $value): void
{
if (null === $offset) {
if ($offset === null) {
$this->array[] = $value;
} else {
$this->array[$offset] = $value;
}
}

/**
* @param mixed $offset
*/
public function offsetUnset($offset): void
{
unset($this->array[$offset]);
}

public function getIterator()
public function getIterator(): Traversable
{
return new ArrayIterator($this->array);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Constraint/ArraySubsetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

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

use DMS\PHPUnitExtensions\ArraySubset\ArrayAccessible;
use ArrayObject;
use Countable;
use DMS\PHPUnitExtensions\ArraySubset\ArrayAccessible;
use DMS\PHPUnitExtensions\ArraySubset\Constraint\ArraySubset;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\SelfDescribing;
Expand Down