mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-16 12:26:30 +00:00
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:
@@ -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
|
||||
|
||||
|
||||
@@ -32,6 +32,9 @@ class Markup implements \Countable, \JsonSerializable
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return mb_strlen($this->content, $this->charset);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user