diff --git a/composer.json b/composer.json index dbb1417..b996cc2 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "support": { "issues": "https://github.com/opencultureconsulting/oai-pmh2/issues", "source": "https://github.com/opencultureconsulting/oai-pmh2", - "docs": "https://github.com/opencultureconsulting/oai-pmh2/blob/main/README.md" + "docs": "https://opencultureconsulting.github.io/oai-pmh2/" }, "require": { "php": "^8.1", @@ -61,8 +61,8 @@ }, "scripts": { "pre-install-cmd": [ - "@php -r \"!is_dir('./data') && mkdir('./data', 0775);\"", - "@php -r \"!file_exists('./config/config.yml') && copy('./config/config.dist.yml', './config/config.yml');\"" + "@php -r \"if (!is_dir('./data')) { mkdir('./data', 0775); }\"", + "@php -r \"if (!file_exists('./config/config.yml')) { copy('./config/config.dist.yml', './config/config.yml'); }\"" ], "post-install-cmd": [ "@doctrine:clear-cache --quiet", diff --git a/public/index.php b/public/index.php index ca81279..eec4d35 100644 --- a/public/index.php +++ b/public/index.php @@ -24,5 +24,4 @@ namespace OCC\OaiPmh2; require __DIR__ . '/../vendor/autoload.php'; -$app = new App(); -$app->run(); +(new App())->run(); diff --git a/src/Middleware.php b/src/Middleware.php index c62f870..10e8c56 100644 --- a/src/Middleware.php +++ b/src/Middleware.php @@ -77,4 +77,11 @@ abstract class Middleware extends AbstractMiddleware } return $response; } + + final public function __construct() + { + // Make constructor final to avoid issues in dispatcher. + // @see https://psalm.dev/229 + } + } diff --git a/src/Middleware/Dispatcher.php b/src/Middleware/Dispatcher.php index 04f39d9..1259088 100644 --- a/src/Middleware/Dispatcher.php +++ b/src/Middleware/Dispatcher.php @@ -88,9 +88,10 @@ class Dispatcher extends AbstractMiddleware if (!ErrorHandler::getInstance()->hasErrors()) { /** @var string */ $verb = $request->getAttribute('verb'); - /** @var Middleware $middleware */ $middleware = __NAMESPACE__ . '\\' . $verb; - $this->requestHandler->queue->enqueue(new $middleware()); + if (is_a($middleware, Middleware::class, true)) { + $this->requestHandler->queue->enqueue(new $middleware()); + } } $this->requestHandler->queue->enqueue(ErrorHandler::getInstance()); return $request;