Skip to content

Commit

Permalink
Fix PHP8.1 return types of internal PHP interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
glaubinix committed Apr 25, 2024
1 parent 6f3287b commit 0f08b29
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
16 changes: 8 additions & 8 deletions lib/recurly/currency_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,35 @@ public function getCurrency($currencyCode) {
return isset($this->currencies[$currencyCode]) ? $this->currencies[$currencyCode] : null;
}

public function offsetSet($offset, $value) {
return $this->addCurrency($offset, $value);
public function offsetSet($offset, $value): void {
$this->addCurrency($offset, $value);
}

public function offsetExists($offset) {
public function offsetExists($offset): bool {
return isset($this->currencies[$offset]);
}

public function offsetUnset($offset) {
public function offsetUnset($offset): void {
unset($this->currencies[$offset]);
}

public function offsetGet($offset) {
public function offsetGet($offset): mixed {
return $this->getCurrency($offset);
}

public function __set($k, $v) {
return $this->offsetSet($k, $v);
$this->offsetSet($k, $v);
}

public function __get($k) {
return $this->offsetGet($k);
}

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

public function getIterator() {
public function getIterator(): Traversable {
return new ArrayIterator($this->currencies);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/recurly/custom_field_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Recurly_CustomFieldList extends ArrayObject
* @param object $value Must be instance of Recurly_CustomField
* @throws Exception
*/
public function offsetSet($index, $value) {
public function offsetSet($index, $value): void {
if (!$value instanceof Recurly_CustomField) {
throw new Exception("value must be an instance of Recurly_CustomField");
}
Expand All @@ -25,7 +25,7 @@ public function offsetSet($index, $value) {
parent::offsetSet($index, $value);
}

public function offsetUnset($index) {
public function offsetUnset($index): void {
parent::offsetSet($index, new Recurly_CustomField($index, null));
}

Expand Down
12 changes: 6 additions & 6 deletions lib/recurly/error_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,29 @@ function __construct() {
}

// array access to the errors collection
public function offsetSet($offset, $value) {
public function offsetSet($offset, $value): void {
if (is_null($offset)) {
$this->errors[] = $value;
} else {
$this->errors[$offset] = $value;
}
}
public function offsetExists($offset) {
public function offsetExists($offset): bool {
return isset($this->errors[$offset]);
}
public function offsetUnset($offset) {
public function offsetUnset($offset): void {
unset($this->errors[$offset]);
}
public function offsetGet($offset) {
public function offsetGet($offset): mixed {
return isset($this->errors[$offset]) ? $this->errors[$offset] : null;
}

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

public function getIterator() {
public function getIterator(): Traversable {
return new ArrayIterator($this->errors);
}

Expand Down
14 changes: 7 additions & 7 deletions lib/recurly/pager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ abstract class Recurly_Pager extends Recurly_Base implements Iterator, Countable
* @return integer number of records in list
* @throws Recurly_Error
*/
public function count() {
public function count(): int {
if (isset($this->_href)) {
$headers = Recurly_Base::_head($this->_href, $this->_client);
if (isset($headers['x-records'])) {
Expand All @@ -28,7 +28,7 @@ public function count() {
return count($this->_objects);
}

return null;
return 0;
}

protected function get_first_page() {
Expand All @@ -47,7 +47,7 @@ protected function get_first_page() {
*
* @throws Recurly_Error
*/
public function rewind() {
public function rewind(): void {
$this->_loadFrom($this->_href);
$this->_position = 0;
}
Expand All @@ -58,7 +58,7 @@ public function rewind() {
* @return Recurly_Resource the current object
* @throws Recurly_Error
*/
public function current()
public function current(): mixed
{
// Work around pre-PHP 5.5 issue that prevents `empty($this->count())`:
if (!isset($this->_objects)) {
Expand All @@ -84,21 +84,21 @@ public function current()
/**
* @return integer current position within the current page
*/
public function key() {
public function key(): mixed {
return $this->_position;
}

/**
* Increments the position to the next element
*/
public function next() {
public function next(): void {
++$this->_position;
}

/**
* @return boolean True if the current position is valid.
*/
public function valid() {
public function valid(): bool {
return (isset($this->_objects[$this->_position]) || isset($this->_links['next']));
}

Expand Down

0 comments on commit 0f08b29

Please sign in to comment.