Skip to content

Commit

Permalink
Update method signatures to remove deprecation warning in PHP 8.1
Browse files Browse the repository at this point in the history
Signed-off-by: Kai Sassnowski <[email protected]>
  • Loading branch information
ksassnowski authored and btry committed Dec 1, 2021
1 parent cbee45d commit 98aa221
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 29 deletions.
39 changes: 21 additions & 18 deletions src/CFPropertyList/CFArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,18 @@ public function toArray()
* @return void
* @uses $iteratorPosition set to 0
*/
public function rewind()
public function rewind(): void
{
$this->iteratorPosition = 0;
}

/**
* Get Iterator's current {@link CFType} identified by {@link $iteratorPosition}
* @link http:https://php.net/manual/en/iterator.current.php
* @return CFType current Item
* @return mixed current Item
* @uses $iteratorPosition identify current key
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->value[$this->iteratorPosition];
Expand All @@ -196,9 +197,10 @@ public function current()
/**
* Get Iterator's current key identified by {@link $iteratorPosition}
* @link http:https://php.net/manual/en/iterator.key.php
* @return string key of the current Item
* @return mixed key of the current Item: mixed
* @uses $iteratorPosition identify current key
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->iteratorPosition;
Expand All @@ -210,19 +212,19 @@ public function key()
* @return void
* @uses $iteratorPosition increment by 1
*/
public function next()
public function next(): void
{
$this->iteratorPosition++;
}

/**
* Test if {@link $iteratorPosition} addresses a valid element of {@link $value}
* @link http:https://php.net/manual/en/iterator.valid.php
* @return boolean true if current position is valid, false else
* @return bool true if current position is valid, false else
* @uses $iteratorPosition test if within {@link $iteratorKeys}
* @uses $iteratorPosition test if within {@link $value}
*/
public function valid()
public function valid(): bool
{
return isset($this->value[$this->iteratorPosition]);
}
Expand All @@ -233,53 +235,54 @@ public function valid()

/**
* Determine if the array's key exists
* @param string $key the key to check
* @param string $offset the key to check
* @return bool true if the offset exists, false if not
* @link http:https://php.net/manual/en/arrayaccess.offsetexists.php
* @uses $value to check if $key exists
* @author Sean Coates <[email protected]>
*/
public function offsetExists($key)
public function offsetExists($offset): bool
{
return isset($this->value[$key]);
return isset($this->value[$offset]);
}

/**
* Fetch a specific key from the CFArray
* @param string $key the key to check
* @param mixed $offset the key to check
* @return mixed the value associated with the key; null if the key is not found
* @link http:https://php.net/manual/en/arrayaccess.offsetget.php
* @uses get() to get the key's value
* @author Sean Coates <[email protected]>
*/
public function offsetGet($key)
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->get($key);
return $this->get($offset);
}

/**
* Set a value in the array
* @param string $key the key to set
* @param string $value the value to set
* @param mixed $offset the key to set
* @param mixed $value the value to set
* @return void
* @link http:https://php.net/manual/en/arrayaccess.offsetset.php
* @uses setValue() to set the key's new value
* @author Sean Coates <[email protected]>
*/
public function offsetSet($key, $value)
public function offsetSet($offset, $value): void
{
return $this->setValue($value);
$this->setValue($value);
}

/**
* Unsets a value in the array
* <b>Note:</b> this dummy does nothing
* @param string $key the key to set
* @param mixed $offset the key to set
* @return void
* @link http:https://php.net/manual/en/arrayaccess.offsetunset.php
* @author Sean Coates <[email protected]>
*/
public function offsetUnset($key)
public function offsetUnset($offset): void
{
}
}
14 changes: 8 additions & 6 deletions src/CFPropertyList/CFDictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,29 +181,31 @@ public function toArray()
* @uses $iteratorPosition set to 0
* @uses $iteratorKeys store keys of {@link $value}
*/
public function rewind()
public function rewind(): void
{
$this->iteratorPosition = 0;
$this->iteratorKeys = array_keys($this->value);
}
/**
* Get Iterator's current {@link CFType} identified by {@link $iteratorPosition}
* @link http:https://php.net/manual/en/iterator.current.php
* @return CFType current Item
* @return mixed current Item
* @uses $iteratorPosition identify current key
* @uses $iteratorKeys identify current value
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->value[$this->iteratorKeys[$this->iteratorPosition]];
}
/**
* Get Iterator's current key identified by {@link $iteratorPosition}
* @link http:https://php.net/manual/en/iterator.key.php
* @return string key of the current Item
* @return mixed key of the current Item
* @uses $iteratorPosition identify current key
* @uses $iteratorKeys identify current value
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->iteratorKeys[$this->iteratorPosition];
Expand All @@ -214,18 +216,18 @@ public function key()
* @return void
* @uses $iteratorPosition increment by 1
*/
public function next()
public function next(): void
{
$this->iteratorPosition++;
}
/**
* Test if {@link $iteratorPosition} addresses a valid element of {@link $value}
* @link http:https://php.net/manual/en/iterator.valid.php
* @return boolean true if current position is valid, false else
* @return bool true if current position is valid, false else
* @uses $iteratorPosition test if within {@link $iteratorKeys}
* @uses $iteratorPosition test if within {@link $value}
*/
public function valid()
public function valid(): bool
{
return isset($this->iteratorKeys[$this->iteratorPosition]) && isset($this->value[$this->iteratorKeys[$this->iteratorPosition]]);
}
Expand Down
12 changes: 7 additions & 5 deletions src/CFPropertyList/CFPropertyList.php
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ public function toArray()
* @uses $iteratorPosition set to 0
* @uses $iteratorKeys store keys of {@link $value}
*/
public function rewind()
public function rewind(): void
{
$this->iteratorPosition = 0;
$this->iteratorKeys = array_keys($this->value);
Expand All @@ -676,10 +676,11 @@ public function rewind()
/**
* Get Iterator's current {@link CFType} identified by {@link $iteratorPosition}
* @link http:https://php.net/manual/en/iterator.current.php
* @return CFType current Item
* @return mixed current Item
* @uses $iteratorPosition identify current key
* @uses $iteratorKeys identify current value
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->value[$this->iteratorKeys[$this->iteratorPosition]];
Expand All @@ -688,10 +689,11 @@ public function current()
/**
* Get Iterator's current key identified by {@link $iteratorPosition}
* @link http:https://php.net/manual/en/iterator.key.php
* @return string key of the current Item
* @return mixed key of the current Item
* @uses $iteratorPosition identify current key
* @uses $iteratorKeys identify current value
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->iteratorKeys[$this->iteratorPosition];
Expand All @@ -703,7 +705,7 @@ public function key()
* @return void
* @uses $iteratorPosition increment by 1
*/
public function next()
public function next(): void
{
$this->iteratorPosition++;
}
Expand All @@ -715,7 +717,7 @@ public function next()
* @uses $iteratorPosition test if within {@link $iteratorKeys}
* @uses $iteratorPosition test if within {@link $value}
*/
public function valid()
public function valid(): bool
{
return isset($this->iteratorKeys[$this->iteratorPosition]) && isset($this->value[$this->iteratorKeys[$this->iteratorPosition]]);
}
Expand Down

0 comments on commit 98aa221

Please sign in to comment.