Remove usage of ReturnTypeWillChange

This commit is contained in:
Fabien Potencier
2023-12-24 11:20:45 +01:00
parent 2956688a95
commit 13e57cb3fe
8 changed files with 18 additions and 51 deletions
+2 -10
View File
@@ -32,20 +32,12 @@ class Markup implements \Countable, \JsonSerializable
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;
}
+1 -5
View File
@@ -144,11 +144,7 @@ class Node implements \Countable, \IteratorAggregate
unset($this->nodes[$name]);
}
/**
* @return int
*/
#[\ReturnTypeWillChange]
public function count()
public function count(): int
{
return \count($this->nodes);
}
+2 -10
View File
@@ -16,20 +16,12 @@ namespace Twig\Util;
*/
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();
}
+2 -4
View File
@@ -381,8 +381,7 @@ final class CoreTestIterator implements \Iterator
$this->position = 0;
}
#[\ReturnTypeWillChange]
public function current()
public function current(): mixed
{
if ($this->allowValueAccess) {
return $this->array[$this->key()];
@@ -391,8 +390,7 @@ final class CoreTestIterator implements \Iterator
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];
}
+2 -4
View File
@@ -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); }
@@ -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); }
+4 -8
View File
@@ -106,14 +106,12 @@ class TwigTestFoo implements \Iterator
$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';
}
@@ -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;
}
@@ -377,8 +374,7 @@ class SimpleIteratorForTesting implements \Iterator
++$this->key;
}
#[\ReturnTypeWillChange]
public function key()
public function key(): mixed
{
return $this->key;
}
+3 -6
View File
@@ -469,8 +469,7 @@ class TemplateArrayAccessObject implements \ArrayAccess
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;
}
@@ -559,8 +558,7 @@ class TemplatePropertyObjectAndArrayAccess extends TemplatePropertyObject implem
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';
}
@@ -708,8 +706,7 @@ class TemplateArrayAccess implements \ArrayAccess
return \array_key_exists($offset, $this->children);
}
#[\ReturnTypeWillChange]
public function offsetGet($offset)
public function offsetGet($offset): mixed
{
return $this->children[$offset];
}