Skip to content

Commit

Permalink
Merge pull request nette#70 from JanTvrdik/php56
Browse files Browse the repository at this point in the history
5.6
  • Loading branch information
dg committed Aug 26, 2015
2 parents 0d9ef49 + 5f0bbf7 commit 880a3a3
Show file tree
Hide file tree
Showing 18 changed files with 34 additions and 36 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
language: php
php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}
],
"require": {
"php": ">=5.4.4",
"php": ">=5.6.0",
"nette/utils": "~2.2, >=2.2.2"
},
"require-dev": {
Expand Down
8 changes: 4 additions & 4 deletions src/Bridges/HttpDI/HttpExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ public function loadConfiguration()
$config = $this->validateConfig($this->defaults);

$container->addDefinition($this->prefix('requestFactory'))
->setClass('Nette\Http\RequestFactory')
->setClass(Nette\Http\RequestFactory::class)
->addSetup('setProxy', [$config['proxy']]);

$container->addDefinition($this->prefix('request'))
->setClass('Nette\Http\Request')
->setClass(Nette\Http\Request::class)
->setFactory('@Nette\Http\RequestFactory::createHttpRequest');

$container->addDefinition($this->prefix('response'))
->setClass('Nette\Http\Response');
->setClass(Nette\Http\Response::class);

$container->addDefinition($this->prefix('context'))
->setClass('Nette\Http\Context');
->setClass(Nette\Http\Context::class);

if ($this->name === 'http') {
$container->addAlias('nette.httpRequestFactory', $this->prefix('requestFactory'));
Expand Down
4 changes: 2 additions & 2 deletions src/Bridges/HttpDI/SessionExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ public function loadConfiguration()
$this->setConfig($config);

$session = $container->addDefinition($this->prefix('session'))
->setClass('Nette\Http\Session');
->setClass(Nette\Http\Session::class);

if ($config['expiration']) {
$session->addSetup('setExpiration', [$config['expiration']]);
}

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::class)
]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(IRequest $request, IResponse $response)

/**
* Attempts to cache the sent entity by its last modification date.
* @param string|int|\DateTime last modified time
* @param string|int|\DateTimeInterface last modified time
* @param string strong entity tag validator
* @return bool
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Helpers

/**
* Returns HTTP valid date format.
* @param string|int|\DateTime
* @param string|int|\DateTimeInterface
* @return string
*/
public static function formatDate($time)
Expand Down
2 changes: 1 addition & 1 deletion src/Http/IResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function redirect($url, $code = self::S302_FOUND);

/**
* Sets the number of seconds before a page cached on a browser expires.
* @param string|int|\DateTime time, value 0 means "until the browser is closed"
* @param string|int|\DateTimeInterface time, value 0 means "until the browser is closed"
* @return void
*/
function setExpiration($seconds);
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function redirect($url, $code = self::S302_FOUND)

/**
* Sets the number of seconds before a page cached on a browser expires.
* @param string|int|\DateTime time, value 0 means "until the browser is closed"
* @param string|int|\DateTimeInterface time, value 0 means "until the browser is closed"
* @return self
* @throws Nette\InvalidStateException if HTTP headers have been sent
*/
Expand Down Expand Up @@ -244,7 +244,7 @@ public function __destruct()
* Sends a cookie.
* @param string name of the cookie
* @param string value
* @param string|int|\DateTime expiration time, value 0 means "until the browser is closed"
* @param string|int|\DateTimeInterface expiration time, value 0 means "until the browser is closed"
* @param string
* @param string
* @param bool
Expand Down
8 changes: 4 additions & 4 deletions src/Http/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*/
class Session extends Nette\Object
{
/** Default file lifetime is 3 hours */
const DEFAULT_FILE_LIFETIME = 10800;
/** Default file lifetime */
const DEFAULT_FILE_LIFETIME = 3 * Nette\Utils\DateTime::HOUR;

/** @var bool has been session ID regenerated? */
private $regenerated;
Expand Down Expand Up @@ -284,7 +284,7 @@ public function getName()
* @return SessionSection
* @throws Nette\InvalidArgumentException
*/
public function getSection($section, $class = 'Nette\Http\SessionSection')
public function getSection($section, $class = SessionSection::class)
{
return new $class($this, $section);
}
Expand Down Expand Up @@ -446,7 +446,7 @@ private function configure(array $config)

/**
* Sets the amount of time allowed between requests before the session will be terminated.
* @param string|int|\DateTime time, value 0 means "until the browser is closed"
* @param string|int|\DateTimeInterface time, value 0 means "until the browser is closed"
* @return self
*/
public function setExpiration($time)
Expand Down
2 changes: 1 addition & 1 deletion src/Http/SessionSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function offsetUnset($name)

/**
* Sets the expiration of the section or specific variables.
* @param string|int|\DateTime time, value 0 means "until the browser is closed"
* @param string|int|\DateTimeInterface time, value 0 means "until the browser is closed"
* @param mixed optional list of variables / single variable to expire
* @return self
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Http/UserStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function getNamespace()

/**
* Enables log out after inactivity.
* @param string|int|\DateTime Number of seconds or timestamp
* @param string|int|\DateTimeInterface Number of seconds or timestamp
* @param int Log out when the browser is closed | Clear the identity from persistent storage?
* @return self
*/
Expand Down
8 changes: 4 additions & 4 deletions tests/Http.DI/HttpExtension.services.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ eval($compiler->compile([], 'Container1'));

$container = new Container1;

Assert::type('Nette\Http\RequestFactory', $container->getService('http.requestFactory'));
Assert::type('Nette\Http\Request', $container->getService('http.request'));
Assert::type('Nette\Http\Response', $container->getService('http.response'));
Assert::type('Nette\Http\Context', $container->getService('http.context'));
Assert::type(Nette\Http\RequestFactory::class, $container->getService('http.requestFactory'));
Assert::type(Nette\Http\Request::class, $container->getService('http.request'));
Assert::type(Nette\Http\Response::class, $container->getService('http.response'));
Assert::type(Nette\Http\Context::class, $container->getService('http.context'));

// aliases
Assert::same($container->getService('http.requestFactory'), $container->getService('nette.httpRequestFactory'));
Expand Down
2 changes: 1 addition & 1 deletion tests/Http.DI/SessionExtension.autoStart.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ eval($compiler->compile($config, 'Container1'));
$container = new Container1;

$session = $container->getService('session.session');
Assert::type('Nette\Http\Session', $session);
Assert::type(Nette\Http\Session::class, $session);
Assert::false($session->isStarted());

// aliases
Expand Down
8 changes: 4 additions & 4 deletions tests/Http/Request.files.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ $_FILES = [
$factory = new Http\RequestFactory;
$request = $factory->createHttpRequest();

Assert::type('Nette\Http\FileUpload', $request->files['file1']);
Assert::type('Nette\Http\FileUpload', $request->files['file2'][2]);
Assert::type('Nette\Http\FileUpload', $request->files['file3']['y']['z']);
Assert::type('Nette\Http\FileUpload', $request->files['file3'][1]);
Assert::type(Nette\Http\FileUpload::class, $request->files['file1']);
Assert::type(Nette\Http\FileUpload::class, $request->files['file2'][2]);
Assert::type(Nette\Http\FileUpload::class, $request->files['file3']['y']['z']);
Assert::type(Nette\Http\FileUpload::class, $request->files['file3'][1]);

Assert::false(isset($request->files['file0']));
Assert::true(isset($request->files['file1']));
Expand Down
8 changes: 4 additions & 4 deletions tests/Http/Request.invalidEncoding.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ test(function () { // unfiltered data
Assert::same('1', $request->getCookie(CONTROL_CHARACTERS));
Assert::same('1', $request->cookies['array'][INVALID]);

Assert::type('Nette\Http\FileUpload', $request->getFile(INVALID));
Assert::type('Nette\Http\FileUpload', $request->getFile(CONTROL_CHARACTERS));
Assert::type('Nette\Http\FileUpload', $request->files['file1']);
Assert::type(Nette\Http\FileUpload::class, $request->getFile(INVALID));
Assert::type(Nette\Http\FileUpload::class, $request->getFile(CONTROL_CHARACTERS));
Assert::type(Nette\Http\FileUpload::class, $request->files['file1']);
});


Expand Down Expand Up @@ -116,6 +116,6 @@ test(function () { // filtered data

Assert::null($request->getFile(INVALID));
Assert::null($request->getFile(CONTROL_CHARACTERS));
Assert::type('Nette\Http\FileUpload', $request->files['file1']);
Assert::type(Nette\Http\FileUpload::class, $request->files['file1']);
Assert::same('', $request->files['file1']->name);
});
2 changes: 1 addition & 1 deletion tests/Http/Response.error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ $response->setHeader('A', 'b');
Assert::exception(function () use ($response) {
ob_flush();
$response->setHeader('A', 'b');
}, 'Nette\InvalidStateException', 'Cannot send header after HTTP headers have been sent (output started at ' . __FILE__ . ':' . (__LINE__ - 2) . ').');
}, Nette\InvalidStateException::class, 'Cannot send header after HTTP headers have been sent (output started at ' . __FILE__ . ':' . (__LINE__ - 2) . ').');
2 changes: 1 addition & 1 deletion tests/Http/Session.sections.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ $section->hello = 'world';
Assert::true($session->hasSection('trees')); // hasSection() should have returned TRUE for a section with keys set

$section = $session->getSection('default');
Assert::type('Nette\Http\SessionSection', $section);
Assert::type(Nette\Http\SessionSection::class, $section);
2 changes: 1 addition & 1 deletion tests/Http/Session.start.error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ $session = new Session(new Nette\Http\Request(new Nette\Http\UrlScript), new Net

Assert::exception(function () use ($session) {
$session->start();
}, 'Nette\InvalidStateException', '%a?%open(%A%) failed: %a%');
}, Nette\InvalidStateException::class, '%a?%open(%A%) failed: %a%');

0 comments on commit 880a3a3

Please sign in to comment.