Merge branch '1.x' into 2.x

* 1.x:
  Add some return types
  remove the C extension
  Fix length filter doc
This commit is contained in:
Fabien Potencier
2021-02-02 16:25:09 +01:00
4 changed files with 15 additions and 6 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ return value of the ``count()`` method.
For objects that implement the ``__toString()`` magic method (and not ``Countable``),
it will return the length of the string provided by that method.
For objects that implement the ``IteratorAggregate`` interface, ``length`` will use the return value of the ``iterator_count()`` method.
For objects that implement the ``Traversable`` interface, ``length`` will use the return value of the ``iterator_count()`` method.
.. code-block:: twig
+3
View File
@@ -32,6 +32,9 @@ class Markup implements \Countable, \JsonSerializable
return $this->content;
}
/**
* @return int
*/
public function count()
{
return mb_strlen($this->content, $this->charset);
+6
View File
@@ -158,11 +158,17 @@ class Node implements \Countable, \IteratorAggregate
unset($this->nodes[$name]);
}
/**
* @return int
*/
public function count()
{
return \count($this->nodes);
}
/**
* @return \Traversable
*/
public function getIterator()
{
return new \ArrayIterator($this->nodes);
+5 -5
View File
@@ -157,17 +157,17 @@ class Profile implements \IteratorAggregate, \Serializable
$this->enter();
}
public function getIterator()
public function getIterator(): \Traversable
{
return new \ArrayIterator($this->profiles);
}
public function serialize()
public function serialize(): string
{
return serialize($this->__serialize());
}
public function unserialize($data)
public function unserialize($data): void
{
$this->__unserialize(unserialize($data));
}
@@ -175,7 +175,7 @@ class Profile implements \IteratorAggregate, \Serializable
/**
* @internal
*/
public function __serialize()
public function __serialize(): array
{
return [$this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles];
}
@@ -183,7 +183,7 @@ class Profile implements \IteratorAggregate, \Serializable
/**
* @internal
*/
public function __unserialize(array $data)
public function __unserialize(array $data): void
{
list($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles) = $data;
}