Skip to content

Commit

Permalink
reduce deprecation notices from later PHP versions
Browse files Browse the repository at this point in the history
  • Loading branch information
scottaubrey committed Nov 7, 2024
1 parent 93779a6 commit f1e97dc
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/Collection/ArraySequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public function offsetExists($offset) : bool
return isset($this->array[$offset]);
}

#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
if (!isset($this->array[$offset])) {
Expand Down
1 change: 1 addition & 0 deletions src/Collection/EmptySequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public function offsetExists($offset) : bool
return false;
}

#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return null;
Expand Down
1 change: 1 addition & 0 deletions src/Collection/PromiseSequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public function offsetExists($offset) : bool
return $this->wait()->offsetExists($offset);
}

#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->wait()->offsetGet($offset);
Expand Down
4 changes: 2 additions & 2 deletions src/ImmutableArrayAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

trait ImmutableArrayAccess
{
final public function offsetSet($offset, $value)
final public function offsetSet($offset, $value): void
{
throw new BadMethodCallException('Object is immutable');
}

final public function offsetUnset($offset)
final public function offsetUnset($offset): void
{
throw new BadMethodCallException('Object is immutable');
}
Expand Down
10 changes: 6 additions & 4 deletions src/Model/SearchSubjects.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,35 @@ public function __construct(array $subjects, array $results)
$this->results = $results;
}

public function count()
public function count(): int
{
return count($this->subjects);
}

#[\ReturnTypeWillChange]
public function current()
{
return current($this->results);
}

public function next()
public function next(): void
{
next($this->subjects);
next($this->results);
}

#[\ReturnTypeWillChange]
public function key()
{
return current($this->subjects);
}

public function valid()
public function valid(): bool
{
return false !== $this->key();
}

public function rewind()
public function rewind(): void
{
reset($this->subjects);
reset($this->results);
Expand Down
2 changes: 1 addition & 1 deletion src/Model/SearchTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(array $typesToResults)
$this->typesToResults = $typesToResults;
}

public function count()
public function count(): int
{
return count($this->typesToResults);
}
Expand Down
1 change: 1 addition & 0 deletions src/SlicedArrayAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function offsetExists($offset) : bool
return null !== $this->offsetGet($offset);
}

#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
try {
Expand Down
8 changes: 5 additions & 3 deletions src/SlicedIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ trait SlicedIterator

private $key = 1;

#[\ReturnTypeWillChange]
final public function current()
{
$page = (int) ceil($this->key / $this->pageBatch);
Expand All @@ -23,11 +24,12 @@ final public function current()
return $pageContents[$inPage];
}

final public function next()
final public function next(): void
{
++$this->key;
}

#[\ReturnTypeWillChange]
final public function key()
{
if ($this->key > $this->count()) {
Expand All @@ -37,12 +39,12 @@ final public function key()
return $this->key;
}

final public function valid()
final public function valid(): bool
{
return $this->key <= $this->count();
}

final public function rewind()
final public function rewind(): void
{
$this->key = 1;
}
Expand Down

0 comments on commit f1e97dc

Please sign in to comment.