diff --git a/composer.json b/composer.json index e4981af..f35e4e8 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ } }, "require-dev": { - "vimeo/psalm": "~5.6", + "innmind/static-analysis": "^1.2.1", "innmind/black-box": "~6.5", "innmind/coding-standard": "~2.0", "innmind/async-http-server": "~2.0|~3.0" diff --git a/src/Application/Async/Http.php b/src/Application/Async/Http.php index 135e0b7..4f9617d 100644 --- a/src/Application/Async/Http.php +++ b/src/Application/Async/Http.php @@ -98,6 +98,7 @@ public static function of(OperatingSystem $os): self /** * @psalm-mutation-free */ + #[\Override] public function mapEnvironment(callable $map): self { $previous = $this->map; @@ -120,6 +121,7 @@ static function(OperatingSystem $os, Environment $env) use ($previous, $map): ar /** * @psalm-mutation-free */ + #[\Override] public function mapOperatingSystem(callable $map): self { $previous = $this->map; @@ -142,6 +144,7 @@ static function(OperatingSystem $os, Environment $env) use ($previous, $map): ar /** * @psalm-mutation-free */ + #[\Override] public function service(string|Service $name, callable $definition): self { $container = $this->container; @@ -162,6 +165,7 @@ public function service(string|Service $name, callable $definition): self /** * @psalm-mutation-free */ + #[\Override] public function command(callable $command): self { return $this; @@ -170,6 +174,7 @@ public function command(callable $command): self /** * @psalm-mutation-free */ + #[\Override] public function mapCommand(callable $map): self { return $this; @@ -178,6 +183,7 @@ public function mapCommand(callable $map): self /** * @psalm-mutation-free */ + #[\Override] public function route(string $pattern, callable $handle): self { return $this->appendRoutes( @@ -196,6 +202,7 @@ public function route(string $pattern, callable $handle): self /** * @psalm-mutation-free */ + #[\Override] public function appendRoutes(callable $append): self { return new self( @@ -211,6 +218,7 @@ public function appendRoutes(callable $append): self /** * @psalm-mutation-free */ + #[\Override] public function mapRequestHandler(callable $map): self { $previous = $this->mapRequestHandler; @@ -238,6 +246,7 @@ public function mapRequestHandler(callable $map): self /** * @psalm-mutation-free */ + #[\Override] public function notFoundRequestHandler(callable $handle): self { return new self( @@ -250,6 +259,7 @@ public function notFoundRequestHandler(callable $handle): self ); } + #[\Override] public function run($input) { $map = $this->map; diff --git a/src/Application/Cli.php b/src/Application/Cli.php index 31c5254..8734eb3 100644 --- a/src/Application/Cli.php +++ b/src/Application/Cli.php @@ -77,6 +77,7 @@ public static function of(OperatingSystem $os, Environment $env): self /** * @psalm-mutation-free */ + #[\Override] public function mapEnvironment(callable $map): self { /** @psalm-suppress ImpureFunctionCall Mutation free to force the user to use the returned object */ @@ -92,6 +93,7 @@ public function mapEnvironment(callable $map): self /** * @psalm-mutation-free */ + #[\Override] public function mapOperatingSystem(callable $map): self { /** @psalm-suppress ImpureFunctionCall Mutation free to force the user to use the returned object */ @@ -107,6 +109,7 @@ public function mapOperatingSystem(callable $map): self /** * @psalm-mutation-free */ + #[\Override] public function service(string|Service $name, callable $definition): self { $container = $this->container; @@ -126,6 +129,7 @@ public function service(string|Service $name, callable $definition): self /** * @psalm-mutation-free */ + #[\Override] public function command(callable $command): self { /** @psalm-suppress ImpureMethodCall Mutation free to force the user to use the returned object */ @@ -144,6 +148,7 @@ public function command(callable $command): self /** * @psalm-mutation-free */ + #[\Override] public function mapCommand(callable $map): self { $previous = $this->mapCommand; @@ -170,6 +175,7 @@ public function mapCommand(callable $map): self /** * @psalm-mutation-free */ + #[\Override] public function route(string $pattern, callable $handle): self { return $this; @@ -178,6 +184,7 @@ public function route(string $pattern, callable $handle): self /** * @psalm-mutation-free */ + #[\Override] public function appendRoutes(callable $append): self { return $this; @@ -186,6 +193,7 @@ public function appendRoutes(callable $append): self /** * @psalm-mutation-free */ + #[\Override] public function mapRequestHandler(callable $map): self { return $this; @@ -194,11 +202,13 @@ public function mapRequestHandler(callable $map): self /** * @psalm-mutation-free */ + #[\Override] public function notFoundRequestHandler(callable $handle): self { return $this; } + #[\Override] public function run($input) { $container = ($this->container)($this->os, $this->env)->build(); diff --git a/src/Application/Http.php b/src/Application/Http.php index 8596160..cf58942 100644 --- a/src/Application/Http.php +++ b/src/Application/Http.php @@ -87,6 +87,7 @@ public static function of(OperatingSystem $os, Environment $env): self /** * @psalm-mutation-free */ + #[\Override] public function mapEnvironment(callable $map): self { /** @psalm-suppress ImpureFunctionCall Mutation free to force the user to use the returned object */ @@ -103,6 +104,7 @@ public function mapEnvironment(callable $map): self /** * @psalm-mutation-free */ + #[\Override] public function mapOperatingSystem(callable $map): self { /** @psalm-suppress ImpureFunctionCall Mutation free to force the user to use the returned object */ @@ -119,6 +121,7 @@ public function mapOperatingSystem(callable $map): self /** * @psalm-mutation-free */ + #[\Override] public function service(string|Service $name, callable $definition): self { $container = $this->container; @@ -139,6 +142,7 @@ public function service(string|Service $name, callable $definition): self /** * @psalm-mutation-free */ + #[\Override] public function command(callable $command): self { return $this; @@ -147,6 +151,7 @@ public function command(callable $command): self /** * @psalm-mutation-free */ + #[\Override] public function mapCommand(callable $map): self { return $this; @@ -155,6 +160,7 @@ public function mapCommand(callable $map): self /** * @psalm-mutation-free */ + #[\Override] public function route(string $pattern, callable $handle): self { return $this->appendRoutes( @@ -173,6 +179,7 @@ public function route(string $pattern, callable $handle): self /** * @psalm-mutation-free */ + #[\Override] public function appendRoutes(callable $append): self { return new self( @@ -188,6 +195,7 @@ public function appendRoutes(callable $append): self /** * @psalm-mutation-free */ + #[\Override] public function mapRequestHandler(callable $map): self { $previous = $this->mapRequestHandler; @@ -215,6 +223,7 @@ public function mapRequestHandler(callable $map): self /** * @psalm-mutation-free */ + #[\Override] public function notFoundRequestHandler(callable $handle): self { return new self( @@ -227,6 +236,7 @@ public function notFoundRequestHandler(callable $handle): self ); } + #[\Override] public function run($input) { $container = ($this->container)($this->os, $this->env)->build(); diff --git a/src/Cli/Command/Defer.php b/src/Cli/Command/Defer.php index ff32142..de3e4b8 100644 --- a/src/Cli/Command/Defer.php +++ b/src/Cli/Command/Defer.php @@ -36,6 +36,7 @@ public function __construct( $this->map = $map; } + #[\Override] public function __invoke(Console $console): Console { // we map the command when running it instead of when loading it to @@ -50,6 +51,7 @@ public function __invoke(Console $console): Console /** * @psalm-mutation-free */ + #[\Override] public function usage(): string { /** @psalm-suppress ImpureMethodCall */ diff --git a/src/Exception/LogicException.php b/src/Exception/LogicException.php index 83ed6bb..d023836 100644 --- a/src/Exception/LogicException.php +++ b/src/Exception/LogicException.php @@ -3,6 +3,6 @@ namespace Innmind\Framework\Exception; -class LogicException extends \LogicException implements Exception +final class LogicException extends \LogicException implements Exception { } diff --git a/src/Http/Router.php b/src/Http/Router.php index 55904ea..f3dab7b 100644 --- a/src/Http/Router.php +++ b/src/Http/Router.php @@ -38,6 +38,7 @@ public function __construct(Sequence $routes, Maybe $notFound) $this->notFound = $notFound; } + #[\Override] public function __invoke(ServerRequest $request): Response { $match = new RequestMatcher($this->routes); diff --git a/src/Main/Async/Http.php b/src/Main/Async/Http.php index 328651e..2784211 100644 --- a/src/Main/Async/Http.php +++ b/src/Main/Async/Http.php @@ -15,6 +15,7 @@ */ abstract class Http extends Main { + #[\Override] protected function main(Environment $env, OperatingSystem $os): Environment { /** diff --git a/src/Main/Cli.php b/src/Main/Cli.php index 9b2fe02..abf678c 100644 --- a/src/Main/Cli.php +++ b/src/Main/Cli.php @@ -15,6 +15,7 @@ abstract class Cli extends Main { + #[\Override] protected function main(Environment $env, OperatingSystem $os): Environment { /** diff --git a/src/Main/Http.php b/src/Main/Http.php index 8a3dbac..c1c5e98 100644 --- a/src/Main/Http.php +++ b/src/Main/Http.php @@ -19,11 +19,13 @@ abstract class Http extends Main { private Application $app; + #[\Override] protected function preload(OperatingSystem $os, Environment $env): void { $this->app = static::configure(Application::http($os, AppEnv::http($env))); } + #[\Override] protected function main(ServerRequest $request): Response { /** diff --git a/src/Middleware/LoadDotEnv.php b/src/Middleware/LoadDotEnv.php index 15e8389..ce9b992 100644 --- a/src/Middleware/LoadDotEnv.php +++ b/src/Middleware/LoadDotEnv.php @@ -28,6 +28,7 @@ private function __construct(Path $folder) $this->folder = $folder; } + #[\Override] public function __invoke(Application $app): Application { $folder = $this->folder; diff --git a/src/Middleware/Optional.php b/src/Middleware/Optional.php index da9353d..8e42f10 100644 --- a/src/Middleware/Optional.php +++ b/src/Middleware/Optional.php @@ -25,6 +25,7 @@ private function __construct(string $middleware, callable $factory) $this->factory = $factory; } + #[\Override] public function __invoke(Application $app): Application { if (!\class_exists($this->middleware)) {