Skip to content

Commit

Permalink
Fix contravariance with ArrayAccess
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Tekiela <[email protected]>
  • Loading branch information
kamil-tekiela committed Jan 2, 2024
1 parent 0418ed9 commit 071a5ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/TokensList.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public function getNextOfTypeAndFlag(TokenType $type, int $flag): Token|null
* @param int|null $offset the offset to be set
* @param Token $value the token to be saved
*/
public function offsetSet($offset, $value): void
public function offsetSet(mixed $offset, mixed $value): void
{
if ($offset === null) {
$this->tokens[$this->count++] = $value;
Expand All @@ -204,7 +204,7 @@ public function offsetSet($offset, $value): void
*
* @param int $offset the offset to be returned
*/
public function offsetGet($offset): Token|null
public function offsetGet(mixed $offset): Token|null
{
return $offset < $this->count ? $this->tokens[$offset] : null;
}
Expand All @@ -214,7 +214,7 @@ public function offsetGet($offset): Token|null
*
* @param int $offset the offset to be checked
*/
public function offsetExists($offset): bool
public function offsetExists(mixed $offset): bool
{
return $offset < $this->count;
}
Expand All @@ -224,7 +224,7 @@ public function offsetExists($offset): bool
*
* @param int $offset the offset to be unset
*/
public function offsetUnset($offset): void
public function offsetUnset(mixed $offset): void
{
unset($this->tokens[$offset]);
--$this->count;
Expand Down
8 changes: 4 additions & 4 deletions src/UtfString.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function __construct($str)
*
* @param int $offset the offset to be checked
*/
public function offsetExists($offset): bool
public function offsetExists(mixed $offset): bool
{
return ($offset >= 0) && ($offset < $this->charLen);
}
Expand All @@ -100,7 +100,7 @@ public function offsetExists($offset): bool
*
* @param int $offset the offset to be returned
*/
public function offsetGet($offset): string|null
public function offsetGet(mixed $offset): string|null
{
// This function moves the internal byte and character pointer to the requested offset.
// This function is part of hot code so the aim is to do the following
Expand Down Expand Up @@ -143,7 +143,7 @@ public function offsetGet($offset): string|null
*
* @throws Exception not implemented.
*/
public function offsetSet($offset, $value): void
public function offsetSet(mixed $offset, mixed $value): void
{
throw new Exception('Not implemented.');
}
Expand All @@ -155,7 +155,7 @@ public function offsetSet($offset, $value): void
*
* @throws Exception not implemented.
*/
public function offsetUnset($offset): void
public function offsetUnset(mixed $offset): void
{
throw new Exception('Not implemented.');
}
Expand Down

0 comments on commit 071a5ba

Please sign in to comment.