Skip to content

Commit

Permalink
improved coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jun 19, 2015
1 parent d3e44f5 commit 360dadc
Show file tree
Hide file tree
Showing 60 changed files with 503 additions and 502 deletions.
2 changes: 1 addition & 1 deletion src/Bridges/HttpDI/SessionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function loadConfiguration()

if ($this->debugMode && $config['debugger']) {
$session->addSetup('@Tracy\Bar::addPanel', [
new Nette\DI\Statement('Nette\Bridges\HttpTracy\SessionPanel')
new Nette\DI\Statement('Nette\Bridges\HttpTracy\SessionPanel'),
]);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Bridges/HttpTracy/SessionPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace Nette\Bridges\HttpTracy;

use Nette,
Tracy;
use Nette;
use Tracy;


/**
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace Nette\Http;

use Nette,
Nette\Utils\DateTime;
use Nette;
use Nette\Utils\DateTime;


/**
Expand Down
2 changes: 1 addition & 1 deletion src/Http/IResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface IResponse
S303_POST_GET = 303,
S304_NOT_MODIFIED = 304,
S305_USE_PROXY = 305,
S307_TEMPORARY_REDIRECT= 307,
S307_TEMPORARY_REDIRECT = 307,
S400_BAD_REQUEST = 400,
S401_UNAUTHORIZED = 401,
S402_PAYMENT_REQUIRED = 402,
Expand Down
3 changes: 2 additions & 1 deletion src/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ public function detectLanguage(array $langs)
foreach ($matches[1] as $key => $value) {
$q = $matches[2][$key] === '' ? 1.0 : (float) $matches[2][$key];
if ($q > $max) {
$max = $q; $lang = $value;
$max = $q;
$lang = $value;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/Http/RequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace Nette\Http;

use Nette,
Nette\Utils\Strings;
use Nette;
use Nette\Utils\Strings;


/**
Expand Down Expand Up @@ -213,7 +213,7 @@ public function createHttpRequest()
}

// raw body
$rawBodyCallback = function() {
$rawBodyCallback = function () {
static $rawBody;

if (PHP_VERSION_ID >= 50600) {
Expand Down
6 changes: 3 additions & 3 deletions src/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace Nette\Http;

use Nette,
Nette\Utils\DateTime;
use Nette;
use Nette\Utils\DateTime;


/**
Expand Down Expand Up @@ -291,7 +291,7 @@ private function checkHeaders()
if (headers_sent($file, $line)) {
throw new Nette\InvalidStateException('Cannot send header after HTTP headers have been sent' . ($file ? " (output started at $file:$line)." : '.'));

} elseif ($this->warnOnBuffer && ob_get_length() && !array_filter(ob_get_status(TRUE), function($i) { return !$i['chunk_size']; })) {
} elseif ($this->warnOnBuffer && ob_get_length() && !array_filter(ob_get_status(TRUE), function ($i) { return !$i['chunk_size']; })) {
trigger_error('Possible problem: you are sending a HTTP header while already having some data in output buffer. Try Tracy\OutputDebugger or start session earlier.', E_USER_NOTICE);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Http/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public function regenerateId()
{
if (self::$started && !$this->regenerated) {
if (headers_sent($file, $line)) {
throw new Nette\InvalidStateException("Cannot regenerate session ID after HTTP headers have been sent" . ($file ? " (output started at $file:$line)." : "."));
throw new Nette\InvalidStateException('Cannot regenerate session ID after HTTP headers have been sent' . ($file ? " (output started at $file:$line)." : '.'));
}
session_regenerate_id(TRUE);
session_write_close();
Expand Down Expand Up @@ -413,7 +413,7 @@ private function configure(array $config)

} else {
if (defined('SID')) {
throw new Nette\InvalidStateException("Unable to set 'session.$key' to value '$value' when session has been started" . ($this->started ? "." : " by session.auto_start or session_start()."));
throw new Nette\InvalidStateException("Unable to set 'session.$key' to value '$value' when session has been started" . ($this->started ? '.' : ' by session.auto_start or session_start().'));
}
if (isset($special[$key])) {
$key = "session_$key";
Expand Down Expand Up @@ -479,7 +479,7 @@ public function setCookieParameters($path, $domain = NULL, $secure = NULL)
return $this->setOptions([
'cookie_path' => $path,
'cookie_domain' => $domain,
'cookie_secure' => $secure
'cookie_secure' => $secure,
]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Http/SessionSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SessionSection extends Nette\Object implements \IteratorAggregate, \ArrayA
public function __construct(Session $session, $name)
{
if (!is_string($name)) {
throw new Nette\InvalidArgumentException("Session namespace must be a string, " . gettype($name) . " given.");
throw new Nette\InvalidArgumentException('Session namespace must be a string, ' . gettype($name) . ' given.');
}

$this->session = $session;
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public function canonicalize()
{
$this->path = preg_replace_callback(
'#[^!$&\'()*+,/:;=@%]+#',
function($m) { return rawurlencode($m[0]); },
function ($m) { return rawurlencode($m[0]); },
self::unescape($this->path, '%/')
);
$this->host = strtolower($this->host);
Expand Down Expand Up @@ -474,7 +474,7 @@ public static function unescape($s, $reserved = '%;/?:@&=+$,')
if ($reserved !== '') {
$s = preg_replace_callback(
'#%(' . substr(chunk_split(bin2hex($reserved), 2, '|'), 0, -1) . ')#i',
function($m) { return '%25' . strtoupper($m[1]); },
function ($m) { return '%25' . strtoupper($m[1]); },
$s
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Http/UserStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace Nette\Http;

use Nette,
Nette\Security\IIdentity;
use Nette;
use Nette\Security\IIdentity;


/**
Expand All @@ -29,7 +29,7 @@ class UserStorage extends Nette\Object implements Nette\Security\IUserStorage
private $sessionSection;


public function __construct(Session $sessionHandler)
public function __construct(Session $sessionHandler)
{
$this->sessionHandler = $sessionHandler;
}
Expand Down
12 changes: 6 additions & 6 deletions tests/Http.DI/HttpExtension.defaultHeaders.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* Test: HttpExtension.
*/

use Nette\DI,
Nette\Bridges\HttpDI\HttpExtension,
Tester\Assert;
use Nette\DI;
use Nette\Bridges\HttpDI\HttpExtension;
use Tester\Assert;


require __DIR__ . '/../bootstrap.php';
Expand All @@ -24,6 +24,6 @@ $container = new Container1;
$container->initialize();

$headers = headers_list();
Assert::contains( 'X-Frame-Options: SAMEORIGIN', $headers );
Assert::contains( 'Content-Type: text/html; charset=utf-8', $headers );
Assert::contains( 'X-Powered-By: Nette Framework', $headers );
Assert::contains('X-Frame-Options: SAMEORIGIN', $headers);
Assert::contains('Content-Type: text/html; charset=utf-8', $headers);
Assert::contains('X-Powered-By: Nette Framework', $headers);
20 changes: 10 additions & 10 deletions tests/Http.DI/HttpExtension.headers.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* Test: HttpExtension.
*/

use Nette\DI,
Nette\Bridges\HttpDI\HttpExtension,
Tester\Assert;
use Nette\DI;
use Nette\Bridges\HttpDI\HttpExtension;
use Tester\Assert;


require __DIR__ . '/../bootstrap.php';
Expand All @@ -32,19 +32,19 @@ $container = new Container1;
$container->initialize();

$headers = headers_list();
Assert::contains( 'X-Frame-Options: SAMEORIGIN', $headers );
Assert::contains( 'Content-Type: text/html; charset=utf-8', $headers );
Assert::contains( 'X-Powered-By: Nette Framework', $headers );
Assert::contains( 'A: b', $headers );
Assert::notContains( 'C:', $headers );
Assert::contains('X-Frame-Options: SAMEORIGIN', $headers);
Assert::contains('Content-Type: text/html; charset=utf-8', $headers);
Assert::contains('X-Powered-By: Nette Framework', $headers);
Assert::contains('A: b', $headers);
Assert::notContains('C:', $headers);



echo ' '; @ob_flush(); flush();

Assert::true( headers_sent() );
Assert::true(headers_sent());

Assert::error(function() use ($container) {
Assert::error(function () use ($container) {
$container->initialize();
}, [
[E_WARNING, 'Cannot modify header information - headers already sent %a%'],
Expand Down
6 changes: 3 additions & 3 deletions tests/Http.DI/HttpExtension.services.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* Test: HttpExtension.
*/

use Nette\DI,
Nette\Bridges\HttpDI\HttpExtension,
Tester\Assert;
use Nette\DI;
use Nette\Bridges\HttpDI\HttpExtension;
use Tester\Assert;


require __DIR__ . '/../bootstrap.php';
Expand Down
8 changes: 4 additions & 4 deletions tests/Http.DI/SessionExtension.autoStart.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Test: SessionExtension.
*/

use Nette\DI,
Nette\Bridges\HttpDI\HttpExtension,
Nette\Bridges\HttpDI\SessionExtension,
Tester\Assert;
use Nette\DI;
use Nette\Bridges\HttpDI\HttpExtension;
use Nette\Bridges\HttpDI\SessionExtension;
use Tester\Assert;


require __DIR__ . '/../bootstrap.php';
Expand Down
8 changes: 4 additions & 4 deletions tests/Http.DI/SessionExtension.config.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Test: SessionExtension.
*/

use Nette\DI,
Nette\Bridges\HttpDI\HttpExtension,
Nette\Bridges\HttpDI\SessionExtension,
Tester\Assert;
use Nette\DI;
use Nette\Bridges\HttpDI\HttpExtension;
use Nette\Bridges\HttpDI\SessionExtension;
use Tester\Assert;


require __DIR__ . '/../bootstrap.php';
Expand Down
34 changes: 17 additions & 17 deletions tests/Http/FileUpload.basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
* Test: Nette\Http\FileUpload basic test.
*/

use Nette\Http\FileUpload,
Tester\Assert;
use Nette\Http\FileUpload;
use Tester\Assert;


require __DIR__ . '/../bootstrap.php';


test(function() {
test(function () {
$upload = new FileUpload([
'name' => 'readme.txt',
'type' => 'text/plain',
Expand All @@ -20,19 +20,19 @@ test(function() {
'size' => 209,
]);

Assert::same( 'readme.txt', $upload->getName() );
Assert::same( 'readme.txt', $upload->getSanitizedName() );
Assert::same( 209, $upload->getSize() );
Assert::same( __DIR__ . '/files/file.txt', $upload->getTemporaryFile() );
Assert::same( __DIR__ . '/files/file.txt', (string) $upload );
Assert::same( 0, $upload->getError() );
Assert::true( $upload->isOk() );
Assert::false( $upload->isImage() );
Assert::same( file_get_contents(__DIR__ . '/files/file.txt'), $upload->getContents() );
Assert::same('readme.txt', $upload->getName());
Assert::same('readme.txt', $upload->getSanitizedName());
Assert::same(209, $upload->getSize());
Assert::same(__DIR__ . '/files/file.txt', $upload->getTemporaryFile());
Assert::same(__DIR__ . '/files/file.txt', (string) $upload);
Assert::same(0, $upload->getError());
Assert::true($upload->isOk());
Assert::false($upload->isImage());
Assert::same(file_get_contents(__DIR__ . '/files/file.txt'), $upload->getContents());
});


test(function() {
test(function () {
$upload = new FileUpload([
'name' => '../.image.png',
'type' => 'text/plain',
Expand All @@ -41,8 +41,8 @@ test(function() {
'size' => 209,
]);

Assert::same( '../.image.png', $upload->getName() );
Assert::same( 'image.png', $upload->getSanitizedName() );
Assert::same( 'image/png', $upload->getContentType() );
Assert::true( $upload->isImage() );
Assert::same('../.image.png', $upload->getName());
Assert::same('image.png', $upload->getSanitizedName());
Assert::same('image/png', $upload->getContentType());
Assert::true($upload->isImage());
});

0 comments on commit 360dadc

Please sign in to comment.