From 8646aeee53304711068b643d8a1636fa84cf9075 Mon Sep 17 00:00:00 2001 From: Jan Tvrdik Date: Sun, 23 Aug 2015 23:54:32 +0200 Subject: [PATCH 1/4] requires PHP 5.6.0 --- .travis.yml | 2 -- composer.json | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1aafc800..eec6b29d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,5 @@ language: php php: - - 5.4 - - 5.5 - 5.6 - 7.0 - hhvm diff --git a/composer.json b/composer.json index 6858de37..06d2cc1c 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ } ], "require": { - "php": ">=5.4.4", + "php": ">=5.6.0", "nette/utils": "~2.2, >=2.2.2" }, "require-dev": { From 29310a083f038759e69ba02bac21675478f3be7b Mon Sep 17 00:00:00 2001 From: Jan Tvrdik Date: Sun, 23 Aug 2015 23:59:19 +0200 Subject: [PATCH 2/4] use ClassName::class syntax --- src/Bridges/HttpDI/HttpExtension.php | 8 ++++---- src/Bridges/HttpDI/SessionExtension.php | 4 ++-- src/Http/Session.php | 2 +- tests/Http.DI/HttpExtension.services.phpt | 8 ++++---- tests/Http.DI/SessionExtension.autoStart.phpt | 2 +- tests/Http/Request.files.phpt | 8 ++++---- tests/Http/Request.invalidEncoding.phpt | 8 ++++---- tests/Http/Response.error.phpt | 2 +- tests/Http/Session.sections.phpt | 2 +- tests/Http/Session.start.error.phpt | 2 +- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Bridges/HttpDI/HttpExtension.php b/src/Bridges/HttpDI/HttpExtension.php index 2dffa953..f9a818d9 100644 --- a/src/Bridges/HttpDI/HttpExtension.php +++ b/src/Bridges/HttpDI/HttpExtension.php @@ -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')); diff --git a/src/Bridges/HttpDI/SessionExtension.php b/src/Bridges/HttpDI/SessionExtension.php index d2f8a26f..eb9100a3 100644 --- a/src/Bridges/HttpDI/SessionExtension.php +++ b/src/Bridges/HttpDI/SessionExtension.php @@ -38,7 +38,7 @@ 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']]); @@ -46,7 +46,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::class) ]); } diff --git a/src/Http/Session.php b/src/Http/Session.php index ce41962e..db140bfe 100644 --- a/src/Http/Session.php +++ b/src/Http/Session.php @@ -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); } diff --git a/tests/Http.DI/HttpExtension.services.phpt b/tests/Http.DI/HttpExtension.services.phpt index 957c2b5f..6001b9bf 100644 --- a/tests/Http.DI/HttpExtension.services.phpt +++ b/tests/Http.DI/HttpExtension.services.phpt @@ -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')); diff --git a/tests/Http.DI/SessionExtension.autoStart.phpt b/tests/Http.DI/SessionExtension.autoStart.phpt index ed14290a..47f8fbb5 100644 --- a/tests/Http.DI/SessionExtension.autoStart.phpt +++ b/tests/Http.DI/SessionExtension.autoStart.phpt @@ -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 diff --git a/tests/Http/Request.files.phpt b/tests/Http/Request.files.phpt index 2717d3df..de962bba 100644 --- a/tests/Http/Request.files.phpt +++ b/tests/Http/Request.files.phpt @@ -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'])); diff --git a/tests/Http/Request.invalidEncoding.phpt b/tests/Http/Request.invalidEncoding.phpt index bc8524ca..6459afc4 100644 --- a/tests/Http/Request.invalidEncoding.phpt +++ b/tests/Http/Request.invalidEncoding.phpt @@ -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']); }); @@ -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); }); diff --git a/tests/Http/Response.error.phpt b/tests/Http/Response.error.phpt index a08766e5..cad99538 100644 --- a/tests/Http/Response.error.phpt +++ b/tests/Http/Response.error.phpt @@ -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) . ').'); diff --git a/tests/Http/Session.sections.phpt b/tests/Http/Session.sections.phpt index 770063fa..96b51ef3 100644 --- a/tests/Http/Session.sections.phpt +++ b/tests/Http/Session.sections.phpt @@ -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); diff --git a/tests/Http/Session.start.error.phpt b/tests/Http/Session.start.error.phpt index c5a5340c..9edbee61 100644 --- a/tests/Http/Session.start.error.phpt +++ b/tests/Http/Session.start.error.phpt @@ -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%'); From 3b597f237ea88a0f1fd8e2330d081aaa700da454 Mon Sep 17 00:00:00 2001 From: Jan Tvrdik Date: Mon, 24 Aug 2015 22:15:46 +0200 Subject: [PATCH 3/4] use constant expressions --- src/Http/Session.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Http/Session.php b/src/Http/Session.php index db140bfe..c3a8bf56 100644 --- a/src/Http/Session.php +++ b/src/Http/Session.php @@ -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; From 5f0bbf7e80da2b00573192d63fb33ea05a7787d7 Mon Sep 17 00:00:00 2001 From: Jan Tvrdik Date: Mon, 24 Aug 2015 22:36:51 +0200 Subject: [PATCH 4/4] use DateTimeInterface --- src/Http/Context.php | 2 +- src/Http/Helpers.php | 2 +- src/Http/IResponse.php | 2 +- src/Http/Response.php | 4 ++-- src/Http/Session.php | 2 +- src/Http/SessionSection.php | 2 +- src/Http/UserStorage.php | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Http/Context.php b/src/Http/Context.php index 994d06f1..f7fa7c22 100644 --- a/src/Http/Context.php +++ b/src/Http/Context.php @@ -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 */ diff --git a/src/Http/Helpers.php b/src/Http/Helpers.php index 892367c8..b61ce677 100644 --- a/src/Http/Helpers.php +++ b/src/Http/Helpers.php @@ -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) diff --git a/src/Http/IResponse.php b/src/Http/IResponse.php index 5ede9a59..3beb1644 100644 --- a/src/Http/IResponse.php +++ b/src/Http/IResponse.php @@ -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); diff --git a/src/Http/Response.php b/src/Http/Response.php index 92be0f2e..42adf77a 100644 --- a/src/Http/Response.php +++ b/src/Http/Response.php @@ -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 */ @@ -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 diff --git a/src/Http/Session.php b/src/Http/Session.php index c3a8bf56..c6e41fd9 100644 --- a/src/Http/Session.php +++ b/src/Http/Session.php @@ -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) diff --git a/src/Http/SessionSection.php b/src/Http/SessionSection.php index b47e2e96..853f140d 100644 --- a/src/Http/SessionSection.php +++ b/src/Http/SessionSection.php @@ -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 */ diff --git a/src/Http/UserStorage.php b/src/Http/UserStorage.php index 2bcbad7b..9753b9a3 100644 --- a/src/Http/UserStorage.php +++ b/src/Http/UserStorage.php @@ -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 */