diff --git a/composer.lock b/composer.lock index 73a4c20..d5d78e0 100644 --- a/composer.lock +++ b/composer.lock @@ -12,7 +12,7 @@ "source": { "type": "git", "url": "https://patchii.net/flash/index.git", - "reference": "e31781c69f0b13fe251771c8e7e529222630a44f" + "reference": "9d5b050b8928435416a7efbebe2a19ae8e626224" }, "require": { "ext-mbstring": "*", @@ -50,7 +50,7 @@ ], "description": "Composer package for the common library for my projects.", "homepage": "https://railgun.sh/index", - "time": "2023-11-20T19:01:19+00:00" + "time": "2024-03-28T23:27:04+00:00" }, { "name": "flashwave/syokuhou", @@ -58,7 +58,7 @@ "source": { "type": "git", "url": "https://patchii.net/flash/syokuhou.git", - "reference": "fdf3c38cc216bf7024af331cbe1758532355c22f" + "reference": "c1fe9371ada20fcea51c225cc53b9ceae4642bc4" }, "require": { "flashwave/index": "dev-master", @@ -89,7 +89,7 @@ ], "description": "Configuration library for PHP.", "homepage": "https://railgun.sh/syokuhou", - "time": "2023-11-20T19:10:04+00:00" + "time": "2024-01-04T02:12:49+00:00" }, { "name": "guzzlehttp/psr7", @@ -209,16 +209,16 @@ }, { "name": "jean85/pretty-package-versions", - "version": "2.0.5", + "version": "2.0.6", "source": { "type": "git", "url": "https://github.com/Jean85/pretty-package-versions.git", - "reference": "ae547e455a3d8babd07b96966b17d7fd21d9c6af" + "reference": "f9fdd29ad8e6d024f52678b570e5593759b550b4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/ae547e455a3d8babd07b96966b17d7fd21d9c6af", - "reference": "ae547e455a3d8babd07b96966b17d7fd21d9c6af", + "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/f9fdd29ad8e6d024f52678b570e5593759b550b4", + "reference": "f9fdd29ad8e6d024f52678b570e5593759b550b4", "shasum": "" }, "require": { @@ -226,9 +226,9 @@ "php": "^7.1|^8.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.17", + "friendsofphp/php-cs-fixer": "^3.2", "jean85/composer-provided-replaced-stub-package": "^1.0", - "phpstan/phpstan": "^0.12.66", + "phpstan/phpstan": "^1.4", "phpunit/phpunit": "^7.5|^8.5|^9.4", "vimeo/psalm": "^4.3" }, @@ -262,9 +262,9 @@ ], "support": { "issues": "https://github.com/Jean85/pretty-package-versions/issues", - "source": "https://github.com/Jean85/pretty-package-versions/tree/2.0.5" + "source": "https://github.com/Jean85/pretty-package-versions/tree/2.0.6" }, - "time": "2021-10-08T21:21:46+00:00" + "time": "2024-03-08T09:58:59+00:00" }, { "name": "psr/http-factory", @@ -525,16 +525,16 @@ }, { "name": "sentry/sentry", - "version": "4.1.0", + "version": "4.6.1", "source": { "type": "git", "url": "https://github.com/getsentry/sentry-php.git", - "reference": "89666f297891ff937fceb2f3d1fb967a6848cf37" + "reference": "5a94184175e5830b589bf923da8c9c3af2c0f409" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/89666f297891ff937fceb2f3d1fb967a6848cf37", - "reference": "89666f297891ff937fceb2f3d1fb967a6848cf37", + "url": "https://api.github.com/repos/getsentry/sentry-php/zipball/5a94184175e5830b589bf923da8c9c3af2c0f409", + "reference": "5a94184175e5830b589bf923da8c9c3af2c0f409", "shasum": "" }, "require": { @@ -558,7 +558,7 @@ "phpbench/phpbench": "^1.0", "phpstan/phpstan": "^1.3", "phpunit/phpunit": "^8.5.14|^9.4", - "symfony/phpunit-bridge": "^5.2|^6.0", + "symfony/phpunit-bridge": "^5.2|^6.0|^7.0", "vimeo/psalm": "^4.17" }, "suggest": { @@ -598,7 +598,7 @@ ], "support": { "issues": "https://github.com/getsentry/sentry-php/issues", - "source": "https://github.com/getsentry/sentry-php/tree/4.1.0" + "source": "https://github.com/getsentry/sentry-php/tree/4.6.1" }, "funding": [ { @@ -610,7 +610,7 @@ "type": "custom" } ], - "time": "2023-12-04T12:41:21+00:00" + "time": "2024-03-08T08:18:09+00:00" }, { "name": "symfony/deprecation-contracts", @@ -758,5 +758,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/src/Booru/BooruRoutes.php b/src/Booru/BooruRoutes.php index b6c87c1..1458dc0 100644 --- a/src/Booru/BooruRoutes.php +++ b/src/Booru/BooruRoutes.php @@ -3,8 +3,7 @@ namespace Satori\Booru; use stdClass; use Index\XArray; -use Index\Routing\Route; -use Index\Routing\RouteHandler; +use Index\Http\Routing\{HttpGet,RouteHandler}; class BooruRoutes extends RouteHandler { public function __construct( @@ -36,7 +35,7 @@ class BooruRoutes extends RouteHandler { }); } - #[Route('GET', '/booru.php')] + #[HttpGet('/booru.php')] public function getPHP($response, $request) { $sourceName = (string)$request->getParam('b'); $tags = (string)$request->getParam('t'); diff --git a/src/DatabaseContext.php b/src/DatabaseContext.php index b6113e2..24b078c 100644 --- a/src/DatabaseContext.php +++ b/src/DatabaseContext.php @@ -2,9 +2,7 @@ namespace Satori; use Index\Data\IDbConnection; -use Index\Data\Migration\IDbMigrationRepo; -use Index\Data\Migration\DbMigrationManager; -use Index\Data\Migration\FsDbMigrationRepo; +use Index\Data\Migration\{IDbMigrationRepo,DbMigrationManager,FsDbMigrationRepo}; class DatabaseContext { public function __construct( diff --git a/src/Dictionary/DictionaryRoutes.php b/src/Dictionary/DictionaryRoutes.php index 20556e0..d60c63c 100644 --- a/src/Dictionary/DictionaryRoutes.php +++ b/src/Dictionary/DictionaryRoutes.php @@ -1,15 +1,14 @@ getParam('word')); if($word === '') @@ -36,7 +35,7 @@ class DictionaryRoutes extends RouteHandler { return $response; } - #[Route('GET', '/word-define.php')] + #[HttpGet('/word-define.php')] public function getPHP($response, $request) { $word = trim((string)$request->getParam('word')); if($word === '') diff --git a/src/ExRate/ExRateRoutes.php b/src/ExRate/ExRateRoutes.php index daa64e4..b2b234a 100644 --- a/src/ExRate/ExRateRoutes.php +++ b/src/ExRate/ExRateRoutes.php @@ -2,15 +2,14 @@ namespace Satori\ExRate; use stdClass; -use Index\Routing\Route; -use Index\Routing\RouteHandler; +use Index\Http\Routing\{HttpGet,RouteHandler}; class ExRateRoutes extends RouteHandler { public function __construct( private ExRateContext $context ) {} - #[Route('GET', '/exrate/convert')] + #[HttpGet('/exrate/convert')] public function getConvert($response, $request) { $from = strtoupper((string)$request->getParam('from')); $targets = explode(',', strtoupper((string)$request->getParam('to'))); @@ -47,7 +46,7 @@ class ExRateRoutes extends RouteHandler { return $response; } - #[Route('GET', '/exrate.php')] + #[HttpGet('/exrate.php')] public function getPHP($response, $request) { $from = strtoupper((string)$request->getParam('from')); $to = strtoupper((string)$request->getParam('to')); diff --git a/src/RoutingContext.php b/src/RoutingContext.php index 415e631..15885bc 100644 --- a/src/RoutingContext.php +++ b/src/RoutingContext.php @@ -1,16 +1,14 @@ router = new HttpFx; + $this->router = new HttpRouter(errorHandler: new RoutingErrorHandler); $this->router->use('/', fn($resp) => $resp->setPoweredBy('Satori')); } @@ -18,14 +16,6 @@ class RoutingContext { return $this->router; } - public function registerDefaultErrorPages(): void { - $this->router->addErrorHandler(401, fn($resp) => $resp->setContent(file_get_contents(SAT_DIR_PUBLIC . '/404.html'))); - $this->router->addErrorHandler(403, fn($resp) => $resp->setContent(file_get_contents(SAT_DIR_PUBLIC . '/404.html'))); - $this->router->addErrorHandler(404, fn($resp) => $resp->setContent(file_get_contents(SAT_DIR_PUBLIC . '/404.html'))); - $this->router->addErrorHandler(500, fn($resp) => $resp->setContent(file_get_contents(SAT_DIR_PUBLIC . '/404.html'))); - $this->router->addErrorHandler(503, fn($resp) => $resp->setContent(file_get_contents(SAT_DIR_PUBLIC . '/404.html'))); - } - public function register(IRouteHandler $handler): void { $this->router->register($handler); } diff --git a/src/RoutingErrorHandler.php b/src/RoutingErrorHandler.php new file mode 100644 index 0000000..fa6959b --- /dev/null +++ b/src/RoutingErrorHandler.php @@ -0,0 +1,18 @@ +setTypeHTML(); + $response->setContent(file_get_contents(SAT_DIR_PUBLIC . '/404.html')); + return; + } + + parent::handle($response, $request, $code, $message); + } +} diff --git a/src/SatoriContext.php b/src/SatoriContext.php index 602c853..cd646ca 100644 --- a/src/SatoriContext.php +++ b/src/SatoriContext.php @@ -54,7 +54,6 @@ final class SatoriContext { public function createRouting(): RoutingContext { $routingCtx = new RoutingContext; - $routingCtx->registerDefaultErrorPages(); $routingCtx->register(new ExRate\ExRateRoutes($this->createExRates())); $routingCtx->register(new Dictionary\DictionaryRoutes($this->createDictionary())); diff --git a/src/Splatoon/SplatoonRoutes.php b/src/Splatoon/SplatoonRoutes.php index c043e40..44bd8c9 100644 --- a/src/Splatoon/SplatoonRoutes.php +++ b/src/Splatoon/SplatoonRoutes.php @@ -3,8 +3,7 @@ namespace Satori\Splatoon; use stdClass; use Index\XArray; -use Index\Routing\Route; -use Index\Routing\RouteHandler; +use Index\Http\Routing\{HttpGet,RouteHandler}; class SplatoonRoutes extends RouteHandler { public function __construct( @@ -28,7 +27,7 @@ class SplatoonRoutes extends RouteHandler { ]; } - #[Route('GET', '/splatoon.php')] + #[HttpGet('/splatoon.php')] public function getPHP($response, $request) { $gameInfo = $this->context->getGameByName((string)$request->getParam('g')); if($gameInfo === null) diff --git a/src/Translation/TranslateRoutes.php b/src/Translation/TranslateRoutes.php index 2c48167..0faaa0a 100644 --- a/src/Translation/TranslateRoutes.php +++ b/src/Translation/TranslateRoutes.php @@ -2,15 +2,14 @@ namespace Satori\Translation; use DOMDocument; -use Index\Routing\Route; -use Index\Routing\RouteHandler; +use Index\Http\Routing\{HttpGet,RouteHandler}; class TranslateRoutes extends RouteHandler { public function __construct( private TranslateContext $context ) {} - #[Route('GET', '/translate.php')] + #[HttpGet('/translate.php')] public function getPHP($response, $request) { $format = (string)($request->getParam('fmt') ?? 'json'); if($format !== 'json' && $format !== 'xml')