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 $this->content;
} }
/** public function count(): int
* @return int
*/
#[\ReturnTypeWillChange]
public function count()
{ {
return mb_strlen($this->content, $this->charset); return mb_strlen($this->content, $this->charset);
} }
/** public function jsonSerialize(): mixed
* @return mixed
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{ {
return $this->content; return $this->content;
} }
+1 -5
View File
@@ -144,11 +144,7 @@ class Node implements \Countable, \IteratorAggregate
unset($this->nodes[$name]); unset($this->nodes[$name]);
} }
/** public function count(): int
* @return int
*/
#[\ReturnTypeWillChange]
public function count()
{ {
return \count($this->nodes); return \count($this->nodes);
} }
+2 -10
View File
@@ -16,20 +16,12 @@ namespace Twig\Util;
*/ */
class TemplateDirIterator extends \IteratorIterator class TemplateDirIterator extends \IteratorIterator
{ {
/** public function current(): mixed
* @return mixed
*/
#[\ReturnTypeWillChange]
public function current()
{ {
return file_get_contents(parent::current()); return file_get_contents(parent::current());
} }
/** public function key(): mixed
* @return mixed
*/
#[\ReturnTypeWillChange]
public function key()
{ {
return (string) parent::key(); return (string) parent::key();
} }
+2 -4
View File
@@ -381,8 +381,7 @@ final class CoreTestIterator implements \Iterator
$this->position = 0; $this->position = 0;
} }
#[\ReturnTypeWillChange] public function current(): mixed
public function current()
{ {
if ($this->allowValueAccess) { if ($this->allowValueAccess) {
return $this->array[$this->key()]; 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.'); throw new \LogicException('Code should only use the keys, not the values provided by iterator.');
} }
#[\ReturnTypeWillChange] public function key(): mixed
public function key()
{ {
return $this->arrayKeys[$this->position]; return $this->arrayKeys[$this->position];
} }
+2 -4
View File
@@ -19,10 +19,8 @@
class ItemsIterator implements \Iterator class ItemsIterator implements \Iterator
{ {
protected $values = ['foo' => 'bar', 'bar' => 'foo']; protected $values = ['foo' => 'bar', 'bar' => 'foo'];
#[\ReturnTypeWillChange] public function current(): mixed { return current($this->values); }
public function current() { return current($this->values); } public function key(): mixed { return key($this->values); }
#[\ReturnTypeWillChange]
public function key() { return key($this->values); }
public function next(): void { next($this->values); } public function next(): void { next($this->values); }
public function rewind(): void { reset($this->values); } public function rewind(): void { reset($this->values); }
public function valid(): bool { return false !== current($this->values); } public function valid(): bool { return false !== current($this->values); }
@@ -20,10 +20,8 @@
class ItemsIteratorCountable implements \Iterator, \Countable class ItemsIteratorCountable implements \Iterator, \Countable
{ {
protected $values = ['foo' => 'bar', 'bar' => 'foo']; protected $values = ['foo' => 'bar', 'bar' => 'foo'];
#[\ReturnTypeWillChange] public function current(): mixed { return current($this->values); }
public function current() { return current($this->values); } public function key(): mixed { return key($this->values); }
#[\ReturnTypeWillChange]
public function key() { return key($this->values); }
public function next(): void { next($this->values); } public function next(): void { next($this->values); }
public function rewind(): void { reset($this->values); } public function rewind(): void { reset($this->values); }
public function valid(): bool { return false !== current($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; $this->position = 0;
} }
#[\ReturnTypeWillChange] public function current(): mixed
public function current()
{ {
return $this->array[$this->position]; return $this->array[$this->position];
} }
#[\ReturnTypeWillChange] public function key(): mixed
public function key()
{ {
return 'a'; return 'a';
} }
@@ -366,8 +364,7 @@ class SimpleIteratorForTesting implements \Iterator
private $data = [1, 2, 3, 4, 5, 6, 7]; private $data = [1, 2, 3, 4, 5, 6, 7];
private $key = 0; private $key = 0;
#[\ReturnTypeWillChange] public function current(): mixed
public function current()
{ {
return $this->key; return $this->key;
} }
@@ -377,8 +374,7 @@ class SimpleIteratorForTesting implements \Iterator
++$this->key; ++$this->key;
} }
#[\ReturnTypeWillChange] public function key(): mixed
public function key()
{ {
return $this->key; return $this->key;
} }
+3 -6
View File
@@ -469,8 +469,7 @@ class TemplateArrayAccessObject implements \ArrayAccess
return \array_key_exists($name, $this->attributes); return \array_key_exists($name, $this->attributes);
} }
#[\ReturnTypeWillChange] public function offsetGet($name): mixed
public function offsetGet($name)
{ {
return \array_key_exists($name, $this->attributes) ? $this->attributes[$name] : null; 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); return \array_key_exists($offset, $this->data);
} }
#[\ReturnTypeWillChange] public function offsetGet($offset): mixed
public function offsetGet($offset)
{ {
return $this->offsetExists($offset) ? $this->data[$offset] : 'n/a'; return $this->offsetExists($offset) ? $this->data[$offset] : 'n/a';
} }
@@ -708,8 +706,7 @@ class TemplateArrayAccess implements \ArrayAccess
return \array_key_exists($offset, $this->children); return \array_key_exists($offset, $this->children);
} }
#[\ReturnTypeWillChange] public function offsetGet($offset): mixed
public function offsetGet($offset)
{ {
return $this->children[$offset]; return $this->children[$offset];
} }