1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 21:22:40 +00:00

CS fixes and version bump

This commit is contained in:
J. King 2018-01-12 09:48:33 -05:00
parent 34b508171b
commit cbc9491f75
11 changed files with 26 additions and 28 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;
@ -69,7 +68,7 @@ class REST {
$req = $req ?? ServerRequestFactory::fromGlobals();
// 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
@ -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");

View file

@ -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;

View file

@ -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;

View file

@ -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"));

View file

@ -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 {

View file

@ -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,11 +322,11 @@ 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],
];

View file

@ -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)) {