Skip to content

Commit

Permalink
Remove usage of ReturnTypeWillChange
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Dec 24, 2023
1 parent fa91edf commit 5c9723e
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 51 deletions.
12 changes: 2 additions & 10 deletions src/Markup.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,12 @@ public function __toString()
return $this->content;
}

/**
* @return int
*/
#[\ReturnTypeWillChange]
public function count()
public function count(): int
{
return mb_strlen($this->content, $this->charset);
}

/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
public function jsonSerialize(): mixed
{
return $this->content;
}
Expand Down
6 changes: 1 addition & 5 deletions src/Node/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,7 @@ public function removeNode(string $name): void
unset($this->nodes[$name]);
}

/**
* @return int
*/
#[\ReturnTypeWillChange]
public function count()
public function count(): int
{
return \count($this->nodes);
}
Expand Down
12 changes: 2 additions & 10 deletions src/Util/TemplateDirIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,12 @@
*/
class TemplateDirIterator extends \IteratorIterator
{
/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function current()
public function current(): mixed
{
return file_get_contents(parent::current());
}

/**
* @return mixed
*/
#[\ReturnTypeWillChange]
public function key()
public function key(): mixed
{
return (string) parent::key();
}
Expand Down
6 changes: 2 additions & 4 deletions tests/Extension/CoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,7 @@ public function rewind(): void
$this->position = 0;
}

#[\ReturnTypeWillChange]
public function current()
public function current(): mixed
{
if ($this->allowValueAccess) {
return $this->array[$this->key()];
Expand All @@ -391,8 +390,7 @@ public function current()
throw new \LogicException('Code should only use the keys, not the values provided by iterator.');
}

#[\ReturnTypeWillChange]
public function key()
public function key(): mixed
{
return $this->arrayKeys[$this->position];
}
Expand Down
6 changes: 2 additions & 4 deletions tests/Fixtures/tags/for/objects.test
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
class ItemsIterator implements \Iterator
{
protected $values = ['foo' => 'bar', 'bar' => 'foo'];
#[\ReturnTypeWillChange]
public function current() { return current($this->values); }
#[\ReturnTypeWillChange]
public function key() { return key($this->values); }
public function current(): mixed { return current($this->values); }
public function key(): mixed { return key($this->values); }
public function next(): void { next($this->values); }
public function rewind(): void { reset($this->values); }
public function valid(): bool { return false !== current($this->values); }
Expand Down
6 changes: 2 additions & 4 deletions tests/Fixtures/tags/for/objects_countable.test
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
class ItemsIteratorCountable implements \Iterator, \Countable
{
protected $values = ['foo' => 'bar', 'bar' => 'foo'];
#[\ReturnTypeWillChange]
public function current() { return current($this->values); }
#[\ReturnTypeWillChange]
public function key() { return key($this->values); }
public function current(): mixed { return current($this->values); }
public function key(): mixed { return key($this->values); }
public function next(): void { next($this->values); }
public function rewind(): void { reset($this->values); }
public function valid(): bool { return false !== current($this->values); }
Expand Down
12 changes: 4 additions & 8 deletions tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,12 @@ public function rewind(): void
$this->position = 0;
}

#[\ReturnTypeWillChange]
public function current()
public function current(): mixed
{
return $this->array[$this->position];
}

#[\ReturnTypeWillChange]
public function key()
public function key(): mixed
{
return 'a';
}
Expand Down Expand Up @@ -366,8 +364,7 @@ class SimpleIteratorForTesting implements \Iterator
private $data = [1, 2, 3, 4, 5, 6, 7];
private $key = 0;

#[\ReturnTypeWillChange]
public function current()
public function current(): mixed
{
return $this->key;
}
Expand All @@ -377,8 +374,7 @@ public function next(): void
++$this->key;
}

#[\ReturnTypeWillChange]
public function key()
public function key(): mixed
{
return $this->key;
}
Expand Down
9 changes: 3 additions & 6 deletions tests/TemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,7 @@ public function offsetExists($name): bool
return \array_key_exists($name, $this->attributes);
}

#[\ReturnTypeWillChange]
public function offsetGet($name)
public function offsetGet($name): mixed
{
return \array_key_exists($name, $this->attributes) ? $this->attributes[$name] : null;
}
Expand Down Expand Up @@ -559,8 +558,7 @@ public function offsetExists($offset): bool
return \array_key_exists($offset, $this->data);
}

#[\ReturnTypeWillChange]
public function offsetGet($offset)
public function offsetGet($offset): mixed
{
return $this->offsetExists($offset) ? $this->data[$offset] : 'n/a';
}
Expand Down Expand Up @@ -708,8 +706,7 @@ public function offsetExists($offset): bool
return \array_key_exists($offset, $this->children);
}

#[\ReturnTypeWillChange]
public function offsetGet($offset)
public function offsetGet($offset): mixed
{
return $this->children[$offset];
}
Expand Down

0 comments on commit 5c9723e

Please sign in to comment.