Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Micro optim using explicit root namespaces #24866

Merged
merged 1 commit into from Nov 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Symfony/Component/EventDispatcher/EventDispatcher.php
Expand Up @@ -209,7 +209,7 @@ protected function doDispatch($listeners, $eventName, Event $event)
if ($event->isPropagationStopped()) {
break;
}
call_user_func($listener, $event, $eventName, $this);
\call_user_func($listener, $event, $eventName, $this);
}
}

Expand All @@ -225,7 +225,7 @@ private function sortListeners($eventName)

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;
}
Expand Down
18 changes: 13 additions & 5 deletions src/Symfony/Component/HttpFoundation/HeaderBag.php
Expand Up @@ -121,7 +121,7 @@ public function get($key, $default = null, $first = true)
}

if ($first) {
return count($headers[$key]) ? $headers[$key][0] : $default;
return \count($headers[$key]) ? $headers[$key][0] : $default;
}

return $headers[$key];
Expand All @@ -138,12 +138,20 @@ public function set($key, $values, $replace = true)
{
$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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/ResponseHeaderBag.php
Expand Up @@ -122,7 +122,7 @@ public function set($key, $values, $replace = true)
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';
Expand Down