diff --git a/lib/Database.php b/lib/Database.php index db6f087..b3b2b22 100644 --- a/lib/Database.php +++ b/lib/Database.php @@ -755,7 +755,7 @@ class Database { } /** Lists a user's subscriptions, returning various data - * + * * Each record has the following keys: * * - "id": The numeric identifier of the subscription @@ -993,7 +993,7 @@ class Database { * - "url": The URL of the icon * - "type": The Content-Type of the icon e.g. "image/png" * - "data": The icon itself, as a binary sring; if $withData is false this will be null - * + * * If the subscription has no icon null is returned instead of an array * * @param string|null $user The user who owns the subscription being queried; using null here is supported for TT-RSS and SHOULD NOT be used elsewhere as it leaks information @@ -1031,7 +1031,7 @@ class Database { } /** Evalutes the filter rules specified for a subscription against every article associated with the subscription's feed - * + * * @param string $user The user who owns the subscription * @param integer $id The identifier of the subscription whose rules are to be evaluated */ @@ -1072,7 +1072,6 @@ class Database { } } - /** Ensures the specified subscription exists and raises an exception otherwise * * Returns an associative array containing the id of the subscription and the id of the underlying newsfeed @@ -1747,7 +1746,7 @@ class Database { } elseif (!$context->$m) { throw new Db\ExceptionInput("tooShort", ['field' => $m, 'action' => $this->caller(), 'min' => 1]); // must have at least one array element } - $columns = array_map(function ($c) use ($colDefs) { + $columns = array_map(function($c) use ($colDefs) { assert(isset($colDefs[$c]), new Exception("constantUnknown", $c)); return $colDefs[$c]; }, $columns); @@ -1758,7 +1757,7 @@ class Database { if (!$context->not->$m() || !$context->not->$m) { continue; } - $columns = array_map(function ($c) use ($colDefs) { + $columns = array_map(function($c) use ($colDefs) { assert(isset($colDefs[$c]), new Exception("constantUnknown", $c)); return $colDefs[$c]; }, $columns); diff --git a/lib/Factory.php b/lib/Factory.php index 9698902..0dfcea8 100644 --- a/lib/Factory.php +++ b/lib/Factory.php @@ -10,4 +10,4 @@ class Factory { public function get(string $class) { return new $class; } -} \ No newline at end of file +} diff --git a/lib/Misc/ValueInfo.php b/lib/Misc/ValueInfo.php index 9977e78..688a394 100644 --- a/lib/Misc/ValueInfo.php +++ b/lib/Misc/ValueInfo.php @@ -59,7 +59,6 @@ class ValueInfo { 'float' => ["U.u", "U.u" ], ]; - public static function normalize($value, int $type, string $dateInFormat = null, $dateOutFormat = null) { $allowNull = ($type & self::M_NULL); $strict = ($type & (self::M_STRICT | self::M_DROP)); diff --git a/lib/REST/Miniflux/V1.php b/lib/REST/Miniflux/V1.php index 097a9c8..3b192f9 100644 --- a/lib/REST/Miniflux/V1.php +++ b/lib/REST/Miniflux/V1.php @@ -55,7 +55,7 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { ]; protected const VALID_JSON = [ // user properties which map directly to Arsse user metadata are listed separately; - // not all these properties are used by our implementation, but they are treated + // not all these properties are used by our implementation, but they are treated // with the same strictness as in Miniflux to ease cross-compatibility 'url' => "string", 'username' => "string", @@ -90,7 +90,7 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { 'stylesheet' => ["stylesheet", ""], ]; /** A map between Miniflux's input properties and our input properties when modifiying feeds - * + * * Miniflux also allows changing the following properties: * * - feed_url @@ -107,7 +107,7 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { * or cannot be changed because feeds are deduplicated and changing * how they are fetched is not practical with our implementation. * The properties are still checked for type and syntactic validity - * where practical, on the assumption Miniflux would also reject + * where practical, on the assumption Miniflux would also reject * invalid values. */ protected const FEED_META_MAP = [ @@ -118,11 +118,11 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { 'blocklist_rules' => "block_rule", ]; protected const ARTICLE_COLUMNS = [ - "id", "url", "title", "subscription", + "id", "url", "title", "subscription", "author", "fingerprint", - "published_date", "modified_date", + "published_date", "modified_date", "starred", "unread", "hidden", - "content", "media_url", "media_type" + "content", "media_url", "media_type", ]; protected const CALLS = [ // handler method Admin Path Body Query Required fields '/categories' => [ @@ -291,7 +291,7 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { } try { return $this->$func(...$args); - // @codeCoverageIgnoreStart + // @codeCoverageIgnoreStart } catch (Exception $e) { // if there was a REST exception return 400 return new EmptyResponse(400); @@ -348,7 +348,7 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { return new ErrorResponse(["InvalidInputType", 'field' => $k, 'expected' => $t, 'actual' => gettype($body[$k])], 422); } elseif ( (in_array($k, ["keeplist_rules", "blocklist_rules"]) && !Rule::validate($body[$k])) - || (in_array($k, ["url", "feed_url"]) && !URL::absolute($body[$k])) + || (in_array($k, ["url", "feed_url"]) && !URL::absolute($body[$k])) || ($k === "category_id" && $body[$k] < 1) || ($k === "status" && !in_array($body[$k], ["read", "unread", "removed"])) ) { @@ -492,7 +492,7 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { protected function editUser(string $user, array $data): array { // map Miniflux properties to internal metadata properties $in = []; - foreach (self::USER_META_MAP as $i => [$o,]) { + foreach (self::USER_META_MAP as $i => [$o]) { if (isset($data[$i])) { if ($i === "entry_sorting_direction") { $in[$o] = $data[$i] === "asc"; @@ -640,9 +640,9 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { } /** Returns a useful subset of user metadata - * + * * The following keys are included: - * + * * - "num": The user's numeric ID, * - "root": The effective name of the root folder */ @@ -880,8 +880,8 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { return new ErrorResponse("404", 404); } return new Response([ - 'id' => $icon['id'], - 'data' => $icon['type'].";base64,".base64_encode($icon['data']), + 'id' => $icon['id'], + 'data' => $icon['type'].";base64,".base64_encode($icon['data']), 'mime_type' => $icon['type'], ]); } @@ -960,7 +960,7 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { 'url' => $entry['media_url'], 'mime_type' => $entry['media_type'] ?: "application/octet-stream", 'size' => 0, - ] + ], ]; } else { $enclosures = null; @@ -1030,7 +1030,7 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { $out['feed'] = $this->transformFeed(Arsse::$db->subscriptionPropertiesGet(Arsse::$user->id, $out['feed_id']), $meta['num'], $meta['root'], $meta['tz']); return $out; } - + protected function getEntries(array $query): ResponseInterface { try { return new Response($this->listEntries($query, new Context)); @@ -1038,7 +1038,7 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { return new ErrorResponse("MissingCategory", 400); } } - + protected function getFeedEntries(array $path, array $query): ResponseInterface { $c = (new Context)->subscription((int) $path[1]); try { @@ -1048,7 +1048,7 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { return new ErrorResponse("404", 404); } } - + protected function getCategoryEntries(array $path, array $query): ResponseInterface { $query['category_id'] = (int) $path[1]; try { @@ -1057,7 +1057,7 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { return new ErrorResponse("404", 404); } } - + protected function getEntry(array $path): ResponseInterface { try { return new Response($this->findEntry((int) $path[1])); @@ -1065,7 +1065,7 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { return new ErrorResponse("404", 404); } } - + protected function getFeedEntry(array $path): ResponseInterface { $c = (new Context)->subscription((int) $path[1]); try { @@ -1074,7 +1074,7 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler { return new ErrorResponse("404", 404); } } - + protected function getCategoryEntry(array $path): ResponseInterface { $c = new Context; if ($path[1] === "1") { diff --git a/tests/cases/Misc/TestFactory.php b/tests/cases/Misc/TestFactory.php index e400c2f..c694019 100644 --- a/tests/cases/Misc/TestFactory.php +++ b/tests/cases/Misc/TestFactory.php @@ -14,4 +14,4 @@ class TestFactory extends \JKingWeb\Arsse\Test\AbstractTest { $f = new Factory; $this->assertInstanceOf(\stdClass::class, $f->get(\stdClass::class)); } -} \ No newline at end of file +} diff --git a/tests/cases/REST/Miniflux/TestV1.php b/tests/cases/REST/Miniflux/TestV1.php index 73b9b4a..ad6b988 100644 --- a/tests/cases/REST/Miniflux/TestV1.php +++ b/tests/cases/REST/Miniflux/TestV1.php @@ -12,7 +12,6 @@ use JKingWeb\Arsse\User; use JKingWeb\Arsse\Database; use JKingWeb\Arsse\Db\Transaction; use JKingWeb\Arsse\Db\ExceptionInput; -use JKingWeb\Arsse\Misc\Date; use JKingWeb\Arsse\REST\Miniflux\V1; use JKingWeb\Arsse\REST\Miniflux\ErrorResponse; use JKingWeb\Arsse\Feed\Exception as FeedException; @@ -46,7 +45,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest { ['id' => 42, 'url' => "http://example.com/42", 'title' => "Title 42", 'subscription' => 55, 'author' => "Thomas Costain", 'fingerprint' => "FINGERPRINT", 'published_date' => "2021-01-22 02:21:12", 'modified_date' => "2021-01-22 13:44:47", 'starred' => 0, 'unread' => 0, 'hidden' => 0, 'content' => "Content 42", 'media_url' => null, 'media_type' => null], ['id' => 44, 'url' => "http://example.com/44", 'title' => "Title 44", 'subscription' => 55, 'author' => null, 'fingerprint' => "FINGERPRINT", 'published_date' => "2021-01-22 02:21:12", 'modified_date' => "2021-01-22 13:44:47", 'starred' => 1, 'unread' => 1, 'hidden' => 0, 'content' => "Content 44", 'media_url' => "http://example.com/44/enclosure", 'media_type' => null], ['id' => 47, 'url' => "http://example.com/47", 'title' => "Title 47", 'subscription' => 55, 'author' => null, 'fingerprint' => "FINGERPRINT", 'published_date' => "2021-01-22 02:21:12", 'modified_date' => "2021-01-22 13:44:47", 'starred' => 0, 'unread' => 1, 'hidden' => 1, 'content' => "Content 47", 'media_url' => "http://example.com/47/enclosure", 'media_type' => ""], - ['id' => 2112, 'url' => "http://example.com/2112", 'title' => "Title 2112", 'subscription' => 55, 'author' => null, 'fingerprint' => "FINGERPRINT", 'published_date' => "2021-01-22 02:21:12", 'modified_date' => "2021-01-22 13:44:47", 'starred' => 0, 'unread' => 0, 'hidden' => 1, 'content' => "Content 2112", 'media_url' => "http://example.com/2112/enclosure", 'media_type' => "image/png"] + ['id' => 2112, 'url' => "http://example.com/2112", 'title' => "Title 2112", 'subscription' => 55, 'author' => null, 'fingerprint' => "FINGERPRINT", 'published_date' => "2021-01-22 02:21:12", 'modified_date' => "2021-01-22 13:44:47", 'starred' => 0, 'unread' => 0, 'hidden' => 1, 'content' => "Content 2112", 'media_url' => "http://example.com/2112/enclosure", 'media_type' => "image/png"], ]; protected const ENTRIES_OUT = [ ['id' => 42, 'user_id' => 42, 'feed_id' => 55, 'status' => "read", 'hash' => "FINGERPRINT", 'title' => "Title 42", 'url' => "http://example.com/42", 'comments_url' => "", 'published_at' => "2021-01-22T04:21:12+02:00", 'created_at' => "2021-01-22T15:44:47.000000+02:00", 'content' => "Content 42", 'author' => "Thomas Costain", 'share_code' => "", 'starred' => false, 'reading_time' => 0, 'enclosures' => null, 'feed' => self::FEEDS_OUT[1]], @@ -663,7 +662,7 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest { [['crawler' => false], ['scrape' => false], true, $success], [['keeplist_rules' => ""], ['keep_rule' => ""], true, $success], [['blocklist_rules' => "ook"], ['block_rule' => "ook"], true, $success], - [['title' => "Ook!", 'crawler' => true], ['title' => "Ook!", 'scrape' => true], true, $success] + [['title' => "Ook!", 'crawler' => true], ['title' => "Ook!", 'scrape' => true], true, $success], ]; } @@ -857,8 +856,8 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest { [['entry_ids' => 1, 'status' => "read"], null, new ErrorResponse(["InvalidInputType", 'field' => "entry_ids", 'expected' => "array", 'actual' => "integer"], 422)], [['entry_ids' => ["1"], 'status' => "read"], null, new ErrorResponse(["InvalidInputType", 'field' => "entry_ids", 'expected' => "integer", 'actual' => "string"], 422)], [['entry_ids' => [1], 'status' => 1], null, new ErrorResponse(["InvalidInputType", 'field' => "status", 'expected' => "string", 'actual' => "integer"], 422)], - [['entry_ids' => [0], 'status' => "read"], null, new ErrorResponse(["InvalidInputValue", 'field' => "entry_ids",], 422)], - [['entry_ids' => [1], 'status' => "reread"], null, new ErrorResponse(["InvalidInputValue", 'field' => "status",], 422)], + [['entry_ids' => [0], 'status' => "read"], null, new ErrorResponse(["InvalidInputValue", 'field' => "entry_ids"], 422)], + [['entry_ids' => [1], 'status' => "reread"], null, new ErrorResponse(["InvalidInputValue", 'field' => "status"], 422)], [['entry_ids' => [1, 2], 'status' => "read"], ['read' => true, 'hidden' => false], new EmptyResponse(204)], [['entry_ids' => [1, 2], 'status' => "unread"], ['read' => false, 'hidden' => false], new EmptyResponse(204)], [['entry_ids' => [1, 2], 'status' => "removed"], ['read' => true, 'hidden' => true], new EmptyResponse(204)], @@ -1009,4 +1008,4 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest { $this->assertException("doesNotExist", "User", "ExceptionConflict"); V1::tokenList("john.doe@example.com"); } -} \ No newline at end of file +} diff --git a/tests/cases/REST/TestREST.php b/tests/cases/REST/TestREST.php index 1864215..a7eb83e 100644 --- a/tests/cases/REST/TestREST.php +++ b/tests/cases/REST/TestREST.php @@ -9,7 +9,6 @@ namespace JKingWeb\Arsse\TestCase\REST; use JKingWeb\Arsse\Arsse; use JKingWeb\Arsse\User; use JKingWeb\Arsse\REST; -use JKingWeb\Arsse\REST\Handler; use JKingWeb\Arsse\REST\Exception501; use JKingWeb\Arsse\REST\NextcloudNews\V1_2 as NCN; use JKingWeb\Arsse\REST\TinyTinyRSS\API as TTRSS; diff --git a/tests/cases/REST/TinyTinyRSS/TestAPI.php b/tests/cases/REST/TinyTinyRSS/TestAPI.php index e79a2f6..139f7dc 100644 --- a/tests/cases/REST/TinyTinyRSS/TestAPI.php +++ b/tests/cases/REST/TinyTinyRSS/TestAPI.php @@ -19,8 +19,8 @@ use JKingWeb\Arsse\REST\TinyTinyRSS\API; use Psr\Http\Message\ResponseInterface; use Laminas\Diactoros\Response\JsonResponse as Response; use Laminas\Diactoros\Response\EmptyResponse; -/** @covers \JKingWeb\Arsse\REST\TinyTinyRSS\API +/** @covers \JKingWeb\Arsse\REST\TinyTinyRSS\API * @covers \JKingWeb\Arsse\REST\TinyTinyRSS\Exception */ class TestAPI extends \JKingWeb\Arsse\Test\AbstractTest { protected const NOW = "2020-12-21T23:09:17.189065Z"; @@ -1317,7 +1317,7 @@ LONG_STRING; // create a mock-current time \Phake::when(Arsse::$obj)->get(\DateTimeImmutable::class)->thenReturn(new \DateTimeImmutable(self::NOW)); // TT-RSS always responds the same regardless of success or failure - $this->assertMessage($this->respGood(['status' => "OK"]), $this->req($in)); + $this->assertMessage($this->respGood(['status' => "OK"]), $this->req($in)); if (isset($c)) { \Phake::verify(Arsse::$db)->articleMark(Arsse::$user->id, ['read' => true], $c); } else {