Micro optim using explicit root namespaces

This commit is contained in:
Nicolas Grekas 2017-11-07 21:33:43 +01:00
parent 850bb2d20a
commit e78d1c4551
3 changed files with 16 additions and 8 deletions

View File

@ -209,7 +209,7 @@ class EventDispatcher implements EventDispatcherInterface
if ($event->isPropagationStopped()) {
break;
}
call_user_func($listener, $event, $eventName, $this);
\call_user_func($listener, $event, $eventName, $this);
}
}
@ -225,7 +225,7 @@ class EventDispatcher implements EventDispatcherInterface
foreach ($this->listeners[$eventName] as $priority => $listeners) {
foreach ($listeners as $k => $listener) {
if (is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure) {
if (\is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure) {
$listener[0] = $listener[0]();
$this->listeners[$eventName][$priority][$k] = $listener;
}

View File

@ -121,7 +121,7 @@ class HeaderBag implements \IteratorAggregate, \Countable
}
if ($first) {
return count($headers[$key]) ? $headers[$key][0] : $default;
return \count($headers[$key]) ? $headers[$key][0] : $default;
}
return $headers[$key];
@ -138,12 +138,20 @@ class HeaderBag implements \IteratorAggregate, \Countable
{
$key = str_replace('_', '-', strtolower($key));
$values = array_values((array) $values);
if (\is_array($values)) {
$values = array_values($values);
if (true === $replace || !isset($this->headers[$key])) {
$this->headers[$key] = $values;
if (true === $replace || !isset($this->headers[$key])) {
$this->headers[$key] = $values;
} else {
$this->headers[$key] = array_merge($this->headers[$key], $values);
}
} else {
$this->headers[$key] = array_merge($this->headers[$key], $values);
if (true === $replace || !isset($this->headers[$key])) {
$this->headers[$key] = array($values);
} else {
$this->headers[$key][] = $values;
}
}
if ('cache-control' === $key) {

View File

@ -122,7 +122,7 @@ class ResponseHeaderBag extends HeaderBag
parent::set($key, $values, $replace);
// ensure the cache-control header has sensible defaults
if (in_array($uniqueKey, array('cache-control', 'etag', 'last-modified', 'expires'))) {
if (\in_array($uniqueKey, array('cache-control', 'etag', 'last-modified', 'expires'), true)) {
$computed = $this->computeCacheControlValue();
$this->headers['cache-control'] = array($computed);
$this->headerNames['cache-control'] = 'Cache-Control';