Skip to content

Commit 33fc446

Browse files
authored
Merge branch '4.x' into dependabot/composer/phpstan/phpstan-tw-1.11
2 parents d2e7707 + 45ffce3 commit 33fc446

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+165
-12
lines changed

Slim/App.php

+10
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131

3232
use function strtoupper;
3333

34+
/**
35+
* @api
36+
* @template TContainerInterface of (ContainerInterface|null)
37+
* @template-extends RouteCollectorProxy<TContainerInterface>
38+
*/
3439
class App extends RouteCollectorProxy implements RequestHandlerInterface
3540
{
3641
/**
@@ -44,6 +49,9 @@ class App extends RouteCollectorProxy implements RequestHandlerInterface
4449

4550
protected MiddlewareDispatcherInterface $middlewareDispatcher;
4651

52+
/**
53+
* @param TContainerInterface $container
54+
*/
4755
public function __construct(
4856
ResponseFactoryInterface $responseFactory,
4957
?ContainerInterface $container = null,
@@ -89,6 +97,7 @@ public function getMiddlewareDispatcher(): MiddlewareDispatcherInterface
8997

9098
/**
9199
* @param MiddlewareInterface|string|callable $middleware
100+
* @return App<TContainerInterface>
92101
*/
93102
public function add($middleware): self
94103
{
@@ -98,6 +107,7 @@ public function add($middleware): self
98107

99108
/**
100109
* @param MiddlewareInterface $middleware
110+
* @return App<TContainerInterface>
101111
*/
102112
public function addMiddleware(MiddlewareInterface $middleware): self
103113
{

Slim/CallableResolver.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,19 @@
2626
use function preg_match;
2727
use function sprintf;
2828

29+
/**
30+
* @template TContainerInterface of (ContainerInterface|null)
31+
*/
2932
final class CallableResolver implements AdvancedCallableResolverInterface
3033
{
3134
public static string $callablePattern = '!^([^\:]+)\:([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)$!';
3235

36+
/** @var TContainerInterface $container */
3337
private ?ContainerInterface $container;
3438

39+
/**
40+
* @param TContainerInterface $container
41+
*/
3542
public function __construct(?ContainerInterface $container = null)
3643
{
3744
$this->container = $container;
@@ -120,11 +127,10 @@ private function isMiddleware($toResolve): bool
120127
*/
121128
private function resolveSlimNotation(string $toResolve): array
122129
{
130+
/** @psalm-suppress ArgumentTypeCoercion */
123131
preg_match(CallableResolver::$callablePattern, $toResolve, $matches);
124132
[$class, $method] = $matches ? [$matches[1], $matches[2]] : [$toResolve, null];
125133

126-
/** @var string $class */
127-
/** @var string|null $method */
128134
if ($this->container && $this->container->has($class)) {
129135
$instance = $this->container->get($class);
130136
if (!is_object($instance)) {

Slim/Error/Renderers/HtmlErrorRenderer.php

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ private function renderExceptionFragment(Throwable $exception): string
3939
{
4040
$html = sprintf('<div><strong>Type:</strong> %s</div>', get_class($exception));
4141

42-
/** @var int|string $code */
4342
$code = $exception->getCode();
4443
$html .= sprintf('<div><strong>Code:</strong> %s</div>', $code);
4544

Slim/Error/Renderers/JsonErrorRenderer.php

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public function __invoke(Throwable $exception, bool $displayErrorDetails): strin
4343
*/
4444
private function formatExceptionFragment(Throwable $exception): array
4545
{
46-
/** @var int|string $code */
4746
$code = $exception->getCode();
4847
return [
4948
'type' => get_class($exception),

Slim/Error/Renderers/PlainTextErrorRenderer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private function formatExceptionFragment(Throwable $exception): string
4343
$text = sprintf("Type: %s\n", get_class($exception));
4444

4545
$code = $exception->getCode();
46-
/** @var int|string $code */
46+
4747
$text .= sprintf("Code: %s\n", $code);
4848

4949
$text .= sprintf("Message: %s\n", $exception->getMessage());

Slim/Exception/HttpBadRequestException.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Slim\Exception;
1212

13+
/** @api */
1314
class HttpBadRequestException extends HttpSpecializedException
1415
{
1516
/**

Slim/Exception/HttpException.php

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Throwable;
1616

1717
/**
18+
* @api
1819
* @method int getCode()
1920
*/
2021
class HttpException extends RuntimeException

Slim/Exception/HttpForbiddenException.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Slim\Exception;
1212

13+
/** @api */
1314
class HttpForbiddenException extends HttpSpecializedException
1415
{
1516
/**

Slim/Exception/HttpGoneException.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Slim\Exception;
1212

13+
/** @api */
1314
class HttpGoneException extends HttpSpecializedException
1415
{
1516
/**

Slim/Exception/HttpInternalServerErrorException.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Slim\Exception;
1212

13+
/** @api */
1314
class HttpInternalServerErrorException extends HttpSpecializedException
1415
{
1516
/**

Slim/Exception/HttpNotImplementedException.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Slim\Exception;
1212

13+
/** @api */
1314
class HttpNotImplementedException extends HttpSpecializedException
1415
{
1516
/**

Slim/Exception/HttpTooManyRequestsException.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Slim\Exception;
1212

13+
/** @api */
1314
class HttpTooManyRequestsException extends HttpSpecializedException
1415
{
1516
/**

Slim/Exception/HttpUnauthorizedException.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Slim\Exception;
1212

13+
/** @api */
1314
class HttpUnauthorizedException extends HttpSpecializedException
1415
{
1516
/**

Slim/Factory/AppFactory.php

+11
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Slim\Interfaces\RouteCollectorInterface;
2525
use Slim\Interfaces\RouteResolverInterface;
2626

27+
/** @api */
2728
class AppFactory
2829
{
2930
protected static ?Psr17FactoryProviderInterface $psr17FactoryProvider = null;
@@ -44,6 +45,11 @@ class AppFactory
4445

4546
protected static bool $slimHttpDecoratorsAutomaticDetectionEnabled = true;
4647

48+
/**
49+
* @template TContainerInterface of (ContainerInterface|null)
50+
* @param TContainerInterface $container
51+
* @return (TContainerInterface is ContainerInterface ? App<TContainerInterface> : App<ContainerInterface|null>)
52+
*/
4753
public static function create(
4854
?ResponseFactoryInterface $responseFactory = null,
4955
?ContainerInterface $container = null,
@@ -63,6 +69,11 @@ public static function create(
6369
);
6470
}
6571

72+
/**
73+
* @template TContainerInterface of (ContainerInterface)
74+
* @param TContainerInterface $container
75+
* @return App<TContainerInterface>
76+
*/
6677
public static function createFromContainer(ContainerInterface $container): App
6778
{
6879
$responseFactory = $container->has(ResponseFactoryInterface::class)

Slim/Factory/ServerRequestCreatorFactory.php

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Slim\Interfaces\Psr17FactoryProviderInterface;
1818
use Slim\Interfaces\ServerRequestCreatorInterface;
1919

20+
/** @api */
2021
class ServerRequestCreatorFactory
2122
{
2223
protected static ?Psr17FactoryProviderInterface $psr17FactoryProvider = null;

Slim/Handlers/ErrorHandler.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
*
4444
* It outputs the error message and diagnostic information in one of the following formats:
4545
* JSON, XML, Plain Text or HTML based on the Accept header.
46+
* @api
4647
*/
4748
class ErrorHandler implements ErrorHandlerInterface
4849
{
@@ -259,7 +260,7 @@ protected function writeToErrorLog(): void
259260
{
260261
$renderer = $this->callableResolver->resolve($this->logErrorRenderer);
261262
$error = $renderer($this->exception, $this->logErrorDetails);
262-
if (!$this->displayErrorDetails) {
263+
if ($this->logErrorRenderer === PlainTextErrorRenderer::class && !$this->displayErrorDetails) {
263264
$error .= "\nTips: To display error details in HTTP response ";
264265
$error .= 'set "displayErrorDetails" to true in the ErrorHandler constructor.';
265266
}

Slim/Handlers/Strategies/RequestResponseArgs.php

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
/**
2020
* Route callback strategy with route parameters as individual arguments.
21+
* @api
2122
*/
2223
class RequestResponseArgs implements InvocationStrategyInterface
2324
{

Slim/Handlers/Strategies/RequestResponseNamedArgs.php

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
/**
1919
* Route callback strategy with route parameters as individual arguments.
20+
* @api
2021
*/
2122
class RequestResponseNamedArgs implements InvocationStrategyInterface
2223
{

Slim/Interfaces/MiddlewareDispatcherInterface.php

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Psr\Http\Server\MiddlewareInterface;
1414
use Psr\Http\Server\RequestHandlerInterface;
1515

16+
/** @api */
1617
interface MiddlewareDispatcherInterface extends RequestHandlerInterface
1718
{
1819
/**

Slim/Interfaces/Psr17FactoryProviderInterface.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace Slim\Interfaces;
1212

13+
/** @api */
1314
interface Psr17FactoryProviderInterface
1415
{
1516
/**

Slim/Interfaces/RouteCollectorInterface.php

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use InvalidArgumentException;
1414
use RuntimeException;
1515

16+
/** @api */
1617
interface RouteCollectorInterface
1718
{
1819
/**

Slim/Interfaces/RouteCollectorProxyInterface.php

+8
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@
1414
use Psr\Http\Message\ResponseFactoryInterface;
1515
use Psr\Http\Message\UriInterface;
1616

17+
/**
18+
* @api
19+
* @template TContainerInterface of (ContainerInterface|null)
20+
*/
1721
interface RouteCollectorProxyInterface
1822
{
1923
public function getResponseFactory(): ResponseFactoryInterface;
2024

2125
public function getCallableResolver(): CallableResolverInterface;
2226

27+
/**
28+
* @return TContainerInterface
29+
*/
2330
public function getContainer(): ?ContainerInterface;
2431

2532
public function getRouteCollector(): RouteCollectorInterface;
@@ -31,6 +38,7 @@ public function getBasePath(): string;
3138

3239
/**
3340
* Set the RouteCollectorProxy's base path
41+
* @return RouteCollectorProxyInterface<TContainerInterface>
3442
*/
3543
public function setBasePath(string $basePath): RouteCollectorProxyInterface;
3644

Slim/Interfaces/RouteGroupInterface.php

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Psr\Http\Server\MiddlewareInterface;
1414
use Slim\MiddlewareDispatcher;
1515

16+
/** @api */
1617
interface RouteGroupInterface
1718
{
1819
public function collectRoutes(): RouteGroupInterface;
@@ -31,6 +32,7 @@ public function addMiddleware(MiddlewareInterface $middleware): RouteGroupInterf
3132

3233
/**
3334
* Append the group's middleware to the MiddlewareDispatcher
35+
* @param MiddlewareDispatcher<\Psr\Container\ContainerInterface|null> $dispatcher
3436
*/
3537
public function appendMiddlewareToDispatcher(MiddlewareDispatcher $dispatcher): RouteGroupInterface;
3638

Slim/Interfaces/RouteInterface.php

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Psr\Http\Message\ServerRequestInterface;
1515
use Psr\Http\Server\MiddlewareInterface;
1616

17+
/** @api */
1718
interface RouteInterface
1819
{
1920
/**

Slim/Interfaces/RouteParserInterface.php

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Psr\Http\Message\UriInterface;
1515
use RuntimeException;
1616

17+
/** @api */
1718
interface RouteParserInterface
1819
{
1920
/**

Slim/Middleware/BodyParsingMiddleware.php

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
use const LIBXML_VERSION;
3535

36+
/** @api */
3637
class BodyParsingMiddleware implements MiddlewareInterface
3738
{
3839
/**

Slim/Middleware/ContentLengthMiddleware.php

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Psr\Http\Server\MiddlewareInterface;
1616
use Psr\Http\Server\RequestHandlerInterface;
1717

18+
/** @api */
1819
class ContentLengthMiddleware implements MiddlewareInterface
1920
{
2021
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface

Slim/Middleware/ErrorMiddleware.php

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use function get_class;
2626
use function is_subclass_of;
2727

28+
/** @api */
2829
class ErrorMiddleware implements MiddlewareInterface
2930
{
3031
protected CallableResolverInterface $callableResolver;

Slim/Middleware/MethodOverrideMiddleware.php

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use function is_array;
1919
use function strtoupper;
2020

21+
/** @api */
2122
class MethodOverrideMiddleware implements MiddlewareInterface
2223
{
2324
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface

Slim/Middleware/OutputBufferingMiddleware.php

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use function ob_get_clean;
2424
use function ob_start;
2525

26+
/** @api */
2627
class OutputBufferingMiddleware implements MiddlewareInterface
2728
{
2829
public const APPEND = 'append';

0 commit comments

Comments
 (0)