feature #20971 [WebProfilerBundle] Split PHP version if needed (ro0NL)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[WebProfilerBundle] Split PHP version if needed

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes/no
| Fixed tickets | https://github.com/symfony/symfony/pull/20697#issuecomment-263966015
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!--highly recommended for new features-->

Commits
-------

1241a00 [WebProfilerBundle] Split PHP version if needed
This commit is contained in:
Fabien Potencier 2016-12-19 09:26:18 +01:00
commit dd1fd31d7a
3 changed files with 19 additions and 3 deletions

View File

@ -75,7 +75,7 @@
<div class="sf-toolbar-info-group">
<div class="sf-toolbar-info-piece sf-toolbar-info-php">
<b>PHP version</b>
<span>
<span{% if collector.phpversionextra %} title="{{ collector.phpversion ~ collector.phpversionextra }}"{% endif %}>
{{ collector.phpversion }}
&nbsp; <a href="{{ path('_profiler_phpinfo') }}">View phpinfo()</a>
</span>
@ -213,7 +213,7 @@
<div class="metrics">
<div class="metric">
<span class="value">{{ collector.phpversion }}</span>
<span class="value">{{ collector.phpversion }}{% if collector.phpversionextra %} <span class="unit">{{ collector.phpversionextra }}</span>{% endif %}</span>
<span class="label">PHP version</span>
</div>

View File

@ -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)
*/

View File

@ -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(class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', $c->getPhpIntlLocale());
$this->assertSame(date_default_timezone_get(), $c->getPhpTimezone());