diff --git a/lib/Arsse.php b/lib/Arsse.php index 528cb800..26fd7f5c 100644 --- a/lib/Arsse.php +++ b/lib/Arsse.php @@ -7,7 +7,7 @@ declare(strict_types=1); namespace JKingWeb\Arsse; class Arsse { - const VERSION = "0.2.1"; + const VERSION = "0.3.0"; /** @var Lang */ public static $lang; diff --git a/lib/Misc/Date.php b/lib/Misc/Date.php index 0eacf8c0..bf5e7a3c 100644 --- a/lib/Misc/Date.php +++ b/lib/Misc/Date.php @@ -13,7 +13,7 @@ class Date { return null; } $out = ValueInfo::normalize($date, ValueInfo::T_STRING, null, $outFormat); - if($outFormat=="unix") { + if ($outFormat=="unix") { $out = (int) $out; } elseif ($outFormat=="float") { $out = (float) $out; diff --git a/lib/REST.php b/lib/REST.php index 3820308e..340707a4 100644 --- a/lib/REST.php +++ b/lib/REST.php @@ -6,7 +6,6 @@ declare(strict_types=1); namespace JKingWeb\Arsse; - use JKingWeb\Arsse\Arsse; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ServerRequestInterface; @@ -67,9 +66,9 @@ class REST { public function dispatch(ServerRequestInterface $req = null): ResponseInterface { // create a request object if not provided $req = $req ?? ServerRequestFactory::fromGlobals(); - // find the API to handle + // find the API to handle try { - list ($api, $target, $class) = $this->apiMatch($req->getRequestTarget(), $this->apis); + list($api, $target, $class) = $this->apiMatch($req->getRequestTarget(), $this->apis); // authenticate the request pre-emptively $req = $this->authenticateRequest($req); // modify the request to have an uppercase method and a stripped target @@ -119,7 +118,7 @@ class REST { return [$id, $target, $api['class']]; } } - // or throw an exception otherwise + // or throw an exception otherwise throw new REST\Exception501(); } @@ -197,7 +196,7 @@ class REST { if ($req->hasHeader("Access-Control-Request-Headers")) { $res = $res->withHeader("Access-Control-Allow-Headers", $req->getHeaderLine("Access-Control-Request-Headers")); } - $res = $res->withHeader("Access-Control-Max-Age", (string) (60 *60 *24) ); // one day + $res = $res->withHeader("Access-Control-Max-Age", (string) (60 *60 *24)); // one day } $res = $res->withHeader("Access-Control-Allow-Origin", $req->getHeaderLine("Origin")); $res = $res->withHeader("Access-Control-Allow-Credentials", "true"); diff --git a/lib/REST/Target.php b/lib/REST/Target.php index bde4c6c1..e04a0e2b 100644 --- a/lib/REST/Target.php +++ b/lib/REST/Target.php @@ -62,7 +62,7 @@ class Target { protected function parseFragment(string $target): string { // store and strip off any fragment identifier and return the target without a fragment - $pos = strpos($target,"#"); + $pos = strpos($target, "#"); if ($pos !== false) { $this->fragment = rawurldecode(substr($target, $pos + 1)); $target = substr($target, 0, $pos); @@ -74,7 +74,7 @@ class Target { // store and strip off any query string and return the target without a query // note that the function assumes any fragment identifier has already been stripped off // unlike the other parts the query string is currently neither parsed nor normalized - $pos = strpos($target,"?"); + $pos = strpos($target, "?"); if ($pos !== false) { $this->query = substr($target, $pos + 1); $target = substr($target, 0, $pos); @@ -106,7 +106,7 @@ class Target { $target = explode("/", $target); $out = []; // resolve relative path segments and decode each retained segment - foreach($target as $index => $segment) { + foreach ($target as $index => $segment) { if ($segment==".") { // self-referential segments can be ignored continue; @@ -128,4 +128,4 @@ class Target { return []; } } -} \ No newline at end of file +} diff --git a/tests/cases/Lang/TestBasic.php b/tests/cases/Lang/TestBasic.php index fbd71291..351ede8d 100644 --- a/tests/cases/Lang/TestBasic.php +++ b/tests/cases/Lang/TestBasic.php @@ -9,7 +9,6 @@ namespace JKingWeb\Arsse\TestCase\Lang; use JKingWeb\Arsse\Lang as TestClass; use org\bovigo\vfs\vfsStream; - /** @covers \JKingWeb\Arsse\Lang */ class TestBasic extends \JKingWeb\Arsse\Test\AbstractTest { use \JKingWeb\Arsse\Test\Lang\Setup; diff --git a/tests/cases/Misc/TestDate.php b/tests/cases/Misc/TestDate.php index 4aaf0b25..e82f6c8b 100644 --- a/tests/cases/Misc/TestDate.php +++ b/tests/cases/Misc/TestDate.php @@ -14,7 +14,7 @@ class TestDate extends \JKingWeb\Arsse\Test\AbstractTest { $this->clearData(); } - function testNormalizeADate() { + public function testNormalizeADate() { $exp = new \DateTimeImmutable("2018-01-01T00:00:00Z"); $this->assertEquals($exp, Date::normalize(1514764800)); $this->assertEquals($exp, Date::normalize("2018-01-01T00:00:00")); @@ -26,7 +26,7 @@ class TestDate extends \JKingWeb\Arsse\Test\AbstractTest { $this->assertNull(Date::normalize("2018-01-01T00:00:00Z", "http")); } - function testFormatADate() { + public function testFormatADate() { $test = new \DateTimeImmutable("2018-01-01T00:00:00Z"); $this->assertNull(Date::transform(null, "http")); $this->assertNull(Date::transform("ook", "http")); @@ -40,7 +40,7 @@ class TestDate extends \JKingWeb\Arsse\Test\AbstractTest { $this->assertSame(1514764800.265579, Date::transform("2018-01-01T00:00:00.265579Z", "float", "iso8601m")); } - function testMoveDateForward() { + public function testMoveDateForward() { $test = new \DateTimeImmutable("2018-01-01T00:00:00Z"); $this->assertNull(Date::add("P1D", null)); $this->assertNull(Date::add("P1D", "ook")); @@ -49,7 +49,7 @@ class TestDate extends \JKingWeb\Arsse\Test\AbstractTest { $this->assertNull(Date::add("ook", $test)); } - function testMoveDateBack() { + public function testMoveDateBack() { $test = new \DateTimeImmutable("2018-01-01T00:00:00Z"); $this->assertNull(Date::sub("P1D", null)); $this->assertNull(Date::sub("P1D", "ook")); diff --git a/tests/cases/REST/NextCloudNews/TestV1_2.php b/tests/cases/REST/NextCloudNews/TestV1_2.php index a1b8a828..ab4baad8 100644 --- a/tests/cases/REST/NextCloudNews/TestV1_2.php +++ b/tests/cases/REST/NextCloudNews/TestV1_2.php @@ -317,7 +317,7 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest { if (Arsse::$user->auth()) { $req = $req->withAttribute("authenticated", true)->withAttribute("authenticatedUser", "john.doe@example.com"); } - foreach($headers as $key => $value) { + foreach ($headers as $key => $value) { if (!is_null($value)) { $req = $req->withHeader($key, $value); } else { diff --git a/tests/cases/REST/TestREST.php b/tests/cases/REST/TestREST.php index 6cb7d91a..1f78524d 100644 --- a/tests/cases/REST/TestREST.php +++ b/tests/cases/REST/TestREST.php @@ -264,7 +264,7 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest { public function provideUnnormalizedResponses() { $stream = fopen("php://memory", "w+b"); - fwrite($stream,"ook"); + fwrite($stream, "ook"); return [ [new EmptyResponse(204), new EmptyResponse(204)], [new EmptyResponse(401), new EmptyResponse(401, ['WWW-Authenticate' => "Fake Value"])], @@ -322,13 +322,13 @@ class TestREST extends \JKingWeb\Arsse\Test\AbstractTest { public function provideMockRequests() { return [ - [new ServerRequest([], [], "/index.php/apps/news/api/v1-2/feeds", "GET"), "GET", true, NCN::Class, "/feeds"], - [new ServerRequest([], [], "/index.php/apps/news/api/v1-2/feeds", "HEAD"), "GET", true, NCN::Class, "/feeds"], - [new ServerRequest([], [], "/index.php/apps/news/api/v1-2/feeds", "get"), "GET", true, NCN::Class, "/feeds"], - [new ServerRequest([], [], "/index.php/apps/news/api/v1-2/feeds", "head"), "GET", true, NCN::Class, "/feeds"], - [new ServerRequest([], [], "/tt-rss/api/", "POST"), "POST", true, TTRSS::Class, "/"], + [new ServerRequest([], [], "/index.php/apps/news/api/v1-2/feeds", "GET"), "GET", true, NCN::class, "/feeds"], + [new ServerRequest([], [], "/index.php/apps/news/api/v1-2/feeds", "HEAD"), "GET", true, NCN::class, "/feeds"], + [new ServerRequest([], [], "/index.php/apps/news/api/v1-2/feeds", "get"), "GET", true, NCN::class, "/feeds"], + [new ServerRequest([], [], "/index.php/apps/news/api/v1-2/feeds", "head"), "GET", true, NCN::class, "/feeds"], + [new ServerRequest([], [], "/tt-rss/api/", "POST"), "POST", true, TTRSS::class, "/"], [new ServerRequest([], [], "/no/such/api/", "HEAD"), "GET", false], [new ServerRequest([], [], "/no/such/api/", "GET"), "GET", false], ]; } -} \ No newline at end of file +} diff --git a/tests/cases/REST/TestTarget.php b/tests/cases/REST/TestTarget.php index 5577af85..6b5a3834 100644 --- a/tests/cases/REST/TestTarget.php +++ b/tests/cases/REST/TestTarget.php @@ -63,4 +63,4 @@ class TestTarget extends \JKingWeb\Arsse\Test\AbstractTest { ["#%2e?%2f", [], true, true, "", ".?/", "#.%3F%2F"], ]; } -} \ No newline at end of file +} diff --git a/tests/cases/REST/TinyTinyRSS/PDO/TestAPI.php b/tests/cases/REST/TinyTinyRSS/PDO/TestAPI.php index 9c9e36f1..4acaf6d9 100644 --- a/tests/cases/REST/TinyTinyRSS/PDO/TestAPI.php +++ b/tests/cases/REST/TinyTinyRSS/PDO/TestAPI.php @@ -10,4 +10,4 @@ namespace JKingWeb\Arsse\TestCase\REST\TinyTinyRSS\PDO; * @covers \JKingWeb\Arsse\REST\TinyTinyRSS\Exception */ class TestAPI extends \JKingWeb\Arsse\TestCase\REST\TinyTinyRSS\TestAPI { use \JKingWeb\Arsse\Test\PDOTest; -} \ No newline at end of file +} diff --git a/tests/lib/PDOTest.php b/tests/lib/PDOTest.php index 3013734f..0147e28d 100644 --- a/tests/lib/PDOTest.php +++ b/tests/lib/PDOTest.php @@ -11,7 +11,7 @@ trait PDOTest { if (!is_array($value)) { return $value; } - foreach($value as $k => $v) { + foreach ($value as $k => $v) { if (is_array($v)) { $value[$k] = $this->v($v); } elseif (is_int($v) || is_float($v)) { @@ -20,4 +20,4 @@ trait PDOTest { } return $value; } -} \ No newline at end of file +}