Skip to content

Commit

Permalink
utilizing the static return type
Browse files Browse the repository at this point in the history
  • Loading branch information
peldax committed Nov 25, 2020
1 parent 717e3d3 commit c91bb5e
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Utils/BaseSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ abstract class BaseSet implements \Iterator, \ArrayAccess, \Countable

protected array $array = [];

public function merge(self $objectSet, bool $allowReplace = false) : self
public function merge(self $objectSet, bool $allowReplace = false) : static
{
if (!$objectSet instanceof static) {
throw new \Exception('I can only merge Sets of same type');
Expand Down Expand Up @@ -83,7 +83,7 @@ public function offsetUnset($offset) : void
unset($this->array[$offset]);
}

abstract protected function mergeImpl(self $objectSet, bool $allowReplace) : self;
abstract protected function mergeImpl(self $objectSet, bool $allowReplace) : static;

abstract protected function offsetSetImpl($offset, object $object) : void;
}
2 changes: 1 addition & 1 deletion src/Utils/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private function __construct(?string $json, ?\Infinityloop\Utils\Json\JsonContra
$this->inner = $data;
}

public static function fromString(string $json) : self
public static function fromString(string $json) : static
{
return new self($json, null);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/Json/JsonContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract class JsonContract implements \Countable, \IteratorAggregate, \ArrayAcc
\JSON_UNESCAPED_SLASHES |
\JSON_PRESERVE_ZERO_FRACTION;

abstract public static function fromString(string $json) : self;
abstract public static function fromString(string $json) : static;

abstract public function toString() : string;

Expand Down
2 changes: 1 addition & 1 deletion src/Utils/Json/MapJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private function __construct(?string $json, ?\stdClass $data)
$this->data = $data;
}

public static function fromString(string $json) : self
public static function fromString(string $json) : static
{
return new self($json, null);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/Json/SequentialJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private function __construct(?string $json, ?array $data)
$this->data = $data;
}

public static function fromString(string $json) : self
public static function fromString(string $json) : static
{
return new self($json, null);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/ObjectMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function key() : string
return \key($this->array);
}

protected function mergeImpl(BaseSet $objectSet, bool $allowReplace = false) : self
protected function mergeImpl(BaseSet $objectSet, bool $allowReplace = false) : static
{
foreach ($objectSet as $offset => $object) {
if (!$allowReplace && $this->offsetExists($offset)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/ObjectSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function key() : int
return \key($this->array);
}

protected function mergeImpl(BaseSet $objectSet, bool $allowReplace = false) : self
protected function mergeImpl(BaseSet $objectSet, bool $allowReplace = false) : static
{
foreach ($objectSet as $offset => $object) {
$this->offsetSet($allowReplace
Expand Down

0 comments on commit c91bb5e

Please sign in to comment.