diff --git a/bitcoin b/bitcoin new file mode 120000 index 000000000..f3c139563 --- /dev/null +++ b/bitcoin @@ -0,0 +1 @@ +bitcoin \ No newline at end of file diff --git a/composer.json b/composer.json index 41193ac70..d7acb28fe 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "pleonasm/merkle-tree": "1.0.0", "composer/semver": "^1.4.0|^3.2.0", "lastguest/murmurhash": "v2.0.0", - "mdanter/ecc": "^0.5.0", + "mdanter/ecc": ">0.5.0", "bitwasp/buffertools": "^0.5.0", "bitwasp/bech32": "^0.0.1" }, diff --git a/src/Transaction/Mutator/AbstractCollectionMutator.php b/src/Transaction/Mutator/AbstractCollectionMutator.php index 222e69d03..81841249a 100644 --- a/src/Transaction/Mutator/AbstractCollectionMutator.php +++ b/src/Transaction/Mutator/AbstractCollectionMutator.php @@ -3,117 +3,87 @@ declare(strict_types=1); namespace BitWasp\Bitcoin\Transaction\Mutator; +use ArrayAccess; +use Countable; +use Iterator; +use SplFixedArray; -abstract class AbstractCollectionMutator implements \Iterator, \ArrayAccess, \Countable +abstract class AbstractCollectionMutator implements Iterator, ArrayAccess, Countable { - /** - * @var \SplFixedArray - */ protected $set; + private $position; + + public function __construct(int $size) + { + $this->set = new SplFixedArray($size); + $this->position = 0; + } - /** - * @return array - */ public function all(): array { return $this->set->toArray(); } - /** - * @return bool - */ public function isNull(): bool { return count($this->set) === 0; } - /** - * @return int - */ - public function count(): int - { - return $this->set->count(); - } - - /** - * - */ public function rewind() { - $this->set->rewind(); + $this->position = 0; } - /** - * @return mixed - */ public function current() { - return $this->set->current(); + return $this->set[$this->position]; } - /** - * @return int - */ public function key() { - return $this->set->key(); + return $this->position; } - /** - * - */ public function next() { - $this->set->next(); + $this->position++; } - /** - * @return bool - */ public function valid() { - return $this->set->valid(); + return isset($this->set[$this->position]); } - /** - * @param int $offset - * @return bool - */ public function offsetExists($offset) { - return $this->set->offsetExists($offset); + return isset($this->set[$offset]); } - /** - * @param int $offset - */ - public function offsetUnset($offset) + public function offsetGet($offset) { - if (!$this->offsetExists($offset)) { - throw new \InvalidArgumentException('Offset does not exist'); - } - - $this->set->offsetUnset($offset); + return $this->set[$offset]; } - /** - * @param int $offset - * @return mixed - */ - public function offsetGet($offset) + public function offsetSet($offset, $value) { if (!$this->set->offsetExists($offset)) { throw new \OutOfRangeException('Nothing found at this offset'); } - return $this->set->offsetGet($offset); + + $this->set[$offset] = $value; } - /** - * @param int $offset - * @param mixed $value - */ - public function offsetSet($offset, $value) + public function offsetUnset($offset) { - $this->set->offsetSet($offset, $value); + if (!$this->offsetExists($offset)) { + throw new \InvalidArgumentException('Offset does not exist'); + } + + unset($this->set[$offset]); + } + + public function count() + { + return $this->set->count(); } } diff --git a/src/Transaction/Mutator/InputCollectionMutator.php b/src/Transaction/Mutator/InputCollectionMutator.php index 8832942d2..b571a3017 100644 --- a/src/Transaction/Mutator/InputCollectionMutator.php +++ b/src/Transaction/Mutator/InputCollectionMutator.php @@ -23,14 +23,6 @@ public function __construct(array $inputs) $this->set = \SplFixedArray::fromArray($set, false); } - /** - * @return InputMutator - */ - public function current(): InputMutator - { - return $this->set->current(); - } - /** * @param int $offset * @return InputMutator