From 1241a00f6de36240614350c8f82f13ee51362f15 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Sat, 17 Dec 2016 14:14:25 +0000 Subject: [PATCH] [WebProfilerBundle] Split PHP version if needed --- .../Resources/views/Collector/config.html.twig | 4 ++-- .../DataCollector/ConfigDataCollector.php | 15 +++++++++++++++ .../DataCollector/ConfigDataCollectorTest.php | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig index 3281de24d6..12a2c4a3bc 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig @@ -75,7 +75,7 @@
PHP version - + {{ collector.phpversion }}   View phpinfo() @@ -213,7 +213,7 @@
- {{ collector.phpversion }} + {{ collector.phpversion }}{% if collector.phpversionextra %} {{ collector.phpversionextra }}{% endif %} PHP version
diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php index 20128171f4..644c89ee06 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -89,6 +89,11 @@ class ConfigDataCollector extends DataCollector $this->data['symfony_eom'] = $eom->format('F Y'); $this->data['symfony_eol'] = $eol->format('F Y'); } + + if (preg_match('~^(\d+(?:\.\d+)*)(.+)?$~', $this->data['php_version'], $matches) && isset($matches[2])) { + $this->data['php_version'] = $matches[1]; + $this->data['php_version_extra'] = $matches[2]; + } } public function getApplicationName() @@ -174,6 +179,16 @@ class ConfigDataCollector extends DataCollector return $this->data['php_version']; } + /** + * Gets the PHP version extra part. + * + * @return string|null The extra part + */ + public function getPhpVersionExtra() + { + return isset($this->data['php_version_extra']) ? $this->data['php_version_extra'] : null; + } + /** * @return int The PHP architecture as number of bits (e.g. 32 or 64) */ diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php index 1cc76e02c4..9f98ef44ba 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php @@ -30,7 +30,8 @@ class ConfigDataCollectorTest extends \PHPUnit_Framework_TestCase $this->assertTrue($c->isDebug()); $this->assertSame('config', $c->getName()); $this->assertSame('testkernel', $c->getAppName()); - $this->assertSame(PHP_VERSION, $c->getPhpVersion()); + $this->assertRegExp('~^'.preg_quote($c->getPhpVersion(), '~').'~', PHP_VERSION); + $this->assertRegExp('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', PHP_VERSION); $this->assertSame(PHP_INT_SIZE * 8, $c->getPhpArchitecture()); $this->assertSame(\Locale::getDefault() ?: 'n/a', $c->getPhpIntlLocale()); $this->assertSame(date_default_timezone_get(), $c->getPhpTimezone());