Update Twig from 1.35.0 to 1.42.4 (PHP 5.5 is now required!)

This fixes some errors on PHP 7.4 and contains even more fixes
Also bumped PHP version to 5.5 as Twig requires it.
This commit is contained in:
slawkens
2020-02-15 05:41:38 +01:00
parent d9e449b6cf
commit 8021308822
414 changed files with 9276 additions and 5531 deletions

View File

@@ -9,25 +9,29 @@
* file that was distributed with this source code.
*/
namespace Twig\Profiler\Dumper;
use Twig\Profiler\Profile;
/**
* @author Fabien Potencier <fabien@symfony.com>
*/
abstract class Twig_Profiler_Dumper_Base
abstract class BaseDumper
{
private $root;
public function dump(Twig_Profiler_Profile $profile)
public function dump(Profile $profile)
{
return $this->dumpProfile($profile);
}
abstract protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix);
abstract protected function formatTemplate(Profile $profile, $prefix);
abstract protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix);
abstract protected function formatNonTemplate(Profile $profile, $prefix);
abstract protected function formatTime(Twig_Profiler_Profile $profile, $percent);
abstract protected function formatTime(Profile $profile, $percent);
private function dumpProfile(Twig_Profiler_Profile $profile, $prefix = '', $sibling = false)
private function dumpProfile(Profile $profile, $prefix = '', $sibling = false)
{
if ($profile->isRoot()) {
$this->root = $profile->getDuration();
@@ -49,7 +53,7 @@ abstract class Twig_Profiler_Dumper_Base
$str = sprintf("%s %s\n", $start, $this->formatTime($profile, $percent));
}
$nCount = count($profile->getProfiles());
$nCount = \count($profile->getProfiles());
foreach ($profile as $i => $p) {
$str .= $this->dumpProfile($p, $prefix, $i + 1 !== $nCount);
}
@@ -58,5 +62,4 @@ abstract class Twig_Profiler_Dumper_Base
}
}
class_alias('Twig_Profiler_Dumper_Base', 'Twig\Profiler\Dumper\BaseDumper', false);
class_exists('Twig_Profiler_Profile');
class_alias('Twig\Profiler\Dumper\BaseDumper', 'Twig_Profiler_Dumper_Base');

View File

@@ -9,16 +9,20 @@
* file that was distributed with this source code.
*/
namespace Twig\Profiler\Dumper;
use Twig\Profiler\Profile;
/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @final
*/
class Twig_Profiler_Dumper_Blackfire
class BlackfireDumper
{
public function dump(Twig_Profiler_Profile $profile)
public function dump(Profile $profile)
{
$data = array();
$data = [];
$this->dumpProfile('main()', $profile, $data);
$this->dumpChildren('main()', $profile, $data);
@@ -38,7 +42,7 @@ EOF;
return $str;
}
private function dumpChildren($parent, Twig_Profiler_Profile $profile, &$data)
private function dumpChildren($parent, Profile $profile, &$data)
{
foreach ($profile as $p) {
if ($p->isTemplate()) {
@@ -51,22 +55,22 @@ EOF;
}
}
private function dumpProfile($edge, Twig_Profiler_Profile $profile, &$data)
private function dumpProfile($edge, Profile $profile, &$data)
{
if (isset($data[$edge])) {
$data[$edge]['ct'] += 1;
++$data[$edge]['ct'];
$data[$edge]['wt'] += floor($profile->getDuration() * 1000000);
$data[$edge]['mu'] += $profile->getMemoryUsage();
$data[$edge]['pmu'] += $profile->getPeakMemoryUsage();
} else {
$data[$edge] = array(
$data[$edge] = [
'ct' => 1,
'wt' => floor($profile->getDuration() * 1000000),
'mu' => $profile->getMemoryUsage(),
'pmu' => $profile->getPeakMemoryUsage(),
);
];
}
}
}
class_alias('Twig_Profiler_Dumper_Blackfire', 'Twig\Profiler\Dumper\BlackfireDumper', false);
class_alias('Twig\Profiler\Dumper\BlackfireDumper', 'Twig_Profiler_Dumper_Blackfire');

View File

@@ -9,39 +9,43 @@
* file that was distributed with this source code.
*/
namespace Twig\Profiler\Dumper;
use Twig\Profiler\Profile;
/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @final
*/
class Twig_Profiler_Dumper_Html extends Twig_Profiler_Dumper_Base
class HtmlDumper extends BaseDumper
{
private static $colors = array(
private static $colors = [
'block' => '#dfd',
'macro' => '#ddf',
'template' => '#ffd',
'big' => '#d44',
);
];
public function dump(Twig_Profiler_Profile $profile)
public function dump(Profile $profile)
{
return '<pre>'.parent::dump($profile).'</pre>';
}
protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix)
protected function formatTemplate(Profile $profile, $prefix)
{
return sprintf('%s└ <span style="background-color: %s">%s</span>', $prefix, self::$colors['template'], $profile->getTemplate());
}
protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix)
protected function formatNonTemplate(Profile $profile, $prefix)
{
return sprintf('%s└ %s::%s(<span style="background-color: %s">%s</span>)', $prefix, $profile->getTemplate(), $profile->getType(), isset(self::$colors[$profile->getType()]) ? self::$colors[$profile->getType()] : 'auto', $profile->getName());
}
protected function formatTime(Twig_Profiler_Profile $profile, $percent)
protected function formatTime(Profile $profile, $percent)
{
return sprintf('<span style="color: %s">%.2fms/%.0f%%</span>', $percent > 20 ? self::$colors['big'] : 'auto', $profile->getDuration() * 1000, $percent);
}
}
class_alias('Twig_Profiler_Dumper_Html', 'Twig\Profiler\Dumper\HtmlDumper', false);
class_alias('Twig\Profiler\Dumper\HtmlDumper', 'Twig_Profiler_Dumper_Html');

View File

@@ -9,27 +9,31 @@
* file that was distributed with this source code.
*/
namespace Twig\Profiler\Dumper;
use Twig\Profiler\Profile;
/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @final
*/
class Twig_Profiler_Dumper_Text extends Twig_Profiler_Dumper_Base
class TextDumper extends BaseDumper
{
protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix)
protected function formatTemplate(Profile $profile, $prefix)
{
return sprintf('%s└ %s', $prefix, $profile->getTemplate());
}
protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix)
protected function formatNonTemplate(Profile $profile, $prefix)
{
return sprintf('%s└ %s::%s(%s)', $prefix, $profile->getTemplate(), $profile->getType(), $profile->getName());
}
protected function formatTime(Twig_Profiler_Profile $profile, $percent)
protected function formatTime(Profile $profile, $percent)
{
return sprintf('%.2fms/%.0f%%', $profile->getDuration() * 1000, $percent);
}
}
class_alias('Twig_Profiler_Dumper_Text', 'Twig\Profiler\Dumper\TextDumper', false);
class_alias('Twig\Profiler\Dumper\TextDumper', 'Twig_Profiler_Dumper_Text');