: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* This file is part of Twig.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
namespace WPML\Core\Twig\Profiler;
* @author Fabien Potencier <fabien@symfony.com>
class Profile implements \IteratorAggregate, \Serializable
const TEMPLATE = 'template';
public function __construct($template = 'main', $type = self::ROOT, $name = 'main')
$this->template = $template;
$this->name = 0 === \strpos($name, '__internal_') ? 'INTERNAL' : $name;
public function getTemplate()
public function getType()
public function getName()
return self::ROOT === $this->type;
public function isTemplate()
return self::TEMPLATE === $this->type;
public function isBlock()
return self::BLOCK === $this->type;
public function isMacro()
return self::MACRO === $this->type;
public function getProfiles()
public function addProfile(self $profile)
$this->profiles[] = $profile;
* Returns the duration in microseconds.
public function getDuration()
if ($this->isRoot() && $this->profiles) {
// for the root node with children, duration is the sum of all child durations
foreach ($this->profiles as $profile) {
$duration += $profile->getDuration();
return isset($this->ends['wt']) && isset($this->starts['wt']) ? $this->ends['wt'] - $this->starts['wt'] : 0;
* Returns the memory usage in bytes.
public function getMemoryUsage()
return isset($this->ends['mu']) && isset($this->starts['mu']) ? $this->ends['mu'] - $this->starts['mu'] : 0;
* Returns the peak memory usage in bytes.
public function getPeakMemoryUsage()
return isset($this->ends['pmu']) && isset($this->starts['pmu']) ? $this->ends['pmu'] - $this->starts['pmu'] : 0;
$this->starts = ['wt' => \microtime(\true), 'mu' => \memory_get_usage(), 'pmu' => \memory_get_peak_usage()];
$this->ends = ['wt' => \microtime(\true), 'mu' => \memory_get_usage(), 'pmu' => \memory_get_peak_usage()];
$this->starts = $this->ends = $this->profiles = [];
public function getIterator()
return new \ArrayIterator($this->profiles);
public function serialize()
return \serialize($this->__serialize());
public function unserialize($data)
$this->__unserialize(\unserialize($data));
public function __serialize()
return [$this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles];
public function __unserialize(array $data)
list($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles) = $data;
\class_alias('WPML\\Core\\Twig\\Profiler\\Profile', 'WPML\\Core\\Twig_Profiler_Profile');