Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@
<disableExtensions>
<extension name="random" />
</disableExtensions>
<issueHandlers>
<UndefinedAttributeClass errorLevel="suppress" />
</issueHandlers>
</psalm>
15 changes: 15 additions & 0 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ private function __construct(
*
* @return self<ServerRequest, Response>
*/
#[\NoDiscard]
public static function http(OperatingSystem $os, Environment $env): self
{
return new self(Application\Http::of($os, $env));
Expand All @@ -56,6 +57,7 @@ public static function http(OperatingSystem $os, Environment $env): self
*
* @return self<CliEnv, Attempt<CliEnv>>
*/
#[\NoDiscard]
public static function cli(OperatingSystem $os, Environment $env): self
{
return new self(Application\Cli::of($os, $env));
Expand All @@ -67,6 +69,7 @@ public static function cli(OperatingSystem $os, Environment $env): self
*
* @return self<CliEnv, Attempt<CliEnv>>
*/
#[\NoDiscard]
public static function asyncHttp(OperatingSystem $os): self
{
return new self(Application\Async\Http::of($os));
Expand All @@ -79,6 +82,7 @@ public static function asyncHttp(OperatingSystem $os): self
*
* @return self<I, O>
*/
#[\NoDiscard]
public function mapEnvironment(callable $map): self
{
return new self($this->app->mapEnvironment($map));
Expand All @@ -91,6 +95,7 @@ public function mapEnvironment(callable $map): self
*
* @return self<I, O>
*/
#[\NoDiscard]
public function mapOperatingSystem(callable $map): self
{
return new self($this->app->mapOperatingSystem($map));
Expand All @@ -101,6 +106,7 @@ public function mapOperatingSystem(callable $map): self
*
* @return self<I, O>
*/
#[\NoDiscard]
public function map(Middleware $map): self
{
/** @psalm-suppress ImpureMethodCall Mutation free to force the user to use the returned object */
Expand All @@ -114,6 +120,7 @@ public function map(Middleware $map): self
*
* @return self<I, O>
*/
#[\NoDiscard]
public function service(Service $name, callable $definition): self
{
return new self($this->app->service($name, $definition));
Expand All @@ -126,6 +133,7 @@ public function service(Service $name, callable $definition): self
*
* @return self<I, O>
*/
#[\NoDiscard]
public function command(callable $command): self
{
return new self($this->app->command($command));
Expand All @@ -138,6 +146,7 @@ public function command(callable $command): self
*
* @return self<I, O>
*/
#[\NoDiscard]
public function mapCommand(callable $map): self
{
return new self($this->app->mapCommand($map));
Expand All @@ -150,6 +159,7 @@ public function mapCommand(callable $map): self
*
* @return self<I, O>
*/
#[\NoDiscard]
public function route(Http\Route\Reference|callable $handle): self
{
if ($handle instanceof Http\Route\Reference) {
Expand All @@ -166,6 +176,7 @@ public function route(Http\Route\Reference|callable $handle): self
*
* @return self<I, O>
*/
#[\NoDiscard]
public function routes(string $routes): self
{
$self = $this;
Expand All @@ -184,6 +195,7 @@ public function routes(string $routes): self
*
* @return self<I, O>
*/
#[\NoDiscard]
public function mapRoute(callable $map): self
{
return new self($this->app->mapRoute($map));
Expand All @@ -196,6 +208,7 @@ public function mapRoute(callable $map): self
*
* @return self<I, O>
*/
#[\NoDiscard]
public function routeNotFound(callable $handle): self
{
return new self($this->app->routeNotFound($handle));
Expand All @@ -208,6 +221,7 @@ public function routeNotFound(callable $handle): self
*
* @return self<I, O>
*/
#[\NoDiscard]
public function recoverRouteError(callable $recover): self
{
return new self($this->app->recoverRouteError($recover));
Expand All @@ -218,6 +232,7 @@ public function recoverRouteError(callable $recover): self
*
* @return O
*/
#[\NoDiscard]
public function run(CliEnv|ServerRequest $input): Attempt|Response
{
return $this->app->run($input);
Expand Down
1 change: 1 addition & 0 deletions src/Cli/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function __invoke(Console $console): Attempt
*
* @param class-string<CommandInterface> $class
*/
#[\NoDiscard]
public static function of(
string $class,
Service ...$dependencies,
Expand Down
7 changes: 7 additions & 0 deletions src/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ private function __construct(private Map $variables)
*
* @param Map<string, string> $variables
*/
#[\NoDiscard]
public static function of(Map $variables): self
{
return new self($variables);
Expand All @@ -37,6 +38,7 @@ public static function of(Map $variables): self
*
* @param list<array{string, string}> $variables
*/
#[\NoDiscard]
public static function test(array $variables): self
{
return self::of(Map::of(...$variables));
Expand All @@ -45,6 +47,7 @@ public static function test(array $variables): self
/**
* @psalm-pure
*/
#[\NoDiscard]
public static function http(HttpEnvironment $env): self
{
return $env->reduce(
Expand All @@ -53,6 +56,7 @@ public static function http(HttpEnvironment $env): self
);
}

#[\NoDiscard]
public function with(string $key, string $value): self
{
return new self(($this->variables)($key, $value));
Expand All @@ -63,6 +67,7 @@ public function with(string $key, string $value): self
*
* @throws LogicException If the variable doesn't exist
*/
#[\NoDiscard]
public function get(string $key): string
{
return $this->maybe($key)->match(
Expand All @@ -74,6 +79,7 @@ public function get(string $key): string
/**
* @return Maybe<string>
*/
#[\NoDiscard]
public function maybe(string $key): Maybe
{
return $this->variables->get($key);
Expand All @@ -82,6 +88,7 @@ public function maybe(string $key): Maybe
/**
* @return Map<string, string>
*/
#[\NoDiscard]
public function all(): Map
{
return $this->variables;
Expand Down
11 changes: 11 additions & 0 deletions src/Http/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ private function __construct()
*
* @return callable(Pipe, Container): Component<mixed, Response>
*/
#[\NoDiscard]
public static function get(
string|Template|Alias $endpoint,
Service $handler,
Expand All @@ -52,6 +53,7 @@ public static function get(
*
* @return callable(Pipe, Container): Component<mixed, Response>
*/
#[\NoDiscard]
public static function post(
string|Template|Alias $endpoint,
Service $handler,
Expand All @@ -73,6 +75,7 @@ public static function post(
*
* @return callable(Pipe, Container): Component<mixed, Response>
*/
#[\NoDiscard]
public static function put(
string|Template|Alias $endpoint,
Service $handler,
Expand All @@ -94,6 +97,7 @@ public static function put(
*
* @return callable(Pipe, Container): Component<mixed, Response>
*/
#[\NoDiscard]
public static function patch(
string|Template|Alias $endpoint,
Service $handler,
Expand All @@ -115,6 +119,7 @@ public static function patch(
*
* @return callable(Pipe, Container): Component<mixed, Response>
*/
#[\NoDiscard]
public static function delete(
string|Template|Alias $endpoint,
Service $handler,
Expand All @@ -136,6 +141,7 @@ public static function delete(
*
* @return callable(Pipe, Container): Component<mixed, Response>
*/
#[\NoDiscard]
public static function options(
string|Template|Alias $endpoint,
Service $handler,
Expand All @@ -157,6 +163,7 @@ public static function options(
*
* @return callable(Pipe, Container): Component<mixed, Response>
*/
#[\NoDiscard]
public static function trace(
string|Template|Alias $endpoint,
Service $handler,
Expand All @@ -178,6 +185,7 @@ public static function trace(
*
* @return callable(Pipe, Container): Component<mixed, Response>
*/
#[\NoDiscard]
public static function connect(
string|Template|Alias $endpoint,
Service $handler,
Expand All @@ -199,6 +207,7 @@ public static function connect(
*
* @return callable(Pipe, Container): Component<mixed, Response>
*/
#[\NoDiscard]
public static function head(
string|Template|Alias $endpoint,
Service $handler,
Expand All @@ -220,6 +229,7 @@ public static function head(
*
* @return callable(Pipe, Container): Component<mixed, Response>
*/
#[\NoDiscard]
public static function link(
string|Template|Alias $endpoint,
Service $handler,
Expand All @@ -241,6 +251,7 @@ public static function link(
*
* @return callable(Pipe, Container): Component<mixed, Response>
*/
#[\NoDiscard]
public static function unlink(
string|Template|Alias $endpoint,
Service $handler,
Expand Down
1 change: 1 addition & 0 deletions src/Http/Route/Reference.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ interface Reference extends \UnitEnum
/**
* @return callable(Pipe, Container): Component<SideEffect, Response>
*/
#[\NoDiscard]
public function route(): callable;
}
1 change: 1 addition & 0 deletions src/Middleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ interface Middleware
*
* @return Application<I, O>
*/
#[\NoDiscard]
public function __invoke(Application $app): Application;
}