Skip to content

Commit

Permalink
Folded all curly brackets of control structures to conform to PEAR/ZF CS
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek authored and fabpot committed May 7, 2010
1 parent e799768 commit 2684de0
Show file tree
Hide file tree
Showing 223 changed files with 1,916 additions and 4,272 deletions.
44 changes: 14 additions & 30 deletions src/Symfony/Components/BrowserKit/Client.php
Expand Up @@ -75,8 +75,7 @@ public function followRedirects($followRedirect = true)
*/
public function insulate($insulated = true)
{
if (!class_exists('Symfony\\Components\\Process\\Process'))
{
if (!class_exists('Symfony\\Components\\Process\\Process')) {
// @codeCoverageIgnoreStart
throw new \RuntimeException('Unable to isolate requests as the Symfony Process Component is not installed.');
// @codeCoverageIgnoreEnd
Expand Down Expand Up @@ -189,8 +188,7 @@ public function request($method, $uri, $parameters = array(), $headers = array()
$uri = $this->getAbsoluteUri($uri);

$server = array_merge($this->server, $server);
if (!$this->history->isEmpty())
{
if (!$this->history->isEmpty()) {
$server['HTTP_REFERER'] = $this->history->current()->getUri();
}
$server['HTTP_HOST'] = parse_url($uri, PHP_URL_HOST);
Expand All @@ -200,17 +198,13 @@ public function request($method, $uri, $parameters = array(), $headers = array()

$this->request = $this->filterRequest($request);

if (true === $changeHistory)
{
if (true === $changeHistory) {
$this->history->add($request);
}

if ($this->insulated)
{
if ($this->insulated) {
$this->response = $this->doRequestInProcess($this->request);
}
else
{
} else {
$this->response = $this->doRequest($this->request);
}

Expand All @@ -220,8 +214,7 @@ public function request($method, $uri, $parameters = array(), $headers = array()

$this->redirect = $response->getHeader('Location');

if ($this->followRedirects && $this->redirect)
{
if ($this->followRedirects && $this->redirect) {
return $this->crawler = $this->followRedirect();
}

Expand All @@ -242,8 +235,7 @@ protected function doRequestInProcess($request)
$process = new PhpProcess($this->getScript($request));
$process->run();

if ($process->getExitCode() > 0)
{
if ($process->getExitCode() > 0) {
throw new \RuntimeException($process->getErrorOutput());
}

Expand Down Expand Up @@ -324,8 +316,7 @@ public function reload()
*/
public function followRedirect()
{
if (empty($this->redirect))
{
if (empty($this->redirect)) {
throw new \LogicException('The request was not redirected.');
}

Expand All @@ -346,35 +337,28 @@ public function restart()
protected function getAbsoluteUri($uri)
{
// already absolute?
if ('http' === substr($uri, 0, 4))
{
if ('http' === substr($uri, 0, 4)) {
return $uri;
}

if (!$this->history->isEmpty())
{
if (!$this->history->isEmpty()) {
$currentUri = $this->history->current()->getUri();
}
else
{
} else {
$currentUri = sprintf('http%s://%s/',
isset($this->server['HTTPS']) ? 's' : '',
isset($this->server['HTTP_HOST']) ? $this->server['HTTP_HOST'] : 'localhost'
);
}

// anchor?
if (!$uri || '#' == $uri[0])
{
if (!$uri || '#' == $uri[0]) {
return preg_replace('/#.*?$/', '', $currentUri).$uri;
}

if ('/' !== $uri[0])
{
if ('/' !== $uri[0]) {
$path = parse_url($currentUri, PHP_URL_PATH);

if ('/' !== substr($path, -1))
{
if ('/' !== substr($path, -1)) {
$path = substr($path, 0, strrpos($path, '/') + 1);
}

Expand Down
15 changes: 5 additions & 10 deletions src/Symfony/Components/BrowserKit/CookieJar.php
Expand Up @@ -71,8 +71,7 @@ public function clear()
*/
public function updateFromResponse(Response $response)
{
foreach ($response->getCookies() as $name => $cookie)
{
foreach ($response->getCookies() as $name => $cookie) {
$this->set(new Cookie(
$name,
isset($cookie['value']) ? $cookie['value'] : '',
Expand Down Expand Up @@ -110,20 +109,17 @@ public function getValues($uri)
$parts = parse_url($uri);

$cookies = array();
foreach ($this->cookieJar as $cookie)
{
foreach ($this->cookieJar as $cookie) {
if ($cookie->getDomain() && $cookie->getDomain() != substr($parts['host'], -strlen($cookie->getDomain())))
{
continue;
}

if ($cookie->getPath() != substr($parts['path'], 0, strlen($cookie->getPath())))
{
if ($cookie->getPath() != substr($parts['path'], 0, strlen($cookie->getPath()))) {
continue;
}

if ($cookie->isSecure() && 'https' != $parts['scheme'])
{
if ($cookie->isSecure() && 'https' != $parts['scheme']) {
continue;
}

Expand All @@ -139,8 +135,7 @@ public function getValues($uri)
public function flushExpiredCookies()
{
$cookies = $this->cookieJar;
foreach ($cookies as $name => $cookie)
{
foreach ($cookies as $name => $cookie) {
if ($cookie->isExpired())
{
unset($this->cookieJar[$name]);
Expand Down
9 changes: 3 additions & 6 deletions src/Symfony/Components/BrowserKit/History.php
Expand Up @@ -71,8 +71,7 @@ public function isEmpty()
*/
public function back()
{
if ($this->position < 1)
{
if ($this->position < 1) {
throw new \LogicException('You are already on the first page.');
}

Expand All @@ -88,8 +87,7 @@ public function back()
*/
public function forward()
{
if ($this->position > count($this->stack) - 2)
{
if ($this->position > count($this->stack) - 2) {
throw new \LogicException('You are already on the last page.');
}

Expand All @@ -105,8 +103,7 @@ public function forward()
*/
public function current()
{
if (-1 == $this->position)
{
if (-1 == $this->position) {
throw new \LogicException('The page history is empty.');
}

Expand Down
9 changes: 3 additions & 6 deletions src/Symfony/Components/BrowserKit/Response.php
Expand Up @@ -44,12 +44,10 @@ public function __construct($content = '', $status = 200, $headers = array(), $c
public function __toString()
{
$headers = '';
foreach ($this->headers as $name => $value)
{
foreach ($this->headers as $name => $value) {
$headers .= sprintf("%s: %s\n", $name, $value);
}
foreach ($this->cookies as $name => $cookie)
{
foreach ($this->cookies as $name => $cookie) {
$headers .= sprintf("Set-Cookie: %s=%s\n", $name, $cookie['value']);
}

Expand Down Expand Up @@ -95,8 +93,7 @@ public function getHeaders()
*/
public function getHeader($header)
{
foreach ($this->headers as $key => $value)
{
foreach ($this->headers as $key => $value) {
if (str_replace('-', '_', strtolower($key)) == str_replace('-', '_', strtolower($header)))
{
return $value;
Expand Down

0 comments on commit 2684de0

Please sign in to comment.